iobroker.eos-admin 9.0.27 → 9.0.29

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 (180) hide show
  1. package/NEXOWATT_EOS_BUILD_INFO.json +10 -12
  2. package/README.md +17 -227
  3. package/adminWww/.vite/manifest.json +224 -233
  4. package/adminWww/NEXOWATT_EOS_FRONTEND_MANIFEST.json +13887 -13897
  5. package/adminWww/assets/{AdapterUpdateDialog-L3aqW3ID.js → AdapterUpdateDialog-DXp4Dgkx.js} +5 -5
  6. package/adminWww/assets/{Adapters-Db3kbmAj.js → Adapters-1AOp__74.js} +5 -5
  7. package/adminWww/assets/AddLink-0L0E-LsA.js +1 -0
  8. package/adminWww/assets/ColorLens-DA51K29x.js +1 -0
  9. package/adminWww/assets/ConfigManager-CGGXU4Jp.js +1 -0
  10. package/adminWww/assets/Enums-Bl4EngJF.js +92 -0
  11. package/adminWww/assets/Fields-zSEjRWOB.js +1 -0
  12. package/adminWww/assets/FileCopy-B16lEuur.js +1 -0
  13. package/adminWww/assets/Files-CnYmjEbu.js +1 -0
  14. package/adminWww/assets/{Hosts-DimiJ78g.js → Hosts-zFJyiuvd.js} +6 -6
  15. package/adminWww/assets/Instances-D10dnQY4.js +4 -0
  16. package/adminWww/assets/Intro-DxLBfGZ8.js +2 -0
  17. package/adminWww/assets/Lens-9lkeoWGk.js +1 -0
  18. package/adminWww/assets/LinearScale-Be5h2beh.js +1 -0
  19. package/adminWww/assets/{Logs-D9dqF5Ag.js → Logs-CAc6o-d_.js} +2 -2
  20. package/adminWww/assets/North-C2whbHM-.js +1 -0
  21. package/adminWww/assets/{Objects-oliB7_Se.js → Objects-I64lF3ZS.js} +4 -4
  22. package/adminWww/assets/Overview-BQ7HBH-7.js +3 -0
  23. package/adminWww/assets/PersonOff-DqBq0Fho.js +1 -0
  24. package/adminWww/assets/PlaylistAdd-O8k92YBd.js +1 -0
  25. package/adminWww/assets/State-DHLL8gAc.js +1 -0
  26. package/adminWww/assets/UsedResources-DlQ_XqoR.js +2 -0
  27. package/adminWww/assets/Users-CKHDvxG5.js +1 -0
  28. package/adminWww/assets/{bootstrap-BVw0diuj.js → bootstrap-CIDT4MeX.js} +25 -25
  29. package/adminWww/assets/date-fns-C1dqkno9.js +1 -0
  30. package/adminWww/assets/{hostInit-C_7OBoza.js → hostInit-Cvl4lPGh.js} +1 -1
  31. package/adminWww/assets/icons-material-ngdwOXrt.js +1 -0
  32. package/adminWww/assets/{index-DwDSxDMx.js → index-B9Tfj1YG.js} +2 -2
  33. package/adminWww/assets/{installSVGRenderer--VTzKbml.js → installSVGRenderer-COP6GC9p.js} +1 -1
  34. package/adminWww/assets/isSameWeek-Crh37s7U.js +1 -0
  35. package/adminWww/assets/isWithinInterval-Bo1WiDfq.js +1 -0
  36. package/adminWww/assets/locale-hLcz_Xh2.js +1 -0
  37. package/adminWww/assets/{mf-entry-bootstrap-0-6f3e4c6b.js → mf-entry-bootstrap-0-31191d2e.js} +2 -2
  38. package/adminWww/assets/sentry-DwQQLI7N.js +1 -0
  39. package/adminWww/assets/startOfWeek-DJph8SIW.js +1 -0
  40. package/adminWww/index.html +23 -23
  41. package/adminWww/mf-manifest.json +1 -1
  42. package/adminWww/mf-stats.json +1 -1
  43. package/adminWww/remoteEntry-eos-9.0.29.js +12 -0
  44. package/adminWww/remoteEntry.js +1 -1
  45. package/build/lib/eosTlsHttp.js +25 -0
  46. package/build/lib/eosTlsHttp.js.map +1 -1
  47. package/build/lib/eosTlsManager.js +317 -67
  48. package/build/lib/eosTlsManager.js.map +1 -1
  49. package/docs/DOKUMENTATION_9.0.27.md +7 -0
  50. package/docs/README.md +14 -0
  51. package/docs/UMSORTIERTE_DATEIEN.tsv +153 -0
  52. package/docs/reports/unified-9.0.14/PRUEFBERICHT.md +1 -1
  53. package/docs/reports/unified-9.0.16/PRUEFBERICHT.md +1 -1
  54. package/docs/reports/unified-9.0.17/PRUEFBERICHT.md +1 -1
  55. package/docs/reports/unified-9.0.18/PRUEFBERICHT.md +1 -1
  56. package/docs/reports/unified-9.0.21/PRUEFBERICHT.md +1 -1
  57. package/docs/reports/unified-9.0.22/PRUEFBERICHT.md +1 -1
  58. package/docs/reports/unified-9.0.28/PRUEFBERICHT.md +40 -0
  59. package/docs/reports/unified-9.0.28/PRUEFERGEBNISSE.json +112 -0
  60. package/docs/reports/unified-9.0.28/raw/INDEX.json +87 -0
  61. package/docs/reports/unified-9.0.28/raw/backend.log +5 -0
  62. package/docs/reports/unified-9.0.28/raw/frontend.log +151 -0
  63. package/docs/reports/unified-9.0.28/raw/installer.log +26 -0
  64. package/docs/reports/unified-9.0.28/raw/lint.log +5 -0
  65. package/docs/reports/unified-9.0.28/raw/modules.log +5 -0
  66. package/docs/reports/unified-9.0.28/raw/node22-tests-final.log +17060 -0
  67. package/docs/reports/unified-9.0.28/raw/node22-version.log +1 -0
  68. package/docs/reports/unified-9.0.28/raw/node24-tests-final.log +2845 -0
  69. package/docs/reports/unified-9.0.28/raw/node24-version.log +1 -0
  70. package/docs/reports/unified-9.0.28/raw/npm-audit-runtime.json +77 -0
  71. package/docs/reports/unified-9.0.28/raw/runtime-mirror-check.log +1 -0
  72. package/docs/reports/unified-9.0.28/raw/typecheck.log +5 -0
  73. package/docs/reports/unified-9.0.28/raw/ui-runtime.log +7 -0
  74. package/docs/reports/unified-9.0.29/PRUEFBERICHT.md +30 -0
  75. package/docs/reports/unified-9.0.29/PRUEFERGEBNISSE.json +112 -0
  76. package/docs/reports/unified-9.0.29/raw/INDEX.json +97 -0
  77. package/docs/reports/unified-9.0.29/raw/backend.log +5 -0
  78. package/docs/reports/unified-9.0.29/raw/frontend.log +151 -0
  79. package/docs/reports/unified-9.0.29/raw/installer.log +26 -0
  80. package/docs/reports/unified-9.0.29/raw/lint.log +5 -0
  81. package/docs/reports/unified-9.0.29/raw/modules.log +5 -0
  82. package/docs/reports/unified-9.0.29/raw/node22-tests-final.log +17104 -0
  83. package/docs/reports/unified-9.0.29/raw/node22-version.log +1 -0
  84. package/docs/reports/unified-9.0.29/raw/node24-tests-final.log +2852 -0
  85. package/docs/reports/unified-9.0.29/raw/node24-version.log +1 -0
  86. package/docs/reports/unified-9.0.29/raw/npm-audit-runtime.json +77 -0
  87. package/docs/reports/unified-9.0.29/raw/tls-lint.log +0 -0
  88. package/docs/reports/unified-9.0.29/raw/tls-targeted-build-node22.log +139 -0
  89. package/docs/reports/unified-9.0.29/raw/tls-targeted-node24.log +132 -0
  90. package/docs/reports/unified-9.0.29/raw/typecheck.log +5 -0
  91. package/docs/reports/unified-9.0.29/raw/ui-runtime.log +7 -0
  92. package/docs/reports/unified-9.0.4/PRUEFBERICHT.md +1 -1
  93. package/docs/reports/unified-9.0.5/PRUEFBERICHT.md +1 -1
  94. package/docs/reports/unified-9.0.6/PRUEFBERICHT.md +1 -1
  95. package/docs/reports/unified-9.0.7/PRUEFBERICHT.md +1 -1
  96. package/docs/reports/unified-9.0.8/PRUEFBERICHT.md +1 -1
  97. package/docs/reports/unified-9.0.9/PRUEFBERICHT.md +1 -1
  98. package/{START_HIER_9.0.1.md → docs/start/START_HIER_9.0.1.md} +5 -5
  99. package/{START_HIER_9.0.10.md → docs/start/START_HIER_9.0.10.md} +1 -1
  100. package/{START_HIER_9.0.11.md → docs/start/START_HIER_9.0.11.md} +1 -1
  101. package/{START_HIER_9.0.12.md → docs/start/START_HIER_9.0.12.md} +1 -1
  102. package/{START_HIER_9.0.13.md → docs/start/START_HIER_9.0.13.md} +2 -2
  103. package/{START_HIER_9.0.14.md → docs/start/START_HIER_9.0.14.md} +1 -1
  104. package/{START_HIER_9.0.15.md → docs/start/START_HIER_9.0.15.md} +2 -2
  105. package/{START_HIER_9.0.16.md → docs/start/START_HIER_9.0.16.md} +1 -1
  106. package/{START_HIER_9.0.17.md → docs/start/START_HIER_9.0.17.md} +2 -2
  107. package/{START_HIER_9.0.18.md → docs/start/START_HIER_9.0.18.md} +4 -4
  108. package/{START_HIER_9.0.19.md → docs/start/START_HIER_9.0.19.md} +2 -2
  109. package/{START_HIER_9.0.2.md → docs/start/START_HIER_9.0.2.md} +2 -2
  110. package/{START_HIER_9.0.20.md → docs/start/START_HIER_9.0.20.md} +1 -1
  111. package/{START_HIER_9.0.21.md → docs/start/START_HIER_9.0.21.md} +1 -1
  112. package/{START_HIER_9.0.22.md → docs/start/START_HIER_9.0.22.md} +4 -4
  113. package/{START_HIER_9.0.24.md → docs/start/START_HIER_9.0.24.md} +1 -1
  114. package/{START_HIER_9.0.25.md → docs/start/START_HIER_9.0.25.md} +1 -1
  115. package/{START_HIER_9.0.26.md → docs/start/START_HIER_9.0.26.md} +1 -1
  116. package/{START_HIER_9.0.27.md → docs/start/START_HIER_9.0.27.md} +3 -3
  117. package/docs/start/START_HIER_9.0.28.md +20 -0
  118. package/docs/start/START_HIER_9.0.29.md +22 -0
  119. package/{START_HIER_9.0.3.md → docs/start/START_HIER_9.0.3.md} +3 -3
  120. package/{START_HIER_9.0.4.md → docs/start/START_HIER_9.0.4.md} +3 -3
  121. package/{START_HIER_9.0.5.md → docs/start/START_HIER_9.0.5.md} +2 -2
  122. package/{START_HIER_9.0.6.md → docs/start/START_HIER_9.0.6.md} +3 -3
  123. package/{START_HIER_9.0.7.md → docs/start/START_HIER_9.0.7.md} +4 -4
  124. package/{START_HIER_9.0.8.md → docs/start/START_HIER_9.0.8.md} +3 -3
  125. package/{START_HIER_9.0.9.md → docs/start/START_HIER_9.0.9.md} +1 -1
  126. package/docs/unified/ARCHITECTURE.md +37 -1
  127. package/docs/unified/BESTANDSUEBERNAHME_9_0_7.md +1 -1
  128. package/docs/unified/INSTALL_PUBLISH.md +2 -2
  129. package/docs/unified/NEXOWATT_TLS_DE.md +18 -4
  130. package/io-package.json +12 -12
  131. package/package.json +38 -31
  132. package/public/eos-tls/index.html +96 -8
  133. package/public/eos-tls/index.js +194 -41
  134. package/release-manifests/unified/build-environment.cdx.json +6 -6
  135. package/release-manifests/unified/files.json +300 -136
  136. package/release-manifests/unified/frontend.cdx.json +6 -6
  137. package/release-manifests/unified/installer.cdx.json +6 -6
  138. package/release-manifests/unified/obsolete-admin-assets.json +214 -6
  139. package/release-manifests/unified/runtime.cdx.json +26 -26
  140. package/release-manifests/unified/validation.json +15 -15
  141. package/tools/eos-release-manifest.cjs +2 -2
  142. package/ui/io-package.json +9 -1
  143. package/ui/lib/smarthome-device-detection.js +177 -4
  144. package/ui/main.js +69 -5
  145. package/ui/package.json +1 -1
  146. package/ui/www/licenses/smarthome-markdown-components.json +156 -156
  147. package/ui/www/manifest.webmanifest +2 -2
  148. package/ui/www/smarthome-config-workspace.css +7 -0
  149. package/ui/www/smarthome-config.html +4 -4
  150. package/ui/www/smarthome-config.js +178 -163
  151. package/ui/www/smarthome-device-config.js +131 -6
  152. package/ui/www/smarthome-setup.js +252 -59
  153. package/adminWww/assets/AccessTime-CuR73YC3.js +0 -1
  154. package/adminWww/assets/ConfigManager-D33l1qlC.js +0 -1
  155. package/adminWww/assets/Enums-HlPEZ4AF.js +0 -92
  156. package/adminWww/assets/Fields-BWBgNDOp.js +0 -1
  157. package/adminWww/assets/Files-BYaJp3AG.js +0 -1
  158. package/adminWww/assets/Instances-C5kAjcqw.js +0 -4
  159. package/adminWww/assets/Intro-B8keS0Ph.js +0 -2
  160. package/adminWww/assets/KeyboardArrowRight-ifvmV1ZL.js +0 -1
  161. package/adminWww/assets/MoreHoriz-CS7nODK8.js +0 -1
  162. package/adminWww/assets/Overview-BmjcCFve.js +0 -3
  163. package/adminWww/assets/Pageview-wzrLQZ-j.js +0 -1
  164. package/adminWww/assets/PersonOff-YtHcY0sV.js +0 -1
  165. package/adminWww/assets/Star-D8VNXawT.js +0 -1
  166. package/adminWww/assets/State-DQz1O54D.js +0 -1
  167. package/adminWww/assets/UsedResources-DOAuH0-U.js +0 -2
  168. package/adminWww/assets/Users-Dv1iXiRk.js +0 -1
  169. package/adminWww/assets/ViewCompact-D7bHgn99.js +0 -1
  170. package/adminWww/assets/ViewSidebar-CjClbCI5.js +0 -1
  171. package/adminWww/assets/WifiTethering-DJ9VO12W.js +0 -1
  172. package/adminWww/assets/date-fns-BtR4dG_j.js +0 -1
  173. package/adminWww/assets/en-US-BjjaEI6N.js +0 -1
  174. package/adminWww/assets/icons-material-Apny8Mbp.js +0 -1
  175. package/adminWww/assets/isSameWeek-WMSJR5Qs.js +0 -1
  176. package/adminWww/assets/locale-DN6Bdkdt.js +0 -1
  177. package/adminWww/assets/sentry-CPzCHrwe.js +0 -1
  178. package/adminWww/assets/setYear-DDSuW45e.js +0 -1
  179. package/adminWww/remoteEntry-eos-9.0.27.js +0 -12
  180. /package/{START_HIER_9.0.23.md → docs/start/START_HIER_9.0.23.md} +0 -0
@@ -1,7 +1,7 @@
1
- import{$a as e,$o as t,$r as n,Aa as r,An as i,Ao as a,Bo as o,Ci as s,Co as c,Do as l,Ds as u,Es as d,Ga as f,Ha as p,Hi as m,Hs as h,Is as g,Jo as _,Ka as v,Ko as y,Lr as ee,Ls as te,Mi as ne,Mo as b,Ni as re,Oi as ie,On as ae,Po as x,Qa as oe,Qo as se,Qs as ce,Ro as le,Rr as ue,Rs as de,Si as fe,To as S,Tr as C,Ts as w,Us as T,Vo as E,Vs as D,Wa as pe,Wo as O,Wr as k,Xn as me,Xo as A,Zo as he,_i as ge,ao as _e,br as ve,cs as ye,da as be,ea as xe,eo as Se,es as Ce,fo as we,fs as Te,go as j,hs as Ee,is as De,jo as M,kn as Oe,kr as ke,lo as N,ls as Ae,mo as P,no as je,ns as Me,oc as Ne,os as F,pa as Pe,po as I,ps as Fe,qo as L,qs as Ie,r as R,ro as Le,rs as Re,sa as ze,so as Be,tc as z,tn as Ve,to as B,ua as He,wo as Ue,xo as We,ya as Ge,yo as V,zr as Ke,zs as qe}from"./loadShare-eager-dmdYQhAl.js";import{a as Je,c as Ye,d as Xe,f as Ze,i as Qe,l as $e,n as et,o as tt,p as nt,r as rt,s as it,t as at,u as ot}from"./Star-D8VNXawT.js";import{f as st}from"./WifiTethering-DJ9VO12W.js";import{t as ct}from"./DeleteForever-CioJt3X3.js";import{t as lt}from"./Remove-IN7ZNaCF.js";import{t as ut}from"./ViewList-DVj9ENkU.js";import{n as dt,o as ft,r as pt,t as mt}from"./AdminUtils-Dc1eHsx5.js";import{A as ht,E as gt,F as H,I as _t,O as vt,Q as yt,i as bt,j as xt,n as St,q as Ct,yt as wt}from"./bootstrap-BVw0diuj.js";import{n as Tt,r as Et,t as Dt}from"./sentry-CPzCHrwe.js";import{i as Ot,n as kt,r as At,t as jt}from"./AdapterUpdateDialog-L3aqW3ID.js";import{t as Mt}from"./CustomModal-Do2qVZr7.js";d();var U={smallAvatar:{width:24,height:24},listItem:e=>({mb:`2px`,background:e.palette.background,"@media screen and (max-width: 400px)":{pl:`2px`}}),toVersion:e=>({color:e.palette.mode===`dark`?`#00dc00`:`#008100`,fontWeight:`bold`,ml:`4px`}),updateDone:{background:`#5ef05e80`,opacity:.7},minWidthCss:{"@media screen and (max-width: 400px)":{minWidth:32}},wrapperButton:{},typography:{paddingRight:30},versions:{minWidth:110,display:`inline-block`},closeButton:e=>({position:`absolute`,right:8,top:8,color:e.palette.grey[500]}),languageButton:{position:`absolute`,right:60,top:8},languageButtonActive:e=>({color:e.palette.primary.main}),versionHeader:e=>({background:`#4dabf5`,borderRadius:`3px`,pl:`10px`,fontWeight:`bold`,color:e.palette.mode===`dark`?`black`:`white`}),repoStableVersionText:e=>({color:e.palette.mode===`dark`?`#8dff7a`:`#2b9800`,fontWeight:`bold`,marginLeft:`4px`}),repoLatestVersionText:e=>({color:e.palette.mode===`dark`?`#a3fcff`:`#005498`,fontWeight:`bold`,marginLeft:`4px`})},Nt=class e extends z{constructor(e){super(e),w(this,`updateAvailable`,void 0),w(this,`initialVersions`,void 0),w(this,`currentRef`,void 0),w(this,`current`,void 0),this.updateAvailable=this.detectUpdates(),this.initialVersions={},this.updateAvailable.forEach(e=>this.initialVersions[e]=this.props.installed[e].version),this.state={showNews:null},this.currentRef=Ie.createRef(),this.current=e.current,this.props.onUpdateSelected([...this.updateAvailable],this.updateAvailable)}static isUpdateAvailable(e){let{oldVersion:t,newVersion:n,name:r}=e;try{return R.gt(n,t)}catch{return console.warn(`Cannot compare "${n}" and "${t}" of adapter ${r}`),!1}}detectUpdates(){let t=[];return Object.keys(this.props.repository).forEach(n=>{let r=this.props.installed[n];n!==`js-controller`&&n!==`admin`&&n!==`eos-admin`&&r&&this.props.repository[n].version&&r.ignoreVersion!==this.props.repository[n].version&&e.isUpdateAvailable({oldVersion:r.version,newVersion:this.props.repository[n].version,name:n})&&(kt(this.props.repository[n].messages,r.version,this.props.repository[n].version)?console.log(`Adapter ${n} is filtered out from update all functionality, because it has messages which need to be read before update`):this.props.rightDependenciesFunc(n)?t.push(n):console.log(`Adapter ${n} is filtered out from update all functionality, because its dependencies are not met`))}),t.sort(),t}getNews(e){let t=this.props.repository[e],n=this.props.installed[e],r=[],i=t==null?void 0:t.news;return n&&i&&Object.keys(i).forEach(t=>{try{R.gt(t,n.version)&&r.push({version:t,news:this.props.noTranslation?i[t].en:i[t][this.props.lang]||i[t].en})}catch{console.warn(`Cannot compare "${t}" and "${n.version}" of adapter ${e}`)}}),r}renderOneAdapter(e){var n;let r=this.props.selected.includes(e);if((this.props.finished||this.props.inProcess)&&!r||!this.props.installed[e])return null;let i=this.props.installed[e].localIcon,a=i?`.${i}`:((n=this.props.repository[e])==null?void 0:n.extIcon)||`img/no-image.svg`;return T(t,{dense:!0,sx:{"&.MuiListItem-root":k.getStyle(this.props.theme,U.listItem,this.props.updated.includes(e)&&U.updateDone)},ref:this.props.current===e?this.currentRef:null,secondaryAction:!this.props.finished&&!this.props.inProcess?h(S,{edge:`end`,checked:r,tabIndex:-1,disableRipple:!0,disabled:this.props.inProcess,onClick:()=>{let t=[...this.props.selected],n=t.indexOf(e);n===-1?(t.push(e),t.sort()):t.splice(n,1),this.props.onUpdateSelected(t)}}):this.props.current===e&&!this.props.stopped&&!this.props.finished&&h(l,{}),children:[h(Me,{sx:U.minWidthCss,children:h(Ee,{variant:`square`,alt:e,src:a,style:U.smallAvatar})}),h(Re,{primary:e,title:this.getNews(e).map(e=>`${e.version}: ${e.news}`).join(`
1
+ import{$a as e,$o as t,$r as n,Aa as r,An as i,Ao as a,Bo as o,Ci as s,Co as c,Do as l,Ds as u,Es as d,Ga as f,Ha as p,Hi as m,Hs as h,Is as g,Jo as _,Ka as v,Ko as y,Lr as ee,Ls as te,Mi as ne,Mo as b,Ni as re,Oi as ie,On as ae,Po as x,Qa as oe,Qo as se,Qs as ce,Ro as le,Rr as ue,Rs as de,Si as fe,To as S,Tr as C,Ts as w,Us as T,Vo as E,Vs as D,Wa as pe,Wo as O,Wr as k,Xn as me,Xo as A,Zo as he,_i as ge,ao as _e,br as ve,cs as ye,da as be,ea as xe,eo as Se,es as Ce,fo as we,fs as Te,go as j,hs as Ee,is as De,jo as M,kn as Oe,kr as ke,lo as N,ls as Ae,mo as P,no as je,ns as Me,oc as Ne,os as F,pa as Pe,po as I,ps as Fe,qo as L,qs as Ie,r as R,ro as Le,rs as Re,sa as ze,so as Be,tc as z,tn as Ve,to as B,ua as He,wo as Ue,xo as We,ya as Ge,yo as V,zr as Ke,zs as qe}from"./loadShare-eager-dmdYQhAl.js";import{n as Je,o as Ye,r as Xe,t as Ze}from"./AdminUtils-Dc1eHsx5.js";import{H as Qe,Q as $e,R as et,U as tt,Z as nt,a as rt,at as H,bt as it,j as at,n as ot,pt as st}from"./bootstrap-CIDT4MeX.js";import{S as ct}from"./LinearScale-Be5h2beh.js";import{t as lt}from"./ViewList-DVj9ENkU.js";import{a as ut,c as dt,d as ft,f as pt,i as mt,l as ht,n as gt,o as _t,p as vt,r as yt,s as bt,t as xt,u as St}from"./North-C2whbHM-.js";import{n as Ct,r as wt,t as Tt}from"./sentry-DwQQLI7N.js";import{i as Et,n as Dt,r as Ot,t as kt}from"./AdapterUpdateDialog-DXp4Dgkx.js";import{t as At}from"./Remove-IN7ZNaCF.js";import{t as jt}from"./DeleteForever-CioJt3X3.js";import{t as Mt}from"./CustomModal-Do2qVZr7.js";d();var U={smallAvatar:{width:24,height:24},listItem:e=>({mb:`2px`,background:e.palette.background,"@media screen and (max-width: 400px)":{pl:`2px`}}),toVersion:e=>({color:e.palette.mode===`dark`?`#00dc00`:`#008100`,fontWeight:`bold`,ml:`4px`}),updateDone:{background:`#5ef05e80`,opacity:.7},minWidthCss:{"@media screen and (max-width: 400px)":{minWidth:32}},wrapperButton:{},typography:{paddingRight:30},versions:{minWidth:110,display:`inline-block`},closeButton:e=>({position:`absolute`,right:8,top:8,color:e.palette.grey[500]}),languageButton:{position:`absolute`,right:60,top:8},languageButtonActive:e=>({color:e.palette.primary.main}),versionHeader:e=>({background:`#4dabf5`,borderRadius:`3px`,pl:`10px`,fontWeight:`bold`,color:e.palette.mode===`dark`?`black`:`white`}),repoStableVersionText:e=>({color:e.palette.mode===`dark`?`#8dff7a`:`#2b9800`,fontWeight:`bold`,marginLeft:`4px`}),repoLatestVersionText:e=>({color:e.palette.mode===`dark`?`#a3fcff`:`#005498`,fontWeight:`bold`,marginLeft:`4px`})},Nt=class e extends z{constructor(e){super(e),w(this,`updateAvailable`,void 0),w(this,`initialVersions`,void 0),w(this,`currentRef`,void 0),w(this,`current`,void 0),this.updateAvailable=this.detectUpdates(),this.initialVersions={},this.updateAvailable.forEach(e=>this.initialVersions[e]=this.props.installed[e].version),this.state={showNews:null},this.currentRef=Ie.createRef(),this.current=e.current,this.props.onUpdateSelected([...this.updateAvailable],this.updateAvailable)}static isUpdateAvailable(e){let{oldVersion:t,newVersion:n,name:r}=e;try{return R.gt(n,t)}catch{return console.warn(`Cannot compare "${n}" and "${t}" of adapter ${r}`),!1}}detectUpdates(){let t=[];return Object.keys(this.props.repository).forEach(n=>{let r=this.props.installed[n];n!==`js-controller`&&n!==`admin`&&n!==`eos-admin`&&r&&this.props.repository[n].version&&r.ignoreVersion!==this.props.repository[n].version&&e.isUpdateAvailable({oldVersion:r.version,newVersion:this.props.repository[n].version,name:n})&&(Dt(this.props.repository[n].messages,r.version,this.props.repository[n].version)?console.log(`Adapter ${n} is filtered out from update all functionality, because it has messages which need to be read before update`):this.props.rightDependenciesFunc(n)?t.push(n):console.log(`Adapter ${n} is filtered out from update all functionality, because its dependencies are not met`))}),t.sort(),t}getNews(e){let t=this.props.repository[e],n=this.props.installed[e],r=[],i=t==null?void 0:t.news;return n&&i&&Object.keys(i).forEach(t=>{try{R.gt(t,n.version)&&r.push({version:t,news:this.props.noTranslation?i[t].en:i[t][this.props.lang]||i[t].en})}catch{console.warn(`Cannot compare "${t}" and "${n.version}" of adapter ${e}`)}}),r}renderOneAdapter(e){var n;let r=this.props.selected.includes(e);if((this.props.finished||this.props.inProcess)&&!r||!this.props.installed[e])return null;let i=this.props.installed[e].localIcon,a=i?`.${i}`:((n=this.props.repository[e])==null?void 0:n.extIcon)||`img/no-image.svg`;return T(t,{dense:!0,sx:{"&.MuiListItem-root":k.getStyle(this.props.theme,U.listItem,this.props.updated.includes(e)&&U.updateDone)},ref:this.props.current===e?this.currentRef:null,secondaryAction:!this.props.finished&&!this.props.inProcess?h(S,{edge:`end`,checked:r,tabIndex:-1,disableRipple:!0,disabled:this.props.inProcess,onClick:()=>{let t=[...this.props.selected],n=t.indexOf(e);n===-1?(t.push(e),t.sort()):t.splice(n,1),this.props.onUpdateSelected(t)}}):this.props.current===e&&!this.props.stopped&&!this.props.finished&&h(l,{}),children:[h(Me,{sx:U.minWidthCss,children:h(Ee,{variant:`square`,alt:e,src:a,style:U.smallAvatar})}),h(Re,{primary:e,title:this.getNews(e).map(e=>`${e.version}: ${e.news}`).join(`
2
2
  `),secondary:T(`span`,{children:[T(`div`,{style:U.versions,children:[this.initialVersions[e],` →`,h(j,{component:`span`,sx:U.toVersion,children:this.props.repository[e].version})]}),h(y,{title:C.t(`Show change log`),onClick:()=>this.setState({showNews:{adapter:e,version:this.props.repository[e].version,fromVersion:this.initialVersions[e]}}),size:`small`,children:h(xe,{})})]})})]},e)}getReactNews(e,t){let n=this.props.repository[e],r=this.props.installed[e];t||=r.version;let i=[],a,o,s=this.props.repository._repoInfo;if(s!=null&&s.stable){var c,l;a=(c=this.props.repository[e])==null?void 0:c.version,o=(l=this.props.repository[e])==null?void 0:l.latestVersion}else{var u,d;a=(u=this.props.repository[e])==null?void 0:u.stable,o=(d=this.props.repository[e])==null?void 0:d.version}let f=n==null?void 0:n.news;return r&&f&&Object.keys(f).forEach(n=>{try{if(R.gt(n,t)&&f[n]){let e=(this.props.noTranslation?f[n].en||``:f[n][this.props.lang]||f[n].en||``).split(`
3
- `).map(e=>Ot(e.trim()).replace(/<!--[^>]*->/g,``).replace(/<! -[^>]*->/g,``).trim()).filter(e=>!!e);i.push(T(O,{children:[T(P,{sx:U.versionHeader,children:[n,o===n?h(j,{component:`span`,sx:U.repoLatestVersionText,children:`(latest)`}):null,a===n?h(j,{component:`span`,sx:U.repoStableVersionText,children:`(${C.t(`stable`)})`}):null]}),e.map((e,t)=>h(At,{text:e},`${n}-${t}`))]},n))}}catch{console.warn(`Cannot compare "${n}" and "${t}" of adapter ${e}`)}}),i}renderShowNews(){if(this.state.showNews){let e=this.getReactNews(this.state.showNews.adapter,this.state.showNews.fromVersion),t=k.getStyle(this.props.theme,U.closeButton),n=k.getStyle(this.props.theme,U.languageButtonActive);return T(a,{onClose:()=>this.setState({showNews:null}),open:!0,children:[h(x,{children:T(P,{component:`h2`,variant:`h6`,sx:{"&.MuiTypography-root":U.typography},children:[h(`div`,{style:{width:`calc(100% - 60px)`},children:C.t(`Update "%s" to v%s`,this.state.showNews.adapter,this.state.showNews.version)}),h(y,{size:`large`,style:t,onClick:()=>this.setState({showNews:null}),children:h(v,{})}),C.getLanguage()!==`en`&&this.props.toggleTranslation?h(y,{size:`large`,style:{...U.languageButton,...this.props.noTranslation?n:void 0},onClick:this.props.toggleTranslation,title:C.t(`Disable/Enable translation`),children:h(r,{})}):null]})}),h(b,{dividers:!0,children:h(O,{container:!0,spacing:2,wrap:`nowrap`,sx:{flexDirection:`column`},children:e.length?T(O,{children:[h(P,{variant:`h6`,gutterBottom:!0,children:C.t(`Change log`)}),h(O,{container:!0,spacing:2,wrap:`nowrap`,sx:{flexDirection:`column`},children:e})]}):C.t(`No change log available`)})}),h(M,{style:U.wrapperButton,children:h(V,{variant:`contained`,onClick:()=>this.setState({showNews:null}),color:`grey`,startIcon:h(v,{}),children:C.t(`Close`)})})]})}return null}render(){return this.current!==this.props.current&&(this.current=this.props.current,setTimeout(()=>{var e;return(e=this.currentRef.current)==null?void 0:e.scrollIntoView()},200)),T(se,{style:U.root,children:[this.updateAvailable.map(e=>this.renderOneAdapter(e)),this.renderShowNews()]})}};d();var W={dialogRoot:{height:`calc(100% - 64px)`},wrapperHead:{justifyContent:`space-between`,display:`flex`},checkbox:{marginRight:10},appBar:e=>({flexWrap:`wrap`,position:`sticky`,bottom:-10,pl:1,pr:1,borderRadius:`${e.shape.borderRadius}px`,background:e.palette.background.paper}),container:{overflow:`hidden`,flex:`1 1 auto`,minHeight:0,flexWrap:`nowrap`,"@media screen and (max-width: 602px)":{flex:`none`,flexWrap:`wrap`}},content:{display:`flex`,flexDirection:`column`,"& > .MuiToolbar-root":{flexShrink:0},"@media screen and (max-width: 500px)":{p:1}},languageButton:{position:`absolute`,right:73,top:11},languageButtonActive:e=>({color:e.palette.primary.main})},Pt=class extends z{constructor(e){super(e),w(this,`updateAvailable`,[]),w(this,`onAdapterFinished`,null),w(this,`processList`,[]),this.state={selected:[],inProcess:!1,finished:!1,current:``,updated:[],stopped:!1,debug:(window._localStorage||window.localStorage).getItem(`AdaptersUpdaterDialog.debug`)===`true`,stopOnError:(window._localStorage||window.localStorage).getItem(`AdaptersUpdaterDialog.stopOnError`)!==`false`,closeOnFinished:(window._localStorage||window.localStorage).getItem(`AdaptersUpdaterDialog.closeOnFinished`)===`true`,currentVersion:``},this.updateAvailable=[]}updateAdapter(e,t,n){this.onAdapterFinished=n,this.setState({current:e,currentVersion:t})}onStartUpdate(){this.props.ready?this.setState({inProcess:!0},()=>{this.props.onSetCommandRunning(!0),this.processList=[...this.state.selected].sort((e,t)=>e===`eos-admin`?1:t===`eos-admin`?-1:e.localeCompare(t)).map(e=>{var t;return{adapter:e,version:(t=this.props.repository[e])==null?void 0:t.version}}),this.updateAdapters(()=>{this.setState({inProcess:!1,finished:!0},()=>{this.props.onSetCommandRunning(!1),this.state.closeOnFinished&&this.props.onClose(!!this.state.updated.length)})})}):window.alert(this.props.t(`The connection is not ready yet. Please wait a moment and try again.`))}updateAdapters(e){if(!this.processList||!this.processList.length||this.state.stopped)e&&e();else{let{adapter:t,version:n}=this.processList.shift();this.updateAdapter(t,n,()=>{let n=[...this.state.updated];n.push(t),this.setState({updated:n},()=>setTimeout(()=>this.updateAdapters(e),200))})}}render(){let e=this.props.noTranslation?k.getStyle(this.props.theme,W.languageButtonActive):void 0;return T(a,{open:!0,maxWidth:`lg`,fullWidth:!!this.state.current,onClose:()=>this.props.onClose(!!this.state.updated.length),"aria-labelledby":`update-dialog-title`,"aria-describedby":`update-dialog-description`,sx:{"& .MuiPaper-root":W.dialogRoot},scroll:`paper`,children:[h(x,{id:`update-dialog-title`,children:T(`div`,{style:W.wrapperHead,children:[this.props.t(`Update %s adapter(s)`,this.state.selected.length),!this.state.finished&&!this.state.inProcess&&h(I,{title:this.props.t(`Select/Unselect all`),slotProps:{popper:{sx:{pointerEvents:`none`}}},children:h(S,{checked:this.state.selected.length===this.updateAvailable.length,style:W.checkbox,tabIndex:-1,indeterminate:this.state.selected.length!==this.updateAvailable.length&&this.state.selected.length!==0,disableRipple:!0,onClick:()=>{let e=[];this.state.selected.length!==this.updateAvailable.length&&(e=[...this.updateAvailable]),this.setState({selected:e})}})}),C.getLanguage()!==`en`&&this.props.toggleTranslation?h(y,{size:`large`,style:{...W.languageButton,...e},onClick:()=>{var e,t;return(e=(t=this.props).toggleTranslation)==null?void 0:e.call(t)},title:C.t(`Disable/Enable translation`),children:h(r,{})}):null]})}),T(b,{sx:{"&.MuiDialogContent-root":W.content},children:[T(O,{container:!0,direction:`row`,sx:W.container,children:[h(O,{style:{height:`100%`,overflow:`hidden`,width:this.state.current?250:`100%`},children:h(`div`,{style:{height:`100%`,overflow:`auto`},children:h(Nt,{finished:this.state.finished,inProcess:this.state.inProcess,selected:this.state.selected,current:this.state.current,stopped:this.state.stopped,updated:this.state.updated,lang:this.props.lang,installed:this.props.installed,repository:this.props.repository,noTranslation:!!this.props.noTranslation,toggleTranslation:this.props.toggleTranslation||(()=>{}),onUpdateSelected:(e,t)=>{t&&(this.updateAvailable=t),this.setState({selected:e})},theme:this.props.theme,rightDependenciesFunc:this.props.rightDependenciesFunc})})}),!!this.state.current&&h(O,{style:{height:`100%`,overflow:`hidden`,width:`calc(100% - 260px)`,minWidth:240},children:h(_t,{noSpacing:!0,ready:this.props.ready,host:this.props.currentHost,socket:this.props.socket,t:this.props.t,cmd:`upgrade ${this.state.current}@${this.state.currentVersion}${this.state.debug?` --debug`:``}`,onFinished:()=>{var e;return(e=this.onAdapterFinished)==null?void 0:e.call(this)},errorFunc:()=>{if(this.state.stopOnError)this.setState({stopped:!0,finished:!0}),this.onAdapterFinished=null,this.props.onSetCommandRunning(!1);else{var e;(e=this.onAdapterFinished)==null||e.call(this)}}},this.state.current)})]}),T(we,{variant:`dense`,disableGutters:!0,sx:W.appBar,children:[h(E,{control:h(S,{disabled:this.state.finished,checked:this.state.stopOnError,onChange:()=>{(window._localStorage||window.localStorage).setItem(`AdaptersUpdaterDialog.stopOnError`,this.state.stopOnError?`false`:`true`),this.setState({stopOnError:!this.state.stopOnError})}}),label:this.props.t(`Stop on error`)}),h(E,{control:h(S,{disabled:this.state.finished,checked:this.state.closeOnFinished,onChange:()=>{(window._localStorage||window.localStorage).setItem(`AdaptersUpdaterDialog.closeOnFinished`,this.state.closeOnFinished?`false`:`true`),this.setState({closeOnFinished:!this.state.closeOnFinished})}}),label:this.props.t(`Close on finished`)}),h(E,{control:h(S,{disabled:this.state.finished||this.state.inProcess,checked:this.state.debug,onChange:()=>{(window._localStorage||window.localStorage).setItem(`AdaptersUpdaterDialog.debug`,this.state.debug?`false`:`true`),this.setState({debug:!this.state.debug})}}),label:this.props.t(`Debug info`)})]})]}),T(M,{children:[h(V,{id:`adapters-update-dialog-update`,variant:`contained`,disabled:this.state.stopped||this.state.inProcess||this.state.finished||!this.state.selected.length||!this.props.ready,onClick:()=>this.onStartUpdate(),color:`primary`,autoFocus:!0,startIcon:h(pe,{}),children:this.props.t(`Update`)}),h(V,{id:`adapters-update-dialog-cancel`,variant:`contained`,disabled:!this.state.inProcess,color:`grey`,startIcon:h(n,{}),onClick:()=>{this.setState({stopped:!0,finished:!0}),this.props.onSetCommandRunning(!1)},children:this.props.t(`Cancel`)}),h(V,{id:`adapters-update-dialog-close`,variant:`contained`,onClick:()=>this.props.onClose(!!this.state.updated.length),disabled:this.state.inProcess&&!this.state.stopped,color:this.state.stopped?`error`:`grey`,startIcon:h(v,{}),children:this.props.t(`Close`)})]})]})}},Ft=u(T(D,{children:[h(`path`,{d:`M21 10.12h-6.78l2.74-2.82c-2.73-2.7-7.15-2.8-9.88-.1-2.73 2.71-2.73 7.08 0 9.79s7.15 2.71 9.88 0C18.32 15.65 19 14.08 19 12.1h2c0 1.98-.88 4.55-2.64 6.29-3.51 3.48-9.21 3.48-12.72 0-3.5-3.47-3.53-9.11-.02-12.58s9.14-3.47 12.65 0L21 3z`}),h(`path`,{d:`M8.6 8.7h2.9v2.9H8.6zM12.5 8.7h2.9v2.9h-2.9zM8.6 12.6h2.9v2.9H8.6zM12.5 12.6h2.9v2.9h-2.9z`})]}),`UpdateAll`);d();var It=class extends gt{constructor(e,t){super(e,`${t}.adapter`,`adapter`),w(this,`host`,void 0),w(this,`prefix`,void 0),this.prefix=`${t}.adapter.`,this.host=t}getObject(e){return this.objects&&this.objects[this.prefix+e]||null}getHost(){return this.host}};function Lt(e){var t;return(e==null||(t=e.licenseInformation)==null?void 0:t.link)||Rt(e)}function Rt(e){if(!e)return``;let t=e.licenseUrl;if(!t||!t.includes(`/LICENSE`)||!t.includes(`raw.githubusercontent.com`)){if(t=e.extIcon,!t){if(t=e.readme,!t)return console.error(`No extIcon for ${e.name||JSON.stringify(e)}`),``;t=t.replace(`github.com`,`raw.githubusercontent.com`).replace(`/blob/`,`/`),t.includes(`/main`)?t=`${t.split(`/main`)[0]}/main/LICENSE`:t.includes(`/master`)&&(t=`${t.split(`/master`)[0]}/master/LICENSE`)}if(t.includes(`/main`))t=`${t.split(`/main`)[0]}/main/LICENSE`;else if(t.includes(`/master`))t=`${t.split(`/master`)[0]}/master/LICENSE`;else return``}return t}function zt(e){if(!e)return null;let t=e.trim().split(`?`)[0].split(`#`)[0],n=t.match(/iobroker\.([a-z\d][a-z\d_-]*?)-\d+\.\d+\.\d+[^/\\]*\.tgz$/i);if(n)return n[1].toLowerCase();let r=t.match(/iobroker\.([a-z\d][a-z\d_-]*)/i);return r?r[1].toLowerCase():/^[a-z\d][a-z\d_-]*$/i.test(t)?t.toLowerCase():null}var Bt=`data:image/svg+xml,%3csvg%20viewBox='0%200%202500%202500'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M0%200h2500v2500H0z'%20fill='%23c00'/%3e%3cpath%20d='M1241.5%20268.5h-973v1962.9h972.9V763.5h495v1467.9h495V268.5z'%20fill='%23fff'/%3e%3c/svg%3e`;function Vt(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=r.result,n=e.indexOf(`,`);t(n===-1?e:e.substring(n+1))},r.onerror=()=>n(r.error||Error(`Cannot read file`)),r.readAsDataURL(e)})}function Ht(e){return{id:`github-install-dialog-tab-${e}`,"aria-controls":`github-install-dialog-panel-${e}`}}var G={root:e=>({backgroundColor:e.palette.background.paper,width:`100%`,height:`100%`}),paper:{maxWidth:1e3},tabPaper:{padding:16},title:e=>({mt:`10px`,p:1,ml:1,fontSize:18,color:e.palette.primary.main}),warningText:{color:`#f53939`},noteText:{marginTop:16},errorTextNoGit:{fontSize:13,color:`#ff1616`},listIcon:{width:24,height:24},listIconWithMargin:{width:24,height:24,marginRight:8},tabSelected:e=>({color:e.palette.mode===`dark`?e.palette.secondary.contrastText:`#222 !important`})};function Ut(e){let t=[];for(let n=0;n<e.length;n++)typeof e[n]==`object`?e[n].forEach(e=>t.push(e)):t.push(e[n]);return t}var Wt=10,Gt=class extends Ie.Component{constructor(e){super(e);let t=[],n=(window._localstorage||window.localStorage).getItem(`App.npmHistory`);if(n)try{t=JSON.parse(n)}catch{}this.state={autoCompleteValue:(window._localstorage||window.localStorage).getItem(`App.autocomplete`)||null,debug:(window._localstorage||window.localStorage).getItem(`App.gitDebug`)===`true`,createInstance:(window._localstorage||window.localStorage).getItem(`App.createInstanceAfterInstall`)!==`false`,url:(window._localstorage||window.localStorage).getItem(`App.userUrl`)||``,currentTab:(window._localstorage||window.localStorage).getItem(`App.gitTab`)||`npm`,customHistory:t,selectedFile:null,restartAfterInstall:(window._localstorage||window.localStorage).getItem(`App.restartAfterInstall`)!==`false`,uploading:!1,selectedHost:e.currentHost,cmdExecFilesSupported:!1}}async componentDidMount(){try{let e=await this.props.socket.checkFeatureSupported(`CONTROLLER_CMD_EXEC_FILES`);this.setState({cmdExecFilesSupported:!!e})}catch(e){console.error(`Cannot read feature: ${e}`)}}async uploadFileToServer(){if(!this.state.selectedFile)return null;this.setState({uploading:!0});try{let e=new FormData;e.append(`file`,this.state.selectedFile);let t=await fetch(`./upload-adapter`,{method:`POST`,body:e});if(!t.ok){let e;try{e=(await t.json()).error||`Upload failed with status ${t.status}`}catch{e=`Upload failed with status ${t.status}`}throw Error(e)}return(await t.json()).filePath}catch(e){return window.alert(`${C.t(`Upload failed`)}: ${e.message}`),null}finally{this.setState({uploading:!1})}}async restartInstances(e){if(!this.state.restartAfterInstall||!e)return;let t=await this.props.socket.getAdapterInstances(e);for(let e of t){var n;e!=null&&(n=e.common)!=null&&n.enabled&&await this.props.socket.extendObject(e._id,{})}}async createInstanceIfDesired(e,t){if(this.state.createInstance&&e)try{await this.props.createInstance(e,t)}catch(t){console.error(`Cannot create the instance of ${e}: ${t.message}`)}}async installFile(){if(!this.state.selectedFile)return;let e=zt(this.state.selectedFile.name)||``;if(this.state.cmdExecFilesSupported){try{let t=await Vt(this.state.selectedFile),n=this.state.selectedFile.name.replace(/[^a-zA-Z0-9._-]/g,`_`),r=await this.props.installFromUrl(n,this.state.debug,!0,{host:this.state.selectedHost,files:[{name:n,file:t}]});await this.restartInstances(e),r&&await this.createInstanceIfDesired(e,this.state.selectedHost)}catch(e){console.error(`Installation from file failed: ${e.message}`)}return}let t=await this.uploadFileToServer();if(t)try{let n=await this.props.installFromUrl(t,this.state.debug,!0);await this.restartInstances(e),n&&await this.createInstanceIfDesired(e)}catch(e){console.error(`Installation from file failed: ${e.message}`)}}async handleInstall(){if(this.state.currentTab===`GitHub`){var e;let t=(((e=this.state.autoCompleteValue)==null?void 0:e.value)||``).split(`/`),n=`${t[1]}/ioBroker.${t[0]}`;await this.props.installFromUrl(n,this.state.debug,!0)&&await this.createInstanceIfDesired(t[0])}else if(this.state.currentTab===`URL`){let e=this.state.customHistory.filter(e=>e!==this.state.url);e.unshift(this.state.url),e.length>Wt&&e.pop(),(window._localstorage||window.localStorage).setItem(`App.npmHistory`,JSON.stringify(e));let t=this.state.url.includes(`.`)?this.state.url:`iobroker.${this.state.url}`;await this.props.installFromUrl(t,this.state.debug,!0)&&await this.createInstanceIfDesired(zt(t))}else if(this.state.currentTab===`File`)await this.installFile();else if(this.state.currentTab===`npm`){var t;let e=(((t=this.state.autoCompleteValue)==null?void 0:t.value)||``).split(`/`)[0],n=e.includes(`.`)?e.split(`.`)[1]:e;try{let e=await this.props.installFromUrl(`iobroker.${n}@latest`,this.state.debug,!0);await this.props.upload(n),e&&await this.createInstanceIfDesired(n)}catch(e){console.error(`Installation from url failed: ${e.message}`)}}}renderCreateInstance(){return h(`div`,{style:{display:`flex`,alignItems:`center`},children:h(E,{control:h(S,{checked:this.state.createInstance,onChange:e=>{(window._localstorage||window.localStorage).setItem(`App.createInstanceAfterInstall`,e.target.checked?`true`:`false`),this.setState({createInstance:e.target.checked})}}),label:this.props.t(`Create instance if it does not exist yet`)})})}renderNpm(){return this.state.currentTab===`npm`?T(Ae,{style:G.tabPaper,id:`github-install-dialog-panel-npm`,children:[h(`div`,{style:{display:`flex`,alignItems:`center`},children:h(E,{control:h(S,{checked:this.state.debug,onChange:e=>{(window._localstorage||window.localStorage).setItem(`App.gitDebug`,e.target.checked?`true`:`false`),this.setState({debug:e.target.checked})}}),label:this.props.t(`Debug outputs`)})}),this.renderCreateInstance(),T(`div`,{style:{display:`flex`,alignItems:`flex-end`},children:[h(rt,{style:{marginRight:10}}),h(ye,{fullWidth:!0,value:this.state.autoCompleteValue,onChange:(e,t)=>{(window._localstorage||window.localStorage).setItem(`App.autocomplete`,t||void 0),this.setState({autoCompleteValue:t||null})},options:this.getList(),getOptionLabel:e=>(e==null?void 0:e.name)??``,renderInput:e=>{var t;return h(N,{variant:`standard`,...e,slotProps:{...e.slotProps,input:{...e.slotProps.input,startAdornment:h(L,{position:`start`,children:h(ve,{src:((t=this.state.autoCompleteValue)==null?void 0:t.icon)||``,style:G.listIcon})})}},label:C.t(`Select adapter`)})},renderOption:(e,t)=>T(j,{component:`li`,sx:{"& > img":{mr:2,flexShrink:0}},...e,children:[h(ve,{src:(t==null?void 0:t.icon)||``,style:G.listIconWithMargin}),(t==null?void 0:t.name)??``]})})]}),h(`div`,{style:{fontSize:24,fontWeight:`bold`,marginTop:40},children:this.props.t(`Warning!`)}),h(`div`,{style:G.warningText,children:this.props.t(`npm_warning`,`NPM`,`NPM`)}),h(`div`,{style:G.noteText,children:this.props.t(`github_note`)})]}):null}renderGitHub(){return this.state.currentTab===`GitHub`?T(Ae,{style:G.tabPaper,id:`github-install-dialog-panel-github`,children:[h(`div`,{style:{display:`flex`,alignItems:`center`},children:h(E,{control:h(S,{checked:this.state.debug,onChange:e=>{(window._localstorage||window.localStorage).setItem(`App.gitDebug`,e.target.checked?`true`:`false`),this.setState({debug:e.target.checked})}}),label:this.props.t(`Debug outputs`)})}),this.renderCreateInstance(),T(`div`,{style:{display:`flex`,alignItems:`flex-end`},children:[h(rt,{style:{marginRight:10}}),h(ye,{fullWidth:!0,value:this.state.autoCompleteValue,getOptionDisabled:e=>!!(e!=null&&e.nogit),renderOption:(e,t)=>T(j,{component:`li`,sx:{"& > img":{mr:2,flexShrink:0}},...e,children:[h(ve,{src:(t==null?void 0:t.icon)||``,style:G.listIconWithMargin}),(t==null?void 0:t.name)??``,(t==null?void 0:t.nogit)&&h(`div`,{style:G.errorTextNoGit,children:C.t(`This adapter cannot be installed from git as must be built before installation.`)})]}),onChange:(e,t)=>{(window._localstorage||window.localStorage).setItem(`App.autocomplete`,t),this.setState({autoCompleteValue:t})},options:this.getList(),getOptionLabel:e=>(e==null?void 0:e.name)??``,renderInput:e=>{var t;return h(N,{variant:`standard`,...e,slotProps:{...e.slotProps,input:{...e.slotProps.input,startAdornment:h(L,{position:`start`,children:h(ve,{src:((t=this.state.autoCompleteValue)==null?void 0:t.icon)||``,style:G.listIconWithMargin})})}},label:C.t(`Select adapter`)})}})]}),h(`div`,{style:{fontSize:24,fontWeight:`bold`,marginTop:40},children:this.props.t(`Warning!`)}),h(`div`,{style:G.warningText,children:this.props.t(`github_warning`,`GitHub`,`GitHub`)}),h(`div`,{style:G.noteText,children:this.props.t(`github_note`)})]}):null}renderCustom(){return this.state.currentTab===`URL`?T(Ae,{style:G.tabPaper,id:`github-install-dialog-panel-custom`,children:[h(`div`,{style:{display:`flex`,alignItems:`center`},children:h(E,{control:h(S,{checked:this.state.debug,onChange:e=>{(window._localstorage||window.localStorage).setItem(`App.gitDebug`,e.target.checked?`true`:`false`),this.setState({debug:e.target.checked})}}),label:this.props.t(`Debug outputs`)})}),this.renderCreateInstance(),h(`div`,{style:{display:`flex`,alignItems:`center`},children:h(ye,{fullWidth:!0,value:this.state.url||``,onInputChange:(e,t)=>{(window._localstorage||window.localStorage).setItem(`App.userUrl`,t||``),this.setState({url:t||``})},onChange:(e,t)=>{(window._localstorage||window.localStorage).setItem(`App.userUrl`,t||``),this.setState({url:t||``})},renderOption:(e,t)=>T(j,{component:`li`,...e,style:{display:`flex`,alignItems:`left`},children:[t,h(`div`,{style:{flexGrow:1}}),h(y,{size:`small`,onClick:e=>{e.stopPropagation();let n=this.state.customHistory.filter(e=>e!==t);(window._localstorage||window.localStorage).setItem(`App.npmHistory`,JSON.stringify(n)),this.setState({customHistory:n})},children:h(p,{})})]}),freeSolo:!0,options:this.state.customHistory,renderInput:e=>h(N,{variant:`standard`,...e,onKeyUp:e=>{e.key===`Enter`&&this.state.url&&this.handleInstall().then(()=>{this.setState({autoCompleteValue:null,url:``}),this.props.onClose()})},helperText:this.props.t(`URL or file path`),label:this.props.t(`URL`)})})}),h(`div`,{style:{fontSize:24,fontWeight:`bold`,marginTop:40},children:this.props.t(`Warning!`)}),h(`div`,{style:G.warningText,children:this.props.t(`github_warning`,`URL`,`URL`)}),h(`div`,{style:G.noteText,children:this.props.t(`github_note`)})]}):null}renderFile(){return this.state.currentTab===`File`?T(Ae,{style:G.tabPaper,id:`github-install-dialog-panel-file`,children:[T(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[T(V,{variant:`outlined`,component:`label`,startIcon:h(be,{}),disabled:this.state.uploading,children:[this.props.t(`Select file`),h(`input`,{type:`file`,accept:`.tgz`,hidden:!0,onChange:e=>{var t;let n=((t=e.target.files)==null?void 0:t[0])||null;this.setState({selectedFile:n,url:``}),(window._localstorage||window.localStorage).setItem(`App.userUrl`,``),e.target.value=``}})]}),this.state.selectedFile&&T(D,{children:[h(P,{variant:`body2`,style:{flex:1},children:this.state.selectedFile.name}),h(y,{size:`small`,onClick:()=>this.setState({selectedFile:null}),children:h(v,{})})]}),this.state.uploading&&h(l,{size:24})]}),this.state.selectedFile&&h(E,{control:h(S,{checked:this.state.restartAfterInstall,onChange:e=>{(window._localstorage||window.localStorage).setItem(`App.restartAfterInstall`,e.target.checked?`true`:`false`),this.setState({restartAfterInstall:e.target.checked})}}),label:this.props.t(`Restart adapter after install`)}),this.renderCreateInstance(),this.state.cmdExecFilesSupported&&T(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:8},children:[T(P,{variant:`body2`,children:[this.props.t(`Install on host`),`:`]}),h(vt,{socket:this.props.socket,currentHost:this.state.selectedHost,hostsWorker:this.props.hostsWorker,expertMode:this.props.expertMode,themeType:this.props.themeType,tooltip:this.props.t(`Install on host`),setCurrentHost:(e,t)=>this.setState({selectedHost:t})})]}),h(`div`,{style:{fontSize:24,fontWeight:`bold`,marginTop:40},children:this.props.t(`Warning!`)}),h(`div`,{style:G.warningText,children:this.props.t(`github_warning`,`File`,`File`)}),h(`div`,{style:G.noteText,children:this.props.t(`github_note`)})]}):null}getList(){let e=Ut(this.props.categories.map(e=>e.adapters));return e.sort(),e.map((t,n)=>{if(n&&e[n-1]===t)return null;let r=this.props.repository[t];if(!(r!=null&&r.controller)){let e=(r.extIcon||r.meta||r.readme||``).toString().split(`/`),n=r==null?void 0:r.name;n||=(n=r.titleLang,n&&typeof n==`object`?n[C.getLanguage()]||n.en:r.title||t);let i={value:`${t}/${e[3]}`,name:`${n} [${e[3]}]`,icon:r.extIcon||r.icon||``,nogit:!!r.nogit,title:t};return this.props.installed[n]&&n!==`admin`&&(i.icon=ft(`adapter/${t}/${(r.icon||``).split(`/admin/`).pop()}`)),i}return null}).filter(e=>e).sort((e,t)=>e.name<t.name?-1:+(e.name>t.name))}render(){var e;let t=()=>this.setState({autoCompleteValue:null,url:``,selectedFile:null,uploading:!1});return T(a,{onClose:()=>this.props.onClose(),open:!0,sx:{"& .MuiDialog-paper":G.paper},children:[h(b,{dividers:!0,children:T(j,{component:`div`,sx:G.root,children:[h(De,{position:`static`,color:`default`,children:T(Be,{value:this.state.currentTab,onChange:(e,t)=>{(window._localstorage||window.localStorage).setItem(`App.gitTab`,t),this.setState({currentTab:t})},variant:`fullWidth`,indicatorColor:`secondary`,children:[h(oe,{label:this.props.t(`From npm`),wrapped:!0,sx:{"&.Mui-selected":G.tabSelected},icon:h(`img`,{src:Bt,alt:`npm`,width:24,height:24}),...Ht(`npm`),value:`npm`}),h(oe,{label:this.props.t(`From github`),wrapped:!0,sx:{"&.Mui-selected":G.tabSelected},icon:h(m,{style:{width:24,height:24},width:24,height:24}),...Ht(`github`),value:`GitHub`}),h(oe,{label:this.props.t(`Custom`),wrapped:!0,sx:{"&.Mui-selected":G.tabSelected},icon:h(r,{width:24,height:24}),...Ht(`custom`),value:`URL`}),h(oe,{label:this.props.t(`From file`),wrapped:!0,sx:{"&.Mui-selected":G.tabSelected},icon:h(ge,{style:{width:24,height:24}}),...Ht(`file`),value:`File`})]})}),h(j,{component:`div`,sx:G.title,children:this.props.t(`Install or update the adapter from %s`,this.state.currentTab||`npm`)}),this.renderNpm(),this.renderGitHub(),this.renderCustom(),this.renderFile()]})}),T(M,{children:[h(V,{id:`github-install-dialog-ok`,variant:`contained`,disabled:this.state.uploading||this.props.commandRunning||(this.state.currentTab===`GitHub`||this.state.currentTab===`npm`)&&!((e=this.state.autoCompleteValue)!=null&&e.value)||this.state.currentTab===`URL`&&!this.state.url||this.state.currentTab===`File`&&!this.state.selectedFile,autoFocus:!0,onClick:async()=>{await this.handleInstall(),this.props.onClose(),t()},color:`primary`,startIcon:this.props.commandRunning?h(l,{size:20}):h(pe,{}),children:this.props.t(`Install`)}),h(V,{id:`github-install-dialog-close`,variant:`contained`,onClick:()=>{this.props.onClose(),t()},color:`grey`,startIcon:h(v,{}),children:this.props.t(`Close`)})]})]})}};d();var K={formControl:{marginTop:24,width:100},closeButton:e=>({position:`absolute`,right:8,top:8,color:e.palette.grey[500]}),languageButton:{position:`absolute`,right:60,top:8},languageButtonActive:e=>({color:e.palette.primary.main}),paper:{},typography:{pr:`30px`},messageText:{},messageColor_warn:{color:`#cb7642`},messageColor_error:{color:`#f5614d`},messageColor_info:{color:`#5abd29`},messageTitle_warn:e=>({background:`#cb7642`,borderRadius:`3px`,pl:`10px`,fontWeight:`bold`,color:e.palette.mode===`dark`?`black`:`white`}),messageTitle_error:e=>({background:`#f5614d`,borderRadius:`3px`,pl:`10px`,fontWeight:`bold`,color:e.palette.mode===`dark`?`black`:`white`}),messageTitle_info:e=>({background:`#5abd29`,borderRadius:`3px`,pl:`10px`,fontWeight:`bold`,color:e.palette.mode===`dark`?`black`:`white`}),deps:e=>({m:`10px`,fontSize:16,color:e.palette.mode===`dark`?`#e70000`:`#840101`})},Kt=class extends z{constructor(e){super(e),w(this,`t`,void 0),w(this,`messages`,null),w(this,`lang`,void 0),this.state={instanceNumbers:[]},this.t=e.t,this.lang=C.getLanguage(),this.messages=kt(e.adapterObject.messages,null,e.adapterObject.version,e.instances)}componentDidMount(){this.props.instancesWorker.getObjects().then(e=>{let t=Object.keys(e||{}).filter(t=>{var n;return(e==null||(n=e[t])==null||(n=n.common)==null?void 0:n.name)===this.props.adapter}).map(e=>e.substring(e.lastIndexOf(`.`)+1));this.setState({instanceNumbers:t})})}getAvailableInstances(){let e=[];e.push(h(F,{value:`auto`,children:this.t(`auto`)},`auto`));for(let t=0;t<=100&&(this.state.instanceNumbers.includes(t.toString())||e.push(h(F,{value:t.toString(),children:t},t)),!(e.length>11));t++);return e}checkDependencies(e=this.props.dependencies){if(!e)return``;let t=[];for(let r of e){var n;r.installedVersion?(n=r.wrongHosts)!=null&&n.length?t.push(T(`div`,{children:[h(`div`,{children:this.props.t(`The following hosts do not fulfill the required version %s of %s:`,r.version||`unknown`,r.name)}),h(`ul`,{style:{margin:`4px 0`},children:r.wrongHosts.map(e=>T(`li`,{children:[e.host,`: `,e.installedVersion]},e.host))})]},r.name)):r.rightVersion||t.push(h(`div`,{children:`${this.props.t(`Invalid version of %s. Required %s. Current `,r.name,r.version||`unknown`)}${r.installedVersion}`},r.name)):t.push(h(`div`,{children:this.props.t(`No version of %s`,r.name,r.name)},r.name))}return t.length?t:``}getText(e,t){return e&&typeof e==`object`?t?e.en:e[this.lang]||e.en:typeof e==`object`?``:e}renderOneMessage(e,t){return T(O,{children:[h(P,{sx:K[`messageTitle_${e.level||`warn`}`],children:this.getText(e.title,this.props.noTranslation)||``}),h(P,{component:`div`,variant:`body2`,style:K.messageText,children:this.getText(e.text,this.props.noTranslation)||``}),e.link?h(V,{onClick:()=>{let t=window.open(e.link,`_blank`);t==null||t.focus()},startIcon:h(me,{}),variant:`contained`,color:`grey`,children:this.getText(e.linkText||``,this.props.noTranslation)||this.props.t(`More info`)}):null]},t)}renderMessages(){return this.messages?h(O,{container:!0,spacing:2,wrap:`nowrap`,sx:{marginBottom:1,flexDirection:`column`},children:this.messages.map((e,t)=>this.renderOneMessage(e,t))}):null}render(){let e=this.checkDependencies();return T(a,{onClose:()=>{},open:!0,sx:{"& .MuiDialog-paper":K.paper},children:[h(x,{children:T(P,{component:`h2`,variant:`h6`,sx:{"&.MuiTypography-root":K.typography},children:[this.t(`You are going to add new instance:`),` `,this.props.adapter,h(y,{size:`large`,sx:K.closeButton,onClick:()=>this.props.onClose(!1),children:h(v,{})}),this.messages&&this.lang!==`en`&&this.props.toggleTranslation?h(y,{size:`large`,style:k.getStyle(this.props.theme,K.languageButton,this.props.noTranslation&&K.languageButtonActive),onClick:this.props.toggleTranslation,title:C.t(`Disable/Enable translation`),children:h(r,{})}):null]})}),T(b,{dividers:!0,children:[this.renderMessages(),!e&&this.props.expertMode?T(O,{container:!0,sx:{flexDirection:`column`},children:[h(vt,{tooltip:this.t(`Select host to add the instance`),expertMode:!0,socket:this.props.socket,hostsWorker:this.props.hostsWorker,currentHost:this.props.currentHost,setCurrentHost:(e,t)=>this.props.onHostChange(t.replace(/^system\.host\./,``))}),T(o,{variant:`standard`,style:K.formControl,children:[h(_,{id:`instance-label`,children:this.t(`Instance`)}),h(Fe,{variant:`standard`,labelId:`instance-label`,value:this.props.currentInstance,onChange:this.props.onInstanceChange,children:this.getAvailableInstances()})]})]}):null,h(j,{component:`div`,sx:K.deps,children:e})]}),T(M,{children:[h(V,{id:`instance-add-dialog-ok`,variant:`contained`,autoFocus:!0,disabled:!!e,onClick:()=>this.props.onClose(!0),color:`primary`,startIcon:h(s,{}),children:this.t(`Add`)}),h(V,{id:`instance-add-dialog-cancel`,variant:`contained`,onClick:()=>this.props.onClose(!1),color:`grey`,startIcon:h(v,{}),children:this.t(`Close`)})]})]})}},q=class e extends z{constructor(e){super(e),this.state={showDialog:!1,showLicenseDialog:null,addInstanceHostName:``,addInstanceId:`auto`,addInstanceDialog:``}}renderLicenseDialog(t){var n;return this.state.showLicenseDialog?h(bt,{licenseType:this.state.showLicenseDialog.licenseType,url:this.state.showLicenseDialog.url,link:(n=t.repository[this.state.showLicenseDialog.adapterName])==null||(n=n.licenseInformation)==null?void 0:n.link,onClose:n=>{let r=n?this.state.showLicenseDialog:null;this.setState({showLicenseDialog:null,showDialog:!1},()=>{r&&(r.upload?e.upload(r.adapterName,t):this.addInstance({adapterName:r.adapterName,context:t}).catch(e=>window.alert(`Cannot add instance: ${e}`)))})}}):null}async addInstance(t){if(!t.customUrl){let e=t.context.repository[t.adapterName],n=kt(e.messages,null,e.version,t.context.compactInstances);if(!t.instance&&(t.context.expertMode||n))return this.setState({addInstanceDialog:t.adapterName,showDialog:!0,addInstanceHostName:t.context.currentHost.replace(/^system\.host\./,``),addInstanceId:t.instance||`auto`}),!1;if(t.instance){let e=await t.context.instancesWorker.getObjects();if(e&&e[`system.adapter.${t.adapterName}.${t.instance}`])return window.alert(t.context.t(`Instance %s already exists`,`${t.adapterName}.${t.instance}`)),!1}}let n=(t.host||this.state.addInstanceHostName||t.context.currentHost).replace(/^system\.host\./,``);if(!t.customUrl){let r=await e.getSingletonRefusal(t.adapterName,n,t.context);if(r)return window.alert(r),!1}try{await new Promise((e,r)=>{t.context.executeCommand(`${t.customUrl?`url`:`add`} ${t.adapterName} ${t.instance?`${t.instance} `:``}--host ${n} ${t.debug||t.context.expertMode?`--debug`:``}`,n,t=>t?r(Error(`The process returned an exit code of ${t}`)):e(),t.files)})}catch(e){return window.alert(`${C.t(`Cannot install`)}: ${e}`),!1}return!0}static isSingletonInstalled(e,t){var n;if(!((n=t.adapters[`system.adapter.${e}`])!=null&&(n=n.common)!=null&&n.singleton))return!1;let r=`system.adapter.${e}.`;return Object.keys(t.compactInstances).some(e=>e.startsWith(r))}static async getSingletonRefusal(e,t,n){var r;let i=(r=n.adapters[`system.adapter.${e}`])==null?void 0:r.common;if(!(i!=null&&i.singleton)&&!(i!=null&&i.singletonHost))return null;let a=await n.instancesWorker.getObjects().catch(()=>null)||{},o=`system.adapter.${e}.`,s=Object.values(a).filter(e=>e==null?void 0:e._id.startsWith(o));if(i.singleton&&s.length)return n.t(`Adapter "%s" allows only one instance, and %s exists already`,e,s[0]._id.substring(15));let c=s.find(e=>e.common.host===t);return i.singletonHost&&c?n.t(`Adapter "%s" allows only one instance per host, and %s exists already on host "%s"`,e,c._id.substring(15),t):null}static async createInstanceIfNotExists(e){let{adapterName:t,context:n}=e,r=(e.host||n.currentHost).replace(/^system\.host\./,``),i;for(let e=0;e<5&&!i;e++){await new Promise(e=>setTimeout(e,500));try{i=await n.socket.getObject(`system.adapter.${t}`)}catch{}}if(!i){console.warn(`Cannot create an instance: adapter "${t}" not found after the installation`);return}let a=await n.instancesWorker.getObjects(!0);if(!(a&&Object.keys(a).find(e=>e.startsWith(`system.adapter.${t}.`))))try{await new Promise((i,a)=>{n.executeCommand(`add ${t} --host ${r} ${e.debug||n.expertMode?`--debug`:``}`,r,e=>e?a(Error(`The process returned an exit code of ${e}`)):i())})}catch(e){window.alert(`${C.t(`Cannot create instance`)}: ${e}`)}}static getDependencies(e,t){let n=t.repository[e],r=[];if(n){let e=n.dependencies?Array.isArray(n.dependencies)?n.dependencies:[n.dependencies]:[],a=n.globalDependencies?Array.isArray(n.globalDependencies)?n.globalDependencies:[n.globalDependencies]:[],o=n.node;if(e.length)for(let n of e){let e={name:``,version:null,installed:!1,installedVersion:null,rightVersion:!1},i=typeof n!=`string`,a=Object.keys(n);if(e.name=(i?a?a[0]:``:n)||``,e.version=i?n[e.name]:null,e.name){let n=t.installed[e.name];e.installed=!!n,e.installedVersion=n?n.version:null;try{e.rightVersion=n?!i||R.satisfies(n.version,e.version||`*`,{includePrerelease:!0}):!1}catch{e.rightVersion=!0}}r.push(e)}if(a.length)for(let e of a){let n={name:``,version:null,installed:!1,installedVersion:null,rightVersion:!1},a=typeof e!=`string`,o=Object.keys(e);if(n.name=(a?o?o[0]:``:e)||``,n.version=a?e[n.name]:null,n.name){var i;let e=t.installedGlobal[n.name];n.installed=!!e,n.installedVersion=e?e.version:null;let r=(i=t.installedGlobalHosts)==null?void 0:i[n.name];if(a&&r&&Object.keys(r).length>1){let t=[];for(let[e,i]of Object.entries(r)){let r;try{r=R.satisfies(i,n.version||`*`,{includePrerelease:!0})}catch{r=!0}r||t.push({host:e,installedVersion:i})}n.wrongHosts=t,n.rightVersion=e?!t.length:!1}else try{n.rightVersion=e?!a||R.satisfies(e.version,n.version||`*`,{includePrerelease:!0}):!1}catch{n.rightVersion=!0}}r.push(n)}let s=n.ifInstalledDependencies||{};if(typeof s==`object`&&!Array.isArray(s)){let e=Object.keys(s);for(let n of e){let e={name:n,version:s[n],installed:!1,installedVersion:null,rightVersion:!1};if(e.name){let n=t.installedGlobal[e.name];e.installed=!!n,e.installedVersion=n?n.version:null;try{e.rightVersion=!n||R.satisfies(n.version,e.version||`*`,{includePrerelease:!0})}catch{e.rightVersion=!0}}r.push(e)}}if(o){let e={name:`node`,version:o,installed:!0,installedVersion:t.nodeJsVersion,rightVersion:!1};try{e.rightVersion=R.satisfies(t.nodeJsVersion,o)}catch{e.rightVersion=!0}r.push(e)}}return r}renderAddInstanceDialog(t){return this.state.addInstanceDialog?h(Kt,{adapter:this.state.addInstanceDialog,socket:t.socket,hostsWorker:t.hostsWorker,instancesWorker:t.instancesWorker,dependencies:e.getDependencies(this.state.addInstanceDialog,t),currentHost:`system.host.${this.state.addInstanceHostName}`,currentInstance:this.state.addInstanceId,t:t.t,onClose:e=>{let n=e?this.state.addInstanceDialog:``,r=e?this.state.addInstanceId:``;this.setState({addInstanceDialog:``,addInstanceId:`auto`,showDialog:!1},()=>{if(n)try{this.addInstance({adapterName:n,instance:r,context:t})}catch(e){window.alert(`Cannot add instance: ${e}`)}})},onHostChange:e=>this.setState({addInstanceHostName:e.replace(/^system\.host\./,``)}),onInstanceChange:e=>this.setState({addInstanceId:e.target.value.toString()}),adapterObject:t.repository[this.state.addInstanceDialog],instances:t.compactInstances,toggleTranslation:t.toggleTranslation,noTranslation:this.props.noTranslation,expertMode:t.expertMode,theme:t.theme}):null}static upload(e,t){t.executeCommand(`upload ${e}${t.expertMode?` --debug`:``}`)}onAddInstance(e,t){var n;let r=t.repository[e],i=Rt(r),a=((n=r.licenseInformation)==null?void 0:n.license)||r.license;a===`MIT`||a===`Apache-2.0`||a===`ISC`||a===`BSD-3-Clause`||a===`BSD-2-Clause`||!a?this.addInstance({adapterName:e,context:t}).catch(e=>window.alert(`Cannot add instance: ${e}`)):this.setState({showLicenseDialog:{url:i,adapterName:e,licenseType:a},showDialog:!0})}renderDialogs(e){return this.state.showDialog?T(D,{children:[this.renderAddInstanceDialog(e),this.renderLicenseDialog(e)]}):null}},J={name:{flexWrap:`nowrap`,width:300,marginTop:0},nameDiv:{display:`flex`,alignItems:`center`},categoryName:{fontWeight:`bold`,cursor:`pointer`},green:{color:te[500]},blue:{color:de[700]},category:{backgroundColor:`background.default`},marginRight5:{marginRight:5}};function qt(e){let{installedCount:t,name:n,categoryName:r}=e;return T(_e,{hover:!1,sx:J.category,children:[h(B,{children:h(O,{container:!0,spacing:1,style:J.name,sx:{alignItems:`center`},children:h(O,{component:`div`,children:h(y,{size:`small`,onClick:e.onToggle,children:e.expanded?h(i,{}):h(Ze,{})})})})}),h(B,{onClick:e.onToggle,children:T(`div`,{style:{...J.nameDiv,...J.categoryName},children:[h(Et,{iconName:r,style:J.marginRight5}),n]})}),T(B,{colSpan:e.descHidden?5:6,children:[h(P,{component:`span`,variant:`body2`,style:J.green,children:t}),` ${e.t(`of`)} `,h(P,{component:`span`,variant:`body2`,style:J.blue,children:e.count}),` ${e.t(`Adapters from this Group installed`)}`]})]})}var Y={rating:{marginBottom:20},listRating:{marginRight:8},listTime:{opacity:.5,fontStyle:`italic`},list:{},listOwn:e=>({backgroundColor:e.palette.mode===`light`?`#16516e2e`:e.palette.secondary.dark}),listTitle:e=>({backgroundColor:e.palette.primary.dark,pt:`4px`,pb:`4px`,mb:`4px`,color:`#ffffff`,textAlign:`center`}),languageFilter:{width:300},ratingTextControl:{width:`calc(100% - 138px)`,marginRight:8},ratingLanguageControl:{width:130},noComments:{width:`100%`,textAlign:`center`,marginTop:16},commentCount:{marginTop:2,marginLeft:8,opacity:.8,fontSize:10,float:`right`},infoText:{textAlign:`left`,fontSize:`14px`},infoTextContainer:{display:`flex`,paddingBottom:`10px`,alignItems:`center`,gap:`10px`}},Jt=[{id:`en`,title:`English`},{id:`de`,title:`Deutsch`},{id:`ru`,title:`русский`},{id:`pt`,title:`Portugues`},{id:`nl`,title:`Nederlands`},{id:`fr`,title:`français`},{id:`it`,title:`Italiano`},{id:`es`,title:`Espanol`},{id:`pl`,title:`Polski`},{id:`uk`,title:`Українська`},{id:`zh-cn`,title:`简体中文`}],Yt=class extends z{constructor(e){super(e),this.state={ratingNumber:0,ratingComment:``,votings:null,ratingLang:this.props.lang,filterLang:(window._localStorage||window.localStorage).getItem(`app.commentLang`)||this.props.lang,commentsByLanguage:{}}}componentDidMount(){fetch(`https://rating.iobroker.net/adapter/${this.props.adapter}?uuid=${this.props.uuid}`).then(e=>e.json()).then(e=>{e||={},e.rating||={};let t=Object.keys(e.rating);t.sort((t,n)=>e.rating[t].ts>e.rating[n].ts?-1:+(e.rating[t].ts<e.rating[n].ts));let n={};if(e.comments&&(e.comments.sort((e,t)=>e.ts>t.ts?-1:+(e.ts<t.ts)),e.comments.forEach(e=>{n[e.lang]=n[e.lang]||0,n[e.lang]++})),t.length){let r=e.rating[t[0]];this.setState({votings:e,ratingNumber:r?r.r:0,commentsByLanguage:n})}else this.setState({votings:e,commentsByLanguage:n})})}setAdapterRating(e,t,n,r,i){return fetch(`https://rating.iobroker.net/vote`,{method:`POST`,headers:{"Content-Type":`application/json`},redirect:`follow`,body:JSON.stringify({uuid:this.props.uuid,adapter:e,version:t,rating:n,comment:r,lang:i})}).then(e=>e.json()).then(r=>(window.alert(`${this.props.t(`Vote:`)} ${e}@${t}=${n}`),delete r.adapter,r)).catch(e=>(window.alert(`Cannot vote: ${e}`),null))}renderInfoText(){return T(`div`,{style:Y.infoTextContainer,children:[h(xe,{}),h(P,{style:Y.infoText,children:this.props.t(`use GitHub for issues`)})]})}renderComments(){var e;if((e=this.state.votings)!=null&&e.comments&&this.state.votings.comments.length){let e=this.state.votings.comments.find(e=>!(this.state.filterLang&&this.state.filterLang!==`_`&&e.lang!==this.state.filterLang));return T(`div`,{style:{width:`100%`,textAlign:`left`},children:[h(j,{component:`h3`,sx:Y.listTitle,children:this.props.t(`Comments`)}),T(o,{variant:`standard`,style:Y.languageFilter,children:[h(_,{children:this.props.t(`Show comments in language`)}),T(Fe,{variant:`standard`,value:this.state.filterLang,onChange:e=>{(window._localStorage||window.localStorage).setItem(`app.commentLang`,e.target.value),this.setState({filterLang:e.target.value})},children:[T(F,{value:`_`,children:[this.props.t(`All`),` `,h(`span`,{style:Y.commentCount,children:this.state.votings.comments.length})]}),Jt.map(e=>T(F,{value:e.id,children:[e.title,` `,this.state.commentsByLanguage[e.id]?h(`span`,{style:Y.commentCount,children:this.state.commentsByLanguage[e.id]}):null]},e.id))]})]}),T(se,{style:Y.list,dense:!0,disablePadding:!0,children:[e&&this.state.votings.comments.map((e,n)=>this.state.filterLang&&this.state.filterLang!==`_`&&e.lang!==this.state.filterLang?null:e?T(t,{title:e.uuid?this.props.t(`Your comment`):``,sx:{"&.MuiListItem-root":e.uuid?Y.listOwn:void 0},dense:!0,children:[h(Ce,{style:Y.listRating,children:h(Te,{readOnly:!0,defaultValue:e.rating,size:`small`})}),h(Re,{primary:e.comment,secondary:`${new Date(e.ts).toLocaleString()} / v${e.version}`,sx:{"& .MuiListItemText-secondary":Y.listTime}})]},n):null),!e&&h(`div`,{style:Y.noComments,children:this.props.t(`No comments in selected language`)})]})]})}return null}render(){var e,t;let n,r;if(this.state.votings){let e=this.state.votings.rating||{};r=Object.keys(e),r.sort((t,n)=>e[t].ts>e[n].ts?-1:+(e[t].ts<e[n].ts)),r.length&&(n=e[r[0]])}return T(a,{open:!0,onClose:()=>this.props.onClose(),children:[h(x,{children:`${this.props.t(`Review`)} ${this.props.adapter}${this.props.version?`@${this.props.version}`:``}`}),T(b,{style:{textAlign:`center`},title:((e=this.props.currentRating)==null?void 0:e.title)||``,children:[this.renderInfoText(),h(Te,{style:Y.rating,name:this.props.adapter,value:this.props.version?this.state.ratingNumber:(t=this.props.currentRating)==null||(t=t.rating)==null?void 0:t.r,size:`large`,readOnly:!this.props.version,onChange:(e,t)=>this.setState({ratingNumber:t})}),this.props.version?T(`div`,{style:{width:`100%`,textAlign:`left`},children:[h(N,{variant:`standard`,style:Y.ratingTextControl,value:this.state.ratingComment,label:this.props.t(`Comment to version`),helperText:this.props.t(`Max length %s characters`,200),onChange:e=>this.setState({ratingComment:e.target.value}),slotProps:{input:{endAdornment:this.state.ratingComment?h(L,{position:`end`,children:h(y,{tabIndex:-1,size:`small`,onClick:()=>this.setState({ratingComment:``}),children:h(v,{})})}):null},htmlInput:{maxLength:200}}}),T(o,{variant:`standard`,style:Y.ratingLanguageControl,children:[h(_,{children:this.props.t(`Language`)}),h(Fe,{variant:`standard`,value:this.state.ratingLang,onChange:e=>this.setState({ratingLang:e.target.value}),children:Jt.map(e=>h(F,{value:e.id,children:e.title},e.id))})]})]}):null,this.props.version?h(`div`,{style:{paddingTop:20,paddingBottom:16},children:this.props.t(`Rate how good this version of the adapter works on your system. You can vote for every new version.`)}):null,r&&n?h(`div`,{children:this.props.t(`You voted for %s on %s`,r[0],new Date(n.ts).toLocaleDateString())}):null,this.renderComments()]}),T(M,{children:[this.props.version&&h(V,{variant:`contained`,autoFocus:!0,color:`primary`,disabled:!this.state.ratingNumber||this.state.votings===null,onClick:()=>{this.state.ratingNumber!==(n==null?void 0:n.r)||this.state.ratingComment?this.setAdapterRating(this.props.adapter,this.props.version,this.state.ratingNumber||5,this.state.ratingComment,this.state.ratingLang).then(e=>this.props.onClose(e)):this.props.onClose()},startIcon:h(Ye,{}),children:this.props.t(`Rate`)}),h(V,{autoFocus:!this.props.version,variant:`contained`,onClick:()=>this.props.onClose(),color:`grey`,startIcon:h(v,{}),children:this.props.t(`Close`)})]})]})}};d();var Xt={formControl:{marginTop:24},closeButton:e=>({position:`absolute`,right:8,top:8,color:e.palette.grey[500]}),typography:{paddingRight:30}},Zt=class extends z{constructor(e){super(e),w(this,`t`,void 0),this.state={deleteCustom:!1,deleteCustomSupported:!1},this.t=e.t}componentDidMount(){this.props.socket.checkFeatureSupported(`DEL_INSTANCE_CUSTOM`).then(e=>{if(e)return this.props.socket.getObject(`system.adapter.${this.props.adapter}`).then(e=>{e!=null&&e.common?e.common.supportCustoms&&this.setState({deleteCustomSupported:e.common.supportCustoms}):this.setState({deleteCustomSupported:!0})})})}render(){return T(a,{onClose:this.props.onClose,open:!0,children:[h(x,{children:T(P,{component:`h2`,variant:`h6`,sx:{"&.MuiTypography-root":Xt.typography},children:[this.t(`Please confirm`),h(y,{size:`large`,sx:Xt.closeButton,onClick:this.props.onClose,children:h(v,{})})]})}),T(b,{dividers:!0,children:[h(P,{gutterBottom:!0,children:this.t(`Are you sure you want to delete adapter %s?`,this.props.adapter)}),this.state.deleteCustomSupported&&h(E,{control:h(S,{checked:this.state.deleteCustom,onChange:e=>this.setState({deleteCustom:e.target.checked})}),label:this.t(`Delete all custom object settings of this adapter too`)})]}),T(M,{children:[h(V,{id:`adapter-delete-dialog-ok`,variant:`contained`,autoFocus:!0,onClick:()=>{this.props.onClick(this.state.deleteCustom),this.props.onClose()},color:`primary`,startIcon:h(pe,{}),children:this.t(`Ok`)}),h(V,{id:`adapter-delete-dialog-cancel`,variant:`contained`,autoFocus:!0,onClick:()=>this.props.onClose(),color:`grey`,startIcon:h(v,{}),children:this.t(`Close`)})]})]})}},Qt={none:h($e,{}),patch:h(tt,{style:{color:`green`}}),minor:h(Qe,{style:{color:`orange`}}),major:h(ne,{style:{color:`red`}})},$t=class extends Ie.Component{constructor(e){super(e),this.state={currentSavedPolicy:`none`,policy:`none`,repositories:[],supported:!0}}async componentDidMount(){await this.getConfiguredRepositories(),await this.getCurrentAutoUpgradeSetting()}async getConfiguredRepositories(){var e;let t=await this.props.socket.getObject(`system.config`);if(!(t!=null&&(e=t.common)!=null&&e.adapterAutoUpgrade))return;let n=Object.entries(t.common.adapterAutoUpgrade.repositories).filter(([,e])=>e).map(([e])=>e);this.setState({repositories:n})}getAdapterId(){return`${this.props.hostId}.adapter.${this.props.adapter}`}async getCurrentAutoUpgradeSetting(){let e=await this.props.socket.getObject(this.getAdapterId());e?this.setState({policy:e.common.automaticUpgrade||`none`,currentSavedPolicy:e.common.automaticUpgrade||`none`}):(console.error(`no adapter object existing`),this.setState({supported:!1}))}async save(){let e=await this.props.socket.getObject(this.getAdapterId());e?(e.common.automaticUpgrade=this.state.policy,await this.props.socket.setObject(this.getAdapterId(),e),this.setState({currentSavedPolicy:this.state.policy},()=>this.props.onClose())):(console.error(`no adapter object existing`),this.setState({supported:!1}))}render(){return T(a,{open:!0,maxWidth:`md`,fullWidth:!0,children:[h(x,{children:C.t(`Auto upgrade policy for %s`,this.props.adapter)}),T(b,{style:{padding:`0 20px`,overflow:`hidden`},children:[h(H,{value:!this.state.supported,children:h(P,{children:C.t(`This feature is supported up from js-controller Kiera (Version 6)!`)})}),T(H,{value:this.state.supported,children:[h(P,{children:C.t(`Allow only the following upgrades to be performed automatically:`)}),h(Fe,{variant:`standard`,style:{marginTop:20,minWidth:150,marginBottom:8},value:this.state.policy,onChange:e=>this.setState({policy:e.target.value}),children:pt.map(e=>h(F,{value:e,children:T(`div`,{style:{display:`flex`,gap:8},children:[Qt[e],dt[e]]})},e))}),h(H,{value:this.state.repositories.includes(`beta`)&&this.state.policy!==`none`,children:h(ke,{type:`warning`,children:C.t(`repo_update_hint`)})}),h(H,{value:this.state.policy===`major`,children:h(ke,{type:`warning`,children:C.t(`The current selected configuration will allow to automatically pull in incompatible changes of this adapter!`)})})]})]}),T(M,{children:[h(V,{disabled:this.state.currentSavedPolicy===this.state.policy,color:`primary`,variant:`contained`,startIcon:h(f,{}),onClick:()=>this.save(),children:C.t(`Save`)}),h(V,{variant:`contained`,onClick:()=>this.props.onClose(),color:`grey`,startIcon:h(v,{}),children:C.t(`Close`)})]})]})}};d();var en=new Set([`admin`,`eos-admin`,`backitup`,`nexowatt-devices`,`nexowatt-device`,`nexowatt-dev`,`nexowatt-ui`]),tn=e=>String(e||``).toLowerCase().replace(/^system\.adapter\./,``).replace(/^iobroker\./,``).replace(/^@nexowatt\/iobroker\./,``).replace(/^@nexowatt\//,``).replace(/\.\d+$/,``),nn=e=>{let t=tn(e);return en.has(t)},rn={hidden:{display:`none`},buttonUpdate:{border:`1px solid`,padding:`0px 7px`,borderRadius:5,display:`flex`,alignItems:`center`,cursor:`pointer`,transition:`background 0.5s`,"&:hover":{background:`#00800026`}},buttonUpdateIcon:{height:20,width:20,marginRight:10},classPoll:{color:`orange`},classPush:{color:`green`},classAssumption:{color:`red`,transform:`rotate(90deg)`},marginLeft5:{marginLeft:5},ratingSet:{cursor:`pointer`},sentry:{width:21,height:21,objectFit:`fill`,marginTop:3,filter:`invert(0%) sepia(90%) saturate(1267%) hue-rotate(-260deg) brightness(99%) contrast(97%)`},tooltip:{pointerEvents:`none`},wrongDependencies:{color:qe[700]},updateAvailable:{color:te[700]},repositoryVersionAvailable:{color:g[800]},currentVersion:e=>({cursor:`pointer`,mb:`6px`,mr:`8px`,mt:`4px`,"&:hover":{background:e.palette.primary.dark}}),header:e=>({fontWeight:`bold`,background:e.palette.secondary.main,p:`10px`}),modalDialog:{height:`calc(100% - 64px)`,overflowY:`hidden`},currentVersionText:e=>({color:e.palette.mode===`dark`?`#a3ffa3`:`#009800`,fontWeight:`bold`,marginLeft:`4px`}),repoStableVersionText:e=>({color:e.palette.mode===`dark`?`#8dff7a`:`#2b9800`,fontWeight:`bold`,marginLeft:`4px`}),repoLatestVersionText:e=>({color:e.palette.mode===`dark`?`#a3fcff`:`#005498`,fontWeight:`bold`,marginLeft:`4px`}),rating:{},containerVersion:{},containerSpecificVersion:{},versionWarn:{color:g[500]},cardContentFlexBetween:{},cardContentFlex:{}},an=class e extends q{constructor(e){super(e),w(this,`installedVersion`,``),Object.assign(this.state,{autoUpgradeDialogOpen:!1,showUpdateDialog:!1,installRepositoryVersion:!1,adapterDeletionDialog:!1,adapterInstallSpecificVersion:``,showInstallVersion:!1,showSetRating:null})}static renderImage(e){var t;let{style:n,alt:r,...i}=e,a=(t=n.backgroundImage)==null?void 0:t.substring(5,n.backgroundImage.length-2);return h(`img`,{...i,alt:r,src:a,onError:e=>{e.target&&(e.target.onerror=null,e.target.src=`img/no-image.svg`)}})}renderAddInstanceButton(){let e=!this.props.context.repository[this.props.adapterName]||this.props.context.repository[this.props.adapterName].allowAdapterInstall;return h(H,{value:e!==!1&&!q.isSingletonInstalled(this.props.adapterName,this.props.context),children:h(I,{title:this.props.context.t(`Add instance`),slotProps:{popper:{sx:this.styles.tooltip}},children:h(y,{size:`small`,disabled:this.props.commandRunning,style:this.props.cached.rightOs?void 0:this.styles.hidden,onClick:this.props.cached.rightOs?e=>{e.preventDefault(),e.stopPropagation(),this.onAddInstance(this.props.adapterName,this.props.context)}:void 0,children:h(s,{})})})})}renderAutoUpgradeButton(){var e;let t=this.props.context.hostAdapterWorker.getObject(this.props.adapterName);if(!t)return h(`div`,{style:{width:34,height:34,display:`inline-block`}});let n=(e=t.common)==null?void 0:e.automaticUpgrade;return h(I,{title:this.props.context.t(`Automatic Upgrade Policy`)+(n?`: ${n}`:``),slotProps:{popper:{sx:this.styles.tooltip}},children:h(y,{size:`small`,onClick:e=>{e.preventDefault(),e.stopPropagation(),this.setState({autoUpgradeDialogOpen:!0,showDialog:!0})},children:!n||n===`none`?h(it,{}):Qt[n]})})}renderReadmeButton(){let e=!this.props.context.repository[this.props.adapterName]||this.props.context.repository[this.props.adapterName].allowAdapterReadme;return h(H,{value:e,children:h(I,{title:this.props.context.t(`Readme`),slotProps:{popper:{sx:this.styles.tooltip}},children:h(y,{size:`small`,onClick:e=>{e.preventDefault(),e.stopPropagation(),this.openInfoDialog()},children:h(re,{})})})})}renderRating(){var e,t;let n=!this.props.context.repository[this.props.adapterName]||this.props.context.repository[this.props.adapterName].allowAdapterRating;return this.props.context.isTileView&&(this.props.context.sortPopularFirst||this.props.context.sortRecentlyUpdated||this.props.context.sortRecentlyCreated)||!this.props.context.repository[this.props.adapterName].stat||n===!1?null:h(`div`,{onClick:()=>this.setState({showSetRating:{version:this.installedVersion,rating:this.props.context.repository[this.props.adapterName].rating},showDialog:!0}),style:{...this.styles.rating,...this.styles.ratingSet},title:(e=this.props.context.repository[this.props.adapterName].rating)==null?void 0:e.title,children:h(Te,{name:this.props.adapterName,precision:.5,size:`small`,readOnly:!0,value:((t=this.props.context.repository[this.props.adapterName].rating)==null||(t=t.rating)==null?void 0:t.r)||0})})}renderConnectionType(){var e;let t=(e=this.props.context.repository[this.props.adapterName])==null?void 0:e.connectionType;return t===`cloud`?h(I,{title:this.props.context.t(`Adapter requires the specific cloud access for these devices/service`),slotProps:{popper:{sx:this.styles.tooltip}},children:h(wt,{})}):t===`local`?h(I,{title:this.props.context.t(`Adapter does not use the cloud for these devices/service`),slotProps:{popper:{sx:this.styles.tooltip}},children:h(Xe,{})}):null}renderDataSource(){var e;let t=(e=this.props.context.repository[this.props.adapterName])==null?void 0:e.dataSource;return t?h(`div`,{style:this.styles.marginLeft5,title:t,children:t===`poll`?h(I,{title:this.props.context.t(`The device or service will be periodically asked`),slotProps:{popper:{sx:this.styles.tooltip}},children:h(Oe,{style:this.styles.classPoll})}):t===`push`?h(I,{title:this.props.context.t(`The device or service delivers the new state actively`),slotProps:{popper:{sx:this.styles.tooltip}},children:h(ae,{style:this.styles.classPush})}):t===`assumption`?h(I,{slotProps:{popper:{sx:this.styles.tooltip}},title:this.props.context.t(`Adapter cannot request the exactly device status and the status will be guessed on the last sent command`),children:h(lt,{style:this.styles.classAssumption})}):h(`div`,{style:{width:24,height:24}})}):null}renderLicenseInfo(e=!1){var t,n,r,i;let a=this.props.context.repository[this.props.adapterName],o=Lt(a),s=(t=a.licenseInformation)!=null&&t.type?h(he,{href:o,target:`_blank`,rel:`noopener`,sx:e=>({color:e.palette.mode===`dark`?`white`:`black`,"&:hover":{color:e.palette.mode===`dark`?`white`:`black`}}),children:((n=a.licenseInformation)==null?void 0:n.type)===`paid`?h(I,{title:this.props.context.t(`The adapter requires a paid license.`),slotProps:{popper:{sx:this.styles.tooltip}},children:h(Je,{})}):((r=a.licenseInformation)==null?void 0:r.type)===`commercial`?h(I,{slotProps:{popper:{sx:this.styles.tooltip}},title:this.props.context.t(`The adapter requires a paid license for commercial use.`),children:h(Je,{opacity:.5})}):((i=a.licenseInformation)==null?void 0:i.type)===`limited`?h(I,{slotProps:{popper:{sx:this.styles.tooltip}},title:this.props.context.t(`The adapter has a limited functionality without a paid license.`),children:h(Je,{opacity:.5})}):null}):null;return!s&&e?h(`div`,{style:{width:24,height:24}}):s}renderSentryInfo(){var e;return(e=this.props.context.repository[this.props.adapterName])!=null&&(e=e.plugins)!=null&&e.sentry?h(`div`,{style:this.styles.marginLeft5,children:h(I,{title:`sentry`,slotProps:{popper:{sx:this.styles.tooltip}},children:h(Ue,{style:this.styles.sentry,component:`img`,image:Dt})})}):null}getDependencies(){let e=q.getDependencies(this.props.adapterName,this.props.context);if(!e)return null;let t=[];for(let r of e){var n;r.installedVersion?(n=r.wrongHosts)!=null&&n.length?t.push(`${this.props.context.t(`The following hosts do not fulfill the required version %s of %s:`,r.version||`unknown`,r.name)} ${r.wrongHosts.map(e=>`${e.host} (${e.installedVersion})`).join(`, `)}`):r.rightVersion||t.push(`${this.props.context.t(`Invalid version of %s. Required %s. Current `,r.name,r.version||`unknown`)}${r.installedVersion}`):t.push(this.props.context.t(`No version of %s`,r.name,r.name))}return t.length?(t.unshift(this.props.context.t(`Wrong dependencies`)),t.map((e,t)=>h(`div`,{style:t?void 0:{fontWeight:`bold`,fontSize:`larger`},children:e},e))):null}renderVersion(){let e=!this.props.context.repository[this.props.adapterName]||this.props.context.repository[this.props.adapterName].allowAdapterUpdate,t=this.props.context.repository[this.props.adapterName],n=t==null?void 0:t.version;return n?!this.props.commandRunning&&e!==!1&&this.isRepositoryVersionInstallable()?h(I,{title:this.props.context.t(`Install version %s from repository`,n),slotProps:{popper:{sx:this.styles.tooltip}},children:T(`div`,{onClick:()=>this.setState({showUpdateDialog:!0,showDialog:!0,installRepositoryVersion:!0}),style:{...this.styles.buttonUpdate,...this.props.cached.rightDependencies?this.styles.repositoryVersionAvailable:void 0},children:[h(y,{style:this.styles.buttonUpdateIcon,size:`small`,children:h(yt,{})}),n]})}):!this.props.commandRunning&&this.props.cached.updateAvailable&&e!==!1?h(I,{title:this.props.context.t(`Update`),slotProps:{popper:{sx:this.styles.tooltip}},children:T(`div`,{onClick:e=>{e.preventDefault(),e.stopPropagation(),this.setState({showUpdateDialog:!0,showDialog:!0,installRepositoryVersion:!1})},style:{...this.styles.buttonUpdate,...this.props.cached.rightDependencies?this.styles.updateAvailable:void 0},children:[h(y,{style:this.styles.buttonUpdateIcon,size:`small`,children:h(He,{})}),n]})}):h(I,{title:this.getDependencies(),slotProps:{popper:{sx:this.styles.tooltip}},children:h(`span`,{style:this.props.cached.rightDependencies?void 0:this.styles.wrongDependencies,children:n})}):h(`span`,{style:this.styles.wrongDependencies,children:this.props.context.t(`not maintained`)})}isRepositoryVersionInstallable(){var e,t,n;let r=(e=this.props.context.repository[this.props.adapterName])==null?void 0:e.version,i=(t=this.props.context.installed[this.props.adapterName])==null?void 0:t.version;if(!r||!i||this.props.cached.updateAvailable)return!1;if(r!==i)return mt.updateAvailable(r,i,`adapter "${this.props.adapterName}"`);let a=(n=this.props.context.adapters[`system.adapter.${this.props.adapterName}`])==null||(n=n.common)==null?void 0:n.installedFrom;return!!a&&!a.startsWith(`iobroker.${this.props.adapterName}@`)}static extractGitHubCommitHash(e){if(!e)return null;let t=e.indexOf(`#`);if(t===-1)return null;let n=e.substring(t+1);return n.length>=7?n.substring(0,7):n}renderInstalledVersion(t){var n;let r=this.props.context.installed[this.props.adapterName],i=(n=this.props.context.adapters[`system.adapter.${this.props.adapterName}`])==null||(n=n.common)==null?void 0:n.installedFrom,{adapterName:a}=this.props,o=i&&!i.startsWith(`iobroker.${a}@`),s=o?e.extractGitHubCommitHash(i):null,c=o&&s?`${this.installedVersion}+${s}`:this.installedVersion;if(t){let e=r==null?void 0:r.enabled,t=r==null?void 0:r.count;return T(O,{container:!0,wrap:`nowrap`,spacing:1,sx:{alignItems:`center`},children:[this.installedVersion?h(O,{children:c+(t?` (${t}${t===e?``:`~`})`:``)}):null,o&&h(O,{container:!0,children:h(I,{title:`${this.props.context.t(`Non-NPM-Version`)}: ${i}`,slotProps:{popper:{sx:this.styles.tooltip}},children:h(ot,{fontSize:`small`,style:this.styles.versionWarn})})})]})}return this.installedVersion?T(P,{component:`span`,style:this.styles.cardContentFlexBetween,children:[T(`div`,{children:[this.props.context.t(`Installed version`),`:`]}),T(`div`,{style:this.styles.cardContentFlex,children:[o&&h(I,{title:`${this.props.context.t(`Non-NPM-Version`)}: ${i}`,slotProps:{popper:{sx:this.styles.tooltip}},children:h(ot,{fontSize:`small`,style:this.styles.versionWarn})}),c]})]}):null}renderUploadButton(){return this.props.context.expertMode&&this.installedVersion?h(I,{title:this.props.context.t(`Upload`),slotProps:{popper:{sx:this.styles.tooltip}},children:h(y,{size:`small`,disabled:this.props.commandRunning,"data-eos-adapter-action":`upload`,onClick:e=>{e.preventDefault(),e.stopPropagation(),this.onUpload()},children:h(be,{})})}):null}renderDeleteButton(){let e=nn(this.props.adapterName);return h(H,{value:!!this.installedVersion&&!e,children:h(I,{title:this.props.context.t(`Delete adapter`),slotProps:{popper:{sx:this.styles.tooltip}},children:h(y,{size:`small`,disabled:this.props.commandRunning,"data-eos-adapter-action":`delete`,onClick:e=>{e.preventDefault(),e.stopPropagation(),this.setState({adapterDeletionDialog:!0,showDialog:!0})},children:h(ct,{})})})})}renderInstallSpecificVersionButton(){return this.props.context.expertMode&&this.installedVersion?h(I,{title:this.props.context.t(`Install a specific version`),slotProps:{popper:{sx:this.styles.tooltip}},children:h(y,{disabled:this.props.commandRunning,size:`small`,"data-eos-adapter-action":`install-specific-version`,onClick:e=>{e.preventDefault(),e.stopPropagation(),this.setState({showInstallVersion:!0,showDialog:!0})},children:h(nt,{})})}):null}renderRebuildButton(){return!this.props.context.expertMode||!this.installedVersion?null:h(I,{title:this.props.context.t(`Rebuild`),children:h(y,{size:`small`,disabled:this.props.commandRunning,"data-eos-adapter-action":`rebuild`,onClick:e=>{e.preventDefault(),e.stopPropagation(),this.rebuild()},children:h(fe,{})})})}renderAutoUpdateDialog(){return this.state.autoUpgradeDialogOpen?h($t,{onClose:()=>this.setState({autoUpgradeDialogOpen:!1,showDialog:!1}),adapter:this.props.adapterName,hostId:this.props.context.adminHost,socket:this.props.context.socket}):null}async ignoreVersion(e){let t=await this.props.context.socket.getObject(`system.adapter.${this.props.adapterName}`);t!=null&&t.common?(t.common.ignoreVersion=e,this.props.context.socket.setObject(t._id,t).catch(e=>window.alert(`Cannot write object: ${e}`))):window.alert(`Adapter "${this.props.adapterName}" does not exist!`),this.props.context.removeUpdateAvailable(this.props.adapterName)}renderUpdateAdapterDialog(){var e,t;if(!this.state.showUpdateDialog)return null;this.installedVersion=(e=this.props.context.installed[this.props.adapterName])==null?void 0:e.version;let n=(t=this.props.context.repository[this.props.adapterName])==null?void 0:t.version;return h(jt,{textTitle:this.state.installRepositoryVersion?this.props.context.t(`Install "%s" v%s from repository instead of v%s`,this.props.adapterName,n,this.installedVersion):void 0,textUpdate:this.state.installRepositoryVersion?this.props.context.t(`Install`):void 0,adapter:this.props.adapterName,adapterObject:this.props.context.repository[this.props.adapterName],t:this.props.context.t,dependencies:q.getDependencies(this.props.adapterName,this.props.context),rightDependencies:this.props.context.rightDependenciesFunc(this.props.adapterName),news:this.getNews(),toggleTranslation:this.props.context.toggleTranslation,noTranslation:this.props.noTranslation,installedVersion:this.installedVersion,onUpdate:e=>this.setState({showUpdateDialog:!1,showDialog:!1},()=>this.update(e)),isStable:this.props.context.repository._repoInfo.stable,onIgnore:this.state.installRepositoryVersion?void 0:e=>this.setState({showUpdateDialog:!1,showDialog:!1},()=>void this.ignoreVersion(e)),onClose:()=>this.setState({showUpdateDialog:!1,showDialog:!1}),instances:this.props.context.compactInstances,theme:this.props.context.theme})}static formatNews(e){return(e||``).toString().split(`
4
- `).map(e=>e.trim().replace(/^\*+/,``).replace(/^-/,``).replace(/\*+$/,``).replace(/\r/g,``).trim()).filter(e=>e).map((e,t)=>T(`div`,{style:{},children:[h(`span`,{children:`- `}),e]},t))}renderAdapterInstallVersion(){if(!this.state.showInstallVersion)return null;let t,n,r=this.props.context.repository._repoInfo;if(r!=null&&r.stable){var i,a;t=(i=this.props.context.repository[this.props.adapterName])==null?void 0:i.version,n=(a=this.props.context.repository[this.props.adapterName])==null?void 0:a.latestVersion}else{var o,s;t=(o=this.props.context.repository[this.props.adapterName])==null?void 0:o.stable,n=(s=this.props.context.repository[this.props.adapterName])==null?void 0:s.version}return h(Mt,{title:this.props.context.t(`Please select specific version of %s`,this.props.adapterName),applyButton:!1,onClose:()=>this.setState({showInstallVersion:!1,adapterInstallSpecificVersion:``,showDialog:!1}),theme:this.props.context.theme,toggleTranslation:this.props.context.toggleTranslation,noTranslation:this.props.noTranslation,children:T(`div`,{style:{height:`100%`,overflowY:`hidden`},children:[T(`div`,{style:this.styles.containerSpecificVersion,children:[T(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[h(N,{variant:`standard`,style:{flexGrow:1},label:this.props.context.t(`Enter version manually`),value:this.state.adapterInstallSpecificVersion,onChange:e=>this.setState({adapterInstallSpecificVersion:e.target.value}),slotProps:{input:{endAdornment:this.state.adapterInstallSpecificVersion?h(L,{position:`end`,children:h(y,{tabIndex:-1,size:`small`,onClick:()=>this.setState({adapterInstallSpecificVersion:``}),children:h(v,{})})}):null}}}),h(V,{color:`primary`,variant:`contained`,size:`small`,disabled:!this.state.adapterInstallSpecificVersion,onClick:()=>{this.state.adapterInstallSpecificVersion&&(this.update(this.state.adapterInstallSpecificVersion),this.setState({showInstallVersion:!1,adapterInstallSpecificVersion:``,showDialog:!1}))},children:this.props.context.t(`Install`)})]}),h(I,{title:this.props.context.t(`npmjs.com`),slotProps:{popper:{sx:this.styles.tooltip}},children:h(y,{size:`small`,onClick:()=>{var e;(e=window.open(`https://www.npmjs.com/package/iobroker.${this.props.adapterName}?activeTab=versions`,this.props.adapterName))==null||e.focus()},children:h(ie,{})})})]}),h(j,{component:`div`,sx:this.styles.header,children:this.props.context.t(`Or select from the list`)}),h(`div`,{style:{...this.styles.containerVersion,height:`calc(100% - 122px)`,overflowY:`auto`},children:this.getNews(!0).map(({version:r,news:i})=>h(We,{variant:`outlined`,sx:this.styles.currentVersion,onClick:()=>{this.update(r),this.setState({showInstallVersion:!1,showDialog:!1})},children:T(c,{children:[T(P,{sx:k.getStyle(this.props.context.theme,this.installedVersion===r&&this.styles.currentVersionText,{fontSize:16,fontWeight:`bold`}),color:`text.secondary`,gutterBottom:!0,children:[r,this.installedVersion===r?h(j,{component:`span`,sx:this.styles.currentVersionText,children:`(${this.props.context.t(`current`)})`}):null,n===r?h(j,{component:`span`,sx:this.styles.repoLatestVersionText,children:`(latest)`}):null,t===r?h(j,{component:`span`,sx:this.styles.repoStableVersionText,children:`(${this.props.context.t(`stable`)})`}):null]}),h(P,{variant:`body2`,style:{opacity:.7},children:e.formatNews(i)})]})},r))})]})})}renderSetRatingDialog(){return this.state.showSetRating?h(Yt,{t:this.props.context.t,lang:this.props.context.lang,version:this.state.showSetRating.version,adapter:this.props.adapterName,currentRating:this.state.showSetRating.rating,onClose:e=>{e&&this.props.context.updateRating(this.props.adapterName,e),this.setState({showSetRating:null,showDialog:!1})},uuid:this.props.context.uuid}):null}renderAdapterDeletionDialog(){return this.state.adapterDeletionDialog?h(Zt,{adapter:this.props.adapterName,socket:this.props.context.socket,t:this.props.context.t,onClick:e=>this.delete(e),onClose:()=>this.setState({adapterDeletionDialog:!1,showDialog:!1})}):null}openInfoDialog(){var e;let t=(e=this.props.context.repository[this.props.adapterName].docs)!=null&&e[this.props.context.lang]?this.props.context.lang:`en`;window.open(mt.getDocsLinkForAdapter({lang:t,adapterName:this.props.adapterName}),`help`)}getNews(e=!1){let t=this.props.context.repository[this.props.adapterName],n=this.props.context.installed[this.props.adapterName],r=[];return n&&t!=null&&t.news&&Object.keys(t.news).forEach(i=>{try{if(R.gt(i,n.version)||e){let e;e=typeof t.news[i]==`object`?this.props.noTranslation?t.news[i].en:t.news[i][this.props.context.lang]||t.news[i].en:t.news[i],r.push({version:i,news:e})}}catch{console.warn(`[ADAPTERS] Cannot compare "${i}" and "${n.version}" (${this.props.adapterName})`)}}),r}onUpload(){var e;let t=this.props.context.repository[this.props.adapterName],n=Rt(t),r=((e=t.licenseInformation)==null?void 0:e.license)||t.license;r!==`MIT`&&r!==`Apache-2.0`&&r!==`ISC`&&r!==`BSD-3-Clause`&&r!==`BSD-2-Clause`&&r?this.setState({showLicenseDialog:{url:n,upload:!0,adapterName:this.props.adapterName,licenseType:r},showDialog:!0}):q.upload(this.props.adapterName,this.props.context)}delete(e){nn(this.props.adapterName)?window.alert(`Dieser Adapter ist ein geschütztes NexoWatt-EOS-Systemmodul und darf nicht gelöscht werden.`):this.props.context.executeCommand(`del ${this.props.adapterName}${e?` --custom`:``}${this.props.context.expertMode?` --debug`:``}`)}update(e){this.props.context.executeCommand(`upgrade ${this.props.adapterName}@${e}${this.props.context.expertMode?` --debug`:``}`)}rebuild(){this.props.context.executeCommand(`rebuild ${this.props.adapterName}${this.props.context.expertMode?` --debug`:``}`)}renderDialogs(){return this.state.showDialog?T(D,{children:[this.renderAddInstanceDialog(this.props.context),this.renderLicenseDialog(this.props.context),this.renderUpdateAdapterDialog(),this.renderAdapterInstallVersion(),this.renderSetRatingDialog(),this.renderAdapterDeletionDialog(),this.renderAutoUpdateDialog()]}):null}};d();var on=`0 8px 17px 0 rgba(0, 0, 0, .2),0 6px 20px 0 rgba(0, 0, 0, .19)`,sn={...rn,type:{color:`tile`},root:e=>({position:`relative`,m:`10px`,width:300,minHeight:200,borderRadius:24,overflow:`hidden`,background:`linear-gradient(180deg, rgba(13, 36, 58, 0.90), rgba(7, 23, 39, 0.88))`,boxShadow:`0 14px 30px rgba(0,0,0,.24)`,display:`flex`,flexDirection:`column`,transition:`box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease`,"&:hover":{boxShadow:on}}),imageBlock:e=>({background:`linear-gradient(135deg, rgba(0,255,136,.16), rgba(0,212,255,.11))`,borderBottom:`1px solid rgba(0,255,136,.20)`,minHeight:60,display:`flex`,padding:`0 10px 0 10px`,position:`relative`,justifyContent:`space-between`,color:`#eef7ff`}),img:{width:45,height:45,margin:`auto 0`,position:`relative`,"&:after":{content:`""`,position:`absolute`,zIndex:2,top:0,left:0,width:`100%`,height:`100%`,background:`url("img/no-image.svg") 100% 100% no-repeat`,backgroundSize:`cover`,backgroundColor:`#fff`}},installed:{background:`#77c7ff8c`},update:{background:`#10ff006b`},fab:{position:`absolute`,bottom:-20,width:40,height:40,right:20},greenText:e=>({color:e.palette.success.dark}),collapse:{height:`100%`,background:`linear-gradient(180deg, rgba(8, 29, 47, 0.985), rgba(4, 14, 25, 0.975))`,color:`#eef7ff`,border:`1px solid rgba(0, 255, 136, 0.34)`,borderRadius:24,position:`absolute`,width:`100%`,zIndex:1200,marginTop:`auto`,bottom:0,overflow:`hidden`,pointerEvents:`auto`,justifyContent:`space-between`,display:`flex`,flexDirection:`column`},close:{display:`flex`,ml:`auto`,mt:`-4px`,color:`#eaf9ff`},footerBlock:e=>({background:`rgba(2, 9, 20, 0.90)`,borderTop:`1px solid rgba(0,255,136,.22)`,position:`relative`,zIndex:40,pointerEvents:`auto`,p:`10px`,display:`flex`,justifyContent:`space-between`}),versionDate:{alignSelf:`center`},adapter:e=>({width:`100%`,fontWeight:`bold`,fontSize:16,verticalAlign:`middle`,pl:1,pt:2,color:(e.palette.mode,`#333`)}),adapterWithAgo:{width:`calc(100% - 145px)`},description:e=>({display:`block`,color:`rgba(238, 247, 255, 0.94)`,fontSize:13.5,lineHeight:1.48,whiteSpace:`normal`,overflowWrap:`anywhere`}),cardContent:{overflow:`auto`},cardContentDiv:{position:`sticky`,right:0,top:0,background:`linear-gradient(135deg, rgba(0,255,136,.16), rgba(0,212,255,.09))`,borderBottom:`1px solid rgba(0,255,136,.22)`,zIndex:2},cardContentFlex:{display:`flex`},cardContentFlexBetween:{display:`flex`,justifyContent:`space-between`},cardContent2:{height:`100%`,display:`flex`,flexDirection:`column`,justifyContent:`space-between`},cardMargin10:{marginTop:10},availableVersion:{display:`flex`,justifyContent:`space-between`},curdContentFlexCenter:{display:`flex`,alignItems:`center`},versionWarn:{color:g[500],marginRight:5},rating:{marginTop:20}},cn=class extends an{constructor(e){super(e),w(this,`styles`,sn),Object.assign(this.state,{openCollapse:!1})}renderInfoCard(){return T(`div`,{className:`eos-adapter-info-card`,style:this.styles.collapse,children:[T(c,{style:this.styles.cardContent,children:[h(`div`,{style:this.styles.cardContentDiv,children:h(y,{size:`small`,sx:this.styles.close,onClick:()=>this.setState({openCollapse:!this.state.openCollapse}),children:h(v,{})})}),h(P,{gutterBottom:!0,component:`span`,variant:`body2`,sx:this.styles.description,children:this.props.cached.desc})]}),T(j,{component:`div`,sx:this.styles.footerBlock,children:[this.renderAddInstanceButton(),T(`div`,{style:this.styles.cardContentFlex,children:[this.renderAutoUpgradeButton(),this.renderReadmeButton(),this.renderUploadButton(),this.renderDeleteButton(),this.renderInstallSpecificVersionButton()]})]})]})}renderCardMedia(){let e=this.props.context.repository[this.props.adapterName],t=e==null?void 0:e.version;return T(j,{component:`div`,sx:k.getStyle(this.props.context.theme,this.styles.imageBlock,this.installedVersion&&this.styles.installed,this.installedVersion&&t&&this.installedVersion!==t&&this.props.cached.updateAvailable&&this.styles.update),children:[h(Ue,{sx:this.styles.img,component:e=>an.renderImage(e),src:this.props.cached.image||`img/no-image.svg`,image:this.props.cached.image||`img/no-image.svg`}),h(j,{component:`div`,sx:k.getStyle(this.props.context.theme,this.styles.adapter,(e.stat||this.props.context.sortRecentlyUpdated||this.props.context.sortRecentlyCreated)&&this.styles.adapterWithAgo),children:this.props.adapterName}),this.props.context.sortPopularFirst?h(`div`,{style:this.styles.versionDate,children:e.stat}):null,this.props.context.sortRecentlyUpdated?h(`div`,{style:this.styles.versionDate,children:this.props.cached.daysAgoText}):null,this.props.context.sortRecentlyCreated?h(`div`,{style:this.styles.versionDate,children:this.props.cached.createdDaysAgoText}):null,!this.props.context.sortPopularFirst&&!this.props.context.sortRecentlyUpdated&&!this.props.context.sortRecentlyCreated?this.renderRating():null,this.state.openCollapse?null:h(I,{title:this.props.context.t(`Info`),slotProps:{popper:{sx:{pointerEvents:`none`}}},children:h(le,{onClick:()=>this.setState({openCollapse:!this.state.openCollapse}),style:this.styles.fab,color:`primary`,"aria-label":`add`,children:h(Ve,{})})})]})}renderCardContent(){let e=!this.props.context.repository[this.props.adapterName]||this.props.context.repository[this.props.adapterName].allowAdapterUpdate,t=this.props.context.installed[this.props.adapterName];return T(c,{style:this.styles.cardContent2,children:[h(P,{gutterBottom:!0,variant:`h5`,component:`h5`,children:this.props.cached.title}),T(`div`,{style:this.styles.cardContentFlex,children:[this.renderConnectionType(),this.renderDataSource(),h(`div`,{children:this.renderLicenseInfo()}),this.renderSentryInfo()]}),T(`div`,{style:this.styles.cardMargin10,children:[t!=null&&t.count?T(P,{component:`span`,style:this.styles.cardContentFlexBetween,children:[T(`div`,{children:[this.props.context.t(`Installed instances`),`:`]}),h(`div`,{children:t.count})]}):null,h(H,{value:e,children:T(P,{component:`span`,style:this.styles.availableVersion,children:[h(`div`,{children:this.props.context.t(`Available version:`)}),h(j,{component:`div`,sx:k.getStyle(this.props.context.theme,this.props.cached.updateAvailable&&this.styles.greenText,this.styles.curdContentFlexCenter),children:this.renderVersion()})]})}),this.renderInstalledVersion()]})]})}render(){var e;return this.installedVersion=(e=this.props.context.installed[this.props.adapterName])==null?void 0:e.version,T(We,{sx:this.styles.root,children:[this.state.openCollapse?this.renderInfoCard():null,this.renderCardMedia(),this.renderCardContent(),this.renderDialogs()]})}};d();var ln={...rn,type:{color:`line`},smallAvatar:{width:32,height:32,marginLeft:4},paddingNone:{padding:`0 !important`},name:{flexWrap:`nowrap`,width:300,marginTop:0},flex:{display:`flex`},nameCell:{paddingTop:`0 !important`,paddingBottom:`0 !important`}},un=class extends an{constructor(...e){super(...e),w(this,`styles`,ln)}render(){var e,t;let n=this.props.context.repository[this.props.adapterName],r=!n||n.allowAdapterRating;return this.installedVersion=(e=this.props.context.installed[this.props.adapterName])==null?void 0:e.version,T(_e,{hover:!0,children:[h(B,{}),h(B,{children:T(O,{container:!0,spacing:1,style:this.styles.name,sx:{alignItems:`center`},children:[h(I,{title:this.props.adapterName,slotProps:{popper:{sx:this.styles.tooltip}},children:h(O,{style:this.styles.paddingNone,children:h(Ee,{variant:`square`,alt:this.props.cached.title,src:this.props.cached.image,style:this.styles.smallAvatar})})}),r===!1?h(O,{children:this.props.cached.title}):T(O,{style:this.styles.nameCell,children:[h(`div`,{children:this.props.cached.title}),this.renderRating()]})]})}),!this.props.context.descHidden&&h(B,{title:this.props.cached.desc,style:{width:20,wordWrap:`break-word`},children:this.props.cached.desc}),h(B,{children:T(`div`,{style:this.styles.flex,children:[this.renderConnectionType()||h(`div`,{style:{width:24,height:24}}),this.renderDataSource()||h(`div`,{style:{marginLeft:5,width:24,height:24}}),this.renderSentryInfo()||h(`div`,{style:{marginLeft:5,width:24,height:24}}),this.renderLicenseInfo(!0)]})}),h(B,{children:this.renderInstalledVersion(!0)}),h(B,{children:h(O,{container:!0,sx:{alignItems:`center`},children:this.renderVersion()})}),h(B,{style:{fontSize:`smaller`},children:(n==null||(t=n.licenseInformation)==null?void 0:t.license)||(n==null?void 0:n.license)}),T(B,{children:[this.renderAddInstanceButton(),this.renderAutoUpgradeButton(),this.renderReadmeButton(),this.renderUploadButton(),this.renderDeleteButton(),this.renderInstallSpecificVersionButton(),this.renderRebuildButton()]}),this.renderDialogs()]})}};d();var dn=246,X={emptyBlock:50,name:300,connectionType:120,installed:120,available:120,update:40,license:80,install:dn},fn=Object.keys(X).reduce((e,t)=>e+X[t],0),Z={container:{height:`100%`,width:`100%`},containerNotFullHeight:{height:`calc(100% - 50px)`},containerFullHeight:{height:`100%`},table:{width:`100%`,tableLayout:`fixed`,minWidth:960,"& td":{whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`,pt:`2px`,pb:`2px`,pr:`4px`,pl:`4px`},"& th":{whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`,pt:`2px`,pb:`2px`,pr:`4px`,pl:`4px`}},name:{flexWrap:`nowrap`,width:X.name},emptyBlock:{flexWrap:`nowrap`,width:X.emptyBlock},description:{width:`calc(100% - ${fn+2}px)`},connectionType:{width:X.connectionType},installed:{width:X.installed},available:{width:X.available,paddingRight:6},update:{width:X.update,padding:0},license:{width:X.license},install:{width:X.install},viewModeDiv:{display:`flex`,flexFlow:`wrap`,overflow:`auto`,justifyContent:`center`}},pn=class extends z{constructor(e){super(e),w(this,`lastRenderCounter`,-1),this.state={descWidth:e.descWidth,repoName:e.repoName,systemConfig:!!e.systemConfig,tableViewMode:e.tableViewMode,oneListView:e.oneListView,categoriesExpanded:JSON.stringify(e.categoriesExpanded),cachedAdapters:e.cachedAdapters?Object.keys(e.cachedAdapters).length:0,update:e.update,sortByName:e.sortByName,sortPopularFirst:e.sortPopularFirst,sortRecentlyUpdated:e.sortRecentlyUpdated,sortRecentlyCreated:e.sortRecentlyCreated,renderCounter:0,listOfVisibleAdapter:JSON.stringify(e.listOfVisibleAdapter),expertMode:e.context.expertMode,commandRunning:e.commandRunning,noTranslation:e.noTranslation}}getRow(e,t){var n;let r=(n=this.props.cachedAdapters)==null?void 0:n[e];return r?h(un,{context:t,adapterName:e,cached:r,commandRunning:this.state.commandRunning,noTranslation:this.state.noTranslation},`adapter-${e}`):null}getRows(e){if(!this.props.listOfVisibleAdapter)return h(_e,{children:h(B,{colSpan:8,children:h(A,{})})});let t=0,n=[];if(this.props.oneListView){for(let t=0;t<this.props.listOfVisibleAdapter.length;t++){var r;let i=this.props.listOfVisibleAdapter[t];if(n.length>50&&!((r=this.props.context.installed[i])!=null&&r.version))continue;let a=this.getRow(i,e);a&&n.push(a)}if(t=n.length,t&&this.props.listOfVisibleAdapter.length>n.length){let e=this.props.listOfVisibleAdapter.length-n.length,t=e===1?this.props.context.t(`Filter adapters to see others. There is %s more`,1):this.props.context.t(`Filter adapters to see others. There are %s more`,e);n.push(h(_e,{children:h(B,{colSpan:8,style:{fontSize:20,padding:20,textAlign:`center`},children:t})},`more`))}}else n=this.props.categories.map(n=>{if(!n.adapters.find(e=>{var t;return(t=this.props.listOfVisibleAdapter)==null?void 0:t.includes(e)}))return null;let r=n.name,i=this.props.categoriesExpanded[r];return t++,T(Ne,{children:[h(qt,{categoryName:r,count:n.count,expanded:i,installedCount:n.installed,name:n.translation,descHidden:e.descHidden,onToggle:()=>this.props.toggleCategory(r),t:this.props.context.t},`category-${r}1`),i&&n.adapters.map(n=>{let r=this.getRow(n,e);return r&&t++,r})]},`category-${r} ${n.adapters.length}`)});return t?n:this.props.update?null:h(`tr`,{children:T(`td`,{colSpan:8,style:{textAlign:`center`},children:[this.props.searchFilter||this.props.installedListFilter?h(V,{variant:`outlined`,title:this.props.context.t(`Click to clear all filters`),onClick:()=>this.props.clearAllFilters(),children:this.props.context.t(`all items are filtered out`)}):null,this.props.updateListFilter&&(this.props.searchFilter||this.props.installedListFilter)?h(`br`,{}):null,this.props.updateListFilter?h(V,{style:{marginTop:16},variant:`outlined`,onClick:()=>this.props.clearAllFilters(!0),startIcon:h(Ct,{}),children:this.props.context.t(`Remove filter for updatable adapters`)}):null]})})}getTiles(e){if(!this.props.listOfVisibleAdapter)return h(A,{});if(!this.props.listOfVisibleAdapter.length)return this.props.update?null:T(`div`,{style:{width:`100%`,display:`flex`,flexDirection:`column`,justifyContent:`center`,alignItems:`center`,gap:16},children:[this.props.searchFilter||this.props.installedListFilter?h(I,{title:this.props.context.t(`Click to clear all filters`),slotProps:{popper:{sx:{pointerEvents:`none`}}},children:h(V,{variant:`outlined`,onClick:()=>this.props.clearAllFilters(),children:this.props.context.t(`all items are filtered out`)})}):null,this.props.updateListFilter?h(V,{variant:`outlined`,onClick:()=>this.props.clearAllFilters(!0),startIcon:h(Ct,{}),children:this.props.context.t(`Remove filter for updatable adapters`)}):null]});let t=[];for(let i=0;i<this.props.listOfVisibleAdapter.length;i++){var n,r;let a=this.props.listOfVisibleAdapter[i],o=(n=this.props.cachedAdapters)==null?void 0:n[a];t.length>50&&!((r=this.props.context.installed[a])!=null&&r.version)||o&&t.push(h(cn,{context:e,adapterName:a,cached:o,commandRunning:this.state.commandRunning,noTranslation:this.state.noTranslation},`adapter-${a}`))}return this.props.listOfVisibleAdapter.length>t.length&&(t.push(h(`div`,{style:{flexBasis:`100%`,height:0}},`newLine`)),t.push(h(`div`,{style:{fontSize:20,margin:20},children:this.props.context.t(`Filter adapters to see others. There is %s more`,this.props.listOfVisibleAdapter.length-t.length)},`more`))),t}shouldShowRepositoryWarning(e,t){return!e&&String(t||``).toLowerCase()!==`nexowatt`}renderTileView(e,t,n){return T(D,{children:[this.shouldShowRepositoryWarning(e,t)?h(j,{sx:{marginX:2,marginTop:1,width:`calc(100% - 32px)`},children:h(ke,{type:`warning`,children:this.props.context.t(`Active repo is "%s"`,t)})}):null,h(`div`,{style:Z.viewModeDiv,children:this.getTiles(n)})]})}renderTableView(t,n,r){return T(ue,{children:[this.shouldShowRepositoryWarning(t,n)?h(j,{sx:{marginX:2,marginTop:1,width:`calc(100% - 32px)`},children:h(ke,{type:`warning`,children:this.props.context.t(`Active repo is "%s"`,n)})}):null,h(je,{style:{...Z.container,...t?Z.containerFullHeight:Z.containerNotFullHeight},children:T(e,{stickyHeader:!0,size:`small`,sx:Z.table,children:[h(Le,{children:T(_e,{children:[h(B,{style:Z.emptyBlock}),h(B,{style:Z.name,children:h(P,{children:this.props.context.t(`Name`)})}),!r.descHidden&&h(B,{style:{...Z.description,width:this.props.descWidth},children:h(P,{children:this.props.context.t(`Description`)})}),h(B,{style:Z.connectionType}),h(B,{style:Z.installed,children:h(P,{children:this.props.context.t(`Installed`)})}),h(B,{style:Z.available,children:h(P,{children:this.props.context.t(`Available`)})}),h(B,{style:Z.license,children:h(P,{children:this.props.context.t(`License`)})}),h(B,{style:{...Z.install,width:this.state.expertMode?dn:178},children:h(P,{children:this.props.context.t(`Install`)})})]})}),h(Se,{children:this.getRows(r)})]})})]})}static getDerivedStateFromProps(e,t){let n=!1;e.descWidth!==t.descWidth&&(console.log(`Render because of descWidth`),n=!0),e.repoName!==t.repoName&&(console.log(`Render because of repoName`),n=!0),!!e.systemConfig!==t.systemConfig&&(console.log(`Render because of systemConfig`),n=!0),e.tableViewMode!==t.tableViewMode&&(console.log(`Render because of tableViewMode`),n=!0),e.oneListView!==t.oneListView&&(console.log(`Render because of oneListView`),n=!0);let r=JSON.stringify(e.categoriesExpanded);r!==t.categoriesExpanded&&(console.log(`Render because of categoriesExpanded`),n=!0);let i=e.cachedAdapters?Object.keys(e.cachedAdapters).length:0;i!==t.cachedAdapters&&(console.log(`Render because of cachedAdapters ${i} <> ${t.cachedAdapters}`),n=!0),e.update!==t.update&&(console.log(`Render because of update`),n=!0),e.sortByName!==t.sortByName&&(console.log(`Render because of sortByName`),n=!0),e.sortPopularFirst!==t.sortPopularFirst&&(console.log(`Render because of sortPopularFirst`),n=!0),e.sortRecentlyUpdated!==t.sortRecentlyUpdated&&(console.log(`Render because of sortRecentlyUpdated`),n=!0),e.sortRecentlyCreated!==t.sortRecentlyCreated&&(console.log(`Render because of sortRecentlyCreated`),n=!0),e.context.expertMode!==t.expertMode&&(console.log(`Render because of expertMode`),n=!0);let a=JSON.stringify(e.listOfVisibleAdapter);return a!==t.listOfVisibleAdapter&&(console.log(`Render because of listOfVisibleAdapter`),n=!0),e.commandRunning!==t.commandRunning&&(console.log(`Render because of commandRunning`),n=!0),e.noTranslation!==t.noTranslation&&(console.log(`Render because of commandRunning`),n=!0),n?{descWidth:e.descWidth,repoName:e.repoName,systemConfig:!!e.systemConfig,tableViewMode:e.tableViewMode,oneListView:e.oneListView,categoriesExpanded:r,cachedAdapters:i,update:e.update,sortByName:e.sortByName,sortPopularFirst:e.sortPopularFirst,sortRecentlyUpdated:e.sortRecentlyUpdated,sortRecentlyCreated:e.sortRecentlyCreated,listOfVisibleAdapter:a,renderCounter:t.renderCounter+1,expertMode:e.context.expertMode,commandRunning:e.commandRunning,noTranslation:e.noTranslation}:null}shouldComponentUpdate(e,t){return this.lastRenderCounter!==t.renderCounter&&(this.lastRenderCounter=t.renderCounter,!0)}render(){var e;return(e=this.props.systemConfig)!=null&&(e=e.common)!=null&&e.activeRepo?this.props.tableViewMode?this.renderTableView(this.props.stableRepo,this.props.repoName,this.props.context):this.renderTileView(this.props.stableRepo,this.props.repoName,this.props.context):h(A,{})}};d();var mn=class extends z{constructor(e){super(e),w(this,`updating`,void 0),w(this,`interval`,null),w(this,`startTimeout`,null),w(this,`textareaRef`,void 0),w(this,`link`,void 0),w(this,`oldVersion`,void 0),this.state={response:null,error:null,starting:!0,upAgain:!1},this.updating=!1,this.textareaRef=Ie.createRef(),this.link=`${window.location.protocol}//${window.location.host}/`}setUpdating(e){this.updating!==e&&(this.updating=e,this.props.onUpdating(e))}async getWebserverParams(){let e=await this.props.socket.getObject(`system.adapter.${this.props.adminInstance}`);return{useHttps:e==null?void 0:e.native.secure,port:e==null?void 0:e.native.port,certPrivateName:e==null?void 0:e.native.certPrivate,certPublicName:e==null?void 0:e.native.certPublic}}async componentDidMount(){let{certPrivateName:e,certPublicName:t,port:n,useHttps:r}=await this.getWebserverParams();this.oldVersion=this.props.currentAdminVersion,await this.props.socket.upgradeAdapterWithWebserver(this.props.host,{version:this.props.version,adapterName:`eos-admin`,port:n,useHttps:r,certPublicName:t,certPrivateName:e}),this.setUpdating(!0),this.interval=setInterval(()=>this.checkStatus(),1e3),this.startTimeout=setTimeout(()=>{this.startTimeout=null,this.setState({starting:!1})},1e4)}componentWillUnmount(){this.interval&&=(clearInterval(this.interval),null),this.startTimeout&&=(clearTimeout(this.startTimeout),null)}async checkVersion(){try{let e=await(await fetch(`./version`)).text();return e&&e.length<20&&e!==this.oldVersion?(this.interval&&=(clearInterval(this.interval),null),this.setState({response:{running:!1,success:!0,stderr:[],stdout:[C.t(`Version updated to %s`,e)]},upAgain:!0,error:null},()=>this.setUpdating(!1)),!0):e===this.oldVersion}catch{return!1}}async checkStatus(){console.log(`Request update status from: ${this.link}`);try{let e=await(await fetch(this.link)).text();if(console.log(`Received status: ${e}`),e.startsWith(`{`)&&e.endsWith(`}`))try{let t=JSON.parse(e);t!=null&&t.stderr&&(t.stderr=t.stderr.filter(e=>e.trim())),t&&!t.running&&t.success&&t.stdout?(t.stdout.push(``),t.stdout.push(`---------------------------------------------------`),t.stdout.push(C.t(`%s was successfully updated to %s`,`eos-admin`,this.props.version))):t!=null&&t.stdout&&(t.stdout.unshift(``),t.stdout.unshift(`---------------------------------------------------`),t.stdout.unshift(C.t(`updating %s to %s...`,`eos-admin`,this.props.version))),this.setState({response:t,error:null},()=>{t&&!t.running?(this.interval&&=(clearInterval(this.interval),null),this.waitForAdapterStart()):t!=null&&t.running&&this.setUpdating(!0),this.textareaRef.current&&setTimeout(()=>this.textareaRef.current&&(this.textareaRef.current.scrollTop=this.textareaRef.current.scrollHeight),100)})}catch(t){console.error(`Cannot parse response: ${t}`),this.setState({error:e},()=>this.setUpdating(!1))}else await this.checkVersion()||console.error(`Response is not JSON: ${e}`)}catch(e){this.state.starting||this.setState({error:e.toString()},()=>this.setUpdating(!1))}}waitForAdapterStart(){this.interval=setInterval(async()=>{try{await fetch(this.link),this.interval&&clearInterval(this.interval),this.interval=null,this.setState({upAgain:!0})}catch{}},1e3)}render(){var e,t,n,r,i,o,s;return T(a,{onClose:(e,t)=>{t!==`escapeKeyDown`&&t!==`backdropClick`&&this.props.onClose()},open:!0,maxWidth:`lg`,fullWidth:!0,children:[h(x,{children:C.t(`Updating %s...`,`eos-admin`)}),T(b,{style:{height:400,padding:`0 20px`,overflow:`hidden`},children:[(!this.state.response||this.state.response.running)&&!this.state.error?h(A,{}):null,this.state.response||this.state.error?h(`textarea`,{ref:this.textareaRef,style:{width:`100%`,height:`100%`,resize:`none`,background:this.props.themeType===`dark`?`#000`:`#fff`,color:this.props.themeType===`dark`?`#EEE`:`#111`,boxSizing:`border-box`,fontFamily:`Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace`,border:(e=this.state.response)!=null&&e.success?`2px solid green`:this.state.error||this.state.response&&!this.state.response.running&&!this.state.response.success?`2px solid red`:void 0},value:this.state.error?this.state.error:(t=this.state.response)!=null&&(t=t.stderr)!=null&&t.length?this.state.response.stderr.join(`
3
+ `).map(e=>Et(e.trim()).replace(/<!--[^>]*->/g,``).replace(/<! -[^>]*->/g,``).trim()).filter(e=>!!e);i.push(T(O,{children:[T(P,{sx:U.versionHeader,children:[n,o===n?h(j,{component:`span`,sx:U.repoLatestVersionText,children:`(latest)`}):null,a===n?h(j,{component:`span`,sx:U.repoStableVersionText,children:`(${C.t(`stable`)})`}):null]}),e.map((e,t)=>h(Ot,{text:e},`${n}-${t}`))]},n))}}catch{console.warn(`Cannot compare "${n}" and "${t}" of adapter ${e}`)}}),i}renderShowNews(){if(this.state.showNews){let e=this.getReactNews(this.state.showNews.adapter,this.state.showNews.fromVersion),t=k.getStyle(this.props.theme,U.closeButton),n=k.getStyle(this.props.theme,U.languageButtonActive);return T(a,{onClose:()=>this.setState({showNews:null}),open:!0,children:[h(x,{children:T(P,{component:`h2`,variant:`h6`,sx:{"&.MuiTypography-root":U.typography},children:[h(`div`,{style:{width:`calc(100% - 60px)`},children:C.t(`Update "%s" to v%s`,this.state.showNews.adapter,this.state.showNews.version)}),h(y,{size:`large`,style:t,onClick:()=>this.setState({showNews:null}),children:h(v,{})}),C.getLanguage()!==`en`&&this.props.toggleTranslation?h(y,{size:`large`,style:{...U.languageButton,...this.props.noTranslation?n:void 0},onClick:this.props.toggleTranslation,title:C.t(`Disable/Enable translation`),children:h(r,{})}):null]})}),h(b,{dividers:!0,children:h(O,{container:!0,spacing:2,wrap:`nowrap`,sx:{flexDirection:`column`},children:e.length?T(O,{children:[h(P,{variant:`h6`,gutterBottom:!0,children:C.t(`Change log`)}),h(O,{container:!0,spacing:2,wrap:`nowrap`,sx:{flexDirection:`column`},children:e})]}):C.t(`No change log available`)})}),h(M,{style:U.wrapperButton,children:h(V,{variant:`contained`,onClick:()=>this.setState({showNews:null}),color:`grey`,startIcon:h(v,{}),children:C.t(`Close`)})})]})}return null}render(){return this.current!==this.props.current&&(this.current=this.props.current,setTimeout(()=>{var e;return(e=this.currentRef.current)==null?void 0:e.scrollIntoView()},200)),T(se,{style:U.root,children:[this.updateAvailable.map(e=>this.renderOneAdapter(e)),this.renderShowNews()]})}};d();var W={dialogRoot:{height:`calc(100% - 64px)`},wrapperHead:{justifyContent:`space-between`,display:`flex`},checkbox:{marginRight:10},appBar:e=>({flexWrap:`wrap`,position:`sticky`,bottom:-10,pl:1,pr:1,borderRadius:`${e.shape.borderRadius}px`,background:e.palette.background.paper}),container:{overflow:`hidden`,flex:`1 1 auto`,minHeight:0,flexWrap:`nowrap`,"@media screen and (max-width: 602px)":{flex:`none`,flexWrap:`wrap`}},content:{display:`flex`,flexDirection:`column`,"& > .MuiToolbar-root":{flexShrink:0},"@media screen and (max-width: 500px)":{p:1}},languageButton:{position:`absolute`,right:73,top:11},languageButtonActive:e=>({color:e.palette.primary.main})},Pt=class extends z{constructor(e){super(e),w(this,`updateAvailable`,[]),w(this,`onAdapterFinished`,null),w(this,`processList`,[]),this.state={selected:[],inProcess:!1,finished:!1,current:``,updated:[],stopped:!1,debug:(window._localStorage||window.localStorage).getItem(`AdaptersUpdaterDialog.debug`)===`true`,stopOnError:(window._localStorage||window.localStorage).getItem(`AdaptersUpdaterDialog.stopOnError`)!==`false`,closeOnFinished:(window._localStorage||window.localStorage).getItem(`AdaptersUpdaterDialog.closeOnFinished`)===`true`,currentVersion:``},this.updateAvailable=[]}updateAdapter(e,t,n){this.onAdapterFinished=n,this.setState({current:e,currentVersion:t})}onStartUpdate(){this.props.ready?this.setState({inProcess:!0},()=>{this.props.onSetCommandRunning(!0),this.processList=[...this.state.selected].sort((e,t)=>e===`eos-admin`?1:t===`eos-admin`?-1:e.localeCompare(t)).map(e=>{var t;return{adapter:e,version:(t=this.props.repository[e])==null?void 0:t.version}}),this.updateAdapters(()=>{this.setState({inProcess:!1,finished:!0},()=>{this.props.onSetCommandRunning(!1),this.state.closeOnFinished&&this.props.onClose(!!this.state.updated.length)})})}):window.alert(this.props.t(`The connection is not ready yet. Please wait a moment and try again.`))}updateAdapters(e){if(!this.processList||!this.processList.length||this.state.stopped)e&&e();else{let{adapter:t,version:n}=this.processList.shift();this.updateAdapter(t,n,()=>{let n=[...this.state.updated];n.push(t),this.setState({updated:n},()=>setTimeout(()=>this.updateAdapters(e),200))})}}render(){let e=this.props.noTranslation?k.getStyle(this.props.theme,W.languageButtonActive):void 0;return T(a,{open:!0,maxWidth:`lg`,fullWidth:!!this.state.current,onClose:()=>this.props.onClose(!!this.state.updated.length),"aria-labelledby":`update-dialog-title`,"aria-describedby":`update-dialog-description`,sx:{"& .MuiPaper-root":W.dialogRoot},scroll:`paper`,children:[h(x,{id:`update-dialog-title`,children:T(`div`,{style:W.wrapperHead,children:[this.props.t(`Update %s adapter(s)`,this.state.selected.length),!this.state.finished&&!this.state.inProcess&&h(I,{title:this.props.t(`Select/Unselect all`),slotProps:{popper:{sx:{pointerEvents:`none`}}},children:h(S,{checked:this.state.selected.length===this.updateAvailable.length,style:W.checkbox,tabIndex:-1,indeterminate:this.state.selected.length!==this.updateAvailable.length&&this.state.selected.length!==0,disableRipple:!0,onClick:()=>{let e=[];this.state.selected.length!==this.updateAvailable.length&&(e=[...this.updateAvailable]),this.setState({selected:e})}})}),C.getLanguage()!==`en`&&this.props.toggleTranslation?h(y,{size:`large`,style:{...W.languageButton,...e},onClick:()=>{var e,t;return(e=(t=this.props).toggleTranslation)==null?void 0:e.call(t)},title:C.t(`Disable/Enable translation`),children:h(r,{})}):null]})}),T(b,{sx:{"&.MuiDialogContent-root":W.content},children:[T(O,{container:!0,direction:`row`,sx:W.container,children:[h(O,{style:{height:`100%`,overflow:`hidden`,width:this.state.current?250:`100%`},children:h(`div`,{style:{height:`100%`,overflow:`auto`},children:h(Nt,{finished:this.state.finished,inProcess:this.state.inProcess,selected:this.state.selected,current:this.state.current,stopped:this.state.stopped,updated:this.state.updated,lang:this.props.lang,installed:this.props.installed,repository:this.props.repository,noTranslation:!!this.props.noTranslation,toggleTranslation:this.props.toggleTranslation||(()=>{}),onUpdateSelected:(e,t)=>{t&&(this.updateAvailable=t),this.setState({selected:e})},theme:this.props.theme,rightDependenciesFunc:this.props.rightDependenciesFunc})})}),!!this.state.current&&h(O,{style:{height:`100%`,overflow:`hidden`,width:`calc(100% - 260px)`,minWidth:240},children:h(st,{noSpacing:!0,ready:this.props.ready,host:this.props.currentHost,socket:this.props.socket,t:this.props.t,cmd:`upgrade ${this.state.current}@${this.state.currentVersion}${this.state.debug?` --debug`:``}`,onFinished:()=>{var e;return(e=this.onAdapterFinished)==null?void 0:e.call(this)},errorFunc:()=>{if(this.state.stopOnError)this.setState({stopped:!0,finished:!0}),this.onAdapterFinished=null,this.props.onSetCommandRunning(!1);else{var e;(e=this.onAdapterFinished)==null||e.call(this)}}},this.state.current)})]}),T(we,{variant:`dense`,disableGutters:!0,sx:W.appBar,children:[h(E,{control:h(S,{disabled:this.state.finished,checked:this.state.stopOnError,onChange:()=>{(window._localStorage||window.localStorage).setItem(`AdaptersUpdaterDialog.stopOnError`,this.state.stopOnError?`false`:`true`),this.setState({stopOnError:!this.state.stopOnError})}}),label:this.props.t(`Stop on error`)}),h(E,{control:h(S,{disabled:this.state.finished,checked:this.state.closeOnFinished,onChange:()=>{(window._localStorage||window.localStorage).setItem(`AdaptersUpdaterDialog.closeOnFinished`,this.state.closeOnFinished?`false`:`true`),this.setState({closeOnFinished:!this.state.closeOnFinished})}}),label:this.props.t(`Close on finished`)}),h(E,{control:h(S,{disabled:this.state.finished||this.state.inProcess,checked:this.state.debug,onChange:()=>{(window._localStorage||window.localStorage).setItem(`AdaptersUpdaterDialog.debug`,this.state.debug?`false`:`true`),this.setState({debug:!this.state.debug})}}),label:this.props.t(`Debug info`)})]})]}),T(M,{children:[h(V,{id:`adapters-update-dialog-update`,variant:`contained`,disabled:this.state.stopped||this.state.inProcess||this.state.finished||!this.state.selected.length||!this.props.ready,onClick:()=>this.onStartUpdate(),color:`primary`,autoFocus:!0,startIcon:h(pe,{}),children:this.props.t(`Update`)}),h(V,{id:`adapters-update-dialog-cancel`,variant:`contained`,disabled:!this.state.inProcess,color:`grey`,startIcon:h(n,{}),onClick:()=>{this.setState({stopped:!0,finished:!0}),this.props.onSetCommandRunning(!1)},children:this.props.t(`Cancel`)}),h(V,{id:`adapters-update-dialog-close`,variant:`contained`,onClick:()=>this.props.onClose(!!this.state.updated.length),disabled:this.state.inProcess&&!this.state.stopped,color:this.state.stopped?`error`:`grey`,startIcon:h(v,{}),children:this.props.t(`Close`)})]})]})}},Ft=u(T(D,{children:[h(`path`,{d:`M21 10.12h-6.78l2.74-2.82c-2.73-2.7-7.15-2.8-9.88-.1-2.73 2.71-2.73 7.08 0 9.79s7.15 2.71 9.88 0C18.32 15.65 19 14.08 19 12.1h2c0 1.98-.88 4.55-2.64 6.29-3.51 3.48-9.21 3.48-12.72 0-3.5-3.47-3.53-9.11-.02-12.58s9.14-3.47 12.65 0L21 3z`}),h(`path`,{d:`M8.6 8.7h2.9v2.9H8.6zM12.5 8.7h2.9v2.9h-2.9zM8.6 12.6h2.9v2.9H8.6zM12.5 12.6h2.9v2.9h-2.9z`})]}),`UpdateAll`);d();var It=class extends at{constructor(e,t){super(e,`${t}.adapter`,`adapter`),w(this,`host`,void 0),w(this,`prefix`,void 0),this.prefix=`${t}.adapter.`,this.host=t}getObject(e){return this.objects&&this.objects[this.prefix+e]||null}getHost(){return this.host}};function Lt(e){var t;return(e==null||(t=e.licenseInformation)==null?void 0:t.link)||Rt(e)}function Rt(e){if(!e)return``;let t=e.licenseUrl;if(!t||!t.includes(`/LICENSE`)||!t.includes(`raw.githubusercontent.com`)){if(t=e.extIcon,!t){if(t=e.readme,!t)return console.error(`No extIcon for ${e.name||JSON.stringify(e)}`),``;t=t.replace(`github.com`,`raw.githubusercontent.com`).replace(`/blob/`,`/`),t.includes(`/main`)?t=`${t.split(`/main`)[0]}/main/LICENSE`:t.includes(`/master`)&&(t=`${t.split(`/master`)[0]}/master/LICENSE`)}if(t.includes(`/main`))t=`${t.split(`/main`)[0]}/main/LICENSE`;else if(t.includes(`/master`))t=`${t.split(`/master`)[0]}/master/LICENSE`;else return``}return t}function zt(e){if(!e)return null;let t=e.trim().split(`?`)[0].split(`#`)[0],n=t.match(/iobroker\.([a-z\d][a-z\d_-]*?)-\d+\.\d+\.\d+[^/\\]*\.tgz$/i);if(n)return n[1].toLowerCase();let r=t.match(/iobroker\.([a-z\d][a-z\d_-]*)/i);return r?r[1].toLowerCase():/^[a-z\d][a-z\d_-]*$/i.test(t)?t.toLowerCase():null}var Bt=`data:image/svg+xml,%3csvg%20viewBox='0%200%202500%202500'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M0%200h2500v2500H0z'%20fill='%23c00'/%3e%3cpath%20d='M1241.5%20268.5h-973v1962.9h972.9V763.5h495v1467.9h495V268.5z'%20fill='%23fff'/%3e%3c/svg%3e`;function Vt(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=r.result,n=e.indexOf(`,`);t(n===-1?e:e.substring(n+1))},r.onerror=()=>n(r.error||Error(`Cannot read file`)),r.readAsDataURL(e)})}function Ht(e){return{id:`github-install-dialog-tab-${e}`,"aria-controls":`github-install-dialog-panel-${e}`}}var G={root:e=>({backgroundColor:e.palette.background.paper,width:`100%`,height:`100%`}),paper:{maxWidth:1e3},tabPaper:{padding:16},title:e=>({mt:`10px`,p:1,ml:1,fontSize:18,color:e.palette.primary.main}),warningText:{color:`#f53939`},noteText:{marginTop:16},errorTextNoGit:{fontSize:13,color:`#ff1616`},listIcon:{width:24,height:24},listIconWithMargin:{width:24,height:24,marginRight:8},tabSelected:e=>({color:e.palette.mode===`dark`?e.palette.secondary.contrastText:`#222 !important`})};function Ut(e){let t=[];for(let n=0;n<e.length;n++)typeof e[n]==`object`?e[n].forEach(e=>t.push(e)):t.push(e[n]);return t}var Wt=10,Gt=class extends Ie.Component{constructor(e){super(e);let t=[],n=(window._localstorage||window.localStorage).getItem(`App.npmHistory`);if(n)try{t=JSON.parse(n)}catch{}this.state={autoCompleteValue:(window._localstorage||window.localStorage).getItem(`App.autocomplete`)||null,debug:(window._localstorage||window.localStorage).getItem(`App.gitDebug`)===`true`,createInstance:(window._localstorage||window.localStorage).getItem(`App.createInstanceAfterInstall`)!==`false`,url:(window._localstorage||window.localStorage).getItem(`App.userUrl`)||``,currentTab:(window._localstorage||window.localStorage).getItem(`App.gitTab`)||`npm`,customHistory:t,selectedFile:null,restartAfterInstall:(window._localstorage||window.localStorage).getItem(`App.restartAfterInstall`)!==`false`,uploading:!1,selectedHost:e.currentHost,cmdExecFilesSupported:!1}}async componentDidMount(){try{let e=await this.props.socket.checkFeatureSupported(`CONTROLLER_CMD_EXEC_FILES`);this.setState({cmdExecFilesSupported:!!e})}catch(e){console.error(`Cannot read feature: ${e}`)}}async uploadFileToServer(){if(!this.state.selectedFile)return null;this.setState({uploading:!0});try{let e=new FormData;e.append(`file`,this.state.selectedFile);let t=await fetch(`./upload-adapter`,{method:`POST`,body:e});if(!t.ok){let e;try{e=(await t.json()).error||`Upload failed with status ${t.status}`}catch{e=`Upload failed with status ${t.status}`}throw Error(e)}return(await t.json()).filePath}catch(e){return window.alert(`${C.t(`Upload failed`)}: ${e.message}`),null}finally{this.setState({uploading:!1})}}async restartInstances(e){if(!this.state.restartAfterInstall||!e)return;let t=await this.props.socket.getAdapterInstances(e);for(let e of t){var n;e!=null&&(n=e.common)!=null&&n.enabled&&await this.props.socket.extendObject(e._id,{})}}async createInstanceIfDesired(e,t){if(this.state.createInstance&&e)try{await this.props.createInstance(e,t)}catch(t){console.error(`Cannot create the instance of ${e}: ${t.message}`)}}async installFile(){if(!this.state.selectedFile)return;let e=zt(this.state.selectedFile.name)||``;if(this.state.cmdExecFilesSupported){try{let t=await Vt(this.state.selectedFile),n=this.state.selectedFile.name.replace(/[^a-zA-Z0-9._-]/g,`_`),r=await this.props.installFromUrl(n,this.state.debug,!0,{host:this.state.selectedHost,files:[{name:n,file:t}]});await this.restartInstances(e),r&&await this.createInstanceIfDesired(e,this.state.selectedHost)}catch(e){console.error(`Installation from file failed: ${e.message}`)}return}let t=await this.uploadFileToServer();if(t)try{let n=await this.props.installFromUrl(t,this.state.debug,!0);await this.restartInstances(e),n&&await this.createInstanceIfDesired(e)}catch(e){console.error(`Installation from file failed: ${e.message}`)}}async handleInstall(){if(this.state.currentTab===`GitHub`){var e;let t=(((e=this.state.autoCompleteValue)==null?void 0:e.value)||``).split(`/`),n=`${t[1]}/ioBroker.${t[0]}`;await this.props.installFromUrl(n,this.state.debug,!0)&&await this.createInstanceIfDesired(t[0])}else if(this.state.currentTab===`URL`){let e=this.state.customHistory.filter(e=>e!==this.state.url);e.unshift(this.state.url),e.length>Wt&&e.pop(),(window._localstorage||window.localStorage).setItem(`App.npmHistory`,JSON.stringify(e));let t=this.state.url.includes(`.`)?this.state.url:`iobroker.${this.state.url}`;await this.props.installFromUrl(t,this.state.debug,!0)&&await this.createInstanceIfDesired(zt(t))}else if(this.state.currentTab===`File`)await this.installFile();else if(this.state.currentTab===`npm`){var t;let e=(((t=this.state.autoCompleteValue)==null?void 0:t.value)||``).split(`/`)[0],n=e.includes(`.`)?e.split(`.`)[1]:e;try{let e=await this.props.installFromUrl(`iobroker.${n}@latest`,this.state.debug,!0);await this.props.upload(n),e&&await this.createInstanceIfDesired(n)}catch(e){console.error(`Installation from url failed: ${e.message}`)}}}renderCreateInstance(){return h(`div`,{style:{display:`flex`,alignItems:`center`},children:h(E,{control:h(S,{checked:this.state.createInstance,onChange:e=>{(window._localstorage||window.localStorage).setItem(`App.createInstanceAfterInstall`,e.target.checked?`true`:`false`),this.setState({createInstance:e.target.checked})}}),label:this.props.t(`Create instance if it does not exist yet`)})})}renderNpm(){return this.state.currentTab===`npm`?T(Ae,{style:G.tabPaper,id:`github-install-dialog-panel-npm`,children:[h(`div`,{style:{display:`flex`,alignItems:`center`},children:h(E,{control:h(S,{checked:this.state.debug,onChange:e=>{(window._localstorage||window.localStorage).setItem(`App.gitDebug`,e.target.checked?`true`:`false`),this.setState({debug:e.target.checked})}}),label:this.props.t(`Debug outputs`)})}),this.renderCreateInstance(),T(`div`,{style:{display:`flex`,alignItems:`flex-end`},children:[h(ft,{style:{marginRight:10}}),h(ye,{fullWidth:!0,value:this.state.autoCompleteValue,onChange:(e,t)=>{(window._localstorage||window.localStorage).setItem(`App.autocomplete`,t||void 0),this.setState({autoCompleteValue:t||null})},options:this.getList(),getOptionLabel:e=>(e==null?void 0:e.name)??``,renderInput:e=>{var t;return h(N,{variant:`standard`,...e,slotProps:{...e.slotProps,input:{...e.slotProps.input,startAdornment:h(L,{position:`start`,children:h(ve,{src:((t=this.state.autoCompleteValue)==null?void 0:t.icon)||``,style:G.listIcon})})}},label:C.t(`Select adapter`)})},renderOption:(e,t)=>T(j,{component:`li`,sx:{"& > img":{mr:2,flexShrink:0}},...e,children:[h(ve,{src:(t==null?void 0:t.icon)||``,style:G.listIconWithMargin}),(t==null?void 0:t.name)??``]})})]}),h(`div`,{style:{fontSize:24,fontWeight:`bold`,marginTop:40},children:this.props.t(`Warning!`)}),h(`div`,{style:G.warningText,children:this.props.t(`npm_warning`,`NPM`,`NPM`)}),h(`div`,{style:G.noteText,children:this.props.t(`github_note`)})]}):null}renderGitHub(){return this.state.currentTab===`GitHub`?T(Ae,{style:G.tabPaper,id:`github-install-dialog-panel-github`,children:[h(`div`,{style:{display:`flex`,alignItems:`center`},children:h(E,{control:h(S,{checked:this.state.debug,onChange:e=>{(window._localstorage||window.localStorage).setItem(`App.gitDebug`,e.target.checked?`true`:`false`),this.setState({debug:e.target.checked})}}),label:this.props.t(`Debug outputs`)})}),this.renderCreateInstance(),T(`div`,{style:{display:`flex`,alignItems:`flex-end`},children:[h(ft,{style:{marginRight:10}}),h(ye,{fullWidth:!0,value:this.state.autoCompleteValue,getOptionDisabled:e=>!!(e!=null&&e.nogit),renderOption:(e,t)=>T(j,{component:`li`,sx:{"& > img":{mr:2,flexShrink:0}},...e,children:[h(ve,{src:(t==null?void 0:t.icon)||``,style:G.listIconWithMargin}),(t==null?void 0:t.name)??``,(t==null?void 0:t.nogit)&&h(`div`,{style:G.errorTextNoGit,children:C.t(`This adapter cannot be installed from git as must be built before installation.`)})]}),onChange:(e,t)=>{(window._localstorage||window.localStorage).setItem(`App.autocomplete`,t),this.setState({autoCompleteValue:t})},options:this.getList(),getOptionLabel:e=>(e==null?void 0:e.name)??``,renderInput:e=>{var t;return h(N,{variant:`standard`,...e,slotProps:{...e.slotProps,input:{...e.slotProps.input,startAdornment:h(L,{position:`start`,children:h(ve,{src:((t=this.state.autoCompleteValue)==null?void 0:t.icon)||``,style:G.listIconWithMargin})})}},label:C.t(`Select adapter`)})}})]}),h(`div`,{style:{fontSize:24,fontWeight:`bold`,marginTop:40},children:this.props.t(`Warning!`)}),h(`div`,{style:G.warningText,children:this.props.t(`github_warning`,`GitHub`,`GitHub`)}),h(`div`,{style:G.noteText,children:this.props.t(`github_note`)})]}):null}renderCustom(){return this.state.currentTab===`URL`?T(Ae,{style:G.tabPaper,id:`github-install-dialog-panel-custom`,children:[h(`div`,{style:{display:`flex`,alignItems:`center`},children:h(E,{control:h(S,{checked:this.state.debug,onChange:e=>{(window._localstorage||window.localStorage).setItem(`App.gitDebug`,e.target.checked?`true`:`false`),this.setState({debug:e.target.checked})}}),label:this.props.t(`Debug outputs`)})}),this.renderCreateInstance(),h(`div`,{style:{display:`flex`,alignItems:`center`},children:h(ye,{fullWidth:!0,value:this.state.url||``,onInputChange:(e,t)=>{(window._localstorage||window.localStorage).setItem(`App.userUrl`,t||``),this.setState({url:t||``})},onChange:(e,t)=>{(window._localstorage||window.localStorage).setItem(`App.userUrl`,t||``),this.setState({url:t||``})},renderOption:(e,t)=>T(j,{component:`li`,...e,style:{display:`flex`,alignItems:`left`},children:[t,h(`div`,{style:{flexGrow:1}}),h(y,{size:`small`,onClick:e=>{e.stopPropagation();let n=this.state.customHistory.filter(e=>e!==t);(window._localstorage||window.localStorage).setItem(`App.npmHistory`,JSON.stringify(n)),this.setState({customHistory:n})},children:h(p,{})})]}),freeSolo:!0,options:this.state.customHistory,renderInput:e=>h(N,{variant:`standard`,...e,onKeyUp:e=>{e.key===`Enter`&&this.state.url&&this.handleInstall().then(()=>{this.setState({autoCompleteValue:null,url:``}),this.props.onClose()})},helperText:this.props.t(`URL or file path`),label:this.props.t(`URL`)})})}),h(`div`,{style:{fontSize:24,fontWeight:`bold`,marginTop:40},children:this.props.t(`Warning!`)}),h(`div`,{style:G.warningText,children:this.props.t(`github_warning`,`URL`,`URL`)}),h(`div`,{style:G.noteText,children:this.props.t(`github_note`)})]}):null}renderFile(){return this.state.currentTab===`File`?T(Ae,{style:G.tabPaper,id:`github-install-dialog-panel-file`,children:[T(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[T(V,{variant:`outlined`,component:`label`,startIcon:h(be,{}),disabled:this.state.uploading,children:[this.props.t(`Select file`),h(`input`,{type:`file`,accept:`.tgz`,hidden:!0,onChange:e=>{var t;let n=((t=e.target.files)==null?void 0:t[0])||null;this.setState({selectedFile:n,url:``}),(window._localstorage||window.localStorage).setItem(`App.userUrl`,``),e.target.value=``}})]}),this.state.selectedFile&&T(D,{children:[h(P,{variant:`body2`,style:{flex:1},children:this.state.selectedFile.name}),h(y,{size:`small`,onClick:()=>this.setState({selectedFile:null}),children:h(v,{})})]}),this.state.uploading&&h(l,{size:24})]}),this.state.selectedFile&&h(E,{control:h(S,{checked:this.state.restartAfterInstall,onChange:e=>{(window._localstorage||window.localStorage).setItem(`App.restartAfterInstall`,e.target.checked?`true`:`false`),this.setState({restartAfterInstall:e.target.checked})}}),label:this.props.t(`Restart adapter after install`)}),this.renderCreateInstance(),this.state.cmdExecFilesSupported&&T(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginTop:8},children:[T(P,{variant:`body2`,children:[this.props.t(`Install on host`),`:`]}),h(et,{socket:this.props.socket,currentHost:this.state.selectedHost,hostsWorker:this.props.hostsWorker,expertMode:this.props.expertMode,themeType:this.props.themeType,tooltip:this.props.t(`Install on host`),setCurrentHost:(e,t)=>this.setState({selectedHost:t})})]}),h(`div`,{style:{fontSize:24,fontWeight:`bold`,marginTop:40},children:this.props.t(`Warning!`)}),h(`div`,{style:G.warningText,children:this.props.t(`github_warning`,`File`,`File`)}),h(`div`,{style:G.noteText,children:this.props.t(`github_note`)})]}):null}getList(){let e=Ut(this.props.categories.map(e=>e.adapters));return e.sort(),e.map((t,n)=>{if(n&&e[n-1]===t)return null;let r=this.props.repository[t];if(!(r!=null&&r.controller)){let e=(r.extIcon||r.meta||r.readme||``).toString().split(`/`),n=r==null?void 0:r.name;n||=(n=r.titleLang,n&&typeof n==`object`?n[C.getLanguage()]||n.en:r.title||t);let i={value:`${t}/${e[3]}`,name:`${n} [${e[3]}]`,icon:r.extIcon||r.icon||``,nogit:!!r.nogit,title:t};return this.props.installed[n]&&n!==`admin`&&(i.icon=Ye(`adapter/${t}/${(r.icon||``).split(`/admin/`).pop()}`)),i}return null}).filter(e=>e).sort((e,t)=>e.name<t.name?-1:+(e.name>t.name))}render(){var e;let t=()=>this.setState({autoCompleteValue:null,url:``,selectedFile:null,uploading:!1});return T(a,{onClose:()=>this.props.onClose(),open:!0,sx:{"& .MuiDialog-paper":G.paper},children:[h(b,{dividers:!0,children:T(j,{component:`div`,sx:G.root,children:[h(De,{position:`static`,color:`default`,children:T(Be,{value:this.state.currentTab,onChange:(e,t)=>{(window._localstorage||window.localStorage).setItem(`App.gitTab`,t),this.setState({currentTab:t})},variant:`fullWidth`,indicatorColor:`secondary`,children:[h(oe,{label:this.props.t(`From npm`),wrapped:!0,sx:{"&.Mui-selected":G.tabSelected},icon:h(`img`,{src:Bt,alt:`npm`,width:24,height:24}),...Ht(`npm`),value:`npm`}),h(oe,{label:this.props.t(`From github`),wrapped:!0,sx:{"&.Mui-selected":G.tabSelected},icon:h(m,{style:{width:24,height:24},width:24,height:24}),...Ht(`github`),value:`GitHub`}),h(oe,{label:this.props.t(`Custom`),wrapped:!0,sx:{"&.Mui-selected":G.tabSelected},icon:h(r,{width:24,height:24}),...Ht(`custom`),value:`URL`}),h(oe,{label:this.props.t(`From file`),wrapped:!0,sx:{"&.Mui-selected":G.tabSelected},icon:h(ge,{style:{width:24,height:24}}),...Ht(`file`),value:`File`})]})}),h(j,{component:`div`,sx:G.title,children:this.props.t(`Install or update the adapter from %s`,this.state.currentTab||`npm`)}),this.renderNpm(),this.renderGitHub(),this.renderCustom(),this.renderFile()]})}),T(M,{children:[h(V,{id:`github-install-dialog-ok`,variant:`contained`,disabled:this.state.uploading||this.props.commandRunning||(this.state.currentTab===`GitHub`||this.state.currentTab===`npm`)&&!((e=this.state.autoCompleteValue)!=null&&e.value)||this.state.currentTab===`URL`&&!this.state.url||this.state.currentTab===`File`&&!this.state.selectedFile,autoFocus:!0,onClick:async()=>{await this.handleInstall(),this.props.onClose(),t()},color:`primary`,startIcon:this.props.commandRunning?h(l,{size:20}):h(pe,{}),children:this.props.t(`Install`)}),h(V,{id:`github-install-dialog-close`,variant:`contained`,onClick:()=>{this.props.onClose(),t()},color:`grey`,startIcon:h(v,{}),children:this.props.t(`Close`)})]})]})}};d();var K={formControl:{marginTop:24,width:100},closeButton:e=>({position:`absolute`,right:8,top:8,color:e.palette.grey[500]}),languageButton:{position:`absolute`,right:60,top:8},languageButtonActive:e=>({color:e.palette.primary.main}),paper:{},typography:{pr:`30px`},messageText:{},messageColor_warn:{color:`#cb7642`},messageColor_error:{color:`#f5614d`},messageColor_info:{color:`#5abd29`},messageTitle_warn:e=>({background:`#cb7642`,borderRadius:`3px`,pl:`10px`,fontWeight:`bold`,color:e.palette.mode===`dark`?`black`:`white`}),messageTitle_error:e=>({background:`#f5614d`,borderRadius:`3px`,pl:`10px`,fontWeight:`bold`,color:e.palette.mode===`dark`?`black`:`white`}),messageTitle_info:e=>({background:`#5abd29`,borderRadius:`3px`,pl:`10px`,fontWeight:`bold`,color:e.palette.mode===`dark`?`black`:`white`}),deps:e=>({m:`10px`,fontSize:16,color:e.palette.mode===`dark`?`#e70000`:`#840101`})},Kt=class extends z{constructor(e){super(e),w(this,`t`,void 0),w(this,`messages`,null),w(this,`lang`,void 0),this.state={instanceNumbers:[]},this.t=e.t,this.lang=C.getLanguage(),this.messages=Dt(e.adapterObject.messages,null,e.adapterObject.version,e.instances)}componentDidMount(){this.props.instancesWorker.getObjects().then(e=>{let t=Object.keys(e||{}).filter(t=>{var n;return(e==null||(n=e[t])==null||(n=n.common)==null?void 0:n.name)===this.props.adapter}).map(e=>e.substring(e.lastIndexOf(`.`)+1));this.setState({instanceNumbers:t})})}getAvailableInstances(){let e=[];e.push(h(F,{value:`auto`,children:this.t(`auto`)},`auto`));for(let t=0;t<=100&&(this.state.instanceNumbers.includes(t.toString())||e.push(h(F,{value:t.toString(),children:t},t)),!(e.length>11));t++);return e}checkDependencies(e=this.props.dependencies){if(!e)return``;let t=[];for(let r of e){var n;r.installedVersion?(n=r.wrongHosts)!=null&&n.length?t.push(T(`div`,{children:[h(`div`,{children:this.props.t(`The following hosts do not fulfill the required version %s of %s:`,r.version||`unknown`,r.name)}),h(`ul`,{style:{margin:`4px 0`},children:r.wrongHosts.map(e=>T(`li`,{children:[e.host,`: `,e.installedVersion]},e.host))})]},r.name)):r.rightVersion||t.push(h(`div`,{children:`${this.props.t(`Invalid version of %s. Required %s. Current `,r.name,r.version||`unknown`)}${r.installedVersion}`},r.name)):t.push(h(`div`,{children:this.props.t(`No version of %s`,r.name,r.name)},r.name))}return t.length?t:``}getText(e,t){return e&&typeof e==`object`?t?e.en:e[this.lang]||e.en:typeof e==`object`?``:e}renderOneMessage(e,t){return T(O,{children:[h(P,{sx:K[`messageTitle_${e.level||`warn`}`],children:this.getText(e.title,this.props.noTranslation)||``}),h(P,{component:`div`,variant:`body2`,style:K.messageText,children:this.getText(e.text,this.props.noTranslation)||``}),e.link?h(V,{onClick:()=>{let t=window.open(e.link,`_blank`);t==null||t.focus()},startIcon:h(me,{}),variant:`contained`,color:`grey`,children:this.getText(e.linkText||``,this.props.noTranslation)||this.props.t(`More info`)}):null]},t)}renderMessages(){return this.messages?h(O,{container:!0,spacing:2,wrap:`nowrap`,sx:{marginBottom:1,flexDirection:`column`},children:this.messages.map((e,t)=>this.renderOneMessage(e,t))}):null}render(){let e=this.checkDependencies();return T(a,{onClose:()=>{},open:!0,sx:{"& .MuiDialog-paper":K.paper},children:[h(x,{children:T(P,{component:`h2`,variant:`h6`,sx:{"&.MuiTypography-root":K.typography},children:[this.t(`You are going to add new instance:`),` `,this.props.adapter,h(y,{size:`large`,sx:K.closeButton,onClick:()=>this.props.onClose(!1),children:h(v,{})}),this.messages&&this.lang!==`en`&&this.props.toggleTranslation?h(y,{size:`large`,style:k.getStyle(this.props.theme,K.languageButton,this.props.noTranslation&&K.languageButtonActive),onClick:this.props.toggleTranslation,title:C.t(`Disable/Enable translation`),children:h(r,{})}):null]})}),T(b,{dividers:!0,children:[this.renderMessages(),!e&&this.props.expertMode?T(O,{container:!0,sx:{flexDirection:`column`},children:[h(et,{tooltip:this.t(`Select host to add the instance`),expertMode:!0,socket:this.props.socket,hostsWorker:this.props.hostsWorker,currentHost:this.props.currentHost,setCurrentHost:(e,t)=>this.props.onHostChange(t.replace(/^system\.host\./,``))}),T(o,{variant:`standard`,style:K.formControl,children:[h(_,{id:`instance-label`,children:this.t(`Instance`)}),h(Fe,{variant:`standard`,labelId:`instance-label`,value:this.props.currentInstance,onChange:this.props.onInstanceChange,children:this.getAvailableInstances()})]})]}):null,h(j,{component:`div`,sx:K.deps,children:e})]}),T(M,{children:[h(V,{id:`instance-add-dialog-ok`,variant:`contained`,autoFocus:!0,disabled:!!e,onClick:()=>this.props.onClose(!0),color:`primary`,startIcon:h(s,{}),children:this.t(`Add`)}),h(V,{id:`instance-add-dialog-cancel`,variant:`contained`,onClick:()=>this.props.onClose(!1),color:`grey`,startIcon:h(v,{}),children:this.t(`Close`)})]})]})}},q=class e extends z{constructor(e){super(e),this.state={showDialog:!1,showLicenseDialog:null,addInstanceHostName:``,addInstanceId:`auto`,addInstanceDialog:``}}renderLicenseDialog(t){var n;return this.state.showLicenseDialog?h(rt,{licenseType:this.state.showLicenseDialog.licenseType,url:this.state.showLicenseDialog.url,link:(n=t.repository[this.state.showLicenseDialog.adapterName])==null||(n=n.licenseInformation)==null?void 0:n.link,onClose:n=>{let r=n?this.state.showLicenseDialog:null;this.setState({showLicenseDialog:null,showDialog:!1},()=>{r&&(r.upload?e.upload(r.adapterName,t):this.addInstance({adapterName:r.adapterName,context:t}).catch(e=>window.alert(`Cannot add instance: ${e}`)))})}}):null}async addInstance(t){if(!t.customUrl){let e=t.context.repository[t.adapterName],n=Dt(e.messages,null,e.version,t.context.compactInstances);if(!t.instance&&(t.context.expertMode||n))return this.setState({addInstanceDialog:t.adapterName,showDialog:!0,addInstanceHostName:t.context.currentHost.replace(/^system\.host\./,``),addInstanceId:t.instance||`auto`}),!1;if(t.instance){let e=await t.context.instancesWorker.getObjects();if(e&&e[`system.adapter.${t.adapterName}.${t.instance}`])return window.alert(t.context.t(`Instance %s already exists`,`${t.adapterName}.${t.instance}`)),!1}}let n=(t.host||this.state.addInstanceHostName||t.context.currentHost).replace(/^system\.host\./,``);if(!t.customUrl){let r=await e.getSingletonRefusal(t.adapterName,n,t.context);if(r)return window.alert(r),!1}try{await new Promise((e,r)=>{t.context.executeCommand(`${t.customUrl?`url`:`add`} ${t.adapterName} ${t.instance?`${t.instance} `:``}--host ${n} ${t.debug||t.context.expertMode?`--debug`:``}`,n,t=>t?r(Error(`The process returned an exit code of ${t}`)):e(),t.files)})}catch(e){return window.alert(`${C.t(`Cannot install`)}: ${e}`),!1}return!0}static isSingletonInstalled(e,t){var n;if(!((n=t.adapters[`system.adapter.${e}`])!=null&&(n=n.common)!=null&&n.singleton))return!1;let r=`system.adapter.${e}.`;return Object.keys(t.compactInstances).some(e=>e.startsWith(r))}static async getSingletonRefusal(e,t,n){var r;let i=(r=n.adapters[`system.adapter.${e}`])==null?void 0:r.common;if(!(i!=null&&i.singleton)&&!(i!=null&&i.singletonHost))return null;let a=await n.instancesWorker.getObjects().catch(()=>null)||{},o=`system.adapter.${e}.`,s=Object.values(a).filter(e=>e==null?void 0:e._id.startsWith(o));if(i.singleton&&s.length)return n.t(`Adapter "%s" allows only one instance, and %s exists already`,e,s[0]._id.substring(15));let c=s.find(e=>e.common.host===t);return i.singletonHost&&c?n.t(`Adapter "%s" allows only one instance per host, and %s exists already on host "%s"`,e,c._id.substring(15),t):null}static async createInstanceIfNotExists(e){let{adapterName:t,context:n}=e,r=(e.host||n.currentHost).replace(/^system\.host\./,``),i;for(let e=0;e<5&&!i;e++){await new Promise(e=>setTimeout(e,500));try{i=await n.socket.getObject(`system.adapter.${t}`)}catch{}}if(!i){console.warn(`Cannot create an instance: adapter "${t}" not found after the installation`);return}let a=await n.instancesWorker.getObjects(!0);if(!(a&&Object.keys(a).find(e=>e.startsWith(`system.adapter.${t}.`))))try{await new Promise((i,a)=>{n.executeCommand(`add ${t} --host ${r} ${e.debug||n.expertMode?`--debug`:``}`,r,e=>e?a(Error(`The process returned an exit code of ${e}`)):i())})}catch(e){window.alert(`${C.t(`Cannot create instance`)}: ${e}`)}}static getDependencies(e,t){let n=t.repository[e],r=[];if(n){let e=n.dependencies?Array.isArray(n.dependencies)?n.dependencies:[n.dependencies]:[],a=n.globalDependencies?Array.isArray(n.globalDependencies)?n.globalDependencies:[n.globalDependencies]:[],o=n.node;if(e.length)for(let n of e){let e={name:``,version:null,installed:!1,installedVersion:null,rightVersion:!1},i=typeof n!=`string`,a=Object.keys(n);if(e.name=(i?a?a[0]:``:n)||``,e.version=i?n[e.name]:null,e.name){let n=t.installed[e.name];e.installed=!!n,e.installedVersion=n?n.version:null;try{e.rightVersion=n?!i||R.satisfies(n.version,e.version||`*`,{includePrerelease:!0}):!1}catch{e.rightVersion=!0}}r.push(e)}if(a.length)for(let e of a){let n={name:``,version:null,installed:!1,installedVersion:null,rightVersion:!1},a=typeof e!=`string`,o=Object.keys(e);if(n.name=(a?o?o[0]:``:e)||``,n.version=a?e[n.name]:null,n.name){var i;let e=t.installedGlobal[n.name];n.installed=!!e,n.installedVersion=e?e.version:null;let r=(i=t.installedGlobalHosts)==null?void 0:i[n.name];if(a&&r&&Object.keys(r).length>1){let t=[];for(let[e,i]of Object.entries(r)){let r;try{r=R.satisfies(i,n.version||`*`,{includePrerelease:!0})}catch{r=!0}r||t.push({host:e,installedVersion:i})}n.wrongHosts=t,n.rightVersion=e?!t.length:!1}else try{n.rightVersion=e?!a||R.satisfies(e.version,n.version||`*`,{includePrerelease:!0}):!1}catch{n.rightVersion=!0}}r.push(n)}let s=n.ifInstalledDependencies||{};if(typeof s==`object`&&!Array.isArray(s)){let e=Object.keys(s);for(let n of e){let e={name:n,version:s[n],installed:!1,installedVersion:null,rightVersion:!1};if(e.name){let n=t.installedGlobal[e.name];e.installed=!!n,e.installedVersion=n?n.version:null;try{e.rightVersion=!n||R.satisfies(n.version,e.version||`*`,{includePrerelease:!0})}catch{e.rightVersion=!0}}r.push(e)}}if(o){let e={name:`node`,version:o,installed:!0,installedVersion:t.nodeJsVersion,rightVersion:!1};try{e.rightVersion=R.satisfies(t.nodeJsVersion,o)}catch{e.rightVersion=!0}r.push(e)}}return r}renderAddInstanceDialog(t){return this.state.addInstanceDialog?h(Kt,{adapter:this.state.addInstanceDialog,socket:t.socket,hostsWorker:t.hostsWorker,instancesWorker:t.instancesWorker,dependencies:e.getDependencies(this.state.addInstanceDialog,t),currentHost:`system.host.${this.state.addInstanceHostName}`,currentInstance:this.state.addInstanceId,t:t.t,onClose:e=>{let n=e?this.state.addInstanceDialog:``,r=e?this.state.addInstanceId:``;this.setState({addInstanceDialog:``,addInstanceId:`auto`,showDialog:!1},()=>{if(n)try{this.addInstance({adapterName:n,instance:r,context:t})}catch(e){window.alert(`Cannot add instance: ${e}`)}})},onHostChange:e=>this.setState({addInstanceHostName:e.replace(/^system\.host\./,``)}),onInstanceChange:e=>this.setState({addInstanceId:e.target.value.toString()}),adapterObject:t.repository[this.state.addInstanceDialog],instances:t.compactInstances,toggleTranslation:t.toggleTranslation,noTranslation:this.props.noTranslation,expertMode:t.expertMode,theme:t.theme}):null}static upload(e,t){t.executeCommand(`upload ${e}${t.expertMode?` --debug`:``}`)}onAddInstance(e,t){var n;let r=t.repository[e],i=Rt(r),a=((n=r.licenseInformation)==null?void 0:n.license)||r.license;a===`MIT`||a===`Apache-2.0`||a===`ISC`||a===`BSD-3-Clause`||a===`BSD-2-Clause`||!a?this.addInstance({adapterName:e,context:t}).catch(e=>window.alert(`Cannot add instance: ${e}`)):this.setState({showLicenseDialog:{url:i,adapterName:e,licenseType:a},showDialog:!0})}renderDialogs(e){return this.state.showDialog?T(D,{children:[this.renderAddInstanceDialog(e),this.renderLicenseDialog(e)]}):null}},J={name:{flexWrap:`nowrap`,width:300,marginTop:0},nameDiv:{display:`flex`,alignItems:`center`},categoryName:{fontWeight:`bold`,cursor:`pointer`},green:{color:te[500]},blue:{color:de[700]},category:{backgroundColor:`background.default`},marginRight5:{marginRight:5}};function qt(e){let{installedCount:t,name:n,categoryName:r}=e;return T(_e,{hover:!1,sx:J.category,children:[h(B,{children:h(O,{container:!0,spacing:1,style:J.name,sx:{alignItems:`center`},children:h(O,{component:`div`,children:h(y,{size:`small`,onClick:e.onToggle,children:e.expanded?h(i,{}):h(St,{})})})})}),h(B,{onClick:e.onToggle,children:T(`div`,{style:{...J.nameDiv,...J.categoryName},children:[h(wt,{iconName:r,style:J.marginRight5}),n]})}),T(B,{colSpan:e.descHidden?5:6,children:[h(P,{component:`span`,variant:`body2`,style:J.green,children:t}),` ${e.t(`of`)} `,h(P,{component:`span`,variant:`body2`,style:J.blue,children:e.count}),` ${e.t(`Adapters from this Group installed`)}`]})]})}var Y={rating:{marginBottom:20},listRating:{marginRight:8},listTime:{opacity:.5,fontStyle:`italic`},list:{},listOwn:e=>({backgroundColor:e.palette.mode===`light`?`#16516e2e`:e.palette.secondary.dark}),listTitle:e=>({backgroundColor:e.palette.primary.dark,pt:`4px`,pb:`4px`,mb:`4px`,color:`#ffffff`,textAlign:`center`}),languageFilter:{width:300},ratingTextControl:{width:`calc(100% - 138px)`,marginRight:8},ratingLanguageControl:{width:130},noComments:{width:`100%`,textAlign:`center`,marginTop:16},commentCount:{marginTop:2,marginLeft:8,opacity:.8,fontSize:10,float:`right`},infoText:{textAlign:`left`,fontSize:`14px`},infoTextContainer:{display:`flex`,paddingBottom:`10px`,alignItems:`center`,gap:`10px`}},Jt=[{id:`en`,title:`English`},{id:`de`,title:`Deutsch`},{id:`ru`,title:`русский`},{id:`pt`,title:`Portugues`},{id:`nl`,title:`Nederlands`},{id:`fr`,title:`français`},{id:`it`,title:`Italiano`},{id:`es`,title:`Espanol`},{id:`pl`,title:`Polski`},{id:`uk`,title:`Українська`},{id:`zh-cn`,title:`简体中文`}],Yt=class extends z{constructor(e){super(e),this.state={ratingNumber:0,ratingComment:``,votings:null,ratingLang:this.props.lang,filterLang:(window._localStorage||window.localStorage).getItem(`app.commentLang`)||this.props.lang,commentsByLanguage:{}}}componentDidMount(){fetch(`https://rating.iobroker.net/adapter/${this.props.adapter}?uuid=${this.props.uuid}`).then(e=>e.json()).then(e=>{e||={},e.rating||={};let t=Object.keys(e.rating);t.sort((t,n)=>e.rating[t].ts>e.rating[n].ts?-1:+(e.rating[t].ts<e.rating[n].ts));let n={};if(e.comments&&(e.comments.sort((e,t)=>e.ts>t.ts?-1:+(e.ts<t.ts)),e.comments.forEach(e=>{n[e.lang]=n[e.lang]||0,n[e.lang]++})),t.length){let r=e.rating[t[0]];this.setState({votings:e,ratingNumber:r?r.r:0,commentsByLanguage:n})}else this.setState({votings:e,commentsByLanguage:n})})}setAdapterRating(e,t,n,r,i){return fetch(`https://rating.iobroker.net/vote`,{method:`POST`,headers:{"Content-Type":`application/json`},redirect:`follow`,body:JSON.stringify({uuid:this.props.uuid,adapter:e,version:t,rating:n,comment:r,lang:i})}).then(e=>e.json()).then(r=>(window.alert(`${this.props.t(`Vote:`)} ${e}@${t}=${n}`),delete r.adapter,r)).catch(e=>(window.alert(`Cannot vote: ${e}`),null))}renderInfoText(){return T(`div`,{style:Y.infoTextContainer,children:[h(xe,{}),h(P,{style:Y.infoText,children:this.props.t(`use GitHub for issues`)})]})}renderComments(){var e;if((e=this.state.votings)!=null&&e.comments&&this.state.votings.comments.length){let e=this.state.votings.comments.find(e=>!(this.state.filterLang&&this.state.filterLang!==`_`&&e.lang!==this.state.filterLang));return T(`div`,{style:{width:`100%`,textAlign:`left`},children:[h(j,{component:`h3`,sx:Y.listTitle,children:this.props.t(`Comments`)}),T(o,{variant:`standard`,style:Y.languageFilter,children:[h(_,{children:this.props.t(`Show comments in language`)}),T(Fe,{variant:`standard`,value:this.state.filterLang,onChange:e=>{(window._localStorage||window.localStorage).setItem(`app.commentLang`,e.target.value),this.setState({filterLang:e.target.value})},children:[T(F,{value:`_`,children:[this.props.t(`All`),` `,h(`span`,{style:Y.commentCount,children:this.state.votings.comments.length})]}),Jt.map(e=>T(F,{value:e.id,children:[e.title,` `,this.state.commentsByLanguage[e.id]?h(`span`,{style:Y.commentCount,children:this.state.commentsByLanguage[e.id]}):null]},e.id))]})]}),T(se,{style:Y.list,dense:!0,disablePadding:!0,children:[e&&this.state.votings.comments.map((e,n)=>this.state.filterLang&&this.state.filterLang!==`_`&&e.lang!==this.state.filterLang?null:e?T(t,{title:e.uuid?this.props.t(`Your comment`):``,sx:{"&.MuiListItem-root":e.uuid?Y.listOwn:void 0},dense:!0,children:[h(Ce,{style:Y.listRating,children:h(Te,{readOnly:!0,defaultValue:e.rating,size:`small`})}),h(Re,{primary:e.comment,secondary:`${new Date(e.ts).toLocaleString()} / v${e.version}`,sx:{"& .MuiListItemText-secondary":Y.listTime}})]},n):null),!e&&h(`div`,{style:Y.noComments,children:this.props.t(`No comments in selected language`)})]})]})}return null}render(){var e,t;let n,r;if(this.state.votings){let e=this.state.votings.rating||{};r=Object.keys(e),r.sort((t,n)=>e[t].ts>e[n].ts?-1:+(e[t].ts<e[n].ts)),r.length&&(n=e[r[0]])}return T(a,{open:!0,onClose:()=>this.props.onClose(),children:[h(x,{children:`${this.props.t(`Review`)} ${this.props.adapter}${this.props.version?`@${this.props.version}`:``}`}),T(b,{style:{textAlign:`center`},title:((e=this.props.currentRating)==null?void 0:e.title)||``,children:[this.renderInfoText(),h(Te,{style:Y.rating,name:this.props.adapter,value:this.props.version?this.state.ratingNumber:(t=this.props.currentRating)==null||(t=t.rating)==null?void 0:t.r,size:`large`,readOnly:!this.props.version,onChange:(e,t)=>this.setState({ratingNumber:t})}),this.props.version?T(`div`,{style:{width:`100%`,textAlign:`left`},children:[h(N,{variant:`standard`,style:Y.ratingTextControl,value:this.state.ratingComment,label:this.props.t(`Comment to version`),helperText:this.props.t(`Max length %s characters`,200),onChange:e=>this.setState({ratingComment:e.target.value}),slotProps:{input:{endAdornment:this.state.ratingComment?h(L,{position:`end`,children:h(y,{tabIndex:-1,size:`small`,onClick:()=>this.setState({ratingComment:``}),children:h(v,{})})}):null},htmlInput:{maxLength:200}}}),T(o,{variant:`standard`,style:Y.ratingLanguageControl,children:[h(_,{children:this.props.t(`Language`)}),h(Fe,{variant:`standard`,value:this.state.ratingLang,onChange:e=>this.setState({ratingLang:e.target.value}),children:Jt.map(e=>h(F,{value:e.id,children:e.title},e.id))})]})]}):null,this.props.version?h(`div`,{style:{paddingTop:20,paddingBottom:16},children:this.props.t(`Rate how good this version of the adapter works on your system. You can vote for every new version.`)}):null,r&&n?h(`div`,{children:this.props.t(`You voted for %s on %s`,r[0],new Date(n.ts).toLocaleDateString())}):null,this.renderComments()]}),T(M,{children:[this.props.version&&h(V,{variant:`contained`,autoFocus:!0,color:`primary`,disabled:!this.state.ratingNumber||this.state.votings===null,onClick:()=>{this.state.ratingNumber!==(n==null?void 0:n.r)||this.state.ratingComment?this.setAdapterRating(this.props.adapter,this.props.version,this.state.ratingNumber||5,this.state.ratingComment,this.state.ratingLang).then(e=>this.props.onClose(e)):this.props.onClose()},startIcon:h(mt,{}),children:this.props.t(`Rate`)}),h(V,{autoFocus:!this.props.version,variant:`contained`,onClick:()=>this.props.onClose(),color:`grey`,startIcon:h(v,{}),children:this.props.t(`Close`)})]})]})}};d();var Xt={formControl:{marginTop:24},closeButton:e=>({position:`absolute`,right:8,top:8,color:e.palette.grey[500]}),typography:{paddingRight:30}},Zt=class extends z{constructor(e){super(e),w(this,`t`,void 0),this.state={deleteCustom:!1,deleteCustomSupported:!1},this.t=e.t}componentDidMount(){this.props.socket.checkFeatureSupported(`DEL_INSTANCE_CUSTOM`).then(e=>{if(e)return this.props.socket.getObject(`system.adapter.${this.props.adapter}`).then(e=>{e!=null&&e.common?e.common.supportCustoms&&this.setState({deleteCustomSupported:e.common.supportCustoms}):this.setState({deleteCustomSupported:!0})})})}render(){return T(a,{onClose:this.props.onClose,open:!0,children:[h(x,{children:T(P,{component:`h2`,variant:`h6`,sx:{"&.MuiTypography-root":Xt.typography},children:[this.t(`Please confirm`),h(y,{size:`large`,sx:Xt.closeButton,onClick:this.props.onClose,children:h(v,{})})]})}),T(b,{dividers:!0,children:[h(P,{gutterBottom:!0,children:this.t(`Are you sure you want to delete adapter %s?`,this.props.adapter)}),this.state.deleteCustomSupported&&h(E,{control:h(S,{checked:this.state.deleteCustom,onChange:e=>this.setState({deleteCustom:e.target.checked})}),label:this.t(`Delete all custom object settings of this adapter too`)})]}),T(M,{children:[h(V,{id:`adapter-delete-dialog-ok`,variant:`contained`,autoFocus:!0,onClick:()=>{this.props.onClick(this.state.deleteCustom),this.props.onClose()},color:`primary`,startIcon:h(pe,{}),children:this.t(`Ok`)}),h(V,{id:`adapter-delete-dialog-cancel`,variant:`contained`,autoFocus:!0,onClick:()=>this.props.onClose(),color:`grey`,startIcon:h(v,{}),children:this.t(`Close`)})]})]})}},Qt={none:h(yt,{}),patch:h(gt,{style:{color:`green`}}),minor:h(xt,{style:{color:`orange`}}),major:h(ne,{style:{color:`red`}})},$t=class extends Ie.Component{constructor(e){super(e),this.state={currentSavedPolicy:`none`,policy:`none`,repositories:[],supported:!0}}async componentDidMount(){await this.getConfiguredRepositories(),await this.getCurrentAutoUpgradeSetting()}async getConfiguredRepositories(){var e;let t=await this.props.socket.getObject(`system.config`);if(!(t!=null&&(e=t.common)!=null&&e.adapterAutoUpgrade))return;let n=Object.entries(t.common.adapterAutoUpgrade.repositories).filter(([,e])=>e).map(([e])=>e);this.setState({repositories:n})}getAdapterId(){return`${this.props.hostId}.adapter.${this.props.adapter}`}async getCurrentAutoUpgradeSetting(){let e=await this.props.socket.getObject(this.getAdapterId());e?this.setState({policy:e.common.automaticUpgrade||`none`,currentSavedPolicy:e.common.automaticUpgrade||`none`}):(console.error(`no adapter object existing`),this.setState({supported:!1}))}async save(){let e=await this.props.socket.getObject(this.getAdapterId());e?(e.common.automaticUpgrade=this.state.policy,await this.props.socket.setObject(this.getAdapterId(),e),this.setState({currentSavedPolicy:this.state.policy},()=>this.props.onClose())):(console.error(`no adapter object existing`),this.setState({supported:!1}))}render(){return T(a,{open:!0,maxWidth:`md`,fullWidth:!0,children:[h(x,{children:C.t(`Auto upgrade policy for %s`,this.props.adapter)}),T(b,{style:{padding:`0 20px`,overflow:`hidden`},children:[h(H,{value:!this.state.supported,children:h(P,{children:C.t(`This feature is supported up from js-controller Kiera (Version 6)!`)})}),T(H,{value:this.state.supported,children:[h(P,{children:C.t(`Allow only the following upgrades to be performed automatically:`)}),h(Fe,{variant:`standard`,style:{marginTop:20,minWidth:150,marginBottom:8},value:this.state.policy,onChange:e=>this.setState({policy:e.target.value}),children:Xe.map(e=>h(F,{value:e,children:T(`div`,{style:{display:`flex`,gap:8},children:[Qt[e],Je[e]]})},e))}),h(H,{value:this.state.repositories.includes(`beta`)&&this.state.policy!==`none`,children:h(ke,{type:`warning`,children:C.t(`repo_update_hint`)})}),h(H,{value:this.state.policy===`major`,children:h(ke,{type:`warning`,children:C.t(`The current selected configuration will allow to automatically pull in incompatible changes of this adapter!`)})})]})]}),T(M,{children:[h(V,{disabled:this.state.currentSavedPolicy===this.state.policy,color:`primary`,variant:`contained`,startIcon:h(f,{}),onClick:()=>this.save(),children:C.t(`Save`)}),h(V,{variant:`contained`,onClick:()=>this.props.onClose(),color:`grey`,startIcon:h(v,{}),children:C.t(`Close`)})]})]})}};d();var en=new Set([`admin`,`eos-admin`,`backitup`,`nexowatt-devices`,`nexowatt-device`,`nexowatt-dev`,`nexowatt-ui`]),tn=e=>String(e||``).toLowerCase().replace(/^system\.adapter\./,``).replace(/^iobroker\./,``).replace(/^@nexowatt\/iobroker\./,``).replace(/^@nexowatt\//,``).replace(/\.\d+$/,``),nn=e=>{let t=tn(e);return en.has(t)},rn={hidden:{display:`none`},buttonUpdate:{border:`1px solid`,padding:`0px 7px`,borderRadius:5,display:`flex`,alignItems:`center`,cursor:`pointer`,transition:`background 0.5s`,"&:hover":{background:`#00800026`}},buttonUpdateIcon:{height:20,width:20,marginRight:10},classPoll:{color:`orange`},classPush:{color:`green`},classAssumption:{color:`red`,transform:`rotate(90deg)`},marginLeft5:{marginLeft:5},ratingSet:{cursor:`pointer`},sentry:{width:21,height:21,objectFit:`fill`,marginTop:3,filter:`invert(0%) sepia(90%) saturate(1267%) hue-rotate(-260deg) brightness(99%) contrast(97%)`},tooltip:{pointerEvents:`none`},wrongDependencies:{color:qe[700]},updateAvailable:{color:te[700]},repositoryVersionAvailable:{color:g[800]},currentVersion:e=>({cursor:`pointer`,mb:`6px`,mr:`8px`,mt:`4px`,"&:hover":{background:e.palette.primary.dark}}),header:e=>({fontWeight:`bold`,background:e.palette.secondary.main,p:`10px`}),modalDialog:{height:`calc(100% - 64px)`,overflowY:`hidden`},currentVersionText:e=>({color:e.palette.mode===`dark`?`#a3ffa3`:`#009800`,fontWeight:`bold`,marginLeft:`4px`}),repoStableVersionText:e=>({color:e.palette.mode===`dark`?`#8dff7a`:`#2b9800`,fontWeight:`bold`,marginLeft:`4px`}),repoLatestVersionText:e=>({color:e.palette.mode===`dark`?`#a3fcff`:`#005498`,fontWeight:`bold`,marginLeft:`4px`}),rating:{},containerVersion:{},containerSpecificVersion:{},versionWarn:{color:g[500]},cardContentFlexBetween:{},cardContentFlex:{}},an=class e extends q{constructor(e){super(e),w(this,`installedVersion`,``),Object.assign(this.state,{autoUpgradeDialogOpen:!1,showUpdateDialog:!1,installRepositoryVersion:!1,adapterDeletionDialog:!1,adapterInstallSpecificVersion:``,showInstallVersion:!1,showSetRating:null})}static renderImage(e){var t;let{style:n,alt:r,...i}=e,a=(t=n.backgroundImage)==null?void 0:t.substring(5,n.backgroundImage.length-2);return h(`img`,{...i,alt:r,src:a,onError:e=>{e.target&&(e.target.onerror=null,e.target.src=`img/no-image.svg`)}})}renderAddInstanceButton(){let e=!this.props.context.repository[this.props.adapterName]||this.props.context.repository[this.props.adapterName].allowAdapterInstall;return h(H,{value:e!==!1&&!q.isSingletonInstalled(this.props.adapterName,this.props.context),children:h(I,{title:this.props.context.t(`Add instance`),slotProps:{popper:{sx:this.styles.tooltip}},children:h(y,{size:`small`,disabled:this.props.commandRunning,style:this.props.cached.rightOs?void 0:this.styles.hidden,onClick:this.props.cached.rightOs?e=>{e.preventDefault(),e.stopPropagation(),this.onAddInstance(this.props.adapterName,this.props.context)}:void 0,children:h(s,{})})})})}renderAutoUpgradeButton(){var e;let t=this.props.context.hostAdapterWorker.getObject(this.props.adapterName);if(!t)return h(`div`,{style:{width:34,height:34,display:`inline-block`}});let n=(e=t.common)==null?void 0:e.automaticUpgrade;return h(I,{title:this.props.context.t(`Automatic Upgrade Policy`)+(n?`: ${n}`:``),slotProps:{popper:{sx:this.styles.tooltip}},children:h(y,{size:`small`,onClick:e=>{e.preventDefault(),e.stopPropagation(),this.setState({autoUpgradeDialogOpen:!0,showDialog:!0})},children:!n||n===`none`?h(ht,{}):Qt[n]})})}renderReadmeButton(){let e=!this.props.context.repository[this.props.adapterName]||this.props.context.repository[this.props.adapterName].allowAdapterReadme;return h(H,{value:e,children:h(I,{title:this.props.context.t(`Readme`),slotProps:{popper:{sx:this.styles.tooltip}},children:h(y,{size:`small`,onClick:e=>{e.preventDefault(),e.stopPropagation(),this.openInfoDialog()},children:h(re,{})})})})}renderRating(){var e,t;let n=!this.props.context.repository[this.props.adapterName]||this.props.context.repository[this.props.adapterName].allowAdapterRating;return this.props.context.isTileView&&(this.props.context.sortPopularFirst||this.props.context.sortRecentlyUpdated||this.props.context.sortRecentlyCreated)||!this.props.context.repository[this.props.adapterName].stat||n===!1?null:h(`div`,{onClick:()=>this.setState({showSetRating:{version:this.installedVersion,rating:this.props.context.repository[this.props.adapterName].rating},showDialog:!0}),style:{...this.styles.rating,...this.styles.ratingSet},title:(e=this.props.context.repository[this.props.adapterName].rating)==null?void 0:e.title,children:h(Te,{name:this.props.adapterName,precision:.5,size:`small`,readOnly:!0,value:((t=this.props.context.repository[this.props.adapterName].rating)==null||(t=t.rating)==null?void 0:t.r)||0})})}renderConnectionType(){var e;let t=(e=this.props.context.repository[this.props.adapterName])==null?void 0:e.connectionType;return t===`cloud`?h(I,{title:this.props.context.t(`Adapter requires the specific cloud access for these devices/service`),slotProps:{popper:{sx:this.styles.tooltip}},children:h(Qe,{})}):t===`local`?h(I,{title:this.props.context.t(`Adapter does not use the cloud for these devices/service`),slotProps:{popper:{sx:this.styles.tooltip}},children:h(dt,{})}):null}renderDataSource(){var e;let t=(e=this.props.context.repository[this.props.adapterName])==null?void 0:e.dataSource;return t?h(`div`,{style:this.styles.marginLeft5,title:t,children:t===`poll`?h(I,{title:this.props.context.t(`The device or service will be periodically asked`),slotProps:{popper:{sx:this.styles.tooltip}},children:h(Oe,{style:this.styles.classPoll})}):t===`push`?h(I,{title:this.props.context.t(`The device or service delivers the new state actively`),slotProps:{popper:{sx:this.styles.tooltip}},children:h(ae,{style:this.styles.classPush})}):t===`assumption`?h(I,{slotProps:{popper:{sx:this.styles.tooltip}},title:this.props.context.t(`Adapter cannot request the exactly device status and the status will be guessed on the last sent command`),children:h(At,{style:this.styles.classAssumption})}):h(`div`,{style:{width:24,height:24}})}):null}renderLicenseInfo(e=!1){var t,n,r,i;let a=this.props.context.repository[this.props.adapterName],o=Lt(a),s=(t=a.licenseInformation)!=null&&t.type?h(he,{href:o,target:`_blank`,rel:`noopener`,sx:e=>({color:e.palette.mode===`dark`?`white`:`black`,"&:hover":{color:e.palette.mode===`dark`?`white`:`black`}}),children:((n=a.licenseInformation)==null?void 0:n.type)===`paid`?h(I,{title:this.props.context.t(`The adapter requires a paid license.`),slotProps:{popper:{sx:this.styles.tooltip}},children:h(_t,{})}):((r=a.licenseInformation)==null?void 0:r.type)===`commercial`?h(I,{slotProps:{popper:{sx:this.styles.tooltip}},title:this.props.context.t(`The adapter requires a paid license for commercial use.`),children:h(_t,{opacity:.5})}):((i=a.licenseInformation)==null?void 0:i.type)===`limited`?h(I,{slotProps:{popper:{sx:this.styles.tooltip}},title:this.props.context.t(`The adapter has a limited functionality without a paid license.`),children:h(_t,{opacity:.5})}):null}):null;return!s&&e?h(`div`,{style:{width:24,height:24}}):s}renderSentryInfo(){var e;return(e=this.props.context.repository[this.props.adapterName])!=null&&(e=e.plugins)!=null&&e.sentry?h(`div`,{style:this.styles.marginLeft5,children:h(I,{title:`sentry`,slotProps:{popper:{sx:this.styles.tooltip}},children:h(Ue,{style:this.styles.sentry,component:`img`,image:Tt})})}):null}getDependencies(){let e=q.getDependencies(this.props.adapterName,this.props.context);if(!e)return null;let t=[];for(let r of e){var n;r.installedVersion?(n=r.wrongHosts)!=null&&n.length?t.push(`${this.props.context.t(`The following hosts do not fulfill the required version %s of %s:`,r.version||`unknown`,r.name)} ${r.wrongHosts.map(e=>`${e.host} (${e.installedVersion})`).join(`, `)}`):r.rightVersion||t.push(`${this.props.context.t(`Invalid version of %s. Required %s. Current `,r.name,r.version||`unknown`)}${r.installedVersion}`):t.push(this.props.context.t(`No version of %s`,r.name,r.name))}return t.length?(t.unshift(this.props.context.t(`Wrong dependencies`)),t.map((e,t)=>h(`div`,{style:t?void 0:{fontWeight:`bold`,fontSize:`larger`},children:e},e))):null}renderVersion(){let e=!this.props.context.repository[this.props.adapterName]||this.props.context.repository[this.props.adapterName].allowAdapterUpdate,t=this.props.context.repository[this.props.adapterName],n=t==null?void 0:t.version;return n?!this.props.commandRunning&&e!==!1&&this.isRepositoryVersionInstallable()?h(I,{title:this.props.context.t(`Install version %s from repository`,n),slotProps:{popper:{sx:this.styles.tooltip}},children:T(`div`,{onClick:()=>this.setState({showUpdateDialog:!0,showDialog:!0,installRepositoryVersion:!0}),style:{...this.styles.buttonUpdate,...this.props.cached.rightDependencies?this.styles.repositoryVersionAvailable:void 0},children:[h(y,{style:this.styles.buttonUpdateIcon,size:`small`,children:h(tt,{})}),n]})}):!this.props.commandRunning&&this.props.cached.updateAvailable&&e!==!1?h(I,{title:this.props.context.t(`Update`),slotProps:{popper:{sx:this.styles.tooltip}},children:T(`div`,{onClick:e=>{e.preventDefault(),e.stopPropagation(),this.setState({showUpdateDialog:!0,showDialog:!0,installRepositoryVersion:!1})},style:{...this.styles.buttonUpdate,...this.props.cached.rightDependencies?this.styles.updateAvailable:void 0},children:[h(y,{style:this.styles.buttonUpdateIcon,size:`small`,children:h(He,{})}),n]})}):h(I,{title:this.getDependencies(),slotProps:{popper:{sx:this.styles.tooltip}},children:h(`span`,{style:this.props.cached.rightDependencies?void 0:this.styles.wrongDependencies,children:n})}):h(`span`,{style:this.styles.wrongDependencies,children:this.props.context.t(`not maintained`)})}isRepositoryVersionInstallable(){var e,t,n;let r=(e=this.props.context.repository[this.props.adapterName])==null?void 0:e.version,i=(t=this.props.context.installed[this.props.adapterName])==null?void 0:t.version;if(!r||!i||this.props.cached.updateAvailable)return!1;if(r!==i)return Ze.updateAvailable(r,i,`adapter "${this.props.adapterName}"`);let a=(n=this.props.context.adapters[`system.adapter.${this.props.adapterName}`])==null||(n=n.common)==null?void 0:n.installedFrom;return!!a&&!a.startsWith(`iobroker.${this.props.adapterName}@`)}static extractGitHubCommitHash(e){if(!e)return null;let t=e.indexOf(`#`);if(t===-1)return null;let n=e.substring(t+1);return n.length>=7?n.substring(0,7):n}renderInstalledVersion(t){var n;let r=this.props.context.installed[this.props.adapterName],i=(n=this.props.context.adapters[`system.adapter.${this.props.adapterName}`])==null||(n=n.common)==null?void 0:n.installedFrom,{adapterName:a}=this.props,o=i&&!i.startsWith(`iobroker.${a}@`),s=o?e.extractGitHubCommitHash(i):null,c=o&&s?`${this.installedVersion}+${s}`:this.installedVersion;if(t){let e=r==null?void 0:r.enabled,t=r==null?void 0:r.count;return T(O,{container:!0,wrap:`nowrap`,spacing:1,sx:{alignItems:`center`},children:[this.installedVersion?h(O,{children:c+(t?` (${t}${t===e?``:`~`})`:``)}):null,o&&h(O,{container:!0,children:h(I,{title:`${this.props.context.t(`Non-NPM-Version`)}: ${i}`,slotProps:{popper:{sx:this.styles.tooltip}},children:h(bt,{fontSize:`small`,style:this.styles.versionWarn})})})]})}return this.installedVersion?T(P,{component:`span`,style:this.styles.cardContentFlexBetween,children:[T(`div`,{children:[this.props.context.t(`Installed version`),`:`]}),T(`div`,{style:this.styles.cardContentFlex,children:[o&&h(I,{title:`${this.props.context.t(`Non-NPM-Version`)}: ${i}`,slotProps:{popper:{sx:this.styles.tooltip}},children:h(bt,{fontSize:`small`,style:this.styles.versionWarn})}),c]})]}):null}renderUploadButton(){return this.props.context.expertMode&&this.installedVersion?h(I,{title:this.props.context.t(`Upload`),slotProps:{popper:{sx:this.styles.tooltip}},children:h(y,{size:`small`,disabled:this.props.commandRunning,"data-eos-adapter-action":`upload`,onClick:e=>{e.preventDefault(),e.stopPropagation(),this.onUpload()},children:h(be,{})})}):null}renderDeleteButton(){let e=nn(this.props.adapterName);return h(H,{value:!!this.installedVersion&&!e,children:h(I,{title:this.props.context.t(`Delete adapter`),slotProps:{popper:{sx:this.styles.tooltip}},children:h(y,{size:`small`,disabled:this.props.commandRunning,"data-eos-adapter-action":`delete`,onClick:e=>{e.preventDefault(),e.stopPropagation(),this.setState({adapterDeletionDialog:!0,showDialog:!0})},children:h(jt,{})})})})}renderInstallSpecificVersionButton(){return this.props.context.expertMode&&this.installedVersion?h(I,{title:this.props.context.t(`Install a specific version`),slotProps:{popper:{sx:this.styles.tooltip}},children:h(y,{disabled:this.props.commandRunning,size:`small`,"data-eos-adapter-action":`install-specific-version`,onClick:e=>{e.preventDefault(),e.stopPropagation(),this.setState({showInstallVersion:!0,showDialog:!0})},children:h(ut,{})})}):null}renderRebuildButton(){return!this.props.context.expertMode||!this.installedVersion?null:h(I,{title:this.props.context.t(`Rebuild`),children:h(y,{size:`small`,disabled:this.props.commandRunning,"data-eos-adapter-action":`rebuild`,onClick:e=>{e.preventDefault(),e.stopPropagation(),this.rebuild()},children:h(fe,{})})})}renderAutoUpdateDialog(){return this.state.autoUpgradeDialogOpen?h($t,{onClose:()=>this.setState({autoUpgradeDialogOpen:!1,showDialog:!1}),adapter:this.props.adapterName,hostId:this.props.context.adminHost,socket:this.props.context.socket}):null}async ignoreVersion(e){let t=await this.props.context.socket.getObject(`system.adapter.${this.props.adapterName}`);t!=null&&t.common?(t.common.ignoreVersion=e,this.props.context.socket.setObject(t._id,t).catch(e=>window.alert(`Cannot write object: ${e}`))):window.alert(`Adapter "${this.props.adapterName}" does not exist!`),this.props.context.removeUpdateAvailable(this.props.adapterName)}renderUpdateAdapterDialog(){var e,t;if(!this.state.showUpdateDialog)return null;this.installedVersion=(e=this.props.context.installed[this.props.adapterName])==null?void 0:e.version;let n=(t=this.props.context.repository[this.props.adapterName])==null?void 0:t.version;return h(kt,{textTitle:this.state.installRepositoryVersion?this.props.context.t(`Install "%s" v%s from repository instead of v%s`,this.props.adapterName,n,this.installedVersion):void 0,textUpdate:this.state.installRepositoryVersion?this.props.context.t(`Install`):void 0,adapter:this.props.adapterName,adapterObject:this.props.context.repository[this.props.adapterName],t:this.props.context.t,dependencies:q.getDependencies(this.props.adapterName,this.props.context),rightDependencies:this.props.context.rightDependenciesFunc(this.props.adapterName),news:this.getNews(),toggleTranslation:this.props.context.toggleTranslation,noTranslation:this.props.noTranslation,installedVersion:this.installedVersion,onUpdate:e=>this.setState({showUpdateDialog:!1,showDialog:!1},()=>this.update(e)),isStable:this.props.context.repository._repoInfo.stable,onIgnore:this.state.installRepositoryVersion?void 0:e=>this.setState({showUpdateDialog:!1,showDialog:!1},()=>void this.ignoreVersion(e)),onClose:()=>this.setState({showUpdateDialog:!1,showDialog:!1}),instances:this.props.context.compactInstances,theme:this.props.context.theme})}static formatNews(e){return(e||``).toString().split(`
4
+ `).map(e=>e.trim().replace(/^\*+/,``).replace(/^-/,``).replace(/\*+$/,``).replace(/\r/g,``).trim()).filter(e=>e).map((e,t)=>T(`div`,{style:{},children:[h(`span`,{children:`- `}),e]},t))}renderAdapterInstallVersion(){if(!this.state.showInstallVersion)return null;let t,n,r=this.props.context.repository._repoInfo;if(r!=null&&r.stable){var i,a;t=(i=this.props.context.repository[this.props.adapterName])==null?void 0:i.version,n=(a=this.props.context.repository[this.props.adapterName])==null?void 0:a.latestVersion}else{var o,s;t=(o=this.props.context.repository[this.props.adapterName])==null?void 0:o.stable,n=(s=this.props.context.repository[this.props.adapterName])==null?void 0:s.version}return h(Mt,{title:this.props.context.t(`Please select specific version of %s`,this.props.adapterName),applyButton:!1,onClose:()=>this.setState({showInstallVersion:!1,adapterInstallSpecificVersion:``,showDialog:!1}),theme:this.props.context.theme,toggleTranslation:this.props.context.toggleTranslation,noTranslation:this.props.noTranslation,children:T(`div`,{style:{height:`100%`,overflowY:`hidden`},children:[T(`div`,{style:this.styles.containerSpecificVersion,children:[T(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[h(N,{variant:`standard`,style:{flexGrow:1},label:this.props.context.t(`Enter version manually`),value:this.state.adapterInstallSpecificVersion,onChange:e=>this.setState({adapterInstallSpecificVersion:e.target.value}),slotProps:{input:{endAdornment:this.state.adapterInstallSpecificVersion?h(L,{position:`end`,children:h(y,{tabIndex:-1,size:`small`,onClick:()=>this.setState({adapterInstallSpecificVersion:``}),children:h(v,{})})}):null}}}),h(V,{color:`primary`,variant:`contained`,size:`small`,disabled:!this.state.adapterInstallSpecificVersion,onClick:()=>{this.state.adapterInstallSpecificVersion&&(this.update(this.state.adapterInstallSpecificVersion),this.setState({showInstallVersion:!1,adapterInstallSpecificVersion:``,showDialog:!1}))},children:this.props.context.t(`Install`)})]}),h(I,{title:this.props.context.t(`npmjs.com`),slotProps:{popper:{sx:this.styles.tooltip}},children:h(y,{size:`small`,onClick:()=>{var e;(e=window.open(`https://www.npmjs.com/package/iobroker.${this.props.adapterName}?activeTab=versions`,this.props.adapterName))==null||e.focus()},children:h(ie,{})})})]}),h(j,{component:`div`,sx:this.styles.header,children:this.props.context.t(`Or select from the list`)}),h(`div`,{style:{...this.styles.containerVersion,height:`calc(100% - 122px)`,overflowY:`auto`},children:this.getNews(!0).map(({version:r,news:i})=>h(We,{variant:`outlined`,sx:this.styles.currentVersion,onClick:()=>{this.update(r),this.setState({showInstallVersion:!1,showDialog:!1})},children:T(c,{children:[T(P,{sx:k.getStyle(this.props.context.theme,this.installedVersion===r&&this.styles.currentVersionText,{fontSize:16,fontWeight:`bold`}),color:`text.secondary`,gutterBottom:!0,children:[r,this.installedVersion===r?h(j,{component:`span`,sx:this.styles.currentVersionText,children:`(${this.props.context.t(`current`)})`}):null,n===r?h(j,{component:`span`,sx:this.styles.repoLatestVersionText,children:`(latest)`}):null,t===r?h(j,{component:`span`,sx:this.styles.repoStableVersionText,children:`(${this.props.context.t(`stable`)})`}):null]}),h(P,{variant:`body2`,style:{opacity:.7},children:e.formatNews(i)})]})},r))})]})})}renderSetRatingDialog(){return this.state.showSetRating?h(Yt,{t:this.props.context.t,lang:this.props.context.lang,version:this.state.showSetRating.version,adapter:this.props.adapterName,currentRating:this.state.showSetRating.rating,onClose:e=>{e&&this.props.context.updateRating(this.props.adapterName,e),this.setState({showSetRating:null,showDialog:!1})},uuid:this.props.context.uuid}):null}renderAdapterDeletionDialog(){return this.state.adapterDeletionDialog?h(Zt,{adapter:this.props.adapterName,socket:this.props.context.socket,t:this.props.context.t,onClick:e=>this.delete(e),onClose:()=>this.setState({adapterDeletionDialog:!1,showDialog:!1})}):null}openInfoDialog(){var e;let t=(e=this.props.context.repository[this.props.adapterName].docs)!=null&&e[this.props.context.lang]?this.props.context.lang:`en`;window.open(Ze.getDocsLinkForAdapter({lang:t,adapterName:this.props.adapterName}),`help`)}getNews(e=!1){let t=this.props.context.repository[this.props.adapterName],n=this.props.context.installed[this.props.adapterName],r=[];return n&&t!=null&&t.news&&Object.keys(t.news).forEach(i=>{try{if(R.gt(i,n.version)||e){let e;e=typeof t.news[i]==`object`?this.props.noTranslation?t.news[i].en:t.news[i][this.props.context.lang]||t.news[i].en:t.news[i],r.push({version:i,news:e})}}catch{console.warn(`[ADAPTERS] Cannot compare "${i}" and "${n.version}" (${this.props.adapterName})`)}}),r}onUpload(){var e;let t=this.props.context.repository[this.props.adapterName],n=Rt(t),r=((e=t.licenseInformation)==null?void 0:e.license)||t.license;r!==`MIT`&&r!==`Apache-2.0`&&r!==`ISC`&&r!==`BSD-3-Clause`&&r!==`BSD-2-Clause`&&r?this.setState({showLicenseDialog:{url:n,upload:!0,adapterName:this.props.adapterName,licenseType:r},showDialog:!0}):q.upload(this.props.adapterName,this.props.context)}delete(e){nn(this.props.adapterName)?window.alert(`Dieser Adapter ist ein geschütztes NexoWatt-EOS-Systemmodul und darf nicht gelöscht werden.`):this.props.context.executeCommand(`del ${this.props.adapterName}${e?` --custom`:``}${this.props.context.expertMode?` --debug`:``}`)}update(e){this.props.context.executeCommand(`upgrade ${this.props.adapterName}@${e}${this.props.context.expertMode?` --debug`:``}`)}rebuild(){this.props.context.executeCommand(`rebuild ${this.props.adapterName}${this.props.context.expertMode?` --debug`:``}`)}renderDialogs(){return this.state.showDialog?T(D,{children:[this.renderAddInstanceDialog(this.props.context),this.renderLicenseDialog(this.props.context),this.renderUpdateAdapterDialog(),this.renderAdapterInstallVersion(),this.renderSetRatingDialog(),this.renderAdapterDeletionDialog(),this.renderAutoUpdateDialog()]}):null}};d();var on=`0 8px 17px 0 rgba(0, 0, 0, .2),0 6px 20px 0 rgba(0, 0, 0, .19)`,sn={...rn,type:{color:`tile`},root:e=>({position:`relative`,m:`10px`,width:300,minHeight:200,borderRadius:24,overflow:`hidden`,background:`linear-gradient(180deg, rgba(13, 36, 58, 0.90), rgba(7, 23, 39, 0.88))`,boxShadow:`0 14px 30px rgba(0,0,0,.24)`,display:`flex`,flexDirection:`column`,transition:`box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease`,"&:hover":{boxShadow:on}}),imageBlock:e=>({background:`linear-gradient(135deg, rgba(0,255,136,.16), rgba(0,212,255,.11))`,borderBottom:`1px solid rgba(0,255,136,.20)`,minHeight:60,display:`flex`,padding:`0 10px 0 10px`,position:`relative`,justifyContent:`space-between`,color:`#eef7ff`}),img:{width:45,height:45,margin:`auto 0`,position:`relative`,"&:after":{content:`""`,position:`absolute`,zIndex:2,top:0,left:0,width:`100%`,height:`100%`,background:`url("img/no-image.svg") 100% 100% no-repeat`,backgroundSize:`cover`,backgroundColor:`#fff`}},installed:{background:`#77c7ff8c`},update:{background:`#10ff006b`},fab:{position:`absolute`,bottom:-20,width:40,height:40,right:20},greenText:e=>({color:e.palette.success.dark}),collapse:{height:`100%`,background:`linear-gradient(180deg, rgba(8, 29, 47, 0.985), rgba(4, 14, 25, 0.975))`,color:`#eef7ff`,border:`1px solid rgba(0, 255, 136, 0.34)`,borderRadius:24,position:`absolute`,width:`100%`,zIndex:1200,marginTop:`auto`,bottom:0,overflow:`hidden`,pointerEvents:`auto`,justifyContent:`space-between`,display:`flex`,flexDirection:`column`},close:{display:`flex`,ml:`auto`,mt:`-4px`,color:`#eaf9ff`},footerBlock:e=>({background:`rgba(2, 9, 20, 0.90)`,borderTop:`1px solid rgba(0,255,136,.22)`,position:`relative`,zIndex:40,pointerEvents:`auto`,p:`10px`,display:`flex`,justifyContent:`space-between`}),versionDate:{alignSelf:`center`},adapter:e=>({width:`100%`,fontWeight:`bold`,fontSize:16,verticalAlign:`middle`,pl:1,pt:2,color:(e.palette.mode,`#333`)}),adapterWithAgo:{width:`calc(100% - 145px)`},description:e=>({display:`block`,color:`rgba(238, 247, 255, 0.94)`,fontSize:13.5,lineHeight:1.48,whiteSpace:`normal`,overflowWrap:`anywhere`}),cardContent:{overflow:`auto`},cardContentDiv:{position:`sticky`,right:0,top:0,background:`linear-gradient(135deg, rgba(0,255,136,.16), rgba(0,212,255,.09))`,borderBottom:`1px solid rgba(0,255,136,.22)`,zIndex:2},cardContentFlex:{display:`flex`},cardContentFlexBetween:{display:`flex`,justifyContent:`space-between`},cardContent2:{height:`100%`,display:`flex`,flexDirection:`column`,justifyContent:`space-between`},cardMargin10:{marginTop:10},availableVersion:{display:`flex`,justifyContent:`space-between`},curdContentFlexCenter:{display:`flex`,alignItems:`center`},versionWarn:{color:g[500],marginRight:5},rating:{marginTop:20}},cn=class extends an{constructor(e){super(e),w(this,`styles`,sn),Object.assign(this.state,{openCollapse:!1})}renderInfoCard(){return T(`div`,{className:`eos-adapter-info-card`,style:this.styles.collapse,children:[T(c,{style:this.styles.cardContent,children:[h(`div`,{style:this.styles.cardContentDiv,children:h(y,{size:`small`,sx:this.styles.close,onClick:()=>this.setState({openCollapse:!this.state.openCollapse}),children:h(v,{})})}),h(P,{gutterBottom:!0,component:`span`,variant:`body2`,sx:this.styles.description,children:this.props.cached.desc})]}),T(j,{component:`div`,sx:this.styles.footerBlock,children:[this.renderAddInstanceButton(),T(`div`,{style:this.styles.cardContentFlex,children:[this.renderAutoUpgradeButton(),this.renderReadmeButton(),this.renderUploadButton(),this.renderDeleteButton(),this.renderInstallSpecificVersionButton()]})]})]})}renderCardMedia(){let e=this.props.context.repository[this.props.adapterName],t=e==null?void 0:e.version;return T(j,{component:`div`,sx:k.getStyle(this.props.context.theme,this.styles.imageBlock,this.installedVersion&&this.styles.installed,this.installedVersion&&t&&this.installedVersion!==t&&this.props.cached.updateAvailable&&this.styles.update),children:[h(Ue,{sx:this.styles.img,component:e=>an.renderImage(e),src:this.props.cached.image||`img/no-image.svg`,image:this.props.cached.image||`img/no-image.svg`}),h(j,{component:`div`,sx:k.getStyle(this.props.context.theme,this.styles.adapter,(e.stat||this.props.context.sortRecentlyUpdated||this.props.context.sortRecentlyCreated)&&this.styles.adapterWithAgo),children:this.props.adapterName}),this.props.context.sortPopularFirst?h(`div`,{style:this.styles.versionDate,children:e.stat}):null,this.props.context.sortRecentlyUpdated?h(`div`,{style:this.styles.versionDate,children:this.props.cached.daysAgoText}):null,this.props.context.sortRecentlyCreated?h(`div`,{style:this.styles.versionDate,children:this.props.cached.createdDaysAgoText}):null,!this.props.context.sortPopularFirst&&!this.props.context.sortRecentlyUpdated&&!this.props.context.sortRecentlyCreated?this.renderRating():null,this.state.openCollapse?null:h(I,{title:this.props.context.t(`Info`),slotProps:{popper:{sx:{pointerEvents:`none`}}},children:h(le,{onClick:()=>this.setState({openCollapse:!this.state.openCollapse}),style:this.styles.fab,color:`primary`,"aria-label":`add`,children:h(Ve,{})})})]})}renderCardContent(){let e=!this.props.context.repository[this.props.adapterName]||this.props.context.repository[this.props.adapterName].allowAdapterUpdate,t=this.props.context.installed[this.props.adapterName];return T(c,{style:this.styles.cardContent2,children:[h(P,{gutterBottom:!0,variant:`h5`,component:`h5`,children:this.props.cached.title}),T(`div`,{style:this.styles.cardContentFlex,children:[this.renderConnectionType(),this.renderDataSource(),h(`div`,{children:this.renderLicenseInfo()}),this.renderSentryInfo()]}),T(`div`,{style:this.styles.cardMargin10,children:[t!=null&&t.count?T(P,{component:`span`,style:this.styles.cardContentFlexBetween,children:[T(`div`,{children:[this.props.context.t(`Installed instances`),`:`]}),h(`div`,{children:t.count})]}):null,h(H,{value:e,children:T(P,{component:`span`,style:this.styles.availableVersion,children:[h(`div`,{children:this.props.context.t(`Available version:`)}),h(j,{component:`div`,sx:k.getStyle(this.props.context.theme,this.props.cached.updateAvailable&&this.styles.greenText,this.styles.curdContentFlexCenter),children:this.renderVersion()})]})}),this.renderInstalledVersion()]})]})}render(){var e;return this.installedVersion=(e=this.props.context.installed[this.props.adapterName])==null?void 0:e.version,T(We,{sx:this.styles.root,children:[this.state.openCollapse?this.renderInfoCard():null,this.renderCardMedia(),this.renderCardContent(),this.renderDialogs()]})}};d();var ln={...rn,type:{color:`line`},smallAvatar:{width:32,height:32,marginLeft:4},paddingNone:{padding:`0 !important`},name:{flexWrap:`nowrap`,width:300,marginTop:0},flex:{display:`flex`},nameCell:{paddingTop:`0 !important`,paddingBottom:`0 !important`}},un=class extends an{constructor(...e){super(...e),w(this,`styles`,ln)}render(){var e,t;let n=this.props.context.repository[this.props.adapterName],r=!n||n.allowAdapterRating;return this.installedVersion=(e=this.props.context.installed[this.props.adapterName])==null?void 0:e.version,T(_e,{hover:!0,children:[h(B,{}),h(B,{children:T(O,{container:!0,spacing:1,style:this.styles.name,sx:{alignItems:`center`},children:[h(I,{title:this.props.adapterName,slotProps:{popper:{sx:this.styles.tooltip}},children:h(O,{style:this.styles.paddingNone,children:h(Ee,{variant:`square`,alt:this.props.cached.title,src:this.props.cached.image,style:this.styles.smallAvatar})})}),r===!1?h(O,{children:this.props.cached.title}):T(O,{style:this.styles.nameCell,children:[h(`div`,{children:this.props.cached.title}),this.renderRating()]})]})}),!this.props.context.descHidden&&h(B,{title:this.props.cached.desc,style:{width:20,wordWrap:`break-word`},children:this.props.cached.desc}),h(B,{children:T(`div`,{style:this.styles.flex,children:[this.renderConnectionType()||h(`div`,{style:{width:24,height:24}}),this.renderDataSource()||h(`div`,{style:{marginLeft:5,width:24,height:24}}),this.renderSentryInfo()||h(`div`,{style:{marginLeft:5,width:24,height:24}}),this.renderLicenseInfo(!0)]})}),h(B,{children:this.renderInstalledVersion(!0)}),h(B,{children:h(O,{container:!0,sx:{alignItems:`center`},children:this.renderVersion()})}),h(B,{style:{fontSize:`smaller`},children:(n==null||(t=n.licenseInformation)==null?void 0:t.license)||(n==null?void 0:n.license)}),T(B,{children:[this.renderAddInstanceButton(),this.renderAutoUpgradeButton(),this.renderReadmeButton(),this.renderUploadButton(),this.renderDeleteButton(),this.renderInstallSpecificVersionButton(),this.renderRebuildButton()]}),this.renderDialogs()]})}};d();var dn=246,X={emptyBlock:50,name:300,connectionType:120,installed:120,available:120,update:40,license:80,install:dn},fn=Object.keys(X).reduce((e,t)=>e+X[t],0),Z={container:{height:`100%`,width:`100%`},containerNotFullHeight:{height:`calc(100% - 50px)`},containerFullHeight:{height:`100%`},table:{width:`100%`,tableLayout:`fixed`,minWidth:960,"& td":{whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`,pt:`2px`,pb:`2px`,pr:`4px`,pl:`4px`},"& th":{whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`,pt:`2px`,pb:`2px`,pr:`4px`,pl:`4px`}},name:{flexWrap:`nowrap`,width:X.name},emptyBlock:{flexWrap:`nowrap`,width:X.emptyBlock},description:{width:`calc(100% - ${fn+2}px)`},connectionType:{width:X.connectionType},installed:{width:X.installed},available:{width:X.available,paddingRight:6},update:{width:X.update,padding:0},license:{width:X.license},install:{width:X.install},viewModeDiv:{display:`flex`,flexFlow:`wrap`,overflow:`auto`,justifyContent:`center`}},pn=class extends z{constructor(e){super(e),w(this,`lastRenderCounter`,-1),this.state={descWidth:e.descWidth,repoName:e.repoName,systemConfig:!!e.systemConfig,tableViewMode:e.tableViewMode,oneListView:e.oneListView,categoriesExpanded:JSON.stringify(e.categoriesExpanded),cachedAdapters:e.cachedAdapters?Object.keys(e.cachedAdapters).length:0,update:e.update,sortByName:e.sortByName,sortPopularFirst:e.sortPopularFirst,sortRecentlyUpdated:e.sortRecentlyUpdated,sortRecentlyCreated:e.sortRecentlyCreated,renderCounter:0,listOfVisibleAdapter:JSON.stringify(e.listOfVisibleAdapter),expertMode:e.context.expertMode,commandRunning:e.commandRunning,noTranslation:e.noTranslation}}getRow(e,t){var n;let r=(n=this.props.cachedAdapters)==null?void 0:n[e];return r?h(un,{context:t,adapterName:e,cached:r,commandRunning:this.state.commandRunning,noTranslation:this.state.noTranslation},`adapter-${e}`):null}getRows(e){if(!this.props.listOfVisibleAdapter)return h(_e,{children:h(B,{colSpan:8,children:h(A,{})})});let t=0,n=[];if(this.props.oneListView){for(let t=0;t<this.props.listOfVisibleAdapter.length;t++){var r;let i=this.props.listOfVisibleAdapter[t];if(n.length>50&&!((r=this.props.context.installed[i])!=null&&r.version))continue;let a=this.getRow(i,e);a&&n.push(a)}if(t=n.length,t&&this.props.listOfVisibleAdapter.length>n.length){let e=this.props.listOfVisibleAdapter.length-n.length,t=e===1?this.props.context.t(`Filter adapters to see others. There is %s more`,1):this.props.context.t(`Filter adapters to see others. There are %s more`,e);n.push(h(_e,{children:h(B,{colSpan:8,style:{fontSize:20,padding:20,textAlign:`center`},children:t})},`more`))}}else n=this.props.categories.map(n=>{if(!n.adapters.find(e=>{var t;return(t=this.props.listOfVisibleAdapter)==null?void 0:t.includes(e)}))return null;let r=n.name,i=this.props.categoriesExpanded[r];return t++,T(Ne,{children:[h(qt,{categoryName:r,count:n.count,expanded:i,installedCount:n.installed,name:n.translation,descHidden:e.descHidden,onToggle:()=>this.props.toggleCategory(r),t:this.props.context.t},`category-${r}1`),i&&n.adapters.map(n=>{let r=this.getRow(n,e);return r&&t++,r})]},`category-${r} ${n.adapters.length}`)});return t?n:this.props.update?null:h(`tr`,{children:T(`td`,{colSpan:8,style:{textAlign:`center`},children:[this.props.searchFilter||this.props.installedListFilter?h(V,{variant:`outlined`,title:this.props.context.t(`Click to clear all filters`),onClick:()=>this.props.clearAllFilters(),children:this.props.context.t(`all items are filtered out`)}):null,this.props.updateListFilter&&(this.props.searchFilter||this.props.installedListFilter)?h(`br`,{}):null,this.props.updateListFilter?h(V,{style:{marginTop:16},variant:`outlined`,onClick:()=>this.props.clearAllFilters(!0),startIcon:h(it,{}),children:this.props.context.t(`Remove filter for updatable adapters`)}):null]})})}getTiles(e){if(!this.props.listOfVisibleAdapter)return h(A,{});if(!this.props.listOfVisibleAdapter.length)return this.props.update?null:T(`div`,{style:{width:`100%`,display:`flex`,flexDirection:`column`,justifyContent:`center`,alignItems:`center`,gap:16},children:[this.props.searchFilter||this.props.installedListFilter?h(I,{title:this.props.context.t(`Click to clear all filters`),slotProps:{popper:{sx:{pointerEvents:`none`}}},children:h(V,{variant:`outlined`,onClick:()=>this.props.clearAllFilters(),children:this.props.context.t(`all items are filtered out`)})}):null,this.props.updateListFilter?h(V,{variant:`outlined`,onClick:()=>this.props.clearAllFilters(!0),startIcon:h(it,{}),children:this.props.context.t(`Remove filter for updatable adapters`)}):null]});let t=[];for(let i=0;i<this.props.listOfVisibleAdapter.length;i++){var n,r;let a=this.props.listOfVisibleAdapter[i],o=(n=this.props.cachedAdapters)==null?void 0:n[a];t.length>50&&!((r=this.props.context.installed[a])!=null&&r.version)||o&&t.push(h(cn,{context:e,adapterName:a,cached:o,commandRunning:this.state.commandRunning,noTranslation:this.state.noTranslation},`adapter-${a}`))}return this.props.listOfVisibleAdapter.length>t.length&&(t.push(h(`div`,{style:{flexBasis:`100%`,height:0}},`newLine`)),t.push(h(`div`,{style:{fontSize:20,margin:20},children:this.props.context.t(`Filter adapters to see others. There is %s more`,this.props.listOfVisibleAdapter.length-t.length)},`more`))),t}shouldShowRepositoryWarning(e,t){return!e&&String(t||``).toLowerCase()!==`nexowatt`}renderTileView(e,t,n){return T(D,{children:[this.shouldShowRepositoryWarning(e,t)?h(j,{sx:{marginX:2,marginTop:1,width:`calc(100% - 32px)`},children:h(ke,{type:`warning`,children:this.props.context.t(`Active repo is "%s"`,t)})}):null,h(`div`,{style:Z.viewModeDiv,children:this.getTiles(n)})]})}renderTableView(t,n,r){return T(ue,{children:[this.shouldShowRepositoryWarning(t,n)?h(j,{sx:{marginX:2,marginTop:1,width:`calc(100% - 32px)`},children:h(ke,{type:`warning`,children:this.props.context.t(`Active repo is "%s"`,n)})}):null,h(je,{style:{...Z.container,...t?Z.containerFullHeight:Z.containerNotFullHeight},children:T(e,{stickyHeader:!0,size:`small`,sx:Z.table,children:[h(Le,{children:T(_e,{children:[h(B,{style:Z.emptyBlock}),h(B,{style:Z.name,children:h(P,{children:this.props.context.t(`Name`)})}),!r.descHidden&&h(B,{style:{...Z.description,width:this.props.descWidth},children:h(P,{children:this.props.context.t(`Description`)})}),h(B,{style:Z.connectionType}),h(B,{style:Z.installed,children:h(P,{children:this.props.context.t(`Installed`)})}),h(B,{style:Z.available,children:h(P,{children:this.props.context.t(`Available`)})}),h(B,{style:Z.license,children:h(P,{children:this.props.context.t(`License`)})}),h(B,{style:{...Z.install,width:this.state.expertMode?dn:178},children:h(P,{children:this.props.context.t(`Install`)})})]})}),h(Se,{children:this.getRows(r)})]})})]})}static getDerivedStateFromProps(e,t){let n=!1;e.descWidth!==t.descWidth&&(console.log(`Render because of descWidth`),n=!0),e.repoName!==t.repoName&&(console.log(`Render because of repoName`),n=!0),!!e.systemConfig!==t.systemConfig&&(console.log(`Render because of systemConfig`),n=!0),e.tableViewMode!==t.tableViewMode&&(console.log(`Render because of tableViewMode`),n=!0),e.oneListView!==t.oneListView&&(console.log(`Render because of oneListView`),n=!0);let r=JSON.stringify(e.categoriesExpanded);r!==t.categoriesExpanded&&(console.log(`Render because of categoriesExpanded`),n=!0);let i=e.cachedAdapters?Object.keys(e.cachedAdapters).length:0;i!==t.cachedAdapters&&(console.log(`Render because of cachedAdapters ${i} <> ${t.cachedAdapters}`),n=!0),e.update!==t.update&&(console.log(`Render because of update`),n=!0),e.sortByName!==t.sortByName&&(console.log(`Render because of sortByName`),n=!0),e.sortPopularFirst!==t.sortPopularFirst&&(console.log(`Render because of sortPopularFirst`),n=!0),e.sortRecentlyUpdated!==t.sortRecentlyUpdated&&(console.log(`Render because of sortRecentlyUpdated`),n=!0),e.sortRecentlyCreated!==t.sortRecentlyCreated&&(console.log(`Render because of sortRecentlyCreated`),n=!0),e.context.expertMode!==t.expertMode&&(console.log(`Render because of expertMode`),n=!0);let a=JSON.stringify(e.listOfVisibleAdapter);return a!==t.listOfVisibleAdapter&&(console.log(`Render because of listOfVisibleAdapter`),n=!0),e.commandRunning!==t.commandRunning&&(console.log(`Render because of commandRunning`),n=!0),e.noTranslation!==t.noTranslation&&(console.log(`Render because of commandRunning`),n=!0),n?{descWidth:e.descWidth,repoName:e.repoName,systemConfig:!!e.systemConfig,tableViewMode:e.tableViewMode,oneListView:e.oneListView,categoriesExpanded:r,cachedAdapters:i,update:e.update,sortByName:e.sortByName,sortPopularFirst:e.sortPopularFirst,sortRecentlyUpdated:e.sortRecentlyUpdated,sortRecentlyCreated:e.sortRecentlyCreated,listOfVisibleAdapter:a,renderCounter:t.renderCounter+1,expertMode:e.context.expertMode,commandRunning:e.commandRunning,noTranslation:e.noTranslation}:null}shouldComponentUpdate(e,t){return this.lastRenderCounter!==t.renderCounter&&(this.lastRenderCounter=t.renderCounter,!0)}render(){var e;return(e=this.props.systemConfig)!=null&&(e=e.common)!=null&&e.activeRepo?this.props.tableViewMode?this.renderTableView(this.props.stableRepo,this.props.repoName,this.props.context):this.renderTileView(this.props.stableRepo,this.props.repoName,this.props.context):h(A,{})}};d();var mn=class extends z{constructor(e){super(e),w(this,`updating`,void 0),w(this,`interval`,null),w(this,`startTimeout`,null),w(this,`textareaRef`,void 0),w(this,`link`,void 0),w(this,`oldVersion`,void 0),this.state={response:null,error:null,starting:!0,upAgain:!1},this.updating=!1,this.textareaRef=Ie.createRef(),this.link=`${window.location.protocol}//${window.location.host}/`}setUpdating(e){this.updating!==e&&(this.updating=e,this.props.onUpdating(e))}async getWebserverParams(){let e=await this.props.socket.getObject(`system.adapter.${this.props.adminInstance}`);return{useHttps:e==null?void 0:e.native.secure,port:e==null?void 0:e.native.port,certPrivateName:e==null?void 0:e.native.certPrivate,certPublicName:e==null?void 0:e.native.certPublic}}async componentDidMount(){let{certPrivateName:e,certPublicName:t,port:n,useHttps:r}=await this.getWebserverParams();this.oldVersion=this.props.currentAdminVersion,await this.props.socket.upgradeAdapterWithWebserver(this.props.host,{version:this.props.version,adapterName:`eos-admin`,port:n,useHttps:r,certPublicName:t,certPrivateName:e}),this.setUpdating(!0),this.interval=setInterval(()=>this.checkStatus(),1e3),this.startTimeout=setTimeout(()=>{this.startTimeout=null,this.setState({starting:!1})},1e4)}componentWillUnmount(){this.interval&&=(clearInterval(this.interval),null),this.startTimeout&&=(clearTimeout(this.startTimeout),null)}async checkVersion(){try{let e=await(await fetch(`./version`)).text();return e&&e.length<20&&e!==this.oldVersion?(this.interval&&=(clearInterval(this.interval),null),this.setState({response:{running:!1,success:!0,stderr:[],stdout:[C.t(`Version updated to %s`,e)]},upAgain:!0,error:null},()=>this.setUpdating(!1)),!0):e===this.oldVersion}catch{return!1}}async checkStatus(){console.log(`Request update status from: ${this.link}`);try{let e=await(await fetch(this.link)).text();if(console.log(`Received status: ${e}`),e.startsWith(`{`)&&e.endsWith(`}`))try{let t=JSON.parse(e);t!=null&&t.stderr&&(t.stderr=t.stderr.filter(e=>e.trim())),t&&!t.running&&t.success&&t.stdout?(t.stdout.push(``),t.stdout.push(`---------------------------------------------------`),t.stdout.push(C.t(`%s was successfully updated to %s`,`eos-admin`,this.props.version))):t!=null&&t.stdout&&(t.stdout.unshift(``),t.stdout.unshift(`---------------------------------------------------`),t.stdout.unshift(C.t(`updating %s to %s...`,`eos-admin`,this.props.version))),this.setState({response:t,error:null},()=>{t&&!t.running?(this.interval&&=(clearInterval(this.interval),null),this.waitForAdapterStart()):t!=null&&t.running&&this.setUpdating(!0),this.textareaRef.current&&setTimeout(()=>this.textareaRef.current&&(this.textareaRef.current.scrollTop=this.textareaRef.current.scrollHeight),100)})}catch(t){console.error(`Cannot parse response: ${t}`),this.setState({error:e},()=>this.setUpdating(!1))}else await this.checkVersion()||console.error(`Response is not JSON: ${e}`)}catch(e){this.state.starting||this.setState({error:e.toString()},()=>this.setUpdating(!1))}}waitForAdapterStart(){this.interval=setInterval(async()=>{try{await fetch(this.link),this.interval&&clearInterval(this.interval),this.interval=null,this.setState({upAgain:!0})}catch{}},1e3)}render(){var e,t,n,r,i,o,s;return T(a,{onClose:(e,t)=>{t!==`escapeKeyDown`&&t!==`backdropClick`&&this.props.onClose()},open:!0,maxWidth:`lg`,fullWidth:!0,children:[h(x,{children:C.t(`Updating %s...`,`eos-admin`)}),T(b,{style:{height:400,padding:`0 20px`,overflow:`hidden`},children:[(!this.state.response||this.state.response.running)&&!this.state.error?h(A,{}):null,this.state.response||this.state.error?h(`textarea`,{ref:this.textareaRef,style:{width:`100%`,height:`100%`,resize:`none`,background:this.props.themeType===`dark`?`#000`:`#fff`,color:this.props.themeType===`dark`?`#EEE`:`#111`,boxSizing:`border-box`,fontFamily:`Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace`,border:(e=this.state.response)!=null&&e.success?`2px solid green`:this.state.error||this.state.response&&!this.state.response.running&&!this.state.response.success?`2px solid red`:void 0},value:this.state.error?this.state.error:(t=this.state.response)!=null&&(t=t.stderr)!=null&&t.length?this.state.response.stderr.join(`
5
5
  `):(n=this.state.response)==null||(n=n.stdout)==null?void 0:n.join(`
6
- `),readOnly:!0}):null]}),h(M,{children:h(V,{variant:`contained`,disabled:this.state.starting||!this.state.error&&!this.state.upAgain,onClick:()=>{var e;(e=this.state.response)!=null&&e.success&&window.location.reload(),this.props.onClose()},color:(r=this.state.response)!=null&&r.success?`primary`:`grey`,startIcon:(i=this.state.response)!=null&&i.success?h(He,{}):h(v,{}),children:(o=this.state.response)!=null&&o.success&&!this.state.upAgain?h(l,{}):(s=this.state.response)!=null&&s.success?C.t(`Reload`):C.t(`Close`)})})]})}};d();var hn=864e5,gn=5e3,_n=hn/10,Q={grow:{flexGrow:1},counters:{mr:`10px`,minWidth:120,display:`flex`,"& div":{ml:`3px`}},infoAdapters:e=>({fontSize:10,color:e.palette.mode===`dark`?`#9c9c9c`:`#333`,cursor:`pointer`}),greenText:{color:`#00a005d1`},tooltip:{pointerEvents:`none`}},$=`Description A-Z`,vn=`Name A-Z`,yn=`Popular first`,bn=`Recently updated`,xn=`Recently created`,Sn=[{name:$},{name:vn},{name:yn,notByList:!0},{name:bn,notByList:!0},{name:xn,notByList:!0}],Cn=class e extends q{static isTransientConnectionError(e){return/notconnected|not connected|connectionerror|close_abnormal|closed_no_status|websocket|timeout|networkerror/i.test(e instanceof Error?e.message:typeof e==`string`?e:``)}scheduleInitializationRetry(){if(this.unmounted||this.initializationRetryTimer)return;let e=[250,500,1e3,2e3,4e3,8e3,12e3,15e3],t=e[Math.min(this.initializationRetryAttempt,e.length-1)];this.initializationRetryAttempt++,this.initializationRetryTimer=setTimeout(()=>{this.initializationRetryTimer=null,this.initializeAdapters()},t)}async initializeAdapters(){if(!(this.unmounted||this.initialized||this.initializing||!this.props.ready)){this.initializing=!0;try{if(!this.hostAdapterWorker||this.hostAdapterWorker.getHost()!==this.props.currentHost){var t;(t=this.hostAdapterWorker)==null||t.destroy(),this.hostAdapterWorker=new It(this.props.socket,this.props.currentHost),this.hostAdapterWorker.registerHandler(this.onHostAdapterChanged)}if(!await this.hostAdapterWorker.getObjects())throw Error(`Host adapter data are not available yet`);if(await this.updateAll(),this.unmounted)return;this.state.search&&this.filterAdapters(),this.workerHandlersRegistered||=(this.props.adaptersWorker.registerHandler(this.onAdaptersChanged),this.props.instancesWorker.registerHandler(this.onAdaptersChanged),!0),this.initialized=!0,this.initializationRetryAttempt=0}catch(t){this.unmounted||(e.isTransientConnectionError(t)||console.error(`Cannot initialize adapter list: ${t}`),this.scheduleInitializationRetry())}finally{this.initializing=!1}}}constructor(e){super(e),w(this,`inputRef`,void 0),w(this,`countRef`,void 0),w(this,`t`,void 0),w(this,`wordCache`,{}),w(this,`cache`,{listOfVisibleAdapter:null,adapters:null}),w(this,`listOfVisibleAdapterLength`,0),w(this,`allAdapters`,0),w(this,`installedAdapters`,0),w(this,`recentUpdatedAdapters`,0),w(this,`recentCreatedAdapters`,0),w(this,`uuid`,``),w(this,`buildCacheTimer`,null),w(this,`updateTimeout`,null),w(this,`typingTimer`,null),w(this,`hostsTimer`,null),w(this,`onHostAdapterTimer`,null),w(this,`tempAdapters`,null),w(this,`tempInstalled`,null),w(this,`tempInstances`,null),w(this,`hostAdapterWorker`,null),w(this,`initializing`,!1),w(this,`initialized`,!1),w(this,`unmounted`,!1),w(this,`initializationRetryTimer`,null),w(this,`initializationRetryAttempt`,0),w(this,`workerHandlersRegistered`,!1),w(this,`installedOfHosts`,{}),w(this,`installedReadId`,0),w(this,`installedShownId`,0),w(this,`installedPending`,!1),w(this,`translate`,(e,t,n)=>t===void 0?(this.wordCache[e]||=this.props.t(e),this.wordCache[e]):n===void 0?this.props.t(e,t):this.props.t(e,t,n)),w(this,`onAdaptersChanged`,e=>{this.tempAdapters||=JSON.parse(JSON.stringify(this.state.adapters||{})),this.tempInstalled||=JSON.parse(JSON.stringify(this.state.installed||{})),this.tempInstances||=JSON.parse(JSON.stringify(this.state.compactInstances||{}));let t=this.tempAdapters,n=this.tempInstalled,r=this.tempInstances;e.forEach(e=>{if(e.id.match(/\.\d+$/))e.type===`deleted`||!e.obj?delete r[e.id]:r[e.id]={enabled:e.obj.common.enabled,icon:e.obj.common.icon,name:e.obj.common.name,adminTab:e.obj.common.adminTab,version:e.obj.common.version};else if(e.type===`deleted`||!e.obj){let r=e.id.split(`.`);delete n[r[2]],delete t[e.id]}else{let r=e.obj.common.name;n[r]?Object.keys(n[r]).forEach(t=>{e.obj.common[t]!==void 0&&t!==`installedFrom`&&(n[r][t]=e.obj.common[t])}):n[e.id.split(`.`).pop()||``]=JSON.parse(JSON.stringify(e.obj.common)),t[e.id]=e.obj}}),this.updateTimeout&&clearTimeout(this.updateTimeout),this.updateTimeout=setTimeout(()=>{this.updateTimeout=null;let e=this.tempAdapters;this.tempAdapters=null;let t=this.tempInstalled;this.tempInstalled=null;let n=this.tempInstances;this.tempInstances=null,this.analyseInstalled({adapters:e||{},installedLocal:t||{},cb:()=>this.calculateInfo(n||{})})},300)}),w(this,`rightDependencies`,e=>q.getDependencies(e,this.state).every(e=>e.rightVersion)),w(this,`onHostAdapterChanged`,e=>{this.onHostAdapterTimer&&clearTimeout(this.onHostAdapterTimer),this.onHostAdapterTimer=setTimeout(()=>{this.onHostAdapterTimer=null,this.cache.listOfVisibleAdapter=null,this.forceUpdate()},200)}),w(this,`setAdminUpgradeTo`,e=>this.setState({adminUpgradeTo:e})),this.state={...this.state||{},lastUpdate:0,repository:{},installed:{},installedGlobal:{},installedGlobalHosts:{},adapters:{},compactInstances:{},categories:[],hostData:null,compactRepositories:null,hostOs:``,nodeJsVersion:``,init:!1,update:!1,filterConnectionType:!1,search:(window._localStorage||window.localStorage).getItem(`Adapter.search`)||``,oneListView:!1,tableViewMode:!1,updateList:!1,installedList:0,categoriesTiles:`All`,filterTiles:$,gitHubInstallDialog:!1,updateAvailable:[],filteredList:null,showUpdater:!1,descWidth:300,showStatistics:!1,readTimeoutMs:St.getReadTimeoutMs(),showSlowConnectionWarning:!1,currentHost:e.currentHost,forceUpdateAdapters:e.forceUpdateAdapters,triggerUpdate:e.triggerUpdate,ratings:null,categoriesExpanded:{},adminUpgradeTo:``},this.inputRef=ce(),this.countRef=ce(),this.t=this.translate}renderSlowConnectionWarning(){return this.state.showSlowConnectionWarning?h(St,{readTimeoutMs:this.state.readTimeoutMs,t:this.t,onClose:e=>{e?this.setState({showSlowConnectionWarning:!1,readTimeoutMs:e},()=>this.updateAll()):this.setState({showSlowConnectionWarning:!1})}}):null}componentDidMount(){this.unmounted=!1,this.initializeAdapters()}async updateAll(e,t,n){let r=this.state.currentHost?this.readAdaptersInfo(e):null,i=++this.installedReadId,a=this.readInstalled(e,i),{repository:o,allInstalled:s}=await this.getAdapters(a,e,t,n);r&&await this.getAdaptersInfo(r,n),!s&&i===this.installedReadId&&(this.installedShownId=i,a.then(async()=>{i===this.installedReadId&&(await this.readMissingNews(o),this.showInstalled(o))})),i===this.installedReadId&&this.props.adaptersWorker.isForceUpdate()&&await this.updateAll(!0)}componentDidUpdate(e){!this.props.ready||e.ready&&this.initialized||this.initializeAdapters();let t=this.getDescWidth();this.state.descWidth!==t&&this.setState({descWidth:t}),this.countRef.current&&(this.countRef.current.innerHTML=this.listOfVisibleAdapterLength.toString())}componentWillUnmount(){var e;this.unmounted=!0,this.initializationRetryTimer&&=(clearTimeout(this.initializationRetryTimer),null),this.updateTimeout&&=(clearTimeout(this.updateTimeout),null),this.buildCacheTimer&&=(clearTimeout(this.buildCacheTimer),null),this.typingTimer&&=(clearTimeout(this.typingTimer),null),this.hostsTimer&&=(clearTimeout(this.hostsTimer),null),this.onHostAdapterTimer&&=(clearTimeout(this.onHostAdapterTimer),null),this.installedReadId++,this.workerHandlersRegistered&&=(this.props.adaptersWorker.unregisterHandler(this.onAdaptersChanged),this.props.instancesWorker.unregisterHandler(this.onAdaptersChanged),!1),(e=this.hostAdapterWorker)==null||e.destroy(),this.hostAdapterWorker=null}analyseInstalled(e){let{adapters:t,repository:n}=e,{cb:r,installedLocal:i}=e,{installedGlobal:a,installedGlobalHosts:o}=e;t||=this.state.adapters;let s=i||this.state.installed;a||=this.state.installedGlobal,o||=this.state.installedGlobalHosts,n||=this.state.repository;let c=[];Object.keys(s).forEach(e=>{if(s[e]){let t=s[e].version,r=n[e];r&&r.version!==t&&mt.updateAvailable(t,r.version,`adapter "${e}"`)&&!c.includes(e)&&c.push(e)}}),this.cache.listOfVisibleAdapter=null,this.setState({adapters:t,updateAvailable:c,installed:s,repository:n,installedGlobal:a,installedGlobalHosts:o},()=>r&&r())}async readInstalled(e,t){this.installedPending=!0;let n=[];try{n=await this.props.socket.getHosts(e),Object.keys(this.installedOfHosts).forEach(e=>{n.find(t=>t._id===e)||delete this.installedOfHosts[e]})}catch(e){window.alert(`Cannot read hosts: ${e}`)}let r=n.length;await Promise.all(n.map(async n=>{let i=null;try{let t=await this.props.socket.getState(`${n._id}.alive`);t!=null&&t.val&&(i=await this.props.socket.getInstalled(n._id,e,this.state.readTimeoutMs))}catch(e){window.alert(`Cannot getInstalled from "${n._id}" (timeout ${this.state.readTimeoutMs}ms): ${e}`),e.toString().includes(`timeout`)&&this.setState({showSlowConnectionWarning:!0})}t===this.installedReadId&&(i?this.installedOfHosts[n._id]=i:delete this.installedOfHosts[n._id],r--,r&&this.installedShownId===t&&this.showInstalled())})),t===this.installedReadId&&(this.installedPending=!1)}mergeInstalled(){let e={},t={},n={};return Object.keys(this.installedOfHosts).sort().forEach(r=>{let i=this.installedOfHosts[r];r===this.state.currentHost&&(e=i);let a=r.replace(/^system\.host\./,``);for(let e of Object.keys(i)){var o;e!==`hosts`&&(o=i[e])!=null&&o.version&&(n[e]||={},n[e][a]=i[e].version)}t={...t,...i}}),{installedLocal:e,installedGlobal:t,installedGlobalHosts:n}}showInstalled(e){this.analyseInstalled({adapters:this.state.adapters,repository:e,...this.mergeInstalled(),cb:()=>void this.calculateInfo(this.state.compactInstances||{})})}async readMissingNews(e){try{await ht(this.props.socket,this.state.currentHost,e,Object.keys(this.mergeInstalled().installedGlobal),{repo:this.props.systemConfig.common.activeRepo,lang:this.props.lang},this.state.readTimeoutMs)}catch(e){console.warn(`Cannot read the news of the installed adapters: ${e}`)}}async getAdapters(e,t,n,r){console.log(`[ADAPTERS] getAdapters`);let i=this.state.currentHost;t||=this.props.adaptersWorker.isForceUpdate(),!this.state.update&&(t||r)&&this.setState({update:!0});let[a,o]=await Promise.all([this.props.adaptersWorker.getObjects(t).then(e=>e||{}).catch(e=>(window.alert(`Cannot getAdapters: ${e}`),{})),xt(this.props.socket,i,{repo:this.props.systemConfig.common.activeRepo,update:n||r,lang:this.props.lang},t,this.state.readTimeoutMs).then(e=>e).catch(e=>(window.alert(`Cannot getRepository: ${e}`),e.toString().includes(`timeout`)&&this.setState({showSlowConnectionWarning:!0}),{}))]);if(this.installedPending){let t;await Promise.race([e,new Promise(e=>t=setTimeout(e,gn))]),clearTimeout(t)}let s=!this.installedPending;return s&&await this.readMissingNews(o),await new Promise(e=>this.analyseInstalled({adapters:a,repository:o,...this.mergeInstalled(),cb:e})),{repository:o,allInstalled:s}}getWordVotes(e){if(e===1)return this.t(`vote`);if(e>=2&&e<=4)return this.t(`votes2`);if(e>=5&&e<=20)return this.t(`votes`);let t=e%10;return t===1?this.t(`vote21`):t>=2&&t<=4?this.t(`votes2`):this.t(`votes`)}static getAdapterTitle(e,t,n){if(!t[e])return e;let r=t[e].titleLang||t[e].title||``,i;return i=typeof r==`object`?r[n]||r.en:r,i=((i||``).toString()||``).replace(`ioBroker Visualisation - `,``),i.toLowerCase()}static sortAdapters(t,n,r,i,a,o,s,c,l){let u={};t.sort((t,d)=>{if(o){var f,p,m,h;return((f=i[d])==null?void 0:f.stat)===((p=i[t])==null?void 0:p.stat)?(u[t]||=e.getAdapterTitle(t,i,n),u[d]||=e.getAdapterTitle(d,i,n),u[t]>u[d]?1:u[t]<u[d]?-1:0):(((m=i[d])==null?void 0:m.stat)??0)-(((h=i[t])==null?void 0:h.stat)??0)}if(s){if(!i[t])return-1;if(!i[d])return 1;let r=i[t].daysAgo,a=i[d].daysAgo,o=Number.isFinite(r)?r:1/0,s=Number.isFinite(a)?a:1/0;return o===s?(u[t]||=e.getAdapterTitle(t,i,n),u[d]||=e.getAdapterTitle(d,i,n),u[t]>u[d]?1:u[t]<u[d]?-1:0):o-s}if(c){if(!i[t])return-1;if(!i[d])return 1;let r=i[t].createdDaysAgo,a=i[d].createdDaysAgo,o=Number.isFinite(r)?r:1/0,s=Number.isFinite(a)?a:1/0;return o===s?(u[t]||=e.getAdapterTitle(t,i,n),u[d]||=e.getAdapterTitle(d,i,n),u[t]>u[d]?1:u[t]<u[d]?-1:0):o-s}if(l){if(l[t].exact&&!l[d].exact)return-1;if(!l[t].exact&&l[d].exact)return 1}return r[t]&&r[d]?a?t>d?1:t<d?-1:0:(u[t]||=e.getAdapterTitle(t,i,n),u[d]||=e.getAdapterTitle(d,i,n),u[t]>u[d]?1:u[t]<u[d]?-1:0):r[t]?-1:r[d]?1:a?t>d?1:t<d?-1:0:(u[t]||=e.getAdapterTitle(t,i,n),u[d]||=e.getAdapterTitle(d,i,n),u[t]>u[d]?1:u[t]<u[d]?-1:0)})}calculateInfo(t,n,r,i){r||=this.state.hostData,n||=this.state.ratings,t||=this.state.compactInstances,i!=null&&i._id||(i=this.state.compactRepositories);let a=this.state.adapters,o=JSON.parse(JSON.stringify(this.state.installed)),s=JSON.parse(JSON.stringify(this.state.repository)),c=((r==null?void 0:r[`Node.js`])||``).replace(`v`,``),l=(r==null?void 0:r.os)||``,u={},d=[],f={};try{f=JSON.parse((window._localStorage||window.localStorage).getItem(`Adapters.expandedCategories`)||`null`)||{}}catch{}Object.keys(o).forEach(e=>{var t;let n=o[e];(t=a[e])!=null&&(t=t.common)!=null&&t.ignoreVersion&&(n.ignoreVersion=a[e].common.ignoreVersion),n.controller||e===`hosts`||s[e]||(s[e]=JSON.parse(JSON.stringify(n)),s[e].version=``),n.count=0,n.enabled=0}),Object.keys(t).forEach(e=>{let n=t[e].name;o[n]&&o[n].count++});let p=Date.now();this.recentUpdatedAdapters=0,this.installedAdapters=0,Object.keys(s).forEach(e=>{var t;if(e===`hosts`||e.startsWith(`_`))return;let r=s[e];if(typeof r!=`object`){console.error(`[${e}] ${e} is not an object.`);return}r.keywords&&=r.keywords.map(e=>e.toLowerCase());let i=o[e];if(r.rating=n==null?void 0:n[e],(t=r.rating)!=null&&t.rating){var a,c,l;r.rating.title=[`${this.t(`Total rating:`)} ${r.rating.rating.r} (${r.rating.rating.c} ${this.getWordVotes(r.rating.rating.c)})`,i!=null&&i.version&&r.rating[i.version]?`${this.t(`Rating for`)} v${i.version}: ${(a=r.rating[i.version])==null?void 0:a.r} (${(c=r.rating[i.version])==null?void 0:c.c} ${this.getWordVotes(((l=r.rating.rating)==null?void 0:l.c)??0)})`:``].filter(e=>e).join(`
7
- `)}else r.rating={title:this.t(`No rating or too few data`)};if(!r.controller){let t=r.type||``,n=o[e],i=Math.round((p-new Date(r.versionDate||0).getTime())/hn),a=Math.round((p-new Date(r.published||0).getTime())/hn);i<=31&&this.recentUpdatedAdapters++,a<=31&&this.recentCreatedAdapters++,o[e]&&this.installedAdapters++,u[t]?(u[t].count++,u[t].adapters.push(e),n&&u[t].installed++):u[t]={name:t,translation:this.t(`${t}_group`),count:1,installed:+!!n,adapters:[e]}}}),Object.keys(u).sort((e,t)=>e===`general`&&t!==`general`?-1:e!==`general`&&t===`general`||u[e].translation>u[t].translation?1:u[e].translation<u[t].translation?-1:0).forEach(e=>d.push(u[e]));let m=this.state.filterTiles===vn;Object.keys(u).forEach(t=>e.sortAdapters(u[t].adapters,this.props.lang,o,s,m));let h=0;try{h=JSON.parse((window._localStorage||window.localStorage).getItem(`Adapters.installedList`)||`0`),h===!1&&(h=0)}catch{}let g=(window._localStorage||window.localStorage).getItem(`Adapters.list`)===`true`,_=(window._localStorage||window.localStorage).getItem(`Adapters.viewMode`)===`true`,v=(window._localStorage||window.localStorage).getItem(`Adapters.updateList`)===`true`,y=(window._localStorage||window.localStorage).getItem(`Adapters.categoriesTiles`)||`All`,ee=(window._localStorage||window.localStorage).getItem(`Adapters.filterTiles`)||$;return ee===`A-Z`&&(ee=$),this.allAdapters=Object.keys(s).length-1,this.cache.listOfVisibleAdapter=null,new Promise(e=>{this.setState({repository:s,installed:o,ratings:n,filterTiles:ee,categoriesTiles:y,compactRepositories:i,installedList:h,compactInstances:t,updateList:v,tableViewMode:_,oneListView:g,lastUpdate:Date.now(),hostData:r,hostOs:l,nodeJsVersion:c,categories:d,categoriesExpanded:f,init:!0,update:this.installedPending},()=>e())})}readAdaptersInfo(e){var t;let n=this.state.currentHost,r=((t=this.props.adminGuiConfig.admin)==null||(t=t.adapters)==null?void 0:t.allowAdapterRating)!==!1;return Promise.all([this.props.socket.getHostInfoShort(n,e,this.state.readTimeoutMs).catch(e=>{window.alert(`Cannot getHostInfo for "${n}": ${e}`),e.toString().includes(`timeout`)&&this.setState({showSlowConnectionWarning:!0})}),r?this.props.socket.getRatings(e).catch(e=>(window.alert(`Cannot read ratings: ${e}`),null)):Promise.resolve(null),this.props.socket.getCompactInstances(e).catch(e=>(window.alert(`Cannot read countsOfInstances: ${e}`),{})),this.props.socket.getCompactSystemRepositories(e).catch(e=>(window.alert(`Cannot read getCompactSystemRepositories: ${e}`),{}))]).then(([e,t,n,i])=>(r&&(this.uuid=(t==null?void 0:t.uuid)||``),{hostData:e,ratings:t,compactInstances:n||{},compactRepositories:i}))}async getAdaptersInfo(e,t){if(this.state.currentHost&&Date.now()-this.state.lastUpdate>1e3){console.log(`[ADAPTERS] getAdaptersInfo`);try{(!this.state.update||t)&&await new Promise(e=>{this.setState({update:!0},()=>e())});let{hostData:n,ratings:r,compactInstances:i,compactRepositories:a}=await e;await this.calculateInfo(i,r,n,a)}catch(e){window.alert(`Cannot get adapters info: ${e}`)}}}toggleCategory(e){this.setState(t=>{let n=t.categoriesExpanded;return n[e]=!n[e],(window._localStorage||window.localStorage).setItem(`Adapters.expandedCategories`,JSON.stringify(n)),{categoriesExpanded:n}})}rightOs(e){let t=this.state.repository[e];return t!=null&&t.os?Array.isArray(t.os)?!!t.os.find(e=>this.state.hostOs===e):this.state.hostOs===t.os:!0}handleFilterChange(e){this.typingTimer&&clearTimeout(this.typingTimer),this.typingTimer=setTimeout(e=>{(window._localStorage||window.localStorage).setItem(`Adapter.search`,e||``),this.typingTimer=null,this.filterAdapters(e)},300,e.target.value)}expandAll(){this.setState(e=>{let t=e.categories,n=e.categoriesExpanded;return t.forEach(e=>n[e.name]=!0),(window._localStorage||window.localStorage).setItem(`Adapters.expandedCategories`,JSON.stringify(n)),{categoriesExpanded:n}})}collapseAll(){let e={};(window._localStorage||window.localStorage).setItem(`Adapters.expandedCategories`,JSON.stringify(e)),this.setState({categoriesExpanded:e})}listTable(){let e=!this.state.oneListView;e&&this.expandAll(),(window._localStorage||window.localStorage).setItem(`Adapters.list`,e?`true`:`false`),this.setState({oneListView:e})}changeViewMode(){this.cache.listOfVisibleAdapter=null;let e=!this.state.tableViewMode,t=this.state.filterTiles;e&&t!==$&&t!==vn&&(t=$,(window._localStorage||window.localStorage).setItem(`Adapters.filterTiles`,t)),(window._localStorage||window.localStorage).setItem(`Adapters.viewMode`,e?`true`:`false`),this.setState({tableViewMode:e,filterTiles:t})}changeUpdateList(){this.cache.listOfVisibleAdapter=null;let e=!this.state.updateList;(window._localStorage||window.localStorage).setItem(`Adapters.updateList`,e?`true`:`false`),this.setState({updateList:e})}changeInstalledList(e){this.cache.listOfVisibleAdapter=null;let t=this.state.installedList?this.state.installedList<2?2:0:1;!t&&e&&(t=1),(window._localStorage||window.localStorage).setItem(`Adapters.installedList`,JSON.stringify(t)),this.setState({installedList:t})}changeFilterTiles(e){this.cache.listOfVisibleAdapter=null,(window._localStorage||window.localStorage).setItem(`Adapters.filterTiles`,e),this.setState({filterTiles:e})}changeCategoriesTiles(e){this.cache.listOfVisibleAdapter=null,(window._localStorage||window.localStorage).setItem(`Adapters.categoriesTiles`,e),this.setState({categoriesTiles:e})}filterAdapters(e){e=e===void 0?this.state.search:e,e=(e||``).toLowerCase().trim();let t=null;if(e){let n={};this.state.categories.forEach(t=>t.adapters.forEach(t=>{var r;let i=this.state.repository[t];if(!i)return;let a,o,s=i.titleLang||i.title;a=typeof s==`object`?s[this.props.lang]||s.en:s,a=((a||``).toString()||``).replace(`ioBroker Visualisation - `,``),o=i.desc?typeof i.desc==`string`?i.desc:i.desc[this.props.lang]||i.desc.en||``:``,t.includes(e)?n[t]={exact:t===e,type:`name`,start:t.startsWith(e)}:a&&typeof a==`string`&&a.toLowerCase().includes(e)?n[t]={exact:!1,type:`title`}:o&&typeof o==`string`&&o.toLowerCase().includes(e)?n[t]={exact:!1,type:`desc`}:(r=i.keywords)!=null&&r.find(t=>t.includes(e))&&(n[t]={exact:!1,type:`keywords`})})),t=n}this.setState({filteredList:t,search:e},()=>{this.cache.listOfVisibleAdapter=null,this.forceUpdate()})}clearAllFilters(e){e?((window._localStorage||window.localStorage).removeItem(`Adapters.updateList`),this.setState({updateList:!1},()=>this.filterAdapters())):((window._localStorage||window.localStorage).removeItem(`Adapter.search`),(window._localStorage||window.localStorage).removeItem(`Adapters.installedList`),(window._localStorage||window.localStorage).removeItem(`Adapters.updateList`),this.inputRef.current&&(this.inputRef.current.value=``),this.setState({filteredList:null,updateList:!1,filterConnectionType:!1,installedList:0,search:``},()=>this.filterAdapters()))}getContext(e){return{expertMode:this.props.expertMode,t:this.t,socket:this.props.socket,removeUpdateAvailable:e=>{let t=[...this.state.updateAvailable],n=t.indexOf(e);n!==-1&&(t.splice(n,1),this.setState({updateAvailable:t}))},toggleTranslation:this.props.toggleTranslation,rightDependenciesFunc:this.rightDependencies,lang:this.props.lang,uuid:this.uuid,themeType:this.props.themeType,theme:this.props.theme,onUpdating:this.props.onUpdating,repository:this.state.repository,installed:this.state.installed,installedGlobal:this.state.installedGlobal,installedGlobalHosts:this.state.installedGlobalHosts,compactInstances:this.state.compactInstances||{},adapters:this.state.adapters,nodeJsVersion:this.state.nodeJsVersion,currentHost:this.state.currentHost,adminHost:this.props.adminHost,adminInstance:this.props.adminInstance,instancesWorker:this.props.instancesWorker,hostsWorker:this.props.hostsWorker,executeCommand:this.props.executeCommand,categories:this.state.categories,descHidden:e,sortPopularFirst:!this.state.tableViewMode&&this.state.filterTiles===yn,sortRecentlyUpdated:!this.state.tableViewMode&&this.state.filterTiles===bn,sortRecentlyCreated:!this.state.tableViewMode&&this.state.filterTiles===xn,isTileView:!this.state.tableViewMode,updateRating:(e,t)=>{let n=JSON.parse(JSON.stringify(this.state.repository));Object.assign(n[e].rating||{},t),this.setState({repository:n})},setAdminUpgradeTo:this.setAdminUpgradeTo,hostAdapterWorker:this.hostAdapterWorker}}buildCache(t){this.cache.listOfVisibleAdapter=[],this.cache.adapters={};let n=Date.now(),r=this.t(`0 %d days ago`),i=this.t(`1 %d days ago`),a=this.t(`2 %d days ago`),o=this.t(`5 %d days ago`);this.state.categories.filter(e=>this.state.tableViewMode||!this.state.categoriesTiles||this.state.categoriesTiles===`All`||e.name===this.state.categoriesTiles).forEach(e=>e.adapters.forEach(e=>{let t=this.state.repository[e];if(t&&!t.controller){let l=t.connectionType?t.connectionType:`-`,u=this.state.updateAvailable.includes(e),d=this.state.installed[e],f=!this.state.filteredList||!!this.state.filteredList[e];if(f&&this.state.filterConnectionType&&(f=l===`local`),f&&this.state.updateList&&(f=u),f&&this.state.installedList&&(f=this.state.installedList<2?!!(d&&d.version):!!(d&&d.version&&!d.count)),f){var s,c;(s=this.cache.listOfVisibleAdapter)==null||s.push(e);let l=Math.round((n-new Date(t.versionDate||0).getTime())/_n),u=Math.round(l/10),f=Math.round((n-new Date(t.published||0).getTime())/_n),p=Math.round(f/10),m=t.titleLang||t.title,h;h=m&&typeof m==`object`?m[this.props.lang]||m.en:m||e,h=((h||``).toString()||``).replace(`ioBroker Visualisation - `,``);let g;g=t.desc?typeof t.desc==`string`?t.desc:t.desc[this.props.lang]||t.desc.en||``:``;let _=u%100<=10||u%100>=20?u%10:5,v=p%100<=10||p%100>=20?p%10:5;this.cache.adapters[e]={title:h,desc:g,image:d!=null&&d.localIcon&&this.state.adapters[`system.adapter.${e}`]?`.${d.localIcon}`:t.extIcon||``,connectionType:t.connectionType?t.connectionType:`-`,updateAvailable:this.state.updateAvailable.includes(e),rightDependencies:this.rightDependencies(e),rightOs:this.rightOs(e),sentry:!!((c=t.plugins)!=null&&c.sentry),daysAgo:l,createdDaysAgo:f,stat:t.stat||0,daysAgoText:u||u===0?u===0?r:_===1?i.replace(`%d`,u.toString()):_===2||_===3||_===4?a.replace(`%d`,u.toString()):o.replace(`%d`,u.toString()):``,createdDaysAgoText:p||p===0?p===0?r:v===1?i.replace(`%d`,p.toString()):v===2||v===3||v===4?a.replace(`%d`,p.toString()):o.replace(`%d`,p.toString()):``}}}})),this.listOfVisibleAdapterLength=this.cache.listOfVisibleAdapter.length;let s=this.state.filterTiles===vn;this.state.tableViewMode&&this.state.categories.forEach(t=>e.sortAdapters(t.adapters,this.props.lang,this.state.installed,this.cache.adapters||{},s)),e.sortAdapters(this.cache.listOfVisibleAdapter,this.props.lang,this.state.installed,this.cache.adapters,s,t.sortPopularFirst,t.sortRecentlyUpdated,t.sortRecentlyCreated,this.state.filteredList),this.forceUpdate()}getUpdater(){return this.state.showUpdater?h(Pt,{theme:this.props.theme,onSetCommandRunning:e=>this.props.onSetCommandRunning(e),t:this.props.t,currentHost:this.state.currentHost,lang:this.props.lang,installed:this.state.installed,repository:this.state.repository,toggleTranslation:this.props.toggleTranslation,noTranslation:this.props.noTranslation,onClose:e=>this.setState({showUpdater:!1},()=>e&&this.updateAll(!0,!1)),socket:this.props.socket,rightDependenciesFunc:this.rightDependencies,ready:this.props.ready}):null}getDescWidth(){return this.props.menuOpened?document.body.scrollWidth-fn-180+13:this.props.menuClosed?document.body.scrollWidth-fn:document.body.scrollWidth-fn-50+13}getStatistics(){return this.state.showStatistics?T(a,{open:!0,onClose:()=>this.setState({showStatistics:!1}),children:[h(x,{children:this.t(`Statistics`)}),T(b,{style:{fontSize:16},children:[T(j,{component:`div`,sx:Q.counters,children:[this.t(`Total adapters`),`:`,` `,h(`span`,{style:{paddingLeft:6,fontWeight:`bold`},children:this.allAdapters})]}),T(j,{component:`div`,sx:Q.counters,children:[this.t(`Installed adapters`),`:`,` `,h(`span`,{style:{paddingLeft:6,fontWeight:`bold`},children:this.installedAdapters})]}),T(j,{component:`div`,sx:Q.counters,children:[this.t(`Last month updated adapters`),`:`,` `,h(`span`,{style:{paddingLeft:6,fontWeight:`bold`},children:this.recentUpdatedAdapters})]}),T(j,{component:`div`,sx:Q.counters,children:[this.t(`Last month created adapters`),`:`,` `,h(`span`,{style:{paddingLeft:6,fontWeight:`bold`},children:this.recentCreatedAdapters})]})]}),h(M,{children:h(V,{variant:`contained`,onClick:()=>this.setState({showStatistics:!1}),color:`primary`,autoFocus:!0,startIcon:h(v,{}),children:this.props.t(`Close`)})})]}):null}renderGitHubInstallDialog(e){return this.state.gitHubInstallDialog?h(Gt,{t:this.t,categories:this.state.categories,installed:this.state.installedGlobal,socket:e.socket,currentHost:e.currentHost,hostsWorker:e.hostsWorker,expertMode:e.expertMode,themeType:e.themeType,commandRunning:this.props.commandRunning,upload:e=>new Promise(t=>this.props.executeCommand(`upload ${e}${this.props.expertMode?` --debug`:``}`,void 0,()=>t())),createInstance:(t,n)=>q.createInstanceIfNotExists({adapterName:t,context:e,host:n}),installFromUrl:(t,n,r,i)=>this.addInstance({adapterName:t,debug:n,customUrl:r,context:e,host:i==null?void 0:i.host,files:i==null?void 0:i.files}),repository:this.state.repository,onClose:()=>{this.setState({gitHubInstallDialog:!1})}}):null}renderRepositoryTimestamp(){var e;let t=(e=this.state.compactRepositories)==null||(e=e.native)==null?void 0:e.repositories;if(!t)return null;let n=null,r=null,i=[];if(typeof this.props.systemConfig.common.activeRepo==`string`){var a;let e=(a=t[this.props.systemConfig.common.activeRepo])==null||(a=a.json)==null?void 0:a._repoInfo;if(e){n=e.repoTime||null,r=e.repoReadTime||null;let t=this.getRepositoryName(e);t&&i.push(t)}}else if(Array.isArray(this.props.systemConfig.common.activeRepo)){let e=null,a=null;this.props.systemConfig.common.activeRepo.forEach(n=>{var r;let o=(r=t[n])==null||(r=r.json)==null?void 0:r._repoInfo;if(o){let t=this.getRepositoryName(o);t&&i.push(t),o.repoTime&&(!e||new Date(o.repoTime)<new Date(e))&&(e=o.repoTime),o.repoReadTime&&(!a||new Date(o.repoReadTime)<new Date(a))&&(a=o.repoReadTime)}}),n=e,r=a}let o=r||n;if(!o)return null;let s=this.formatRepositoryTimestamp(o),c=``;return c=i.length>1?this.t(`Repository timestamps (oldest from %s):`,i.join(`, `)):this.t(`Repository timestamps:`),n&&(c+=`\n${this.t(`Generated: %s`,this.formatRepositoryTimestamp(n))}`),r&&(c+=`\n${this.t(`Last read: %s`,this.formatRepositoryTimestamp(r))}`),h(I,{title:c,slotProps:{popper:{sx:Q.tooltip}},children:h(j,{component:`div`,sx:{display:`flex`,alignItems:`center`,marginLeft:1,fontSize:`0.75rem`,color:`text.secondary`,cursor:`help`,whiteSpace:`nowrap`},children:s})})}getRepositoryName(e){return e!=null&&e.name?typeof e.name==`object`?e.name[this.props.lang]||e.name.en:e.name:null}formatRepositoryTimestamp(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4),i=Math.floor(r/60),a=Math.floor(i/24);return r<60?this.t(`%s minutes ago`,r.toString()):i<24?this.t(`%s hours ago`,i.toString()):a<30?this.t(`%s days ago`,a.toString()):t.toLocaleDateString(this.props.lang||`en`)}catch{return e}}renderHeader(){var e;let t=!this.props.commandRunning&&!!this.props.ready&&!!this.state.updateList&&this.state.updateAvailable.length>1;return t&&this.state.updateAvailable.length===2&&this.state.updateAvailable.includes(`admin`)&&(t=!1),T(Ke,{children:[this.props.menuButtonSpace?h(j,{sx:{width:40,flexShrink:0}}):null,h(I,{title:this.t(`Change view mode`),slotProps:{popper:{sx:Q.tooltip}},children:h(y,{size:`large`,onClick:()=>this.changeViewMode(),children:this.state.tableViewMode?h(ze,{}):h(ut,{})})}),h(I,{title:this.t(`Check adapter for updates`),slotProps:{popper:{sx:Q.tooltip}},children:h(y,{size:`large`,onClick:()=>this.updateAll(!0,!0),children:h(He,{})})}),this.renderRepositoryTimestamp(),this.state.tableViewMode&&!this.state.oneListView&&h(I,{title:this.t(`expand all`),slotProps:{popper:{sx:Q.tooltip}},children:h(y,{size:`large`,onClick:()=>this.expandAll(),children:h(Ge,{})})}),this.state.tableViewMode&&!this.state.oneListView&&h(I,{title:this.t(`collapse all`),slotProps:{popper:{sx:Q.tooltip}},children:h(y,{size:`large`,onClick:()=>this.collapseAll(),children:h(st,{})})}),this.state.tableViewMode&&h(I,{title:this.t(`list`),slotProps:{popper:{sx:Q.tooltip}},children:h(y,{size:`large`,onClick:()=>this.listTable(),children:h(Pe,{color:this.state.oneListView?`primary`:`inherit`})})}),this.state.updateList?h(y,{size:`large`,onClick:()=>this.changeInstalledList(!0),children:h(at,{color:`primary`,style:{opacity:.3,color:this.state.installedList===2?`red`:void 0}})}):h(I,{slotProps:{popper:{sx:Q.tooltip}},title:this.t(this.state.installedList?this.state.installedList===1?`Showed only installed adapters`:`Showed only installed adapters without instance.`:`Show only installed`),children:h(y,{size:`large`,onClick:()=>this.changeInstalledList(),children:h(at,{style:this.state.installedList===2?{color:`red`}:void 0,color:this.state.installedList===1?`primary`:`inherit`})})}),h(H,{config:this.props.adminGuiConfig.admin,name:`admin.adapters.filterUpdates`,children:h(I,{title:this.t(`Filter adapter with updates`),slotProps:{popper:{sx:Q.tooltip}},children:h(y,{size:`large`,onClick:()=>this.changeUpdateList(),children:h(Ct,{color:this.state.updateList?`primary`:`inherit`})})})}),t&&h(I,{title:this.t(`Update all adapters`),slotProps:{popper:{sx:Q.tooltip}},children:h(y,{size:`large`,onClick:()=>this.setState({showUpdater:!0}),children:h(Ft,{})})}),this.props.expertMode&&((e=this.props.adminGuiConfig.admin)==null||(e=e.adapters)==null?void 0:e.gitHubInstall)!==!1&&h(I,{title:this.t(`Install from custom URL`),slotProps:{popper:{sx:Q.tooltip}},children:h(y,{size:`large`,onClick:()=>this.setState({gitHubInstallDialog:!0}),children:h(m,{})})}),h(`div`,{style:Q.grow}),h(N,{variant:`standard`,inputRef:this.inputRef,label:this.t(`Filter by name`),defaultValue:this.state.search,onChange:e=>this.handleFilterChange(e),slotProps:{input:{endAdornment:this.state.search?h(L,{position:`end`,children:h(y,{tabIndex:-1,size:`small`,onClick:()=>{(window._localStorage||window.localStorage).removeItem(`Adapter.search`),this.inputRef.current&&(this.inputRef.current.value=``),this.setState({search:``},()=>this.filterAdapters())},children:h(v,{})})}):null}}}),!this.state.tableViewMode&&h(Tt,{t:this.t,icons:!0,contained:this.state.categoriesTiles!==`All`,translateSuffix:`_group`,arrayItem:[{name:`All`},...this.state.categories],onClick:e=>this.changeCategoriesTiles(e),value:this.state.categoriesTiles}),h(Tt,{title:this.t(`Sort by`),t:this.t,buttonIcon:h(et,{style:{marginRight:4}}),arrayItem:this.state.tableViewMode?Sn.filter(e=>!e.notByList):Sn,onClick:e=>this.changeFilterTiles(e),value:this.state.filterTiles}),h(`div`,{style:Q.grow}),h(H,{config:this.props.adminGuiConfig.admin,name:`admin.adapters.statistics`,children:T(j,{component:`div`,sx:k.getStyle(this.props.theme,Q.infoAdapters,{display:{xs:`none`,md:`inline-block`}}),onClick:()=>this.setState({showStatistics:!0}),children:[T(j,{component:`div`,sx:{...Q.counters,...Q.greenText},children:[this.t(`Selected adapters`),h(`div`,{ref:this.countRef})]}),T(j,{component:`div`,sx:Q.counters,children:[this.t(`Total adapters`),`:`,h(`div`,{children:this.allAdapters})]}),T(j,{component:`div`,sx:Q.counters,children:[this.t(`Installed adapters`),`:`,h(`div`,{children:this.installedAdapters})]}),T(j,{component:`div`,sx:Q.counters,children:[this.t(`Last month updated adapters`),`:`,h(`div`,{children:this.recentUpdatedAdapters})]})]})}),h(j,{sx:{ml:`auto`,pl:1},children:this.props.hostSelector})]})}renderWebserverUpgrade(){return this.state.adminUpgradeTo?h(mn,{socket:this.props.socket,themeType:this.props.themeType,host:this.props.adminHost,onClose:()=>{console.log(`Close dialog`),this.setState({adminUpgradeTo:``,showDialog:!1})},version:this.state.adminUpgradeTo,adminInstance:this.props.adminInstance,onUpdating:e=>{this.props.onUpdating(e)},currentAdminVersion:this.props.currentAdminVersion}):null}render(){var e;if(!this.state.init)return h(A,{});this.state.triggerUpdate!==this.props.triggerUpdate&&setTimeout(()=>{this.setState({triggerUpdate:this.props.triggerUpdate},()=>this.updateAll(!0))},100),(this.props.currentHost!==this.state.currentHost||this.props.forceUpdateAdapters!==this.state.forceUpdateAdapters)&&(this.hostsTimer=this.hostsTimer||setTimeout(()=>{this.hostsTimer=null,this.setState({currentHost:this.props.currentHost,forceUpdateAdapters:this.props.forceUpdateAdapters},async()=>{var e;if(((e=this.hostAdapterWorker)==null?void 0:e.getHost())!==this.props.currentHost){var t;(t=this.hostAdapterWorker)==null||t.destroy(),this.hostAdapterWorker=new It(this.props.socket,this.props.currentHost),this.hostAdapterWorker.registerHandler(this.onHostAdapterChanged,!0),await this.hostAdapterWorker.getObjects()}await this.updateAll(!1,!1,!0)})},200));let t=k.isStableRepository(this.props.systemConfig.common.activeRepo),n=((e=this.state.compactRepositories)==null||(e=e.native)==null?void 0:e.repositories)||{};if(n&&this.props.systemConfig.common.activeRepo){if(Array.isArray(this.props.systemConfig.common.activeRepo))t=this.props.systemConfig.common.activeRepo.every(e=>{var t;return e.toLowerCase().startsWith(`stable`)||((t=n[e])==null||(t=t.json)==null||(t=t._repoInfo)==null?void 0:t.stable)});else if(typeof this.props.systemConfig.common.activeRepo==`string`){var r;t=this.props.systemConfig.common.activeRepo.toLowerCase().startsWith(`stable`)||((r=n[this.props.systemConfig.common.activeRepo])==null||(r=r.json)==null||(r=r._repoInfo)==null?void 0:r.stable)}}let i=``;if(!t){if(i=Array.isArray(this.props.systemConfig.common.activeRepo)?this.props.systemConfig.common.activeRepo.join(`, `):this.props.systemConfig.common.activeRepo,typeof this.props.systemConfig.common.activeRepo==`string`){var a;let e=n&&((a=n[this.props.systemConfig.common.activeRepo])==null||(a=a.json)==null?void 0:a._repoInfo);e!=null&&e.name&&(i=e.name&&typeof e.name==`object`?e.name[this.props.lang]||e.name.en:e.name)}else this.props.systemConfig.common.activeRepo&&typeof this.props.systemConfig.common.activeRepo!=`string`&&(i=this.props.systemConfig.common.activeRepo.map(e=>{var t;let r=n&&((t=n[e])==null||(t=t.json)==null?void 0:t._repoInfo);return r!=null&&r.name?r.name&&typeof r.name==`object`?r.name[this.props.lang]||r.name.en:r.name:e}).join(`, `))}let o=this.getContext(this.state.descWidth<50);return this.cache.listOfVisibleAdapter||(this.buildCacheTimer=this.buildCacheTimer||setTimeout(()=>{this.buildCacheTimer=null,this.buildCache(o)},0)),T(ee,{children:[this.state.update&&h(O,{children:h(A,{})}),this.renderHeader(),h(pn,{stableRepo:t,repoName:i,context:o,noTranslation:this.props.noTranslation,systemConfig:this.props.systemConfig,tableViewMode:this.state.tableViewMode,oneListView:this.state.oneListView,update:this.state.update,updateListFilter:this.state.updateList,searchFilter:this.state.search,installedListFilter:this.state.installedList,cachedAdapters:this.cache.adapters,categories:this.state.categories,categoriesExpanded:this.state.categoriesExpanded,listOfVisibleAdapter:this.cache.listOfVisibleAdapter,toggleCategory:e=>this.toggleCategory(e),clearAllFilters:e=>this.clearAllFilters(e),descWidth:this.state.descWidth,sortByName:this.state.filterTiles===vn,sortPopularFirst:o.sortPopularFirst,sortRecentlyUpdated:o.sortRecentlyUpdated,sortRecentlyCreated:o.sortRecentlyCreated,commandRunning:this.props.commandRunning}),this.getUpdater(),this.getStatistics(),this.renderSlowConnectionWarning(),this.renderGitHubInstallDialog(o),this.renderWebserverUpgrade(),this.renderDialogs(o)]})}};export{Cn as default};
6
+ `),readOnly:!0}):null]}),h(M,{children:h(V,{variant:`contained`,disabled:this.state.starting||!this.state.error&&!this.state.upAgain,onClick:()=>{var e;(e=this.state.response)!=null&&e.success&&window.location.reload(),this.props.onClose()},color:(r=this.state.response)!=null&&r.success?`primary`:`grey`,startIcon:(i=this.state.response)!=null&&i.success?h(He,{}):h(v,{}),children:(o=this.state.response)!=null&&o.success&&!this.state.upAgain?h(l,{}):(s=this.state.response)!=null&&s.success?C.t(`Reload`):C.t(`Close`)})})]})}};d();var hn=864e5,gn=5e3,_n=hn/10,Q={grow:{flexGrow:1},counters:{mr:`10px`,minWidth:120,display:`flex`,"& div":{ml:`3px`}},infoAdapters:e=>({fontSize:10,color:e.palette.mode===`dark`?`#9c9c9c`:`#333`,cursor:`pointer`}),greenText:{color:`#00a005d1`},tooltip:{pointerEvents:`none`}},$=`Description A-Z`,vn=`Name A-Z`,yn=`Popular first`,bn=`Recently updated`,xn=`Recently created`,Sn=[{name:$},{name:vn},{name:yn,notByList:!0},{name:bn,notByList:!0},{name:xn,notByList:!0}],Cn=class e extends q{static isTransientConnectionError(e){return/notconnected|not connected|connectionerror|close_abnormal|closed_no_status|websocket|timeout|networkerror/i.test(e instanceof Error?e.message:typeof e==`string`?e:``)}scheduleInitializationRetry(){if(this.unmounted||this.initializationRetryTimer)return;let e=[250,500,1e3,2e3,4e3,8e3,12e3,15e3],t=e[Math.min(this.initializationRetryAttempt,e.length-1)];this.initializationRetryAttempt++,this.initializationRetryTimer=setTimeout(()=>{this.initializationRetryTimer=null,this.initializeAdapters()},t)}async initializeAdapters(){if(!(this.unmounted||this.initialized||this.initializing||!this.props.ready)){this.initializing=!0;try{if(!this.hostAdapterWorker||this.hostAdapterWorker.getHost()!==this.props.currentHost){var t;(t=this.hostAdapterWorker)==null||t.destroy(),this.hostAdapterWorker=new It(this.props.socket,this.props.currentHost),this.hostAdapterWorker.registerHandler(this.onHostAdapterChanged)}if(!await this.hostAdapterWorker.getObjects())throw Error(`Host adapter data are not available yet`);if(await this.updateAll(),this.unmounted)return;this.state.search&&this.filterAdapters(),this.workerHandlersRegistered||=(this.props.adaptersWorker.registerHandler(this.onAdaptersChanged),this.props.instancesWorker.registerHandler(this.onAdaptersChanged),!0),this.initialized=!0,this.initializationRetryAttempt=0}catch(t){this.unmounted||(e.isTransientConnectionError(t)||console.error(`Cannot initialize adapter list: ${t}`),this.scheduleInitializationRetry())}finally{this.initializing=!1}}}constructor(e){super(e),w(this,`inputRef`,void 0),w(this,`countRef`,void 0),w(this,`t`,void 0),w(this,`wordCache`,{}),w(this,`cache`,{listOfVisibleAdapter:null,adapters:null}),w(this,`listOfVisibleAdapterLength`,0),w(this,`allAdapters`,0),w(this,`installedAdapters`,0),w(this,`recentUpdatedAdapters`,0),w(this,`recentCreatedAdapters`,0),w(this,`uuid`,``),w(this,`buildCacheTimer`,null),w(this,`updateTimeout`,null),w(this,`typingTimer`,null),w(this,`hostsTimer`,null),w(this,`onHostAdapterTimer`,null),w(this,`tempAdapters`,null),w(this,`tempInstalled`,null),w(this,`tempInstances`,null),w(this,`hostAdapterWorker`,null),w(this,`initializing`,!1),w(this,`initialized`,!1),w(this,`unmounted`,!1),w(this,`initializationRetryTimer`,null),w(this,`initializationRetryAttempt`,0),w(this,`workerHandlersRegistered`,!1),w(this,`installedOfHosts`,{}),w(this,`installedReadId`,0),w(this,`installedShownId`,0),w(this,`installedPending`,!1),w(this,`translate`,(e,t,n)=>t===void 0?(this.wordCache[e]||=this.props.t(e),this.wordCache[e]):n===void 0?this.props.t(e,t):this.props.t(e,t,n)),w(this,`onAdaptersChanged`,e=>{this.tempAdapters||=JSON.parse(JSON.stringify(this.state.adapters||{})),this.tempInstalled||=JSON.parse(JSON.stringify(this.state.installed||{})),this.tempInstances||=JSON.parse(JSON.stringify(this.state.compactInstances||{}));let t=this.tempAdapters,n=this.tempInstalled,r=this.tempInstances;e.forEach(e=>{if(e.id.match(/\.\d+$/))e.type===`deleted`||!e.obj?delete r[e.id]:r[e.id]={enabled:e.obj.common.enabled,icon:e.obj.common.icon,name:e.obj.common.name,adminTab:e.obj.common.adminTab,version:e.obj.common.version};else if(e.type===`deleted`||!e.obj){let r=e.id.split(`.`);delete n[r[2]],delete t[e.id]}else{let r=e.obj.common.name;n[r]?Object.keys(n[r]).forEach(t=>{e.obj.common[t]!==void 0&&t!==`installedFrom`&&(n[r][t]=e.obj.common[t])}):n[e.id.split(`.`).pop()||``]=JSON.parse(JSON.stringify(e.obj.common)),t[e.id]=e.obj}}),this.updateTimeout&&clearTimeout(this.updateTimeout),this.updateTimeout=setTimeout(()=>{this.updateTimeout=null;let e=this.tempAdapters;this.tempAdapters=null;let t=this.tempInstalled;this.tempInstalled=null;let n=this.tempInstances;this.tempInstances=null,this.analyseInstalled({adapters:e||{},installedLocal:t||{},cb:()=>this.calculateInfo(n||{})})},300)}),w(this,`rightDependencies`,e=>q.getDependencies(e,this.state).every(e=>e.rightVersion)),w(this,`onHostAdapterChanged`,e=>{this.onHostAdapterTimer&&clearTimeout(this.onHostAdapterTimer),this.onHostAdapterTimer=setTimeout(()=>{this.onHostAdapterTimer=null,this.cache.listOfVisibleAdapter=null,this.forceUpdate()},200)}),w(this,`setAdminUpgradeTo`,e=>this.setState({adminUpgradeTo:e})),this.state={...this.state||{},lastUpdate:0,repository:{},installed:{},installedGlobal:{},installedGlobalHosts:{},adapters:{},compactInstances:{},categories:[],hostData:null,compactRepositories:null,hostOs:``,nodeJsVersion:``,init:!1,update:!1,filterConnectionType:!1,search:(window._localStorage||window.localStorage).getItem(`Adapter.search`)||``,oneListView:!1,tableViewMode:!1,updateList:!1,installedList:0,categoriesTiles:`All`,filterTiles:$,gitHubInstallDialog:!1,updateAvailable:[],filteredList:null,showUpdater:!1,descWidth:300,showStatistics:!1,readTimeoutMs:ot.getReadTimeoutMs(),showSlowConnectionWarning:!1,currentHost:e.currentHost,forceUpdateAdapters:e.forceUpdateAdapters,triggerUpdate:e.triggerUpdate,ratings:null,categoriesExpanded:{},adminUpgradeTo:``},this.inputRef=ce(),this.countRef=ce(),this.t=this.translate}renderSlowConnectionWarning(){return this.state.showSlowConnectionWarning?h(ot,{readTimeoutMs:this.state.readTimeoutMs,t:this.t,onClose:e=>{e?this.setState({showSlowConnectionWarning:!1,readTimeoutMs:e},()=>this.updateAll()):this.setState({showSlowConnectionWarning:!1})}}):null}componentDidMount(){this.unmounted=!1,this.initializeAdapters()}async updateAll(e,t,n){let r=this.state.currentHost?this.readAdaptersInfo(e):null,i=++this.installedReadId,a=this.readInstalled(e,i),{repository:o,allInstalled:s}=await this.getAdapters(a,e,t,n);r&&await this.getAdaptersInfo(r,n),!s&&i===this.installedReadId&&(this.installedShownId=i,a.then(async()=>{i===this.installedReadId&&(await this.readMissingNews(o),this.showInstalled(o))})),i===this.installedReadId&&this.props.adaptersWorker.isForceUpdate()&&await this.updateAll(!0)}componentDidUpdate(e){!this.props.ready||e.ready&&this.initialized||this.initializeAdapters();let t=this.getDescWidth();this.state.descWidth!==t&&this.setState({descWidth:t}),this.countRef.current&&(this.countRef.current.innerHTML=this.listOfVisibleAdapterLength.toString())}componentWillUnmount(){var e;this.unmounted=!0,this.initializationRetryTimer&&=(clearTimeout(this.initializationRetryTimer),null),this.updateTimeout&&=(clearTimeout(this.updateTimeout),null),this.buildCacheTimer&&=(clearTimeout(this.buildCacheTimer),null),this.typingTimer&&=(clearTimeout(this.typingTimer),null),this.hostsTimer&&=(clearTimeout(this.hostsTimer),null),this.onHostAdapterTimer&&=(clearTimeout(this.onHostAdapterTimer),null),this.installedReadId++,this.workerHandlersRegistered&&=(this.props.adaptersWorker.unregisterHandler(this.onAdaptersChanged),this.props.instancesWorker.unregisterHandler(this.onAdaptersChanged),!1),(e=this.hostAdapterWorker)==null||e.destroy(),this.hostAdapterWorker=null}analyseInstalled(e){let{adapters:t,repository:n}=e,{cb:r,installedLocal:i}=e,{installedGlobal:a,installedGlobalHosts:o}=e;t||=this.state.adapters;let s=i||this.state.installed;a||=this.state.installedGlobal,o||=this.state.installedGlobalHosts,n||=this.state.repository;let c=[];Object.keys(s).forEach(e=>{if(s[e]){let t=s[e].version,r=n[e];r&&r.version!==t&&Ze.updateAvailable(t,r.version,`adapter "${e}"`)&&!c.includes(e)&&c.push(e)}}),this.cache.listOfVisibleAdapter=null,this.setState({adapters:t,updateAvailable:c,installed:s,repository:n,installedGlobal:a,installedGlobalHosts:o},()=>r&&r())}async readInstalled(e,t){this.installedPending=!0;let n=[];try{n=await this.props.socket.getHosts(e),Object.keys(this.installedOfHosts).forEach(e=>{n.find(t=>t._id===e)||delete this.installedOfHosts[e]})}catch(e){window.alert(`Cannot read hosts: ${e}`)}let r=n.length;await Promise.all(n.map(async n=>{let i=null;try{let t=await this.props.socket.getState(`${n._id}.alive`);t!=null&&t.val&&(i=await this.props.socket.getInstalled(n._id,e,this.state.readTimeoutMs))}catch(e){window.alert(`Cannot getInstalled from "${n._id}" (timeout ${this.state.readTimeoutMs}ms): ${e}`),e.toString().includes(`timeout`)&&this.setState({showSlowConnectionWarning:!0})}t===this.installedReadId&&(i?this.installedOfHosts[n._id]=i:delete this.installedOfHosts[n._id],r--,r&&this.installedShownId===t&&this.showInstalled())})),t===this.installedReadId&&(this.installedPending=!1)}mergeInstalled(){let e={},t={},n={};return Object.keys(this.installedOfHosts).sort().forEach(r=>{let i=this.installedOfHosts[r];r===this.state.currentHost&&(e=i);let a=r.replace(/^system\.host\./,``);for(let e of Object.keys(i)){var o;e!==`hosts`&&(o=i[e])!=null&&o.version&&(n[e]||={},n[e][a]=i[e].version)}t={...t,...i}}),{installedLocal:e,installedGlobal:t,installedGlobalHosts:n}}showInstalled(e){this.analyseInstalled({adapters:this.state.adapters,repository:e,...this.mergeInstalled(),cb:()=>void this.calculateInfo(this.state.compactInstances||{})})}async readMissingNews(e){try{await nt(this.props.socket,this.state.currentHost,e,Object.keys(this.mergeInstalled().installedGlobal),{repo:this.props.systemConfig.common.activeRepo,lang:this.props.lang},this.state.readTimeoutMs)}catch(e){console.warn(`Cannot read the news of the installed adapters: ${e}`)}}async getAdapters(e,t,n,r){console.log(`[ADAPTERS] getAdapters`);let i=this.state.currentHost;t||=this.props.adaptersWorker.isForceUpdate(),!this.state.update&&(t||r)&&this.setState({update:!0});let[a,o]=await Promise.all([this.props.adaptersWorker.getObjects(t).then(e=>e||{}).catch(e=>(window.alert(`Cannot getAdapters: ${e}`),{})),$e(this.props.socket,i,{repo:this.props.systemConfig.common.activeRepo,update:n||r,lang:this.props.lang},t,this.state.readTimeoutMs).then(e=>e).catch(e=>(window.alert(`Cannot getRepository: ${e}`),e.toString().includes(`timeout`)&&this.setState({showSlowConnectionWarning:!0}),{}))]);if(this.installedPending){let t;await Promise.race([e,new Promise(e=>t=setTimeout(e,gn))]),clearTimeout(t)}let s=!this.installedPending;return s&&await this.readMissingNews(o),await new Promise(e=>this.analyseInstalled({adapters:a,repository:o,...this.mergeInstalled(),cb:e})),{repository:o,allInstalled:s}}getWordVotes(e){if(e===1)return this.t(`vote`);if(e>=2&&e<=4)return this.t(`votes2`);if(e>=5&&e<=20)return this.t(`votes`);let t=e%10;return t===1?this.t(`vote21`):t>=2&&t<=4?this.t(`votes2`):this.t(`votes`)}static getAdapterTitle(e,t,n){if(!t[e])return e;let r=t[e].titleLang||t[e].title||``,i;return i=typeof r==`object`?r[n]||r.en:r,i=((i||``).toString()||``).replace(`ioBroker Visualisation - `,``),i.toLowerCase()}static sortAdapters(t,n,r,i,a,o,s,c,l){let u={};t.sort((t,d)=>{if(o){var f,p,m,h;return((f=i[d])==null?void 0:f.stat)===((p=i[t])==null?void 0:p.stat)?(u[t]||=e.getAdapterTitle(t,i,n),u[d]||=e.getAdapterTitle(d,i,n),u[t]>u[d]?1:u[t]<u[d]?-1:0):(((m=i[d])==null?void 0:m.stat)??0)-(((h=i[t])==null?void 0:h.stat)??0)}if(s){if(!i[t])return-1;if(!i[d])return 1;let r=i[t].daysAgo,a=i[d].daysAgo,o=Number.isFinite(r)?r:1/0,s=Number.isFinite(a)?a:1/0;return o===s?(u[t]||=e.getAdapterTitle(t,i,n),u[d]||=e.getAdapterTitle(d,i,n),u[t]>u[d]?1:u[t]<u[d]?-1:0):o-s}if(c){if(!i[t])return-1;if(!i[d])return 1;let r=i[t].createdDaysAgo,a=i[d].createdDaysAgo,o=Number.isFinite(r)?r:1/0,s=Number.isFinite(a)?a:1/0;return o===s?(u[t]||=e.getAdapterTitle(t,i,n),u[d]||=e.getAdapterTitle(d,i,n),u[t]>u[d]?1:u[t]<u[d]?-1:0):o-s}if(l){if(l[t].exact&&!l[d].exact)return-1;if(!l[t].exact&&l[d].exact)return 1}return r[t]&&r[d]?a?t>d?1:t<d?-1:0:(u[t]||=e.getAdapterTitle(t,i,n),u[d]||=e.getAdapterTitle(d,i,n),u[t]>u[d]?1:u[t]<u[d]?-1:0):r[t]?-1:r[d]?1:a?t>d?1:t<d?-1:0:(u[t]||=e.getAdapterTitle(t,i,n),u[d]||=e.getAdapterTitle(d,i,n),u[t]>u[d]?1:u[t]<u[d]?-1:0)})}calculateInfo(t,n,r,i){r||=this.state.hostData,n||=this.state.ratings,t||=this.state.compactInstances,i!=null&&i._id||(i=this.state.compactRepositories);let a=this.state.adapters,o=JSON.parse(JSON.stringify(this.state.installed)),s=JSON.parse(JSON.stringify(this.state.repository)),c=((r==null?void 0:r[`Node.js`])||``).replace(`v`,``),l=(r==null?void 0:r.os)||``,u={},d=[],f={};try{f=JSON.parse((window._localStorage||window.localStorage).getItem(`Adapters.expandedCategories`)||`null`)||{}}catch{}Object.keys(o).forEach(e=>{var t;let n=o[e];(t=a[e])!=null&&(t=t.common)!=null&&t.ignoreVersion&&(n.ignoreVersion=a[e].common.ignoreVersion),n.controller||e===`hosts`||s[e]||(s[e]=JSON.parse(JSON.stringify(n)),s[e].version=``),n.count=0,n.enabled=0}),Object.keys(t).forEach(e=>{let n=t[e].name;o[n]&&o[n].count++});let p=Date.now();this.recentUpdatedAdapters=0,this.installedAdapters=0,Object.keys(s).forEach(e=>{var t;if(e===`hosts`||e.startsWith(`_`))return;let r=s[e];if(typeof r!=`object`){console.error(`[${e}] ${e} is not an object.`);return}r.keywords&&=r.keywords.map(e=>e.toLowerCase());let i=o[e];if(r.rating=n==null?void 0:n[e],(t=r.rating)!=null&&t.rating){var a,c,l;r.rating.title=[`${this.t(`Total rating:`)} ${r.rating.rating.r} (${r.rating.rating.c} ${this.getWordVotes(r.rating.rating.c)})`,i!=null&&i.version&&r.rating[i.version]?`${this.t(`Rating for`)} v${i.version}: ${(a=r.rating[i.version])==null?void 0:a.r} (${(c=r.rating[i.version])==null?void 0:c.c} ${this.getWordVotes(((l=r.rating.rating)==null?void 0:l.c)??0)})`:``].filter(e=>e).join(`
7
+ `)}else r.rating={title:this.t(`No rating or too few data`)};if(!r.controller){let t=r.type||``,n=o[e],i=Math.round((p-new Date(r.versionDate||0).getTime())/hn),a=Math.round((p-new Date(r.published||0).getTime())/hn);i<=31&&this.recentUpdatedAdapters++,a<=31&&this.recentCreatedAdapters++,o[e]&&this.installedAdapters++,u[t]?(u[t].count++,u[t].adapters.push(e),n&&u[t].installed++):u[t]={name:t,translation:this.t(`${t}_group`),count:1,installed:+!!n,adapters:[e]}}}),Object.keys(u).sort((e,t)=>e===`general`&&t!==`general`?-1:e!==`general`&&t===`general`||u[e].translation>u[t].translation?1:u[e].translation<u[t].translation?-1:0).forEach(e=>d.push(u[e]));let m=this.state.filterTiles===vn;Object.keys(u).forEach(t=>e.sortAdapters(u[t].adapters,this.props.lang,o,s,m));let h=0;try{h=JSON.parse((window._localStorage||window.localStorage).getItem(`Adapters.installedList`)||`0`),h===!1&&(h=0)}catch{}let g=(window._localStorage||window.localStorage).getItem(`Adapters.list`)===`true`,_=(window._localStorage||window.localStorage).getItem(`Adapters.viewMode`)===`true`,v=(window._localStorage||window.localStorage).getItem(`Adapters.updateList`)===`true`,y=(window._localStorage||window.localStorage).getItem(`Adapters.categoriesTiles`)||`All`,ee=(window._localStorage||window.localStorage).getItem(`Adapters.filterTiles`)||$;return ee===`A-Z`&&(ee=$),this.allAdapters=Object.keys(s).length-1,this.cache.listOfVisibleAdapter=null,new Promise(e=>{this.setState({repository:s,installed:o,ratings:n,filterTiles:ee,categoriesTiles:y,compactRepositories:i,installedList:h,compactInstances:t,updateList:v,tableViewMode:_,oneListView:g,lastUpdate:Date.now(),hostData:r,hostOs:l,nodeJsVersion:c,categories:d,categoriesExpanded:f,init:!0,update:this.installedPending},()=>e())})}readAdaptersInfo(e){var t;let n=this.state.currentHost,r=((t=this.props.adminGuiConfig.admin)==null||(t=t.adapters)==null?void 0:t.allowAdapterRating)!==!1;return Promise.all([this.props.socket.getHostInfoShort(n,e,this.state.readTimeoutMs).catch(e=>{window.alert(`Cannot getHostInfo for "${n}": ${e}`),e.toString().includes(`timeout`)&&this.setState({showSlowConnectionWarning:!0})}),r?this.props.socket.getRatings(e).catch(e=>(window.alert(`Cannot read ratings: ${e}`),null)):Promise.resolve(null),this.props.socket.getCompactInstances(e).catch(e=>(window.alert(`Cannot read countsOfInstances: ${e}`),{})),this.props.socket.getCompactSystemRepositories(e).catch(e=>(window.alert(`Cannot read getCompactSystemRepositories: ${e}`),{}))]).then(([e,t,n,i])=>(r&&(this.uuid=(t==null?void 0:t.uuid)||``),{hostData:e,ratings:t,compactInstances:n||{},compactRepositories:i}))}async getAdaptersInfo(e,t){if(this.state.currentHost&&Date.now()-this.state.lastUpdate>1e3){console.log(`[ADAPTERS] getAdaptersInfo`);try{(!this.state.update||t)&&await new Promise(e=>{this.setState({update:!0},()=>e())});let{hostData:n,ratings:r,compactInstances:i,compactRepositories:a}=await e;await this.calculateInfo(i,r,n,a)}catch(e){window.alert(`Cannot get adapters info: ${e}`)}}}toggleCategory(e){this.setState(t=>{let n=t.categoriesExpanded;return n[e]=!n[e],(window._localStorage||window.localStorage).setItem(`Adapters.expandedCategories`,JSON.stringify(n)),{categoriesExpanded:n}})}rightOs(e){let t=this.state.repository[e];return t!=null&&t.os?Array.isArray(t.os)?!!t.os.find(e=>this.state.hostOs===e):this.state.hostOs===t.os:!0}handleFilterChange(e){this.typingTimer&&clearTimeout(this.typingTimer),this.typingTimer=setTimeout(e=>{(window._localStorage||window.localStorage).setItem(`Adapter.search`,e||``),this.typingTimer=null,this.filterAdapters(e)},300,e.target.value)}expandAll(){this.setState(e=>{let t=e.categories,n=e.categoriesExpanded;return t.forEach(e=>n[e.name]=!0),(window._localStorage||window.localStorage).setItem(`Adapters.expandedCategories`,JSON.stringify(n)),{categoriesExpanded:n}})}collapseAll(){let e={};(window._localStorage||window.localStorage).setItem(`Adapters.expandedCategories`,JSON.stringify(e)),this.setState({categoriesExpanded:e})}listTable(){let e=!this.state.oneListView;e&&this.expandAll(),(window._localStorage||window.localStorage).setItem(`Adapters.list`,e?`true`:`false`),this.setState({oneListView:e})}changeViewMode(){this.cache.listOfVisibleAdapter=null;let e=!this.state.tableViewMode,t=this.state.filterTiles;e&&t!==$&&t!==vn&&(t=$,(window._localStorage||window.localStorage).setItem(`Adapters.filterTiles`,t)),(window._localStorage||window.localStorage).setItem(`Adapters.viewMode`,e?`true`:`false`),this.setState({tableViewMode:e,filterTiles:t})}changeUpdateList(){this.cache.listOfVisibleAdapter=null;let e=!this.state.updateList;(window._localStorage||window.localStorage).setItem(`Adapters.updateList`,e?`true`:`false`),this.setState({updateList:e})}changeInstalledList(e){this.cache.listOfVisibleAdapter=null;let t=this.state.installedList?this.state.installedList<2?2:0:1;!t&&e&&(t=1),(window._localStorage||window.localStorage).setItem(`Adapters.installedList`,JSON.stringify(t)),this.setState({installedList:t})}changeFilterTiles(e){this.cache.listOfVisibleAdapter=null,(window._localStorage||window.localStorage).setItem(`Adapters.filterTiles`,e),this.setState({filterTiles:e})}changeCategoriesTiles(e){this.cache.listOfVisibleAdapter=null,(window._localStorage||window.localStorage).setItem(`Adapters.categoriesTiles`,e),this.setState({categoriesTiles:e})}filterAdapters(e){e=e===void 0?this.state.search:e,e=(e||``).toLowerCase().trim();let t=null;if(e){let n={};this.state.categories.forEach(t=>t.adapters.forEach(t=>{var r;let i=this.state.repository[t];if(!i)return;let a,o,s=i.titleLang||i.title;a=typeof s==`object`?s[this.props.lang]||s.en:s,a=((a||``).toString()||``).replace(`ioBroker Visualisation - `,``),o=i.desc?typeof i.desc==`string`?i.desc:i.desc[this.props.lang]||i.desc.en||``:``,t.includes(e)?n[t]={exact:t===e,type:`name`,start:t.startsWith(e)}:a&&typeof a==`string`&&a.toLowerCase().includes(e)?n[t]={exact:!1,type:`title`}:o&&typeof o==`string`&&o.toLowerCase().includes(e)?n[t]={exact:!1,type:`desc`}:(r=i.keywords)!=null&&r.find(t=>t.includes(e))&&(n[t]={exact:!1,type:`keywords`})})),t=n}this.setState({filteredList:t,search:e},()=>{this.cache.listOfVisibleAdapter=null,this.forceUpdate()})}clearAllFilters(e){e?((window._localStorage||window.localStorage).removeItem(`Adapters.updateList`),this.setState({updateList:!1},()=>this.filterAdapters())):((window._localStorage||window.localStorage).removeItem(`Adapter.search`),(window._localStorage||window.localStorage).removeItem(`Adapters.installedList`),(window._localStorage||window.localStorage).removeItem(`Adapters.updateList`),this.inputRef.current&&(this.inputRef.current.value=``),this.setState({filteredList:null,updateList:!1,filterConnectionType:!1,installedList:0,search:``},()=>this.filterAdapters()))}getContext(e){return{expertMode:this.props.expertMode,t:this.t,socket:this.props.socket,removeUpdateAvailable:e=>{let t=[...this.state.updateAvailable],n=t.indexOf(e);n!==-1&&(t.splice(n,1),this.setState({updateAvailable:t}))},toggleTranslation:this.props.toggleTranslation,rightDependenciesFunc:this.rightDependencies,lang:this.props.lang,uuid:this.uuid,themeType:this.props.themeType,theme:this.props.theme,onUpdating:this.props.onUpdating,repository:this.state.repository,installed:this.state.installed,installedGlobal:this.state.installedGlobal,installedGlobalHosts:this.state.installedGlobalHosts,compactInstances:this.state.compactInstances||{},adapters:this.state.adapters,nodeJsVersion:this.state.nodeJsVersion,currentHost:this.state.currentHost,adminHost:this.props.adminHost,adminInstance:this.props.adminInstance,instancesWorker:this.props.instancesWorker,hostsWorker:this.props.hostsWorker,executeCommand:this.props.executeCommand,categories:this.state.categories,descHidden:e,sortPopularFirst:!this.state.tableViewMode&&this.state.filterTiles===yn,sortRecentlyUpdated:!this.state.tableViewMode&&this.state.filterTiles===bn,sortRecentlyCreated:!this.state.tableViewMode&&this.state.filterTiles===xn,isTileView:!this.state.tableViewMode,updateRating:(e,t)=>{let n=JSON.parse(JSON.stringify(this.state.repository));Object.assign(n[e].rating||{},t),this.setState({repository:n})},setAdminUpgradeTo:this.setAdminUpgradeTo,hostAdapterWorker:this.hostAdapterWorker}}buildCache(t){this.cache.listOfVisibleAdapter=[],this.cache.adapters={};let n=Date.now(),r=this.t(`0 %d days ago`),i=this.t(`1 %d days ago`),a=this.t(`2 %d days ago`),o=this.t(`5 %d days ago`);this.state.categories.filter(e=>this.state.tableViewMode||!this.state.categoriesTiles||this.state.categoriesTiles===`All`||e.name===this.state.categoriesTiles).forEach(e=>e.adapters.forEach(e=>{let t=this.state.repository[e];if(t&&!t.controller){let l=t.connectionType?t.connectionType:`-`,u=this.state.updateAvailable.includes(e),d=this.state.installed[e],f=!this.state.filteredList||!!this.state.filteredList[e];if(f&&this.state.filterConnectionType&&(f=l===`local`),f&&this.state.updateList&&(f=u),f&&this.state.installedList&&(f=this.state.installedList<2?!!(d&&d.version):!!(d&&d.version&&!d.count)),f){var s,c;(s=this.cache.listOfVisibleAdapter)==null||s.push(e);let l=Math.round((n-new Date(t.versionDate||0).getTime())/_n),u=Math.round(l/10),f=Math.round((n-new Date(t.published||0).getTime())/_n),p=Math.round(f/10),m=t.titleLang||t.title,h;h=m&&typeof m==`object`?m[this.props.lang]||m.en:m||e,h=((h||``).toString()||``).replace(`ioBroker Visualisation - `,``);let g;g=t.desc?typeof t.desc==`string`?t.desc:t.desc[this.props.lang]||t.desc.en||``:``;let _=u%100<=10||u%100>=20?u%10:5,v=p%100<=10||p%100>=20?p%10:5;this.cache.adapters[e]={title:h,desc:g,image:d!=null&&d.localIcon&&this.state.adapters[`system.adapter.${e}`]?`.${d.localIcon}`:t.extIcon||``,connectionType:t.connectionType?t.connectionType:`-`,updateAvailable:this.state.updateAvailable.includes(e),rightDependencies:this.rightDependencies(e),rightOs:this.rightOs(e),sentry:!!((c=t.plugins)!=null&&c.sentry),daysAgo:l,createdDaysAgo:f,stat:t.stat||0,daysAgoText:u||u===0?u===0?r:_===1?i.replace(`%d`,u.toString()):_===2||_===3||_===4?a.replace(`%d`,u.toString()):o.replace(`%d`,u.toString()):``,createdDaysAgoText:p||p===0?p===0?r:v===1?i.replace(`%d`,p.toString()):v===2||v===3||v===4?a.replace(`%d`,p.toString()):o.replace(`%d`,p.toString()):``}}}})),this.listOfVisibleAdapterLength=this.cache.listOfVisibleAdapter.length;let s=this.state.filterTiles===vn;this.state.tableViewMode&&this.state.categories.forEach(t=>e.sortAdapters(t.adapters,this.props.lang,this.state.installed,this.cache.adapters||{},s)),e.sortAdapters(this.cache.listOfVisibleAdapter,this.props.lang,this.state.installed,this.cache.adapters,s,t.sortPopularFirst,t.sortRecentlyUpdated,t.sortRecentlyCreated,this.state.filteredList),this.forceUpdate()}getUpdater(){return this.state.showUpdater?h(Pt,{theme:this.props.theme,onSetCommandRunning:e=>this.props.onSetCommandRunning(e),t:this.props.t,currentHost:this.state.currentHost,lang:this.props.lang,installed:this.state.installed,repository:this.state.repository,toggleTranslation:this.props.toggleTranslation,noTranslation:this.props.noTranslation,onClose:e=>this.setState({showUpdater:!1},()=>e&&this.updateAll(!0,!1)),socket:this.props.socket,rightDependenciesFunc:this.rightDependencies,ready:this.props.ready}):null}getDescWidth(){return this.props.menuOpened?document.body.scrollWidth-fn-180+13:this.props.menuClosed?document.body.scrollWidth-fn:document.body.scrollWidth-fn-50+13}getStatistics(){return this.state.showStatistics?T(a,{open:!0,onClose:()=>this.setState({showStatistics:!1}),children:[h(x,{children:this.t(`Statistics`)}),T(b,{style:{fontSize:16},children:[T(j,{component:`div`,sx:Q.counters,children:[this.t(`Total adapters`),`:`,` `,h(`span`,{style:{paddingLeft:6,fontWeight:`bold`},children:this.allAdapters})]}),T(j,{component:`div`,sx:Q.counters,children:[this.t(`Installed adapters`),`:`,` `,h(`span`,{style:{paddingLeft:6,fontWeight:`bold`},children:this.installedAdapters})]}),T(j,{component:`div`,sx:Q.counters,children:[this.t(`Last month updated adapters`),`:`,` `,h(`span`,{style:{paddingLeft:6,fontWeight:`bold`},children:this.recentUpdatedAdapters})]}),T(j,{component:`div`,sx:Q.counters,children:[this.t(`Last month created adapters`),`:`,` `,h(`span`,{style:{paddingLeft:6,fontWeight:`bold`},children:this.recentCreatedAdapters})]})]}),h(M,{children:h(V,{variant:`contained`,onClick:()=>this.setState({showStatistics:!1}),color:`primary`,autoFocus:!0,startIcon:h(v,{}),children:this.props.t(`Close`)})})]}):null}renderGitHubInstallDialog(e){return this.state.gitHubInstallDialog?h(Gt,{t:this.t,categories:this.state.categories,installed:this.state.installedGlobal,socket:e.socket,currentHost:e.currentHost,hostsWorker:e.hostsWorker,expertMode:e.expertMode,themeType:e.themeType,commandRunning:this.props.commandRunning,upload:e=>new Promise(t=>this.props.executeCommand(`upload ${e}${this.props.expertMode?` --debug`:``}`,void 0,()=>t())),createInstance:(t,n)=>q.createInstanceIfNotExists({adapterName:t,context:e,host:n}),installFromUrl:(t,n,r,i)=>this.addInstance({adapterName:t,debug:n,customUrl:r,context:e,host:i==null?void 0:i.host,files:i==null?void 0:i.files}),repository:this.state.repository,onClose:()=>{this.setState({gitHubInstallDialog:!1})}}):null}renderRepositoryTimestamp(){var e;let t=(e=this.state.compactRepositories)==null||(e=e.native)==null?void 0:e.repositories;if(!t)return null;let n=null,r=null,i=[];if(typeof this.props.systemConfig.common.activeRepo==`string`){var a;let e=(a=t[this.props.systemConfig.common.activeRepo])==null||(a=a.json)==null?void 0:a._repoInfo;if(e){n=e.repoTime||null,r=e.repoReadTime||null;let t=this.getRepositoryName(e);t&&i.push(t)}}else if(Array.isArray(this.props.systemConfig.common.activeRepo)){let e=null,a=null;this.props.systemConfig.common.activeRepo.forEach(n=>{var r;let o=(r=t[n])==null||(r=r.json)==null?void 0:r._repoInfo;if(o){let t=this.getRepositoryName(o);t&&i.push(t),o.repoTime&&(!e||new Date(o.repoTime)<new Date(e))&&(e=o.repoTime),o.repoReadTime&&(!a||new Date(o.repoReadTime)<new Date(a))&&(a=o.repoReadTime)}}),n=e,r=a}let o=r||n;if(!o)return null;let s=this.formatRepositoryTimestamp(o),c=``;return c=i.length>1?this.t(`Repository timestamps (oldest from %s):`,i.join(`, `)):this.t(`Repository timestamps:`),n&&(c+=`\n${this.t(`Generated: %s`,this.formatRepositoryTimestamp(n))}`),r&&(c+=`\n${this.t(`Last read: %s`,this.formatRepositoryTimestamp(r))}`),h(I,{title:c,slotProps:{popper:{sx:Q.tooltip}},children:h(j,{component:`div`,sx:{display:`flex`,alignItems:`center`,marginLeft:1,fontSize:`0.75rem`,color:`text.secondary`,cursor:`help`,whiteSpace:`nowrap`},children:s})})}getRepositoryName(e){return e!=null&&e.name?typeof e.name==`object`?e.name[this.props.lang]||e.name.en:e.name:null}formatRepositoryTimestamp(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4),i=Math.floor(r/60),a=Math.floor(i/24);return r<60?this.t(`%s minutes ago`,r.toString()):i<24?this.t(`%s hours ago`,i.toString()):a<30?this.t(`%s days ago`,a.toString()):t.toLocaleDateString(this.props.lang||`en`)}catch{return e}}renderHeader(){var e;let t=!this.props.commandRunning&&!!this.props.ready&&!!this.state.updateList&&this.state.updateAvailable.length>1;return t&&this.state.updateAvailable.length===2&&this.state.updateAvailable.includes(`admin`)&&(t=!1),T(Ke,{children:[this.props.menuButtonSpace?h(j,{sx:{width:40,flexShrink:0}}):null,h(I,{title:this.t(`Change view mode`),slotProps:{popper:{sx:Q.tooltip}},children:h(y,{size:`large`,onClick:()=>this.changeViewMode(),children:this.state.tableViewMode?h(ze,{}):h(lt,{})})}),h(I,{title:this.t(`Check adapter for updates`),slotProps:{popper:{sx:Q.tooltip}},children:h(y,{size:`large`,onClick:()=>this.updateAll(!0,!0),children:h(He,{})})}),this.renderRepositoryTimestamp(),this.state.tableViewMode&&!this.state.oneListView&&h(I,{title:this.t(`expand all`),slotProps:{popper:{sx:Q.tooltip}},children:h(y,{size:`large`,onClick:()=>this.expandAll(),children:h(Ge,{})})}),this.state.tableViewMode&&!this.state.oneListView&&h(I,{title:this.t(`collapse all`),slotProps:{popper:{sx:Q.tooltip}},children:h(y,{size:`large`,onClick:()=>this.collapseAll(),children:h(ct,{})})}),this.state.tableViewMode&&h(I,{title:this.t(`list`),slotProps:{popper:{sx:Q.tooltip}},children:h(y,{size:`large`,onClick:()=>this.listTable(),children:h(Pe,{color:this.state.oneListView?`primary`:`inherit`})})}),this.state.updateList?h(y,{size:`large`,onClick:()=>this.changeInstalledList(!0),children:h(vt,{color:`primary`,style:{opacity:.3,color:this.state.installedList===2?`red`:void 0}})}):h(I,{slotProps:{popper:{sx:Q.tooltip}},title:this.t(this.state.installedList?this.state.installedList===1?`Showed only installed adapters`:`Showed only installed adapters without instance.`:`Show only installed`),children:h(y,{size:`large`,onClick:()=>this.changeInstalledList(),children:h(vt,{style:this.state.installedList===2?{color:`red`}:void 0,color:this.state.installedList===1?`primary`:`inherit`})})}),h(H,{config:this.props.adminGuiConfig.admin,name:`admin.adapters.filterUpdates`,children:h(I,{title:this.t(`Filter adapter with updates`),slotProps:{popper:{sx:Q.tooltip}},children:h(y,{size:`large`,onClick:()=>this.changeUpdateList(),children:h(it,{color:this.state.updateList?`primary`:`inherit`})})})}),t&&h(I,{title:this.t(`Update all adapters`),slotProps:{popper:{sx:Q.tooltip}},children:h(y,{size:`large`,onClick:()=>this.setState({showUpdater:!0}),children:h(Ft,{})})}),this.props.expertMode&&((e=this.props.adminGuiConfig.admin)==null||(e=e.adapters)==null?void 0:e.gitHubInstall)!==!1&&h(I,{title:this.t(`Install from custom URL`),slotProps:{popper:{sx:Q.tooltip}},children:h(y,{size:`large`,onClick:()=>this.setState({gitHubInstallDialog:!0}),children:h(m,{})})}),h(`div`,{style:Q.grow}),h(N,{variant:`standard`,inputRef:this.inputRef,label:this.t(`Filter by name`),defaultValue:this.state.search,onChange:e=>this.handleFilterChange(e),slotProps:{input:{endAdornment:this.state.search?h(L,{position:`end`,children:h(y,{tabIndex:-1,size:`small`,onClick:()=>{(window._localStorage||window.localStorage).removeItem(`Adapter.search`),this.inputRef.current&&(this.inputRef.current.value=``),this.setState({search:``},()=>this.filterAdapters())},children:h(v,{})})}):null}}}),!this.state.tableViewMode&&h(Ct,{t:this.t,icons:!0,contained:this.state.categoriesTiles!==`All`,translateSuffix:`_group`,arrayItem:[{name:`All`},...this.state.categories],onClick:e=>this.changeCategoriesTiles(e),value:this.state.categoriesTiles}),h(Ct,{title:this.t(`Sort by`),t:this.t,buttonIcon:h(pt,{style:{marginRight:4}}),arrayItem:this.state.tableViewMode?Sn.filter(e=>!e.notByList):Sn,onClick:e=>this.changeFilterTiles(e),value:this.state.filterTiles}),h(`div`,{style:Q.grow}),h(H,{config:this.props.adminGuiConfig.admin,name:`admin.adapters.statistics`,children:T(j,{component:`div`,sx:k.getStyle(this.props.theme,Q.infoAdapters,{display:{xs:`none`,md:`inline-block`}}),onClick:()=>this.setState({showStatistics:!0}),children:[T(j,{component:`div`,sx:{...Q.counters,...Q.greenText},children:[this.t(`Selected adapters`),h(`div`,{ref:this.countRef})]}),T(j,{component:`div`,sx:Q.counters,children:[this.t(`Total adapters`),`:`,h(`div`,{children:this.allAdapters})]}),T(j,{component:`div`,sx:Q.counters,children:[this.t(`Installed adapters`),`:`,h(`div`,{children:this.installedAdapters})]}),T(j,{component:`div`,sx:Q.counters,children:[this.t(`Last month updated adapters`),`:`,h(`div`,{children:this.recentUpdatedAdapters})]})]})}),h(j,{sx:{ml:`auto`,pl:1},children:this.props.hostSelector})]})}renderWebserverUpgrade(){return this.state.adminUpgradeTo?h(mn,{socket:this.props.socket,themeType:this.props.themeType,host:this.props.adminHost,onClose:()=>{console.log(`Close dialog`),this.setState({adminUpgradeTo:``,showDialog:!1})},version:this.state.adminUpgradeTo,adminInstance:this.props.adminInstance,onUpdating:e=>{this.props.onUpdating(e)},currentAdminVersion:this.props.currentAdminVersion}):null}render(){var e;if(!this.state.init)return h(A,{});this.state.triggerUpdate!==this.props.triggerUpdate&&setTimeout(()=>{this.setState({triggerUpdate:this.props.triggerUpdate},()=>this.updateAll(!0))},100),(this.props.currentHost!==this.state.currentHost||this.props.forceUpdateAdapters!==this.state.forceUpdateAdapters)&&(this.hostsTimer=this.hostsTimer||setTimeout(()=>{this.hostsTimer=null,this.setState({currentHost:this.props.currentHost,forceUpdateAdapters:this.props.forceUpdateAdapters},async()=>{var e;if(((e=this.hostAdapterWorker)==null?void 0:e.getHost())!==this.props.currentHost){var t;(t=this.hostAdapterWorker)==null||t.destroy(),this.hostAdapterWorker=new It(this.props.socket,this.props.currentHost),this.hostAdapterWorker.registerHandler(this.onHostAdapterChanged,!0),await this.hostAdapterWorker.getObjects()}await this.updateAll(!1,!1,!0)})},200));let t=k.isStableRepository(this.props.systemConfig.common.activeRepo),n=((e=this.state.compactRepositories)==null||(e=e.native)==null?void 0:e.repositories)||{};if(n&&this.props.systemConfig.common.activeRepo){if(Array.isArray(this.props.systemConfig.common.activeRepo))t=this.props.systemConfig.common.activeRepo.every(e=>{var t;return e.toLowerCase().startsWith(`stable`)||((t=n[e])==null||(t=t.json)==null||(t=t._repoInfo)==null?void 0:t.stable)});else if(typeof this.props.systemConfig.common.activeRepo==`string`){var r;t=this.props.systemConfig.common.activeRepo.toLowerCase().startsWith(`stable`)||((r=n[this.props.systemConfig.common.activeRepo])==null||(r=r.json)==null||(r=r._repoInfo)==null?void 0:r.stable)}}let i=``;if(!t){if(i=Array.isArray(this.props.systemConfig.common.activeRepo)?this.props.systemConfig.common.activeRepo.join(`, `):this.props.systemConfig.common.activeRepo,typeof this.props.systemConfig.common.activeRepo==`string`){var a;let e=n&&((a=n[this.props.systemConfig.common.activeRepo])==null||(a=a.json)==null?void 0:a._repoInfo);e!=null&&e.name&&(i=e.name&&typeof e.name==`object`?e.name[this.props.lang]||e.name.en:e.name)}else this.props.systemConfig.common.activeRepo&&typeof this.props.systemConfig.common.activeRepo!=`string`&&(i=this.props.systemConfig.common.activeRepo.map(e=>{var t;let r=n&&((t=n[e])==null||(t=t.json)==null?void 0:t._repoInfo);return r!=null&&r.name?r.name&&typeof r.name==`object`?r.name[this.props.lang]||r.name.en:r.name:e}).join(`, `))}let o=this.getContext(this.state.descWidth<50);return this.cache.listOfVisibleAdapter||(this.buildCacheTimer=this.buildCacheTimer||setTimeout(()=>{this.buildCacheTimer=null,this.buildCache(o)},0)),T(ee,{children:[this.state.update&&h(O,{children:h(A,{})}),this.renderHeader(),h(pn,{stableRepo:t,repoName:i,context:o,noTranslation:this.props.noTranslation,systemConfig:this.props.systemConfig,tableViewMode:this.state.tableViewMode,oneListView:this.state.oneListView,update:this.state.update,updateListFilter:this.state.updateList,searchFilter:this.state.search,installedListFilter:this.state.installedList,cachedAdapters:this.cache.adapters,categories:this.state.categories,categoriesExpanded:this.state.categoriesExpanded,listOfVisibleAdapter:this.cache.listOfVisibleAdapter,toggleCategory:e=>this.toggleCategory(e),clearAllFilters:e=>this.clearAllFilters(e),descWidth:this.state.descWidth,sortByName:this.state.filterTiles===vn,sortPopularFirst:o.sortPopularFirst,sortRecentlyUpdated:o.sortRecentlyUpdated,sortRecentlyCreated:o.sortRecentlyCreated,commandRunning:this.props.commandRunning}),this.getUpdater(),this.getStatistics(),this.renderSlowConnectionWarning(),this.renderGitHubInstallDialog(o),this.renderWebserverUpgrade(),this.renderDialogs(o)]})}};export{Cn as default};