iobroker.eos-admin 9.0.29 → 9.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/NEXOWATT_EOS_BUILD_INFO.json +11 -13
  2. package/README.md +9 -11
  3. package/adminWww/.vite/manifest.json +39 -39
  4. package/adminWww/NEXOWATT_EOS_FRONTEND_MANIFEST.json +111 -110
  5. package/adminWww/apple-touch-icon-eos-v2.png +0 -0
  6. package/adminWww/apple-touch-icon.png +0 -0
  7. package/adminWww/assets/{AdapterUpdateDialog-DXp4Dgkx.js → AdapterUpdateDialog-UhaQHyF1.js} +1 -1
  8. package/adminWww/assets/{Adapters-1AOp__74.js → Adapters-Di3sM_ky.js} +1 -1
  9. package/adminWww/assets/{ConfigManager-CGGXU4Jp.js → ConfigManager-C2naRwDl.js} +1 -1
  10. package/adminWww/assets/{Enums-Bl4EngJF.js → Enums-B9ucB-qg.js} +1 -1
  11. package/adminWww/assets/{Fields-zSEjRWOB.js → Fields-DN41WFbp.js} +1 -1
  12. package/adminWww/assets/{Files-CnYmjEbu.js → Files-C3PbbeNR.js} +1 -1
  13. package/adminWww/assets/{Hosts-zFJyiuvd.js → Hosts-DXjTE0pX.js} +1 -1
  14. package/adminWww/assets/{Instances-D10dnQY4.js → Instances-PKvEjDNQ.js} +1 -1
  15. package/adminWww/assets/{Intro-DxLBfGZ8.js → Intro-BnYMjDZr.js} +1 -1
  16. package/adminWww/assets/{Logs-CAc6o-d_.js → Logs-DTo6XJF_.js} +1 -1
  17. package/adminWww/assets/{Objects-I64lF3ZS.js → Objects-DyEBMDK6.js} +1 -1
  18. package/adminWww/assets/{Overview-BQ7HBH-7.js → Overview-CWLYuqZx.js} +1 -1
  19. package/adminWww/assets/{State-DHLL8gAc.js → State-Ca9_Ke_c.js} +1 -1
  20. package/adminWww/assets/{UsedResources-DlQ_XqoR.js → UsedResources-20bsoxmj.js} +1 -1
  21. package/adminWww/assets/{Users-CKHDvxG5.js → Users-yZyZX-18.js} +1 -1
  22. package/adminWww/assets/{bootstrap-CIDT4MeX.js → bootstrap-BQ4OzwbT.js} +3 -3
  23. package/adminWww/assets/{hostInit-Cvl4lPGh.js → hostInit-CGSSNegd.js} +1 -1
  24. package/adminWww/assets/{icons-material-ngdwOXrt.js → icons-material-C3PNaipj.js} +1 -1
  25. package/adminWww/assets/{index-B9Tfj1YG.js → index-C4CShixx.js} +2 -2
  26. package/adminWww/assets/{installSVGRenderer-COP6GC9p.js → installSVGRenderer-DeaOAT3W.js} +1 -1
  27. package/adminWww/assets/{mf-entry-bootstrap-0-31191d2e.js → mf-entry-bootstrap-0-c5733c2d.js} +2 -2
  28. package/adminWww/index.html +24 -24
  29. package/adminWww/mf-manifest.json +1 -1
  30. package/adminWww/mf-stats.json +1 -1
  31. package/adminWww/remoteEntry-eos-9.0.31.js +12 -0
  32. package/adminWww/remoteEntry.js +1 -1
  33. package/build/lib/eosRuntimeControl.js +21 -10
  34. package/build/lib/eosRuntimeControl.js.map +1 -1
  35. package/build/lib/eosRuntimeHealth.js +12 -9
  36. package/build/lib/eosRuntimeHealth.js.map +1 -1
  37. package/build/lib/eosSplitRuntime.js +61 -0
  38. package/build/lib/eosSplitRuntime.js.map +1 -0
  39. package/build/lib/eosUiProcess.js +91 -13
  40. package/build/lib/eosUiProcess.js.map +1 -1
  41. package/build/lib/eosUiProcessWorker.js +15 -8
  42. package/build/lib/eosUiProcessWorker.js.map +1 -1
  43. package/build/lib/web.js +26 -15
  44. package/build/lib/web.js.map +1 -1
  45. package/docs/README.md +2 -2
  46. package/docs/reports/unified-9.0.30/PRUEFBERICHT.md +37 -0
  47. package/docs/reports/{unified-9.0.29 → unified-9.0.30}/PRUEFERGEBNISSE.json +13 -13
  48. package/docs/reports/unified-9.0.30/raw/INDEX.json +137 -0
  49. package/docs/reports/unified-9.0.30/raw/acceptance-node22.log +30 -0
  50. package/docs/reports/unified-9.0.30/raw/acceptance-node24.log +11 -0
  51. package/docs/reports/{unified-9.0.29 → unified-9.0.30}/raw/backend.log +1 -1
  52. package/docs/reports/unified-9.0.30/raw/baseline-10000.json +1 -0
  53. package/docs/reports/unified-9.0.30/raw/baseline-50000.json +1 -0
  54. package/docs/reports/unified-9.0.30/raw/candidate-10000.json +1 -0
  55. package/docs/reports/unified-9.0.30/raw/candidate-50000.json +1 -0
  56. package/docs/reports/{unified-9.0.29 → unified-9.0.30}/raw/frontend.log +25 -25
  57. package/docs/reports/{unified-9.0.29 → unified-9.0.30}/raw/installer.log +4 -4
  58. package/docs/reports/{unified-9.0.29 → unified-9.0.30}/raw/lint.log +2 -2
  59. package/docs/reports/{unified-9.0.29 → unified-9.0.30}/raw/modules.log +1 -1
  60. package/docs/reports/unified-9.0.30/raw/node22-profile.json +611 -0
  61. package/docs/reports/unified-9.0.30/raw/node22-tests-final.log +17170 -0
  62. package/docs/reports/unified-9.0.30/raw/node24-profile.json +611 -0
  63. package/docs/reports/{unified-9.0.29 → unified-9.0.30}/raw/node24-tests-final.log +2774 -2764
  64. package/docs/reports/unified-9.0.30/raw/profile-combined-node24.log +12 -0
  65. package/docs/reports/unified-9.0.30/raw/profile-split-node24.log +12 -0
  66. package/docs/reports/{unified-9.0.29 → unified-9.0.30}/raw/typecheck.log +1 -1
  67. package/docs/reports/{unified-9.0.29 → unified-9.0.30}/raw/ui-runtime.log +3 -2
  68. package/docs/reports/unified-9.0.31/PRUEFBERICHT.md +22 -0
  69. package/docs/reports/unified-9.0.31/PRUEFERGEBNISSE.json +112 -0
  70. package/docs/reports/unified-9.0.31/raw/INDEX.json +102 -0
  71. package/docs/reports/unified-9.0.31/raw/backend.log +5 -0
  72. package/docs/reports/unified-9.0.31/raw/branding-build-node22.log +59 -0
  73. package/docs/reports/unified-9.0.31/raw/branding-node24.log +17 -0
  74. package/docs/reports/unified-9.0.31/raw/frontend.log +151 -0
  75. package/docs/reports/unified-9.0.31/raw/https-build-node22.log +235 -0
  76. package/docs/reports/unified-9.0.31/raw/https-node24.log +46 -0
  77. package/docs/reports/unified-9.0.31/raw/installer.log +26 -0
  78. package/docs/reports/unified-9.0.31/raw/lint.log +5 -0
  79. package/docs/reports/unified-9.0.31/raw/modules.log +5 -0
  80. package/docs/reports/{unified-9.0.29 → unified-9.0.31}/raw/node22-tests-final.log +5274 -5208
  81. package/docs/reports/unified-9.0.31/raw/node22-version.log +1 -0
  82. package/docs/reports/unified-9.0.31/raw/node24-tests-final.log +2862 -0
  83. package/docs/reports/unified-9.0.31/raw/node24-version.log +1 -0
  84. package/docs/reports/unified-9.0.31/raw/typecheck.log +5 -0
  85. package/docs/reports/unified-9.0.31/raw/ui-runtime.log +8 -0
  86. package/docs/reports/unified-9.0.31/raw/web-lint.log +0 -0
  87. package/docs/start/START_HIER_9.0.30.md +16 -0
  88. package/docs/start/START_HIER_9.0.31.md +16 -0
  89. package/docs/unified/ARCHITECTURE.md +18 -12
  90. package/io-package.json +12 -12
  91. package/modules/devices/README.md +1 -1
  92. package/modules/devices/lib/deviceRuntime.js +18 -14
  93. package/modules/devices/test/driverLoading.test.js +76 -0
  94. package/package.json +8 -6
  95. package/public/eos-runtime/index.js +7 -6
  96. package/public/eos-tls/trust.html +1 -1
  97. package/release-manifests/unified/build-environment.cdx.json +7 -7
  98. package/release-manifests/unified/files.json +179 -116
  99. package/release-manifests/unified/frontend.cdx.json +7 -7
  100. package/release-manifests/unified/installer.cdx.json +7 -7
  101. package/release-manifests/unified/obsolete-admin-assets.json +172 -6
  102. package/release-manifests/unified/runtime.cdx.json +28 -28
  103. package/release-manifests/unified/validation.json +15 -15
  104. package/tools/eos-release-check.cjs +2 -0
  105. package/tools/eos-release-manifest.cjs +1 -1
  106. package/ui/io-package.json +6 -2
  107. package/ui/lib/datapoint-picker.js +184 -0
  108. package/ui/lib/eos-presentation-routes.js +58 -0
  109. package/ui/lib/eos-presentation.js +140 -0
  110. package/ui/lib/ephemeral-cache.js +7 -4
  111. package/ui/lib/ui-access-policy.js +12 -3
  112. package/ui/main.js +8 -310
  113. package/ui/package.json +1 -1
  114. package/ui/www/ems-apps.html +1 -1
  115. package/ui/www/energy-ledger.html +1 -1
  116. package/ui/www/evcs.html +1 -1
  117. package/ui/www/history.html +1 -1
  118. package/ui/www/index.html +1 -1
  119. package/ui/www/logic.html +1 -1
  120. package/ui/www/login.html +1 -1
  121. package/ui/www/manifest.webmanifest +2 -2
  122. package/ui/www/settings.html +1 -1
  123. package/ui/www/simulation.html +1 -1
  124. package/ui/www/smarthome-config.html +1 -1
  125. package/ui/www/smarthome.html +1 -1
  126. package/ui/www/storagefarm.html +1 -1
  127. package/adminWww/remoteEntry-eos-9.0.29.js +0 -12
  128. package/docs/reports/unified-9.0.29/PRUEFBERICHT.md +0 -30
  129. package/docs/reports/unified-9.0.29/raw/INDEX.json +0 -97
  130. package/docs/reports/unified-9.0.29/raw/tls-targeted-build-node22.log +0 -139
  131. package/docs/reports/unified-9.0.29/raw/tls-targeted-node24.log +0 -132
  132. package/docs/start/START_HIER_9.0.29.md +0 -22
  133. /package/docs/reports/{unified-9.0.29 → unified-9.0.30}/raw/node22-version.log +0 -0
  134. /package/docs/reports/{unified-9.0.29 → unified-9.0.30}/raw/node24-version.log +0 -0
  135. /package/docs/reports/{unified-9.0.29 → unified-9.0.30}/raw/npm-audit-runtime.json +0 -0
  136. /package/docs/reports/{unified-9.0.29/raw/tls-lint.log → unified-9.0.30/raw/split-lint.log} +0 -0
@@ -1,3 +1,3 @@
1
- import{Do as e,Ds as t,Eo as n,Es as r,Fr as i,Hs as a,Ir as o,Ko as s,Pr as c,Ts as l,Us as u,Vs as d,Xo as f,_o as p,br as m,go as h,mo as g,po as _,qs as v,tc as y,xo as b,yo as x}from"./loadShare-eager-dmdYQhAl.js";import{t as S}from"./AdminUtils-Dc1eHsx5.js";import{N as C}from"./bootstrap-CIDT4MeX.js";import{t as w}from"./Storage-B44xXFFu.js";import{n as T,t as E}from"./UnfoldMore-DOHSVdRn.js";import{t as D}from"./Extension-DIV5Bi1u.js";import{$ as O,$t as k,A as ee,C as te,D as A,Dt as j,Jt as ne,L as re,M as ie,N as ae,Nt as oe,O as se,Pt as ce,Qt as le,R as ue,V as de,W as fe,Xt as M,Y as pe,Yt as me,Zt as N,_n as P,ct as he,dn as ge,en as F,ft as _e,gn as ve,i as ye,in as I,it as L,j as be,k as R,l as z,ln as B,mn as xe,n as Se,nn as Ce,nt as V,o as we,on as H,q as Te,r as Ee,rn as De,rt as U,s as Oe,sn as ke,t as Ae,tn as je,un as Me,v as Ne,y as Pe,z as Fe}from"./installSVGRenderer-COP6GC9p.js";import{n as Ie,t as Le}from"./Timeline-BtOuO808.js";var Re=function(e,t){if(t===`all`)return{type:`all`,title:e.getLocaleModel().get([`legend`,`selector`,`all`])};if(t===`inverse`)return{type:`inverse`,title:e.getLocaleModel().get([`legend`,`selector`,`inverse`])}},W=function(e){P(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n.layoutMode={type:`box`,ignoreSize:!0},n}return t.prototype.init=function(e,t,n){this.mergeDefaultAndTheme(e,n),e.selected=e.selected||{},this._updateSelector(e)},t.prototype.mergeOption=function(t,n){e.prototype.mergeOption.call(this,t,n),this._updateSelector(t)},t.prototype._updateSelector=function(e){var t=e.selector,n=this.ecModel;t===!0&&(t=e.selector=[`all`,`inverse`]),I(t)&&k(t,function(e,r){B(e)&&(e={type:e}),t[r]=ge(e,Re(n,e.type))})},t.prototype.optionUpdated=function(){this._updateData(this.ecModel);var e=this._data;if(e[0]&&this.get(`selectedMode`)===`single`){for(var t=!1,n=0;n<e.length;n++){var r=e[n].get(`name`);if(this.isSelected(r)){this.select(r),t=!0;break}}!t&&this.select(e[0].get(`name`))}},t.prototype._updateData=function(e){var t=[],n=[];e.eachRawSeries(function(r){var i=r.name;n.push(i);var a;if(r.legendVisualProvider){var o=r.legendVisualProvider.getAllNames();e.isSeriesFiltered(r)||(n=n.concat(o)),o.length?t=t.concat(o):a=!0}else a=!0;a&&_e(r)&&t.push(r.name)}),this._availableNames=n;var r=this.get(`data`)||t,i=M(),a=Me(r,function(e){return(B(e)||ke(e))&&(e={name:e}),i.get(e.name)?null:(i.set(e.name,!0),new ue(e,this,this.ecModel))},this);this._data=je(a,function(e){return!!e})},t.prototype.getData=function(){return this._data},t.prototype.select=function(e){var t=this.option.selected;if(this.get(`selectedMode`)===`single`){var n=this._data;k(n,function(e){t[e.get(`name`)]=!1})}t[e]=!0},t.prototype.unSelect=function(e){this.get(`selectedMode`)!==`single`&&(this.option.selected[e]=!1)},t.prototype.toggleSelected=function(e){var t=this.option.selected;t.hasOwnProperty(e)||(t[e]=!0),this[t[e]?`unSelect`:`select`](e)},t.prototype.allSelect=function(){var e=this._data,t=this.option.selected;k(e,function(e){t[e.get(`name`,!0)]=!0})},t.prototype.inverseSelect=function(){var e=this._data,t=this.option.selected;k(e,function(e){var n=e.get(`name`,!0);t.hasOwnProperty(n)||(t[n]=!0),t[n]=!t[n]})},t.prototype.isSelected=function(e){var t=this.option.selected;return!(t.hasOwnProperty(e)&&!t[e])&&De(this._availableNames,e)>=0},t.prototype.getOrient=function(){return this.get(`orient`)===`vertical`?{index:1,name:`vertical`}:{index:0,name:`horizontal`}},t.type=`legend.plain`,t.dependencies=[`series`],t.defaultOption={z:4,show:!0,orient:`horizontal`,left:`center`,bottom:A.size.m,align:`auto`,backgroundColor:A.color.transparent,borderColor:A.color.border,borderRadius:0,borderWidth:0,padding:5,itemGap:8,itemWidth:25,itemHeight:14,symbolRotate:`inherit`,symbolKeepAspect:!0,inactiveColor:A.color.disabled,inactiveBorderColor:A.color.disabled,inactiveBorderWidth:`auto`,itemStyle:{color:`inherit`,opacity:`inherit`,borderColor:`inherit`,borderWidth:`auto`,borderCap:`inherit`,borderJoin:`inherit`,borderDashOffset:`inherit`,borderMiterLimit:`inherit`},lineStyle:{width:`auto`,color:`inherit`,inactiveColor:A.color.disabled,inactiveWidth:2,opacity:`inherit`,type:`inherit`,cap:`inherit`,join:`inherit`,dashOffset:`inherit`,miterLimit:`inherit`},textStyle:{color:A.color.secondary},selectedMode:!0,selector:!1,selectorLabel:{show:!0,borderRadius:10,padding:[3,5,3,5],fontSize:12,fontFamily:`sans-serif`,color:A.color.tertiary,borderWidth:1,borderColor:A.color.border},emphasis:{selectorLabel:{show:!0,color:A.color.quaternary}},selectorPosition:`auto`,selectorItemGap:7,selectorButtonGap:10,tooltip:{show:!1},triggerEvent:!1},t}(se),G=N,K=k,q=j,ze=function(e){P(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n.newlineDisabled=!1,n}return t.prototype.init=function(){this.group.add(this._contentGroup=new q),this.group.add(this._selectorGroup=new q),this._isFirstRender=!0},t.prototype.getContentGroup=function(){return this._contentGroup},t.prototype.getSelectorGroup=function(){return this._selectorGroup},t.prototype.render=function(e,t,n){var r=this._isFirstRender;if(this._isFirstRender=!1,this.resetInner(),e.get(`show`,!0)){var i=e.get(`align`),a=e.get(`orient`);i&&i!==`auto`||(i=e.get(`left`)===`right`&&a===`vertical`?`right`:`left`);var o=e.get(`selector`,!0),s=e.get(`selectorPosition`,!0);o&&(!s||s===`auto`)&&(s=a===`horizontal`?`end`:`start`),this.renderInner(i,e,t,n,o,a,s);var c=ee(e,n).refContainer,l=e.getBoxLayoutParams(),u=e.get(`padding`),d=ie(l,c,u),f=this.layoutInner(e,i,d,r,o,s),p=ie(le({width:f.width,height:f.height},l),c,u);this.group.x=p.x-f.x,this.group.y=p.y-f.y,this.group.markRedraw(),this.group.add(this._backgroundEl=Ee(f,e))}},t.prototype.resetInner=function(){this.getContentGroup().removeAll(),this._backgroundEl&&this.group.remove(this._backgroundEl),this.getSelectorGroup().removeAll()},t.prototype.renderInner=function(e,t,n,r,i,a,o){var s=this.getContentGroup(),c=M(),l=t.get(`selectedMode`),u=t.get(`triggerEvent`),d=[];n.eachRawSeries(function(e){!e.get(`legendHoverLink`)&&d.push(e.id)}),K(t.getData(),function(i,a){var o=this,f=i.get(`name`);if(!this.newlineDisabled&&(f===``||f===`
1
+ import{Do as e,Ds as t,Eo as n,Es as r,Fr as i,Hs as a,Ir as o,Ko as s,Pr as c,Ts as l,Us as u,Vs as d,Xo as f,_o as p,br as m,go as h,mo as g,po as _,qs as v,tc as y,xo as b,yo as x}from"./loadShare-eager-dmdYQhAl.js";import{t as S}from"./AdminUtils-Dc1eHsx5.js";import{N as C}from"./bootstrap-BQ4OzwbT.js";import{t as w}from"./Storage-B44xXFFu.js";import{n as T,t as E}from"./UnfoldMore-DOHSVdRn.js";import{t as D}from"./Extension-DIV5Bi1u.js";import{$ as O,$t as k,A as ee,C as te,D as A,Dt as j,Jt as ne,L as re,M as ie,N as ae,Nt as oe,O as se,Pt as ce,Qt as le,R as ue,V as de,W as fe,Xt as M,Y as pe,Yt as me,Zt as N,_n as P,ct as he,dn as ge,en as F,ft as _e,gn as ve,i as ye,in as I,it as L,j as be,k as R,l as z,ln as B,mn as xe,n as Se,nn as Ce,nt as V,o as we,on as H,q as Te,r as Ee,rn as De,rt as U,s as Oe,sn as ke,t as Ae,tn as je,un as Me,v as Ne,y as Pe,z as Fe}from"./installSVGRenderer-DeaOAT3W.js";import{n as Ie,t as Le}from"./Timeline-BtOuO808.js";var Re=function(e,t){if(t===`all`)return{type:`all`,title:e.getLocaleModel().get([`legend`,`selector`,`all`])};if(t===`inverse`)return{type:`inverse`,title:e.getLocaleModel().get([`legend`,`selector`,`inverse`])}},W=function(e){P(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n.layoutMode={type:`box`,ignoreSize:!0},n}return t.prototype.init=function(e,t,n){this.mergeDefaultAndTheme(e,n),e.selected=e.selected||{},this._updateSelector(e)},t.prototype.mergeOption=function(t,n){e.prototype.mergeOption.call(this,t,n),this._updateSelector(t)},t.prototype._updateSelector=function(e){var t=e.selector,n=this.ecModel;t===!0&&(t=e.selector=[`all`,`inverse`]),I(t)&&k(t,function(e,r){B(e)&&(e={type:e}),t[r]=ge(e,Re(n,e.type))})},t.prototype.optionUpdated=function(){this._updateData(this.ecModel);var e=this._data;if(e[0]&&this.get(`selectedMode`)===`single`){for(var t=!1,n=0;n<e.length;n++){var r=e[n].get(`name`);if(this.isSelected(r)){this.select(r),t=!0;break}}!t&&this.select(e[0].get(`name`))}},t.prototype._updateData=function(e){var t=[],n=[];e.eachRawSeries(function(r){var i=r.name;n.push(i);var a;if(r.legendVisualProvider){var o=r.legendVisualProvider.getAllNames();e.isSeriesFiltered(r)||(n=n.concat(o)),o.length?t=t.concat(o):a=!0}else a=!0;a&&_e(r)&&t.push(r.name)}),this._availableNames=n;var r=this.get(`data`)||t,i=M(),a=Me(r,function(e){return(B(e)||ke(e))&&(e={name:e}),i.get(e.name)?null:(i.set(e.name,!0),new ue(e,this,this.ecModel))},this);this._data=je(a,function(e){return!!e})},t.prototype.getData=function(){return this._data},t.prototype.select=function(e){var t=this.option.selected;if(this.get(`selectedMode`)===`single`){var n=this._data;k(n,function(e){t[e.get(`name`)]=!1})}t[e]=!0},t.prototype.unSelect=function(e){this.get(`selectedMode`)!==`single`&&(this.option.selected[e]=!1)},t.prototype.toggleSelected=function(e){var t=this.option.selected;t.hasOwnProperty(e)||(t[e]=!0),this[t[e]?`unSelect`:`select`](e)},t.prototype.allSelect=function(){var e=this._data,t=this.option.selected;k(e,function(e){t[e.get(`name`,!0)]=!0})},t.prototype.inverseSelect=function(){var e=this._data,t=this.option.selected;k(e,function(e){var n=e.get(`name`,!0);t.hasOwnProperty(n)||(t[n]=!0),t[n]=!t[n]})},t.prototype.isSelected=function(e){var t=this.option.selected;return!(t.hasOwnProperty(e)&&!t[e])&&De(this._availableNames,e)>=0},t.prototype.getOrient=function(){return this.get(`orient`)===`vertical`?{index:1,name:`vertical`}:{index:0,name:`horizontal`}},t.type=`legend.plain`,t.dependencies=[`series`],t.defaultOption={z:4,show:!0,orient:`horizontal`,left:`center`,bottom:A.size.m,align:`auto`,backgroundColor:A.color.transparent,borderColor:A.color.border,borderRadius:0,borderWidth:0,padding:5,itemGap:8,itemWidth:25,itemHeight:14,symbolRotate:`inherit`,symbolKeepAspect:!0,inactiveColor:A.color.disabled,inactiveBorderColor:A.color.disabled,inactiveBorderWidth:`auto`,itemStyle:{color:`inherit`,opacity:`inherit`,borderColor:`inherit`,borderWidth:`auto`,borderCap:`inherit`,borderJoin:`inherit`,borderDashOffset:`inherit`,borderMiterLimit:`inherit`},lineStyle:{width:`auto`,color:`inherit`,inactiveColor:A.color.disabled,inactiveWidth:2,opacity:`inherit`,type:`inherit`,cap:`inherit`,join:`inherit`,dashOffset:`inherit`,miterLimit:`inherit`},textStyle:{color:A.color.secondary},selectedMode:!0,selector:!1,selectorLabel:{show:!0,borderRadius:10,padding:[3,5,3,5],fontSize:12,fontFamily:`sans-serif`,color:A.color.tertiary,borderWidth:1,borderColor:A.color.border},emphasis:{selectorLabel:{show:!0,color:A.color.quaternary}},selectorPosition:`auto`,selectorItemGap:7,selectorButtonGap:10,tooltip:{show:!1},triggerEvent:!1},t}(se),G=N,K=k,q=j,ze=function(e){P(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n.newlineDisabled=!1,n}return t.prototype.init=function(){this.group.add(this._contentGroup=new q),this.group.add(this._selectorGroup=new q),this._isFirstRender=!0},t.prototype.getContentGroup=function(){return this._contentGroup},t.prototype.getSelectorGroup=function(){return this._selectorGroup},t.prototype.render=function(e,t,n){var r=this._isFirstRender;if(this._isFirstRender=!1,this.resetInner(),e.get(`show`,!0)){var i=e.get(`align`),a=e.get(`orient`);i&&i!==`auto`||(i=e.get(`left`)===`right`&&a===`vertical`?`right`:`left`);var o=e.get(`selector`,!0),s=e.get(`selectorPosition`,!0);o&&(!s||s===`auto`)&&(s=a===`horizontal`?`end`:`start`),this.renderInner(i,e,t,n,o,a,s);var c=ee(e,n).refContainer,l=e.getBoxLayoutParams(),u=e.get(`padding`),d=ie(l,c,u),f=this.layoutInner(e,i,d,r,o,s),p=ie(le({width:f.width,height:f.height},l),c,u);this.group.x=p.x-f.x,this.group.y=p.y-f.y,this.group.markRedraw(),this.group.add(this._backgroundEl=Ee(f,e))}},t.prototype.resetInner=function(){this.getContentGroup().removeAll(),this._backgroundEl&&this.group.remove(this._backgroundEl),this.getSelectorGroup().removeAll()},t.prototype.renderInner=function(e,t,n,r,i,a,o){var s=this.getContentGroup(),c=M(),l=t.get(`selectedMode`),u=t.get(`triggerEvent`),d=[];n.eachRawSeries(function(e){!e.get(`legendHoverLink`)&&d.push(e.id)}),K(t.getData(),function(i,a){var o=this,f=i.get(`name`);if(!this.newlineDisabled&&(f===``||f===`
2
2
  `)){var p=new q;p.newline=!0,s.add(p)}else{var m=n.getSeriesByName(f)[0];if(!c.get(f)){if(m){var h=m.getData(),g=h.getVisual(`legendLineStyle`)||{},_=h.getVisual(`legendIcon`),v=h.getVisual(`style`),y=this._createItem(m,f,a,i,t,e,g,v,_,l,r);y.on(`click`,G(He,f,null,r,d)).on(`mouseover`,G(J,m.name,null,r,d)).on(`mouseout`,G(Y,m.name,null,r,d)),n.ssr&&y.eachChild(function(e){var t=V(e);t.seriesIndex=m.seriesIndex,t.dataIndex=a,t.ssrType=`legend`}),u&&y.eachChild(function(e){o.packEventData(e,t,m,a,f)}),c.set(f,!0)}else n.eachRawSeries(function(o){var s=this;if(!c.get(f)&&o.legendVisualProvider){var p=o.legendVisualProvider;if(!p.containName(f))return;var m=p.indexOfName(f),h=p.getItemVisual(m,`style`),g=p.getItemVisual(m,`legendIcon`),_=oe(h.fill);_&&_[3]===0&&(_[3]=.2,h=F(F({},h),{fill:ce(_,`rgba`)}));var v=this._createItem(o,f,a,i,t,e,{},h,g,l,r);v.on(`click`,G(He,null,f,r,d)).on(`mouseover`,G(J,null,f,r,d)).on(`mouseout`,G(Y,null,f,r,d)),n.ssr&&v.eachChild(function(e){var t=V(e);t.seriesIndex=o.seriesIndex,t.dataIndex=a,t.ssrType=`legend`}),u&&v.eachChild(function(e){s.packEventData(e,t,o,a,f)}),c.set(f,!0)}},this)}}},this),i&&this._createSelector(i,t,r,a,o)},t.prototype.packEventData=function(e,t,n,r,i){var a={componentType:`legend`,componentIndex:t.componentIndex,dataIndex:r,value:i,seriesIndex:n.seriesIndex};V(e).eventData=a},t.prototype._createSelector=function(e,t,n,r,i){var a=this.getSelectorGroup();K(e,function(e){var r=e.type,i=new U({style:{x:0,y:0,align:`center`,verticalAlign:`middle`},onclick:function(){n.dispatchAction({type:r===`all`?`legendAllSelect`:`legendInverseSelect`,legendId:t.id})}});a.add(i);var o=t.getModel(`selectorLabel`),s=t.getModel([`emphasis`,`selectorLabel`]);de(i,{normal:o,emphasis:s},{defaultText:e.title}),O(i)})},t.prototype._createItem=function(e,t,n,r,i,a,o,s,c,l,u){var d=e.visualDrawType,f=i.get(`itemWidth`),p=i.get(`itemHeight`),m=i.isSelected(t),h=r.get(`symbolRotate`),g=r.get(`symbolKeepAspect`),_=r.get(`icon`);c=_||c||`roundRect`;var v=Be(c,r,o,s,d,m,u),y=new q,b=r.getModel(`textStyle`);if(H(e.getLegendIcon)&&(!_||_===`inherit`))y.add(e.getLegendIcon({itemWidth:f,itemHeight:p,icon:c,iconRotate:h,itemStyle:v.itemStyle,lineStyle:v.lineStyle,symbolKeepAspect:g}));else{var x=_===`inherit`&&e.getData().getVisual(`symbol`)?h===`inherit`?e.getData().getVisual(`symbolRotate`):h:0;y.add(Ve({itemWidth:f,itemHeight:p,icon:c,iconRotate:x,itemStyle:v.itemStyle,lineStyle:v.lineStyle,symbolKeepAspect:g}))}var S=a===`left`?f+5:-5,C=a,w=i.get(`formatter`),T=t;B(w)&&w?T=w.replace(`{name}`,t??``):H(w)&&(T=w(t));var E=m?b.getTextColor():r.get(`inactiveColor`);y.add(new U({style:Fe(b,{text:T,x:S,y:p/2,fill:E,align:C,verticalAlign:`middle`},{inheritColor:E})}));var D=new L({shape:y.getBoundingRect(),style:{fill:`transparent`}}),k=r.getModel(`tooltip`);return k.get(`show`)&&Te({el:D,componentModel:i,itemName:t,itemTooltipOption:k.option}),y.add(D),y.eachChild(function(e){e.silent=!0}),D.silent=!l,this.getContentGroup().add(y),O(y),y.__legendDataIndex=n,y},t.prototype.layoutInner=function(e,t,n,r,i,a){var o=this.getContentGroup(),s=this.getSelectorGroup();R(e.get(`orient`),o,e.get(`itemGap`),n.width,n.height);var c=o.getBoundingRect(),l=[-c.x,-c.y];if(s.markRedraw(),o.markRedraw(),i){R(`horizontal`,s,e.get(`selectorItemGap`,!0));var u=s.getBoundingRect(),d=[-u.x,-u.y],f=e.get(`selectorButtonGap`,!0),p=e.getOrient().index,m=p===0?`width`:`height`,h=p===0?`height`:`width`,g=p===0?`y`:`x`;a===`end`?d[p]+=c[m]+f:l[p]+=u[m]+f,d[1-p]+=c[h]/2-u[h]/2,s.x=d[0],s.y=d[1],o.x=l[0],o.y=l[1];var _={x:0,y:0};return _[m]=c[m]+f+u[m],_[h]=Math.max(c[h],u[h]),_[g]=Math.min(0,u[g]+d[1-p]),_}return o.x=l[0],o.y=l[1],this.group.getBoundingRect()},t.prototype.remove=function(){this.getContentGroup().removeAll(),this._isFirstRender=!0},t.type=`legend.plain`,t}(te);function Be(e,t,n,r,i,a,o){function s(e,t){e.lineWidth===`auto`&&(e.lineWidth=t.lineWidth>0?2:0),K(e,function(n,r){e[r]===`inherit`&&(e[r]=t[r])})}var c=t.getModel(`itemStyle`),l=c.getItemStyle(),u=e.lastIndexOf(`empty`,0)===0?`fill`:`stroke`,d=c.getShallow(`decal`);l.decal=!d||d===`inherit`?r.decal:Ne(d,o),l.fill===`inherit`&&(l.fill=r[i]),l.stroke===`inherit`&&(l.stroke=r[u]),l.opacity===`inherit`&&(l.opacity=(i===`fill`?r:n).opacity),s(l,r);var f=t.getModel(`lineStyle`),p=f.getLineStyle();if(s(p,n),l.fill===`auto`&&(l.fill=r.fill),l.stroke===`auto`&&(l.stroke=r.fill),p.stroke===`auto`&&(p.stroke=r.fill),!a){var m=t.get(`inactiveBorderWidth`),h=l[u];l.lineWidth=m===`auto`?r.lineWidth>0&&h?2:0:l.lineWidth,l.fill=t.get(`inactiveColor`),l.stroke=t.get(`inactiveBorderColor`),p.stroke=f.get(`inactiveColor`),p.lineWidth=f.get(`inactiveWidth`)}return{itemStyle:l,lineStyle:p}}function Ve(e){var t=e.icon||`roundRect`,n=Pe(t,0,0,e.itemWidth,e.itemHeight,e.itemStyle.fill,e.symbolKeepAspect);return n.setStyle(e.itemStyle),n.rotation=(e.iconRotate||0)*Math.PI/180,n.setOrigin([e.itemWidth/2,e.itemHeight/2]),t.indexOf(`empty`)>-1&&(n.style.stroke=n.style.fill,n.style.fill=A.color.neutral00,n.style.lineWidth=2),n}function He(e,t,n,r){Y(e,t,n,r),n.dispatchAction({type:`legendToggleSelect`,name:e??t}),J(e,t,n,r)}function J(e,t,n,r){n.usingTHL()||n.dispatchAction({type:`highlight`,seriesName:e,name:t,excludeSeriesId:r})}function Y(e,t,n,r){n.usingTHL()||n.dispatchAction({type:`downplay`,seriesName:e,name:t,excludeSeriesId:r})}function X(e,t,n){var r=e===`allSelect`||e===`inverseSelect`,i={},a=[];n.eachComponent({mainType:`legend`,query:t},function(n){r?n[e]():n[e](t.name),Ue(n,i),a.push(n.componentIndex)});var o={};return n.eachComponent(`legend`,function(e){k(i,function(t,n){e[t?`select`:`unSelect`](n)}),Ue(e,o)}),r?{selected:o,legendIndex:a}:{name:t.name,selected:o}}function Ue(e,t){var n=t||{};return k(e.getData(),function(t){var r=t.get(`name`);if(r!==`
3
3
  `&&r!==``){var i=e.isSelected(r);n[r]=Ce(n,r)?n[r]&&i:i}}),n}function We(e){e.registerAction(`legendToggleSelect`,`legendselectchanged`,N(X,`toggleSelected`)),e.registerAction(`legendAllSelect`,`legendselectall`,N(X,`allSelect`)),e.registerAction(`legendInverseSelect`,`legendinverseselect`,N(X,`inverseSelect`)),e.registerAction(`legendSelect`,`legendselected`,N(X,`select`)),e.registerAction(`legendUnSelect`,`legendunselected`,N(X,`unSelect`))}var Ge=he(Ke);function Ke(e){var t=e.findComponents({mainType:`legend`});t&&t.length&&e.filterSeries(function(e){for(var n=0;n<t.length;n++)if(!t[n].isSelected(e.name))return!1;return!0})}function qe(e){e.registerComponentModel(W),e.registerComponentView(ze),e.registerProcessor(e.PRIORITY.PROCESSOR.SERIES_FILTER,Ge),e.registerSubTypeDefaulter(`legend`,function(){return`plain`}),We(e)}var Je=function(e){P(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n}return t.prototype.setScrollDataIndex=function(e){this.option.scrollDataIndex=e},t.prototype.init=function(t,n,r){var i=be(t);e.prototype.init.call(this,t,n,r),Ye(this,t,i)},t.prototype.mergeOption=function(t,n){e.prototype.mergeOption.call(this,t,n),Ye(this,this.option,t)},t.type=`legend.scroll`,t.defaultOption=re(W.defaultOption,{scrollDataIndex:0,pageButtonItemGap:5,pageButtonGap:null,pageButtonPosition:`end`,pageFormatter:`{current}/{total}`,pageIcons:{horizontal:[`M0,0L12,-10L12,10z`,`M0,0L-12,-10L-12,10z`],vertical:[`M0,0L20,0L10,-20z`,`M0,0L20,0L10,20z`]},pageIconColor:A.color.accent50,pageIconInactiveColor:A.color.accent10,pageIconSize:15,pageTextStyle:{color:A.color.tertiary},animationDurationUpdate:800}),t}(W);function Ye(e,t,n){var r=e.getOrient(),i=[1,1];i[r.index]=0,ae(t,n,{type:`box`,ignoreSize:!!i})}var Xe=j,Z=[`width`,`height`],Q=[`x`,`y`],Ze=function(e){P(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n.newlineDisabled=!0,n._currentIndex=0,n}return t.prototype.init=function(){e.prototype.init.call(this),this.group.add(this._containerGroup=new Xe),this._containerGroup.add(this.getContentGroup()),this.group.add(this._controllerGroup=new Xe)},t.prototype.resetInner=function(){e.prototype.resetInner.call(this),this._controllerGroup.removeAll(),this._containerGroup.removeClipPath(),this._containerGroup.__rectSize=null},t.prototype.renderInner=function(t,n,r,i,a,o,s){var c=this;e.prototype.renderInner.call(this,t,n,r,i,a,o,s);var l=this._controllerGroup,u=n.get(`pageIconSize`,!0),d=I(u)?u:[u,u];p(`pagePrev`,0);var f=n.getModel(`pageTextStyle`);l.add(new U({name:`pageText`,style:{text:`xx/xx`,fill:f.getTextColor(),font:f.getFont(),verticalAlign:`middle`,align:`center`},silent:!0})),p(`pageNext`,1);function p(e,t){var r=e+`DataIndex`,a=fe(n.get(`pageIcons`,!0)[n.getOrient().name][t],{onclick:ne(c._pageGo,c,r,n,i)},{x:-d[0]/2,y:-d[1]/2,width:d[0],height:d[1]});a.name=e,l.add(a)}},t.prototype.layoutInner=function(e,t,n,r,i,a){var o=this.getSelectorGroup(),s=e.getOrient().index,c=Z[s],l=Q[s],u=Z[1-s],d=Q[1-s];i&&R(`horizontal`,o,e.get(`selectorItemGap`,!0));var f=e.get(`selectorButtonGap`,!0),p=o.getBoundingRect(),m=[-p.x,-p.y],h=me(n);i&&(h[c]=n[c]-p[c]-f);var g=this._layoutContentAndController(e,r,h,s,c,u,d,l);if(i){if(a===`end`)m[s]+=g[c]+f;else{var _=p[c]+f;m[s]-=_,g[l]-=_}g[c]+=p[c]+f,m[1-s]+=g[d]+g[u]/2-p[u]/2,g[u]=Math.max(g[u],p[u]),g[d]=Math.min(g[d],p[d]+m[1-s]),o.x=m[0],o.y=m[1],o.markRedraw()}return g},t.prototype._layoutContentAndController=function(e,t,n,r,i,a,o,s){var c=this.getContentGroup(),l=this._containerGroup,u=this._controllerGroup;R(e.get(`orient`),c,e.get(`itemGap`),r?n.width:null,r?null:n.height),R(`horizontal`,u,e.get(`pageButtonItemGap`,!0));var d=c.getBoundingRect(),f=u.getBoundingRect(),p=this._showController=d[i]>n[i],m=[-d.x,-d.y];t||(m[r]=c[s]);var h=[0,0],g=[-f.x,-f.y],_=xe(e.get(`pageButtonGap`,!0),e.get(`itemGap`,!0));p&&(e.get(`pageButtonPosition`,!0)===`end`?g[r]+=n[i]-f[i]:h[r]+=f[i]+_),g[1-r]+=d[a]/2-f[a]/2,c.setPosition(m),l.setPosition(h),u.setPosition(g);var v={x:0,y:0};if(v[i]=p?n[i]:d[i],v[a]=Math.max(d[a],f[a]),v[o]=Math.min(0,f[o]+g[1-r]),l.__rectSize=n[i],p){var y={x:0,y:0};y[i]=Math.max(n[i]-f[i]-_,0),y[a]=v[a],l.setClipPath(new L({shape:y})),l.__rectSize=y[i]}else u.eachChild(function(e){e.attr({invisible:!0,silent:!0})});var b=this._getPageInfo(e);return b.pageIndex!=null&&pe(c,{x:b.contentPosition[0],y:b.contentPosition[1]},p?e:null),this._updatePageInfoView(e,b),v},t.prototype._pageGo=function(e,t,n){var r=this._getPageInfo(t)[e];r!=null&&n.dispatchAction({type:`legendScroll`,scrollDataIndex:r,legendId:t.id})},t.prototype._updatePageInfoView=function(e,t){var n=this._controllerGroup;k([`pagePrev`,`pageNext`],function(r){var i=t[r+`DataIndex`]!=null,a=n.childOfName(r);a&&(a.setStyle(`fill`,i?e.get(`pageIconColor`,!0):e.get(`pageIconInactiveColor`,!0)),a.cursor=i?`pointer`:`default`)});var r=n.childOfName(`pageText`),i=e.get(`pageFormatter`),a=t.pageIndex,o=a==null?0:a+1,s=t.pageCount;r&&i&&r.setStyle(`text`,B(i)?i.replace(`{current}`,o==null?``:o+``).replace(`{total}`,s==null?``:s+``):i({current:o,total:s}))},t.prototype._getPageInfo=function(e){var t=e.get(`scrollDataIndex`,!0),n=this.getContentGroup(),r=this._containerGroup.__rectSize,i=e.getOrient().index,a=Z[i],o=Q[i],s=this._findTargetItemIndex(t),c=n.children(),l=c[s],u=c.length,d=+!!u,f={contentPosition:[n.x,n.y],pageCount:d,pageIndex:d-1,pagePrevDataIndex:null,pageNextDataIndex:null};if(!l)return f;var p=v(l);f.contentPosition[i]=-p.s;for(var m=s+1,h=p,g=p,_=null;m<=u;++m)_=v(c[m]),(!_&&g.e>h.s+r||_&&!y(_,h.s))&&(h=g.i>h.i?g:_,h&&(f.pageNextDataIndex??=h.i,++f.pageCount)),g=_;for(var m=s-1,h=p,g=p,_=null;m>=-1;--m)_=v(c[m]),(!_||!y(g,_.s))&&h.i<g.i&&(g=h,f.pagePrevDataIndex??=h.i,++f.pageCount,++f.pageIndex),h=_;return f;function v(e){if(e){var t=e.getBoundingRect(),n=t[o]+e[o];return{s:n,e:n+t[a],i:e.__legendDataIndex}}}function y(e,t){return e.e>=t&&e.s<=t+r}},t.prototype._findTargetItemIndex=function(e){if(!this._showController)return 0;var t,n=this.getContentGroup(),r;return n.eachChild(function(n,i){var a=n.__legendDataIndex;r==null&&a!=null&&(r=i),a===e&&(t=i)}),t??r},t.type=`legend.scroll`,t}(ze);function Qe(e){e.registerAction(`legendScroll`,`legendscroll`,function(e,t){var n=e.scrollDataIndex;n!=null&&t.eachComponent({mainType:`legend`,subType:`scroll`,query:e},function(e){e.setScrollDataIndex(n)})})}function $e(e){z(qe),e.registerComponentModel(Je),e.registerComponentView(Ze),Qe(e)}function et(e){z(qe),z($e)}var tt=t(u(d,{children:[a(`g`,{transform:`translate(-1.4 -1) scale(0.8)`,children:a(`path`,{d:`M20.5 11H19V7c0-1.1-.9-2-2-2h-4V3.5C13 2.12 11.88 1 10.5 1S8 2.12 8 3.5V5H4c-1.1 0-1.99.9-1.99 2v3.8H3.5c1.49 0 2.7 1.21 2.7 2.7s-1.21 2.7-2.7 2.7H2V20c0 1.1.9 2 2 2h3.8v-1.5c0-1.49 1.21-2.7 2.7-2.7s2.7 1.21 2.7 2.7V22H17c1.1 0 2-.9 2-2v-4h1.5c1.38 0 2.5-1.12 2.5-2.5S21.88 11 20.5 11`})}),a(`circle`,{cx:`19.2`,cy:`19.2`,r:`4.4`})]}),`Instance`);r(),z([we,ye,et,Se,Ae]);var nt=36e5,rt=3e4,it=class extends y{constructor(e){super(e),l(this,`refreshTimer`,null),this.state={historyInstance:``,blocker:null,loading:!0,enabling:!1,cpu:[],mem:[],error:``}}componentDidMount(){this.props.paused||(this.detectAndLoad(),this.startTimer())}componentDidUpdate(e){e.currentHost!==this.props.currentHost&&this.setState({loading:!0,cpu:[],mem:[]},()=>void this.detectAndLoad()),e.paused!==this.props.paused&&(this.props.paused?this.stopTimer():(this.detectAndLoad(),this.startTimer()))}componentWillUnmount(){this.stopTimer()}startTimer(){this.stopTimer(),this.refreshTimer=setInterval(()=>{this.state.blocker?this.detectAndLoad():this.readData()},rt)}stopTimer(){this.refreshTimer&&=(clearInterval(this.refreshTimer),null)}getIds(){return{cpu:`${this.props.currentHost}.cpu`,mem:`${this.props.currentHost}.mem`}}async detectAndLoad(){try{var e,t,n,r,i,a,o;let d=await this.props.socket.getCompactSystemConfig(),f=(d==null||(e=d.common)==null?void 0:e.defaultHistory)||``;if(!f){var s,c;this.setState({historyInstance:``,blocker:`noDefaultHistory`,loading:!1}),(s=(c=this.props).onAvailabilityChange)==null||s.call(c,!1);return}let p=await this.props.socket.getState(`system.adapter.${f}.alive`);if(!(p!=null&&p.val)){var l,u;this.setState({historyInstance:f,blocker:`historyNotAlive`,loading:!1}),(l=(u=this.props).onAvailabilityChange)==null||l.call(u,!1);return}(t=(n=this.props).onAvailabilityChange)==null||t.call(n,!0);let m=this.getIds(),[h,g]=await Promise.all([this.props.socket.getObject(m.cpu),this.props.socket.getObject(m.mem)]),_=!!(h!=null&&(r=h.common)!=null&&(r=r.custom)!=null&&(r=r[f])!=null&&r.enabled)&&!!(g!=null&&(i=g.common)!=null&&(i=i.custom)!=null&&(i=i[f])!=null&&i.enabled);if((a=(o=this.props).onRecordingChange)==null||a.call(o,_),!_){this.setState({historyInstance:f,blocker:`notRecorded`,loading:!1});return}this.setState({historyInstance:f,blocker:null},()=>void this.readData())}catch(e){this.setState({error:e.toString(),loading:!1})}}async enableRecording(){return this.setRecording(!0)}async stopRecording(){return this.setRecording(!1)}async setRecording(e){this.setState({enabling:!0});try{let t=this.getIds();for(let n of[t.cpu,t.mem]){let t=await this.props.socket.getObject(n);t&&(t.common.custom||={},t.common.custom[this.state.historyInstance]={...t.common.custom[this.state.historyInstance]||{},enabled:e},await this.props.socket.setObject(n,t))}this.setState({enabling:!1,loading:!0},()=>void this.detectAndLoad())}catch(e){this.setState({enabling:!1,error:e.toString()})}}async readData(){let e=this.getIds(),t=Date.now(),n=t-nt,r={instance:this.state.historyInstance,start:n,end:t,step:6e4,aggregate:`average`,from:!1,ack:!1,q:!1,addId:!1};try{let[t,n]=await Promise.all([this.props.socket.getHistory(e.cpu,r),this.props.socket.getHistory(e.mem,r)]),i=e=>(e||[]).filter(e=>e.val!==null&&e.val!==void 0).map(e=>[e.ts,Math.round(Number(e.val)*100)/100]);this.setState({cpu:i(t),mem:i(n),loading:!1})}catch(e){this.setState({error:e.toString(),loading:!1})}}renderBlocker(){let{t}=this.props;return u(h,{sx:{display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:2,height:260,color:`text.secondary`,textAlign:`center`,px:2},children:[a(Le,{sx:{fontSize:40,opacity:.4}}),a(g,{variant:`body2`,children:t(`CPU and RAM of this host are not recorded by %s yet`,this.state.historyInstance)}),this.state.blocker===`notRecorded`?a(x,{variant:`contained`,disabled:this.state.enabling,startIcon:this.state.enabling?a(e,{size:16}):null,onClick:()=>void this.enableRecording(),children:t(`Record CPU and RAM`)}):null]})}renderChart(){let{theme:e,themeType:t,t:n}=this.props,r=t===`dark`?`#96A2B4`:`#5C6675`,i={backgroundColor:`transparent`,grid:{left:45,right:45,top:40,bottom:30},tooltip:{trigger:`axis`},legend:{data:[n(`CPU (%)`),n(`Memory (%)`)],textStyle:{color:r},top:0},xAxis:{type:`time`,axisLabel:{color:r},axisLine:{lineStyle:{color:r}},splitLine:{show:!1}},yAxis:[{type:`value`,name:`%`,min:0,max:100,nameTextStyle:{color:r},axisLabel:{color:r},splitLine:{lineStyle:{color:e.palette.divider}}}],series:[{name:n(`CPU (%)`),type:`line`,showSymbol:!1,smooth:!0,lineStyle:{width:2,color:e.palette.primary.main},itemStyle:{color:e.palette.primary.main},data:this.state.cpu},{name:n(`Memory (%)`),type:`line`,showSymbol:!1,smooth:!0,lineStyle:{width:2,color:e.palette.secondary.main},itemStyle:{color:e.palette.secondary.main},data:this.state.mem}]};return a(ve,{echarts:Oe,option:i,style:{height:260,width:`100%`},opts:{renderer:`svg`},notMerge:!0})}render(){return this.state.blocker===`noDefaultHistory`||this.state.blocker===`historyNotAlive`?null:this.state.error?a(h,{sx:{height:260,display:`flex`,alignItems:`center`,justifyContent:`center`},children:a(g,{variant:`body2`,color:`error`,children:this.state.error})}):this.state.loading?a(h,{sx:{height:260,display:`flex`,alignItems:`center`,justifyContent:`center`},children:a(e,{})}):this.state.blocker?this.renderBlocker():!this.state.cpu.length&&!this.state.mem.length?u(h,{sx:{display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:2,height:260,color:`text.secondary`,textAlign:`center`,px:2},children:[a(Le,{sx:{fontSize:40,opacity:.4}}),a(g,{variant:`body2`,children:this.props.t(`Recording is active, but there is no data for the last hour yet`)})]}):this.renderChart()}};r();var at=3e4,ot=5e3,st=6,ct=16,lt=`App.overviewChartMinimized`,ut=5,$=`--`,dt=class e extends y{constructor(e){super(e),l(this,`refreshTimer`,null),l(this,`chartRef`,v.createRef()),l(this,`objectsTimer`,null),l(this,`mounted`,!1),l(this,`subscribedHost`,``),l(this,`onCpu`,(e,t)=>{this.mounted&&this.setState({cpu:(t==null?void 0:t.val)===null||(t==null?void 0:t.val)===void 0?null:Number(t.val)})}),l(this,`onMem`,(e,t)=>{this.mounted&&this.setState({mem:(t==null?void 0:t.val)===null||(t==null?void 0:t.val)===void 0?null:Number(t.val)})}),l(this,`onLogs`,e=>{this.mounted&&this.setState(t=>({logs:[...t.logs,...e].slice(-16)}))}),l(this,`onChartButton`,()=>{if(!this.state.chartMinimized&&this.state.chartRecording){var e;(e=this.chartRef.current)==null||e.stopRecording();return}let t=!this.state.chartMinimized;(window._localStorage||window.localStorage).setItem(lt,t?`true`:`false`),this.setState({chartMinimized:t})}),this.state={loaded:!1,objectsLoaded:!1,hostAlive:!1,adaptersTotal:0,adaptersActive:0,instancesTotal:0,instancesAlive:0,objectsCount:0,statesCount:0,hostInfo:null,adapters:[],logs:[],cpu:null,mem:null,chartAvailable:!0,chartRecording:!0,chartMinimized:(window._localStorage||window.localStorage).getItem(lt)===`true`}}componentDidMount(){this.mounted=!0,this.readAll(),this.objectsTimer=setTimeout(()=>{this.objectsTimer=null,this.readObjects()},ot),this.subscribeHost(),this.refreshTimer=setInterval(()=>void this.readAll(),at),this.props.logsWorker.registerHandler(this.onLogs)}async readObjects(){let e,t=0;try{let n=await this.props.socket.getObjectsCount();e=n.total,t=n.byType.state||0}catch(r){console.warn(`Cannot count the objects on the server, reading them all: ${r.message}`);let i=await this.props.objectsWorker.getObjects()||{};e=Object.keys(i).length;for(let e of Object.keys(i)){var n;((n=i[e])==null?void 0:n.type)===`state`&&t++}}this.mounted&&this.setState({objectsCount:e,statesCount:t,objectsLoaded:!0})}componentDidUpdate(e){e.currentHost!==this.props.currentHost&&(this.setState({loaded:!1,cpu:null,mem:null,hostInfo:null}),this.subscribeHost(),this.readAll())}componentWillUnmount(){this.mounted=!1,this.refreshTimer&&=(clearInterval(this.refreshTimer),null),this.objectsTimer&&=(clearTimeout(this.objectsTimer),null),this.unsubscribeHost(),this.props.logsWorker.unregisterHandler(this.onLogs)}subscribeHost(){this.unsubscribeHost(),this.subscribedHost=this.props.currentHost,this.subscribedHost&&(this.props.socket.subscribeState(`${this.subscribedHost}.cpu`,this.onCpu),this.props.socket.subscribeState(`${this.subscribedHost}.mem`,this.onMem))}unsubscribeHost(){this.subscribedHost&&=(this.props.socket.unsubscribeState(`${this.subscribedHost}.cpu`,this.onCpu),this.props.socket.unsubscribeState(`${this.subscribedHost}.mem`,this.onMem),``)}async readAll(){let{socket:e,currentHost:t}=this.props,[n,r,i,a]=await Promise.all([this.props.instancesWorker.getObjects(),e.getForeignStates(`system.adapter.*.alive`).catch(()=>({})),e.getState(`${t}.alive`).catch(()=>null),this.props.logsWorker.getLogs().catch(()=>({logs:[],logSize:0}))]);if(!this.mounted)return;let o=Object.values(n||{}).filter(e=>{var t;return(e==null||(t=e.common)==null?void 0:t.host)===this.hostName()}),s=new Set,c=new Set,l=[],u=0;for(let e of o){var d;let t=e._id.replace(`system.adapter.`,``).split(`.`)[0];if(s.add(t),(d=r[`${e._id}.alive`])!=null&&d.val){u++,c.add(t);let n=l.find(e=>e.name===t);if(n)n.instances++;else{var f,p;l.push({name:t,version:((f=e.common)==null?void 0:f.version)||``,instances:1,icon:(p=e.common)!=null&&p.icon?`adapter/${t}/${e.common.icon}`:``})}}}l.sort((e,t)=>e.name.localeCompare(t.name));let m=this.state.hostInfo;try{m=await this.props.socket.getHostInfo(t)}catch{}this.mounted&&this.setState({loaded:!0,hostAlive:!!(i!=null&&i.val),adaptersTotal:s.size,adaptersActive:c.size,instancesTotal:o.length,instancesAlive:u,hostInfo:m,adapters:l,logs:(a.logs||[]).slice(-16)})}static logText(e){return typeof e.message==`string`?e.message:e.message.original}hostName(){return this.props.currentHostName||this.props.currentHost.replace(`system.host.`,``)}static renderGaugeRow(e,t,n){return u(h,{sx:{display:`flex`,alignItems:`center`,gap:2,py:1},children:[a(g,{variant:`body2`,color:`text.secondary`,sx:{width:80},children:e}),a(f,{variant:`determinate`,value:Math.max(0,Math.min(100,t??0)),sx:{flex:1,maxWidth:160}}),a(g,{variant:`body2`,sx:{flex:1,textAlign:`right`},children:n})]},e)}renderSystemInfo(){let{t}=this.props,n=this.state.hostInfo,r=n!=null&&n.RAM?Number(n.RAM)/1024/1024/1024:0,s=this.state.mem!==null&&r?r*this.state.mem/100:null;return u(b,{sx:{flex:`1 1 340px`,p:2.5},children:[a(i,{title:t(`System information`)}),n?u(d,{children:[a(o,{name:t(`Platform`),value:String(n.Platform??`-`)}),a(o,{name:t(`Architecture`),value:String(n.Architecture??`-`)}),a(o,{name:`Node.js`,value:String(n[`Node.js`]??`-`)}),a(o,{name:`NPM`,value:String(n.NPM??`-`)}),a(o,{name:t(`System uptime`),value:S.formatSeconds(Number(n[`System uptime`]??0),t)}),e.renderGaugeRow(t(`RAM`),this.state.mem,s===null?`-`:`${s.toFixed(1)} GB / ${r==null?void 0:r.toFixed(1)} GB (${Math.round(this.state.mem??0)}%)`),e.renderGaugeRow(`CPU`,this.state.cpu,this.state.cpu===null?`-`:`${Math.round(this.state.cpu)}%`)]}):a(f,{})]})}renderAdapters(){let{t:e,theme:t}=this.props;return u(b,{sx:{flex:`1 1 340px`,p:2.5},children:[a(i,{title:e(`Running adapters`),action:{text:e(`Show all`),onClick:()=>this.props.handleNavigation(`tab-instances`)}}),this.state.adapters.length?this.state.adapters.slice(0,ut).map(r=>u(h,{sx:{display:`flex`,alignItems:`center`,gap:1.5,py:1,borderTop:`1px solid`,borderColor:`divider`},children:[a(h,{sx:{width:26,height:26,borderRadius:`50%`,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`,backgroundColor:p(t.palette.success.main,.2),border:`1px solid ${p(t.palette.success.main,.5)}`},children:r.icon?a(m,{src:r.icon,alt:r.name,style:{width:18,height:18,borderRadius:`50%`}}):null}),a(g,{variant:`body2`,sx:{flex:1},children:r.name}),u(g,{variant:`caption`,color:`text.secondary`,children:[`v`,r.version]}),a(n,{size:`small`,color:`success`,variant:`outlined`,label:r.instances>1?e(`%s instances`,r.instances):e(`active`)})]},r.name)):a(g,{variant:`body2`,color:`text.secondary`,children:e(`No running adapters`)})]})}renderChartButton(){let{t:e}=this.props,t,n;return this.state.chartMinimized?(t=a(E,{}),n=e(`Maximize`)):this.state.chartRecording?(t=a(Ie,{}),n=e(`Stop recording`)):(t=a(T,{}),n=e(`Minimize`)),a(_,{title:n,children:a(s,{size:`small`,onClick:this.onChartButton,"aria-label":n,children:t})})}renderLog(){let{t,theme:n}=this.props,r={error:n.palette.error.main,warn:n.palette.warning.main};return u(b,{sx:{flex:`2 1 460px`,p:2.5,minWidth:0},children:[a(i,{title:t(`System log`),action:{text:t(`Show all`),onClick:()=>this.props.handleNavigation(`tab-logs`)}}),this.state.logs.length?this.state.logs.slice(-(this.state.chartMinimized?ct:st)).map((t,i)=>u(h,{sx:{display:`flex`,alignItems:`center`,gap:1.5,py:1,borderTop:`1px solid`,borderColor:`divider`,minWidth:0},children:[a(h,{sx:{width:8,height:8,borderRadius:`50%`,flexShrink:0,backgroundColor:r[t.severity]||n.palette.success.main}}),a(g,{variant:`caption`,color:`text.secondary`,sx:{whiteSpace:`nowrap`},children:new Date(t.ts).toLocaleTimeString()}),a(g,{variant:`caption`,sx:{color:r[t.severity]||`text.secondary`,width:34,flexShrink:0},children:t.severity}),a(g,{variant:`caption`,sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.logText(t)})]},`${t.key??t.ts}_${i}`)):a(g,{variant:`body2`,color:`text.secondary`,children:t(`No messages`)})]})}render(){let{t:e,theme:t}=this.props,r=this.state.hostAlive,o=this.state.loaded,s=S.countAdapterUpdates(this.props.installed,this.props.repository);return u(h,{sx:{height:`100%`,overflow:`auto`,p:3,pt:0},children:[u(h,{sx:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,mb:2,gap:2},children:[this.props.menuButtonSpace?a(h,{sx:{width:40,flexShrink:0}}):null,u(h,{children:[a(g,{sx:{fontSize:`1.5rem`,fontWeight:700},children:e(`Overview`)}),a(g,{variant:`body2`,color:`text.secondary`,children:e(`System overview and status`)})]}),u(h,{sx:{display:`flex`,alignItems:`center`,gap:1.5},children:[o?a(n,{size:`small`,label:e(r?`online`:`offline`),color:r?`success`:`error`}):null,a(h,{sx:{ml:`auto`,pl:1},children:this.props.hostSelector})]})]}),u(h,{sx:{display:`flex`,gap:2,flexWrap:`wrap`,mb:2},children:[a(c,{title:e(`System status`),value:o?e(r?`OK`:`Offline`):$,valueColor:o?r?t.palette.success.main:t.palette.error.main:void 0,hint:e(o?r?`ioBroker is running`:`Host does not answer`:`Loading...`),color:o?r?t.palette.success.main:t.palette.error.main:t.palette.text.secondary,icon:a(C,{}),onClick:()=>this.props.handleNavigation(`tab-hosts`)}),a(c,{title:e(`Adapters`),value:o?String(this.state.adaptersTotal):$,hint:o?e(`%s active / %s inactive`,this.state.adaptersActive,this.state.adaptersTotal-this.state.adaptersActive):e(`Loading...`),chip:s?{label:s===1?e(`1 update`):e(`%s updates`,s),color:`warning`}:void 0,color:t.palette.primary.main,icon:a(D,{}),onClick:()=>this.props.handleNavigation(`tab-adapters`)}),a(c,{title:e(`Instances`),value:o?String(this.state.instancesTotal):$,hint:o?e(`%s active / %s inactive`,this.state.instancesAlive,this.state.instancesTotal-this.state.instancesAlive):e(`Loading...`),color:t.palette.secondary.main,icon:a(tt,{}),onClick:()=>this.props.handleNavigation(`tab-instances`)}),a(c,{title:e(`Objects`),value:this.state.objectsLoaded?this.state.objectsCount.toLocaleString(this.props.lang):$,hint:this.state.objectsLoaded?e(`%s states`,this.state.statesCount.toLocaleString(this.props.lang)):e(`Loading...`),color:t.palette.warning.main,icon:a(w,{}),onClick:()=>this.props.handleNavigation(`tab-objects`)})]}),u(h,{sx:{display:`flex`,gap:2,flexWrap:`wrap`,mb:2},children:[this.renderSystemInfo(),u(b,{sx:{flex:`2 1 460px`,p:2.5,minWidth:0,alignSelf:this.state.chartMinimized?`flex-start`:void 0,display:this.state.chartAvailable?void 0:`none`},children:[a(i,{title:e(`Resource usage`),actions:this.renderChartButton()}),a(h,{sx:{display:this.state.chartMinimized?`none`:void 0},children:a(it,{ref:this.chartRef,socket:this.props.socket,currentHost:this.props.currentHost,theme:this.props.theme,themeType:this.props.themeType,t:e,paused:this.state.chartMinimized,onAvailabilityChange:e=>{e!==this.state.chartAvailable&&this.setState({chartAvailable:e})},onRecordingChange:e=>{e!==this.state.chartRecording&&this.setState({chartRecording:e})}})})]})]}),u(h,{sx:{display:`flex`,gap:2,flexWrap:`wrap`},children:[this.renderAdapters(),this.renderLog()]})]})}};export{dt as default};
@@ -1 +1 @@
1
- import{$r as e,Hs as t,Ls as n,Us as r,Wo as i,mo as a,zs as o}from"./loadShare-eager-dmdYQhAl.js";import{X as s}from"./bootstrap-CIDT4MeX.js";var c={checkIcon:{color:n[700]},cancelIcon:{color:o[700]},wrapperContent:{display:`flex`,flexFlow:`nowrap`,alignItems:`inherit`}};function l(n){return r(i,{container:!0,style:c.wrapperContent,direction:`row`,spacing:1,sx:{alignItems:`center`},children:[t(i,{children:n.state?t(s,{style:c.checkIcon}):t(e,{style:c.cancelIcon})}),t(i,{children:t(a,{children:n.children})})]})}export{l as t};
1
+ import{$r as e,Hs as t,Ls as n,Us as r,Wo as i,mo as a,zs as o}from"./loadShare-eager-dmdYQhAl.js";import{X as s}from"./bootstrap-BQ4OzwbT.js";var c={checkIcon:{color:n[700]},cancelIcon:{color:o[700]},wrapperContent:{display:`flex`,flexFlow:`nowrap`,alignItems:`inherit`}};function l(n){return r(i,{container:!0,style:c.wrapperContent,direction:`row`,spacing:1,sx:{alignItems:`center`},children:[t(i,{children:n.state?t(s,{style:c.checkIcon}):t(e,{style:c.cancelIcon})}),t(i,{children:t(a,{children:n.children})})]})}export{l as t};
@@ -1,2 +1,2 @@
1
- import{$a as e,An as t,Eo as n,Hs as r,Qt as i,Us as a,Vt as o,ao as s,eo as c,go as l,mo as u,oi as d,pc as f,po as p,ro as m,sc as h,to as g}from"./loadShare-eager-dmdYQhAl.js";import{o as _}from"./AdminUtils-Dc1eHsx5.js";import{N as v}from"./bootstrap-CIDT4MeX.js";import{n as y,r as b,t as x}from"./Usb-C8HitPqx.js";var S=`system.host.*.usedResources.*`,C=`.usedResources.`;function w(e){let t=e.indexOf(C);return e.startsWith(`system.host.`)&&t>0?e.substring(0,t):null}function T(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.type==`string`&&/^[A-Za-z0-9_-]{1,64}$/.test(t.type)&&typeof t.instance==`string`&&!!t.instance&&typeof t.ts==`number`&&typeof t.isBlocked==`boolean`&&typeof t.data==`object`&&t.data!==null&&!Array.isArray(t.data)}function E(e){if(!e||typeof e.val!=`string`||!e.val)return[];try{let t=JSON.parse(e.val);return Array.isArray(t)?t.filter(T):[]}catch{return[]}}var D=new Set([`0.0.0.0`,`::`,`*`,``]);function O(e,t,n){if(e===`tcpPort`||e===`udpPort`){if(t.port!==n.port||t.family!==void 0&&n.family!==void 0&&t.family!==n.family)return!1;if(t.bind===void 0||n.bind===void 0)return!0;let e=String(t.bind).trim(),r=String(n.bind).trim();return D.has(e)||D.has(r)||e===r}if(e===`serialPort`)return(t.device??t.port)===(n.device??n.port);if(e===`usb`)return t.path===n.path;let r=(e,t)=>Object.keys(e).every(n=>e[n]===void 0||e[n]===t[n]);return r(t,n)||r(n,t)}var k={serialPort:`Serial port`,tcpPort:`TCP port`,udpPort:`UDP port`,usb:`USB device`,bluetooth:`Bluetooth`,gpio:`GPIO`};function A(e){return e.flatMap(e=>Object.keys(k).map(t=>`${e}.usedResources.${t}`))}async function j(e,t){let n=A(t),r=t.length===1?`${t[0]}.usedResources.*`:S,[i,a]=await Promise.all([n.length?e.getForeignStates(n).catch(e=>(console.warn(`Cannot read the used resources: ${e}`),{})):Promise.resolve({}),e.getForeignStates(r).catch(e=>(console.warn(`Cannot read ${r}: ${e}`),{}))]),o={...i,...a};for(let e of Object.keys(o))o[e]||delete o[e];return o}function M(e){let t=[];for(let[n,r]of Object.entries(e)){let e=w(n);if(e)for(let n of E(r))t.push({...n,hostId:e,conflicts:[]})}for(let e of t)e.conflicts=t.filter(t=>t.hostId===e.hostId&&t.type===e.type&&t.instance!==e.instance&&O(e.type,e.data,t.data)).map(e=>e.instance);return t.sort((e,t)=>e.hostId.localeCompare(t.hostId)||e.type.localeCompare(t.type)||N(e).localeCompare(N(t),void 0,{numeric:!0})||e.instance.localeCompare(t.instance))}function N(e){let t=e.data,n=[],r;switch(e.type){case`tcpPort`:case`udpPort`:r=String(t.port??``),t.bind!==void 0&&!D.has(String(t.bind).trim())&&n.push(String(t.bind)),t.family!==void 0&&n.push(`IPv${t.family}`);break;case`serialPort`:r=String(t.port??``),t.device!==void 0&&t.device!==t.port&&n.push(`→ ${t.device}`),t.baudRate!==void 0&&n.push(`${t.baudRate} Bd`);break;case`usb`:r=String(t.path??``),(t.vendorId!==void 0||t.productId!==void 0)&&n.push(`${t.vendorId??`?`}:${t.productId??`?`}`);break;case`bluetooth`:r=String(t.hci??``);break;case`gpio`:r=String(t.pin??``),t.chip!==void 0&&n.push(String(t.chip));break;default:r=Object.entries(t).map(([e,t])=>`${e}: ${t}`).join(`, `)}return n.length?`${r} (${n.join(`, `)})`:r}var P={serialPort:r(o,{fontSize:`small`}),tcpPort:r(y,{fontSize:`small`}),udpPort:r(y,{fontSize:`small`}),usb:r(x,{fontSize:`small`}),bluetooth:r(i,{fontSize:`small`}),gpio:r(v,{fontSize:`small`})};function F(e){return P[e]||r(b,{fontSize:`small`})}function I(e,t){return k[e]?t(k[e]):e}function L(e,t){return t(`Also registered by: %s`,e.conflicts.join(`, `))}function R(e,t){let[n,r]=f(null);return h(()=>{let n=`${t}.usedResources.*`,i={},a=!0,o=()=>{a&&r(Object.keys(i).length?M(i):null)},s=(e,t)=>{i={...i,[e]:t},o()};return j(e,[t]).then(e=>{i={...e,...i},o()}),e.subscribeState(n,s),()=>{a=!1,e.unsubscribeState(n,s)}},[e,t]),n}var z={};function B(e){let t=e.instance.split(`.`)[0],[n,i]=f(``);return h(()=>{let n=!0;return z[t]||=e.socket.getObject(`system.adapter.${t}`).then(e=>{var n;return e!=null&&(n=e.common)!=null&&n.icon?_(`adapter/${t}/${e.common.icon}`):``}).catch(()=>``),z[t].then(e=>{n&&i(e)}),()=>{n=!1}},[e.socket,t]),r(l,{sx:{width:20,height:20,flexShrink:0},children:n?r(`img`,{src:n,alt:``,style:{width:20,height:20,objectFit:`contain`}}):null})}function V(t){let{t:i}=t;return a(e,{size:`small`,sx:{"& td, & th":{py:.5}},children:[r(m,{children:a(s,{children:[r(g,{children:i(`Type`)}),r(g,{children:i(`Resource`)}),t.hideInstance?null:r(g,{children:i(`Instance`)}),r(g,{children:i(`Status`)}),r(g,{children:i(`Registered`)})]})}),r(c,{children:t.resources.map(e=>{let o=N(e);return a(s,{children:[r(g,{children:a(l,{sx:{display:`flex`,alignItems:`center`,gap:1,whiteSpace:`nowrap`},children:[F(e.type),I(e.type,i)]})}),r(g,{children:a(l,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[o,e.conflicts.length?r(p,{title:L(e,i),children:r(d,{fontSize:`small`,color:`warning`})}):null]})}),t.hideInstance?null:r(g,{children:a(l,{sx:{display:`flex`,alignItems:`center`,gap:1,whiteSpace:`nowrap`},children:[r(B,{socket:t.socket,instance:e.instance}),e.instance]})}),r(g,{children:r(p,{title:e.isBlocked?i(`The instance runs and holds the resource`):i(`The instance does not run and would take the resource when started`),children:r(n,{size:`small`,variant:e.isBlocked?`filled`:`outlined`,color:e.isBlocked?`success`:`info`,label:e.isBlocked?i(`In use`):i(`Reserved`)})})}),r(g,{sx:{whiteSpace:`nowrap`},children:new Date(e.ts).toLocaleString()})]},`${e.instance}|${e.type}|${o}`)})})]})}function H(e){let i=R(e.socket,e.hostId),[o,s]=f(!1);if(!i)return null;let c=i.filter(e=>e.conflicts.length);return a(l,{sx:{width:`100%`,px:2,pb:1},onClick:e=>e.stopPropagation(),children:[a(l,{sx:e=>({display:`inline-flex`,alignItems:`center`,gap:1,py:.5,pl:.5,pr:1.5,borderRadius:2,cursor:`pointer`,border:`1px solid ${e.palette.divider}`,backgroundColor:e.palette.action.hover,"&:hover":{backgroundColor:e.palette.action.selected}}),onClick:()=>s(!o),children:[r(t,{fontSize:`small`,sx:{transition:`transform 0.2s`,transform:o?`rotate(180deg)`:void 0}}),r(u,{variant:`subtitle2`,sx:{fontWeight:`bold`},children:e.t(`Used resources`)}),r(n,{size:`small`,label:i.length}),c.length?r(p,{title:r(`span`,{style:{whiteSpace:`pre-line`},children:c.map(t=>`${N(t)}: ${L(t,e.t)}`).join(`
1
+ import{$a as e,An as t,Eo as n,Hs as r,Qt as i,Us as a,Vt as o,ao as s,eo as c,go as l,mo as u,oi as d,pc as f,po as p,ro as m,sc as h,to as g}from"./loadShare-eager-dmdYQhAl.js";import{o as _}from"./AdminUtils-Dc1eHsx5.js";import{N as v}from"./bootstrap-BQ4OzwbT.js";import{n as y,r as b,t as x}from"./Usb-C8HitPqx.js";var S=`system.host.*.usedResources.*`,C=`.usedResources.`;function w(e){let t=e.indexOf(C);return e.startsWith(`system.host.`)&&t>0?e.substring(0,t):null}function T(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.type==`string`&&/^[A-Za-z0-9_-]{1,64}$/.test(t.type)&&typeof t.instance==`string`&&!!t.instance&&typeof t.ts==`number`&&typeof t.isBlocked==`boolean`&&typeof t.data==`object`&&t.data!==null&&!Array.isArray(t.data)}function E(e){if(!e||typeof e.val!=`string`||!e.val)return[];try{let t=JSON.parse(e.val);return Array.isArray(t)?t.filter(T):[]}catch{return[]}}var D=new Set([`0.0.0.0`,`::`,`*`,``]);function O(e,t,n){if(e===`tcpPort`||e===`udpPort`){if(t.port!==n.port||t.family!==void 0&&n.family!==void 0&&t.family!==n.family)return!1;if(t.bind===void 0||n.bind===void 0)return!0;let e=String(t.bind).trim(),r=String(n.bind).trim();return D.has(e)||D.has(r)||e===r}if(e===`serialPort`)return(t.device??t.port)===(n.device??n.port);if(e===`usb`)return t.path===n.path;let r=(e,t)=>Object.keys(e).every(n=>e[n]===void 0||e[n]===t[n]);return r(t,n)||r(n,t)}var k={serialPort:`Serial port`,tcpPort:`TCP port`,udpPort:`UDP port`,usb:`USB device`,bluetooth:`Bluetooth`,gpio:`GPIO`};function A(e){return e.flatMap(e=>Object.keys(k).map(t=>`${e}.usedResources.${t}`))}async function j(e,t){let n=A(t),r=t.length===1?`${t[0]}.usedResources.*`:S,[i,a]=await Promise.all([n.length?e.getForeignStates(n).catch(e=>(console.warn(`Cannot read the used resources: ${e}`),{})):Promise.resolve({}),e.getForeignStates(r).catch(e=>(console.warn(`Cannot read ${r}: ${e}`),{}))]),o={...i,...a};for(let e of Object.keys(o))o[e]||delete o[e];return o}function M(e){let t=[];for(let[n,r]of Object.entries(e)){let e=w(n);if(e)for(let n of E(r))t.push({...n,hostId:e,conflicts:[]})}for(let e of t)e.conflicts=t.filter(t=>t.hostId===e.hostId&&t.type===e.type&&t.instance!==e.instance&&O(e.type,e.data,t.data)).map(e=>e.instance);return t.sort((e,t)=>e.hostId.localeCompare(t.hostId)||e.type.localeCompare(t.type)||N(e).localeCompare(N(t),void 0,{numeric:!0})||e.instance.localeCompare(t.instance))}function N(e){let t=e.data,n=[],r;switch(e.type){case`tcpPort`:case`udpPort`:r=String(t.port??``),t.bind!==void 0&&!D.has(String(t.bind).trim())&&n.push(String(t.bind)),t.family!==void 0&&n.push(`IPv${t.family}`);break;case`serialPort`:r=String(t.port??``),t.device!==void 0&&t.device!==t.port&&n.push(`→ ${t.device}`),t.baudRate!==void 0&&n.push(`${t.baudRate} Bd`);break;case`usb`:r=String(t.path??``),(t.vendorId!==void 0||t.productId!==void 0)&&n.push(`${t.vendorId??`?`}:${t.productId??`?`}`);break;case`bluetooth`:r=String(t.hci??``);break;case`gpio`:r=String(t.pin??``),t.chip!==void 0&&n.push(String(t.chip));break;default:r=Object.entries(t).map(([e,t])=>`${e}: ${t}`).join(`, `)}return n.length?`${r} (${n.join(`, `)})`:r}var P={serialPort:r(o,{fontSize:`small`}),tcpPort:r(y,{fontSize:`small`}),udpPort:r(y,{fontSize:`small`}),usb:r(x,{fontSize:`small`}),bluetooth:r(i,{fontSize:`small`}),gpio:r(v,{fontSize:`small`})};function F(e){return P[e]||r(b,{fontSize:`small`})}function I(e,t){return k[e]?t(k[e]):e}function L(e,t){return t(`Also registered by: %s`,e.conflicts.join(`, `))}function R(e,t){let[n,r]=f(null);return h(()=>{let n=`${t}.usedResources.*`,i={},a=!0,o=()=>{a&&r(Object.keys(i).length?M(i):null)},s=(e,t)=>{i={...i,[e]:t},o()};return j(e,[t]).then(e=>{i={...e,...i},o()}),e.subscribeState(n,s),()=>{a=!1,e.unsubscribeState(n,s)}},[e,t]),n}var z={};function B(e){let t=e.instance.split(`.`)[0],[n,i]=f(``);return h(()=>{let n=!0;return z[t]||=e.socket.getObject(`system.adapter.${t}`).then(e=>{var n;return e!=null&&(n=e.common)!=null&&n.icon?_(`adapter/${t}/${e.common.icon}`):``}).catch(()=>``),z[t].then(e=>{n&&i(e)}),()=>{n=!1}},[e.socket,t]),r(l,{sx:{width:20,height:20,flexShrink:0},children:n?r(`img`,{src:n,alt:``,style:{width:20,height:20,objectFit:`contain`}}):null})}function V(t){let{t:i}=t;return a(e,{size:`small`,sx:{"& td, & th":{py:.5}},children:[r(m,{children:a(s,{children:[r(g,{children:i(`Type`)}),r(g,{children:i(`Resource`)}),t.hideInstance?null:r(g,{children:i(`Instance`)}),r(g,{children:i(`Status`)}),r(g,{children:i(`Registered`)})]})}),r(c,{children:t.resources.map(e=>{let o=N(e);return a(s,{children:[r(g,{children:a(l,{sx:{display:`flex`,alignItems:`center`,gap:1,whiteSpace:`nowrap`},children:[F(e.type),I(e.type,i)]})}),r(g,{children:a(l,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[o,e.conflicts.length?r(p,{title:L(e,i),children:r(d,{fontSize:`small`,color:`warning`})}):null]})}),t.hideInstance?null:r(g,{children:a(l,{sx:{display:`flex`,alignItems:`center`,gap:1,whiteSpace:`nowrap`},children:[r(B,{socket:t.socket,instance:e.instance}),e.instance]})}),r(g,{children:r(p,{title:e.isBlocked?i(`The instance runs and holds the resource`):i(`The instance does not run and would take the resource when started`),children:r(n,{size:`small`,variant:e.isBlocked?`filled`:`outlined`,color:e.isBlocked?`success`:`info`,label:e.isBlocked?i(`In use`):i(`Reserved`)})})}),r(g,{sx:{whiteSpace:`nowrap`},children:new Date(e.ts).toLocaleString()})]},`${e.instance}|${e.type}|${o}`)})})]})}function H(e){let i=R(e.socket,e.hostId),[o,s]=f(!1);if(!i)return null;let c=i.filter(e=>e.conflicts.length);return a(l,{sx:{width:`100%`,px:2,pb:1},onClick:e=>e.stopPropagation(),children:[a(l,{sx:e=>({display:`inline-flex`,alignItems:`center`,gap:1,py:.5,pl:.5,pr:1.5,borderRadius:2,cursor:`pointer`,border:`1px solid ${e.palette.divider}`,backgroundColor:e.palette.action.hover,"&:hover":{backgroundColor:e.palette.action.selected}}),onClick:()=>s(!o),children:[r(t,{fontSize:`small`,sx:{transition:`transform 0.2s`,transform:o?`rotate(180deg)`:void 0}}),r(u,{variant:`subtitle2`,sx:{fontWeight:`bold`},children:e.t(`Used resources`)}),r(n,{size:`small`,label:i.length}),c.length?r(p,{title:r(`span`,{style:{whiteSpace:`pre-line`},children:c.map(t=>`${N(t)}: ${L(t,e.t)}`).join(`
2
2
  `)}),children:a(l,{sx:{display:`flex`,alignItems:`center`,gap:.5,color:`warning.main`},children:[r(d,{fontSize:`small`,color:`warning`}),c.length]})}):null]}),o?r(l,{sx:{mt:1,maxHeight:400,overflowY:`auto`},children:i.length?r(V,{socket:e.socket,resources:i,t:e.t}):r(u,{variant:`body2`,color:`textSecondary`,children:e.t(`No instance has registered a resource`)})}):null]})}export{S as a,j as c,I as i,L as n,M as o,F as r,N as s,H as t};
@@ -1 +1 @@
1
- import{Ao as e,Co as t,Es as n,Ha as r,Hs as i,Ka as a,Kn as o,Ko as s,Lr as c,Mo as l,No as u,Po as d,Qa as f,Qi as p,Ro as m,Rr as h,To as g,Ts as _,Us as v,Vo as ee,Wa as y,Wo as b,Wr as x,Xo as te,ba as S,bi as C,br as w,fc as ne,ga as T,go as E,jo as D,mo as O,qn as k,sc as re,so as A,tc as j,xa as M,xo as N,xr as P,yo as F}from"./loadShare-eager-dmdYQhAl.js";import{o as I,t as L}from"./AdminUtils-Dc1eHsx5.js";import{Ct as ie,Et as R,Ot as z,St as B,wt as ae,xt as oe}from"./bootstrap-CIDT4MeX.js";import{t as V}from"./VpnKey-BbZdswcd.js";import{n as H,r as U,t as W}from"./Fields-zSEjRWOB.js";import{n as G,r as K,t as q}from"./ColorLens-DA51K29x.js";import{n as se,r as ce,t as le}from"./PersonOff-DqBq0Fho.js";var J=e=>{let n=+!e.isDragging,a=x.getInvertedColor(e.user.common.color,e.themeType,!0),c={cursor:`grab`,opacity:n,overflow:`hidden`,color:a};return e.user.common.color&&(c.backgroundColor=e.user.common.color),i(N,{style:c,sx:e.styles.userGroupCard2,children:v(`div`,{style:e.styles.userCardContent,children:[v(`div`,{style:e.styles.right,children:[i(g,{checked:e.user.common.enabled,style:{color:a},disabled:e.user.common.dontDelete,onChange:()=>{e.socket.extendObject(e.user._id,{common:{enabled:!e.user.common.enabled}}).then(()=>e.updateData())}}),i(s,{size:`small`,onClick:()=>e.showUserEditDialog(e.user,!1),children:i(S,{style:{color:a}})}),i(s,{size:`small`,onClick:()=>e.showUserDeleteDialog(e.user),disabled:e.user.common.dontDelete,children:i(r,{style:e.user.common.dontDelete?void 0:{color:a}})})]}),v(t,{children:[v(O,{gutterBottom:!0,component:`div`,style:e.styles.userGroupTitle,children:[e.user.common.icon?i(w,{style:e.styles.icon,src:e.user.common.icon}):i(k,{style:e.styles.icon}),v(`div`,{children:[v(`div`,{children:[i(`span`,{style:e.styles.userGroupUserName,children:e.getText(e.user.common.name)}),v(`span`,{style:e.styles.userGroupUserID,children:[`[`,e.user._id,`]`]})]}),i(`span`,{children:e.user.common.desc?i(`div`,{style:e.styles.description,children:e.getText(e.user.common.desc)}):null})]})]}),e.groups.find(t=>t.common.members&&t.common.members.includes(e.user._id))?v(`div`,{children:[e.t(`In groups`),`:`]}):null,i(`div`,{children:e.groups.map(t=>{var n,r;if(!t.common.members||!t.common.members.includes(e.user._id))return null;let c=t&&(n=t.common)!=null&&n.color?x.getInvertedColor(t.common.color,e.themeType,!0):a;return v(N,{variant:`outlined`,sx:e.styles.userGroupMember,style:{color:c,borderColor:`${c}80`,background:((r=t.common)==null?void 0:r.color)||`inherit`},children:[t.common.icon?i(w,{style:e.styles.icon,src:t.common.icon}):i(o,{style:e.styles.icon}),e.getText(t.common.name),i(s,{size:`small`,onClick:()=>e.removeUserFromGroup(e.user._id,t._id),children:i(p,{style:{color:c}})})]},t._id)})})]})]})})},ue=e=>{let t=ne(null),[{isDragging:n},r,a]=R({type:`user`,item:()=>{var n;return{userId:e.user._id,preview:i(`div`,{style:{width:(n=t.current)==null?void 0:n.offsetWidth},children:i(J,{...e})})}},end:(t,n)=>{let r=n.getDropResult();if(t&&r){var i;(i=e.addUserToGroup)==null||i.call(e,t.userId,r.groupId)}},collect:e=>({isDragging:e.isDragging(),handlerId:e.getHandlerId()})});return re(()=>{a(ie(),{captureDraggingState:!0})},[a]),i(`div`,{ref:e=>{r(e)},children:i(`div`,{ref:t,children:i(J,{isDragging:n,...e})})})};function de(e,t){return!t.group.common.members||!t.group.common.members.includes(e.getItem().userId)}var fe=e=>{var n;let[{CanDrop:a,isOver:c},l]=ae(()=>({accept:`user`,drop:()=>({groupId:e.group._id}),canDrop:(t,n)=>de(n,e),collect:e=>({isOver:e.isOver(),CanDrop:e.canDrop()})}),[e.group.common.members]),u=.7,d;a&&c?(u=a?1:.125,d=e.styles.userGroupCardSecondary):a&&(u=a?.75:.25);let f=x.getInvertedColor(e.group.common.color,e.themeType,!0),m={opacity:u,overflow:`hidden`,color:f};return e.group.common.color&&(m.backgroundColor=e.group.common.color),v(N,{style:m,ref:e=>{l(e)},sx:x.getStyle(e.theme,e.styles.userGroupCard2,d),children:[v(`div`,{style:e.styles.right,children:[i(s,{size:`small`,onClick:()=>e.showGroupEditDialog(e.group,!1),children:i(S,{style:{color:f}})}),i(s,{size:`small`,onClick:()=>e.showGroupDeleteDialog(e.group),disabled:e.group.common.dontDelete,children:i(r,{style:e.group.common.dontDelete?void 0:{color:f}})})]}),v(t,{children:[v(O,{gutterBottom:!0,component:`div`,style:e.styles.userGroupTitle,children:[e.group.common.icon?i(w,{style:e.styles.icon,src:e.group.common.icon}):i(o,{style:e.styles.icon}),v(`div`,{children:[v(`div`,{children:[i(`span`,{style:e.styles.userGroupUserName,children:e.getText(e.group.common.name)}),v(`span`,{children:[`[`,e.group._id,`]`]})]}),e.group.common.desc?i(`div`,{style:e.styles.description,children:e.getText(e.group.common.desc)}):null]})]}),(n=e.group.common.members)!=null&&n.length?v(`div`,{children:[e.t(`Group members`),`:`]}):null,i(`div`,{children:(e.group.common.members||[]).map((t,n)=>{var r,a;let o=e.users.find(e=>e._id===t),c=o&&(r=o.common)!=null&&r.color?x.getInvertedColor(o.common.color,e.themeType,!0):f;return o?v(N,{variant:`outlined`,sx:e.styles.userGroupMember,style:{color:c,borderColor:`${c}40`,background:((a=o.common)==null?void 0:a.color)||`inherit`},children:[o.common.icon?i(w,{style:e.styles.icon,src:o.common.icon}):i(k,{style:e.styles.icon}),e.getText(o.common.name),i(s,{size:`small`,onClick:()=>e.removeUserFromGroup(t,e.group._id),children:i(p,{style:{color:c}})})]},n):null})})]})]})},Y=[new URL(`user1-D1GAYfim.svg`,import.meta.url).href,new URL(`user2-kVvfO6hI.svg`,import.meta.url).href,new URL(`user3-B1MPu8jB.svg`,import.meta.url).href,new URL(`user4-DmVDIOoi.svg`,import.meta.url).href,new URL(`user5-DwFpzcW1.svg`,import.meta.url).href,new URL(`user6-DHgFm0fc.svg`,import.meta.url).href,new URL(`user7-DkJFgUmb.svg`,import.meta.url).href,new URL(`user8-BZA6Afc4.svg`,import.meta.url).href,new URL(`user9-BLdaSIG0.svg`,import.meta.url).href,new URL(`user10-DvWuZ_uc.svg`,import.meta.url).href,new URL(`user11-Ch5DvO34.svg`,import.meta.url).href,new URL(`user12-DEiNnJWd.svg`,import.meta.url).href],pe={contentRoot:{padding:`16px 24px`}},me=class extends j{constructor(e){super(e),this.state={originalId:e.user._id,passwordRepeat:e.user.common.password,originalData:JSON.stringify(e.user)}}componentDidMount(){if(this.props.isNew){let e=Y[Math.round(Math.random()*(Y.length-1))];e&&x.getSvg(e).then(e=>{let t=x.clone(this.props.user);t.common.icon=e,this.props.onChange(t)})}}render(){let t=this.props.users.find(e=>e._id===this.props.user._id),n=this.props.user._id!==this.state.originalId,r=e=>e.split(`.`).pop()||``,o=e=>e.replace(x.FORBIDDEN_CHARS,`_`).replace(/\s/g,`_`).replace(/\./g,`_`).replace(/,/g,`_`).replace(/__/g,`_`).replace(/__/g,`_`).toLowerCase(),s=(e,t)=>{let n=e.split(`.`);return n[n.length-1]=t,n.join(`.`)},c=this.props.getText(this.props.user.common.desc),u=this.props.getText(this.props.user.common.name),f=L.checkPassword(this.props.user.common.password),p=L.checkPassword(this.props.user.common.password,this.state.passwordRepeat),m=this.props.isNew||JSON.stringify(this.props.user)!==this.state.originalData,h=this.props.user._id!==`system.user.`&&!f&&!p&&m;return(this.props.isNew&&t||t&&n)&&(h=!1),v(e,{fullWidth:this.props.innerWidth<500,open:!0,onClose:(e,t)=>{t!==`backdropClick`&&t!==`escapeKeyDown`&&this.props.onClose()},children:[i(d,{style:{...this.props.styles.dialogTitle,padding:12},children:this.props.t(`User parameters`)}),v(l,{sx:{"&.MuiDialogContent-root":{...this.props.innerWidth<500?this.props.styles.narrowContent:void 0,...pe.contentRoot}},children:[v(b,{container:!0,spacing:this.props.innerWidth<500?1:4,style:this.props.styles.dialog,children:[i(b,{size:{xs:12,md:6},children:i(H,{label:`Name`,t:this.props.t,value:u,onChange:e=>{let t=x.clone(this.props.user);!this.props.user.common.dontDelete&&o(this.props.getText(t.common.name))===r(t._id)&&(t._id=s(t._id,o(e))),t.common.name=e,this.props.onChange(t)},autoComplete:`new-password`,icon:C,styles:this.props.styles})}),i(b,{size:{xs:12,md:6},children:i(H,{label:`ID edit`,t:this.props.t,disabled:this.props.user.common.dontDelete,value:this.props.user._id.split(`.`)[this.props.user._id.split(`.`).length-1],onChange:e=>{let t=x.clone(this.props.user);t._id=s(t._id,o(e)),this.props.onChange(t)},icon:K,styles:this.props.styles})}),i(b,{size:{xs:12,md:6},children:i(H,{label:`ID preview`,t:this.props.t,disabled:!0,value:this.props.user._id,icon:G,styles:this.props.styles})}),i(b,{size:{xs:12,md:6},children:i(H,{label:`Description`,t:this.props.t,value:c,onChange:e=>{let t=x.clone(this.props.user);t.common.desc=e,this.props.onChange(t)},icon:M,styles:this.props.styles})}),i(b,{size:{xs:12,md:6},children:i(H,{label:`Password`,t:this.props.t,value:this.props.user.common.password,error:f?this.props.t(f):void 0,onChange:e=>{let t=x.clone(this.props.user);t.common.password=e,this.props.onChange(t)},type:`password`,autoComplete:`new-password`,icon:V,styles:this.props.styles})}),i(b,{size:{xs:12,md:6},children:i(H,{label:`Password repeat`,t:this.props.t,value:this.state.passwordRepeat,error:p?this.props.t(p):void 0,onChange:e=>this.setState({passwordRepeat:e}),type:`password`,autoComplete:`new-password`,icon:V,styles:this.props.styles})}),i(b,{size:{xs:12,md:6},children:i(P,{icons:Y,label:`Icon`,value:this.props.user.common.icon,onChange:e=>{let t=x.clone(this.props.user);t.common.icon=e,this.props.onChange(t)},previewStyle:this.props.styles.iconPreview,icon:T})}),i(b,{size:{xs:12,md:6},children:i(W,{label:`Color`,t:this.props.t,value:this.props.user.common.color||``,previewStyle:this.props.styles.iconPreview,onChange:e=>{let t=x.clone(this.props.user);t.common.color=e,this.props.onChange(t)},icon:q,style:this.props.styles.colorPicker,styles:this.props.styles})})]}),this.props.isNew?null:this.renderOidcButton()]}),v(D,{children:[i(F,{variant:`contained`,color:`primary`,autoFocus:!0,onClick:()=>this.props.saveData(this.props.isNew?null:this.state.originalId),disabled:!h,startIcon:i(y,{}),children:this.props.t(`Save`)}),i(F,{variant:`contained`,color:`grey`,onClick:this.props.onClose,startIcon:i(a,{}),children:this.props.t(`Cancel`)})]})]})}renderOidcButton(){var e;return window.ssoActive===`true`?(e=this.props.user.common)!=null&&(e=e.externalAuthentication)!=null&&e.oidc?i(F,{variant:`contained`,color:`secondary`,fullWidth:!0,startIcon:i(le,{}),sx:{marginTop:2},onClick:async()=>{var e;(e=this.props.user.common.externalAuthentication)==null||delete e.oidc,await this.props.saveData(this.state.originalId),window.alert(`Single-Sign On disconnected!`)},children:this.props.t(`Disconnect Single-Sign On`)}):i(F,{variant:`contained`,color:`secondary`,fullWidth:!0,onClick:()=>{window.location.href=I(`sso?redirectUrl=${encodeURIComponent(`${window.origin}${I(`#tab-users`)}`)}&method=register&user=${encodeURIComponent((this.state.originalId||this.props.user._id).replace(/^system\.user\./,``))}`)},startIcon:i(k,{}),sx:{marginTop:2},children:this.props.t(`Add Single-Sign On`)}):null}},X=[new URL(`group1-CmFsZszo.svg`,import.meta.url).href,new URL(`group2-CuvSswwx.svg`,import.meta.url).href,new URL(`group3-CRAMNPrf.svg`,import.meta.url).href,new URL(`group4-D4IM6-jV.svg`,import.meta.url).href,new URL(`group5-T3CGkJFm.svg`,import.meta.url).href,new URL(`group6-CLVorg7G.svg`,import.meta.url).href,new URL(`group7-D-h4KR6w.svg`,import.meta.url).href,new URL(`group8-BXzJmR7Y.svg`,import.meta.url).href,`data:image/svg+xml,%3csvg%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20461.367%20461.367'%3e%3cpath%20style='fill:%231EA6C6;'%20d='M373.88,367.988c0,0.037,0,0.075,0,0.122c-37.818,34.295-88.019,55.185-143.083,55.185%20c-55.073,0-105.275-20.89-143.092-55.185c0-0.047,0-0.084,0-0.122c0-57.04,33.377-106.277,81.659-129.256%20c18.145,18.098,39.391,27.85,61.434,27.85c22.052,0,43.288-9.752,61.443-27.85C340.521,261.711,373.88,310.947,373.88,367.988z%20'/%3e%3cpath%20style='fill:%23FCD09F;'%20d='M230.797,58.571c43.71,0,79.148,35.429,79.148,79.139c0,43.719-35.438,103.504-79.148,103.504%20s-79.148-59.785-79.148-103.504C151.649,94,187.087,58.571,230.797,58.571z'/%3e%3cpath%20style='fill:%23EF806F;'%20d='M164.094,213.389c2.426,3.457,4.937,6.698,7.532,9.742l-7.897,3.756%20c-26.286,12.506-48.525,32.075-64.328,56.59c-12.853,19.944-20.909,42.427-23.71,65.865%20c-28.562-7.785-54.38-22.22-75.691-41.546v-0.103c0-49.705,29.087-92.609,71.157-112.638%20c15.813,15.775,34.323,24.272,53.527,24.272c12.581,0,24.871-3.644,36.291-10.595%20C161.977,210.307,163.026,211.862,164.094,213.389z'/%3e%3cpath%20style='fill:%23EFC59C;'%20d='M138.539,137.707c0,16.431,4.272,34.511,11.878,51.504c-7.953,5.04-16.637,8.009-25.733,8.009%20c-38.089,0-68.965-52.094-68.965-90.193c0-38.089,30.876-68.956,68.965-68.956c21.124,0,40.038,9.499,52.684,24.459%20C153.883,79.28,138.539,106.737,138.539,137.707z'/%3e%3cpath%20style='fill:%23EF806F;'%20d='M297.273,213.389c-2.426,3.457-4.937,6.698-7.532,9.742l7.897,3.756%20c26.286,12.506,48.525,32.075,64.328,56.59c12.853,19.944,20.909,42.427,23.71,65.865c28.562-7.785,54.38-22.22,75.691-41.546%20v-0.103c0-49.705-29.087-92.609-71.157-112.638c-15.813,15.775-34.323,24.272-53.527,24.272%20c-12.581,0-24.871-3.644-36.291-10.595C299.39,210.307,298.341,211.862,297.273,213.389z'/%3e%3cpath%20style='fill:%23EFC59C;'%20d='M322.828,137.707c0,16.431-4.272,34.511-11.878,51.504c7.953,5.04,16.637,8.009,25.733,8.009%20c38.089,0,68.965-52.094,68.965-90.193c0-38.089-30.876-68.956-68.965-68.956c-21.124,0-40.038,9.499-52.684,24.459%20C307.484,79.28,322.828,106.737,322.828,137.707z'/%3e%3c/svg%3e`,new URL(`group10-Dp9tRs6I.svg`,import.meta.url).href];function he(e){let t=(e,t)=>Object.values(e).map((n,r)=>{let i=Object.keys(e)[r];return t(n,i)}),n=e.group.common.acl||{},r=e=>e,a={...n,object:{read:!0,list:!0,write:!0,delete:!1,create:!1,...r(n.object)},state:{read:!0,list:!0,write:!0,delete:!1,create:!1,...r(n.state)},users:{read:!1,list:!1,write:!1,delete:!1,create:!1,...r(n.users)},other:{http:!1,execute:!1,sendto:!0,...r(n.other)},file:{read:!0,list:!0,write:!1,delete:!1,create:!1,...r(n.file)}};return i(b,{container:!0,spacing:e.innerWidth<500?1:4,style:e.styles.dialog,children:t(a,(n,r)=>v(b,{size:{xs:12,md:12},children:[i(E,{component:`h2`,sx:e.styles.permHeaders,children:e.t(`group_acl_${r}`)}),t(n,(t,n)=>i(ee,{control:i(g,{disabled:e.group._id===`system.group.administrator`,checked:t,onChange:t=>{let i=x.clone(e.group);i.common.acl=x.clone(a),i.common.acl[r][n]=t.target.checked,e.onChange(i)}}),label:e.t(`group_acl_${n}`),labelPlacement:`top`},n))]},r))},`PermissionsTab`)}var ge={contentRoot:{padding:`16px 24px`}},Z=class extends j{constructor(e){super(e),this.state={tab:0,originalId:e.group._id,originalData:JSON.stringify(e.group)}}componentDidMount(){if(this.props.isNew){let e=X[Math.round(Math.random()*(X.length-1))];e&&x.getSvg(e).then(e=>{let t=x.clone(this.props.group);t.common.icon=e,this.props.onChange(t)})}}render(){let t=this.props.groups.find(e=>e._id===this.props.group._id),n=this.props.group._id!==this.state.originalId,r=this.props.isNew||JSON.stringify(this.props.group)!==this.state.originalData,o=this.props.group._id!==`system.group.`&&this.props.group.common.password===this.props.group.common.passwordRepeat&&r,s=e=>e.split(`.`).pop()||``,c=e=>e.replace(x.FORBIDDEN_CHARS,`_`).replace(/\s/g,`_`).replace(/\./g,`_`).toLowerCase(),u=(e,t)=>{let n=e.split(`.`);return n[n.length-1]=t,n.join(`.`)};this.props.isNew?t&&(o=!1):t&&n&&(o=!1);let p=this.props.getText(this.props.group.common.desc),m=this.props.getText(this.props.group.common.name),h=[v(b,{container:!0,spacing:this.props.innerWidth<500?1:4,style:this.props.styles.dialog,children:[i(b,{size:{xs:12,md:6},children:i(H,{label:`Name`,t:this.props.t,value:m,onChange:e=>{let t=x.clone(this.props.group);!this.props.group.common.dontDelete&&c(this.props.getText(t.common.name))===s(t._id)&&(t._id=u(t._id,c(e))),t.common.name=e,this.props.onChange(t)},autoComplete:`off`,icon:C,styles:this.props.styles})}),i(b,{size:{xs:12,md:6},children:i(H,{label:`ID edit`,t:this.props.t,disabled:this.props.group.common.dontDelete,value:this.props.group._id.split(`.`)[this.props.group._id.split(`.`).length-1],onChange:e=>{let t=x.clone(this.props.group);t._id=u(t._id,c(e)),this.props.onChange(t)},icon:K,styles:this.props.styles})}),i(b,{size:{xs:12,md:6},children:i(H,{label:`ID preview`,t:this.props.t,disabled:!0,value:this.props.group._id,icon:G,styles:this.props.styles})}),i(b,{size:{xs:12,md:6},children:i(H,{label:`Description`,t:this.props.t,value:p,onChange:e=>{let t=x.clone(this.props.group);t.common.desc=e,this.props.onChange(t)},icon:M,styles:this.props.styles})}),i(b,{size:{xs:12,md:6},children:i(P,{label:`Icon`,icons:X,value:this.props.group.common.icon,onChange:e=>{let t=x.clone(this.props.group);t.common.icon=e,this.props.onChange(t)},previewStyle:this.props.styles.iconPreview,icon:T})}),i(b,{size:{xs:12,md:6},children:i(W,{label:`Color`,t:this.props.t,value:this.props.group.common.color||``,previewStyle:this.props.styles.iconPreview,onChange:e=>{let t=x.clone(this.props.group);t.common.color=e,this.props.onChange(t)},icon:q,style:this.props.styles.colorPicker,styles:this.props.styles})})]}),he(this.props)][this.state.tab];return v(e,{open:!0,onClose:(e,t)=>{t!==`backdropClick`&&t!==`escapeKeyDown`&&this.props.onClose()},fullWidth:this.props.innerWidth<500,children:[i(d,{style:this.props.styles.dialogTitle,children:v(A,{variant:`fullWidth`,value:this.state.tab,onChange:(e,t)=>this.setState({tab:t}),children:[i(f,{label:this.props.t(`Main`),value:0}),i(f,{label:this.props.t(`Permissions`),value:1})]})}),i(l,{sx:{"&.MuiDialogContent-root":{...this.props.innerWidth<500?this.props.styles.narrowContent:void 0,...ge.contentRoot}},children:h}),v(D,{style:this.props.styles.dialogActions,children:[i(F,{variant:`contained`,color:`primary`,autoFocus:!0,onClick:()=>this.props.saveData(this.props.isNew?null:this.state.originalId),disabled:!o,startIcon:i(y,{}),children:this.props.t(`Save`)}),i(F,{variant:`contained`,color:`grey`,onClick:this.props.onClose,startIcon:i(a,{}),children:this.props.t(`Cancel`)})]})]})}};function _e(t){return v(e,{open:!0,onClose:t.onClose,children:[i(d,{children:t.t(`Please confirm`)}),i(l,{children:i(u,{children:t.t(`Do you want to delete user %s?`,t.getText(t.user.common.name))})}),v(D,{children:[i(F,{variant:`contained`,color:`primary`,onClick:()=>t.deleteUser(t.user._id),startIcon:i(r,{}),children:t.t(`Delete`)}),i(F,{variant:`contained`,color:`grey`,autoFocus:!0,onClick:t.onClose,startIcon:i(a,{}),children:t.t(`Cancel`)})]})]})}function ve(t){return v(e,{open:!0,onClose:t.onClose,children:[i(d,{children:t.t(`Please confirm`)}),i(l,{children:i(u,{children:t.t(`Do you want to delete group %s?`,t.getText(t.group.common.name))})}),v(D,{style:t.styles.dialogActions,children:[i(F,{variant:`contained`,color:`primary`,onClick:()=>t.deleteGroup(t.group._id),startIcon:i(r,{}),children:t.t(`Delete`)}),i(F,{variant:`contained`,color:`grey`,autoFocus:!0,onClick:t.onClose,startIcon:i(a,{}),children:t.t(`Cancel`)})]})]})}n();var Q=`***********`,ye=`0 1px 1px 0 rgba(0, 0, 0, .4),0 6px 6px 0 rgba(0, 0, 0, .2)`,$={mainGridCont:{height:`calc(100% - 55px)`,overflowY:`auto`},childGridCont:{display:`flex`,flexDirection:`column`},childGridContWide:{height:`100%`},canDrop:e=>({backgroundColor:e.palette.background.default}),headContainer:{margin:10},blocksContainer:{overflowY:`auto`,overflowX:`hidden`},userGroupCard2:e=>({border:`1px solid #FFF`,borderColor:e.palette.divider,m:`10px`,minHeight:150,backgroundColor:e.palette.background.default,color:e.palette.text.primary,transition:`all 200ms ease-out`,opacity:1,overflow:`hidden`,"&:hover":{overflowY:`auto`,boxShadow:ye}}),userGroupCardSecondary:e=>({color:e.palette.text.primary,backgroundColor:e.palette.success.light}),permHeaders:e=>({backgroundColor:e.palette.mode===`dark`?e.palette.background.default:e.palette.primary.main,p:`4px`,borderRadius:`2px`,color:`#EEE`}),userCardContent:{height:`100%`,opacity:1},userGroupTitle:{display:`inline-flex`,alignItems:`center`},userGroupUserName:{fontWeight:900,padding:5},userGroupUserID:{opacity:.7,padding:5},description:{fontSize:10,fontStyle:`italic`,marginLeft:5,opacity:.7},userGroupMember:e=>({display:`inline-flex`,m:`4px`,p:`4px`,backgroundColor:`#00000010`,border:`1px solid #FFF`,borderColor:e.palette.text.primary,color:e.palette.text.primary,alignItems:`center`}),icon:{height:32,width:32,marginRight:5,backgroundSize:`cover`,backgroundPosition:`center`},right:{float:`right`},left:{float:`left`,marginRight:10},dialog:{},flex:{display:`flex`},formControl:{display:`flex`,padding:24,flexGrow:1e3},formContainer:{display:`flex`,justifyContent:`center`,alignItems:`center`},formIcon:{margin:10,opacity:.6},descriptionPanel:e=>({width:`100%`,backgroundColor:`transparent`,mb:`20px`,mt:`20px`,ml:`20px`,opacity:.75,border:`none`,display:`flex`,alignItems:`center`,"& a":{pl:`3px`,color:e.palette.mode===`dark`?`#EEE`:`#111`}}),dialogTitle:{borderBottom:`1px solid #00000020`,padding:0,width:`100%`},dialogActions:{borderTop:`1px solid #00000020`,width:`100%`},dialogPaper:{overflowY:`initial`,display:`flex`,flexDirection:`column`,justifyContent:`center`,alignItems:`center`,width:`calc(100% - 100px)`,height:`calc(100% - 100px)`,maxWidth:800,maxHeight:`100%`},dialogPaperMini:{maxHeight:300},colorPicker:{},iconPreview:{height:40,width:40},mainDescription:{fontSize:`200%`},deleteDialog:{padding:20},narrowContent:{padding:`8px 8px 8px 8px`}},be=()=>{let e=U();return e.display?i(`div`,{style:e.style,children:e.item.preview}):null},xe={_id:`system.user.`,type:`user`,common:{name:``,password:``,enabled:!0,color:``,desc:``},native:{},enums:{}},Se={_id:``,native:{},type:`group`,common:{name:``,desc:``,members:[],dontDelete:!0,acl:{object:{list:!1,read:!1,write:!1,delete:!1,create:!1},state:{list:!1,read:!1,write:!1,create:!1,delete:!1},users:{list:!1,read:!1,write:!1,create:!1,delete:!1},other:{execute:!1,http:!1,sendto:!1},file:{list:!1,read:!1,write:!1,create:!1,delete:!1}},icon:``,color:``}},Ce=class e extends j{constructor(e){super(e),_(this,`getText`,e=>e&&(typeof e==`object`?e[this.props.lang]||e.en||``:e||``)||``),_(this,`showUserEditDialog`,(e,t)=>{e=x.clone(e),e.common.password=e.common.password?Q:``,this.setState({userEditDialog:e,userEditDialogNew:t})}),_(this,`showGroupEditDialog`,(e,t)=>{e=x.clone(e),this.setState({groupEditDialog:e,groupEditDialogNew:t})}),_(this,`updateData`,()=>{let e;return this.props.socket.getForeignObjects(`system.user.*`,`user`).then(t=>(e=Object.values(t).sort((e,t)=>e._id>t._id?1:-1),e.forEach(e=>{e.common&&e.common.description&&(e.common.desc||(e.common.desc=e.common.description),delete e.common.description)}),this.props.socket.getForeignObjects(`system.group.*`,`group`))).then(t=>{let n=Object.values(t).sort((e,t)=>e._id>t._id?1:-1);n.forEach(e=>{e.common&&e.common.description&&(e.common.desc||(e.common.desc=e.common.description),delete e.common.description)}),this.setState({groups:n,users:e})})}),_(this,`changeUserFormData`,e=>this.setState({userEditDialog:e})),_(this,`changeGroupFormData`,e=>this.setState({groupEditDialog:e})),_(this,`saveUser`,async e=>{var t;let n=x.clone(this.state.userEditDialog),r=(t=this.state.users)==null?void 0:t.find(e=>e._id===n._id),i=n.common.password&&n.common.password!==Q?n.common.password:``;if(r?n.common.password=r.common.password:n.common.password=``,await this.props.socket.setObject(n._id,n),typeof this.state.userEditDialog==`object`&&e&&e!==this.state.userEditDialog._id)try{await this.props.socket.delObject(e);let t=this.state.groups||[];for(let r=0;r<t.length;r++){let i=t[r];if(i.common.members.includes(e)){let t=x.clone(i);t.common.members[t.common.members.indexOf(e)]=n._id,await this.props.socket.setObject(t._id,t)}}}catch(e){window.alert(`Cannot delete user: ${e}`)}if(i)try{await this.props.socket.changePassword(n._id,i)}catch(e){window.alert(`Cannot change password: ${e}`)}this.setState({userEditDialog:!1},()=>this.updateData())}),_(this,`saveGroup`,async e=>{if(typeof this.state.groupEditDialog==`object`){if(await this.props.socket.setObject(this.state.groupEditDialog._id,this.state.groupEditDialog),e&&e!==this.state.groupEditDialog._id)try{await this.props.socket.delObject(e)}catch(e){window.alert(`Cannot delete user: ${e}`)}this.setState({groupEditDialog:!1},()=>this.updateData())}}),_(this,`showUserDeleteDialog`,e=>this.setState({userDeleteDialog:e})),_(this,`showGroupDeleteDialog`,e=>this.setState({groupDeleteDialog:e})),_(this,`deleteUser`,e=>{this.props.socket.delObject(e).then(()=>Promise.all((this.state.groups||[]).map(t=>{if(t.common.members.includes(e)){let n=x.clone(t);return n.common.members.splice(n.common.members.indexOf(e),1),this.props.socket.setObject(n._id,n)}return Promise.resolve(null)}))).catch(e=>window.alert(`Cannot delete user: ${e}`)).then(()=>{this.setState({userDeleteDialog:!1},()=>this.updateData())})}),_(this,`deleteGroup`,e=>this.props.socket.delObject(e).then(()=>this.setState({groupDeleteDialog:!1},()=>this.updateData())).catch(e=>window.alert(`Cannot delete user: ${e}`))),_(this,`addUserToGroup`,(e,t)=>{var n;let r=(n=this.state.groups)==null?void 0:n.find(e=>e._id===t),i=(r==null?void 0:r.common.members)||[];r&&!i.includes(e)&&(i.push(e),this.props.socket.setObject(r._id,r).then(()=>this.updateData()).catch(e=>window.alert(`Cannot delete user: ${e}`)))}),_(this,`removeUserFromGroup`,(e,t)=>{var n;let r=(n=this.state.groups)==null?void 0:n.find(e=>e._id===t),i=(r==null?void 0:r.common.members)||[];r&&i.includes(e)&&(i.splice(i.indexOf(e),1),this.props.socket.setObject(r._id,r).then(()=>this.updateData()))}),this.state={users:null,groups:null,userEditDialog:!1,userEditDialogNew:!1,groupEditDialog:!1,groupEditDialogNew:!1,userDeleteDialog:!1,groupDeleteDialog:!1,innerWidth:0}}componentDidMount(){this.setState({innerWidth:window.innerWidth},()=>this.updateData())}componentDidUpdate(){window.innerWidth!==this.state.innerWidth&&setTimeout(()=>this.setState({innerWidth:window.innerWidth}),100)}static _isUniqueName(e,t,n){return!e.find(e=>e._id===`system.user.${t.toLowerCase()}_${n}`||e.common.name===`${t} ${n}`)}static findNewUniqueName(t,n,r){let i=1;for(;!e._isUniqueName(n,r,i);)i++;return{_id:`system.${t?`group`:`user`}.${r.toLowerCase()}_${i}`,name:`${r} ${i}`}}render(){return!this.state.users||!this.state.groups?i(te,{}):v(z,{backend:L.isTouchDevice()?oe:B,children:[i(be,{}),i(E,{component:`div`,sx:$.descriptionPanel,children:this.props.t(`You can drag users to groups.`)}),v(b,{container:!0,spacing:2,style:$.mainGridCont,children:[v(b,{size:{xs:12,md:6},style:{...$.childGridCont,...this.state.innerWidth>600?$.childGridContWide:void 0},children:[v(`div`,{style:$.headContainer,children:[i(m,{size:`small`,style:$.right,onClick:()=>{let{_id:t,name:n}=e.findNewUniqueName(!0,this.state.groups||[],this.props.t(`Group`)),r=x.clone(Se);r._id=t,r.common.name=n,this.showGroupEditDialog(r,!0)},children:i(se,{})}),i(O,{gutterBottom:!0,variant:`h4`,component:`h4`,children:this.props.t(`Groups`)})]}),i(`div`,{style:$.blocksContainer,children:this.state.groups.sort((e,t)=>{var n,r;let i=(this.getText(e==null||(n=e.common)==null?void 0:n.name)||e._id).toLowerCase(),a=(this.getText(t==null||(r=t.common)==null?void 0:r.name)||t._id).toLowerCase();return i>a?1:i<a?-1:0}).map(e=>i(fe,{group:e,users:this.state.users||[],showGroupEditDialog:this.showGroupEditDialog,showGroupDeleteDialog:this.showGroupDeleteDialog,removeUserFromGroup:this.removeUserFromGroup,getText:this.getText,styles:$,...this.props},e._id))})]}),v(b,{size:{xs:12,md:6},style:{...$.childGridCont,...this.state.innerWidth>600?$.childGridContWide:void 0},children:[v(`div`,{style:$.headContainer,children:[i(m,{size:`small`,style:$.right,onClick:()=>{let{_id:t,name:n}=e.findNewUniqueName(!1,this.state.users||[],this.props.t(`User`)),r=x.clone(xe);r._id=t,r.common.name=n,this.showUserEditDialog(r,!0)},children:i(ce,{})}),i(O,{gutterBottom:!0,variant:`h4`,component:`h4`,children:this.props.t(`Users`)})]}),i(`div`,{style:$.blocksContainer,children:this.state.users.sort((e,t)=>{var n,r;let i=(this.getText(e==null||(n=e.common)==null?void 0:n.name)||e._id).toLowerCase(),a=(this.getText(t==null||(r=t.common)==null?void 0:r.name)||t._id).toLowerCase();return i>a?1:i<a?-1:0}).map(e=>i(ue,{user:e,groups:this.state.groups||[],showUserEditDialog:this.showUserEditDialog,showUserDeleteDialog:this.showUserDeleteDialog,updateData:this.updateData,addUserToGroup:this.addUserToGroup,removeUserFromGroup:this.removeUserFromGroup,getText:this.getText,styles:$,...this.props},e._id))})]})]}),this.state.userEditDialog?i(me,{onClose:()=>this.setState({userEditDialog:!1}),users:this.state.users,user:this.state.userEditDialog,isNew:this.state.userEditDialogNew,t:this.props.t,getText:this.getText,styles:$,onChange:this.changeUserFormData,saveData:this.saveUser,innerWidth:this.state.innerWidth}):null,this.state.groupEditDialog?i(Z,{onClose:()=>this.setState({groupEditDialog:!1}),groups:this.state.groups,group:this.state.groupEditDialog,isNew:this.state.groupEditDialogNew,t:this.props.t,getText:this.getText,styles:$,onChange:this.changeGroupFormData,innerWidth:this.state.innerWidth,saveData:this.saveGroup}):null,this.state.userDeleteDialog?i(_e,{getText:this.getText,onClose:()=>this.setState({userDeleteDialog:!1}),user:this.state.userDeleteDialog,t:this.props.t,deleteUser:this.deleteUser}):null,this.state.groupDeleteDialog?i(ve,{getText:this.getText,onClose:()=>this.setState({groupDeleteDialog:!1}),group:this.state.groupDeleteDialog,t:this.props.t,styles:$,deleteGroup:this.deleteGroup}):null]})}};function we(e){return i(c,{children:i(h,{style:{display:`flex`,flexDirection:`column`,overflow:`auto`},children:i(Ce,{t:e.t,lang:e.lang,socket:e.socket,ready:e.ready,expertMode:e.expertMode,themeType:e.themeType,theme:e.theme})})})}export{we as default};
1
+ import{Ao as e,Co as t,Es as n,Ha as r,Hs as i,Ka as a,Kn as o,Ko as s,Lr as c,Mo as l,No as u,Po as d,Qa as f,Qi as p,Ro as m,Rr as h,To as g,Ts as _,Us as v,Vo as ee,Wa as y,Wo as b,Wr as x,Xo as te,ba as S,bi as C,br as w,fc as ne,ga as T,go as E,jo as D,mo as O,qn as k,sc as re,so as A,tc as j,xa as M,xo as N,xr as P,yo as F}from"./loadShare-eager-dmdYQhAl.js";import{o as I,t as L}from"./AdminUtils-Dc1eHsx5.js";import{Ct as ie,Et as R,Ot as z,St as B,wt as ae,xt as oe}from"./bootstrap-BQ4OzwbT.js";import{t as V}from"./VpnKey-BbZdswcd.js";import{n as H,r as U,t as W}from"./Fields-DN41WFbp.js";import{n as G,r as K,t as q}from"./ColorLens-DA51K29x.js";import{n as se,r as ce,t as le}from"./PersonOff-DqBq0Fho.js";var J=e=>{let n=+!e.isDragging,a=x.getInvertedColor(e.user.common.color,e.themeType,!0),c={cursor:`grab`,opacity:n,overflow:`hidden`,color:a};return e.user.common.color&&(c.backgroundColor=e.user.common.color),i(N,{style:c,sx:e.styles.userGroupCard2,children:v(`div`,{style:e.styles.userCardContent,children:[v(`div`,{style:e.styles.right,children:[i(g,{checked:e.user.common.enabled,style:{color:a},disabled:e.user.common.dontDelete,onChange:()=>{e.socket.extendObject(e.user._id,{common:{enabled:!e.user.common.enabled}}).then(()=>e.updateData())}}),i(s,{size:`small`,onClick:()=>e.showUserEditDialog(e.user,!1),children:i(S,{style:{color:a}})}),i(s,{size:`small`,onClick:()=>e.showUserDeleteDialog(e.user),disabled:e.user.common.dontDelete,children:i(r,{style:e.user.common.dontDelete?void 0:{color:a}})})]}),v(t,{children:[v(O,{gutterBottom:!0,component:`div`,style:e.styles.userGroupTitle,children:[e.user.common.icon?i(w,{style:e.styles.icon,src:e.user.common.icon}):i(k,{style:e.styles.icon}),v(`div`,{children:[v(`div`,{children:[i(`span`,{style:e.styles.userGroupUserName,children:e.getText(e.user.common.name)}),v(`span`,{style:e.styles.userGroupUserID,children:[`[`,e.user._id,`]`]})]}),i(`span`,{children:e.user.common.desc?i(`div`,{style:e.styles.description,children:e.getText(e.user.common.desc)}):null})]})]}),e.groups.find(t=>t.common.members&&t.common.members.includes(e.user._id))?v(`div`,{children:[e.t(`In groups`),`:`]}):null,i(`div`,{children:e.groups.map(t=>{var n,r;if(!t.common.members||!t.common.members.includes(e.user._id))return null;let c=t&&(n=t.common)!=null&&n.color?x.getInvertedColor(t.common.color,e.themeType,!0):a;return v(N,{variant:`outlined`,sx:e.styles.userGroupMember,style:{color:c,borderColor:`${c}80`,background:((r=t.common)==null?void 0:r.color)||`inherit`},children:[t.common.icon?i(w,{style:e.styles.icon,src:t.common.icon}):i(o,{style:e.styles.icon}),e.getText(t.common.name),i(s,{size:`small`,onClick:()=>e.removeUserFromGroup(e.user._id,t._id),children:i(p,{style:{color:c}})})]},t._id)})})]})]})})},ue=e=>{let t=ne(null),[{isDragging:n},r,a]=R({type:`user`,item:()=>{var n;return{userId:e.user._id,preview:i(`div`,{style:{width:(n=t.current)==null?void 0:n.offsetWidth},children:i(J,{...e})})}},end:(t,n)=>{let r=n.getDropResult();if(t&&r){var i;(i=e.addUserToGroup)==null||i.call(e,t.userId,r.groupId)}},collect:e=>({isDragging:e.isDragging(),handlerId:e.getHandlerId()})});return re(()=>{a(ie(),{captureDraggingState:!0})},[a]),i(`div`,{ref:e=>{r(e)},children:i(`div`,{ref:t,children:i(J,{isDragging:n,...e})})})};function de(e,t){return!t.group.common.members||!t.group.common.members.includes(e.getItem().userId)}var fe=e=>{var n;let[{CanDrop:a,isOver:c},l]=ae(()=>({accept:`user`,drop:()=>({groupId:e.group._id}),canDrop:(t,n)=>de(n,e),collect:e=>({isOver:e.isOver(),CanDrop:e.canDrop()})}),[e.group.common.members]),u=.7,d;a&&c?(u=a?1:.125,d=e.styles.userGroupCardSecondary):a&&(u=a?.75:.25);let f=x.getInvertedColor(e.group.common.color,e.themeType,!0),m={opacity:u,overflow:`hidden`,color:f};return e.group.common.color&&(m.backgroundColor=e.group.common.color),v(N,{style:m,ref:e=>{l(e)},sx:x.getStyle(e.theme,e.styles.userGroupCard2,d),children:[v(`div`,{style:e.styles.right,children:[i(s,{size:`small`,onClick:()=>e.showGroupEditDialog(e.group,!1),children:i(S,{style:{color:f}})}),i(s,{size:`small`,onClick:()=>e.showGroupDeleteDialog(e.group),disabled:e.group.common.dontDelete,children:i(r,{style:e.group.common.dontDelete?void 0:{color:f}})})]}),v(t,{children:[v(O,{gutterBottom:!0,component:`div`,style:e.styles.userGroupTitle,children:[e.group.common.icon?i(w,{style:e.styles.icon,src:e.group.common.icon}):i(o,{style:e.styles.icon}),v(`div`,{children:[v(`div`,{children:[i(`span`,{style:e.styles.userGroupUserName,children:e.getText(e.group.common.name)}),v(`span`,{children:[`[`,e.group._id,`]`]})]}),e.group.common.desc?i(`div`,{style:e.styles.description,children:e.getText(e.group.common.desc)}):null]})]}),(n=e.group.common.members)!=null&&n.length?v(`div`,{children:[e.t(`Group members`),`:`]}):null,i(`div`,{children:(e.group.common.members||[]).map((t,n)=>{var r,a;let o=e.users.find(e=>e._id===t),c=o&&(r=o.common)!=null&&r.color?x.getInvertedColor(o.common.color,e.themeType,!0):f;return o?v(N,{variant:`outlined`,sx:e.styles.userGroupMember,style:{color:c,borderColor:`${c}40`,background:((a=o.common)==null?void 0:a.color)||`inherit`},children:[o.common.icon?i(w,{style:e.styles.icon,src:o.common.icon}):i(k,{style:e.styles.icon}),e.getText(o.common.name),i(s,{size:`small`,onClick:()=>e.removeUserFromGroup(t,e.group._id),children:i(p,{style:{color:c}})})]},n):null})})]})]})},Y=[new URL(`user1-D1GAYfim.svg`,import.meta.url).href,new URL(`user2-kVvfO6hI.svg`,import.meta.url).href,new URL(`user3-B1MPu8jB.svg`,import.meta.url).href,new URL(`user4-DmVDIOoi.svg`,import.meta.url).href,new URL(`user5-DwFpzcW1.svg`,import.meta.url).href,new URL(`user6-DHgFm0fc.svg`,import.meta.url).href,new URL(`user7-DkJFgUmb.svg`,import.meta.url).href,new URL(`user8-BZA6Afc4.svg`,import.meta.url).href,new URL(`user9-BLdaSIG0.svg`,import.meta.url).href,new URL(`user10-DvWuZ_uc.svg`,import.meta.url).href,new URL(`user11-Ch5DvO34.svg`,import.meta.url).href,new URL(`user12-DEiNnJWd.svg`,import.meta.url).href],pe={contentRoot:{padding:`16px 24px`}},me=class extends j{constructor(e){super(e),this.state={originalId:e.user._id,passwordRepeat:e.user.common.password,originalData:JSON.stringify(e.user)}}componentDidMount(){if(this.props.isNew){let e=Y[Math.round(Math.random()*(Y.length-1))];e&&x.getSvg(e).then(e=>{let t=x.clone(this.props.user);t.common.icon=e,this.props.onChange(t)})}}render(){let t=this.props.users.find(e=>e._id===this.props.user._id),n=this.props.user._id!==this.state.originalId,r=e=>e.split(`.`).pop()||``,o=e=>e.replace(x.FORBIDDEN_CHARS,`_`).replace(/\s/g,`_`).replace(/\./g,`_`).replace(/,/g,`_`).replace(/__/g,`_`).replace(/__/g,`_`).toLowerCase(),s=(e,t)=>{let n=e.split(`.`);return n[n.length-1]=t,n.join(`.`)},c=this.props.getText(this.props.user.common.desc),u=this.props.getText(this.props.user.common.name),f=L.checkPassword(this.props.user.common.password),p=L.checkPassword(this.props.user.common.password,this.state.passwordRepeat),m=this.props.isNew||JSON.stringify(this.props.user)!==this.state.originalData,h=this.props.user._id!==`system.user.`&&!f&&!p&&m;return(this.props.isNew&&t||t&&n)&&(h=!1),v(e,{fullWidth:this.props.innerWidth<500,open:!0,onClose:(e,t)=>{t!==`backdropClick`&&t!==`escapeKeyDown`&&this.props.onClose()},children:[i(d,{style:{...this.props.styles.dialogTitle,padding:12},children:this.props.t(`User parameters`)}),v(l,{sx:{"&.MuiDialogContent-root":{...this.props.innerWidth<500?this.props.styles.narrowContent:void 0,...pe.contentRoot}},children:[v(b,{container:!0,spacing:this.props.innerWidth<500?1:4,style:this.props.styles.dialog,children:[i(b,{size:{xs:12,md:6},children:i(H,{label:`Name`,t:this.props.t,value:u,onChange:e=>{let t=x.clone(this.props.user);!this.props.user.common.dontDelete&&o(this.props.getText(t.common.name))===r(t._id)&&(t._id=s(t._id,o(e))),t.common.name=e,this.props.onChange(t)},autoComplete:`new-password`,icon:C,styles:this.props.styles})}),i(b,{size:{xs:12,md:6},children:i(H,{label:`ID edit`,t:this.props.t,disabled:this.props.user.common.dontDelete,value:this.props.user._id.split(`.`)[this.props.user._id.split(`.`).length-1],onChange:e=>{let t=x.clone(this.props.user);t._id=s(t._id,o(e)),this.props.onChange(t)},icon:K,styles:this.props.styles})}),i(b,{size:{xs:12,md:6},children:i(H,{label:`ID preview`,t:this.props.t,disabled:!0,value:this.props.user._id,icon:G,styles:this.props.styles})}),i(b,{size:{xs:12,md:6},children:i(H,{label:`Description`,t:this.props.t,value:c,onChange:e=>{let t=x.clone(this.props.user);t.common.desc=e,this.props.onChange(t)},icon:M,styles:this.props.styles})}),i(b,{size:{xs:12,md:6},children:i(H,{label:`Password`,t:this.props.t,value:this.props.user.common.password,error:f?this.props.t(f):void 0,onChange:e=>{let t=x.clone(this.props.user);t.common.password=e,this.props.onChange(t)},type:`password`,autoComplete:`new-password`,icon:V,styles:this.props.styles})}),i(b,{size:{xs:12,md:6},children:i(H,{label:`Password repeat`,t:this.props.t,value:this.state.passwordRepeat,error:p?this.props.t(p):void 0,onChange:e=>this.setState({passwordRepeat:e}),type:`password`,autoComplete:`new-password`,icon:V,styles:this.props.styles})}),i(b,{size:{xs:12,md:6},children:i(P,{icons:Y,label:`Icon`,value:this.props.user.common.icon,onChange:e=>{let t=x.clone(this.props.user);t.common.icon=e,this.props.onChange(t)},previewStyle:this.props.styles.iconPreview,icon:T})}),i(b,{size:{xs:12,md:6},children:i(W,{label:`Color`,t:this.props.t,value:this.props.user.common.color||``,previewStyle:this.props.styles.iconPreview,onChange:e=>{let t=x.clone(this.props.user);t.common.color=e,this.props.onChange(t)},icon:q,style:this.props.styles.colorPicker,styles:this.props.styles})})]}),this.props.isNew?null:this.renderOidcButton()]}),v(D,{children:[i(F,{variant:`contained`,color:`primary`,autoFocus:!0,onClick:()=>this.props.saveData(this.props.isNew?null:this.state.originalId),disabled:!h,startIcon:i(y,{}),children:this.props.t(`Save`)}),i(F,{variant:`contained`,color:`grey`,onClick:this.props.onClose,startIcon:i(a,{}),children:this.props.t(`Cancel`)})]})]})}renderOidcButton(){var e;return window.ssoActive===`true`?(e=this.props.user.common)!=null&&(e=e.externalAuthentication)!=null&&e.oidc?i(F,{variant:`contained`,color:`secondary`,fullWidth:!0,startIcon:i(le,{}),sx:{marginTop:2},onClick:async()=>{var e;(e=this.props.user.common.externalAuthentication)==null||delete e.oidc,await this.props.saveData(this.state.originalId),window.alert(`Single-Sign On disconnected!`)},children:this.props.t(`Disconnect Single-Sign On`)}):i(F,{variant:`contained`,color:`secondary`,fullWidth:!0,onClick:()=>{window.location.href=I(`sso?redirectUrl=${encodeURIComponent(`${window.origin}${I(`#tab-users`)}`)}&method=register&user=${encodeURIComponent((this.state.originalId||this.props.user._id).replace(/^system\.user\./,``))}`)},startIcon:i(k,{}),sx:{marginTop:2},children:this.props.t(`Add Single-Sign On`)}):null}},X=[new URL(`group1-CmFsZszo.svg`,import.meta.url).href,new URL(`group2-CuvSswwx.svg`,import.meta.url).href,new URL(`group3-CRAMNPrf.svg`,import.meta.url).href,new URL(`group4-D4IM6-jV.svg`,import.meta.url).href,new URL(`group5-T3CGkJFm.svg`,import.meta.url).href,new URL(`group6-CLVorg7G.svg`,import.meta.url).href,new URL(`group7-D-h4KR6w.svg`,import.meta.url).href,new URL(`group8-BXzJmR7Y.svg`,import.meta.url).href,`data:image/svg+xml,%3csvg%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20461.367%20461.367'%3e%3cpath%20style='fill:%231EA6C6;'%20d='M373.88,367.988c0,0.037,0,0.075,0,0.122c-37.818,34.295-88.019,55.185-143.083,55.185%20c-55.073,0-105.275-20.89-143.092-55.185c0-0.047,0-0.084,0-0.122c0-57.04,33.377-106.277,81.659-129.256%20c18.145,18.098,39.391,27.85,61.434,27.85c22.052,0,43.288-9.752,61.443-27.85C340.521,261.711,373.88,310.947,373.88,367.988z%20'/%3e%3cpath%20style='fill:%23FCD09F;'%20d='M230.797,58.571c43.71,0,79.148,35.429,79.148,79.139c0,43.719-35.438,103.504-79.148,103.504%20s-79.148-59.785-79.148-103.504C151.649,94,187.087,58.571,230.797,58.571z'/%3e%3cpath%20style='fill:%23EF806F;'%20d='M164.094,213.389c2.426,3.457,4.937,6.698,7.532,9.742l-7.897,3.756%20c-26.286,12.506-48.525,32.075-64.328,56.59c-12.853,19.944-20.909,42.427-23.71,65.865%20c-28.562-7.785-54.38-22.22-75.691-41.546v-0.103c0-49.705,29.087-92.609,71.157-112.638%20c15.813,15.775,34.323,24.272,53.527,24.272c12.581,0,24.871-3.644,36.291-10.595%20C161.977,210.307,163.026,211.862,164.094,213.389z'/%3e%3cpath%20style='fill:%23EFC59C;'%20d='M138.539,137.707c0,16.431,4.272,34.511,11.878,51.504c-7.953,5.04-16.637,8.009-25.733,8.009%20c-38.089,0-68.965-52.094-68.965-90.193c0-38.089,30.876-68.956,68.965-68.956c21.124,0,40.038,9.499,52.684,24.459%20C153.883,79.28,138.539,106.737,138.539,137.707z'/%3e%3cpath%20style='fill:%23EF806F;'%20d='M297.273,213.389c-2.426,3.457-4.937,6.698-7.532,9.742l7.897,3.756%20c26.286,12.506,48.525,32.075,64.328,56.59c12.853,19.944,20.909,42.427,23.71,65.865c28.562-7.785,54.38-22.22,75.691-41.546%20v-0.103c0-49.705-29.087-92.609-71.157-112.638c-15.813,15.775-34.323,24.272-53.527,24.272%20c-12.581,0-24.871-3.644-36.291-10.595C299.39,210.307,298.341,211.862,297.273,213.389z'/%3e%3cpath%20style='fill:%23EFC59C;'%20d='M322.828,137.707c0,16.431-4.272,34.511-11.878,51.504c7.953,5.04,16.637,8.009,25.733,8.009%20c38.089,0,68.965-52.094,68.965-90.193c0-38.089-30.876-68.956-68.965-68.956c-21.124,0-40.038,9.499-52.684,24.459%20C307.484,79.28,322.828,106.737,322.828,137.707z'/%3e%3c/svg%3e`,new URL(`group10-Dp9tRs6I.svg`,import.meta.url).href];function he(e){let t=(e,t)=>Object.values(e).map((n,r)=>{let i=Object.keys(e)[r];return t(n,i)}),n=e.group.common.acl||{},r=e=>e,a={...n,object:{read:!0,list:!0,write:!0,delete:!1,create:!1,...r(n.object)},state:{read:!0,list:!0,write:!0,delete:!1,create:!1,...r(n.state)},users:{read:!1,list:!1,write:!1,delete:!1,create:!1,...r(n.users)},other:{http:!1,execute:!1,sendto:!0,...r(n.other)},file:{read:!0,list:!0,write:!1,delete:!1,create:!1,...r(n.file)}};return i(b,{container:!0,spacing:e.innerWidth<500?1:4,style:e.styles.dialog,children:t(a,(n,r)=>v(b,{size:{xs:12,md:12},children:[i(E,{component:`h2`,sx:e.styles.permHeaders,children:e.t(`group_acl_${r}`)}),t(n,(t,n)=>i(ee,{control:i(g,{disabled:e.group._id===`system.group.administrator`,checked:t,onChange:t=>{let i=x.clone(e.group);i.common.acl=x.clone(a),i.common.acl[r][n]=t.target.checked,e.onChange(i)}}),label:e.t(`group_acl_${n}`),labelPlacement:`top`},n))]},r))},`PermissionsTab`)}var ge={contentRoot:{padding:`16px 24px`}},Z=class extends j{constructor(e){super(e),this.state={tab:0,originalId:e.group._id,originalData:JSON.stringify(e.group)}}componentDidMount(){if(this.props.isNew){let e=X[Math.round(Math.random()*(X.length-1))];e&&x.getSvg(e).then(e=>{let t=x.clone(this.props.group);t.common.icon=e,this.props.onChange(t)})}}render(){let t=this.props.groups.find(e=>e._id===this.props.group._id),n=this.props.group._id!==this.state.originalId,r=this.props.isNew||JSON.stringify(this.props.group)!==this.state.originalData,o=this.props.group._id!==`system.group.`&&this.props.group.common.password===this.props.group.common.passwordRepeat&&r,s=e=>e.split(`.`).pop()||``,c=e=>e.replace(x.FORBIDDEN_CHARS,`_`).replace(/\s/g,`_`).replace(/\./g,`_`).toLowerCase(),u=(e,t)=>{let n=e.split(`.`);return n[n.length-1]=t,n.join(`.`)};this.props.isNew?t&&(o=!1):t&&n&&(o=!1);let p=this.props.getText(this.props.group.common.desc),m=this.props.getText(this.props.group.common.name),h=[v(b,{container:!0,spacing:this.props.innerWidth<500?1:4,style:this.props.styles.dialog,children:[i(b,{size:{xs:12,md:6},children:i(H,{label:`Name`,t:this.props.t,value:m,onChange:e=>{let t=x.clone(this.props.group);!this.props.group.common.dontDelete&&c(this.props.getText(t.common.name))===s(t._id)&&(t._id=u(t._id,c(e))),t.common.name=e,this.props.onChange(t)},autoComplete:`off`,icon:C,styles:this.props.styles})}),i(b,{size:{xs:12,md:6},children:i(H,{label:`ID edit`,t:this.props.t,disabled:this.props.group.common.dontDelete,value:this.props.group._id.split(`.`)[this.props.group._id.split(`.`).length-1],onChange:e=>{let t=x.clone(this.props.group);t._id=u(t._id,c(e)),this.props.onChange(t)},icon:K,styles:this.props.styles})}),i(b,{size:{xs:12,md:6},children:i(H,{label:`ID preview`,t:this.props.t,disabled:!0,value:this.props.group._id,icon:G,styles:this.props.styles})}),i(b,{size:{xs:12,md:6},children:i(H,{label:`Description`,t:this.props.t,value:p,onChange:e=>{let t=x.clone(this.props.group);t.common.desc=e,this.props.onChange(t)},icon:M,styles:this.props.styles})}),i(b,{size:{xs:12,md:6},children:i(P,{label:`Icon`,icons:X,value:this.props.group.common.icon,onChange:e=>{let t=x.clone(this.props.group);t.common.icon=e,this.props.onChange(t)},previewStyle:this.props.styles.iconPreview,icon:T})}),i(b,{size:{xs:12,md:6},children:i(W,{label:`Color`,t:this.props.t,value:this.props.group.common.color||``,previewStyle:this.props.styles.iconPreview,onChange:e=>{let t=x.clone(this.props.group);t.common.color=e,this.props.onChange(t)},icon:q,style:this.props.styles.colorPicker,styles:this.props.styles})})]}),he(this.props)][this.state.tab];return v(e,{open:!0,onClose:(e,t)=>{t!==`backdropClick`&&t!==`escapeKeyDown`&&this.props.onClose()},fullWidth:this.props.innerWidth<500,children:[i(d,{style:this.props.styles.dialogTitle,children:v(A,{variant:`fullWidth`,value:this.state.tab,onChange:(e,t)=>this.setState({tab:t}),children:[i(f,{label:this.props.t(`Main`),value:0}),i(f,{label:this.props.t(`Permissions`),value:1})]})}),i(l,{sx:{"&.MuiDialogContent-root":{...this.props.innerWidth<500?this.props.styles.narrowContent:void 0,...ge.contentRoot}},children:h}),v(D,{style:this.props.styles.dialogActions,children:[i(F,{variant:`contained`,color:`primary`,autoFocus:!0,onClick:()=>this.props.saveData(this.props.isNew?null:this.state.originalId),disabled:!o,startIcon:i(y,{}),children:this.props.t(`Save`)}),i(F,{variant:`contained`,color:`grey`,onClick:this.props.onClose,startIcon:i(a,{}),children:this.props.t(`Cancel`)})]})]})}};function _e(t){return v(e,{open:!0,onClose:t.onClose,children:[i(d,{children:t.t(`Please confirm`)}),i(l,{children:i(u,{children:t.t(`Do you want to delete user %s?`,t.getText(t.user.common.name))})}),v(D,{children:[i(F,{variant:`contained`,color:`primary`,onClick:()=>t.deleteUser(t.user._id),startIcon:i(r,{}),children:t.t(`Delete`)}),i(F,{variant:`contained`,color:`grey`,autoFocus:!0,onClick:t.onClose,startIcon:i(a,{}),children:t.t(`Cancel`)})]})]})}function ve(t){return v(e,{open:!0,onClose:t.onClose,children:[i(d,{children:t.t(`Please confirm`)}),i(l,{children:i(u,{children:t.t(`Do you want to delete group %s?`,t.getText(t.group.common.name))})}),v(D,{style:t.styles.dialogActions,children:[i(F,{variant:`contained`,color:`primary`,onClick:()=>t.deleteGroup(t.group._id),startIcon:i(r,{}),children:t.t(`Delete`)}),i(F,{variant:`contained`,color:`grey`,autoFocus:!0,onClick:t.onClose,startIcon:i(a,{}),children:t.t(`Cancel`)})]})]})}n();var Q=`***********`,ye=`0 1px 1px 0 rgba(0, 0, 0, .4),0 6px 6px 0 rgba(0, 0, 0, .2)`,$={mainGridCont:{height:`calc(100% - 55px)`,overflowY:`auto`},childGridCont:{display:`flex`,flexDirection:`column`},childGridContWide:{height:`100%`},canDrop:e=>({backgroundColor:e.palette.background.default}),headContainer:{margin:10},blocksContainer:{overflowY:`auto`,overflowX:`hidden`},userGroupCard2:e=>({border:`1px solid #FFF`,borderColor:e.palette.divider,m:`10px`,minHeight:150,backgroundColor:e.palette.background.default,color:e.palette.text.primary,transition:`all 200ms ease-out`,opacity:1,overflow:`hidden`,"&:hover":{overflowY:`auto`,boxShadow:ye}}),userGroupCardSecondary:e=>({color:e.palette.text.primary,backgroundColor:e.palette.success.light}),permHeaders:e=>({backgroundColor:e.palette.mode===`dark`?e.palette.background.default:e.palette.primary.main,p:`4px`,borderRadius:`2px`,color:`#EEE`}),userCardContent:{height:`100%`,opacity:1},userGroupTitle:{display:`inline-flex`,alignItems:`center`},userGroupUserName:{fontWeight:900,padding:5},userGroupUserID:{opacity:.7,padding:5},description:{fontSize:10,fontStyle:`italic`,marginLeft:5,opacity:.7},userGroupMember:e=>({display:`inline-flex`,m:`4px`,p:`4px`,backgroundColor:`#00000010`,border:`1px solid #FFF`,borderColor:e.palette.text.primary,color:e.palette.text.primary,alignItems:`center`}),icon:{height:32,width:32,marginRight:5,backgroundSize:`cover`,backgroundPosition:`center`},right:{float:`right`},left:{float:`left`,marginRight:10},dialog:{},flex:{display:`flex`},formControl:{display:`flex`,padding:24,flexGrow:1e3},formContainer:{display:`flex`,justifyContent:`center`,alignItems:`center`},formIcon:{margin:10,opacity:.6},descriptionPanel:e=>({width:`100%`,backgroundColor:`transparent`,mb:`20px`,mt:`20px`,ml:`20px`,opacity:.75,border:`none`,display:`flex`,alignItems:`center`,"& a":{pl:`3px`,color:e.palette.mode===`dark`?`#EEE`:`#111`}}),dialogTitle:{borderBottom:`1px solid #00000020`,padding:0,width:`100%`},dialogActions:{borderTop:`1px solid #00000020`,width:`100%`},dialogPaper:{overflowY:`initial`,display:`flex`,flexDirection:`column`,justifyContent:`center`,alignItems:`center`,width:`calc(100% - 100px)`,height:`calc(100% - 100px)`,maxWidth:800,maxHeight:`100%`},dialogPaperMini:{maxHeight:300},colorPicker:{},iconPreview:{height:40,width:40},mainDescription:{fontSize:`200%`},deleteDialog:{padding:20},narrowContent:{padding:`8px 8px 8px 8px`}},be=()=>{let e=U();return e.display?i(`div`,{style:e.style,children:e.item.preview}):null},xe={_id:`system.user.`,type:`user`,common:{name:``,password:``,enabled:!0,color:``,desc:``},native:{},enums:{}},Se={_id:``,native:{},type:`group`,common:{name:``,desc:``,members:[],dontDelete:!0,acl:{object:{list:!1,read:!1,write:!1,delete:!1,create:!1},state:{list:!1,read:!1,write:!1,create:!1,delete:!1},users:{list:!1,read:!1,write:!1,create:!1,delete:!1},other:{execute:!1,http:!1,sendto:!1},file:{list:!1,read:!1,write:!1,create:!1,delete:!1}},icon:``,color:``}},Ce=class e extends j{constructor(e){super(e),_(this,`getText`,e=>e&&(typeof e==`object`?e[this.props.lang]||e.en||``:e||``)||``),_(this,`showUserEditDialog`,(e,t)=>{e=x.clone(e),e.common.password=e.common.password?Q:``,this.setState({userEditDialog:e,userEditDialogNew:t})}),_(this,`showGroupEditDialog`,(e,t)=>{e=x.clone(e),this.setState({groupEditDialog:e,groupEditDialogNew:t})}),_(this,`updateData`,()=>{let e;return this.props.socket.getForeignObjects(`system.user.*`,`user`).then(t=>(e=Object.values(t).sort((e,t)=>e._id>t._id?1:-1),e.forEach(e=>{e.common&&e.common.description&&(e.common.desc||(e.common.desc=e.common.description),delete e.common.description)}),this.props.socket.getForeignObjects(`system.group.*`,`group`))).then(t=>{let n=Object.values(t).sort((e,t)=>e._id>t._id?1:-1);n.forEach(e=>{e.common&&e.common.description&&(e.common.desc||(e.common.desc=e.common.description),delete e.common.description)}),this.setState({groups:n,users:e})})}),_(this,`changeUserFormData`,e=>this.setState({userEditDialog:e})),_(this,`changeGroupFormData`,e=>this.setState({groupEditDialog:e})),_(this,`saveUser`,async e=>{var t;let n=x.clone(this.state.userEditDialog),r=(t=this.state.users)==null?void 0:t.find(e=>e._id===n._id),i=n.common.password&&n.common.password!==Q?n.common.password:``;if(r?n.common.password=r.common.password:n.common.password=``,await this.props.socket.setObject(n._id,n),typeof this.state.userEditDialog==`object`&&e&&e!==this.state.userEditDialog._id)try{await this.props.socket.delObject(e);let t=this.state.groups||[];for(let r=0;r<t.length;r++){let i=t[r];if(i.common.members.includes(e)){let t=x.clone(i);t.common.members[t.common.members.indexOf(e)]=n._id,await this.props.socket.setObject(t._id,t)}}}catch(e){window.alert(`Cannot delete user: ${e}`)}if(i)try{await this.props.socket.changePassword(n._id,i)}catch(e){window.alert(`Cannot change password: ${e}`)}this.setState({userEditDialog:!1},()=>this.updateData())}),_(this,`saveGroup`,async e=>{if(typeof this.state.groupEditDialog==`object`){if(await this.props.socket.setObject(this.state.groupEditDialog._id,this.state.groupEditDialog),e&&e!==this.state.groupEditDialog._id)try{await this.props.socket.delObject(e)}catch(e){window.alert(`Cannot delete user: ${e}`)}this.setState({groupEditDialog:!1},()=>this.updateData())}}),_(this,`showUserDeleteDialog`,e=>this.setState({userDeleteDialog:e})),_(this,`showGroupDeleteDialog`,e=>this.setState({groupDeleteDialog:e})),_(this,`deleteUser`,e=>{this.props.socket.delObject(e).then(()=>Promise.all((this.state.groups||[]).map(t=>{if(t.common.members.includes(e)){let n=x.clone(t);return n.common.members.splice(n.common.members.indexOf(e),1),this.props.socket.setObject(n._id,n)}return Promise.resolve(null)}))).catch(e=>window.alert(`Cannot delete user: ${e}`)).then(()=>{this.setState({userDeleteDialog:!1},()=>this.updateData())})}),_(this,`deleteGroup`,e=>this.props.socket.delObject(e).then(()=>this.setState({groupDeleteDialog:!1},()=>this.updateData())).catch(e=>window.alert(`Cannot delete user: ${e}`))),_(this,`addUserToGroup`,(e,t)=>{var n;let r=(n=this.state.groups)==null?void 0:n.find(e=>e._id===t),i=(r==null?void 0:r.common.members)||[];r&&!i.includes(e)&&(i.push(e),this.props.socket.setObject(r._id,r).then(()=>this.updateData()).catch(e=>window.alert(`Cannot delete user: ${e}`)))}),_(this,`removeUserFromGroup`,(e,t)=>{var n;let r=(n=this.state.groups)==null?void 0:n.find(e=>e._id===t),i=(r==null?void 0:r.common.members)||[];r&&i.includes(e)&&(i.splice(i.indexOf(e),1),this.props.socket.setObject(r._id,r).then(()=>this.updateData()))}),this.state={users:null,groups:null,userEditDialog:!1,userEditDialogNew:!1,groupEditDialog:!1,groupEditDialogNew:!1,userDeleteDialog:!1,groupDeleteDialog:!1,innerWidth:0}}componentDidMount(){this.setState({innerWidth:window.innerWidth},()=>this.updateData())}componentDidUpdate(){window.innerWidth!==this.state.innerWidth&&setTimeout(()=>this.setState({innerWidth:window.innerWidth}),100)}static _isUniqueName(e,t,n){return!e.find(e=>e._id===`system.user.${t.toLowerCase()}_${n}`||e.common.name===`${t} ${n}`)}static findNewUniqueName(t,n,r){let i=1;for(;!e._isUniqueName(n,r,i);)i++;return{_id:`system.${t?`group`:`user`}.${r.toLowerCase()}_${i}`,name:`${r} ${i}`}}render(){return!this.state.users||!this.state.groups?i(te,{}):v(z,{backend:L.isTouchDevice()?oe:B,children:[i(be,{}),i(E,{component:`div`,sx:$.descriptionPanel,children:this.props.t(`You can drag users to groups.`)}),v(b,{container:!0,spacing:2,style:$.mainGridCont,children:[v(b,{size:{xs:12,md:6},style:{...$.childGridCont,...this.state.innerWidth>600?$.childGridContWide:void 0},children:[v(`div`,{style:$.headContainer,children:[i(m,{size:`small`,style:$.right,onClick:()=>{let{_id:t,name:n}=e.findNewUniqueName(!0,this.state.groups||[],this.props.t(`Group`)),r=x.clone(Se);r._id=t,r.common.name=n,this.showGroupEditDialog(r,!0)},children:i(se,{})}),i(O,{gutterBottom:!0,variant:`h4`,component:`h4`,children:this.props.t(`Groups`)})]}),i(`div`,{style:$.blocksContainer,children:this.state.groups.sort((e,t)=>{var n,r;let i=(this.getText(e==null||(n=e.common)==null?void 0:n.name)||e._id).toLowerCase(),a=(this.getText(t==null||(r=t.common)==null?void 0:r.name)||t._id).toLowerCase();return i>a?1:i<a?-1:0}).map(e=>i(fe,{group:e,users:this.state.users||[],showGroupEditDialog:this.showGroupEditDialog,showGroupDeleteDialog:this.showGroupDeleteDialog,removeUserFromGroup:this.removeUserFromGroup,getText:this.getText,styles:$,...this.props},e._id))})]}),v(b,{size:{xs:12,md:6},style:{...$.childGridCont,...this.state.innerWidth>600?$.childGridContWide:void 0},children:[v(`div`,{style:$.headContainer,children:[i(m,{size:`small`,style:$.right,onClick:()=>{let{_id:t,name:n}=e.findNewUniqueName(!1,this.state.users||[],this.props.t(`User`)),r=x.clone(xe);r._id=t,r.common.name=n,this.showUserEditDialog(r,!0)},children:i(ce,{})}),i(O,{gutterBottom:!0,variant:`h4`,component:`h4`,children:this.props.t(`Users`)})]}),i(`div`,{style:$.blocksContainer,children:this.state.users.sort((e,t)=>{var n,r;let i=(this.getText(e==null||(n=e.common)==null?void 0:n.name)||e._id).toLowerCase(),a=(this.getText(t==null||(r=t.common)==null?void 0:r.name)||t._id).toLowerCase();return i>a?1:i<a?-1:0}).map(e=>i(ue,{user:e,groups:this.state.groups||[],showUserEditDialog:this.showUserEditDialog,showUserDeleteDialog:this.showUserDeleteDialog,updateData:this.updateData,addUserToGroup:this.addUserToGroup,removeUserFromGroup:this.removeUserFromGroup,getText:this.getText,styles:$,...this.props},e._id))})]})]}),this.state.userEditDialog?i(me,{onClose:()=>this.setState({userEditDialog:!1}),users:this.state.users,user:this.state.userEditDialog,isNew:this.state.userEditDialogNew,t:this.props.t,getText:this.getText,styles:$,onChange:this.changeUserFormData,saveData:this.saveUser,innerWidth:this.state.innerWidth}):null,this.state.groupEditDialog?i(Z,{onClose:()=>this.setState({groupEditDialog:!1}),groups:this.state.groups,group:this.state.groupEditDialog,isNew:this.state.groupEditDialogNew,t:this.props.t,getText:this.getText,styles:$,onChange:this.changeGroupFormData,innerWidth:this.state.innerWidth,saveData:this.saveGroup}):null,this.state.userDeleteDialog?i(_e,{getText:this.getText,onClose:()=>this.setState({userDeleteDialog:!1}),user:this.state.userDeleteDialog,t:this.props.t,deleteUser:this.deleteUser}):null,this.state.groupDeleteDialog?i(ve,{getText:this.getText,onClose:()=>this.setState({groupDeleteDialog:!1}),group:this.state.groupDeleteDialog,t:this.props.t,styles:$,deleteGroup:this.deleteGroup}):null]})}};function we(e){return i(c,{children:i(h,{style:{display:`flex`,flexDirection:`column`,overflow:`auto`},children:i(Ce,{t:e.t,lang:e.lang,socket:e.socket,ready:e.ready,expertMode:e.expertMode,themeType:e.themeType,theme:e.theme})})})}export{we as default};