@matterbridge/frontend 3.4.18-dev-20260620-9802e5b → 3.4.18-dev-20260620-2b9580a
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/build/assets/index.js +3 -3
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/build/assets/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import{a as e}from"./rolldown-runtime.js";import{c as t}from"./vendor_emotion.js
|
|
|
19
19
|
::-webkit-scrollbar-track {
|
|
20
20
|
background: ${i};
|
|
21
21
|
}
|
|
22
|
-
`,t.head.appendChild(a)},style:{display:`block`,flex:`1 1 auto`,width:`100%`,height:`100%`,border:`none`,backgroundColor:`var(--div-bg-color)`}})}),(0,Y.jsx)(x,{sx:{flex:`0 0 auto`,justifyContent:`center`},children:(0,Y.jsx)(L,{onClick:()=>E(null),children:`Close`})})]})]}):(0,Y.jsx)(Wt,{})}var Ln=(0,G.memo)(In),Rn=[`matterbridge-`,`matterbridge-plugin-template`,`matterbridge-dyson`,`matterbridge-tuya`,`matterbridge-matter`,`matterbridge-automations`,`matterbridge-securitysystem`,`matterbridge-adapter`],zn=e=>e.replace(`git+`,``).replace(`.git`,``).trim(),Bn=e=>{let t=zn(e);return t.startsWith(`git://`)&&(t=`https://${t.slice(6)}`),t.startsWith(`ssh://git@github.com/`)&&(t=`https://github.com/${t.slice(21)}`),t.startsWith(`git@github.com:`)&&(t=`https://github.com/${t.slice(15).replace(`:`,`/`)}`),t},Vn=e=>{if(typeof e==`string`)return e.trim()||null;if(!e||typeof e!=`object`)return null;let t=e.url;return typeof t==`string`&&t.trim()||null},Hn=()=>{try{let e=window.localStorage.getItem(K.searchPluginsTotal);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t)){if(!e||!r||typeof r!=`object`)continue;let t=r;typeof t.total==`number`&&typeof t.asOf==`string`&&(n[e]={total:t.total,asOf:t.asOf})}return n}catch{return{}}},Un=e=>{try{window.localStorage.setItem(K.searchPluginsTotal,JSON.stringify(e))}catch{}},Wn=()=>{try{let e=window.localStorage.getItem(K.searchPluginsMeta);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t)){if(!e||!r||typeof r!=`object`)continue;let t=r;typeof t.asOf==`string`&&(n[e]={homepage:typeof t.homepage==`string`?t.homepage:null,help:typeof t.help==`string`?t.help:null,changelog:typeof t.changelog==`string`?t.changelog:null,asOf:t.asOf})}return n}catch{return{}}},Gn=e=>{try{window.localStorage.setItem(K.searchPluginsMeta,JSON.stringify(e))}catch{}},Kn=()=>{try{let e=window.localStorage.getItem(K.searchPluginsVersions);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t)){if(!e||!r||typeof r!=`object`)continue;let t=r;typeof t.asOf==`string`&&Array.isArray(t.versions)&&(n[e]={versions:t.versions.filter(e=>typeof e==`string`),asOf:t.asOf})}return n}catch{return{}}},qn=e=>{try{window.localStorage.setItem(K.searchPluginsVersions,JSON.stringify(e))}catch{}},Jn=({open:e,onClose:t,onSelect:n,onVersions:r})=>{let{mobile:i}=(0,G.useContext)(Vt),[a,o]=(0,G.useState)(``),s=(0,G.useRef)(``),c=(0,G.useRef)(!1),l=(0,G.useRef)(null),[u,d]=(0,G.useState)([]),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(!1),[_,y]=(0,G.useState)(!1),[b,S]=(0,G.useState)({done:0,total:0}),[C,w]=(0,G.useState)(null),E=(0,G.useRef)({}),O=()=>{let e=document.activeElement;e&&e instanceof HTMLElement&&e.blur()},k=e=>`${e.getFullYear().toString()}-${(e.getMonth()+1).toString().padStart(2,`0`)}-${e.getDate().toString().padStart(2,`0`)}`,A=(0,G.useCallback)(async(e,t)=>{let n=E.current[e];if(n&&n.asOf===t&&Array.isArray(n.versions)&&n.versions.length>0&&n.versions[0]===`latest`)return q&&console.log(`[SearchPluginsDialog] versions cache hit for ${e} (${n.versions.length.toString()})`),n.versions;n&&n.asOf===t&&n.versions.length>0&&n.versions[0]!==`latest`&&q&&console.log(`[SearchPluginsDialog] versions cache ignored (old format) for ${e} (asOf=${t})`);let r=`https://registry.npmjs.org/${encodeURIComponent(e)}`;q&&console.log(`[SearchPluginsDialog] fetching versions for ${e} from: ${r}`);let i=await fetch(r,{signal:l.current?.signal});if(!i.ok)return q&&console.log(`[SearchPluginsDialog] versions fetch failed for ${e}: ${i.status.toString()} ${i.statusText}`),[];let a=await i.json(),o=Object.keys(a.versions??{}),s=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`});o.sort((e,t)=>s.compare(e,t)).reverse();let c=a[`dist-tags`]??{},u=typeof c?.dev==`string`&&String(c.dev).trim().length>0,d=o.slice(0,20),f=[`latest`];return u&&f.push(`dev`),f.push(...d),q&&console.log(`[SearchPluginsDialog] fetched versions for ${e} (tags: latest${u?`, dev`:``}; latestVersions=${d.length.toString()}; allVersions=${o.length.toString()}):`,f),E.current[e]={versions:f,asOf:t},qn(E.current),f},[]),j=e=>new Intl.NumberFormat().format(e),M=[{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:e=>typeof e==`number`?j(e):``},{label:`Total`,id:`total`,align:`right`,maxWidth:120,render:e=>typeof e==`number`?j(e):``},{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:(e,t,n,r)=>(0,Y.jsxs)(`div`,{style:{margin:`0`,padding:`0`,gap:`4px`,display:`flex`,flexDirection:`row`,justifyContent:`center`},children:[(0,Y.jsx)(H,{title:n.homepage?`Open the plugin homepage`:`No homepage available`,children:(0,Y.jsx)(`span`,{children:(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`var(--main-icon-color)`},disabled:!n.homepage,onClick:e=>{if(e.stopPropagation(),n.homepage)try{let e=new URL(n.homepage);(e.protocol===`http:`||e.protocol===`https:`)&&window.open(e.toString(),`_blank`)}catch{}},size:`small`,children:(0,Y.jsx)(ce,{})})})}),(0,Y.jsx)(H,{title:n.help?`Open the plugin help`:`No help available`,children:(0,Y.jsx)(`span`,{children:(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`var(--main-icon-color)`},disabled:!n.help,onClick:e=>{if(e.stopPropagation(),n.help)try{let e=new URL(n.help);(e.protocol===`http:`||e.protocol===`https:`)&&window.open(e.toString(),`_blank`)}catch{}},size:`small`,children:(0,Y.jsx)(g,{})})})}),(0,Y.jsx)(H,{title:n.changelog?`Open the plugin changelog`:`No changelog available`,children:(0,Y.jsx)(`span`,{children:(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`var(--main-icon-color)`},disabled:!n.changelog,onClick:e=>{if(e.stopPropagation(),n.changelog)try{let e=new URL(n.changelog);(e.protocol===`http:`||e.protocol===`https:`)&&window.open(e.toString(),`_blank`)}catch{}},size:`small`,children:(0,Y.jsx)(v,{})})})})]})}];(0,G.useEffect)(()=>{if(!e){c.current=!1,s.current=``,l.current?.abort(),l.current=null,d([]),p(!1),h(!1),y(!1),S({done:0,total:0}),w(null),o(``);return}if(c.current)return;c.current=!0;let t=new AbortController;return l.current=t,E.current=Kn(),(async()=>{let e=`matterbridge-`,n=e=>new Promise(t=>setTimeout(t,e)),r=e=>{if(!Array.isArray(e.downloads))return null;let t=0,n=!1;for(let r of e.downloads)typeof r?.downloads==`number`&&(t+=r.downloads,n=!0);return n?t:null};try{p(!0),w(null);let i=e=>{let t=String(e??``).trim().toLowerCase();return t?!!(t===`github actions`||t===`github-actions`||t===`github-actions[bot]`||t.includes(`github-actions`)||t.endsWith(`[bot]`)):!1},a=e=>{let t=(e.maintainers??[]).map(e=>(e.username??``).trim()).filter(Boolean),n=(e.publisher?.username??``).trim();return t.find(e=>!i(e))||(n&&!i(n)?n:t[0]??n??``)},o=await fetch(`https://registry.npmjs.org/-/v1/search?text=matterbridge-&size=250`,{signal:t.signal});if(!o.ok)throw Error(`npm registry request failed: ${o.status} ${o.statusText}`);let s=await o.json(),c=`luligu`,l=e=>e.publisher?.username?.toLowerCase()===c||(e.maintainers??[]).some(e=>e.username?.toLowerCase()===c),u=(s.objects??[]).filter(e=>!!e?.package&&typeof e.package.name==`string`).filter(t=>t.package?.name?.startsWith(e)).filter(e=>!Rn.includes(e.package?.name??``)).sort((e,t)=>{let n=l(e.package??{});return n===l(t.package??{})?(e.package?.name??``).localeCompare(t.package?.name??``):n?-1:1}).map(e=>{let t=e.package,n=t.name??``,r=a(t),i=typeof e.downloads?.monthly==`number`?e.downloads.monthly:null,o=(t.links?.npm??``).trim(),s=((t.links?.homepage??``).trim()||o||(n?`https://www.npmjs.com/package/${encodeURIComponent(n)}`:``)).trim()||null;return{name:n,version:t.version??``,downloads:i,total:null,description:t.description??``,author:r,official:l(t),homepage:s,help:null,changelog:null}}),f=k(new Date),m=Hn(),h=Wn();d(u.map(e=>{let t=m[e.name];return!t||typeof t.total!=`number`?e:(q&&console.log(`[SearchPluginsDialog] total downloads loaded from cache for ${e.name} (asOf=${t.asOf}):`,t.total),{...e,total:t.total})}).map(e=>{let t=h[e.name];if(!t||t.asOf!==f)return e;let n=t.homepage??e.homepage,r=t.help,i=t.changelog;return q&&(r||i||n&&n!==e.homepage)&&console.log(`[SearchPluginsDialog] metadata loaded from cache for ${e.name} (asOf=${t.asOf}):`,{homepage:n,help:r,changelog:i}),{...e,homepage:n,help:r,changelog:i}}));let g=u.map(e=>e.name).filter(e=>{let t=E.current[e];return!t||t.asOf!==f||t.versions.length===0});q&&console.log(`[SearchPluginsDialog] versions prefetch queue (${g.length.toString()}):`,g);let _=0,v=async()=>{for(;_<g.length;){if(t.signal.aborted)return;let e=_;_+=1;let r=g[e];if(r)try{let e=await A(r,f);q&&e.length>0&&console.log(`[SearchPluginsDialog] versions fetched for ${r} (${e.length.toString()}):`,e.slice(0,5))}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return}finally{t.signal.aborted||await n(200)}}};Promise.all(Array.from({length:Math.min(1,u.length)},()=>v()));let b=u.map(e=>e.name).filter(e=>{let t=h[e],n=!!t&&t.asOf===f,r=!!t&&!!t.help&&!!t.changelog,i=!n||!r;return!i&&q&&console.log(`[SearchPluginsDialog] metadata fetch skipped (cache fresh+complete) for ${e} (asOf=${t.asOf}).`),n&&!r&&q&&console.log(`[SearchPluginsDialog] metadata fetch forced (cache incomplete) for ${e} (asOf=${t.asOf}).`),i}),x=new Set(b),C=async(e,n)=>{let r=`https://registry.npmjs.org/${encodeURIComponent(e)}/latest`;try{let e=await fetch(r,{signal:t.signal});if(!e.ok)return null;let i=await e.json(),a=typeof i.homepage==`string`&&i.homepage.includes(`http`)?zn(i.homepage):null,o=typeof i.help==`string`&&i.help.startsWith(`http`)?i.help.trim():null,s=typeof i.changelog==`string`&&i.changelog.startsWith(`http`)?i.changelog.trim():null,c=Vn(i.repository),l=c?Bn(c):null,u=l&&l.includes(`http`)?l:null,d=a||u||n||null;return{homepage:d,help:o||(u?`${u}/blob/main/README.md`:null)||d||null,changelog:s||(u?`${u}/blob/main/CHANGELOG.md`:null)||d||null}}catch(e){return e instanceof DOMException&&e.name,null}},T=0,D=async()=>{for(;T<b.length;){if(t.signal.aborted)return;let e=T;T+=1;let r=b[e];if(!r||!x.has(r))continue;x.delete(r);let i=await C(r,u.find(e=>e.name===r)?.homepage??null);if(t.signal.aborted)return;i&&(d(e=>e.map(e=>e.name===r?{...e,homepage:i.homepage??e.homepage,help:i.help,changelog:i.changelog}:e)),h[r]={homepage:i.homepage,help:i.help,changelog:i.changelog,asOf:f},Gn(h)),t.signal.aborted||await n(250)}};Promise.all(Array.from({length:Math.min(1,u.length)},()=>D()));let O=`2020-01-01`,j=u.map(e=>e.name).filter(e=>{let t=m[e],n=!t||t.asOf!==f;return n||q&&console.log(`[SearchPluginsDialog] total downloads fetch skipped (cache fresh) for ${e} (asOf=${t.asOf}).`),n}),M=new Set(j),N=j.length;S({done:0,total:N}),y(N>0);let P=async e=>{let i=`https://api.npmjs.org/downloads/range/${O}:${f}/${encodeURIComponent(e)}`;for(let e=0;e<3;e+=1){let a=await fetch(i,{signal:t.signal});if(a.ok)return r(await a.json());if(a.status===404)return null;if(a.status===429){let t=a.headers.get(`retry-after`),r=t?Number(t):NaN;await n(Number.isFinite(r)?r*1e3:2e3*(e+1));continue}return null}return null},ee=0,F=0,te=async()=>{for(;ee<j.length;){if(t.signal.aborted)return;let e=ee;ee+=1;let r=j[e];if(r&&M.has(r)){M.delete(r);try{q&&console.log(`[SearchPluginsDialog] fetching total downloads for ${r} (range ${O}:${f})...`);let e=await P(r);if(t.signal.aborted)return;q&&console.log(`[SearchPluginsDialog] total downloads fetched for ${r}:`,e),d(t=>t.map(t=>t.name===r?{...t,total:e}:t)),typeof e==`number`&&(m[r]={total:e,asOf:f},Un(m),q&&console.log(`[SearchPluginsDialog] total downloads saved to localStorage for ${r} (asOf=${f}):`,e))}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return}finally{F+=1,S({done:F,total:N}),t.signal.aborted||await n(500)}}}};Promise.all(Array.from({length:Math.min(1,u.length)},()=>te())).finally(()=>{t.signal.aborted||y(!1)}),q&&console.log(`[SearchPluginsDialog] npm packages starting with "${e}" (filtered/sorted):`,u)}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;console.error(`[SearchPluginsDialog] npm registry fetch error:`,e),w(e instanceof Error?e.message:String(e))}finally{p(!1)}})(),()=>t.abort()},[e,A]);let N=async()=>{O();let e=s.current||a;if(!(!e||m))try{h(!0);let t=await A(e,k(new Date));q&&console.log(`[SearchPluginsDialog] passing versions to onVersions() for ${e} (${t.length.toString()}):`,t),r(t),h(!1),n(e)}catch(t){if(t instanceof DOMException&&t.name===`AbortError`)return;console.error(`[SearchPluginsDialog] npm versions fetch error:`,t),r([]),h(!1),n(e)}},P=()=>{O(),t(),r([])},ee=u.reduce((e,t)=>e+(typeof t.downloads==`number`?t.downloads:0),0),te=u.reduce((e,t)=>(typeof t.total==`number`&&(e.total+=t.total,e.hasAny=!0),e),{total:0,hasAny:!1}),I=_?` Totals: ${b.done.toString()}/${b.total.toString()} fetched`:``,ne=te.hasAny?j(te.total):`...`;return(0,Y.jsxs)(D,{open:e,onClose:()=>{O(),t()},maxWidth:!1,fullWidth:!0,slotProps:{paper:{sx:{width:J&&i?`100vw`:`75vw`,height:J&&i?`100vh`:`75vh`,maxWidth:J&&i?`100vw`:`75vw`,maxHeight:J&&i?`100vh`:`75vh`,margin:J&&i?`0px`:void 0,display:`flex`,flexDirection:`column`}}},children:[(0,Y.jsx)(F,{children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h4`,{style:{margin:0},children:`Search Plugins`})]})}),(0,Y.jsx)(re,{dividers:!0,sx:{padding:`10px`,flex:`1 1 auto`,minHeight:0},children:(0,Y.jsx)(`div`,{style:{height:`100%`,width:`100%`,display:`flex`,flexDirection:`column`,minHeight:0},children:f?(0,Y.jsx)(`div`,{style:{padding:`20px`},children:`Loading npm registry...`}):C?(0,Y.jsx)(`div`,{style:{padding:`20px`},children:C}):(0,Y.jsx)(Sn,{name:`Search plugins`,rows:u,columns:M,getRowKey:`name`,onRowClick:(e,t,n)=>{s.current=e.name,o(e.name),n.detail===2&&N()},footerLeft:`Total packages: ${u.length.toString()} Total downloads: ${j(ee)} / ${ne}${I}`,footerRight:a?`Selected: ${a}`:``})})}),(0,Y.jsxs)(x,{sx:{justifyContent:`center`,gap:1.5,flexWrap:`wrap`},children:[(0,Y.jsx)(H,{title:`Select the plugin and close the dialog. Double-click a row to select and close the dialog.`,children:(0,Y.jsx)(L,{variant:`contained`,onClick:N,disabled:!(s.current||a)||m,children:`Select`})}),(0,Y.jsx)(H,{title:`Close the dialog without selecting a plugin.`,children:(0,Y.jsx)(L,{onClick:P,children:`Cancel`})})]})]})};function Yn(){let{mobile:e,showSnackbarMessage:t}=(0,G.useContext)(Vt),{logMessage:n,sendMessage:r,getUniqueId:i}=(0,G.useContext)(X),[a,o]=(0,G.useState)(`matterbridge-`),[s,c]=(0,G.useState)([`latest`,`dev`]),[l,d]=(0,G.useState)(`latest`),[f,p]=(0,G.useState)(!1),m=(0,G.useRef)(i()),h=e=>{let t=String(e??``).trim();if(!t)return{name:``,specifier:null};if(t.startsWith(`@`)){let e=t.lastIndexOf(`@`);if(e>0){let n=t.slice(0,e),r=t.slice(e+1);if(n.includes(`/`)&&r)return{name:n,specifier:r}}return{name:t,specifier:null}}let n=t.indexOf(`@`);if(n>0){let e=t.slice(0,n),r=t.slice(n+1);return r?{name:e,specifier:r}:{name:e,specifier:null}}return{name:t,specifier:null}},g=()=>{let{name:e,specifier:t}=h(a);return e?t?`${e}@${t}`:l?`${e}@${l}`:e:``},_=e=>{e.preventDefault(),p(!0)},v=()=>{p(!1)},y=e=>{e.preventDefault(),p(!1);let t=e.dataTransfer.files[0];if(t){n(`Plugins`,`Installing package ${t.name}. Please wait...`);let e=new FormData;e.append(`file`,t),e.append(`filename`,t.name),fetch(`./api/uploadpackage`,{method:`POST`,body:e}).then(e=>e.text()).then(e=>{n(`Plugins`,`Server response: ${e}`)}).catch(e=>{console.error(`Error uploading plugin file:`,e),n(`Plugins`,`Error installing package ${e}`)})}},b=e=>{let t=e.target.files&&e.target.files[0];if(t){n(`Plugins`,`Uploading package ${t.name}`);let e=new FormData;e.append(`file`,t),e.append(`filename`,t.name),fetch(`./api/uploadpackage`,{method:`POST`,body:e}).then(e=>e.text()).then(e=>{n(`Plugins`,`Server response: ${e}`)}).catch(e=>{console.error(`Error uploading plugin file:`,e),n(`Plugins`,`Error uploading package ${e}`)})}},x=()=>{let e=g();if(e){if(Rn.includes(e.split(`@`)[0])){t(`Installation of plugin "${e}" is blocked by the ignore list.`);return}r({id:m.current,sender:`InstallPlugins`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:e,restart:!1}})}},S=()=>{r({id:m.current,sender:`InstallPlugins`,method:`/api/uninstall`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:a}})},C=()=>{document.getElementById(`file-upload`)?.click()},w=()=>{if(Rn.includes(a.split(`@`)[0])){t(`Addition of plugin "${a}" is blocked by the ignore list.`);return}r({id:m.current,sender:`InstallPlugins`,method:`/api/addplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginNameOrPath:a}})},E=e=>{e.preventDefault(),q&&console.log(`Right-clicked Upload button`)},D=e=>{e.preventDefault(),q&&console.log(`Right-clicked Add button`)},[O,k]=(0,G.useState)(!1),A=()=>{k(!0),q&&console.log(`Dialog opened for selection`)},j=()=>{o(`matterbridge-`),k(!1),q&&console.log(`Dialog closed without selection`)},M=e=>{o(e),k(!1),q&&console.log(`Select plugin:`,e)},P=e=>{c(e),d(e.includes(`latest`)?`latest`:e[0]??``),q&&console.log(`Select plugin versions:`,e)},[ee,F]=(0,G.useState)(!1);return q&&console.log(`HomeInstallAddPlugins rendering...`),ee?null:(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(Gt,{children:[(0,Y.jsx)(Kt,{children:`Install plugins`}),(0,Y.jsx)(Zt,{close:()=>F(!0)})]}),(0,Y.jsxs)(Xt,{onDragOver:_,onDragLeave:v,onDrop:y,style:J&&e?{flexWrap:`wrap`,alignItems:`center`,gap:`10px`}:{flexWrap:`wrap`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(Jn,{open:O,onClose:j,onSelect:M,onVersions:P}),(0,Y.jsxs)(`div`,{style:{flex:`1 1 auto`,display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(H,{title:`Provide the npm name or the local path of the plugin to install, uninstall, or add`,children:(0,Y.jsx)(B,{value:a,onChange:e=>{let t=e.target.value;c([`latest`,`dev`]),d(`latest`),o(t)},size:`small`,id:`plugin-name`,label:`Plugin name or plugin path`,variant:`outlined`,fullWidth:!0})}),s.length>0&&(0,Y.jsx)(H,{title:`Select the npm tag/version to install`,children:(0,Y.jsx)(`span`,{children:(0,Y.jsxs)(Fe,{size:`small`,style:{minWidth:`150px`},children:[(0,Y.jsx)(le,{id:`plugin-version-label`,children:`Tag or version`}),(0,Y.jsx)(ye,{labelId:`plugin-version-label`,id:`plugin-version`,value:l,label:`Tag or version`,onChange:e=>d(String(e.target.value??``)),sx:{"& .MuiSelect-icon":{color:`var(--main-label-color)`}},children:s.map(e=>(0,Y.jsx)(V,{value:e,children:e},e))})]})})}),(0,Y.jsx)(H,{title:`Search on npm the plugin to install`,children:(0,Y.jsx)(T,{size:`large`,onClick:A,children:(0,Y.jsx)(te,{fontSize:`inherit`})})})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(H,{title:`Install or update a plugin from npm`,children:(0,Y.jsxs)(L,{onClick:x,endIcon:(0,Y.jsx)(u,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Install`]})}),(0,Y.jsx)(H,{title:`Uninstall and remove a plugin`,children:(0,Y.jsxs)(L,{onClick:S,endIcon:(0,Y.jsx)(Pe,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Uninstall`]})}),(0,Y.jsx)(H,{title:`Upload and install a plugin from a tarball`,children:(0,Y.jsxs)(L,{onClick:C,onContextMenu:E,endIcon:(0,Y.jsx)(Ie,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Upload`]})}),(0,Y.jsx)(H,{title:`Add an already installed plugin or a plugin from a local path`,children:(0,Y.jsxs)(L,{onClick:w,onContextMenu:D,endIcon:(0,Y.jsx)(N,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Add`]})}),(0,Y.jsx)(`input`,{id:`file-upload`,type:`file`,accept:`.tgz`,style:{display:`none`},onChange:b})]})]})]})}var Xn=(0,G.memo)(Yn),Zn=()=>{let e=window;return`ontouchstart`in window||e.DocumentTouch!==void 0&&document instanceof e.DocumentTouch?(q&&console.log(`WebSocketLogs detectTouchscreen = true`),!0):(q&&console.log(`WebSocketLogs detectTouchscreen = false`),!1)};function Qn(){let{messages:e,logAutoScroll:t}=(0,G.useContext)(Ht),[n,r]=(0,G.useState)(!1),i=(0,G.useRef)(null),a=(0,G.useRef)(0),o=(0,G.useRef)(null),s=(0,G.useMemo)(()=>Zn(),[]),c=()=>r(!0),l=()=>r(!1);(0,G.useEffect)(()=>{if(q&&console.log(`WebSocketLogs logAutoScroll: ${t.current} isHovering: ${n}`),t.current&&!n&&!s){let e=Date.now();e-a.current>=500?(q&&console.log(`WebSocketLogs auto-scroll to bottom`),a.current=e,i.current?.scrollIntoView({behavior:`smooth`,block:`end`})):(q&&console.log(`WebSocketLogs auto-scroll skipped to avoid flicker`),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{i.current?.scrollIntoView({behavior:`smooth`}),a.current=Date.now()},1e3))}},[e,t,n,s]);let u=e=>{switch(e.toLowerCase()){case`debug`:return`gray`;case`info`:return`#267fb7`;case`notice`:return`green`;case`warn`:return`#e9db18`;case`error`:return`red`;case`fatal`:return`#ff0000`;case`spawn`:return`#ff00d0`;default:return`#5c0e91`}},d=e=>{switch(e.toLowerCase()){case`warn`:return`black`;default:return`white`}};return(0,Y.jsx)(`div`,{style:{margin:`0px`,padding:`0px`},onMouseEnter:c,onMouseLeave:l,children:(0,Y.jsxs)(`ul`,{style:{margin:`0px`,padding:`0px`},children:[e.map((e,t)=>(0,Y.jsxs)(`li`,{style:{wordWrap:`break-word`,maxHeight:`200px`,overflow:`hidden`},children:[(0,Y.jsx)(`span`,{style:{marginRight:`5px`,padding:`1px 5px`,backgroundColor:u(e.level),color:d(e.level),fontSize:`12px`,borderRadius:`3px`,textAlign:`center`},children:e.level}),e.time&&(0,Y.jsx)(`span`,{style:{marginRight:`3px`,color:`#505050`},children:`[`+e.time+`]`}),e.name&&(0,Y.jsx)(`span`,{style:{marginRight:`3px`,color:`#09516d`},children:`[`+e.name+`]`}),(0,Y.jsx)(`span`,{style:{color:`var(--main-log-color)`},children:e.message})]},t)),(0,Y.jsx)(`div`,{ref:i})]})})}var $n=(0,G.memo)(Qn);function er(){let[e,t]=(0,G.useState)(localStorage.getItem(K.logFilterLevel)??`info`),[n,r]=(0,G.useState)(localStorage.getItem(K.logFilterSearch)??`*`),{online:i,logAutoScroll:a}=(0,G.useContext)(X);return q&&console.log(`HomeLogs rendering...`),i?(0,Y.jsxs)(Q,{style:{flex:`1 1 auto`},children:[(0,Y.jsxs)(Gt,{children:[(0,Y.jsx)(Kt,{children:`Logs`}),(0,Y.jsxs)(Kt,{style:{fontWeight:`normal`,fontSize:`12px`,marginTop:`2px`},children:[`Filter: logger level "`,e,`" and search "`,n===``?`*`:n,`" Scroll: `,a.current?`auto`:`manual`]})]}),(0,Y.jsx)(Xt,{style:{flex:`1 1 auto`,overflow:`auto`,margin:`0px`,padding:`10px`,alignItems:`start`},children:(0,Y.jsx)($n,{})})]}):(0,Y.jsx)(Wt,{})}var tr=(0,G.memo)(er);function nr(e){return e.id!==0&&e.src===`Matterbridge`&&e.dst===`Frontend`}var rr={fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},ir={fontSize:`12px`,fontWeight:`normal`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},ar={fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},or={fontSize:`14px`,fontWeight:`normal`,color:`var(--secondary-color)`,backgroundColor:`var(--div-bg-color)`},sr={fontSize:`16px`,fontWeight:`bold`,backgroundColor:`var(--div-bg-color)`},cr={padding:`0px`,margin:`0px`},lr=`5px 10px 5px 10px`,ur={},dr={},fr={},pr={},mr=[],hr=[],gr=[];function _r(e,t){let n=e?.properties;if(!n||typeof n!=`object`)return!1;let r=n[t];return!r||typeof r!=`object`?!1:typeof r.type==`string`}function vr(e){let t=e.items;return t!==void 0&&typeof t==`object`&&!Array.isArray(t)}function yr(e,t){let n=e?.properties;if(!n||typeof n!=`object`)return!1;let r=n[t];if(!r||typeof r!=`object`||r.type!==`array`||r.uniqueItems!==!0)return!1;let i=r.items;return i!==void 0&&typeof i==`object`&&!Array.isArray(i)&&Array.isArray(i.enum)}var br=({open:e,onClose:t,plugin:n})=>{let{sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,G.useContext)(X),s=(0,G.useRef)(o()),c=(0,G.useRef)({}),l=(0,G.useRef)({}),[u,d]=(0,G.useState)(n.configJson),[f,m]=(0,G.useState)(n.schemaJson),[g,_]=(0,G.useState)({"ui:submitButtonOptions":{submitText:`Confirm`},"ui:globalOptions":{orderable:!0}}),v=(0,G.useRef)(``),y=n.configJson;(0,G.useEffect)(()=>{let e=e=>{e.src===`Matterbridge`&&e.dst===`Frontend`&&(nr(e)&&e.id===s.current&&e.method===`/api/select/devices`&&e.response&&(q&&console.log(`ConfigPluginDialog (id: ${e.id}) received ${e.response.length} /api/select/devices:`,e.response),hr=e.response),nr(e)&&e.id===s.current&&e.method===`/api/select/entities`&&e.response&&(q&&console.log(`ConfigPluginDialog (id: ${e.id}) received ${e.response.length} /api/select/entities:`,e.response),gr=e.response))};if(i(e,s.current),q&&console.log(`ConfigPluginDialog added WebSocket listener id:`,s.current),q&&console.log(`ConfigPluginDialog mounting...`),q&&console.log(`ConfigPluginDialog mounting with form:`,u),q&&console.log(`ConfigPluginDialog mounting with schema:`,f),q&&console.log(`ConfigPluginDialog mounting with uiSchema:`,g),u&&f&&f.properties){let e=(t,n,r=[])=>{!t||typeof t!=`object`||(t.properties&&Object.keys(t.properties).forEach(i=>{let a=t.properties?.[i],o=[...r,i];Object.keys(a).forEach(e=>{if(e.startsWith(`ui:`)){let t=n;o.forEach(e=>{t[e]||(t[e]={}),t=t[e]}),t[e]=a[e],delete a[e]}}),e(a,n,o)}),[`oneOf`,`anyOf`,`allOf`].forEach(i=>{Array.isArray(t[i])&&t[i].forEach(t=>{e(t,n,r)})}),t.items&&typeof t.items==`object`&&e(t.items,n,r))};e(f,g),_(g),c.current=f,l.current=g}return n.name&&n.configJson&&n.schemaJson&&(d(n.configJson),m(n.schemaJson),r({id:s.current,sender:`ConfigPlugin`,method:`/api/select/devices`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:n.name}}),r({id:s.current,sender:`ConfigPlugin`,method:`/api/select/entities`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:n.name}}),q&&console.log(`HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:`,n.name)),()=>{a(e),q&&console.log(`ConfigPluginDialog removed WebSocket listener`)}},[i,u,n,a,f,r,g]);let b=(e,t)=>{y=e.formData},S=e=>{q&&console.log(`ConfigPluginDialog handleSaveChanges:`,e.formData),d(e.formData),n.configJson=e.formData,n.restartRequired=!0,r({id:s.current,sender:`ConfigPlugin`,method:`/api/savepluginconfig`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.formData.name,formData:e.formData}}),t()};function C(e){let{id:t,label:n,onKeyRenameBlur:r,onRemoveProperty:i,disabled:a,schema:o,children:s,registry:c,readonly:l,required:u}=e,{templates:d}=c,{RemoveButton:f}=d.ButtonTemplates,p=Ct in o,m=(0,G.useRef)(null);return(0,G.useEffect)(()=>{let e=v.current;!p||e===``||!/^newKey(?:-\d+)?$/.test(n)||!m.current||(q&&console.log(`WrapIfAdditionalTemplate: renaming additional property "${n}" to "${e}"`),m.current.value=e,r({target:m.current}),v.current=``)},[p,n,r]),p?(0,Y.jsxs)(W,{sx:{display:`flex`,flexDirection:`row`,flexGrow:1,padding:0,margin:0,border:`none`},children:[(0,Y.jsx)(B,{id:`${t}-key`,name:`${t}-key`,required:u,disabled:a||l,defaultValue:n,inputRef:m,onBlur:l?void 0:r,type:`text`,variant:`outlined`,sx:{width:`250px`,minWidth:`250px`,maxWidth:`250px`,marginRight:`20px`}}),(0,Y.jsx)(W,{sx:{flex:1},children:s}),(0,Y.jsx)(f,{disabled:a||l,onClick:i,registry:c})]}):(0,Y.jsx)(W,{sx:{display:`flex`,flexDirection:`column`,flexGrow:1,padding:0,margin:0,border:`none`},children:s})}function w(e){let{children:t,description:n,displayLabel:r,errors:i,help:a,hidden:o,registry:s,uiSchema:c}=e,l=St(`WrapIfAdditionalTemplate`,s,xt(c));return o?(0,Y.jsx)(`div`,{style:{display:`none`},children:t}):(0,Y.jsx)(W,{sx:{display:`flex`,flexDirection:`column`,flexGrow:1,padding:0,margin:0,border:`none`},children:(0,Y.jsxs)(l,{...e,children:[r===!0&&n,t,i,a]})})}function E(e){let{description:t}=e;return t?(0,Y.jsx)(p,{sx:ir,children:t}):null}function O(e){let{required:t,title:n}=e;return n?(0,Y.jsx)(W,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:(0,Y.jsxs)(p,{sx:rr,children:[`Title `,n,` `,t&&(0,Y.jsx)(`mark`,{children:`***`})]})}):null}function k(e){let{help:t}=e;return t?(0,Y.jsx)(W,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:(0,Y.jsx)(p,{sx:or,children:t})}):null}function A(e){let{errors:t}=e;return t?(0,Y.jsxs)(W,{sx:{padding:`10px`,margin:`10px`,border:`1px solid grey`},children:[(0,Y.jsx)(p,{color:`error`,sx:sr,children:`Please fix the following errors:`}),(0,Y.jsx)(at,{children:t.map((e,t)=>(0,Y.jsxs)(se,{children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(Be,{color:`error`})}),(0,Y.jsx)(z,{primary:e.stack})]},t))})]}):null}function P(e){let{errors:t}=e;return t?(0,Y.jsx)(W,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:t.map((e,t)=>(0,Y.jsxs)(p,{color:`error`,variant:`body2`,sx:{marginLeft:1},children:[`This field `,e]},t))}):null}function ee(e){let{id:t,name:n,_schema:r,_uiSchema:i,value:a,options:o,label:s,type:c,placeholder:l,required:u,disabled:d,readonly:f,autofocus:p,onChange:m,onChangeOverride:h,onBlur:g,onFocus:_,_rawErrors:v,_hideError:y,_registry:b,_formContext:x}=e;return(0,Y.jsx)(W,{sx:{padding:`0px`,margin:`0px`},children:(0,Y.jsx)(B,{id:t,name:t,label:l&&l!==``?s:void 0,variant:`outlined`,placeholder:l&&l!==``?l:s,required:u,disabled:d||f,autoFocus:p,value:a||a===0?a:``,type:c,autoComplete:c===`password`?`current-password`:n,onChange:h||(({target:{value:e}})=>m(e===``?o.emptyValue:e)),onBlur:({target:e})=>g(t,e&&e.value),onFocus:({target:e})=>_(t,e&&e.value),fullWidth:!0})})}function te(e){return console.log(`ArrayFieldTitleTemplate:`,e),null}function I(e){return console.log(`ArrayFieldDescriptionTemplate:`,e),null}function ne(e){let{buttonsProps:t,children:n}=e;return(0,Y.jsxs)(W,{sx:{margin:`2px 0px`,padding:`0px`,display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(W,{sx:{flexGrow:1,marginRight:`10px`},children:n}),(0,Y.jsx)(T,{disabled:!t.hasMoveUp,onClick:t.onMoveUpItem,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(Te,{})}),(0,Y.jsx)(T,{disabled:!t.hasMoveDown,onClick:t.onMoveDownItem,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(Oe,{})}),t.hasRemove&&(0,Y.jsx)(T,{onClick:t.onRemoveItem,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(ke,{})})]})}function ie(e){let{canAdd:t,onAddClick:n,schema:r,title:i,formData:a}=e,[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(!1),[f,m]=(0,G.useState)(``),g=e=>{m(e.target.value)},_=()=>{q&&console.log(`ArrayFieldTemplate: handleDialogDeviceToggle filter:`,f,`selectDevices:`,hr),s(!o)},v=()=>{q&&console.log(`ArrayFieldTemplate: handleDialogEntityToggle filter:`,f,`selectEntities:`,gr),l(!c)},y=()=>{q&&console.log(`ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:`,f,`selectDevices:`,hr),d(!u)},b=e=>{s(!1),r.selectFrom===`serial`&&vr(r)?r.items.default=e.serial:r.selectFrom===`name`&&vr(r)&&(r.items.default=e.name),n()},S=e=>{l(!1),r.selectEntityFrom===`name`&&vr(r)?r.items.default=e.name:r.selectEntityFrom===`description`&&vr(r)&&(r.items.default=e.description),n()},C=e=>{d(!1),r.selectDeviceEntityFrom===`name`&&vr(r)?r.items.default=e.name:r.selectDeviceEntityFrom===`description`&&vr(r)&&(r.items.default=e.description),n()};return(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:`5px 10px 5px 10px`,border:`1px solid grey`},children:[i&&(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:`0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[i&&(0,Y.jsx)(p,{sx:rr,children:i}),t&&(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:`0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[r.selectFrom&&(0,Y.jsx)(H,{title:`Add a device from the list`,children:(0,Y.jsx)(T,{onClick:_,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(et,{})})}),r.selectEntityFrom&&(0,Y.jsx)(H,{title:`Add an entity from the list`,children:(0,Y.jsx)(T,{onClick:v,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(et,{})})}),r.selectDeviceEntityFrom&&(0,Y.jsx)(H,{title:`Add a device entity from the list`,children:(0,Y.jsx)(T,{onClick:y,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(et,{})})}),(0,Y.jsx)(H,{title:`Add a new item`,children:(0,Y.jsx)(T,{onClick:n,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(N,{})})})]})]}),r.description&&(0,Y.jsx)(p,{sx:ir,children:r.description}),e.items,(0,Y.jsxs)(D,{open:o,onClose:_,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,Y.jsx)(F,{children:`Select a device`}),(0,Y.jsxs)(re,{children:[(0,Y.jsxs)(W,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,Y.jsx)(p,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,Y.jsx)(B,{fullWidth:!0,variant:`outlined`,value:f,onChange:g,placeholder:`Enter serial or name`})]}),(0,Y.jsx)(at,{dense:!0,children:hr.filter(e=>e.serial.toLowerCase().includes(f.toLowerCase())||e.name.toLowerCase().includes(f.toLowerCase())).filter(e=>!r.uniqueItems||!a.includes(r.selectFrom===`serial`?e.serial:e.name)).map((e,t)=>(0,Y.jsxs)(h,{onClick:()=>b(e),sx:ur,children:[e.icon===`wifi`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(j,{style:dr})}),e.icon===`ble`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(ve,{style:dr})}),e.icon===`hub`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ke,{style:dr})}),(0,Y.jsx)(z,{primary:e.name,secondary:e.serial,primaryTypographyProps:{style:fr},secondaryTypographyProps:{style:pr}})]},t))})]}),(0,Y.jsx)(x,{children:(0,Y.jsx)(L,{onClick:_,children:`Close`})})]}),(0,Y.jsxs)(D,{open:c,onClose:v,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,Y.jsx)(F,{children:`Select an entity`}),(0,Y.jsxs)(re,{children:[(0,Y.jsxs)(W,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,Y.jsx)(p,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,Y.jsx)(B,{fullWidth:!0,variant:`outlined`,value:f,onChange:g,placeholder:`Enter name or description`})]}),(0,Y.jsx)(at,{dense:!0,children:gr.filter(e=>e.name.toLowerCase().includes(f.toLowerCase())||e.description.toLowerCase().includes(f.toLowerCase())).filter(e=>!r.uniqueItems||!a.includes(r.selectEntityFrom===`name`?e.name:e.description)).map((e,t)=>(0,Y.jsxs)(h,{onClick:()=>S(e),sx:ur,children:[e.icon===`wifi`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(j,{style:dr})}),e.icon===`ble`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(ve,{style:dr})}),e.icon===`hub`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ke,{style:dr})}),e.icon===`component`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Re,{style:dr})}),e.icon===`matter`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ae,{style:dr})}),(0,Y.jsx)(z,{primary:e.name,secondary:e.description,primaryTypographyProps:{style:fr},secondaryTypographyProps:{style:pr}})]},t))})]}),(0,Y.jsx)(x,{children:(0,Y.jsx)(L,{onClick:v,children:`Close`})})]}),(0,Y.jsxs)(D,{open:u,onClose:y,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,Y.jsxs)(F,{children:[`Select an entity for `,i]}),(0,Y.jsx)(re,{children:(0,Y.jsx)(at,{dense:!0,children:hr.filter(e=>e.serial===i||e.name===i).map(e=>e.entities?.filter(e=>!r.uniqueItems||!Array.isArray(a)||!a.includes(r.selectDeviceEntityFrom===`name`?e.name:e.description)).map((e,t)=>(0,Y.jsxs)(h,{onClick:()=>C(e),sx:ur,children:[e.icon===`wifi`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(j,{style:dr})}),e.icon===`ble`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(ve,{style:dr})}),e.icon===`hub`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ke,{style:dr})}),e.icon===`component`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Re,{style:dr})}),e.icon===`matter`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ae,{style:dr})}),(0,Y.jsx)(z,{primary:e.name,secondary:e.description,primaryTypographyProps:{style:fr},secondaryTypographyProps:{style:pr}})]},t)))})}),(0,Y.jsx)(x,{children:(0,Y.jsx)(L,{onClick:y,children:`Close`})})]})]})}function ae(e){let{onAddProperty:t,schema:n,properties:r,title:i,description:a}=e,[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(``),u=e=>{l(e.target.value)},d=()=>{s(!o)},f=e=>{q&&console.log(`ObjectFieldTemplate: handleSelectValue value "${e.serial}" for schema "${n.selectFrom}"`),s(!1);let r=``;n.selectFrom===`serial`?r=e.serial:n.selectFrom===`name`&&(r=e.name),v.current=r,q&&console.log(`ObjectFieldTemplate: handleSelectValue pendingAdditionalPropertyKey "${r}"`),t()},m=()=>{t()},g=!n.additionalProperties;return q&&console.log(`ObjectFieldTemplate: isRoot ${g} pendingAdditionalPropertyKey "${v.current}"`),(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:g?`10px`:`5px 10px 0px 10px`,border:g?`none`:`1px solid grey`},children:[n.title&&g&&(0,Y.jsx)(W,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`,marginBottom:`10px`},children:(0,Y.jsx)(p,{sx:rr,children:n.title})}),i&&!g&&(0,Y.jsxs)(W,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`},children:[(0,Y.jsx)(p,{sx:rr,children:i}),(0,Y.jsxs)(W,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`},children:[n.selectFrom&&(0,Y.jsx)(H,{title:`Add a device from the list`,children:(0,Y.jsx)(T,{onClick:d,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(et,{})})}),(0,Y.jsx)(H,{title:`Add a new item`,children:(0,Y.jsx)(T,{onClick:m,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(N,{})})})]})]}),n.description&&(0,Y.jsx)(W,{sx:{padding:`0px`,margin:`0px`,marginBottom:`10px`},children:(0,Y.jsx)(p,{sx:ir,children:n.description})}),r.map(({content:e,name:t,hidden:r})=>{if(r)return null;let i=_r(n,t),a=yr(n,t),o=i&&[`object`,`array`].includes(n.properties[t].type);return(0,Y.jsxs)(W,{sx:{margin:`0px`,marginBottom:`10px`,padding:o&&!a?`0px`:lr,border:o&&!a?`none`:`1px solid grey`},children:[i&&![`object`,`array`,`boolean`].includes(n.properties[t].type)&&(0,Y.jsx)(p,{sx:rr,children:n.properties[t].title||t}),a&&(0,Y.jsx)(p,{sx:rr,children:n.properties[t].title||t}),(0,Y.jsx)(W,{sx:{flexGrow:1,padding:`0px`,margin:`0px`},children:e})]},t)}),(0,Y.jsxs)(D,{open:o,onClose:d,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,Y.jsx)(F,{children:`Select a device`}),(0,Y.jsxs)(re,{children:[(0,Y.jsxs)(W,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,Y.jsx)(p,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,Y.jsx)(B,{fullWidth:!0,variant:`outlined`,value:c,onChange:u,placeholder:`Enter serial or name`})]}),(0,Y.jsx)(at,{dense:!0,children:hr.filter(e=>e.serial.toLowerCase().includes(c.toLowerCase())||e.name.toLowerCase().includes(c.toLowerCase())).map((e,t)=>(0,Y.jsxs)(h,{onClick:()=>f(e),sx:ur,children:[e.icon===`wifi`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(j,{style:dr})}),e.icon===`ble`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(ve,{style:dr})}),e.icon===`hub`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ke,{style:dr})}),(0,Y.jsx)(z,{primary:e.name,secondary:e.serial,primaryTypographyProps:{style:fr},secondaryTypographyProps:{style:pr}})]},t))})]}),(0,Y.jsx)(x,{children:(0,Y.jsx)(L,{onClick:d,children:`Close`})})]})]})}function oe(e){let{uiSchema:n}=e,{submitText:r,norender:i}=bt(n);return i?null:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,margin:`10px`,padding:`0px`,gap:`20px`},children:[(0,Y.jsx)(L,{type:`submit`,variant:`contained`,color:`primary`,children:r}),(0,Y.jsx)(L,{variant:`contained`,color:`primary`,onClick:t,children:`Cancel`})]})}function ce(e){let{className:t,disabled:n,onClick:r,registry:i,style:a,uiSchema:o,...s}=e;return(0,Y.jsx)(H,{title:`Remove the item`,children:(0,Y.jsx)(T,{disabled:n,size:`small`,color:`primary`,onClick:r,children:(0,Y.jsx)(ke,{})})})}function le(e){let{className:t,disabled:n,onClick:r,registry:i,uiSchema:a,...o}=e;return(0,Y.jsx)(H,{title:`Add an item`,children:(0,Y.jsx)(T,{size:`small`,color:`primary`,onClick:r,children:(0,Y.jsx)(N,{})})})}function ue(e){let{disabled:t,onClick:n,registry:r,style:i,uiSchema:a,...o}=e;return(0,Y.jsx)(H,{title:`Move up the item`,children:(0,Y.jsx)(T,{size:`small`,color:`primary`,onClick:n,children:(0,Y.jsx)(Te,{})})})}function de(e){let{disabled:t,onClick:n,registry:r,style:i,uiSchema:a,...o}=e;return(0,Y.jsx)(H,{title:`Move down the item`,children:(0,Y.jsx)(T,{size:`small`,color:`primary`,onClick:n,children:(0,Y.jsx)(Oe,{})})})}function fe(e){let{id:i,name:a,value:o,schema:c,readonly:l,onChange:d}=e,[f,m]=(0,G.useState)(),h=e=>{q&&console.log(`CheckboxWidget ${a} onChangeField:`,e),m(e&&e!==``?e:void 0)},g=()=>{q&&console.log(`CheckboxWidget onClick plugin="${n.name}" action="${a}" value="${f}"`),r({id:s.current,sender:`ConfigPlugin`,method:`/api/action`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:n.name,action:a,value:f,formData:y,id:i}}),c.buttonClose===!0?t():c.buttonSave===!0&&S({formData:u})};return c.buttonText&&(c.title||c.description)?(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:`5px 0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Y.jsx)(p,{sx:ar,children:c.title||c.description}),(0,Y.jsx)(L,{variant:`contained`,color:`primary`,onClick:()=>g(),children:c.buttonText})]}):c.buttonField&&(c.title||c.description)?(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:`5px 0px`,gap:`20px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Y.jsx)(p,{sx:ar,children:c.title||c.description}),(0,Y.jsx)(B,{id:a+`-input`,name:a,label:c.textLabel,placeholder:c.textPlaceholder,onChange:e=>h(e.target.value),sx:{width:`250px`,minWidth:`250px`,maxWidth:`250px`}}),(0,Y.jsx)(L,{id:a+`-button`,variant:`contained`,color:`primary`,disabled:f===void 0,onClick:()=>g(),children:c.buttonField})]}):(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:`0px`},children:[a&&(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:`0px`,gap:`10px`,display:`flex`,justifyContent:`flex-start`,alignItems:`center`},children:[(0,Y.jsx)(p,{sx:rr,children:c.title||a}),(0,Y.jsx)(M,{checked:o,readOnly:l,onChange:()=>d(!o),sx:{padding:`0px`,margin:`0px`}})]}),c.description&&(0,Y.jsx)(p,{sx:ir,children:c.description})]})}function pe({schema:e,id:t,name:n,options:r,label:i,hideLabel:a,required:o,disabled:s,placeholder:c,readonly:l,value:u,multiple:d,autofocus:f,onChange:p,onBlur:m,onFocus:h,errorSchema:g,rawErrors:_=mr,registry:v,uiSchema:y,hideError:b,...x}){let{enumOptions:S,enumDisabled:C,emptyValue:w}=r,T=d?[]:``,E=u===void 0||d&&u.length<1||!d&&u===T,D=({target:{value:e}})=>p(Dt(e,S,w)),O=({target:e})=>m(t,Dt(e&&e.value,S,w)),k=({target:e})=>h(t,Dt(e&&e.value,S,w)),A=Tt(u,S,d);return(0,Y.jsx)(B,{id:t,name:n,value:!E&&A!==void 0?A:T,required:o,disabled:s||l,autoFocus:f,error:_.length>0,onChange:D,onBlur:O,onFocus:k,select:!0,slotProps:{select:{multiple:d,...d?{renderValue:e=>!Array.isArray(e)||!Array.isArray(S)?``:e.map(e=>S[Number(e)]?.label).filter(e=>typeof e==`string`).join(`, `)}:{}}},"aria-describedby":Et(t),children:Array.isArray(S)&&S.map(({value:e,label:t},n)=>{let r=Array.isArray(C)&&C.indexOf(e)!==-1,i=Array.isArray(A)&&A.includes(String(n));return(0,Y.jsxs)(V,{value:String(n),disabled:r,children:[d&&(0,Y.jsx)(U,{sx:{minWidth:`32px`},children:(0,Y.jsx)(M,{checked:i,disableRipple:!0,tabIndex:-1,sx:{padding:`0px`,margin:`0px`}})}),t]},n)})})}return q&&console.log(`ConfigPluginDialog rendering...`),!e||!f||!u?null:(0,Y.jsxs)(D,{open:e,onClose:t,slotProps:{paper:{sx:{maxWidth:`800px`}}},children:[(0,Y.jsx)(F,{gap:`20px`,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h3`,{children:`Matterbridge plugin configuration`})]})}),(0,Y.jsx)(re,{style:{padding:`0px`,margin:`0px`,width:`800px`,height:`600px`,overflow:`auto`},children:(0,Y.jsx)(Ot,{schema:f,formData:u,uiSchema:g,validator:wt,templates:{FieldTemplate:w,BaseInputTemplate:ee,TitleFieldTemplate:O,DescriptionFieldTemplate:E,FieldHelpTemplate:k,FieldErrorTemplate:P,ErrorListTemplate:A,WrapIfAdditionalTemplate:C,ArrayFieldTitleTemplate:te,ArrayFieldDescriptionTemplate:I,ArrayFieldItemTemplate:ne,ArrayFieldTemplate:ie,ObjectFieldTemplate:ae,ButtonTemplates:{SubmitButton:oe,RemoveButton:ce,AddButton:le,MoveUpButton:ue,MoveDownButton:de}},widgets:{CheckboxWidget:fe,SelectWidget:pe},onChange:b,onSubmit:S})})]})};function xr({status:e,enabledText:t=`Enabled`,disabledText:n,tooltipText:r}){if(e===void 0)return null;{let i=(0,Y.jsx)(`div`,{className:e?`status-enabled`:`status-disabled`,style:{cursor:`default`},children:e?t:n??t});return r===void 0?i:(0,Y.jsx)(H,{title:r,children:i})}}function Sr({storeId:e,setStoreId:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,G.useContext)(X),{mobile:s,showConfirmCancelDialog:c}=(0,G.useContext)(Vt),l=(0,G.useRef)(o()),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(null),[h,_]=(0,G.useState)([]),[y,b]=(0,G.useState)(null),S=[{label:`Name`,id:`name`,required:!0,render:(e,t,n,r)=>(0,Y.jsx)(H,{title:`Plugin path ${n.path}`,children:(0,Y.jsx)(`button`,{type:`button`,style:{cursor:`pointer`,background:`none`,border:`none`,padding:0,font:`inherit`,color:`inherit`,textAlign:`left`},onClick:()=>P(n),children:n.name})})},{label:`Description`,id:`description`,render:(e,t,n,r)=>(0,Y.jsx)(H,{title:`Open the plugin homepage`,children:(0,Y.jsx)(`button`,{type:`button`,style:{cursor:`pointer`,background:`none`,border:`none`,padding:0,font:`inherit`,color:`inherit`,textAlign:`left`},onClick:()=>P(n),children:n.description})})},{label:`Version`,id:`version`,render:(e,t,n,r)=>(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(H,{title:`Plugin v.${n.version}`,children:(0,Y.jsx)(`span`,{children:n.version.split(`-`)[0]+(n.version.includes(`-dev-`)?`@dev`:``)+(n.version.includes(`-git-`)?`@git`:``)})})})},{label:`Author`,id:`author`,render:(e,t,n,r)=>(0,Y.jsx)(Y.Fragment,{children:n.author?n.author.replace(`https://github.com/`,``):`Unknown`})},{label:`Type`,id:`type`,render:(e,t,n,r)=>(0,Y.jsx)(Y.Fragment,{children:n.type?n.type.replace(`Platform`,``):`Unknown`})},{label:`Devices`,id:`registeredDevices`},{label:`Actions`,id:`actions`,required:!0,noSort:!0,render:(e,n,r,i)=>(0,Y.jsxs)(`div`,{style:{margin:`0px`,padding:`0px`,gap:`4px`,display:`flex`,flexDirection:`row`},children:[f&&f.bridgeMode===`childbridge`&&!r.error&&r.enabled&&(0,Y.jsx)(H,{title:`Shows the QRCode or the fabrics`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:Pn(r.matter)},onClick:()=>{r.matter?.id&&t(r.matter?.id)},size:`small`,children:(0,Y.jsx)(ee,{})})}),f&&f.bridgeMode===`childbridge`&&!r.error&&r.enabled&&(0,Y.jsx)(H,{title:`Restart the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`},onClick:()=>M(r),size:`small`,children:(0,Y.jsx)(ot,{})})}),(0,Y.jsx)(H,{title:`Plugin config`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{disabled:r.restartRequired===!0,style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>ue(r),size:`small`,children:(0,Y.jsx)(Se,{})})}),f&&!f.readOnly&&(0,Y.jsx)(H,{title:`Remove the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>{w(`Remove plugin`,`Are you sure? This will also remove all devices and configuration from the controller.`,`remove`,r)},size:`small`,children:(0,Y.jsx)(Pe,{})})}),r.enabled?(0,Y.jsx)(H,{title:`Disable the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>{w(`Disable plugin`,`Are you sure? This will also remove all devices and configuration from the controller.`,`disable`,r)},size:`small`,children:(0,Y.jsx)(nt,{})})}):(0,Y.jsx)(Y.Fragment,{}),r.enabled?(0,Y.jsx)(Y.Fragment,{}):(0,Y.jsx)(H,{title:`Enable the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>N(r),size:`small`,children:(0,Y.jsx)(oe,{})})}),(0,Y.jsx)(H,{title:`Open the plugin help`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>te(r),size:`small`,children:(0,Y.jsx)(g,{})})}),(0,Y.jsx)(H,{title:`Open the plugin version history`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>I(r),size:`small`,children:(0,Y.jsx)(v,{})})}),r.enabled&&r.frontendPath&&(0,Y.jsx)(H,{title:`Open the plugin frontend`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>ne(r),size:`small`,children:(0,Y.jsx)(m,{})})}),r.latestVersion!==void 0&&r.latestVersion!==r.version&&f&&!f.readOnly&&(0,Y.jsx)(H,{title:`Update the plugin to the latest version v.${r.latestVersion}`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{color:`var(--primary-color)`,margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>k(r),size:`small`,children:(0,Y.jsx)(st,{})})}),(r.version.includes(`-dev-`)||r.version.includes(`-git-`))&&r.devVersion!==void 0&&r.devVersion!==r.version&&f&&!f.readOnly&&(0,Y.jsx)(H,{title:`Update the plugin to the latest dev version v.${r.devVersion}`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{color:`var(--secondary-color)`,margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>A(r),size:`small`,children:(0,Y.jsx)(st,{})})}),f&&!f.readOnly&&(0,Y.jsx)(H,{title:`Sponsor the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`#b6409c`},onClick:()=>F(r),size:`small`,children:(0,Y.jsx)(it,{})})})]})},{label:`Status`,id:`status`,required:!0,noSort:!0,render:(e,t,n,r)=>(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,flex:`1 1 auto`,margin:`0`,padding:`0`,gap:`5px`,width:`auto`,maxWidth:`max-content`},children:n.error?(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(xr,{status:!1,enabledText:`Error`,disabledText:`Error`,tooltipText:`The plugin is in error state. Check the log!`})}):(0,Y.jsx)(Y.Fragment,{children:n.enabled?(0,Y.jsx)(Y.Fragment,{children:n.loaded&&n.started&&n.configured?(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(xr,{status:n.loaded,enabledText:`Running`,tooltipText:`Whether the plugin is running`})}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(xr,{status:n.loaded,enabledText:`Loaded`,tooltipText:`Whether the plugin has been loaded`}),(0,Y.jsx)(xr,{status:n.started,enabledText:`Started`,tooltipText:`Whether the plugin started`}),(0,Y.jsx)(xr,{status:n.configured,enabledText:`Configured`,tooltipText:`Whether the plugin has been configured`})]})}):(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(xr,{status:n.enabled,enabledText:`Enabled`,disabledText:`Disabled`,tooltipText:`Whether the plugin is enable or disabled`})})})})}];(0,G.useEffect)(()=>{let e=e=>{q&&console.log(`HomePlugins received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`plugins`?e.response.lock?(q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} lock=${e.response.lock} and locking plugins list`),_(t=>t.map(t=>t.name===e.response.lock?{...t,restartRequired:!0}:t))):(q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} lock=${e.response.lock} and sending /api/plugins request`),r({id:l.current,sender:`HomePlugins`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`refresh_required`&&e.response.changed===`matter`?(q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} and setting matter id ${e.response.matter?.id}`),_(t=>{let n=t.findIndex(t=>t.matter?.id===e.response.matter?.id);if(n<0)return q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} and matter id ${e.response.matter?.id} not found`),t;q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} set matter id ${e.response.matter?.id}`);let r=[...t];return r[n]={...r[n],matter:e.response.matter},r})):e.method===`refresh_required`&&e.response.changed===`settings`&&(q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} and sending /api/settings request`),r({id:l.current,sender:`HomePlugins`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})),e.id===l.current&&e.method===`/api/settings`?(q&&console.log(`HomePlugins (id: ${e.id}) received settings:`,e.response),d(e.response.systemInformation),p(e.response.matterbridgeInformation)):e.id===l.current&&e.method===`/api/plugins`&&(q&&console.log(`HomePlugins (id: ${e.id}) received ${e.response.length} plugins:`,e.response),_(e.response))};return i(e,l.current),q&&console.log(`HomePlugins added WebSocket listener id:`,l.current),()=>{a(e),q&&console.log(`HomePlugins removed WebSocket listener`)}},[i,a,r]),(0,G.useEffect)(()=>{n&&(q&&console.log(`HomePlugins sending api requests`),r({id:l.current,sender:`HomePlugins`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),r({id:l.current,sender:`HomePlugins`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[n,r]);let C=(0,G.useRef)(null),w=(e,t,n,r)=>{q&&console.log(`handleActionWithConfirmCancel ${n} ${r.name}`),C.current=r,c(e,t,n,E,O)},E=e=>{q&&console.log(`handleConfirm action confirmed ${e} ${C.current?.name}`),e===`remove`&&C.current?j(C.current):e===`disable`&&C.current&&N(C.current),C.current=null},O=e=>{q&&console.log(`handleCancel action canceled ${e} ${C.current?.name}`),C.current=null},k=e=>{q&&console.log(`handleUpdatePlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:e.name,restart:!1}})},A=e=>{q&&console.log(`handleUpdateDevPlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:e.name+`@dev`,restart:!1}})},j=e=>{q&&console.log(`handleRemovePlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/removeplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})},M=e=>{q&&console.log(`handleRestartPlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/restartplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})},N=e=>{q&&console.log(`handleEnableDisablePlugin plugin:`,e.name,`enabled:`,e.enabled),e.enabled?(e.enabled=!1,r({id:l.current,sender:`HomePlugins`,method:`/api/disableplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})):(e.enabled=!0,r({id:l.current,sender:`HomePlugins`,method:`/api/enableplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}}))},P=e=>{q&&console.log(`handleHomepagePlugin plugin: ${e.name} homepage: ${e.homepage}`),e.homepage&&window.open(e.homepage,`_blank`)},F=e=>{q&&console.log(`handleSponsorPlugin plugin:`,e.name,`funding:`,e.funding),e.funding&&window.open(e.funding,`_blank`)},te=e=>{q&&console.log(`handleHelpPlugin plugin:`,e.name,`help:`,e.help),e.help&&window.open(e.help,`_blank`)},I=e=>{q&&console.log(`handleChangelogPlugin plugin:`,e.name,`changelog:`,e.changelog),e.changelog&&window.open(e.changelog,`_blank`)},ne=e=>{let t=`/plugins/${e.name}`;q&&console.log(`handleFrontendPlugin plugin:`,e.name,`frontend:`,e.frontendPath,`path:`,t),e.frontendPath&&b({name:e.name,path:t})},ie=e=>{let t=e.currentTarget.contentDocument;if(!t?.head)return;let n=getComputedStyle(document.body),r=n.getPropertyValue(`--primary-color`).trim()||`#0d6efd`,i=n.getPropertyValue(`--div-bg-color`).trim()||`#111111`;t.getElementById(`matterbridge-plugin-scrollbar-style`)?.remove();let a=t.createElement(`style`);a.id=`matterbridge-plugin-scrollbar-style`,a.textContent=`
|
|
22
|
+
`,t.head.appendChild(a)},style:{display:`block`,flex:`1 1 auto`,width:`100%`,height:`100%`,border:`none`,backgroundColor:`var(--div-bg-color)`}})}),(0,Y.jsx)(x,{sx:{flex:`0 0 auto`,justifyContent:`center`},children:(0,Y.jsx)(L,{onClick:()=>E(null),children:`Close`})})]})]}):(0,Y.jsx)(Wt,{})}var Ln=(0,G.memo)(In),Rn=[`matterbridge-`,`matterbridge-plugin-template`,`matterbridge-dyson`,`matterbridge-tuya`,`matterbridge-matter`,`matterbridge-automations`,`matterbridge-securitysystem`,`matterbridge-adapter`],zn=e=>e.replace(`git+`,``).replace(`.git`,``).trim(),Bn=e=>{let t=zn(e);return t.startsWith(`git://`)&&(t=`https://${t.slice(6)}`),t.startsWith(`ssh://git@github.com/`)&&(t=`https://github.com/${t.slice(21)}`),t.startsWith(`git@github.com:`)&&(t=`https://github.com/${t.slice(15).replace(`:`,`/`)}`),t},Vn=e=>{if(typeof e==`string`)return e.trim()||null;if(!e||typeof e!=`object`)return null;let t=e.url;return typeof t==`string`&&t.trim()||null},Hn=()=>{try{let e=window.localStorage.getItem(K.searchPluginsTotal);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t)){if(!e||!r||typeof r!=`object`)continue;let t=r;typeof t.total==`number`&&typeof t.asOf==`string`&&(n[e]={total:t.total,asOf:t.asOf})}return n}catch{return{}}},Un=e=>{try{window.localStorage.setItem(K.searchPluginsTotal,JSON.stringify(e))}catch{}},Wn=()=>{try{let e=window.localStorage.getItem(K.searchPluginsMeta);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t)){if(!e||!r||typeof r!=`object`)continue;let t=r;typeof t.asOf==`string`&&(n[e]={homepage:typeof t.homepage==`string`?t.homepage:null,help:typeof t.help==`string`?t.help:null,changelog:typeof t.changelog==`string`?t.changelog:null,asOf:t.asOf})}return n}catch{return{}}},Gn=e=>{try{window.localStorage.setItem(K.searchPluginsMeta,JSON.stringify(e))}catch{}},Kn=()=>{try{let e=window.localStorage.getItem(K.searchPluginsVersions);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t)){if(!e||!r||typeof r!=`object`)continue;let t=r;typeof t.asOf==`string`&&Array.isArray(t.versions)&&(n[e]={versions:t.versions.filter(e=>typeof e==`string`),asOf:t.asOf})}return n}catch{return{}}},qn=e=>{try{window.localStorage.setItem(K.searchPluginsVersions,JSON.stringify(e))}catch{}},Jn=({open:e,onClose:t,onSelect:n,onVersions:r})=>{let{mobile:i}=(0,G.useContext)(Vt),[a,o]=(0,G.useState)(``),s=(0,G.useRef)(``),c=(0,G.useRef)(!1),l=(0,G.useRef)(null),[u,d]=(0,G.useState)([]),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(!1),[_,y]=(0,G.useState)(!1),[b,S]=(0,G.useState)({done:0,total:0}),[C,w]=(0,G.useState)(null),E=(0,G.useRef)({}),O=()=>{let e=document.activeElement;e&&e instanceof HTMLElement&&e.blur()},k=e=>`${e.getFullYear().toString()}-${(e.getMonth()+1).toString().padStart(2,`0`)}-${e.getDate().toString().padStart(2,`0`)}`,A=(0,G.useCallback)(async(e,t)=>{let n=E.current[e];if(n&&n.asOf===t&&Array.isArray(n.versions)&&n.versions.length>0&&n.versions[0]===`latest`)return q&&console.log(`[SearchPluginsDialog] versions cache hit for ${e} (${n.versions.length.toString()})`),n.versions;n&&n.asOf===t&&n.versions.length>0&&n.versions[0]!==`latest`&&q&&console.log(`[SearchPluginsDialog] versions cache ignored (old format) for ${e} (asOf=${t})`);let r=`https://registry.npmjs.org/${encodeURIComponent(e)}`;q&&console.log(`[SearchPluginsDialog] fetching versions for ${e} from: ${r}`);let i=await fetch(r,{signal:l.current?.signal});if(!i.ok)return q&&console.log(`[SearchPluginsDialog] versions fetch failed for ${e}: ${i.status.toString()} ${i.statusText}`),[];let a=await i.json(),o=Object.keys(a.versions??{}),s=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`});o.sort((e,t)=>s.compare(e,t)).reverse();let c=a[`dist-tags`]??{},u=typeof c?.dev==`string`&&String(c.dev).trim().length>0,d=o.slice(0,20),f=[`latest`];return u&&f.push(`dev`),f.push(...d),q&&console.log(`[SearchPluginsDialog] fetched versions for ${e} (tags: latest${u?`, dev`:``}; latestVersions=${d.length.toString()}; allVersions=${o.length.toString()}):`,f),E.current[e]={versions:f,asOf:t},qn(E.current),f},[]),j=e=>new Intl.NumberFormat().format(e),M=[{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:e=>typeof e==`number`?j(e):``},{label:`Total`,id:`total`,align:`right`,maxWidth:120,render:e=>typeof e==`number`?j(e):``},{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:(e,t,n,r)=>(0,Y.jsxs)(`div`,{style:{margin:`0`,padding:`0`,gap:`4px`,display:`flex`,flexDirection:`row`,justifyContent:`center`},children:[(0,Y.jsx)(H,{title:n.homepage?`Open the plugin homepage`:`No homepage available`,children:(0,Y.jsx)(`span`,{children:(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`var(--main-icon-color)`},disabled:!n.homepage,onClick:e=>{if(e.stopPropagation(),n.homepage)try{let e=new URL(n.homepage);(e.protocol===`http:`||e.protocol===`https:`)&&window.open(e.toString(),`_blank`)}catch{}},size:`small`,children:(0,Y.jsx)(ce,{})})})}),(0,Y.jsx)(H,{title:n.help?`Open the plugin help`:`No help available`,children:(0,Y.jsx)(`span`,{children:(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`var(--main-icon-color)`},disabled:!n.help,onClick:e=>{if(e.stopPropagation(),n.help)try{let e=new URL(n.help);(e.protocol===`http:`||e.protocol===`https:`)&&window.open(e.toString(),`_blank`)}catch{}},size:`small`,children:(0,Y.jsx)(g,{})})})}),(0,Y.jsx)(H,{title:n.changelog?`Open the plugin changelog`:`No changelog available`,children:(0,Y.jsx)(`span`,{children:(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`var(--main-icon-color)`},disabled:!n.changelog,onClick:e=>{if(e.stopPropagation(),n.changelog)try{let e=new URL(n.changelog);(e.protocol===`http:`||e.protocol===`https:`)&&window.open(e.toString(),`_blank`)}catch{}},size:`small`,children:(0,Y.jsx)(v,{})})})})]})}];(0,G.useEffect)(()=>{if(!e){c.current=!1,s.current=``,l.current?.abort(),l.current=null,d([]),p(!1),h(!1),y(!1),S({done:0,total:0}),w(null),o(``);return}if(c.current)return;c.current=!0;let t=new AbortController;return l.current=t,E.current=Kn(),(async()=>{let e=`matterbridge-`,n=e=>new Promise(t=>setTimeout(t,e)),r=e=>{if(!Array.isArray(e.downloads))return null;let t=0,n=!1;for(let r of e.downloads)typeof r?.downloads==`number`&&(t+=r.downloads,n=!0);return n?t:null};try{p(!0),w(null);let i=e=>{let t=String(e??``).trim().toLowerCase();return t?!!(t===`github actions`||t===`github-actions`||t===`github-actions[bot]`||t.includes(`github-actions`)||t.endsWith(`[bot]`)):!1},a=e=>{let t=(e.maintainers??[]).map(e=>(e.username??``).trim()).filter(Boolean),n=(e.publisher?.username??``).trim();return t.find(e=>!i(e))||(n&&!i(n)?n:t[0]??n??``)},o=await fetch(`https://registry.npmjs.org/-/v1/search?text=matterbridge-&size=250`,{signal:t.signal});if(!o.ok)throw Error(`npm registry request failed: ${o.status} ${o.statusText}`);let s=await o.json(),c=`luligu`,l=e=>e.publisher?.username?.toLowerCase()===c||(e.maintainers??[]).some(e=>e.username?.toLowerCase()===c),u=(s.objects??[]).filter(e=>!!e?.package&&typeof e.package.name==`string`).filter(t=>t.package?.name?.startsWith(e)).filter(e=>!Rn.includes(e.package?.name??``)).sort((e,t)=>{let n=l(e.package??{});return n===l(t.package??{})?(e.package?.name??``).localeCompare(t.package?.name??``):n?-1:1}).map(e=>{let t=e.package,n=t.name??``,r=a(t),i=typeof e.downloads?.monthly==`number`?e.downloads.monthly:null,o=(t.links?.npm??``).trim(),s=((t.links?.homepage??``).trim()||o||(n?`https://www.npmjs.com/package/${encodeURIComponent(n)}`:``)).trim()||null;return{name:n,version:t.version??``,downloads:i,total:null,description:t.description??``,author:r,official:l(t),homepage:s,help:null,changelog:null}}),f=k(new Date),m=Hn(),h=Wn();d(u.map(e=>{let t=m[e.name];return!t||typeof t.total!=`number`?e:(q&&console.log(`[SearchPluginsDialog] total downloads loaded from cache for ${e.name} (asOf=${t.asOf}):`,t.total),{...e,total:t.total})}).map(e=>{let t=h[e.name];if(!t||t.asOf!==f)return e;let n=t.homepage??e.homepage,r=t.help,i=t.changelog;return q&&(r||i||n&&n!==e.homepage)&&console.log(`[SearchPluginsDialog] metadata loaded from cache for ${e.name} (asOf=${t.asOf}):`,{homepage:n,help:r,changelog:i}),{...e,homepage:n,help:r,changelog:i}}));let g=u.map(e=>e.name).filter(e=>{let t=E.current[e];return!t||t.asOf!==f||t.versions.length===0});q&&console.log(`[SearchPluginsDialog] versions prefetch queue (${g.length.toString()}):`,g);let _=0,v=async()=>{for(;_<g.length;){if(t.signal.aborted)return;let e=_;_+=1;let r=g[e];if(r)try{let e=await A(r,f);q&&e.length>0&&console.log(`[SearchPluginsDialog] versions fetched for ${r} (${e.length.toString()}):`,e.slice(0,5))}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return}finally{t.signal.aborted||await n(200)}}};Promise.all(Array.from({length:Math.min(1,u.length)},()=>v()));let b=u.map(e=>e.name).filter(e=>{let t=h[e],n=!!t&&t.asOf===f,r=!!t&&!!t.help&&!!t.changelog,i=!n||!r;return!i&&q&&console.log(`[SearchPluginsDialog] metadata fetch skipped (cache fresh+complete) for ${e} (asOf=${t.asOf}).`),n&&!r&&q&&console.log(`[SearchPluginsDialog] metadata fetch forced (cache incomplete) for ${e} (asOf=${t.asOf}).`),i}),x=new Set(b),C=async(e,n)=>{let r=`https://registry.npmjs.org/${encodeURIComponent(e)}/latest`;try{let e=await fetch(r,{signal:t.signal});if(!e.ok)return null;let i=await e.json(),a=typeof i.homepage==`string`&&i.homepage.includes(`http`)?zn(i.homepage):null,o=typeof i.help==`string`&&i.help.startsWith(`http`)?i.help.trim():null,s=typeof i.changelog==`string`&&i.changelog.startsWith(`http`)?i.changelog.trim():null,c=Vn(i.repository),l=c?Bn(c):null,u=l&&l.includes(`http`)?l:null,d=a||u||n||null;return{homepage:d,help:o||(u?`${u}/blob/main/README.md`:null)||d||null,changelog:s||(u?`${u}/blob/main/CHANGELOG.md`:null)||d||null}}catch(e){return e instanceof DOMException&&e.name,null}},T=0,D=async()=>{for(;T<b.length;){if(t.signal.aborted)return;let e=T;T+=1;let r=b[e];if(!r||!x.has(r))continue;x.delete(r);let i=await C(r,u.find(e=>e.name===r)?.homepage??null);if(t.signal.aborted)return;i&&(d(e=>e.map(e=>e.name===r?{...e,homepage:i.homepage??e.homepage,help:i.help,changelog:i.changelog}:e)),h[r]={homepage:i.homepage,help:i.help,changelog:i.changelog,asOf:f},Gn(h)),t.signal.aborted||await n(250)}};Promise.all(Array.from({length:Math.min(1,u.length)},()=>D()));let O=`2020-01-01`,j=u.map(e=>e.name).filter(e=>{let t=m[e],n=!t||t.asOf!==f;return n||q&&console.log(`[SearchPluginsDialog] total downloads fetch skipped (cache fresh) for ${e} (asOf=${t.asOf}).`),n}),M=new Set(j),N=j.length;S({done:0,total:N}),y(N>0);let P=async e=>{let i=`https://api.npmjs.org/downloads/range/${O}:${f}/${encodeURIComponent(e)}`;for(let e=0;e<3;e+=1){let a=await fetch(i,{signal:t.signal});if(a.ok)return r(await a.json());if(a.status===404)return null;if(a.status===429){let t=a.headers.get(`retry-after`),r=t?Number(t):NaN;await n(Number.isFinite(r)?r*1e3:2e3*(e+1));continue}return null}return null},ee=0,F=0,te=async()=>{for(;ee<j.length;){if(t.signal.aborted)return;let e=ee;ee+=1;let r=j[e];if(r&&M.has(r)){M.delete(r);try{q&&console.log(`[SearchPluginsDialog] fetching total downloads for ${r} (range ${O}:${f})...`);let e=await P(r);if(t.signal.aborted)return;q&&console.log(`[SearchPluginsDialog] total downloads fetched for ${r}:`,e),d(t=>t.map(t=>t.name===r?{...t,total:e}:t)),typeof e==`number`&&(m[r]={total:e,asOf:f},Un(m),q&&console.log(`[SearchPluginsDialog] total downloads saved to localStorage for ${r} (asOf=${f}):`,e))}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return}finally{F+=1,S({done:F,total:N}),t.signal.aborted||await n(500)}}}};Promise.all(Array.from({length:Math.min(1,u.length)},()=>te())).finally(()=>{t.signal.aborted||y(!1)}),q&&console.log(`[SearchPluginsDialog] npm packages starting with "${e}" (filtered/sorted):`,u)}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;console.error(`[SearchPluginsDialog] npm registry fetch error:`,e),w(e instanceof Error?e.message:String(e))}finally{p(!1)}})(),()=>t.abort()},[e,A]);let N=async()=>{O();let e=s.current||a;if(!(!e||m))try{h(!0);let t=await A(e,k(new Date));q&&console.log(`[SearchPluginsDialog] passing versions to onVersions() for ${e} (${t.length.toString()}):`,t),r(t),h(!1),n(e)}catch(t){if(t instanceof DOMException&&t.name===`AbortError`)return;console.error(`[SearchPluginsDialog] npm versions fetch error:`,t),r([]),h(!1),n(e)}},P=()=>{O(),t(),r([])},ee=u.reduce((e,t)=>e+(typeof t.downloads==`number`?t.downloads:0),0),te=u.reduce((e,t)=>(typeof t.total==`number`&&(e.total+=t.total,e.hasAny=!0),e),{total:0,hasAny:!1}),I=_?` Totals: ${b.done.toString()}/${b.total.toString()} fetched`:``,ne=te.hasAny?j(te.total):`...`;return(0,Y.jsxs)(D,{open:e,onClose:()=>{O(),t()},maxWidth:!1,fullWidth:!0,slotProps:{paper:{sx:{width:J&&i?`100vw`:`75vw`,height:J&&i?`100vh`:`75vh`,maxWidth:J&&i?`100vw`:`75vw`,maxHeight:J&&i?`100vh`:`75vh`,margin:J&&i?`0px`:void 0,display:`flex`,flexDirection:`column`}}},children:[(0,Y.jsx)(F,{children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h4`,{style:{margin:0},children:`Search Plugins`})]})}),(0,Y.jsx)(re,{dividers:!0,sx:{padding:`10px`,flex:`1 1 auto`,minHeight:0},children:(0,Y.jsx)(`div`,{style:{height:`100%`,width:`100%`,display:`flex`,flexDirection:`column`,minHeight:0},children:f?(0,Y.jsx)(`div`,{style:{padding:`20px`},children:`Loading npm registry...`}):C?(0,Y.jsx)(`div`,{style:{padding:`20px`},children:C}):(0,Y.jsx)(Sn,{name:`Search plugins`,rows:u,columns:M,getRowKey:`name`,onRowClick:(e,t,n)=>{s.current=e.name,o(e.name),n.detail===2&&N()},footerLeft:`Total packages: ${u.length.toString()} Total downloads: ${j(ee)} / ${ne}${I}`,footerRight:a?`Selected: ${a}`:``})})}),(0,Y.jsxs)(x,{sx:{justifyContent:`center`,gap:1.5,flexWrap:`wrap`},children:[(0,Y.jsx)(H,{title:`Select the plugin and close the dialog. Double-click a row to select and close the dialog.`,children:(0,Y.jsx)(L,{variant:`contained`,onClick:N,disabled:!(s.current||a)||m,children:`Select`})}),(0,Y.jsx)(H,{title:`Close the dialog without selecting a plugin.`,children:(0,Y.jsx)(L,{onClick:P,children:`Cancel`})})]})]})};function Yn(){let{mobile:e,showSnackbarMessage:t}=(0,G.useContext)(Vt),{logMessage:n,sendMessage:r,getUniqueId:i}=(0,G.useContext)(X),[a,o]=(0,G.useState)(`matterbridge-`),[s,c]=(0,G.useState)([`latest`,`dev`]),[l,d]=(0,G.useState)(`latest`),[f,p]=(0,G.useState)(!1),m=(0,G.useRef)(i()),h=e=>{let t=(e??``).trim();if(!t)return{name:``,specifier:null};if(t.startsWith(`@`)){let e=t.lastIndexOf(`@`);if(e>0){let n=t.slice(0,e),r=t.slice(e+1);if(n.includes(`/`)&&r)return{name:n,specifier:r}}return{name:t,specifier:null}}let n=t.indexOf(`@`);if(n>0){let e=t.slice(0,n),r=t.slice(n+1);return r?{name:e,specifier:r}:{name:e,specifier:null}}return{name:t,specifier:null}},g=()=>{let{name:e,specifier:t}=h(a);return e?t?`${e}@${t}`:l?`${e}@${l}`:e:``},_=e=>{e.preventDefault(),p(!0)},v=()=>{p(!1)},y=e=>{e.preventDefault(),p(!1);let t=e.dataTransfer.files[0];if(t){n(`Plugins`,`Installing package ${t.name}. Please wait...`);let e=new FormData;e.append(`file`,t),e.append(`filename`,t.name),fetch(`./api/uploadpackage`,{method:`POST`,body:e}).then(e=>e.text()).then(e=>{n(`Plugins`,`Server response: ${e}`)}).catch(e=>{console.error(`Error uploading plugin file:`,e),n(`Plugins`,`Error installing package ${e}`)})}},b=e=>{let t=e.target.files&&e.target.files[0];if(t){n(`Plugins`,`Uploading package ${t.name}`);let e=new FormData;e.append(`file`,t),e.append(`filename`,t.name),fetch(`./api/uploadpackage`,{method:`POST`,body:e}).then(e=>e.text()).then(e=>{n(`Plugins`,`Server response: ${e}`)}).catch(e=>{console.error(`Error uploading plugin file:`,e),n(`Plugins`,`Error uploading package ${e}`)})}},x=()=>{let e=g();if(e){if(Rn.includes(e.split(`@`)[0])){t(`Installation of plugin "${e}" is blocked by the ignore list.`);return}r({id:m.current,sender:`InstallPlugins`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:e,restart:!1}})}},S=()=>{r({id:m.current,sender:`InstallPlugins`,method:`/api/uninstall`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:a}})},C=()=>{document.getElementById(`file-upload`)?.click()},w=()=>{if(Rn.includes(a.split(`@`)[0])){t(`Addition of plugin "${a}" is blocked by the ignore list.`);return}r({id:m.current,sender:`InstallPlugins`,method:`/api/addplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginNameOrPath:a}})},E=e=>{e.preventDefault(),q&&console.log(`Right-clicked Upload button`)},D=e=>{e.preventDefault(),q&&console.log(`Right-clicked Add button`)},[O,k]=(0,G.useState)(!1),A=()=>{k(!0),q&&console.log(`Dialog opened for selection`)},j=()=>{o(`matterbridge-`),k(!1),q&&console.log(`Dialog closed without selection`)},M=e=>{o(e),k(!1),q&&console.log(`Select plugin:`,e)},P=e=>{c(e),d(e.includes(`latest`)?`latest`:e[0]??``),q&&console.log(`Select plugin versions:`,e)},[ee,F]=(0,G.useState)(!1);return q&&console.log(`HomeInstallAddPlugins rendering...`),ee?null:(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(Gt,{children:[(0,Y.jsx)(Kt,{children:`Install plugins`}),(0,Y.jsx)(Zt,{close:()=>F(!0)})]}),(0,Y.jsxs)(Xt,{onDragOver:_,onDragLeave:v,onDrop:y,style:J&&e?{flexWrap:`wrap`,alignItems:`center`,gap:`10px`}:{flexWrap:`wrap`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(Jn,{open:O,onClose:j,onSelect:M,onVersions:P}),(0,Y.jsxs)(`div`,{style:{flex:`1 1 auto`,display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(H,{title:`Provide the npm name or the local path of the plugin to install, uninstall, or add`,children:(0,Y.jsx)(B,{value:a,onChange:e=>{let t=e.target.value;c([`latest`,`dev`]),d(`latest`),o(t)},size:`small`,id:`plugin-name`,label:`Plugin name or plugin path`,variant:`outlined`,fullWidth:!0})}),s.length>0&&(0,Y.jsx)(H,{title:`Select the npm tag/version to install`,children:(0,Y.jsx)(`span`,{children:(0,Y.jsxs)(Fe,{size:`small`,style:{minWidth:`150px`},children:[(0,Y.jsx)(le,{id:`plugin-version-label`,children:`Tag or version`}),(0,Y.jsx)(ye,{labelId:`plugin-version-label`,id:`plugin-version`,value:l,label:`Tag or version`,onChange:e=>d(e.target.value??``),sx:{"& .MuiSelect-icon":{color:`var(--main-label-color)`}},children:s.map(e=>(0,Y.jsx)(V,{value:e,children:e},e))})]})})}),(0,Y.jsx)(H,{title:`Search on npm the plugin to install`,children:(0,Y.jsx)(T,{size:`large`,onClick:A,children:(0,Y.jsx)(te,{fontSize:`inherit`})})})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(H,{title:`Install or update a plugin from npm`,children:(0,Y.jsxs)(L,{onClick:x,endIcon:(0,Y.jsx)(u,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Install`]})}),(0,Y.jsx)(H,{title:`Uninstall and remove a plugin`,children:(0,Y.jsxs)(L,{onClick:S,endIcon:(0,Y.jsx)(Pe,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Uninstall`]})}),(0,Y.jsx)(H,{title:`Upload and install a plugin from a tarball`,children:(0,Y.jsxs)(L,{onClick:C,onContextMenu:E,endIcon:(0,Y.jsx)(Ie,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Upload`]})}),(0,Y.jsx)(H,{title:`Add an already installed plugin or a plugin from a local path`,children:(0,Y.jsxs)(L,{onClick:w,onContextMenu:D,endIcon:(0,Y.jsx)(N,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:[` `,`Add`]})}),(0,Y.jsx)(`input`,{id:`file-upload`,type:`file`,accept:`.tgz`,style:{display:`none`},onChange:b})]})]})]})}var Xn=(0,G.memo)(Yn),Zn=()=>{let e=window;return`ontouchstart`in window||e.DocumentTouch!==void 0&&document instanceof e.DocumentTouch?(q&&console.log(`WebSocketLogs detectTouchscreen = true`),!0):(q&&console.log(`WebSocketLogs detectTouchscreen = false`),!1)};function Qn(){let{messages:e,logAutoScroll:t}=(0,G.useContext)(Ht),[n,r]=(0,G.useState)(!1),i=(0,G.useRef)(null),a=(0,G.useRef)(0),o=(0,G.useRef)(null),s=(0,G.useMemo)(()=>Zn(),[]),c=()=>r(!0),l=()=>r(!1);(0,G.useEffect)(()=>{if(q&&console.log(`WebSocketLogs logAutoScroll: ${t.current} isHovering: ${n}`),t.current&&!n&&!s){let e=Date.now();e-a.current>=500?(q&&console.log(`WebSocketLogs auto-scroll to bottom`),a.current=e,i.current?.scrollIntoView({behavior:`smooth`,block:`end`})):(q&&console.log(`WebSocketLogs auto-scroll skipped to avoid flicker`),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{i.current?.scrollIntoView({behavior:`smooth`}),a.current=Date.now()},1e3))}},[e,t,n,s]);let u=e=>{switch(e.toLowerCase()){case`debug`:return`gray`;case`info`:return`#267fb7`;case`notice`:return`green`;case`warn`:return`#e9db18`;case`error`:return`red`;case`fatal`:return`#ff0000`;case`spawn`:return`#ff00d0`;default:return`#5c0e91`}},d=e=>{switch(e.toLowerCase()){case`warn`:return`black`;default:return`white`}};return(0,Y.jsx)(`div`,{style:{margin:`0px`,padding:`0px`},onMouseEnter:c,onMouseLeave:l,children:(0,Y.jsxs)(`ul`,{style:{margin:`0px`,padding:`0px`},children:[e.map((e,t)=>(0,Y.jsxs)(`li`,{style:{wordWrap:`break-word`,maxHeight:`200px`,overflow:`hidden`},children:[(0,Y.jsx)(`span`,{style:{marginRight:`5px`,padding:`1px 5px`,backgroundColor:u(e.level),color:d(e.level),fontSize:`12px`,borderRadius:`3px`,textAlign:`center`},children:e.level}),e.time&&(0,Y.jsx)(`span`,{style:{marginRight:`3px`,color:`#505050`},children:`[`+e.time+`]`}),e.name&&(0,Y.jsx)(`span`,{style:{marginRight:`3px`,color:`#09516d`},children:`[`+e.name+`]`}),(0,Y.jsx)(`span`,{style:{color:`var(--main-log-color)`},children:e.message})]},t)),(0,Y.jsx)(`div`,{ref:i})]})})}var $n=(0,G.memo)(Qn);function er(){let[e,t]=(0,G.useState)(localStorage.getItem(K.logFilterLevel)??`info`),[n,r]=(0,G.useState)(localStorage.getItem(K.logFilterSearch)??`*`),{online:i,logAutoScroll:a}=(0,G.useContext)(X);return q&&console.log(`HomeLogs rendering...`),i?(0,Y.jsxs)(Q,{style:{flex:`1 1 auto`},children:[(0,Y.jsxs)(Gt,{children:[(0,Y.jsx)(Kt,{children:`Logs`}),(0,Y.jsxs)(Kt,{style:{fontWeight:`normal`,fontSize:`12px`,marginTop:`2px`},children:[`Filter: logger level "`,e,`" and search "`,n===``?`*`:n,`" Scroll: `,a.current?`auto`:`manual`]})]}),(0,Y.jsx)(Xt,{style:{flex:`1 1 auto`,overflow:`auto`,margin:`0px`,padding:`10px`,alignItems:`start`},children:(0,Y.jsx)($n,{})})]}):(0,Y.jsx)(Wt,{})}var tr=(0,G.memo)(er);function nr(e){return e.id!==0&&e.src===`Matterbridge`&&e.dst===`Frontend`}var rr={fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},ir={fontSize:`12px`,fontWeight:`normal`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},ar={fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`},or={fontSize:`14px`,fontWeight:`normal`,color:`var(--secondary-color)`,backgroundColor:`var(--div-bg-color)`},sr={fontSize:`16px`,fontWeight:`bold`,backgroundColor:`var(--div-bg-color)`},cr={padding:`0px`,margin:`0px`},lr=`5px 10px 5px 10px`,ur={},dr={},fr={},pr={},mr=[],hr=[],gr=[];function _r(e,t){let n=e?.properties;if(!n||typeof n!=`object`)return!1;let r=n[t];return!r||typeof r!=`object`?!1:typeof r.type==`string`}function vr(e){let t=e.items;return t!==void 0&&typeof t==`object`&&!Array.isArray(t)}function yr(e,t){let n=e?.properties;if(!n||typeof n!=`object`)return!1;let r=n[t];if(!r||typeof r!=`object`||r.type!==`array`||r.uniqueItems!==!0)return!1;let i=r.items;return i!==void 0&&typeof i==`object`&&!Array.isArray(i)&&Array.isArray(i.enum)}var br=({open:e,onClose:t,plugin:n})=>{let{sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,G.useContext)(X),s=(0,G.useRef)(o()),c=(0,G.useRef)({}),l=(0,G.useRef)({}),[u,d]=(0,G.useState)(n.configJson),[f,m]=(0,G.useState)(n.schemaJson),[g,_]=(0,G.useState)({"ui:submitButtonOptions":{submitText:`Confirm`},"ui:globalOptions":{orderable:!0}}),v=(0,G.useRef)(``),y=n.configJson;(0,G.useEffect)(()=>{let e=e=>{e.src===`Matterbridge`&&e.dst===`Frontend`&&(nr(e)&&e.id===s.current&&e.method===`/api/select/devices`&&e.response&&(q&&console.log(`ConfigPluginDialog (id: ${e.id}) received ${e.response.length} /api/select/devices:`,e.response),hr=e.response),nr(e)&&e.id===s.current&&e.method===`/api/select/entities`&&e.response&&(q&&console.log(`ConfigPluginDialog (id: ${e.id}) received ${e.response.length} /api/select/entities:`,e.response),gr=e.response))};if(i(e,s.current),q&&console.log(`ConfigPluginDialog added WebSocket listener id:`,s.current),q&&console.log(`ConfigPluginDialog mounting...`),q&&console.log(`ConfigPluginDialog mounting with form:`,u),q&&console.log(`ConfigPluginDialog mounting with schema:`,f),q&&console.log(`ConfigPluginDialog mounting with uiSchema:`,g),u&&f&&f.properties){let e=(t,n,r=[])=>{!t||typeof t!=`object`||(t.properties&&Object.keys(t.properties).forEach(i=>{let a=t.properties?.[i],o=[...r,i];Object.keys(a).forEach(e=>{if(e.startsWith(`ui:`)){let t=n;o.forEach(e=>{t[e]||(t[e]={}),t=t[e]}),t[e]=a[e],delete a[e]}}),e(a,n,o)}),[`oneOf`,`anyOf`,`allOf`].forEach(i=>{Array.isArray(t[i])&&t[i].forEach(t=>{e(t,n,r)})}),t.items&&typeof t.items==`object`&&e(t.items,n,r))};e(f,g),_(g),c.current=f,l.current=g}return n.name&&n.configJson&&n.schemaJson&&(d(n.configJson),m(n.schemaJson),r({id:s.current,sender:`ConfigPlugin`,method:`/api/select/devices`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:n.name}}),r({id:s.current,sender:`ConfigPlugin`,method:`/api/select/entities`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:n.name}}),q&&console.log(`HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:`,n.name)),()=>{a(e),q&&console.log(`ConfigPluginDialog removed WebSocket listener`)}},[i,u,n,a,f,r,g]);let b=(e,t)=>{y=e.formData},S=e=>{q&&console.log(`ConfigPluginDialog handleSaveChanges:`,e.formData),d(e.formData),n.configJson=e.formData,n.restartRequired=!0,r({id:s.current,sender:`ConfigPlugin`,method:`/api/savepluginconfig`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.formData.name,formData:e.formData}}),t()};function C(e){let{id:t,label:n,onKeyRenameBlur:r,onRemoveProperty:i,disabled:a,schema:o,children:s,registry:c,readonly:l,required:u}=e,{templates:d}=c,{RemoveButton:f}=d.ButtonTemplates,p=Ct in o,m=(0,G.useRef)(null);return(0,G.useEffect)(()=>{let e=v.current;!p||e===``||!/^newKey(?:-\d+)?$/.test(n)||!m.current||(q&&console.log(`WrapIfAdditionalTemplate: renaming additional property "${n}" to "${e}"`),m.current.value=e,r({target:m.current}),v.current=``)},[p,n,r]),p?(0,Y.jsxs)(W,{sx:{display:`flex`,flexDirection:`row`,flexGrow:1,padding:0,margin:0,border:`none`},children:[(0,Y.jsx)(B,{id:`${t}-key`,name:`${t}-key`,required:u,disabled:a||l,defaultValue:n,inputRef:m,onBlur:l?void 0:r,type:`text`,variant:`outlined`,sx:{width:`250px`,minWidth:`250px`,maxWidth:`250px`,marginRight:`20px`}}),(0,Y.jsx)(W,{sx:{flex:1},children:s}),(0,Y.jsx)(f,{disabled:a||l,onClick:i,registry:c})]}):(0,Y.jsx)(W,{sx:{display:`flex`,flexDirection:`column`,flexGrow:1,padding:0,margin:0,border:`none`},children:s})}function w(e){let{children:t,description:n,displayLabel:r,errors:i,help:a,hidden:o,registry:s,uiSchema:c}=e,l=St(`WrapIfAdditionalTemplate`,s,xt(c));return o?(0,Y.jsx)(`div`,{style:{display:`none`},children:t}):(0,Y.jsx)(W,{sx:{display:`flex`,flexDirection:`column`,flexGrow:1,padding:0,margin:0,border:`none`},children:(0,Y.jsxs)(l,{...e,children:[r===!0&&n,t,i,a]})})}function E(e){let{description:t}=e;return t?(0,Y.jsx)(p,{sx:ir,children:t}):null}function O(e){let{required:t,title:n}=e;return n?(0,Y.jsx)(W,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:(0,Y.jsxs)(p,{sx:rr,children:[`Title `,n,` `,t&&(0,Y.jsx)(`mark`,{children:`***`})]})}):null}function k(e){let{help:t}=e;return t?(0,Y.jsx)(W,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:(0,Y.jsx)(p,{sx:or,children:t})}):null}function A(e){let{errors:t}=e;return t?(0,Y.jsxs)(W,{sx:{padding:`10px`,margin:`10px`,border:`1px solid grey`},children:[(0,Y.jsx)(p,{color:`error`,sx:sr,children:`Please fix the following errors:`}),(0,Y.jsx)(at,{children:t.map((e,t)=>(0,Y.jsxs)(se,{children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(Be,{color:`error`})}),(0,Y.jsx)(z,{primary:e.stack})]},t))})]}):null}function P(e){let{errors:t}=e;return t?(0,Y.jsx)(W,{sx:{padding:`0px`,margin:`0px`,marginTop:`5px`},children:t.map((e,t)=>(0,Y.jsxs)(p,{color:`error`,variant:`body2`,sx:{marginLeft:1},children:[`This field `,e]},t))}):null}function ee(e){let{id:t,name:n,_schema:r,_uiSchema:i,value:a,options:o,label:s,type:c,placeholder:l,required:u,disabled:d,readonly:f,autofocus:p,onChange:m,onChangeOverride:h,onBlur:g,onFocus:_,_rawErrors:v,_hideError:y,_registry:b,_formContext:x}=e;return(0,Y.jsx)(W,{sx:{padding:`0px`,margin:`0px`},children:(0,Y.jsx)(B,{id:t,name:t,label:l&&l!==``?s:void 0,variant:`outlined`,placeholder:l&&l!==``?l:s,required:u,disabled:d||f,autoFocus:p,value:a||a===0?a:``,type:c,autoComplete:c===`password`?`current-password`:n,onChange:h||(({target:{value:e}})=>m(e===``?o.emptyValue:e)),onBlur:({target:e})=>g(t,e&&e.value),onFocus:({target:e})=>_(t,e&&e.value),fullWidth:!0})})}function te(e){return console.log(`ArrayFieldTitleTemplate:`,e),null}function I(e){return console.log(`ArrayFieldDescriptionTemplate:`,e),null}function ne(e){let{buttonsProps:t,children:n}=e;return(0,Y.jsxs)(W,{sx:{margin:`2px 0px`,padding:`0px`,display:`flex`,alignItems:`center`},children:[(0,Y.jsx)(W,{sx:{flexGrow:1,marginRight:`10px`},children:n}),(0,Y.jsx)(T,{disabled:!t.hasMoveUp,onClick:t.onMoveUpItem,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(Te,{})}),(0,Y.jsx)(T,{disabled:!t.hasMoveDown,onClick:t.onMoveDownItem,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(Oe,{})}),t.hasRemove&&(0,Y.jsx)(T,{onClick:t.onRemoveItem,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(ke,{})})]})}function ie(e){let{canAdd:t,onAddClick:n,schema:r,title:i,formData:a}=e,[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(!1),[f,m]=(0,G.useState)(``),g=e=>{m(e.target.value)},_=()=>{q&&console.log(`ArrayFieldTemplate: handleDialogDeviceToggle filter:`,f,`selectDevices:`,hr),s(!o)},v=()=>{q&&console.log(`ArrayFieldTemplate: handleDialogEntityToggle filter:`,f,`selectEntities:`,gr),l(!c)},y=()=>{q&&console.log(`ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:`,f,`selectDevices:`,hr),d(!u)},b=e=>{s(!1),r.selectFrom===`serial`&&vr(r)?r.items.default=e.serial:r.selectFrom===`name`&&vr(r)&&(r.items.default=e.name),n()},S=e=>{l(!1),r.selectEntityFrom===`name`&&vr(r)?r.items.default=e.name:r.selectEntityFrom===`description`&&vr(r)&&(r.items.default=e.description),n()},C=e=>{d(!1),r.selectDeviceEntityFrom===`name`&&vr(r)?r.items.default=e.name:r.selectDeviceEntityFrom===`description`&&vr(r)&&(r.items.default=e.description),n()};return(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:`5px 10px 5px 10px`,border:`1px solid grey`},children:[i&&(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:`0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[i&&(0,Y.jsx)(p,{sx:rr,children:i}),t&&(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:`0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[r.selectFrom&&(0,Y.jsx)(H,{title:`Add a device from the list`,children:(0,Y.jsx)(T,{onClick:_,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(et,{})})}),r.selectEntityFrom&&(0,Y.jsx)(H,{title:`Add an entity from the list`,children:(0,Y.jsx)(T,{onClick:v,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(et,{})})}),r.selectDeviceEntityFrom&&(0,Y.jsx)(H,{title:`Add a device entity from the list`,children:(0,Y.jsx)(T,{onClick:y,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(et,{})})}),(0,Y.jsx)(H,{title:`Add a new item`,children:(0,Y.jsx)(T,{onClick:n,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(N,{})})})]})]}),r.description&&(0,Y.jsx)(p,{sx:ir,children:r.description}),e.items,(0,Y.jsxs)(D,{open:o,onClose:_,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,Y.jsx)(F,{children:`Select a device`}),(0,Y.jsxs)(re,{children:[(0,Y.jsxs)(W,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,Y.jsx)(p,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,Y.jsx)(B,{fullWidth:!0,variant:`outlined`,value:f,onChange:g,placeholder:`Enter serial or name`})]}),(0,Y.jsx)(at,{dense:!0,children:hr.filter(e=>e.serial.toLowerCase().includes(f.toLowerCase())||e.name.toLowerCase().includes(f.toLowerCase())).filter(e=>!r.uniqueItems||!a.includes(r.selectFrom===`serial`?e.serial:e.name)).map((e,t)=>(0,Y.jsxs)(h,{onClick:()=>b(e),sx:ur,children:[e.icon===`wifi`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(j,{style:dr})}),e.icon===`ble`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(ve,{style:dr})}),e.icon===`hub`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ke,{style:dr})}),(0,Y.jsx)(z,{primary:e.name,secondary:e.serial,primaryTypographyProps:{style:fr},secondaryTypographyProps:{style:pr}})]},t))})]}),(0,Y.jsx)(x,{children:(0,Y.jsx)(L,{onClick:_,children:`Close`})})]}),(0,Y.jsxs)(D,{open:c,onClose:v,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,Y.jsx)(F,{children:`Select an entity`}),(0,Y.jsxs)(re,{children:[(0,Y.jsxs)(W,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,Y.jsx)(p,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,Y.jsx)(B,{fullWidth:!0,variant:`outlined`,value:f,onChange:g,placeholder:`Enter name or description`})]}),(0,Y.jsx)(at,{dense:!0,children:gr.filter(e=>e.name.toLowerCase().includes(f.toLowerCase())||e.description.toLowerCase().includes(f.toLowerCase())).filter(e=>!r.uniqueItems||!a.includes(r.selectEntityFrom===`name`?e.name:e.description)).map((e,t)=>(0,Y.jsxs)(h,{onClick:()=>S(e),sx:ur,children:[e.icon===`wifi`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(j,{style:dr})}),e.icon===`ble`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(ve,{style:dr})}),e.icon===`hub`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ke,{style:dr})}),e.icon===`component`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Re,{style:dr})}),e.icon===`matter`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ae,{style:dr})}),(0,Y.jsx)(z,{primary:e.name,secondary:e.description,primaryTypographyProps:{style:fr},secondaryTypographyProps:{style:pr}})]},t))})]}),(0,Y.jsx)(x,{children:(0,Y.jsx)(L,{onClick:v,children:`Close`})})]}),(0,Y.jsxs)(D,{open:u,onClose:y,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,Y.jsxs)(F,{children:[`Select an entity for `,i]}),(0,Y.jsx)(re,{children:(0,Y.jsx)(at,{dense:!0,children:hr.filter(e=>e.serial===i||e.name===i).map(e=>e.entities?.filter(e=>!r.uniqueItems||!Array.isArray(a)||!a.includes(r.selectDeviceEntityFrom===`name`?e.name:e.description)).map((e,t)=>(0,Y.jsxs)(h,{onClick:()=>C(e),sx:ur,children:[e.icon===`wifi`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(j,{style:dr})}),e.icon===`ble`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(ve,{style:dr})}),e.icon===`hub`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ke,{style:dr})}),e.icon===`component`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Re,{style:dr})}),e.icon===`matter`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ae,{style:dr})}),(0,Y.jsx)(z,{primary:e.name,secondary:e.description,primaryTypographyProps:{style:fr},secondaryTypographyProps:{style:pr}})]},t)))})}),(0,Y.jsx)(x,{children:(0,Y.jsx)(L,{onClick:y,children:`Close`})})]})]})}function ae(e){let{onAddProperty:t,schema:n,properties:r,title:i,description:a}=e,[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(``),u=e=>{l(e.target.value)},d=()=>{s(!o)},f=e=>{q&&console.log(`ObjectFieldTemplate: handleSelectValue value "${e.serial}" for schema "${n.selectFrom}"`),s(!1);let r=``;n.selectFrom===`serial`?r=e.serial:n.selectFrom===`name`&&(r=e.name),v.current=r,q&&console.log(`ObjectFieldTemplate: handleSelectValue pendingAdditionalPropertyKey "${r}"`),t()},m=()=>{t()},g=!n.additionalProperties;return q&&console.log(`ObjectFieldTemplate: isRoot ${g} pendingAdditionalPropertyKey "${v.current}"`),(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:g?`10px`:`5px 10px 0px 10px`,border:g?`none`:`1px solid grey`},children:[n.title&&g&&(0,Y.jsx)(W,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`,marginBottom:`10px`},children:(0,Y.jsx)(p,{sx:rr,children:n.title})}),i&&!g&&(0,Y.jsxs)(W,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`},children:[(0,Y.jsx)(p,{sx:rr,children:i}),(0,Y.jsxs)(W,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,padding:`0px`,margin:`0px`},children:[n.selectFrom&&(0,Y.jsx)(H,{title:`Add a device from the list`,children:(0,Y.jsx)(T,{onClick:d,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(et,{})})}),(0,Y.jsx)(H,{title:`Add a new item`,children:(0,Y.jsx)(T,{onClick:m,size:`small`,color:`primary`,sx:cr,children:(0,Y.jsx)(N,{})})})]})]}),n.description&&(0,Y.jsx)(W,{sx:{padding:`0px`,margin:`0px`,marginBottom:`10px`},children:(0,Y.jsx)(p,{sx:ir,children:n.description})}),r.map(({content:e,name:t,hidden:r})=>{if(r)return null;let i=_r(n,t),a=yr(n,t),o=i&&[`object`,`array`].includes(n.properties[t].type);return(0,Y.jsxs)(W,{sx:{margin:`0px`,marginBottom:`10px`,padding:o&&!a?`0px`:lr,border:o&&!a?`none`:`1px solid grey`},children:[i&&![`object`,`array`,`boolean`].includes(n.properties[t].type)&&(0,Y.jsx)(p,{sx:rr,children:n.properties[t].title||t}),a&&(0,Y.jsx)(p,{sx:rr,children:n.properties[t].title||t}),(0,Y.jsx)(W,{sx:{flexGrow:1,padding:`0px`,margin:`0px`},children:e})]},t)}),(0,Y.jsxs)(D,{open:o,onClose:d,PaperProps:{sx:{maxHeight:`50vh`,maxWidth:`50vw`,overflow:`auto`}},children:[(0,Y.jsx)(F,{children:`Select a device`}),(0,Y.jsxs)(re,{children:[(0,Y.jsxs)(W,{sx:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`,marginBottom:`10px`},children:[(0,Y.jsx)(p,{variant:`subtitle1`,sx:{whiteSpace:`nowrap`},children:`Filter by:`}),(0,Y.jsx)(B,{fullWidth:!0,variant:`outlined`,value:c,onChange:u,placeholder:`Enter serial or name`})]}),(0,Y.jsx)(at,{dense:!0,children:hr.filter(e=>e.serial.toLowerCase().includes(c.toLowerCase())||e.name.toLowerCase().includes(c.toLowerCase())).map((e,t)=>(0,Y.jsxs)(h,{onClick:()=>f(e),sx:ur,children:[e.icon===`wifi`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(j,{style:dr})}),e.icon===`ble`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(ve,{style:dr})}),e.icon===`hub`&&(0,Y.jsx)(U,{children:(0,Y.jsx)(Ke,{style:dr})}),(0,Y.jsx)(z,{primary:e.name,secondary:e.serial,primaryTypographyProps:{style:fr},secondaryTypographyProps:{style:pr}})]},t))})]}),(0,Y.jsx)(x,{children:(0,Y.jsx)(L,{onClick:d,children:`Close`})})]})]})}function oe(e){let{uiSchema:n}=e,{submitText:r,norender:i}=bt(n);return i?null:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,margin:`10px`,padding:`0px`,gap:`20px`},children:[(0,Y.jsx)(L,{type:`submit`,variant:`contained`,color:`primary`,children:r}),(0,Y.jsx)(L,{variant:`contained`,color:`primary`,onClick:t,children:`Cancel`})]})}function ce(e){let{className:t,disabled:n,onClick:r,registry:i,style:a,uiSchema:o,...s}=e;return(0,Y.jsx)(H,{title:`Remove the item`,children:(0,Y.jsx)(T,{disabled:n,size:`small`,color:`primary`,onClick:r,children:(0,Y.jsx)(ke,{})})})}function le(e){let{className:t,disabled:n,onClick:r,registry:i,uiSchema:a,...o}=e;return(0,Y.jsx)(H,{title:`Add an item`,children:(0,Y.jsx)(T,{size:`small`,color:`primary`,onClick:r,children:(0,Y.jsx)(N,{})})})}function ue(e){let{disabled:t,onClick:n,registry:r,style:i,uiSchema:a,...o}=e;return(0,Y.jsx)(H,{title:`Move up the item`,children:(0,Y.jsx)(T,{size:`small`,color:`primary`,onClick:n,children:(0,Y.jsx)(Te,{})})})}function de(e){let{disabled:t,onClick:n,registry:r,style:i,uiSchema:a,...o}=e;return(0,Y.jsx)(H,{title:`Move down the item`,children:(0,Y.jsx)(T,{size:`small`,color:`primary`,onClick:n,children:(0,Y.jsx)(Oe,{})})})}function fe(e){let{id:i,name:a,value:o,schema:c,readonly:l,onChange:d}=e,[f,m]=(0,G.useState)(),h=e=>{q&&console.log(`CheckboxWidget ${a} onChangeField:`,e),m(e&&e!==``?e:void 0)},g=()=>{q&&console.log(`CheckboxWidget onClick plugin="${n.name}" action="${a}" value="${f}"`),r({id:s.current,sender:`ConfigPlugin`,method:`/api/action`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:n.name,action:a,value:f,formData:y,id:i}}),c.buttonClose===!0?t():c.buttonSave===!0&&S({formData:u})};return c.buttonText&&(c.title||c.description)?(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:`5px 0px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Y.jsx)(p,{sx:ar,children:c.title||c.description}),(0,Y.jsx)(L,{variant:`contained`,color:`primary`,onClick:()=>g(),children:c.buttonText})]}):c.buttonField&&(c.title||c.description)?(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:`5px 0px`,gap:`20px`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Y.jsx)(p,{sx:ar,children:c.title||c.description}),(0,Y.jsx)(B,{id:a+`-input`,name:a,label:c.textLabel,placeholder:c.textPlaceholder,onChange:e=>h(e.target.value),sx:{width:`250px`,minWidth:`250px`,maxWidth:`250px`}}),(0,Y.jsx)(L,{id:a+`-button`,variant:`contained`,color:`primary`,disabled:f===void 0,onClick:()=>g(),children:c.buttonField})]}):(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:`0px`},children:[a&&(0,Y.jsxs)(W,{sx:{margin:`0px`,padding:`0px`,gap:`10px`,display:`flex`,justifyContent:`flex-start`,alignItems:`center`},children:[(0,Y.jsx)(p,{sx:rr,children:c.title||a}),(0,Y.jsx)(M,{checked:o,readOnly:l,onChange:()=>d(!o),sx:{padding:`0px`,margin:`0px`}})]}),c.description&&(0,Y.jsx)(p,{sx:ir,children:c.description})]})}function pe({schema:e,id:t,name:n,options:r,label:i,hideLabel:a,required:o,disabled:s,placeholder:c,readonly:l,value:u,multiple:d,autofocus:f,onChange:p,onBlur:m,onFocus:h,errorSchema:g,rawErrors:_=mr,registry:v,uiSchema:y,hideError:b,...x}){let{enumOptions:S,enumDisabled:C,emptyValue:w}=r,T=d?[]:``,E=u===void 0||d&&u.length<1||!d&&u===T,D=({target:{value:e}})=>p(Dt(e,S,w)),O=({target:e})=>m(t,Dt(e&&e.value,S,w)),k=({target:e})=>h(t,Dt(e&&e.value,S,w)),A=Tt(u,S,d);return(0,Y.jsx)(B,{id:t,name:n,value:!E&&A!==void 0?A:T,required:o,disabled:s||l,autoFocus:f,error:_.length>0,onChange:D,onBlur:O,onFocus:k,select:!0,slotProps:{select:{multiple:d,...d?{renderValue:e=>!Array.isArray(e)||!Array.isArray(S)?``:e.map(e=>S[Number(e)]?.label).filter(e=>typeof e==`string`).join(`, `)}:{}}},"aria-describedby":Et(t),children:Array.isArray(S)&&S.map(({value:e,label:t},n)=>{let r=Array.isArray(C)&&C.indexOf(e)!==-1,i=Array.isArray(A)&&A.includes(String(n));return(0,Y.jsxs)(V,{value:String(n),disabled:r,children:[d&&(0,Y.jsx)(U,{sx:{minWidth:`32px`},children:(0,Y.jsx)(M,{checked:i,disableRipple:!0,tabIndex:-1,sx:{padding:`0px`,margin:`0px`}})}),t]},n)})})}return q&&console.log(`ConfigPluginDialog rendering...`),!e||!f||!u?null:(0,Y.jsxs)(D,{open:e,onClose:t,slotProps:{paper:{sx:{maxWidth:`800px`}}},children:[(0,Y.jsx)(F,{gap:`20px`,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h3`,{children:`Matterbridge plugin configuration`})]})}),(0,Y.jsx)(re,{style:{padding:`0px`,margin:`0px`,width:`800px`,height:`600px`,overflow:`auto`},children:(0,Y.jsx)(Ot,{schema:f,formData:u,uiSchema:g,validator:wt,templates:{FieldTemplate:w,BaseInputTemplate:ee,TitleFieldTemplate:O,DescriptionFieldTemplate:E,FieldHelpTemplate:k,FieldErrorTemplate:P,ErrorListTemplate:A,WrapIfAdditionalTemplate:C,ArrayFieldTitleTemplate:te,ArrayFieldDescriptionTemplate:I,ArrayFieldItemTemplate:ne,ArrayFieldTemplate:ie,ObjectFieldTemplate:ae,ButtonTemplates:{SubmitButton:oe,RemoveButton:ce,AddButton:le,MoveUpButton:ue,MoveDownButton:de}},widgets:{CheckboxWidget:fe,SelectWidget:pe},onChange:b,onSubmit:S})})]})};function xr({status:e,enabledText:t=`Enabled`,disabledText:n,tooltipText:r}){if(e===void 0)return null;{let i=(0,Y.jsx)(`div`,{className:e?`status-enabled`:`status-disabled`,style:{cursor:`default`},children:e?t:n??t});return r===void 0?i:(0,Y.jsx)(H,{title:r,children:i})}}function Sr({storeId:e,setStoreId:t}){let{online:n,sendMessage:r,addListener:i,removeListener:a,getUniqueId:o}=(0,G.useContext)(X),{mobile:s,showConfirmCancelDialog:c}=(0,G.useContext)(Vt),l=(0,G.useRef)(o()),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(null),[h,_]=(0,G.useState)([]),[y,b]=(0,G.useState)(null),S=[{label:`Name`,id:`name`,required:!0,render:(e,t,n,r)=>(0,Y.jsx)(H,{title:`Plugin path ${n.path}`,children:(0,Y.jsx)(`button`,{type:`button`,style:{cursor:`pointer`,background:`none`,border:`none`,padding:0,font:`inherit`,color:`inherit`,textAlign:`left`},onClick:()=>P(n),children:n.name})})},{label:`Description`,id:`description`,render:(e,t,n,r)=>(0,Y.jsx)(H,{title:`Open the plugin homepage`,children:(0,Y.jsx)(`button`,{type:`button`,style:{cursor:`pointer`,background:`none`,border:`none`,padding:0,font:`inherit`,color:`inherit`,textAlign:`left`},onClick:()=>P(n),children:n.description})})},{label:`Version`,id:`version`,render:(e,t,n,r)=>(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(H,{title:`Plugin v.${n.version}`,children:(0,Y.jsx)(`span`,{children:n.version.split(`-`)[0]+(n.version.includes(`-dev-`)?`@dev`:``)+(n.version.includes(`-git-`)?`@git`:``)})})})},{label:`Author`,id:`author`,render:(e,t,n,r)=>(0,Y.jsx)(Y.Fragment,{children:n.author?n.author.replace(`https://github.com/`,``):`Unknown`})},{label:`Type`,id:`type`,render:(e,t,n,r)=>(0,Y.jsx)(Y.Fragment,{children:n.type?n.type.replace(`Platform`,``):`Unknown`})},{label:`Devices`,id:`registeredDevices`},{label:`Actions`,id:`actions`,required:!0,noSort:!0,render:(e,n,r,i)=>(0,Y.jsxs)(`div`,{style:{margin:`0px`,padding:`0px`,gap:`4px`,display:`flex`,flexDirection:`row`},children:[f&&f.bridgeMode===`childbridge`&&!r.error&&r.enabled&&(0,Y.jsx)(H,{title:`Shows the QRCode or the fabrics`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:Pn(r.matter)},onClick:()=>{r.matter?.id&&t(r.matter?.id)},size:`small`,children:(0,Y.jsx)(ee,{})})}),f&&f.bridgeMode===`childbridge`&&!r.error&&r.enabled&&(0,Y.jsx)(H,{title:`Restart the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`},onClick:()=>M(r),size:`small`,children:(0,Y.jsx)(ot,{})})}),(0,Y.jsx)(H,{title:`Plugin config`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{disabled:r.restartRequired===!0,style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>ue(r),size:`small`,children:(0,Y.jsx)(Se,{})})}),f&&!f.readOnly&&(0,Y.jsx)(H,{title:`Remove the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>{w(`Remove plugin`,`Are you sure? This will also remove all devices and configuration from the controller.`,`remove`,r)},size:`small`,children:(0,Y.jsx)(Pe,{})})}),r.enabled?(0,Y.jsx)(H,{title:`Disable the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>{w(`Disable plugin`,`Are you sure? This will also remove all devices and configuration from the controller.`,`disable`,r)},size:`small`,children:(0,Y.jsx)(nt,{})})}):(0,Y.jsx)(Y.Fragment,{}),r.enabled?(0,Y.jsx)(Y.Fragment,{}):(0,Y.jsx)(H,{title:`Enable the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>N(r),size:`small`,children:(0,Y.jsx)(oe,{})})}),(0,Y.jsx)(H,{title:`Open the plugin help`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>te(r),size:`small`,children:(0,Y.jsx)(g,{})})}),(0,Y.jsx)(H,{title:`Open the plugin version history`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>I(r),size:`small`,children:(0,Y.jsx)(v,{})})}),r.enabled&&r.frontendPath&&(0,Y.jsx)(H,{title:`Open the plugin frontend`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>ne(r),size:`small`,children:(0,Y.jsx)(m,{})})}),r.latestVersion!==void 0&&r.latestVersion!==r.version&&f&&!f.readOnly&&(0,Y.jsx)(H,{title:`Update the plugin to the latest version v.${r.latestVersion}`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{color:`var(--primary-color)`,margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>k(r),size:`small`,children:(0,Y.jsx)(st,{})})}),(r.version.includes(`-dev-`)||r.version.includes(`-git-`))&&r.devVersion!==void 0&&r.devVersion!==r.version&&f&&!f.readOnly&&(0,Y.jsx)(H,{title:`Update the plugin to the latest dev version v.${r.devVersion}`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{color:`var(--secondary-color)`,margin:`0px 2px`,padding:`0px`,width:`19px`,height:`19px`},onClick:()=>A(r),size:`small`,children:(0,Y.jsx)(st,{})})}),f&&!f.readOnly&&(0,Y.jsx)(H,{title:`Sponsor the plugin`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[30,15]}}]}},children:(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`,width:`19px`,height:`19px`,color:`#b6409c`},onClick:()=>F(r),size:`small`,children:(0,Y.jsx)(it,{})})})]})},{label:`Status`,id:`status`,required:!0,noSort:!0,render:(e,t,n,r)=>(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,flex:`1 1 auto`,margin:`0`,padding:`0`,gap:`5px`,width:`auto`,maxWidth:`max-content`},children:n.error?(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(xr,{status:!1,enabledText:`Error`,disabledText:`Error`,tooltipText:`The plugin is in error state. Check the log!`})}):(0,Y.jsx)(Y.Fragment,{children:n.enabled?(0,Y.jsx)(Y.Fragment,{children:n.loaded&&n.started&&n.configured?(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(xr,{status:n.loaded,enabledText:`Running`,tooltipText:`Whether the plugin is running`})}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(xr,{status:n.loaded,enabledText:`Loaded`,tooltipText:`Whether the plugin has been loaded`}),(0,Y.jsx)(xr,{status:n.started,enabledText:`Started`,tooltipText:`Whether the plugin started`}),(0,Y.jsx)(xr,{status:n.configured,enabledText:`Configured`,tooltipText:`Whether the plugin has been configured`})]})}):(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsx)(xr,{status:n.enabled,enabledText:`Enabled`,disabledText:`Disabled`,tooltipText:`Whether the plugin is enable or disabled`})})})})}];(0,G.useEffect)(()=>{let e=e=>{q&&console.log(`HomePlugins received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`plugins`?e.response.lock?(q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} lock=${e.response.lock} and locking plugins list`),_(t=>t.map(t=>t.name===e.response.lock?{...t,restartRequired:!0}:t))):(q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} lock=${e.response.lock} and sending /api/plugins request`),r({id:l.current,sender:`HomePlugins`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`refresh_required`&&e.response.changed===`matter`?(q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} and setting matter id ${e.response.matter?.id}`),_(t=>{let n=t.findIndex(t=>t.matter?.id===e.response.matter?.id);if(n<0)return q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} and matter id ${e.response.matter?.id} not found`),t;q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} set matter id ${e.response.matter?.id}`);let r=[...t];return r[n]={...r[n],matter:e.response.matter},r})):e.method===`refresh_required`&&e.response.changed===`settings`?(q&&console.log(`HomePlugins received refresh_required: changed=${e.response.changed} and sending /api/settings request`),r({id:l.current,sender:`HomePlugins`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`plugin_update_required`&&(q&&console.log(`HomePlugins received plugin_update_required`,e.response),_(t=>t.map(t=>t.name===e.response.plugin?e.response.devVersion?{...t,devVersion:e.response.version}:{...t,latestVersion:e.response.version}:t))),e.id===l.current&&e.method===`/api/settings`?(q&&console.log(`HomePlugins (id: ${e.id}) received settings:`,e.response),d(e.response.systemInformation),p(e.response.matterbridgeInformation)):e.id===l.current&&e.method===`/api/plugins`&&(q&&console.log(`HomePlugins (id: ${e.id}) received ${e.response.length} plugins:`,e.response),_(e.response))};return i(e,l.current),q&&console.log(`HomePlugins added WebSocket listener id:`,l.current),()=>{a(e),q&&console.log(`HomePlugins removed WebSocket listener`)}},[i,a,r]),(0,G.useEffect)(()=>{n&&(q&&console.log(`HomePlugins sending api requests`),r({id:l.current,sender:`HomePlugins`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),r({id:l.current,sender:`HomePlugins`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[n,r]);let C=(0,G.useRef)(null),w=(e,t,n,r)=>{q&&console.log(`handleActionWithConfirmCancel ${n} ${r.name}`),C.current=r,c(e,t,n,E,O)},E=e=>{q&&console.log(`handleConfirm action confirmed ${e} ${C.current?.name}`),e===`remove`&&C.current?j(C.current):e===`disable`&&C.current&&N(C.current),C.current=null},O=e=>{q&&console.log(`handleCancel action canceled ${e} ${C.current?.name}`),C.current=null},k=e=>{q&&console.log(`handleUpdatePlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:e.name,restart:!1}})},A=e=>{q&&console.log(`handleUpdateDevPlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:e.name+`@dev`,restart:!1}})},j=e=>{q&&console.log(`handleRemovePlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/removeplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})},M=e=>{q&&console.log(`handleRestartPlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/restartplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})},N=e=>{q&&console.log(`handleEnableDisablePlugin plugin:`,e.name,`enabled:`,e.enabled),e.enabled?(e.enabled=!1,r({id:l.current,sender:`HomePlugins`,method:`/api/disableplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}})):(e.enabled=!0,r({id:l.current,sender:`HomePlugins`,method:`/api/enableplugin`,src:`Frontend`,dst:`Matterbridge`,params:{pluginName:e.name}}))},P=e=>{q&&console.log(`handleHomepagePlugin plugin: ${e.name} homepage: ${e.homepage}`),e.homepage&&window.open(e.homepage,`_blank`)},F=e=>{q&&console.log(`handleSponsorPlugin plugin:`,e.name,`funding:`,e.funding),e.funding&&window.open(e.funding,`_blank`)},te=e=>{q&&console.log(`handleHelpPlugin plugin:`,e.name,`help:`,e.help),e.help&&window.open(e.help,`_blank`)},I=e=>{q&&console.log(`handleChangelogPlugin plugin:`,e.name,`changelog:`,e.changelog),e.changelog&&window.open(e.changelog,`_blank`)},ne=e=>{let t=`/plugins/${e.name}`;q&&console.log(`handleFrontendPlugin plugin:`,e.name,`frontend:`,e.frontendPath,`path:`,t),e.frontendPath&&b({name:e.name,path:t})},ie=e=>{let t=e.currentTarget.contentDocument;if(!t?.head)return;let n=getComputedStyle(document.body),r=n.getPropertyValue(`--primary-color`).trim()||`#0d6efd`,i=n.getPropertyValue(`--div-bg-color`).trim()||`#111111`;t.getElementById(`matterbridge-plugin-scrollbar-style`)?.remove();let a=t.createElement(`style`);a.id=`matterbridge-plugin-scrollbar-style`,a.textContent=`
|
|
23
23
|
html,
|
|
24
24
|
body {
|
|
25
25
|
background-color: ${i};
|
|
@@ -39,6 +39,6 @@ import{a as e}from"./rolldown-runtime.js";import{c as t}from"./vendor_emotion.js
|
|
|
39
39
|
::-webkit-scrollbar-track {
|
|
40
40
|
background: ${i};
|
|
41
41
|
}
|
|
42
|
-
`,t.head.appendChild(a)},[ae,se]=(0,G.useState)(),[ce,le]=(0,G.useState)(!1),ue=e=>{q&&console.log(`handleConfigPlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/select/devices`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:e.name}}),r({id:l.current,sender:`HomePlugins`,method:`/api/select/entities`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:e.name}}),se(e),de()},de=()=>{le(!0)};return q&&console.log(`HomePlugins rendering...`),n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(Q,{children:[ae&&(0,Y.jsx)(br,{open:ce,onClose:()=>{le(!1)},plugin:ae}),(0,Y.jsx)(Sn,{name:`Plugins`,columns:S,rows:h,footerRight:``,footerLeft:``})]}),(0,Y.jsxs)(D,{open:y!==null,onClose:()=>b(null),slotProps:{paper:{sx:{width:J&&s?`100vw`:`75vw`,height:J&&s?`100vh`:`75vh`,maxWidth:J&&s?`100vw`:`75vw`,maxHeight:J&&s?`100vh`:`75vh`,margin:J&&s?`0px`:void 0,display:`flex`,flexDirection:`column`,overflow:`hidden`,backgroundColor:`var(--div-bg-color)`}}},children:[(0,Y.jsx)(re,{style:{display:`flex`,flex:`1 1 auto`,minHeight:0,padding:`0px`,margin:`0px`,overflow:`hidden`,backgroundColor:`var(--div-bg-color)`},children:y&&(0,Y.jsx)(`iframe`,{title:`${y.name} frontend`,src:y.path,onLoad:ie,style:{display:`block`,flex:`1 1 auto`,width:`100%`,height:`100%`,border:`none`,backgroundColor:`var(--div-bg-color)`}})}),(0,Y.jsx)(x,{sx:{flex:`0 0 auto`,justifyContent:`center`},children:(0,Y.jsx)(L,{onClick:()=>b(null),children:`Close`})})]})]}):(0,Y.jsx)(Wt,{})}var Cr=(0,G.memo)(Sr);function wr({version:e,changelog:t}){let{online:n}=(0,G.useContext)(X);return q&&console.log(`HomeShowChangelog rendering...`),n?(0,Y.jsxs)(Q,{children:[(0,Y.jsx)(Gt,{children:(0,Y.jsx)(Kt,{children:`Matterbridge Update`})}),(0,Y.jsxs)(Xt,{style:{flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Y.jsxs)(`h4`,{style:{margin:0},children:[`Matterbridge has been updated to version `,e,`.`]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:`10px`},children:[(0,Y.jsx)(L,{onClick:()=>window.open(`https://github.com/Luligu/matterbridge`,`_blank`),endIcon:(0,Y.jsx)(Xe,{style:{color:`#FFD700`}}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Star`}),(0,Y.jsx)(L,{onClick:()=>window.open(`https://www.buymeacoffee.com/luligugithub`,`_blank`),endIcon:(0,Y.jsx)(it,{style:{color:`#b6409c`}}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Sponsor`}),(0,Y.jsx)(L,{onClick:()=>window.open(t,`_blank`),endIcon:(0,Y.jsx)(v,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Changelog`}),(0,Y.jsx)(L,{onClick:()=>window.location.reload(),endIcon:(0,Y.jsx)(Ce,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Close`})]})]})]}):(0,Y.jsx)(Wt,{})}var Tr=(0,G.memo)(wr);function Er({value:e,maxChars:t}){let n=e;if(e.length>t&&t>3){let r=t-3;n=`${e.substring(0,Math.ceil(r/2))} … ${e.substring(e.length-Math.floor(r/2),e.length)}`}return e===n?(0,Y.jsx)(`span`,{children:n}):(0,Y.jsx)(H,{title:e,placement:`top`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[0,12]}}]}},children:(0,Y.jsx)(`span`,{children:n})})}function Dr({matterbridgeInfo:e}){let{mobile:t}=(0,G.useContext)(Vt);q&&console.log(`MatterbridgeInfoTable:`,e);let n=new Set([`matterbridgeLatestVersion`,`matterbridgeDevVersion`,`dockerDev`,`dockerLatestVersion`,`dockerDevVersion`,`--matterFileLogger`,`--fileLogger`,`--matterLoggerLevel`,`--loggerLevel`,`--virtualMode`,`--bridgeMode`,`--restartMode`,`--restartRequired`,`fixedRestartRequired`,`--updateRequired`,`matterMdnsInterface`,`matterIpv4Address`,`matterIpv6Address`,`readOnly`,`shellyBoard`,`shellySysUpdate`,`shellyMainUpdate`,`matterPort`,`matterDiscriminator`,`matterPasscode`]),[r,i]=(0,G.useState)(!1);return!e||r?null:(q&&console.log(`MatterbridgeInfoTable rendering...`),(0,Y.jsxs)(Q,{style:J&&t?{flex:`1 1 300px`}:{flex:`0 1 auto`,width:`302px`,minWidth:`302px`},children:[(0,Y.jsxs)(Gt,{children:[(0,Y.jsx)(Kt,{children:`Matterbridge info`}),(0,Y.jsx)(Zt,{close:()=>i(!0)})]}),(0,Y.jsx)(Xt,{style:J&&t?{flex:`1 1 auto`,margin:`0px`,padding:`0px`,gap:`0px`}:{flex:`1 1 auto`,overflow:`auto`,margin:`0px`,padding:`0px`,gap:`0px`},children:(0,Y.jsxs)(`table`,{style:{border:`none`,borderCollapse:`collapse`,tableLayout:`fixed`},children:[(0,Y.jsxs)(`colgroup`,{children:[(0,Y.jsx)(`col`,{style:{width:`40%`}}),(0,Y.jsx)(`col`,{style:{width:`60%`}})]}),(0,Y.jsx)(`tbody`,{style:{border:`none`,borderCollapse:`collapse`},children:Object.entries(e).filter(([e,t])=>!n.has(e)&&t!=null&&t!==``).map(([e,n],r)=>(0,Y.jsxs)(`tr`,{className:r%2==0?`table-content-even`:`table-content-odd`,style:{border:`none`,borderCollapse:`collapse`},children:[(0,Y.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`},children:e.replace(`matterbridgeVersion`,`Matterbridge version`).replace(`frontendVersion`,`Frontend version`).replace(`dockerVersion`,`Docker 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`)}),(0,Y.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:J&&t?typeof n==`string`?n:n.toString():(0,Y.jsx)(Er,{value:typeof n==`string`?n:n.toString(),maxChars:24})})]},e))})]})})]}))}var Or=(0,G.memo)(Dr),kr={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`}},Ar=e=>{if(!e)return``;let t=e.replace(/[^0-9]/g,``);return t.length<5?t:[t.slice(0,4),t.slice(4,7),t.slice(7,11)].filter(Boolean).join(`-`)};function jr({id:e}){let{online:t,sendMessage:n,addListener:r,removeListener:i,getUniqueId:a}=(0,G.useContext)(X),[o,s]=(0,G.useState)(null),c=(0,G.useRef)(null),l=(0,G.useRef)(null),u=(0,G.useRef)(a()),{mobile:d,showConfirmCancelDialog:f}=(0,G.useContext)(Vt);q&&console.log(`QRDiv loading with id = "${e}" storeId = "${c.current}" timeout = ${l.current?`set`:`none`} and matter:`,o),(0,G.useEffect)(()=>{q&&console.log(`QRDiv id effect "${e}"`),c.current=e,l.current&&clearTimeout(l.current),l.current=null,e?(q&&console.log(`QRDiv id effect sending data request for storeId "${e}"`),n({id:u.current,sender:`QRDiv`,method:`/api/matter`,src:`Frontend`,dst:`Matterbridge`,params:{id:e,server:!0}})):(q&&console.log(`QRDiv id effect setting matter to null`),s(null))},[e,n]),(0,G.useEffect)(()=>{let e=e=>{q&&console.log(`QRDiv received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`matter`&&e.response.matter&&(q&&console.log(`QRDiv received refresh_required: changed=${e.response.changed} for storeId "${e.response.matter.id}":`,e.response.matter),c.current===e.response.matter.id&&(q&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${e.response.matter.id}":`,e.response.matter),l.current&&clearTimeout(l.current),s(e.response.matter)))};return r(e,u.current),q&&console.log(`QRDiv webSocket effect mounted`),()=>{i(e),l.current&&clearTimeout(l.current),l.current=null,q&&console.log(`QRDiv webSocket effect unmounted`)}},[r,i]);let p=()=>{q&&console.log(`QRDiv sent matter startCommission for node "${o?.id}"`),o&&n({id:u.current,sender:`QRDiv`,method:`/api/matter`,src:`Frontend`,dst:`Matterbridge`,params:{id:o.id,startCommission:!0}})},m=()=>{q&&console.log(`QRDiv sent matter stopCommission for node "${o?.id}"`),o&&n({id:u.current,sender:`QRDiv`,method:`/api/matter`,src:`Frontend`,dst:`Matterbridge`,params:{id:o.id,stopCommission:!0}})},h=()=>{q&&console.log(`QRDiv sent matter advertise for node "${o?.id}"`),o&&n({id:u.current,sender:`QRDiv`,method:`/api/matter`,src:`Frontend`,dst:`Matterbridge`,params:{id:o.id,advertise:!0}})},g=e=>{q&&console.log(`QRDiv sent matter removeFabric for node "${o?.id}" and fabricIndex ${e}`),o&&n({id:u.current,sender:`QRDiv`,method:`/api/matter`,src:`Frontend`,dst:`Matterbridge`,params:{id:o.id,removeFabric:e}})};return!o||!t?(q&&console.log(`QRDiv rendering undefined state`),null):o.online?o.advertising&&o.qrPairingCode&&o.manualPairingCode?(q&&console.log(`QRDiv rendering advertising state`),(0,Y.jsxs)(Q,{style:J&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`},children:[(0,Y.jsxs)(Gt,{children:[(0,Y.jsx)(Kt,{children:`QR pairing code`}),(0,Y.jsxs)(Zt,{children:[(0,Y.jsx)(T,{"aria-label":`send advertising`,size:`small`,onClick:h,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,Y.jsx)(H,{title:`Send again the mDNS advertisement`,arrow:!0,children:(0,Y.jsx)(Z.Icon,{path:dt,size:`22px`})})}),(0,Y.jsx)(T,{"aria-label":`stop pairing`,size:`small`,onClick:m,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,Y.jsx)(H,{title:`Turn off pairing`,arrow:!0,children:(0,Y.jsx)(Z.Icon,{path:gt,size:`22px`})})})]})]}),(0,Y.jsx)(Yt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,Y.jsx)(kt,{value:o.qrPairingCode,size:256,level:`M`,fgColor:`var(--div-text-color)`,bgColor:`var(--div-bg-color)`,style:{margin:`20px`}}),(0,Y.jsxs)(qt,{style:{justifyContent:`space-between`},children:[(0,Y.jsxs)(Jt,{style:{fontWeight:`normal`,color:`var(--div-text-color)`},children:[`Manual pairing code: `,Ar(o.manualPairingCode)]}),(0,Y.jsx)(Zt,{children:(0,Y.jsx)(H,{title:`Copy manual pairing code`,arrow:!0,children:(0,Y.jsx)(T,{"aria-label":`copy manual pairing code`,size:`small`,onClick:async()=>{if(!o||!o.manualPairingCode)return;let e=o.manualPairingCode;try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(e);else{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.focus(),t.select(),document.execCommand(`copy`),document.body.removeChild(t)}q&&console.log(`Manual pairing code copied to clipboard`)}catch(e){console.error(`Failed to copy manual pairing code`,e)}},sx:kr,children:(0,Y.jsx)(Z.Icon,{path:mt,size:.85})})})})]})]})):o.commissioned&&o.fabricInformations&&o.sessionInformations?(q&&console.log(`QRDiv rendering commissioned state`),(0,Y.jsxs)(Q,{style:J&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`,overflow:`hidden`},children:[(0,Y.jsxs)(Gt,{children:[(0,Y.jsx)(Kt,{children:`Paired fabrics`}),(0,Y.jsxs)(Zt,{children:[(0,Y.jsx)(T,{"aria-label":`send advertising`,size:`small`,onClick:h,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,Y.jsx)(H,{title:`Send again the mDNS advertisement`,arrow:!0,children:(0,Y.jsx)(Z.Icon,{path:dt,size:`22px`})})}),(0,Y.jsx)(T,{"aria-label":`start pairing`,size:`small`,onClick:p,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,Y.jsx)(H,{title:`Turn on pairing`,arrow:!0,children:(0,Y.jsx)(Z.Icon,{path:_t,size:`22px`})})})]})]}),(0,Y.jsx)(Yt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,Y.jsx)(Xt,{style:{flexDirection:`column`,justifyContent:`flex-start`,flex:`1 1 auto`,overflow:`auto`,padding:`0px 0px 10px 0px`,gap:`0px`},children:o.fabricInformations.map((e,t)=>(0,Y.jsxs)(`div`,{style:{margin:`0px`,padding:`10px`,gap:`0px`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`,textAlign:`left`,fontSize:`14px`},children:[(0,Y.jsxs)(`div`,{style:{marginLeft:`20px`,marginBottom:`10px`,display:`flex`,flexDirection:`row`,justifyContent:`space-between`,gap:`20px`,alignItems:`center`},children:[(0,Y.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: `,e.fabricIndex]}),(0,Y.jsx)(H,{title:`Remove the fabric. You will also need to remove it from the controller.`,arrow:!0,children:(0,Y.jsx)(T,{"aria-label":`remove the fabric`,size:`small`,onClick:()=>f(`Remove fabric`,`Are you sure you want to remove this fabric? You will also need to remove it from the controller.`,`RemoveFabric`,()=>g(e.fabricIndex),()=>{}),sx:{...kr,padding:`2px`},children:(0,Y.jsx)(Z.Icon,{path:ut,size:1})})})]}),(0,Y.jsxs)(`p`,{style:{margin:`0px 20px 0px 20px`,color:`var(--div-text-color)`},children:[`Vendor: `,e.rootVendorId,` `,e.rootVendorName]}),e.label!==``&&(0,Y.jsxs)(`p`,{style:{margin:`0px 20px 0px 20px`,color:`var(--div-text-color)`},children:[`Label: `,e.label]}),(0,Y.jsxs)(`p`,{style:{margin:`0px 20px 0px 20px`,color:`var(--div-text-color)`},children:[`Sessions: `,o.sessionInformations?o.sessionInformations.filter(t=>t.fabric?.fabricIndex===e.fabricIndex&&t.isPeerActive).length:`0`,` `,`subscriptions: `,o.sessionInformations?o.sessionInformations.filter(t=>t.fabric?.fabricIndex===e.fabricIndex&&t.isPeerActive&&t.numberOfActiveSubscriptions>0).length:`0`]})]},t))}),(0,Y.jsx)(qt,{style:{justifyContent:`center`},children:(0,Y.jsxs)(Jt,{style:{fontWeight:`normal`},children:[`Serial number: `,o.serialNumber]})})]})):!o.commissioned&&!o.advertising?(q&&console.log(`QRDiv rendering not commissioned and not advertising state`),(0,Y.jsxs)(Q,{style:J&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`},children:[(0,Y.jsx)(Gt,{children:(0,Y.jsx)(Kt,{children:`QR pairing code`})}),(0,Y.jsx)(Yt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,Y.jsx)(L,{onClick:p,endIcon:(0,Y.jsx)(Z.Icon,{path:_t,size:1}),style:{margin:`20px`,color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:`Turn on pairing`}),(0,Y.jsx)(qt,{style:{justifyContent:`center`},children:(0,Y.jsxs)(Jt,{style:{fontWeight:`normal`},children:[`Serial number: `,o.serialNumber]})})]})):(q&&console.log(`QRDiv rendering unknown state`),null):(q&&console.log(`QRDiv rendering offline state`),(0,Y.jsxs)(Q,{style:J&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`},children:[(0,Y.jsx)(Gt,{style:{height:`30px`,justifyContent:`space-between`},children:(0,Y.jsx)(Kt,{children:`Server node`})}),(0,Y.jsx)(Yt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,Y.jsx)(Yt,{style:{fontWeight:`bold`},children:`Server offline`}),(0,Y.jsx)(qt,{style:{justifyContent:`center`},children:(0,Y.jsxs)(Jt,{style:{fontWeight:`normal`},children:[`Serial number: `,o.serialNumber]})})]}))}var Mr=(0,G.memo)(jr);function Nr({systemInfo:e,compact:t}){let{mobile:n}=(0,G.useContext)(Vt),{addListener:r,removeListener:i,getUniqueId:a,sendMessage:o}=(0,G.useContext)(X),[s,c]=(0,G.useState)(e),l=(0,G.useRef)(a());if(q&&console.log(`SystemInfoTable loading with systemInfo:`,s,`compact:`,t),e&&t&&s.totalMemory&&s.freeMemory){let e=s.totalMemory;s.freeMemory=`${s.freeMemory} / ${e}`,s.totalMemory=``}if(e&&t&&s.heapTotal&&s.heapUsed){let e=s.heapTotal;s.heapUsed=`${s.heapUsed} / ${e}`,s.heapTotal=``}e&&t&&s.osRelease&&s.osType&&(s.osType=`${s.osType} (${s.osRelease})`,s.osRelease=``),e&&t&&s.osArch&&s.osPlatform&&(s.osPlatform=`${s.osPlatform} (${s.osArch})`,s.osArch=``);let u=(e,t,n,r,i)=>{c(a=>({...a,totalMemory:e,freeMemory:t,heapTotal:n,heapUsed:r,rss:i}))},d=e=>{c(t=>({...t,cpuUsage:e.toFixed(2)+` %`}))},f=e=>{c(t=>({...t,processCpuUsage:e.toFixed(2)+` %`}))},p=(e,t)=>{c(n=>({...n,systemUptime:e,processUptime:t}))},m=()=>{q&&console.log(`SystemInfoTable handleViewHistory clicked`),o({id:l.current,sender:`Header`,method:`/api/viewhistorypage`,src:`Frontend`,dst:`Matterbridge`,params:{}})};(0,G.useEffect)(()=>{let e=e=>{q&&console.log(`SystemInfoTable received WebSocket Message:`,e),e.method===`memory_update`&&e.response&&e.response.totalMemory&&e.response.freeMemory&&e.response.heapTotal&&e.response.heapUsed&&e.response.rss?(q&&console.log(`SystemInfoTable received memory_update`,e),u(e.response.totalMemory,e.response.freeMemory,e.response.heapTotal,e.response.heapUsed,e.response.rss)):e.method===`cpu_update`&&e.response&&e.response.cpuUsage?(q&&console.log(`SystemInfoTable received cpu_update`,e),d(e.response.cpuUsage),f(e.response.processCpuUsage)):e.method===`uptime_update`&&e.response&&e.response.systemUptime&&e.response.processUptime?(q&&console.log(`SystemInfoTable received uptime_update`,e),p(e.response.systemUptime,e.response.processUptime)):e.method===`/api/viewhistorypage`&&e.id===l.current&&e.success&&(q&&console.log(`SystemInfoTable received /api/viewhistorypage success`),window.open(`./api/viewhistory`,`_blank`,`noopener,noreferrer`))};return r(e,l.current),q&&console.log(`SystemInfoTable added WebSocket listener id ${l.current}`),()=>{i(e),q&&console.log(`SystemInfoTable removed WebSocket listener`)}},[r,i]);let[h,g]=(0,G.useState)(!1);return!s||h?null:(q&&console.log(`SystemInfoTable rendering...`),(0,Y.jsxs)(Q,{style:J&&n?{flex:`1 1 300px`}:{flex:`0 1 auto`,width:`302px`,minWidth:`302px`},children:[(0,Y.jsxs)(Gt,{children:[(0,Y.jsx)(Kt,{children:`System info`}),(0,Y.jsx)(Zt,{close:()=>g(!0),children:(0,Y.jsx)(T,{size:`small`,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},onClick:m,children:(0,Y.jsx)(H,{title:`Open the cpu and memory usage page`,arrow:!0,children:(0,Y.jsx)(Z.Icon,{path:ft,size:`22px`})})})})]}),(0,Y.jsx)(Xt,{style:J&&n?{flex:`1 1 auto`,margin:`0px`,padding:`0px`,gap:`0px`}:{flex:`1 1 auto`,overflow:`auto`,margin:`0px`,padding:`0px`,gap:`0px`},children:(0,Y.jsxs)(`table`,{style:{border:`none`,borderCollapse:`collapse`,tableLayout:`fixed`},children:[(0,Y.jsxs)(`colgroup`,{children:[(0,Y.jsx)(`col`,{style:{width:`40%`}}),(0,Y.jsx)(`col`,{style:{width:`60%`}})]}),(0,Y.jsx)(`tbody`,{style:{border:`none`,borderCollapse:`collapse`},children:Object.entries(s).filter(([e,t])=>t!==void 0&&t!==``).map(([e,t],r)=>(0,Y.jsxs)(`tr`,{className:r%2==0?`table-content-even`:`table-content-odd`,style:{border:`none`,borderCollapse:`collapse`},children:[(0,Y.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`},children:e.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`)}),(0,Y.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:J&&n?typeof t==`string`?t:t.toString():(0,Y.jsx)(Er,{value:typeof t==`string`?t:t.toString(),maxChars:22})})]},e))})]})})]}))}var Pr=(0,G.memo)(Nr);function Fr(){let[e,t]=(0,G.useState)(null),[n,r]=(0,G.useState)(null),[i,a]=(0,G.useState)([]),[o]=(0,G.useState)(localStorage.getItem(K.homePagePlugins)!==`false`),[s,c]=(0,G.useState)(localStorage.getItem(K.homePageMode)??`devices`),[l,u]=(0,G.useState)(`https://matterbridge.io/CHANGELOG.html`),[d,f]=(0,G.useState)(!1),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(null),{mobile:_}=(0,G.useContext)(Vt),{addListener:v,removeListener:y,online:b,sendMessage:x,getUniqueId:S}=(0,G.useContext)(X),C=(0,G.useRef)(S());return(0,G.useEffect)(()=>{let e=e=>{q&&console.log(`Home received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`settings`&&(q&&console.log(`Home received refresh_required: changed=${e.response.changed} and sending /api/settings request`),g(null),a([]),x({id:C.current,sender:`Home`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),x({id:C.current,sender:`Home`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}})),e.method===`/api/settings`&&e.id===C.current&&(q&&console.log(`Home received settings:`,e.response),t(e.response.systemInformation),r(e.response.matterbridgeInformation),localStorage.getItem(K.frontendVersion)===null&&e.response.matterbridgeInformation.frontendVersion?localStorage.setItem(K.frontendVersion,e.response.matterbridgeInformation.frontendVersion):e.response.matterbridgeInformation.frontendVersion!==localStorage.getItem(K.frontendVersion)&&e.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem(K.frontendVersion,e.response.matterbridgeInformation.frontendVersion),m(!0)),localStorage.getItem(K.matterbridgeVersion)===null?localStorage.setItem(K.matterbridgeVersion,e.response.matterbridgeInformation.matterbridgeVersion):e.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem(K.matterbridgeVersion)&&(localStorage.setItem(K.matterbridgeVersion,e.response.matterbridgeInformation.matterbridgeVersion),f(!0)),e.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem(K.homePageMode)||(localStorage.setItem(K.homePageMode,`devices`),c(`devices`)))),e.method===`/api/plugins`&&e.id===C.current&&(q&&console.log(`Home received plugins:`,e.response),a(e.response))};return v(e,C.current),q&&console.log(`Home added WebSocket listener id ${C.current}`),()=>{y(e),q&&console.log(`Home removed WebSocket listener`)}},[v,y,x]),(0,G.useEffect)(()=>{if(q&&console.log(`Home storeId effect with storeId ${h}`),n?.bridgeMode===`bridge`&&!h&&(q&&console.log(`Home storeId effect set storeId to Matterbridge`),g(`Matterbridge`)),n?.bridgeMode===`childbridge`&&!h&&i){for(let e of i)if(e.matter?.id){q&&console.log(`Home storeId effect set storeId to ${e.matter.id}`),g(e.matter.id);break}}},[n,i,h]),(0,G.useEffect)(()=>{b&&(q&&console.log(`Home online effect, sending /api/settings and /api/plugins requests`),x({id:C.current,sender:`Home`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),x({id:C.current,sender:`Home`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[b,x]),q&&console.log(`Home rendering...`),!b||!e||!n?(0,Y.jsx)(Wt,{}):(0,Y.jsxs)(kn,{name:`Home`,style:J&&_?{alignItems:`center`,gap:`10px`}:{flexDirection:`row`},children:[(J&&!_||!J)&&(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,width:`302px`,minWidth:`302px`,gap:`20px`},children:[(0,Y.jsx)(Mr,{id:h}),(0,Y.jsx)(Pr,{systemInfo:e,compact:!0})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,width:`100%`,gap:J&&_?`10px`:`20px`},children:[p&&(0,Y.jsx)(Nn,{version:n.frontendVersion}),d&&(0,Y.jsx)(Tr,{version:n.matterbridgeVersion,changelog:l}),J&&_&&(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:`10px`},children:[(0,Y.jsx)(Mr,{id:h}),(0,Y.jsx)(Pr,{systemInfo:e,compact:!0}),(0,Y.jsx)(Or,{matterbridgeInfo:n})]}),o&&!n.readOnly&&(0,Y.jsx)(Xn,{}),o&&(0,Y.jsx)(Cr,{storeId:h,setStoreId:g}),s===`devices`&&(0,Y.jsx)(Ln,{storeId:h,setStoreId:g}),s===`logs`&&(0,Y.jsx)(tr,{})]})]})}var Ir=(0,G.memo)(Fr);function Lr(){let{logLength:e,logAutoScroll:t,setMessages:n,setLogFilterLevel:r,setLogFilterSearch:i,online:a,filterLogMessages:o}=(0,G.useContext)(X),[s,c]=(0,G.useState)(localStorage.getItem(K.logFilterLevel)??`info`),[l,u]=(0,G.useState)(localStorage.getItem(K.logFilterSearch)??`*`),[f,p]=(0,G.useState)(e.current.toString()),[m,h]=(0,G.useState)(t.current);return q&&console.log(`Logs rendering...`),a?(0,Y.jsxs)(kn,{name:`Logs`,children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`,margin:`0px`,padding:`0px`,gap:`10px`},children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(le,{id:`select-level`,style:{color:`var(--div-text-color)`},children:`Filter log by level:`}),(0,Y.jsxs)(ye,{style:{height:`30px`,backgroundColor:`var(--main-bg-color)`},labelId:`select-level`,id:`debug-level`,value:s,onChange:e=>{let t=e.target.value;c(t),r(t),o(t,l),localStorage.setItem(K.logFilterLevel,t),q&&console.log(`handleLogFilterLevelChange called with value:`,t)},children:[(0,Y.jsx)(V,{value:`debug`,children:`Debug`}),(0,Y.jsx)(V,{value:`info`,children:`Info`}),(0,Y.jsx)(V,{value:`notice`,children:`Notice`}),(0,Y.jsx)(V,{value:`warn`,children:`Warn`}),(0,Y.jsx)(V,{value:`error`,children:`Error`}),(0,Y.jsx)(V,{value:`fatal`,children:`Fatal`})]})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`5px`},children:[(0,Y.jsx)(le,{id:`search`,style:{color:`var(--div-text-color)`},children:`Filter log by text:`}),(0,Y.jsx)(H,{title:`Use /text/ for case-insensitive regex search`,children:(0,Y.jsx)(B,{style:{width:`210px`},size:`small`,id:`logsearch`,variant:`outlined`,value:l,onChange:e=>{let t=e.target.value;u(t),i(t),o(s,t),localStorage.setItem(K.logFilterSearch,t),q&&console.log(`handleLogFilterSearchChange called with value:`,t)},slotProps:{input:{style:{height:`30px`,padding:`0 0px`,backgroundColor:`var(--main-bg-color)`}}}})})]}),(0,Y.jsx)(d,{control:(0,Y.jsx)(M,{checked:m,onChange:e=>{let n=e.target.checked;h(n),t.current=n,o(s,l),localStorage.setItem(K.logAutoScroll,n?`true`:`false`),q&&console.log(`handleAutoScrollChange called with value:`,n)}}),label:`Auto scroll`,style:{color:`var(--div-text-color)`}})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(le,{id:`select-size-label`,style:{color:`var(--div-text-color)`},children:`Log length:`}),(0,Y.jsxs)(ye,{style:{height:`30px`,backgroundColor:`var(--main-bg-color)`},labelId:`select-size-label`,id:`select-size`,value:f,onChange:t=>{let n=t.target.value;p(n),e.current=Number(n),localStorage.setItem(K.logLength,n),q&&console.log(`handleLogLengthChange called with value:`,n)},children:[(0,Y.jsx)(V,{value:100,children:`100`}),(0,Y.jsx)(V,{value:200,children:`200`}),(0,Y.jsx)(V,{value:500,children:`500`}),(0,Y.jsx)(V,{value:1e3,children:`1000`})]}),(0,Y.jsx)(H,{title:`Clear the logs`,children:(0,Y.jsx)(L,{onClick:()=>{q&&console.log(`handleClearLogsClick called`),n([])},endIcon:(0,Y.jsx)(ke,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Clear`})})]})]}),(0,Y.jsx)(`div`,{style:{flex:`1`,overflow:`auto`,margin:`0px`,padding:`0px`},children:(0,Y.jsx)($n,{})})]}):(0,Y.jsx)(Wt,{})}var Rr=(0,G.memo)(Lr),zr=1200,Br,Vr;function Hr(e,t){Br=e,Vr=t}function Ur(){let{mobile:e,showSnackbarMessage:t,showConfirmCancelDialog:n}=(0,G.useContext)(Vt),{online:i,sendMessage:a,logMessage:o,addListener:c,removeListener:l,getUniqueId:d}=(0,G.useContext)(X),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(!1),[_,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(!1),[S,C]=(0,G.useState)(null),w=(0,G.useRef)(d()),[E,D]=(0,G.useState)(null),[O,k]=(0,G.useState)(null),[A,j]=(0,G.useState)(null),[M,N]=(0,G.useState)(null),ee=r(),F=()=>{window.open(`https://www.buymeacoffee.com/luligugithub`,`_blank`)},te=()=>{window.open(`https://matterbridge.io/`)},I=()=>{window.open(`https://matterbridge.io/README.html`)},ne=()=>{window.open(`https://matterbridge.io/CHANGELOG.html`)},re=()=>{window.open(`https://discord.gg/QX58CDe6hd`,`_blank`)},ie=()=>{window.open(`https://github.com/Luligu/matterbridge`,`_blank`)},ae=()=>{a({id:w.current,sender:`Header`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:`matterbridge`,restart:!0}}),y(!1)},L=()=>{a({id:w.current,sender:`Header`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:`matterbridge@dev`,restart:!0}}),x(!1)},oe=()=>{a({id:w.current,sender:`Header`,method:`/api/checkupdates`,src:`Frontend`,dst:`Matterbridge`,params:{}})},se=()=>{q&&console.log(`Header: handleShellySystemUpdateClick`),o(`Matterbridge`,`Installing system updates...`),a({id:w.current,sender:`Header`,method:`/api/shellysysupdate`,src:`Frontend`,dst:`Matterbridge`,params:{}})},le=()=>{q&&console.log(`Header: handleShellyMainUpdateClick`),o(`Matterbridge`,`Installing software updates...`),a({id:w.current,sender:`Header`,method:`/api/shellymainupdate`,src:`Frontend`,dst:`Matterbridge`,params:{}})},ue=()=>{q&&console.log(`Header: handleShellyCreateSystemLog`),a({id:w.current,sender:`Header`,method:`/api/shellycreatesystemlog`,src:`Frontend`,dst:`Matterbridge`,params:{}})},de=()=>{q&&console.log(`Header: handleShellyDownloadSystemLog`),o(`Matterbridge`,`Downloading Shelly system log...`),t(`Downloading Shelly system log...`,5),window.location.href=`./api/shellydownloadsystemlog`},fe=()=>{S?.matterbridgeInformation.restartMode===``?a({id:w.current,sender:`Header`,method:`/api/restart`,src:`Frontend`,dst:`Matterbridge`,params:{}}):a({id:w.current,sender:`Header`,method:`/api/shutdown`,src:`Frontend`,dst:`Matterbridge`,params:{}})},pe=()=>{a({id:w.current,sender:`Header`,method:`/api/shutdown`,src:`Frontend`,dst:`Matterbridge`,params:{}})},me=()=>{a({id:w.current,sender:`Header`,method:`/api/reboot`,src:`Frontend`,dst:`Matterbridge`,params:{}})},he=()=>{a({id:w.current,sender:`Header`,method:`/api/softreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},ge=()=>{a({id:w.current,sender:`Header`,method:`/api/hardreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},_e=e=>{D(e.currentTarget)},R=e=>{q&&console.log(`Header: handleMenuClose`,e),D(null),e===`/`||e===`/devices`||e===`/log`||e===`/settings`?ee(e):e===`reset_frontend`?(o(`Matterbridge`,`Resetting frontend UI...`),t(`Resetting frontend UI...`,5),Mt(),window.location.reload()):e===`download-mblog`?(o(`Matterbridge`,`Downloading matterbridge log...`),t(`Downloading matterbridge log...`,5),window.location.href=`./api/download-mblog`):e===`download-mjlog`?(o(`Matterbridge`,`Downloading matter log...`),t(`Downloading matter log...`,5),window.location.href=`./api/download-mjlog`):e===`view-mblog`?(o(`Matterbridge`,`Loading matterbridge log...`),t(`Loading matterbridge log...`,5),window.open(`./api/view-mblog`,`_blank`,`noopener,noreferrer`)):e===`view-mjlog`?(o(`Matterbridge`,`Loading matter log...`),t(`Loading matter log...`,5),window.open(`./api/view-mjlog`,`_blank`,`noopener,noreferrer`)):e===`view-diagnostic`?(o(`Matterbridge`,`Loading diagnostic log...`),t(`Loading diagnostic log...`,5),window.open(`./api/view-diagnostic`,`_blank`,`noopener,noreferrer`)):e===`download-diagnostic`?(o(`Matterbridge`,`Downloading diagnostic log...`),t(`Downloading diagnostic log...`,5),window.location.href=`./api/download-diagnostic`):e===`view-history`?a({id:w.current,sender:`Header`,method:`/api/viewhistorypage`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`download-history`?a({id:w.current,sender:`Header`,method:`/api/downloadhistorypage`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`view-shellylog`?(o(`Matterbridge`,`Loading shelly system log...`),t(`Loading shelly system log...`,5),window.location.href=`./api/shellyviewsystemlog`):e===`download-mbstorage`?(o(`Matterbridge`,`Downloading matterbridge storage...`),t(`Downloading matterbridge storage...`,5),window.location.href=`./api/download-mbstorage`):e===`download-pluginstorage`?(o(`Matterbridge`,`Downloading matterbridge plugins storage...`),t(`Downloading matterbridge plugins storage...`,5),window.location.href=`./api/download-pluginstorage`):e===`download-pluginconfig`?(o(`Matterbridge`,`Downloading matterbridge plugins config...`),t(`Downloading matterbridge plugins config...`,5),window.location.href=`./api/download-pluginconfig`):e===`download-mjstorage`?(o(`Matterbridge`,`Downloading matter storage...`),t(`Downloading matter storage...`,5),window.location.href=`./api/download-mjstorage`):e===`download-backup`?(o(`Matterbridge`,`Downloading backup...`),t(`Downloading backup...`,10),window.location.href=`./api/download-backup`):e===`update`?ae():e===`updatedev`?L():e===`updatecheck`?oe():e===`shelly-sys-update`?se():e===`shelly-main-update`?le():e===`shelly-create-system-log`?ue():e===`shelly-download-system-log`?de():e===`softreset`?he():e===`hardreset`?ge():e===`restart`?fe():e===`shutdown`?pe():e===`reboot`?me():e===`create-backup`?a({id:w.current,sender:`Header`,method:`/api/create-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-matterbridge-storage-backup`?a({id:w.current,sender:`Header`,method:`/api/create-matterbridge-storage-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-matter-storage-backup`?a({id:w.current,sender:`Header`,method:`/api/create-matter-storage-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-plugin-backup`?a({id:w.current,sender:`Header`,method:`/api/create-plugin-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-config-backup`?a({id:w.current,sender:`Header`,method:`/api/create-config-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`unregister`?a({id:w.current,sender:`Header`,method:`/api/unregister`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`reset`?a({id:w.current,sender:`Header`,method:`/api/reset`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`factoryreset`&&a({id:w.current,sender:`Header`,method:`/api/factoryreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},ve=e=>{q&&console.log(`Header: handleMenuCloseCancel:`,e),D(null)},ye=e=>{k(e.currentTarget)},xe=()=>{k(null)},Se=e=>{j(e.currentTarget)},Ce=()=>{j(null)},we=e=>{N(e.currentTarget)},Te=()=>{N(null)};return(0,G.useEffect)(()=>{let e=e=>{q&&console.log(`Header received WebSocket Message:`,e),e.method===`/api/settings`&&e.id===w.current?(q&&console.log(`Header received settings:`,e.response),C(e.response),p(e.response.matterbridgeInformation.restartRequired||e.response.matterbridgeInformation.fixedRestartRequired),h(e.response.matterbridgeInformation.fixedRestartRequired),y(e.response.matterbridgeInformation.updateRequired)):e.method===`refresh_required`&&e.response.changed===`settings`?(q&&console.log(`Header received refresh_required: changed=${e.response.changed} and sending /api/settings request`),a({id:w.current,sender:`Header`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`restart_required`?(q&&console.log(`Header received restart_required with fixed: ${e.response.fixed}`),p(!0),e.response.fixed&&h(!0)):e.method===`restart_not_required`?(q&&console.log(`Header received restart_not_required`),p(!1)):e.method===`update_required`?(q&&console.log(`Header received update_required`),e.response.devVersion?x(!0):y(!0),a({id:w.current,sender:`Header`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`shelly_sys_update`?(q&&console.log(`Header received WS_ID_SHELLY_SYS_UPDATE:`),C(t=>t?{matterbridgeInformation:{...t.matterbridgeInformation,shellySysUpdate:e.response.available},systemInformation:t.systemInformation}:null)):e.method===`shelly_main_update`?(q&&console.log(`Header received WS_ID_SHELLY_MAIN_UPDATE:`),C(t=>t?{matterbridgeInformation:{...t.matterbridgeInformation,shellyMainUpdate:e.response.available},systemInformation:t.systemInformation}:null)):e.method===`/api/viewhistorypage`&&e.id===w.current&&e.success?(q&&console.log(`Header received /api/viewhistorypage success`),window.open(`./api/viewhistory`,`_blank`,`noopener,noreferrer`)):e.method===`/api/downloadhistorypage`&&e.id===w.current&&e.success?(q&&console.log(`Header received /api/downloadhistorypage success`),window.location.href=`./api/downloadhistory`):e.method===`archive`&&e.success&&e.response.command===`zip`&&(q&&console.log(`Header received archive success response for zip command`,e.response),e.response.archivePath.endsWith(`matterbridge.backup.zip`)?window.location.href=`./api/download-backup`:e.response.archivePath.endsWith(`matterbridge.storage.zip`)?window.location.href=`./api/download-mbstorage`:e.response.archivePath.endsWith(`matterbridge.matterstorage.zip`)?window.location.href=`./api/download-mjstorage`:e.response.archivePath.endsWith(`matterbridge.pluginstorage.zip`)?window.location.href=`./api/download-pluginstorage`:e.response.archivePath.endsWith(`matterbridge.pluginconfig.zip`)&&(window.location.href=`./api/download-pluginconfig`))};return c(e,w.current),q&&console.log(`Header added WebSocket listener id ${w.current}`),()=>{l(e),q&&console.log(`Header removed WebSocket listener`)}},[c,l,a,t]),(0,G.useEffect)(()=>{i&&(q&&console.log(`Header sending /api/settings and /api/checkupdates requests`),a({id:w.current,sender:`Header`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),a({id:w.current,sender:`Header`,method:`/api/checkupdates`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[i,a]),q&&console.log(`Header rendering... mobile %s`,e),!i||!S?null:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`,width:`100%`,gap:`10px`},children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`},onClick:()=>{Nt(),q&&console.log(`Matterbridge logo clicked: debug is now`,q)},children:(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`30px`}})}),(0,Y.jsx)(`h2`,{style:{fontSize:`22px`,color:`var(--main-icon-color)`,margin:`0px`},children:`Matterbridge`})]}),(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:(0,Y.jsxs)(`nav`,{children:[(0,Y.jsx)(s,{to:`/`,className:`nav-link`,children:`Home`}),(0,Y.jsx)(s,{to:`/devices`,className:`nav-link`,children:`Devices`}),(0,Y.jsx)(s,{to:`/log`,className:`nav-link`,children:`Logs`}),(0,Y.jsx)(s,{to:`/settings`,className:`nav-link`,children:`Settings`})]})})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[!S.matterbridgeInformation.readOnly&&(0,Y.jsx)(H,{title:`Matterbridge v.${S.matterbridgeInformation.matterbridgeVersion}`,children:(0,Y.jsxs)(`span`,{className:`status-information`,style:{cursor:`default`},children:[`v.`,S.matterbridgeInformation.matterbridgeVersion.split(`-`)[0]+(S.matterbridgeInformation.matterbridgeVersion.includes(`-dev-`)?`@dev`:``)+(S.matterbridgeInformation.matterbridgeVersion.includes(`-edge-`)?`@edge`:``)+(S.matterbridgeInformation.matterbridgeVersion.includes(`-local-`)?`@local`:``)+(S.matterbridgeInformation.matterbridgeVersion.includes(`-git-`)?`@git`:``)]})}),S.matterbridgeInformation.shellyBoard&&(0,Y.jsx)(`img`,{src:`Shelly.svg`,alt:`Shelly Icon`,style:{height:`30px`,padding:`0px`,margin:`0px`,marginRight:`30px`}}),S.matterbridgeInformation.bridgeMode!==``&&!S.matterbridgeInformation.readOnly?(0,Y.jsx)(H,{title:`Bridge mode`,children:(0,Y.jsx)(`span`,{className:`status-information`,style:{cursor:`default`},children:S.matterbridgeInformation.bridgeMode})}):null,S.matterbridgeInformation.restartMode!==``&&!S.matterbridgeInformation.readOnly?(0,Y.jsx)(H,{title:`Restart mode`,children:(0,Y.jsx)(`span`,{className:`status-information`,style:{cursor:`default`},children:S.matterbridgeInformation.restartMode})}):null,S.matterbridgeInformation.profile&&S.matterbridgeInformation.profile!==``&&!S.matterbridgeInformation.readOnly?(0,Y.jsx)(H,{title:`Current profile`,children:(0,Y.jsx)(`span`,{className:`status-information`,style:{cursor:`default`},children:S.matterbridgeInformation.profile})}):null,q&&(0,Y.jsxs)(`span`,{className:`status-information`,style:{cursor:`default`},children:[e?`Mobile `:`Desktop `,`${Br}x${Vr}`,` enabled ${localStorage.getItem(K.enableMobile)!==`false`}`]})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`5px`},children:[S.matterbridgeInformation.readOnly?null:(0,Y.jsx)(H,{title:`Matterbridge discord group`,children:(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`},onClick:re,children:(0,Y.jsx)(`img`,{src:`discord.svg`,alt:`Discord Logo`,style:{height:`25px`}})})}),S.matterbridgeInformation.readOnly?null:(0,Y.jsx)(H,{title:`Give a star to Matterbridge`,children:(0,Y.jsx)(T,{style:{color:`#FFD700`,margin:`0`,padding:`0`},onClick:ie,children:(0,Y.jsx)(Xe,{})})}),S.matterbridgeInformation.readOnly?null:(0,Y.jsx)(H,{title:`Sponsor Matterbridge`,children:(0,Y.jsx)(T,{style:{color:`#b6409c`,margin:`0`,padding:`0`},onClick:F,children:(0,Y.jsx)(it,{})})}),(0,Y.jsx)(H,{title:`Matterbridge homepage`,children:(0,Y.jsx)(T,{style:{color:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:te,children:(0,Y.jsx)(ce,{})})}),(0,Y.jsx)(H,{title:`Matterbridge help`,children:(0,Y.jsx)(T,{style:{color:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:I,children:(0,Y.jsx)(g,{})})}),(0,Y.jsx)(H,{title:`Matterbridge changelog`,children:(0,Y.jsx)(T,{style:{color:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:ne,children:(0,Y.jsx)(v,{})})}),S.matterbridgeInformation&&!S.matterbridgeInformation.readOnly&&_&&(0,Y.jsx)(H,{title:`Update matterbridge to latest version v.${S.matterbridgeInformation.matterbridgeLatestVersion}`,children:(0,Y.jsx)(T,{style:{color:`var(--primary-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:ae,children:(0,Y.jsx)(st,{})})}),S.matterbridgeInformation&&!S.matterbridgeInformation.readOnly&&b&&(0,Y.jsx)(H,{title:`Update matterbridge to latest dev version v.${S.matterbridgeInformation.matterbridgeDevVersion}`,children:(0,Y.jsx)(T,{style:{color:`var(--secondary-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:L,children:(0,Y.jsx)(st,{})})}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&S.matterbridgeInformation.shellySysUpdate&&(0,Y.jsx)(H,{title:`Shelly system update`,children:(0,Y.jsx)(T,{style:{color:`var(--primary-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:se,children:(0,Y.jsx)(st,{})})}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&S.matterbridgeInformation.shellyMainUpdate&&(0,Y.jsx)(H,{title:`Shelly software update`,children:(0,Y.jsx)(T,{style:{color:`var(--primary-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:le,children:(0,Y.jsx)(st,{})})}),(0,Y.jsx)(H,{title:`Restart matterbridge`,children:(0,Y.jsx)(T,{style:{color:f||m?`var(--primary-color)`:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:fe,children:(0,Y.jsx)(ot,{})})}),S.matterbridgeInformation.restartMode===``?(0,Y.jsx)(H,{title:`Shut down matterbridge`,children:(0,Y.jsx)(T,{style:{color:f||m?`var(--primary-color)`:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:pe,children:(0,Y.jsx)(be,{})})}):null,(0,Y.jsx)(H,{title:`Download, backup and more`,children:(0,Y.jsx)(T,{onClick:_e,children:(0,Y.jsx)(We,{style:{color:`var(--main-icon-color)`}})})}),(0,Y.jsxs)(ct,{id:`command-menu`,anchorEl:E,keepMounted:!0,open:!!E,onClose:()=>R(``),children:[J&&e&&(0,Y.jsxs)(V,{onClick:()=>R(`/`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Home page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),J&&e&&(0,Y.jsxs)(V,{onClick:()=>R(`/devices`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Devices page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),J&&e&&(0,Y.jsxs)(V,{onClick:()=>R(`/log`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Logs page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),J&&e&&(0,Y.jsxs)(V,{onClick:()=>R(`/settings`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Settings page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&!S.matterbridgeInformation.readOnly&&(0,Y.jsxs)(V,{onClick:()=>R(`update`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(st,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Install latest stable`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&!S.matterbridgeInformation.readOnly&&(0,Y.jsxs)(V,{onClick:()=>R(`updatedev`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(st,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Install latest dev`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&!S.matterbridgeInformation.readOnly&&(0,Y.jsxs)(V,{onClick:()=>R(`updatecheck`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(st,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Check for updates`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&S.matterbridgeInformation.shellySysUpdate&&(0,Y.jsxs)(V,{onClick:()=>R(`shelly-sys-update`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(st,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Shelly system update`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&S.matterbridgeInformation.shellyMainUpdate&&(0,Y.jsxs)(V,{onClick:()=>R(`shelly-main-update`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(st,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Shelly software update`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>R(`restart`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(ot,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Restart`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation.restartMode===``?(0,Y.jsxs)(V,{onClick:()=>R(`shutdown`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Shutdown`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}):null,S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,Y.jsxs)(V,{onClick:()=>{n(`Reboot`,`Are you sure you want to reboot the Shelly board?`,`reboot`,R,ve)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(ot,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Reboot...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsx)(P,{}),(0,Y.jsxs)(V,{onClick:ye,children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`View`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(ct,{id:`sub-menu-view`,anchorEl:O,keepMounted:!0,open:!!O,onClose:xe,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,Y.jsxs)(V,{onClick:()=>{Ft(),xe(),ve(``),window.open(`/home`,`_self`)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Desktop site`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{Pt(),xe(),ve(``),window.open(`/home`,`_self`)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Mobile site`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`view-mblog`),xe()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`view-mjlog`),xe()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matter log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`view-diagnostic`),xe()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge diagnostic log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`view-history`),xe()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge system history`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,Y.jsxs)(V,{onClick:()=>{R(`view-shellylog`),xe()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Shelly system log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]})]}),(0,Y.jsx)(P,{}),(0,Y.jsxs)(V,{onClick:Se,children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Download`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(ct,{id:`sub-menu-download`,anchorEl:A,keepMounted:!0,open:!!A,onClose:Ce,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,Y.jsxs)(V,{onClick:()=>{R(`create-matterbridge-storage-backup`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge storage`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`create-plugin-backup`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge plugins storage`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`create-config-backup`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge plugins config`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`download-mblog`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`create-matter-storage-backup`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matter storage`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`download-mjlog`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matter log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`download-diagnostic`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge diagnostic log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`download-history`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge system history`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,Y.jsxs)(V,{onClick:()=>{R(`shelly-create-system-log`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Create Shelly system log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,Y.jsxs)(V,{onClick:()=>{R(`shelly-download-system-log`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Download Shelly system log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]})]}),(0,Y.jsx)(P,{}),(0,Y.jsxs)(V,{onClick:()=>{R(`create-backup`)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(Je,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Backup`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsx)(P,{}),(0,Y.jsxs)(V,{onClick:we,children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(Me,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Reset`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(ct,{id:`sub-menu-reset`,anchorEl:M,keepMounted:!0,open:!!M,onClose:Te,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,Y.jsxs)(V,{onClick:()=>{Te(),n(`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`,R,ve)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Reset the frontend UI...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{Te(),n(`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`,R,ve)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Reset all devices...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{Te(),n(`Reset commissioning and shutdown`,`Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.`,`reset`,R,ve)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Reset commissioning...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),!S.matterbridgeInformation.readOnly&&(0,Y.jsxs)(V,{onClick:()=>{Te(),n(`Factory reset and shutdown`,`Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.`,`factoryreset`,R,ve)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Factory reset...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,Y.jsxs)(V,{onClick:()=>{Te(),n(`Network reset`,`Are you sure you want to factory reset the network parameters?`,`softreset`,R,ve)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Reset network...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,Y.jsxs)(V,{onClick:()=>{Te(),n(`Factory reset`,`Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.`,`hardreset`,R,ve)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Factory reset...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]})]})]})]})]})}var Wr=(0,G.memo)(Ur);function Gr(){if(typeof window<`u`){let e=Math.floor(window.visualViewport?.width??window.innerWidth),t=Math.floor(window.visualViewport?.height??window.innerHeight);Hr(e,t);let n=e<1200||t<900;return q&&console.log(`Visual viewport (%s) width %i height %i mobile %s`,window.visualViewport!==void 0,e,t,n),n}return!1}function Kr({children:e}){let{mobile:t,setMobile:n}=(0,G.useContext)(Vt),{logAutoScroll:r}=(0,G.useContext)(X);return(0,G.useEffect)(()=>{function e(){let e=Gr();e&&(r.current=!1,localStorage.setItem(K.logAutoScroll,`false`)),n(e)}return window.addEventListener(`resize`,e),n(Gr()),()=>window.removeEventListener(`resize`,e)},[r,n]),q&&console.log(`MbfScreen rendering... mobile %s`,t),J&&t?(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,overflow:`visible`,margin:`0px`,padding:`10px`,gap:`10px`},children:[(0,Y.jsx)(Wr,{}),(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,width:`100%`,height:`100%`,margin:`0px`,padding:`0px`,gap:`10px`},children:e})]}):(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,overflow:`hidden`,width:t?`${zr}px`:`calc(100vw - 40px)`,height:t?`900px`:`calc(100vh - 40px)`,margin:`0px`,padding:`20px`,gap:`20px`},children:[(0,Y.jsx)(Wr,{}),(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,width:`100%`,height:`calc(100% - 60px)`,margin:`0px`,padding:`0px`,gap:`20px`},children:e})]})}function qr(e=1e3){let t=null,n=(n=>{t!==null&&window.clearTimeout(t),t=window.setTimeout(()=>{n(),t=null},e)});return n.cancel=()=>{t!==null&&(window.clearTimeout(t),t=null)},n}var Jr=({open:e,onClose:t,onSave:n})=>{let[r,i]=(0,G.useState)(``),[a,o]=(0,G.useState)(``),s=e=>{i(e.target.value)},c=e=>{o(e.target.value)},l=r.length>0&&r===a;return(0,Y.jsxs)(D,{open:e,onClose:(e,n)=>{n===`backdropClick`||n===`escapeKeyDown`||t()},maxWidth:`sm`,style:{maxWidth:`500px`,margin:`auto`},disableEscapeKeyDown:!0,children:[(0,Y.jsx)(F,{children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h4`,{style:{margin:0},children:`Change Password`})]})}),(0,Y.jsx)(re,{dividers:!0,children:(0,Y.jsx)(Fe,{component:`fieldset`,fullWidth:!0,sx:{margin:0,padding:0,gap:`20px`},children:(0,Y.jsxs)(_,{container:!0,spacing:2,sx:{mt:2},children:[(0,Y.jsx)(_,{size:12,children:(0,Y.jsx)(B,{type:`password`,autoComplete:`new-password`,label:`New Password`,size:`small`,variant:`outlined`,fullWidth:!0,value:r,onChange:s})}),(0,Y.jsx)(_,{size:12,children:(0,Y.jsx)(B,{type:`password`,autoComplete:`new-password`,label:`Confirm Password`,size:`small`,variant:`outlined`,fullWidth:!0,value:a,onChange:c,error:a!==``&&r!==a,helperText:a!==``&&r!==a?`Passwords do not match`:``})})]})})}),(0,Y.jsxs)(x,{children:[(0,Y.jsx)(L,{onClick:()=>{t()},children:`Cancel`}),(0,Y.jsx)(L,{variant:`contained`,onClick:()=>{l&&(n(r),t())},disabled:!l,children:`Change`}),(0,Y.jsx)(L,{variant:`contained`,onClick:()=>{n(``),t()},children:`Reset`})]})]})},Yr=({open:e,ip:t,onClose:n,onSave:r})=>{let i=t?t.split(`.`).slice(0,3).join(`.`)+`.1`:``,[a,o]=(0,G.useState)(`dhcp`),[s,c]=(0,G.useState)({ip:t??``,subnet:`255.255.255.0`,gateway:i,dns:i}),l=e=>t=>{c({...s,[e]:t.target.value})};return(0,Y.jsxs)(D,{open:e,onClose:(e,t)=>{t===`backdropClick`||t===`escapeKeyDown`||n()},maxWidth:`sm`,style:{maxWidth:`550px`,margin:`auto`},children:[(0,Y.jsx)(F,{gap:`20px`,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h4`,{style:{margin:0},children:`Network Configuration`})]})}),(0,Y.jsxs)(re,{dividers:!0,children:[(0,Y.jsxs)(Fe,{component:`fieldset`,fullWidth:!0,children:[(0,Y.jsx)(I,{component:`legend`,children:`Select IP Configuration`}),(0,Y.jsxs)(Ve,{row:!0,value:a,onChange:e=>o(e.target.value),children:[(0,Y.jsx)(d,{value:`dhcp`,control:(0,Y.jsx)(je,{}),label:`DHCP`}),(0,Y.jsx)(d,{value:`static`,control:(0,Y.jsx)(je,{}),label:`Static`})]})]}),a===`static`&&(0,Y.jsxs)(_,{container:!0,spacing:2,sx:{mt:2},children:[(0,Y.jsx)(_,{size:6,children:(0,Y.jsx)(B,{label:`IP Address`,fullWidth:!0,value:s.ip,onChange:l(`ip`)})}),(0,Y.jsx)(_,{size:6,children:(0,Y.jsx)(B,{label:`Subnet Mask`,fullWidth:!0,value:s.subnet,onChange:l(`subnet`)})}),(0,Y.jsx)(_,{size:6,children:(0,Y.jsx)(B,{label:`Gateway`,fullWidth:!0,value:s.gateway,onChange:l(`gateway`)})}),(0,Y.jsx)(_,{size:6,children:(0,Y.jsx)(B,{label:`DNS Server`,fullWidth:!0,value:s.dns,onChange:l(`dns`)})})]})]}),(0,Y.jsxs)(x,{children:[(0,Y.jsx)(L,{onClick:()=>{n()},children:`Cancel`}),(0,Y.jsx)(L,{variant:`contained`,onClick:()=>{r({type:a,...s}),n()},children:`Save`})]})]})},Xr=330;function Zr(){let{mobile:e}=(0,G.useContext)(Vt),{online:t,addListener:n,removeListener:r,sendMessage:i,getUniqueId:a}=(0,G.useContext)(X),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),u=(0,G.useRef)(a());return(0,G.useEffect)(()=>{let e=e=>{q&&console.log(`Settings received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`settings`?(q&&console.log(`Settings received refresh_required: changed=${e.response.changed} and sending /api/settings request`),i({id:u.current,sender:`Settings`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`/api/settings`&&(q&&console.log(`Settings received /api/settings:`,e.response),s(e.response.matterbridgeInformation),l(e.response.systemInformation))};return n(e,u.current),q&&console.log(`Settings added WebSocket listener`),()=>{r(e),q&&console.log(`Settings removed WebSocket listener`)}},[n,r,i]),(0,G.useEffect)(()=>{t&&(q&&console.log(`Settings received online`),i({id:u.current,sender:`Settings`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[t,i]),q&&console.log(`Settings rendering...`),!t||!o||!c?(0,Y.jsx)(Wt,{}):(0,Y.jsx)(kn,{name:`Settings`,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:J&&e?`10px`:`20px`},children:[(0,Y.jsx)(Qr,{matterbridgeInfo:o,systemInfo:c}),(0,Y.jsx)($r,{matterbridgeInfo:o}),(0,Y.jsx)(ei,{matterbridgeInfo:o}),(0,Y.jsx)(ti,{systemInfo:c})]})})}function Qr({matterbridgeInfo:e,systemInfo:t}){let{sendMessage:n,getUniqueId:r}=(0,G.useContext)(X),[i,a]=(0,G.useState)(`bridge`),[o,s]=(0,G.useState)(`Info`),[c,l]=(0,G.useState)(!1),[u,f]=(0,G.useState)(`dark`),[p,m]=(0,G.useState)(localStorage.getItem(K.homePagePlugins)!==`false`),[h,g]=(0,G.useState)(localStorage.getItem(K.homePageMode)??`devices`),[_,v]=(0,G.useState)(localStorage.getItem(K.virtualMode)??`outlet`),y=(0,G.useRef)(r()),[b,x]=(0,G.useState)(!1),S=()=>x(!1),C=e=>{q&&console.log(`handleSaveNetConfig called with config:`,e),n({id:y.current,sender:`Settings`,method:`/api/shellynetconfig`,src:`Frontend`,dst:`Matterbridge`,params:e})},[w,T]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{e&&(a(e.bridgeMode===`bridge`?`bridge`:`childbridge`),s(e.loggerLevel.charAt(0).toUpperCase()+e.loggerLevel.slice(1)),l(e.fileLogger),v(e.virtualMode))},[e]),(0,G.useEffect)(()=>{let e=localStorage.getItem(K.frontendTheme);e&&f(e)},[]),!e||!t?null:(0,Y.jsxs)(Q,{style:{flex:`1 1 ${Xr}px`},children:[(0,Y.jsx)(Gt,{children:(0,Y.jsx)(Kt,{children:`Matterbridge settings`})}),(0,Y.jsx)(Yr,{open:b,ip:t.ipv4Address,onClose:S,onSave:C}),(0,Y.jsx)(Jr,{open:w,onClose:()=>T(!1),onSave:e=>{q&&console.log(`handleSaveChangePassword called with password:`,e),n({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setpassword`,value:e}}),Lt(e)}}),(0,Y.jsxs)(Xt,{style:{flexDirection:`column`,padding:`10px`,gap:`0px`,backgroundColor:`var(--div-bg-color)`,color:`var(--div-text-color)`},children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`matterbridgeInfo-mode`,children:`Mode:`}),(0,Y.jsxs)(Ve,{row:!0,name:`mode-buttons-group`,value:i,onChange:e=>{q&&console.log(`handleChangeBridgeMode called with value:`,e.target.value),a(e.target.value),n({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setbridgemode`,value:e.target.value}})},children:[(0,Y.jsx)(d,{value:`bridge`,control:(0,Y.jsx)(je,{}),label:`Bridge`,disabled:e.readOnly}),(0,Y.jsx)(d,{value:`childbridge`,control:(0,Y.jsx)(je,{}),label:`Childbridge`,disabled:e.readOnly})]})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,marginBottom:`5px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`mblogger-level-label`,children:`Logger level:`}),(0,Y.jsxs)(ye,{style:{height:`30px`},labelId:`mblogger-level-label`,id:`mblogger-level`,value:o,onChange:e=>{q&&console.log(`handleChangeMbLoggerLevel called with value:`,e.target.value),s(e.target.value),n({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmbloglevel`,value:e.target.value}})},children:[(0,Y.jsx)(V,{value:`Debug`,children:`Debug`}),(0,Y.jsx)(V,{value:`Info`,children:`Info`}),(0,Y.jsx)(V,{value:`Notice`,children:`Notice`}),(0,Y.jsx)(V,{value:`Warn`,children:`Warn`}),(0,Y.jsx)(V,{value:`Error`,children:`Error`}),(0,Y.jsx)(V,{value:`Fatal`,children:`Fatal`})]})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`mblogger-file-label`,children:`Log on file:`}),(0,Y.jsx)(M,{checked:c,onChange:e=>{q&&console.log(`handleLogOnFileMbChange called with value:`,e.target.checked),l(e.target.checked),n({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmblogfile`,value:e.target.checked}})},id:`mblogger-file`,name:`logOnFileMb`})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`5px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`frontend-theme-label`,children:`Frontend theme:`}),(0,Y.jsxs)(ye,{style:{height:`30px`},labelId:`frontend-theme-label`,id:`frontend-theme`,value:u,onChange:e=>{let t=e.target.value;q&&console.log(`handleChangeTheme called with value:`,t),f(t),localStorage.setItem(K.frontendTheme,t),document.body.setAttribute(`frontend-theme`,t)},children:[(0,Y.jsx)(V,{value:`classic`,children:`Classic`}),(0,Y.jsx)(V,{value:`light`,children:`Light`}),(0,Y.jsx)(V,{value:`dark`,children:`Dark`})]})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`5px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`frontend-home-plugin-label`,children:`Home page plugins:`}),(0,Y.jsx)(M,{checked:p,onChange:e=>{let t=e.target.checked;q&&console.log(`handleChangeHomePagePlugins called with value:`,t),m(t),localStorage.setItem(K.homePagePlugins,t?`true`:`false`)},name:`showPlugins`})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`5px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`frontend-home-label`,children:`Home page bottom panel:`}),(0,Y.jsxs)(ye,{style:{height:`30px`},labelId:`frontend-home-label`,id:`frontend-home`,value:h,onChange:e=>{let t=e.target.value;q&&console.log(`handleChangeHomePageMode called with value:`,t),g(t),localStorage.setItem(K.homePageMode,t)},children:[(0,Y.jsx)(V,{value:`logs`,children:`Logs`}),(0,Y.jsx)(V,{value:`devices`,children:`Devices`})]})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`10px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`frontend-virtual-label`,children:`Virtual devices:`}),(0,Y.jsxs)(ye,{style:{height:`30px`},labelId:`frontend-virtual-label`,id:`frontend-virtual`,value:_,onChange:e=>{let t=e.target.value;q&&console.log(`handleChangeVirtualMode called with value:`,t),v(t),localStorage.setItem(K.virtualMode,t),n({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setvirtualmode`,value:t}})},children:[(0,Y.jsx)(V,{value:`disabled`,children:`Disabled`}),(0,Y.jsx)(V,{value:`outlet`,children:`Outlet`}),(0,Y.jsx)(V,{value:`light`,children:`Light`}),(0,Y.jsx)(V,{value:`switch`,children:`Switch`}),(0,Y.jsx)(V,{value:`mounted_switch`,children:`Mounted Switch`})]})]}),(0,Y.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`20px`},children:(0,Y.jsx)(L,{variant:`contained`,color:`primary`,onClick:()=>T(!0),children:`Change password`})}),e.shellyBoard&&(0,Y.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`20px`},children:(0,Y.jsx)(L,{variant:`contained`,color:`primary`,onClick:()=>x(!0),children:`Configure IP`})})]})]})}function $r({matterbridgeInfo:e}){let{sendMessage:t,getUniqueId:n}=(0,G.useContext)(X),[r,i]=(0,G.useState)(`Info`),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(``),[l,u]=(0,G.useState)(``),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(``),[_,v]=(0,G.useState)(``),y=(0,G.useRef)(n()),b=(0,G.useMemo)(()=>qr(1e3),[]),x=(0,G.useMemo)(()=>qr(1e3),[]),S=(0,G.useMemo)(()=>qr(1e3),[]),C=(0,G.useMemo)(()=>qr(1e3),[]),w=(0,G.useMemo)(()=>qr(1e3),[]),T=(0,G.useMemo)(()=>qr(1e3),[]);return(0,G.useEffect)(()=>{e&&(i(e.matterLoggerLevel.charAt(0).toUpperCase()+e.matterLoggerLevel.slice(1)),o(e.matterFileLogger),c(e.matterMdnsInterface||``),u(e.matterIpv4Address||``),f(e.matterIpv6Address||``),m(e.matterPort?e.matterPort.toString():``),g(e.matterDiscriminator?e.matterDiscriminator.toString():``),v(e.matterPasscode?e.matterPasscode.toString():``))},[e]),(0,G.useEffect)(()=>()=>b.cancel(),[b]),(0,G.useEffect)(()=>()=>x.cancel(),[x]),(0,G.useEffect)(()=>()=>S.cancel(),[S]),(0,G.useEffect)(()=>()=>C.cancel(),[C]),(0,G.useEffect)(()=>()=>w.cancel(),[w]),(0,G.useEffect)(()=>()=>T.cancel(),[T]),e?(0,Y.jsxs)(Q,{style:{flex:`1 1 ${Xr}px`},children:[(0,Y.jsx)(Gt,{children:(0,Y.jsx)(Kt,{children:`Matter settings`})}),(0,Y.jsxs)(Xt,{style:{flexDirection:`column`,padding:`10px`,gap:`0px`,backgroundColor:`var(--div-bg-color)`,color:`var(--div-text-color)`},children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,marginBottom:`5px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`mjlogger-level-label`,children:`Logger level:`}),(0,Y.jsxs)(ye,{style:{height:`30px`},labelId:`mjlogger-level-label`,id:`mjlogger-level`,value:r,onChange:e=>{q&&console.log(`handleChangeMjLoggerLevel called with value:`,e.target.value),i(e.target.value),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmjloglevel`,value:e.target.value}})},children:[(0,Y.jsx)(V,{value:`Debug`,children:`Debug`}),(0,Y.jsx)(V,{value:`Info`,children:`Info`}),(0,Y.jsx)(V,{value:`Notice`,children:`Notice`}),(0,Y.jsx)(V,{value:`Warn`,children:`Warn`}),(0,Y.jsx)(V,{value:`Error`,children:`Error`}),(0,Y.jsx)(V,{value:`Fatal`,children:`Fatal`})]})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,marginBottom:`5px`,gap:`10px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`mjlogger-file-label`,children:`Log on file:`}),(0,Y.jsx)(M,{checked:a,onChange:e=>{q&&console.log(`handleLogOnFileMjChange called with value:`,e.target.checked),o(e.target.checked),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmjlogfile`,value:e.target.checked}})},id:`mjlogger-file`,name:`logOnFileMj`})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Mdns interface:`}),(0,Y.jsx)(B,{value:s,onChange:e=>{q&&console.log(`handleChangeMdnsInterface called with value:`,e.target.value);let n=e.target.value;c(n),b(()=>{q&&console.log(`debounced sendMessage setmdnsinterface with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmdnsinterface`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly,style:{height:`30px`,padding:`0`}}})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Ipv4 address:`}),(0,Y.jsx)(B,{value:l,onChange:e=>{q&&console.log(`handleChangeIpv4Address called with value:`,e.target.value);let n=e.target.value;u(n),x(()=>{q&&console.log(`debounced sendMessage setipv4address with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setipv4address`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly,style:{height:`30px`,padding:`0`}}})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Ipv6 address:`}),(0,Y.jsx)(B,{value:d,onChange:e=>{q&&console.log(`handleChangeIpv6Address called with value:`,e.target.value);let n=e.target.value;f(n),S(()=>{q&&console.log(`debounced sendMessage setipv6address with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setipv6address`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly,style:{height:`30px`,padding:`0`}}})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Commissioning port:`}),(0,Y.jsx)(B,{value:p,onChange:e=>{q&&console.log(`handleChangeMatterPort called with value:`,e.target.value);let n=e.target.value;m(n),C(()=>{q&&console.log(`debounced sendMessage setmatterport with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmatterport`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly,style:{height:`30px`,padding:`0`}}})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Commissioning discriminator:`}),(0,Y.jsx)(B,{value:h,onChange:e=>{q&&console.log(`handleChangeMatterDiscriminator called with value:`,e.target.value);let n=e.target.value;g(n),w(()=>{q&&console.log(`debounced sendMessage setmatterdiscriminator with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmatterdiscriminator`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly,style:{height:`30px`,padding:`0`}}})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Commissioning passcode:`}),(0,Y.jsx)(B,{value:_,onChange:e=>{q&&console.log(`handleChangemMatterPasscode called with value:`,e.target.value);let n=e.target.value;v(n),T(()=>{q&&console.log(`debounced sendMessage setmatterpasscode with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmatterpasscode`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly,style:{height:`30px`,padding:`0`}}})]})]})]}):null}function ei({matterbridgeInfo:e}){return e?(0,Y.jsxs)(Q,{style:{flex:`1 1 ${Xr}px`},children:[(0,Y.jsx)(Gt,{children:(0,Y.jsx)(Kt,{children:`Matterbridge info`})}),(0,Y.jsxs)(Xt,{style:{flexDirection:`column`,padding:`10px`,gap:`5px`},children:[(0,Y.jsx)(ni,{value:e.matterbridgeVersion,label:`Current Version`}),(0,Y.jsx)(ni,{value:e.matterbridgeLatestVersion,label:`Latest Version`}),(0,Y.jsx)(ni,{value:e.rootDirectory,label:`Root Directory`}),(0,Y.jsx)(ni,{value:e.homeDirectory,label:`Home Directory`}),(0,Y.jsx)(ni,{value:e.matterbridgeDirectory,label:`Matterbridge Storage Directory`}),(0,Y.jsx)(ni,{value:e.matterbridgePluginDirectory,label:`Matterbridge Plugin Directory`}),(0,Y.jsx)(ni,{value:e.globalModulesDirectory,label:`Global Module Directory`})]})]}):null}function ti({systemInfo:e}){return e?(0,Y.jsxs)(Q,{style:{flex:`1 1 ${Xr}px`},children:[(0,Y.jsx)(Gt,{children:(0,Y.jsx)(Kt,{children:`System info`})}),(0,Y.jsxs)(Xt,{style:{flexDirection:`column`,padding:`10px`,gap:`5px`},children:[(0,Y.jsx)(ni,{value:e.interfaceName,label:`Interface name`}),(0,Y.jsx)(ni,{value:e.macAddress,label:`MAC Address`}),(0,Y.jsx)(ni,{value:e.ipv4Address,label:`IPv4 Address`}),(0,Y.jsx)(ni,{value:e.ipv6Address,label:`IPv6 Address`}),(0,Y.jsx)(ni,{value:e.nodeVersion,label:`Node Version`}),(0,Y.jsx)(ni,{value:e.hostname,label:`Hostname`}),(0,Y.jsx)(ni,{value:e.user,label:`User`})]})]}):null}function ni({value:e,label:t,width:n}){return(0,Y.jsx)(B,{focused:!0,value:e,size:`small`,label:t,variant:`standard`,sx:{width:n?`${n-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)`}}}}})}var ri=(0,G.memo)(Zr);function ii(){let{online:e,sendMessage:t,addListener:n,removeListener:r,getUniqueId:i}=(0,G.useContext)(X),{showSnackbarMessage:a}=(0,G.useContext)(Vt),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)([]),[u,d]=(0,G.useState)([]),[f,p]=(0,G.useState)(null),[m,h]=(0,G.useState)({cpuUsage:0}),[g,_]=(0,G.useState)({totalMemory:``,freeMemory:``,heapTotal:``,heapUsed:``,external:``,arrayBuffers:``,rss:``}),[v,y]=(0,G.useState)({systemUptime:``,processUptime:``}),b=(0,G.useRef)(i());return q&&console.log(`Test uniqueId:`,b),(0,G.useEffect)(()=>{q&&console.log(`Test useEffect WebSocketMessage mounting`);let e=e=>{if(e.method===`restart_required`)q&&console.log(`Test received restart_required`),a(`Restart required`,0);else if(e.method===`refresh_required`)q&&console.log(`Test received refresh_required: changed=${e.response.changed} and sending api requests`),a(`Refresh required`,0),t({id:b.current,method:`/api/settings`,sender:`Test`,src:`Frontend`,dst:`Matterbridge`,params:{}}),t({id:b.current,method:`/api/plugins`,sender:`Test`,src:`Frontend`,dst:`Matterbridge`,params:{}}),t({id:b.current,method:`/api/devices`,sender:`Test`,src:`Frontend`,dst:`Matterbridge`,params:{}});else if(e.method===`memory_update`)q&&console.log(`Test received memory_update`,e),_(e.response);else if(e.method===`cpu_update`)q&&console.log(`Test received cpu_update`,e),h(e.response);else if(e.method===`uptime_update`)q&&console.log(`Test received uptime_update`,e),y(e.response);else if(e.method===`/api/settings`&&e.response)q&&console.log(`Test received /api/settings:`,e.response),a(`Test received /api/settings`,0),s(e.response);else if(e.method===`/api/plugins`&&e.response)q&&console.log(`Test received ${e.response.length} plugins:`,e.response),a(`Test received /api/plugins`,0),l(e.response);else if(e.method===`/api/devices`&&e.response){q&&console.log(`Test received ${e.response.length} devices:`,e.response),a(`Test received /api/devices`,0),d(e.response);for(let n of e.response)q&&console.log(`Test sending /api/clusters for device:`,n.pluginName,n.name,n.endpoint),t({id:b.current,method:`/api/clusters`,sender:`Test`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:n.pluginName,endpoint:n.endpoint||0}})}else e.method===`/api/clusters`&&e.response&&(q&&console.log(`Test received ${e.response.clusters.length} clusters for device ${e.response.deviceName} endpoint ${e.response.id}:${e.response.number}:`,e),a(`Test received /api/clusters for ${e.response.plugin}::${e.response.deviceName}`,0),p(e.response))};return n(e,b.current),q&&console.log(`Test useEffect WebSocketMessage mounted`),()=>{q&&console.log(`Test useEffect WebSocketMessage unmounting`),r(e),q&&console.log(`Test useEffect WebSocketMessage unmounted`)}},[n,r,t,a]),(0,G.useEffect)(()=>(q&&console.log(`Test useEffect online mounting`),e&&q&&console.log(`Test useEffect online received online`),q&&console.log(`Test useEffect online mounted`),()=>{q&&console.log(`Test useEffect online unmounted`)}),[e,t,a]),q&&console.log(`Test rendering...`),e?(0,Y.jsx)(kn,{name:`Test`,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,justifyContent:`center`,alignItems:`center`,alignContent:`center`,gap:`20px`,height:`100vh`,width:`100vw`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`256px`,width:`256px`,margin:`10px`}}),(0,Y.jsx)(`p`,{children:`Welcome to the Test page of the Matterbridge frontend`})]})}):(0,Y.jsx)(Wt,{})}var ai=(0,G.memo)(ii);function oi({open:e,title:t,message:n,onConfirm:r,onCancel:i}){return(0,Y.jsxs)(D,{open:e,children:[(0,Y.jsx)(F,{gap:`20px`,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h4`,{style:{margin:0},children:t})]})}),(0,Y.jsxs)(re,{children:[(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`center`,margin:`0`,marginBottom:`20px`,maxHeight:`350px`,maxWidth:`350px`},children:(0,Y.jsx)(`p`,{style:{flex:1,margin:`0`},children:n})}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`space-around`},children:[(0,Y.jsx)(L,{onClick:e=>{q&&console.log(`Confirmed`),e.preventDefault(),r()},variant:`contained`,color:`primary`,size:`small`,children:`Confirm`}),(0,Y.jsx)(L,{onClick:e=>{q&&console.log(`Canceled`),e.preventDefault(),i()},variant:`contained`,color:`primary`,size:`small`,children:`Cancel`})]})]})]})}var si=({open:e,output:t,title:n,_command:r,_packageName:i,onInstall:a,onClose:o})=>{let{installAutoExit:s,mobile:c,setInstallAutoExit:l}=(0,G.useContext)(Vt),u=(0,G.useRef)(null),f=e=>{l(e.target.checked),localStorage.setItem(K.installAutoExit,e.target.checked?`true`:`false`),q&&console.log(`handleInstallAutoExitChange called with value:`,e.target.checked)};return(0,G.useEffect)(()=>{q&&console.log(`InstallProgressDialog output effect mounted, scrolling to bottom:`,u.current),setTimeout(()=>{q&&console.log(`Scrolling to bottom:`,u.current),u.current?.scrollIntoView({behavior:`smooth`,block:`end`})},0)},[t]),(0,Y.jsxs)(D,{open:e,onClose:(e,t)=>{t===`backdropClick`||t===`escapeKeyDown`||o()},slotProps:{paper:{sx:{width:J&&c?`100vw`:`75vw`,maxWidth:J&&c?`100vw`:`75vw`,height:J&&c?`100vh`:`75vw`,maxHeight:J&&c?`100vh`:`75vh`,margin:J&&c?`0px`:void 0,overflow:`hidden`}}},children:[(0,Y.jsx)(F,{children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h4`,{style:{margin:0},children:n})]})}),(0,Y.jsxs)(re,{dividers:!0,style:{overflow:`hidden`,display:`flex`,flexDirection:`column`,height:400,paddingBottom:0},children:[(0,Y.jsx)(`div`,{style:{display:`block`,marginBottom:`10px`,fontSize:`16px`,fontWeight:`bold`,color:`var(--primary-color)`},children:`Process log`}),(0,Y.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:[t.split(`
|
|
42
|
+
`,t.head.appendChild(a)},[ae,se]=(0,G.useState)(),[ce,le]=(0,G.useState)(!1),ue=e=>{q&&console.log(`handleConfigPlugin plugin:`,e.name),r({id:l.current,sender:`HomePlugins`,method:`/api/select/devices`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:e.name}}),r({id:l.current,sender:`HomePlugins`,method:`/api/select/entities`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:e.name}}),se(e),de()},de=()=>{le(!0)};return q&&console.log(`HomePlugins rendering...`),n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(Q,{children:[ae&&(0,Y.jsx)(br,{open:ce,onClose:()=>{le(!1)},plugin:ae}),(0,Y.jsx)(Sn,{name:`Plugins`,columns:S,rows:h,footerRight:``,footerLeft:``})]}),(0,Y.jsxs)(D,{open:y!==null,onClose:()=>b(null),slotProps:{paper:{sx:{width:J&&s?`100vw`:`75vw`,height:J&&s?`100vh`:`75vh`,maxWidth:J&&s?`100vw`:`75vw`,maxHeight:J&&s?`100vh`:`75vh`,margin:J&&s?`0px`:void 0,display:`flex`,flexDirection:`column`,overflow:`hidden`,backgroundColor:`var(--div-bg-color)`}}},children:[(0,Y.jsx)(re,{style:{display:`flex`,flex:`1 1 auto`,minHeight:0,padding:`0px`,margin:`0px`,overflow:`hidden`,backgroundColor:`var(--div-bg-color)`},children:y&&(0,Y.jsx)(`iframe`,{title:`${y.name} frontend`,src:y.path,onLoad:ie,style:{display:`block`,flex:`1 1 auto`,width:`100%`,height:`100%`,border:`none`,backgroundColor:`var(--div-bg-color)`}})}),(0,Y.jsx)(x,{sx:{flex:`0 0 auto`,justifyContent:`center`},children:(0,Y.jsx)(L,{onClick:()=>b(null),children:`Close`})})]})]}):(0,Y.jsx)(Wt,{})}var Cr=(0,G.memo)(Sr);function wr({version:e,changelog:t}){let{online:n}=(0,G.useContext)(X);return q&&console.log(`HomeShowChangelog rendering...`),n?(0,Y.jsxs)(Q,{children:[(0,Y.jsx)(Gt,{children:(0,Y.jsx)(Kt,{children:`Matterbridge Update`})}),(0,Y.jsxs)(Xt,{style:{flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Y.jsxs)(`h4`,{style:{margin:0},children:[`Matterbridge has been updated to version `,e,`.`]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:`10px`},children:[(0,Y.jsx)(L,{onClick:()=>window.open(`https://github.com/Luligu/matterbridge`,`_blank`),endIcon:(0,Y.jsx)(Xe,{style:{color:`#FFD700`}}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Star`}),(0,Y.jsx)(L,{onClick:()=>window.open(`https://www.buymeacoffee.com/luligugithub`,`_blank`),endIcon:(0,Y.jsx)(it,{style:{color:`#b6409c`}}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Sponsor`}),(0,Y.jsx)(L,{onClick:()=>window.open(t,`_blank`),endIcon:(0,Y.jsx)(v,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Changelog`}),(0,Y.jsx)(L,{onClick:()=>window.location.reload(),endIcon:(0,Y.jsx)(Ce,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Close`})]})]})]}):(0,Y.jsx)(Wt,{})}var Tr=(0,G.memo)(wr);function Er({value:e,maxChars:t}){let n=e;if(e.length>t&&t>3){let r=t-3;n=`${e.substring(0,Math.ceil(r/2))} … ${e.substring(e.length-Math.floor(r/2),e.length)}`}return e===n?(0,Y.jsx)(`span`,{children:n}):(0,Y.jsx)(H,{title:e,placement:`top`,slotProps:{popper:{modifiers:[{name:`offset`,options:{offset:[0,12]}}]}},children:(0,Y.jsx)(`span`,{children:n})})}function Dr({matterbridgeInfo:e}){let{mobile:t}=(0,G.useContext)(Vt);q&&console.log(`MatterbridgeInfoTable:`,e);let n=new Set([`matterbridgeLatestVersion`,`matterbridgeDevVersion`,`dockerDev`,`dockerLatestVersion`,`dockerDevVersion`,`--matterFileLogger`,`--fileLogger`,`--matterLoggerLevel`,`--loggerLevel`,`--virtualMode`,`--bridgeMode`,`--restartMode`,`--restartRequired`,`fixedRestartRequired`,`--updateRequired`,`matterMdnsInterface`,`matterIpv4Address`,`matterIpv6Address`,`readOnly`,`shellyBoard`,`shellySysUpdate`,`shellyMainUpdate`,`matterPort`,`matterDiscriminator`,`matterPasscode`]),[r,i]=(0,G.useState)(!1);return!e||r?null:(q&&console.log(`MatterbridgeInfoTable rendering...`),(0,Y.jsxs)(Q,{style:J&&t?{flex:`1 1 300px`}:{flex:`0 1 auto`,width:`302px`,minWidth:`302px`},children:[(0,Y.jsxs)(Gt,{children:[(0,Y.jsx)(Kt,{children:`Matterbridge info`}),(0,Y.jsx)(Zt,{close:()=>i(!0)})]}),(0,Y.jsx)(Xt,{style:J&&t?{flex:`1 1 auto`,margin:`0px`,padding:`0px`,gap:`0px`}:{flex:`1 1 auto`,overflow:`auto`,margin:`0px`,padding:`0px`,gap:`0px`},children:(0,Y.jsxs)(`table`,{style:{border:`none`,borderCollapse:`collapse`,tableLayout:`fixed`},children:[(0,Y.jsxs)(`colgroup`,{children:[(0,Y.jsx)(`col`,{style:{width:`40%`}}),(0,Y.jsx)(`col`,{style:{width:`60%`}})]}),(0,Y.jsx)(`tbody`,{style:{border:`none`,borderCollapse:`collapse`},children:Object.entries(e).filter(([e,t])=>!n.has(e)&&t!=null&&t!==``).map(([e,n],r)=>(0,Y.jsxs)(`tr`,{className:r%2==0?`table-content-even`:`table-content-odd`,style:{border:`none`,borderCollapse:`collapse`},children:[(0,Y.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`},children:e.replace(`matterbridgeVersion`,`Matterbridge version`).replace(`frontendVersion`,`Frontend version`).replace(`dockerVersion`,`Docker 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`)}),(0,Y.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:J&&t?typeof n==`string`?n:n.toString():(0,Y.jsx)(Er,{value:typeof n==`string`?n:n.toString(),maxChars:24})})]},e))})]})})]}))}var Or=(0,G.memo)(Dr),kr={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`}},Ar=e=>{if(!e)return``;let t=e.replace(/[^0-9]/g,``);return t.length<5?t:[t.slice(0,4),t.slice(4,7),t.slice(7,11)].filter(Boolean).join(`-`)};function jr({id:e}){let{online:t,sendMessage:n,addListener:r,removeListener:i,getUniqueId:a}=(0,G.useContext)(X),[o,s]=(0,G.useState)(null),c=(0,G.useRef)(null),l=(0,G.useRef)(null),u=(0,G.useRef)(a()),{mobile:d,showConfirmCancelDialog:f}=(0,G.useContext)(Vt);q&&console.log(`QRDiv loading with id = "${e}" storeId = "${c.current}" timeout = ${l.current?`set`:`none`} and matter:`,o),(0,G.useEffect)(()=>{q&&console.log(`QRDiv id effect "${e}"`),c.current=e,l.current&&clearTimeout(l.current),l.current=null,e?(q&&console.log(`QRDiv id effect sending data request for storeId "${e}"`),n({id:u.current,sender:`QRDiv`,method:`/api/matter`,src:`Frontend`,dst:`Matterbridge`,params:{id:e,server:!0}})):(q&&console.log(`QRDiv id effect setting matter to null`),s(null))},[e,n]),(0,G.useEffect)(()=>{let e=e=>{q&&console.log(`QRDiv received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`matter`&&e.response.matter&&(q&&console.log(`QRDiv received refresh_required: changed=${e.response.changed} for storeId "${e.response.matter.id}":`,e.response.matter),c.current===e.response.matter.id&&(q&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${e.response.matter.id}":`,e.response.matter),l.current&&clearTimeout(l.current),s(e.response.matter)))};return r(e,u.current),q&&console.log(`QRDiv webSocket effect mounted`),()=>{i(e),l.current&&clearTimeout(l.current),l.current=null,q&&console.log(`QRDiv webSocket effect unmounted`)}},[r,i]);let p=()=>{q&&console.log(`QRDiv sent matter startCommission for node "${o?.id}"`),o&&n({id:u.current,sender:`QRDiv`,method:`/api/matter`,src:`Frontend`,dst:`Matterbridge`,params:{id:o.id,startCommission:!0}})},m=()=>{q&&console.log(`QRDiv sent matter stopCommission for node "${o?.id}"`),o&&n({id:u.current,sender:`QRDiv`,method:`/api/matter`,src:`Frontend`,dst:`Matterbridge`,params:{id:o.id,stopCommission:!0}})},h=()=>{q&&console.log(`QRDiv sent matter advertise for node "${o?.id}"`),o&&n({id:u.current,sender:`QRDiv`,method:`/api/matter`,src:`Frontend`,dst:`Matterbridge`,params:{id:o.id,advertise:!0}})},g=e=>{q&&console.log(`QRDiv sent matter removeFabric for node "${o?.id}" and fabricIndex ${e}`),o&&n({id:u.current,sender:`QRDiv`,method:`/api/matter`,src:`Frontend`,dst:`Matterbridge`,params:{id:o.id,removeFabric:e}})};return!o||!t?(q&&console.log(`QRDiv rendering undefined state`),null):o.online?o.advertising&&o.qrPairingCode&&o.manualPairingCode?(q&&console.log(`QRDiv rendering advertising state`),(0,Y.jsxs)(Q,{style:J&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`},children:[(0,Y.jsxs)(Gt,{children:[(0,Y.jsx)(Kt,{children:`QR pairing code`}),(0,Y.jsxs)(Zt,{children:[(0,Y.jsx)(T,{"aria-label":`send advertising`,size:`small`,onClick:h,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,Y.jsx)(H,{title:`Send again the mDNS advertisement`,arrow:!0,children:(0,Y.jsx)(Z.Icon,{path:dt,size:`22px`})})}),(0,Y.jsx)(T,{"aria-label":`stop pairing`,size:`small`,onClick:m,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,Y.jsx)(H,{title:`Turn off pairing`,arrow:!0,children:(0,Y.jsx)(Z.Icon,{path:gt,size:`22px`})})})]})]}),(0,Y.jsx)(Yt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,Y.jsx)(kt,{value:o.qrPairingCode,size:256,level:`M`,fgColor:`var(--div-text-color)`,bgColor:`var(--div-bg-color)`,style:{margin:`20px`}}),(0,Y.jsxs)(qt,{style:{justifyContent:`space-between`},children:[(0,Y.jsxs)(Jt,{style:{fontWeight:`normal`,color:`var(--div-text-color)`},children:[`Manual pairing code: `,Ar(o.manualPairingCode)]}),(0,Y.jsx)(Zt,{children:(0,Y.jsx)(H,{title:`Copy manual pairing code`,arrow:!0,children:(0,Y.jsx)(T,{"aria-label":`copy manual pairing code`,size:`small`,onClick:async()=>{if(!o||!o.manualPairingCode)return;let e=o.manualPairingCode;try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(e);else{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.focus(),t.select(),document.execCommand(`copy`),document.body.removeChild(t)}q&&console.log(`Manual pairing code copied to clipboard`)}catch(e){console.error(`Failed to copy manual pairing code`,e)}},sx:kr,children:(0,Y.jsx)(Z.Icon,{path:mt,size:.85})})})})]})]})):o.commissioned&&o.fabricInformations&&o.sessionInformations?(q&&console.log(`QRDiv rendering commissioned state`),(0,Y.jsxs)(Q,{style:J&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`,overflow:`hidden`},children:[(0,Y.jsxs)(Gt,{children:[(0,Y.jsx)(Kt,{children:`Paired fabrics`}),(0,Y.jsxs)(Zt,{children:[(0,Y.jsx)(T,{"aria-label":`send advertising`,size:`small`,onClick:h,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,Y.jsx)(H,{title:`Send again the mDNS advertisement`,arrow:!0,children:(0,Y.jsx)(Z.Icon,{path:dt,size:`22px`})})}),(0,Y.jsx)(T,{"aria-label":`start pairing`,size:`small`,onClick:p,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},children:(0,Y.jsx)(H,{title:`Turn on pairing`,arrow:!0,children:(0,Y.jsx)(Z.Icon,{path:_t,size:`22px`})})})]})]}),(0,Y.jsx)(Yt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,Y.jsx)(Xt,{style:{flexDirection:`column`,justifyContent:`flex-start`,flex:`1 1 auto`,overflow:`auto`,padding:`0px 0px 10px 0px`,gap:`0px`},children:o.fabricInformations.map((e,t)=>(0,Y.jsxs)(`div`,{style:{margin:`0px`,padding:`10px`,gap:`0px`,color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`,textAlign:`left`,fontSize:`14px`},children:[(0,Y.jsxs)(`div`,{style:{marginLeft:`20px`,marginBottom:`10px`,display:`flex`,flexDirection:`row`,justifyContent:`space-between`,gap:`20px`,alignItems:`center`},children:[(0,Y.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: `,e.fabricIndex]}),(0,Y.jsx)(H,{title:`Remove the fabric. You will also need to remove it from the controller.`,arrow:!0,children:(0,Y.jsx)(T,{"aria-label":`remove the fabric`,size:`small`,onClick:()=>f(`Remove fabric`,`Are you sure you want to remove this fabric? You will also need to remove it from the controller.`,`RemoveFabric`,()=>g(e.fabricIndex),()=>{}),sx:{...kr,padding:`2px`},children:(0,Y.jsx)(Z.Icon,{path:ut,size:1})})})]}),(0,Y.jsxs)(`p`,{style:{margin:`0px 20px 0px 20px`,color:`var(--div-text-color)`},children:[`Vendor: `,e.rootVendorId,` `,e.rootVendorName]}),e.label!==``&&(0,Y.jsxs)(`p`,{style:{margin:`0px 20px 0px 20px`,color:`var(--div-text-color)`},children:[`Label: `,e.label]}),(0,Y.jsxs)(`p`,{style:{margin:`0px 20px 0px 20px`,color:`var(--div-text-color)`},children:[`Sessions: `,o.sessionInformations?o.sessionInformations.filter(t=>t.fabric?.fabricIndex===e.fabricIndex&&t.isPeerActive).length:`0`,` `,`subscriptions: `,o.sessionInformations?o.sessionInformations.filter(t=>t.fabric?.fabricIndex===e.fabricIndex&&t.isPeerActive&&t.numberOfActiveSubscriptions>0).length:`0`]})]},t))}),(0,Y.jsx)(qt,{style:{justifyContent:`center`,height:`auto`,minHeight:`30px`},children:(0,Y.jsxs)(Jt,{style:{fontWeight:`normal`,overflowWrap:`anywhere`,textAlign:`center`},children:[`Serial number: `,o.serialNumber]})})]})):!o.commissioned&&!o.advertising?(q&&console.log(`QRDiv rendering not commissioned and not advertising state`),(0,Y.jsxs)(Q,{style:J&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`},children:[(0,Y.jsx)(Gt,{children:(0,Y.jsx)(Kt,{children:`QR pairing code`})}),(0,Y.jsx)(Yt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,Y.jsx)(L,{onClick:p,endIcon:(0,Y.jsx)(Z.Icon,{path:_t,size:1}),style:{margin:`20px`,color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`,minWidth:`90px`},children:`Turn on pairing`}),(0,Y.jsx)(qt,{style:{justifyContent:`center`,height:`auto`,minHeight:`30px`},children:(0,Y.jsxs)(Jt,{style:{fontWeight:`normal`,overflowWrap:`anywhere`,textAlign:`center`},children:[`Serial number: `,o.serialNumber]})})]})):(q&&console.log(`QRDiv rendering unknown state`),null):(q&&console.log(`QRDiv rendering offline state`),(0,Y.jsxs)(Q,{style:J&&d?{flex:`1 1 300px`,alignItems:`center`}:{alignItems:`center`,width:`302px`,minWidth:`302px`},children:[(0,Y.jsx)(Gt,{style:{height:`30px`,justifyContent:`space-between`},children:(0,Y.jsx)(Kt,{children:`Server node`})}),(0,Y.jsx)(Yt,{style:{maxWidth:`280px`,fontWeight:`bold`,color:`var(--secondary-color)`},children:c.current}),(0,Y.jsx)(Yt,{style:{fontWeight:`bold`},children:`Server offline`}),(0,Y.jsx)(qt,{style:{justifyContent:`center`,height:`auto`,minHeight:`30px`},children:(0,Y.jsxs)(Jt,{style:{fontWeight:`normal`,overflowWrap:`anywhere`,textAlign:`center`},children:[`Serial number: `,o.serialNumber]})})]}))}var Mr=(0,G.memo)(jr);function Nr({systemInfo:e,compact:t}){let{mobile:n}=(0,G.useContext)(Vt),{addListener:r,removeListener:i,getUniqueId:a,sendMessage:o}=(0,G.useContext)(X),[s,c]=(0,G.useState)(e),l=(0,G.useRef)(a());if(q&&console.log(`SystemInfoTable loading with systemInfo:`,s,`compact:`,t),e&&t&&s.totalMemory&&s.freeMemory){let e=s.totalMemory;s.freeMemory=`${s.freeMemory} / ${e}`,s.totalMemory=``}if(e&&t&&s.heapTotal&&s.heapUsed){let e=s.heapTotal;s.heapUsed=`${s.heapUsed} / ${e}`,s.heapTotal=``}e&&t&&s.osRelease&&s.osType&&(s.osType=`${s.osType} (${s.osRelease})`,s.osRelease=``),e&&t&&s.osArch&&s.osPlatform&&(s.osPlatform=`${s.osPlatform} (${s.osArch})`,s.osArch=``);let u=(e,t,n,r,i)=>{c(a=>({...a,totalMemory:e,freeMemory:t,heapTotal:n,heapUsed:r,rss:i}))},d=e=>{c(t=>({...t,cpuUsage:e.toFixed(2)+` %`}))},f=e=>{c(t=>({...t,processCpuUsage:e.toFixed(2)+` %`}))},p=(e,t)=>{c(n=>({...n,systemUptime:e,processUptime:t}))},m=()=>{q&&console.log(`SystemInfoTable handleViewHistory clicked`),o({id:l.current,sender:`Header`,method:`/api/viewhistorypage`,src:`Frontend`,dst:`Matterbridge`,params:{}})};(0,G.useEffect)(()=>{let e=e=>{q&&console.log(`SystemInfoTable received WebSocket Message:`,e),e.method===`memory_update`&&e.response&&e.response.totalMemory&&e.response.freeMemory&&e.response.heapTotal&&e.response.heapUsed&&e.response.rss?(q&&console.log(`SystemInfoTable received memory_update`,e),u(e.response.totalMemory,e.response.freeMemory,e.response.heapTotal,e.response.heapUsed,e.response.rss)):e.method===`cpu_update`&&e.response&&e.response.cpuUsage?(q&&console.log(`SystemInfoTable received cpu_update`,e),d(e.response.cpuUsage),f(e.response.processCpuUsage)):e.method===`uptime_update`&&e.response&&e.response.systemUptime&&e.response.processUptime?(q&&console.log(`SystemInfoTable received uptime_update`,e),p(e.response.systemUptime,e.response.processUptime)):e.method===`/api/viewhistorypage`&&e.id===l.current&&e.success&&(q&&console.log(`SystemInfoTable received /api/viewhistorypage success`),window.open(`./api/viewhistory`,`_blank`,`noopener,noreferrer`))};return r(e,l.current),q&&console.log(`SystemInfoTable added WebSocket listener id ${l.current}`),()=>{i(e),q&&console.log(`SystemInfoTable removed WebSocket listener`)}},[r,i]);let[h,g]=(0,G.useState)(!1);return!s||h?null:(q&&console.log(`SystemInfoTable rendering...`),(0,Y.jsxs)(Q,{style:J&&n?{flex:`1 1 300px`}:{flex:`0 1 auto`,width:`302px`,minWidth:`302px`},children:[(0,Y.jsxs)(Gt,{children:[(0,Y.jsx)(Kt,{children:`System info`}),(0,Y.jsx)(Zt,{close:()=>g(!0),children:(0,Y.jsx)(T,{size:`small`,sx:{color:`var(--header-text-color)`,margin:`0px`,padding:`0px`},onClick:m,children:(0,Y.jsx)(H,{title:`Open the cpu and memory usage page`,arrow:!0,children:(0,Y.jsx)(Z.Icon,{path:ft,size:`22px`})})})})]}),(0,Y.jsx)(Xt,{style:J&&n?{flex:`1 1 auto`,margin:`0px`,padding:`0px`,gap:`0px`}:{flex:`1 1 auto`,overflow:`auto`,margin:`0px`,padding:`0px`,gap:`0px`},children:(0,Y.jsxs)(`table`,{style:{border:`none`,borderCollapse:`collapse`,tableLayout:`fixed`},children:[(0,Y.jsxs)(`colgroup`,{children:[(0,Y.jsx)(`col`,{style:{width:`40%`}}),(0,Y.jsx)(`col`,{style:{width:`60%`}})]}),(0,Y.jsx)(`tbody`,{style:{border:`none`,borderCollapse:`collapse`},children:Object.entries(s).filter(([e,t])=>t!==void 0&&t!==``).map(([e,t],r)=>(0,Y.jsxs)(`tr`,{className:r%2==0?`table-content-even`:`table-content-odd`,style:{border:`none`,borderCollapse:`collapse`},children:[(0,Y.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`},children:e.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`)}),(0,Y.jsx)(`td`,{style:{border:`none`,borderCollapse:`collapse`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:J&&n?typeof t==`string`?t:t.toString():(0,Y.jsx)(Er,{value:typeof t==`string`?t:t.toString(),maxChars:22})})]},e))})]})})]}))}var Pr=(0,G.memo)(Nr);function Fr(){let[e,t]=(0,G.useState)(null),[n,r]=(0,G.useState)(null),[i,a]=(0,G.useState)([]),[o]=(0,G.useState)(localStorage.getItem(K.homePagePlugins)!==`false`),[s,c]=(0,G.useState)(localStorage.getItem(K.homePageMode)??`devices`),[l,u]=(0,G.useState)(`https://matterbridge.io/CHANGELOG.html`),[d,f]=(0,G.useState)(!1),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(null),{mobile:_}=(0,G.useContext)(Vt),{addListener:v,removeListener:y,online:b,sendMessage:x,getUniqueId:S}=(0,G.useContext)(X),C=(0,G.useRef)(S());return(0,G.useEffect)(()=>{let e=e=>{q&&console.log(`Home received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`settings`?(q&&console.log(`Home received refresh_required: changed=${e.response.changed} and sending /api/settings request`),g(null),a([]),x({id:C.current,sender:`Home`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),x({id:C.current,sender:`Home`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`update_required`&&(q&&console.log(`Home received update_required`,e.response),e.response.devVersion?r(t=>t?{...t,matterbridgeDevVersion:e.response.version}:null):r(t=>t?{...t,matterbridgeLatestVersion:e.response.version}:null)),e.method===`/api/settings`&&e.id===C.current?(q&&console.log(`Home received settings:`,e.response),t(e.response.systemInformation),r(e.response.matterbridgeInformation),localStorage.getItem(K.frontendVersion)===null&&e.response.matterbridgeInformation.frontendVersion?localStorage.setItem(K.frontendVersion,e.response.matterbridgeInformation.frontendVersion):e.response.matterbridgeInformation.frontendVersion!==localStorage.getItem(K.frontendVersion)&&e.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem(K.frontendVersion,e.response.matterbridgeInformation.frontendVersion),m(!0)),localStorage.getItem(K.matterbridgeVersion)===null?localStorage.setItem(K.matterbridgeVersion,e.response.matterbridgeInformation.matterbridgeVersion):e.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem(K.matterbridgeVersion)&&(localStorage.setItem(K.matterbridgeVersion,e.response.matterbridgeInformation.matterbridgeVersion),f(!0)),e.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem(K.homePageMode)||(localStorage.setItem(K.homePageMode,`devices`),c(`devices`)))):e.method===`/api/plugins`&&e.id===C.current&&(q&&console.log(`Home received plugins:`,e.response),a(e.response))};return v(e,C.current),q&&console.log(`Home added WebSocket listener id ${C.current}`),()=>{y(e),q&&console.log(`Home removed WebSocket listener`)}},[v,y,x]),(0,G.useEffect)(()=>{if(q&&console.log(`Home storeId effect with storeId ${h}`),n?.bridgeMode===`bridge`&&!h&&(q&&console.log(`Home storeId effect set storeId to Matterbridge`),g(`Matterbridge`)),n?.bridgeMode===`childbridge`&&!h&&i){for(let e of i)if(e.matter?.id){q&&console.log(`Home storeId effect set storeId to ${e.matter.id}`),g(e.matter.id);break}}},[n,i,h]),(0,G.useEffect)(()=>{b&&(q&&console.log(`Home online effect, sending /api/settings and /api/plugins requests`),x({id:C.current,sender:`Home`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),x({id:C.current,sender:`Home`,method:`/api/plugins`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[b,x]),q&&console.log(`Home rendering...`),!b||!e||!n?(0,Y.jsx)(Wt,{}):(0,Y.jsxs)(kn,{name:`Home`,style:J&&_?{alignItems:`center`,gap:`10px`}:{flexDirection:`row`},children:[(J&&!_||!J)&&(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,width:`302px`,minWidth:`302px`,gap:`20px`},children:[(0,Y.jsx)(Mr,{id:h}),(0,Y.jsx)(Pr,{systemInfo:e,compact:!0})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100%`,width:`100%`,gap:J&&_?`10px`:`20px`},children:[p&&(0,Y.jsx)(Nn,{version:n.frontendVersion}),d&&(0,Y.jsx)(Tr,{version:n.matterbridgeVersion,changelog:l}),J&&_&&(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:`10px`},children:[(0,Y.jsx)(Mr,{id:h}),(0,Y.jsx)(Pr,{systemInfo:e,compact:!0}),(0,Y.jsx)(Or,{matterbridgeInfo:n})]}),o&&!n.readOnly&&(0,Y.jsx)(Xn,{}),o&&(0,Y.jsx)(Cr,{storeId:h,setStoreId:g}),s===`devices`&&(0,Y.jsx)(Ln,{storeId:h,setStoreId:g}),s===`logs`&&(0,Y.jsx)(tr,{})]})]})}var Ir=(0,G.memo)(Fr);function Lr(){let{logLength:e,logAutoScroll:t,setMessages:n,setLogFilterLevel:r,setLogFilterSearch:i,online:a,filterLogMessages:o}=(0,G.useContext)(X),[s,c]=(0,G.useState)(localStorage.getItem(K.logFilterLevel)??`info`),[l,u]=(0,G.useState)(localStorage.getItem(K.logFilterSearch)??`*`),[f,p]=(0,G.useState)(e.current.toString()),[m,h]=(0,G.useState)(t.current);return q&&console.log(`Logs rendering...`),a?(0,Y.jsxs)(kn,{name:`Logs`,children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`,margin:`0px`,padding:`0px`,gap:`10px`},children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(le,{id:`select-level`,style:{color:`var(--div-text-color)`},children:`Filter log by level:`}),(0,Y.jsxs)(ye,{style:{height:`30px`,backgroundColor:`var(--main-bg-color)`},labelId:`select-level`,id:`debug-level`,value:s,onChange:e=>{let t=e.target.value;c(t),r(t),o(t,l),localStorage.setItem(K.logFilterLevel,t),q&&console.log(`handleLogFilterLevelChange called with value:`,t)},children:[(0,Y.jsx)(V,{value:`debug`,children:`Debug`}),(0,Y.jsx)(V,{value:`info`,children:`Info`}),(0,Y.jsx)(V,{value:`notice`,children:`Notice`}),(0,Y.jsx)(V,{value:`warn`,children:`Warn`}),(0,Y.jsx)(V,{value:`error`,children:`Error`}),(0,Y.jsx)(V,{value:`fatal`,children:`Fatal`})]})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`5px`},children:[(0,Y.jsx)(le,{id:`search`,style:{color:`var(--div-text-color)`},children:`Filter log by text:`}),(0,Y.jsx)(H,{title:`Use /text/ for case-insensitive regex search`,children:(0,Y.jsx)(B,{style:{width:`210px`},size:`small`,id:`logsearch`,variant:`outlined`,value:l,onChange:e=>{let t=e.target.value;u(t),i(t),o(s,t),localStorage.setItem(K.logFilterSearch,t),q&&console.log(`handleLogFilterSearchChange called with value:`,t)},slotProps:{input:{style:{height:`30px`,padding:`0 0px`,backgroundColor:`var(--main-bg-color)`}}}})})]}),(0,Y.jsx)(d,{control:(0,Y.jsx)(M,{checked:m,onChange:e=>{let n=e.target.checked;h(n),t.current=n,o(s,l),localStorage.setItem(K.logAutoScroll,n?`true`:`false`),q&&console.log(`handleAutoScrollChange called with value:`,n)}}),label:`Auto scroll`,style:{color:`var(--div-text-color)`}})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(le,{id:`select-size-label`,style:{color:`var(--div-text-color)`},children:`Log length:`}),(0,Y.jsxs)(ye,{style:{height:`30px`,backgroundColor:`var(--main-bg-color)`},labelId:`select-size-label`,id:`select-size`,value:f,onChange:t=>{let n=t.target.value;p(n),e.current=Number(n),localStorage.setItem(K.logLength,n),q&&console.log(`handleLogLengthChange called with value:`,n)},children:[(0,Y.jsx)(V,{value:100,children:`100`}),(0,Y.jsx)(V,{value:200,children:`200`}),(0,Y.jsx)(V,{value:500,children:`500`}),(0,Y.jsx)(V,{value:1e3,children:`1000`})]}),(0,Y.jsx)(H,{title:`Clear the logs`,children:(0,Y.jsx)(L,{onClick:()=>{q&&console.log(`handleClearLogsClick called`),n([])},endIcon:(0,Y.jsx)(ke,{}),style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,height:`30px`},children:`Clear`})})]})]}),(0,Y.jsx)(`div`,{style:{flex:`1`,overflow:`auto`,margin:`0px`,padding:`0px`},children:(0,Y.jsx)($n,{})})]}):(0,Y.jsx)(Wt,{})}var Rr=(0,G.memo)(Lr),zr=1200,Br,Vr;function Hr(e,t){Br=e,Vr=t}function Ur(){let{mobile:e,showSnackbarMessage:t,showConfirmCancelDialog:n}=(0,G.useContext)(Vt),{online:i,sendMessage:a,logMessage:o,addListener:c,removeListener:l,getUniqueId:d}=(0,G.useContext)(X),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(!1),[_,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(!1),[S,C]=(0,G.useState)(null),w=(0,G.useRef)(d()),[E,D]=(0,G.useState)(null),[O,k]=(0,G.useState)(null),[A,j]=(0,G.useState)(null),[M,N]=(0,G.useState)(null),ee=r(),F=()=>{window.open(`https://www.buymeacoffee.com/luligugithub`,`_blank`)},te=()=>{window.open(`https://matterbridge.io/`)},I=()=>{window.open(`https://matterbridge.io/README.html`)},ne=()=>{window.open(`https://matterbridge.io/CHANGELOG.html`)},re=()=>{window.open(`https://discord.gg/QX58CDe6hd`,`_blank`)},ie=()=>{window.open(`https://github.com/Luligu/matterbridge`,`_blank`)},ae=()=>{a({id:w.current,sender:`Header`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:`matterbridge`,restart:!0}}),y(!1)},L=()=>{a({id:w.current,sender:`Header`,method:`/api/install`,src:`Frontend`,dst:`Matterbridge`,params:{packageName:`matterbridge@dev`,restart:!0}}),x(!1)},oe=()=>{a({id:w.current,sender:`Header`,method:`/api/checkupdates`,src:`Frontend`,dst:`Matterbridge`,params:{}})},se=()=>{q&&console.log(`Header: handleShellySystemUpdateClick`),o(`Matterbridge`,`Installing system updates...`),a({id:w.current,sender:`Header`,method:`/api/shellysysupdate`,src:`Frontend`,dst:`Matterbridge`,params:{}})},le=()=>{q&&console.log(`Header: handleShellyMainUpdateClick`),o(`Matterbridge`,`Installing software updates...`),a({id:w.current,sender:`Header`,method:`/api/shellymainupdate`,src:`Frontend`,dst:`Matterbridge`,params:{}})},ue=()=>{q&&console.log(`Header: handleShellyCreateSystemLog`),a({id:w.current,sender:`Header`,method:`/api/shellycreatesystemlog`,src:`Frontend`,dst:`Matterbridge`,params:{}})},de=()=>{q&&console.log(`Header: handleShellyDownloadSystemLog`),o(`Matterbridge`,`Downloading Shelly system log...`),t(`Downloading Shelly system log...`,5),window.location.href=`./api/shellydownloadsystemlog`},fe=()=>{S?.matterbridgeInformation.restartMode===``?a({id:w.current,sender:`Header`,method:`/api/restart`,src:`Frontend`,dst:`Matterbridge`,params:{}}):a({id:w.current,sender:`Header`,method:`/api/shutdown`,src:`Frontend`,dst:`Matterbridge`,params:{}})},pe=()=>{a({id:w.current,sender:`Header`,method:`/api/shutdown`,src:`Frontend`,dst:`Matterbridge`,params:{}})},me=()=>{a({id:w.current,sender:`Header`,method:`/api/reboot`,src:`Frontend`,dst:`Matterbridge`,params:{}})},he=()=>{a({id:w.current,sender:`Header`,method:`/api/softreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},ge=()=>{a({id:w.current,sender:`Header`,method:`/api/hardreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},_e=e=>{D(e.currentTarget)},R=e=>{q&&console.log(`Header: handleMenuClose`,e),D(null),e===`/`||e===`/devices`||e===`/log`||e===`/settings`?ee(e):e===`reset_frontend`?(o(`Matterbridge`,`Resetting frontend UI...`),t(`Resetting frontend UI...`,5),Mt(),window.location.reload()):e===`download-mblog`?(o(`Matterbridge`,`Downloading matterbridge log...`),t(`Downloading matterbridge log...`,5),window.location.href=`./api/download-mblog`):e===`download-mjlog`?(o(`Matterbridge`,`Downloading matter log...`),t(`Downloading matter log...`,5),window.location.href=`./api/download-mjlog`):e===`view-mblog`?(o(`Matterbridge`,`Loading matterbridge log...`),t(`Loading matterbridge log...`,5),window.open(`./api/view-mblog`,`_blank`,`noopener,noreferrer`)):e===`view-mjlog`?(o(`Matterbridge`,`Loading matter log...`),t(`Loading matter log...`,5),window.open(`./api/view-mjlog`,`_blank`,`noopener,noreferrer`)):e===`view-diagnostic`?(o(`Matterbridge`,`Loading diagnostic log...`),t(`Loading diagnostic log...`,5),window.open(`./api/view-diagnostic`,`_blank`,`noopener,noreferrer`)):e===`download-diagnostic`?(o(`Matterbridge`,`Downloading diagnostic log...`),t(`Downloading diagnostic log...`,5),window.location.href=`./api/download-diagnostic`):e===`view-history`?a({id:w.current,sender:`Header`,method:`/api/viewhistorypage`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`download-history`?a({id:w.current,sender:`Header`,method:`/api/downloadhistorypage`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`view-shellylog`?(o(`Matterbridge`,`Loading shelly system log...`),t(`Loading shelly system log...`,5),window.location.href=`./api/shellyviewsystemlog`):e===`download-mbstorage`?(o(`Matterbridge`,`Downloading matterbridge storage...`),t(`Downloading matterbridge storage...`,5),window.location.href=`./api/download-mbstorage`):e===`download-pluginstorage`?(o(`Matterbridge`,`Downloading matterbridge plugins storage...`),t(`Downloading matterbridge plugins storage...`,5),window.location.href=`./api/download-pluginstorage`):e===`download-pluginconfig`?(o(`Matterbridge`,`Downloading matterbridge plugins config...`),t(`Downloading matterbridge plugins config...`,5),window.location.href=`./api/download-pluginconfig`):e===`download-mjstorage`?(o(`Matterbridge`,`Downloading matter storage...`),t(`Downloading matter storage...`,5),window.location.href=`./api/download-mjstorage`):e===`download-backup`?(o(`Matterbridge`,`Downloading backup...`),t(`Downloading backup...`,10),window.location.href=`./api/download-backup`):e===`update`?ae():e===`updatedev`?L():e===`updatecheck`?oe():e===`shelly-sys-update`?se():e===`shelly-main-update`?le():e===`shelly-create-system-log`?ue():e===`shelly-download-system-log`?de():e===`softreset`?he():e===`hardreset`?ge():e===`restart`?fe():e===`shutdown`?pe():e===`reboot`?me():e===`create-backup`?a({id:w.current,sender:`Header`,method:`/api/create-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-matterbridge-storage-backup`?a({id:w.current,sender:`Header`,method:`/api/create-matterbridge-storage-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-matter-storage-backup`?a({id:w.current,sender:`Header`,method:`/api/create-matter-storage-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-plugin-backup`?a({id:w.current,sender:`Header`,method:`/api/create-plugin-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`create-config-backup`?a({id:w.current,sender:`Header`,method:`/api/create-config-backup`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`unregister`?a({id:w.current,sender:`Header`,method:`/api/unregister`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`reset`?a({id:w.current,sender:`Header`,method:`/api/reset`,src:`Frontend`,dst:`Matterbridge`,params:{}}):e===`factoryreset`&&a({id:w.current,sender:`Header`,method:`/api/factoryreset`,src:`Frontend`,dst:`Matterbridge`,params:{}})},ve=e=>{q&&console.log(`Header: handleMenuCloseCancel:`,e),D(null)},ye=e=>{k(e.currentTarget)},xe=()=>{k(null)},Se=e=>{j(e.currentTarget)},Ce=()=>{j(null)},we=e=>{N(e.currentTarget)},Te=()=>{N(null)};return(0,G.useEffect)(()=>{let e=e=>{q&&console.log(`Header received WebSocket Message:`,e),e.method===`/api/settings`&&e.id===w.current?(q&&console.log(`Header received settings:`,e.response),C(e.response),p(e.response.matterbridgeInformation.restartRequired||e.response.matterbridgeInformation.fixedRestartRequired),h(e.response.matterbridgeInformation.fixedRestartRequired),y(e.response.matterbridgeInformation.updateRequired)):e.method===`refresh_required`&&e.response.changed===`settings`?(q&&console.log(`Header received refresh_required: changed=${e.response.changed} and sending /api/settings request`),a({id:w.current,sender:`Header`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`restart_required`?(q&&console.log(`Header received restart_required with fixed: ${e.response.fixed}`),p(!0),e.response.fixed&&h(!0)):e.method===`restart_not_required`?(q&&console.log(`Header received restart_not_required`),p(!1)):e.method===`update_required`?(q&&console.log(`Header received update_required`),e.response.devVersion?(C(t=>t?{...t,matterbridgeInformation:{...t.matterbridgeInformation,matterbridgeDevVersion:e.response.version}}:null),x(!0)):(C(t=>t?{...t,matterbridgeInformation:{...t.matterbridgeInformation,matterbridgeLatestVersion:e.response.version}}:null),y(!0))):e.method===`shelly_sys_update`?(q&&console.log(`Header received WS_ID_SHELLY_SYS_UPDATE:`),C(t=>t?{matterbridgeInformation:{...t.matterbridgeInformation,shellySysUpdate:e.response.available},systemInformation:t.systemInformation}:null)):e.method===`shelly_main_update`?(q&&console.log(`Header received WS_ID_SHELLY_MAIN_UPDATE:`),C(t=>t?{matterbridgeInformation:{...t.matterbridgeInformation,shellyMainUpdate:e.response.available},systemInformation:t.systemInformation}:null)):e.method===`/api/viewhistorypage`&&e.id===w.current&&e.success?(q&&console.log(`Header received /api/viewhistorypage success`),window.open(`./api/viewhistory`,`_blank`,`noopener,noreferrer`)):e.method===`/api/downloadhistorypage`&&e.id===w.current&&e.success?(q&&console.log(`Header received /api/downloadhistorypage success`),window.location.href=`./api/downloadhistory`):e.method===`archive`&&e.success&&e.response.command===`zip`&&(q&&console.log(`Header received archive success response for zip command`,e.response),e.response.archivePath.endsWith(`matterbridge.backup.zip`)?window.location.href=`./api/download-backup`:e.response.archivePath.endsWith(`matterbridge.storage.zip`)?window.location.href=`./api/download-mbstorage`:e.response.archivePath.endsWith(`matterbridge.matterstorage.zip`)?window.location.href=`./api/download-mjstorage`:e.response.archivePath.endsWith(`matterbridge.pluginstorage.zip`)?window.location.href=`./api/download-pluginstorage`:e.response.archivePath.endsWith(`matterbridge.pluginconfig.zip`)&&(window.location.href=`./api/download-pluginconfig`))};return c(e,w.current),q&&console.log(`Header added WebSocket listener id ${w.current}`),()=>{l(e),q&&console.log(`Header removed WebSocket listener`)}},[c,l,a,t]),(0,G.useEffect)(()=>{i&&(q&&console.log(`Header sending /api/settings and /api/checkupdates requests`),a({id:w.current,sender:`Header`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}),a({id:w.current,sender:`Header`,method:`/api/checkupdates`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[i,a]),q&&console.log(`Header rendering... mobile %s`,e),!i||!S?null:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`space-between`,alignItems:`center`,width:`100%`,gap:`10px`},children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`},onClick:()=>{Nt(),q&&console.log(`Matterbridge logo clicked: debug is now`,q)},children:(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`30px`}})}),(0,Y.jsx)(`h2`,{style:{fontSize:`22px`,color:`var(--main-icon-color)`,margin:`0px`},children:`Matterbridge`})]}),(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`10px`},children:(0,Y.jsxs)(`nav`,{children:[(0,Y.jsx)(s,{to:`/`,className:`nav-link`,children:`Home`}),(0,Y.jsx)(s,{to:`/devices`,className:`nav-link`,children:`Devices`}),(0,Y.jsx)(s,{to:`/log`,className:`nav-link`,children:`Logs`}),(0,Y.jsx)(s,{to:`/settings`,className:`nav-link`,children:`Settings`})]})})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`10px`},children:[!S.matterbridgeInformation.readOnly&&(0,Y.jsx)(H,{title:`Matterbridge v.${S.matterbridgeInformation.matterbridgeVersion}`,children:(0,Y.jsxs)(`span`,{className:`status-information`,style:{cursor:`default`},children:[`v.`,S.matterbridgeInformation.matterbridgeVersion.split(`-`)[0]+(S.matterbridgeInformation.matterbridgeVersion.includes(`-dev-`)?`@dev`:``)+(S.matterbridgeInformation.matterbridgeVersion.includes(`-edge-`)?`@edge`:``)+(S.matterbridgeInformation.matterbridgeVersion.includes(`-local-`)?`@local`:``)+(S.matterbridgeInformation.matterbridgeVersion.includes(`-git-`)?`@git`:``)]})}),S.matterbridgeInformation.shellyBoard&&(0,Y.jsx)(`img`,{src:`Shelly.svg`,alt:`Shelly Icon`,style:{height:`30px`,padding:`0px`,margin:`0px`,marginRight:`30px`}}),S.matterbridgeInformation.bridgeMode!==``&&!S.matterbridgeInformation.readOnly?(0,Y.jsx)(H,{title:`Bridge mode`,children:(0,Y.jsx)(`span`,{className:`status-information`,style:{cursor:`default`},children:S.matterbridgeInformation.bridgeMode})}):null,S.matterbridgeInformation.restartMode!==``&&!S.matterbridgeInformation.readOnly?(0,Y.jsx)(H,{title:`Restart mode`,children:(0,Y.jsx)(`span`,{className:`status-information`,style:{cursor:`default`},children:S.matterbridgeInformation.restartMode})}):null,S.matterbridgeInformation.profile&&S.matterbridgeInformation.profile!==``&&!S.matterbridgeInformation.readOnly?(0,Y.jsx)(H,{title:`Current profile`,children:(0,Y.jsx)(`span`,{className:`status-information`,style:{cursor:`default`},children:S.matterbridgeInformation.profile})}):null,q&&(0,Y.jsxs)(`span`,{className:`status-information`,style:{cursor:`default`},children:[e?`Mobile `:`Desktop `,`${Br}x${Vr}`,` enabled ${localStorage.getItem(K.enableMobile)!==`false`}`]})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,alignItems:`center`,gap:`5px`},children:[S.matterbridgeInformation.readOnly?null:(0,Y.jsx)(H,{title:`Matterbridge discord group`,children:(0,Y.jsx)(T,{style:{margin:`0`,padding:`0`},onClick:re,children:(0,Y.jsx)(`img`,{src:`discord.svg`,alt:`Discord Logo`,style:{height:`25px`}})})}),S.matterbridgeInformation.readOnly?null:(0,Y.jsx)(H,{title:`Give a star to Matterbridge`,children:(0,Y.jsx)(T,{style:{color:`#FFD700`,margin:`0`,padding:`0`},onClick:ie,children:(0,Y.jsx)(Xe,{})})}),S.matterbridgeInformation.readOnly?null:(0,Y.jsx)(H,{title:`Sponsor Matterbridge`,children:(0,Y.jsx)(T,{style:{color:`#b6409c`,margin:`0`,padding:`0`},onClick:F,children:(0,Y.jsx)(it,{})})}),(0,Y.jsx)(H,{title:`Matterbridge homepage`,children:(0,Y.jsx)(T,{style:{color:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:te,children:(0,Y.jsx)(ce,{})})}),(0,Y.jsx)(H,{title:`Matterbridge help`,children:(0,Y.jsx)(T,{style:{color:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:I,children:(0,Y.jsx)(g,{})})}),(0,Y.jsx)(H,{title:`Matterbridge changelog`,children:(0,Y.jsx)(T,{style:{color:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:ne,children:(0,Y.jsx)(v,{})})}),S.matterbridgeInformation&&!S.matterbridgeInformation.readOnly&&_&&(0,Y.jsx)(H,{title:`Update matterbridge to latest version v.${S.matterbridgeInformation.matterbridgeLatestVersion}`,children:(0,Y.jsx)(T,{style:{color:`var(--primary-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:ae,children:(0,Y.jsx)(st,{})})}),S.matterbridgeInformation&&!S.matterbridgeInformation.readOnly&&b&&(0,Y.jsx)(H,{title:`Update matterbridge to latest dev version v.${S.matterbridgeInformation.matterbridgeDevVersion}`,children:(0,Y.jsx)(T,{style:{color:`var(--secondary-color)`,margin:`0`,marginLeft:`5px`,padding:`0`},onClick:L,children:(0,Y.jsx)(st,{})})}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&S.matterbridgeInformation.shellySysUpdate&&(0,Y.jsx)(H,{title:`Shelly system update`,children:(0,Y.jsx)(T,{style:{color:`var(--primary-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:se,children:(0,Y.jsx)(st,{})})}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&S.matterbridgeInformation.shellyMainUpdate&&(0,Y.jsx)(H,{title:`Shelly software update`,children:(0,Y.jsx)(T,{style:{color:`var(--primary-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:le,children:(0,Y.jsx)(st,{})})}),(0,Y.jsx)(H,{title:`Restart matterbridge`,children:(0,Y.jsx)(T,{style:{color:f||m?`var(--primary-color)`:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:fe,children:(0,Y.jsx)(ot,{})})}),S.matterbridgeInformation.restartMode===``?(0,Y.jsx)(H,{title:`Shut down matterbridge`,children:(0,Y.jsx)(T,{style:{color:f||m?`var(--primary-color)`:`var(--main-icon-color)`,margin:`0`,marginLeft:`5px`,padding:`0px`},onClick:pe,children:(0,Y.jsx)(be,{})})}):null,(0,Y.jsx)(H,{title:`Download, backup and more`,children:(0,Y.jsx)(T,{onClick:_e,children:(0,Y.jsx)(We,{style:{color:`var(--main-icon-color)`}})})}),(0,Y.jsxs)(ct,{id:`command-menu`,anchorEl:E,keepMounted:!0,open:!!E,onClose:()=>R(``),children:[J&&e&&(0,Y.jsxs)(V,{onClick:()=>R(`/`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Home page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),J&&e&&(0,Y.jsxs)(V,{onClick:()=>R(`/devices`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Devices page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),J&&e&&(0,Y.jsxs)(V,{onClick:()=>R(`/log`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Logs page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),J&&e&&(0,Y.jsxs)(V,{onClick:()=>R(`/settings`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Settings page`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&!S.matterbridgeInformation.readOnly&&(0,Y.jsxs)(V,{onClick:()=>R(`update`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(st,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Install latest stable`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&!S.matterbridgeInformation.readOnly&&(0,Y.jsxs)(V,{onClick:()=>R(`updatedev`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(st,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Install latest dev`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&!S.matterbridgeInformation.readOnly&&(0,Y.jsxs)(V,{onClick:()=>R(`updatecheck`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(st,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Check for updates`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&S.matterbridgeInformation.shellySysUpdate&&(0,Y.jsxs)(V,{onClick:()=>R(`shelly-sys-update`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(st,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Shelly system update`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&S.matterbridgeInformation.shellyMainUpdate&&(0,Y.jsxs)(V,{onClick:()=>R(`shelly-main-update`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(st,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Shelly software update`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>R(`restart`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(ot,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Restart`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation.restartMode===``?(0,Y.jsxs)(V,{onClick:()=>R(`shutdown`),children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Shutdown`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}):null,S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,Y.jsxs)(V,{onClick:()=>{n(`Reboot`,`Are you sure you want to reboot the Shelly board?`,`reboot`,R,ve)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(ot,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Reboot...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsx)(P,{}),(0,Y.jsxs)(V,{onClick:ye,children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`View`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(ct,{id:`sub-menu-view`,anchorEl:O,keepMounted:!0,open:!!O,onClose:xe,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,Y.jsxs)(V,{onClick:()=>{Ft(),xe(),ve(``),window.open(`/home`,`_self`)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Desktop site`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{Pt(),xe(),ve(``),window.open(`/home`,`_self`)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Mobile site`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`view-mblog`),xe()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`view-mjlog`),xe()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matter log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`view-diagnostic`),xe()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge diagnostic log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`view-history`),xe()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge system history`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,Y.jsxs)(V,{onClick:()=>{R(`view-shellylog`),xe()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(He,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Shelly system log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]})]}),(0,Y.jsx)(P,{}),(0,Y.jsxs)(V,{onClick:Se,children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Download`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(ct,{id:`sub-menu-download`,anchorEl:A,keepMounted:!0,open:!!A,onClose:Ce,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,Y.jsxs)(V,{onClick:()=>{R(`create-matterbridge-storage-backup`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge storage`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`create-plugin-backup`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge plugins storage`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`create-config-backup`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge plugins config`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`download-mblog`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`create-matter-storage-backup`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matter storage`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`download-mjlog`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matter log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`download-diagnostic`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge diagnostic log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{R(`download-history`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Matterbridge system history`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,Y.jsxs)(V,{onClick:()=>{R(`shelly-create-system-log`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Create Shelly system log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,Y.jsxs)(V,{onClick:()=>{R(`shelly-download-system-log`),Ce()},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(u,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Download Shelly system log`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]})]}),(0,Y.jsx)(P,{}),(0,Y.jsxs)(V,{onClick:()=>{R(`create-backup`)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(Je,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Backup`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsx)(P,{}),(0,Y.jsxs)(V,{onClick:we,children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(Me,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Reset`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(ct,{id:`sub-menu-reset`,anchorEl:M,keepMounted:!0,open:!!M,onClose:Te,sx:{"& .MuiPaper-root":{backgroundColor:`#e2e2e2`}},children:[(0,Y.jsxs)(V,{onClick:()=>{Te(),n(`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`,R,ve)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Reset the frontend UI...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{Te(),n(`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`,R,ve)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Reset all devices...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),(0,Y.jsxs)(V,{onClick:()=>{Te(),n(`Reset commissioning and shutdown`,`Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.`,`reset`,R,ve)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Reset commissioning...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),!S.matterbridgeInformation.readOnly&&(0,Y.jsxs)(V,{onClick:()=>{Te(),n(`Factory reset and shutdown`,`Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.`,`factoryreset`,R,ve)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Factory reset...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,Y.jsxs)(V,{onClick:()=>{Te(),n(`Network reset`,`Are you sure you want to factory reset the network parameters?`,`softreset`,R,ve)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Reset network...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]}),S.matterbridgeInformation&&S.matterbridgeInformation.shellyBoard&&(0,Y.jsxs)(V,{onClick:()=>{Te(),n(`Factory reset`,`Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.`,`hardreset`,R,ve)},children:[(0,Y.jsx)(U,{children:(0,Y.jsx)(be,{style:{color:`var(--main-icon-color)`}})}),(0,Y.jsx)(z,{primary:`Factory reset...`,primaryTypographyProps:{style:{fontWeight:`normal`,color:`var(--main-icon-color)`}}})]})]})]})]})]})}var Wr=(0,G.memo)(Ur);function Gr(){if(typeof window<`u`){let e=Math.floor(window.visualViewport?.width??window.innerWidth),t=Math.floor(window.visualViewport?.height??window.innerHeight);Hr(e,t);let n=e<1200||t<900;return q&&console.log(`Visual viewport (%s) width %i height %i mobile %s`,window.visualViewport!==void 0,e,t,n),n}return!1}function Kr({children:e}){let{mobile:t,setMobile:n}=(0,G.useContext)(Vt),{logAutoScroll:r}=(0,G.useContext)(X);return(0,G.useEffect)(()=>{function e(){let e=Gr();e&&(r.current=!1,localStorage.setItem(K.logAutoScroll,`false`)),n(e)}return window.addEventListener(`resize`,e),n(Gr()),()=>window.removeEventListener(`resize`,e)},[r,n]),q&&console.log(`MbfScreen rendering... mobile %s`,t),J&&t?(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,overflow:`visible`,margin:`0px`,padding:`10px`,gap:`10px`},children:[(0,Y.jsx)(Wr,{}),(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,width:`100%`,height:`100%`,margin:`0px`,padding:`0px`,gap:`10px`},children:e})]}):(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,overflow:`hidden`,width:t?`${zr}px`:`calc(100vw - 40px)`,height:t?`900px`:`calc(100vh - 40px)`,margin:`0px`,padding:`20px`,gap:`20px`},children:[(0,Y.jsx)(Wr,{}),(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,width:`100%`,height:`calc(100% - 60px)`,margin:`0px`,padding:`0px`,gap:`20px`},children:e})]})}function qr(e=1e3){let t=null,n=(n=>{t!==null&&window.clearTimeout(t),t=window.setTimeout(()=>{n(),t=null},e)});return n.cancel=()=>{t!==null&&(window.clearTimeout(t),t=null)},n}var Jr=({open:e,onClose:t,onSave:n})=>{let[r,i]=(0,G.useState)(``),[a,o]=(0,G.useState)(``),s=e=>{i(e.target.value)},c=e=>{o(e.target.value)},l=r.length>0&&r===a;return(0,Y.jsxs)(D,{open:e,onClose:(e,n)=>{n===`backdropClick`||n===`escapeKeyDown`||t()},maxWidth:`sm`,style:{maxWidth:`500px`,margin:`auto`},disableEscapeKeyDown:!0,children:[(0,Y.jsx)(F,{children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h4`,{style:{margin:0},children:`Change Password`})]})}),(0,Y.jsx)(re,{dividers:!0,children:(0,Y.jsx)(Fe,{component:`fieldset`,fullWidth:!0,sx:{margin:0,padding:0,gap:`20px`},children:(0,Y.jsxs)(_,{container:!0,spacing:2,sx:{mt:2},children:[(0,Y.jsx)(_,{size:12,children:(0,Y.jsx)(B,{type:`password`,autoComplete:`new-password`,label:`New Password`,size:`small`,variant:`outlined`,fullWidth:!0,value:r,onChange:s})}),(0,Y.jsx)(_,{size:12,children:(0,Y.jsx)(B,{type:`password`,autoComplete:`new-password`,label:`Confirm Password`,size:`small`,variant:`outlined`,fullWidth:!0,value:a,onChange:c,error:a!==``&&r!==a,helperText:a!==``&&r!==a?`Passwords do not match`:``})})]})})}),(0,Y.jsxs)(x,{children:[(0,Y.jsx)(L,{onClick:()=>{t()},children:`Cancel`}),(0,Y.jsx)(L,{variant:`contained`,onClick:()=>{l&&(n(r),t())},disabled:!l,children:`Change`}),(0,Y.jsx)(L,{variant:`contained`,onClick:()=>{n(``),t()},children:`Reset`})]})]})},Yr=({open:e,ip:t,onClose:n,onSave:r})=>{let i=t?t.split(`.`).slice(0,3).join(`.`)+`.1`:``,[a,o]=(0,G.useState)(`dhcp`),[s,c]=(0,G.useState)({ip:t??``,subnet:`255.255.255.0`,gateway:i,dns:i}),l=e=>t=>{c({...s,[e]:t.target.value})};return(0,Y.jsxs)(D,{open:e,onClose:(e,t)=>{t===`backdropClick`||t===`escapeKeyDown`||n()},maxWidth:`sm`,style:{maxWidth:`550px`,margin:`auto`},children:[(0,Y.jsx)(F,{gap:`20px`,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h4`,{style:{margin:0},children:`Network Configuration`})]})}),(0,Y.jsxs)(re,{dividers:!0,children:[(0,Y.jsxs)(Fe,{component:`fieldset`,fullWidth:!0,children:[(0,Y.jsx)(I,{component:`legend`,children:`Select IP Configuration`}),(0,Y.jsxs)(Ve,{row:!0,value:a,onChange:e=>o(e.target.value),children:[(0,Y.jsx)(d,{value:`dhcp`,control:(0,Y.jsx)(je,{}),label:`DHCP`}),(0,Y.jsx)(d,{value:`static`,control:(0,Y.jsx)(je,{}),label:`Static`})]})]}),a===`static`&&(0,Y.jsxs)(_,{container:!0,spacing:2,sx:{mt:2},children:[(0,Y.jsx)(_,{size:6,children:(0,Y.jsx)(B,{label:`IP Address`,fullWidth:!0,value:s.ip,onChange:l(`ip`)})}),(0,Y.jsx)(_,{size:6,children:(0,Y.jsx)(B,{label:`Subnet Mask`,fullWidth:!0,value:s.subnet,onChange:l(`subnet`)})}),(0,Y.jsx)(_,{size:6,children:(0,Y.jsx)(B,{label:`Gateway`,fullWidth:!0,value:s.gateway,onChange:l(`gateway`)})}),(0,Y.jsx)(_,{size:6,children:(0,Y.jsx)(B,{label:`DNS Server`,fullWidth:!0,value:s.dns,onChange:l(`dns`)})})]})]}),(0,Y.jsxs)(x,{children:[(0,Y.jsx)(L,{onClick:()=>{n()},children:`Cancel`}),(0,Y.jsx)(L,{variant:`contained`,onClick:()=>{r({type:a,...s}),n()},children:`Save`})]})]})},Xr=330;function Zr(){let{mobile:e}=(0,G.useContext)(Vt),{online:t,addListener:n,removeListener:r,sendMessage:i,getUniqueId:a}=(0,G.useContext)(X),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),u=(0,G.useRef)(a());return(0,G.useEffect)(()=>{let e=e=>{q&&console.log(`Settings received WebSocket Message:`,e),e.method===`refresh_required`&&e.response.changed===`settings`?(q&&console.log(`Settings received refresh_required: changed=${e.response.changed} and sending /api/settings request`),i({id:u.current,sender:`Settings`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}})):e.method===`update_required`?(q&&console.log(`Settings received update_required`,e.response),e.response.devVersion?s(t=>t?{...t,matterbridgeDevVersion:e.response.version}:null):s(t=>t?{...t,matterbridgeLatestVersion:e.response.version}:null)):e.method===`/api/settings`&&(q&&console.log(`Settings received /api/settings:`,e.response),s(e.response.matterbridgeInformation),l(e.response.systemInformation))};return n(e,u.current),q&&console.log(`Settings added WebSocket listener`),()=>{r(e),q&&console.log(`Settings removed WebSocket listener`)}},[n,r,i]),(0,G.useEffect)(()=>{t&&(q&&console.log(`Settings received online`),i({id:u.current,sender:`Settings`,method:`/api/settings`,src:`Frontend`,dst:`Matterbridge`,params:{}}))},[t,i]),q&&console.log(`Settings rendering...`),!t||!o||!c?(0,Y.jsx)(Wt,{}):(0,Y.jsx)(kn,{name:`Settings`,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,flexWrap:`wrap`,gap:J&&e?`10px`:`20px`},children:[(0,Y.jsx)(Qr,{matterbridgeInfo:o,systemInfo:c}),(0,Y.jsx)($r,{matterbridgeInfo:o}),(0,Y.jsx)(ei,{matterbridgeInfo:o}),(0,Y.jsx)(ti,{systemInfo:c})]})})}function Qr({matterbridgeInfo:e,systemInfo:t}){let{sendMessage:n,getUniqueId:r}=(0,G.useContext)(X),[i,a]=(0,G.useState)(`bridge`),[o,s]=(0,G.useState)(`Info`),[c,l]=(0,G.useState)(!1),[u,f]=(0,G.useState)(`dark`),[p,m]=(0,G.useState)(localStorage.getItem(K.homePagePlugins)!==`false`),[h,g]=(0,G.useState)(localStorage.getItem(K.homePageMode)??`devices`),[_,v]=(0,G.useState)(localStorage.getItem(K.virtualMode)??`outlet`),y=(0,G.useRef)(r()),[b,x]=(0,G.useState)(!1),S=()=>x(!1),C=e=>{q&&console.log(`handleSaveNetConfig called with config:`,e),n({id:y.current,sender:`Settings`,method:`/api/shellynetconfig`,src:`Frontend`,dst:`Matterbridge`,params:e})},[w,T]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{e&&(a(e.bridgeMode===`bridge`?`bridge`:`childbridge`),s(e.loggerLevel.charAt(0).toUpperCase()+e.loggerLevel.slice(1)),l(e.fileLogger),v(e.virtualMode))},[e]),(0,G.useEffect)(()=>{let e=localStorage.getItem(K.frontendTheme);e&&f(e)},[]),!e||!t?null:(0,Y.jsxs)(Q,{style:{flex:`1 1 ${Xr}px`},children:[(0,Y.jsx)(Gt,{children:(0,Y.jsx)(Kt,{children:`Matterbridge settings`})}),(0,Y.jsx)(Yr,{open:b,ip:t.ipv4Address,onClose:S,onSave:C}),(0,Y.jsx)(Jr,{open:w,onClose:()=>T(!1),onSave:e=>{q&&console.log(`handleSaveChangePassword called with password:`,e),n({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setpassword`,value:e}}),Lt(e)}}),(0,Y.jsxs)(Xt,{style:{flexDirection:`column`,padding:`10px`,gap:`0px`,backgroundColor:`var(--div-bg-color)`,color:`var(--div-text-color)`},children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`matterbridgeInfo-mode`,children:`Mode:`}),(0,Y.jsxs)(Ve,{row:!0,name:`mode-buttons-group`,value:i,onChange:e=>{q&&console.log(`handleChangeBridgeMode called with value:`,e.target.value),a(e.target.value),n({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setbridgemode`,value:e.target.value}})},children:[(0,Y.jsx)(d,{value:`bridge`,control:(0,Y.jsx)(je,{}),label:`Bridge`,disabled:e.readOnly}),(0,Y.jsx)(d,{value:`childbridge`,control:(0,Y.jsx)(je,{}),label:`Childbridge`,disabled:e.readOnly})]})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,marginBottom:`5px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`mblogger-level-label`,children:`Logger level:`}),(0,Y.jsxs)(ye,{style:{height:`30px`},labelId:`mblogger-level-label`,id:`mblogger-level`,value:o,onChange:e=>{q&&console.log(`handleChangeMbLoggerLevel called with value:`,e.target.value),s(e.target.value),n({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmbloglevel`,value:e.target.value}})},children:[(0,Y.jsx)(V,{value:`Debug`,children:`Debug`}),(0,Y.jsx)(V,{value:`Info`,children:`Info`}),(0,Y.jsx)(V,{value:`Notice`,children:`Notice`}),(0,Y.jsx)(V,{value:`Warn`,children:`Warn`}),(0,Y.jsx)(V,{value:`Error`,children:`Error`}),(0,Y.jsx)(V,{value:`Fatal`,children:`Fatal`})]})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`10px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`mblogger-file-label`,children:`Log on file:`}),(0,Y.jsx)(M,{checked:c,onChange:e=>{q&&console.log(`handleLogOnFileMbChange called with value:`,e.target.checked),l(e.target.checked),n({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmblogfile`,value:e.target.checked}})},id:`mblogger-file`,name:`logOnFileMb`})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`5px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`frontend-theme-label`,children:`Frontend theme:`}),(0,Y.jsxs)(ye,{style:{height:`30px`},labelId:`frontend-theme-label`,id:`frontend-theme`,value:u,onChange:e=>{let t=e.target.value;q&&console.log(`handleChangeTheme called with value:`,t),f(t),localStorage.setItem(K.frontendTheme,t),document.body.setAttribute(`frontend-theme`,t)},children:[(0,Y.jsx)(V,{value:`classic`,children:`Classic`}),(0,Y.jsx)(V,{value:`light`,children:`Light`}),(0,Y.jsx)(V,{value:`dark`,children:`Dark`})]})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`5px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`frontend-home-plugin-label`,children:`Home page plugins:`}),(0,Y.jsx)(M,{checked:p,onChange:e=>{let t=e.target.checked;q&&console.log(`handleChangeHomePagePlugins called with value:`,t),m(t),localStorage.setItem(K.homePagePlugins,t?`true`:`false`)},name:`showPlugins`})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`5px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`frontend-home-label`,children:`Home page bottom panel:`}),(0,Y.jsxs)(ye,{style:{height:`30px`},labelId:`frontend-home-label`,id:`frontend-home`,value:h,onChange:e=>{let t=e.target.value;q&&console.log(`handleChangeHomePageMode called with value:`,t),g(t),localStorage.setItem(K.homePageMode,t)},children:[(0,Y.jsx)(V,{value:`logs`,children:`Logs`}),(0,Y.jsx)(V,{value:`devices`,children:`Devices`})]})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`10px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`frontend-virtual-label`,children:`Virtual devices:`}),(0,Y.jsxs)(ye,{style:{height:`30px`},labelId:`frontend-virtual-label`,id:`frontend-virtual`,value:_,onChange:e=>{let t=e.target.value;q&&console.log(`handleChangeVirtualMode called with value:`,t),v(t),localStorage.setItem(K.virtualMode,t),n({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setvirtualmode`,value:t}})},children:[(0,Y.jsx)(V,{value:`disabled`,children:`Disabled`}),(0,Y.jsx)(V,{value:`outlet`,children:`Outlet`}),(0,Y.jsx)(V,{value:`light`,children:`Light`}),(0,Y.jsx)(V,{value:`switch`,children:`Switch`}),(0,Y.jsx)(V,{value:`mounted_switch`,children:`Mounted Switch`})]})]}),(0,Y.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`20px`},children:(0,Y.jsx)(L,{variant:`contained`,color:`primary`,onClick:()=>T(!0),children:`Change password`})}),e.shellyBoard&&(0,Y.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`15px`,marginTop:`20px`},children:(0,Y.jsx)(L,{variant:`contained`,color:`primary`,onClick:()=>x(!0),children:`Configure IP`})})]})]})}function $r({matterbridgeInfo:e}){let{sendMessage:t,getUniqueId:n}=(0,G.useContext)(X),[r,i]=(0,G.useState)(`Info`),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(``),[l,u]=(0,G.useState)(``),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(``),[_,v]=(0,G.useState)(``),y=(0,G.useRef)(n()),b=(0,G.useMemo)(()=>qr(1e3),[]),x=(0,G.useMemo)(()=>qr(1e3),[]),S=(0,G.useMemo)(()=>qr(1e3),[]),C=(0,G.useMemo)(()=>qr(1e3),[]),w=(0,G.useMemo)(()=>qr(1e3),[]),T=(0,G.useMemo)(()=>qr(1e3),[]);return(0,G.useEffect)(()=>{e&&(i(e.matterLoggerLevel.charAt(0).toUpperCase()+e.matterLoggerLevel.slice(1)),o(e.matterFileLogger),c(e.matterMdnsInterface||``),u(e.matterIpv4Address||``),f(e.matterIpv6Address||``),m(e.matterPort?e.matterPort.toString():``),g(e.matterDiscriminator?e.matterDiscriminator.toString():``),v(e.matterPasscode?e.matterPasscode.toString():``))},[e]),(0,G.useEffect)(()=>()=>b.cancel(),[b]),(0,G.useEffect)(()=>()=>x.cancel(),[x]),(0,G.useEffect)(()=>()=>S.cancel(),[S]),(0,G.useEffect)(()=>()=>C.cancel(),[C]),(0,G.useEffect)(()=>()=>w.cancel(),[w]),(0,G.useEffect)(()=>()=>T.cancel(),[T]),e?(0,Y.jsxs)(Q,{style:{flex:`1 1 ${Xr}px`},children:[(0,Y.jsx)(Gt,{children:(0,Y.jsx)(Kt,{children:`Matter settings`})}),(0,Y.jsxs)(Xt,{style:{flexDirection:`column`,padding:`10px`,gap:`0px`,backgroundColor:`var(--div-bg-color)`,color:`var(--div-text-color)`},children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,marginBottom:`5px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`mjlogger-level-label`,children:`Logger level:`}),(0,Y.jsxs)(ye,{style:{height:`30px`},labelId:`mjlogger-level-label`,id:`mjlogger-level`,value:r,onChange:e=>{q&&console.log(`handleChangeMjLoggerLevel called with value:`,e.target.value),i(e.target.value),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmjloglevel`,value:e.target.value}})},children:[(0,Y.jsx)(V,{value:`Debug`,children:`Debug`}),(0,Y.jsx)(V,{value:`Info`,children:`Info`}),(0,Y.jsx)(V,{value:`Notice`,children:`Notice`}),(0,Y.jsx)(V,{value:`Warn`,children:`Warn`}),(0,Y.jsx)(V,{value:`Error`,children:`Error`}),(0,Y.jsx)(V,{value:`Fatal`,children:`Fatal`})]})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,marginBottom:`5px`,gap:`10px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`},id:`mjlogger-file-label`,children:`Log on file:`}),(0,Y.jsx)(M,{checked:a,onChange:e=>{q&&console.log(`handleLogOnFileMjChange called with value:`,e.target.checked),o(e.target.checked),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmjlogfile`,value:e.target.checked}})},id:`mjlogger-file`,name:`logOnFileMj`})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Mdns interface:`}),(0,Y.jsx)(B,{value:s,onChange:e=>{q&&console.log(`handleChangeMdnsInterface called with value:`,e.target.value);let n=e.target.value;c(n),b(()=>{q&&console.log(`debounced sendMessage setmdnsinterface with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmdnsinterface`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly,style:{height:`30px`,padding:`0`}}})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Ipv4 address:`}),(0,Y.jsx)(B,{value:l,onChange:e=>{q&&console.log(`handleChangeIpv4Address called with value:`,e.target.value);let n=e.target.value;u(n),x(()=>{q&&console.log(`debounced sendMessage setipv4address with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setipv4address`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly,style:{height:`30px`,padding:`0`}}})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Ipv6 address:`}),(0,Y.jsx)(B,{value:d,onChange:e=>{q&&console.log(`handleChangeIpv6Address called with value:`,e.target.value);let n=e.target.value;f(n),S(()=>{q&&console.log(`debounced sendMessage setipv6address with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setipv6address`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly,style:{height:`30px`,padding:`0`}}})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Commissioning port:`}),(0,Y.jsx)(B,{value:p,onChange:e=>{q&&console.log(`handleChangeMatterPort called with value:`,e.target.value);let n=e.target.value;m(n),C(()=>{q&&console.log(`debounced sendMessage setmatterport with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmatterport`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly,style:{height:`30px`,padding:`0`}}})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Commissioning discriminator:`}),(0,Y.jsx)(B,{value:h,onChange:e=>{q&&console.log(`handleChangeMatterDiscriminator called with value:`,e.target.value);let n=e.target.value;g(n),w(()=>{q&&console.log(`debounced sendMessage setmatterdiscriminator with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmatterdiscriminator`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly,style:{height:`30px`,padding:`0`}}})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,width:`100%`,marginBottom:`10px`,gap:`15px`},children:[(0,Y.jsx)(I,{style:{padding:`0px`,margin:`0px`,textWrap:`nowrap`},children:`Commissioning passcode:`}),(0,Y.jsx)(B,{value:_,onChange:e=>{q&&console.log(`handleChangemMatterPasscode called with value:`,e.target.value);let n=e.target.value;v(n),T(()=>{q&&console.log(`debounced sendMessage setmatterpasscode with value:`,n),t({id:y.current,sender:`Settings`,method:`/api/config`,src:`Frontend`,dst:`Matterbridge`,params:{name:`setmatterpasscode`,value:n}})})},size:`small`,variant:`outlined`,style:{height:`30px`,flexGrow:1},InputProps:{readOnly:e.readOnly,style:{height:`30px`,padding:`0`}}})]})]})]}):null}function ei({matterbridgeInfo:e}){return e?(0,Y.jsxs)(Q,{style:{flex:`1 1 ${Xr}px`},children:[(0,Y.jsx)(Gt,{children:(0,Y.jsx)(Kt,{children:`Matterbridge info`})}),(0,Y.jsxs)(Xt,{style:{flexDirection:`column`,padding:`10px`,gap:`5px`},children:[(0,Y.jsx)(ni,{value:e.matterbridgeVersion,label:`Current Version`}),(0,Y.jsx)(ni,{value:e.matterbridgeLatestVersion,label:`Latest Version`}),(0,Y.jsx)(ni,{value:e.rootDirectory,label:`Root Directory`}),(0,Y.jsx)(ni,{value:e.homeDirectory,label:`Home Directory`}),(0,Y.jsx)(ni,{value:e.matterbridgeDirectory,label:`Matterbridge Storage Directory`}),(0,Y.jsx)(ni,{value:e.matterbridgePluginDirectory,label:`Matterbridge Plugin Directory`}),(0,Y.jsx)(ni,{value:e.globalModulesDirectory,label:`Global Module Directory`})]})]}):null}function ti({systemInfo:e}){return e?(0,Y.jsxs)(Q,{style:{flex:`1 1 ${Xr}px`},children:[(0,Y.jsx)(Gt,{children:(0,Y.jsx)(Kt,{children:`System info`})}),(0,Y.jsxs)(Xt,{style:{flexDirection:`column`,padding:`10px`,gap:`5px`},children:[(0,Y.jsx)(ni,{value:e.interfaceName,label:`Interface name`}),(0,Y.jsx)(ni,{value:e.macAddress,label:`MAC Address`}),(0,Y.jsx)(ni,{value:e.ipv4Address,label:`IPv4 Address`}),(0,Y.jsx)(ni,{value:e.ipv6Address,label:`IPv6 Address`}),(0,Y.jsx)(ni,{value:e.nodeVersion,label:`Node Version`}),(0,Y.jsx)(ni,{value:e.hostname,label:`Hostname`}),(0,Y.jsx)(ni,{value:e.user,label:`User`})]})]}):null}function ni({value:e,label:t,width:n}){return(0,Y.jsx)(B,{focused:!0,value:e,size:`small`,label:t,variant:`standard`,sx:{width:n?`${n-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)`}}}}})}var ri=(0,G.memo)(Zr);function ii(){let{online:e,sendMessage:t,addListener:n,removeListener:r,getUniqueId:i}=(0,G.useContext)(X),{showSnackbarMessage:a}=(0,G.useContext)(Vt),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)([]),[u,d]=(0,G.useState)([]),[f,p]=(0,G.useState)(null),[m,h]=(0,G.useState)({cpuUsage:0}),[g,_]=(0,G.useState)({totalMemory:``,freeMemory:``,heapTotal:``,heapUsed:``,external:``,arrayBuffers:``,rss:``}),[v,y]=(0,G.useState)({systemUptime:``,processUptime:``}),b=(0,G.useRef)(i());return q&&console.log(`Test uniqueId:`,b),(0,G.useEffect)(()=>{q&&console.log(`Test useEffect WebSocketMessage mounting`);let e=e=>{if(e.method===`restart_required`)q&&console.log(`Test received restart_required`),a(`Restart required`,0);else if(e.method===`refresh_required`)q&&console.log(`Test received refresh_required: changed=${e.response.changed} and sending api requests`),a(`Refresh required`,0),t({id:b.current,method:`/api/settings`,sender:`Test`,src:`Frontend`,dst:`Matterbridge`,params:{}}),t({id:b.current,method:`/api/plugins`,sender:`Test`,src:`Frontend`,dst:`Matterbridge`,params:{}}),t({id:b.current,method:`/api/devices`,sender:`Test`,src:`Frontend`,dst:`Matterbridge`,params:{}});else if(e.method===`memory_update`)q&&console.log(`Test received memory_update`,e),_(e.response);else if(e.method===`cpu_update`)q&&console.log(`Test received cpu_update`,e),h(e.response);else if(e.method===`uptime_update`)q&&console.log(`Test received uptime_update`,e),y(e.response);else if(e.method===`/api/settings`&&e.response)q&&console.log(`Test received /api/settings:`,e.response),a(`Test received /api/settings`,0),s(e.response);else if(e.method===`/api/plugins`&&e.response)q&&console.log(`Test received ${e.response.length} plugins:`,e.response),a(`Test received /api/plugins`,0),l(e.response);else if(e.method===`/api/devices`&&e.response){q&&console.log(`Test received ${e.response.length} devices:`,e.response),a(`Test received /api/devices`,0),d(e.response);for(let n of e.response)q&&console.log(`Test sending /api/clusters for device:`,n.pluginName,n.name,n.endpoint),t({id:b.current,method:`/api/clusters`,sender:`Test`,src:`Frontend`,dst:`Matterbridge`,params:{plugin:n.pluginName,endpoint:n.endpoint||0}})}else e.method===`/api/clusters`&&e.response&&(q&&console.log(`Test received ${e.response.clusters.length} clusters for device ${e.response.deviceName} endpoint ${e.response.id}:${e.response.number}:`,e),a(`Test received /api/clusters for ${e.response.plugin}::${e.response.deviceName}`,0),p(e.response))};return n(e,b.current),q&&console.log(`Test useEffect WebSocketMessage mounted`),()=>{q&&console.log(`Test useEffect WebSocketMessage unmounting`),r(e),q&&console.log(`Test useEffect WebSocketMessage unmounted`)}},[n,r,t,a]),(0,G.useEffect)(()=>(q&&console.log(`Test useEffect online mounting`),e&&q&&console.log(`Test useEffect online received online`),q&&console.log(`Test useEffect online mounted`),()=>{q&&console.log(`Test useEffect online unmounted`)}),[e,t,a]),q&&console.log(`Test rendering...`),e?(0,Y.jsx)(kn,{name:`Test`,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,justifyContent:`center`,alignItems:`center`,alignContent:`center`,gap:`20px`,height:`100vh`,width:`100vw`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`256px`,width:`256px`,margin:`10px`}}),(0,Y.jsx)(`p`,{children:`Welcome to the Test page of the Matterbridge frontend`})]})}):(0,Y.jsx)(Wt,{})}var ai=(0,G.memo)(ii);function oi({open:e,title:t,message:n,onConfirm:r,onCancel:i}){return(0,Y.jsxs)(D,{open:e,children:[(0,Y.jsx)(F,{gap:`20px`,children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h4`,{style:{margin:0},children:t})]})}),(0,Y.jsxs)(re,{children:[(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`center`,margin:`0`,marginBottom:`20px`,maxHeight:`350px`,maxWidth:`350px`},children:(0,Y.jsx)(`p`,{style:{flex:1,margin:`0`},children:n})}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`space-around`},children:[(0,Y.jsx)(L,{onClick:e=>{q&&console.log(`Confirmed`),e.preventDefault(),r()},variant:`contained`,color:`primary`,size:`small`,children:`Confirm`}),(0,Y.jsx)(L,{onClick:e=>{q&&console.log(`Canceled`),e.preventDefault(),i()},variant:`contained`,color:`primary`,size:`small`,children:`Cancel`})]})]})]})}var si=({open:e,output:t,title:n,_command:r,_packageName:i,onInstall:a,onClose:o})=>{let{installAutoExit:s,mobile:c,setInstallAutoExit:l}=(0,G.useContext)(Vt),u=(0,G.useRef)(null),f=e=>{l(e.target.checked),localStorage.setItem(K.installAutoExit,e.target.checked?`true`:`false`),q&&console.log(`handleInstallAutoExitChange called with value:`,e.target.checked)};return(0,G.useEffect)(()=>{q&&console.log(`InstallProgressDialog output effect mounted, scrolling to bottom:`,u.current),setTimeout(()=>{q&&console.log(`Scrolling to bottom:`,u.current),u.current?.scrollIntoView({behavior:`smooth`,block:`end`})},0)},[t]),(0,Y.jsxs)(D,{open:e,onClose:(e,t)=>{t===`backdropClick`||t===`escapeKeyDown`||o()},slotProps:{paper:{sx:{width:J&&c?`100vw`:`75vw`,maxWidth:J&&c?`100vw`:`75vw`,height:J&&c?`100vh`:`75vw`,maxHeight:J&&c?`100vh`:`75vh`,margin:J&&c?`0px`:void 0,overflow:`hidden`}}},children:[(0,Y.jsx)(F,{children:(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h4`,{style:{margin:0},children:n})]})}),(0,Y.jsxs)(re,{dividers:!0,style:{overflow:`hidden`,display:`flex`,flexDirection:`column`,height:400,paddingBottom:0},children:[(0,Y.jsx)(`div`,{style:{display:`block`,marginBottom:`10px`,fontSize:`16px`,fontWeight:`bold`,color:`var(--primary-color)`},children:`Process log`}),(0,Y.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:[t.split(`
|
|
43
43
|
`).map((e,t)=>(0,Y.jsx)(`li`,{style:{padding:0,margin:0,wordBreak:`break-all`},children:e},t)),(0,Y.jsx)(`li`,{ref:u,style:{padding:0,margin:0}})]})]}),(0,Y.jsxs)(x,{sx:{justifyContent:`space-evenly`},children:[a&&(0,Y.jsx)(L,{variant:`contained`,onClick:a,children:`Install`}),(0,Y.jsx)(L,{onClick:o,children:`Close`}),(0,Y.jsx)(d,{control:(0,Y.jsx)(M,{checked:s,onChange:e=>f(e)}),label:`Close on success`,style:{color:`var(--div-text-color)`}})]})]})},ci=[];function li({children:e}){let[t,n]=(0,G.useState)(!1),[r,i]=(0,G.useState)(null),{enqueueSnackbar:a,closeSnackbar:o}=vt(),s=(0,G.useCallback)(e=>{q&&console.log(`UiProvider closeSnackbarMessage: message ${e}`);let t=ci.findIndex(t=>t.message===e);t!==-1&&(o(ci[t].key),ci.splice(t,1),q&&console.log(`UiProvider closeSnackbarMessage: message ${e} removed from persistMessages`))},[o]),c=(0,G.useCallback)((e,t,n)=>{q&&console.log(`UiProvider showSnackbarMessage: message ${e} timeout ${t}`);let r=a(e,{variant:`default`,autoHideDuration:t==null||t>0?(t??5)*1e3:null,persist:t===0,content:t=>(0,Y.jsx)(W,{sx:{margin:`0`,padding:`0`,width:`300px`,marginRight:`30px`},children:(0,Y.jsx)(pe,{severity:n??`info`,variant:`filled`,sx:{color:`#fff`,fontWeight:`normal`,width:`100%`,cursor:`pointer`,padding:`0px 10px`},onClick:()=>o(t),action:(0,Y.jsx)(T,{size:`small`,onClick:()=>o(t),sx:{color:`#fff`},children:(0,Y.jsx)(Qe,{fontSize:`small`})}),children:e},t)},t)});t===0&&(q&&console.log(`UiProvider showSnackbarMessage: message ${e} timeout ${t} - persist key ${r}`),ci.push({message:e,key:r}))},[a,o]),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(``),_=(0,G.useRef)(null),v=(0,G.useRef)(null),y=()=>{q&&console.log(`UiProvider handle confirm action ${h}`),u(!1),_.current&&_.current(h)},b=()=>{q&&console.log(`UiProvider handle cancel action ${h}`),u(!1),v.current&&v.current(h)},x=(0,G.useCallback)((e,t,n,r,i)=>{q&&console.log(`UiProvider showConfirmCancelDialog for command ${n}`),f(e),m(t),g(n),_.current=r,v.current=i,u(!0)},[]),[S,C]=(0,G.useState)(!1),[w,E]=(0,G.useState)(``),[D,O]=(0,G.useState)(``),[k,A]=(0,G.useState)(``),[j,M]=(0,G.useState)(``),[N,P]=(0,G.useState)(localStorage.getItem(K.installAutoExit)!==`false`),ee=(0,G.useCallback)((e,t,n)=>{q&&console.log(`UiProvider show install progress for package ${e}`),E(e),O(t),A(n),C(!0)},[]),F=(0,G.useCallback)(e=>{q&&console.log(`UiProvider addInstallProgress: output ${e}`),M(t=>t+e+`
|
|
44
|
-
`)},[]),te=(0,G.useCallback)(()=>{q&&console.log(`UiProvider exitInstallProgressSuccess: package ${k}`),localStorage.getItem(K.installAutoExit)!==`false`&&C(!1)},[k]),I=(0,G.useCallback)(()=>{q&&console.log(`UiProvider exitInstallProgressError: package ${k}`)},[k]),ne=(0,G.useCallback)(()=>{q&&console.log(`UiProvider hide install progress`),C(!1)},[]),re=()=>{q&&console.log(`UiProvider handle install close action`),C(!1),A(``),M(``)},ie=(0,G.useMemo)(()=>({mobile:t,setMobile:n,currentPage:r,setCurrentPage:i,showSnackbarMessage:c,closeSnackbarMessage:s,closeSnackbar:o,showConfirmCancelDialog:x,showInstallProgress:ee,exitInstallProgressSuccess:te,exitInstallProgressError:I,hideInstallProgress:ne,addInstallProgress:F,installAutoExit:N,setInstallAutoExit:P}),[t,r,n,i,c,s,o,x,ee,te,I,ne,F,N,P]);return(0,Y.jsxs)(Vt.Provider,{value:ie,children:[(0,Y.jsx)(oi,{open:l,title:d,message:p,onConfirm:y,onCancel:b}),(0,Y.jsx)(si,{open:S,title:w,_command:D,_packageName:k,output:j,onClose:re}),e]})}function ui(e,t){q&&console.log(`getCssVariable:`,e,`defaultValue`,t);let n=getComputedStyle(document.body).getPropertyValue(e).trim();return n||console.error(`getCssVariable: undefined`,n),n||t}function di(e){return C({palette:{primary:{main:e},action:{disabled:`var(--main-label-color)`},text:{disabled:`var(--main-label-color)`}},typography:{fontFamily:`Roboto, Helvetica, Arial, sans-serif`},components:{MuiDialog:{styleOverrides:{paper:{color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`,border:`2px solid var(--div-border-color)`,borderRadius:`var(--div-border-radius)`,boxShadow:`2px 2px 5px var(--div-shadow-color)`}}},MuiTooltip:{defaultProps:{placement:`top-start`,arrow:!0}},MuiButton:{styleOverrides:{root:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,"&:hover":{backgroundColor:`var(--main-button-bg-color)`},"&.Mui-disabled":{color:`var(--main-button-color)`,backgroundColor:`var(--main-grey-color)`}},contained:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`},outlined:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`},text:{color:`var(--main-button-color)`}},defaultProps:{variant:`contained`,size:`small`}},MuiIconButton:{styleOverrides:{root:{color:`var(--main-icon-color)`,"&:hover .MuiSvgIcon-root":{color:`var(--primary-color)`}}}},MuiCheckbox:{styleOverrides:{root:{color:`var(--main-label-color)`,"&.Mui-checked":{color:`var(--primary-color)`}}}},MuiTextField:{defaultProps:{size:`small`,variant:`outlined`,fullWidth:!0}},MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:`var(--div-bg-color)`,"& .MuiOutlinedInput-notchedOutline":{borderColor:`var(--main-label-color)`},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:`var(--main-text-color)`},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:`var(--primary-color)`},padding:`0px`},input:{color:`var(--div-text-color)`,padding:`4px 8px`}}},MuiInputLabel:{styleOverrides:{root:{color:`var(--main-label-color)`,"&.Mui-focused":{color:`var(--primary-color)`}}}},MuiFormLabel:{styleOverrides:{root:{color:`var(--main-label-color)`,"&.Mui-focused":{color:`var(--main-label-color)`}}}},MuiFormControl:{styleOverrides:{root:{color:`var(--main-grey-color)`}}},MuiRadio:{styleOverrides:{root:{color:`var(--main-label-color)`,"&.Mui-checked":{color:`var(--primary-color)`}}}},MuiSelect:{styleOverrides:{root:{backgroundColor:`var(--div-bg-color)`,color:`var(--div-text-color)`,height:`30px`,"&:hover":{borderColor:`var(--main-text-color)`},"&.Mui-focused":{borderColor:`var(--primary-color)`}}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:`var(--main-menu-bg-color)`,padding:`0px`,margin:`0px`},list:{padding:`0px`}}},MuiMenuItem:{styleOverrides:{root:{color:`var(--main-menu-color)`,backgroundColor:`var(--main-menu-bg-color)`,"&:hover":{backgroundColor:`var(--main-menu-hover-color)`},"&.Mui-selected":{color:`var(--main-menu-color)`,backgroundColor:`var(--main-menu-bg-color)`},"&.Mui-selected:hover":{backgroundColor:`var(--main-menu-hover-color)`}}}},MuiListItemButton:{styleOverrides:{root:{cursor:`pointer`,"&:hover":{backgroundColor:`var(--main-bg-color)`}}}},MuiListItemIcon:{styleOverrides:{root:{color:`var(--div-text-color)`}}},MuiListItemText:{styleOverrides:{primary:{fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`},secondary:{fontSize:`14px`,fontWeight:`normal`,color:`var(--div-text-color)`}}}}})}function fi({setLoggedIn:e}){let[t,n]=(0,G.useState)(``),[r,i]=(0,G.useState)(``),a={display:`flex`,justifyContent:`center`,alignItems:`center`,height:`100vh`,backgroundColor:`var(--main-bg-color)`},o={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)`},s={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)`},c=async t=>{try{let n=await fetch(`./api/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:t})});if(n.ok){let{valid:r}=await n.json();r?(e(!0),t!==``&&Lt(t)):t!==``&&i(`Incorrect password!`)}else console.error(`Failed to log in:`,n.statusText)}catch(e){console.error(`Failed to log in:`,e)}};return
|
|
44
|
+
`)},[]),te=(0,G.useCallback)(()=>{q&&console.log(`UiProvider exitInstallProgressSuccess: package ${k}`),localStorage.getItem(K.installAutoExit)!==`false`&&C(!1)},[k]),I=(0,G.useCallback)(()=>{q&&console.log(`UiProvider exitInstallProgressError: package ${k}`)},[k]),ne=(0,G.useCallback)(()=>{q&&console.log(`UiProvider hide install progress`),C(!1)},[]),re=()=>{q&&console.log(`UiProvider handle install close action`),C(!1),A(``),M(``)},ie=(0,G.useMemo)(()=>({mobile:t,setMobile:n,currentPage:r,setCurrentPage:i,showSnackbarMessage:c,closeSnackbarMessage:s,closeSnackbar:o,showConfirmCancelDialog:x,showInstallProgress:ee,exitInstallProgressSuccess:te,exitInstallProgressError:I,hideInstallProgress:ne,addInstallProgress:F,installAutoExit:N,setInstallAutoExit:P}),[t,r,n,i,c,s,o,x,ee,te,I,ne,F,N,P]);return(0,Y.jsxs)(Vt.Provider,{value:ie,children:[(0,Y.jsx)(oi,{open:l,title:d,message:p,onConfirm:y,onCancel:b}),(0,Y.jsx)(si,{open:S,title:w,_command:D,_packageName:k,output:j,onClose:re}),e]})}function ui(e,t){q&&console.log(`getCssVariable:`,e,`defaultValue`,t);let n=getComputedStyle(document.body).getPropertyValue(e).trim();return n||console.error(`getCssVariable: undefined`,n),n||t}function di(e){return C({palette:{primary:{main:e},action:{disabled:`var(--main-label-color)`},text:{disabled:`var(--main-label-color)`}},typography:{fontFamily:`Roboto, Helvetica, Arial, sans-serif`},components:{MuiDialog:{styleOverrides:{paper:{color:`var(--div-text-color)`,backgroundColor:`var(--div-bg-color)`,border:`2px solid var(--div-border-color)`,borderRadius:`var(--div-border-radius)`,boxShadow:`2px 2px 5px var(--div-shadow-color)`}}},MuiTooltip:{defaultProps:{placement:`top-start`,arrow:!0}},MuiButton:{styleOverrides:{root:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,"&:hover":{backgroundColor:`var(--main-button-bg-color)`},"&.Mui-disabled":{color:`var(--main-button-color)`,backgroundColor:`var(--main-grey-color)`}},contained:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`},outlined:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`},text:{color:`var(--main-button-color)`}},defaultProps:{variant:`contained`,size:`small`}},MuiIconButton:{styleOverrides:{root:{color:`var(--main-icon-color)`,"&:hover .MuiSvgIcon-root":{color:`var(--primary-color)`}}}},MuiCheckbox:{styleOverrides:{root:{color:`var(--main-label-color)`,"&.Mui-checked":{color:`var(--primary-color)`}}}},MuiTextField:{defaultProps:{size:`small`,variant:`outlined`,fullWidth:!0}},MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:`var(--div-bg-color)`,"& .MuiOutlinedInput-notchedOutline":{borderColor:`var(--main-label-color)`},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:`var(--main-text-color)`},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:`var(--primary-color)`},padding:`0px`},input:{color:`var(--div-text-color)`,padding:`4px 8px`}}},MuiInputLabel:{styleOverrides:{root:{color:`var(--main-label-color)`,"&.Mui-focused":{color:`var(--primary-color)`}}}},MuiFormLabel:{styleOverrides:{root:{color:`var(--main-label-color)`,"&.Mui-focused":{color:`var(--main-label-color)`}}}},MuiFormControl:{styleOverrides:{root:{color:`var(--main-grey-color)`}}},MuiRadio:{styleOverrides:{root:{color:`var(--main-label-color)`,"&.Mui-checked":{color:`var(--primary-color)`}}}},MuiSelect:{styleOverrides:{root:{backgroundColor:`var(--div-bg-color)`,color:`var(--div-text-color)`,height:`30px`,"&:hover":{borderColor:`var(--main-text-color)`},"&.Mui-focused":{borderColor:`var(--primary-color)`}}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:`var(--main-menu-bg-color)`,padding:`0px`,margin:`0px`},list:{padding:`0px`}}},MuiMenuItem:{styleOverrides:{root:{color:`var(--main-menu-color)`,backgroundColor:`var(--main-menu-bg-color)`,"&:hover":{backgroundColor:`var(--main-menu-hover-color)`},"&.Mui-selected":{color:`var(--main-menu-color)`,backgroundColor:`var(--main-menu-bg-color)`},"&.Mui-selected:hover":{backgroundColor:`var(--main-menu-hover-color)`}}}},MuiListItemButton:{styleOverrides:{root:{cursor:`pointer`,"&:hover":{backgroundColor:`var(--main-bg-color)`}}}},MuiListItemIcon:{styleOverrides:{root:{color:`var(--div-text-color)`}}},MuiListItemText:{styleOverrides:{primary:{fontSize:`16px`,fontWeight:`bold`,color:`var(--div-text-color)`},secondary:{fontSize:`14px`,fontWeight:`normal`,color:`var(--div-text-color)`}}}}})}function fi({setLoggedIn:e}){let[t,n]=(0,G.useState)(``),[r,i]=(0,G.useState)(``),a={display:`flex`,justifyContent:`center`,alignItems:`center`,height:`100vh`,backgroundColor:`var(--main-bg-color)`},o={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)`},s={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)`},c=(0,G.useCallback)(async t=>{try{let n=await fetch(`./api/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({password:t})});if(n.ok){let{valid:r}=await n.json();r?(e(!0),t!==``&&Lt(t)):t!==``&&i(`Incorrect password!`)}else console.error(`Failed to log in:`,n.statusText)}catch(e){console.error(`Failed to log in:`,e)}},[e]);return(0,G.useEffect)(()=>{c(``)},[c]),(0,Y.jsx)(`div`,{style:a,children:(0,Y.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),c(t)},style:o,children:[(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:`20px`},children:[(0,Y.jsx)(`img`,{src:`matterbridge.svg`,alt:`Matterbridge Logo`,style:{height:`32px`,width:`32px`}}),(0,Y.jsx)(`h3`,{style:{color:`var(--div-text-color)`},children:`Welcome to Matterbridge`})]}),(0,Y.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`space-between`,gap:`20px`},children:[(0,Y.jsx)(`input`,{type:`text`,name:`username`,autoComplete:`username`,style:{display:`none`},tabIndex:-1}),(0,Y.jsx)(`input`,{type:`password`,value:t,onChange:e=>n(e.target.value),style:s,placeholder:`password`,autoComplete:`current-password`}),(0,Y.jsx)(`button`,{type:`submit`,style:{color:`var(--main-button-color)`,backgroundColor:`var(--main-button-bg-color)`,borderColor:`var(--div-bg-color)`},children:`Log in`})]}),(0,Y.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,alignItems:`center`,justifyContent:`center`,margin:0,height:`30px`},children:r&&(0,Y.jsx)(`p`,{style:{color:`red`},children:r})})]})})}function pi(){let[e,t]=(0,G.useState)(!1),r=localStorage.getItem(K.frontendTheme)||`dark`;q&&console.log(`Setting frontend theme "%s"`,r),document.body.setAttribute(`frontend-theme`,r);let o=ui(`--primary-color`,`#1976d2`);q&&console.log(`Primary color from CSS "%s"`,o);let s=di(o),l=window.location.href,u=window.location.pathname;(u.endsWith(`/devices`)||u.endsWith(`/log`)||u.endsWith(`/settings`)||u.endsWith(`/test`))&&(u=u.substring(0,u.lastIndexOf(`/`)));let d=u.endsWith(`/`)?u:u+`/`,f=u.includes(`/api/hassio_ingress/`);return zt(f),q&&(console.log(`Loading App...`),console.log(`- href = "${l}"`),console.log(`- pathname = "${window.location.pathname}" >>> "${u}"`),console.log(`- baseName = "${d}"`),console.log(`- isIngress = "${f}"`)),e?(0,Y.jsx)(he,{theme:s,children:(0,Y.jsx)(yt,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:`bottom`,horizontal:`right`},children:(0,Y.jsx)(li,{children:(0,Y.jsx)(Ut,{children:(0,Y.jsx)(a,{basename:d,children:(0,Y.jsx)(Kr,{children:(0,Y.jsxs)(c,{children:[(0,Y.jsx)(i,{path:`/`,element:(0,Y.jsx)(Ir,{})}),(0,Y.jsx)(i,{path:`/devices`,element:(0,Y.jsx)(jn,{})}),(0,Y.jsx)(i,{path:`/log`,element:(0,Y.jsx)(Rr,{})}),(0,Y.jsx)(i,{path:`/settings`,element:(0,Y.jsx)(ri,{})}),(0,Y.jsx)(i,{path:`/test`,element:(0,Y.jsx)(ai,{})}),(0,Y.jsx)(i,{path:`*`,element:(0,Y.jsx)(n,{to:`/`})})]})})})})})})}):(0,Y.jsx)(fi,{setLoggedIn:t})}var mi=document.getElementById(`root`);if(mi===null)throw Error(`Root element not found`);At.createRoot(mi).render((0,Y.jsx)(G.StrictMode,{children:(0,Y.jsx)(pi,{})}));
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matterbridge/frontend",
|
|
3
|
-
"version": "3.4.18-dev-20260620-
|
|
3
|
+
"version": "3.4.18-dev-20260620-2b9580a",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@matterbridge/frontend",
|
|
9
|
-
"version": "3.4.18-dev-20260620-
|
|
9
|
+
"version": "3.4.18-dev-20260620-2b9580a",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@emotion/react": "11.14.0",
|
package/package.json
CHANGED