iobroker.admin 7.7.2 → 7.7.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +120 -13
- package/admin/README.md +3 -0
- package/admin/admin.png +0 -0
- package/admin/i18n/de.json +1 -1
- package/admin/i18n/es.json +1 -1
- package/admin/i18n/fr.json +1 -1
- package/admin/i18n/it.json +1 -1
- package/admin/i18n/nl.json +1 -1
- package/admin/i18n/pl.json +1 -1
- package/admin/i18n/pt.json +1 -1
- package/admin/i18n/ru.json +1 -1
- package/admin/i18n/uk.json +1 -1
- package/admin/i18n/zh-cn.json +1 -1
- package/admin/jsonConfig.json5 +1 -2
- package/adminWww/assets/AdapterUpdateDialog-CJRQB5ud.js +2 -0
- package/adminWww/assets/Adapters-B5LWXJ3G.js +9 -0
- package/adminWww/assets/Config-D3mtokJQ.js +1 -0
- package/adminWww/assets/CustomModal-DCjdghJB.js +1 -0
- package/adminWww/assets/CustomTab-CBVvppVS.js +1 -0
- package/adminWww/assets/DefaultPropsProvider-BZ42HOhu.js +15 -0
- package/adminWww/assets/DefaultPropsProvider-DoV5d6EJ.js +1 -0
- package/adminWww/assets/EasyMode-CR0Vw-OT.js +1 -0
- package/adminWww/assets/Enums-BImz5cPM.js +111 -0
- package/adminWww/assets/Fields-V2W2HJlv.js +1 -0
- package/adminWww/assets/Files-Ci2XDKh8.js +6 -0
- package/adminWww/assets/FilledInput-0vrRQpr_.js +2 -0
- package/adminWww/assets/Google-FmfjVx6X.js +27 -0
- package/adminWww/assets/Hosts-AXD2lYOf.js +121 -0
- package/adminWww/assets/Instances-j88MVgOp.js +2 -0
- package/adminWww/assets/Intro-DH7_8X9J.js +2 -0
- package/adminWww/assets/Logs-BJEYaBGh.js +1 -0
- package/adminWww/assets/Objects-CeqK8jeG.js +60 -0
- package/adminWww/assets/State-DhReNijC.js +1 -0
- package/adminWww/assets/TextField-fjsX40wR.js +138 -0
- package/adminWww/assets/Users-BJgk5zRR.js +1 -0
- package/adminWww/assets/___vite-browser-external_commonjs-proxy-DMh1aSo_.js +1 -0
- package/adminWww/assets/_commonjs-dynamic-modules-TDtrdbi3.js +1 -0
- package/adminWww/assets/_commonjsHelpers-CE1G-McA.js +1 -0
- package/adminWww/assets/ace-DgO9yth5.js +985 -0
- package/adminWww/assets/assertThisInitialized-CKqanoMB.js +1 -0
- package/adminWww/assets/blueGrey-BFcAYvAO.js +29 -0
- package/adminWww/assets/{bootstrap-CrpeRPv0.css → bootstrap-DSlxhDzw.css} +1 -1
- package/adminWww/assets/bootstrap-xC60EdKn.js +303 -0
- package/adminWww/assets/createSvgIcon-CC7aIjya.js +1 -0
- package/adminWww/assets/createTheme-O_VGsRib.js +16 -0
- package/adminWww/assets/defaultTheme-CF56WVgQ.js +1 -0
- package/adminWww/assets/emotion-cache.browser.esm-BgJfNZJN.js +1 -0
- package/adminWww/assets/emotion-react.browser.esm-LdYA3M0T.js +8 -0
- package/adminWww/assets/emotion-serialize.esm-Q4o_CgeF.js +1 -0
- package/adminWww/assets/emotion-styled.browser.esm-D6u524ZG.js +1 -0
- package/adminWww/assets/emotion-use-insertion-effect-with-fallbacks.browser.esm-q3_hvwuL.js +1 -0
- package/adminWww/assets/en-US-B8gg5zk_.js +1 -0
- package/adminWww/assets/ext-language_tools-DJmHbGA8.js +389 -0
- package/adminWww/assets/geosearch.module-BN92cSpK.js +1 -0
- package/adminWww/assets/{hostInit-fzxL8JAx.js → hostInit-OBG53iVO.js} +2 -2
- package/adminWww/assets/iconBase-CB0tx1VT.js +1 -0
- package/adminWww/assets/{index-D--ojYan.js → index-28qkNZAi.js} +1 -1
- package/adminWww/assets/index-8V8iNIbi.js +5 -0
- package/adminWww/assets/{index-CJvbfjSs.js → index-B0C4gXUO.js} +1 -1
- package/adminWww/assets/index-B5NvG6mn.js +2 -0
- package/adminWww/assets/index-BVQ-ZSLt.js +10 -0
- package/adminWww/assets/index-B_eoqXoQ.js +890 -0
- package/adminWww/assets/index-Bc8bBbjM.js +15 -0
- package/adminWww/assets/{index-Co3YA5NW.js → index-BgpTxVrG.js} +1 -1
- package/adminWww/assets/{index-DTGUg51P.js → index-C73G-H4k.js} +2 -2
- package/adminWww/assets/{index-rKfs-rCa.js → index-CbQYNHIO.js} +1 -1
- package/adminWww/assets/index-ChtI58Wj.js +1 -0
- package/adminWww/assets/index-CkI9667U.js +1 -0
- package/adminWww/assets/index-DEgEIbz9.js +1 -0
- package/adminWww/assets/index-DYa0xJDK.js +1 -0
- package/adminWww/assets/index-Dy_ekAsY.js +1 -0
- package/adminWww/assets/index-d-Zo1uu9.js +55 -0
- package/adminWww/assets/{iobroker_admin__loadShare___mf_0_emotion_mf_1_react__loadShare__-BOKYvG_W.js → iobroker_admin__loadShare___mf_0_emotion_mf_1_react__loadShare__-CXogaIXO.js} +1 -1
- package/adminWww/assets/iobroker_admin__loadShare___mf_0_iobroker_mf_1_adapter_mf_2_react_mf_2_v5__loadShare__-D-aUnioX.js +1 -0
- package/adminWww/assets/iobroker_admin__loadShare___mf_0_iobroker_mf_1_json_mf_2_config__loadShare__-DQH_iIDO.js +1 -0
- package/adminWww/assets/iobroker_admin__loadShare___mf_0_mui_mf_1_icons_mf_2_material__loadShare__-Dy1SQ0vs.js +1 -0
- package/adminWww/assets/{iobroker_admin__loadShare__leaflet__loadShare__-h9SMNPLU.js → iobroker_admin__loadShare__leaflet__loadShare__-BfU5U5_j.js} +1 -1
- package/adminWww/assets/iobroker_admin__loadShare__prop_mf_2_types__loadShare__-CpCTEixV.js +1 -0
- package/adminWww/assets/{iobroker_admin__loadShare__react__loadShare__-Bis6NHgw.js → iobroker_admin__loadShare__react__loadShare__-CMWK8WhK.js} +1 -1
- package/adminWww/assets/iobroker_admin__loadShare__react_mf_2_dom__loadShare__-GTRt2eft.js +1 -0
- package/adminWww/assets/iobroker_admin__loadShare__react_mf_2_dropzone__loadShare__-BF_gp27r.js +1 -0
- package/adminWww/assets/iobroker_admin__mf_v__runtimeInit__mf_v__-CHE4rLsT.js +5 -0
- package/adminWww/assets/leaflet-src-B98elavC.js +4 -0
- package/adminWww/assets/locale-ZVMVA5rz.js +1 -0
- package/adminWww/assets/pl-OOhGZ0tn.js +1 -0
- package/adminWww/assets/preload-helper-BDBacUwf.js +1 -0
- package/adminWww/assets/sdk-DTP6UH26.js +15 -0
- package/adminWww/assets/sentry-C8mPNiGL.js +1 -0
- package/adminWww/assets/useTheme-C-uGEZO5.js +1 -0
- package/adminWww/assets/useTheme-UOPilb5j.js +1 -0
- package/adminWww/assets/{zh-cn-vvAC9zpl.js → zh-cn-Dy5SHo8v.js} +13 -13
- package/adminWww/img/admin.png +0 -0
- package/adminWww/index.html +4 -4
- package/adminWww/lib/js/ace/ext-searchbox.js +1 -1
- package/adminWww/lib/js/socket.io.js +7 -1
- package/adminWww/mf-manifest.json +1 -1
- package/adminWww/remoteEntry.js +2 -2
- package/build/i18n/de.json +18 -0
- package/build/i18n/es.json +18 -0
- package/build/i18n/fr.json +18 -0
- package/build/i18n/it.json +18 -0
- package/build/i18n/nl.json +18 -0
- package/build/i18n/pl.json +18 -0
- package/build/i18n/pt.json +18 -0
- package/build/i18n/ru.json +18 -0
- package/build/i18n/uk.json +18 -0
- package/build/i18n/zh-cn.json +18 -0
- package/build/lib/checkLinuxPass.js.map +1 -0
- package/{build-backend → build}/lib/testPassword.js +1 -1
- package/build/lib/testPassword.js.map +1 -0
- package/{build-backend → build}/lib/translations.js +16 -1
- package/build/lib/translations.js.map +1 -0
- package/{build-backend → build}/lib/utils.js +20 -0
- package/build/lib/utils.js.map +1 -0
- package/{build-backend → build}/lib/web.js +6 -7
- package/build/lib/web.js.map +1 -0
- package/{build-backend → build}/main.js +68 -5
- package/build/main.js.map +1 -0
- package/io-package.json +27 -40
- package/package.json +117 -110
- package/adminWww/assets/AdapterUpdateDialog-DHGhgEEq.js +0 -2
- package/adminWww/assets/Adapters-CgSIajcF.js +0 -7
- package/adminWww/assets/Config-BQSl4bfA.js +0 -1
- package/adminWww/assets/CustomModal-DNMTLv4y.js +0 -1
- package/adminWww/assets/CustomTab-Bl8S8QZW.js +0 -1
- package/adminWww/assets/DefaultPropsProvider-u5xB1Fxz.js +0 -30
- package/adminWww/assets/EasyMode-xDbqrply.js +0 -1
- package/adminWww/assets/Enums-BSICIhWI.js +0 -111
- package/adminWww/assets/Fields-C3JkTmfP.js +0 -1
- package/adminWww/assets/Files-DK85-COY.js +0 -6
- package/adminWww/assets/FilledInput-CysG4ax_.js +0 -2
- package/adminWww/assets/Hosts-qIsB4Gub.js +0 -121
- package/adminWww/assets/Instances-BA_DCzs8.js +0 -2
- package/adminWww/assets/Intro-00oh6SLw.js +0 -2
- package/adminWww/assets/Logs-Cvpgh-zN.js +0 -1
- package/adminWww/assets/Objects-Dp71iotS.js +0 -60
- package/adminWww/assets/State-BqfD2ABf.js +0 -1
- package/adminWww/assets/Tabs-sxfWgN0b.js +0 -138
- package/adminWww/assets/Users-CDcWqTfZ.js +0 -1
- package/adminWww/assets/_commonjsHelpers-D6-XlEtG.js +0 -1
- package/adminWww/assets/ace-BG5WYul1.js +0 -985
- package/adminWww/assets/blueGrey-DYsiMDOn.js +0 -29
- package/adminWww/assets/bootstrap-BYQTdf9r.js +0 -2024
- package/adminWww/assets/createSvgIcon-Bh3KWtyp.js +0 -1
- package/adminWww/assets/emotion-cache.browser.esm-B8BFze5o.js +0 -1
- package/adminWww/assets/emotion-react.browser.esm-BCDt9NrH.js +0 -8
- package/adminWww/assets/emotion-serialize.esm-BUa21YfQ.js +0 -1
- package/adminWww/assets/emotion-styled.browser.esm-CyFqGgyG.js +0 -1
- package/adminWww/assets/emotion-utils.browser.esm-pglN4_eI.js +0 -1
- package/adminWww/assets/geosearch.module-DH4NhiPj.js +0 -1
- package/adminWww/assets/iconBase-C3vi24ZE.js +0 -1
- package/adminWww/assets/index-B1ITPhEY.js +0 -7
- package/adminWww/assets/index-C_-7Z7UV.js +0 -1
- package/adminWww/assets/index-D3IAEXXP.js +0 -10
- package/adminWww/assets/index-DPDg2YA0.js +0 -1
- package/adminWww/assets/index-Qa7Q_Dz5.js +0 -1
- package/adminWww/assets/index-qcIeekse.js +0 -55
- package/adminWww/assets/index-wN1ZlPSW.js +0 -2
- package/adminWww/assets/iobroker_admin__loadShare__prop_mf_2_types__loadShare__-BnsS7SOQ.js +0 -1
- package/adminWww/assets/iobroker_admin__mf_v__runtimeInit__mf_v__-CTkuGOOk.js +0 -5
- package/adminWww/assets/leaflet-src-A2ZHl6nF.js +0 -4
- package/adminWww/assets/locale-9HzB0nxi.js +0 -1
- package/adminWww/assets/preload-helper-Dp1pzeXC.js +0 -1
- package/adminWww/assets/sentry-H_UdJ2zx.js +0 -1
- package/adminWww/lib/js/crypto-js/aes.js +0 -234
- package/adminWww/lib/js/crypto-js/blowfish.js +0 -471
- package/adminWww/lib/js/crypto-js/bower.json +0 -39
- package/adminWww/lib/js/crypto-js/cipher-core.js +0 -895
- package/adminWww/lib/js/crypto-js/core.js +0 -807
- package/adminWww/lib/js/crypto-js/crypto-js.js +0 -6657
- package/adminWww/lib/js/crypto-js/docs/QuickStartGuide.wiki +0 -470
- package/adminWww/lib/js/crypto-js/enc-base64.js +0 -136
- package/adminWww/lib/js/crypto-js/enc-base64url.js +0 -148
- package/adminWww/lib/js/crypto-js/enc-hex.js +0 -18
- package/adminWww/lib/js/crypto-js/enc-latin1.js +0 -18
- package/adminWww/lib/js/crypto-js/enc-utf16.js +0 -149
- package/adminWww/lib/js/crypto-js/enc-utf8.js +0 -18
- package/adminWww/lib/js/crypto-js/evpkdf.js +0 -134
- package/adminWww/lib/js/crypto-js/format-hex.js +0 -66
- package/adminWww/lib/js/crypto-js/format-openssl.js +0 -18
- package/adminWww/lib/js/crypto-js/hmac-md5.js +0 -18
- package/adminWww/lib/js/crypto-js/hmac-ripemd160.js +0 -18
- package/adminWww/lib/js/crypto-js/hmac-sha1.js +0 -18
- package/adminWww/lib/js/crypto-js/hmac-sha224.js +0 -18
- package/adminWww/lib/js/crypto-js/hmac-sha256.js +0 -18
- package/adminWww/lib/js/crypto-js/hmac-sha3.js +0 -18
- package/adminWww/lib/js/crypto-js/hmac-sha384.js +0 -18
- package/adminWww/lib/js/crypto-js/hmac-sha512.js +0 -18
- package/adminWww/lib/js/crypto-js/hmac.js +0 -143
- package/adminWww/lib/js/crypto-js/index.js +0 -18
- package/adminWww/lib/js/crypto-js/lib-typedarrays.js +0 -76
- package/adminWww/lib/js/crypto-js/md5.js +0 -268
- package/adminWww/lib/js/crypto-js/mode-cfb.js +0 -80
- package/adminWww/lib/js/crypto-js/mode-ctr-gladman.js +0 -116
- package/adminWww/lib/js/crypto-js/mode-ctr.js +0 -58
- package/adminWww/lib/js/crypto-js/mode-ecb.js +0 -40
- package/adminWww/lib/js/crypto-js/mode-ofb.js +0 -54
- package/adminWww/lib/js/crypto-js/package.json +0 -42
- package/adminWww/lib/js/crypto-js/pad-ansix923.js +0 -49
- package/adminWww/lib/js/crypto-js/pad-iso10126.js +0 -44
- package/adminWww/lib/js/crypto-js/pad-iso97971.js +0 -40
- package/adminWww/lib/js/crypto-js/pad-nopadding.js +0 -30
- package/adminWww/lib/js/crypto-js/pad-pkcs7.js +0 -18
- package/adminWww/lib/js/crypto-js/pad-zeropadding.js +0 -47
- package/adminWww/lib/js/crypto-js/pbkdf2.js +0 -145
- package/adminWww/lib/js/crypto-js/rabbit-legacy.js +0 -190
- package/adminWww/lib/js/crypto-js/rabbit.js +0 -192
- package/adminWww/lib/js/crypto-js/rc4.js +0 -139
- package/adminWww/lib/js/crypto-js/ripemd160.js +0 -267
- package/adminWww/lib/js/crypto-js/sha1.js +0 -150
- package/adminWww/lib/js/crypto-js/sha224.js +0 -80
- package/adminWww/lib/js/crypto-js/sha256.js +0 -199
- package/adminWww/lib/js/crypto-js/sha3.js +0 -326
- package/adminWww/lib/js/crypto-js/sha384.js +0 -83
- package/adminWww/lib/js/crypto-js/sha512.js +0 -326
- package/adminWww/lib/js/crypto-js/tripledes.js +0 -779
- package/adminWww/lib/js/crypto-js/x64-core.js +0 -304
- package/build-backend/i18n/de.json +0 -18
- package/build-backend/i18n/es.json +0 -18
- package/build-backend/i18n/fr.json +0 -18
- package/build-backend/i18n/it.json +0 -18
- package/build-backend/i18n/nl.json +0 -18
- package/build-backend/i18n/pl.json +0 -18
- package/build-backend/i18n/pt.json +0 -18
- package/build-backend/i18n/ru.json +0 -18
- package/build-backend/i18n/uk.json +0 -18
- package/build-backend/i18n/zh-cn.json +0 -18
- package/build-backend/lib/checkLinuxPass.js.map +0 -1
- package/build-backend/lib/testPassword.js.map +0 -1
- package/build-backend/lib/translations.js.map +0 -1
- package/build-backend/lib/utils.js.map +0 -1
- package/build-backend/lib/web.js.map +0 -1
- package/build-backend/main.js.map +0 -1
- /package/{build-backend → build}/i18n/en.json +0 -0
- /package/{build-backend → build}/lib/checkLinuxPass.js +0 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-CbQYNHIO.js","./iobroker_admin__loadShare__prop_mf_2_types__loadShare__-CpCTEixV.js","./_commonjsHelpers-CE1G-McA.js","./iobroker_admin__mf_v__runtimeInit__mf_v__-CHE4rLsT.js","./iobroker_admin__loadShare__react__loadShare__-CMWK8WhK.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as te,a}from"./iobroker_admin__loadShare__react__loadShare__-CMWK8WhK.js";import{l as ze}from"./index-8HslT92O.js";import{c as ge,g as Ke}from"./_commonjsHelpers-CE1G-McA.js";import{c as Ge}from"./_commonjs-dynamic-modules-TDtrdbi3.js";import{r as Xe}from"./___vite-browser-external_commonjs-proxy-DMh1aSo_.js";import{a as v,i as l,I as Ye}from"./iobroker_admin__loadShare___mf_0_mui_mf_1_icons_mf_2_material__loadShare__-Dy1SQ0vs.js";import{i as p,A as Qe}from"./iobroker_admin__loadShare___mf_0_iobroker_mf_1_adapter_mf_2_react_mf_2_v5__loadShare__-D-aUnioX.js";import{R as Ze}from"./iobroker_admin__loadShare__react_mf_2_dom__loadShare__-GTRt2eft.js";import{F as et}from"./FilledInput-0vrRQpr_.js";import{b as tt}from"./createTheme-O_VGsRib.js";import{C as st}from"./Google-FmfjVx6X.js";import{r as at,l as nt,i as it}from"./iobroker_admin__mf_v__runtimeInit__mf_v__-CHE4rLsT.js";import{i as He,A as ot}from"./ext-language_tools-DJmHbGA8.js";import{D as qe}from"./iobroker_admin__loadShare__react_mf_2_dropzone__loadShare__-BF_gp27r.js";import{_ as rt}from"./preload-helper-BDBacUwf.js";import"./iobroker_admin__loadShare__prop_mf_2_types__loadShare__-CpCTEixV.js";import"./DefaultPropsProvider-BZ42HOhu.js";import"./emotion-serialize.esm-Q4o_CgeF.js";import"./iobroker_admin__loadShare___mf_0_emotion_mf_1_react__loadShare__-CXogaIXO.js";import"./useTheme-UOPilb5j.js";import"./DefaultPropsProvider-DoV5d6EJ.js";import"./defaultTheme-CF56WVgQ.js";const lt=Object.freeze(Object.defineProperty({__proto__:null,get ConfigGeneric(){return d},get ConfigPanel(){return X},get JsonConfig(){return Js},get JsonConfigComponent(){return me}},Symbol.toStringTag,{value:"Module"}));var we={exports:{}},de={exports:{}},ht=de.exports,Se;function pt(){return Se||(Se=1,(function(u,e){(function(t,s){u.exports=s()})(ht,function(){var t=t||(function(s,n){var i;if(typeof window<"u"&&window.crypto&&(i=window.crypto),typeof self<"u"&&self.crypto&&(i=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(i=globalThis.crypto),!i&&typeof window<"u"&&window.msCrypto&&(i=window.msCrypto),!i&&typeof ge<"u"&&ge.crypto&&(i=ge.crypto),!i&&typeof Ge=="function")try{i=Xe}catch{}var o=function(){if(i){if(typeof i.getRandomValues=="function")try{return i.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof i.randomBytes=="function")try{return i.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},r=Object.create||(function(){function y(){}return function(I){var _;return y.prototype=I,_=new y,y.prototype=null,_}})(),h={},c=h.lib={},m=c.Base=(function(){return{extend:function(y){var I=r(this);return y&&I.mixIn(y),(!I.hasOwnProperty("init")||this.init===I.init)&&(I.init=function(){I.$super.init.apply(this,arguments)}),I.init.prototype=I,I.$super=this,I},create:function(){var y=this.extend();return y.init.apply(y,arguments),y},init:function(){},mixIn:function(y){for(var I in y)y.hasOwnProperty(I)&&(this[I]=y[I]);y.hasOwnProperty("toString")&&(this.toString=y.toString)},clone:function(){return this.init.prototype.extend(this)}}})(),f=c.WordArray=m.extend({init:function(y,I){y=this.words=y||[],I!=n?this.sigBytes=I:this.sigBytes=y.length*4},toString:function(y){return(y||D).stringify(this)},concat:function(y){var I=this.words,_=y.words,O=this.sigBytes,F=y.sigBytes;if(this.clamp(),O%4)for(var N=0;N<F;N++){var L=_[N>>>2]>>>24-N%4*8&255;I[O+N>>>2]|=L<<24-(O+N)%4*8}else for(var A=0;A<F;A+=4)I[O+A>>>2]=_[A>>>2];return this.sigBytes+=F,this},clamp:function(){var y=this.words,I=this.sigBytes;y[I>>>2]&=4294967295<<32-I%4*8,y.length=s.ceil(I/4)},clone:function(){var y=m.clone.call(this);return y.words=this.words.slice(0),y},random:function(y){for(var I=[],_=0;_<y;_+=4)I.push(o());return new f.init(I,y)}}),g=h.enc={},D=g.Hex={stringify:function(y){for(var I=y.words,_=y.sigBytes,O=[],F=0;F<_;F++){var N=I[F>>>2]>>>24-F%4*8&255;O.push((N>>>4).toString(16)),O.push((N&15).toString(16))}return O.join("")},parse:function(y){for(var I=y.length,_=[],O=0;O<I;O+=2)_[O>>>3]|=parseInt(y.substr(O,2),16)<<24-O%8*4;return new f.init(_,I/2)}},b=g.Latin1={stringify:function(y){for(var I=y.words,_=y.sigBytes,O=[],F=0;F<_;F++){var N=I[F>>>2]>>>24-F%4*8&255;O.push(String.fromCharCode(N))}return O.join("")},parse:function(y){for(var I=y.length,_=[],O=0;O<I;O++)_[O>>>2]|=(y.charCodeAt(O)&255)<<24-O%4*8;return new f.init(_,I)}},C=g.Utf8={stringify:function(y){try{return decodeURIComponent(escape(b.stringify(y)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(y){return b.parse(unescape(encodeURIComponent(y)))}},k=c.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new f.init,this._nDataBytes=0},_append:function(y){typeof y=="string"&&(y=C.parse(y)),this._data.concat(y),this._nDataBytes+=y.sigBytes},_process:function(y){var I,_=this._data,O=_.words,F=_.sigBytes,N=this.blockSize,L=N*4,A=F/L;y?A=s.ceil(A):A=s.max((A|0)-this._minBufferSize,0);var V=A*N,M=s.min(V*4,F);if(V){for(var B=0;B<V;B+=N)this._doProcessBlock(O,B);I=O.splice(0,V),_.sigBytes-=M}return new f.init(I,M)},clone:function(){var y=m.clone.call(this);return y._data=this._data.clone(),y},_minBufferSize:0});c.Hasher=k.extend({cfg:m.extend(),init:function(y){this.cfg=this.cfg.extend(y),this.reset()},reset:function(){k.reset.call(this),this._doReset()},update:function(y){return this._append(y),this._process(),this},finalize:function(y){y&&this._append(y);var I=this._doFinalize();return I},blockSize:16,_createHelper:function(y){return function(I,_){return new y.init(_).finalize(I)}},_createHmacHelper:function(y){return function(I,_){return new x.HMAC.init(y,_).finalize(I)}}});var x=h.algo={};return h})(Math);return t})})(de)),de.exports}var ct=we.exports;(function(u,e){(function(t,s){u.exports=s(pt())})(ct,function(t){return(function(s){var n=t,i=n.lib,o=i.WordArray,r=i.Hasher,h=n.algo,c=[];(function(){for(var C=0;C<64;C++)c[C]=s.abs(s.sin(C+1))*4294967296|0})();var m=h.MD5=r.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(C,k){for(var x=0;x<16;x++){var y=k+x,I=C[y];C[y]=(I<<8|I>>>24)&16711935|(I<<24|I>>>8)&4278255360}var _=this._hash.words,O=C[k+0],F=C[k+1],N=C[k+2],L=C[k+3],A=C[k+4],V=C[k+5],M=C[k+6],B=C[k+7],Y=C[k+8],J=C[k+9],z=C[k+10],ae=C[k+11],ne=C[k+12],ie=C[k+13],oe=C[k+14],re=C[k+15],E=_[0],T=_[1],w=_[2],S=_[3];E=f(E,T,w,S,O,7,c[0]),S=f(S,E,T,w,F,12,c[1]),w=f(w,S,E,T,N,17,c[2]),T=f(T,w,S,E,L,22,c[3]),E=f(E,T,w,S,A,7,c[4]),S=f(S,E,T,w,V,12,c[5]),w=f(w,S,E,T,M,17,c[6]),T=f(T,w,S,E,B,22,c[7]),E=f(E,T,w,S,Y,7,c[8]),S=f(S,E,T,w,J,12,c[9]),w=f(w,S,E,T,z,17,c[10]),T=f(T,w,S,E,ae,22,c[11]),E=f(E,T,w,S,ne,7,c[12]),S=f(S,E,T,w,ie,12,c[13]),w=f(w,S,E,T,oe,17,c[14]),T=f(T,w,S,E,re,22,c[15]),E=g(E,T,w,S,F,5,c[16]),S=g(S,E,T,w,M,9,c[17]),w=g(w,S,E,T,ae,14,c[18]),T=g(T,w,S,E,O,20,c[19]),E=g(E,T,w,S,V,5,c[20]),S=g(S,E,T,w,z,9,c[21]),w=g(w,S,E,T,re,14,c[22]),T=g(T,w,S,E,A,20,c[23]),E=g(E,T,w,S,J,5,c[24]),S=g(S,E,T,w,oe,9,c[25]),w=g(w,S,E,T,L,14,c[26]),T=g(T,w,S,E,Y,20,c[27]),E=g(E,T,w,S,ie,5,c[28]),S=g(S,E,T,w,N,9,c[29]),w=g(w,S,E,T,B,14,c[30]),T=g(T,w,S,E,ne,20,c[31]),E=D(E,T,w,S,V,4,c[32]),S=D(S,E,T,w,Y,11,c[33]),w=D(w,S,E,T,ae,16,c[34]),T=D(T,w,S,E,oe,23,c[35]),E=D(E,T,w,S,F,4,c[36]),S=D(S,E,T,w,A,11,c[37]),w=D(w,S,E,T,B,16,c[38]),T=D(T,w,S,E,z,23,c[39]),E=D(E,T,w,S,ie,4,c[40]),S=D(S,E,T,w,O,11,c[41]),w=D(w,S,E,T,L,16,c[42]),T=D(T,w,S,E,M,23,c[43]),E=D(E,T,w,S,J,4,c[44]),S=D(S,E,T,w,ne,11,c[45]),w=D(w,S,E,T,re,16,c[46]),T=D(T,w,S,E,N,23,c[47]),E=b(E,T,w,S,O,6,c[48]),S=b(S,E,T,w,B,10,c[49]),w=b(w,S,E,T,oe,15,c[50]),T=b(T,w,S,E,V,21,c[51]),E=b(E,T,w,S,ne,6,c[52]),S=b(S,E,T,w,L,10,c[53]),w=b(w,S,E,T,z,15,c[54]),T=b(T,w,S,E,F,21,c[55]),E=b(E,T,w,S,Y,6,c[56]),S=b(S,E,T,w,re,10,c[57]),w=b(w,S,E,T,M,15,c[58]),T=b(T,w,S,E,ie,21,c[59]),E=b(E,T,w,S,A,6,c[60]),S=b(S,E,T,w,ae,10,c[61]),w=b(w,S,E,T,N,15,c[62]),T=b(T,w,S,E,J,21,c[63]),_[0]=_[0]+E|0,_[1]=_[1]+T|0,_[2]=_[2]+w|0,_[3]=_[3]+S|0},_doFinalize:function(){var C=this._data,k=C.words,x=this._nDataBytes*8,y=C.sigBytes*8;k[y>>>5]|=128<<24-y%32;var I=s.floor(x/4294967296),_=x;k[(y+64>>>9<<4)+15]=(I<<8|I>>>24)&16711935|(I<<24|I>>>8)&4278255360,k[(y+64>>>9<<4)+14]=(_<<8|_>>>24)&16711935|(_<<24|_>>>8)&4278255360,C.sigBytes=(k.length+1)*4,this._process();for(var O=this._hash,F=O.words,N=0;N<4;N++){var L=F[N];F[N]=(L<<8|L>>>24)&16711935|(L<<24|L>>>8)&4278255360}return O},clone:function(){var C=r.clone.call(this);return C._hash=this._hash.clone(),C}});function f(C,k,x,y,I,_,O){var F=C+(k&x|~k&y)+I+O;return(F<<_|F>>>32-_)+k}function g(C,k,x,y,I,_,O){var F=C+(k&y|x&~y)+I+O;return(F<<_|F>>>32-_)+k}function D(C,k,x,y,I,_,O){var F=C+(k^x^y)+I+O;return(F<<_|F>>>32-_)+k}function b(C,k,x,y,I,_,O){var F=C+(x^(k|~y))+I+O;return(F<<_|F>>>32-_)+k}n.MD5=r._createHelper(m),n.HmacMD5=r._createHmacHelper(m)})(Math),t.MD5})})(we);var ut=we.exports;const Ie=Ke(ut),dt=window.innerWidth<=600?12:void 0;function ye(u){return Object.prototype.toString.call(u)==="[object Object]"}class d extends te.Component{static DIFFERENT_VALUE="__different__";static DIFFERENT_LABEL="ra___different__";static NONE_VALUE="";static NONE_LABEL="ra_none";defaultValue;isError;lang;defaultSendToDone;sendToTimeout;noPlaceRequired;constructor(e){super(e),this.state={confirmDialog:!1,confirmNewValue:null,confirmAttr:null,confirmData:null,confirmCallback:null},this.isError={},e.schema&&(e.custom?this.defaultValue=e.schema.defaultFunc?this.executeCustom(e.schema.defaultFunc,e.data,e.customObj,e.oContext.instanceObj,e.arrayIndex,e.globalData):e.schema.default:e.schema.type!=="state"&&(this.defaultValue=e.schema.defaultFunc?this.execute(e.schema.defaultFunc,e.schema.default,e.data,e.arrayIndex,e.globalData):e.schema.default)),this.lang=p.I18n.getLanguage()}componentDidMount(){this.props.oContext.registerOnForceUpdate&&this.props.oContext.registerOnForceUpdate(this.props.attr,this.onUpdate);const e=["select","autocomplete","autocompleteSendTo"];if(this.defaultValue!==void 0){const t=d.getValue(this.props.data,this.props.attr);(t===void 0||e.includes(this.props.schema.type)&&(t===""||t===null))&&setTimeout(()=>{this.props.custom?this.props.onChange(this.props.attr,this.defaultValue,()=>setTimeout(()=>this.props.oContext.forceUpdate([this.props.attr],this.props.data),100)):(d.setValue(this.props.data,this.props.attr,this.defaultValue),this.props.onChange(this.props.data,void 0,()=>this.props.oContext.forceUpdate([this.props.attr],this.props.data)))},100)}else this.props.schema.defaultSendTo&&this.sendTo()}sendTo(){if(this.props.alive){this.defaultSendToDone=!0;let e=this.props.schema.data;if(e===void 0&&this.props.schema.jsonData){const t=this.getPattern(this.props.schema.jsonData,null,!0);try{e=JSON.parse(t)}catch{console.error(`Cannot parse json data: ${t}`)}}else e={attr:this.props.attr,value:d.getValue(this.props.data,this.props.attr)};e===void 0&&(e=null),this.props.oContext.socket.sendTo(`${this.props.oContext.adapterName}.${this.props.oContext.instance}`,this.props.schema.defaultSendTo,e).then(t=>{t!=null&&(this.props.custom?this.props.onChange(this.props.attr,t,()=>this.props.oContext.forceUpdate([this.props.attr],this.props.data)):(d.setValue(this.props.data,this.props.attr,t),this.props.onChange(this.props.data,void 0,()=>this.props.oContext.forceUpdate([this.props.attr],this.props.data))))})}else this.defaultSendToDone=!1,this.props.schema.allowSaveWithError||this.onError(this.props.attr,p.I18n.t("ra_Instance %s is not alive",this.props.oContext.instance.toString()))}componentWillUnmount(){this.props.oContext.registerOnForceUpdate&&this.props.oContext.registerOnForceUpdate(this.props.attr),this.sendToTimeout&&(clearTimeout(this.sendToTimeout),this.sendToTimeout=null)}onUpdate=e=>{const t=d.getValue(e||this.props.data,this.props.attr)||"";this.state.value!==t?this.setState({value:t}):this.forceUpdate()};static getValue(e,t){if(typeof t=="string")return d.getValue(e,t.split("."));if(t.length===1)return e[t[0]];const s=t.shift();if(typeof s=="string"&&typeof e[s]=="object")return d.getValue(e[s],t)}static setValue(e,t,s){if(typeof t=="string"){d.setValue(e,t.split("."),s);return}if(t.length===1)s===null?delete e[t[0]]:e[t[0]]=s;else{const n=t.shift();if(typeof n!="string")return;(!e[n]||typeof e[n]=="object")&&(e[n]=e[n]||{}),d.setValue(e[n],t,s)}}getText(e,t){if(!e)return"";if(typeof e=="string"){const s=t?e:p.I18n.t(e);return s.includes("${")?this.getPattern(s,null,t):s}return ye(e)?e.func?typeof e.func=="object"?this.getPattern(e.func[this.lang]||e.func.en||"",null,!0):this.getPattern(e.func,null,t):e[this.lang]||e.en||"":e.toString()}renderDialogConfirm(){if(!this.state.confirmDialog)return null;const e=this.state.confirmData||this.props.schema.confirm;let t=null;return e.type==="warning"?t=a.createElement(v.Warning,null):e.type==="error"?t=a.createElement(v.Error,null):e.type==="info"&&(t=a.createElement(v.Info,null)),a.createElement(p.DialogConfirm,{title:this.getText(e.title)||p.I18n.t("ra_Please confirm"),text:this.getText(e.text),ok:this.getText(e.ok)||p.I18n.t("ra_Ok"),cancel:this.getText(e.cancel)||p.I18n.t("ra_Cancel"),icon:t||void 0,onClose:s=>this.setState({confirmDialog:!1},()=>{if(s){if(this.state.confirmCallback){const i=this.state.confirmCallback;this.setState({confirmCallback:null},()=>i(!0));return}const n=JSON.parse(JSON.stringify(this.props.data));this.state.confirmDepAttr&&d.setValue(n,this.state.confirmDepAttr,this.state.confirmDepNewValue),d.setValue(n,this.state.confirmAttr,this.state.confirmNewValue),this.setState({confirmDialog:!1,confirmDepAttr:null,confirmDepNewValue:null,confirmNewValue:null,confirmAttr:null,confirmData:null},()=>this.props.onChange(n))}else{const n=this.state.confirmCallback;this.setState({confirmDialog:!1,confirmDepAttr:null,confirmDepNewValue:null,confirmNewValue:null,confirmAttr:null,confirmData:null,confirmCallback:null},()=>{n&&n(!1)})}})})}getIcon(e){e=e||this.props.schema.icon;let t=null;return e==="auth"?t=a.createElement(v.Key,null):e==="send"?t=a.createElement(v.Send,null):e==="web"?t=a.createElement(v.Public,null):e==="warning"?t=a.createElement(v.Warning,null):e==="error"?t=a.createElement(v.Error,null):e==="info"?t=a.createElement(v.Info,null):e==="search"?t=a.createElement(v.Search,null):e==="book"?t=a.createElement(v.MenuBook,null):e==="help"?t=a.createElement(v.Help,null):e==="upload"?t=a.createElement(v.UploadFile,null):e==="edit"?t=a.createElement(v.Edit,null):e==="user"?t=a.createElement(v.Person,null):e==="group"?t=a.createElement(v.Group,null):e==="delete"?t=a.createElement(v.Delete,null):e==="refresh"?t=a.createElement(v.Refresh,null):e==="add"?t=a.createElement(v.Add,null):e==="unpair"?t=a.createElement(v.LinkOff,null):e==="pair"?t=a.createElement(v.Link,null):e==="save"?t=a.createElement(v.Save,null):e==="open"?t=a.createElement(v.OpenInNew,null):e&&((e.endsWith(".png")||e.endsWith(".svg")||e.endsWith(".jpg"))&&!e.startsWith("http://")&&!e.startsWith("https://")&&(e=`./adapter/${this.props.oContext.adapterName}/${e}`),t=a.createElement(p.Icon,{src:e,style:{width:22,height:22}})),t}onChangeAsync(e,t){return new Promise(s=>{const n=this.onChange(e,t,s);n instanceof Promise&&n.catch(i=>console.error(`Cannot set value: ${i}`))})}onChange(e,t,s){const n=JSON.parse(JSON.stringify(this.props.data));if(d.setValue(n,e,t),this.props.schema.confirm&&this.execute(this.props.schema.confirm.condition,!1,n,this.props.arrayIndex,this.props.globalData))return new Promise(o=>{this.setState({confirmDialog:!0,confirmNewValue:t,confirmAttr:e,confirmData:null},()=>{typeof s=="function"?s():o()})});if(this.props.schema.confirmDependsOn)for(let o=0;o<this.props.schema.confirmDependsOn.length;o++){const r=this.props.schema.confirmDependsOn[o];if(r.confirm){const h=d.getValue(n,r.attr);if(this.execute(r.confirm.condition,!1,n,this.props.arrayIndex,this.props.globalData))return new Promise(c=>{this.setState({confirmDialog:!0,confirmNewValue:t,confirmAttr:e,confirmDepNewValue:h,confirmDepAttr:r.attr,confirmData:r.confirm},()=>{typeof s=="function"?s():c()})})}}const i=[];if(this.props.schema.onChangeDependsOn)for(let o=0;o<this.props.schema.onChangeDependsOn.length;o++){const r=this.props.schema.onChangeDependsOn[o];if(r.onChange){const h=d.getValue(n,r.attr);let c;this.props.custom?c=this.executeCustom(r.onChange.calculateFunc,n,this.props.customObj,this.props.oContext.instanceObj,this.props.arrayIndex,this.props.globalData):c=this.execute(r.onChange.calculateFunc,h,n,this.props.arrayIndex,this.props.globalData),c!==h&&(d.setValue(n,r.attr,c),i.push(r.attr))}}if(this.props.schema.hiddenDependsOn)for(let o=0;o<this.props.schema.hiddenDependsOn.length;o++){const r=this.props.schema.hiddenDependsOn[o];r.hidden&&i.push(r.attr)}if(this.props.schema.labelDependsOn)for(let o=0;o<this.props.schema.labelDependsOn.length;o++){const r=this.props.schema.labelDependsOn[o];r.hidden&&i.push(r.attr)}if(this.props.schema.helpDependsOn)for(let o=0;o<this.props.schema.helpDependsOn.length;o++){const r=this.props.schema.helpDependsOn[o];r.hidden&&i.push(r.attr)}if(this.props.schema.onChange&&!this.props.schema.onChange.ignoreOwnChanges){const o=d.getValue(n,this.props.attr),r=this.props.custom?this.executeCustom(this.props.schema.onChange.calculateFunc,n,this.props.customObj,this.props.oContext.instanceObj,this.props.arrayIndex,this.props.globalData):this.execute(this.props.schema.onChange.calculateFunc,o,n,this.props.arrayIndex,this.props.globalData);r!==o&&d.setValue(n,this.props.attr,r)}return this.props.custom?(this.props.onChange(e,t,()=>s&&s()),i!=null&&i.length&&i.forEach((o,r)=>setTimeout(()=>this.props.onChange(o,d.getValue(n,o)),r*50))):this.props.onChange(n,void 0,()=>{i.length&&this.props.oContext.forceUpdate(i,n),s&&s()}),Promise.resolve()}execute(e,t,s,n,i){let o;if(ye(e))o=e.func;else if(typeof e=="string")o=e;else return e;if(!o)return t;try{return new Function("data","originalData","_system","_alive","_common","_socket","_instance","arrayIndex","globalData","_changed",o.includes("return")?o:`return ${o}`)(s||this.props.data,this.props.originalData,this.props.oContext.systemConfig,this.props.alive,this.props.common,this.props.oContext.socket,this.props.oContext.instance,n,i,this.props.changed)}catch(r){return console.error(`Cannot execute ${JSON.stringify(e)}: ${r}`),t}}executeCustom(e,t,s,n,i,o){let r;if(ye(e))r=e.func;else if(typeof e=="string")r=e;else return e;if(!r)return null;try{return new Function("data","originalData","_system","instanceObj","customObj","_socket","arrayIndex","globalData","_changed",r.includes("return")?r:`return ${r}`)(t||this.props.data,this.props.originalData,this.props.oContext.systemConfig,n,s,this.props.oContext.socket,i,o,this.props.changed)}catch(h){return console.error(`Cannot execute ${r}: ${h}`),null}}calculate(e){let t,s,n,i;return this.props.custom?(t=e.validator?!this.executeCustom(e.validator,this.props.data,this.props.customObj,this.props.oContext.instanceObj,this.props.arrayIndex,this.props.globalData):!1,e.disabled===!0?s=!0:s=e.disabled?this.executeCustom(e.disabled,this.props.data,this.props.customObj,this.props.oContext.instanceObj,this.props.arrayIndex,this.props.globalData):!1,e.hidden===!0?n=!0:n=e.hidden?this.executeCustom(e.hidden,this.props.data,this.props.customObj,this.props.oContext.instanceObj,this.props.arrayIndex,this.props.globalData):!1,i=e.defaultFunc?this.executeCustom(e.defaultFunc,this.props.data,this.props.customObj,this.props.oContext.instanceObj,this.props.arrayIndex,this.props.globalData):e.default):(t=e.validator?!this.execute(e.validator,!1,this.props.data,this.props.arrayIndex,this.props.globalData):!1,e.disabled===!0?s=!0:s=e.disabled?this.execute(e.disabled,!1,this.props.data,this.props.arrayIndex,this.props.globalData):!1,e.hidden===!0?n=!0:n=e.hidden?this.execute(e.hidden,!1,this.props.data,this.props.arrayIndex,this.props.globalData):!1,i=e.defaultFunc?this.execute(e.defaultFunc,e.default,this.props.data,this.props.arrayIndex,this.props.globalData):e.default),{error:t,disabled:s,hidden:n,defaultValue:i}}onError(e,t){t?this.isError[e]=t:delete this.isError[e],this.props.onError&&this.props.onError(e,t)}renderItem(e,t,s){return this.getText(this.props.schema.label)||this.getText(this.props.schema.text)}renderHelp(e,t,s){return t?a.createElement("a",{href:t,target:"_blank",rel:"noreferrer",style:{color:this.props.oContext.themeType==="dark"?"#a147ff":"#5b238f",textDecoration:"underline"}},this.getText(e,s)):(e=this.getText(e,s)||"",e&&(e.includes("<a ")||e.includes("<br")||e.includes("<b>")||e.includes("<i>"))?p.Utils.renderTextWithA(e):e)}static escapeString(e,t){return typeof e!="string"?"":(e=e.replace(/`/g,"\\`"),e=e.replace(/\${([^}]+)}/g,(s,n)=>{if(n&&typeof n=="string"&&n.startsWith("data.")){const i=d.getValue(t,n.replace(/^data\./,""));if(typeof i=="string"&&(i.includes("\\")||i.includes('"')))return`\${${n}.replace(/\\\\/g, '\\\\\\\\').replace(/"/g, '\\\\"')}`}return s}),e)}getPattern(e,t,s){if(t=t||this.props.data,!e)return"";let n;typeof e=="object"?e.func?n=e.func:(console.log(`Object must be stringified: ${JSON.stringify(e)}`),n=JSON.stringify(e)):n=e;try{if(this.props.custom)return new Function("data","originalData","arrayIndex","globalData","_system","instanceObj","customObj","_socket","_changed",`return \`${d.escapeString(n,t)}\``)(t,this.props.originalData,this.props.arrayIndex,this.props.globalData,this.props.oContext.systemConfig,this.props.oContext.instanceObj,this.props.customObj,this.props.oContext.socket,this.props.changed);const o=new Function("data","originalData","arrayIndex","globalData","_system","_alive","_common","_socket","_changed",`return \`${d.escapeString(n,t)}\``)(t,this.props.originalData,this.props.arrayIndex,this.props.globalData,this.props.oContext.systemConfig,this.props.alive,this.props.common,this.props.oContext.socket,this.props.changed);return s?o:p.I18n.t(o)}catch(i){return console.error(`Cannot execute ${n}: ${i}`),n}}render(){const e=this.props.schema;if(!e||this.props.expertMode===!1&&e.expertMode)return null;this.props.alive&&this.defaultSendToDone===!1&&(this.sendToTimeout=setTimeout(()=>{this.sendToTimeout=null,this.sendTo()},200));const{error:t,disabled:s,hidden:n,defaultValue:i}=this.calculate(e);if(n){if(Object.keys(this.isError).length&&(setTimeout(h=>Object.keys(h).forEach(c=>this.props.onError(c)),100,JSON.parse(JSON.stringify(this.isError))),this.isError={}),e.hideOnlyControl){const h=a.createElement(l.Grid2,{size:{xs:e.xs||dt,sm:e.sm||void 0,md:e.md||void 0,lg:e.lg||void 0,xl:e.xl||void 0},style:{marginBottom:0,textAlign:"left",...e.style,...this.props.oContext.themeType==="dark"?e.darkStyle:{}}});return e.newLine?a.createElement(a.Fragment,null,a.createElement("div",{style:{flexBasis:"100%",height:0}}),h):h}return null}e.validatorNoSaveOnError&&(t&&!Object.keys(this.isError).length?(this.isError={[this.props.attr]:e.validatorErrorText?p.I18n.t(e.validatorErrorText):!0},setTimeout(h=>Object.keys(h).forEach(c=>this.props.onError(c,h[c])),100,JSON.parse(JSON.stringify(this.isError)))):!t&&Object.keys(this.isError).length&&(setTimeout(h=>Object.keys(h).forEach(c=>this.props.onError(c)),100,JSON.parse(JSON.stringify(this.isError))),this.isError={}));const o=this.renderItem(t,s||this.props.commandRunning||this.props.disabled,i);if(this.noPlaceRequired)return o;const r=a.createElement(l.Grid2,{title:this.getText(e.tooltip),size:{xs:e.xs||12,sm:e.sm||void 0,md:e.md||void 0,lg:e.lg||void 0,xl:e.xl||void 0},style:{marginBottom:0,textAlign:"left",width:e.type==="divider"||e.type==="header"?e.width||"100%":void 0,...e.style,...this.props.oContext.themeType==="dark"?e.darkStyle:{}}},this.props.schema.defaultSendTo&&this.props.schema.button?a.createElement(l.Grid2,{container:!0,style:{width:"100%"}},a.createElement(l.Grid2,{flex:1},o),a.createElement(l.Grid2,null,a.createElement(l.Button,{disabled:s,variant:"outlined",onClick:()=>this.sendTo(),title:this.props.schema.buttonTooltip?this.getText(this.props.schema.buttonTooltip,this.props.schema.buttonTooltipNoTranslation):p.I18n.t("ra_Request data by instance")},this.getText(this.props.schema.button)))):o);return e.newLine?a.createElement(a.Fragment,null,a.createElement("div",{style:{flexBasis:"100%",height:0}}),this.renderDialogConfirm(),r):this.state.confirmDialog?a.createElement(a.Fragment,null,this.renderDialogConfirm(),r):r}}const W={fullWidth:{width:"100%"},accordionSummary:u=>({backgroundColor:u.palette.mode==="dark"?"rgba(255, 255, 255, 0.08)":"rgba(0, 0, 0, 0.08)"}),accordionTitle:{},toolbar:u=>({backgroundColor:u.palette.mode==="dark"?"rgba(255, 255, 255, 0.08)":"rgba(0, 0, 0, 0.08)",borderRadius:"3px"}),tooltip:{pointerEvents:"none"}};class mt extends d{typingTimer=null;constructor(e){super(e),this.props.schema.items=this.props.schema.items||[]}componentDidMount(){super.componentDidMount();let e=d.getValue(this.props.data,this.props.attr)||[];Array.isArray(e)||(e=[]),this.setState({value:e,activeIndex:-1,iteration:0,accordionErrors:{}})}componentWillUnmount(){this.typingTimer&&(clearTimeout(this.typingTimer),this.typingTimer=null),super.componentWillUnmount()}onAccordionError=e=>(t,s)=>{const n={...this.state.accordionErrors};n[e]||(n[e]={}),s?n[e][t]=s:(delete n[e][t],Object.keys(n[e]).length===0&&delete n[e]),this.setState({accordionErrors:n}),this.props.onError(t,s)};hasAccordionErrors=e=>!!(this.state.accordionErrors[e]&&Object.keys(this.state.accordionErrors[e]).length>0);itemAccordion(e,t){const{value:s}=this.state,{schema:n}=this.props,i={type:"panel",items:n.items.reduce((o,r)=>(o[r.attr]=r,o),{}),style:{marginLeft:"-8px",marginTop:"10px",marginBottom:"10px"}};return a.createElement(X,{oContext:this.props.oContext,index:t+this.state.iteration,arrayIndex:t,changed:this.props.changed,expertMode:this.props.expertMode,globalData:this.props.data,common:this.props.common,alive:this.props.alive,themeName:this.props.themeName,data:e,custom:!0,schema:i,originalData:this.props.originalData,onChange:(o,r)=>{const h=JSON.parse(JSON.stringify(s));h[t][o]=r,this.setState({value:h},()=>this.onChangeWrapper(h))},onError:this.onAccordionError(t),table:this.props.table})}onDelete=e=>()=>{const t=JSON.parse(JSON.stringify(this.state.value));t.splice(e,1),this.setState({value:t,iteration:this.state.iteration+1e4},()=>this.onChangeWrapper(t))};onClone=e=>()=>{const t=JSON.parse(JSON.stringify(this.state.value)),s=JSON.parse(JSON.stringify(t[e]));if(typeof this.props.schema.clone=="string"&&typeof s[this.props.schema.clone]=="string"){let n=1,i=s[this.props.schema.clone];const o=i.match(/(\d+)$/);for(o?(i=i.replace(o[0],""),n=parseInt(o[0],10)+1):i+="_";t.find(r=>r[this.props.schema.clone]===i+n.toString());)n++;s[this.props.schema.clone]=`${s[this.props.schema.clone]}_${n}`}t.splice(e,0,s),this.setState({value:t,activeIndex:-1,iteration:this.state.iteration+1e4},()=>this.onChangeWrapper(t))};onChangeWrapper=e=>{this.typingTimer&&clearTimeout(this.typingTimer),this.typingTimer=setTimeout(t=>{this.typingTimer=null;const s=this.onChange(this.props.attr,t);s instanceof Promise&&s.catch(n=>this.onError(n))},300,e)};onAdd=()=>{const{schema:e}=this.props,t=JSON.parse(JSON.stringify(this.state.value)),s=e.items&&e.items.reduce((n,i)=>{let o;return i.defaultFunc?this.props.custom?o=i.defaultFunc?this.executeCustom(i.defaultFunc,this.props.data,this.props.customObj,this.props.oContext.instanceObj,t.length,this.props.data):this.props.schema.default:o=i.defaultFunc?this.execute(i.defaultFunc,this.props.schema.default,this.props.data,t.length,this.props.data):this.props.schema.default:o=i.default===void 0?null:i.default,n[i.attr]=o,n},{});t.push(s),this.setState({value:t,activeIndex:t.length-1},()=>this.onChangeWrapper(t))};onMoveUp(e){const t=JSON.parse(JSON.stringify(this.state.value)),s=t[e];t.splice(e,1),t.splice(e-1,0,s);const n=this.state.activeIndex-1;this.setState({value:t,activeIndex:n,iteration:this.state.iteration+1e4},()=>this.onChangeWrapper(t))}onMoveDown(e){const t=JSON.parse(JSON.stringify(this.state.value)),s=t[e];t.splice(e,1),t.splice(e+1,0,s);const n=this.state.activeIndex+1;this.setState({value:t,activeIndex:n,iteration:this.state.iteration+1e4},()=>this.onChangeWrapper(t))}onExport=()=>{const{value:e}=this.state,t=JSON.stringify(e,null,2),s=`data:application/json;charset=utf-8,${encodeURIComponent(t)}`,n=`config_section_${new Date().toISOString().slice(0,19).replace(/:/g,"-")}.json`,i=document.createElement("a");i.setAttribute("href",s),i.setAttribute("download",n),i.click()};onImport=e=>{const t=document.createElement("input");t.type="file",t.accept=".json",t.onchange=s=>{var o;const n=(o=s.target.files)==null?void 0:o[0];if(!n)return;const i=new FileReader;i.onload=r=>{var h;try{const c=JSON.parse((h=r.target)==null?void 0:h.result);if(!Array.isArray(c)){alert(p.I18n.t("ra_Invalid JSON format. Expected an array."));return}let m;e?m=c:m=[...this.state.value,...c],this.setState({value:m,activeIndex:-1},()=>this.onChangeWrapper(m))}catch{alert(p.I18n.t("ra_Invalid JSON file."))}},i.readAsText(n)},t.click()};renderItem(){const{schema:e}=this.props,{value:t}=this.state;return t?a.createElement(l.Paper,null,e.label||!e.noDelete?a.createElement(l.Toolbar,{variant:"dense"},e.label?a.createElement(l.Typography,{variant:"h6",id:"tableTitle",component:"div"},this.getText(e.label)):null,e.noDelete?null:a.createElement(a.Fragment,null,a.createElement(l.Tooltip,{title:p.I18n.t("ra_Export configuration section")},a.createElement(l.IconButton,{size:"small",color:"primary",onClick:this.onExport},a.createElement(v.FileDownload,null))),a.createElement(l.Tooltip,{title:p.I18n.t("ra_Import and replace configuration section")},a.createElement(l.IconButton,{size:"small",color:"primary",onClick:()=>this.onImport(!0)},a.createElement(v.FileUpload,null))),a.createElement(l.Tooltip,{title:p.I18n.t("ra_Import and add configuration section")},a.createElement(l.IconButton,{size:"small",color:"primary",onClick:()=>this.onImport(!1)},a.createElement(v.AddCircle,null))),a.createElement(l.IconButton,{size:"small",color:"primary",onClick:this.onAdd},a.createElement(v.Add,null)))):null,t.map((s,n)=>a.createElement(l.Accordion,{key:`${s}_${n}`,expanded:this.state.activeIndex===n,onChange:(i,o)=>this.setState({activeIndex:o?n:-1})},a.createElement(l.AccordionSummary,{expandIcon:a.createElement(v.ExpandMore,null),sx:p.Utils.getStyle(this.props.oContext.theme,W.fullWidth,W.accordionSummary)},a.createElement(l.Box,{sx:{display:"flex",alignItems:"center",gap:1,width:"100%"}},a.createElement(l.Typography,{style:W.accordionTitle},s[e.titleAttr]),this.hasAccordionErrors(n)&&a.createElement(v.Error,{sx:{fontSize:20,color:"error.main"}}))),a.createElement(l.AccordionDetails,{style:{...e.style,...this.props.oContext.themeType?e.darkStyle:void 0}},this.itemAccordion(t[n],n),a.createElement(l.Toolbar,{sx:W.toolbar},n?a.createElement(l.Tooltip,{title:p.I18n.t("ra_Move up"),slotProps:{popper:{sx:W.tooltip}}},a.createElement(l.IconButton,{size:"small",onClick:()=>this.onMoveUp(n)},a.createElement(v.ArrowUpward,null))):a.createElement("div",{style:W.buttonEmpty}),n<t.length-1?a.createElement(l.Tooltip,{title:p.I18n.t("ra_Move down"),slotProps:{popper:{sx:W.tooltip}}},a.createElement(l.IconButton,{size:"small",onClick:()=>this.onMoveDown(n)},a.createElement(v.ArrowDownward,null))):a.createElement("div",{style:W.buttonEmpty}),e.noDelete?null:a.createElement(l.Tooltip,{title:p.I18n.t("ra_Delete current row"),slotProps:{popper:{sx:W.tooltip}}},a.createElement(l.IconButton,{size:"small",onClick:this.onDelete(n)},a.createElement(v.Delete,null))),e.clone?a.createElement(l.Tooltip,{title:p.I18n.t("ra_Clone current row"),slotProps:{popper:{sx:W.tooltip}}},a.createElement(l.IconButton,{size:"small",onClick:this.onClone(n)},a.createElement(v.ContentCopy,null))):null)))),!e.noDelete&&t.length>0?a.createElement(l.Toolbar,{variant:"dense",sx:W.rootTool},a.createElement(l.IconButton,{size:"small",color:"primary",onClick:this.onAdd},a.createElement(v.Add,null))):null,e.help?a.createElement(l.FormHelperText,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null):null}}const ke={root:{width:"100%"},notAlive:{color:"#a30000"}};class ft extends d{componentDidMount(){super.componentDidMount();const e=this.getInstance();this.props.oContext.socket.getState(`${e}.alive`).then(t=>this.setState({alive:!!(t&&t.val),instance:e}))}getInstance(){let e=this.props.schema.instance||`${this.props.oContext.adapterName}.${this.props.oContext.instance}`;return e.includes("${")&&(e=this.getPattern(e,null,!0)),e&&!e.startsWith("system.adapter.")&&(e=`system.adapter.${e}`),e}renderItem(){if(this.getInstance()!==this.state.instance&&setTimeout(()=>{const t=this.getInstance();t?this.props.oContext.socket.getState(`${t}.alive`).then(s=>this.setState({alive:!!(s&&s.val),instance:t})):this.setState({alive:null,instance:t})},200),this.state.alive!==!1&&this.state.alive!==!0)return null;const e=this.state.instance.replace(/^system.adapter./,"");return a.createElement("div",{style:{...ke.root,...this.state.alive?void 0:ke.notAlive}},this.state.alive?this.props.schema.textAlive!==void 0?this.props.schema.textAlive?p.I18n.t(this.props.schema.textAlive,e):"":p.I18n.t("ra_Instance %s is alive",e):this.props.schema.textNotAlive!==void 0?this.props.schema.textNotAlive?p.I18n.t(this.props.schema.textNotAlive,e):"":p.I18n.t("ra_Instance %s is not alive",e))}}class gt extends d{componentDidMount(){super.componentDidMount();const e=d.getValue(this.props.data,this.props.attr),t=this.props.schema.options.map(s=>typeof s=="string"?{label:s,value:s}:JSON.parse(JSON.stringify(s)));Array.isArray(e)?(t.unshift({label:p.I18n.t(d.DIFFERENT_LABEL),value:d.DIFFERENT_VALUE}),this.setState({value:d.DIFFERENT_VALUE,selectOptions:t})):this.setState({value:e,selectOptions:t})}renderItem(e,t){if(!this.state.selectOptions)return null;let s;const n=JSON.parse(JSON.stringify(this.state.selectOptions));return Array.isArray(this.state.value)||this.state.value===d.DIFFERENT_VALUE?([...this.state.value].filter(o=>!n.find(r=>typeof r=="object"?r.value===o:r===o)).forEach(o=>n.push({label:o.toString(),value:o})),s={label:p.I18n.t(d.DIFFERENT_LABEL),value:d.DIFFERENT_VALUE},n.unshift(s)):(s=this.state.value!==null&&this.state.value!==void 0&&n.find(o=>typeof o=="object"?o.value==this.state.value:o==this.state.value),this.state.value!==null&&this.state.value!==void 0&&!s&&this.props.schema.freeSolo&&(s={value:this.state.value,label:this.state.value},n.push(s))),a.createElement(l.Autocomplete,{fullWidth:!0,freeSolo:!!this.props.schema.freeSolo,value:s,options:n,isOptionEqualToValue:(o,r)=>o.value===r.value,filterOptions:(o,r)=>{const h=o.filter(c=>r.inputValue===""?!0:c.label.toLowerCase().includes(r.inputValue.toLowerCase())||c.value.toLowerCase().includes(r.inputValue.toLowerCase()));return this.props.schema.freeSolo&&r.inputValue!==""&&h.push({label:r.inputValue,value:r.inputValue}),h},onInputChange:o=>{if(!o||!this.props.schema.freeSolo)return;const r=o.target.value;r!==this.state.value&&this.setState({value:r},()=>this.onChange(this.props.attr,r))},onChange:(o,r)=>{const h=typeof r=="object"?r?r.value:"":r;h!==this.state.value&&this.setState({value:h},()=>this.onChange(this.props.attr,h))},getOptionLabel:o=>typeof o=="object"?(o==null?void 0:o.label)??"":"",renderInput:o=>a.createElement(l.TextField,{variant:"standard",...o,error:!!e,placeholder:this.getText(this.props.schema.placeholder),label:this.getText(this.props.schema.label),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation),disabled:t})})}}class yt extends d{initialized=!1;localContext;askInstance(){const e=d.getValue(this.props.data,this.props.attr),t=this.props.schema.options?this.props.schema.options.map(s=>typeof s=="string"?{label:s,value:s}:JSON.parse(JSON.stringify(s))):[];if(this.props.alive){let s=this.props.schema.data;if(s===void 0&&this.props.schema.jsonData){const n=this.getPattern(this.props.schema.jsonData,null,!0);try{typeof n=="string"&&(s=JSON.parse(n))}catch{console.error(`Cannot parse json data: ${JSON.stringify(s)}`)}}s===void 0&&(s=null),this.setState({loading:!0}),this.props.oContext.socket.sendTo(`${this.props.oContext.adapterName}.${this.props.oContext.instance}`,this.props.schema.command||"send",s).then(n=>{n&&Array.isArray(n)&&n.forEach(i=>t.push(typeof i=="string"?{label:i,value:i}:JSON.parse(JSON.stringify(i)))),Array.isArray(e)?(t.unshift({label:p.I18n.t(d.DIFFERENT_LABEL),value:d.DIFFERENT_VALUE}),this.setState({value:d.DIFFERENT_VALUE,selectOptions:t,loading:!1})):this.setState({value:e,selectOptions:t,loading:!1})}).catch(n=>{console.error("Error in autocompleteSendTo:",n),this.setState({loading:!1})})}else Array.isArray(e)?(t.unshift({label:p.I18n.t(d.DIFFERENT_LABEL),value:d.DIFFERENT_VALUE}),this.setState({value:d.DIFFERENT_VALUE,selectOptions:t})):this.setState({value:e,selectOptions:t})}getContext(){const e={};return Array.isArray(this.props.schema.alsoDependsOn)&&this.props.schema.alsoDependsOn.forEach(t=>e[t]=d.getValue(this.props.data,t)),JSON.stringify(e)}renderItem(e,t){if(this.props.alive){const o=this.getContext();(o!==this.localContext||!this.initialized)&&(this.localContext=o,setTimeout(()=>this.askInstance(),this.initialized?300:50),this.initialized=!0)}let s;const n=this.state.selectOptions?JSON.parse(JSON.stringify(this.state.selectOptions)):[];return Array.isArray(this.state.value)||this.state.value===d.DIFFERENT_LABEL?([...this.state.value].filter(o=>!n.find(r=>r.value===o)).forEach(o=>n.push({label:o.toString(),value:o})),s={label:p.I18n.t(d.DIFFERENT_LABEL),value:d.DIFFERENT_VALUE},n.unshift(s)):(s=this.state.value!==null&&this.state.value!==void 0&&n.find(o=>o.value==this.state.value),this.state.value!==null&&this.state.value!==void 0&&!s&&this.props.schema.freeSolo&&(s={value:this.state.value,label:this.state.value},n.push(s)),s=s||null),n.length?a.createElement(l.Autocomplete,{value:s,fullWidth:!0,freeSolo:!!this.props.schema.freeSolo,options:n,isOptionEqualToValue:(o,r)=>o.value===r.value,filterOptions:(o,r)=>{const h=o.filter(c=>r.inputValue===""?!0:c.label.toLowerCase().includes(r.inputValue.toLowerCase())||c.value.toLowerCase().includes(r.inputValue.toLowerCase()));return this.props.schema.freeSolo&&r.inputValue!==""&&h.push({label:r.inputValue,value:r.inputValue}),h},getOptionLabel:o=>(o==null?void 0:o.label)??"",onInputChange:o=>{if(!o||!this.props.schema.freeSolo)return;const r=o.target.value;r!==this.state.value&&this.setState({value:r},()=>this.onChange(this.props.attr,r))},onChange:(o,r)=>{const h=typeof r=="object"?r?r.value:"":r;h!==this.state.value&&this.setState({value:h},()=>this.onChange(this.props.attr,h))},renderInput:o=>a.createElement(l.TextField,{variant:"standard",...o,error:!!e,placeholder:this.getText(this.props.schema.placeholder),label:this.getText(this.props.schema.label),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation),disabled:t,InputProps:{...o.InputProps,endAdornment:a.createElement(a.Fragment,null,this.state.loading?a.createElement(l.InputAdornment,{position:"end"},a.createElement(l.CircularProgress,{size:20})):null,o.InputProps.endAdornment)}})}):a.createElement(l.TextField,{variant:"standard",fullWidth:!0,value:this.state.value===null||this.state.value===void 0?"":this.state.value,error:!!e,disabled:t,inputProps:{maxLength:this.props.schema.maxLength||this.props.schema.max||void 0},InputProps:this.state.loading?{endAdornment:a.createElement(l.InputAdornment,{position:"end"},a.createElement(l.CircularProgress,{size:20}))}:void 0,onChange:o=>{const r=o.target.value;this.setState({value:r},()=>this.onChange(this.props.attr,(r||"").trim()))},placeholder:this.getText(this.props.schema.placeholder),label:this.getText(this.props.schema.label),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)})}}const ve={fullWidth:{width:"100%"},flex:{display:"flex"},button:{height:48,marginLeft:4,minWidth:48}};class vt extends d{componentDidMount(){super.componentDidMount();const{data:e,attr:t}=this.props,s=d.getValue(e,t)||"";this.setState({value:s,showDialog:!1})}renderItem(e,t){const{schema:s,attr:n}=this.props,{value:i,showDialog:o}=this.state;return a.createElement(l.FormControl,{style:ve.fullWidth,variant:"standard"},s.label?a.createElement(l.InputLabel,{shrink:!0},this.getText(s.label)):null,a.createElement("div",{style:ve.flex},a.createElement(l.TextField,{variant:"standard",fullWidth:!0,value:i??"",error:!!e,disabled:t,placeholder:this.getText(s.placeholder),label:this.getText(s.label),helperText:this.renderHelp(s.help,s.helpLink,s.noTranslation),onChange:r=>{const h=r.target.value;this.setState({value:h},()=>this.onChange(n,h))}}),a.createElement(l.Button,{color:"grey",disabled:t,style:ve.button,size:"small",variant:"outlined",onClick:()=>this.setState({showDialog:!0})},"...")),o?a.createElement(p.DialogCron,{title:p.I18n.t("ra_Define schedule"),simple:s.simple,complex:s.complex,cron:i,onClose:()=>this.setState({showDialog:!1}),cancel:p.I18n.t("ra_Cancel"),ok:p.I18n.t("ra_Ok"),theme:this.props.oContext.theme,onOk:r=>this.setState({showDialog:!1,value:r},()=>this.onChange(n,r))}):null)}}class bt extends d{async componentDidMount(){super.componentDidMount();const e=d.getValue(this.props.data,this.props.attr),s=(await this.props.oContext.socket.getCertificates()).filter(n=>{const i=this.props.attr.toLowerCase();return i.includes(n.type)||n.type==="public"&&i.includes("cert")||n.type==="private"&&(i.includes("priv")||i.includes("key"))?!0:!!(n.type==="chained"&&(i.includes("chain")||i.includes("ca")))}).map(n=>({label:n.name,value:n.name}));s.unshift({label:p.I18n.t(d.NONE_LABEL),value:d.NONE_VALUE}),this.setState({value:e,selectOptions:s})}renderItem(e,t){var n,i;if(!this.state.selectOptions)return null;const s=(n=this.state.selectOptions)==null?void 0:n.find(o=>o.value===this.state.value);return a.createElement(l.FormControl,{style:{width:"100%"},variant:"standard"},this.props.schema.label?a.createElement(l.InputLabel,{shrink:!0},this.getText(this.props.schema.label)):null,a.createElement(l.Select,{variant:"standard",error:!!e,displayEmpty:!0,disabled:!!t,value:this.state.value,renderValue:()=>this.getText(s==null?void 0:s.label,this.props.schema.noTranslation!==!1),onChange:o=>this.setState({value:o.target.value},()=>this.onChange(this.props.attr,this.state.value))},(i=this.state.selectOptions)==null?void 0:i.map(o=>a.createElement(l.MenuItem,{key:o.value,value:o.value,style:o.value===d.NONE_VALUE?{opacity:.5}:{}},this.getText(o.label,this.props.schema.noTranslation!==!1)))),this.props.schema.help?a.createElement(l.FormHelperText,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}const ee={fullWidth:{width:"100%"},leWidth:{width:620,marginBottom:10},certWidth:{width:200,marginRight:10}};class Ct extends d{async componentDidMount(){var r;super.componentDidMount();const e=await this.props.oContext.socket.getCertificates(),t=[],s=[],n=[];let i=[];const o=await this.props.oContext.socket.getObject("system.certificates");(r=o==null?void 0:o.native)!=null&&r.collections?i=Object.keys(o.native.collections):i=null,e.forEach(h=>{h.type==="public"?t.push({label:h.name,value:h.name}):h.type==="private"?s.push({label:h.name,value:h.name}):h.type==="chained"?n.push({label:h.name,value:h.name}):(t.push({label:h.name,value:h.name}),s.push({label:h.name,value:h.name}),n.push({label:h.name,value:h.name}))}),t.unshift({label:p.I18n.t(d.NONE_LABEL),value:d.NONE_VALUE}),s.unshift({label:p.I18n.t(d.NONE_LABEL),value:d.NONE_VALUE}),n.unshift({label:p.I18n.t(d.NONE_LABEL),value:d.NONE_VALUE}),this.setState({certsPublicOptions:t,certsChainOptions:n,certsPrivateOptions:s,collectionsOptions:i})}renderItem(e,t){var m,f,g,D,b,C,k;if(!this.state.certsPublicOptions||!this.state.certsPrivateOptions||!this.state.certsChainOptions)return null;const s=(d.getValue(this.props.data,this.props.schema.leCollectionName||"leCollection")||"false").toString(),n=d.getValue(this.props.data,this.props.schema.certPublicName||"certPublic"),i=d.getValue(this.props.data,this.props.schema.certPrivateName||"certPrivate"),o=d.getValue(this.props.data,this.props.schema.certChainedName||"certChained"),r=(m=this.state.certsPublicOptions)==null?void 0:m.find(x=>x.value===n),h=(f=this.state.certsPrivateOptions)==null?void 0:f.find(x=>x.value===i),c=(g=this.state.certsChainOptions)==null?void 0:g.find(x=>x.value===o);return a.createElement("div",{style:ee.fullWidth},this.state.collectionsOptions?a.createElement(l.FormControl,{style:ee.leWidth,variant:"standard"},a.createElement(l.InputLabel,{shrink:!0},"Let's encrypt"),a.createElement(l.Select,{variant:"standard",error:!!e,displayEmpty:!0,disabled:!!t,value:s,onChange:x=>this.onChange(this.props.schema.leCollectionName||"leCollection",x.target.value==="false"?!1:x.target.value==="true"?!0:x.target.value)},a.createElement(l.MenuItem,{key:"_false",value:"false",style:{fontWeight:"bold"}},p.I18n.t("ra_Do not use let's encrypt")),a.createElement(l.MenuItem,{key:"_true",value:"true",style:{fontWeight:"bold"}},p.I18n.t("ra_Use all available let's encrypt certificates")),(D=this.state.collectionsOptions)==null?void 0:D.map(x=>a.createElement(l.MenuItem,{key:x,value:x},x)))):null,this.state.collectionsOptions?a.createElement("br",null):null,this.state.collectionsOptions&&s!=="false"?a.createElement("div",null,p.I18n.t("ra_Fallback custom certificates")):null,a.createElement(l.FormControl,{style:ee.certWidth,variant:"standard"},a.createElement(l.InputLabel,{shrink:!0},p.I18n.t("ra_Public certificate")),a.createElement(l.Select,{variant:"standard",error:!!e,displayEmpty:!0,disabled:!!t,value:n||"",renderValue:()=>this.getText(r==null?void 0:r.label,!0),onChange:x=>this.onChange(this.props.schema.certPublicName||"certPublic",x.target.value)},(b=this.state.certsPublicOptions)==null?void 0:b.map((x,y)=>a.createElement(l.MenuItem,{key:`${x.value}_${y}`,value:x.value,style:x.value===d.NONE_VALUE?{opacity:.5}:{}},this.getText(x.label,!0))))),a.createElement(l.FormControl,{style:ee.certWidth,variant:"standard"},a.createElement(l.InputLabel,{shrink:!0},p.I18n.t("ra_Private certificate")),a.createElement(l.Select,{variant:"standard",error:!!e,displayEmpty:!0,disabled:!!t,value:i||"",renderValue:()=>this.getText(h==null?void 0:h.label,!0),onChange:x=>this.onChange(this.props.schema.certPrivateName||"certPrivate",x.target.value)},(C=this.state.certsPrivateOptions)==null?void 0:C.map((x,y)=>a.createElement(l.MenuItem,{key:`${x.value}_${y}`,value:x.value,style:x.value===d.NONE_VALUE?{opacity:.5}:{}},this.getText(x.label,!0))))),a.createElement(l.FormControl,{style:ee.certWidth,variant:"standard"},a.createElement(l.InputLabel,{shrink:!0},p.I18n.t("ra_Chained certificate")),a.createElement(l.Select,{variant:"standard",error:!!e,displayEmpty:!0,disabled:!!t,value:o||"",renderValue:()=>this.getText(c==null?void 0:c.label,!0),onChange:x=>this.onChange(this.props.schema.certChainedName||"certChained",x.target.value)},(k=this.state.certsChainOptions)==null?void 0:k.map((x,y)=>a.createElement(l.MenuItem,{key:`${x.value}_${y}`,value:x.value,style:x.value===d.NONE_VALUE?{opacity:.5}:{}},this.getText(x.label,!0))))))}}class xt extends d{async componentDidMount(){var s;super.componentDidMount();let e;const t=await this.props.oContext.socket.getObject("system.certificates");(s=t==null?void 0:t.native)!=null&&s.collections?e=Object.keys(t.native.collections):e=[],this.setState({collectionsOptions:e})}renderItem(e,t){var n;if(!this.state.collectionsOptions)return null;const s=(d.getValue(this.props.data,this.props.schema.leCollectionName||"leCollection")||"false").toString();return a.createElement(l.FormControl,{style:{width:"100%"},variant:"standard"},this.props.schema.label?a.createElement(l.InputLabel,{shrink:!0},this.getText(this.props.schema.label)):null,a.createElement(l.Select,{variant:"standard",error:!!e,displayEmpty:!0,disabled:!!t,value:s,onChange:i=>this.onChange(this.props.schema.leCollectionName||"leCollection",i.target.value==="false"?!1:i.target.value==="true"?!0:i.target.value)},a.createElement(l.MenuItem,{key:"_false",value:"false",style:{fontWeight:"bold"}},p.I18n.t("ra_Do not use let's encrypt")),a.createElement(l.MenuItem,{key:"_true",value:"true",style:{fontWeight:"bold"}},p.I18n.t("ra_Use all available let's encrypt certificates")),(n=this.state.collectionsOptions)==null?void 0:n.map(i=>a.createElement(l.MenuItem,{key:i,value:i},i))),this.props.schema.help?a.createElement(l.FormHelperText,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}class Et extends d{async componentDidMount(){super.componentDidMount();const e=await this.props.oContext.socket.getCurrentInstance();this.setState({requesting:!0},async()=>{const t=await this.props.oContext.socket.sendTo(e,"checkDocker",null);this.setState({requesting:!1,version:(t==null?void 0:t.version)||"",errorDocker:t?t.daemonRunning?"":p.I18n.t("ra_Docker is not installed or not running"):p.I18n.t("ra_No response from admin")})})}renderItem(e,t){const s=d.getValue(this.props.data,this.props.attr);return this.state.requesting?a.createElement(l.CircularProgress,null):this.state.errorDocker&&!s?a.createElement(l.FormHelperText,{style:{color:"orange"}},p.I18n.t("ra_Docker is not available"),": ",p.I18n.t(`ra_${this.state.errorDocker}`).replace(/^ra_/,"")):a.createElement(l.FormControl,{style:{width:"100%"},variant:"standard"},a.createElement(l.FormControlLabel,{onClick:n=>{if(n.preventDefault(),n.stopPropagation(),!t){const i=this.onChange(this.props.attr,!s);i instanceof Promise&&i.catch(o=>console.error(`Cannot set value: ${o}`))}},control:a.createElement(l.Checkbox,{checked:!!s,onChange:n=>{this.onChange(this.props.attr,n.target.checked)},disabled:t||!!this.state.errorDocker&&!s}),label:this.getText(this.props.schema.label)}),this.props.schema.hideVersion?null:a.createElement(l.FormHelperText,null,this.state.errorDocker?this.state.errorDocker:this.state.version),this.props.schema.help?a.createElement(l.FormHelperText,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}const j={fullWidth:{width:"100%"},licLabel:{fontWeight:"bold",minWidth:100,marginRight:10,textTransform:"capitalize",display:"inline-block"},errorTitle:u=>({color:u.palette.mode==="dark"?"#e39191":"#b62020"}),okTitle:u=>({color:u.palette.mode==="dark"?"#6fd56f":"#007c00"}),errorText:u=>({color:u.palette.mode==="dark"?"#e39191":"#b62020",mb:"30px"})};class K extends d{componentDidMount(){super.componentDidMount(),this.setState({_error:"",running:!1,showLicenseData:null,foundSuitableLicense:!1,licenseOfflineCheck:!1,result:null,allLicenses:null,askForUpdate:!1,showLinkToProfile:!1})}renderErrorDialog(){if(this.state._error&&!this.state.showLicenseData){let e=this.state._error;return this.state.allLicenses&&(e=[a.createElement("div",{key:"error"},e)],e.push(a.createElement(l.Button,{key:"button",variant:"contained",onClick:()=>window.open("https://iobroker.net/www/account/licenses","_blank")},p.I18n.t("iobroker.net"))),this.state.allLicenses.length?e.push(a.createElement(l.TableContainer,{key:"table"},a.createElement(l.Table,{size:"small"},a.createElement(l.TableHead,null,a.createElement(l.TableRow,null,a.createElement(l.TableCell,null,p.I18n.t("ra_Product")),a.createElement(l.TableCell,null,p.I18n.t("ra_Version")),a.createElement(l.TableCell,null,"UUID"),a.createElement(l.TableCell,null,p.I18n.t("ra_ValidTill")),a.createElement(l.TableCell,null,p.I18n.t("ra_Commercial")),a.createElement(l.TableCell,null,"ID"))),a.createElement(l.TableBody,null,this.state.allLicenses.map(t=>a.createElement(l.TableRow,{key:t.id},a.createElement(l.TableCell,{sx:t.validName?null:j.errorText},t.license.product),a.createElement(l.TableCell,{sx:t.validVersion?null:j.errorText},t.license.version),a.createElement(l.TableCell,{sx:t.validUuid?null:j.errorText},t.license.uuid||"--"),a.createElement(l.TableCell,{sx:t.validTill?null:j.errorText},t.license.validTill&&t.license.validTill!=="0000-00-00 00:00:00"?new Date(t.license.validTill).toLocaleDateString():"--"),a.createElement(l.TableCell,null,t.license.invoice!=="free"?t.license.invoice==="MANUALLY_CREATED"?"✓":t.license.invoice:"-"),a.createElement(l.TableCell,null,t.id))))))):(e.push(a.createElement("div",{key:"text1"},p.I18n.t("ra_No one license found in license manager"))),e.push(a.createElement("div",{key:"text2"},p.I18n.t("ra_Please create license"))))),a.createElement(l.Dialog,{open:!0,maxWidth:"xl",fullWidth:this.props.fullWidth!==void 0?this.props.fullWidth:!0,onClick:()=>this.setState({_error:"",allLicenses:null})},a.createElement(l.DialogTitle,null,p.I18n.t("ra_Error")),a.createElement(l.DialogContent,null,a.createElement(l.DialogContentText,null,e)),a.createElement(l.DialogActions,null,a.createElement(l.Button,{variant:"contained",onClick:()=>this.setState({_error:"",allLicenses:null}),color:"primary",autoFocus:!0,startIcon:a.createElement(v.Check,null)},p.I18n.t("ra_Ok"))))}return null}renderMessageDialog(){if(this.state.showLicenseData){const e=[],t=this.state.showLicenseData;return Object.keys(t).forEach(s=>{if(!(t[s]===null||t[s]===void 0))if(typeof t[s]=="object"){const n=t[s];Object.keys(n).forEach(i=>{n[i]!==null&&n[i]!==void 0&&(typeof n[i]=="object"?e.push(a.createElement("div",{key:i},a.createElement("div",{style:j.licLabel},i,":"),JSON.stringify(n[i],null,2))):e.push(a.createElement("div",{key:i},a.createElement("div",{style:j.licLabel},s," -",i,":"),n[i].toString())))})}else e.push(a.createElement("div",{key:s},a.createElement("div",{style:j.licLabel},s.replace(/_/g," "),":"),t[s].toString()))}),e.push(a.createElement("div",{key:"checked"},a.createElement("div",{style:j.licLabel},p.I18n.t("ra_Checked"),":"),this.state.licenseOfflineCheck?p.I18n.t("ra_locally"):p.I18n.t("ra_via internet"))),a.createElement(l.Dialog,{open:!0,onClose:()=>this.setState({showLicenseData:null})},a.createElement(l.DialogTitle,null,a.createElement(l.Box,{component:"span",sx:this.state.result?j.okTitle:j.errorTitle},p.I18n.t("ra_License %s",this.state.result?"OK":"INVALID"))),a.createElement(l.DialogContent,null,this.state.showLinkToProfile?a.createElement(l.Button,{variant:"contained",onClick:()=>window.open("https://iobroker.net/www/account/licenses","_blank")},"https://iobroker.net"):null,this.state._error?a.createElement(l.Box,{component:"div",sx:j.errorText},this.state._error):null,e),a.createElement(l.DialogActions,null,a.createElement(l.Button,{onClick:()=>this.setState({showLicenseData:null,_error:""}),color:"primary",variant:"contained"},p.I18n.t("ra_Close"))))}return null}static parseJwt(e){const s=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(atob(s).split("").map(i=>`%${`00${i.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""));try{return JSON.parse(n)}catch{return null}}static isVersionValid(e,t,s,n){if(!t||!e)return!0;let i=!0;const[o]=e.split(".");return t.startsWith(">=")?i=parseInt(o,10)>=parseInt(t.substring(2,10)):t.startsWith("<=")?i=parseInt(o,10)<=parseInt(t.substring(2,10)):t.startsWith(">")?i=parseInt(o,10)>parseInt(t.substring(1,10)):t.startsWith("<")?i=parseInt(o,10)<parseInt(t.substring(1,10)):t.startsWith("=")?i=parseInt(o,10)===parseInt(t.substring(1,10)):t.startsWith("==")?i=parseInt(o,10)===parseInt(t.substring(2,10)):t.startsWith("===")&&(i=parseInt(o,10)===parseInt(t.substring(3,10))),!0}async findInLicenseManager(e){var n,i,o,r;const t=await this.props.oContext.socket.getObject("system.licenses"),s=[];if((i=(n=t==null?void 0:t.native)==null?void 0:n.licenses)!=null&&i.length){let h=null;const c=Date.now();let m;if(this.props.schema.uuid){const g=await this.props.oContext.socket.getObject("system.meta.uuid");m=(o=g==null?void 0:g.native)==null?void 0:o.uuid}let f;if(this.props.schema.version){const g=await this.props.oContext.socket.getObject(`system.adapter.${e}`);f=(r=g==null?void 0:g.common)==null?void 0:r.version}t.native.licenses.forEach(g=>{const D=!g.validTill||g.validTill==="0000-00-00 00:00:00"||new Date(g.validTill).getTime()>c,b=(g.product||"").split("."),C=b[1]===e||e==="vis-2"&&b[1]==="vis",k=!m||!g.uuid||g.uuid===m,x=K.isVersionValid(f,g.version,g.invoice,e);(!h||g.invoice!=="free")&&D&&C&&k&&x&&(h=g),s.push({id:g.id,validName:C,validUuid:k,validVersion:x,validTill:D,license:g})}),h&&(s.find(g=>g.id===h.id).used=!0)}return s}async checkLicense(e,t){var r,h,c;let s;if(this.props.schema.uuid){const m=await this.props.oContext.socket.getObject("system.meta.uuid");s=(r=m==null?void 0:m.native)==null?void 0:r.uuid}let n;if(this.props.schema.version){const m=await this.props.oContext.socket.getObject(`system.adapter.${t}`);n=(h=m==null?void 0:m.common)==null?void 0:h.version}const i=new AbortController;let o=setTimeout(()=>{o=null,i.abort()},5e3);try{const m=await window.fetch("https://iobroker.net/api/v1/public/cert/",{method:"POST",body:JSON.stringify({json:e,uuid:s}),headers:{"Content-Type":"text/plain"},signal:i.signal});o&&clearTimeout(o);const f=await m.text();let g;try{g=JSON.parse(f)}catch{}if(g!=null&&g.error)try{const D=K.parseJwt(e),b=p.I18n.t(`ra_${D.error||g.error||"Unknown error"}`).replace(/^ra_/,"");return this.setState({_error:b,licenseOfflineCheck:!1,showLicenseData:D,result:!1,running:!1})}catch{return console.log("Cannot parse license"),this.setState({_error:g.error,result:!1,running:!1})}else{let D=null;try{D=K.parseJwt(e)}catch{}if(g){const b=g.validTill||g.valid_till;if(b&&b!=="0000-00-00 00:00:00"&&new Date(b).getTime()<Date.now())return this.setState({_error:p.I18n.t("ra_License expired on %s",new Date(b).toLocaleString()),licenseOfflineCheck:!1,showLicenseData:D,result:!1,running:!1});const C=(g.name||"").split(".");return C[1]===t||C[1]==="vis"&&t==="vis-2"?s&&!g.uuid&&t==="vis-2"?this.setState({_error:p.I18n.t("ra_License must be converted",g.uuid),showLinkToProfile:!0,licenseOfflineCheck:!1,showLicenseData:D,result:!1,running:!1}):s&&g.uuid&&g.uuid!==s?this.setState({_error:p.I18n.t('ra_Serial number (UUID) "%s" in license is for other device.',g.uuid),licenseOfflineCheck:!1,showLicenseData:D,result:!1,running:!1}):K.isVersionValid(n,g.version,g.invoice,t)?this.setState({licenseOfflineCheck:!1,showLicenseData:D,result:!0,running:!1}):this.setState({_error:p.I18n.t("ra_License is for version %s, but required version is %s",g.version,this.props.schema.version),licenseOfflineCheck:!1,showLicenseData:D,result:!1,running:!1}):this.setState({_error:p.I18n.t('ra_License for other product "%s"',g.name),licenseOfflineCheck:!1,showLicenseData:D,result:!1,running:!1})}throw new Error("ra_Invalid answer from server")}}catch(m){if(((c=m==null?void 0:m.response)==null?void 0:c.status)===404)return this.setState({_error:p.I18n.t("ra_License does not exist"),result:!1,running:!1});try{const f=K.parseJwt(e),g=(f.name||"").split(".");return f.valid_till&&f.valid_till!=="0000-00-00 00:00:00"&&new Date(f.valid_till).getTime()<Date.now()?this.setState({_error:p.I18n.t("ra_License expired on %s",new Date(f.valid_till).toLocaleString()),showLicenseData:f,licenseOfflineCheck:!0,running:!1,result:!1}):g[1]===t?s&&f.uuid&&f.uuid!==s?this.setState({_error:p.I18n.t('ra_Serial number (UUID) "%s" in license is for other device.',f.uuid),showLicenseData:f,licenseOfflineCheck:!0,result:!1,running:!1}):K.isVersionValid(n,f.version,f.invoice,t)?this.setState({running:!1,result:!0,licenseOfflineCheck:!0,showLicenseData:f}):this.setState({_error:p.I18n.t("ra_License is for version %s, but required version is %s",f.version,this.props.schema.version),licenseOfflineCheck:!0,showLicenseData:f,result:!1,running:!1}):this.setState({_error:p.I18n.t('ra_License for other product "%s"',f.name),licenseOfflineCheck:!0,showLicenseData:f,result:!1,running:!1})}catch{return this.setState({_error:p.I18n.t("ra_Cannot decode license"),result:!1,licenseOfflineCheck:!0,running:!1})}}}renderAskForUpdate(){return this.state.askForUpdate?a.createElement(p.DialogConfirm,{text:p.I18n.t("ra_License not found in license manager. Do you want to read licenses from iobroker.net?"),ok:p.I18n.t("ra_Yes"),onClose:async e=>{if(e){this.setState({askForUpdate:!1});try{await this.props.oContext.socket.updateLicenses(null,null)}catch(t){window.alert(p.I18n.t("ra_Cannot read licenses: %s",t));return}await this._onClick(!0)}else this.setState({askForUpdate:!1,running:!1})}}):null}async _onClick(e){const t=this.props.oContext.adapterName==="vis-2"?"vis":this.props.oContext.adapterName;this.setState({running:!0});let s,n;if(this.props.data.useLicenseManager){if(n=await this.findInLicenseManager(t),s=n.find(i=>i.used),s&&(s=s.license.json),!s&&!e){this.setState({askForUpdate:!0});return}}else s=this.props.data.license;s?await this.checkLicense(s,t):this.props.data.useLicenseManager?this.setState({_error:p.I18n.t("ra_Suitable license not found in license manager"),result:!1,running:!1,allLicenses:n}):this.setState({_error:p.I18n.t("ra_Please enter the license"),result:!1,running:!1})}renderItem(){return a.createElement("div",{style:j.fullWidth},a.createElement(l.Button,{variant:this.props.schema.variant||"outlined",color:this.props.schema.color||"primary",style:j.fullWidth,disabled:!this.props.data.license&&!this.props.data.useLicenseManager||this.state.running,startIcon:a.createElement(v.Send,null),onClick:()=>this._onClick()},this.state.running?a.createElement(l.CircularProgress,{size:20,style:{marginRight:8}}):null,this.getText(this.props.schema.label||"ra_Check license",this.props.schema.noTranslation)),this.renderMessageDialog(),this.renderErrorDialog(),this.renderAskForUpdate())}}class Tt extends d{renderItem(e,t){const s=d.getValue(this.props.data,this.props.attr),n=Array.isArray(s);return a.createElement(l.FormControl,{style:{width:"100%"},variant:"standard"},a.createElement(l.FormControlLabel,{onClick:i=>{if(i.preventDefault(),i.stopPropagation(),!t){const o=this.onChange(this.props.attr,!s);o instanceof Promise&&o.catch(r=>console.error(`Cannot set value: ${r}`))}},control:a.createElement(l.Checkbox,{indeterminate:n,checked:!!s,onChange:i=>{let o;n?o=this.onChange(this.props.attr,!0):o=this.onChange(this.props.attr,i.target.checked),o instanceof Promise&&o.catch(r=>console.error(`Cannot set value: ${r}`))},disabled:t||this.props.schema.readOnly}),label:this.getText(this.props.schema.label)}),a.createElement(l.FormHelperText,{style:{color:"red"}},e?this.props.schema.validatorErrorText?p.I18n.t(this.props.schema.validatorErrorText):p.I18n.t("ra_Error"):null),this.props.schema.help?a.createElement(l.FormHelperText,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}const wt={standard:l.Input,filled:et,outlined:l.OutlinedInput},St=u=>{const e=u.palette.mode==="light",t=e?"rgba(0, 0, 0, 0.42)":"rgba(255, 255, 255, 0.7)";return{root:{},inputRoot:{display:"inline-flex",flexWrap:"wrap",flex:1,marginTop:0,minWidth:70,"&.mui-variant-outlined,&.mui-variant-filled":{boxSizing:"border-box"},"&.mui-variant-outlined":{paddingTop:"14px"},"&.mui-variant-filled":{paddingTop:"28px"}},input:{display:"inline-block",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",appearance:"none",WebkitTapHighlightColor:"rgba(0,0,0,0)",float:"left",flex:1},chipContainer:{display:"flex",flexFlow:"row wrap",alignItems:"center",cursor:"text",marginBottom:"-2px",minHeight:40},outlined:{"& input":{height:16,paddingTop:"4px",paddingBottom:"12px",marginTop:"4px",marginBottom:"4px"}},standard:{marginTop:"18px"},filled:{"& input":{height:22,marginBottom:"4px",marginTop:"4px",paddingTop:0},"$marginDense & input":{height:26}},labeled:{},label:{top:4,"&$outlined&:not($labelShrink)":{top:2,"$marginDense &":{top:5}},"&$filled&:not($labelShrink)":{top:15,"$marginDense &":{top:20}}},labelShrink:{top:0},helperText:{marginBottom:-20},focused:{},disabled:{},underline:{"&:after":{borderBottom:`2px solid ${u.palette.primary[e?"dark":"light"]}`,left:0,bottom:0,content:'""',position:"absolute",right:0,transform:"scaleX(0)",transition:u.transitions.create("transform",{duration:u.transitions.duration.shorter,easing:u.transitions.easing.easeOut}),pointerEvents:"none"},"&$focused:after":{transform:"scaleX(1)"},"&$error:after":{borderBottomColor:u.palette.error.main,transform:"scaleX(1)"},"&:before":{borderBottom:`1px solid ${t}`,left:0,bottom:0,content:'"\\00a0"',position:"absolute",right:0,transition:u.transitions.create("border-bottom-color",{duration:u.transitions.duration.shorter}),pointerEvents:"none"},"&:hover:not($disabled):not($focused):not($error):before":{borderBottom:`2px solid ${u.palette.text.primary}`,"@media (hover: none)":{borderBottom:`1px solid ${t}`}},"&$disabled:before":{borderBottomStyle:"dotted"}},error:{"&:after":{backgroundColor:u.palette.error.main,transform:"scaleX(1)"}},chip:{margin:"0 8px 8px 0",float:"left"},marginDense:{}}},le={BACKSPACE:8,DELETE:46,LEFT_ARROW:37,RIGHT_ARROW:39},It=({value:u,isFocused:e,isDisabled:t,isReadOnly:s,handleClick:n,handleDelete:i,style:o},r)=>a.createElement(l.Chip,{key:r,style:{...o,pointerEvents:t||s?"none":void 0,backgroundColor:e?tt[300]:void 0},onClick:n,onDelete:i,label:u});class kt extends a.Component{labelRef;labelNode=null;input;newChipKeyCodes;newChipKeys;actualInput=null;inputBlurTimeout=null;_keyPressed;_preventChipCreation;styles={};styleTheme=null;constructor(e){super(e),this.state={chips:e.defaultValue||[],focusedChip:null,inputValue:"",isFocused:!1,chipsUpdated:!1,prevPropsValue:[],variant:this.props.variant||"standard"},this.newChipKeyCodes=e.newChipKeyCodes||[13],this.newChipKeys=e.newChipKeys||["Enter"],this.labelRef=a.createRef(),this.input=a.createRef()}componentDidMount(){this.state.variant==="outlined"&&(this.labelNode=Ze.findDOMNode(this.labelRef.current),this.forceUpdate())}componentWillUnmount(){this.inputBlurTimeout&&clearTimeout(this.inputBlurTimeout)}static getDerivedStateFromProps(e,t){let s=null;return e.value&&e.value.length!==t.prevPropsValue.length&&(s={prevPropsValue:e.value},e.clearInputValueOnChange&&(s.inputValue="")),e.clearInputValueOnChange&&e.value&&e.value.length!==t.prevPropsValue.length&&(s={prevPropsValue:e.value,inputValue:""}),e.disabled&&(s={...s,focusedChip:null}),!t.chipsUpdated&&e.defaultValue&&(s={...s,chips:e.defaultValue}),s}focus=()=>{var e;(e=this.actualInput)==null||e.focus(),this.state.focusedChip&&this.setState({focusedChip:null})};handleInputBlur=e=>{this.props.onBlur&&this.props.onBlur(e),this.setState({isFocused:!1}),this.state.focusedChip&&this.setState({focusedChip:null});const t=e.target.value;let s;switch(this.props.blurBehavior||"clear"){case"add-or-clear":s={clearInputOnFail:!0};case"add":if(this.props.delayBeforeAdd){const n=(this.props.value||this.state.chips).length;this.inputBlurTimeout=setTimeout(()=>{const i=(this.props.value||this.state.chips).length;n===i?this.handleAddChip(t,s):this.clearInput()},150)}else this.handleAddChip(t,s);break;case"clear":this.clearInput();break}};handleInputFocus=e=>{var t,s;this.setState({isFocused:!0}),(s=(t=this.props).onFocus)==null||s.call(t,e)};handleKeyDown=e=>{const{focusedChip:t}=this.state;if(this._keyPressed=!1,this._preventChipCreation=!1,this.props.onKeyDown&&(this.props.onKeyDown(e),e.isDefaultPrevented()))return;const s=this.props.value||this.state.chips;if(this.newChipKeyCodes.includes(e.keyCode)||this.newChipKeys.includes(e.key)){this.handleAddChip(e.target.value)!==!1&&e.preventDefault();return}switch(e.keyCode){case le.BACKSPACE:e.target.value===""&&(t?(this.handleDeleteChip(s[t],t),t&&this.setState({focusedChip:t-1})):this.setState({focusedChip:s.length-1}));break;case le.DELETE:e.target.value===""&&t&&(this.handleDeleteChip(s[t],t),t<=s.length-1&&this.setState({focusedChip:t}));break;case le.LEFT_ARROW:t===null&&e.target.value===""&&s.length?this.setState({focusedChip:s.length-1}):t!==null&&t>0&&this.setState({focusedChip:t-1});break;case le.RIGHT_ARROW:t!==null&&t<s.length-1?this.setState({focusedChip:t+1}):this.setState({focusedChip:null});break;default:this.setState({focusedChip:null});break}};handleKeyUp=e=>{!this._preventChipCreation&&(this.newChipKeyCodes.includes(e.keyCode)||this.newChipKeys.includes(e.key))&&this._keyPressed?this.clearInput():this.updateInput(e.target.value),this.props.onKeyUp&&this.props.onKeyUp(e)};handleUpdateInput=e=>{(this.props.inputValue===null||this.props.inputValue===void 0)&&this.updateInput(e.target.value),this.props.onUpdateInput&&this.props.onUpdateInput(e)};handleAddChip(e,t){if(this.props.onBeforeAdd&&!this.props.onBeforeAdd(e))return this._preventChipCreation=!0,t&&t.clearInputOnFail&&this.clearInput(),!1;this.clearInput();const s=this.props.value||this.state.chips;return e.trim().length?((this.props.allowDuplicates||!s.includes(e))&&(this.props.value&&this.props.onAdd?this.props.onAdd(e):this.updateChips([...this.state.chips,e])),!0):!1}handleDeleteChip(e,t){if(this.props.value)this.props.onDelete&&this.props.onDelete(e,t);else{const s=this.state.chips.slice();if(s.splice(t,1)){let i=this.state.focusedChip;this.state.focusedChip===t?i=null:this.state.focusedChip!==null&&this.state.focusedChip>t&&(i=this.state.focusedChip-1),this.updateChips(s,{focusedChip:i})}}}updateChips(e,t={}){this.setState({chips:e,chipsUpdated:!0,...t}),this.props.onChange&&this.props.onChange(e)}clearInput(){this.updateInput("")}updateInput(e){this.setState({inputValue:e})}setActualInputRef=e=>{this.actualInput=e,this.props.inputRef&&this.props.inputRef(e)};render(){const{alwaysShowPlaceholder:e,chipRenderer:t=It,className:s,disabled:n,disableUnderline:i,error:o,FormHelperTextProps:r,fullWidth:h,fullWidthInput:c,helperText:m,id:f,InputProps:g={},InputLabelProps:D={},inputValue:b,label:C,placeholder:k,readOnly:x,required:y,rootRef:I,value:_,margin:O}=this.props,F=this.state.variant;this.styleTheme!==this.props.theme.palette.mode&&(this.styleTheme=this.props.theme.palette.mode,this.styles=p.Utils.getStyle(this.props.theme,St));let N=_||this.state.chips||[];Array.isArray(N)||(N=(N||"").toString().split(/[,\s]+/).map(J=>J.trim()));const L=b??this.state.inputValue,A=(this.props.value||L).length||L.length,V=typeof D.shrink=="boolean"?D.shrink:C!==null&&(A||this.state.isFocused||N.length),M=N.map((J,z)=>t({value:J,isDisabled:!!n,isReadOnly:!!x,isFocused:this.state.focusedChip===z,handleClick:()=>this.setState({focusedChip:z}),handleDelete:()=>this.handleDeleteChip(J,z),style:this.styles.chip},z.toString())),B={};F==="outlined"&&(B.notched=!!V,B.labelWidth=V&&this.labelNode&&this.labelNode.offsetWidth||0),F!=="standard"?B.startAdornment=M:g.disableUnderline=!0;const Y=wt[F];return a.createElement(l.FormControl,{ref:I,fullWidth:h,className:s,sx:{...this.styles.root,...O==="dense"?this.styles.marginDense:{}},error:o,required:N.length>0?void 0:y,onClick:this.focus,disabled:n,variant:F,component:"div",margin:O},C&&a.createElement(l.InputLabel,{htmlFor:f,sx:{"&.MuiInputLabel-root":this.styles.label,"&.MuiInputLabel-shrink":this.styles.labelShrink},shrink:!!V,focused:this.state.isFocused,variant:F,ref:this.labelRef,required:y,component:"label",...D},C),a.createElement(l.Box,{component:"div",id:"input-chip-container",sx:{...this.styles[F],...this.styles.chipContainer,...this.state.isFocused?this.styles.focused:void 0,...!i&&F==="standard"?this.styles.underline:void 0,...n?this.styles.disabled:void 0,...C?this.styles.labeled:void 0,...o?this.styles.error:void 0}},F==="standard"&&M,a.createElement(Y,{ref:this.input,className:`mui-variant-${this.styles[F]} ${C?"mui-chip-with-label":"mui-chip-no-label"}`,sx:{"&.MuiInputBase-input":{...this.styles.input,...this.styles[F]},"&.MuiInputBase-root":{...this.styles.inputRoot}},id:f,value:L,onChange:this.handleUpdateInput,onKeyDown:this.handleKeyDown,onKeyUp:this.handleKeyUp,onFocus:this.handleInputFocus,onBlur:this.handleInputBlur,inputRef:this.setActualInputRef,disabled:n,fullWidth:c,placeholder:!A&&(V||C===null||C===void 0)||e?k:void 0,readOnly:x,...g,...B})),m&&a.createElement(l.FormHelperText,{...r,className:r==null?void 0:r.className,style:this.styles.helperText},m))}}class De extends d{componentDidMount(){super.componentDidMount();const{data:e,attr:t}=this.props,s=d.getValue(e,t);if(this.props.schema.delimiter&&typeof s=="string"){const n=s.split(this.props.schema.delimiter).map(i=>i.trim()).filter(i=>i);this.setState({value:n})}else this.setState({value:s||[]})}renderItem(e,t){const{attr:s,schema:n}=this.props,{value:i}=this.state;return a.createElement(l.FormControl,{fullWidth:!0,variant:"standard"},a.createElement(kt,{value:i,disabled:!!t,label:this.getText(n.label),error:!!e,onAdd:o=>{const r=JSON.parse(JSON.stringify(i));r.push(o),this.setState({value:r},()=>{let h;this.props.schema.delimiter?h=this.onChange(s,r.join(`${this.props.schema.delimiter} `)):h=this.onChange(s,r),h instanceof Promise&&h.catch(c=>console.error(c))})},theme:this.props.oContext.theme,onDelete:(o,r)=>{const h=JSON.parse(JSON.stringify(i));h.splice(r,1),this.setState({value:h},()=>{let c;this.props.schema.delimiter?c=this.onChange(s,h.join(`${this.props.schema.delimiter} `)):c=this.onChange(s,h),c instanceof Promise&&c.catch(m=>console.error(m))})}}),a.createElement(l.FormHelperText,null,p.I18n.t("ra_Press ENTER Key to add new item")),this.props.schema.help?a.createElement(l.FormHelperText,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}class Dt extends d{renderColorDialog(){return!!this.state.showColorDialog&&a.createElement(l.Dialog,{onClose:()=>this.setState({showColorDialog:!1}),open:this.state.showColorDialog},a.createElement(st,{color:this.state.colorDialogValue,onChange:e=>this.setState({colorDialogValue:e.hex},()=>this.onChange(this.props.attr,this.state.colorDialogValue))}))}renderItem(e,t){const s=d.getValue(this.props.data,this.props.attr);let n=p.Utils.isUseBright(s,null);return n===null&&(n=void 0),a.createElement(a.Fragment,null,this.renderColorDialog(),a.createElement(l.TextField,{variant:"standard",disabled:!!t,style:{minWidth:100,width:"calc(100% - 8px)"},label:this.getText(this.props.schema.label),value:s||"",onClick:()=>!this.props.schema.readOnly&&this.setState({showColorDialog:!0,colorDialogValue:s||""}),onChange:i=>{const o=i.target.value,r=this.onChange(this.props.attr,o);r instanceof Promise&&r.catch(h=>console.error(`Cannot set value: ${h}`))},slotProps:{htmlInput:{style:{backgroundColor:s,color:n?"#FFF":"#000"},readOnly:this.props.schema.readOnly||!1},input:{endAdornment:!this.props.schema.readOnly&&s&&!this.props.schema.noClearButton?a.createElement(l.IconButton,{tabIndex:-1,size:"small",onClick:i=>{i.stopPropagation();const o=this.onChange(this.props.attr,"");o instanceof Promise&&o.catch(r=>console.error(`Cannot set value: ${r}`))}},a.createElement(v.Close,null)):void 0},inputLabel:{shrink:!0}}}))}}const be={width:{width:"calc(100% - 85px)"},width50:{width:120,marginRight:5}};class _t extends d{componentDidMount(){super.componentDidMount();const e=d.getValue(this.props.data,this.props.attr);this.setState({value:e});const t={};this.props.schema.useSystemName&&(t.useSystem=!!d.getValue(this.props.data,this.props.schema.useSystemName)),this.props.schema.longitudeName&&this.props.schema.latitudeName?(t.longitude=d.getValue(this.props.data,this.props.schema.longitudeName),t.latitude=d.getValue(this.props.data,this.props.schema.latitudeName),!t.longitude&&!t.latitude&&this.props.schema.autoInit&&setTimeout(()=>this.getCoordinates(),300)):!d.getValue(this.props.data,this.props.attr)&&this.props.schema.autoInit&&setTimeout(()=>this.getCoordinates(),300),Object.keys(t).length&&setTimeout(()=>this.setState(t),50)}async getSystemCoordinates(){const e=await this.props.oContext.socket.getCompactSystemConfig();if(e!=null&&e.common&&(e.common.longitude||e.common.latitude))if(window.alert(p.I18n.t("ra_Used system settings")),this.props.schema.longitudeName&&this.props.schema.latitudeName)this.setState({longitude:e.common.longitude,latitude:e.common.latitude},async()=>{await this.onChange(this.props.schema.longitudeName,e.common.longitude),await this.onChange(this.props.schema.latitudeName,e.common.latitude)});else{const t=e.common.latitude+(this.props.schema.divider||",")+e.common.longitude;this.setState({value:t},()=>{const s=this.onChange(this.props.attr,t);s instanceof Promise&&s.catch(n=>console.error(`Cannot set value: ${n}`))})}else window.alert(p.I18n.t("ra_Cannot determine position: System settings are empty and GPS detection is disabled in browser"))}getCoordinates(){navigator.geolocation?navigator.geolocation.getCurrentPosition(async e=>{if(e!=null&&e.coords)if(this.props.schema.longitudeName&&this.props.schema.latitudeName)this.setState({longitude:e.coords.longitude,latitude:e.coords.latitude},async()=>{await this.onChange(this.props.schema.longitudeName,e.coords.longitude||""),await this.onChange(this.props.schema.latitudeName,e.coords.latitude||"")});else{const t=e.coords.latitude+(this.props.schema.divider||",")+e.coords.longitude;this.setState({value:t},()=>{const s=this.onChange(this.props.attr,t);s instanceof Promise&&s.catch(n=>console.error(`Cannot set value: ${n}`))})}else await this.getSystemCoordinates()},async e=>{console.error(`Cannot determine coordinates from browser: ${e.message}`),await this.getSystemCoordinates()}):this.getSystemCoordinates().catch(e=>{console.error(`Cannot determine coordinates: ${e}`)})}renderItem(e,t){return a.createElement(a.Fragment,null,this.props.schema.useSystemName?a.createElement(l.FormControlLabel,{control:a.createElement(l.Checkbox,{checked:!!this.state.useSystem,onChange:s=>{const n=s.target.checked;n&&this.getSystemCoordinates().catch(i=>console.error(`Cannot determine coordinates: ${i}`)),this.setState({useSystem:n},()=>this.onChange(this.props.schema.useSystemName,n))}}),label:p.I18n.t("ra_Use system settings for position")}):null,this.props.schema.longitudeName&&this.props.schema.latitudeName?a.createElement(l.TextField,{variant:"standard",style:be.width50,value:this.state.longitude??"",error:!!e,disabled:this.state.useSystem||!!t,onChange:s=>{const n=s.target.value;this.setState({longitude:n},()=>{const i=this.onChange(this.props.schema.longitudeName,(n||"").trim());i instanceof Promise&&i.catch(o=>console.error(`Cannot set value: ${o}`))})},label:p.I18n.t("ra_Longitude")}):null,this.props.schema.longitudeName&&this.props.schema.latitudeName?a.createElement(l.TextField,{variant:"standard",style:be.width50,value:this.state.latitude??"",error:!!e,disabled:this.state.useSystem||!!t,onChange:s=>{const n=s.target.value;this.setState({latitude:n},()=>this.onChange(this.props.schema.latitudeName,(n||"").trim()))},label:p.I18n.t("ra_Latitude")}):null,!this.props.schema.longitudeName||!this.props.schema.latitudeName?a.createElement(l.TextField,{variant:"standard",style:be.width,value:this.state.value===null||this.state.value===void 0?"":this.state.value,error:!!e,disabled:!!t,slotProps:{htmlInput:{maxLength:this.props.schema.maxLength||this.props.schema.max||void 0,readOnly:this.state.useSystem}},onChange:s=>{const n=s.target.value;this.setState({value:n},()=>this.onChange(this.props.attr,(n||"").trim()))},placeholder:this.getText(this.props.schema.placeholder),label:this.getText(this.props.schema.label),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)}):null,this.state.useSystem?null:a.createElement(l.Fab,{size:"small",onClick:()=>this.getCoordinates(),title:p.I18n.t("ra_Take browser position"),style:{marginRight:4}},a.createElement(v.LocationOn,null)),this.state.useSystem?null:a.createElement(l.Fab,{size:"small",onClick:()=>this.getSystemCoordinates(),title:p.I18n.t("ra_Take position from system settings")},a.createElement(v.GpsFixed,null)))}}it({name:"iobroker_admin",shared:{"@iobroker/adapter-react-v5":{lib:()=>Qe,version:"*"},"@mui/icons-material":{lib:()=>Ye,version:"*"},"@iobroker/json-config":{lib:()=>lt,version:"*"}},remotes:[]});class se extends d{static runningLoads={};constructor(e){super(e),Object.assign(this.state,{Component:null,error:""})}async componentDidMount(){if(!this.props.schema.url){console.error("URL is empty. Cannot load custom component!"),this.setState({error:"URL is empty. Cannot load custom component!"});return}let e;this.props.schema.url.startsWith("http:")||this.props.schema.url.startsWith("https:")?e=this.props.schema.url:this.props.schema.url.startsWith("./")?e=`${window.location.protocol}//${window.location.host}${this.props.schema.url.replace(/^\./,"")}`:e=`${window.location.protocol}//${window.location.host}/adapter/${this.props.oContext.adapterName}/${this.props.schema.url}`;const[t,s,...n]=this.props.schema.name.split("/"),i=n.join("/");if(!e){console.error('Cannot find URL for custom component! Please define "url" as "custom/customComponents.js" in the schema');return}if(!t||!s||!i){console.error('Invalid format of "name"! Please define "name" as "ConfigCustomBackItUpSet/Components/AdapterExist" in the schema');return}let o=se.runningLoads[`${e}!${s}`];if(!(o instanceof Promise)){let r;if(this.props.schema.i18n===!0){const h=e.lastIndexOf("/");let c;h!==-1?c=e.substring(0,h):c=e;const m=p.I18n.getLanguage(),f=`${c}/i18n/${m}.json`;r=fetch(f).then(g=>g.json()).then(g=>p.I18n.extendTranslations(g,m)).catch(g=>{if(m!=="en"){fetch(`${c}/i18n/en.json`).then(D=>D.json()).then(D=>p.I18n.extendTranslations(D,m)).catch(D=>console.log(`Cannot load i18n "${f}": ${D}`));return}console.log(`Cannot load i18n "${f}": ${g}`)})}else if(this.props.schema.i18n&&typeof this.props.schema.i18n=="object")try{p.I18n.extendTranslations(this.props.schema.i18n)}catch(h){console.error(`Cannot import i18n: ${h}`)}try{console.log(e,t,s,i),at([{name:t,entry:e,type:this.props.schema.bundlerType||void 0}]),o=nt(`${t}/${s}`),r instanceof Promise&&(o=Promise.all([o,r]).then(h=>h[0])),se.runningLoads[`${e}!${s}`]=o}catch(h){console.error(h),this.setState({error:`Cannot import from ${this.props.schema.url}: ${h}`})}}try{const r=(await o).default;if(r!=null&&r[i])this.setState({Component:r[i]});else{const h=Object.keys(r||{});console.error("URL is empty. Cannot load custom component!"),this.setState({error:`Component ${this.props.schema.name} not found in ${this.props.schema.url}. Found: ${h.join(", ")}`})}}catch(r){console.error(r),this.setState({error:`Cannot import from ${this.props.schema.url}: ${r}`})}}render(){const e=this.state.Component,t=this.props.schema||{},s=e?a.createElement(e,{...this.props,socket:this.props.oContext.socket,theme:this.props.oContext.theme,themeType:this.props.oContext.themeType,instance:this.props.oContext.instance,adapterName:this.props.oContext.adapterName,systemConfig:this.props.oContext.systemConfig,forceUpdate:this.props.oContext.forceUpdate}):this.state.error?a.createElement("div",null,this.state.error):a.createElement(l.LinearProgress,null);return t.newLine?a.createElement(a.Fragment,null,a.createElement("div",{style:{flexBasis:"100%",height:0}}),s):s}}class Ot extends d{componentDidMount(){super.componentDidMount();const e=d.getValue(this.props.data,this.props.attr);this.setState({value:e})}renderItem(e,t){return a.createElement(He.DatePicker,{sx:s=>({width:"100%",borderBottom:`1px solid ${s.palette.text.primary}`,"& fieldset":{display:"none"},"& input":{padding:`${s.spacing(1.5)} 0 4px 0`},"& .MuiInputAdornment-root":{marginLeft:0,marginTop:1},"& label":{transform:"translate(0px, -9px) scale(0.75)"}}),format:this.props.oContext.systemConfig.dateFormat.toLowerCase().replace("mm","MM"),disabled:!!t,value:this.state.value,onChange:s=>{this.setState({value:s},()=>this.onChange(this.props.attr,this.state.value))},label:this.getText(this.props.schema.label)})}}class Ft extends d{renderItem(){if(!this.props.schema)return null;if(this.props.oContext.DeviceManager){const t=this.props.oContext.DeviceManager;return a.createElement(t,{uploadImagesToInstance:`${this.props.oContext.adapterName}.${this.props.oContext.instance}`,title:this.getText(this.props.schema.label),socket:this.props.oContext.socket,selectedInstance:`${this.props.oContext.adapterName}.${this.props.oContext.instance}`,themeName:this.props.themeName,theme:this.props.oContext.theme,themeType:this.props.oContext.themeType,isFloatComma:this.props.oContext.isFloatComma,dateFormat:this.props.oContext.dateFormat})}return a.createElement("div",null,"DeviceManager not found")}}const U={fullWidth:{width:"100%"},uploadDiv:{position:"relative",width:"100%"},uploadDivDragging:{opacity:1,background:"rgba(128,255,128,0.1)"},uploadCenterDiv:{margin:5,border:"3px dashed grey",borderRadius:5,width:"100%",height:"100%",position:"absolute",display:"flex"},uploadCenterIcon:{paddingTop:10,width:48,height:48},uploadCenterText:{fontSize:16},uploadCenterTextAndIcon:{textAlign:"center",position:"absolute",top:0,bottom:0,left:0,right:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},disabledOpacity:{opacity:.3,cursor:"default"},error:{border:"2px solid red"},deleteButton:{},selectedImage:{height:40,width:40,display:"inline-block",marginRight:8}},$t=["jpg","jpeg","svg","png","webp","gif","apng","avif","webp"],Nt=["mp3","ogg","wav","aac"],At=["avi","mp4","mov"],Lt=["txt","log","html","htm"],Vt=["json","js","ts"];class fe extends d{dropzoneRef;imagePrefix;objectID;path;constructor(e){super(e),this.dropzoneRef=a.createRef(),this.imagePrefix=this.props.oContext.imagePrefix===void 0?"./files":this.props.oContext.imagePrefix}componentDidMount(){super.componentDidMount(),this.objectID=(this.props.schema.objectID||"0_userdata.0").replace("%INSTANCE%",(this.props.oContext.instance||0).toString()),this.path=this.props.schema.upload,this.path&&(this.path==="/"?this.path="":this.path.endsWith("/")||(this.path=`${this.path}/`)),this.updateFiles().then(()=>{const e=d.getValue(this.props.data,this.props.attr);this.setState({value:e}),this.props.oContext.socket.subscribeFiles(this.objectID,`${this.path}/*`,this.onFolderChanged).catch(t=>console.error(`Cannot subscribe: ${t}`))})}onFolderChanged=(e,t)=>{this.path&&t.startsWith(this.path)&&this.updateFiles().catch(s=>console.error(`Cannot update files: ${s}`))};componentWillUnmount(){this.props.oContext.socket.subscribeFiles(this.objectID,`${this.path}/*`,this.onFolderChanged).catch(e=>console.error(`Cannot subscribe: ${e}`)),super.componentWillUnmount()}async updateFiles(){const e=await this.readFiles(this.props.schema.pattern);await new Promise(t=>this.setState({files:e},t))}async readFolder(e,t,s){try{const n=await this.props.oContext.socket.readDir(this.objectID,e.replace(/^\//,"")||null);for(let i=0;i<n.length;i++){const o=n[i];if(o.isDir)await this.readFolder(`${e+o.file}/`,t,s);else{let r=!1;s==="*.*"&&o.file.includes(".")||!s||s==="*"||s===".*"&&o.file.startsWith(".")?r=!0:r=new RegExp(`^${s.replace(/\./g,"\\.").replace(/\*/g,".*")}$`).test(o.file),r&&t.push({name:e+o.file,size:o.stats?p.Utils.formatBytes(o.stats.size):"--"})}}}catch(n){console.error(`Cannot read "${e}": ${n}`)}return t}async readFiles(e){const t=[];e=e||this.props.schema.pattern,e||(e="**/*.*");let s;const n=e.lastIndexOf("/");if(n===-1?s=e:s=e.substring(n+1),e.startsWith("**"))await this.readFolder("/",t,s);else{const i=e.lastIndexOf("/");if(i===-1)await this.readFolder("/",t,s);else{const o=e.substring(0,i+1);await this.readFolder(o,t,s)}}return t}onDrop(e){const t=e[0],s=new FileReader,n=this.props.schema.maxSize||2*1024*1024;s.onabort=()=>console.log("file reading was aborted"),s.onerror=()=>console.log("file reading has failed"),s.onload=()=>{if(t.size>n){window.alert(p.I18n.t("File is too big. Max %sk allowed. Try use SVG.",Math.round(n/1024)));return}this.props.oContext.socket.writeFile64(this.objectID,this.path+t.name,s.result).then(()=>this.updateFiles()).then(()=>this.setState({value:this.path+t.name},()=>this.onChange(this.props.attr,this.path+t.name))).catch(i=>window.alert(`Cannot upload file: ${i}`))},s.readAsArrayBuffer(t)}renderDeleteDialog(){return this.state.deleteFile?a.createElement(p.DialogConfirm,{title:p.I18n.t("ra_Are you sure?"),text:p.I18n.t("ra_File will be deleted"),ok:p.I18n.t("ra_Delete"),cancel:p.I18n.t("ra_Cancel"),onClose:e=>{const t=this.state.deleteFile;this.setState({deleteFile:""},()=>{e&&this.props.oContext.socket.deleteFile(this.objectID,t).then(()=>this.updateFiles()).catch(s=>window.alert(`Cannot delete file: ${s}`))})}}):null}static base64ToArrayBuffer(e){const t=window.atob(e),s=t.length,n=new Uint8Array(s);for(let i=0;i<s;i++)n[i]=t.charCodeAt(i);return n.buffer}loadFile(){return this.props.oContext.socket.readFile(this.objectID,this.state.value,!0)}play(){this.loadFile().then(e=>{if(typeof AudioContext<"u"){const t=new AudioContext,s=fe.base64ToArrayBuffer(e.file);t.decodeAudioData(s,n=>{const i=t.createBufferSource();i.buffer=n,i.connect(t.destination),i.start(0)},n=>window.alert(`Cannot play: ${n.message}`))}})}getFileIcon(e){return e!=null&&e.extension?$t.includes(e.extension)?a.createElement("div",{style:{...U.selectedImage,backgroundImage:`url(${this.imagePrefix}/${this.objectID}/${e.value})`,backgroundSize:"contain",backgroundRepeat:"no-repeat"}}):Nt.includes(e.extension)?a.createElement(v.MusicNote,null):Lt.includes(e.extension)?a.createElement(v.Article,null):At.includes(e.extension)?a.createElement(v.Videocam,null):Vt.includes(e.extension)?a.createElement(v.Code,null):null:null}renderItem(e,t){if(!this.state.files)return null;const s=[];this.props.schema.withFolder||this.state.files.forEach(m=>{const f=m.name.lastIndexOf("/");if(f===-1)s.includes("/")||s.push("/");else{const g=m.name.substring(0,f+1);s.includes(g)||s.push(g)}});const n=this.state.files.map(m=>({value:m.name,label:!this.props.schema.withFolder&&s.length===1?`${m.name.substring(s[0].length)}`:`${m.name}${this.props.schema.noSize?"":`(${m.size})`}`,extension:m.name.toLowerCase().split(".").pop()}));this.props.schema.noNone||n.unshift({label:p.I18n.t("ra_none"),value:""});const i=n.find(m=>m.value===this.state.value);let o=0;this.props.schema.upload&&o++,this.props.schema.refresh&&o++;const r=this.state.value&&(this.state.value.endsWith(".mp3")||this.state.value.endsWith(".ogg")||this.state.value.endsWith(".wav"));r&&o++;const h=a.createElement("div",{style:U.fullWidth},a.createElement(l.FormControl,{variant:"standard",style:{width:`calc(100% - ${o*42}px)`}},this.props.schema.label?a.createElement(l.InputLabel,null,this.getText(this.props.schema.label)):null,a.createElement(l.Select,{variant:"standard",error:!!e,disabled:!!t,value:this.state.value||"_",renderValue:()=>a.createElement(a.Fragment,null,this.getFileIcon(i),a.createElement("span",null,(i==null?void 0:i.label)||"")),onChange:m=>{this.setState({value:m.target.value==="_"?"":m.target.value},()=>this.onChange(this.props.attr,this.state.value))}},n.map(m=>a.createElement(l.MenuItem,{key:m.value,value:m.value},a.createElement(l.ListItemIcon,null,this.getFileIcon(m)),a.createElement(l.ListItemText,null,m.label),this.props.schema.delete&&i.value?a.createElement(l.IconButton,{style:U.deleteButton,size:"small",onClick:()=>this.setState({deleteFile:i.value})},a.createElement(v.Delete,null)):null))),this.props.schema.help?a.createElement(l.FormHelperText,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null),this.props.schema.refresh&&a.createElement(l.IconButton,{onClick:()=>this.updateFiles()},a.createElement(v.Refresh,null)),this.props.schema.upload&&a.createElement(l.IconButton,{onClick:()=>{var m;return(m=this.dropzoneRef.current)==null?void 0:m.open()}},a.createElement(v.UploadFile,null)),r&&a.createElement(l.IconButton,{style:{color:"#00FF00"},onClick:()=>this.play()},a.createElement(v.PlayArrow,null)));if(!this.props.schema.upload)return a.createElement(a.Fragment,null,h,this.renderDeleteDialog());let c={"*/*":[]};if(this.props.schema.fileTypes==="image"?c={"image/*":[".png",".jpg",".svg",".gif",".apng",".avif",".webp"]}:this.props.schema.fileTypes==="audio"?c={"audio/*":[".mp3",".ogg",".wav",".mp4"]}:this.props.schema.fileTypes==="text"&&(c={"text/plain":[".txt"]}),this.props.schema.pattern){const m=this.props.schema.pattern.split("/").pop().toLowerCase().replace(/.*\./,"");m==="png"||m==="jpg"||m==="svg"||m==="gif"||m==="apng"||m==="avif"||m==="webp"?c={"image/*":[".png",".jpg",".svg",".gif",".apng",".avif",".webp"]}:m==="mp3"||m==="ogg"||m==="wav"?c={"audio/*":[".mp3",".ogg",".wav",".mp4"]}:m==="ics"?c={"text/calendar":[".ics"]}:m==="txt"?c={"text/plain":[".txt"]}:m==="pem"?c={"text/plain":[".pem"]}:c={"*/*":[`.${m}`]}}return a.createElement(qe,{ref:this.dropzoneRef,multiple:!1,accept:c,noKeyboard:!0,noClick:!0,maxSize:this.props.schema.maxSize||2*1024*1024,onDragEnter:()=>{this.setState({uploadFile:"dragging"})},onDragLeave:()=>this.setState({uploadFile:!0}),onDrop:(m,f)=>{var g,D,b;this.setState({uploadFile:!1}),m.length?this.onDrop(m):window.alert(((b=(D=(g=f==null?void 0:f[0])==null?void 0:g.errors)==null?void 0:D[0])==null?void 0:b.message)||p.I18n.t("Cannot upload"))}},({getRootProps:m,getInputProps:f})=>a.createElement("div",{style:{...U.uploadDiv,...this.state.uploadFile==="dragging"?U.uploadDivDragging:void 0,...t?U.disabledOpacity:void 0},...m()},a.createElement("input",{...f()}),this.state.uploadFile==="dragging"?a.createElement("div",{style:{...U.uploadCenterDiv,...this.state.uploadError?U.error:void 0}},a.createElement("div",{style:U.uploadCenterTextAndIcon},a.createElement(v.UploadFile,{style:U.uploadCenterIcon}),a.createElement("div",{style:U.uploadCenterText},this.state.uploadFile==="dragging"?p.I18n.t("ra_Drop file here"):p.I18n.t("ra_Place your files here or click here to open the browse dialog")))):null,h,this.renderDeleteDialog()))}}const he={fullWidth:{width:"100%"},fullWidthOneButton:{width:"calc(100% - 69px)",marginRight:4},fullWidthIcon:{width:"calc(100% - 119px)",marginRight:4},selectedImage:{height:40,width:40,display:"inline-block",marginRight:8}},Bt=["jpg","jpeg","svg","png","webp","gif","apng","avif","webp"],jt=["mp3","ogg","wav","aac"],Pt=["avi","mp4","mov"],Wt=["txt","log","html","htm"],Ut=["json","js","ts"];class Mt extends d{imagePrefix="../..";componentDidMount(){super.componentDidMount();const e=d.getValue(this.props.data,this.props.attr);this.imagePrefix=this.props.oContext.imagePrefix===void 0?"./files":this.props.oContext.imagePrefix,this.setState({value:e??""})}static getDerivedStateFromProps(e,t){const s=d.getValue(e.data,e.attr);return s==null||s.toString().trim()!==(t.value||"").toString().trim()?{value:s??""}:null}loadFile(){const e=this.state.value.indexOf("/");if(e!==-1){const t=this.state.value.substring(0,e),s=this.state.value.substring(e+1);return this.props.oContext.socket.readFile(t,s,!0)}return Promise.resolve(null)}play(){this.loadFile().then(e=>{if(typeof AudioContext<"u"&&(e!=null&&e.file)){const t=new AudioContext,s=fe.base64ToArrayBuffer(e.file);t.decodeAudioData(s,n=>{const i=t.createBufferSource();i.buffer=n,i.connect(t.destination),i.start(0)},n=>window.alert(`Cannot play: ${n.message}`))}})}getIcon(){const e=this.state.value.split(".").pop().toLowerCase();return Bt.includes(e)?a.createElement("div",{style:{...he.selectedImage,backgroundImage:`url(${this.imagePrefix}/${this.state.value})`,backgroundSize:"contain",backgroundRepeat:"no-repeat"}}):jt.includes(e)?a.createElement(l.IconButton,{style:{color:"#00FF00"},onClick:()=>this.play()},a.createElement(v.PlayArrow,null)):Wt.includes(e)?a.createElement(v.Article,null):Pt.includes(e)?a.createElement(v.Videocam,null):Ut.includes(e)?a.createElement(v.Code,null):null}renderFileBrowser(){return this.state.showFileBrowser?a.createElement(p.DialogSelectFile,{imagePrefix:this.props.oContext.imagePrefix,socket:this.props.oContext.socket,selected:this.state.value,onClose:()=>this.setState({showFileBrowser:!1}),onOk:e=>{const t=Array.isArray(e)?e[0]:e;this.setState({value:t},()=>this.onChange(this.props.attr,this.props.schema.trim===!1?t:(t||"").trim()))},selectOnlyFolders:this.props.schema.selectOnlyFolders,allowUpload:this.props.schema.allowUpload,allowDownload:this.props.schema.allowDownload,allowCreateFolder:this.props.schema.allowCreateFolder,allowView:this.props.schema.allowView,showToolbar:this.props.schema.showToolbar,limitPath:this.props.schema.limitPath,theme:this.props.oContext.theme}):null}renderItem(e,t){const s=this.getIcon();return a.createElement("div",{style:he.fullWidth},s,a.createElement(l.TextField,{variant:"standard",style:s?he.fullWidthIcon:he.fullWidthOneButton,value:this.state.value===null||this.state.value===void 0?"":this.state.value,error:!!e,disabled:!!t,slotProps:{htmlInput:{maxLength:this.props.schema.maxLength||this.props.schema.max||void 0,readOnly:!!this.props.schema.disableEdit}},onChange:n=>{const i=n.target.value;this.setState({value:i},()=>this.onChange(this.props.attr,this.props.schema.trim===!1?i:(i||"").trim()))},placeholder:this.getText(this.props.schema.placeholder),label:this.getText(this.props.schema.label),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)}),a.createElement(l.Button,{disabled:t,variant:"outlined",onClick:()=>this.setState({showFileBrowser:!0})},"..."),this.renderFileBrowser())}}class Rt extends d{componentDidMount(){super.componentDidMount();const e=d.getValue(this.props.data,this.props.attr);this.props.oContext.socket.getEnums("functions").then(t=>{const s=Object.keys(t).map(n=>({value:this.props.schema.short?n.replace("enum.functions.",""):n,label:this.getText(t[n].common.name),obj:t[n]}));this.props.schema.allowDeactivate!==!1&&s.unshift({label:p.I18n.t(d.NONE_LABEL),value:d.NONE_VALUE}),this.setState({value:e,selectOptions:s})})}renderItem(e,t){if(!this.state.selectOptions)return null;const s=this.state.selectOptions.find(n=>n.value===this.state.value);return a.createElement(l.FormControl,{variant:"standard",fullWidth:!0},this.props.schema.label?a.createElement(l.InputLabel,null,this.getText(this.props.schema.label)):null,a.createElement(l.Select,{variant:"standard",error:!!e,disabled:!!t,value:this.state.value||"_",renderValue:()=>s?s.obj?a.createElement(p.TextWithIcon,{value:s.obj,themeType:this.props.oContext.themeType,lang:p.I18n.getLanguage()}):s.label:"",onChange:n=>{this.setState({value:n.target.value==="_"?"":n.target.value},()=>this.onChange(this.props.attr,this.state.value))}},this.state.selectOptions.map(n=>a.createElement(l.MenuItem,{key:n.value,value:n.value,style:n.value===d.DIFFERENT_VALUE?{opacity:.5}:{}},n.obj?a.createElement(p.TextWithIcon,{value:n.obj,themeType:this.props.oContext.themeType,lang:p.I18n.getLanguage()}):n.label))),this.props.schema.help?a.createElement(l.FormHelperText,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}class Jt extends d{componentDidMount(){super.componentDidMount(),this.props.oContext.socket.getHostByIp(this.props.common.host).then(e=>{this.props.schema.listenOnAllPorts||(e=e.filter(t=>t.address!=="0.0.0.0"&&t.address!=="::")),this.props.schema.onlyIp4?e=e.filter(t=>t.family==="ipv4"):this.props.schema.onlyIp6&&(e=e.filter(t=>t.family==="ipv6")),this.props.schema.noInternal&&(e=e.filter(t=>!t.internal)),e.forEach(t=>{t.address==="0.0.0.0"?t.name=`[IPv4] 0.0.0.0 - ${p.I18n.t("ra_Listen on all IPs")}`:t.address==="::"&&(t.name=`[IPv6] :: - ${p.I18n.t("ra_Listen on all IPs")}`)}),this.setState({ips:e})}).catch(e=>console.error(e))}renderItem(e,t){var i,o;const s=d.getValue(this.props.data,this.props.attr),n=(i=this.state.ips)==null?void 0:i.find(r=>r.address===s);return a.createElement(l.FormControl,{fullWidth:!0,variant:"standard"},this.state.ips&&this.props.schema.label?a.createElement(l.InputLabel,null,this.getText(this.props.schema.label)):null,this.state.ips?a.createElement(l.Select,{variant:"standard",error:!!e,disabled:!!t,value:s,renderValue:r=>(n==null?void 0:n.name)||r,onChange:r=>this.onChange(this.props.attr,r.target.value)},(o=this.state.ips)==null?void 0:o.map((r,h)=>a.createElement(l.MenuItem,{key:h,value:r.address},r.name))):a.createElement(l.TextField,{fullWidth:!0,variant:"standard",error:!!e,disabled:!!t,value:s,onChange:r=>this.onChange(this.props.attr,r.target.value),label:this.getText(this.props.schema.label)}),this.props.schema.help?a.createElement(l.FormHelperText,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}class zt extends d{initialized=!1;localContext;componentDidMount(){super.componentDidMount(),this.askInstance()}askInstance(){if(this.props.alive){let e=this.props.schema.data;if(e===void 0&&this.props.schema.jsonData){const t=this.getPattern(this.props.schema.jsonData,null,!0);if(t)try{e=JSON.parse(t)}catch{console.error(`Cannot parse json data: ${JSON.stringify(e)}`)}}e===void 0&&(e=null),this.props.oContext.socket.sendTo(`${this.props.oContext.adapterName}.${this.props.oContext.instance}`,this.props.schema.command||"send",e).then(t=>this.setState({image:t||""}))}}getContext(){const e={};return Array.isArray(this.props.schema.alsoDependsOn)&&this.props.schema.alsoDependsOn.forEach(t=>e[t]=d.getValue(this.props.data,t)),JSON.stringify(e)}renderItem(){if(this.props.alive){const e=this.getContext();(e!==this.localContext||!this.initialized)&&(this.localContext=e,setTimeout(()=>this.askInstance(),this.initialized?300:50),this.initialized=!0)}return this.state.image===void 0?null:a.createElement("img",{alt:"dynamic content",src:this.state.image,style:{width:this.props.schema.width||"100%",height:this.props.schema.height}})}}class Ht extends d{index;constructor(e){super(e),this.index=Date.now()}componentDidMount(){if(super.componentDidMount(),this.props.schema.base64){const e=d.getValue(this.props.data,this.props.attr);this.setState({value:e})}else this.props.oContext.socket.fileExists(`${this.props.oContext.adapterName}.${this.props.oContext.instance}`,this.props.attr).then(e=>e&&this.loadImage())}_getUrl(e){e&&(this.index=Date.now());let t=`files/${this.props.oContext.adapterName}.${this.props.oContext.instance}/${this.props.attr}?t=${this.index}`;return window.location.port==="3000"&&(t=`${window.location.protocol}//${window.location.hostname}:8081/${t}`),t}loadImage(){fetch(this._getUrl()).then(e=>e.blob()).then(e=>{const t=new FileReader;t.onload=()=>{this.setState({value:t.result})},t.readAsDataURL(e)}).catch(e=>console.error(e))}renderItem(e,t){return a.createElement(l.FormControl,{fullWidth:!0,variant:"standard"},this.props.schema.label?a.createElement(l.InputLabel,{shrink:!0},this.getText(this.props.schema.label)):null,a.createElement(p.UploadImage,{error:!!e,disabled:t,accept:this.props.schema.accept,crop:this.props.schema.crop,maxSize:this.props.schema.maxSize||256*1024,icon:this.state.value||void 0,removeIconFunc:()=>this.setState({value:null},()=>{if(this.props.schema.base64){const s=this.onChange(this.props.attr,this.state.value);s instanceof Promise&&s.catch(n=>console.error(`Cannot set value: ${n}`))}else this.props.oContext.socket.deleteFile(`${this.props.oContext.adapterName}.${this.props.oContext.instance}`,this.props.attr).catch(s=>console.error(s))}),onChange:s=>this.setState({value:s},()=>{if(this.props.schema.base64){const n=this.onChange(this.props.attr,this.state.value);n instanceof Promise&&n.catch(i=>console.error(`Cannot set value: ${i}`))}else s.startsWith("data")&&(s=s.split(",")[1]);this.props.oContext.socket.writeFile64(`${this.props.oContext.adapterName}.${this.props.oContext.instance}`,this.props.attr,s).catch(n=>console.error(n))})}),this.props.schema.help?a.createElement(l.FormHelperText,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}class qt extends d{renderItem(){return a.createElement(p.InfoBox,{type:this.props.schema.boxType||"info",closeable:this.props.schema.closeable!==void 0?this.props.schema.closeable:!0,storeId:this.props.schema.closed!==void 0?void 0:`${!!this.props.oContext.adapterName} ${this.props.attr}`,closed:this.props.schema.closed,style:{width:"100%",...this.props.schema.style}},this.props.schema.title?a.createElement(l.Box,{component:"div",sx:{fontWeight:"bold",fontSize:"larger"}},this.getText(this.props.schema.title)):null,this.getText(this.props.schema.text))}}const _e={icon:{width:20,height:20,marginRight:4}};class Kt extends d{componentDidMount(){super.componentDidMount();const e=d.getValue(this.props.data,this.props.attr);let t=this.props.schema.adapter;t==="_dataSources"&&(t=void 0),this.props.oContext.socket.getAdapterInstances(t,!0).then(async s=>{this.props.schema.adapter==="_dataSources"?s=s.filter(i=>{var o;return(o=i==null?void 0:i.common)==null?void 0:o.getHistory}):this.props.schema.adapter?s=s.filter(i=>i==null?void 0:i._id.startsWith(`system.adapter.${this.props.schema.adapter}.`)):this.props.schema.adapters&&Array.isArray(this.props.schema.adapters)&&(s=s.filter(i=>{var o;return this.props.schema.adapters.includes((o=i==null?void 0:i.common)==null?void 0:o.name)})),this.props.schema.onlyEnabled&&(s=s.filter(i=>{var o;return(o=i==null?void 0:i.common)==null?void 0:o.enabled}));const n=s.map(i=>({value:this.props.schema.long?i._id:this.props.schema.short?i._id.split(".").pop():i._id.replace(/^system\.adapter\./,""),label:`${i.common.name} [${i._id.replace(/^system\.adapter\./,"")}]`,icon:`adapter/${i.common.name}/${i.common.icon}`}));n.sort((i,o)=>i.value>o.value?1:i.value<o.value?-1:0),this.props.schema.allowDeactivate!==!1&&n.unshift({label:p.I18n.t(d.NONE_LABEL),value:d.NONE_VALUE}),this.props.schema.all&&n.unshift({label:p.I18n.t("sch_all"),value:"*"}),this.setState({value:e||"",selectOptions:n}),await this.props.oContext.socket.subscribeObject(`system.adapter.${t?`${t}.`:""}*`,this.onInstancesUpdate)}).catch(s=>console.error(`Cannot get instances: ${s}`))}componentWillUnmount(){this.props.oContext.socket.unsubscribeObject("system.adapter.*",this.onInstancesUpdate).then(()=>{}),super.componentWillUnmount()}onInstancesUpdate=(e,t)=>{if(!e.match(/^system\.adapter\.[-_a-z\d]+\.\d+$/))return;const s=this.props.schema.long?e:this.props.schema.short?e.split(".").pop():e.replace(/^system\.adapter\./,""),n=this.state.selectOptions.findIndex(i=>i.value===s);if(t){if(this.props.schema.adapter==="_dataSources"&&(!t.common||!t.common.getHistory))return;if(n===-1){const i=JSON.parse(JSON.stringify(this.state.selectOptions)),o=typeof t.common.name=="object"?t.common.name[p.I18n.getLanguage()]||t.common.name.en:t.common.name;i.push({value:this.props.schema.long?t._id:this.props.schema.short?t._id.split(".").pop():t._id.replace(/^system\.adapter\./,""),label:`${o} [${t._id.replace(/^system\.adapter\./,"")}]`,icon:`adapter/${o}/${t.common.icon}`}),i.sort((r,h)=>r.label>h.label?1:r.label<h.label?-1:0),this.setState({selectOptions:i})}}else if(n!==-1){const i=JSON.parse(JSON.stringify(this.state.selectOptions)),o={};this.state.value===i[n].value&&(o.value=d.NONE_VALUE),i.splice(n,1),o.selectOptions=i,this.setState(o)}};renderItem(e,t){var n;if(!this.state.selectOptions)return null;const s=(n=this.state.selectOptions)==null?void 0:n.find(i=>i.value===this.state.value);return a.createElement(l.FormControl,{fullWidth:!0,key:this.props.attr,variant:"standard"},this.props.schema.label?a.createElement(l.InputLabel,{shrink:!0},this.getText(this.props.schema.label)):null,a.createElement(l.Select,{variant:"standard",error:!!e,displayEmpty:!0,disabled:!!t,value:this.state.value,renderValue:()=>a.createElement("span",{style:{display:"flex"}},s!=null&&s.icon?a.createElement("img",{src:`./${s.icon}`,alt:s.value,style:_e.icon}):null,this.getText(s==null?void 0:s.label,!0)),onChange:i=>this.setState({value:i.target.value},()=>this.onChange(this.props.attr,this.state.value))},this.state.selectOptions.map(i=>a.createElement(l.MenuItem,{key:i.value,value:i.value,style:i.value===d.NONE_VALUE?{opacity:.5}:{}},i.icon?a.createElement("img",{src:`./${i.icon}`,alt:i.value,style:_e.icon}):null,this.getText(i.label,!0)))),this.props.schema.help?a.createElement(l.FormHelperText,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}const Oe={address:{fontSize:"smaller",opacity:.5,marginLeft:8}};class Gt extends d{componentDidMount(){super.componentDidMount(),this.props.oContext.socket.getObject(`system.host.${this.props.common.host}`).then(e=>{var s,n;const t=[];if((n=(s=e==null?void 0:e.native)==null?void 0:s.hardware)!=null&&n.networkInterfaces){const i=e.native.hardware.networkInterfaces;Object.keys(i).forEach(o=>{if(this.props.schema.ignoreInternal&&!i[o].find(h=>!h.internal)||this.props.schema.ignoreLoopback&&i[o].find(h=>h.address==="127.0.0.1"||h.address==="::1"))return;let r=i[o].find(h=>h.family==="IPv4");r||=i[o].find(h=>h.family==="IPv6"),t.push({value:o,address:r.address})})}this.setState({interfaces:t})}).catch(e=>window.alert(`Cannot read interfaces: ${e}`))}renderItem(e,t){var i,o,r;const s=d.getValue(this.props.data,this.props.attr),n=(i=this.state.interfaces)==null?void 0:i.find(h=>h.value===s);return a.createElement(l.FormControl,{fullWidth:!0,variant:"standard"},(o=this.state.interfaces)!=null&&o.length&&this.props.schema.label?a.createElement(l.InputLabel,null,this.getText(this.props.schema.label)):null,(r=this.state.interfaces)!=null&&r.length?a.createElement(l.Select,{variant:"standard",error:!!e,disabled:!!t,value:s,renderValue:h=>n?a.createElement("span",null,n.value,a.createElement("span",{style:Oe.address},n.address)):h,onChange:h=>this.onChange(this.props.attr,h.target.value)},this.state.interfaces.map((h,c)=>a.createElement(l.MenuItem,{key:c,value:h.value},a.createElement("span",null,h.value,a.createElement("span",{style:Oe.address},h.address))))):a.createElement(l.TextField,{fullWidth:!0,variant:"standard",error:!!e,disabled:!!t,value:s,onChange:h=>this.onChange(this.props.attr,h.target.value),label:this.getText(this.props.schema.label)}),this.props.schema.help?a.createElement(l.FormHelperText,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}const Q={modalDialog:{minWidth:400,maxWidth:800},overflowHidden:{display:"flex",overflow:"hidden"},titleIcon:{marginRight:5},content:{fontSize:16},languageButton:{position:"absolute",right:8,top:8},languageButtonActive:{color:"primary.main"}},Xt=({toggleTranslation:u,noTranslation:e,title:t,fullWidth:s,help:n,maxWidth:i,progress:o,icon:r,applyDisabled:h,applyButton:c,onClose:m,children:f,titleButtonApply:g,titleButtonClose:D,onApply:b,textInput:C,defaultValue:k,overflowHidden:x})=>{const[y,I]=te.useState(k);te.useEffect(()=>{I(k)},[k]);const _=l.useTheme(),O=l.useMediaQuery(_.breakpoints.down("md"));let F=null;return r&&(F=r),a.createElement(l.Dialog,{open:!0,maxWidth:O?!1:i||"md",fullWidth:!!s,fullScreen:O,disableEscapeKeyDown:!1,onClose:m,sx:{"& .MuiPaper-root":O?{}:Q.modalDialog}},t&&a.createElement(l.DialogTitle,null,r?a.createElement(F,{style:Q.titleIcon}):null,t,p.I18n.getLanguage()!=="en"&&u?a.createElement(l.IconButton,{size:"large",style:{...Q.languageButton,...e?Q.languageButtonActive:{}},onClick:()=>u(),title:p.I18n.t("Disable/Enable translation")},a.createElement(v.Language,null)):null),a.createElement(l.DialogContent,{sx:{...x?Q.overflowHidden:{},...Q.content},style:{paddingTop:8}},C&&a.createElement(l.TextField,{autoComplete:"off",fullWidth:!0,autoFocus:!0,variant:"outlined",size:"medium",multiline:!0,value:y,onChange:N=>I(N.target.value)}),f,n?a.createElement("div",null,n):null),a.createElement(l.DialogActions,null,c!==!1&&a.createElement(l.Button,{startIcon:a.createElement(v.Check,null),disabled:o||h&&k===y,onClick:()=>b&&b(C?y:""),variant:"contained",color:"primary"},p.I18n.t(g||"Ok")),a.createElement(l.Button,{color:"grey",onClick:()=>m&&m(),disabled:o,variant:"contained",startIcon:a.createElement(v.Close,null)},p.I18n.t(D||"Cancel"))))},Fe={jsonError:{border:"1px solid red",minHeight:200},jsonNoError:{border:"1px solid #00000000",minHeight:200}};function Yt(u){return a.createElement(ot,{style:u.error===!0?Fe.jsonError:u.error===!1?Fe.jsonNoError:void 0,mode:u.mode||"json",width:"100%",height:"100%",showPrintMargin:u.editValueMode,showGutter:u.editValueMode,highlightActiveLine:u.editValueMode,defaultValue:u.defaultValue,theme:u.themeType==="dark"?"clouds_midnight":"chrome",value:u.value,readOnly:!u.onChange,onChange:e=>{var t;return(t=u.onChange)==null?void 0:t.call(u,e)},name:u.name||"UNIQUE_ID_OF_DIV1",fontSize:u.fontSize||14,setOptions:{enableBasicAutocompletion:!0,enableLiveAutocompletion:!0,enableSnippets:!0,showLineNumbers:u.editValueMode,tabSize:u.editValueMode?2:void 0},editorProps:{$blockScrolling:!0}})}const Ce={flex:{display:"flex"},button:{height:48,minWidth:48},wrapper:{width:"calc(100vw - 40px)",height:"calc(100vh - 188px)"}};class Qt extends d{componentDidMount(){super.componentDidMount();const{data:e,attr:t}=this.props,s=d.getValue(e,t)||"{}";this.setState({value:s,initialized:!0,jsonError:this.validateJson(s)})}validateJson(e){let t=!1;if(this.props.schema.validateJson!==!1&&(e||!this.props.schema.allowEmpty))try{this.props.schema.json5?ze.parse(e):JSON.parse(e)}catch(s){console.log("Error in JSON",s),t=!0}return t}renderItem(e,t){if(!this.state.initialized)return null;const{schema:s,data:n,attr:i}=this.props,{value:o,showSelectId:r}=this.state,h=s.readOnly===!0;return a.createElement(l.FormControl,{fullWidth:!0,variant:"standard"},a.createElement("div",{style:Ce.flex},a.createElement(l.Button,{color:"grey",disabled:t,style:Ce.button,size:"small",variant:"outlined",onClick:()=>this.setState({showSelectId:!0})},p.I18n.t("ra_JSON editor"))),r?a.createElement(Xt,{title:this.getText(s.label),overflowHidden:!0,applyDisabled:this.state.jsonError&&this.props.schema.doNotApplyWithError||h,onClose:()=>this.setState({showSelectId:!1,value:d.getValue(n,i)||{}}),onApply:h?void 0:()=>this.setState({showSelectId:!1},()=>this.onChange(i,o))},a.createElement("div",{style:{...Ce.wrapper,border:this.state.jsonError?"2px solid red":"2px solid transparent"}},a.createElement(Yt,{mode:this.props.schema.json5?"json5":"json",value:typeof o=="object"?JSON.stringify(o):o,onChange:h?void 0:c=>this.setState({value:c,jsonError:this.validateJson(c)}),name:"ConfigJsonEditor",themeType:this.props.oContext.themeType}))):null,s.help||this.state.jsonError?a.createElement(l.FormHelperText,null,this.state.jsonError?p.I18n.t("ra_Invalid JSON"):this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}const Zt=[{value:"en",label:"English"},{value:"de",label:"Deutsch"},{value:"ru",label:"русский"},{value:"pt",label:"Portugues"},{value:"nl",label:"Nederlands"},{value:"fr",label:"français"},{value:"it",label:"Italiano"},{value:"es",label:"Espanol"},{value:"pl",label:"Polski"},{value:"uk",label:"Український"},{value:"zh-cn",label:"简体中文"}];class es extends d{componentDidMount(){super.componentDidMount();const e=d.getValue(this.props.data,this.props.attr),t=[...Zt];this.props.schema.system?t.unshift({value:"",label:p.I18n.t("ra_System language")}):t.unshift({value:"",label:p.I18n.t("ra_none")}),this.setState({value:this.props.schema.system?e||"":e||p.I18n.getLanguage(),selectOptions:t})}renderItem(e,t){var n,i;if(!this.state.selectOptions)return null;const s=(n=this.state.selectOptions)==null?void 0:n.find(o=>o.value===this.state.value||!o.value&&!this.state.value);return a.createElement(l.FormControl,{fullWidth:!0,variant:"standard"},this.props.schema.label?a.createElement(l.InputLabel,null,this.getText(this.props.schema.label)):null,a.createElement(l.Select,{variant:"standard",error:!!e,disabled:t,value:this.state.value||"_",renderValue:()=>this.getText(s==null?void 0:s.label,this.props.schema.noTranslation),onChange:o=>{let{value:r}=o.target;r==="_"&&(r=""),this.setState({value:r},()=>{const h=this.onChange(this.props.attr,r);if(h instanceof Promise&&h.catch(c=>console.error(c)),this.props.schema.changeGuiLanguage)if(r){if(r===p.I18n.getLanguage())return;p.I18n.setLanguage(r),this.props.oContext.changeLanguage&&this.props.oContext.changeLanguage()}else this.props.oContext.socket.getSystemConfig().then(c=>{c.common.language!==p.I18n.getLanguage()&&c.common.language&&(p.I18n.setLanguage(c.common.language),this.props.oContext.changeLanguage&&this.props.oContext.changeLanguage())}).catch(c=>console.error(`Cannot read system config: ${c}`))})}},(i=this.state.selectOptions)==null?void 0:i.map(o=>a.createElement(l.MenuItem,{key:o.value,value:o.value},o.label))),this.props.schema.help?a.createElement(l.FormHelperText,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}class ts extends d{scrollRef;constructor(e){super(e),this.scrollRef=a.createRef()}scrolledDown(){return this.scrollRef.current?this.scrollRef.current.offsetHeight+this.scrollRef.current.scrollTop>=this.scrollRef.current.scrollHeight:!1}componentDidMount(){super.componentDidMount(),d.getValue(this.props.data,this.props.attr)||(this.props.schema.licenseUrl?(this.setState({showLicenseDialog:!0,loading:!0,scrolledDown:!1}),fetch(this.props.schema.licenseUrl).then(e=>e.text()).then(e=>this.setState({license:e,loading:!1})).catch(e=>this.setState({license:e.toString(),loading:!1,error:!0,scrolledDown:!1}))):this.setState({showLicenseDialog:!0,scrolledDown:!1}),setTimeout(()=>{this.scrollRef.current&&(this.scrolledDown()?this.setState({scrolledDown:!0}):this.scrollRef.current.addEventListener("scroll",()=>{!this.state.scrolledDown&&this.scrolledDown()&&this.setState({scrolledDown:!0})}))},1e3))}renderItem(e,t){return this.state.showLicenseDialog?a.createElement(l.Dialog,{maxWidth:"lg",open:!0,onClose:(s,n)=>{n!=="escapeKeyDown"&&n!=="backdropClick"&&this.setState({showLicenseDialog:!1})}},a.createElement(l.DialogTitle,null,this.props.schema.title?p.I18n.t(this.props.schema.title):p.I18n.t("ra_License agreement")),a.createElement(l.DialogContent,null,this.props.schema.licenseUrl?a.createElement(a.Fragment,null,this.state.loading?a.createElement(l.LinearProgress,null):null,a.createElement("pre",{ref:this.scrollRef,style:{width:"100%",height:"100%",overflowY:"auto",fontSize:14}},this.state.license)):null,!this.props.schema.licenseUrl&&this.props.schema.texts?a.createElement("div",{ref:this.scrollRef,style:{width:"100%",height:"100%",overflowY:"auto",fontSize:14}},this.props.schema.texts.map((s,n)=>this.props.schema.noTranslation?a.createElement("p",{key:n},s):a.createElement("p",{key:n},p.I18n.t(s)))):null),a.createElement(l.DialogActions,null,this.props.schema.checkBox?a.createElement(l.FormControlLabel,{control:a.createElement(l.Checkbox,{disabled:t,checked:!!this.state.licenseChecked,onClick:()=>this.setState({licenseChecked:!this.state.licenseChecked})}),label:p.I18n.t(this.props.schema.checkBox)}):null,a.createElement(l.Button,{disabled:t||this.state.loading||this.state.error||this.props.schema.checkBox&&!this.state.licenseChecked||!this.state.scrolledDown,onClick:()=>{this.setState({showLicenseDialog:!1});const s=this.onChange(this.props.attr,!0);s instanceof Promise&&s.catch(n=>console.error(`Cannot set value: ${n}`))},color:"primary",variant:"contained",startIcon:a.createElement(v.Check,null)},this.props.schema.agreeText?p.I18n.t(this.props.schema.agreeText):p.I18n.t("ra_Accept license")),a.createElement(l.Button,{onClick:()=>{this.setState({showLicenseDialog:!1}),setTimeout(()=>this.setState({showLicenseDialog:!0}),2e3)},color:"grey",variant:"contained",startIcon:a.createElement(v.Close,null)},p.I18n.t("ra_Close")))):null}}const $e={indeterminate:{opacity:.5},control:{flexDirection:"row",width:"100%"}};class ss extends d{updateTimeout;componentDidMount(){super.componentDidMount();let e=d.getValue(this.props.data,this.props.attr);if(e==null&&(e=""),Array.isArray(e)&&this.props.oContext.multiEdit){e=d.DIFFERENT_VALUE,this.setState({_value:e,oldValue:e});return}this.setState({_value:e.toString(),oldValue:e.toString()})}static getDerivedStateFromProps(e,t){if(e.schema.min!==void 0&&e.schema.min<0||e.schema.max!==void 0&&e.schema.max<0)return null;const s=d.getValue(e.data,e.attr);return e.oContext.multiEdit&&t._value===d.DIFFERENT_VALUE?{_value:d.DIFFERENT_VALUE}:s==null||t.oldValue===null||t.oldValue===void 0||s.toString()!==parseFloat(t._value).toString()&&s.toString()!==t.oldValue.toString()?{_value:s}:null}checkValue(e){if(e==null||(e=e.toString().trim().replace(",","."),e==="-"))return null;const t=e===""?0:parseFloat(e);return e!==""&&Number.isNaN(t)?"ra_Not a number":e!==""&&window.isFinite(t)?this.props.schema.min!==void 0&&t<this.props.schema.min?"ra_Too small":this.props.schema.max!==void 0&&t>this.props.schema.max?"ra_Too big":e===""||e==="-"||Number.isNaN(t)?"ra_Not a number":null:"ra_Not a number"}renderItem(e,t){var i;const s=Array.isArray(this.state._value)||this.state._value===d.DIFFERENT_VALUE;if(this.state.oldValue!==null&&this.state.oldValue!==void 0?(this.updateTimeout&&clearTimeout(this.updateTimeout),this.updateTimeout=setTimeout(()=>{this.updateTimeout=void 0,this.setState({oldValue:null})},30)):this.updateTimeout&&(clearTimeout(this.updateTimeout),this.updateTimeout=void 0),s){const o=d.getValue(this.props.data,this.props.attr),r=(o==null?void 0:o.filter(h=>h||h===0).map(h=>({label:h.toString(),value:h})))||[];return r.unshift({label:p.I18n.t(d.DIFFERENT_LABEL),value:d.DIFFERENT_VALUE}),a.createElement(l.Autocomplete,{style:$e.indeterminate,fullWidth:!0,freeSolo:!0,value:r[0],getOptionSelected:(h,c)=>h.label===c.label,onChange:(h,c)=>{const m=this.onChange(this.props.attr,c==null?void 0:c.value,()=>{this.setState({_value:c==null?void 0:c.value,oldValue:this.state._value})});m instanceof Promise&&m.catch(f=>console.error(f))},options:r,getOptionLabel:h=>h.label,renderInput:h=>a.createElement(l.TextField,{...h,label:this.getText(this.props.schema.label),variant:"standard",slotProps:{htmlInput:{...h.inputProps,readOnly:this.props.schema.readOnly||!1},input:{endAdornment:this.props.schema.unit?this.getText(this.props.schema.unit,this.props.schema.noTranslation):void 0}},error:!!e,placeholder:this.getText(this.props.schema.placeholder),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation),disabled:!!t})})}!e&&this.state._value!==null&&this.state._value!==void 0&&this.state._value&&(e=this.checkValue(this.state._value),e&&(e=p.I18n.t(e)));const n=parseFloat(((i=this.state._value)==null?void 0:i.toString().replace(",","."))||"");return a.createElement(l.FormControl,{variant:"standard",style:$e.control},a.createElement(l.TextField,{sx:{"& .up-down":{display:"none"},"&:hover .up-down":{display:"block"}},variant:"standard",type:Number.isNaN(n)?"text":this.props.schema.min!==void 0&&this.props.schema.min>=0?"number":"text",fullWidth:!0,slotProps:{htmlInput:{min:this.props.schema.min,max:this.props.schema.max,step:this.props.schema.step,readOnly:this.props.schema.readOnly||!1},input:{endAdornment:this.props.schema.unit?this.getText(this.props.schema.unit,this.props.schema.noTranslation):null}},value:this.state._value===null||this.state._value===void 0?"":this.state._value,error:!!e,disabled:!!t,onChange:o=>{const r=o.target.value,h=this.checkValue(r);h?this.onError(this.props.attr,p.I18n.t(h)):this.onError(this.props.attr),this.setState({_value:r,oldValue:this.state._value},()=>{const c=parseFloat(r.toString().replace(",","."));Number.isNaN(c)?this.onChange(this.props.attr,r.toString().replace(",",".")):this.onChange(this.props.attr,c)})},placeholder:this.getText(this.props.schema.placeholder),label:this.getText(this.props.schema.label),helperText:e&&typeof e=="string"?e:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)}))}}class as extends d{authWindow;oid;url;constructor(e){super(e),this.state={...this.state,accessTokens:"",success:!1,blocked:!1,running:!1,pressed:!1},this.url=`https://oauth2.iobroker.in/${e.schema.identifier}?redirect=true`,e.schema.scope&&(this.url+=`&scope=${encodeURIComponent(e.schema.scope)}`),this.oid=`${this.props.oContext.adapterName}.${this.props.oContext.instance}.${this.props.schema.saveTokenIn||"oauth2Tokens"}`}async componentDidMount(){super.componentDidMount(),window.addEventListener?window.addEventListener("message",this.onMessage,!1):window.attachEvent("onmessage",this.onMessage,!1),await this.props.oContext.socket.subscribeState(this.oid,this.onTokensUpdated);const e=await this.props.oContext.socket.getState(this.oid);if(e){const t=JSON.parse(e.val);new Date(t.access_token_expires_on).getTime()>Date.now()&&this.setState({accessTokens:e.val})}}onTokensUpdated=(e,t)=>{if(t!=null&&t.val){const s=JSON.parse(t.val);if(new Date(s.access_token_expires_on).getTime()>Date.now()){this.state.accessTokens!==t.val&&this.setState({accessTokens:t.val});return}}this.setState({accessTokens:""})};componentWillUnmount(){super.componentWillUnmount(),window.removeEventListener?window.removeEventListener("message",this.onMessage,!1):window.detachEvent("onmessage",this.onMessage,!1),this.props.oContext.socket.unsubscribeState(this.oid,this.onTokensUpdated)}saveToken(e){try{e&&!e.startsWith("{")&&(e=atob(e));const t=JSON.parse(e);t.access_token&&t.refresh_token&&t.expires_in&&(t.access_token_expires_on||=new Date(Date.now()+t.expires_in*1e3).toISOString(),this.props.oContext.socket.setState(this.oid,JSON.stringify(t),!0).catch(s=>console.log(`Error occurred: ${s.toString()}`)))}catch(t){console.warn(t)}}onMessage=e=>{var t,s,n;if(e.origin==="https://oauth2.iobroker.in"&&(typeof e.data=="string"&&e.data.startsWith(`${this.props.schema.identifier}-authentication:`)||typeof e.message=="string"&&e.message.startsWith(`${this.props.schema.identifier}-authentication:`))){const i=(e.data||e.message).split(":");i[1]==="success"?(this.setState({accessTokens:i[2],success:!0,pressed:!1},()=>this.saveToken(this.state.accessTokens)),(t=this.authWindow)==null||t.postMessage("close",e.origin),this.authWindow=null):(n=(s=this.props).onError)==null||n.call(s,i[2])}};onOpenUrl(){this.authWindow=window.open(this.url,this.props.schema.identifier),!this.authWindow||this.authWindow.closed||typeof this.authWindow.closed>"u"?this.setState({blocked:!0}):this.setState({pressed:!0})}renderItem(){let e="";if(this.state.accessTokens)try{const n=JSON.parse(this.state.accessTokens);e=new Date(n.access_token_expires_on).toLocaleString()}catch{}let t;this.state.accessTokens?t=this.props.schema.refreshLabel?this.getText(this.props.schema.refreshLabel):p.I18n.t("ra_Renew %s access",this.props.schema.identifier[0].toUpperCase()+this.props.schema.identifier.slice(1)):t=this.props.schema.label?this.getText(this.props.schema.label):p.I18n.t("ra_Get %s access",this.props.schema.identifier[0].toUpperCase()+this.props.schema.identifier.slice(1));const s=this.getIcon();return a.createElement("div",{style:{width:"100%",margin:"0 0 1rem 0"}},a.createElement(l.Button,{disabled:this.state.running,endIcon:s||a.createElement(v.CloudUpload,null),variant:"contained",onClick:()=>this.onOpenUrl()},t),this.state.blocked?a.createElement("div",{style:{color:"red",fontSize:16,marginTop:20}},p.I18n.t("ra_Please allow popups in your browser for this page!")):null,this.state.accessTokens?a.createElement("div",{style:{color:"green",fontSize:16,marginTop:20}},this.props.alive?p.I18n.t("ra_Successfully authorized. Token valid till %s and will be automatically renewed.",e):p.I18n.t("ra_Successfully authorized. Token valid till %s but it can expire as the instance is not running.",e)):null,this.state.pressed?a.createElement(a.Fragment,null,a.createElement("div",{style:{width:"100%",margin:"1rem 0 1rem 0"}},a.createElement("span",{style:{marginRight:4}},`${p.I18n.t("ra_If the button above does not work, you can authorize manually this app by visiting this url")}`,":"),a.createElement("br",null),a.createElement("a",{target:this.props.schema.identifier,href:this.url,rel:"noreferrer"},this.url)),a.createElement(l.TextField,{value:this.state.accessTokens,label:p.I18n.t("ra_Enter the code from that page here"),variant:"standard",onChange:n=>{let i=n.target.value;i&&!i.startsWith("{")&&(i=atob(i));try{const o=JSON.parse(i);o.access_token&&(o.access_token_expires_on=new Date(Date.now()+(o.expires_in-10)*1e3).toISOString(),this.setState({accessTokens:JSON.stringify(o)},()=>this.saveToken(this.state.accessTokens)))}catch{}},fullWidth:!0})):null)}}const Ne={flex:{display:"flex"},button:{height:48,marginLeft:4,minWidth:48}};class ns extends d{componentDidMount(){super.componentDidMount();const{data:e,attr:t}=this.props,s=d.getValue(e,t)||"";this.setState({value:s,initialized:!0})}renderItem(e,t){if(!this.state.initialized)return null;const s=this.props.oContext.socket,{schema:n,attr:i}=this.props,{value:o,showSelectId:r}=this.state;return a.createElement(l.FormControl,{fullWidth:!0,variant:"standard"},n.label?a.createElement(l.InputLabel,{shrink:!0},this.getText(n.label)):null,a.createElement("div",{style:Ne.flex},a.createElement(l.TextField,{variant:"standard",fullWidth:!0,value:o,error:!!e,disabled:t,placeholder:this.getText(n.placeholder),label:this.getText(n.label),helperText:this.renderHelp(n.help,n.helpLink,n.noTranslation),onChange:h=>{const c=h.target.value;this.setState({value:c},()=>this.onChange(i,c))}}),a.createElement(l.Button,{color:"grey",disabled:t,style:Ne.button,size:"small",variant:"outlined",onClick:()=>this.setState({showSelectId:!0})},"...")),r?a.createElement(p.DialogSelectID,{imagePrefix:this.props.oContext.imagePrefix===void 0?"../..":this.props.oContext.imagePrefix,dialogName:`admin.${this.props.oContext.adapterName}`,filterFunc:n.filterFunc,themeType:this.props.oContext.themeType,theme:this.props.oContext.theme,types:n.types?Array.isArray(n.types)?n.types:[n.types]:void 0,customFilter:n.customFilter,filters:n.filters,socket:s,selected:o,root:n.root,onClose:()=>this.setState({showSelectId:!1}),onOk:h=>this.setState({showSelectId:!1,value:h},()=>this.onChange(i,h))}):null)}}const xe={fullWidth:{width:"100%",display:"inline-block"},halfWidth1:{width:"calc(50% - 5px)",display:"inline-block",marginRight:8},halfWidth2:{width:"calc(50% - 5px)",display:"inline-block"}},pe="____ppp____";class is extends d{componentDidMount(){super.componentDidMount();const e=d.getValue(this.props.data,this.props.attr);this.setState({_repeat:e?pe:"",_visible:!1,value:e?pe:"",_notEqual:!1})}onChangePassword(e,t){e===void 0&&(e=this.state.value),t===void 0&&(t=this.state._repeat);const s=!!this.props.schema.repeat&&t!==e;this.setState({value:e,_repeat:t,_notEqual:s},()=>{if(s)this.onError(this.props.attr,p.I18n.t("ra_Passwords are not equal!"));else{this.onError(this.props.attr);const n=this.onChange(this.props.attr,e);n instanceof Promise&&n.catch(i=>this.onError(this.props.attr,i))}})}renderItem(e,t){if(this.state._notEqual===void 0)return null;const s=a.createElement(l.TextField,{variant:"standard",fullWidth:!0,type:this.state._visible&&this.state.value!==pe?"text":"password",value:this.state.value,error:!!e||this.state._notEqual,disabled:!!t,onChange:n=>this.onChangePassword(n.target.value),label:this.getText(this.props.schema.label),slotProps:{input:{autoComplete:"new-password",endAdornment:this.state.value&&this.state.value!==pe&&this.props.schema.visible&&!t&&!this.props.schema.readOnly?a.createElement(l.InputAdornment,{position:"end"},a.createElement(l.IconButton,{size:"large",tabIndex:-1,onClick:n=>{n.preventDefault(),n.stopPropagation(),this.setState({_visible:!this.state._visible})},edge:"end"},this.state._visible?a.createElement(v.VisibilityOff,null):a.createElement(v.Visibility,null))):void 0},htmlInput:{autoComplete:"new-password",form:{autoComplete:"off"},maxLength:this.props.schema.maxLength||this.props.schema.max||void 0,readOnly:this.props.schema.readOnly||!1}},helperText:this.state._notEqual?p.I18n.t("ra_Passwords are not equal!"):this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)});if(this.props.schema.repeat&&!this.props.schema.readOnly){const n=this.state._visible?null:a.createElement(l.TextField,{variant:"standard",fullWidth:!0,type:"password",value:this.state._repeat,error:!!e||this.state._notEqual,disabled:!!t,onChange:i=>this.onChangePassword(void 0,i.target.value),label:`${this.getText(this.props.schema.label)} (${p.I18n.t("ra_repeat")})`,slotProps:{input:{autoComplete:"new-password"},htmlInput:{autoComplete:"new-password",form:{autoComplete:"off"},maxLength:this.props.schema.maxLength||this.props.schema.max||void 0}},helperText:this.state._notEqual?p.I18n.t("ra_Passwords are not equal!"):this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)});return a.createElement("div",{style:xe.fullWidth},a.createElement("div",{style:xe.halfWidth1},s),a.createElement("div",{style:xe.halfWidth2},n))}return s}}class os extends d{renderItem(e,t){return a.createElement(l.TextField,{variant:"standard",fullWidth:!0,disabled:!!t,slotProps:{input:{endAdornment:this.props.schema.copyToClipboard?a.createElement(l.IconButton,{tabIndex:-1,size:"small",onClick:()=>{p.Utils.copyToClipboard(this.getPattern(this.props.schema.pattern,null,this.props.schema.noTranslation)),window.alert(p.I18n.t("ra_Copied"))}},a.createElement(p.IconCopy,null)):void 0}},value:this.getPattern(this.props.schema.pattern,null,!0),label:this.getText(this.props.schema.label),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)})}}const rs={warning:{"& .Mui-error":{color:"orange"}}};class ls extends d{updateTimeout;async componentDidMount(){super.componentDidMount();let e=d.getValue(this.props.data,this.props.attr);e==null&&(e=""),this.setState({_value:e.toString(),oldValue:e.toString()});const t=await this.props.oContext.socket.getAdapterInstances(),s=`system.adapter.${this.props.oContext.adapterName}.${this.props.oContext.instance}`,n=await this.props.oContext.socket.getObject(s),i=n==null?void 0:n.common.host,o=[];t.forEach(r=>{var c,m,f,g;if(!r||r._id===s||r.common.host!==i||!((c=r.native)!=null&&c.bind))return;if(r!=null&&r.native&&r.native.secure&&r.native.leEnabled&&r.native.leUpdate){const D=parseInt(r.native.leCheckPort||r.native.lePort,10);D&&o.push({name:`${r._id.replace("system.adapter.","")} (LE)`,port:D,v6bind:r.native.bind.includes(":")?r.native.bind:r.native.v6bind,bind:r.native.bind,enabled:!!((m=r.common)!=null&&m.enabled)})}const h=parseInt((f=r==null?void 0:r.native)==null?void 0:f.port,10);h&&o.push({name:r._id.replace("system.adapter.",""),bind:r.native.bind,v6bind:r.native.bind.includes(":")?r.native.bind:r.native.v6bind,port:h,enabled:!!((g=r.common)!=null&&g.enabled)})}),this.setState({ports:o})}static getDerivedStateFromProps(e,t){const s=d.getValue(e.data,e.attr);return s==null||t.oldValue===null||t.oldValue===void 0||s.toString()!==parseInt(t._value,10).toString()&&s.toString()!==t.oldValue.toString()?{_value:s}:null}checkValue(e){if(e==null)return null;const t=this.props.schema.min===void 0?20:this.props.schema.min,s=this.props.schema.max||65535;e=e.toString().trim();const n=e===""?0:parseInt(e,10);return e!==""&&Number.isNaN(n)?"ra_Not a number":e!==""&&window.isFinite(Number(e))?n<t?"ra_Too small":n>s?"ra_Too big":e===""||e==="-"||Number.isNaN(n)?"ra_Not a number":null:"ra_Not a number"}renderItem(e,t){this.state.oldValue!==null&&this.state.oldValue!==void 0?(this.updateTimeout&&clearTimeout(this.updateTimeout),this.updateTimeout=setTimeout(()=>{this.updateTimeout=void 0,this.setState({oldValue:null})},30)):this.updateTimeout&&(clearTimeout(this.updateTimeout),this.updateTimeout=void 0);const s=this.props.schema.min===void 0?20:this.props.schema.min,n=this.props.schema.max||65535;let i;if(this.state.ports){const o=parseInt(this.state._value,10);if(o){const r=this.props.data.bind,h=this.state.ports.filter(m=>{if(m.port!==o)return!1;const f=m.bind,g=m.v6bind;return!r||!f||r==="0.0.0.0"||f==="0.0.0.0"||r==="::"||g==="::"||r===f||r===g});let c=h.findIndex(m=>m.port===o&&m.enabled);if(c!==-1){const m=this.state.ports.find(f=>f.port===o&&f.enabled&&h.some(g=>g.name===f.name&&g.bind===f.bind));e=p.I18n.t("ra_Port is already used by %s",(m==null?void 0:m.name)||h[c].name)}else if(c=h.findIndex(m=>m.port===o&&!m.enabled),c!==-1){i=!0;const m=this.state.ports.find(f=>f.port===o&&!f.enabled&&h.some(g=>g.name===f.name&&g.bind===f.bind));e=p.I18n.t("ra_Port could be used by %s",(m==null?void 0:m.name)||h[c].name)}}}return!e&&this.state._value!==null&&this.state._value!==void 0&&(e=this.checkValue(this.state._value),typeof e=="string"&&(e=p.I18n.t(e))),a.createElement(l.TextField,{variant:"standard",type:"number",fullWidth:!0,slotProps:{htmlInput:{min:s,max:n,readOnly:this.props.schema.readOnly||!1}},value:this.state._value===null||this.state._value===void 0?"":this.state._value,error:!!e,disabled:!!t,sx:i?rs.warning:void 0,onChange:o=>{const r=Number(o.target.value.toString().replace(/[^0-9]/g,"")).toString(),h=this.checkValue(r);h?this.onError(this.props.attr,p.I18n.t(h)):this.onError(this.props.attr),this.setState({_value:r,oldValue:this.state._value},()=>{if(r.trim()===parseInt(r,10).toString()){const c=this.onChange(this.props.attr,parseInt(r,10)||0);c instanceof Promise&&c.catch(m=>{console.error(`Cannot set value for ${this.props.attr}: ${m}`)})}})},placeholder:this.getText(this.props.schema.placeholder),label:this.getText(this.props.schema.label),helperText:e&&typeof e=="string"?e:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)})}}class hs extends d{componentDidMount(){super.componentDidMount();const e=d.getValue(this.props.data,this.props.attr);this.props.oContext.socket.getEnums("rooms").then(t=>{const s=Object.keys(t).map(n=>({value:this.props.schema.short?n.replace("enum.rooms.",""):n,label:this.getText(t[n].common.name),obj:t[n]}));this.props.schema.allowDeactivate!==!1&&s.unshift({label:p.I18n.t(d.NONE_LABEL),value:d.NONE_VALUE}),this.setState({value:e,selectOptions:s})}).catch(t=>console.error(`Cannot get enums: ${t}`))}renderItem(e,t){if(!this.state.selectOptions)return null;const s=this.state.selectOptions.find(n=>n.value===this.state.value);return a.createElement(l.FormControl,{variant:"standard",fullWidth:!0},this.props.schema.label?a.createElement(l.InputLabel,null,this.getText(this.props.schema.label)):null,a.createElement(l.Select,{variant:"standard",error:!!e,disabled:!!t,value:this.state.value||"_",renderValue:()=>s?s.obj?a.createElement(p.TextWithIcon,{value:s.obj,themeType:this.props.oContext.themeType,lang:p.I18n.getLanguage()}):s.label:"",onChange:n=>{this.setState({value:n.target.value==="_"?"":n.target.value},()=>this.onChange(this.props.attr,this.state.value))}},this.state.selectOptions.map(n=>a.createElement(l.MenuItem,{key:n.value,value:n.value,style:n.value===d.DIFFERENT_VALUE?{opacity:.5}:{}},n.obj?a.createElement(p.TextWithIcon,{value:n.obj,themeType:this.props.oContext.themeType,lang:p.I18n.getLanguage()}):n.label))),this.props.schema.help?a.createElement(l.FormHelperText,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}const ps={noMargin:{"&>div":{marginTop:0}}};class cs extends d{initialValue="";componentDidMount(){super.componentDidMount();let e=d.getValue(this.props.data,this.props.attr);this.props.schema.multiple&&(typeof e=="string"?e=[e]:e==null&&(e=[]));const t=[];(this.props.schema.options||[]).forEach(s=>{const n=s;Array.isArray(n.items)?(t.push({label:this.getText(s.label,this.props.schema.noTranslation),value:s.value,group:!0,color:s.color}),n.items.forEach(i=>t.push({label:this.getText(i.label,this.props.schema.noTranslation),value:i.value,hidden:i.hidden,color:s.color}))):t.push({label:this.getText(s.label,this.props.schema.noTranslation),value:s.value,hidden:s.hidden,color:s.color})}),Array.isArray(e)&&!this.props.schema.multiple?(this.initialValue=[...e],t.unshift({label:p.I18n.t(d.DIFFERENT_LABEL),value:d.DIFFERENT_VALUE}),this.setState({value:d.DIFFERENT_VALUE,selectOptions:t})):this.setState({value:e,selectOptions:t})}_getValue(){let e=this.state.value===null||this.state.value===void 0?d.getValue(this.props.data,this.props.attr):this.state.value;return this.props.schema.multiple&&(typeof e=="string"?e=[e]:e==null&&(e=[])),e}renderItem(e,t){if(!this.state.selectOptions)return null;const s=(this.state.selectOptions||[]).filter(o=>o.hidden?this.props.custom?!this.executeCustom(o.hidden,this.props.data,this.props.customObj,this.props.oContext.instanceObj,this.props.arrayIndex,this.props.globalData):!this.execute(o.hidden,this.props.schema.default,this.props.data,this.props.arrayIndex,this.props.globalData):!0),n=this._getValue(),i=this.props.schema.multiple?null:s.find(o=>o.value==n);return a.createElement(l.FormControl,{variant:"standard",fullWidth:!0,sx:this.props.table!==void 0&&ps.noMargin,id:`jsonSelect_${this.props.attr}_${this.props.index||this.props.index===0?this.props.index:""}`},this.props.schema.label?a.createElement(l.InputLabel,null,this.getText(this.props.schema.label)):null,a.createElement(l.Select,{variant:"standard",error:!!e,multiple:this.props.schema.multiple,disabled:!!t,value:n||"_",renderValue:o=>this.props.schema.multiple?a.createElement("div",{style:{display:"flex",flexWrap:"wrap",gap:.5}},o.map(r=>{const h=s.find(c=>c.value===r);if(h||this.props.schema.showAllValues!==!1){const c=(h==null?void 0:h.label)||r;return a.createElement(l.Chip,{key:r,label:c})}return null})):i!=null&&i.color?a.createElement("div",{style:{color:i.color}},(i==null?void 0:i.label)===void 0?o:i.label):(i==null?void 0:i.label)===void 0?o:i.label,onChange:o=>{this.setState({value:o.target.value==="_"?"":o.target.value},()=>{let r;this.state.value===d.DIFFERENT_VALUE?r=this.onChange(this.props.attr,this.initialValue):r=this.onChange(this.props.attr,this.state.value),r instanceof Promise&&r.catch(h=>console.error(h))})}},s.map((o,r)=>o.group?a.createElement(l.ListSubheader,{key:r,style:{color:o.color}},o.label):a.createElement(l.MenuItem,{key:r,value:o.value,style:o.value===d.DIFFERENT_VALUE?{opacity:.5}:{}},this.props.schema.multiple?a.createElement(l.Checkbox,{checked:n.includes(o.value),onClick:()=>{const h=JSON.parse(JSON.stringify(this._getValue())),c=n.indexOf(o.value);c!==-1?h.splice(c,1):(h.push(o.value),h.sort()),this.setState({value:h},()=>this.onChange(this.props.attr,h))}}):null,a.createElement(l.ListItemText,{primary:o.label,style:{color:o.color}})))),this.props.schema.help?a.createElement(l.FormHelperText,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}const us={menuPaper:{maxHeight:800}};class ds extends d{initialized=!1;localContext;askInstance(){if(this.props.alive){let e=this.props.schema.data;if(e===void 0&&this.props.schema.jsonData){const t=this.getPattern(this.props.schema.jsonData,null,!0);try{e=JSON.parse(t)}catch{console.error(`Cannot parse json data: ${t}`)}}e===void 0&&(e=null),this.setState({running:!0},()=>{this.props.oContext.socket.sendTo(`${this.props.oContext.adapterName}.${this.props.oContext.instance}`,this.props.schema.command||"send",e).then(t=>this.setState({list:t,running:!1})).catch(t=>{console.error(`Cannot send command: ${t}`)})})}else{const e=d.getValue(this.props.data,this.props.attr);this.setState({value:e,running:!1})}}getContext(){const e={};return Array.isArray(this.props.schema.alsoDependsOn)&&this.props.schema.alsoDependsOn.forEach(t=>e[t]=d.getValue(this.props.data,t)),JSON.stringify(e)}_getValue(){let e=this.state.value===null||this.state.value===void 0?d.getValue(this.props.data,this.props.attr):this.state.value;return this.props.schema.multiple&&(typeof e=="string"?e=[e]:e==null&&(e=[])),e}renderItem(e,t){if(this.props.alive){const o=this.getContext();(o!==this.localContext||!this.initialized)&&(this.localContext=o,setTimeout(()=>this.askInstance(),this.initialized?300:50),this.initialized=!0)}const s=this._getValue();if(!this.props.alive||!this.state.running&&!Array.isArray(this.state.list))return this.props.schema.multiple||this.props.schema.manual===!1?p.I18n.t("ra_Cannot retrieve options, as instance is offline"):a.createElement(l.TextField,{variant:"standard",fullWidth:!0,value:s,error:!!e,disabled:!!t,onChange:o=>{const r=o.target.value;this.setState({value:r},()=>this.onChange(this.props.attr,(r||"").trim()))},placeholder:this.getText(this.props.schema.placeholder),label:this.getText(this.props.schema.label),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation),slotProps:{input:{endAdornment:this.state.value&&!this.props.schema.noClearButton?a.createElement(l.InputAdornment,{position:"end"},a.createElement(l.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setState({value:""},()=>this.onChange(this.props.attr,""))},a.createElement(v.Close,null))):null}}});if(this.state.running)return a.createElement(l.CircularProgress,{size:"24"});const n=this.state.list.filter(o=>o.hidden?this.props.custom?!this.executeCustom(o.hidden,this.props.data,this.props.customObj,this.props.oContext.instanceObj,this.props.arrayIndex,this.props.globalData):!this.execute(o.hidden,this.props.schema.default,this.props.data,this.props.arrayIndex,this.props.globalData):!0),i=n.find(o=>o.value===s);return a.createElement(l.FormControl,{variant:"standard",fullWidth:!0},this.props.schema.label?a.createElement(l.InputLabel,null,this.getText(this.props.schema.label)):null,a.createElement(l.Select,{variant:"standard",error:!!e,multiple:this.props.schema.multiple,disabled:!!t,sx:{"&.MuiSelect-paper":this.props.schema.multiple?us.menuPaper:void 0},value:s,renderValue:o=>this.props.schema.multiple?a.createElement(l.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5}},o.map(r=>{const h=n.find(c=>c.value===r);if(h||this.props.schema.showAllValues!==!1){const c=(h==null?void 0:h.label)||r;return a.createElement(l.Chip,{key:r,label:c})}return null})):this.getText((i==null?void 0:i.label)||o,this.props.schema.noTranslation),onChange:o=>{const r=this.onChange(this.props.attr,o.target.value);r instanceof Promise&&r.catch(h=>console.error(`Cannot set value: ${h}`))}},n.map((o,r)=>o.group?a.createElement(l.ListSubheader,{key:r},this.getText(o.label,this.props.schema.noTranslation)):a.createElement(l.MenuItem,{key:r,value:o.value},this.props.schema.multiple?a.createElement(l.Checkbox,{checked:s.includes(o.value),onClick:()=>{const h=JSON.parse(JSON.stringify(this._getValue())),c=s.indexOf(o.value);c!==-1?h.splice(c,1):(h.push(o.value),h.sort()),this.setState({value:h},()=>this.onChange(this.props.attr,h))}}):null,a.createElement(l.ListItemText,{primary:o.label})))),this.props.schema.help?a.createElement(l.FormHelperText,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}const Ae={fullWidth:{width:"100%"}};function H(u){return u.split(".").reduce((e,t)=>(e<<8)+parseInt(t,10),0)>>>0}function ms(u,e){var n,i;const t=(i=(n=u==null?void 0:u.native)==null?void 0:n.hardware)==null?void 0:i.networkInterfaces;if(!t)return null;let s;return Object.keys(t).forEach(o=>t[o].forEach(r=>{r.internal||e.includes(":")&&r.family!=="IPv6"||e.includes(".")&&!e.match(/[^.\d]/)&&r.family!=="IPv4"||(r.family==="IPv4"&&!r.address.startsWith("172")&&(e==="127.0.0.0"||e==="localhost"||e.match(/[^.\d]/))?s=r.address:s||(r.family==="IPv4"&&e.includes(".")&&(H(e)&H(r.netmask),H(r.address)&H(r.netmask)),s=r.address))})),s||Object.keys(t).forEach(o=>t[o].forEach(r=>{r.internal||e.includes(":")&&r.family!=="IPv6"||e.includes(".")&&!e.match(/[^.\d]/)&&r.family!=="IPv4"||(r.family==="IPv6"&&(e==="127.0.0.0"||e==="localhost"||e.match(/[^.\d]/))?s=r.address:s||(r.family==="IPv4"&&e.includes(".")&&(H(e)&H(r.netmask),H(r.address)&H(r.netmask)),s=r.address))})),s||Object.keys(t).forEach(o=>{t[o].forEach(r=>{r.internal||e.includes(":")&&r.family!=="IPv6"||e.includes(".")&&!e.match(/[^.\d]/)&&r.family!=="IPv4"||(e==="127.0.0.0"||e==="localhost"||e.match(/[^.\d]/),s=r.address)})}),s||Object.keys(t).forEach(o=>{t[o].forEach(r=>{r.internal||(s=r.address)})}),s}class Le extends d{async componentDidMount(){var t;super.componentDidMount();let e=window.location.hostname;if(this.props.schema.openUrl){const s=await this.props.oContext.socket.getCurrentInstance(),n=await this.props.oContext.socket.getObject(`system.adapter.${s}`);if(n){const i=await this.props.oContext.socket.getObject(`system.host.${(t=n==null?void 0:n.common)==null?void 0:t.host}`);if(i){const o=ms(i,window.location.hostname);if(o)e=`${o}:${window.location.port}`;else{console.warn(`Cannot find suitable IP in host ${n.common.host} for ${n._id}`);return}}}}await new Promise(s=>{this.setState({_error:"",_message:"",hostname:e},s)}),this.props.schema.onLoaded&&this._onClick()}renderErrorDialog(){return this.state._error?a.createElement(p.DialogError,{text:this.state._error,onClose:()=>this.setState({_error:""})}):null}renderMessageDialog(){return this.state._message?a.createElement(p.DialogMessage,{text:this.state._message,onClose:()=>this.setState({_message:""})}):null}_onClick(){this.props.oContext.onCommandRunning(!0),this.setState({running:!0});const e=`${window.location.protocol}//${window.location.host}${window.location.pathname.replace(/\/index\.html$/,"")}`,t=`${window.location.protocol}//${this.state.hostname.split(":").length>3?`[${this.state.hostname}]`:this.state.hostname}${window.location.pathname.replace(/\/index\.html$/,"")}`;let s=this.props.schema.data;if(s===void 0&&this.props.schema.jsonData){const i=this.getPattern(this.props.schema.jsonData,{_origin:e,_originIp:t,...this.props.data},!0);try{s=JSON.parse(i)}catch{console.error(`Cannot parse json data: ${i}`)}}s===void 0&&(s=null),this.props.schema.openUrl&&!s&&(s={_origin:e,_originIp:t});let n;this.props.schema.timeout&&(n=setTimeout(()=>{this.props.oContext.onCommandRunning(!1),this.setState({_error:p.I18n.t("ra_Request timed out"),running:!1})},parseInt(this.props.schema.timeout,10)||1e4)),this.props.oContext.socket.sendTo(`${this.props.oContext.adapterName}.${this.props.oContext.instance}`,this.props.schema.command||"send",s).then(async i=>{var o,r,h,c,m;if(n&&(clearTimeout(n),n=void 0),i!=null&&i.error)if(this.props.schema.error&&this.props.schema.error[i.error]){let f=this.getText(this.props.schema.error[i.error]);(o=i.args)==null||o.forEach(g=>f=f.replace("%s",g)),this.setState({_error:f})}else this.setState({_error:i.error?typeof i.error=="string"?p.I18n.t(i.error):JSON.stringify(i.error):p.I18n.t("ra_Error")});else{if(i!=null&&i.command){(h=(r=this.props.oContext).onBackEndCommand)==null||h.call(r,i.command);return}if(i!=null&&i.reloadBrowser&&this.props.schema.reloadBrowser)window.location.reload();else if(i!=null&&i.openUrl&&this.props.schema.openUrl)window.open(i.openUrl,i.window||this.props.schema.window||"_blank");else if(i!=null&&i.result&&((c=this.props.schema.result)!=null&&c[i.result])){let f=this.getText(this.props.schema.result[i.result]);(m=i.args)==null||m.forEach(g=>f=f.replace("%s",g)),window.alert(f)}if(i!=null&&i.native&&this.props.schema.useNative){for(const[f,g]of Object.entries(i.native))await this.onChangeAsync(f,g);setTimeout(()=>this.props.oContext.forceUpdate(Object.keys(i.native),this.props.data),300)}else i!=null&&i.result?window.alert(typeof i.result=="object"?JSON.stringify(i.result):i.result):window.alert(p.I18n.t("ra_Ok"));i!=null&&i.saveConfig&&this.props.onChange(null,null,null,!0)}}).catch(i=>{this.props.schema.error&&this.props.schema.error[i.toString()]?this.setState({_error:this.getText(this.props.schema.error[i.toString()])}):this.setState({_error:p.I18n.t(i.toString())||p.I18n.t("ra_Error")})}).then(()=>{this.props.oContext.onCommandRunning(!1),this.setState({running:!1})})}renderDialogConfirm(){if(!this.state.confirmDialog)return null;const e=this.state.confirmData||this.props.schema.confirm;let t=null;return e.type==="warning"?t=a.createElement(v.Warning,null):e.type==="error"?t=a.createElement(v.Error,null):e.type==="info"&&(t=a.createElement(v.Info,null)),a.createElement(p.DialogConfirm,{title:this.getText(e.title)||p.I18n.t("ra_Please confirm"),text:this.getText(e.text),ok:this.getText(e.ok)||p.I18n.t("ra_Ok"),cancel:this.getText(e.cancel)||p.I18n.t("ra_Cancel"),icon:t||void 0,onClose:s=>this.setState({confirmDialog:!1},()=>s&&this._onClick())})}renderItem(e,t){const s=this.getIcon();return a.createElement("div",{style:Ae.fullWidth},a.createElement(l.Button,{variant:this.props.schema.variant||void 0,color:this.props.schema.color||"grey",style:{...Ae.fullWidth,...this.props.schema.controlStyle||void 0},disabled:t||!this.props.alive,startIcon:s,title:this.props.alive?this.getText(this.props.schema.title)||"":p.I18n.t("ra_Instance is not alive"),onClick:()=>{this.props.schema.confirm?this.setState({confirmDialog:!0}):this._onClick()}},this.props.schema.showProcess&&this.state.running?a.createElement(l.CircularProgress,{size:20,style:{marginRight:8}}):null,this.getText(this.props.schema.label,this.props.schema.noTranslation)),this.renderErrorDialog(),this.renderMessageDialog())}}const fs={fullWidth:{width:"100%"}};class gs extends d{async _onClick(){var s,n;let e=this.props.schema.val;if(typeof e=="string"&&e.includes("${")){e=this.getPattern(e,null,!0);const i=await this.props.oContext.socket.getObject(this.props.schema.id);((s=i==null?void 0:i.common)==null?void 0:s.type)==="number"?e=parseFloat(e):((n=i==null?void 0:i.common)==null?void 0:n.type)==="boolean"&&(e=e==="true"||e===!0||e==="1"||e===1)}const t=(this.props.schema.id||"").replace(/%INSTANCE%/g,(this.props.oContext.instance||0).toString());try{await this.props.oContext.socket.setState(t,{val:e,ack:!!this.props.schema.ack}),this.props.schema.okText&&window.alert(this.getText(this.props.schema.okText))}catch(i){this.props.schema.error&&this.props.schema.error[i.toString()]?window.alert(this.getText(this.props.schema.error[i.toString()])):window.alert(p.I18n.t(i.toString())||p.I18n.t("ra_Error"))}}renderDialogConfirm(){if(!this.state.confirmDialog)return null;const e=this.state.confirmData||this.props.schema.confirm;let t=null;return e.type==="warning"?t=a.createElement(v.Warning,null):e.type==="error"?t=a.createElement(v.Error,null):e.type==="info"&&(t=a.createElement(v.Info,null)),a.createElement(p.DialogConfirm,{title:this.getText(e.title)||p.I18n.t("ra_Please confirm"),text:this.getText(e.text),ok:this.getText(e.ok)||p.I18n.t("ra_Ok"),cancel:this.getText(e.cancel)||p.I18n.t("ra_Cancel"),icon:t,onClose:s=>this.setState({confirmDialog:!1},()=>s&&this._onClick())})}renderItem(e,t){const s=this.getIcon();return a.createElement(l.Button,{variant:this.props.schema.variant||void 0,color:this.props.schema.color||"grey",style:fs.fullWidth,disabled:t,onClick:async()=>{this.props.schema.confirm?this.setState({confirmDialog:!0}):await this._onClick()},startIcon:s||void 0},this.getText(this.props.schema.label,this.props.schema.noTranslation))}}const Ve={fullWidth:{width:"100%"},slider:{marginLeft:10,marginRight:10,width:"calc(100% - 20px)"}};class ys extends d{componentDidMount(){super.componentDidMount();const e=d.getValue(this.props.data,this.props.attr);this.setState({_value:e})}static getDerivedStateFromProps(e,t){if(e.schema.min!==void 0&&e.schema.min<0||e.schema.max!==void 0&&e.schema.max<0)return null;const s=d.getValue(e.data,e.attr);return s==null||s.toString()!==parseFloat(t._value).toString()?{_value:s}:null}renderItem(e,t){const s=this.props.schema.min||0,n=this.props.schema.max||100,i=this.props.schema.unit?this.getText(this.props.schema.unit,this.props.schema.noTranslation):"",o=[{value:s,label:s+i},{value:n,label:n+i}];return a.createElement(l.Box,{style:Ve.fullWidth},this.props.schema.label?a.createElement(l.Typography,{gutterBottom:!0},this.getText(this.props.schema.label)):null,a.createElement(l.Slider,{style:Ve.slider,value:this.state._value,getAriaValueText:r=>r+i,step:this.props.schema.step||(n-s)/100,valueLabelDisplay:"auto",marks:o,min:s,max:n,disabled:!!t,onChange:r=>{const h=r.target.value;this.setState({_value:h},()=>this.onChange(this.props.attr,h))}}),this.props.schema.help?a.createElement(l.Typography,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}function q(u,e){return u==="edit"||u==="rename"?a.createElement(v.Edit,{style:e}):u==="delete"?a.createElement(v.Delete,{style:e}):u==="refresh"?a.createElement(v.Refresh,{style:e}):u==="newDevice"||u==="new"||u==="add"?a.createElement(v.Add,{style:e}):u==="discover"||u==="search"?a.createElement(v.Search,{style:e}):u==="unpairDevice"||u==="unpair"?a.createElement(v.LinkOff,{style:e}):u==="pairDevice"||u==="pair"?a.createElement(v.Link,{style:e}):u==="identify"?a.createElement(v.NotListedLocation,{style:e}):u==="play"?a.createElement(v.PlayArrow,{style:e}):u==="stop"?a.createElement(v.Stop,{style:e}):u==="pause"?a.createElement(v.Pause,{style:e}):u==="forward"||u==="next"?a.createElement(v.FastForward,{style:e}):u==="rewind"||u==="previous"?a.createElement(v.FastRewind,{style:e}):u==="lamp"||u==="light"?a.createElement(v.Lightbulb,{style:e}):u==="backlight"?a.createElement(v.Fluorescent,{style:e}):u==="dimmer"?a.createElement(v.WbIncandescent,{style:e}):u==="socket"?a.createElement(v.Power,{style:e}):u==="settings"?a.createElement(v.Settings,{style:e}):u==="users"||u==="group"?a.createElement(v.Group,{style:e}):u==="user"?a.createElement(v.Person,{style:e}):u==="qrcode"?a.createElement(v.QrCode,{style:e}):u==="connection"?a.createElement(v.Wifi,{style:e}):u==="no-connection"?a.createElement(v.WifiOff,{style:e}):u==="visible"?a.createElement(v.Visibility,{style:e}):null}function vs(u,e){return typeof e=="string"?{"@keyframes newStateAnimationOnceColor":{"0%":{color:e},"100%":{color:u.palette.mode==="dark"?"#fff":"#000"}},animation:"newStateAnimationOnceColor 2s ease-in-out"}:{"@keyframes newStateAnimationOnce":{"0%":{color:"#00f900"},"80%":{color:u.palette.mode==="dark"?"#518851":"#008000"},"100%":{color:u.palette.mode==="dark"?"#fff":"#000"}},animation:"newStateAnimationOnce 2s ease-in-out"}}class bs extends d{controlTimeout=null;delayedUpdate={timer:null,value:null};getObjectID(){let e=(this.props.schema.oid||"").toString();return e.includes("${")&&(e=this.getPattern(e,null,!0)),this.props.schema.foreign?e:`${this.props.schema.system?"system.adapter.":""}${this.props.oContext.adapterName}.${this.props.oContext.instance||0}.${e}`}async componentDidMount(){var s,n;super.componentDidMount();const e=await this.props.oContext.socket.getObject(this.getObjectID());if((s=e==null?void 0:e.common)!=null&&s.states&&!this.props.schema.options){if(Array.isArray((n=e==null?void 0:e.common)==null?void 0:n.states)){const i={};e.common.states.forEach((o,r)=>{i[r.toString()]=o}),e.common.states=i}Object.keys(e.common.states).length||(e.common.states=void 0)}const t=this.props.schema.control||this.detectType(e);try{const i=await this.props.oContext.socket.getState(this.getObjectID());this.setState({stateValue:i?i.val:null,controlType:t,obj:e},async()=>{await this.props.oContext.socket.subscribeState(this.getObjectID(),this.onStateChanged)})}catch(i){console.error(`Cannot get state ${this.getObjectID()}: ${i}`),this.setState({controlType:t,obj:e})}}componentWillUnmount(){super.componentWillUnmount(),this.props.oContext.socket.unsubscribeState(this.getObjectID(),this.onStateChanged),this.delayedUpdate.timer&&(clearTimeout(this.delayedUpdate.timer),this.delayedUpdate.timer=null),this.controlTimeout&&(clearTimeout(this.controlTimeout),this.controlTimeout=null,this.props.oContext.socket.setState(this.getObjectID(),this.state.stateValue,!1).catch(e=>console.error(`Cannot control value: ${e.toString()}`)))}onStateChanged=(e,t)=>{let s=t?t.val:null;this.state.controlType==="button"||this.state.controlType==="switch"?(s=!!s,this.state.stateValue!==s&&this.setState({stateValue:s})):s!==null&&(this.state.controlType==="slider"||this.state.controlType==="number")?(s=parseFloat(s),console.log(`${Date.now()} Received new value: ${s}`),s!==this.state.stateValue?(this.delayedUpdate.timer&&(clearTimeout(this.delayedUpdate.timer),this.delayedUpdate.timer=null),this.delayedUpdate.value=s,this.delayedUpdate.timer=setTimeout(()=>{this.setState({stateValue:this.delayedUpdate.value})},500)):this.delayedUpdate.timer&&(clearTimeout(this.delayedUpdate.timer),this.delayedUpdate.timer=null)):this.state.stateValue.toString()!==s.toString()&&this.setState({stateValue:s})};detectType(e){if(e||={},e.common||={},e.common.type==="boolean"){if(this.props.schema.controlled!==!1){if(e.common.read===!1||this.props.schema.controlled===!0)return"button";if(e.common.write||this.props.schema.controlled===!0)return"switch"}return"text"}return e.common.type==="number"&&this.props.schema.controlled!==!1?e.common.write||this.props.schema.controlled===!0?e.common.states||this.props.schema.options?"select":e.common.max!==void 0?"slider":"input":"text":e.common.write&&this.props.schema.controlled!==!1?e.common.states||this.props.schema.options?"select":"input":"text"}getNormalizedStates(){let e;return this.props.schema.options?e=this.props.schema.options.map(t=>typeof t=="string"?{value:t,label:this.getText(t,this.props.schema.noTranslation)}:{value:t.value,label:this.getText(t.label,this.props.schema.noTranslation),color:t.color}):this.state.obj.common.states?(e=[],Object.keys(this.state.obj.common.states).forEach(t=>{e.push({value:t,label:this.getText(this.state.obj.common.states[t],this.props.schema.noTranslation)})})):e=[],e}renderItem(e,t){var n,i,o,r,h;if(!this.state.obj)return null;let s;if(this.state.controlType==="select"||!this.state.controlType&&(this.state.obj.common.type==="number"||this.state.obj.common.type==="string")&&this.state.obj.common.write!==!1&&(this.props.schema.options||this.state.obj.common.states)){const c=this.getNormalizedStates(),m=c.find(f=>f.value===this.state.stateValue);s=a.createElement(l.FormControl,{fullWidth:!0},a.createElement(l.InputLabel,null,"$",this.getText(this.props.schema.label)),a.createElement(l.Select,{value:this.state.stateValue,disabled:!!this.props.schema.readOnly||t,onChange:f=>{this.setState({stateValue:f.target.value},()=>{let g=this.state.stateValue;this.state.obj.common.type==="number"&&(g=parseFloat(g.toString().replace(",","."))),this.props.oContext.socket.setState(this.getObjectID(),g,!1)})},renderValue:f=>m!=null&&m.color?a.createElement("div",{style:{color:m.color}},m.label):f},c.map(f=>a.createElement(l.MenuItem,{key:(f.value??"").toString(),value:f.value,style:{color:f.color}},"$",f.label))))}else if(this.state.controlType==="button"||!this.state.controlType&&this.state.obj.common.type==="boolean"&&(this.state.obj.common.write&&this.state.obj.common.read===!1||(n=this.state.obj.common.role)!=null&&n.includes("button"))){let c=null;this.props.schema.falseImage&&(c=q(this.props.schema.falseImage));const m=this.getText(this.props.schema.falseText||this.props.schema.label,this.props.schema.noTranslation);!m&&c?s=a.createElement(l.IconButton,{style:this.props.schema.falseTextStyle,disabled:!!this.props.schema.readOnly,onClick:async()=>{this.props.schema.confirm?this.setState({confirmDialog:!0,confirmCallback:async f=>{f&&await this.props.oContext.socket.setState(this.getObjectID(),this.props.schema.buttonValue!==void 0?this.props.schema.buttonValue:!0,!1)}}):await this.props.oContext.socket.setState(this.getObjectID(),this.props.schema.buttonValue!==void 0?this.props.schema.buttonValue:!0,!1)}},c):s=a.createElement(l.Button,{variant:this.props.schema.variant||"contained",startIcon:c,style:this.props.schema.falseTextStyle,disabled:t||!!this.props.schema.readOnly,onClick:async()=>{this.props.schema.confirm?this.setState({confirmDialog:!0,confirmCallback:async f=>{f&&await this.props.oContext.socket.setState(this.getObjectID(),this.props.schema.buttonValue!==void 0?this.props.schema.buttonValue:!0,!1)}}):await this.props.oContext.socket.setState(this.getObjectID(),this.props.schema.buttonValue!==void 0?this.props.schema.buttonValue:!0,!1)}},m||this.getObjectID().split(".").pop())}else if(this.state.controlType==="input"||!this.state.controlType&&this.state.obj.common.write&&this.state.obj.common.type==="string")s=a.createElement("div",{style:{width:"100%",display:"flex",flexDirection:"row",gap:8,alignItems:"baseline"}},a.createElement(l.TextField,{style:{flex:1},value:this.state.stateValue,variant:"standard",disabled:!!this.props.schema.readOnly||t,slotProps:{input:{endAdornment:this.getText(this.props.schema.unit,this.props.schema.noTranslation)||this.state.obj.common.unit||void 0},htmlInput:{readOnly:!!this.props.schema.readOnly}},onKeyUp:c=>{this.props.schema.setOnEnterKey&&c.key==="Enter"&&this.props.oContext.socket.setState(this.getObjectID(),this.state.stateValue,!1)},onChange:c=>{this.setState({stateValue:c.target.value},()=>{this.props.schema.setOnEnterKey||this.props.schema.showEnterButton||(this.controlTimeout&&clearTimeout(this.controlTimeout),this.controlTimeout=setTimeout(async()=>{this.controlTimeout=null;let m=this.state.stateValue;this.state.obj.common.type==="number"&&(m=parseFloat(m.toString().replace(",","."))),await this.props.oContext.socket.setState(this.getObjectID(),m,!1)},this.props.schema.controlDelay||0))})},label:this.getText(this.props.schema.label),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)}),this.props.schema.showEnterButton&&!this.props.schema.readOnly&&a.createElement(l.Button,{variant:"outlined",disabled:t,onClick:()=>{this.props.oContext.socket.setState(this.getObjectID(),this.state.stateValue,!1)}},this.getText(typeof this.props.schema.showEnterButton=="string"?this.props.schema.showEnterButton:"Set")));else{let c;this.props.schema.size==="normal"?c=16:this.props.schema.size==="large"?c=20:typeof this.props.schema.size=="number"&&(c=this.props.schema.size);let m=this.getText(this.props.schema.label,this.props.schema.noTranslation);const f={display:"flex",alignItems:"center",fontSize:c||"1rem",gap:8};this.props.schema.narrow||(f.width="100%",f.justifyContent="space-between"),m.trim()&&!m.trim().endsWith(":")&&this.props.schema.addColon&&(m=`${m.trim()}:`);let g;this.props.schema.blinkOnUpdate&&(g=vs(this.props.oContext.theme,this.props.schema.blinkOnUpdate));let D;this.props.schema.labelIcon&&(D=a.createElement(p.Icon,{src:this.props.schema.labelIcon,style:{marginRight:4}}));let b;if(m&&D?b=a.createElement("div",{style:{whiteSpace:"nowrap"}},D,m):m?b=a.createElement("div",{style:{whiteSpace:"nowrap"}},m):D&&(b=D),this.state.controlType==="switch"||!this.state.controlType&&this.state.obj.common.type==="boolean"&&(this.state.obj.common.write&&this.state.obj.common.read!==!1||(i=this.state.obj.common.role)!=null&&i.includes("switch"))){let C=null;const k=this.getText(this.props.schema.falseText,this.props.schema.noTranslation);this.props.schema.falseImage&&(C=q(this.props.schema.falseImage,k?{marginLeft:8}:void 0));let x=null;const y=this.getText(this.props.schema.trueText,this.props.schema.noTranslation);this.props.schema.trueImage&&(x=q(this.props.schema.trueImage,y?{marginRight:8}:void 0)),s=a.createElement(l.Switch,{checked:!!this.state.stateValue,disabled:!!this.props.schema.readOnly||t,onChange:async()=>{this.props.schema.confirm?this.setState({confirmDialog:!0,confirmCallback:async I=>{I&&await this.props.oContext.socket.setState(this.getObjectID(),!this.state.stateValue,!1)}}):await this.props.oContext.socket.setState(this.getObjectID(),!this.state.stateValue,!1)}}),(k||C||y||x)&&(s=a.createElement("div",{style:{display:"flex",alignItems:"center",fontSize:14}},a.createElement("span",{style:this.props.schema.falseTextStyle},k,C),s,a.createElement("span",{style:this.props.schema.trueTextStyle},x,y))),b&&(s=a.createElement("div",{style:f},b,s))}else if(this.state.controlType==="slider"||!this.state.controlType&&this.state.obj.common.type==="number"&&(this.state.obj.common.write&&(this.state.obj.common.max!==void 0||this.state.obj.common.unit==="%")||(o=this.state.obj.common.role)!=null&&o.includes("slider")||(r=this.state.obj.common.role)!=null&&r.includes("dimmer")||(h=this.state.obj.common.role)!=null&&h.includes("blind"))){let C=null;const k=this.getText(this.props.schema.falseText,this.props.schema.noTranslation);this.props.schema.falseImage&&(C=q(this.props.schema.falseImage,k?{marginLeft:8}:void 0));let x=null;const y=this.getText(this.props.schema.trueText,this.props.schema.noTranslation);this.props.schema.trueImage&&(x=q(this.props.schema.trueImage,y?{marginRight:8}:void 0));const I=this.props.schema.min===void 0?this.state.obj.common.min||0:this.props.schema.min,_=this.props.schema.max===void 0?this.state.obj.common.max===void 0?100:this.state.obj.common.max:this.props.schema.max,O=this.props.schema.step===void 0?this.state.obj.common.step||1:this.props.schema.step;s=a.createElement(l.Slider,{style:{width:"100%",flexGrow:1},min:I,max:_,disabled:!!this.props.schema.readOnly||t,step:O,value:this.state.stateValue,valueLabelDisplay:"auto",valueLabelFormat:F=>`${F}${this.getText(this.props.schema.unit,this.props.schema.noTranslation)||this.state.obj.common.unit||""}`,onChange:(F,N)=>{this.setState({stateValue:N},()=>{this.controlTimeout&&clearTimeout(this.controlTimeout),this.controlTimeout=setTimeout(async()=>{console.log(`${Date.now()} Send new value: ${this.state.stateValue}`),this.controlTimeout=null,await this.props.oContext.socket.setState(this.getObjectID(),this.state.stateValue,!1)},this.props.schema.controlDelay||0)})}}),(k||C||y||x)&&(s=a.createElement("div",{style:{display:"flex",width:"100%",flexGrow:1,alignItems:"center"}},a.createElement("span",{style:{marginRight:16,...this.props.schema.falseTextStyle}},k,C),s,a.createElement("span",{style:{marginLeft:16,...this.props.schema.trueTextStyle}},x,y))),b&&(s=a.createElement("div",{style:f},b,s))}else if(this.state.obj.common.type==="number"&&this.state.obj.common.write&&!this.state.controlType){const C=this.props.schema.min===void 0?this.state.obj.common.min===void 0?void 0:this.state.obj.common.min:this.props.schema.min,k=this.props.schema.max===void 0?this.state.obj.common.max===void 0?void 0:this.state.obj.common.max:this.props.schema.max,x=this.props.schema.step===void 0?this.state.obj.common.step===void 0?void 0:this.state.obj.common.step:this.props.schema.step;s=a.createElement(l.TextField,{variant:"standard",style:{width:"100%"},value:this.state.stateValue,type:"number",disabled:!!this.props.schema.readOnly||t,slotProps:{htmlInput:{min:C,max:k,step:x,readOnly:!!this.props.schema.readOnly},input:{endAdornment:this.getText(this.props.schema.unit,this.props.schema.noTranslation)||this.state.obj.common.unit||void 0}},onChange:y=>{this.setState({stateValue:y.target.value},()=>{this.controlTimeout&&clearTimeout(this.controlTimeout),this.controlTimeout=setTimeout(async()=>{this.controlTimeout=null;const I=parseFloat(this.state.stateValue);await this.props.oContext.socket.setState(this.getObjectID(),I,!1)},this.props.schema.controlDelay||0)})},label:this.getText(this.props.schema.label,this.props.schema.noTranslation),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)})}else if(this.state.obj.common.type==="boolean"){let C=null,k,x;this.state.stateValue?(k=this.getText(this.props.schema.trueText,this.props.schema.noTranslation),this.props.schema.trueImage&&(C=q(this.props.schema.falseImage,k?{marginRight:8}:void 0)),x=this.props.schema.trueTextStyle):(k=this.getText(this.props.schema.falseText,this.props.schema.noTranslation),this.props.schema.falseImage&&(C=q(this.props.schema.falseImage,k?{marginLeft:8}:void 0)),x=this.props.schema.falseTextStyle),x=Object.assign(f,x),s=a.createElement("div",{style:x},b,a.createElement(l.Box,{style:{display:"flex",alignItems:"center",gap:8},sx:g,key:this.props.schema.blinkOnUpdate?k:void 0},C,k||(this.state.stateValue?p.I18n.t("ra_true"):p.I18n.t("ra_false"))))}else{const C=this.getText(this.props.schema.unit,this.props.schema.noTranslation)||this.state.obj.common.unit;let k=this.state.stateValue;if(k!=null&&(this.props.schema.options||this.state.obj.common.states)){const _=this.getNormalizedStates().find(O=>O.value===k);_&&(k=_.label)}let x,y;this.state.controlType==="html"?(y=(k||"").toString(),x=a.createElement("span",{dangerouslySetInnerHTML:{__html:k}})):this.state.stateValue===null?(x="null",y=x):this.state.stateValue===void 0?(x="undefined",y=x):(x=k.toString(),y=x),s=a.createElement("div",{style:f},b,a.createElement("div",{style:{display:"flex",alignItems:"baseline",gap:4}},a.createElement(l.Box,{sx:g,key:this.props.schema.blinkOnUpdate?y:void 0},x),C?a.createElement("span",{style:{opacity:.7,fontSize:"smaller"}},C):null))}}return s}}const Ee={fullWidth:u=>({width:"100%",backgroundColor:u.palette.mode==="dark"?"#FFF":"#000",borderStyle:"hidden"}),primary:u=>({backgroundColor:u.palette.primary.main}),secondary:u=>({backgroundColor:u.palette.secondary.main})};class Cs extends d{renderItem(){return a.createElement(l.Box,{component:"hr",sx:p.Utils.getStyle(this.props.oContext.theme,Ee.fullWidth,this.props.schema.color==="primary"?Ee.primary:this.props.schema.color==="secondary"?Ee.secondary:{backgroundColor:this.props.schema.color||(this.props.oContext.themeType==="dark"?"#333":"#ddd")},{height:this.props.schema.color?this.props.schema.height||2:this.props.schema.height||1})})}}const xs={header:u=>({width:"100%",background:u.palette.primary.main,color:u.palette.primary.contrastText,padding:"4px !important",borderRadius:"3px",marginBlockEnd:0,marginBlockStart:0})};class Es extends d{renderItem(){let e="h5";switch((this.props.schema.size||5).toString()){case"1":e="h1";break;case"2":e="h2";break;case"3":e="h3";break;case"4":e="h4";break;case"5":default:e="h5";break}return a.createElement(l.Box,{component:e,sx:xs.header},this.getText(this.props.schema.label||this.props.schema.text,this.props.schema.noTranslation))}}class Ts extends d{renderItem(){let e=this.props.schema.src;return e&&!e.startsWith(".")&&!e.startsWith("http")&&!e.startsWith(`adapter/${this.props.oContext.adapterName}/`)&&!e.startsWith(`./adapter/${this.props.oContext.adapterName}/`)&&(e=`adapter/${this.props.oContext.adapterName}/${e}`),a.createElement("img",{src:e,style:{cursor:this.props.schema.href?"pointer":void 0,width:"100%",height:"100%"},onClick:this.props.schema.href?()=>this.props.schema.href&&window.open(this.props.schema.href,"_blank"):null,alt:""})}}function Be(u,e,t){return typeof t=="string"?{"@keyframes newValueAnimationOnceColor":{"0%":{color:e?`${t} !important`:t},"100%":{color:u.palette.mode==="dark"?e?"#fff !important":"#fff":e?"#000 !important":"#000"}},animation:"newValueAnimationOnceColor 2s ease-in-out"}:{"@keyframes newValueAnimationOnce":{"0%":{color:e?"#00f900 !important":"#00f900"},"80%":{color:u.palette.mode==="dark"?e?"#518851 !important":"#518851":e?"#008000 !important":"#008000"},"100%":{color:u.palette.mode==="dark"?e?"#fff !important":"#fff":e?"#000 !important":"#000"}},animation:"newValueAnimationOnce 2s ease-in-out"}}function je(u,e){return typeof e=="string"?{"@keyframes blinkAnimationColor":{"0%":{color:e},"100%":{color:u.palette.mode==="dark"?"#fff":"#000"}},animation:"blinkAnimationColor 2s ease-in-out infinite"}:{"@keyframes blinkAnimation":{"0%":{color:"#00f900"},"80%":{color:u.palette.mode==="dark"?"#518851":"#008000"},"100%":{color:u.palette.mode==="dark"?"#fff":"#000"}},animation:"blinkAnimation 2s ease-in-out infinite"}}const Z={label:{fontWeight:"bold",whiteSpace:"nowrap"},valueImage:{maxHeight:"100%"},valueAndUnit:{display:"flex",gap:4,alignItems:"baseline"},value:{},unit:{fontSize:"smaller",opacity:.7}};class ws extends d{renderItem(e){let t=this.getText(this.props.schema.text||this.props.schema.label,this.props.schema.noTranslation);this.props.schema.addColon&&typeof t=="string"&&!t.trim().endsWith(":")&&(t=`${t.trim()}:`),t&&(t.includes("<a ")||t.includes("<br")||t.includes("<b>")||t.includes("<i>"))&&(t=p.Utils.renderTextWithA(t));let s;this.props.schema.size==="normal"?s=16:this.props.schema.size==="large"?s=20:typeof this.props.schema.size=="number"&&(s=this.props.schema.size);const n={width:"100%",height:"100%",display:"flex",alignItems:"center",position:"relative",fontSize:s};this.props.schema.narrow?n.gap=8:n.justifyContent="space-between";let i,o;this.props.schema.data&&typeof this.props.schema.data=="object"&&this.props.schema.data.en?o=this.getText(this.props.schema.data):typeof this.props.schema.data=="object"||this.props.schema.data===void 0||this.props.schema.data===null?o=JSON.stringify(this.props.schema.data):typeof this.props.schema.data=="number"?(o=this.props.schema.data.toString(),this.props.oContext.isFloatComma&&(o=o.replace(".",","))):(!this.props.schema.booleanAsCheckbox||typeof this.props.schema.data!="boolean")&&(o=this.props.schema.data.toString());let r=!1;if(this.props.schema.booleanAsCheckbox&&typeof this.props.schema.data=="boolean")i=a.createElement(l.Checkbox,{checked:!!i,disabled:!0,size:this.props.schema.size==="small"?"small":this.props.schema.size==="large"?"large":void 0});else if(o.startsWith("data:image/"))i=a.createElement("div",{style:{...Z.value,...Z.valueImage,...this.props.schema.styleValue||void 0}},a.createElement(p.Icon,{src:o}));else{const f={...Z.value,...this.props.schema.styleValue||void 0};this.props.schema.html?i=a.createElement("div",{style:f,dangerouslySetInnerHTML:{__html:o}}):Array.isArray(this.props.schema.data)?(r=!0,i=a.createElement("div",{style:f},this.props.schema.data.map((g,D)=>a.createElement("div",{key:D},typeof g=="object"||g===null||g===void 0?JSON.stringify(g):g)))):o.includes(`
|
|
3
|
+
`)?(r=!0,i=a.createElement("div",{style:f},p.Utils.renderTextWithA(o))):i=a.createElement("div",{style:f},o)}if(this.props.schema.blinkOnUpdate&&this.props.schema.blink){const f=Be(this.props.oContext.theme,!0,this.props.schema.blinkOnUpdate),g=je(this.props.oContext.theme,this.props.schema.blink);i=a.createElement(l.Box,{key:o,sx:{...f,...g}},i)}else if(this.props.schema.blinkOnUpdate){const f=Be(this.props.oContext.theme,!1,this.props.schema.blinkOnUpdate);i=a.createElement(l.Box,{key:o,sx:f},i)}else if(this.props.schema.blink){const f=je(this.props.oContext.theme,this.props.schema.blink);i=a.createElement(l.Box,{sx:f},i)}this.props.schema.unit&&(i=a.createElement("div",{style:Z.valueAndUnit},i,a.createElement("div",{style:{...Z.unit,...this.props.schema.styleUnit||void 0}},this.getText(this.props.schema.unit,this.props.schema.noTranslation))));let h;this.props.schema.labelIcon&&(h=a.createElement(p.Icon,{src:this.props.schema.labelIcon,style:{marginRight:4}}));let c;this.props.schema.copyToClipboard&&(c=a.createElement(v.ContentCopy,{className:"staticCopyButton",style:{position:"absolute",top:"calc(50% - 12px)",right:0,cursor:"pointer"},onClick:()=>{p.Utils.copyToClipboard(o),window.alert(p.I18n.t("ra_Copied"))}}));const m={"& .staticCopyButton":{display:"none"},"& .staticCopyButton:action":{transform:"scale(0.9)"},"&:hover .staticCopyButton":{display:"block"}};return this.props.schema.highlight&&(m["&:hover"]={backgroundColor:this.props.oContext.themeType==="dark"?"#51515180":"#b8b8b880"}),r&&(n.alignItems="top"),a.createElement(l.Box,{component:"div",style:n,sx:m},a.createElement("div",{style:{...Z.label,...this.props.schema.styleLabel||void 0}},h,t),i,c)}}const Pe={fullWidth:{height:"100%",width:"100%"},link:u=>({textDecoration:"underline",color:u.palette.mode==="dark"?"#4dabf5":"#254e72",cursor:"pointer"})};function We(u,e,t){let s,n="";u?u.toString().startsWith("#")||u.toString().startsWith("/")?(s=e||"_self",n=u):u.startsWith("http://")||u.startsWith("https://")?(s=e||"_blank",n=u):(n=`#tab-instances/config/${t}/${u}`,s=e||"_self"):(n=`#tab-instances/config/${t}`,s=e||"_self"),s==="_self"?setTimeout(i=>{i.startsWith("#")?window.location.hash=i:i.startsWith("/")?n=`${window.location.protocol}:${window.location.host}${n}`:(i.startsWith("http://")||i.startsWith("https://"))&&(window.location.href=i)},100,n):(n.startsWith("#")?n=`${window.location.protocol}:${window.location.host}${window.location.pathname}${n}`:n.startsWith("/")&&(n=`${window.location.protocol}:${window.location.host}${n}`),window.open(n,s))}class Ue extends d{renderItem(e,t){if(this.props.schema.button){const n=this.getIcon();return a.createElement(l.Button,{variant:this.props.schema.variant||void 0,color:this.props.schema.color||"grey",style:{...Pe.fullWidth,...this.props.schema.controlStyle||void 0},disabled:t,startIcon:n,onClick:this.props.schema.href?()=>{const i=this.props.schema.href?this.getText(this.props.schema.href,!0):null;i&&(this.props.oContext.onBackEndCommand?this.props.oContext.onBackEndCommand({command:"link",url:i,target:this.props.schema.target,close:this.props.schema.close}):We(i,this.props.schema.target,`${this.props.oContext.adapterName}.${this.props.oContext.instance}`))}:null},this.getText(this.props.schema.text||this.props.schema.label,this.props.schema.noTranslation))}let s=this.getText(this.props.schema.text||this.props.schema.label,this.props.schema.noTranslation);return s&&(s.includes("<a ")||s.includes("<br")||s.includes("<b>")||s.includes("<i>"))&&(s=p.Utils.renderTextWithA(s)),a.createElement(l.Box,{component:"span",style:{...this.props.schema.controlStyle||void 0},sx:this.props.schema.href?Pe.link:void 0,onClick:this.props.schema.href?()=>{const n=this.props.schema.href?this.getText(this.props.schema.href,!0):null;n&&(this.props.oContext.onBackEndCommand?this.props.oContext.onBackEndCommand({command:"link",url:n,target:this.props.schema.target||"_blank",close:this.props.schema.close}):We(n,this.props.schema.target||"_blank",`${this.props.oContext.adapterName}.${this.props.oContext.instance}`))}:null},s)}}const Te=1024*1024,$={paper:{width:"100%",marginBottom:16,backgroundColor:"rgba(255, 255, 255, 0.1)"},headerText:{width:"100%"},table:{minWidth:750},label:{display:"flex",justifyContent:"space-between"},title:{flex:"1 1 100%"},rootTool:{paddingLeft:16,paddingRight:8},silver:{opacity:.2},flex:{display:"flex",alignItems:"baseline"},filteredOut:{padding:10,display:"flex",textAlign:"center"},buttonEmpty:{width:34,display:"inline-block"},buttonCell:{whiteSpace:"nowrap"},dropZone:{width:"100%",height:100,position:"relative"},dropZoneEmpty:{},uploadDiv:{position:"relative",width:"100%",minHeight:300,opacity:.9,marginTop:30,cursor:"pointer",outline:"none"},uploadDivDragging:{opacity:1,background:"rgba(128,255,128,0.1)"},uploadCenterDiv:{margin:5,border:"3px dashed grey",borderRadius:5,width:"calc(100% - 10px)",height:"calc(100% - 10px)",minHeight:300,position:"relative",display:"flex"},uploadCenterIcon:{paddingTop:10,width:48,height:48},uploadCenterText:{fontSize:16},uploadCenterTextAndIcon:{textAlign:"center",position:"absolute",top:0,bottom:0,left:0,right:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},tooltip:{pointerEvents:"none"}};function Ss(u,e,t){e=e||"key";const s=[];return Object.keys(u).forEach(n=>{const i={};i[e]=n,t?(i[t]=u[n],s.push(i)):s.push(Object.assign(i,u[n]))}),s}function Me(u,e,t){e=e||"key";const s={};return u.forEach(n=>{let i=n[e];i==null&&(i=""),delete n[e],t?s[i]=n[t]:s[i]=n}),s}function Is(u,e){let t="";for(let s=0;s<e.length;s++)t+=String.fromCharCode(u[s%u.length].charCodeAt(0)^e.charCodeAt(s));return t}function ks(u,e){let t="";for(let s=0;s<e.length;s++)t+=String.fromCharCode(u[s%u.length].charCodeAt(0)^e.charCodeAt(s));return t}class P extends d{filterRefs;typingTimer=null;resizeTimeout=null;secret="Zgfr56gFe87jJOM";refDiv;constructor(e){super(e),this.filterRefs={},this.props.schema.items=this.props.schema.items||[],this.props.schema.items.forEach(t=>{t.filter&&(this.filterRefs[t.attr]=te.createRef())}),this.refDiv=a.createRef()}async componentDidMount(){super.componentDidMount();const e=d.getValue(this.props.data,this.props.attr)||[];let t;if(this.props.schema.objKeyName?t=Ss(e,this.props.schema.objKeyName,this.props.schema.objValueName):t=e,Array.isArray(t)||(t=[]),this.props.schema.encryptedAttributes){const s=await this.props.oContext.socket.getCompactSystemConfig();this.secret=(s==null?void 0:s.native.secret)||this.secret,e.forEach(n=>{this.props.schema.encryptedAttributes.forEach(i=>{n[i]&&(n[i]=ks(this.secret,n[i]))})})}this.setState({value:t,visibleValue:null,orderBy:"",order:"asc",iteration:0,filterOn:[],width:0,tableErrors:{}},()=>this.validateUniqueProps())}componentWillUnmount(){this.typingTimer&&(clearTimeout(this.typingTimer),this.typingTimer=null),this.resizeTimeout&&(clearTimeout(this.resizeTimeout),this.resizeTimeout=null),super.componentWillUnmount()}itemTable(e,t,s){var r;const{schema:n}=this.props,i=(r=n.items)==null?void 0:r.find(h=>h.attr===e);if(!i)return null;const o={items:{[e]:i}};return a.createElement(X,{oContext:this.props.oContext,alive:this.props.alive,arrayIndex:s,changed:this.props.changed,common:this.props.common,expertMode:this.props.expertMode,custom:!0,data:t,globalData:this.props.data,index:s+this.state.iteration,onChange:(h,c)=>{const m=JSON.parse(JSON.stringify(this.state.value));m[s][h]=c,this.setState({value:m},()=>{this.validateUniqueProps(),this.onChangeWrapper(m,!0)})},onError:this.onTableRowError(s),originalData:this.props.originalData,schema:o,table:!0,themeName:this.props.themeName})}validateUniqueProps(){if(!this.props.schema.uniqueColumns)return;let e=null,t=null;for(const s of this.props.schema.uniqueColumns){const n=[];this.state.value.find(o=>{const r=o[s];return n.includes(r)?(e||(e=s,t=r),this.onError(s,"is not unique"),!0):(n.push(r),!1)})||this.onError(s,null)}e?this.setState({errorMessage:p.I18n.t('Non-allowed duplicate entry "%s" in column "%s"',t,e)}):this.setState({errorMessage:""})}onTableRowError=e=>(t,s)=>{const n={...this.state.tableErrors};n[e]||(n[e]={}),s?n[e][t]=s:(delete n[e][t],Object.keys(n[e]).length===0&&delete n[e]),this.setState({tableErrors:n}),this.props.onError(t,s)};static descendingComparator(e,t,s){return t[s]<e[s]?-1:t[s]>e[s]?1:0}static getComparator(e,t){return e==="desc"?(s,n)=>P.descendingComparator(s,n,t):(s,n)=>-P.descendingComparator(s,n,t)}static getFilterValue(e){var t,s,n;return(n=(s=(t=e==null?void 0:e.current)==null?void 0:t.children[0])==null?void 0:s.children[0])==null?void 0:n.value}static setFilterValue(e,t){return e.current.children[0].children[0].value=t}handleRequestSort=(e,t=!1)=>{const{order:s,orderBy:n}=this.state,o=t?s:n===e&&s==="asc"?"desc":"asc",r=this.stableSort(o,e);JSON.stringify(r)!==JSON.stringify(this.state.value)&&this.setState({value:r,order:o,orderBy:e,iteration:this.state.iteration+1e4},()=>this.applyFilter(!1,r))};stableSort=(e,t)=>{const{value:s}=this.state,n=P.getComparator(e,t),i=s.map((o,r)=>({el:o,index:r}));return i.sort((o,r)=>{const h=n(o.el,r.el);return h!==0?h:o.index-r.index}),i.map(o=>o.el)};renderShowHideFilter(e){return e.filter?a.createElement(l.IconButton,{title:p.I18n.t("ra_Show/hide filter input"),size:"small",onClick:()=>{const t=[...this.state.filterOn],s=this.state.filterOn.indexOf(e.attr);s===-1?t.push(e.attr):t.splice(s,1),this.setState({filterOn:t},()=>{s&&P.getFilterValue(this.filterRefs[e.attr])&&(P.setFilterValue(this.filterRefs[e.attr],""),this.applyFilter())})}},this.state.filterOn.includes(e.attr)?a.createElement(v.FilterAltOff,null):a.createElement(v.FilterAlt,null)):null}renderImportExportButtons(e){return a.createElement(a.Fragment,null,!e.noDelete&&e.import?a.createElement(l.Tooltip,{title:p.I18n.t("ra_Import data from %s file","CSV"),slotProps:{popper:{sx:$.tooltip}}},a.createElement(l.IconButton,{size:"small",onClick:()=>this.setState({showImportDialog:!0})},a.createElement(v.UploadFile,null))):null,e.export?a.createElement(l.Tooltip,{title:p.I18n.t("ra_Export data to %s file","CSV"),slotProps:{popper:{sx:$.tooltip}}},a.createElement(l.IconButton,{size:"small",onClick:()=>this.onExport()},a.createElement(v.Download,null))):null,e.noDelete?null:a.createElement(l.IconButton,{disabled:!0,size:"small"},a.createElement(v.Delete,null)))}renderAddButton(e){return a.createElement(l.Tooltip,{title:e?p.I18n.t("ra_Cannot add items with set filter"):p.I18n.t("ra_Add row"),slotProps:{popper:{sx:$.tooltip}}},a.createElement("span",null,a.createElement(l.IconButton,{size:"small",color:"primary",disabled:!!e&&!this.props.schema.allowAddByFilter,onClick:this.onAdd},a.createElement(v.Add,null))))}enhancedTableHead(e,t){var o;const{schema:s}=this.props,{order:n,orderBy:i}=this.state;return a.createElement(l.TableHead,null,a.createElement(l.TableRow,null,(o=s.items)==null?void 0:o.map((r,h)=>this.renderOneFilter({schema:s,style:{width:r.width},showAddButton:!h&&!s.noDelete,headCell:r,order:n,orderBy:i,index:h,doAnyFilterSet:t})),!s.noDelete&&a.createElement(l.TableCell,{style:{paddingLeft:20,paddingRight:20,width:e,textAlign:"right"},padding:"checkbox"},this.renderImportExportButtons(s))))}onDelete=e=>()=>{const t=JSON.parse(JSON.stringify(this.state.value));t.splice(e,1);const s={...this.state.tableErrors};s[e]&&(Object.keys(s[e]).forEach(i=>{this.props.onError(i,void 0)}),delete s[e]);const n={};Object.keys(s).forEach(i=>{const o=parseInt(i,10);o>e?n[o-1]=s[o]:n[o]=s[o]}),this.setState({value:t,iteration:this.state.iteration+1e4,tableErrors:n},()=>this.applyFilter(!1,null,()=>this.onChangeWrapper(t)))};onExport(){const{schema:e}=this.props,{value:t}=this.state,n=[e.items.map(r=>r.attr).join(";")];t.forEach(r=>{const h=[];e.items.forEach(c=>{r[c.attr]&&typeof r[c.attr]=="string"&&r[c.attr].includes(";")?h.push(`"${r[c.attr]}"`):h.push(r[c.attr]===void 0||r[c.attr]===null?"":r[c.attr])}),n.push(h.join(";"))});const i=document.createElement("a");i.setAttribute("href",`data:text/csv;charset=utf-8,${encodeURIComponent(n.join(`
|
|
4
|
+
`))}`);const o=new Date;i.setAttribute("download",`${o.getFullYear()}_${(o.getMonth()+1).toString().padStart(2,"0")}_${o.getDate().toString().padStart(2,"0")}_${this.props.oContext.adapterName}.${this.props.oContext.instance}_${this.props.attr}.csv`),i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i)}onImport(e){var o;const t=e.split(`
|
|
5
|
+
`).map(r=>r.replace("\r","").trim()),{schema:s}=this.props,n=t.shift().split(";").filter(r=>r&&s.items.find(h=>h.attr===r)),i=[];t.forEach(r=>{const h=r.split(";"),c={};for(let m=0;m<h.length;m++){let f=h[m];if(f.startsWith('"')){for(f=f.substring(1);m<h.length&&!f.endsWith('"');)f+=`;${h[++m]}`;f=f.substring(0,f.length-1)}let g=f;if(f==="true")g=!0;else if(f==="false")g=!1;else if(window.isFinite(f)){const D=this.props.schema.items.find(b=>b.attr===n[m]);D&&D.type==="number"?g=parseFloat(f):g=f}else g=f;c[n[m]]=g}i.push(c)}),i.length?(o=this.state.value)!=null&&o.length?this.setState({showTypeOfImportDialog:i,showImportDialog:!1}):this.setState({value:i,showImportDialog:!1}):window.alert("ra_No data found in file")}onClone=e=>()=>{const t=JSON.parse(JSON.stringify(this.state.value)),s=JSON.parse(JSON.stringify(t[e]));if(typeof this.props.schema.clone=="string"&&typeof s[this.props.schema.clone]=="string"){let n=1,i=s[this.props.schema.clone];const o=i.match(/(\d+)$/);for(o?(i=i.replace(o[0],""),n=parseInt(o[0],10)+1):i+="_";t.find(r=>r[this.props.schema.clone]===i+n.toString());)n++;s[this.props.schema.clone]=`${s[this.props.schema.clone]}_${n}`}t.splice(e,0,s),this.setState({value:t,iteration:this.state.iteration+1e4},()=>this.applyFilter(!1,null,()=>this.onChangeWrapper(t)))};onChangeWrapper=(e,t)=>{this.typingTimer&&clearTimeout(this.typingTimer),this.typingTimer=setTimeout((s,n)=>{this.typingTimer=null;let i;if(this.props.schema.encryptedAttributes){const o=JSON.parse(JSON.stringify(s));if(o.forEach(r=>{this.props.schema.encryptedAttributes.forEach(h=>{r[h]&&(r[h]=Is(this.secret,r[h]))})}),this.props.schema.objKeyName){const r=Me(o,this.props.schema.objKeyName,this.props.schema.objValueName);i=this.onChange(this.props.attr,r)}else i=this.onChange(this.props.attr,o)}else if(this.props.schema.objKeyName){const o=Me(JSON.parse(JSON.stringify(s)),this.props.schema.objKeyName,this.props.schema.objValueName);i=this.onChange(this.props.attr,o)}else i=this.onChange(this.props.attr,s);i instanceof Promise&&i.catch(o=>console.error(`Cannot save: ${o}`)),n&&(this.applyFilter(!1,s),this.handleRequestSort(this.state.orderBy,!0))},300,e,t)};onAdd=()=>{var n;const{schema:e}=this.props,t=JSON.parse(JSON.stringify(this.state.value)),s=(n=e.items)==null?void 0:n.reduce((i,o)=>{let r;return o.defaultFunc?this.props.custom?r=o.defaultFunc?this.executeCustom(o.defaultFunc,this.props.data,this.props.customObj,this.props.oContext.instanceObj,t.length,this.props.data):this.props.schema.default:r=o.defaultFunc?this.execute(o.defaultFunc,this.props.schema.default,this.props.data,t.length,this.props.data):this.props.schema.default:r=o.default===void 0?null:o.default,i[o.attr]=r,i},{});t.push(s),this.setState({value:t},()=>this.applyFilter(!1,null,()=>this.onChangeWrapper(t)))};isAnyFilterSet(){return!!Object.keys(this.filterRefs).find(e=>P.getFilterValue(this.filterRefs[e]))}applyFilter=(e,t,s)=>{t=t||this.state.value;let n=t.map((i,o)=>o);if(Object.keys(this.filterRefs).forEach(i=>{let o=P.getFilterValue(this.filterRefs[i]);!e&&o?(o=o.toLowerCase(),n=n.filter(r=>t[r]&&t[r][i]&&t[r][i].toLowerCase().includes(o))):this.filterRefs[i].current&&P.setFilterValue(this.filterRefs[i],"")}),n.length===t.length&&(n=null),n===null&&this.state.visibleValue===null){s&&s();return}JSON.stringify(n)!==JSON.stringify(this.state.visibleValue)?this.setState({visibleValue:n},()=>s&&s()):s&&s()};onMoveUp(e){const t=JSON.parse(JSON.stringify(this.state.value)),s=t[e];t.splice(e,1),t.splice(e-1,0,s),this.setState({value:t,iteration:this.state.iteration+1e4},()=>this.applyFilter(!1,null,()=>this.onChangeWrapper(t)))}onMoveDown(e){const t=JSON.parse(JSON.stringify(this.state.value)),s=t[e];t.splice(e,1),t.splice(e+1,0,s),this.setState({value:t,iteration:this.state.iteration+1e4},()=>this.applyFilter(!1,null,()=>this.onChangeWrapper(t)))}onDrop(e){const t=e[0],s=new FileReader;s.onabort=()=>console.log("file reading was aborted"),s.onerror=()=>console.log("file reading has failed"),s.onload=()=>{if(t.size>Te){window.alert(p.I18n.t("ra_File is too big. Max %sk allowed. Try use SVG.",Math.round(Te/1024)));return}const n=new Uint8Array(s.result).reduce((i,o)=>i+String.fromCharCode(o),"");this.onImport(n)},s.readAsArrayBuffer(t)}showTypeOfImportDialog(){return this.state.showTypeOfImportDialog?a.createElement(l.Dialog,{open:!0,onClose:()=>this.setState({showTypeOfImportDialog:!1}),maxWidth:"md"},a.createElement(l.DialogTitle,null,p.I18n.t("ra_Append or replace?")),a.createElement(l.DialogContent,null,p.I18n.t("ra_Append %s entries or replace existing?",this.state.showTypeOfImportDialog.length)),a.createElement(l.DialogActions,null,a.createElement(l.Button,{variant:"contained",color:"primary",autoFocus:!0,onClick:()=>{const e=JSON.parse(JSON.stringify(this.state.value));this.state.showTypeOfImportDialog.forEach(t=>e.push(t)),this.setState({value:e,iteration:this.state.iteration+1e4,showTypeOfImportDialog:!1},()=>this.applyFilter(!1,null,()=>this.onChangeWrapper(e)))}},p.I18n.t("ra_Append")),a.createElement(l.Button,{variant:"contained",color:"secondary",autoFocus:!0,onClick:()=>{const e=this.state.showTypeOfImportDialog;this.setState({value:e,iteration:this.state.iteration+1e4,showTypeOfImportDialog:!1},()=>this.applyFilter(!1,null,()=>this.onChangeWrapper(e)))}},p.I18n.t("ra_Replace")))):null}showImportDialog(){return this.state.showImportDialog?a.createElement(l.Dialog,{open:!0,onClose:()=>this.setState({showImportDialog:!1}),sx:{"& .MuiDialog-paper":{minHeight:500}},maxWidth:"md",fullWidth:!0},a.createElement(l.DialogTitle,null,p.I18n.t("ra_Import from %s","CSV")),a.createElement(l.DialogContent,null,a.createElement(qe,{multiple:!1,accept:{"text/csv":[".csv"]},maxSize:Te,onDragEnter:()=>this.setState({uploadFile:"dragging"}),onDragLeave:()=>this.setState({uploadFile:!0}),onDrop:(e,t)=>{this.setState({uploadFile:!1}),e.length?this.onDrop(e):window.alert(t&&t[0]&&t[0].errors&&t[0].errors[0]&&t[0].errors[0].message||p.I18n.t("ra_Cannot upload"))}},({getRootProps:e,getInputProps:t})=>a.createElement("div",{style:{...$.uploadDiv,...this.state.uploadFile==="dragging"?$.uploadDivDragging:void 0,...$.dropZone,...this.state.icon?void 0:$.dropZoneEmpty},...e()},a.createElement("input",{...t()}),a.createElement("div",{style:$.uploadCenterDiv},a.createElement("div",{style:$.uploadCenterTextAndIcon},a.createElement(v.UploadFile,{style:$.uploadCenterIcon}),a.createElement("div",{style:$.uploadCenterText},this.state.uploadFile==="dragging"?p.I18n.t("ra_Drop file here"):p.I18n.t("ra_Place your files here or click here to open the browse dialog"))))))),a.createElement(l.DialogActions,null,a.createElement(l.Button,{variant:"contained",onClick:()=>this.setState({showImportDialog:!1}),color:"primary",startIcon:a.createElement(v.Close,null)},p.I18n.t("Cancel")))):null}renderOneFilter(e){return a.createElement(l.TableCell,{key:`${e.headCell.attr}_${e.index}`,style:e.style,align:"left",sortDirection:e.orderBy===e.headCell.attr?e.order:!1},a.createElement("div",{style:{...$.flex,...e.schema.showFirstAddOnTop?{flexDirection:"column"}:void 0}},e.showAddButton?this.renderAddButton(e.doAnyFilterSet):null,e.headCell.sort&&a.createElement(l.TableSortLabel,{active:!0,style:e.orderBy!==e.headCell.attr?$.silver:void 0,direction:e.orderBy===e.headCell.attr?e.order:"asc",onClick:()=>this.handleRequestSort(e.headCell.attr)}),e.headCell.filter&&this.state.filterOn.includes(e.headCell.attr)?a.createElement(l.TextField,{variant:"standard",ref:this.filterRefs[e.headCell.attr],onChange:()=>this.applyFilter(),title:p.I18n.t("ra_You can filter entries by entering here some text"),slotProps:{input:{endAdornment:P.getFilterValue(this.filterRefs[e.headCell.attr])&&a.createElement(l.InputAdornment,{position:"end"},a.createElement(l.IconButton,{size:"small",tabIndex:-1,onClick:()=>{P.setFilterValue(this.filterRefs[e.headCell.attr],""),this.applyFilter()}},a.createElement(v.Close,null)))}},fullWidth:!0,placeholder:this.getText(e.headCell.title)}):a.createElement("span",{style:$.headerText},this.getText(e.headCell.title)),this.renderShowHideFilter(e.headCell)))}enhancedFilterCard(){var o;const{schema:e}=this.props,{order:t,orderBy:s}=this.state;let n;this.props.schema.compact&&(n={paddingTop:1,paddingBottom:1});const i=!e.noDelete&&e.import||e.export;return i||e.items.find(r=>r.sort||r.filter)?a.createElement(l.Grid2,{size:{xs:e.xs||12,sm:e.sm||void 0,md:e.md||void 0,lg:e.lg||void 0,xl:e.xl||void 0}},a.createElement(l.Card,null,a.createElement(l.Paper,{style:$.paper},a.createElement(l.Accordion,{style:$.paper},a.createElement(l.AccordionSummary,{expandIcon:a.createElement(v.ExpandMore,null)},a.createElement(l.Typography,null,p.I18n.t("ra_Filter and Data Actions"))),a.createElement(l.AccordionDetails,null,a.createElement(l.Table,null,a.createElement(l.TableBody,null,((o=e.items)==null?void 0:o.find(r=>r.sort||r.filter))&&e.items.map((r,h)=>a.createElement(l.TableRow,{key:`${r.attr}_${h}`},this.renderOneFilter({schema:e,style:n,showAddButton:!1,headCell:r,order:t,orderBy:s,index:h,doAnyFilterSet:!1}))),i?a.createElement(l.TableRow,null,a.createElement(l.TableCell,{align:"left",style:n},a.createElement("span",{style:$.headerText},p.I18n.t("ra_Actions"))),a.createElement(l.TableCell,{style:n},this.renderImportExportButtons(e))):null))))))):null}enhancedBottomCard(){const{schema:e}=this.props;let t;this.props.schema.compact&&(t={paddingTop:1,paddingBottom:1});const s=this.isAnyFilterSet();return a.createElement(l.Grid2,{size:{xs:e.xs||12,sm:e.sm||void 0,md:e.md||void 0,lg:e.lg||void 0,xl:e.xl||void 0}},a.createElement(l.Card,null,a.createElement(l.Paper,{style:$.paper},a.createElement(l.Table,null,a.createElement(l.TableBody,null,a.createElement(l.TableRow,null,a.createElement(l.TableCell,{colSpan:e.items.length+1,style:t},this.renderAddButton(s))))))))}renderCards(){const{schema:e}=this.props;let{visibleValue:t}=this.state,s;this.props.schema.compact&&(s={paddingTop:1,paddingBottom:1}),t||=this.state.value.map((i,o)=>o);const n=this.isAnyFilterSet();return a.createElement(l.Grid2,{container:!0},this.showImportDialog(),this.showTypeOfImportDialog(),this.enhancedFilterCard(),t.map((i,o)=>{var r;return a.createElement(l.Grid2,{key:`${i}_${o}`,size:{xs:e.xs||12,sm:e.sm||void 0,md:e.md||void 0,lg:e.lg||void 0,xl:e.xl||void 0}},a.createElement(l.Card,null,a.createElement(l.Paper,{style:$.paper},a.createElement(l.Table,null,a.createElement(l.TableBody,null,(r=e.items)==null?void 0:r.map(h=>a.createElement(l.TableRow,{key:`${h.attr}_${i}`},a.createElement(l.TableCell,{align:"left",style:s},a.createElement("span",{style:$.headerText},this.getText(h.title))),a.createElement(l.TableCell,{align:"left",style:s},this.itemTable(h.attr,this.state.value[i],i)))),!e.noDelete&&a.createElement(l.TableRow,null,a.createElement(l.TableCell,{align:"left",style:s},a.createElement("span",{style:$.headerText},this.getText("Actions"))),a.createElement(l.TableCell,{align:"left",style:s},!n&&!this.state.orderBy?a.createElement(l.Tooltip,{title:p.I18n.t("ra_Move up"),slotProps:{popper:{sx:$.tooltip}}},a.createElement("span",null,a.createElement(l.IconButton,{size:"small",onClick:()=>this.onMoveUp(i),disabled:o===0},a.createElement(v.ArrowUpward,null)))):null,!n&&!this.state.orderBy?a.createElement(l.Tooltip,{title:p.I18n.t("ra_Move down"),slotProps:{popper:{sx:$.tooltip}}},a.createElement("span",null,a.createElement(l.IconButton,{size:"small",onClick:()=>this.onMoveDown(i),disabled:o===t.length-1},a.createElement(v.ArrowDownward,null)))):null,a.createElement(l.Tooltip,{title:p.I18n.t("ra_Delete current row"),slotProps:{popper:{sx:$.tooltip}}},a.createElement(l.IconButton,{size:"small",onClick:this.onDelete(i)},a.createElement(v.Delete,null))),this.props.schema.clone?a.createElement(l.Tooltip,{title:p.I18n.t("ra_Clone current row"),slotProps:{popper:{sx:$.tooltip}}},a.createElement(l.IconButton,{size:"small",onClick:this.onClone(i)},a.createElement(v.ContentCopy,null))):null)))))))}),this.enhancedBottomCard())}renderTable(){const{schema:e}=this.props;let{visibleValue:t}=this.state;t=t||this.state.value.map((i,o)=>o);const s=this.isAnyFilterSet();let n;return this.props.schema.compact&&(n={paddingTop:1,paddingBottom:1}),a.createElement(l.Paper,{style:$.paper},this.showImportDialog(),this.showTypeOfImportDialog(),e.label?a.createElement("div",{style:$.label},a.createElement(l.Toolbar,{variant:"dense",style:$.rootTool},a.createElement(l.Typography,{style:$.title,variant:"h6",id:"tableTitle",component:"div"},this.getText(e.label)))):null,a.createElement(l.TableContainer,null,a.createElement(l.Table,{style:$.table,size:"small"},this.enhancedTableHead(!s&&!this.state.orderBy?120:64,s),a.createElement(l.TableBody,null,t.map((i,o)=>{var r;return a.createElement(l.TableRow,{hover:!0,key:`${i}_${o}`},(r=e.items)==null?void 0:r.map(h=>a.createElement(l.TableCell,{key:`${h.attr}_${i}`,align:"left",style:n},this.itemTable(h.attr,this.state.value[i],i))),!e.noDelete&&a.createElement(l.TableCell,{align:"left",style:{...n,...$.buttonCell}},!s&&!this.state.orderBy?o?a.createElement(l.Tooltip,{title:p.I18n.t("ra_Move up"),slotProps:{popper:{sx:$.tooltip}}},a.createElement(l.IconButton,{size:"small",onClick:()=>this.onMoveUp(i)},a.createElement(v.ArrowUpward,null))):a.createElement("div",{style:$.buttonEmpty}):null,!s&&!this.state.orderBy?o<t.length-1?a.createElement(l.Tooltip,{title:p.I18n.t("ra_Move down"),slotProps:{popper:{sx:$.tooltip}}},a.createElement(l.IconButton,{size:"small",onClick:()=>this.onMoveDown(i)},a.createElement(v.ArrowDownward,null))):a.createElement("div",{style:$.buttonEmpty}):null,a.createElement(l.Tooltip,{title:p.I18n.t("ra_Delete current row"),slotProps:{popper:{sx:$.tooltip}}},a.createElement(l.IconButton,{size:"small",onClick:this.onDelete(i)},a.createElement(v.Delete,null))),this.props.schema.clone?a.createElement(l.Tooltip,{title:p.I18n.t("ra_Clone current row"),slotProps:{popper:{sx:$.tooltip}}},a.createElement(l.IconButton,{size:"small",onClick:this.onClone(i)},a.createElement(v.ContentCopy,null))):null))}),!e.noDelete&&t.length>=(e.showSecondAddAt||5)?a.createElement(l.TableRow,null,a.createElement(l.TableCell,{colSpan:e.items.length+1,style:{...n}},this.renderAddButton(s))):null)),!t.length&&this.state.value.length?a.createElement("div",{style:$.filteredOut},a.createElement(l.Typography,{style:$.title,variant:"h6",id:"tableTitle",component:"div"},p.I18n.t("ra_All items are filtered out"),a.createElement(l.IconButton,{size:"small",onClick:()=>this.applyFilter(!0)},a.createElement(v.Close,null)))):null),e.help?a.createElement(l.FormHelperText,{style:{paddingLeft:16}},this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null,this.state.errorMessage?a.createElement("div",{style:{display:"flex",padding:"5px"}},a.createElement(v.Warning,{color:"error"}),a.createElement("span",{style:{color:"red",alignSelf:"center"}},this.state.errorMessage)):null)}componentDidUpdate(){var e;(e=this.refDiv.current)!=null&&e.clientWidth&&this.refDiv.current.clientWidth!==this.state.width&&(this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{var t;this.resizeTimeout=null,this.setState({width:(t=this.refDiv.current)==null?void 0:t.clientWidth})},50))}getCurrentBreakpoint(){return this.state.width?this.state.width<600?"xs":this.state.width<900?"sm":this.state.width<1200?"md":this.state.width<1536?"lg":"xl":"md"}renderItem(){const{schema:e}=this.props;if(!this.state.value||!Array.isArray(this.state.value))return null;const t=this.getCurrentBreakpoint();let s;return t&&(e.useCardFor||["xs"]).includes(t)?s=this.renderCards():s=this.renderTable(),a.createElement("div",{ref:this.refDiv,style:{width:"100%"}},s)}}const ce={indeterminate:{opacity:.5},label:{width:"100%",fontSize:14,marginBottom:2},helper:{width:"100%",fontSize:12},error:{width:"100%",fontSize:12,color:"#FF0000"}};class Ds extends d{updateTimeout=null;componentDidMount(){super.componentDidMount();let e=d.getValue(this.props.data,this.props.attr);if(Array.isArray(e)&&this.props.oContext.multiEdit){e=d.DIFFERENT_VALUE,this.setState({value:e,oldValue:e,jsonError:!1});return}this.setState({value:e,oldValue:e,jsonError:this.validateJson(e)})}validateJson(e){let t=!1;if(this.props.schema.validateJson&&(e||!this.props.schema.allowEmpty))try{JSON.parse(e)}catch(s){console.log("Error in JSON",s),t=!0}return t}static getDerivedStateFromProps(e,t){if(e.oContext.multiEdit&&t.value===d.DIFFERENT_VALUE)return{value:d.DIFFERENT_VALUE};let s=d.getValue(e.data,e.attr);return s!=null&&(s=s.toString()),s==null||s!==t.value&&s!==t.oldValue?{value:s}:null}renderItem(e,t){const s=Array.isArray(this.state.value)||this.state.value===d.DIFFERENT_VALUE;if(this.props.schema.time){let o="";return typeof this.state.value=="number"?this.state.value&&this.state.value<9466596e5?o=new Date(this.state.value*1e3).toLocaleString():o=new Date(this.state.value).toLocaleString():typeof this.state.value=="string"&&(o=new Date(this.state.value).toLocaleString()),a.createElement(l.TextField,{variant:"standard",fullWidth:!0,value:o,error:!!e||!!this.state.jsonError,disabled:!!t,slotProps:{htmlInput:{readOnly:!0}},placeholder:this.getText(this.props.schema.placeholder),label:this.getText(this.props.schema.label),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)})}if(this.state.oldValue!==null&&this.state.oldValue!==void 0?(this.updateTimeout&&clearTimeout(this.updateTimeout),this.updateTimeout=setTimeout(()=>{this.updateTimeout=null,this.setState({oldValue:null})},30)):this.updateTimeout&&(clearTimeout(this.updateTimeout),this.updateTimeout=null),s){const o=d.getValue(this.props.data,this.props.attr),r=(o==null?void 0:o.filter(h=>h||h===0).map(h=>({label:h.toString()||"",value:h})))||[];return r.unshift({label:p.I18n.t(d.DIFFERENT_LABEL),value:d.DIFFERENT_VALUE}),a.createElement(l.Autocomplete,{style:ce.indeterminate,fullWidth:!0,value:r[0],onChange:(h,c)=>{const m=c?c.value:"",f=this.onChange(this.props.attr,m,()=>{this.setState({value:m,oldValue:m,jsonError:this.validateJson(c)})});f instanceof Promise&&f.catch(g=>console.error(`Cannot set value: ${g}`))},options:r,getOptionLabel:h=>h.label,renderInput:h=>a.createElement(l.TextField,{variant:"standard",...h,error:!!e,placeholder:this.getText(this.props.schema.placeholder),slotProps:{htmlInput:{...h.inputProps,maxLength:this.props.schema.maxLength||this.props.schema.max||void 0,readOnly:this.props.schema.readOnly||!1}},label:this.getText(this.props.schema.label),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation),disabled:!!t})})}let n,i;if((this.props.schema.readOnly||t)&&this.props.schema.copyToClipboard?(this.props.schema.minRows>1&&(i={position:"absolute",right:3,top:20,zIndex:1e3}),n=a.createElement(l.IconButton,{tabIndex:-1,style:i,size:"small",onClick:()=>{p.Utils.copyToClipboard(this.state.value),window.alert(p.I18n.t("ra_Copied"))}},a.createElement(p.IconCopy,null))):!this.props.schema.readOnly&&!t&&this.state.value&&!this.props.schema.noClearButton&&(this.props.schema.minRows>1&&(i={position:"absolute",right:3,top:20,zIndex:1e3}),n=a.createElement(l.IconButton,{style:i,size:"small",tabIndex:-1,onClick:()=>this.setState({value:"",oldValue:this.state.value},()=>this.onChange(this.props.attr,""))},a.createElement(v.Close,null)),this.props.schema.minRows<=1&&(n=a.createElement(l.InputAdornment,{position:"end"},n))),this.props.schema.minRows>1){const o=this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation);return a.createElement("div",{style:{width:"100%",position:"relative"}},this.props.schema.label?a.createElement("div",{style:ce.label},this.getText(this.props.schema.label)):null,a.createElement(l.TextareaAutosize,{style:{width:"100%",resize:"vertical",backgroundColor:this.props.oContext.themeType==="dark"?"#363636":"#cccccc",color:this.props.oContext.themeType==="dark"?"#fff":"#111"},minRows:this.props.schema.minRows,maxRows:this.props.schema.maxRows,value:this.state.value===null||this.state.value===void 0?"":this.state.value,disabled:!!t,readOnly:this.props.schema.readOnly||!1,onChange:r=>{const h=r.target.value;this.setState({value:h,oldValue:this.state.value,jsonError:this.validateJson(h)},()=>this.onChange(this.props.attr,h||""))},placeholder:this.getText(this.props.schema.placeholder)}),o||e||this.state.jsonError?a.createElement("div",{style:e?ce.error:ce.helper},e||(this.state.jsonError?p.I18n.t("ra_Invalid JSON"):o)):null)}return a.createElement(l.TextField,{variant:"standard",fullWidth:!0,value:this.state.value===null||this.state.value===void 0?"":this.state.value,error:!!e||!!this.state.jsonError,disabled:!!t,slotProps:{htmlInput:{maxLength:this.props.schema.maxLength||this.props.schema.max||void 0,readOnly:this.props.schema.readOnly||!1},input:{endAdornment:n}},onChange:o=>{const r=o.target.value;this.setState({value:r,oldValue:this.state.value,jsonError:this.validateJson(r)},()=>this.onChange(this.props.attr,r))},placeholder:this.getText(this.props.schema.placeholder),label:this.getText(this.props.schema.label),helperText:this.state.jsonError?p.I18n.t("ra_Invalid JSON"):this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)})}}const _s={fullWidth:{width:"100%"}};class Os extends d{initialized=!1;localContext;askInstance(){if(this.props.alive){let e=this.props.schema.data;if(e===void 0&&this.props.schema.jsonData){const t=this.getPattern(this.props.schema.jsonData,null,!0);try{e=JSON.parse(t)}catch{console.error(`Cannot parse json data: ${t}`)}}e===void 0&&(e=null),this.props.oContext.socket.sendTo(`${this.props.oContext.adapterName}.${this.props.oContext.instance}`,this.props.schema.command||"send",e).then(t=>{if(typeof t=="object"){const s=t;this.setState({text:s.text||"",style:s.style,icon:s.icon,iconStyle:s.iconStyle})}else typeof t=="string"&&this.setState({text:t||""})}).catch(t=>console.error(`Cannot send command: ${t}`))}}getLocalContext(){const e={};return Array.isArray(this.props.schema.alsoDependsOn)&&this.props.schema.alsoDependsOn.forEach(t=>e[t]=d.getValue(this.props.data,t)),JSON.stringify(e)}renderItem(){if(this.props.alive){const t=this.getLocalContext();(t!==this.localContext||!this.initialized)&&(this.localContext=t,setTimeout(()=>this.askInstance(),this.initialized?300:50),this.initialized=!0)}if(this.state.text===void 0)return null;let e=null;return this.state.icon&&(e=q(this.state.icon,{marginRight:this.state.text?8:void 0,...this.state.iconStyle||void 0}),e||(e=a.createElement(p.Icon,{src:this.state.icon,style:{marginRight:this.state.text?8:void 0,...this.state.iconStyle||void 0}}))),this.props.schema.container==="text"?a.createElement(l.TextField,{variant:"standard",fullWidth:!0,slotProps:{input:{endAdornment:this.props.schema.copyToClipboard?a.createElement(l.IconButton,{tabIndex:-1,size:"small",onClick:()=>{p.Utils.copyToClipboard(this.state.text),window.alert(p.I18n.t("ra_Copied"))}},a.createElement(p.IconCopy,null)):void 0}},value:this.state.text,label:this.getText(this.props.schema.label),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)}):a.createElement("div",{style:{..._s.fullWidth,...this.state.style||void 0}},e,this.props.schema.container==="html"?a.createElement("span",{dangerouslySetInnerHTML:{__html:this.state.text||""}}):this.state.text)}}class Fs extends d{componentDidMount(){super.componentDidMount();const e=d.getValue(this.props.data,this.props.attr);this.setState({value:e})}renderItem(e,t){const s=this.props.schema.returnFormat!=="HH:mm:ss",n=new Date(Date.parse(`Thu, 01 Jan 1970 ${this.state.value||"00:00:00"}`));return a.createElement(He.TimePicker,{sx:i=>({width:"100%",borderBottom:`1px solid ${i.palette.text.primary}`,"& fieldset":{display:"none"},"& input":{padding:`${i.spacing(1.5)} 0 4px 0`},"& .MuiInputAdornment-root":{marginLeft:0,marginTop:1},"& label":{transform:"translate(0px, -9px) scale(0.75)"}}),ampm:this.props.oContext.systemConfig.dateFormat.includes("/"),timeSteps:this.props.schema.timeSteps||this.props.schema.timesteps||{hours:1,minutes:5,seconds:5},format:this.props.schema.format||"HH:mm:ss",disabled:!!t,value:n,onChange:i=>{let o;o=i instanceof Date?i.toTimeString().split(" ")[0]:i.toTimeString(),s&&(o=o.split(":").slice(0,2).join(":")),this.setState({value:o},()=>this.onChange(this.props.attr,this.state.value))},views:this.props.schema.views||["hours","minutes","seconds"],label:this.getText(this.props.schema.label)})}}function $s(u,e){let t;return e&&u.substring(0,e.length)===e?t=u.substring(e.length+1):t=u,t=t.replace(/\./g,"/").replace(/_/g," "),t}class Ns extends d{componentDidMount(){var t;super.componentDidMount();const e=d.getValue(this.props.data,this.props.attr);if(!e&&((t=this.props.customObj)!=null&&t._id)){const s=$s(this.props.customObj._id,`${this.props.oContext.adapterName}.${this.props.oContext.instance}`);this.setState({value:s})}else this.setState({value:e||""})}renderItem(e,t){return a.createElement(l.TextField,{variant:"standard",fullWidth:!0,slotProps:{htmlInput:{maxLength:this.props.schema.maxLength||this.props.schema.max||void 0}},value:this.state.value,error:!!e,disabled:t,placeholder:this.getText(this.props.schema.placeholder),label:this.getText(this.props.schema.label),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation),onChange:s=>{const n=s.target.value;this.setState({value:n},()=>this.onChange(this.props.attr,n))}})}}class As extends d{async componentDidMount(){var t;super.componentDidMount();const e=await this.props.oContext.socket.getObject("system.meta.uuid");this.setState({uuid:((t=e==null?void 0:e.native)==null?void 0:t.uuid)||"unknown"})}renderItem(e,t){return a.createElement(l.TextField,{variant:"standard",fullWidth:!0,error:!!e,disabled:!!t,slotProps:{htmlInput:{readOnly:!0},input:{endAdornment:a.createElement(l.IconButton,{tabIndex:-1,onClick:()=>{p.Utils.copyToClipboard(this.state.uuid),window.alert(p.I18n.t("ra_Copied %s",this.state.uuid))}},a.createElement(v.ContentCopy,null))}},value:this.state.uuid||"",label:this.getText(this.props.schema.label)||p.I18n.t("ra_Serial number (UUID)"),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)})}}const Re={icon:{width:16,height:16,marginRight:8}};class Ls extends d{componentDidMount(){super.componentDidMount(),this.props.oContext.socket.getUsers().then(e=>{const t={},s=p.I18n.getLanguage();this.props.schema.short?e.forEach(n=>{var i,o;return t[n._id]={color:(i=n.common)==null?void 0:i.color,icon:(o=n.common)==null?void 0:o.icon,name:p.Utils.getObjectNameFromObj(n,s)}}):e.forEach(n=>{var i,o;return t[n._id.replace(/^system\.user\./,"")]={color:(i=n.common)==null?void 0:i.color,icon:(o=n.common)==null?void 0:o.icon,name:p.Utils.getObjectNameFromObj(n,s)}}),this.setState({users:t})}).catch(e=>console.error(`Cannot get users: ${e}`))}renderItem(e,t){var n,i;const s=d.getValue(this.props.data,this.props.attr);return a.createElement(l.FormControl,{variant:"standard",fullWidth:!0},this.state.users&&this.props.schema.label?a.createElement(l.InputLabel,null,this.getText(this.props.schema.label)):null,this.state.users?a.createElement(l.Select,{variant:"standard",error:!!e,disabled:!!t,value:s,renderValue:o=>{var r,h,c;return a.createElement("span",null,this.state.users&&((r=this.state.users[o])!=null&&r.icon)?a.createElement(p.Icon,{src:this.state.users&&((h=this.state.users[o])==null?void 0:h.icon),style:Re.icon}):null,this.state.users&&((c=this.state.users[o])==null?void 0:c.name)||o||"")},style:{color:this.state.users&&((n=this.state.users[s])==null?void 0:n.color)||void 0,backgroundColor:p.Utils.getInvertedColor(this.state.users&&((i=this.state.users[s])==null?void 0:i.color),this.props.oContext.themeType)},onChange:o=>this.onChange(this.props.attr,o.target.value)},this.state.users&&Object.keys(this.state.users).map(o=>a.createElement(l.MenuItem,{style:{color:this.state.users[o].color||void 0,backgroundColor:p.Utils.getInvertedColor(this.state.users[o].color,this.props.oContext.themeType)},key:o,value:o},this.state.users[o].icon?a.createElement(p.Icon,{src:this.state.users[o].icon,style:Re.icon}):null,this.state.users[o].name))):a.createElement(l.TextField,{variant:"standard",error:!!e,disabled:!!t,value:s,onChange:o=>this.onChange(this.props.attr,o.target.value),label:this.getText(this.props.schema.label)}),this.props.schema.help?a.createElement(l.FormHelperText,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}class Vs extends d{async componentDidMount(){super.componentDidMount();const e=await rt(()=>import("./index-CbQYNHIO.js").then(t=>t.i),__vite__mapDeps([0,1,2,3,4]),import.meta.url);this.setState({QRCode:e.default})}renderItem(){const e=this.state.QRCode;return e?a.createElement(e,{value:this.props.schema.data,size:this.props.schema.size,fgColor:this.props.schema.fgColor,bgColor:this.props.schema.bgColor,level:this.props.schema.level}):null}}const Bs={accordion:mt,alive:ft,autocomplete:gt,autocompleteSendTo:yt,certCollection:xt,certificate:bt,certificates:Ct,checkbox:Tt,checkDocker:Et,checkLicense:K,chip:De,chips:De,color:Dt,coordinates:_t,cron:vt,custom:se,datePicker:Ot,deviceManager:Ft,divider:Cs,file:Mt,fileSelector:fe,func:Rt,header:Es,image:Ht,imageSendTo:zt,infoBox:qt,instance:Kt,interface:Gt,ip:Jt,jsonEditor:Qt,language:es,license:ts,number:ss,oauth2:as,objectId:ns,password:is,pattern:os,port:ls,qrCode:Vs,room:hs,select:cs,selectSendTo:ds,sendto:Le,sendTo:Le,setState:gs,slider:ys,state:bs,staticImage:Ts,staticInfo:ws,staticLink:Ue,staticText:Ue,table:P,text:Ds,textSendTo:Os,timePicker:Fs,topic:Ns,uuid:As,user:Ls},R={fullWidth:{width:"100%"},paper:{margin:1,width:"auto !important",overflowY:"auto",paddingBottom:1},paperWithIcons:{height:"calc(100vh - 259px) !important"},paperWithoutIcons:{height:"calc(100vh - 235px) !important"},padding:{padding:"10px"},heading:{},primary:u=>({backgroundColor:u.palette.primary.main,color:u.palette.mode==="dark"?"inherit":"#FFF"}),secondary:u=>({backgroundColor:u.palette.secondary.main})};class X extends d{componentDidMount(){var e;super.componentDidMount(),(e=this.props.schema)!=null&&e.collapsable&&this.setState({expanded:(window._localStorage||window.localStorage).getItem(`${this.props.oContext.adapterName}.${this.props.attr}`)==="true"})}renderItems(e,t){return e?Object.keys(e).map(s=>{if(this.props.oContext.multiEdit&&e[s].noMultiEdit)return null;const n=e[s].type||"panel";let i,o="Use this.props.oContext.socket!";return n==="custom"?(e[s].url?i=se:this.props.oContext.customs&&this.props.oContext.customs[e[s].component]?i=this.props.oContext.customs[e[s].component]:(console.error(`Cannot find custom component: ${e[s].component}`),i=d),o=this.props.oContext.socket):n==="panel"?i=X:i=Bs[n]||d,a.createElement(i,{socket:o,globalData:this.props.globalData,oContext:this.props.oContext,key:`${s}_${this.props.index===void 0?"":this.props.index}`,index:this.props.index,changed:this.props.changed,arrayIndex:this.props.arrayIndex,expertMode:this.props.expertMode,commandRunning:this.props.commandRunning,style:R.panel,common:this.props.common,alive:this.props.alive,themeName:this.props.themeName,data:this.props.data,originalData:this.props.originalData,onError:this.props.onError,onChange:this.props.onChange,disabled:t,customObj:this.props.customObj,custom:this.props.custom,schema:e[s],attr:s,table:this.props.table})}):null}render(){const e=this.props.schema;if(!e)return null;const{disabled:t,hidden:s}=this.calculate(e),n=this.props.schema.items,i=this.props.schema.style||{};if(s){if(e.hideOnlyControl){const r=a.createElement(l.Grid2,{size:{xs:e.xs||void 0,sm:e.sm||void 0,md:e.md||void 0,lg:e.lg||void 0,xl:e.xl||void 0},sx:p.Utils.getStyle(this.props.oContext.theme,{marginBottom:0,textAlign:"left"},i,this.props.oContext.themeType==="dark"&&e.darkStyle)});return e.newLine?a.createElement(a.Fragment,null,a.createElement("div",{style:{flexBasis:"100%",height:0}}),r):r}return null}if(this.props.table)return this.renderItems(n,t);if(this.props.custom)return a.createElement(l.Grid2,{key:`${this.props.attr}_${this.props.index}`,container:!0,style:R.fullWidth,columnSpacing:2,rowSpacing:1,sx:i},this.renderItems(n,t));let o;if(e.collapsable)o=a.createElement(l.Accordion,{key:`${this.props.attr}_${this.props.index}`,style:R.fullWidth,expanded:!!this.state.expanded,onChange:()=>{(window._localStorage||window.localStorage).setItem(`${this.props.oContext.adapterName}.${this.props.attr}`,this.state.expanded?"false":"true"),this.setState({expanded:!this.state.expanded})}},a.createElement(l.AccordionSummary,{expandIcon:a.createElement(v.ExpandMore,null),sx:p.Utils.getStyle(this.props.oContext.theme,i,this.props.oContext.themeType&&e.darkStyle,e.color==="primary"?R.primary:e.color==="secondary"&&R.secondary,{width:"100%"})},a.createElement(l.Typography,{style:R.heading},this.getText(e.label))),a.createElement(l.AccordionDetails,null,a.createElement(l.Grid2,{container:!0,columnSpacing:2,rowSpacing:1,sx:{...i,width:"100%",padding:"10px"}},this.renderItems(n,t))));else{const r=p.Utils.getStyle(this.props.oContext.theme,this.props.style,i,{width:"100%"},this.props.isParentTab&&R.paper,this.props.isParentTab&&(this.props.withoutSaveButtons?this.props.withIcons?{height:"calc(100% - 88px) !important"}:{height:"calc(100% - 64px) !important"}:this.props.withIcons?R.paperWithIcons:R.paperWithoutIcons));o=a.createElement(l.Box,{component:"div",key:`${this.props.attr}_${this.props.index}`,className:this.props.className,sx:r},a.createElement(l.Grid2,{container:!0,columnSpacing:2,rowSpacing:1,sx:p.Utils.getStyle(this.props.oContext.theme,{width:"100%"},this.props.isParentTab&&R.padding,this.props.schema.innerStyle)},this.renderItems(n,t)))}if(!this.props.isParentTab){const r=a.createElement(l.Grid2,{title:this.getText(e.tooltip),size:{xs:e.xs||void 0,sm:e.sm||void 0,md:e.md||void 0,lg:e.lg||void 0,xl:e.xl||void 0},sx:{marginBottom:0,textAlign:"left",...i}},o);return e.newLine?a.createElement(a.Fragment,null,a.createElement("div",{style:{flexBasis:"100%",height:0}}),r):r}return o}}const ue={tabs:{height:"100%",width:"100%"},panel:{width:"100%",display:"block"},panelWithIcons:{height:"calc(100% - 72px)"},panelWithoutIcons:{height:"calc(100% - 48px)"}};class js extends d{resizeTimeout=null;refDiv;constructor(e){super(e);let t;if(this.props.root){const s=(window.location.hash||"").replace(/^#/,"").split("/");if(s.length>=3&&s[1]==="config"){const n=s[3],i=parseInt(n,10);n&&i.toString()===n?i>=0&&i<Object.keys(this.props.schema.items).length&&(t=Object.keys(this.props.schema.items)[i]):n&&Object.keys(this.props.schema.items).includes(n)&&(t=n),window.addEventListener("hashchange",this.onHashTabsChanged,!1)}}t===void 0&&(t=(window._localStorage||window.localStorage).getItem(`${this.props.dialogName||"App"}.${this.props.oContext.adapterName}`)||Object.keys(this.props.schema.items)[0],Object.keys(this.props.schema.items).includes(t)||(t=Object.keys(this.props.schema.items)[0])),this.refDiv=a.createRef(),Object.assign(this.state,{tab:t,width:0,openMenu:null,tabErrors:{}})}onTabError=(e,t)=>{const s=this.state.tab;if(!s){this.props.onError(e,t);return}const n={...this.state.tabErrors};n[s]||(n[s]={}),t?n[s][e]=t:(delete n[s][e],Object.keys(n[s]).length===0&&delete n[s]),this.setState({tabErrors:n}),this.props.onError(e,t)};hasTabErrors=e=>!!(this.state.tabErrors[e]&&Object.keys(this.state.tabErrors[e]).length>0);componentWillUnmount(){this.resizeTimeout&&(clearTimeout(this.resizeTimeout),this.resizeTimeout=null),window.removeEventListener("hashchange",this.onHashTabsChanged,!1),super.componentWillUnmount()}onHashTabsChanged=()=>{const e=(window.location.hash||"").replace(/^#/,"").split("/");if(e.length>3&&e[1]==="config"){const t=e[3],s=parseInt(t,10);let n;s.toString()===t?s>=0&&s<Object.keys(this.props.schema.items).length&&(n=Object.keys(this.props.schema.items)[s]):Object.keys(this.props.schema.items).includes(t)&&(n=t),n!==void 0&&n!==this.state.tab&&((window._localStorage||window.localStorage).setItem(`${this.props.dialogName||"App"}.${this.props.oContext.adapterName}`,n),this.setState({tab:n}))}};getCurrentBreakpoint(){if(!this.state.width)return"md";if(!this.state.initialBreakpoint){let e;return this.state.width<600?e="xs":this.state.width<900?e="sm":this.state.width<1200?e="md":this.state.width<1536?e="lg":e="xl",setTimeout(()=>{this.setState({initialBreakpoint:e})},50),e}return this.state.initialBreakpoint}componentDidUpdate(){var e;!this.state.initialBreakpoint&&((e=this.refDiv.current)!=null&&e.clientWidth)&&this.refDiv.current.clientWidth!==this.state.width&&(this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{var t;this.resizeTimeout=null,this.setState({width:(t=this.refDiv.current)==null?void 0:t.clientWidth})},50))}onMenuChange(e){(window._localStorage||window.localStorage).setItem(`${this.props.dialogName||"App"}.${this.props.oContext.adapterName}`,e),this.setState({tab:e},()=>{if(this.props.root){const t=(window.location.hash||"").split("/");t.length>=3&&t[1]==="config"&&(t[3]=this.state.tab,window.location.hash=t.join("/"))}})}render(){const e=this.props.schema.items;let t=!1;const s=[];Object.keys(e).map(o=>{let r;if(e[o].expertMode&&!this.props.expertMode)return;if(this.props.custom){if(this.executeCustom(e[o].hidden,this.props.data,this.props.customObj,this.props.oContext.instanceObj,this.props.index,this.props.globalData))return;r=this.executeCustom(e[o].disabled,this.props.data,this.props.customObj,this.props.oContext.instanceObj,this.props.index,this.props.globalData)}else{if(this.execute(e[o].hidden,!1,this.props.data,this.props.index,this.props.globalData))return;r=this.execute(e[o].disabled,!1,this.props.data,this.props.index,this.props.globalData)}const h=this.getIcon(e[o].icon);t=t||!!h,s.push({icon:h,disabled:r,label:this.getText(e[o].label),name:o})}),s.find(o=>o.name===this.state.tab)||setTimeout(()=>this.setState({tab:s[0].name}),50);const n=this.getCurrentBreakpoint();let i;return n==="xs"&&s.length>2?i=a.createElement(l.Toolbar,{style:{top:2,backgroundColor:this.props.oContext.themeType==="dark"?"#222":"#DDD"},variant:"dense"},a.createElement(l.IconButton,{onClick:o=>this.setState({openMenu:o.currentTarget})},a.createElement(v.Menu,null)),this.state.openMenu?a.createElement(l.Menu,{open:!0,anchorEl:this.state.openMenu,onClose:()=>this.setState({openMenu:null})},s.map(o=>{const r=this.hasTabErrors(o.name);return a.createElement(l.MenuItem,{disabled:o.disabled,key:o.name,onClick:()=>{this.setState({openMenu:null},()=>this.onMenuChange(o.name))},selected:o.name===this.state.tab,sx:r?{color:"error.main"}:void 0},t?a.createElement(l.ListItemIcon,null,o.icon):null,a.createElement(l.Box,{sx:{display:"flex",alignItems:"center",gap:.5,width:"100%"}},o.label,r&&a.createElement(v.Error,{sx:{fontSize:16,color:"error.main"}})))})):null):i=a.createElement(l.Tabs,{variant:"scrollable",scrollButtons:"auto",style:this.props.schema.tabsStyle,value:this.state.tab,onChange:(o,r)=>this.onMenuChange(r)},s.map(o=>{const r=this.hasTabErrors(o.name),h=r?a.createElement(l.Box,{sx:{display:"flex",alignItems:"center",gap:.5}},o.label,a.createElement(v.Error,{sx:{fontSize:16,color:"error.main"}})):o.label;return a.createElement(l.Tab,{id:o.name,wrapped:!0,disabled:o.disabled,key:o.name,value:o.name,iconPosition:this.props.schema.iconPosition||"start",icon:o.icon,label:h,sx:r?{"& .MuiTab-wrapper":{color:"error.main"}}:void 0})})),a.createElement("div",{style:ue.tabs,ref:this.refDiv},i,a.createElement(X,{oContext:this.props.oContext,withoutSaveButtons:this.props.withoutSaveButtons,isParentTab:!0,changed:this.props.changed,key:this.state.tab,expertMode:this.props.expertMode,index:1001,arrayIndex:this.props.arrayIndex,globalData:this.props.globalData,commandRunning:this.props.commandRunning,style:{...ue.panel,...t?ue.panelWithIcons:ue.panelWithoutIcons},common:this.props.common,alive:this.props.alive,themeName:this.props.themeName,data:this.props.data,originalData:this.props.originalData,onChange:this.props.onChange,onError:this.onTabError,customObj:this.props.customObj,custom:this.props.custom,schema:e[this.state.tab],table:this.props.table,withIcons:t}))}}const Ps={root:{width:"100%",height:"100%"}};class me extends te.Component{forceUpdateHandlers;errorTimeout=null;errorCached=null;oContext;constructor(e){super(e),this.state={originalData:JSON.stringify(this.props.data),changed:!1,errors:{},updateData:this.props.updateData||0,systemConfig:null,alive:!1,commandRunning:!1,schema:JSON.parse(JSON.stringify(this.props.schema))},this.forceUpdateHandlers={},this.buildDependencies(this.state.schema),this.readData()}static getDerivedStateFromProps(e,t){return e.updateData!==t.updateData?{updateData:e.updateData,originalData:JSON.stringify(e.data),schema:JSON.parse(JSON.stringify(e.schema))}:null}static async loadI18n(e,t,s){if(t===!0||t&&typeof t=="string"){const n=p.I18n.getLanguage(),i=typeof t=="string"?t:"i18n";let o=await e.fileExists(`${s}.admin`,`${i}/${n}.json`),r;if(o?r=`${i}/${n}.json`:(o=await e.fileExists(`${s}.admin`,`${i}/${n}/translations.json`),o?r=`${i}/${n}/translations.json`:n!=="en"&&(o=await e.fileExists(`${s}.admin`,`${i}/en.json`),o?r=`${i}/en.json`:(o=await e.fileExists(`${s}.admin`,`${i}/en/translations.json`),o&&(r=`${i}/en/translations.json`)))),r){const h=await e.readFile(`${s}.admin`,r);let c;h.file!==void 0?c=h.file:c=h;try{const m=JSON.parse(c);p.I18n.extendTranslations(m,n)}catch(m){return console.error(`Cannot parse language file "${s}.admin/${r}: ${m}`),""}return r}return console.warn(`Cannot find i18n for ${s} / ${r}`),""}return t&&typeof t=="object"&&p.I18n.extendTranslations(t),""}onCommandRunning=e=>this.setState({commandRunning:e});readData(){this.props.socket.getCompactSystemConfig().then(e=>this.props.socket.getState(`system.adapter.${this.props.adapterName}.${this.props.instance}.alive`).then(t=>this.setState({systemConfig:e.common,alive:!!(t&&t.val)},()=>{this.updateContext(!0),this.props.custom||this.props.socket.subscribeState(`system.adapter.${this.props.adapterName}.${this.props.instance}.alive`,this.onAlive)}))).catch(e=>console.error(`Cannot read system config: ${e}`))}onAlive=(e,t)=>{!!(t!=null&&t.val)!==this.state.alive&&this.setState({alive:!!(t!=null&&t.val)})};onChange=(e,t,s,n)=>{if(this.props.onValueChange)this.props.onValueChange(e,t,n),s&&s();else if(e&&this.props.onChange){const i={changed:JSON.stringify(e)!==this.state.originalData};this.setState(i,()=>{this.props.onChange(e,i.changed,n),s&&s()})}else n&&this.props.onChange(null,null,n)};onError=(e,t)=>{this.errorCached=this.errorCached||JSON.parse(JSON.stringify(this.state.errors));const s=this.errorCached;t?s[e]=t:delete s[e],this.errorTimeout&&clearTimeout(this.errorTimeout),JSON.stringify(s)!==JSON.stringify(this.state.errors)?this.errorTimeout=setTimeout(()=>this.setState({errors:this.errorCached},()=>{this.errorTimeout=null,this.errorCached=null,this.props.onError(!!Object.keys(this.state.errors).length)}),50):this.errorCached=null};flatten(e,t){return t=t||{},e.items&&Object.keys(e.items).forEach(s=>{t[s]=e.items[s],this.flatten(e.items[s],t)}),t}buildDependencies(e){const t=this.flatten(e);Object.keys(t).forEach(s=>{var n,i,o,r,h,c,m,f,g,D;(n=t[s].confirm)!=null&&n.alsoDependsOn&&((i=t[s].confirm)==null||i.alsoDependsOn.forEach(b=>{if(!t[b])console.error(`[JsonConfigComponent] Attribute ${b} does not exist!`),b.startsWith("data.")&&console.warn(`[JsonConfigComponent] please use "${b.replace(/^data\./,"")}" instead of "${b}"`);else{t[b].confirmDependsOn=t[b].confirmDependsOn||[];const C={...t[s],attr:s};C.confirm&&(C.confirm.cancel="Undo"),t[b].confirmDependsOn.push(C)}})),(o=t[s].onChange)!=null&&o.alsoDependsOn&&((r=t[s].onChange)==null||r.alsoDependsOn.forEach(b=>{if(!t[b])console.error(`[JsonConfigComponent] Attribute ${b} does not exist!`),b.startsWith("data.")&&console.warn(`[JsonConfigComponent] please use "${b.replace(/^data\./,"")}" instead of "${b}"`);else{t[b].onChangeDependsOn=t[b].onChangeDependsOn||[];const C={...t[s],attr:s};t[b].onChangeDependsOn.push(C)}})),(h=t[s].hidden)!=null&&h.alsoDependsOn&&((c=t[s].hidden)==null||c.alsoDependsOn.forEach(b=>{if(!t[b])console.error(`[JsonConfigComponent] Attribute ${b} does not exist!`),b.startsWith("data.")&&console.warn(`[JsonConfigComponent] please use "${b.replace(/^data\./,"")}" instead of "${b}"`);else{t[b].hiddenDependsOn=t[b].hiddenDependsOn||[];const C={...t[s],attr:s};t[b].hiddenDependsOn.push(C)}})),(m=t[s].label)!=null&&m.alsoDependsOn&&((f=t[s].label)==null||f.alsoDependsOn.forEach(b=>{if(!t[b])console.error(`[JsonConfigComponent] Attribute ${b} does not exist!`),b.startsWith("data.")&&console.warn(`[JsonConfigComponent] please use "${b.replace(/^data\./,"")}" instead of "${b}"`);else{t[b].labelDependsOn=t[b].labelDependsOn||[];const C={...t[s],attr:s};t[b].labelDependsOn.push(C)}})),(g=t[s].help)!=null&&g.alsoDependsOn&&((D=t[s].help)==null||D.alsoDependsOn.forEach(b=>{if(!t[b])console.error(`[JsonConfigComponent] Attribute ${b} does not exist!`),b.startsWith("data.")&&console.warn(`[JsonConfigComponent] please use "${b.replace(/^data\./,"")}" instead of "${b}"`);else{t[b].helpDependsOn=t[b].helpDependsOn||[];const C={...t[s],attr:s};t[b].helpDependsOn.push(C)}}))})}updateContext(e){this.oContext={DeviceManager:this.props.DeviceManager,adapterName:this.props.adapterName,changeLanguage:this.changeLanguage,common:this.props.common,customs:this.props.customs,dateFormat:this.props.dateFormat,embedded:this.props.embedded,forceUpdate:this.forceAttrUpdate,imagePrefix:this.props.imagePrefix,instance:this.props.instance,instanceObj:this.props.instanceObj,isFloatComma:this.props.isFloatComma,multiEdit:this.props.multiEdit,onBackEndCommand:this.props.onBackEndCommand,onCommandRunning:this.onCommandRunning,onValueChange:this.props.onValueChange,registerOnForceUpdate:this.registerOnForceUpdate,socket:this.props.socket,systemConfig:this.state.systemConfig,theme:this.props.theme,themeType:this.props.themeType,_themeName:this.props.themeName,updateData:this.state.updateData},e&&this.forceUpdate()}renderItem(e){return e.type==="tabs"?a.createElement(js,{withoutSaveButtons:this.props.withoutSaveButtons,oContext:this.oContext,alive:this.state.alive,changed:this.state.changed,commandRunning:this.state.commandRunning,common:this.props.common,custom:this.props.custom,customObj:this.props.customObj,data:this.props.data,onChange:this.onChange,onError:(t,s)=>this.onError(t,s),originalData:JSON.parse(this.state.originalData),root:!0,schema:e,expertMode:this.props.expertMode,themeName:this.props.themeName}):e.type==="panel"||!e.type?a.createElement(X,{withoutSaveButtons:this.props.withoutSaveButtons,oContext:this.oContext,alive:this.state.alive,changed:this.state.changed,commandRunning:this.state.commandRunning,common:this.props.common,custom:this.props.custom,customObj:this.props.customObj,data:this.props.data,expertMode:this.props.expertMode,index:1e3,isParentTab:!this.props.embedded&&!this.props.withoutSaveButtons,onChange:this.onChange,onError:(t,s)=>this.onError(t,s),originalData:JSON.parse(this.state.originalData),root:!0,schema:e,themeName:this.props.themeName}):(console.error(`Unknown item type in root: ${JSON.stringify(e)}`),null)}changeLanguage=()=>{this.forceUpdate()};forceAttrUpdate=(e,t)=>{Array.isArray(e)?e.forEach(s=>this.forceUpdateHandlers[s]&&this.forceUpdateHandlers[s](t)):this.forceUpdateHandlers[e]&&this.forceUpdateHandlers[e](t)};registerOnForceUpdate=(e,t)=>{t?this.forceUpdateHandlers[e]=t:this.forceUpdateHandlers[e]&&delete this.forceUpdateHandlers[e]};render(){return!this.state.systemConfig||!this.oContext?a.createElement(l.LinearProgress,null):(this.oContext._themeName!==this.props.themeName&&(this.oContext._themeName=this.props.themeName,setTimeout(()=>this.updateContext(!0),0)),a.createElement("div",{style:{...!this.props.embedded||this.props.withoutSaveButtons?Ps.root:void 0,...this.props.style,...this.state.schema.style}},this.renderItem(this.state.schema)))}}const G={root:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},scroll:{height:"calc(100% - 48px)",overflowY:"auto"},exportImportButtons:{position:"absolute",top:5,right:0,zIndex:3},button:{marginRight:"5px"},tooltip:{pointerEvents:"none"}};function Ws(u,e){let t="";for(let s=0;s<e.length;s++)t+=String.fromCharCode(u[s%u.length].charCodeAt(0)^e.charCodeAt(s));return t}function Us(u,e){let t="";for(let s=0;s<e.length;s++)t+=String.fromCharCode(u[s%u.length].charCodeAt(0)^e.charCodeAt(s));return t}function Ms(u,e){if(typeof e!="string")return e;if(!e.startsWith("$/aes-192-cbc:")||!/^[0-9a-f]{48}$/.test(u))return Ws(u,e);const t=e.split(":",3),s=window.CryptoJS.enc.Hex.parse(u),n=window.CryptoJS.enc.Hex.parse(t[1]),i=window.CryptoJS.lib.CipherParams.create({ciphertext:window.CryptoJS.enc.Hex.parse(t[2])}),o=window.CryptoJS.AES.decrypt(i,s,{iv:n});return window.CryptoJS.enc.Utf8.stringify(o)}function Rs(u,e,t){if(typeof e!="string")return e;if(!/^[0-9a-f]{48}$/.test(u))return Us(u,e);let s;s=window.CryptoJS.lib.WordArray.random(128/8);const n=window.CryptoJS.enc.Hex.parse(u),i=window.CryptoJS.AES.encrypt(e,n,{iv:s}).ciphertext;return`$/aes-192-cbc:${window.CryptoJS.enc.Hex.stringify(s)}:${i}`}function Je(u,e){var t;return document.getElementById(e)?(t=document.getElementById(e))==null?void 0:t.onload:new Promise(s=>{const n=document.createElement("script");n.setAttribute("id",e),n.onload=s,n.src=u,document.getElementsByTagName("head")[0].appendChild(n)})}let Js=class extends p.Router{fileSubscribed=[];fileLangSubscribed="";secret;constructor(e){super(e),this.state={updateData:0,changed:!1,confirmDialog:!1,theme:p.Theme(e.themeName),saveConfigDialog:!1,hash:"_"},this.secret=e.secret||"",this.getInstanceObject().then(t=>this.getConfigFile().then(s=>me.loadI18n(this.props.socket,s==null?void 0:s.i18n,this.props.adapterName).then(n=>{n&&(this.fileLangSubscribed||(this.fileLangSubscribed=n,this.props.socket.subscribeFiles(`${this.props.adapterName}.admin`,this.fileLangSubscribed,this.onFileChange))),t?this.setState({schema:s,data:t.native,common:t.common,hash:Ie(JSON.stringify(s)).toString()}):window.alert(`Instance system.adapter.${this.props.adapterName}.${this.props.instance} not found!`)})))}componentWillUnmount(){super.componentWillUnmount(),this.fileSubscribed.length&&(this.props.socket.unsubscribeFiles(`${this.props.adapterName}.admin`,this.fileSubscribed,this.onFileChange),this.fileSubscribed=[]),this.fileLangSubscribed&&(this.props.socket.unsubscribeFiles(`${this.props.adapterName}.admin`,this.fileLangSubscribed,this.onFileChange),this.fileLangSubscribed="")}handleFileSelect=e=>{const t=e.target.files[0];if(t){const s=new FileReader;s.onload=n=>{if(!n.target)return;const i=n.target.result;try{const o=JSON.parse(i);this.setState({data:o,changed:JSON.stringify(o)!==JSON.stringify(this.state.originalData)})}catch{window.alert(p.I18n.t("[JsonConfig] Failed to parse JSON file"))}},s.readAsText(t)}else window.alert(p.I18n.t("[JsonConfig] Failed to open JSON File"))};getExportImportButtons(){return a.createElement("div",{style:G.exportImportButtons},a.createElement(l.Tooltip,{title:this.props.t("Import settings from JSON file"),slotProps:{popper:{sx:G.tooltip}}},a.createElement(l.Fab,{size:"small",sx:{"&.MuiFab-root":G.button},onClick:()=>{const e=document.createElement("input");e.setAttribute("type","file"),e.setAttribute("id","files"),e.setAttribute("opacity",0),e.addEventListener("change",t=>this.handleFileSelect(t),!1),e.click()}},a.createElement(v.Publish,null))),a.createElement(l.Tooltip,{title:this.props.t("Export setting to JSON file"),slotProps:{popper:{sx:G.tooltip}}},a.createElement(l.Fab,{size:"small",sx:{"&.MuiFab-root":G.button},onClick:()=>{this.state.data&&p.Utils.generateFile(`${this.props.adapterName}.${this.props.instance}.json`,this.state.data)}},a.createElement(v.Publish,{style:{transform:"rotate(180deg)"}}))))}onFileChange=async(e,t,s)=>{var n;if(e===`${this.props.adapterName}.admin`&&s){if(t===this.fileLangSubscribed)try{await me.loadI18n(this.props.socket,(n=this.state.schema)==null?void 0:n.i18n,this.props.adapterName),this.setState({hash:`${this.state.hash}1`})}catch{}else if(this.fileSubscribed.includes(t))try{const i=await this.getConfigFile(this.fileSubscribed[0]);this.setState({schema:i,hash:Ie(JSON.stringify(i)).toString()})}catch{}}};async getInstanceObject(){var e;try{const t=await this.props.socket.getObject(`system.adapter.${this.props.adapterName}.${this.props.instance}`);if(Array.isArray(t.encryptedNative)){if(!this.secret){const s=await this.props.socket.getSystemConfig();await Je("../../lib/js/crypto-js/crypto-js.js","crypto-js"),this.secret=s.native.secret}return(e=t.encryptedNative)==null||e.forEach(s=>{t.native[s]&&(t.native[s]=Ms(this.secret,t.native[s]))}),t}return t}catch(t){window.alert(`[JsonConfig] Cannot read instance object: ${t}`)}return null}renderDialogConfirm(){return this.state.confirmDialog?a.createElement(p.DialogConfirm,{title:p.I18n.t("ra_Please confirm"),text:p.I18n.t("ra_Some data are not stored. Discard?"),ok:p.I18n.t("ra_Discard"),cancel:p.I18n.t("ra_Cancel"),onClose:e=>this.setState({confirmDialog:!1},()=>e&&p.Router.doNavigate(null))}):null}async scanForInclude(e,t){if(typeof e["#include"]=="string"){const n=await this._getConfigFile(e["#include"],[...t]);return delete e["#include"],n&&(e={...e,...n}),e}const s=Object.keys(e);for(let n=0;n<s.length;n++)e[s[n]]&&typeof e[s[n]]=="object"&&(e[s[n]]=await this.scanForInclude(e[s[n]],t));return e}async getConfigFile(e){return this._getConfigFile(e)}async _getConfigFile(e,t){if(e=e||"jsonConfig.json5",t=t||[],t.includes(e))return window.alert(`[JsonConfig] Circular reference in file: ${e} => ${t.join(" => ")}`),null;t.push(e);try{await this.props.socket.fileExists(`${this.props.adapterName}.admin`,e)||(e="jsonConfig.json");const n=await this.props.socket.readFile(`${this.props.adapterName}.admin`,e);let i="",o="";if(n.file!==void 0&&(o=n.file),typeof o=="string")i=o;else if(o.type==="Buffer"){let r="";const h=new Uint8Array(o.data),c=h.byteLength;for(let m=0;m<c;m++)r+=String.fromCharCode(h[m]);i=r}this.fileSubscribed.includes(e)||(this.fileSubscribed.push(e),await this.props.socket.subscribeFiles(`${this.props.adapterName}.admin`,e,this.onFileChange));try{return await this.scanForInclude(ze.parse(i),t)}catch(r){window.alert("[JsonConfig] Cannot parse json5 config!"),console.log(r)}}catch(s){this.state.schema||window.alert(`[JsonConfig] Cannot read file "${e}: ${s}`)}return null}renderSaveConfigDialog(){return this.state.saveConfigDialog?a.createElement(p.DialogConfirm,{title:p.I18n.t("ra_Please confirm"),text:p.I18n.t("Save configuration?"),ok:p.I18n.t("ra_Save"),cancel:p.I18n.t("ra_Cancel"),onClose:e=>this.setState({saveConfigDialog:!1},()=>e&&this.onSave(!0))}):null}findAttr(e,t){if(t=t||this.state.schema,t!=null&&t.items){if(e in t.items)return t.items[e];for(const s of Object.values(t.items)){const n=this.findAttr(e,s);if(n)return n}}return null}postProcessing(e,t,s){if(s=s||this.state.schema,!e){console.error(`Data is empty in postProcessing: ${t}, ${JSON.stringify(s)}`);return}const n=e[t];if(s.items)if(s.type==="table"){const i=n;if(!Array.isArray(i))return;for(const o of i)for(const r of s.items)this.postProcessing(o,r.attr,r)}else for(const[i,o]of Object.entries(s.items)){if(o.type==="panel"||o.type==="tabs"||o.type==="accordion")return;this.postProcessing(e,i,o)}else if(t&&typeof n=="string")if(s.type==="text")s.trim!==!1&&(e[t]=n.trim());else if(s.type==="ip")e[t]=n.trim();else if(s.type==="number"){const i=parseFloat(n.toString().replace(",","."));s.min!==void 0&&i<s.min?e[t]=s.min:s.max!==void 0&&i>s.max?e[t]=s.max:e[t]=i}else if(s.type==="port"){const i=parseInt(n.toString(),10);s.min!==void 0&&i<s.min?e[t]=s.min:s.max!==void 0&&i>s.max&&(e[t]=s.max),e[t]!==0&&i<20?e[t]=20:i>65535?e[t]=65535:e[t]=i}else s.type==="checkbox"&&(e[t]=e[t]===!0||e[t]==="true"||e[t]==="on"||e[t]===1||e[t]==="1")}async onSave(e,t){if(e){const s=await this.getInstanceObject();if(!s){console.error("Something went wrong: may be no connection?"),window.alert("Something went wrong: may be no connection?");return}if(!this.state.data||!this.state.schema)return;const n={};for(const o of Object.keys(this.state.data)){const r=this.findAttr(o);(!r||!r.doNotSave||r.type==="state")&&!o.startsWith("_")?d.setValue(s.native,o,this.state.data[o]):(d.setValue(s.native,o,null),n[o]=this.state.data[o])}try{const o=JSON.parse(JSON.stringify(s));if(Array.isArray(o.encryptedNative)){await Je("../../lib/js/crypto-js/crypto-js.js","crypto-js");for(const r of o.encryptedNative)o.native[r]&&(o.native[r]=Rs(this.secret,o.native[r]))}await this.props.socket.setObject(o._id,o)}catch(o){window.alert(`[JsonConfig] Cannot set object: ${o}`)}const i={...s.native,...n};console.log(i),this.setState({changed:!1,data:i,updateData:this.state.updateData+1,originalData:i},()=>t&&p.Router.doNavigate(null))}else this.state.changed?this.setState({confirmDialog:!0}):p.Router.doNavigate(null)}componentDidUpdate(e,t){t.changed!==this.state.changed&&this.props.configStored(!this.state.changed)}async componentDidMount(){const e=`${window.location.protocol}//${window.location.host}${window.location.pathname}validate_config/${this.props.adapterName}`;console.log(`fetch ${e}`),await fetch(e)}render(){return!this.state.data||!this.state.schema?a.createElement(l.LinearProgress,null):a.createElement("div",{style:G.root},this.renderDialogConfirm(),this.getExportImportButtons(),this.renderSaveConfigDialog(),a.createElement(me,{key:this.state.hash,style:G.scroll,socket:this.props.socket,themeName:this.props.themeName,themeType:this.props.themeType,adapterName:this.props.adapterName,instance:this.props.instance,isFloatComma:this.props.isFloatComma,dateFormat:this.props.dateFormat,schema:this.state.schema,common:this.state.common,expertMode:this.props.expertMode,data:this.state.data,updateData:this.state.updateData,onError:e=>this.setState({error:e}),onChange:(e,t,s)=>{s&&this.state.error&&(window.alert(p.I18n.t("Cannot save configuration because of error in configuration")),s=!1),s&&!this.state.changed&&!t&&(s=!1),e?this.setState({data:e,changed:t,saveConfigDialog:s}):s!==void 0&&this.setState({saveConfigDialog:s})},DeviceManager:this.props.DeviceManager,theme:this.state.theme}),a.createElement(p.SaveCloseButtons,{isIFrame:!1,dense:!0,paddingLeft:0,newReact:!0,theme:this.state.theme,noTextOnButtons:this.props.width==="xs"||this.props.width==="sm"||this.props.width==="md",changed:!!(this.state.error||this.state.changed),error:!!this.state.error,onSave:e=>this.onSave(!0,e),onClose:()=>this.onSave(!1)}))}};export{d as ConfigGeneric,X as ConfigPanel,Js as JsonConfig,me as JsonConfigComponent};
|