iobroker.admin 7.1.2 → 7.1.3
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/README.md +7 -4
- package/adminWww/asset-manifest.json +13 -13
- package/adminWww/index.html +1 -1
- package/adminWww/static/css/{3210.f6c8a5fc.chunk.css → 4684.f5525d8f.chunk.css} +2 -2
- package/adminWww/static/css/4684.f5525d8f.chunk.css.map +1 -0
- package/adminWww/static/js/2534.89c71e34.chunk.js +2 -0
- package/adminWww/static/js/2534.89c71e34.chunk.js.map +1 -0
- package/adminWww/static/js/4684.e5f7632b.chunk.js +2 -0
- package/adminWww/static/js/4684.e5f7632b.chunk.js.map +1 -0
- package/adminWww/static/js/5056.9247882b.chunk.js +3 -0
- package/adminWww/static/js/5056.9247882b.chunk.js.map +1 -0
- package/adminWww/static/js/{8038.ae8b7862.chunk.js → 8038.64137a64.chunk.js} +2 -2
- package/adminWww/static/js/8038.64137a64.chunk.js.map +1 -0
- package/adminWww/static/js/{main.423e60b6.js → main.d3fd9aec.js} +2 -2
- package/adminWww/static/js/{main.423e60b6.js.map → main.d3fd9aec.js.map} +1 -1
- package/io-package.json +14 -14
- package/package.json +4 -13
- package/adminWww/static/css/3210.f6c8a5fc.chunk.css.map +0 -1
- package/adminWww/static/js/2534.d8fd195b.chunk.js +0 -2
- package/adminWww/static/js/2534.d8fd195b.chunk.js.map +0 -1
- package/adminWww/static/js/3210.1be726e7.chunk.js +0 -2
- package/adminWww/static/js/3210.1be726e7.chunk.js.map +0 -1
- package/adminWww/static/js/6539.0a444811.chunk.js +0 -3
- package/adminWww/static/js/6539.0a444811.chunk.js.map +0 -1
- package/adminWww/static/js/8038.ae8b7862.chunk.js.map +0 -1
- /package/adminWww/static/js/{6539.0a444811.chunk.js.LICENSE.txt → 5056.9247882b.chunk.js.LICENSE.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(self.webpackChunksrc_rx=self.webpackChunksrc_rx||[]).push([[8038],{88038:(t,e,s)=>{s.r(e),s.d(e,{default:()=>ft});var o=s(29183),n=s.n(o),i=s(89303),r=s(32075),a=s(26699),l=s(44373),h=s(84929),p=s.n(h),d=s(16732),c=s(58693),u=s(34779),m=s(61204),x=s(96053),g=s(20501),f=s(59718),y=s(5035),v=s.n(y),b=s(99277);class j extends o.Component{constructor(t){super(t),this.updating=!1,this.textareaRef=n().createRef(),this.link=`${window.location.protocol}//${window.location.host}/`,this.interval=void 0,this.startTimeout=void 0,this.state={response:null,error:null,starting:!0}}setUpdating(t){this.updating!==t&&(this.updating=t,this.props.onUpdating(t))}async findIpAddress(){var t,e,s,o;if((await this.props.socket.getObject(`system.adapter.${this.props.adminInstance}`)).common.host===this.props.hostId)return;const n=await this.props.socket.getObject(this.props.hostId),i=await this.props.socket.readBaseSettings(this.props.hostId);let r=null===i||void 0===i||null===(t=i.config)||void 0===t||null===(e=t.objects)||void 0===e?void 0:e.host;if(r&&"localhost"!==r&&(r=v().parse(r).toString(),null!==n&&void 0!==n&&null!==(s=n.native)&&void 0!==s&&null!==(o=s.hardware)&&void 0!==o&&o.networkInterfaces))for(const a of Object.values(n.native.hardware.networkInterfaces))a.find((t=>{try{const e=v().parseCIDR(t.cidr).toString();!1===t.internal&&r.match(e)&&(this.link=`${window.location.protocol}//${"IPv6"===t.family?`[${t.address}]`:t.address}:${window.location.port}`)}catch{}return!1}))}async componentDidMount(){try{await this.findIpAddress()}catch(t){console.error(`Cannot find ip address: ${t.message}`)}try{await this.props.socket.upgradeController(this.props.hostId,this.props.version,parseInt(this.props.adminInstance.split(".").pop(),10))}catch(t){return console.error(`Cannot update controller: ${t.message}`),this.setState({error:a.I18n.t("Not updatable"),starting:!1}),void this.setUpdating(!1)}this.setUpdating(!0),this.interval=setInterval((()=>this.checkStatus()),1e3),this.startTimeout=setTimeout((()=>{this.startTimeout=null,this.setState({starting:!1})}),1e4)}componentWillUnmount(){this.interval&&(clearInterval(this.interval),this.interval=null),this.startTimeout&&(clearTimeout(this.startTimeout),this.startTimeout=null)}async checkStatus(){console.log(`Request update status from: ${this.link}`);try{const t=await fetch(this.link),e=await t.text();console.log(`Received status: ${e}`);const s=JSON.parse(e);null!==s&&void 0!==s&&s.stderr&&(s.stderr=s.stderr.filter((t=>t.trim()))),s&&!s.running&&s.success&&s.stdout?(s.stdout.push(""),s.stdout.push("---------------------------------------------------"),s.stdout.push(a.I18n.t("%s was successfully updated to %s","js-controller",this.props.version))):null!==s&&void 0!==s&&s.stdout&&(s.stdout.unshift(""),s.stdout.unshift("---------------------------------------------------"),s.stdout.unshift(a.I18n.t("updating %s to %s...","js-controller",this.props.version))),this.setState({response:s,error:null},(()=>{s&&!s.running?(this.setUpdating(!1),this.interval&&(clearInterval(this.interval),this.interval=null)):null!==s&&void 0!==s&&s.running&&this.setUpdating(!0),this.textareaRef.current&&setTimeout((()=>this.textareaRef.current.scrollTop=this.textareaRef.current.scrollHeight),100)}))}catch(t){this.state.starting||this.setState({error:t.toString()},(()=>this.setUpdating(!1)))}}render(){var t,e,s,o,n;return(0,b.jsxs)(i.Dialog,{onClose:(t,e)=>{"escapeKeyDown"!==e&&"backdropClick"!==e&&this.props.onClose()},open:!0,maxWidth:"lg",fullWidth:!0,children:[(0,b.jsx)(i.DialogTitle,{children:a.I18n.t("Updating %s...","js-controller")}),(0,b.jsxs)(i.DialogContent,{style:{height:400,padding:"0 20px",overflow:"hidden"},children:[this.state.response&&!this.state.response.running||this.state.error?null:(0,b.jsx)(i.LinearProgress,{}),this.state.response||this.state.error?(0,b.jsx)("textarea",{ref:this.textareaRef,style:{width:"100%",height:"100%",resize:"none",background:"dark"===this.props.themeType?"#000":"#fff",color:"dark"===this.props.themeType?"#EEE":"#111",boxSizing:"border-box",fontFamily:"Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace",border:null!==(t=this.state.response)&&void 0!==t&&t.success?"2px solid green":this.state.error||this.state.response&&!this.state.response.running&&!this.state.response.success?"2px solid red":void 0},value:this.state.error?this.state.error:this.state.response.stderr&&this.state.response.stderr.length?this.state.response.stderr.join("\n"):this.state.response.stdout.join("\n"),readOnly:!0}):null]}),(0,b.jsx)(i.DialogActions,{children:(0,b.jsx)(i.Button,{id:"js-controller-updater-close",variant:"contained",disabled:this.state.starting||!this.state.error&&(null===(e=this.state.response)||void 0===e?void 0:e.running),onClick:()=>{var t;null!==(t=this.state.response)&&void 0!==t&&t.success&&window.location.reload(),this.props.onClose()},color:null!==(s=this.state.response)&&void 0!==s&&s.success?"primary":"grey",startIcon:null!==(o=this.state.response)&&void 0!==o&&o.success?(0,b.jsx)(r.Refresh,{}):(0,b.jsx)(r.Close,{}),children:null!==(n=this.state.response)&&void 0!==n&&n.success?a.I18n.t("Reload"):a.I18n.t("Close")})})]})}}var C=s(62891),S=s(12549);const I={root:{width:"100%",height:"auto",display:"flex",flexDirection:"column",overflow:"auto",padding:10},paper:{maxWidth:1e3},overflowHidden:{display:"flex",overflow:"hidden"},h1:{fontWeight:500,fontSize:35,margin:"10px 0"},h2:t=>({p:"10px 7px",fontSize:25,fontWeight:300,borderRadius:"3px",background:"#4dabf5",color:"dark"===t.palette.mode?"black":"white"}),h22:t=>({p:0,m:0,fontSize:25,fontWeight:300,borderRadius:"3px",background:"#4dabf5",color:"dark"===t.palette.mode?"black":"white"}),standardText:{fontSize:15,margin:"10px 0","& > a":{textDecoration:"none",color:"#1e88e5"}},standardTextSmall:{fontSize:12,color:"black"},standardTextSmall2:{fontSize:12},pre:{whiteSpace:"pre-wrap",background:"#e4e3e3",padding:10,borderRadius:3,position:"relative"},copyButton:{color:"black",position:"absolute",right:10,top:4},comment:{color:"#00000078"},accordionSummary:{background:"#4dabf5",borderRadius:"3px","& .MuiAccordionSummary-content":{m:0}},accordionDetails:{display:"flex",flexDirection:"column"},code:t=>({backgroundColor:"dark"===t.palette.mode?"#123456":"#93bbe7",p:"0 3px 0 3px"}),copyButtonSmall:{width:31,height:16}};function w(t,e,s){const o=t.split("\n"),n=[];let i=!1;for(let r=0;r<o.length;r++){const t=o[r].toLowerCase();t.startsWith("##")&&(i=t.includes(e.toLowerCase())&&(!s||!t.includes(s.toLowerCase()))),i||n.push(o[r])}return n.join("\n")}const k=t=>{let{socket:e,hostId:s,version:n,onClose:l}=t;const[h,p]=(0,o.useState)(null),[d,c]=(0,o.useState)(""),[u,m]=(0,o.useState)(""),x=t=>{a.Utils.copyToClipboard(t),window.alert(a.I18n.t("Copied"))};(0,o.useEffect)((()=>{s&&"string"===typeof s||console.error(`Invalid hostId: "${s}" with type ${typeof s}`),d&&u||!s||"string"!==typeof s||e.getHostInfoShort(s).then((t=>{t.location&&t.location!==d&&c(t.location),t.os&&t.os!==u&&m(t.os),fetch(`https://raw.githubusercontent.com/ioBroker/ioBroker.docs/master/admin/${a.I18n.getLanguage()}/controller-upgrade.md`).then((t=>t.text())).then((e=>{const s=t.os||u,o=(t.location||d).replace(/\\/g,"/"),r=(e=(e=(e=(e="win32"===s?w(e,"linux","windows"):w(e,"windows","linux")).replace(/cd \/opt\/iobroker/g,`cd ${o}`)).replace(/cd C:\\iobroker/g,`cd ${o}`)).replace(/x\.y\.z/g,n)).split("\x3c!-- copy"),l=[];r.forEach((t=>{if(t.includes("--\x3e")){const e=t.split("--\x3e");let s=e[0];const o=e[1];let n=!1;s.startsWith(" small")&&(s=s.replace(/^ {2}small /,""),n=!0),s=s.replace(/^\n\r/,"").replace(/^\n/,""),n?l.push((0,b.jsx)(i.IconButton,{onClick:()=>x(s),children:(0,b.jsx)(a.IconCopy,{})},`b${l.length}`)):l.push((0,b.jsx)(i.Button,{variant:"contained",onClick:()=>x(s),startIcon:(0,b.jsx)(a.IconCopy,{}),children:a.I18n.t("Copy to clipboard")},`b${l.length}`)),l.push(o)}else l.push(t)})),p(l)}))})).catch((t=>window.alert(`Cannot get information about host "${s}": ${t}`)))}),[d,u,e,n,s]);return(0,b.jsxs)(i.Dialog,{onClose:()=>l(),open:!0,sx:{"& .MuiDialog-paper":I.paper},children:[(0,b.jsx)(i.DialogTitle,{children:a.I18n.t("js-controller upgrade instructions")}),(0,b.jsx)(i.DialogContent,{style:h?null:I.overflowHidden,dividers:!0,children:h?(0,b.jsx)(b.Fragment,{children:h.map(((t,e)=>"object"===typeof t?t:(0,b.jsx)(C.o,{components:{em:t=>{let{...e}=t;return(0,b.jsx)(i.IconButton,{style:I.copyButtonSmall,onClick:()=>x(e.children[0].toString()),children:(0,b.jsx)(a.IconCopy,{})})},a:t=>{let{children:e,...s}=t;return(0,b.jsx)("a",{style:{color:"inherit"},...s,children:e})},code:t=>{let{children:e,ref:s,...o}=t;return(0,b.jsx)(i.Box,{component:"code",sx:I.code,ref:s,...o,children:e})}},children:t},`t_${e}`)))}):(0,b.jsxs)(i.Card,{style:I.root,children:[(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t("Due to the different hardware and platforms under which ioBroker runs, the js-controller has to be updated manually. Further details can be found in the appropriate section.")}),(0,b.jsx)(i.Box,{component:"h2",sx:I.h2,children:a.I18n.t("General information for all platforms")}),(0,b.jsxs)(i.Box,{component:"div",sx:I.standardText,children:[a.I18n.t("For an update from js-controller 1.x to 2.x please always read the information at")," ",(0,b.jsx)("a",{href:"https://forum.iobroker.net/topic/26759/js-controller-2-jetzt-f%C3%BCr-alle-im-stable",target:"_blank",rel:"noreferrer",children:"forum"}),"."]}),(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t("Otherwise please update the slaves first with an update of master-slave systems and the master last!")}),"win32"!==u&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(i.Box,{component:"h2",sx:I.h2,children:a.I18n.t("Linux/macOS (new installer)")}),(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t("This is the recommended option")}),(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t("Please execute the following commands in an SSH shell (console):")}),(0,b.jsxs)("pre",{style:I.pre,children:[(0,b.jsx)(i.IconButton,{size:"small",onClick:()=>{window.alert(a.I18n.t("Copied")),x("iob backup\niob stop\niob update\niob upgrade self\niob start")},style:I.copyButton,children:(0,b.jsx)(a.IconCopy,{})}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob backup"}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob stop"}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob update"}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob fix"}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob upgrade self"}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob start"})]}),(0,b.jsx)("div",{style:I.standardTextSmall2,children:a.I18n.t("or reboot server, then ioBroker should restart and you can be sure that all old processes were finished.")}),(0,b.jsx)("div",{style:I.standardTextSmall2,children:a.I18n.t("If the upgrade command displays Access Rights / Permission errors, then please use the install fixer")}),(0,b.jsxs)("pre",{style:I.pre,children:[(0,b.jsx)(i.IconButton,{size:"small",onClick:()=>{window.alert(a.I18n.t("Copied")),x("curl -sL https://iobroker.net/fix.sh | bash -")},style:I.copyButton,children:(0,b.jsx)(a.IconCopy,{})}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"curl -sL https://iobroker.net/fix.sh | bash -"})]}),(0,b.jsx)("div",{style:I.standardTextSmall2,children:a.I18n.t("to fix these issues and upgrade command run again.")}),(0,b.jsx)(i.Box,{component:"h2",sx:I.h2,children:a.I18n.t("Linux/macOS (manually installed)")}),(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t('A manual installation usually takes place under root as user and therefore a "sudo" is necessary before the commands.')}),(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t("Please execute the following commands in an SSH shell (console):")}),(0,b.jsxs)("pre",{style:I.pre,children:[(0,b.jsx)(i.IconButton,{size:"small",onClick:()=>{window.alert(a.I18n.t("Copied")),x(`cd ${d||"/opt/iobroker"}\niob backup\niob stop\niob update\niob fix\niob upgrade self\niob start\n`)},style:I.copyButton,children:(0,b.jsx)(a.IconCopy,{})}),(0,b.jsxs)("div",{style:I.standardTextSmall,children:["cd",d||"/opt/iobroker"]}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob backup"}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob stop"}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob fix"}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob update"}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob upgrade self"}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob start"})]}),(0,b.jsx)("div",{style:I.standardTextSmall2,children:a.I18n.t("or reboot server, then ioBroker should restart and you can be sure that all old processes were finished.")}),(0,b.jsx)("div",{style:I.standardTextSmall2,children:a.I18n.t('If the upgrade command displays permissions / permissions errors, fix them. Sometimes "sudo" is not enough and you have to run the installation as a real root (previously simply sudo su -).')})]}),"win32"===u&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(i.Box,{component:"h2",sx:I.h2,children:a.I18n.t("Windows")}),(0,b.jsxs)(i.Box,{component:"div",sx:I.standardText,children:[a.I18n.t("For updating ioBroker on Windows, download the appropriate installer with the desired js-controller version from the download page "),(0,b.jsx)("a",{rel:"noreferrer",href:"https://www.iobroker.net/#en/download",target:"_blank",children:"https://www.iobroker.net/#en/download"}),a.I18n.t(" and make the update with it. With the Windows Installer, previously manually installed servers or installations from other operating systems can be migrated to Windows and updated.")]}),(0,b.jsx)(i.Box,{component:"h2",sx:I.h2,children:a.I18n.t("Windows (manually installed)")}),(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t("A manual installation is done with administrator rights. Please start a cmd.exe command line window as an administrator (right-click on cmd.exe and execute as administrator) and execute the following commands:")}),(0,b.jsxs)("pre",{style:I.pre,children:[(0,b.jsx)(i.IconButton,{size:"small",onClick:()=>{window.alert(a.I18n.t("Copied")),x(`cd ${(d||"C:\\iobroker").replace(/\//g,"\\")}\niob backup\niob stop\niob status\niob update\niob upgrade self\n`)},style:I.copyButton,children:(0,b.jsx)(a.IconCopy,{})}),(0,b.jsxs)("div",{style:I.standardTextSmall,children:["cd",(d||"C:\\iobroker").replace(/\//g,"\\")," ",d?null:a.I18n.t("(or where ioBroker was installed)")]}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob backup"}),(0,b.jsxs)("div",{style:I.standardTextSmall,children:["iob stop",a.I18n.t("to stop the ioBroker service")]}),(0,b.jsxs)("div",{style:I.standardTextSmall,children:["iob status",a.I18n.t("to check if ioBroker has finished")]}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob update"}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob upgrade self"})]}),(0,b.jsx)("div",{style:I.standardTextSmall2,children:a.I18n.t("Start ioBroker service or reboot computer, then ioBroker should restart and you can be sure that all the old processes were finished.")})]}),(0,b.jsxs)(i.Accordion,{style:{paddingTop:14},children:[(0,b.jsx)(i.AccordionSummary,{sx:I.accordionSummary,expandIcon:(0,b.jsx)(r.ExpandMore,{}),children:(0,b.jsx)(i.Box,{component:"h2",sx:I.h22,children:a.I18n.t("Emergency Linux / macOS / Windows")})}),(0,b.jsxs)(i.AccordionDetails,{style:I.accordionDetails,children:[(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t("(manual reinstallation, if somehow nothing works after the update)")}),(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t('On Windows first please call in the start menu under "ioBroker" the command line of the relevant ioBroker instance. The correct directory is then set automatically. On Linux or macOS please go to the ioBroker directory.')}),(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t("Run npm install iobroker.js-controller there. A specific version can be installed using npm install iobroker.js-controller@x.y.z (replace x.y.z with the desired version).")}),(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t("If there are problems with access rights when running on Linux the command has to be changed slightly:")}),(0,b.jsx)("div",{style:I.standardTextSmall2,children:a.I18n.t("For systems created with the new Linux installer:")}),(0,b.jsxs)("pre",{style:I.pre,children:[(0,b.jsx)(i.IconButton,{size:"small",onClick:()=>{window.alert(a.I18n.t("Copied")),x(`cd ${"win32"===u?(d||"C:\\iobroker").replace(/\//g,"\\"):d||"/opt/iobroker"}\nsudo -u iobroker -H npm install iobroker.js-controller`)},style:I.copyButton,children:(0,b.jsx)(a.IconCopy,{})}),(0,b.jsxs)("div",{style:I.standardTextSmall,children:["cd","win32"===u?(d||"C:\\iobroker").replace(/\//g,"\\"):d||"/opt/iobroker"]}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"sudo -u iobroker -H npm install iobroker.js-controller"})]}),(0,b.jsx)("div",{style:I.standardTextSmall2,children:a.I18n.t("For systems installed manually under Linux, prefix sudo or run as root.")}),(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t("This way is only necessary in very few cases and please consult the forum beforehand!")})]})]})]})}),(0,b.jsxs)(i.DialogActions,{children:[(0,b.jsx)(i.Button,{id:"js-controller-dialog-changelog",variant:"contained",onClick:()=>{window.open(S.Uu,"_blank")},color:"grey",startIcon:(0,b.jsx)(r.Description,{}),children:a.I18n.t("Show whole changelog")}),(0,b.jsx)(i.Button,{id:"js-controller-dialog-ok",variant:"contained",onClick:()=>l(),color:"primary",startIcon:(0,b.jsx)(r.Close,{}),children:a.I18n.t("Ok")})]})]})},T={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"auto",padding:8},controlItem:{width:"calc(100% - 16px)",marginBottom:16,marginRight:8,marginLeft:8},RAM:{width:400,marginRight:8}};class F extends o.Component{constructor(t){super(t),this.focusRef=void 0;const e=this.props.settings||{};this.state={memoryLimitMB:e.memoryLimitMB||0,hostname:e.hostname||"",statisticsInterval:e.statisticsInterval||15e3,checkDiskInterval:e.checkDiskInterval||3e5,instanceStartInterval:e.instanceStartInterval||2e3,compact:e.compact||!1,allowShellCommands:e.allowShellCommands||!1,memLimitWarn:e.memLimitWarn||100,memLimitError:e.memLimitError||50,noChmod:e.noChmod||!1},this.focusRef=(0,o.createRef)()}componentDidMount(){var t;null===(t=this.focusRef.current)||void 0===t||t.focus()}onChange(){this.props.onChange({memoryLimitMB:this.state.memoryLimitMB,hostname:this.state.hostname,statisticsInterval:this.state.statisticsInterval,checkDiskInterval:this.state.checkDiskInterval,noChmod:this.state.noChmod,instanceStartInterval:this.state.instanceStartInterval,compact:this.state.compact,allowShellCommands:this.state.allowShellCommands,memLimitWarn:this.state.memLimitWarn,memLimitError:this.state.memLimitError})}render(){return(0,b.jsx)(i.Paper,{style:T.paper,children:(0,b.jsx)(i.Grid2,{style:T.gridSettings,children:(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:[(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",label:this.props.t("Host name"),style:T.controlItem,value:this.state.hostname||this.props.currentHost.replace("system.host.",""),onChange:t=>this.setState({hostname:t.target.value},(()=>this.onChange())),helperText:this.props.t("You can change the host name, but be aware, that all instances must be assigned anew")})}),(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",label:this.props.t("Check disk space interval"),style:T.controlItem,value:this.state.checkDiskInterval,type:"number",slotProps:{htmlInput:{min:1e3}},onChange:t=>this.setState({checkDiskInterval:parseInt(t.target.value,10)},(()=>this.onChange())),helperText:this.props.t("How oft the disk will be checked. Do not set it to low, because it can affect system performance. Value is in ms")})}),(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",label:this.props.t("Instance statistics update interval"),style:T.controlItem,value:this.state.statisticsInterval,type:"number",slotProps:{htmlInput:{min:5e3}},onChange:t=>this.setState({statisticsInterval:parseInt(t.target.value,10)},(()=>this.onChange())),helperText:this.props.t("How oft the instance statistics will be updated. Used RAM, CPU and so on. Value is in ms")})}),(0,b.jsxs)(i.Grid2,{style:T.controlItem,children:[(0,b.jsx)(i.FormControlLabel,{control:(0,b.jsx)(i.Checkbox,{checked:this.state.compact,onChange:t=>this.setState({compact:t.target.checked},(()=>this.onChange()))}),label:this.props.t("Compact mode")}),(0,b.jsx)("div",{children:this.props.t("When enabled adapter instances can run in one or few processes to save RAM usage.")})]}),(0,b.jsxs)(i.Grid2,{style:T.controlItem,children:[(0,b.jsx)(i.FormControlLabel,{control:(0,b.jsx)(i.Checkbox,{checked:this.state.allowShellCommands,onChange:t=>this.setState({allowShellCommands:t.target.checked},(()=>this.onChange()))}),label:this.props.t("Allow shell's commands")}),(0,b.jsx)("div",{children:this.props.t('Allow execution of sendToHost("shell", "cli command")')})]}),(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",label:this.props.t("Limit RAM size for controller"),style:T.controlItem,value:this.state.memoryLimitMB,type:"number",onChange:t=>this.setState({memoryLimitMB:parseInt(t.target.value,10)},(()=>this.onChange())),helperText:this.props.t("MB")})}),(0,b.jsx)(i.Grid2,{children:(0,b.jsxs)(i.Grid2,{container:!0,direction:"row",style:T.controlItem,children:[(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",label:this.props.t("Show warning im log if RAM less than"),style:T.RAM,value:this.state.memLimitWarn,type:"number",onChange:t=>this.setState({memLimitWarn:parseInt(t.target.value,10)},(()=>this.onChange())),helperText:this.props.t("MB")})}),(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",label:this.props.t("Show error in log if RAM less than"),style:T.RAM,value:this.state.memLimitError,type:"number",onChange:t=>this.setState({memLimitError:parseInt(t.target.value,10)},(()=>this.onChange())),helperText:this.props.t("MB")})})]})})]})})})}}const B=(0,a.withWidth)()(F),O={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"auto",padding:8},controlItem:{width:"calc(100% - 16px)",marginBottom:16,marginRight:8,marginLeft:8},RAM:{width:400,marginRight:8}};class _ extends o.Component{constructor(t){super(t),this.focusRef=void 0;const e=this.props.settings||{};this.state={enabled:e.enabled||!1,secure:e.secure||!0,password:""},e.password&&this.props.socket.decrypt(e.password).then((t=>this.setState({password:t}))),this.focusRef=(0,o.createRef)()}componentDidMount(){var t;null===(t=this.focusRef.current)||void 0===t||t.focus()}onChange(){const t={enabled:this.state.enabled,secure:this.state.secure};this.state.password?this.props.socket.encrypt(this.state.password).then((e=>{t.password=e,this.props.onChange(t)})):this.props.onChange(t)}render(){return(0,b.jsx)(i.Paper,{style:O.paper,children:(0,b.jsx)("form",{style:O.form,noValidate:!0,autoComplete:"off",children:(0,b.jsx)(i.Grid2,{style:O.gridSettings,children:(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:[(0,b.jsxs)(i.Grid2,{style:O.controlItem,children:[(0,b.jsx)(i.FormControlLabel,{control:(0,b.jsx)(i.Checkbox,{checked:this.state.enabled,onChange:t=>this.setState({enabled:t.target.checked},(()=>this.onChange()))}),label:this.props.t("Allow slave connections")}),(0,b.jsx)("div",{children:this.props.t("When activated this host can be discovered by other iobroker installations in your network to become the master of a multihost system.")})]}),(0,b.jsxs)(i.Grid2,{style:O.controlItem,children:[(0,b.jsx)(i.FormControlLabel,{control:(0,b.jsx)(i.Checkbox,{checked:this.state.secure,onChange:t=>this.setState({secure:t.target.checked},(()=>this.onChange()))}),label:this.props.t("With password")}),(0,b.jsx)("div",{children:this.props.t("Ask password by connection establishment")})]}),this.state.secure?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",label:this.props.t("Multi-host password"),style:O.controlItem,value:this.state.password,type:"password",slotProps:{input:{autoComplete:"new-password"},htmlInput:{autoComplete:"off"}},autoComplete:"off",onChange:t=>this.setState({password:t.target.value},(()=>this.onChange()))})}):null]})})})})}}const D=(0,a.withWidth)()(_),A={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"auto",padding:8},controlItem:{width:400,marginBottom:16,marginRight:8,marginLeft:8},dangerZone:{backgroundColor:"rgba(255, 165, 0, 0.05)",border:"2px solid rgba(255, 165, 0)",marginBottom:8},dangerZoneHeader:{background:"rgba(255, 165, 0)",color:"#FFF",paddingLeft:16,paddingTop:4,paddingBottom:4,marginTop:-1,marginLeft:-1},warning:t=>({p:1,fontSize:14,color:"dark"===t.palette.mode?"#ffa500":"#b17200"})},L={autoCompress:{sizeFactor:2,sizeFactorMinimumSize:25e3},throttleFS:{intervalMs:6e4,maxBufferedCommands:1e3}};class M extends o.Component{constructor(t){super(t),this.focusRef=void 0;const e=this.props.settings||{};e.options=e.options||{auth_pass:"",retry_max_delay:2e3,retry_max_count:19,db:0,family:0},e.backup=e.backup||{disabled:!1,files:24,hours:48,period:120,path:""},e.jsonlOptions=e.jsonlOptions||L,e.jsonlOptions.autoCompress=e.jsonlOptions.autoCompress||L.autoCompress,e.jsonlOptions.throttleFS=e.jsonlOptions.throttleFS||L.throttleFS,this.state={type:e.type||"file",host:Array.isArray(e.host)?e.host.join(","):e.host||"127.0.0.1",port:e.port||9001,noFileCache:e.noFileCache||!1,dataDir:e.dataDir||"",connectTimeout:e.connectTimeout||2e3,writeFileInterval:e.writeFileInterval||5e3,options_auth_pass:e.options.auth_pass||e.pass||"",options_retry_max_delay:e.options.retry_max_delay||2e3,options_retry_max_count:e.options.retry_max_count||19,options_db:e.options.db||0,options_family:e.options.family||0,backup_disabled:e.backup.disabled||!1,backup_files:e.backup.files||24,backup_hours:e.backup.hours||48,backup_period:e.backup.period||120,backup_path:e.backup.path||"",jsonlOptions_autoCompress_sizeFactor:e.jsonlOptions.autoCompress.sizeFactor||2,jsonlOptions_autoCompress_sizeFactorMinimumSize:e.jsonlOptions.autoCompress.sizeFactorMinimumSize||25e3,jsonlOptions_throttleFS_intervalMs:e.jsonlOptions.throttleFS.intervalMs||6e4,jsonlOptions_throttleFS_maxBufferedCommands:e.jsonlOptions.throttleFS.maxBufferedCommands||100,textIP:Array.isArray(e.host)||!!(e.host||"").match(/[^.\d]/)||(e.host||"").includes(","),IPs:["0.0.0.0","127.0.0.1"],loading:!0,showWarningDialog:!1,toConfirmType:"",originalDBType:e.type||"file"},this.focusRef=(0,o.createRef)()}componentDidMount(){this.props.socket.getIpAddresses(this.props.currentHost).then((t=>{const e=[...t];e.includes("0.0.0.0")||e.push("0.0.0.0"),e.includes("127.0.0.1")||e.push("127.0.0.1");let s=!!this.state.host.match(/[^.\d]/)||(this.state.host||"").includes(",");s||e.includes(this.state.host)||(s=!0),this.setState({IPs:e,loading:!1,textIP:s},(()=>this.focusRef.current&&this.focusRef.current.focus()))}))}onChange(){const t={type:this.state.type,host:this.state.host,port:parseInt(this.state.port,10),noFileCache:this.state.noFileCache,connectTimeout:parseInt(this.state.connectTimeout,10),writeFileInterval:parseInt(this.state.writeFileInterval,10),dataDir:this.state.dataDir,options:{auth_pass:this.state.options_auth_pass||null,retry_max_delay:parseInt(this.state.options_retry_max_delay,10),retry_max_count:parseInt(this.state.options_retry_max_count,10),db:parseInt(this.state.options_db,10),family:parseInt(this.state.options_family,10)},backup:{disabled:this.state.backup_disabled,files:parseInt(this.state.backup_files,10),hours:parseInt(this.state.backup_hours,10),period:parseInt(this.state.backup_period,10),path:this.state.backup_path},jsonlOptions:{autoCompress:{sizeFactor:parseInt(this.state.jsonlOptions_autoCompress_sizeFactor,10),sizeFactorMinimumSize:parseInt(this.state.jsonlOptions_autoCompress_sizeFactorMinimumSize,10)},throttleFS:{intervalMs:parseInt(this.state.jsonlOptions_throttleFS_intervalMs,10),maxBufferedCommands:parseInt(this.state.jsonlOptions_throttleFS_maxBufferedCommands,10)}}};t.jsonlOptions.autoCompress.sizeFactor<2&&(t.jsonlOptions.autoCompress.sizeFactor=2),t.jsonlOptions.autoCompress.sizeFactorMinimumSize<0&&(t.jsonlOptions.autoCompress.sizeFactorMinimumSize=0),t.jsonlOptions.throttleFS.intervalMs<0&&(t.jsonlOptions.throttleFS.intervalMs=0),t.jsonlOptions.throttleFS.maxBufferedCommands<0&&(t.jsonlOptions.throttleFS.maxBufferedCommands=0),this.props.onChange(t)}renderWarning(){return this.state.showWarningDialog?(0,b.jsx)(a.Confirm,{title:this.props.t("Please confirm"),text:this.props.t("switch_db_note"),onClose:t=>{if(t){let t;t="redis"===this.state.toConfirmType?6379:9001,this.setState({type:this.state.toConfirmType||"file",showWarningDialog:!1,port:t},(()=>this.onChange()))}else this.setState({showWarningDialog:!1})}}):null}render(){return(0,b.jsxs)(i.Paper,{style:A.paper,children:[this.state.loading?(0,b.jsx)(i.LinearProgress,{}):null,this.renderWarning(),(0,b.jsxs)(i.Grid2,{style:{...A.gridSettings,...A.dangerZone},children:[(0,b.jsx)("h3",{style:A.dangerZoneHeader,title:this.props.t("Invalid settings in these fields could lead to dead host"),children:this.props.t("Danger zone")}),(0,b.jsx)(i.Box,{component:"p",sx:A.warning,children:this.props.t("base_settings_hint")}),(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:[(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.Tooltip,{title:this.props.t("switch_db_note"),slotProps:{popper:{sx:{pointerEvents:"none"}}},children:(0,b.jsxs)(i.FormControl,{style:A.controlItem,variant:"standard",children:[(0,b.jsx)(i.InputLabel,{children:this.props.t("Type")}),(0,b.jsxs)(i.Select,{variant:"standard",value:this.state.type,onChange:t=>{if(t.target.value!==this.state.originalDBType)this.setState({toConfirmType:t.target.value,showWarningDialog:!0});else{let e;e="redis"===t.target.value?6379:9001,this.setState({type:t.target.value,port:e},(()=>this.onChange()))}},children:[(0,b.jsx)(i.MenuItem,{value:"jsonl",children:"JSON Lines"}),(0,b.jsx)(i.MenuItem,{value:"file",children:this.props.t("File")}),(0,b.jsx)(i.MenuItem,{value:"redis",children:"Redis"})]})]})})}),(0,b.jsx)(i.Grid2,{style:{paddingLeft:8},children:(0,b.jsx)(i.FormControlLabel,{control:(0,b.jsx)(i.Switch,{checked:this.state.textIP,onChange:t=>this.setState({textIP:t.target.checked},(()=>this.onChange()))}),label:this.props.t("IP is domain or more than one address")})}),(0,b.jsx)(i.Grid2,{children:this.state.textIP?(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.host,type:"text",onChange:t=>this.setState({host:t.target.value},(()=>this.onChange())),label:this.props.t("Bind IP address"),helperText:this.props.t("You can enter more than one address divided by comma")}):(0,b.jsxs)(i.FormControl,{style:A.controlItem,variant:"standard",children:[(0,b.jsx)(i.InputLabel,{children:this.props.t("Bind IP address")}),(0,b.jsx)(i.Select,{variant:"standard",value:this.state.host,onChange:t=>this.setState({host:t.target.value},(()=>this.onChange())),children:this.state.IPs.map((t=>(0,b.jsx)(i.MenuItem,{value:t,children:"0.0.0.0"===t?`0.0.0.0 [${this.props.t("All addresses")}]`:t},t)))})]})}),(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.port,type:"number",slotProps:{htmlInput:{min:1,max:65535}},onChange:t=>this.setState({port:t.target.value},(()=>this.onChange())),label:this.props.t("Port")})}),"file"===this.state.type||"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.dataDir,helperText:this.props.t("Optional. Always relative to iobroker.js-controller/"),onChange:t=>this.setState({dataDir:t.target.value},(()=>this.onChange())),label:this.props.t("Directory path")})}):null,(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.options_auth_pass,type:"password",helperText:this.props.t("Optional"),slotProps:{input:{autoComplete:"new-password"},htmlInput:{autoComplete:"off"}},autoComplete:"off",onChange:t=>this.setState({options_auth_pass:t.target.value},(()=>this.onChange())),label:"redis"===this.state.type?this.props.t("Redis password"):this.props.t("Connection password")})})]})]}),(0,b.jsx)(i.Grid2,{style:A.gridSettings,children:(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:["file"===this.state.type||"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.connectTimeout,helperText:this.props.t("ms"),type:"number",slotProps:{htmlInput:{min:200}},onChange:t=>this.setState({connectTimeout:t.target.value},(()=>this.onChange())),label:this.props.t("Connect timeout")})}):null,"file"===this.state.type||"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsxs)(i.FormControl,{component:"fieldset",variant:"standard",style:A.controlItem,children:[(0,b.jsx)(i.FormGroup,{children:(0,b.jsx)(i.FormControlLabel,{control:(0,b.jsx)(i.Checkbox,{checked:this.state.noFileCache,onChange:t=>this.setState({noFileCache:t.target.checked},(()=>this.onChange()))}),label:this.props.t("No file cache")})}),(0,b.jsx)(i.FormHelperText,{children:this.props.t("Always read files from disk and do not cache them in RAM. Used for debugging.")})]})}):null,"file"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.writeFileInterval,helperText:this.props.t("How often the data from RAM will be saved on disk in ms"),type:"number",slotProps:{htmlInput:{min:200}},onChange:t=>this.setState({writeFileInterval:t.target.value},(()=>this.onChange())),label:this.props.t("Store file interval")})}):null,"redis"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.options_retry_max_delay,type:"number",helperText:this.props.t("Maximum delay between connection attempts"),onChange:t=>this.setState({options_retry_max_delay:t.target.value},(()=>this.onChange())),label:this.props.t("Retry maximum delay")})}):null,"redis"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.options_retry_max_count,type:"number",helperText:this.props.t("Maximum number of connection retries"),onChange:t=>this.setState({options_retry_max_count:t.target.value},(()=>this.onChange())),label:this.props.t("Retry maximum count")})}):null,"redis"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.options_db,type:"number",helperText:this.props.t("Used for sentinels"),onChange:t=>this.setState({options_db:t.target.value},(()=>this.onChange())),label:this.props.t("DB number")})}):null,"redis"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsxs)(i.FormControl,{style:A.controlItem,variant:"standard",children:[(0,b.jsx)(i.InputLabel,{children:this.props.t("Family number")}),(0,b.jsxs)(i.Select,{variant:"standard",value:this.state.options_family,onChange:t=>this.setState({options_family:t.target.value},(()=>this.onChange())),children:[(0,b.jsx)(i.MenuItem,{value:0,children:"auto"}),(0,b.jsx)(i.MenuItem,{value:4,children:"IPv4"}),(0,b.jsx)(i.MenuItem,{value:6,children:"IPv6"})]}),(0,b.jsx)(i.FormHelperText,{children:this.props.t("Used for sentinels")})]})}):null,"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.jsonlOptions_autoCompress_sizeFactor,type:"number",slotProps:{htmlInput:{min:2}},helperText:this.props.t("The JSONL DB is append-only and will contain unnecessary entries after a while."),onChange:t=>this.setState({jsonlOptions_autoCompress_sizeFactor:t.target.value},(()=>this.onChange())),label:this.props.t("Auto-compress size factor")})}):null,"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.jsonlOptions_autoCompress_sizeFactorMinimumSize,type:"number",slotProps:{htmlInput:{min:0}},helperText:this.props.t("It will be compressed when the uncompressed size is >= size * sizeFactor AND >= sizeFactorMinimumSize"),onChange:t=>this.setState({jsonlOptions_autoCompress_sizeFactorMinimumSize:t.target.value},(()=>this.onChange())),label:this.props.t("Auto-compress size factor minimum size")})}):null,"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.jsonlOptions_throttleFS_intervalMs,type:"number",slotProps:{htmlInput:{min:0}},helperText:this.props.t("Write to the database file no more than every X milliseconds"),onChange:t=>this.setState({jsonlOptions_throttleFS_intervalMs:t.target.value},(()=>this.onChange())),label:this.props.t("Minimal write interval")})}):null,"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.jsonlOptions_throttleFS_maxBufferedCommands,type:"number",slotProps:{htmlInput:{min:0}},helperText:this.props.t("Force writing after this many changes have been buffered. This reduces memory consumption and data loss in case of a crash"),onChange:t=>this.setState({jsonlOptions_throttleFS_maxBufferedCommands:t.target.value},(()=>this.onChange())),label:this.props.t("Maximum changes before write")})}):null,"file"===this.state.type||"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsxs)(i.FormControl,{component:"fieldset",variant:"standard",style:A.controlItem,children:[(0,b.jsx)(i.FormGroup,{children:(0,b.jsx)(i.FormControlLabel,{control:(0,b.jsx)(i.Checkbox,{checked:this.state.backup_disabled,onChange:t=>this.setState({backup_disabled:t.target.checked},(()=>this.onChange()))}),label:this.props.t("No on-the-fly backup")})}),(0,b.jsx)(i.FormHelperText,{children:this.props.t("By every write the backup of object.json will be created.")})]})}):null,"file"!==this.state.type&&"jsonl"!==this.state.type||this.state.backup_disabled?null:(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.backup_files,type:"number",helperText:this.props.t("Minimal number of backup files, after the deletion will be executed according to the backup time settings"),onChange:t=>this.setState({backup_files:t.target.value},(()=>this.onChange())),label:this.props.t("Number of files")})}),"file"!==this.state.type&&"jsonl"!==this.state.type||this.state.backup_disabled?null:(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.backup_hours,type:"number",helperText:this.props.t("All backups older than these hours will be deleted, but only if the number of files is greater than of the files number"),onChange:t=>this.setState({backup_hours:t.target.value},(()=>this.onChange())),label:this.props.t("Backup hours")})}),"file"!==this.state.type&&"jsonl"!==this.state.type||this.state.backup_disabled?null:(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.backup_period,type:"number",helperText:this.props.t("By default the backup is every 2 hours. Time is in minutes. To disable backup set the value to 0"),onChange:t=>this.setState({backup_period:t.target.value},(()=>this.onChange())),label:this.props.t("How often")})}),"file"!==this.state.type&&"jsonl"!==this.state.type||this.state.backup_disabled?null:(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.backup_path,helperText:this.props.t("Absolute path to backup directory or empty to backup in data directory. Leave it empty for default storage place."),onChange:t=>this.setState({backup_path:t.target.value},(()=>this.onChange())),label:this.props.t("Path")})})]})})]})}}const z=(0,a.withWidth)()(M),H={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"auto",padding:8},controlItem:{width:400,marginBottom:16,marginRight:8,marginLeft:8},dangerZone:{backgroundColor:"rgba(255, 165, 0, 0.05)",border:"2px solid rgba(255, 165, 0)",marginBottom:8},dangerZoneHeader:{background:"rgba(255, 165, 0)",color:"#FFF",paddingLeft:16,paddingTop:4,paddingBottom:4,marginTop:-1,marginLeft:-1},warning:t=>({p:1,fontSize:14,color:"dark"===t.palette.mode?"#ffa500":"#b17200"})},R={autoCompress:{sizeFactor:2,sizeFactorMinimumSize:25e3},throttleFS:{intervalMs:6e4,maxBufferedCommands:1e3}};class P extends o.Component{constructor(t){super(t),this.focusRef=void 0;const e=this.props.settings||{};e.options=e.options||{auth_pass:"",retry_max_delay:2e3,retry_max_count:19,db:0,family:0},e.backup=e.backup||{disabled:!1,files:24,hours:48,period:120,path:""},e.jsonlOptions=e.jsonlOptions||R,e.jsonlOptions.autoCompress=e.jsonlOptions.autoCompress||R.autoCompress,e.jsonlOptions.throttleFS=e.jsonlOptions.throttleFS||R.throttleFS,this.state={type:e.type||"file",host:Array.isArray(e.host)?e.host.join(","):e.host||"127.0.0.1",port:e.port||9e3,connectTimeout:e.connectTimeout||2e3,writeFileInterval:e.writeFileInterval||5e3,dataDir:e.dataDir||"",options_auth_pass:e.options.auth_pass||e.pass||"",options_retry_max_delay:e.options.retry_max_delay||2e3,options_retry_max_count:e.options.retry_max_count||19,options_db:e.options.db||0,options_family:e.options.family||0,backup_disabled:e.backup.disabled||!1,backup_files:e.backup.files||24,backup_hours:e.backup.hours||48,backup_period:e.backup.period||120,backup_path:e.backup.path||"",jsonlOptions_autoCompress_sizeFactor:e.jsonlOptions.autoCompress.sizeFactor||2,jsonlOptions_autoCompress_sizeFactorMinimumSize:e.jsonlOptions.autoCompress.sizeFactorMinimumSize||25e3,jsonlOptions_throttleFS_intervalMs:e.jsonlOptions.throttleFS.intervalMs||6e4,jsonlOptions_throttleFS_maxBufferedCommands:e.jsonlOptions.throttleFS.maxBufferedCommands||100,textIP:Array.isArray(e.host)||!!(e.host||"").match(/[^.\d]/)||(e.host||"").includes(","),IPs:["0.0.0.0","127.0.0.1"],loading:!0,showWarningDialog:!1,toConfirmType:"",originalDBType:e.type||"file",noFileCache:e.noFileCache||!1},this.focusRef=(0,o.createRef)()}componentDidMount(){this.props.socket.getIpAddresses(this.props.currentHost).then((t=>{const e=[...t];e.includes("0.0.0.0")||e.push("0.0.0.0"),e.includes("127.0.0.1")||e.push("127.0.0.1");let s=!!this.state.host.match(/[^.\d]/)||(this.state.host||"").includes(",");s||e.includes(this.state.host)||(s=!0),this.setState({IPs:e,loading:!1,textIP:s},(()=>this.focusRef.current&&this.focusRef.current.focus()))}))}onChange(){const t={type:this.state.type,host:this.state.host,port:parseInt(this.state.port,10),noFileCache:this.state.noFileCache,connectTimeout:parseInt(this.state.connectTimeout,10),writeFileInterval:parseInt(this.state.writeFileInterval,10),dataDir:this.state.dataDir,options:{auth_pass:this.state.options_auth_pass||null,retry_max_delay:parseInt(this.state.options_retry_max_delay,10),retry_max_count:parseInt(this.state.options_retry_max_count,10),db:parseInt(this.state.options_db,10),family:parseInt(this.state.options_family,10)},backup:{disabled:this.state.backup_disabled,files:parseInt(this.state.backup_files,10),hours:parseInt(this.state.backup_hours,10),period:parseInt(this.state.backup_period,10),path:this.state.backup_path},jsonlOptions:{autoCompress:{sizeFactor:parseInt(this.state.jsonlOptions_autoCompress_sizeFactor,10),sizeFactorMinimumSize:parseInt(this.state.jsonlOptions_autoCompress_sizeFactorMinimumSize,10)},throttleFS:{intervalMs:parseInt(this.state.jsonlOptions_throttleFS_intervalMs,10),maxBufferedCommands:parseInt(this.state.jsonlOptions_throttleFS_maxBufferedCommands,10)}}};t.jsonlOptions.autoCompress.sizeFactor<2&&(t.jsonlOptions.autoCompress.sizeFactor=2),t.jsonlOptions.autoCompress.sizeFactorMinimumSize<0&&(t.jsonlOptions.autoCompress.sizeFactorMinimumSize=0),t.jsonlOptions.throttleFS.intervalMs<0&&(t.jsonlOptions.throttleFS.intervalMs=0),t.jsonlOptions.throttleFS.maxBufferedCommands<0&&(t.jsonlOptions.throttleFS.maxBufferedCommands=0),this.props.onChange(t)}renderWarning(){return this.state.showWarningDialog?(0,b.jsx)(a.Confirm,{title:this.props.t("Please confirm"),text:this.props.t("switch_db_note"),onClose:t=>{if(t){let t;t="redis"===this.state.toConfirmType?6379:9e3,this.setState({type:this.state.toConfirmType||"file",showWarningDialog:!1,port:t},(()=>this.onChange()))}else this.setState({showWarningDialog:!1})}}):null}render(){return(0,b.jsxs)(i.Paper,{style:H.paper,children:[this.state.loading?(0,b.jsx)(i.LinearProgress,{}):null,this.renderWarning(),(0,b.jsxs)(i.Grid2,{style:{...H.gridSettings,...H.dangerZone},children:[(0,b.jsx)("h3",{style:H.dangerZoneHeader,title:this.props.t("Invalid settings in these fields could lead to dead host"),children:this.props.t("Danger zone")}),(0,b.jsx)(i.Box,{component:"p",sx:H.warning,children:this.props.t("base_settings_hint")}),(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:[(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.Tooltip,{title:this.props.t("switch_db_note"),slotProps:{popper:{sx:{pointerEvents:"none"}}},children:(0,b.jsxs)(i.FormControl,{style:H.controlItem,variant:"standard",children:[(0,b.jsx)(i.InputLabel,{children:this.props.t("Type")}),(0,b.jsxs)(i.Select,{variant:"standard",value:this.state.type,onChange:t=>{if(t.target.value!==this.state.originalDBType)this.setState({toConfirmType:t.target.value,showWarningDialog:!0});else{let e;e="redis"===t.target.value?6379:9e3,this.setState({type:t.target.value,port:e},(()=>this.onChange()))}},children:[(0,b.jsx)(i.MenuItem,{value:"jsonl",children:"JSON Lines"}),(0,b.jsx)(i.MenuItem,{value:"file",children:this.props.t("File")}),(0,b.jsx)(i.MenuItem,{value:"redis",children:"Redis"})]})]})})}),(0,b.jsx)(i.Grid2,{style:{paddingLeft:8},children:(0,b.jsx)(i.FormControlLabel,{control:(0,b.jsx)(i.Switch,{checked:this.state.textIP,onChange:t=>this.setState({textIP:t.target.checked},(()=>this.onChange()))}),label:this.props.t("IP is domain or more than one address")})}),(0,b.jsx)(i.Grid2,{children:this.state.textIP?(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.host,type:"text",onChange:t=>this.setState({host:t.target.value},(()=>this.onChange())),label:this.props.t("Bind IP address"),helperText:this.props.t("You can enter more than one address divided by comma")}):(0,b.jsxs)(i.FormControl,{style:H.controlItem,variant:"standard",children:[(0,b.jsx)(i.InputLabel,{children:this.props.t("Bind IP address")}),(0,b.jsx)(i.Select,{variant:"standard",value:this.state.host,onChange:t=>this.setState({host:t.target.value},(()=>this.onChange())),children:this.state.IPs.map((t=>(0,b.jsx)(i.MenuItem,{value:t,children:"0.0.0.0"===t?`0.0.0.0 [${this.props.t("All addresses")}]`:t},t)))})]})}),(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.port,type:"number",slotProps:{htmlInput:{min:1,max:65535}},onChange:t=>this.setState({port:t.target.value},(()=>this.onChange())),label:this.props.t("Port")})}),"file"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.dataDir,helperText:this.props.t("Optional. Always relative to iobroker.js-controller/"),onChange:t=>this.setState({dataDir:t.target.value},(()=>this.onChange())),label:this.props.t("Directory path")})}):null,(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.options_auth_pass,type:"password",helperText:this.props.t("Optional"),slotProps:{input:{autoComplete:"new-password"},htmlInput:{autoComplete:"off"}},autoComplete:"off",onChange:t=>this.setState({options_auth_pass:t.target.value},(()=>this.onChange())),label:"redis"===this.state.type?this.props.t("Redis password"):this.props.t("Connection password")})})]})]}),(0,b.jsx)(i.Grid2,{style:H.gridSettings,children:(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:["file"===this.state.type||"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.connectTimeout,helperText:this.props.t("ms"),type:"number",slotProps:{htmlInput:{min:200}},onChange:t=>this.setState({connectTimeout:t.target.value},(()=>this.onChange())),label:this.props.t("Connect timeout")})}):null,"file"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.writeFileInterval,helperText:this.props.t("How often the data from RAM will be saved on disk in ms"),type:"number",slotProps:{htmlInput:{min:200}},onChange:t=>this.setState({writeFileInterval:t.target.value},(()=>this.onChange())),label:this.props.t("Store file interval")})}):null,"redis"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.options_retry_max_delay,type:"number",helperText:this.props.t("Maximum delay between connection attempts"),onChange:t=>this.setState({options_retry_max_delay:t.target.value},(()=>this.onChange())),label:this.props.t("Retry maximum delay")})}):null,"redis"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.options_retry_max_count,type:"number",helperText:this.props.t("Maximum number of connection retries"),onChange:t=>this.setState({options_retry_max_count:t.target.value},(()=>this.onChange())),label:this.props.t("Retry maximum count")})}):null,"redis"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.options_db,type:"number",helperText:this.props.t("Used for sentinels"),onChange:t=>this.setState({options_db:t.target.value},(()=>this.onChange())),label:this.props.t("DB number")})}):null,"redis"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsxs)(i.FormControl,{style:H.controlItem,variant:"standard",children:[(0,b.jsx)(i.InputLabel,{children:this.props.t("Family number")}),(0,b.jsxs)(i.Select,{variant:"standard",value:this.state.options_family,onChange:t=>this.setState({options_family:t.target.value},(()=>this.onChange())),children:[(0,b.jsx)(i.MenuItem,{value:0,children:"auto"}),(0,b.jsx)(i.MenuItem,{value:4,children:"IPv4"}),(0,b.jsx)(i.MenuItem,{value:6,children:"IPv6"})]}),(0,b.jsx)(i.FormHelperText,{children:this.props.t("Used for sentinels")})]})}):null,"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.jsonlOptions_autoCompress_sizeFactor,type:"number",slotProps:{htmlInput:{min:2}},helperText:this.props.t("The JSONL DB is append-only and will contain unnecessary entries after a while."),onChange:t=>this.setState({jsonlOptions_autoCompress_sizeFactor:t.target.value},(()=>this.onChange())),label:this.props.t("Auto-compress size factor")})}):null,"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.jsonlOptions_autoCompress_sizeFactorMinimumSize,type:"number",slotProps:{htmlInput:{min:0}},helperText:this.props.t("It will be compressed when the uncompressed size is >= size * sizeFactor AND >= sizeFactorMinimumSize"),onChange:t=>this.setState({jsonlOptions_autoCompress_sizeFactorMinimumSize:t.target.value},(()=>this.onChange())),label:this.props.t("Auto-compress size factor minimum size")})}):null,"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.jsonlOptions_throttleFS_intervalMs,type:"number",slotProps:{htmlInput:{min:0}},helperText:this.props.t("Write to the database file no more than every X milliseconds"),onChange:t=>this.setState({jsonlOptions_throttleFS_intervalMs:t.target.value},(()=>this.onChange())),label:this.props.t("Minimal write interval")})}):null,"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.jsonlOptions_throttleFS_maxBufferedCommands,type:"number",slotProps:{htmlInput:{min:0}},helperText:this.props.t("Force writing after this many changes have been buffered. This reduces memory consumption and data loss in case of a crash"),onChange:t=>this.setState({jsonlOptions_throttleFS_maxBufferedCommands:t.target.value},(()=>this.onChange())),label:this.props.t("Maximum changes before write")})}):null,"file"===this.state.type||"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsxs)(i.FormControl,{component:"fieldset",style:H.controlItem,variant:"standard",children:[(0,b.jsx)(i.FormGroup,{children:(0,b.jsx)(i.FormControlLabel,{control:(0,b.jsx)(i.Checkbox,{checked:this.state.backup_disabled,onChange:t=>this.setState({backup_disabled:t.target.checked},(()=>this.onChange()))}),label:this.props.t("No on-the-fly backup")})}),(0,b.jsx)(i.FormHelperText,{children:this.props.t("By every write the backup of object.json will be created.")})]})}):null,"file"!==this.state.type&&"jsonl"!==this.state.type||this.state.backup_disabled?null:(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.backup_files,type:"number",helperText:this.props.t("Minimal number of backup files, after the deletion will be executed according to the backup time settings"),onChange:t=>this.setState({backup_files:t.target.value},(()=>this.onChange())),label:this.props.t("Number of files")})}),"file"!==this.state.type&&"jsonl"!==this.state.type||this.state.backup_disabled?null:(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.backup_hours,type:"number",helperText:this.props.t("All backups older than these hours will be deleted, but only if the number of files is greater than of the files number"),onChange:t=>this.setState({backup_hours:t.target.value},(()=>this.onChange())),label:this.props.t("Backup hours")})}),"file"!==this.state.type&&"jsonl"!==this.state.type||this.state.backup_disabled?null:(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.backup_period,type:"number",helperText:this.props.t("By default the backup is every 2 hours. Time is in minutes. To disable backup set the value to 0"),onChange:t=>this.setState({backup_period:t.target.value},(()=>this.onChange())),label:this.props.t("How often")})}),"file"!==this.state.type&&"jsonl"!==this.state.type||this.state.backup_disabled?null:(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.backup_path,helperText:this.props.t("Absolute path to backup directory or empty to backup in data directory. Leave it empty for default storage place."),onChange:t=>this.setState({backup_path:t.target.value},(()=>this.onChange())),label:this.props.t("Path")})})]})})]})}}const W=(0,a.withWidth)()(P),N="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAbCAYAAADMIInqAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAiPSURBVFhH7Zd7UFTXGcDPvXffy8IusMsbQUEgoyiKD4pBnoKgVkoRX1WpNia2QZ2MzFTS2MykmlqiMzWJqSUxJq1KG0VrE0GxqSgSNVEx4SEaAeXNLrDsLvve2+/cvQusgIHWf2jymzns+b5zLvd+3/nOd75DoGEsWJDLaWvrXsXhcH/S3a0ODArynqfRDLRptfo6qVRcRdOGww8fftbGTv+/YNAB/v4ZsSrVQJHBYAunaVb5BBwOMri58farVI9eR+iejVVPakj8x8dn6cKWlv5zev3YxmMsFiRQqYyv8fleb+XnH2CenexQ2JCqqroLRiMKYHWIzyctLi680ujo4Aa93nDfbDZ72WxIYB/FQUMsbG5+VNHf/6DRrpu8kFeu3EnRaKzhrIxEIq5ZLhdHqdUXMior31+mVJ5fFhKiiBCLqXp2CrJaETKbyTxWnNSQtbWP5w4Pe3d30cWWln9+w4oMdXV/bw8K8tgLZoNkYZpeb5zLDE5yIJ7n7EZI8jtWRl5eLl91dn4azYqDxMZu4ldWVrqxaQMgIAnWK1lhkODgDLHNRuVqNIYMiJQ5Wq0JnCocsFjM/w4PD/ikqurop+zUUYHnY8xmIs9mIxI7O7V4QSDajJc8PEQfZ2fHXyguPhPa2KiLwXNJklLZbDf+wTw4Cr3rkUg8j5dDSYYOOyslRI8Ccs6FJP6J+XZizpz1+bduPf49M8pA0zKZ8N3U1NlvyeWuTYcOFTwlLToTGZmdcu9e9xGj0RZkzxXOEARtE4nIE/v2bdmVl7e+nVUzyGTpHKGQ+BCMXgOOG5FgKQr/tf4xPNxPUFPT8QKWeDzqlsn0rzEjsSMe+fCnCdtcFsG6DfscC0fwUZvPsp9PS3rbSoSHZ/k+eKBshAzPY8cZeDwSGnELHHJ51qyg6tWrUz5/+eW1j9jhESxevDn9xo3Gs3q9lcOqxkQm456fPj1g+fXrRyGbIHTsWAm1e/f7x1tbNauYCU+BJFE/JGRX3P9OByQgH/hpE8+XIEGE2K5kGRDKX3HL+foAWV9/qk0q5f8BDGWH7JhMNqTVWiGEbTsrKx9+uHPne80KRfrNmTPXrC0uLmXWw8HBg8dcqqtbPhgynrbKZLwTQUGibIR0yWFhnoVwqpjsYxCavaalarX6JVZE+/Z9tKS1td/JeD6f6AkOdi9FyPBmYKC0xh4BCDmMnwi6m1pk7hx8PYPQoNzfdSYujQ2MJCowUHQQPuJFCD+uXTc6sAJwUlAfgHO2InQZZ0SoI9JWt7frTzATwJEyGf/V3t6Lg3kFM2/ez1Lv3HlcajbbHe3pKap9553tkTk5aVZPz7RLSqU+kRkAKIq+BnljRXd3mQrLOEKOHy/PraioP6zXWwYjbLwRgPukkEL86SKnrUCI3S87bdTZs1dFNTX1boOhLEheMotl7O3v4cHfq1JdKMB9L6/0k52duhzcFwhI4+bNSTEkSTiVzFwuhywqKr/a32+aimU4blFUlL9XWFiQ9dSpqna12sA4nsslLYsXh0WXl79XjeXhBAdnHmps7PkVK07IAc6A2YSwhDM1ZpOTAxyUlFwSFxS8PVWpHIi3Wul4CO2EgQGLjB1mgPygjYz0nvbllye7CGJRBU1Tz2M9GA4RIGTmPEl/vxEyOrPtAfzb62XvSzuh0GZ6kO1rVKrzMxjhCcLCVkY0NPTU0rT9s/87B1CwqrzXBJk7C6V5ew2jlrOZmUm62tqSr7u6yg7BKmeFhMgVvr4SOCmGIgJyhItAIEjCfZp2GIX3KI3gTjFqGzIeg/8XlrHhQ+swZYqc7Y3Ez0+uFQqdcvXEILg6QiTP8v5c/wY2nlGtWZO/A380Bq8evOQvhYW7Rpzvu3Yd4BQVlTX39hp8WRVyc+Nvg4rxMIcTV2GxEEwEgAt0kHb+bO+PDZfLRb6+fr9pbm6AjYkjwJ7lpFJBTV9f2agREBW1NqK6urUWEiHDhCKA5tynvGf+VH7y9l1GduDvv0KPUBx4wN7k8uRUdsgJcADl4pLcAAcezMMtjl6wYAOTyYODV5506Pn8BGtW1o6ZzEPjIDd3j6tYnNzjeJ7LjTfHxm6cxQ474eGRCrdQx/sX0zxe4lfs0KhgB0CjO+Kos6r8nMG7znBIqNDO2EPQ3uC2V7h8+Q6nFcjKeoW4cuXuL3U6UyirgqsxaZNIRJW47+rK+8SxPaAIIq9evf9qQsJWp6MyJeVFF6Ew7ixCMfdwEwhi6yIjV8iOHn29381NeJudBtuE5lRWfvvuxo17IlgVKir6G7VkyUtbIA9B1ToBbIgmKOkBzozkHI/9xY9ZrRPEwoUb5l+/3nwN7gODHwz3fo1C4XpDpdLcNJstkLH5cZAIfwQJkZ2BjzHBZaWyLJ4VIXSTIXTNz+E+Ab6E2uJqQIDk47t3v33o7i71s9l4+X19RmYco1AIz3R1lWbifkzMhqVffNH0mSO5YSQSnkUs5pbDTbSZz+c/DxXic8Pfj/muLTAemDdGR6974/btlgJ8yxsfliaFQpIABjSxCuyAGSYTfRNWib02Pw1zvUQijtdoLsLet+Pnl36ktVX7C/aTxsWzcABzCqxbt2TP3LlTdkC1ph6e6Z8EanlIfLxrYrEoebjxmL6+8m9cXbmLoAgC/ej/Az/v4SG4A9Vd4nDjMf7+XtvCwhR/5XDwJWskoIdj0Ou0XO7Cap4NTu7Ozv61d0tLx4aamuZZUqlrUm+vjhmXSPidXC5V7evrfnrTprTzW7fmMEfIaCQnbxHX1bWt7OnRZXh6ypLUah0SiwUDRqPxWmCg/Nz8+aGnjxz5rXNdOgyIxpj2dvULcNOLV6sHRJ6erkip7CkJDQ06tX37j+/n5xc1dnRomLnPIgImFVASB3h7L4PwGt8pMB5GLYS+T/zgAPb3e8sPDmB/Jw34voKPREf730DoP5pKhvU07RMQAAAAAElFTkSuQmCC",G={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"hidden",padding:8},gridSettings:t=>({height:`calc(100% - ${t.mixins.toolbar.minHeight}px)`,width:"100%",overflow:"auto"}),controlItem:{width:400,marginBottom:16,marginRight:8,marginLeft:8},delButton:{position:"absolute",top:2,right:48},addButton:{marginRight:8},buttonIcon:{height:24},headingIcon:{height:24,marginRight:8}};class E extends o.Component{constructor(t){super(t),this.focusRef=void 0;const e=this.props.settings||{};e.transport=e.transport||{},Object.keys(e.transport).forEach((t=>{if("file"===e.transport[t].type){const s="string"===typeof e.transport[t].maxSize?e.transport[t].maxSize.includes("k")?.1:e.transport[t].maxSize.includes("g")?10:1:1;e.transport[t].maxSize=(parseInt(e.transport[t].maxSize,10)||0)*s,e.transport[t].level=e.transport[t].level||"",e.transport[t].maxFiles=e.transport[t].maxFiles||0}else"syslog"===e.transport[t].type?(e.transport[t].level=e.transport[t].level||"",e.transport[t].host=e.transport[t].host||"",e.transport[t].port=e.transport[t].port||0,e.transport[t].path=e.transport[t].path||"",e.transport[t].facility=e.transport[t].facility||"",e.transport[t].sysLogType=e.transport[t].sysLogType||"",e.transport[t].app_name=e.transport[t].app_name||"",e.transport[t].eol=e.transport[t].eol||""):"http"===e.transport[t].type?(e.transport[t].level=e.transport[t].level||"",e.transport[t].host=e.transport[t].host||"",e.transport[t].port=e.transport[t].port||0,e.transport[t].path=e.transport[t].path||"/",e.transport[t].auth=e.transport[t].auth||"None",e.transport[t].ssl=e.transport[t].ssl||!1):"stream"===e.transport[t].type?(e.transport[t].stream=e.transport[t].stream||"",e.transport[t].level=e.transport[t].level||"",e.transport[t].silent=e.transport[t].silent||!1,e.transport[t].eol=e.transport[t].eol||""):"seq"===e.transport[t].type&&(e.transport[t].level=e.transport[t].level||"",e.transport[t].serverUrl=e.transport[t].serverUrl||"",e.transport[t].apiKey=e.transport[t].apiKey||"",e.transport[t].eol=e.transport[t].eol||"")})),this.state={level:e.level||"info",maxDays:e.maxDays||7,noStdout:e.noStdout||!0,transport:e.transport||{},expanded:[]},this.focusRef=(0,o.createRef)()}componentDidMount(){var t;null===(t=this.focusRef.current)||void 0===t||t.focus()}onChange(){const t={level:this.state.level,maxDays:parseInt(this.state.maxDays,10),noStdout:this.state.noStdout,transport:{}};Object.keys(this.state.transport).forEach((e=>{t.transport[e]=JSON.parse(JSON.stringify(this.state.transport[e])),"file"===this.state.transport[e].type?(t.transport[e].maxSize=parseInt(t.transport[e].maxSize,10)||null,t.transport[e].maxSize&&(t.transport[e].maxSize=`${t.transport[e].maxSize.toString()}m`),t.transport[e].maxFiles=parseInt(t.transport[e].maxFiles,10)||null):"syslog"===this.state.transport[e].type?(t.transport[e].port||delete t.transport[e].port,t.transport[e].path||delete t.transport[e].path,t.transport[e].sysLogType||delete t.transport[e].sysLogType,t.transport[e].app_name||delete t.transport[e].app_name,t.transport[e].eol||delete t.transport[e].eol):"http"===this.state.transport[e].type?(t.transport[e].host=t.transport[e].host||"",t.transport[e].port=parseInt(t.transport[e].port,10)||80,t.transport[e].path=t.transport[e].path||"/",t.transport[e].auth=t.transport[e].auth||"",t.transport[e].ssl=t.transport[e].ssl||!1):"stream"===this.state.transport[e].type&&(t.transport[e].stream=t.transport[e].stream||"",t.transport[e].level=t.transport[e].level||"info",t.transport[e].silent=t.transport[e].silent||!1,t.transport[e].eol=t.transport[e].eol||"")})),this.props.onChange(t)}onDelete(t){const e=JSON.parse(JSON.stringify(this.state.transport));delete e[t],this.setState({transport:e},(()=>this.onChange()))}renderEnabled(t){return(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.FormControlLabel,{style:G.controlItem,control:(0,b.jsx)(i.Checkbox,{checked:this.state.transport[t].enabled,onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].enabled=e.target.checked,this.setState({transport:s},(()=>this.onChange()))}}),label:this.props.t("Enabled")})})}renderLogLevel(t){return this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsxs)(i.FormControl,{style:G.controlItem,variant:"standard",children:[(0,b.jsx)(i.InputLabel,{children:this.props.t("Level")}),(0,b.jsxs)(i.Select,{variant:"standard",value:this.state.transport[t].level||"_",renderValue:()=>this.state.transport[t].level||this.props.t("default"),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].level="_"===e.target.value?"":e.target.value,this.setState({transport:s},(()=>this.onChange()))},children:[(0,b.jsx)(i.MenuItem,{value:"_",children:this.props.t("default")}),(0,b.jsx)(i.MenuItem,{value:"silly",children:"silly"}),(0,b.jsx)(i.MenuItem,{value:"debug",children:"debug"}),(0,b.jsx)(i.MenuItem,{value:"info",children:"info"}),(0,b.jsx)(i.MenuItem,{value:"warn",children:"warn"}),(0,b.jsx)(i.MenuItem,{value:"error",children:"error"})]}),(0,b.jsx)(i.FormHelperText,{children:this.props.t("Level of messages that this transport should log (default: level set on parent logger)")})]})}):null}renderSyslog(t){return(0,b.jsxs)(i.Accordion,{expanded:this.state.expanded.includes(t),onChange:()=>{const e=[...this.state.expanded],s=e.indexOf(t);-1===s?e.push(t):e.splice(s,1),this.setState({expanded:e})},children:[(0,b.jsxs)(i.AccordionSummary,{expandIcon:(0,b.jsx)(r.ExpandMore,{}),style:{position:"relative",background:"rgba(128, 128, 128, 0.3)"},children:[(0,b.jsx)(r.Computer,{style:G.headingIcon}),(0,b.jsx)(i.Typography,{style:G.heading,children:t}),(0,b.jsx)(i.Fab,{size:"small",style:G.delButton,onClick:()=>this.onDelete(t),children:(0,b.jsx)(r.Delete,{})})]}),(0,b.jsx)(i.AccordionDetails,{children:(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:[this.renderEnabled(t),this.renderLogLevel(t),this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].host,helperText:this.props.t("The host running syslogd, defaults to localhost"),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].host=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("File name")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].port,type:"number",helperText:this.props.t("The port on the host that syslog is running on, defaults to syslogd's default port(514/UDP)."),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].port=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Port")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsxs)(i.FormControl,{style:G.controlItem,variant:"standard",children:[(0,b.jsx)(i.InputLabel,{children:this.props.t("Protocol")}),(0,b.jsxs)(i.Select,{variant:"standard",value:this.state.transport[t].protocol,onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].protocol=e.target.value,this.setState({transport:s},(()=>this.onChange()))},children:[(0,b.jsx)(i.MenuItem,{value:"udp4",children:"udp4"}),(0,b.jsx)(i.MenuItem,{value:"tcp4",children:"tcp4"}),(0,b.jsx)(i.MenuItem,{value:"unix",children:"unix"}),(0,b.jsx)(i.MenuItem,{value:"unix-connect",children:"unix-connect"})]})]})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].path,helperText:this.props.t("The path to the syslog dgram socket (i.e. /dev/log or /var/run/syslog for OS X)."),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].path=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Path")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].facility,helperText:this.props.t("Syslog facility to use (Default: local0)."),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].facility=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Facility")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].localhost,helperText:this.props.t("Host to indicate that log messages are coming from (Default: localhost)."),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].localhost=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Log name")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].sysLogType,helperText:this.props.t("The type of the syslog protocol to use (Default: BSD)."),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].sysLogType=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("SysLog Type")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].app_name,helperText:this.props.t("The name of the application (Default: process.title)."),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].app_name=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Application name")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].eol,helperText:this.props.t("The end of line character to be added to the end of the message (Default: Message without modifications)."),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].eol=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("End of line char")})}):null]})})]},t)}renderFile(t){return(0,b.jsxs)(i.Accordion,{expanded:this.state.expanded.includes(t),onChange:()=>{const e=[...this.state.expanded],s=e.indexOf(t);-1===s?e.push(t):e.splice(s,1),this.setState({expanded:e})},children:[(0,b.jsxs)(i.AccordionSummary,{style:{background:"rgba(128, 128, 128, 0.3)"},expandIcon:(0,b.jsx)(r.ExpandMore,{}),children:[(0,b.jsx)(r.InsertDriveFile,{style:G.headingIcon}),(0,b.jsx)(i.Typography,{style:G.heading,children:t}),(0,b.jsx)(i.Fab,{size:"small",style:G.delButton,onClick:()=>this.onDelete(t),children:(0,b.jsx)(r.Delete,{})})]}),(0,b.jsx)(i.AccordionDetails,{children:(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:[this.renderEnabled(t),this.renderLogLevel(t),this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].filename,onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].filename=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("File name")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].fileext,onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].fileext=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("File extension")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].maxSize,type:"number",helperText:this.props.t("MB"),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].maxSize=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Maximal size of one file")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].maxFiles,type:"number",onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].maxFiles=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Maximal number of files")})}):null]})})]},t)}renderHttp(t){return(0,b.jsxs)(i.Accordion,{expanded:this.state.expanded.includes(t),onChange:()=>{const e=[...this.state.expanded],s=e.indexOf(t);-1===s?e.push(t):e.splice(s,1),this.setState({expanded:e})},children:[(0,b.jsxs)(i.AccordionSummary,{expandIcon:(0,b.jsx)(r.ExpandMore,{}),style:{position:"relative",background:"rgba(128, 128, 128, 0.3)"},children:[(0,b.jsx)(r.Language,{style:G.headingIcon}),(0,b.jsx)(i.Typography,{style:G.heading,children:t}),(0,b.jsx)(i.Fab,{size:"small",style:G.delButton,onClick:()=>this.onDelete(t),children:(0,b.jsx)(r.Delete,{})})]}),(0,b.jsx)(i.AccordionDetails,{children:(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:[this.renderEnabled(t),this.renderLogLevel(t),this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].host,helperText:this.props.t("Remote host of the HTTP logging endpoint"),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].host=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Host")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].port,type:"number",helperText:this.props.t("Remote port of the HTTP logging endpoint"),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].port=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Port")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].path,helperText:this.props.t("Remote URI of the HTTP logging endpoint"),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].path=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Path")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].auth,helperText:this.props.t("An object representing the username and password for HTTP Basic Auth"),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].auth=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Auth")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.FormControlLabel,{style:G.controlItem,control:(0,b.jsx)(i.Checkbox,{checked:this.state.transport[t].ssl,onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].ssl=e.target.checked,this.setState({transport:s},(()=>this.onChange()))}}),label:this.props.t("SSL")})}):null]})})]},t)}renderStream(t){return(0,b.jsxs)(i.Accordion,{expanded:this.state.expanded.includes(t),onChange:()=>{const e=[...this.state.expanded],s=e.indexOf(t);-1===s?e.push(t):e.splice(s,1),this.setState({expanded:e})},children:[(0,b.jsxs)(i.AccordionSummary,{expandIcon:(0,b.jsx)(r.ExpandMore,{}),style:{position:"relative",background:"rgba(128, 128, 128, 0.3)"},children:[(0,b.jsx)(r.Send,{style:G.headingIcon}),(0,b.jsx)(i.Typography,{style:G.heading,children:t}),(0,b.jsx)(i.Fab,{size:"small",style:G.delButton,onClick:()=>this.onDelete(t),children:(0,b.jsx)(r.Delete,{})})]}),(0,b.jsx)(i.AccordionDetails,{children:(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:[this.renderEnabled(t),this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].stream,helperText:this.props.t("any Node.js stream. If an objectMode stream is provided then the entire info object will be written. Otherwise info[MESSAGE] will be written"),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].stream=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("File name")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.FormControlLabel,{style:G.controlItem,control:(0,b.jsx)(i.Checkbox,{checked:this.state.transport[t].silent,onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].silent=e.target.checked,this.setState({transport:s},(()=>this.onChange()))}}),label:this.props.t("Silent")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].eol,helperText:this.props.t("Line-ending character to use. (default: os.EOL).)"),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].eol=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("EOL")})}):null]})})]},t)}renderSEQ(t){return(0,b.jsxs)(i.Accordion,{expanded:this.state.expanded.includes(t),onChange:()=>{const e=[...this.state.expanded],s=e.indexOf(t);-1===s?e.push(t):e.splice(s,1),this.setState({expanded:e})},children:[(0,b.jsxs)(i.AccordionSummary,{expandIcon:(0,b.jsx)(r.ExpandMore,{}),style:{position:"relative",background:"rgba(128, 128, 128, 0.3)"},children:[(0,b.jsx)("img",{style:G.headingIcon,src:N,alt:"seq"}),(0,b.jsx)(i.Typography,{style:G.heading,children:t}),(0,b.jsx)(i.Fab,{size:"small",style:G.delButton,onClick:()=>this.onDelete(t),children:(0,b.jsx)(r.Delete,{})})]}),(0,b.jsx)(i.AccordionDetails,{children:(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:[this.renderEnabled(t),this.renderLogLevel(t),this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].serverUrl,helperText:this.props.t("The http(s) URL including port of the seq server. If you use HTTPS a real certificate is needed; self signed certs are ot accepted."),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].serverUrl=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Server URL")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].apiKey,helperText:this.props.t("The apiKey of the seq system"),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].apiKey=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("API key")})}):null]})})]},t)}findFreeName(t){for(let e=1;;e++)if(!Object.keys(this.state.transport).find((s=>s===t+e)))return t+e}add(t){if("file"===t){const e=this.findFreeName(t),s=JSON.parse(JSON.stringify(this.state.transport));s[e]={type:t,enabled:!0,filename:"log/iobroker",fileext:".log",maxSize:0,maxFiles:0},this.setState({transport:s},(()=>this.onChange()))}else if("syslog"===t){const e=this.findFreeName(t),s=JSON.parse(JSON.stringify(this.state.transport));s[e]={type:t,enabled:!0,host:"127.0.0.1",port:0,protocol:"udp4",path:"",facility:"",localhost:"iobroker",sysLogType:"",app_name:"",eol:""},this.setState({transport:s},(()=>this.onChange()))}else if("http"===t){const e=this.findFreeName(t),s=JSON.parse(JSON.stringify(this.state.transport));s[e]={type:t,enabled:!0,host:"127.0.0.1",port:80,path:"/",auth:"None",ssl:!1},this.setState({transport:s},(()=>this.onChange()))}else if("stream"===t){const e=this.findFreeName(t),s=JSON.parse(JSON.stringify(this.state.transport));s[e]={type:t,enabled:!0,stream:"/dev/null",level:"info",silent:!1,eol:""},this.setState({transport:s},(()=>this.onChange()))}else if("seq"===t){const e=this.findFreeName(t),s=JSON.parse(JSON.stringify(this.state.transport));s[e]={type:t,enabled:!0,level:"info",serverUrl:"http://IP:PORT",apiKey:""},this.setState({transport:s},(()=>this.onChange()))}}render(){return(0,b.jsxs)(i.Paper,{style:G.paper,children:[(0,b.jsx)(i.Grid2,{sx:G.gridSettings,children:(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:[(0,b.jsx)(i.Grid2,{children:(0,b.jsxs)(i.FormControl,{style:G.controlItem,variant:"standard",children:[(0,b.jsx)(i.InputLabel,{children:this.props.t("Level")}),(0,b.jsxs)(i.Select,{variant:"standard",value:this.state.level,onChange:t=>this.setState({level:t.target.value},(()=>this.onChange())),children:[(0,b.jsx)(i.MenuItem,{value:"silly",children:"silly"}),(0,b.jsx)(i.MenuItem,{value:"debug",children:"debug"}),(0,b.jsx)(i.MenuItem,{value:"info",children:"info"}),(0,b.jsx)(i.MenuItem,{value:"warn",children:"warn"}),(0,b.jsx)(i.MenuItem,{value:"error",children:"error"})]})]})}),(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.maxDays,helperText:this.props.t("Every day one file"),type:"number",onChange:t=>this.setState({maxDays:t.target.value},(()=>this.onChange())),label:this.props.t("Maximum number of days")})}),(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.FormControlLabel,{style:G.controlItem,control:(0,b.jsx)(i.Checkbox,{checked:this.state.noStdout,onChange:t=>this.setState({noStdout:t.target.checked},(()=>this.onChange()))}),label:this.props.t("No stdout outputs")})}),Object.keys(this.state.transport).map((t=>{switch(this.state.transport[t].type){case"syslog":return this.renderSyslog(t);case"file":return this.renderFile(t);case"http":return this.renderHttp(t);case"stream":return this.renderStream(t);case"seq":return this.renderSEQ(t);default:return null}}))]})}),(0,b.jsxs)(i.Toolbar,{children:[(0,b.jsxs)(i.Button,{color:"grey",style:G.addButton,variant:"contained",onClick:()=>this.add("file"),startIcon:(0,b.jsx)(r.Add,{}),children:[(0,b.jsx)(r.InsertDriveFile,{style:G.buttonIcon}),this.props.t("File log")]}),(0,b.jsxs)(i.Button,{color:"grey",style:G.addButton,variant:"contained",onClick:()=>this.add("syslog"),startIcon:(0,b.jsx)(r.Add,{}),children:[(0,b.jsx)(r.Computer,{style:G.buttonIcon}),this.props.t("Syslog")]}),(0,b.jsxs)(i.Button,{color:"grey",style:G.addButton,variant:"contained",onClick:()=>this.add("http"),startIcon:(0,b.jsx)(r.Add,{}),children:[(0,b.jsx)(r.Language,{style:G.buttonIcon}),this.props.t("HTTP log")]}),(0,b.jsxs)(i.Button,{color:"grey",style:G.addButton,variant:"contained",onClick:()=>this.add("stream"),startIcon:(0,b.jsx)(r.Add,{}),children:[(0,b.jsx)(r.Send,{style:G.buttonIcon}),this.props.t("Stream log")]}),(0,b.jsxs)(i.Button,{color:"grey",style:G.addButton,variant:"contained",onClick:()=>this.add("seq"),startIcon:(0,b.jsx)(r.Add,{}),children:[(0,b.jsx)("img",{src:N,style:G.buttonIcon,alt:"seq"}),this.props.t("SEQ log")]})]})]})}}const J=(0,a.withWidth)()(E);var U=s(40866);const $={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"auto",padding:8},title:{width:"100%",height:32},divWithoutTitle:{width:"100%",height:"calc(100% - 32px)",border:"2px solid #00000000"},error:{border:"2px solid #FF0000"}};class V extends o.Component{constructor(t){super(t),this.state={settings:JSON.stringify(this.props.settings||{},null,2),error:!1}}onChange(t){const e={settings:t};try{const s=JSON.parse(t);this.state.error&&(e.error=!1),this.setState(e,(()=>this.props.onChange(s)))}catch{e.error=!0,this.setState(e)}}render(){return(0,b.jsxs)(i.Paper,{style:$.paper,children:[(0,b.jsx)("div",{style:$.title,children:this.props.t("For future use")}),(0,b.jsx)("div",{style:{...$.divWithoutTitle,...this.state.error?$.error:void 0},children:(0,b.jsx)(U.A,{themeType:this.props.themeType,value:this.state.settings,onChange:t=>this.onChange(t)})})]})}}const q=(0,a.withWidth)()(V);var K=s(78884);const X={content:{height:500,overflow:"hidden"},tabPanel:t=>({width:"100%",height:`calc(100% - ${t.mixins.toolbar.minHeight}px)`,overflow:"auto"}),selected:t=>({color:"dark"===t.palette.mode?"#FFF !important":"#222 !important"})};class Q extends o.Component{constructor(t){super(t),this.originalSettings=void 0,this.state={currentTab:0,hasChanges:[],currentHost:this.props.currentHost,loading:!0,confirmExit:!1,showRestart:!1,system:null,multihostService:null,objects:null,states:null,log:null,plugins:null,dnsResolution:"ipv4first",dataDir:"",saving:!1}}async componentDidMount(){await this.getSettings(this.state.currentHost)}renderConfirmDialog(){return this.state.confirmExit?(0,b.jsx)(a.Confirm,{text:this.props.t("Discard unsaved changes?"),onClose:t=>this.setState({confirmExit:!1},(()=>t&&this.props.onClose()))}):null}renderRestartDialog(){return this.state.showRestart?(0,b.jsx)(a.Confirm,{title:this.props.t("Please confirm"),text:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{children:this.props.t("Restart works only if controller started as system service.")}),(0,b.jsx)("div",{children:this.props.t("Would you like to restart the controller for your changes to take effect?")})]}),ok:this.props.t("Restart"),cancel:this.props.t("No restart"),onClose:t=>this.setState({showRestart:!1},(()=>{t&&this.props.socket.restartController(this.props.currentHost).then((()=>setTimeout((()=>window.location.reload()),500))).catch((t=>window.alert(`Cannot restart: ${t}`))),this.props.onClose()}))}):null}async getSettings(t){const e=await this.props.socket.readBaseSettings(t||this.state.currentHost);null!==e&&void 0!==e&&e.config&&(this.originalSettings=K.A.clone(e.config),this.setState({loading:!1,system:e.config.system,multihostService:e.config.multihostService,objects:e.config.objects,states:e.config.states,log:e.config.log,plugins:e.config.plugins,dnsResolution:e.config.dnsResolution||"ipv4first",dataDir:e.config.dataDir}))}onSave(t){const e={system:this.state.system,multihostService:this.state.multihostService,objects:this.state.objects,states:this.state.states,log:this.state.log,plugins:this.state.plugins},s={...this.originalSettings,...e};this.setState({saving:!0},(()=>{this.props.socket.writeBaseSettings(t||this.state.currentHost,s).then((()=>{this.originalSettings=JSON.parse(JSON.stringify(e)),this.setState({hasChanges:[],showRestart:!0,saving:!1})})).catch((t=>{window.alert(`Cannot save settings: ${t}`),this.setState({saving:!1})}))}))}updateSettings(t,e){const s=[...this.state.hasChanges],o=JSON.stringify(this.originalSettings[t])!==JSON.stringify(e),n=s.indexOf(t);o&&-1===n?s.push(t):o||-1===n||s.splice(n,1),this.setState({[t]:e,hasChanges:s})}renderSystem(){const t="system";return(0,b.jsx)(B,{settings:this.state[t],t:this.props.t,currentHost:this.props.currentHost,onChange:e=>this.updateSettings(t,e)})}renderMultihost(){const t="multihostService";return(0,b.jsx)(D,{settings:this.state[t],t:this.props.t,socket:this.props.socket,currentHost:this.props.currentHost,onChange:e=>this.updateSettings(t,e)})}renderObjects(){const t="objects";return(0,b.jsx)(z,{settings:this.state[t],t:this.props.t,socket:this.props.socket,currentHost:this.props.currentHost,onChange:e=>this.updateSettings(t,e)})}renderStates(){const t="states";return(0,b.jsx)(W,{settings:this.state[t],t:this.props.t,socket:this.props.socket,currentHost:this.props.currentHost,onChange:e=>this.updateSettings(t,e)})}renderLog(){return(0,b.jsx)(J,{settings:this.state.log,t:this.props.t,socket:this.props.socket,currentHost:this.props.currentHost,onChange:t=>this.updateSettings("log",t)})}renderPlugins(){const t="plugins";return(0,b.jsx)(q,{settings:this.state[t],t:this.props.t,themeType:this.props.themeType,onChange:e=>this.updateSettings(t,e)})}render(){return(0,b.jsxs)(i.Dialog,{style:X.dialog,open:!0,onClose:()=>!1,fullWidth:!0,maxWidth:"xl","aria-labelledby":"base-settings-dialog-title",children:[(0,b.jsxs)(i.DialogTitle,{id:"base-settings-dialog-title",children:[this.props.t("Host Base Settings"),": ",this.props.currentHostName||this.props.currentHost]}),(0,b.jsxs)(i.DialogContent,{style:X.content,children:[(0,b.jsx)(i.AppBar,{position:"static",children:(0,b.jsxs)(i.Tabs,{value:this.state.currentTab,onChange:(t,e)=>this.setState({currentTab:e}),"aria-label":"system tabs",indicatorColor:"secondary",children:[(0,b.jsx)(i.Tab,{label:this.props.t("System"),id:"system-tab","aria-controls":"simple-tabpanel-0",sx:{"&.Mui-selected":X.selected}}),(0,b.jsx)(i.Tab,{label:this.props.t("Multi-host"),id:"multihost-tab",sx:{"&.Mui-selected":X.selected},"aria-controls":"simple-tabpanel-1"}),(0,b.jsx)(i.Tab,{label:this.props.t("Objects"),id:"objects-tab","aria-controls":"simple-tabpanel-3",sx:{"&.Mui-selected":X.selected}}),(0,b.jsx)(i.Tab,{label:this.props.t("States"),id:"states-tab","aria-controls":"simple-tabpanel-4",sx:{"&.Mui-selected":X.selected}}),(0,b.jsx)(i.Tab,{label:this.props.t("Log"),id:"log-tab","aria-controls":"simple-tabpanel-5",sx:{"&.Mui-selected":X.selected}}),(0,b.jsx)(i.Tab,{label:this.props.t("Plugins"),id:"plugins-tab","aria-controls":"simple-tabpanel-6",sx:{"&.Mui-selected":X.selected}})]})}),this.state.loading?(0,b.jsx)(i.LinearProgress,{}):null,this.state.loading||0!==this.state.currentTab?null:(0,b.jsx)(i.Box,{component:"div",sx:X.tabPanel,children:this.renderSystem()}),this.state.loading||1!==this.state.currentTab?null:(0,b.jsx)(i.Box,{component:"div",sx:X.tabPanel,children:this.renderMultihost()}),this.state.loading||2!==this.state.currentTab?null:(0,b.jsx)(i.Box,{component:"div",sx:X.tabPanel,children:this.renderObjects()}),this.state.loading||3!==this.state.currentTab?null:(0,b.jsx)(i.Box,{component:"div",sx:X.tabPanel,children:this.renderStates()}),this.state.loading||4!==this.state.currentTab?null:(0,b.jsx)(i.Box,{component:"div",sx:X.tabPanel,children:this.renderLog()}),this.state.loading||5!==this.state.currentTab?null:(0,b.jsx)(i.Box,{component:"div",sx:X.tabPanel,children:this.renderPlugins()}),this.renderConfirmDialog(),this.renderRestartDialog()]}),(0,b.jsxs)(i.DialogActions,{children:[(0,b.jsx)(i.Button,{variant:"contained",disabled:!this.state.hasChanges.length||this.state.saving,onClick:()=>this.onSave(),color:"primary",startIcon:(0,b.jsx)(r.Check,{}),children:this.props.t("Save & Close")}),(0,b.jsx)(i.Button,{variant:"contained",color:"grey",disabled:this.state.saving,onClick:()=>this.state.hasChanges.length?this.setState({confirmExit:!0}):this.props.onClose(),startIcon:(0,b.jsx)(r.Close,{}),children:this.state.hasChanges.length?this.props.t("Cancel"):this.props.t("Close")})]})]})}}const Z=(0,a.withWidth)()(Q),Y={error:{border:"2px solid #FF0000"},id:{fontStyle:"italic"},dialog:{height:"calc(100% - 64px)"},button:{marginTop:20,marginLeft:8},funcDivEdit:{width:"100%"},funcEditName:{display:"inline-block",width:85},funcEdit:{width:400},marginTop:{marginTop:20},commonTabWrapper:{flexFlow:"wrap",display:"flex"},commonWrapper:{width:500,minWidth:300},flexDrop:{width:"100%",maxWidth:500,margin:"auto",display:"flex"},marginBlock:{marginTop:20},buttonAdd:{minWidth:150},textField:{width:"100%"},flex:{display:"flex"},close:{width:"20px",height:"20px",opacity:"0.9",cursor:"pointer",position:"relative",top:20,transition:"all 0.6s ease","&:hover":{transform:"rotate(90deg)"},"&:before":{position:"absolute",left:"9px",content:'""',height:"20px",width:"3px",backgroundColor:"#ff4f4f",transform:"rotate(45deg)"},"&:after":{position:"absolute",left:"9px",content:'""',height:"20px",width:"3px",backgroundColor:"#ff4f4f",transform:"rotate(-45deg)"}},color:{width:70},buttonRemoveWrapper:{position:"absolute",zIndex:222,right:0},tabsPadding:{padding:"0px 24px"}};class tt extends o.Component{constructor(t){super(t),this.originalObj=void 0,this.state={text:JSON.stringify(this.props.obj,null,2),error:!1,changed:!1},this.originalObj=JSON.stringify(this.props.obj,null,2)}prepareObject(t){t=t||this.state.text;try{const e=JSON.parse(t);return e._id=this.props.obj._id,e}catch{return null}}onChange(t){const e={text:t},s=this.prepareObject(t);s?(e.changed=this.originalObj!==JSON.stringify(s,null,2),this.state.error&&(e.error=!1)):e.error=!0,this.setState(e)}onUpdate(){try{const t=JSON.parse(this.state.text);t._id=this.props.obj._id,this.props.onClose(t)}catch{}}setCommonItem(t,e,s){t.common[e]=s,this.onChange(JSON.stringify(t,null,2))}removeCommonItem(t,e){delete t.common.common[e],this.onChange(JSON.stringify(t,null,2))}buttonAddKey(t,e){const{t:s}=this.props;return(0,b.jsx)("div",{style:Y.marginBlock,children:(0,b.jsx)(i.Button,{style:Y.buttonAdd,variant:"contained",color:"secondary",onClick:e,startIcon:(0,b.jsx)(r.Add,{}),children:s(`Add ${t}`)})})}buttonRemoveKey(t,e){const{t:s}=this.props;return(0,b.jsx)(i.Tooltip,{title:s(`Remove ${t}`),slotProps:{popper:{sx:{pointerEvents:"none"}}},children:(0,b.jsx)(i.Box,{component:"div",sx:Y.close,onClick:e})})}renderCommonEdit(){try{const t=JSON.parse(this.state.text),e=!1,{t:s}=this.props;return(0,b.jsxs)("div",{style:Y.commonTabWrapper,children:[(0,b.jsxs)("div",{style:Y.commonWrapper,children:["undefined"!==typeof t.common.title?(0,b.jsx)(i.TextField,{variant:"standard",disabled:e,label:s("title"),style:{...Y.marginBlock,...Y.textField},fullWidth:!0,value:t.common.title,onChange:e=>this.setCommonItem(t,"title",e.target.value),slotProps:{input:{endAdornment:t.common.title?(0,b.jsx)(i.InputAdornment,{position:"end",children:(0,b.jsx)(i.IconButton,{size:"small",onClick:()=>this.setCommonItem(t,"title",""),children:(0,b.jsx)(r.Close,{})})}):null}}}):this.buttonAddKey("title",(()=>this.setCommonItem(t,"title",""))),"undefined"!==typeof t.common.color?(0,b.jsxs)("div",{style:Y.flex,children:[(0,b.jsx)(i.TextField,{variant:"standard",disabled:e,style:{...Y.marginBlock,...Y.color},label:s("Color"),type:"color",value:t.common.color,onChange:e=>this.setCommonItem(t,"color",e.target.value),slotProps:{input:{endAdornment:t.common.color?(0,b.jsx)(i.InputAdornment,{position:"end",children:(0,b.jsx)(i.IconButton,{size:"small",onClick:()=>this.setCommonItem(t,"color",""),children:(0,b.jsx)(r.Close,{})})}):null}}}),this.buttonRemoveKey("color",(()=>this.removeCommonItem(t,"color")))]}):this.buttonAddKey("color",(()=>this.setCommonItem(t,"color","")))]}),"undefined"!==typeof t.common.icon?(0,b.jsxs)("div",{style:Y.flexDrop,children:[(0,b.jsx)(a.UploadImage,{disabled:e,crop:!0,maxSize:262144,icon:t.common.icon,removeIconFunc:()=>this.setCommonItem(t,"icon",""),onChange:e=>this.setCommonItem(t,"icon",e)}),this.buttonRemoveKey("icon",(()=>this.removeCommonItem(t,"icon")))]}):(0,b.jsx)("div",{style:Y.flexDrop,children:this.buttonAddKey("icon",(()=>this.setCommonItem(t,"icon","")))})]})}catch{return(0,b.jsx)("div",{children:this.props.t("Cannot parse JSON!")})}}render(){return(0,b.jsxs)(i.Dialog,{sx:{"& .MuiDialog-paper":Y.dialog},open:!0,maxWidth:"lg",fullWidth:!0,fullScreen:!1,onClose:()=>this.props.onClose(),"aria-labelledby":"edit-value-dialog-title","aria-describedby":"edit-value-dialog-description",children:[(0,b.jsxs)(i.DialogTitle,{id:"edit-value-dialog-title",children:[this.props.t("Edit host settings"),":",(0,b.jsx)("span",{style:Y.id,children:this.props.obj._id})]}),(0,b.jsx)(i.DialogContent,{children:this.renderCommonEdit()}),(0,b.jsxs)(i.DialogActions,{children:[(0,b.jsx)(i.Button,{variant:"contained",disabled:this.state.error||!this.state.changed,onClick:()=>this.onUpdate(),color:"primary",startIcon:(0,b.jsx)(r.Check,{}),children:this.props.t("Write")}),(0,b.jsx)(i.Button,{variant:"contained",onClick:()=>this.props.onClose(),color:"grey",startIcon:(0,b.jsx)(r.Close,{}),children:this.props.t("Cancel")})]})]})}}const et=tt;var st=s(90869);const ot="0 2px 2px 0 rgba(0, 0, 0, .14),0 3px 1px -2px rgba(0, 0, 0, .12),0 1px 5px 0 rgba(0, 0, 0, .2)",nt="0 8px 17px 0 rgba(0, 0, 0, .2),0 6px 20px 0 rgba(0, 0, 0, .19)",it={img:{width:45,height:45,margin:"auto 0",position:"relative","&:after":{content:'""',position:"absolute",zIndex:2,top:0,left:0,width:"100%",height:"100%",background:'url("img/no-image.png") 100% 100% no-repeat',backgroundSize:"cover",backgroundColor:"#fff"}},collapseOff:{height:0},footerBlock:t=>({background:t.palette.background.default,p:"10px",display:"flex",justifyContent:"space-between"}),hidden:{display:"none"},emptyButton:{width:48},greenText:t=>({color:t.palette.success.dark}),wrapperAvailable:{display:"flex",alignItems:"center"},buttonUpdate:{border:`1px solid ${c.A[700]}`,padding:"2px 7px",borderRadius:"5px",display:"flex",alignItems:"center",cursor:"pointer",transition:"background 0.5s","&:hover":{background:"#00800026"}},buttonUpdateIcon:{height:20,width:20,marginRight:10},debug:{backgroundColor:u.A[700]},info:{backgroundColor:m.A[700]},warn:{backgroundColor:x.A[700]},error:{backgroundColor:g.A[700]},smallAvatar:{width:24,height:24},formControl:{display:"flex"},baseSettingsButton:{transform:"rotate(45deg)"},tooltip:{pointerEvents:"none"}},rt=["silly","debug","info","warn","error"];function at(t,e){const s=t.className.split(" "),o=s.indexOf(e);-1!==o&&(s.splice(o,1),t.className=s.join(" ")),s.push(e),setTimeout((e=>t.className=e),100,s.join(" "))}class lt extends o.Component{constructor(t){super(t),this.refEvents=n().createRef(),this.refWarning=n().createRef(),this.refCpu=n().createRef(),this.refMem=n().createRef(),this.refUptime=n().createRef(),this.outputCache="-",this.inputCache="-",this.cpuCache="- %",this.memCache="- %",this.uptimeCache="-",this.diskFreeCache=1,this.diskSizeCache=1,this.diskWarningCache=1,this.notificationHandler=t=>t&&t[this.props.hostId]&&this.setState({errorHost:{notifications:t[this.props.hostId],count:lt.calculateWarning(t[this.props.hostId])}}),this.eventsInputFunc=(t,e)=>{this.inputCache=e&&null!==e.val?`\u21e5${e.val}`:"-",this.refEvents.current&&(this.refEvents.current.innerHTML=`${this.inputCache} / ${this.outputCache}`,at(this.refEvents.current,`newValueHost-${this.props.themeType||"light"}`))},this.eventsOutputFunc=(t,e)=>{this.outputCache=e&&null!==e.val?`\u21a6${e.val}`:"-",this.refEvents.current&&(this.refEvents.current.innerHTML=`${this.inputCache} / ${this.outputCache}`,at(this.refEvents.current,`newValueHost-${this.props.themeType||"light"}`))},this.warningFunc=(t,e)=>{t.endsWith("diskFree")?this.diskFreeCache=(null===e||void 0===e?void 0:e.val)||0:t.endsWith("diskSize")?this.diskSizeCache=(null===e||void 0===e?void 0:e.val)||0:t.endsWith("diskWarning")&&(this.diskWarningCache=(null===e||void 0===e?void 0:e.val)||0);const s=this.diskFreeCache/this.diskSizeCache*100<=this.diskWarningCache;this.refWarning.current&&(s?(this.refWarning.current.setAttribute("title",this.props.t("Warning: Free space on disk is low")),this.refWarning.current.classList.add("warning")):(this.refWarning.current.removeAttribute("title"),this.refWarning.current.classList.remove("warning")))},this.cpuFunc=(t,e)=>{this.cpuCache=this.formatValue(e,"%"),this.refCpu.current&&(this.refCpu.current.innerHTML=this.cpuCache,at(this.refCpu.current,`newValueHost-${this.props.themeType||"light"}`))},this.memFunc=(t,e)=>{this.memCache=this.formatValue(e,"%"),this.refMem.current&&(this.refMem.current.innerHTML=this.memCache,at(this.refMem.current,`newValueHost-${this.props.themeType||"light"}`))},this.uptimeFunc=(t,e)=>{if(null!==e&&void 0!==e&&e.val){const t=Math.floor(e.val/86400),s=Math.floor(e.val%86400/3600);this.uptimeCache=t?`${t}d${s}h`:`${s}h`}this.refUptime.current&&(this.refUptime.current.innerHTML=this.uptimeCache,at(this.refUptime.current,`newValueHost-${this.props.themeType||"light"}`))},this.logLevelFunc=(t,e)=>{e&&this.setState({logLevel:e.val,logLevelSelect:e.val})},this.state={logLevel:"",logLevelSelect:"",errorHost:{notifications:null,count:0},openDialogLogLevel:!1,hostUpdateDialog:!1,updateAvailable:!1,instructionDialog:!1,updateDialog:!1,baseSettingsDialog:!1,editDialog:!1,changeLog:null}}async getInitialDiskStates(){var t,e,s;const o=await this.props.socket.getState(`${this.props.hostId}.diskWarning`);this.diskWarningCache=null!==(t=null===o||void 0===o?void 0:o.val)&&void 0!==t?t:this.diskWarningCache;const n=await this.props.socket.getState(`${this.props.hostId}.diskFree`);this.diskFreeCache=null!==(e=null===n||void 0===n?void 0:n.val)&&void 0!==e?e:this.diskFreeCache;const i=await this.props.socket.getState(`${this.props.hostId}.diskSize`);this.diskSizeCache=null!==(s=null===i||void 0===i?void 0:i.val)&&void 0!==s?s:this.diskSizeCache}readChangeLog(){this.state.changeLog||fetch(S.Uu.replace("github.com","raw.githubusercontent.com").replace("/blob/","/")).then((t=>t.text())).then((t=>this.setState({changeLog:t}))).catch((t=>console.error(`Cannot read changelog: ${t}`)))}componentDidMount(){this.props.hostsWorker.registerNotificationHandler(this.notificationHandler),this.props.hostsWorker.getNotifications(this.props.hostId).then((t=>this.notificationHandler(t))),this.props.socket.subscribeState(`${this.props.hostId}.inputCount`,this.eventsInputFunc),this.props.socket.subscribeState(`${this.props.hostId}.outputCount`,this.eventsOutputFunc),this.props.socket.subscribeState(`${this.props.hostId}.cpu`,this.cpuFunc),this.props.socket.subscribeState(`${this.props.hostId}.mem`,this.memFunc),this.props.socket.subscribeState(`${this.props.hostId}.uptime`,this.uptimeFunc),this.getInitialDiskStates().finally((async()=>{await this.props.socket.subscribeState(`${this.props.hostId}.diskFree`,this.warningFunc),await this.props.socket.subscribeState(`${this.props.hostId}.diskSize`,this.warningFunc),await this.props.socket.subscribeState(`${this.props.hostId}.diskWarning`,this.warningFunc)})),this.props.socket.subscribeState(`${this.props.hostId}.logLevel`,this.logLevelFunc)}componentWillUnmount(){this.props.hostsWorker.unregisterNotificationHandler(this.notificationHandler),this.props.socket.unsubscribeState(`${this.props.hostId}.inputCount`,this.eventsInputFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.outputCount`,this.eventsOutputFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.cpu`,this.cpuFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.mem`,this.memFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.uptime`,this.uptimeFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.diskFree`,this.warningFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.diskSize`,this.warningFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.diskWarning`,this.warningFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.logLevel`,this.logLevelFunc)}static calculateWarning(t){if(!t)return 0;const{result:e}=t;let s=0;if(!e||!e.system)return s;if(Object.keys(e.system.categories).length){const t=e.system.categories;Object.keys(t).forEach((e=>Object.keys(t[e].instances).forEach((()=>s++))))}return s}formatValue(t,e){return t&&null!==t.val&&void 0!==t.val?this.props.systemConfig.common.isFloatComma?t.val.toString().replace(".",",")+(e?` ${e}`:""):t.val+(e?` ${e}`:""):"-"+(e?` ${e}`:"")}renderDialogLogLevel(){return this.state.openDialogLogLevel?(0,b.jsxs)(st.A,{theme:this.props.theme,title:this.props.t("Edit log level rule for %s",this.props.host.common.name),onApply:()=>{this.props.socket.setState(`${this.props.hostId}.logLevel`,this.state.logLevelSelect).catch((t=>window.alert(`Cannot set log level: ${t}`))),this.setState({openDialogLogLevel:!1})},onClose:()=>this.setState({openDialogLogLevel:!1,logLevelSelect:this.state.logLevel}),children:[(0,b.jsxs)(i.FormControl,{style:{...it.formControl,marginTop:8},variant:"outlined",children:[(0,b.jsx)(i.InputLabel,{children:this.props.t("log level")}),(0,b.jsx)(i.Select,{variant:"standard",value:this.state.logLevelSelect,fullWidth:!0,onChange:t=>this.setState({logLevelSelect:t.target.value}),children:rt.map((t=>(0,b.jsx)(i.MenuItem,{value:t,children:this.props.t(t)},t)))})]}),(0,b.jsxs)(i.FormControl,{style:it.formControl,variant:"outlined",children:[(0,b.jsx)(i.FormHelperText,{children:this.props.t("Log level will be reset to the saved level after the restart of the controller")}),(0,b.jsxs)(i.FormHelperText,{children:[this.props.t("You can set the log level permanently in the base host settings"),(0,b.jsx)(r.Build,{style:it.baseSettingsButton})]})]})]}):null}onCopy(){const t=[];if(this.refCpu.current&&t.push(`CPU: ${this.refCpu.current.innerHTML}`),this.refMem.current&&t.push(`RAM: ${this.refMem.current.innerHTML}`),this.refUptime.current&&t.push(`${this.props.t("Uptime")}: ${this.refUptime.current.innerHTML}`),t.push(`${this.props.t("Available")}: ${this.props.available}`),t.push(`${this.props.t("Installed")}: ${this.props.host.common.installedVersion}`),this.refEvents.current&&t.push(`${this.props.t("Events")}: ${this.refEvents.current.innerHTML}`),this.props.hostData&&"object"===typeof this.props.hostData){const e=this.props.hostData;Object.keys(e).map((s=>t.push(`${this.props.t(s)}: ${lt.formatInfo[s]?lt.formatInfo[s](e[s],this.props.t):e[s]||"--"}`)))}a.Utils.copyToClipboard(t.join("\n")),window.alert(this.props.t("Copied"))}renderUpdateButton(t,e){return t?(0,b.jsx)(i.Tooltip,{title:this.props.t("Update"),slotProps:{popper:{sx:it.tooltip}},children:(0,b.jsxs)(i.Box,{component:"div",onClick:t=>{t.stopPropagation(),this.openHostUpdateDialog()},sx:it.buttonUpdate,children:[(0,b.jsx)(i.IconButton,{style:it.buttonUpdateIcon,size:"small",children:(0,b.jsx)(r.Refresh,{})}),(0,b.jsx)("span",{style:{color:c.A[700]},children:this.props.available})]})}):(0,b.jsx)("span",{style:e,children:this.props.available})}renderHostBaseEdit(){return this.props.expertMode?(0,b.jsx)(i.Tooltip,{title:this.props.t("Host Base Settings"),slotProps:{popper:{sx:it.tooltip}},children:(0,b.jsx)("div",{children:(0,b.jsx)(i.IconButton,{size:"large",disabled:!this.props.alive,onClick:t=>{t.stopPropagation(),this.setState({baseSettingsDialog:!0})},children:(0,b.jsx)(r.Build,{style:it.baseSettingsButton})})})}):null}renderExtendButton(t){return(0,b.jsx)(i.Tooltip,{title:this.props.t(t?"collapse":"Expand"),slotProps:{popper:{sx:it.tooltip}},children:(0,b.jsx)("div",{children:(0,b.jsx)(i.IconButton,{size:"large",children:t?(0,b.jsx)(d.mlL,{}):(0,b.jsx)(d.nwe,{})})})})}renderRestartButton(){return(0,b.jsx)(i.Tooltip,{title:this.props.t("Restart host"),slotProps:{popper:{sx:it.tooltip}},children:(0,b.jsx)("div",{children:(0,b.jsx)(i.IconButton,{size:"large",disabled:!this.props.alive,onClick:t=>{t.stopPropagation(),this.props.socket.restartController(this.props.hostId).catch((t=>window.alert(`Cannot restart: ${t}`)))},children:(0,b.jsx)(r.Cached,{})})})})}renderEditButton(){return(0,b.jsx)(i.IconButton,{size:"large",onClick:t=>{t.stopPropagation(),this.setState({editDialog:!0})},children:(0,b.jsx)(r.Edit,{})})}renderRemoveButton(){return this.props.alive||this.props.isCurrentHost?(0,b.jsx)("div",{style:it.emptyButton}):(0,b.jsx)(i.Tooltip,{title:this.props.alive||this.props.isCurrentHost?this.props.t("You cannot delete host, when it is alive"):this.props.t("Remove"),slotProps:{popper:{sx:it.tooltip}},children:(0,b.jsx)(i.IconButton,{size:"large",onClick:t=>{t.stopPropagation(),this.props.executeCommandRemove()},children:(0,b.jsx)(r.Delete,{})})})}renderCopyButton(t){return(0,b.jsx)(i.Tooltip,{title:this.props.t("Copy"),slotProps:{popper:{sx:it.tooltip}},children:(0,b.jsx)(i.IconButton,{size:"large",onClick:()=>this.onCopy(),style:t,children:(0,b.jsx)(a.IconCopy,{})})})}renderLogLevel(){return(0,b.jsx)(i.Tooltip,{title:`${this.props.t("loglevel")} ${this.state.logLevel}`,slotProps:{popper:{sx:it.tooltip}},children:(0,b.jsx)(i.IconButton,{size:"large",onClick:t=>{t.stopPropagation(),this.setState({openDialogLogLevel:!0})},children:(0,b.jsx)(i.Avatar,{style:{...it.smallAvatar,...it[this.state.logLevel]},children:(t=this.state.logLevel,"debug"===t?(0,b.jsx)(r.BugReport,{}):"info"===t?(0,b.jsx)(r.Info,{}):"warn"===t?(0,b.jsx)(r.Warning,{}):"error"===t?(0,b.jsx)(r.Error,{}):null)})})});var t}renderNotificationsBadge(t,e){return(0,b.jsx)(i.Badge,{sx:e?{right:-3,top:13,padding:"0 4px"}:void 0,title:this.props.t("Hosts notifications"),badgeContent:this.state.errorHost.count,style:it.badge,color:"error",onClick:t=>{t.stopPropagation(),this.props.showAdaptersWarning({[this.props.hostId]:this.state.errorHost.notifications},this.props.hostId)},children:t})}async openHostUpdateDialog(){const t=await this.props.socket.checkFeatureSupported("CONTROLLER_UI_UPGRADE");this.setState({hostUpdateDialog:!0,updateAvailable:t}),this.readChangeLog()}renderHostUpdateDialog(){return this.state.hostUpdateDialog?(0,b.jsx)(f.A,{adapter:this.props.host.common.name,adapterObject:this.props.jsControllerInfo,t:this.props.t,textUpdate:this.state.updateAvailable?this.props.t("Start update"):this.props.t("Show instructions"),textInstruction:this.props.t("Show whole changelog"),rightDependencies:!0,news:this.getNews(),toggleTranslation:this.props.toggleTranslation,noTranslation:this.props.noTranslation,onUpdate:()=>{this.state.updateAvailable?this.setState({hostUpdateDialog:!1,updateDialog:!0}):this.setState({hostUpdateDialog:!1,instructionDialog:!0})},theme:this.props.theme,installedVersion:this.props.host.common.installedVersion,onInstruction:()=>{window.open(S.Uu,"_blank")},onClose:()=>this.setState({hostUpdateDialog:!1})}):null}renderUpdateDialog(){return this.state.updateAvailable&&this.state.updateDialog?(0,b.jsx)(j,{socket:this.props.socket,hostId:this.props.hostId,version:this.props.jsControllerInfo.version,onClose:()=>this.setState({updateDialog:!1}),adminInstance:this.props.adminInstance,onUpdating:t=>this.props.onUpdating(t),themeType:this.props.themeType}):this.state.instructionDialog?(0,b.jsx)(k,{socket:this.props.socket,hostId:this.props.hostId,version:this.props.jsControllerInfo.version,onClose:()=>this.setState({instructionDialog:!1})}):null}static extractNews(t,e){const s=t.split("\n");let o="",n=!1;for(let i=0;i<s.length;i++)if(s[i].startsWith("## ")){if(n)break;s[i].startsWith(`## ${e}`)&&(n=!0)}else n&&(o+=`${s[i].replace(/^\*\s*/,"").replace(/^\(\w+\)\s*/,"")}\n`);return o}getNews(t){const e=this.props.jsControllerInfo,s=this.props.host.common.installedVersion,o=[];return s&&null!==e&&void 0!==e&&e.news&&Object.keys(e.news).forEach((n=>{try{if(p().gt(n,s)||t){let t=!1,s=this.props.noTranslation?e.news[n].en:e.news[n][this.props.lang]||e.news[n].en;if("see CHANGELOG.md"===e.news[n].en&&this.state.changeLog){const e=lt.extractNews(this.state.changeLog,n);e&&(s=e,t=!0)}o.push({version:n,news:s,downloaded:t})}}catch{console.warn(`Cannot compare "${n}" and "${s}"`)}})),o}baseSettingsSettingsDialog(){return this.state.baseSettingsDialog?(0,b.jsx)(Z,{currentHost:this.props.hostId,themeType:this.props.themeType,currentHostName:this.props.host.common.name,onClose:()=>this.setState({baseSettingsDialog:!1}),lang:this.props.lang,socket:this.props.socket,t:this.props.t},"base"):null}renderEditObjectDialog(){return this.state.editDialog?(0,b.jsx)(et,{obj:this.props.host,t:this.props.t,onClose:t=>this.setState({editDialog:!1},(()=>{t&&this.props.socket.setObject(t._id,t).then((()=>this.forceUpdate())).catch((t=>alert(`Cannot write object: ${t}`)))}))}):null}renderDialogs(){return(0,b.jsxs)(b.Fragment,{children:[this.renderDialogLogLevel(),this.renderHostUpdateDialog(),this.renderUpdateDialog(),this.renderEditObjectDialog(),this.baseSettingsSettingsDialog()]})}}lt.formatInfo={Uptime:K.A.formatSeconds,"System uptime":K.A.formatSeconds,RAM:K.A.formatRam,Speed:K.A.formatSpeed,"Disk size":K.A.formatBytes,"Disk free":K.A.formatBytes};const ht={...it,root:t=>({position:"relative",m:"10px",width:300,minHeight:200,background:t.palette.background.default,boxShadow:ot,display:"flex",flexDirection:"column",transition:"box-shadow 0.5s","&:hover":{boxShadow:nt},"& .warning":{backgroundColor:"#de0000 !important","&:before":{position:"absolute",right:0,top:-5,content:'"\u26a0"',fontSize:25,height:"30px",width:"30px",color:"black"},animation:"$warning 2.5s ease-in-out infinite alternate"}}),imageBlock:{minHeight:60,display:"flex",padding:"0 10px 0 10px",position:"relative",justifyContent:"space-between",transition:"background 0.5s"},fab:{position:"absolute",bottom:-20,width:40,height:40,right:20},collapse:{height:"100%",position:"absolute",width:"100%",zIndex:3,marginTop:"auto",bottom:0,transition:"height 0.3s",justifyContent:"space-between",display:"flex",flexDirection:"column"},collapseOff:{height:0},close:{width:20,height:20,opacity:.9,cursor:"pointer",position:"relative",ml:"auto",mb:"10px",transition:"all 0.6s ease","&:hover":{transform:"rotate(90deg)"},"&:before":{position:"absolute",left:9,content:'""',height:20,width:3,backgroundColor:"#ff4f4f",transform:"rotate(45deg)"},"&:after":{position:"absolute",left:9,content:'""',height:20,width:3,backgroundColor:"#ff4f4f",transform:"rotate(-45deg)"}},onOffLine:{alignSelf:"center",width:"100%",height:4},adapter:t=>({width:"100%",fontWeight:"bold",fontSize:16,verticalAlign:"middle",pl:1,pt:2,color:"dark"===t.palette.mode?"#333":"#555"}),cardContentInfo:t=>({overflow:"auto",paddingTop:0,backgroundColor:t.palette.background.paper,color:"dark"===t.palette.mode?"#EEE":"#111"}),cardContentH5:{height:"100%",display:"flex",flexDirection:"column",justifyContent:"space-between",paddingBottom:"10px !important"},marginTop10:{marginTop:10},displayFlex:{display:"flex"},marginLeft5:{marginLeft:5},enableButton:{display:"flex",justifyContent:"space-between",alignItems:"center"},instanceStateNotAlive1:{backgroundColor:"rgba(192, 192, 192, 0.4)"},green:{background:"#00ce00",position:"relative"},red:{background:"#da0000"},dotLine:{width:50,height:"100%",background:"linear-gradient(90deg, rgba(0,206,0,0.7497373949579832) 0%, rgba(31,255,1,1) 50%, rgba(0,206,0,0.7805497198879552) 100%)",zIndex:2,position:"absolute",left:-11},versionDate:{alignSelf:"center"},cardContentDiv:{position:"sticky",right:0,top:0,paddingTop:10},badge:{cursor:"pointer"},curdContentFlexCenter:{display:"flex",alignItems:"center",ml:"4px"},marginRight:{marginRight:"auto"},ul:{paddingTop:0,paddingBottom:0,paddingLeft:16,paddingRight:8},value:{marginLeft:5},label:{fontWeight:"bold"}};const pt=class extends lt{getHostDescriptionAll(){return this.props.hostData?"string"===typeof this.props.hostData?this.props.hostData:this.props.hostData&&"object"===typeof this.props.hostData?(0,b.jsx)("ul",{style:ht.ul,children:Object.keys(this.props.hostData).map((t=>(0,b.jsx)("li",{children:(0,b.jsxs)("span",{style:ht.black,children:[(0,b.jsxs)("span",{style:ht.label,children:[this.props.t(t),": "]}),(0,b.jsx)("span",{style:ht.value,children:lt.formatInfo[t]?lt.formatInfo[t](this.props.hostData[t],this.props.t):this.props.hostData[t]||"--"})]})},t)))},"ul"):(0,b.jsx)("ul",{style:ht.ul,children:(0,b.jsx)(i.Skeleton,{})},"ul"):(0,b.jsx)(i.Skeleton,{})}render(){const t=(this.props.isCurrentHost||this.props.alive)&&K.A.updateAvailable(this.props.host.common.installedVersion,this.props.available),e=this.getHostDescriptionAll();return(0,b.jsxs)(i.Card,{sx:a.Utils.getStyle(this.props.theme,ht.root,this.props.hidden&&ht.hidden),children:[this.renderDialogs(),this.state.openCollapse&&(0,b.jsxs)("div",{style:{...ht.collapse,...this.state.openCollapse?void 0:ht.collapseOff},children:[(0,b.jsxs)(i.CardContent,{sx:ht.cardContentInfo,children:[(0,b.jsx)("div",{style:ht.cardContentDiv,onClick:()=>this.setState({openCollapse:!1}),children:(0,b.jsx)(i.Box,{component:"div",sx:ht.close,onClick:()=>this.setState({openCollapse:!1})})}),e]}),(0,b.jsx)(i.Box,{component:"div",sx:ht.footerBlock})]}),(0,b.jsx)("div",{style:{...ht.onOffLine,...this.props.alive?ht.green:ht.red},children:this.props.alive&&(0,b.jsx)("div",{style:ht.dotLine})}),(0,b.jsxs)("div",{ref:this.refWarning,style:{...ht.imageBlock,...this.props.alive?void 0:ht.instanceStateNotAlive1,background:this.props.host.common.color||"inherit"},children:[(0,b.jsx)(i.CardMedia,{sx:ht.img,component:"img",image:this.props.host.common.icon||"img/no-image.png"}),(0,b.jsx)(i.Box,{component:"div",style:a.Utils.getStyle(this.props.theme,ht.adapter,{color:this.props.host.common.color&&a.Utils.invertColor(this.props.host.common.color,!0)||"inherit"}),children:this.renderNotificationsBadge(this.props.host.common.name,!0)}),this.state.openCollapse?null:(0,b.jsx)(i.Fab,{disabled:"string"===typeof e,onClick:()=>this.setState({openCollapse:!0}),style:ht.fab,color:"primary","aria-label":"add",title:this.props.t("Click for more"),children:(0,b.jsx)(r.MoreVert,{})})]}),(0,b.jsxs)(i.CardContent,{style:ht.cardContentH5,children:[(0,b.jsx)(i.Typography,{variant:"body2",color:"textSecondary",component:"div",children:(0,b.jsxs)("div",{style:ht.displayFlex,children:[(0,b.jsx)("span",{style:ht.label,children:"CPU:"}),(0,b.jsx)("div",{ref:this.refCpu,style:ht.value,children:"- %"})]})}),(0,b.jsx)(i.Typography,{variant:"body2",color:"textSecondary",component:"div",children:(0,b.jsxs)("div",{style:ht.displayFlex,children:[(0,b.jsx)("span",{style:ht.label,children:"RAM:"}),(0,b.jsx)("div",{ref:this.refMem,style:ht.value,children:"- %"})]})}),(0,b.jsx)(i.Typography,{variant:"body2",color:"textSecondary",component:"div",children:(0,b.jsxs)("div",{style:ht.displayFlex,children:[(0,b.jsxs)("span",{style:ht.label,children:[this.props.t("Uptime"),":"]}),(0,b.jsx)("div",{ref:this.refUptime,style:ht.value,children:"-d -h"})]})}),(0,b.jsxs)(i.Typography,{variant:"body2",color:"textSecondary",component:"div",style:ht.wrapperAvailable,children:[(0,b.jsxs)("span",{style:ht.label,children:[this.props.t("Available")," js-controller:"]}),(0,b.jsx)(i.Box,{component:"div",sx:{...t?ht.greenText:void 0,...ht.curdContentFlexCenter},children:this.renderUpdateButton(t)})]}),(0,b.jsxs)(i.Typography,{variant:"body2",color:"textSecondary",component:"p",children:[(0,b.jsxs)("span",{style:ht.label,children:[this.props.t("Installed")," js-controller:"]}),(0,b.jsx)("span",{style:ht.value,children:this.props.host.common.installedVersion})]}),(0,b.jsx)(i.Typography,{variant:"body2",color:"textSecondary",component:"div",children:(0,b.jsxs)("div",{style:ht.displayFlex,children:[(0,b.jsxs)("span",{style:ht.label,children:[this.props.t("Events"),":"]}),(0,b.jsx)("div",{ref:this.refEvents,style:ht.value,children:"- / -"})]})}),(0,b.jsx)("div",{style:ht.marginTop10,children:(0,b.jsxs)(i.Typography,{component:"span",style:ht.enableButton,children:[this.renderEditButton(),this.renderHostBaseEdit(),this.renderRestartButton(),this.props.expertMode&&this.state.logLevel&&this.renderLogLevel(),this.renderRemoveButton(),this.renderCopyButton()]})})]})]},this.props.hostId)}},dt={...it,root:t=>({position:"relative",m:"7px",background:t.palette.background.default,boxShadow:ot,overflow:"hidden",transition:"box-shadow 0.5s,height 0.3s","&:hover":{boxShadow:nt}}),imageBlock:{marginRight:6,minHeight:60,width:"100%",maxWidth:300,display:"flex",padding:"0 10px 0 10px",position:"relative",justifyContent:"space-between",transition:"background 0.5s",alignItems:"baseline"},collapse:{height:200,backgroundColor:"rgba(128, 128, 128, 0.1)",width:"100%",zIndex:3,marginTop:"auto",bottom:0,transition:"height 0.3s",justifyContent:"space-between",display:"flex",flexDirection:"column"},collapseOn:{animation:"height 1s"},onOff:{alignSelf:"center",width:4,height:"100%"},host:t=>({width:"100%",fontWeight:"bold",fontSize:16,paddingLeft:"8px",alignSelf:"center",color:"dark"===t.palette.mode?"#ddd":"#222",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}),cardContentH5:{height:"100%",display:"flex",width:"100%",justifyContent:"space-between",padding:"10px !important",alignItems:"center"},marginTop10:{marginLeft:"auto",display:"flex"},enableButton:{display:"flex",justifyContent:"space-between"},green:{background:"#00ce00",position:"relative",overflow:"hidden"},dotLine:{width:10,height:20,background:"linear-gradient( rgba(0,206,0,0.7497373949579832) 0%, rgba(31,255,1,1) 50%, rgba(0,206,0,0.7805497198879552) 100%)",zIndex:2,position:"absolute",top:-21},red:{background:"#da0000"},flex:{flex:1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},cardContentInfo:{overflow:"auto",paddingTop:0,justifyContent:"center",display:"flex",height:"100%",position:"relative"},cursorNoDrop:{cursor:"no-drop !important"},wrapperFlex:{display:"flex",cursor:"pointer","& .warning":{backgroundColor:"#de0000 !important","&:before":{position:"absolute",right:0,top:-5,content:'"\u26a0"',fontSize:25,height:"30px",width:"30px",color:"black"},animation:"$warning 2.5s ease-in-out infinite alternate"},"@media screen and (max-width: 500px)":{flexDirection:"column"}},wrapperColor:{position:"relative",overflow:"hidden"},hidden1100:{"@media screen and (max-width: 1100px)":{display:"none !important"}},hidden800:{"@media screen and (max-width: 800px)":{display:"none !important"}},hidden600:{"@media screen and (max-width: 600px)":{display:"none !important"}},badge:{top:14},curdContentFlexCenter:{display:"flex",alignItems:"center"},wrapperInfo:{display:"flex",flexFlow:"wrap",width:"100%",justifyContent:"space-around"},wrapperBlockItem:{display:"flex",flexFlow:"nowrap",whiteSpace:"nowrap",margin:10},bold:{fontWeight:"bold"},nowrap:{display:"flex",flexFlow:"nowrap",flex:1,whiteSpace:"nowrap",marginRight:5},cell:{}};const ct=class extends lt{renderValue(t){return"object"!==typeof this.props.hostData?null:(0,b.jsxs)("div",{style:dt.wrapperBlockItem,children:[(0,b.jsxs)("span",{style:{...dt.bold,...dt.nowrap},children:[this.props.t(t),": "]}),lt.formatInfo[t]?lt.formatInfo[t](this.props.hostData[t],this.props.t):this.props.hostData[t]||"--"]},t)}getHostDescriptionAll(){return this.props.hostData?"string"===typeof this.props.hostData?this.props.hostData:(0,b.jsxs)("div",{style:dt.wrapperInfo,children:[(0,b.jsx)("div",{style:dt.marginRight,children:this.props.hostData&&"object"===typeof this.props.hostData?Object.keys(this.props.hostData).map(((t,e)=>e<5&&this.renderValue(t))):(0,b.jsx)(i.Skeleton,{})}),(0,b.jsx)("div",{style:dt.marginRight,children:this.props.hostData&&"object"===typeof this.props.hostData?Object.keys(this.props.hostData).map(((t,e)=>e>4&&e<10&&this.renderValue(t))):(0,b.jsx)(i.Skeleton,{})}),(0,b.jsx)("div",{style:dt.marginRight,children:this.props.hostData&&"object"===typeof this.props.hostData&&Object.keys(this.props.hostData).map(((t,e)=>e>10&&this.renderValue(t)))})]}):(0,b.jsx)(i.Skeleton,{})}render(){const t=(this.props.isCurrentHost||this.props.alive)&&K.A.updateAvailable(this.props.host.common.installedVersion,this.props.available),e=this.getHostDescriptionAll();return(0,b.jsxs)(i.Box,{component:"div",sx:a.Utils.getStyle(this.props.theme,dt.root,this.props.hidden&&dt.hidden,{border:`2px solid ${this.props.host.common.color||"inherit"}`,borderRadius:"5px"}),children:[this.renderDialogs(),(0,b.jsxs)(i.Box,{component:"div",sx:{...dt.wrapperFlex,...this.props.alive?void 0:dt.cursorNoDrop},onClick:this.state.openDialogLogLevel?null:()=>this.setState({openCollapse:!this.state.openCollapse}),children:[(0,b.jsxs)("div",{style:dt.wrapperColor,children:[(0,b.jsx)("div",{style:{...dt.onOff,...this.props.alive?dt.green:dt.red}}),this.props.alive&&(0,b.jsx)("div",{style:dt.dotLine})]}),(0,b.jsxs)("div",{ref:this.refWarning,style:{...dt.imageBlock,background:this.props.host.common.color||"inherit"},children:[this.renderNotificationsBadge((0,b.jsx)(i.CardMedia,{sx:dt.img,component:"img",image:this.props.host.common.icon||"img/no-image.png"}),!0),(0,b.jsx)("div",{style:a.Utils.getStyle(this.props.theme,dt.host,{color:this.props.host.common.color&&a.Utils.invertColor(this.props.host.common.color,!0)||"inherit"}),children:this.props.host.common.name})]}),(0,b.jsxs)(i.CardContent,{sx:{"&.MuiCardContent-root":dt.cardContentH5},children:[(0,b.jsx)(i.Typography,{sx:{...dt.flex,...dt.hidden800,...dt.cell},variant:"body2",color:"textSecondary",component:"div",children:(0,b.jsx)("div",{ref:this.refCpu,children:"- %"})}),(0,b.jsx)(i.Typography,{sx:{...dt.flex,...dt.hidden800,...dt.cell},variant:"body2",color:"textSecondary",component:"div",children:(0,b.jsx)("div",{ref:this.refMem,children:"- %"})}),(0,b.jsx)(i.Typography,{sx:{...dt.flex,...dt.hidden800,...dt.cell},variant:"body2",color:"textSecondary",component:"div",children:(0,b.jsx)("div",{ref:this.refUptime,children:"-/-"})}),(0,b.jsx)(i.Typography,{sx:{...dt.flex,...dt.hidden1100},variant:"body2",color:"textSecondary",component:"p",children:this.props.host.common.installedVersion}),(0,b.jsx)(i.Typography,{sx:{...dt.flex,...dt.hidden1100,...dt.cell},variant:"body2",color:"textSecondary",component:"div",children:(0,b.jsx)(i.Box,{component:"div",sx:{...t?dt.greenText:void 0,...dt.curdContentFlexCenter},children:this.renderUpdateButton(t)})}),(0,b.jsx)(i.Typography,{sx:{...dt.flex,...dt.hidden600,...dt.cell},variant:"body2",color:"textSecondary",component:"div",children:(0,b.jsx)("div",{ref:this.refEvents,children:"- / -"})}),(0,b.jsx)("div",{style:dt.marginTop10,children:(0,b.jsxs)(i.Typography,{component:"span",style:dt.enableButton,children:[this.renderEditButton(),this.renderHostBaseEdit(),this.renderRestartButton(),this.props.expertMode&&this.state.logLevel?this.renderLogLevel():(0,b.jsx)("div",{style:dt.emptyButton}),this.renderRemoveButton(),this.renderExtendButton(this.state.openCollapse)]})})]})]}),"object"===typeof e&&(0,b.jsxs)("div",{style:{...dt.collapse,...this.state.openCollapse?dt.collapseOn:dt.collapseOff},onClick:t=>t.stopPropagation(),children:[(0,b.jsxs)(i.CardContent,{style:dt.cardContentInfo,children:[e,this.renderCopyButton({height:44,width:44})]}),(0,b.jsx)(i.Box,{component:"div",sx:dt.footerBlock})]})]},this.props.hostId)}},ut={grow:{flexGrow:1},cards:{display:"flex",flexFlow:"wrap",justifyContent:"center"},tabHeaderWrapper:{height:30,display:"flex",margin:7},tabHeaderFirstItem:{width:306,paddingLeft:30,fontSize:14,fontWeight:600,alignSelf:"center"},tabHeaderItem:{flex:1,fontSize:14,fontWeight:600,alignSelf:"center"},tabHeaderItemButton:{fontSize:14,fontWeight:600,alignSelf:"center"},widthButtons:{width:240},tabFlex:{display:"flex",flex:1,padding:"0 10px"},bold:{fontWeight:"bold"},marginRight:{marginRight:"auto"},notStableRepo:t=>({background:"dark"===t.palette.mode?"#8a7e00":"#fdee20",color:"#000",fontSize:14,padding:"2px 8px",borderRadius:"5px"}),hidden1100:{"@media screen and (max-width: 1100px)":{display:"none !important"}},hidden800:{"@media screen and (max-width: 800px)":{display:"none !important"}},hidden600:{"@media screen and (max-width: 600px)":{display:"none !important"}},jsController:{fontSize:12,opacity:.4,display:"block"},tooltip:{pointerEvents:"none"}},mt={};function xt(t){var e;if(null!==(e=t.dockerInformation)&&void 0!==e&&e.isDocker){let e=t.dockerInformation.isOfficial?"official image":"unofficial image";t.dockerInformation.isOfficial&&(e+=` - ${t.dockerInformation.officialVersion}`),t.Platform=`${t.Platform} (${e})`}delete t.dockerInformation}class gt extends o.Component{constructor(t){super(t),this.t=(t,e,s)=>(void 0===e||void 0===s||mt[`${t} ${e} ${s}`]?void 0===e||mt[`${t} ${e}`]?mt[t]||(mt[t]=this.props.t(t)):mt[`${t} ${e}`]=this.props.t(t,e):mt[`${t} ${e} ${s}`]=this.props.t(t,e,s),void 0!==e&&void 0!==s?mt[`${t} ${e} ${s}`]:void 0!==e?mt[`${t} ${e}`]:mt[t]),this.updateHosts=t=>{const e=JSON.parse(JSON.stringify(this.state.hosts)),s=JSON.parse(JSON.stringify(this.state.alive));Promise.all(t.map((async t=>{const o=e.find((e=>e._id===t.id));if(o){const s=e.indexOf(o);t.obj?e[s]=t.obj:e.splice(s,1)}else{const o=await this.props.socket.getState(`${t.id}.alive`);s[t.id]=!(null===o||void 0===o||!o.val),e.push(t.obj)}}))).then((()=>{const t={hosts:e,alive:s};this.state.filterText&&e.length<=2&&(t.filterText=""),this.setState(t)}))},this.updateHostsAlive=t=>{const e=JSON.parse(JSON.stringify(this.state.alive));let s=!1;t.forEach((t=>{"deleted"===t.type?void 0!==e[t.id]&&(delete e[t.id],s=!0):!!e[t.id]!==!!t.alive&&(e[t.id]=t.alive,s=!0)})),s&&this.setState({alive:e})},this.state={viewMode:"true"===(window._localStorage||window.localStorage).getItem("Hosts.viewMode"),alive:{},hosts:[],repository:{},hostsData:{},filterText:(window._localStorage||window.localStorage).getItem("Hosts.filterText")||"",showSlowConnectionWarning:!1,readTimeoutMs:l.o.getReadTimeoutMs()}}componentDidMount(){this.readInfo().then((()=>{this.props.hostsWorker.registerHandler(this.updateHosts),this.props.hostsWorker.registerAliveHandler(this.updateHostsAlive)}))}componentWillUnmount(){this.props.hostsWorker.unregisterHandler(this.updateHosts),this.props.hostsWorker.unregisterAliveHandler(this.updateHostsAlive)}getHostsData(t,e){const s=[];for(let o=0;o<t.length;o++)if(e[t[o]._id]){const e=this.props.socket.getHostInfo(t[o]._id,null,this.state.readTimeoutMs).catch((e=>(console.error(`Cannot get getHostInfo: ${e}`),e.toString().includes("timeout")&&this.setState({showSlowConnectionWarning:!0}),{id:t[o]._id,data:e.toString()}))).then((e=>(xt(e),{id:t[o]._id,data:e})));s.push(e)}else s.push(Promise.resolve({id:t[o]._id,data:"offline"}));return Promise.all(s).then((t=>{const e={};return t.forEach((t=>e[t.id]=t.data)),e}))}readInfo(){return this.props.socket.getHosts(!0).then((t=>this.props.socket.getRepository(this.props.currentHost,{update:!1},!1,this.state.readTimeoutMs).then((async e=>{const s=JSON.parse(JSON.stringify(this.state.alive));for(let i=0;i<t.length;i++){const e=await this.props.socket.getState(`${t[i]._id}.alive`);s[t[i]._id]=!!e&&!!e.val}const o=await this.getHostsData(t,s),n={alive:s,hosts:t,hostsData:o,repository:e};this.state.filterText&&t.length<=2&&(n.filterText=""),this.setState(n)})).catch((t=>{window.alert(`Cannot getRepository: ${t}`),t.toString().includes("timeout")&&this.setState({showSlowConnectionWarning:!0})}))))}getPanelsOrRows(){const t=this.renderHosts().filter((t=>t));return t.length?t:this.t("All items are filtered out")}renderSlowConnectionWarning(){return this.state.showSlowConnectionWarning?(0,b.jsx)(l.A,{readTimeoutMs:this.state.readTimeoutMs,t:this.t,onClose:async t=>{this.setState({showSlowConnectionWarning:!1}),t&&(this.setState({readTimeoutMs:t}),await this.readInfo())}}):null}renderHosts(){return this.state.hosts.map((t=>{var e;if(this.state.filterText&&!t.common.name.toLowerCase().includes(this.state.filterText.toLowerCase()))return null;const s=this.state.viewMode?pt:ct;return(0,b.jsx)(s,{adminInstance:this.props.adminInstance,alive:this.state.alive[t._id],available:(null===(e=this.state.repository["js-controller"])||void 0===e?void 0:e.version)||"-",executeCommandRemove:()=>this.props.executeCommand(`host remove ${t.common.name}`),expertMode:this.props.expertMode,host:t,hostData:this.state.hostsData[t._id],hostId:t._id,hostsWorker:this.props.hostsWorker,isCurrentHost:this.props.currentHost===t._id,jsControllerInfo:this.state.repository["js-controller"],lang:this.props.lang,noTranslation:this.props.noTranslation,onUpdating:this.props.onUpdating,showAdaptersWarning:this.props.showAdaptersWarning,socket:this.props.socket,systemConfig:this.props.systemConfig,t:this.t,theme:this.props.theme,themeType:this.props.themeType,toggleTranslation:this.props.toggleTranslation},t._id)}))}renderTableHeader(){return(0,b.jsxs)("div",{style:ut.tabHeaderWrapper,children:[(0,b.jsx)("div",{style:ut.tabHeaderFirstItem,children:this.t("Name:")}),(0,b.jsxs)("div",{style:ut.tabFlex,children:[(0,b.jsx)(i.Box,{component:"div",sx:a.Utils.getStyle(this.props.theme,ut.tabHeaderItem,ut.hidden800),children:"CPU"}),(0,b.jsx)(i.Box,{component:"div",sx:a.Utils.getStyle(this.props.theme,ut.tabHeaderItem,ut.hidden800),children:"RAM"}),(0,b.jsx)(i.Box,{component:"div",sx:a.Utils.getStyle(this.props.theme,ut.tabHeaderItem,ut.hidden800),children:this.t("Uptime")}),(0,b.jsxs)(i.Box,{component:"div",sx:a.Utils.getStyle(this.props.theme,ut.tabHeaderItem,ut.hidden1100),children:[this.t("Installed"),(0,b.jsx)("div",{style:ut.jsController,children:"js-controller"})]}),(0,b.jsxs)(i.Box,{component:"div",sx:a.Utils.getStyle(this.props.theme,ut.tabHeaderItem,ut.hidden1100),children:[this.t("Available"),(0,b.jsx)("div",{style:ut.jsController,children:"js-controller"})]}),(0,b.jsx)(i.Box,{component:"div",sx:a.Utils.getStyle(this.props.theme,ut.tabHeaderItem,ut.hidden600),children:this.t("Events")}),(0,b.jsx)("div",{style:{...ut.tabHeaderItemButton,width:this.props.expertMode?292:244}})]})]})}render(){return this.state.hosts.length?(0,b.jsxs)(a.TabContainer,{children:[(0,b.jsx)("style",{children:"\n @keyframes newValueAnimationHostDark {\n 0% {\n color: #00f900;\n }\n 80% {\n color: #008000;\n }\n 100% {\n color: #fff;\n }\n }\n @keyframes newValueAnimationHostLight {\n 0% {\n color: #00f900;\n }\n 80% {\n color: #008000;\n }\n 100% {\n color: #fff;\n }\n }\n .newValueHost-dark {\n animation: newValueAnimationHostDark 2s ease-in-out;\n }\n .newValueHost-light {\n animation: newValueAnimationHostLight 2s ease-in-out;\n }\n @keyframes colors {\n 0% {\n left: -51px;\n }\n 100% {\n left: 101%;\n }\n }\n @keyframes warning {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0.7;\n }\n }\n @keyframes red {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0.8;\n }\n }\n @keyframes onBlink-keys-dark {\n 0% {\n color: #264d72;\n }\n 80% {\n color: #3679be;\n }\n 100% {\n color: #fff;\n }\n }\n @keyframes onBlink-keys-light {\n 0% {\n color: #3679be;\n }\n 80% {\n color: #264d72;\n }\n 100% {\n color: #000;\n }\n }\n .onBlick-light {\n animation: onBlink-keys-light 2s ease-in-out;\n animation-iteration-count: 2;\n font-size: 12px;\n margin-left: 4px;\n }\n .onBlick-dark {\n animation: onBlink-keys-dark 2s ease-in-out;\n animation-iteration-count: 2;\n font-size: 12px;\n margin-left: 4px;\n }\n @keyframes height {\n 0% {\n height: 0;\n },\n 100% {\n height: 160px;\n }\n }\n"}),this.renderSlowConnectionWarning(),(0,b.jsxs)(a.TabHeader,{children:[(0,b.jsx)(i.Tooltip,{title:this.t("Show / hide List"),slotProps:{popper:{sx:ut.tooltip}},children:(0,b.jsx)(i.IconButton,{size:"large",onClick:()=>{(window._localStorage||window.localStorage).setItem("Hosts.viewMode",this.state.viewMode?"false":"true"),this.setState({viewMode:!this.state.viewMode})},children:this.state.viewMode?(0,b.jsx)(r.ViewModule,{}):(0,b.jsx)(r.ViewList,{})})}),(0,b.jsx)(i.Tooltip,{title:this.t("Reload"),slotProps:{popper:{sx:ut.tooltip}},children:(0,b.jsx)(i.IconButton,{size:"large",onClick:()=>this.forceUpdate(),children:(0,b.jsx)(r.Refresh,{})})}),(0,b.jsx)("div",{style:ut.grow}),this.state.hosts.length>2?(0,b.jsx)(i.TextField,{variant:"standard",label:this.t("Filter"),style:{margin:"5px 0"},value:this.state.filterText,onChange:t=>{(window._localStorage||window.localStorage).setItem("Hosts.viewMode",t.target.value),this.setState({filterText:t.target.value})},slotProps:{input:{endAdornment:this.state.filterText?(0,b.jsx)(i.InputAdornment,{position:"end",children:(0,b.jsx)(i.IconButton,{size:"small",onClick:()=>{(window._localStorage||window.localStorage).setItem("Hosts.viewMode",""),this.setState({filterText:""})},children:(0,b.jsx)(r.Close,{})})}):null}}}):null,(0,b.jsx)("div",{style:ut.grow})]}),(0,b.jsxs)(a.TabContent,{overflow:"auto",children:[a.Utils.isStableRepository(this.props.systemConfig.common.activeRepo)?null:(0,b.jsx)(i.Box,{component:"div",sx:ut.notStableRepo,children:this.t('Active repo is "%s"',this.props.systemConfig.common.activeRepo)}),(0,b.jsxs)("div",{style:this.state.viewMode?ut.cards:void 0,children:[!this.state.viewMode&&this.renderTableHeader(),this.getPanelsOrRows()]})]})]}):(0,b.jsx)(i.LinearProgress,{})}}const ft=(0,a.withWidth)()(gt)}}]);
|
|
2
|
-
//# sourceMappingURL=8038.
|
|
1
|
+
"use strict";(self.webpackChunksrc_rx=self.webpackChunksrc_rx||[]).push([[8038],{88038:(t,e,s)=>{s.r(e),s.d(e,{default:()=>ft});var o=s(29183),n=s.n(o),i=s(89303),r=s(32075),a=s(26699),l=s(44373),h=s(84929),p=s.n(h),d=s(16732),c=s(58693),u=s(34779),m=s(61204),x=s(96053),g=s(20501),f=s(59718),y=s(5035),v=s.n(y),b=s(99277);class j extends o.Component{constructor(t){super(t),this.updating=!1,this.textareaRef=n().createRef(),this.link=`${window.location.protocol}//${window.location.host}/`,this.interval=void 0,this.startTimeout=void 0,this.state={response:null,error:null,starting:!0}}setUpdating(t){this.updating!==t&&(this.updating=t,this.props.onUpdating(t))}async findIpAddress(){var t,e,s,o;if((await this.props.socket.getObject(`system.adapter.${this.props.adminInstance}`)).common.host===this.props.hostId)return;const n=await this.props.socket.getObject(this.props.hostId),i=await this.props.socket.readBaseSettings(this.props.hostId);let r=null===i||void 0===i||null===(t=i.config)||void 0===t||null===(e=t.objects)||void 0===e?void 0:e.host;if(r&&"localhost"!==r&&(r=v().parse(r).toString(),null!==n&&void 0!==n&&null!==(s=n.native)&&void 0!==s&&null!==(o=s.hardware)&&void 0!==o&&o.networkInterfaces))for(const a of Object.values(n.native.hardware.networkInterfaces))a.find((t=>{try{const e=v().parseCIDR(t.cidr).toString();!1===t.internal&&r.match(e)&&(this.link=`${window.location.protocol}//${"IPv6"===t.family?`[${t.address}]`:t.address}:${window.location.port}`)}catch{}return!1}))}async componentDidMount(){try{await this.findIpAddress()}catch(t){console.error(`Cannot find ip address: ${t.message}`)}try{await this.props.socket.upgradeController(this.props.hostId,this.props.version,parseInt(this.props.adminInstance.split(".").pop(),10))}catch(t){return console.error(`Cannot update controller: ${t.message}`),this.setState({error:a.I18n.t("Not updatable"),starting:!1}),void this.setUpdating(!1)}this.setUpdating(!0),this.interval=setInterval((()=>this.checkStatus()),1e3),this.startTimeout=setTimeout((()=>{this.startTimeout=null,this.setState({starting:!1})}),1e4)}componentWillUnmount(){this.interval&&(clearInterval(this.interval),this.interval=null),this.startTimeout&&(clearTimeout(this.startTimeout),this.startTimeout=null)}async checkStatus(){console.log(`Request update status from: ${this.link}`);try{const t=await fetch(this.link),e=await t.text();console.log(`Received status: ${e}`);const s=JSON.parse(e);null!==s&&void 0!==s&&s.stderr&&(s.stderr=s.stderr.filter((t=>t.trim()))),s&&!s.running&&s.success&&s.stdout?(s.stdout.push(""),s.stdout.push("---------------------------------------------------"),s.stdout.push(a.I18n.t("%s was successfully updated to %s","js-controller",this.props.version))):null!==s&&void 0!==s&&s.stdout&&(s.stdout.unshift(""),s.stdout.unshift("---------------------------------------------------"),s.stdout.unshift(a.I18n.t("updating %s to %s...","js-controller",this.props.version))),this.setState({response:s,error:null},(()=>{s&&!s.running?(this.setUpdating(!1),this.interval&&(clearInterval(this.interval),this.interval=null)):null!==s&&void 0!==s&&s.running&&this.setUpdating(!0),this.textareaRef.current&&setTimeout((()=>this.textareaRef.current.scrollTop=this.textareaRef.current.scrollHeight),100)}))}catch(t){this.state.starting||this.setState({error:t.toString()},(()=>this.setUpdating(!1)))}}render(){var t,e,s,o,n;return(0,b.jsxs)(i.Dialog,{onClose:(t,e)=>{"escapeKeyDown"!==e&&"backdropClick"!==e&&this.props.onClose()},open:!0,maxWidth:"lg",fullWidth:!0,children:[(0,b.jsx)(i.DialogTitle,{children:a.I18n.t("Updating %s...","js-controller")}),(0,b.jsxs)(i.DialogContent,{style:{height:400,padding:"0 20px",overflow:"hidden"},children:[this.state.response&&!this.state.response.running||this.state.error?null:(0,b.jsx)(i.LinearProgress,{}),this.state.response||this.state.error?(0,b.jsx)("textarea",{ref:this.textareaRef,style:{width:"100%",height:"100%",resize:"none",background:"dark"===this.props.themeType?"#000":"#fff",color:"dark"===this.props.themeType?"#EEE":"#111",boxSizing:"border-box",fontFamily:"Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace",border:null!==(t=this.state.response)&&void 0!==t&&t.success?"2px solid green":this.state.error||this.state.response&&!this.state.response.running&&!this.state.response.success?"2px solid red":void 0},value:this.state.error?this.state.error:this.state.response.stderr&&this.state.response.stderr.length?this.state.response.stderr.join("\n"):this.state.response.stdout.join("\n"),readOnly:!0}):null]}),(0,b.jsx)(i.DialogActions,{children:(0,b.jsx)(i.Button,{id:"js-controller-updater-close",variant:"contained",disabled:this.state.starting||!this.state.error&&(null===(e=this.state.response)||void 0===e?void 0:e.running),onClick:()=>{var t;null!==(t=this.state.response)&&void 0!==t&&t.success&&window.location.reload(),this.props.onClose()},color:null!==(s=this.state.response)&&void 0!==s&&s.success?"primary":"grey",startIcon:null!==(o=this.state.response)&&void 0!==o&&o.success?(0,b.jsx)(r.Refresh,{}):(0,b.jsx)(r.Close,{}),children:null!==(n=this.state.response)&&void 0!==n&&n.success?a.I18n.t("Reload"):a.I18n.t("Close")})})]})}}var C=s(62891),S=s(12549);const I={root:{width:"100%",height:"auto",display:"flex",flexDirection:"column",overflow:"auto",padding:10},paper:{maxWidth:1e3},overflowHidden:{display:"flex",overflow:"hidden"},h1:{fontWeight:500,fontSize:35,margin:"10px 0"},h2:t=>({p:"10px 7px",fontSize:25,fontWeight:300,borderRadius:"3px",background:"#4dabf5",color:"dark"===t.palette.mode?"black":"white"}),h22:t=>({p:0,m:0,fontSize:25,fontWeight:300,borderRadius:"3px",background:"#4dabf5",color:"dark"===t.palette.mode?"black":"white"}),standardText:{fontSize:15,margin:"10px 0","& > a":{textDecoration:"none",color:"#1e88e5"}},standardTextSmall:{fontSize:12,color:"black"},standardTextSmall2:{fontSize:12},pre:{whiteSpace:"pre-wrap",background:"#e4e3e3",padding:10,borderRadius:3,position:"relative"},copyButton:{color:"black",position:"absolute",right:10,top:4},comment:{color:"#00000078"},accordionSummary:{background:"#4dabf5",borderRadius:"3px","& .MuiAccordionSummary-content":{m:0}},accordionDetails:{display:"flex",flexDirection:"column"},code:t=>({backgroundColor:"dark"===t.palette.mode?"#123456":"#93bbe7",p:"0 3px 0 3px"}),copyButtonSmall:{width:31,height:16}};function w(t,e,s){const o=t.split("\n"),n=[];let i=!1;for(let r=0;r<o.length;r++){const t=o[r].toLowerCase();t.startsWith("##")&&(i=t.includes(e.toLowerCase())&&(!s||!t.includes(s.toLowerCase()))),i||n.push(o[r])}return n.join("\n")}const k=t=>{let{socket:e,hostId:s,version:n,onClose:l}=t;const[h,p]=(0,o.useState)(null),[d,c]=(0,o.useState)(""),[u,m]=(0,o.useState)(""),x=t=>{a.Utils.copyToClipboard(t),window.alert(a.I18n.t("Copied"))};(0,o.useEffect)((()=>{s&&"string"===typeof s||console.error(`Invalid hostId: "${s}" with type ${typeof s}`),d&&u||!s||"string"!==typeof s||e.getHostInfoShort(s).then((t=>{t.location&&t.location!==d&&c(t.location),t.os&&t.os!==u&&m(t.os),fetch(`https://raw.githubusercontent.com/ioBroker/ioBroker.docs/master/admin/${a.I18n.getLanguage()}/controller-upgrade.md`).then((t=>t.text())).then((e=>{const s=t.os||u,o=(t.location||d).replace(/\\/g,"/"),r=(e=(e=(e=(e="win32"===s?w(e,"linux","windows"):w(e,"windows","linux")).replace(/cd \/opt\/iobroker/g,`cd ${o}`)).replace(/cd C:\\iobroker/g,`cd ${o}`)).replace(/x\.y\.z/g,n)).split("\x3c!-- copy"),l=[];r.forEach((t=>{if(t.includes("--\x3e")){const e=t.split("--\x3e");let s=e[0];const o=e[1];let n=!1;s.startsWith(" small")&&(s=s.replace(/^ {2}small /,""),n=!0),s=s.replace(/^\n\r/,"").replace(/^\n/,""),n?l.push((0,b.jsx)(i.IconButton,{onClick:()=>x(s),children:(0,b.jsx)(a.IconCopy,{})},`b${l.length}`)):l.push((0,b.jsx)(i.Button,{variant:"contained",onClick:()=>x(s),startIcon:(0,b.jsx)(a.IconCopy,{}),children:a.I18n.t("Copy to clipboard")},`b${l.length}`)),l.push(o)}else l.push(t)})),p(l)}))})).catch((t=>window.alert(`Cannot get information about host "${s}": ${t}`)))}),[d,u,e,n,s]);return(0,b.jsxs)(i.Dialog,{onClose:()=>l(),open:!0,sx:{"& .MuiDialog-paper":I.paper},children:[(0,b.jsx)(i.DialogTitle,{children:a.I18n.t("js-controller upgrade instructions")}),(0,b.jsx)(i.DialogContent,{style:h?null:I.overflowHidden,dividers:!0,children:h?(0,b.jsx)(b.Fragment,{children:h.map(((t,e)=>"object"===typeof t?t:(0,b.jsx)(C.o,{components:{em:t=>{let{...e}=t;return(0,b.jsx)(i.IconButton,{style:I.copyButtonSmall,onClick:()=>x(e.children[0].toString()),children:(0,b.jsx)(a.IconCopy,{})})},a:t=>{let{children:e,...s}=t;return(0,b.jsx)("a",{style:{color:"inherit"},...s,children:e})},code:t=>{let{children:e,ref:s,...o}=t;return(0,b.jsx)(i.Box,{component:"code",sx:I.code,ref:s,...o,children:e})}},children:t},`t_${e}`)))}):(0,b.jsxs)(i.Card,{style:I.root,children:[(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t("Due to the different hardware and platforms under which ioBroker runs, the js-controller has to be updated manually. Further details can be found in the appropriate section.")}),(0,b.jsx)(i.Box,{component:"h2",sx:I.h2,children:a.I18n.t("General information for all platforms")}),(0,b.jsxs)(i.Box,{component:"div",sx:I.standardText,children:[a.I18n.t("For an update from js-controller 1.x to 2.x please always read the information at")," ",(0,b.jsx)("a",{href:"https://forum.iobroker.net/topic/26759/js-controller-2-jetzt-f%C3%BCr-alle-im-stable",target:"_blank",rel:"noreferrer",children:"forum"}),"."]}),(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t("Otherwise please update the slaves first with an update of master-slave systems and the master last!")}),"win32"!==u&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(i.Box,{component:"h2",sx:I.h2,children:a.I18n.t("Linux/macOS (new installer)")}),(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t("This is the recommended option")}),(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t("Please execute the following commands in an SSH shell (console):")}),(0,b.jsxs)("pre",{style:I.pre,children:[(0,b.jsx)(i.IconButton,{size:"small",onClick:()=>{window.alert(a.I18n.t("Copied")),x("iob backup\niob stop\niob update\niob upgrade self\niob start")},style:I.copyButton,children:(0,b.jsx)(a.IconCopy,{})}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob backup"}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob stop"}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob update"}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob fix"}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob upgrade self"}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob start"})]}),(0,b.jsx)("div",{style:I.standardTextSmall2,children:a.I18n.t("or reboot server, then ioBroker should restart and you can be sure that all old processes were finished.")}),(0,b.jsx)("div",{style:I.standardTextSmall2,children:a.I18n.t("If the upgrade command displays Access Rights / Permission errors, then please use the install fixer")}),(0,b.jsxs)("pre",{style:I.pre,children:[(0,b.jsx)(i.IconButton,{size:"small",onClick:()=>{window.alert(a.I18n.t("Copied")),x("curl -sL https://iobroker.net/fix.sh | bash -")},style:I.copyButton,children:(0,b.jsx)(a.IconCopy,{})}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"curl -sL https://iobroker.net/fix.sh | bash -"})]}),(0,b.jsx)("div",{style:I.standardTextSmall2,children:a.I18n.t("to fix these issues and upgrade command run again.")}),(0,b.jsx)(i.Box,{component:"h2",sx:I.h2,children:a.I18n.t("Linux/macOS (manually installed)")}),(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t('A manual installation usually takes place under root as user and therefore a "sudo" is necessary before the commands.')}),(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t("Please execute the following commands in an SSH shell (console):")}),(0,b.jsxs)("pre",{style:I.pre,children:[(0,b.jsx)(i.IconButton,{size:"small",onClick:()=>{window.alert(a.I18n.t("Copied")),x(`cd ${d||"/opt/iobroker"}\niob backup\niob stop\niob update\niob fix\niob upgrade self\niob start\n`)},style:I.copyButton,children:(0,b.jsx)(a.IconCopy,{})}),(0,b.jsxs)("div",{style:I.standardTextSmall,children:["cd",d||"/opt/iobroker"]}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob backup"}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob stop"}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob fix"}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob update"}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob upgrade self"}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob start"})]}),(0,b.jsx)("div",{style:I.standardTextSmall2,children:a.I18n.t("or reboot server, then ioBroker should restart and you can be sure that all old processes were finished.")}),(0,b.jsx)("div",{style:I.standardTextSmall2,children:a.I18n.t('If the upgrade command displays permissions / permissions errors, fix them. Sometimes "sudo" is not enough and you have to run the installation as a real root (previously simply sudo su -).')})]}),"win32"===u&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(i.Box,{component:"h2",sx:I.h2,children:a.I18n.t("Windows")}),(0,b.jsxs)(i.Box,{component:"div",sx:I.standardText,children:[a.I18n.t("For updating ioBroker on Windows, download the appropriate installer with the desired js-controller version from the download page "),(0,b.jsx)("a",{rel:"noreferrer",href:"https://www.iobroker.net/#en/download",target:"_blank",children:"https://www.iobroker.net/#en/download"}),a.I18n.t(" and make the update with it. With the Windows Installer, previously manually installed servers or installations from other operating systems can be migrated to Windows and updated.")]}),(0,b.jsx)(i.Box,{component:"h2",sx:I.h2,children:a.I18n.t("Windows (manually installed)")}),(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t("A manual installation is done with administrator rights. Please start a cmd.exe command line window as an administrator (right-click on cmd.exe and execute as administrator) and execute the following commands:")}),(0,b.jsxs)("pre",{style:I.pre,children:[(0,b.jsx)(i.IconButton,{size:"small",onClick:()=>{window.alert(a.I18n.t("Copied")),x(`cd ${(d||"C:\\iobroker").replace(/\//g,"\\")}\niob backup\niob stop\niob status\niob update\niob upgrade self\n`)},style:I.copyButton,children:(0,b.jsx)(a.IconCopy,{})}),(0,b.jsxs)("div",{style:I.standardTextSmall,children:["cd",(d||"C:\\iobroker").replace(/\//g,"\\")," ",d?null:a.I18n.t("(or where ioBroker was installed)")]}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob backup"}),(0,b.jsxs)("div",{style:I.standardTextSmall,children:["iob stop",a.I18n.t("to stop the ioBroker service")]}),(0,b.jsxs)("div",{style:I.standardTextSmall,children:["iob status",a.I18n.t("to check if ioBroker has finished")]}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob update"}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"iob upgrade self"})]}),(0,b.jsx)("div",{style:I.standardTextSmall2,children:a.I18n.t("Start ioBroker service or reboot computer, then ioBroker should restart and you can be sure that all the old processes were finished.")})]}),(0,b.jsxs)(i.Accordion,{style:{paddingTop:14},children:[(0,b.jsx)(i.AccordionSummary,{sx:I.accordionSummary,expandIcon:(0,b.jsx)(r.ExpandMore,{}),children:(0,b.jsx)(i.Box,{component:"h2",sx:I.h22,children:a.I18n.t("Emergency Linux / macOS / Windows")})}),(0,b.jsxs)(i.AccordionDetails,{style:I.accordionDetails,children:[(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t("(manual reinstallation, if somehow nothing works after the update)")}),(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t('On Windows first please call in the start menu under "ioBroker" the command line of the relevant ioBroker instance. The correct directory is then set automatically. On Linux or macOS please go to the ioBroker directory.')}),(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t("Run npm install iobroker.js-controller there. A specific version can be installed using npm install iobroker.js-controller@x.y.z (replace x.y.z with the desired version).")}),(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t("If there are problems with access rights when running on Linux the command has to be changed slightly:")}),(0,b.jsx)("div",{style:I.standardTextSmall2,children:a.I18n.t("For systems created with the new Linux installer:")}),(0,b.jsxs)("pre",{style:I.pre,children:[(0,b.jsx)(i.IconButton,{size:"small",onClick:()=>{window.alert(a.I18n.t("Copied")),x(`cd ${"win32"===u?(d||"C:\\iobroker").replace(/\//g,"\\"):d||"/opt/iobroker"}\nsudo -u iobroker -H npm install iobroker.js-controller`)},style:I.copyButton,children:(0,b.jsx)(a.IconCopy,{})}),(0,b.jsxs)("div",{style:I.standardTextSmall,children:["cd","win32"===u?(d||"C:\\iobroker").replace(/\//g,"\\"):d||"/opt/iobroker"]}),(0,b.jsx)("div",{style:I.standardTextSmall,children:"sudo -u iobroker -H npm install iobroker.js-controller"})]}),(0,b.jsx)("div",{style:I.standardTextSmall2,children:a.I18n.t("For systems installed manually under Linux, prefix sudo or run as root.")}),(0,b.jsx)(i.Box,{component:"div",sx:I.standardText,children:a.I18n.t("This way is only necessary in very few cases and please consult the forum beforehand!")})]})]})]})}),(0,b.jsxs)(i.DialogActions,{children:[(0,b.jsx)(i.Button,{id:"js-controller-dialog-changelog",variant:"contained",onClick:()=>{window.open(S.Uu,"_blank")},color:"grey",startIcon:(0,b.jsx)(r.Description,{}),children:a.I18n.t("Show whole changelog")}),(0,b.jsx)(i.Button,{id:"js-controller-dialog-ok",variant:"contained",onClick:()=>l(),color:"primary",startIcon:(0,b.jsx)(r.Close,{}),children:a.I18n.t("Ok")})]})]})},T={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"auto",padding:8},controlItem:{width:"calc(100% - 16px)",marginBottom:16,marginRight:8,marginLeft:8},RAM:{width:400,marginRight:8}};class F extends o.Component{constructor(t){super(t),this.focusRef=void 0;const e=this.props.settings||{};this.state={memoryLimitMB:e.memoryLimitMB||0,hostname:e.hostname||"",statisticsInterval:e.statisticsInterval||15e3,checkDiskInterval:e.checkDiskInterval||3e5,instanceStartInterval:e.instanceStartInterval||2e3,compact:e.compact||!1,allowShellCommands:e.allowShellCommands||!1,memLimitWarn:e.memLimitWarn||100,memLimitError:e.memLimitError||50,noChmod:e.noChmod||!1},this.focusRef=(0,o.createRef)()}componentDidMount(){var t;null===(t=this.focusRef.current)||void 0===t||t.focus()}onChange(){this.props.onChange({memoryLimitMB:this.state.memoryLimitMB,hostname:this.state.hostname,statisticsInterval:this.state.statisticsInterval,checkDiskInterval:this.state.checkDiskInterval,noChmod:this.state.noChmod,instanceStartInterval:this.state.instanceStartInterval,compact:this.state.compact,allowShellCommands:this.state.allowShellCommands,memLimitWarn:this.state.memLimitWarn,memLimitError:this.state.memLimitError})}render(){return(0,b.jsx)(i.Paper,{style:T.paper,children:(0,b.jsx)(i.Grid2,{style:T.gridSettings,children:(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:[(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",label:this.props.t("Host name"),style:T.controlItem,value:this.state.hostname||this.props.currentHost.replace("system.host.",""),onChange:t=>this.setState({hostname:t.target.value},(()=>this.onChange())),helperText:this.props.t("You can change the host name, but be aware, that all instances must be assigned anew")})}),(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",label:this.props.t("Check disk space interval"),style:T.controlItem,value:this.state.checkDiskInterval,type:"number",slotProps:{htmlInput:{min:1e3}},onChange:t=>this.setState({checkDiskInterval:parseInt(t.target.value,10)},(()=>this.onChange())),helperText:this.props.t("How oft the disk will be checked. Do not set it to low, because it can affect system performance. Value is in ms")})}),(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",label:this.props.t("Instance statistics update interval"),style:T.controlItem,value:this.state.statisticsInterval,type:"number",slotProps:{htmlInput:{min:5e3}},onChange:t=>this.setState({statisticsInterval:parseInt(t.target.value,10)},(()=>this.onChange())),helperText:this.props.t("How oft the instance statistics will be updated. Used RAM, CPU and so on. Value is in ms")})}),(0,b.jsxs)(i.Grid2,{style:T.controlItem,children:[(0,b.jsx)(i.FormControlLabel,{control:(0,b.jsx)(i.Checkbox,{checked:this.state.compact,onChange:t=>this.setState({compact:t.target.checked},(()=>this.onChange()))}),label:this.props.t("Compact mode")}),(0,b.jsx)("div",{children:this.props.t("When enabled adapter instances can run in one or few processes to save RAM usage.")})]}),(0,b.jsxs)(i.Grid2,{style:T.controlItem,children:[(0,b.jsx)(i.FormControlLabel,{control:(0,b.jsx)(i.Checkbox,{checked:this.state.allowShellCommands,onChange:t=>this.setState({allowShellCommands:t.target.checked},(()=>this.onChange()))}),label:this.props.t("Allow shell's commands")}),(0,b.jsx)("div",{children:this.props.t('Allow execution of sendToHost("shell", "cli command")')})]}),(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",label:this.props.t("Limit RAM size for controller"),style:T.controlItem,value:this.state.memoryLimitMB,type:"number",onChange:t=>this.setState({memoryLimitMB:parseInt(t.target.value,10)},(()=>this.onChange())),helperText:this.props.t("MB")})}),(0,b.jsx)(i.Grid2,{children:(0,b.jsxs)(i.Grid2,{container:!0,direction:"row",style:T.controlItem,children:[(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",label:this.props.t("Show warning im log if RAM less than"),style:T.RAM,value:this.state.memLimitWarn,type:"number",onChange:t=>this.setState({memLimitWarn:parseInt(t.target.value,10)},(()=>this.onChange())),helperText:this.props.t("MB")})}),(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",label:this.props.t("Show error in log if RAM less than"),style:T.RAM,value:this.state.memLimitError,type:"number",onChange:t=>this.setState({memLimitError:parseInt(t.target.value,10)},(()=>this.onChange())),helperText:this.props.t("MB")})})]})})]})})})}}const B=(0,a.withWidth)()(F),O={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"auto",padding:8},controlItem:{width:"calc(100% - 16px)",marginBottom:16,marginRight:8,marginLeft:8},RAM:{width:400,marginRight:8}};class _ extends o.Component{constructor(t){super(t),this.focusRef=void 0;const e=this.props.settings||{};this.state={enabled:e.enabled||!1,secure:e.secure||!0,password:""},e.password&&this.props.socket.decrypt(e.password).then((t=>this.setState({password:t}))),this.focusRef=(0,o.createRef)()}componentDidMount(){var t;null===(t=this.focusRef.current)||void 0===t||t.focus()}onChange(){const t={enabled:this.state.enabled,secure:this.state.secure};this.state.password?this.props.socket.encrypt(this.state.password).then((e=>{t.password=e,this.props.onChange(t)})):this.props.onChange(t)}render(){return(0,b.jsx)(i.Paper,{style:O.paper,children:(0,b.jsx)("form",{style:O.form,noValidate:!0,autoComplete:"off",children:(0,b.jsx)(i.Grid2,{style:O.gridSettings,children:(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:[(0,b.jsxs)(i.Grid2,{style:O.controlItem,children:[(0,b.jsx)(i.FormControlLabel,{control:(0,b.jsx)(i.Checkbox,{checked:this.state.enabled,onChange:t=>this.setState({enabled:t.target.checked},(()=>this.onChange()))}),label:this.props.t("Allow slave connections")}),(0,b.jsx)("div",{children:this.props.t("When activated this host can be discovered by other iobroker installations in your network to become the master of a multihost system.")})]}),(0,b.jsxs)(i.Grid2,{style:O.controlItem,children:[(0,b.jsx)(i.FormControlLabel,{control:(0,b.jsx)(i.Checkbox,{checked:this.state.secure,onChange:t=>this.setState({secure:t.target.checked},(()=>this.onChange()))}),label:this.props.t("With password")}),(0,b.jsx)("div",{children:this.props.t("Ask password by connection establishment")})]}),this.state.secure?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",label:this.props.t("Multi-host password"),style:O.controlItem,value:this.state.password,type:"password",slotProps:{input:{autoComplete:"new-password"},htmlInput:{autoComplete:"off"}},autoComplete:"off",onChange:t=>this.setState({password:t.target.value},(()=>this.onChange()))})}):null]})})})})}}const D=(0,a.withWidth)()(_),A={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"auto",padding:8},controlItem:{width:400,marginBottom:16,marginRight:8,marginLeft:8},dangerZone:{backgroundColor:"rgba(255, 165, 0, 0.05)",border:"2px solid rgba(255, 165, 0)",marginBottom:8},dangerZoneHeader:{background:"rgba(255, 165, 0)",color:"#FFF",paddingLeft:16,paddingTop:4,paddingBottom:4,marginTop:-1,marginLeft:-1},warning:t=>({p:1,fontSize:14,color:"dark"===t.palette.mode?"#ffa500":"#b17200"})},L={autoCompress:{sizeFactor:2,sizeFactorMinimumSize:25e3},throttleFS:{intervalMs:6e4,maxBufferedCommands:1e3}};class M extends o.Component{constructor(t){super(t),this.focusRef=void 0;const e=this.props.settings||{};e.options=e.options||{auth_pass:"",retry_max_delay:2e3,retry_max_count:19,db:0,family:0},e.backup=e.backup||{disabled:!1,files:24,hours:48,period:120,path:""},e.jsonlOptions=e.jsonlOptions||L,e.jsonlOptions.autoCompress=e.jsonlOptions.autoCompress||L.autoCompress,e.jsonlOptions.throttleFS=e.jsonlOptions.throttleFS||L.throttleFS,this.state={type:e.type||"file",host:Array.isArray(e.host)?e.host.join(","):e.host||"127.0.0.1",port:e.port||9001,noFileCache:e.noFileCache||!1,dataDir:e.dataDir||"",connectTimeout:e.connectTimeout||2e3,writeFileInterval:e.writeFileInterval||5e3,options_auth_pass:e.options.auth_pass||e.pass||"",options_retry_max_delay:e.options.retry_max_delay||2e3,options_retry_max_count:e.options.retry_max_count||19,options_db:e.options.db||0,options_family:e.options.family||0,backup_disabled:e.backup.disabled||!1,backup_files:e.backup.files||24,backup_hours:e.backup.hours||48,backup_period:e.backup.period||120,backup_path:e.backup.path||"",jsonlOptions_autoCompress_sizeFactor:e.jsonlOptions.autoCompress.sizeFactor||2,jsonlOptions_autoCompress_sizeFactorMinimumSize:e.jsonlOptions.autoCompress.sizeFactorMinimumSize||25e3,jsonlOptions_throttleFS_intervalMs:e.jsonlOptions.throttleFS.intervalMs||6e4,jsonlOptions_throttleFS_maxBufferedCommands:e.jsonlOptions.throttleFS.maxBufferedCommands||100,textIP:Array.isArray(e.host)||!!(e.host||"").match(/[^.\d]/)||(e.host||"").includes(","),IPs:["0.0.0.0","127.0.0.1"],loading:!0,showWarningDialog:!1,toConfirmType:"",originalDBType:e.type||"file"},this.focusRef=(0,o.createRef)()}componentDidMount(){this.props.socket.getIpAddresses(this.props.currentHost).then((t=>{const e=[...t];e.includes("0.0.0.0")||e.push("0.0.0.0"),e.includes("127.0.0.1")||e.push("127.0.0.1");let s=!!this.state.host.match(/[^.\d]/)||(this.state.host||"").includes(",");s||e.includes(this.state.host)||(s=!0),this.setState({IPs:e,loading:!1,textIP:s},(()=>this.focusRef.current&&this.focusRef.current.focus()))}))}onChange(){const t={type:this.state.type,host:this.state.host,port:parseInt(this.state.port,10),noFileCache:this.state.noFileCache,connectTimeout:parseInt(this.state.connectTimeout,10),writeFileInterval:parseInt(this.state.writeFileInterval,10),dataDir:this.state.dataDir,options:{auth_pass:this.state.options_auth_pass||null,retry_max_delay:parseInt(this.state.options_retry_max_delay,10),retry_max_count:parseInt(this.state.options_retry_max_count,10),db:parseInt(this.state.options_db,10),family:parseInt(this.state.options_family,10)},backup:{disabled:this.state.backup_disabled,files:parseInt(this.state.backup_files,10),hours:parseInt(this.state.backup_hours,10),period:parseInt(this.state.backup_period,10),path:this.state.backup_path},jsonlOptions:{autoCompress:{sizeFactor:parseInt(this.state.jsonlOptions_autoCompress_sizeFactor,10),sizeFactorMinimumSize:parseInt(this.state.jsonlOptions_autoCompress_sizeFactorMinimumSize,10)},throttleFS:{intervalMs:parseInt(this.state.jsonlOptions_throttleFS_intervalMs,10),maxBufferedCommands:parseInt(this.state.jsonlOptions_throttleFS_maxBufferedCommands,10)}}};t.jsonlOptions.autoCompress.sizeFactor<2&&(t.jsonlOptions.autoCompress.sizeFactor=2),t.jsonlOptions.autoCompress.sizeFactorMinimumSize<0&&(t.jsonlOptions.autoCompress.sizeFactorMinimumSize=0),t.jsonlOptions.throttleFS.intervalMs<0&&(t.jsonlOptions.throttleFS.intervalMs=0),t.jsonlOptions.throttleFS.maxBufferedCommands<0&&(t.jsonlOptions.throttleFS.maxBufferedCommands=0),this.props.onChange(t)}renderWarning(){return this.state.showWarningDialog?(0,b.jsx)(a.Confirm,{title:this.props.t("Please confirm"),text:this.props.t("switch_db_note"),onClose:t=>{if(t){let t;t="redis"===this.state.toConfirmType?6379:9001,this.setState({type:this.state.toConfirmType||"file",showWarningDialog:!1,port:t},(()=>this.onChange()))}else this.setState({showWarningDialog:!1})}}):null}render(){return(0,b.jsxs)(i.Paper,{style:A.paper,children:[this.state.loading?(0,b.jsx)(i.LinearProgress,{}):null,this.renderWarning(),(0,b.jsxs)(i.Grid2,{style:{...A.gridSettings,...A.dangerZone},children:[(0,b.jsx)("h3",{style:A.dangerZoneHeader,title:this.props.t("Invalid settings in these fields could lead to dead host"),children:this.props.t("Danger zone")}),(0,b.jsx)(i.Box,{component:"p",sx:A.warning,children:this.props.t("base_settings_hint")}),(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:[(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.Tooltip,{title:this.props.t("switch_db_note"),slotProps:{popper:{sx:{pointerEvents:"none"}}},children:(0,b.jsxs)(i.FormControl,{style:A.controlItem,variant:"standard",children:[(0,b.jsx)(i.InputLabel,{children:this.props.t("Type")}),(0,b.jsxs)(i.Select,{variant:"standard",value:this.state.type,onChange:t=>{if(t.target.value!==this.state.originalDBType)this.setState({toConfirmType:t.target.value,showWarningDialog:!0});else{let e;e="redis"===t.target.value?6379:9001,this.setState({type:t.target.value,port:e},(()=>this.onChange()))}},children:[(0,b.jsx)(i.MenuItem,{value:"jsonl",children:"JSON Lines"}),(0,b.jsx)(i.MenuItem,{value:"file",children:this.props.t("File")}),(0,b.jsx)(i.MenuItem,{value:"redis",children:"Redis"})]})]})})}),(0,b.jsx)(i.Grid2,{style:{paddingLeft:8},children:(0,b.jsx)(i.FormControlLabel,{control:(0,b.jsx)(i.Switch,{checked:this.state.textIP,onChange:t=>this.setState({textIP:t.target.checked},(()=>this.onChange()))}),label:this.props.t("IP is domain or more than one address")})}),(0,b.jsx)(i.Grid2,{children:this.state.textIP?(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.host,type:"text",onChange:t=>this.setState({host:t.target.value},(()=>this.onChange())),label:this.props.t("Bind IP address"),helperText:this.props.t("You can enter more than one address divided by comma")}):(0,b.jsxs)(i.FormControl,{style:A.controlItem,variant:"standard",children:[(0,b.jsx)(i.InputLabel,{children:this.props.t("Bind IP address")}),(0,b.jsx)(i.Select,{variant:"standard",value:this.state.host,onChange:t=>this.setState({host:t.target.value},(()=>this.onChange())),children:this.state.IPs.map((t=>(0,b.jsx)(i.MenuItem,{value:t,children:"0.0.0.0"===t?`0.0.0.0 [${this.props.t("All addresses")}]`:t},t)))})]})}),(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.port,type:"number",slotProps:{htmlInput:{min:1,max:65535}},onChange:t=>this.setState({port:t.target.value},(()=>this.onChange())),label:this.props.t("Port")})}),"file"===this.state.type||"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.dataDir,helperText:this.props.t("Optional. Always relative to iobroker.js-controller/"),onChange:t=>this.setState({dataDir:t.target.value},(()=>this.onChange())),label:this.props.t("Directory path")})}):null,(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.options_auth_pass,type:"password",helperText:this.props.t("Optional"),slotProps:{input:{autoComplete:"new-password"},htmlInput:{autoComplete:"off"}},autoComplete:"off",onChange:t=>this.setState({options_auth_pass:t.target.value},(()=>this.onChange())),label:"redis"===this.state.type?this.props.t("Redis password"):this.props.t("Connection password")})})]})]}),(0,b.jsx)(i.Grid2,{style:A.gridSettings,children:(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:["file"===this.state.type||"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.connectTimeout,helperText:this.props.t("ms"),type:"number",slotProps:{htmlInput:{min:200}},onChange:t=>this.setState({connectTimeout:t.target.value},(()=>this.onChange())),label:this.props.t("Connect timeout")})}):null,"file"===this.state.type||"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsxs)(i.FormControl,{component:"fieldset",variant:"standard",style:A.controlItem,children:[(0,b.jsx)(i.FormGroup,{children:(0,b.jsx)(i.FormControlLabel,{control:(0,b.jsx)(i.Checkbox,{checked:this.state.noFileCache,onChange:t=>this.setState({noFileCache:t.target.checked},(()=>this.onChange()))}),label:this.props.t("No file cache")})}),(0,b.jsx)(i.FormHelperText,{children:this.props.t("Always read files from disk and do not cache them in RAM. Used for debugging.")})]})}):null,"file"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.writeFileInterval,helperText:this.props.t("How often the data from RAM will be saved on disk in ms"),type:"number",slotProps:{htmlInput:{min:200}},onChange:t=>this.setState({writeFileInterval:t.target.value},(()=>this.onChange())),label:this.props.t("Store file interval")})}):null,"redis"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.options_retry_max_delay,type:"number",helperText:this.props.t("Maximum delay between connection attempts"),onChange:t=>this.setState({options_retry_max_delay:t.target.value},(()=>this.onChange())),label:this.props.t("Retry maximum delay")})}):null,"redis"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.options_retry_max_count,type:"number",helperText:this.props.t("Maximum number of connection retries"),onChange:t=>this.setState({options_retry_max_count:t.target.value},(()=>this.onChange())),label:this.props.t("Retry maximum count")})}):null,"redis"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.options_db,type:"number",helperText:this.props.t("Used for sentinels"),onChange:t=>this.setState({options_db:t.target.value},(()=>this.onChange())),label:this.props.t("DB number")})}):null,"redis"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsxs)(i.FormControl,{style:A.controlItem,variant:"standard",children:[(0,b.jsx)(i.InputLabel,{children:this.props.t("Family number")}),(0,b.jsxs)(i.Select,{variant:"standard",value:this.state.options_family,onChange:t=>this.setState({options_family:t.target.value},(()=>this.onChange())),children:[(0,b.jsx)(i.MenuItem,{value:0,children:"auto"}),(0,b.jsx)(i.MenuItem,{value:4,children:"IPv4"}),(0,b.jsx)(i.MenuItem,{value:6,children:"IPv6"})]}),(0,b.jsx)(i.FormHelperText,{children:this.props.t("Used for sentinels")})]})}):null,"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.jsonlOptions_autoCompress_sizeFactor,type:"number",slotProps:{htmlInput:{min:2}},helperText:this.props.t("The JSONL DB is append-only and will contain unnecessary entries after a while."),onChange:t=>this.setState({jsonlOptions_autoCompress_sizeFactor:t.target.value},(()=>this.onChange())),label:this.props.t("Auto-compress size factor")})}):null,"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.jsonlOptions_autoCompress_sizeFactorMinimumSize,type:"number",slotProps:{htmlInput:{min:0}},helperText:this.props.t("It will be compressed when the uncompressed size is >= size * sizeFactor AND >= sizeFactorMinimumSize"),onChange:t=>this.setState({jsonlOptions_autoCompress_sizeFactorMinimumSize:t.target.value},(()=>this.onChange())),label:this.props.t("Auto-compress size factor minimum size")})}):null,"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.jsonlOptions_throttleFS_intervalMs,type:"number",slotProps:{htmlInput:{min:0}},helperText:this.props.t("Write to the database file no more than every X milliseconds"),onChange:t=>this.setState({jsonlOptions_throttleFS_intervalMs:t.target.value},(()=>this.onChange())),label:this.props.t("Minimal write interval")})}):null,"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.jsonlOptions_throttleFS_maxBufferedCommands,type:"number",slotProps:{htmlInput:{min:0}},helperText:this.props.t("Force writing after this many changes have been buffered. This reduces memory consumption and data loss in case of a crash"),onChange:t=>this.setState({jsonlOptions_throttleFS_maxBufferedCommands:t.target.value},(()=>this.onChange())),label:this.props.t("Maximum changes before write")})}):null,"file"===this.state.type||"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsxs)(i.FormControl,{component:"fieldset",variant:"standard",style:A.controlItem,children:[(0,b.jsx)(i.FormGroup,{children:(0,b.jsx)(i.FormControlLabel,{control:(0,b.jsx)(i.Checkbox,{checked:this.state.backup_disabled,onChange:t=>this.setState({backup_disabled:t.target.checked},(()=>this.onChange()))}),label:this.props.t("No on-the-fly backup")})}),(0,b.jsx)(i.FormHelperText,{children:this.props.t("By every write the backup of object.json will be created.")})]})}):null,"file"!==this.state.type&&"jsonl"!==this.state.type||this.state.backup_disabled?null:(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.backup_files,type:"number",helperText:this.props.t("Minimal number of backup files, after the deletion will be executed according to the backup time settings"),onChange:t=>this.setState({backup_files:t.target.value},(()=>this.onChange())),label:this.props.t("Number of files")})}),"file"!==this.state.type&&"jsonl"!==this.state.type||this.state.backup_disabled?null:(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.backup_hours,type:"number",helperText:this.props.t("All backups older than these hours will be deleted, but only if the number of files is greater than of the files number"),onChange:t=>this.setState({backup_hours:t.target.value},(()=>this.onChange())),label:this.props.t("Backup hours")})}),"file"!==this.state.type&&"jsonl"!==this.state.type||this.state.backup_disabled?null:(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.backup_period,type:"number",helperText:this.props.t("By default the backup is every 2 hours. Time is in minutes. To disable backup set the value to 0"),onChange:t=>this.setState({backup_period:t.target.value},(()=>this.onChange())),label:this.props.t("How often")})}),"file"!==this.state.type&&"jsonl"!==this.state.type||this.state.backup_disabled?null:(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:A.controlItem,value:this.state.backup_path,helperText:this.props.t("Absolute path to backup directory or empty to backup in data directory. Leave it empty for default storage place."),onChange:t=>this.setState({backup_path:t.target.value},(()=>this.onChange())),label:this.props.t("Path")})})]})})]})}}const z=(0,a.withWidth)()(M),H={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"auto",padding:8},controlItem:{width:400,marginBottom:16,marginRight:8,marginLeft:8},dangerZone:{backgroundColor:"rgba(255, 165, 0, 0.05)",border:"2px solid rgba(255, 165, 0)",marginBottom:8},dangerZoneHeader:{background:"rgba(255, 165, 0)",color:"#FFF",paddingLeft:16,paddingTop:4,paddingBottom:4,marginTop:-1,marginLeft:-1},warning:t=>({p:1,fontSize:14,color:"dark"===t.palette.mode?"#ffa500":"#b17200"})},R={autoCompress:{sizeFactor:2,sizeFactorMinimumSize:25e3},throttleFS:{intervalMs:6e4,maxBufferedCommands:1e3}};class P extends o.Component{constructor(t){super(t),this.focusRef=void 0;const e=this.props.settings||{};e.options=e.options||{auth_pass:"",retry_max_delay:2e3,retry_max_count:19,db:0,family:0},e.backup=e.backup||{disabled:!1,files:24,hours:48,period:120,path:""},e.jsonlOptions=e.jsonlOptions||R,e.jsonlOptions.autoCompress=e.jsonlOptions.autoCompress||R.autoCompress,e.jsonlOptions.throttleFS=e.jsonlOptions.throttleFS||R.throttleFS,this.state={type:e.type||"file",host:Array.isArray(e.host)?e.host.join(","):e.host||"127.0.0.1",port:e.port||9e3,connectTimeout:e.connectTimeout||2e3,writeFileInterval:e.writeFileInterval||5e3,dataDir:e.dataDir||"",options_auth_pass:e.options.auth_pass||e.pass||"",options_retry_max_delay:e.options.retry_max_delay||2e3,options_retry_max_count:e.options.retry_max_count||19,options_db:e.options.db||0,options_family:e.options.family||0,backup_disabled:e.backup.disabled||!1,backup_files:e.backup.files||24,backup_hours:e.backup.hours||48,backup_period:e.backup.period||120,backup_path:e.backup.path||"",jsonlOptions_autoCompress_sizeFactor:e.jsonlOptions.autoCompress.sizeFactor||2,jsonlOptions_autoCompress_sizeFactorMinimumSize:e.jsonlOptions.autoCompress.sizeFactorMinimumSize||25e3,jsonlOptions_throttleFS_intervalMs:e.jsonlOptions.throttleFS.intervalMs||6e4,jsonlOptions_throttleFS_maxBufferedCommands:e.jsonlOptions.throttleFS.maxBufferedCommands||100,textIP:Array.isArray(e.host)||!!(e.host||"").match(/[^.\d]/)||(e.host||"").includes(","),IPs:["0.0.0.0","127.0.0.1"],loading:!0,showWarningDialog:!1,toConfirmType:"",originalDBType:e.type||"file",noFileCache:e.noFileCache||!1},this.focusRef=(0,o.createRef)()}componentDidMount(){this.props.socket.getIpAddresses(this.props.currentHost).then((t=>{const e=[...t];e.includes("0.0.0.0")||e.push("0.0.0.0"),e.includes("127.0.0.1")||e.push("127.0.0.1");let s=!!this.state.host.match(/[^.\d]/)||(this.state.host||"").includes(",");s||e.includes(this.state.host)||(s=!0),this.setState({IPs:e,loading:!1,textIP:s},(()=>this.focusRef.current&&this.focusRef.current.focus()))}))}onChange(){const t={type:this.state.type,host:this.state.host,port:parseInt(this.state.port,10),noFileCache:this.state.noFileCache,connectTimeout:parseInt(this.state.connectTimeout,10),writeFileInterval:parseInt(this.state.writeFileInterval,10),dataDir:this.state.dataDir,options:{auth_pass:this.state.options_auth_pass||null,retry_max_delay:parseInt(this.state.options_retry_max_delay,10),retry_max_count:parseInt(this.state.options_retry_max_count,10),db:parseInt(this.state.options_db,10),family:parseInt(this.state.options_family,10)},backup:{disabled:this.state.backup_disabled,files:parseInt(this.state.backup_files,10),hours:parseInt(this.state.backup_hours,10),period:parseInt(this.state.backup_period,10),path:this.state.backup_path},jsonlOptions:{autoCompress:{sizeFactor:parseInt(this.state.jsonlOptions_autoCompress_sizeFactor,10),sizeFactorMinimumSize:parseInt(this.state.jsonlOptions_autoCompress_sizeFactorMinimumSize,10)},throttleFS:{intervalMs:parseInt(this.state.jsonlOptions_throttleFS_intervalMs,10),maxBufferedCommands:parseInt(this.state.jsonlOptions_throttleFS_maxBufferedCommands,10)}}};t.jsonlOptions.autoCompress.sizeFactor<2&&(t.jsonlOptions.autoCompress.sizeFactor=2),t.jsonlOptions.autoCompress.sizeFactorMinimumSize<0&&(t.jsonlOptions.autoCompress.sizeFactorMinimumSize=0),t.jsonlOptions.throttleFS.intervalMs<0&&(t.jsonlOptions.throttleFS.intervalMs=0),t.jsonlOptions.throttleFS.maxBufferedCommands<0&&(t.jsonlOptions.throttleFS.maxBufferedCommands=0),this.props.onChange(t)}renderWarning(){return this.state.showWarningDialog?(0,b.jsx)(a.Confirm,{title:this.props.t("Please confirm"),text:this.props.t("switch_db_note"),onClose:t=>{if(t){let t;t="redis"===this.state.toConfirmType?6379:9e3,this.setState({type:this.state.toConfirmType||"file",showWarningDialog:!1,port:t},(()=>this.onChange()))}else this.setState({showWarningDialog:!1})}}):null}render(){return(0,b.jsxs)(i.Paper,{style:H.paper,children:[this.state.loading?(0,b.jsx)(i.LinearProgress,{}):null,this.renderWarning(),(0,b.jsxs)(i.Grid2,{style:{...H.gridSettings,...H.dangerZone},children:[(0,b.jsx)("h3",{style:H.dangerZoneHeader,title:this.props.t("Invalid settings in these fields could lead to dead host"),children:this.props.t("Danger zone")}),(0,b.jsx)(i.Box,{component:"p",sx:H.warning,children:this.props.t("base_settings_hint")}),(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:[(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.Tooltip,{title:this.props.t("switch_db_note"),slotProps:{popper:{sx:{pointerEvents:"none"}}},children:(0,b.jsxs)(i.FormControl,{style:H.controlItem,variant:"standard",children:[(0,b.jsx)(i.InputLabel,{children:this.props.t("Type")}),(0,b.jsxs)(i.Select,{variant:"standard",value:this.state.type,onChange:t=>{if(t.target.value!==this.state.originalDBType)this.setState({toConfirmType:t.target.value,showWarningDialog:!0});else{let e;e="redis"===t.target.value?6379:9e3,this.setState({type:t.target.value,port:e},(()=>this.onChange()))}},children:[(0,b.jsx)(i.MenuItem,{value:"jsonl",children:"JSON Lines"}),(0,b.jsx)(i.MenuItem,{value:"file",children:this.props.t("File")}),(0,b.jsx)(i.MenuItem,{value:"redis",children:"Redis"})]})]})})}),(0,b.jsx)(i.Grid2,{style:{paddingLeft:8},children:(0,b.jsx)(i.FormControlLabel,{control:(0,b.jsx)(i.Switch,{checked:this.state.textIP,onChange:t=>this.setState({textIP:t.target.checked},(()=>this.onChange()))}),label:this.props.t("IP is domain or more than one address")})}),(0,b.jsx)(i.Grid2,{children:this.state.textIP?(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.host,type:"text",onChange:t=>this.setState({host:t.target.value},(()=>this.onChange())),label:this.props.t("Bind IP address"),helperText:this.props.t("You can enter more than one address divided by comma")}):(0,b.jsxs)(i.FormControl,{style:H.controlItem,variant:"standard",children:[(0,b.jsx)(i.InputLabel,{children:this.props.t("Bind IP address")}),(0,b.jsx)(i.Select,{variant:"standard",value:this.state.host,onChange:t=>this.setState({host:t.target.value},(()=>this.onChange())),children:this.state.IPs.map((t=>(0,b.jsx)(i.MenuItem,{value:t,children:"0.0.0.0"===t?`0.0.0.0 [${this.props.t("All addresses")}]`:t},t)))})]})}),(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.port,type:"number",slotProps:{htmlInput:{min:1,max:65535}},onChange:t=>this.setState({port:t.target.value},(()=>this.onChange())),label:this.props.t("Port")})}),"file"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.dataDir,helperText:this.props.t("Optional. Always relative to iobroker.js-controller/"),onChange:t=>this.setState({dataDir:t.target.value},(()=>this.onChange())),label:this.props.t("Directory path")})}):null,(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.options_auth_pass,type:"password",helperText:this.props.t("Optional"),slotProps:{input:{autoComplete:"new-password"},htmlInput:{autoComplete:"off"}},autoComplete:"off",onChange:t=>this.setState({options_auth_pass:t.target.value},(()=>this.onChange())),label:"redis"===this.state.type?this.props.t("Redis password"):this.props.t("Connection password")})})]})]}),(0,b.jsx)(i.Grid2,{style:H.gridSettings,children:(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:["file"===this.state.type||"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.connectTimeout,helperText:this.props.t("ms"),type:"number",slotProps:{htmlInput:{min:200}},onChange:t=>this.setState({connectTimeout:t.target.value},(()=>this.onChange())),label:this.props.t("Connect timeout")})}):null,"file"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.writeFileInterval,helperText:this.props.t("How often the data from RAM will be saved on disk in ms"),type:"number",slotProps:{htmlInput:{min:200}},onChange:t=>this.setState({writeFileInterval:t.target.value},(()=>this.onChange())),label:this.props.t("Store file interval")})}):null,"redis"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.options_retry_max_delay,type:"number",helperText:this.props.t("Maximum delay between connection attempts"),onChange:t=>this.setState({options_retry_max_delay:t.target.value},(()=>this.onChange())),label:this.props.t("Retry maximum delay")})}):null,"redis"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.options_retry_max_count,type:"number",helperText:this.props.t("Maximum number of connection retries"),onChange:t=>this.setState({options_retry_max_count:t.target.value},(()=>this.onChange())),label:this.props.t("Retry maximum count")})}):null,"redis"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.options_db,type:"number",helperText:this.props.t("Used for sentinels"),onChange:t=>this.setState({options_db:t.target.value},(()=>this.onChange())),label:this.props.t("DB number")})}):null,"redis"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsxs)(i.FormControl,{style:H.controlItem,variant:"standard",children:[(0,b.jsx)(i.InputLabel,{children:this.props.t("Family number")}),(0,b.jsxs)(i.Select,{variant:"standard",value:this.state.options_family,onChange:t=>this.setState({options_family:t.target.value},(()=>this.onChange())),children:[(0,b.jsx)(i.MenuItem,{value:0,children:"auto"}),(0,b.jsx)(i.MenuItem,{value:4,children:"IPv4"}),(0,b.jsx)(i.MenuItem,{value:6,children:"IPv6"})]}),(0,b.jsx)(i.FormHelperText,{children:this.props.t("Used for sentinels")})]})}):null,"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.jsonlOptions_autoCompress_sizeFactor,type:"number",slotProps:{htmlInput:{min:2}},helperText:this.props.t("The JSONL DB is append-only and will contain unnecessary entries after a while."),onChange:t=>this.setState({jsonlOptions_autoCompress_sizeFactor:t.target.value},(()=>this.onChange())),label:this.props.t("Auto-compress size factor")})}):null,"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.jsonlOptions_autoCompress_sizeFactorMinimumSize,type:"number",slotProps:{htmlInput:{min:0}},helperText:this.props.t("It will be compressed when the uncompressed size is >= size * sizeFactor AND >= sizeFactorMinimumSize"),onChange:t=>this.setState({jsonlOptions_autoCompress_sizeFactorMinimumSize:t.target.value},(()=>this.onChange())),label:this.props.t("Auto-compress size factor minimum size")})}):null,"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.jsonlOptions_throttleFS_intervalMs,type:"number",slotProps:{htmlInput:{min:0}},helperText:this.props.t("Write to the database file no more than every X milliseconds"),onChange:t=>this.setState({jsonlOptions_throttleFS_intervalMs:t.target.value},(()=>this.onChange())),label:this.props.t("Minimal write interval")})}):null,"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.jsonlOptions_throttleFS_maxBufferedCommands,type:"number",slotProps:{htmlInput:{min:0}},helperText:this.props.t("Force writing after this many changes have been buffered. This reduces memory consumption and data loss in case of a crash"),onChange:t=>this.setState({jsonlOptions_throttleFS_maxBufferedCommands:t.target.value},(()=>this.onChange())),label:this.props.t("Maximum changes before write")})}):null,"file"===this.state.type||"jsonl"===this.state.type?(0,b.jsx)(i.Grid2,{children:(0,b.jsxs)(i.FormControl,{component:"fieldset",style:H.controlItem,variant:"standard",children:[(0,b.jsx)(i.FormGroup,{children:(0,b.jsx)(i.FormControlLabel,{control:(0,b.jsx)(i.Checkbox,{checked:this.state.backup_disabled,onChange:t=>this.setState({backup_disabled:t.target.checked},(()=>this.onChange()))}),label:this.props.t("No on-the-fly backup")})}),(0,b.jsx)(i.FormHelperText,{children:this.props.t("By every write the backup of object.json will be created.")})]})}):null,"file"!==this.state.type&&"jsonl"!==this.state.type||this.state.backup_disabled?null:(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.backup_files,type:"number",helperText:this.props.t("Minimal number of backup files, after the deletion will be executed according to the backup time settings"),onChange:t=>this.setState({backup_files:t.target.value},(()=>this.onChange())),label:this.props.t("Number of files")})}),"file"!==this.state.type&&"jsonl"!==this.state.type||this.state.backup_disabled?null:(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.backup_hours,type:"number",helperText:this.props.t("All backups older than these hours will be deleted, but only if the number of files is greater than of the files number"),onChange:t=>this.setState({backup_hours:t.target.value},(()=>this.onChange())),label:this.props.t("Backup hours")})}),"file"!==this.state.type&&"jsonl"!==this.state.type||this.state.backup_disabled?null:(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.backup_period,type:"number",helperText:this.props.t("By default the backup is every 2 hours. Time is in minutes. To disable backup set the value to 0"),onChange:t=>this.setState({backup_period:t.target.value},(()=>this.onChange())),label:this.props.t("How often")})}),"file"!==this.state.type&&"jsonl"!==this.state.type||this.state.backup_disabled?null:(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:H.controlItem,value:this.state.backup_path,helperText:this.props.t("Absolute path to backup directory or empty to backup in data directory. Leave it empty for default storage place."),onChange:t=>this.setState({backup_path:t.target.value},(()=>this.onChange())),label:this.props.t("Path")})})]})})]})}}const W=(0,a.withWidth)()(P),N="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAbCAYAAADMIInqAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAiPSURBVFhH7Zd7UFTXGcDPvXffy8IusMsbQUEgoyiKD4pBnoKgVkoRX1WpNia2QZ2MzFTS2MykmlqiMzWJqSUxJq1KG0VrE0GxqSgSNVEx4SEaAeXNLrDsLvve2+/cvQusgIHWf2jymzns+b5zLvd+3/nOd75DoGEsWJDLaWvrXsXhcH/S3a0ODArynqfRDLRptfo6qVRcRdOGww8fftbGTv+/YNAB/v4ZsSrVQJHBYAunaVb5BBwOMri58farVI9eR+iejVVPakj8x8dn6cKWlv5zev3YxmMsFiRQqYyv8fleb+XnH2CenexQ2JCqqroLRiMKYHWIzyctLi680ujo4Aa93nDfbDZ72WxIYB/FQUMsbG5+VNHf/6DRrpu8kFeu3EnRaKzhrIxEIq5ZLhdHqdUXMior31+mVJ5fFhKiiBCLqXp2CrJaETKbyTxWnNSQtbWP5w4Pe3d30cWWln9+w4oMdXV/bw8K8tgLZoNkYZpeb5zLDE5yIJ7n7EZI8jtWRl5eLl91dn4azYqDxMZu4ldWVrqxaQMgIAnWK1lhkODgDLHNRuVqNIYMiJQ5Wq0JnCocsFjM/w4PD/ikqurop+zUUYHnY8xmIs9mIxI7O7V4QSDajJc8PEQfZ2fHXyguPhPa2KiLwXNJklLZbDf+wTw4Cr3rkUg8j5dDSYYOOyslRI8Ccs6FJP6J+XZizpz1+bduPf49M8pA0zKZ8N3U1NlvyeWuTYcOFTwlLToTGZmdcu9e9xGj0RZkzxXOEARtE4nIE/v2bdmVl7e+nVUzyGTpHKGQ+BCMXgOOG5FgKQr/tf4xPNxPUFPT8QKWeDzqlsn0rzEjsSMe+fCnCdtcFsG6DfscC0fwUZvPsp9PS3rbSoSHZ/k+eKBshAzPY8cZeDwSGnELHHJ51qyg6tWrUz5/+eW1j9jhESxevDn9xo3Gs3q9lcOqxkQm456fPj1g+fXrRyGbIHTsWAm1e/f7x1tbNauYCU+BJFE/JGRX3P9OByQgH/hpE8+XIEGE2K5kGRDKX3HL+foAWV9/qk0q5f8BDGWH7JhMNqTVWiGEbTsrKx9+uHPne80KRfrNmTPXrC0uLmXWw8HBg8dcqqtbPhgynrbKZLwTQUGibIR0yWFhnoVwqpjsYxCavaalarX6JVZE+/Z9tKS1td/JeD6f6AkOdi9FyPBmYKC0xh4BCDmMnwi6m1pk7hx8PYPQoNzfdSYujQ2MJCowUHQQPuJFCD+uXTc6sAJwUlAfgHO2InQZZ0SoI9JWt7frTzATwJEyGf/V3t6Lg3kFM2/ez1Lv3HlcajbbHe3pKap9553tkTk5aVZPz7RLSqU+kRkAKIq+BnljRXd3mQrLOEKOHy/PraioP6zXWwYjbLwRgPukkEL86SKnrUCI3S87bdTZs1dFNTX1boOhLEheMotl7O3v4cHfq1JdKMB9L6/0k52duhzcFwhI4+bNSTEkSTiVzFwuhywqKr/a32+aimU4blFUlL9XWFiQ9dSpqna12sA4nsslLYsXh0WXl79XjeXhBAdnHmps7PkVK07IAc6A2YSwhDM1ZpOTAxyUlFwSFxS8PVWpHIi3Wul4CO2EgQGLjB1mgPygjYz0nvbllye7CGJRBU1Tz2M9GA4RIGTmPEl/vxEyOrPtAfzb62XvSzuh0GZ6kO1rVKrzMxjhCcLCVkY0NPTU0rT9s/87B1CwqrzXBJk7C6V5ew2jlrOZmUm62tqSr7u6yg7BKmeFhMgVvr4SOCmGIgJyhItAIEjCfZp2GIX3KI3gTjFqGzIeg/8XlrHhQ+swZYqc7Y3Ez0+uFQqdcvXEILg6QiTP8v5c/wY2nlGtWZO/A380Bq8evOQvhYW7Rpzvu3Yd4BQVlTX39hp8WRVyc+Nvg4rxMIcTV2GxEEwEgAt0kHb+bO+PDZfLRb6+fr9pbm6AjYkjwJ7lpFJBTV9f2agREBW1NqK6urUWEiHDhCKA5tynvGf+VH7y9l1GduDvv0KPUBx4wN7k8uRUdsgJcADl4pLcAAcezMMtjl6wYAOTyYODV5506Pn8BGtW1o6ZzEPjIDd3j6tYnNzjeJ7LjTfHxm6cxQ474eGRCrdQx/sX0zxe4lfs0KhgB0CjO+Kos6r8nMG7znBIqNDO2EPQ3uC2V7h8+Q6nFcjKeoW4cuXuL3U6UyirgqsxaZNIRJW47+rK+8SxPaAIIq9evf9qQsJWp6MyJeVFF6Ew7ixCMfdwEwhi6yIjV8iOHn29381NeJudBtuE5lRWfvvuxo17IlgVKir6G7VkyUtbIA9B1ToBbIgmKOkBzozkHI/9xY9ZrRPEwoUb5l+/3nwN7gODHwz3fo1C4XpDpdLcNJstkLH5cZAIfwQJkZ2BjzHBZaWyLJ4VIXSTIXTNz+E+Ab6E2uJqQIDk47t3v33o7i71s9l4+X19RmYco1AIz3R1lWbifkzMhqVffNH0mSO5YSQSnkUs5pbDTbSZz+c/DxXic8Pfj/muLTAemDdGR6974/btlgJ8yxsfliaFQpIABjSxCuyAGSYTfRNWib02Pw1zvUQijtdoLsLet+Pnl36ktVX7C/aTxsWzcABzCqxbt2TP3LlTdkC1ph6e6Z8EanlIfLxrYrEoebjxmL6+8m9cXbmLoAgC/ej/Az/v4SG4A9Vd4nDjMf7+XtvCwhR/5XDwJWskoIdj0Ou0XO7Cap4NTu7Ozv61d0tLx4aamuZZUqlrUm+vjhmXSPidXC5V7evrfnrTprTzW7fmMEfIaCQnbxHX1bWt7OnRZXh6ypLUah0SiwUDRqPxWmCg/Nz8+aGnjxz5rXNdOgyIxpj2dvULcNOLV6sHRJ6erkip7CkJDQ06tX37j+/n5xc1dnRomLnPIgImFVASB3h7L4PwGt8pMB5GLYS+T/zgAPb3e8sPDmB/Jw34voKPREf730DoP5pKhvU07RMQAAAAAElFTkSuQmCC",G={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"hidden",padding:8},gridSettings:t=>({height:`calc(100% - ${t.mixins.toolbar.minHeight}px)`,width:"100%",overflow:"auto"}),controlItem:{width:400,marginBottom:16,marginRight:8,marginLeft:8},delButton:{position:"absolute",top:2,right:48},addButton:{marginRight:8},buttonIcon:{height:24},headingIcon:{height:24,marginRight:8}};class E extends o.Component{constructor(t){super(t),this.focusRef=void 0;const e=this.props.settings||{};e.transport=e.transport||{},Object.keys(e.transport).forEach((t=>{if("file"===e.transport[t].type){const s="string"===typeof e.transport[t].maxSize?e.transport[t].maxSize.includes("k")?.1:e.transport[t].maxSize.includes("g")?10:1:1;e.transport[t].maxSize=(parseInt(e.transport[t].maxSize,10)||0)*s,e.transport[t].level=e.transport[t].level||"",e.transport[t].maxFiles=e.transport[t].maxFiles||0}else"syslog"===e.transport[t].type?(e.transport[t].level=e.transport[t].level||"",e.transport[t].host=e.transport[t].host||"",e.transport[t].port=e.transport[t].port||0,e.transport[t].path=e.transport[t].path||"",e.transport[t].facility=e.transport[t].facility||"",e.transport[t].sysLogType=e.transport[t].sysLogType||"",e.transport[t].app_name=e.transport[t].app_name||"",e.transport[t].eol=e.transport[t].eol||""):"http"===e.transport[t].type?(e.transport[t].level=e.transport[t].level||"",e.transport[t].host=e.transport[t].host||"",e.transport[t].port=e.transport[t].port||0,e.transport[t].path=e.transport[t].path||"/",e.transport[t].auth=e.transport[t].auth||"None",e.transport[t].ssl=e.transport[t].ssl||!1):"stream"===e.transport[t].type?(e.transport[t].stream=e.transport[t].stream||"",e.transport[t].level=e.transport[t].level||"",e.transport[t].silent=e.transport[t].silent||!1,e.transport[t].eol=e.transport[t].eol||""):"seq"===e.transport[t].type&&(e.transport[t].level=e.transport[t].level||"",e.transport[t].serverUrl=e.transport[t].serverUrl||"",e.transport[t].apiKey=e.transport[t].apiKey||"",e.transport[t].eol=e.transport[t].eol||"")})),this.state={level:e.level||"info",maxDays:e.maxDays||7,noStdout:e.noStdout||!0,transport:e.transport||{},expanded:[]},this.focusRef=(0,o.createRef)()}componentDidMount(){var t;null===(t=this.focusRef.current)||void 0===t||t.focus()}onChange(){const t={level:this.state.level,maxDays:parseInt(this.state.maxDays,10),noStdout:this.state.noStdout,transport:{}};Object.keys(this.state.transport).forEach((e=>{t.transport[e]=JSON.parse(JSON.stringify(this.state.transport[e])),"file"===this.state.transport[e].type?(t.transport[e].maxSize=parseInt(t.transport[e].maxSize,10)||null,t.transport[e].maxSize&&(t.transport[e].maxSize=`${t.transport[e].maxSize.toString()}m`),t.transport[e].maxFiles=parseInt(t.transport[e].maxFiles,10)||null):"syslog"===this.state.transport[e].type?(t.transport[e].port||delete t.transport[e].port,t.transport[e].path||delete t.transport[e].path,t.transport[e].sysLogType||delete t.transport[e].sysLogType,t.transport[e].app_name||delete t.transport[e].app_name,t.transport[e].eol||delete t.transport[e].eol):"http"===this.state.transport[e].type?(t.transport[e].host=t.transport[e].host||"",t.transport[e].port=parseInt(t.transport[e].port,10)||80,t.transport[e].path=t.transport[e].path||"/",t.transport[e].auth=t.transport[e].auth||"",t.transport[e].ssl=t.transport[e].ssl||!1):"stream"===this.state.transport[e].type&&(t.transport[e].stream=t.transport[e].stream||"",t.transport[e].level=t.transport[e].level||"info",t.transport[e].silent=t.transport[e].silent||!1,t.transport[e].eol=t.transport[e].eol||"")})),this.props.onChange(t)}onDelete(t){const e=JSON.parse(JSON.stringify(this.state.transport));delete e[t],this.setState({transport:e},(()=>this.onChange()))}renderEnabled(t){return(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.FormControlLabel,{style:G.controlItem,control:(0,b.jsx)(i.Checkbox,{checked:this.state.transport[t].enabled,onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].enabled=e.target.checked,this.setState({transport:s},(()=>this.onChange()))}}),label:this.props.t("Enabled")})})}renderLogLevel(t){return this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsxs)(i.FormControl,{style:G.controlItem,variant:"standard",children:[(0,b.jsx)(i.InputLabel,{children:this.props.t("Level")}),(0,b.jsxs)(i.Select,{variant:"standard",value:this.state.transport[t].level||"_",renderValue:()=>this.state.transport[t].level||this.props.t("default"),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].level="_"===e.target.value?"":e.target.value,this.setState({transport:s},(()=>this.onChange()))},children:[(0,b.jsx)(i.MenuItem,{value:"_",children:this.props.t("default")}),(0,b.jsx)(i.MenuItem,{value:"silly",children:"silly"}),(0,b.jsx)(i.MenuItem,{value:"debug",children:"debug"}),(0,b.jsx)(i.MenuItem,{value:"info",children:"info"}),(0,b.jsx)(i.MenuItem,{value:"warn",children:"warn"}),(0,b.jsx)(i.MenuItem,{value:"error",children:"error"})]}),(0,b.jsx)(i.FormHelperText,{children:this.props.t("Level of messages that this transport should log (default: level set on parent logger)")})]})}):null}renderSyslog(t){return(0,b.jsxs)(i.Accordion,{expanded:this.state.expanded.includes(t),onChange:()=>{const e=[...this.state.expanded],s=e.indexOf(t);-1===s?e.push(t):e.splice(s,1),this.setState({expanded:e})},children:[(0,b.jsxs)(i.AccordionSummary,{expandIcon:(0,b.jsx)(r.ExpandMore,{}),style:{position:"relative",background:"rgba(128, 128, 128, 0.3)"},children:[(0,b.jsx)(r.Computer,{style:G.headingIcon}),(0,b.jsx)(i.Typography,{style:G.heading,children:t}),(0,b.jsx)(i.Fab,{size:"small",style:G.delButton,onClick:()=>this.onDelete(t),children:(0,b.jsx)(r.Delete,{})})]}),(0,b.jsx)(i.AccordionDetails,{children:(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:[this.renderEnabled(t),this.renderLogLevel(t),this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].host,helperText:this.props.t("The host running syslogd, defaults to localhost"),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].host=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("File name")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].port,type:"number",helperText:this.props.t("The port on the host that syslog is running on, defaults to syslogd's default port(514/UDP)."),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].port=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Port")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsxs)(i.FormControl,{style:G.controlItem,variant:"standard",children:[(0,b.jsx)(i.InputLabel,{children:this.props.t("Protocol")}),(0,b.jsxs)(i.Select,{variant:"standard",value:this.state.transport[t].protocol,onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].protocol=e.target.value,this.setState({transport:s},(()=>this.onChange()))},children:[(0,b.jsx)(i.MenuItem,{value:"udp4",children:"udp4"}),(0,b.jsx)(i.MenuItem,{value:"tcp4",children:"tcp4"}),(0,b.jsx)(i.MenuItem,{value:"unix",children:"unix"}),(0,b.jsx)(i.MenuItem,{value:"unix-connect",children:"unix-connect"})]})]})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].path,helperText:this.props.t("The path to the syslog dgram socket (i.e. /dev/log or /var/run/syslog for OS X)."),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].path=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Path")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].facility,helperText:this.props.t("Syslog facility to use (Default: local0)."),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].facility=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Facility")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].localhost,helperText:this.props.t("Host to indicate that log messages are coming from (Default: localhost)."),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].localhost=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Log name")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].sysLogType,helperText:this.props.t("The type of the syslog protocol to use (Default: BSD)."),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].sysLogType=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("SysLog Type")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].app_name,helperText:this.props.t("The name of the application (Default: process.title)."),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].app_name=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Application name")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].eol,helperText:this.props.t("The end of line character to be added to the end of the message (Default: Message without modifications)."),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].eol=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("End of line char")})}):null]})})]},t)}renderFile(t){return(0,b.jsxs)(i.Accordion,{expanded:this.state.expanded.includes(t),onChange:()=>{const e=[...this.state.expanded],s=e.indexOf(t);-1===s?e.push(t):e.splice(s,1),this.setState({expanded:e})},children:[(0,b.jsxs)(i.AccordionSummary,{style:{background:"rgba(128, 128, 128, 0.3)"},expandIcon:(0,b.jsx)(r.ExpandMore,{}),children:[(0,b.jsx)(r.InsertDriveFile,{style:G.headingIcon}),(0,b.jsx)(i.Typography,{style:G.heading,children:t}),(0,b.jsx)(i.Fab,{size:"small",style:G.delButton,onClick:()=>this.onDelete(t),children:(0,b.jsx)(r.Delete,{})})]}),(0,b.jsx)(i.AccordionDetails,{children:(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:[this.renderEnabled(t),this.renderLogLevel(t),this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].filename,onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].filename=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("File name")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].fileext,onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].fileext=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("File extension")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].maxSize,type:"number",helperText:this.props.t("MB"),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].maxSize=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Maximal size of one file")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].maxFiles,type:"number",onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].maxFiles=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Maximal number of files")})}):null]})})]},t)}renderHttp(t){return(0,b.jsxs)(i.Accordion,{expanded:this.state.expanded.includes(t),onChange:()=>{const e=[...this.state.expanded],s=e.indexOf(t);-1===s?e.push(t):e.splice(s,1),this.setState({expanded:e})},children:[(0,b.jsxs)(i.AccordionSummary,{expandIcon:(0,b.jsx)(r.ExpandMore,{}),style:{position:"relative",background:"rgba(128, 128, 128, 0.3)"},children:[(0,b.jsx)(r.Language,{style:G.headingIcon}),(0,b.jsx)(i.Typography,{style:G.heading,children:t}),(0,b.jsx)(i.Fab,{size:"small",style:G.delButton,onClick:()=>this.onDelete(t),children:(0,b.jsx)(r.Delete,{})})]}),(0,b.jsx)(i.AccordionDetails,{children:(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:[this.renderEnabled(t),this.renderLogLevel(t),this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].host,helperText:this.props.t("Remote host of the HTTP logging endpoint"),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].host=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Host")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].port,type:"number",helperText:this.props.t("Remote port of the HTTP logging endpoint"),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].port=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Port")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].path,helperText:this.props.t("Remote URI of the HTTP logging endpoint"),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].path=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Path")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].auth,helperText:this.props.t("An object representing the username and password for HTTP Basic Auth"),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].auth=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Auth")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.FormControlLabel,{style:G.controlItem,control:(0,b.jsx)(i.Checkbox,{checked:this.state.transport[t].ssl,onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].ssl=e.target.checked,this.setState({transport:s},(()=>this.onChange()))}}),label:this.props.t("SSL")})}):null]})})]},t)}renderStream(t){return(0,b.jsxs)(i.Accordion,{expanded:this.state.expanded.includes(t),onChange:()=>{const e=[...this.state.expanded],s=e.indexOf(t);-1===s?e.push(t):e.splice(s,1),this.setState({expanded:e})},children:[(0,b.jsxs)(i.AccordionSummary,{expandIcon:(0,b.jsx)(r.ExpandMore,{}),style:{position:"relative",background:"rgba(128, 128, 128, 0.3)"},children:[(0,b.jsx)(r.Send,{style:G.headingIcon}),(0,b.jsx)(i.Typography,{style:G.heading,children:t}),(0,b.jsx)(i.Fab,{size:"small",style:G.delButton,onClick:()=>this.onDelete(t),children:(0,b.jsx)(r.Delete,{})})]}),(0,b.jsx)(i.AccordionDetails,{children:(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:[this.renderEnabled(t),this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].stream,helperText:this.props.t("any Node.js stream. If an objectMode stream is provided then the entire info object will be written. Otherwise info[MESSAGE] will be written"),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].stream=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("File name")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.FormControlLabel,{style:G.controlItem,control:(0,b.jsx)(i.Checkbox,{checked:this.state.transport[t].silent,onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].silent=e.target.checked,this.setState({transport:s},(()=>this.onChange()))}}),label:this.props.t("Silent")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].eol,helperText:this.props.t("Line-ending character to use. (default: os.EOL).)"),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].eol=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("EOL")})}):null]})})]},t)}renderSEQ(t){return(0,b.jsxs)(i.Accordion,{expanded:this.state.expanded.includes(t),onChange:()=>{const e=[...this.state.expanded],s=e.indexOf(t);-1===s?e.push(t):e.splice(s,1),this.setState({expanded:e})},children:[(0,b.jsxs)(i.AccordionSummary,{expandIcon:(0,b.jsx)(r.ExpandMore,{}),style:{position:"relative",background:"rgba(128, 128, 128, 0.3)"},children:[(0,b.jsx)("img",{style:G.headingIcon,src:N,alt:"seq"}),(0,b.jsx)(i.Typography,{style:G.heading,children:t}),(0,b.jsx)(i.Fab,{size:"small",style:G.delButton,onClick:()=>this.onDelete(t),children:(0,b.jsx)(r.Delete,{})})]}),(0,b.jsx)(i.AccordionDetails,{children:(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:[this.renderEnabled(t),this.renderLogLevel(t),this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].serverUrl,helperText:this.props.t("The http(s) URL including port of the seq server. If you use HTTPS a real certificate is needed; self signed certs are ot accepted."),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].serverUrl=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("Server URL")})}):null,this.state.transport[t].enabled?(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.transport[t].apiKey,helperText:this.props.t("The apiKey of the seq system"),onChange:e=>{const s=JSON.parse(JSON.stringify(this.state.transport));s[t].apiKey=e.target.value,this.setState({transport:s},(()=>this.onChange()))},label:this.props.t("API key")})}):null]})})]},t)}findFreeName(t){for(let e=1;;e++)if(!Object.keys(this.state.transport).find((s=>s===t+e)))return t+e}add(t){if("file"===t){const e=this.findFreeName(t),s=JSON.parse(JSON.stringify(this.state.transport));s[e]={type:t,enabled:!0,filename:"log/iobroker",fileext:".log",maxSize:0,maxFiles:0},this.setState({transport:s},(()=>this.onChange()))}else if("syslog"===t){const e=this.findFreeName(t),s=JSON.parse(JSON.stringify(this.state.transport));s[e]={type:t,enabled:!0,host:"127.0.0.1",port:0,protocol:"udp4",path:"",facility:"",localhost:"iobroker",sysLogType:"",app_name:"",eol:""},this.setState({transport:s},(()=>this.onChange()))}else if("http"===t){const e=this.findFreeName(t),s=JSON.parse(JSON.stringify(this.state.transport));s[e]={type:t,enabled:!0,host:"127.0.0.1",port:80,path:"/",auth:"None",ssl:!1},this.setState({transport:s},(()=>this.onChange()))}else if("stream"===t){const e=this.findFreeName(t),s=JSON.parse(JSON.stringify(this.state.transport));s[e]={type:t,enabled:!0,stream:"/dev/null",level:"info",silent:!1,eol:""},this.setState({transport:s},(()=>this.onChange()))}else if("seq"===t){const e=this.findFreeName(t),s=JSON.parse(JSON.stringify(this.state.transport));s[e]={type:t,enabled:!0,level:"info",serverUrl:"http://IP:PORT",apiKey:""},this.setState({transport:s},(()=>this.onChange()))}}render(){return(0,b.jsxs)(i.Paper,{style:G.paper,children:[(0,b.jsx)(i.Grid2,{sx:G.gridSettings,children:(0,b.jsxs)(i.Grid2,{container:!0,direction:"column",children:[(0,b.jsx)(i.Grid2,{children:(0,b.jsxs)(i.FormControl,{style:G.controlItem,variant:"standard",children:[(0,b.jsx)(i.InputLabel,{children:this.props.t("Level")}),(0,b.jsxs)(i.Select,{variant:"standard",value:this.state.level,onChange:t=>this.setState({level:t.target.value},(()=>this.onChange())),children:[(0,b.jsx)(i.MenuItem,{value:"silly",children:"silly"}),(0,b.jsx)(i.MenuItem,{value:"debug",children:"debug"}),(0,b.jsx)(i.MenuItem,{value:"info",children:"info"}),(0,b.jsx)(i.MenuItem,{value:"warn",children:"warn"}),(0,b.jsx)(i.MenuItem,{value:"error",children:"error"})]})]})}),(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.TextField,{variant:"standard",style:G.controlItem,value:this.state.maxDays,helperText:this.props.t("Every day one file"),type:"number",onChange:t=>this.setState({maxDays:t.target.value},(()=>this.onChange())),label:this.props.t("Maximum number of days")})}),(0,b.jsx)(i.Grid2,{children:(0,b.jsx)(i.FormControlLabel,{style:G.controlItem,control:(0,b.jsx)(i.Checkbox,{checked:this.state.noStdout,onChange:t=>this.setState({noStdout:t.target.checked},(()=>this.onChange()))}),label:this.props.t("No stdout outputs")})}),Object.keys(this.state.transport).map((t=>{switch(this.state.transport[t].type){case"syslog":return this.renderSyslog(t);case"file":return this.renderFile(t);case"http":return this.renderHttp(t);case"stream":return this.renderStream(t);case"seq":return this.renderSEQ(t);default:return null}}))]})}),(0,b.jsxs)(i.Toolbar,{children:[(0,b.jsxs)(i.Button,{color:"grey",style:G.addButton,variant:"contained",onClick:()=>this.add("file"),startIcon:(0,b.jsx)(r.Add,{}),children:[(0,b.jsx)(r.InsertDriveFile,{style:G.buttonIcon}),this.props.t("File log")]}),(0,b.jsxs)(i.Button,{color:"grey",style:G.addButton,variant:"contained",onClick:()=>this.add("syslog"),startIcon:(0,b.jsx)(r.Add,{}),children:[(0,b.jsx)(r.Computer,{style:G.buttonIcon}),this.props.t("Syslog")]}),(0,b.jsxs)(i.Button,{color:"grey",style:G.addButton,variant:"contained",onClick:()=>this.add("http"),startIcon:(0,b.jsx)(r.Add,{}),children:[(0,b.jsx)(r.Language,{style:G.buttonIcon}),this.props.t("HTTP log")]}),(0,b.jsxs)(i.Button,{color:"grey",style:G.addButton,variant:"contained",onClick:()=>this.add("stream"),startIcon:(0,b.jsx)(r.Add,{}),children:[(0,b.jsx)(r.Send,{style:G.buttonIcon}),this.props.t("Stream log")]}),(0,b.jsxs)(i.Button,{color:"grey",style:G.addButton,variant:"contained",onClick:()=>this.add("seq"),startIcon:(0,b.jsx)(r.Add,{}),children:[(0,b.jsx)("img",{src:N,style:G.buttonIcon,alt:"seq"}),this.props.t("SEQ log")]})]})]})}}const J=(0,a.withWidth)()(E);var U=s(40866);const $={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"auto",padding:8},title:{width:"100%",height:32},divWithoutTitle:{width:"100%",height:"calc(100% - 32px)",border:"2px solid #00000000"},error:{border:"2px solid #FF0000"}};class V extends o.Component{constructor(t){super(t),this.state={settings:JSON.stringify(this.props.settings||{},null,2),error:!1}}onChange(t){const e={settings:t};try{const s=JSON.parse(t);this.state.error&&(e.error=!1),this.setState(e,(()=>this.props.onChange(s)))}catch{e.error=!0,this.setState(e)}}render(){return(0,b.jsxs)(i.Paper,{style:$.paper,children:[(0,b.jsx)("div",{style:$.title,children:this.props.t("For future use")}),(0,b.jsx)("div",{style:{...$.divWithoutTitle,...this.state.error?$.error:void 0},children:(0,b.jsx)(U.A,{themeType:this.props.themeType,value:this.state.settings,onChange:t=>this.onChange(t)})})]})}}const q=(0,a.withWidth)()(V);var K=s(78884);const X={content:{height:500,overflow:"hidden"},tabPanel:t=>({width:"100%",height:`calc(100% - ${t.mixins.toolbar.minHeight}px)`,overflow:"auto"}),selected:t=>({color:"dark"===t.palette.mode?"#FFF !important":"#222 !important"})};class Q extends o.Component{constructor(t){super(t),this.originalSettings=void 0,this.state={currentTab:0,hasChanges:[],currentHost:this.props.currentHost,loading:!0,confirmExit:!1,showRestart:!1,system:null,multihostService:null,objects:null,states:null,log:null,plugins:null,dnsResolution:"ipv4first",dataDir:"",saving:!1}}async componentDidMount(){await this.getSettings(this.state.currentHost)}renderConfirmDialog(){return this.state.confirmExit?(0,b.jsx)(a.Confirm,{text:this.props.t("Discard unsaved changes?"),onClose:t=>this.setState({confirmExit:!1},(()=>t&&this.props.onClose()))}):null}renderRestartDialog(){return this.state.showRestart?(0,b.jsx)(a.Confirm,{title:this.props.t("Please confirm"),text:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{children:this.props.t("Restart works only if controller started as system service.")}),(0,b.jsx)("div",{children:this.props.t("Would you like to restart the controller for your changes to take effect?")})]}),ok:this.props.t("Restart"),cancel:this.props.t("No restart"),onClose:t=>this.setState({showRestart:!1},(()=>{t&&this.props.socket.restartController(this.props.currentHost).then((()=>setTimeout((()=>window.location.reload()),500))).catch((t=>window.alert(`Cannot restart: ${t}`))),this.props.onClose()}))}):null}async getSettings(t){const e=await this.props.socket.readBaseSettings(t||this.state.currentHost);null!==e&&void 0!==e&&e.config&&(this.originalSettings=K.A.clone(e.config),this.setState({loading:!1,system:e.config.system,multihostService:e.config.multihostService,objects:e.config.objects,states:e.config.states,log:e.config.log,plugins:e.config.plugins,dnsResolution:e.config.dnsResolution||"ipv4first",dataDir:e.config.dataDir}))}onSave(t){const e={system:this.state.system,multihostService:this.state.multihostService,objects:this.state.objects,states:this.state.states,log:this.state.log,plugins:this.state.plugins},s={...this.originalSettings,...e};this.setState({saving:!0},(()=>{this.props.socket.writeBaseSettings(t||this.state.currentHost,s).then((()=>{this.originalSettings=JSON.parse(JSON.stringify(e)),this.setState({hasChanges:[],showRestart:!0,saving:!1})})).catch((t=>{window.alert(`Cannot save settings: ${t}`),this.setState({saving:!1})}))}))}updateSettings(t,e){const s=[...this.state.hasChanges],o=JSON.stringify(this.originalSettings[t])!==JSON.stringify(e),n=s.indexOf(t);o&&-1===n?s.push(t):o||-1===n||s.splice(n,1),this.setState({[t]:e,hasChanges:s})}renderSystem(){const t="system";return(0,b.jsx)(B,{settings:this.state[t],t:this.props.t,currentHost:this.props.currentHost,onChange:e=>this.updateSettings(t,e)})}renderMultihost(){const t="multihostService";return(0,b.jsx)(D,{settings:this.state[t],t:this.props.t,socket:this.props.socket,currentHost:this.props.currentHost,onChange:e=>this.updateSettings(t,e)})}renderObjects(){const t="objects";return(0,b.jsx)(z,{settings:this.state[t],t:this.props.t,socket:this.props.socket,currentHost:this.props.currentHost,onChange:e=>this.updateSettings(t,e)})}renderStates(){const t="states";return(0,b.jsx)(W,{settings:this.state[t],t:this.props.t,socket:this.props.socket,currentHost:this.props.currentHost,onChange:e=>this.updateSettings(t,e)})}renderLog(){return(0,b.jsx)(J,{settings:this.state.log,t:this.props.t,socket:this.props.socket,currentHost:this.props.currentHost,onChange:t=>this.updateSettings("log",t)})}renderPlugins(){const t="plugins";return(0,b.jsx)(q,{settings:this.state[t],t:this.props.t,themeType:this.props.themeType,onChange:e=>this.updateSettings(t,e)})}render(){return(0,b.jsxs)(i.Dialog,{style:X.dialog,open:!0,onClose:()=>!1,fullWidth:!0,maxWidth:"xl","aria-labelledby":"base-settings-dialog-title",children:[(0,b.jsxs)(i.DialogTitle,{id:"base-settings-dialog-title",children:[this.props.t("Host Base Settings"),": ",this.props.currentHostName||this.props.currentHost]}),(0,b.jsxs)(i.DialogContent,{style:X.content,children:[(0,b.jsx)(i.AppBar,{position:"static",children:(0,b.jsxs)(i.Tabs,{value:this.state.currentTab,onChange:(t,e)=>this.setState({currentTab:e}),"aria-label":"system tabs",indicatorColor:"secondary",children:[(0,b.jsx)(i.Tab,{label:this.props.t("System"),id:"system-tab","aria-controls":"simple-tabpanel-0",sx:{"&.Mui-selected":X.selected}}),(0,b.jsx)(i.Tab,{label:this.props.t("Multi-host"),id:"multihost-tab",sx:{"&.Mui-selected":X.selected},"aria-controls":"simple-tabpanel-1"}),(0,b.jsx)(i.Tab,{label:this.props.t("Objects"),id:"objects-tab","aria-controls":"simple-tabpanel-3",sx:{"&.Mui-selected":X.selected}}),(0,b.jsx)(i.Tab,{label:this.props.t("States"),id:"states-tab","aria-controls":"simple-tabpanel-4",sx:{"&.Mui-selected":X.selected}}),(0,b.jsx)(i.Tab,{label:this.props.t("Log"),id:"log-tab","aria-controls":"simple-tabpanel-5",sx:{"&.Mui-selected":X.selected}}),(0,b.jsx)(i.Tab,{label:this.props.t("Plugins"),id:"plugins-tab","aria-controls":"simple-tabpanel-6",sx:{"&.Mui-selected":X.selected}})]})}),this.state.loading?(0,b.jsx)(i.LinearProgress,{}):null,this.state.loading||0!==this.state.currentTab?null:(0,b.jsx)(i.Box,{component:"div",sx:X.tabPanel,children:this.renderSystem()}),this.state.loading||1!==this.state.currentTab?null:(0,b.jsx)(i.Box,{component:"div",sx:X.tabPanel,children:this.renderMultihost()}),this.state.loading||2!==this.state.currentTab?null:(0,b.jsx)(i.Box,{component:"div",sx:X.tabPanel,children:this.renderObjects()}),this.state.loading||3!==this.state.currentTab?null:(0,b.jsx)(i.Box,{component:"div",sx:X.tabPanel,children:this.renderStates()}),this.state.loading||4!==this.state.currentTab?null:(0,b.jsx)(i.Box,{component:"div",sx:X.tabPanel,children:this.renderLog()}),this.state.loading||5!==this.state.currentTab?null:(0,b.jsx)(i.Box,{component:"div",sx:X.tabPanel,children:this.renderPlugins()}),this.renderConfirmDialog(),this.renderRestartDialog()]}),(0,b.jsxs)(i.DialogActions,{children:[(0,b.jsx)(i.Button,{variant:"contained",disabled:!this.state.hasChanges.length||this.state.saving,onClick:()=>this.onSave(),color:"primary",startIcon:(0,b.jsx)(r.Check,{}),children:this.props.t("Save & Close")}),(0,b.jsx)(i.Button,{variant:"contained",color:"grey",disabled:this.state.saving,onClick:()=>this.state.hasChanges.length?this.setState({confirmExit:!0}):this.props.onClose(),startIcon:(0,b.jsx)(r.Close,{}),children:this.state.hasChanges.length?this.props.t("Cancel"):this.props.t("Close")})]})]})}}const Z=(0,a.withWidth)()(Q),Y={error:{border:"2px solid #FF0000"},id:{fontStyle:"italic"},dialog:{height:"calc(100% - 64px)"},button:{marginTop:20,marginLeft:8},funcDivEdit:{width:"100%"},funcEditName:{display:"inline-block",width:85},funcEdit:{width:400},marginTop:{marginTop:20},commonTabWrapper:{flexFlow:"wrap",display:"flex"},commonWrapper:{width:500,minWidth:300},flexDrop:{width:"100%",maxWidth:500,margin:"auto",display:"flex"},marginBlock:{marginTop:20},buttonAdd:{minWidth:150},textField:{width:"100%"},flex:{display:"flex"},close:{width:"20px",height:"20px",opacity:"0.9",cursor:"pointer",position:"relative",top:20,transition:"all 0.6s ease","&:hover":{transform:"rotate(90deg)"},"&:before":{position:"absolute",left:"9px",content:'""',height:"20px",width:"3px",backgroundColor:"#ff4f4f",transform:"rotate(45deg)"},"&:after":{position:"absolute",left:"9px",content:'""',height:"20px",width:"3px",backgroundColor:"#ff4f4f",transform:"rotate(-45deg)"}},color:{width:70},buttonRemoveWrapper:{position:"absolute",zIndex:222,right:0},tabsPadding:{padding:"0px 24px"}};class tt extends o.Component{constructor(t){super(t),this.originalObj=void 0,this.state={text:JSON.stringify(this.props.obj,null,2),error:!1,changed:!1},this.originalObj=JSON.stringify(this.props.obj,null,2)}prepareObject(t){t=t||this.state.text;try{const e=JSON.parse(t);return e._id=this.props.obj._id,e}catch{return null}}onChange(t){const e={text:t},s=this.prepareObject(t);s?(e.changed=this.originalObj!==JSON.stringify(s,null,2),this.state.error&&(e.error=!1)):e.error=!0,this.setState(e)}onUpdate(){try{const t=JSON.parse(this.state.text);t._id=this.props.obj._id,this.props.onClose(t)}catch{}}setCommonItem(t,e,s){t.common[e]=s,this.onChange(JSON.stringify(t,null,2))}removeCommonItem(t,e){delete t.common.common[e],this.onChange(JSON.stringify(t,null,2))}buttonAddKey(t,e){const{t:s}=this.props;return(0,b.jsx)("div",{style:Y.marginBlock,children:(0,b.jsx)(i.Button,{style:Y.buttonAdd,variant:"contained",color:"secondary",onClick:e,startIcon:(0,b.jsx)(r.Add,{}),children:s(`Add ${t}`)})})}buttonRemoveKey(t,e){const{t:s}=this.props;return(0,b.jsx)(i.Tooltip,{title:s(`Remove ${t}`),slotProps:{popper:{sx:{pointerEvents:"none"}}},children:(0,b.jsx)(i.Box,{component:"div",sx:Y.close,onClick:e})})}renderCommonEdit(){try{const t=JSON.parse(this.state.text),e=!1,{t:s}=this.props;return(0,b.jsxs)("div",{style:Y.commonTabWrapper,children:[(0,b.jsxs)("div",{style:Y.commonWrapper,children:["undefined"!==typeof t.common.title?(0,b.jsx)(i.TextField,{variant:"standard",disabled:e,label:s("title"),style:{...Y.marginBlock,...Y.textField},fullWidth:!0,value:t.common.title,onChange:e=>this.setCommonItem(t,"title",e.target.value),slotProps:{input:{endAdornment:t.common.title?(0,b.jsx)(i.InputAdornment,{position:"end",children:(0,b.jsx)(i.IconButton,{size:"small",onClick:()=>this.setCommonItem(t,"title",""),children:(0,b.jsx)(r.Close,{})})}):null}}}):this.buttonAddKey("title",(()=>this.setCommonItem(t,"title",""))),"undefined"!==typeof t.common.color?(0,b.jsxs)("div",{style:Y.flex,children:[(0,b.jsx)(i.TextField,{variant:"standard",disabled:e,style:{...Y.marginBlock,...Y.color},label:s("Color"),type:"color",value:t.common.color,onChange:e=>this.setCommonItem(t,"color",e.target.value),slotProps:{input:{endAdornment:t.common.color?(0,b.jsx)(i.InputAdornment,{position:"end",children:(0,b.jsx)(i.IconButton,{size:"small",onClick:()=>this.setCommonItem(t,"color",""),children:(0,b.jsx)(r.Close,{})})}):null}}}),this.buttonRemoveKey("color",(()=>this.removeCommonItem(t,"color")))]}):this.buttonAddKey("color",(()=>this.setCommonItem(t,"color","")))]}),"undefined"!==typeof t.common.icon?(0,b.jsxs)("div",{style:Y.flexDrop,children:[(0,b.jsx)(a.UploadImage,{disabled:e,crop:!0,maxSize:262144,icon:t.common.icon,removeIconFunc:()=>this.setCommonItem(t,"icon",""),onChange:e=>this.setCommonItem(t,"icon",e)}),this.buttonRemoveKey("icon",(()=>this.removeCommonItem(t,"icon")))]}):(0,b.jsx)("div",{style:Y.flexDrop,children:this.buttonAddKey("icon",(()=>this.setCommonItem(t,"icon","")))})]})}catch{return(0,b.jsx)("div",{children:this.props.t("Cannot parse JSON!")})}}render(){return(0,b.jsxs)(i.Dialog,{sx:{"& .MuiDialog-paper":Y.dialog},open:!0,maxWidth:"lg",fullWidth:!0,fullScreen:!1,onClose:()=>this.props.onClose(),"aria-labelledby":"edit-value-dialog-title","aria-describedby":"edit-value-dialog-description",children:[(0,b.jsxs)(i.DialogTitle,{id:"edit-value-dialog-title",children:[this.props.t("Edit host settings"),":",(0,b.jsx)("span",{style:Y.id,children:this.props.obj._id})]}),(0,b.jsx)(i.DialogContent,{children:this.renderCommonEdit()}),(0,b.jsxs)(i.DialogActions,{children:[(0,b.jsx)(i.Button,{variant:"contained",disabled:this.state.error||!this.state.changed,onClick:()=>this.onUpdate(),color:"primary",startIcon:(0,b.jsx)(r.Check,{}),children:this.props.t("Write")}),(0,b.jsx)(i.Button,{variant:"contained",onClick:()=>this.props.onClose(),color:"grey",startIcon:(0,b.jsx)(r.Close,{}),children:this.props.t("Cancel")})]})]})}}const et=tt;var st=s(90869);const ot="0 2px 2px 0 rgba(0, 0, 0, .14),0 3px 1px -2px rgba(0, 0, 0, .12),0 1px 5px 0 rgba(0, 0, 0, .2)",nt="0 8px 17px 0 rgba(0, 0, 0, .2),0 6px 20px 0 rgba(0, 0, 0, .19)",it={img:{width:45,height:45,margin:"auto 0",position:"relative","&:after":{content:'""',position:"absolute",zIndex:2,top:0,left:0,width:"100%",height:"100%",background:'url("img/no-image.png") 100% 100% no-repeat',backgroundSize:"cover",backgroundColor:"#fff"}},collapseOff:{height:0},footerBlock:t=>({background:t.palette.background.default,p:"10px",display:"flex",justifyContent:"space-between"}),hidden:{display:"none"},emptyButton:{width:48},greenText:t=>({color:t.palette.success.dark}),wrapperAvailable:{display:"flex",alignItems:"center"},buttonUpdate:{border:`1px solid ${c.A[700]}`,padding:"2px 7px",borderRadius:"5px",display:"flex",alignItems:"center",cursor:"pointer",transition:"background 0.5s","&:hover":{background:"#00800026"}},buttonUpdateIcon:{height:20,width:20,marginRight:10},debug:{backgroundColor:u.A[700]},info:{backgroundColor:m.A[700]},warn:{backgroundColor:x.A[700]},error:{backgroundColor:g.A[700]},smallAvatar:{width:24,height:24},formControl:{display:"flex"},baseSettingsButton:{transform:"rotate(45deg)"},tooltip:{pointerEvents:"none"}},rt=["silly","debug","info","warn","error"];function at(t,e){const s=t.className.split(" "),o=s.indexOf(e);-1!==o&&(s.splice(o,1),t.className=s.join(" ")),s.push(e),setTimeout((e=>t.className=e),100,s.join(" "))}class lt extends o.Component{constructor(t){super(t),this.refEvents=n().createRef(),this.refWarning=n().createRef(),this.refCpu=n().createRef(),this.refMem=n().createRef(),this.refUptime=n().createRef(),this.outputCache="-",this.inputCache="-",this.cpuCache="- %",this.memCache="- %",this.uptimeCache="-",this.diskFreeCache=1,this.diskSizeCache=1,this.diskWarningCache=1,this.notificationHandler=t=>t&&t[this.props.hostId]&&this.setState({hostNotifications:{notifications:t[this.props.hostId],...lt.calculateWarning(t[this.props.hostId])}}),this.eventsInputFunc=(t,e)=>{this.inputCache=e&&null!==e.val?`\u21e5${e.val}`:"-",this.refEvents.current&&(this.refEvents.current.innerHTML=`${this.inputCache} / ${this.outputCache}`,at(this.refEvents.current,`newValueHost-${this.props.themeType||"light"}`))},this.eventsOutputFunc=(t,e)=>{this.outputCache=e&&null!==e.val?`\u21a6${e.val}`:"-",this.refEvents.current&&(this.refEvents.current.innerHTML=`${this.inputCache} / ${this.outputCache}`,at(this.refEvents.current,`newValueHost-${this.props.themeType||"light"}`))},this.warningFunc=(t,e)=>{t.endsWith("diskFree")?this.diskFreeCache=(null===e||void 0===e?void 0:e.val)||0:t.endsWith("diskSize")?this.diskSizeCache=(null===e||void 0===e?void 0:e.val)||0:t.endsWith("diskWarning")&&(this.diskWarningCache=(null===e||void 0===e?void 0:e.val)||0);const s=this.diskFreeCache/this.diskSizeCache*100<=this.diskWarningCache;this.refWarning.current&&(s?(this.refWarning.current.setAttribute("title",this.props.t("Warning: Free space on disk is low")),this.refWarning.current.classList.add("warning")):(this.refWarning.current.removeAttribute("title"),this.refWarning.current.classList.remove("warning")))},this.cpuFunc=(t,e)=>{this.cpuCache=this.formatValue(e,"%"),this.refCpu.current&&(this.refCpu.current.innerHTML=this.cpuCache,at(this.refCpu.current,`newValueHost-${this.props.themeType||"light"}`))},this.memFunc=(t,e)=>{this.memCache=this.formatValue(e,"%"),this.refMem.current&&(this.refMem.current.innerHTML=this.memCache,at(this.refMem.current,`newValueHost-${this.props.themeType||"light"}`))},this.uptimeFunc=(t,e)=>{if(null!==e&&void 0!==e&&e.val){const t=Math.floor(e.val/86400),s=Math.floor(e.val%86400/3600);this.uptimeCache=t?`${t}d${s}h`:`${s}h`}this.refUptime.current&&(this.refUptime.current.innerHTML=this.uptimeCache,at(this.refUptime.current,`newValueHost-${this.props.themeType||"light"}`))},this.logLevelFunc=(t,e)=>{e&&this.setState({logLevel:e.val,logLevelSelect:e.val})},this.state={logLevel:"",logLevelSelect:"",hostNotifications:{notifications:null,warning:0,other:0},openDialogLogLevel:!1,hostUpdateDialog:!1,updateAvailable:!1,instructionDialog:!1,updateDialog:!1,baseSettingsDialog:!1,editDialog:!1,changeLog:null}}async getInitialDiskStates(){var t,e,s;const o=await this.props.socket.getState(`${this.props.hostId}.diskWarning`);this.diskWarningCache=null!==(t=null===o||void 0===o?void 0:o.val)&&void 0!==t?t:this.diskWarningCache;const n=await this.props.socket.getState(`${this.props.hostId}.diskFree`);this.diskFreeCache=null!==(e=null===n||void 0===n?void 0:n.val)&&void 0!==e?e:this.diskFreeCache;const i=await this.props.socket.getState(`${this.props.hostId}.diskSize`);this.diskSizeCache=null!==(s=null===i||void 0===i?void 0:i.val)&&void 0!==s?s:this.diskSizeCache}readChangeLog(){this.state.changeLog||fetch(S.Uu.replace("github.com","raw.githubusercontent.com").replace("/blob/","/")).then((t=>t.text())).then((t=>this.setState({changeLog:t}))).catch((t=>console.error(`Cannot read changelog: ${t}`)))}componentDidMount(){this.props.hostsWorker.registerNotificationHandler(this.notificationHandler),this.props.hostsWorker.getNotifications(this.props.hostId).then((t=>this.notificationHandler(t))),this.props.socket.subscribeState(`${this.props.hostId}.inputCount`,this.eventsInputFunc),this.props.socket.subscribeState(`${this.props.hostId}.outputCount`,this.eventsOutputFunc),this.props.socket.subscribeState(`${this.props.hostId}.cpu`,this.cpuFunc),this.props.socket.subscribeState(`${this.props.hostId}.mem`,this.memFunc),this.props.socket.subscribeState(`${this.props.hostId}.uptime`,this.uptimeFunc),this.getInitialDiskStates().finally((async()=>{await this.props.socket.subscribeState(`${this.props.hostId}.diskFree`,this.warningFunc),await this.props.socket.subscribeState(`${this.props.hostId}.diskSize`,this.warningFunc),await this.props.socket.subscribeState(`${this.props.hostId}.diskWarning`,this.warningFunc)})),this.props.socket.subscribeState(`${this.props.hostId}.logLevel`,this.logLevelFunc)}componentWillUnmount(){this.props.hostsWorker.unregisterNotificationHandler(this.notificationHandler),this.props.socket.unsubscribeState(`${this.props.hostId}.inputCount`,this.eventsInputFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.outputCount`,this.eventsOutputFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.cpu`,this.cpuFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.mem`,this.memFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.uptime`,this.uptimeFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.diskFree`,this.warningFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.diskSize`,this.warningFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.diskWarning`,this.warningFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.logLevel`,this.logLevelFunc)}static calculateWarning(t){const e={warning:0,other:0};if(!t)return e;const{result:s}=t;if(!s||!s.system)return e;if(Object.keys(s.system.categories).length){const t=s.system.categories;for(const s of Object.values(t))Object.keys(s.instances).forEach((()=>"alert"===s.severity?e.warning++:e.other++))}return e}formatValue(t,e){return t&&null!==t.val&&void 0!==t.val?this.props.systemConfig.common.isFloatComma?t.val.toString().replace(".",",")+(e?` ${e}`:""):t.val+(e?` ${e}`:""):"-"+(e?` ${e}`:"")}renderDialogLogLevel(){return this.state.openDialogLogLevel?(0,b.jsxs)(st.A,{theme:this.props.theme,title:this.props.t("Edit log level rule for %s",this.props.host.common.name),onApply:()=>{this.props.socket.setState(`${this.props.hostId}.logLevel`,this.state.logLevelSelect).catch((t=>window.alert(`Cannot set log level: ${t}`))),this.setState({openDialogLogLevel:!1})},onClose:()=>this.setState({openDialogLogLevel:!1,logLevelSelect:this.state.logLevel}),children:[(0,b.jsxs)(i.FormControl,{style:{...it.formControl,marginTop:8},variant:"outlined",children:[(0,b.jsx)(i.InputLabel,{children:this.props.t("log level")}),(0,b.jsx)(i.Select,{variant:"standard",value:this.state.logLevelSelect,fullWidth:!0,onChange:t=>this.setState({logLevelSelect:t.target.value}),children:rt.map((t=>(0,b.jsx)(i.MenuItem,{value:t,children:this.props.t(t)},t)))})]}),(0,b.jsxs)(i.FormControl,{style:it.formControl,variant:"outlined",children:[(0,b.jsx)(i.FormHelperText,{children:this.props.t("Log level will be reset to the saved level after the restart of the controller")}),(0,b.jsxs)(i.FormHelperText,{children:[this.props.t("You can set the log level permanently in the base host settings"),(0,b.jsx)(r.Build,{style:it.baseSettingsButton})]})]})]}):null}onCopy(){const t=[];if(this.refCpu.current&&t.push(`CPU: ${this.refCpu.current.innerHTML}`),this.refMem.current&&t.push(`RAM: ${this.refMem.current.innerHTML}`),this.refUptime.current&&t.push(`${this.props.t("Uptime")}: ${this.refUptime.current.innerHTML}`),t.push(`${this.props.t("Available")}: ${this.props.available}`),t.push(`${this.props.t("Installed")}: ${this.props.host.common.installedVersion}`),this.refEvents.current&&t.push(`${this.props.t("Events")}: ${this.refEvents.current.innerHTML}`),this.props.hostData&&"object"===typeof this.props.hostData){const e=this.props.hostData;Object.keys(e).map((s=>t.push(`${this.props.t(s)}: ${lt.formatInfo[s]?lt.formatInfo[s](e[s],this.props.t):e[s]||"--"}`)))}a.Utils.copyToClipboard(t.join("\n")),window.alert(this.props.t("Copied"))}renderUpdateButton(t,e){return t?(0,b.jsx)(i.Tooltip,{title:this.props.t("Update"),slotProps:{popper:{sx:it.tooltip}},children:(0,b.jsxs)(i.Box,{component:"div",onClick:t=>(t.stopPropagation(),this.openHostUpdateDialog()),sx:it.buttonUpdate,children:[(0,b.jsx)(i.IconButton,{style:it.buttonUpdateIcon,size:"small",children:(0,b.jsx)(r.Refresh,{})}),(0,b.jsx)("span",{style:{color:c.A[700]},children:this.props.available})]})}):(0,b.jsx)("span",{style:e,children:this.props.available})}renderHostBaseEdit(){return this.props.expertMode?(0,b.jsx)(i.Tooltip,{title:this.props.t("Host Base Settings"),slotProps:{popper:{sx:it.tooltip}},children:(0,b.jsx)("div",{children:(0,b.jsx)(i.IconButton,{size:"large",disabled:!this.props.alive,onClick:t=>{t.stopPropagation(),this.setState({baseSettingsDialog:!0})},children:(0,b.jsx)(r.Build,{style:it.baseSettingsButton})})})}):null}renderExtendButton(t){return(0,b.jsx)(i.Tooltip,{title:this.props.t(t?"collapse":"Expand"),slotProps:{popper:{sx:it.tooltip}},children:(0,b.jsx)("div",{children:(0,b.jsx)(i.IconButton,{size:"large",children:t?(0,b.jsx)(d.mlL,{}):(0,b.jsx)(d.nwe,{})})})})}renderRestartButton(){return(0,b.jsx)(i.Tooltip,{title:this.props.t("Restart host"),slotProps:{popper:{sx:it.tooltip}},children:(0,b.jsx)("div",{children:(0,b.jsx)(i.IconButton,{size:"large",disabled:!this.props.alive,onClick:t=>{t.stopPropagation(),this.props.socket.restartController(this.props.hostId).catch((t=>window.alert(`Cannot restart: ${t}`)))},children:(0,b.jsx)(r.Cached,{})})})})}renderEditButton(){return(0,b.jsx)(i.IconButton,{size:"large",onClick:t=>{t.stopPropagation(),this.setState({editDialog:!0})},children:(0,b.jsx)(r.Edit,{})})}renderRemoveButton(){return this.props.alive||this.props.isCurrentHost?(0,b.jsx)("div",{style:it.emptyButton}):(0,b.jsx)(i.Tooltip,{title:this.props.alive||this.props.isCurrentHost?this.props.t("You cannot delete host, when it is alive"):this.props.t("Remove"),slotProps:{popper:{sx:it.tooltip}},children:(0,b.jsx)(i.IconButton,{size:"large",onClick:t=>{t.stopPropagation(),this.props.executeCommandRemove()},children:(0,b.jsx)(r.Delete,{})})})}renderCopyButton(t){return(0,b.jsx)(i.Tooltip,{title:this.props.t("Copy"),slotProps:{popper:{sx:it.tooltip}},children:(0,b.jsx)(i.IconButton,{size:"large",onClick:()=>this.onCopy(),style:t,children:(0,b.jsx)(a.IconCopy,{})})})}renderLogLevel(){return(0,b.jsx)(i.Tooltip,{title:`${this.props.t("loglevel")} ${this.state.logLevel}`,slotProps:{popper:{sx:it.tooltip}},children:(0,b.jsx)(i.IconButton,{size:"large",onClick:t=>{t.stopPropagation(),this.setState({openDialogLogLevel:!0})},children:(0,b.jsx)(i.Avatar,{style:{...it.smallAvatar,...it[this.state.logLevel]},children:(t=this.state.logLevel,"debug"===t?(0,b.jsx)(r.BugReport,{}):"info"===t?(0,b.jsx)(r.Info,{}):"warn"===t?(0,b.jsx)(r.Warning,{}):"error"===t?(0,b.jsx)(r.Error,{}):null)})})});var t}renderNotificationsBadge(t,e){return(0,b.jsx)(i.Badge,{sx:e?{right:-3,top:13,padding:"0 4px"}:void 0,title:this.props.t("Hosts notifications"),badgeContent:this.state.hostNotifications.warning+this.state.hostNotifications.other,style:it.badge,color:this.state.hostNotifications.warning>0?"error":"secondary",onClick:t=>{t.stopPropagation(),this.props.showAdaptersWarning({[this.props.hostId]:this.state.hostNotifications.notifications},this.props.hostId)},children:t})}async openHostUpdateDialog(){const t=await this.props.socket.checkFeatureSupported("CONTROLLER_UI_UPGRADE");this.setState({hostUpdateDialog:!0,updateAvailable:t}),this.readChangeLog()}renderHostUpdateDialog(){return this.state.hostUpdateDialog?(0,b.jsx)(f.A,{adapter:this.props.host.common.name,adapterObject:this.props.jsControllerInfo,t:this.props.t,textUpdate:this.state.updateAvailable?this.props.t("Start update"):this.props.t("Show instructions"),textInstruction:this.props.t("Show whole changelog"),rightDependencies:!0,news:this.getNews(),toggleTranslation:this.props.toggleTranslation,noTranslation:this.props.noTranslation,onUpdate:()=>{this.state.updateAvailable?this.setState({hostUpdateDialog:!1,updateDialog:!0}):this.setState({hostUpdateDialog:!1,instructionDialog:!0})},theme:this.props.theme,installedVersion:this.props.host.common.installedVersion,onInstruction:()=>{window.open(S.Uu,"_blank")},onClose:()=>this.setState({hostUpdateDialog:!1})}):null}renderUpdateDialog(){return this.state.updateAvailable&&this.state.updateDialog?(0,b.jsx)(j,{socket:this.props.socket,hostId:this.props.hostId,version:this.props.jsControllerInfo.version,onClose:()=>this.setState({updateDialog:!1}),adminInstance:this.props.adminInstance,onUpdating:t=>this.props.onUpdating(t),themeType:this.props.themeType}):this.state.instructionDialog?(0,b.jsx)(k,{socket:this.props.socket,hostId:this.props.hostId,version:this.props.jsControllerInfo.version,onClose:()=>this.setState({instructionDialog:!1})}):null}static extractNews(t,e){const s=t.split("\n");let o="",n=!1;for(let i=0;i<s.length;i++)if(s[i].startsWith("## ")){if(n)break;s[i].startsWith(`## ${e}`)&&(n=!0)}else n&&(o+=`${s[i].replace(/^\*\s*/,"").replace(/^\(\w+\)\s*/,"")}\n`);return o}getNews(t){const e=this.props.jsControllerInfo,s=this.props.host.common.installedVersion,o=[];return s&&null!==e&&void 0!==e&&e.news&&Object.keys(e.news).forEach((n=>{try{if(p().gt(n,s)||t){let t=!1,s=this.props.noTranslation?e.news[n].en:e.news[n][this.props.lang]||e.news[n].en;if("see CHANGELOG.md"===e.news[n].en&&this.state.changeLog){const e=lt.extractNews(this.state.changeLog,n);e&&(s=e,t=!0)}o.push({version:n,news:s,downloaded:t})}}catch{console.warn(`Cannot compare "${n}" and "${s}"`)}})),o}baseSettingsSettingsDialog(){return this.state.baseSettingsDialog?(0,b.jsx)(Z,{currentHost:this.props.hostId,themeType:this.props.themeType,currentHostName:this.props.host.common.name,onClose:()=>this.setState({baseSettingsDialog:!1}),lang:this.props.lang,socket:this.props.socket,t:this.props.t},"base"):null}renderEditObjectDialog(){return this.state.editDialog?(0,b.jsx)(et,{obj:this.props.host,t:this.props.t,onClose:t=>this.setState({editDialog:!1},(()=>{t&&this.props.socket.setObject(t._id,t).then((()=>this.forceUpdate())).catch((t=>alert(`Cannot write object: ${t}`)))}))}):null}renderDialogs(){return(0,b.jsxs)(b.Fragment,{children:[this.renderDialogLogLevel(),this.renderHostUpdateDialog(),this.renderUpdateDialog(),this.renderEditObjectDialog(),this.baseSettingsSettingsDialog()]})}}lt.formatInfo={Uptime:K.A.formatSeconds,"System uptime":K.A.formatSeconds,RAM:K.A.formatRam,Speed:K.A.formatSpeed,"Disk size":K.A.formatBytes,"Disk free":K.A.formatBytes};const ht={...it,root:t=>({position:"relative",m:"10px",width:300,minHeight:200,background:t.palette.background.default,boxShadow:ot,display:"flex",flexDirection:"column",transition:"box-shadow 0.5s","&:hover":{boxShadow:nt},"& .warning":{backgroundColor:"#de0000 !important","&:before":{position:"absolute",right:0,top:-5,content:'"\u26a0"',fontSize:25,height:"30px",width:"30px",color:"black"},animation:"$warning 2.5s ease-in-out infinite alternate"}}),imageBlock:{minHeight:60,display:"flex",padding:"0 10px 0 10px",position:"relative",justifyContent:"space-between",transition:"background 0.5s"},fab:{position:"absolute",bottom:-20,width:40,height:40,right:20},collapse:{height:"100%",position:"absolute",width:"100%",zIndex:3,marginTop:"auto",bottom:0,transition:"height 0.3s",justifyContent:"space-between",display:"flex",flexDirection:"column"},collapseOff:{height:0},close:{width:20,height:20,opacity:.9,cursor:"pointer",position:"relative",ml:"auto",mb:"10px",transition:"all 0.6s ease","&:hover":{transform:"rotate(90deg)"},"&:before":{position:"absolute",left:9,content:'""',height:20,width:3,backgroundColor:"#ff4f4f",transform:"rotate(45deg)"},"&:after":{position:"absolute",left:9,content:'""',height:20,width:3,backgroundColor:"#ff4f4f",transform:"rotate(-45deg)"}},onOffLine:{alignSelf:"center",width:"100%",height:4},adapter:t=>({width:"100%",fontWeight:"bold",fontSize:16,verticalAlign:"middle",pl:1,pt:2,color:"dark"===t.palette.mode?"#333":"#555"}),cardContentInfo:t=>({overflow:"auto",paddingTop:0,backgroundColor:t.palette.background.paper,color:"dark"===t.palette.mode?"#EEE":"#111"}),cardContentH5:{height:"100%",display:"flex",flexDirection:"column",justifyContent:"space-between",paddingBottom:"10px !important"},marginTop10:{marginTop:10},displayFlex:{display:"flex"},marginLeft5:{marginLeft:5},enableButton:{display:"flex",justifyContent:"space-between",alignItems:"center"},instanceStateNotAlive1:{backgroundColor:"rgba(192, 192, 192, 0.4)"},green:{background:"#00ce00",position:"relative"},red:{background:"#da0000"},dotLine:{width:50,height:"100%",background:"linear-gradient(90deg, rgba(0,206,0,0.7497373949579832) 0%, rgba(31,255,1,1) 50%, rgba(0,206,0,0.7805497198879552) 100%)",zIndex:2,position:"absolute",left:-11},versionDate:{alignSelf:"center"},cardContentDiv:{position:"sticky",right:0,top:0,paddingTop:10},badge:{cursor:"pointer"},curdContentFlexCenter:{display:"flex",alignItems:"center",ml:"4px"},marginRight:{marginRight:"auto"},ul:{paddingTop:0,paddingBottom:0,paddingLeft:16,paddingRight:8},value:{marginLeft:5},label:{fontWeight:"bold"}};const pt=class extends lt{getHostDescriptionAll(){return this.props.hostData?"string"===typeof this.props.hostData?this.props.hostData:this.props.hostData&&"object"===typeof this.props.hostData?(0,b.jsx)("ul",{style:ht.ul,children:Object.keys(this.props.hostData).map((t=>(0,b.jsx)("li",{children:(0,b.jsxs)("span",{style:ht.black,children:[(0,b.jsxs)("span",{style:ht.label,children:[this.props.t(t),": "]}),(0,b.jsx)("span",{style:ht.value,children:lt.formatInfo[t]?lt.formatInfo[t](this.props.hostData[t],this.props.t):this.props.hostData[t]||"--"})]})},t)))},"ul"):(0,b.jsx)("ul",{style:ht.ul,children:(0,b.jsx)(i.Skeleton,{})},"ul"):(0,b.jsx)(i.Skeleton,{})}render(){const t=(this.props.isCurrentHost||this.props.alive)&&K.A.updateAvailable(this.props.host.common.installedVersion,this.props.available),e=this.getHostDescriptionAll();return(0,b.jsxs)(i.Card,{sx:a.Utils.getStyle(this.props.theme,ht.root,this.props.hidden&&ht.hidden),children:[this.renderDialogs(),this.state.openCollapse&&(0,b.jsxs)("div",{style:{...ht.collapse,...this.state.openCollapse?void 0:ht.collapseOff},children:[(0,b.jsxs)(i.CardContent,{sx:ht.cardContentInfo,children:[(0,b.jsx)("div",{style:ht.cardContentDiv,onClick:()=>this.setState({openCollapse:!1}),children:(0,b.jsx)(i.Box,{component:"div",sx:ht.close,onClick:()=>this.setState({openCollapse:!1})})}),e]}),(0,b.jsx)(i.Box,{component:"div",sx:ht.footerBlock})]}),(0,b.jsx)("div",{style:{...ht.onOffLine,...this.props.alive?ht.green:ht.red},children:this.props.alive&&(0,b.jsx)("div",{style:ht.dotLine})}),(0,b.jsxs)("div",{ref:this.refWarning,style:{...ht.imageBlock,...this.props.alive?void 0:ht.instanceStateNotAlive1,background:this.props.host.common.color||"inherit"},children:[(0,b.jsx)(i.CardMedia,{sx:ht.img,component:"img",image:this.props.host.common.icon||"img/no-image.png"}),(0,b.jsx)(i.Box,{component:"div",style:a.Utils.getStyle(this.props.theme,ht.adapter,{color:this.props.host.common.color&&a.Utils.invertColor(this.props.host.common.color,!0)||"inherit"}),children:this.renderNotificationsBadge(this.props.host.common.name,!0)}),this.state.openCollapse?null:(0,b.jsx)(i.Fab,{disabled:"string"===typeof e,onClick:()=>this.setState({openCollapse:!0}),style:ht.fab,color:"primary","aria-label":"add",title:this.props.t("Click for more"),children:(0,b.jsx)(r.MoreVert,{})})]}),(0,b.jsxs)(i.CardContent,{style:ht.cardContentH5,children:[(0,b.jsx)(i.Typography,{variant:"body2",color:"textSecondary",component:"div",children:(0,b.jsxs)("div",{style:ht.displayFlex,children:[(0,b.jsx)("span",{style:ht.label,children:"CPU:"}),(0,b.jsx)("div",{ref:this.refCpu,style:ht.value,children:"- %"})]})}),(0,b.jsx)(i.Typography,{variant:"body2",color:"textSecondary",component:"div",children:(0,b.jsxs)("div",{style:ht.displayFlex,children:[(0,b.jsx)("span",{style:ht.label,children:"RAM:"}),(0,b.jsx)("div",{ref:this.refMem,style:ht.value,children:"- %"})]})}),(0,b.jsx)(i.Typography,{variant:"body2",color:"textSecondary",component:"div",children:(0,b.jsxs)("div",{style:ht.displayFlex,children:[(0,b.jsxs)("span",{style:ht.label,children:[this.props.t("Uptime"),":"]}),(0,b.jsx)("div",{ref:this.refUptime,style:ht.value,children:"-d -h"})]})}),(0,b.jsxs)(i.Typography,{variant:"body2",color:"textSecondary",component:"div",style:ht.wrapperAvailable,children:[(0,b.jsxs)("span",{style:ht.label,children:[this.props.t("Available")," js-controller:"]}),(0,b.jsx)(i.Box,{component:"div",sx:{...t?ht.greenText:void 0,...ht.curdContentFlexCenter},children:this.renderUpdateButton(t)})]}),(0,b.jsxs)(i.Typography,{variant:"body2",color:"textSecondary",component:"p",children:[(0,b.jsxs)("span",{style:ht.label,children:[this.props.t("Installed")," js-controller:"]}),(0,b.jsx)("span",{style:ht.value,children:this.props.host.common.installedVersion})]}),(0,b.jsx)(i.Typography,{variant:"body2",color:"textSecondary",component:"div",children:(0,b.jsxs)("div",{style:ht.displayFlex,children:[(0,b.jsxs)("span",{style:ht.label,children:[this.props.t("Events"),":"]}),(0,b.jsx)("div",{ref:this.refEvents,style:ht.value,children:"- / -"})]})}),(0,b.jsx)("div",{style:ht.marginTop10,children:(0,b.jsxs)(i.Typography,{component:"span",style:ht.enableButton,children:[this.renderEditButton(),this.renderHostBaseEdit(),this.renderRestartButton(),this.props.expertMode&&this.state.logLevel&&this.renderLogLevel(),this.renderRemoveButton(),this.renderCopyButton()]})})]})]},this.props.hostId)}},dt={...it,root:t=>({position:"relative",m:"7px",background:t.palette.background.default,boxShadow:ot,overflow:"hidden",transition:"box-shadow 0.5s,height 0.3s","&:hover":{boxShadow:nt}}),imageBlock:{marginRight:6,minHeight:60,width:"100%",maxWidth:300,display:"flex",padding:"0 10px 0 10px",position:"relative",justifyContent:"space-between",transition:"background 0.5s",alignItems:"baseline"},collapse:{height:200,backgroundColor:"rgba(128, 128, 128, 0.1)",width:"100%",zIndex:3,marginTop:"auto",bottom:0,transition:"height 0.3s",justifyContent:"space-between",display:"flex",flexDirection:"column"},collapseOn:{animation:"height 1s"},onOff:{alignSelf:"center",width:4,height:"100%"},host:t=>({width:"100%",fontWeight:"bold",fontSize:16,paddingLeft:"8px",alignSelf:"center",color:"dark"===t.palette.mode?"#ddd":"#222",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}),cardContentH5:{height:"100%",display:"flex",width:"100%",justifyContent:"space-between",padding:"10px !important",alignItems:"center"},marginTop10:{marginLeft:"auto",display:"flex"},enableButton:{display:"flex",justifyContent:"space-between"},green:{background:"#00ce00",position:"relative",overflow:"hidden"},dotLine:{width:10,height:20,background:"linear-gradient( rgba(0,206,0,0.7497373949579832) 0%, rgba(31,255,1,1) 50%, rgba(0,206,0,0.7805497198879552) 100%)",zIndex:2,position:"absolute",top:-21},red:{background:"#da0000"},flex:{flex:1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},cardContentInfo:{overflow:"auto",paddingTop:0,justifyContent:"center",display:"flex",height:"100%",position:"relative"},cursorNoDrop:{cursor:"no-drop !important"},wrapperFlex:{display:"flex",cursor:"pointer","& .warning":{backgroundColor:"#de0000 !important","&:before":{position:"absolute",right:0,top:-5,content:'"\u26a0"',fontSize:25,height:"30px",width:"30px",color:"black"},animation:"$warning 2.5s ease-in-out infinite alternate"},"@media screen and (max-width: 500px)":{flexDirection:"column"}},wrapperColor:{position:"relative",overflow:"hidden"},hidden1100:{"@media screen and (max-width: 1100px)":{display:"none !important"}},hidden800:{"@media screen and (max-width: 800px)":{display:"none !important"}},hidden600:{"@media screen and (max-width: 600px)":{display:"none !important"}},badge:{top:14},curdContentFlexCenter:{display:"flex",alignItems:"center"},wrapperInfo:{display:"flex",flexFlow:"wrap",width:"100%",justifyContent:"space-around"},wrapperBlockItem:{display:"flex",flexFlow:"nowrap",whiteSpace:"nowrap",margin:10},bold:{fontWeight:"bold"},nowrap:{display:"flex",flexFlow:"nowrap",flex:1,whiteSpace:"nowrap",marginRight:5},cell:{}};const ct=class extends lt{renderValue(t){return"object"!==typeof this.props.hostData?null:(0,b.jsxs)("div",{style:dt.wrapperBlockItem,children:[(0,b.jsxs)("span",{style:{...dt.bold,...dt.nowrap},children:[this.props.t(t),": "]}),lt.formatInfo[t]?lt.formatInfo[t](this.props.hostData[t],this.props.t):this.props.hostData[t]||"--"]},t)}getHostDescriptionAll(){return this.props.hostData?"string"===typeof this.props.hostData?this.props.hostData:(0,b.jsxs)("div",{style:dt.wrapperInfo,children:[(0,b.jsx)("div",{style:dt.marginRight,children:this.props.hostData&&"object"===typeof this.props.hostData?Object.keys(this.props.hostData).map(((t,e)=>e<5&&this.renderValue(t))):(0,b.jsx)(i.Skeleton,{})}),(0,b.jsx)("div",{style:dt.marginRight,children:this.props.hostData&&"object"===typeof this.props.hostData?Object.keys(this.props.hostData).map(((t,e)=>e>4&&e<10&&this.renderValue(t))):(0,b.jsx)(i.Skeleton,{})}),(0,b.jsx)("div",{style:dt.marginRight,children:this.props.hostData&&"object"===typeof this.props.hostData&&Object.keys(this.props.hostData).map(((t,e)=>e>10&&this.renderValue(t)))})]}):(0,b.jsx)(i.Skeleton,{})}render(){const t=(this.props.isCurrentHost||this.props.alive)&&K.A.updateAvailable(this.props.host.common.installedVersion,this.props.available),e=this.getHostDescriptionAll();return(0,b.jsxs)(i.Box,{component:"div",sx:a.Utils.getStyle(this.props.theme,dt.root,this.props.hidden&&dt.hidden,{border:`2px solid ${this.props.host.common.color||"inherit"}`,borderRadius:"5px"}),children:[this.renderDialogs(),(0,b.jsxs)(i.Box,{component:"div",sx:{...dt.wrapperFlex,...this.props.alive?void 0:dt.cursorNoDrop},onClick:this.state.openDialogLogLevel?null:()=>this.setState({openCollapse:!this.state.openCollapse}),children:[(0,b.jsxs)("div",{style:dt.wrapperColor,children:[(0,b.jsx)("div",{style:{...dt.onOff,...this.props.alive?dt.green:dt.red}}),this.props.alive&&(0,b.jsx)("div",{style:dt.dotLine})]}),(0,b.jsxs)("div",{ref:this.refWarning,style:{...dt.imageBlock,background:this.props.host.common.color||"inherit"},children:[this.renderNotificationsBadge((0,b.jsx)(i.CardMedia,{sx:dt.img,component:"img",image:this.props.host.common.icon||"img/no-image.png"}),!0),(0,b.jsx)("div",{style:a.Utils.getStyle(this.props.theme,dt.host,{color:this.props.host.common.color&&a.Utils.invertColor(this.props.host.common.color,!0)||"inherit"}),children:this.props.host.common.name})]}),(0,b.jsxs)(i.CardContent,{sx:{"&.MuiCardContent-root":dt.cardContentH5},children:[(0,b.jsx)(i.Typography,{sx:{...dt.flex,...dt.hidden800,...dt.cell},variant:"body2",color:"textSecondary",component:"div",children:(0,b.jsx)("div",{ref:this.refCpu,children:"- %"})}),(0,b.jsx)(i.Typography,{sx:{...dt.flex,...dt.hidden800,...dt.cell},variant:"body2",color:"textSecondary",component:"div",children:(0,b.jsx)("div",{ref:this.refMem,children:"- %"})}),(0,b.jsx)(i.Typography,{sx:{...dt.flex,...dt.hidden800,...dt.cell},variant:"body2",color:"textSecondary",component:"div",children:(0,b.jsx)("div",{ref:this.refUptime,children:"-/-"})}),(0,b.jsx)(i.Typography,{sx:{...dt.flex,...dt.hidden1100},variant:"body2",color:"textSecondary",component:"p",children:this.props.host.common.installedVersion}),(0,b.jsx)(i.Typography,{sx:{...dt.flex,...dt.hidden1100,...dt.cell},variant:"body2",color:"textSecondary",component:"div",children:(0,b.jsx)(i.Box,{component:"div",sx:{...t?dt.greenText:void 0,...dt.curdContentFlexCenter},children:this.renderUpdateButton(t)})}),(0,b.jsx)(i.Typography,{sx:{...dt.flex,...dt.hidden600,...dt.cell},variant:"body2",color:"textSecondary",component:"div",children:(0,b.jsx)("div",{ref:this.refEvents,children:"- / -"})}),(0,b.jsx)("div",{style:dt.marginTop10,children:(0,b.jsxs)(i.Typography,{component:"span",style:dt.enableButton,children:[this.renderEditButton(),this.renderHostBaseEdit(),this.renderRestartButton(),this.props.expertMode&&this.state.logLevel?this.renderLogLevel():(0,b.jsx)("div",{style:dt.emptyButton}),this.renderRemoveButton(),this.renderExtendButton(this.state.openCollapse)]})})]})]}),"object"===typeof e&&(0,b.jsxs)("div",{style:{...dt.collapse,...this.state.openCollapse?dt.collapseOn:dt.collapseOff},onClick:t=>t.stopPropagation(),children:[(0,b.jsxs)(i.CardContent,{style:dt.cardContentInfo,children:[e,this.renderCopyButton({height:44,width:44})]}),(0,b.jsx)(i.Box,{component:"div",sx:dt.footerBlock})]})]},this.props.hostId)}},ut={grow:{flexGrow:1},cards:{display:"flex",flexFlow:"wrap",justifyContent:"center"},tabHeaderWrapper:{height:30,display:"flex",margin:7},tabHeaderFirstItem:{width:306,paddingLeft:30,fontSize:14,fontWeight:600,alignSelf:"center"},tabHeaderItem:{flex:1,fontSize:14,fontWeight:600,alignSelf:"center"},tabHeaderItemButton:{fontSize:14,fontWeight:600,alignSelf:"center"},widthButtons:{width:240},tabFlex:{display:"flex",flex:1,padding:"0 10px"},bold:{fontWeight:"bold"},marginRight:{marginRight:"auto"},notStableRepo:t=>({background:"dark"===t.palette.mode?"#8a7e00":"#fdee20",color:"#000",fontSize:14,padding:"2px 8px",borderRadius:"5px"}),hidden1100:{"@media screen and (max-width: 1100px)":{display:"none !important"}},hidden800:{"@media screen and (max-width: 800px)":{display:"none !important"}},hidden600:{"@media screen and (max-width: 600px)":{display:"none !important"}},jsController:{fontSize:12,opacity:.4,display:"block"},tooltip:{pointerEvents:"none"}},mt={};function xt(t){var e;if(null!==(e=t.dockerInformation)&&void 0!==e&&e.isDocker){let e=t.dockerInformation.isOfficial?"official image":"unofficial image";t.dockerInformation.isOfficial&&(e+=` - ${t.dockerInformation.officialVersion}`),t.Platform=`${t.Platform} (${e})`}delete t.dockerInformation}class gt extends o.Component{constructor(t){super(t),this.t=(t,e,s)=>(void 0===e||void 0===s||mt[`${t} ${e} ${s}`]?void 0===e||mt[`${t} ${e}`]?mt[t]||(mt[t]=this.props.t(t)):mt[`${t} ${e}`]=this.props.t(t,e):mt[`${t} ${e} ${s}`]=this.props.t(t,e,s),void 0!==e&&void 0!==s?mt[`${t} ${e} ${s}`]:void 0!==e?mt[`${t} ${e}`]:mt[t]),this.updateHosts=t=>{const e=JSON.parse(JSON.stringify(this.state.hosts)),s=JSON.parse(JSON.stringify(this.state.alive));Promise.all(t.map((async t=>{const o=e.find((e=>e._id===t.id));if(o){const s=e.indexOf(o);t.obj?e[s]=t.obj:e.splice(s,1)}else{const o=await this.props.socket.getState(`${t.id}.alive`);s[t.id]=!(null===o||void 0===o||!o.val),e.push(t.obj)}}))).then((()=>{const t={hosts:e,alive:s};this.state.filterText&&e.length<=2&&(t.filterText=""),this.setState(t)}))},this.updateHostsAlive=t=>{const e=JSON.parse(JSON.stringify(this.state.alive));let s=!1;t.forEach((t=>{"deleted"===t.type?void 0!==e[t.id]&&(delete e[t.id],s=!0):!!e[t.id]!==!!t.alive&&(e[t.id]=t.alive,s=!0)})),s&&this.setState({alive:e})},this.state={viewMode:"true"===(window._localStorage||window.localStorage).getItem("Hosts.viewMode"),alive:{},hosts:[],repository:{},hostsData:{},filterText:(window._localStorage||window.localStorage).getItem("Hosts.filterText")||"",showSlowConnectionWarning:!1,readTimeoutMs:l.o.getReadTimeoutMs()}}componentDidMount(){this.readInfo().then((()=>{this.props.hostsWorker.registerHandler(this.updateHosts),this.props.hostsWorker.registerAliveHandler(this.updateHostsAlive)}))}componentWillUnmount(){this.props.hostsWorker.unregisterHandler(this.updateHosts),this.props.hostsWorker.unregisterAliveHandler(this.updateHostsAlive)}getHostsData(t,e){const s=[];for(let o=0;o<t.length;o++)if(e[t[o]._id]){const e=this.props.socket.getHostInfo(t[o]._id,null,this.state.readTimeoutMs).catch((e=>(console.error(`Cannot get getHostInfo: ${e}`),e.toString().includes("timeout")&&this.setState({showSlowConnectionWarning:!0}),{id:t[o]._id,data:e.toString()}))).then((e=>(xt(e),{id:t[o]._id,data:e})));s.push(e)}else s.push(Promise.resolve({id:t[o]._id,data:"offline"}));return Promise.all(s).then((t=>{const e={};return t.forEach((t=>e[t.id]=t.data)),e}))}readInfo(){return this.props.socket.getHosts(!0).then((t=>this.props.socket.getRepository(this.props.currentHost,{update:!1},!1,this.state.readTimeoutMs).then((async e=>{const s=JSON.parse(JSON.stringify(this.state.alive));for(let i=0;i<t.length;i++){const e=await this.props.socket.getState(`${t[i]._id}.alive`);s[t[i]._id]=!!e&&!!e.val}const o=await this.getHostsData(t,s),n={alive:s,hosts:t,hostsData:o,repository:e};this.state.filterText&&t.length<=2&&(n.filterText=""),this.setState(n)})).catch((t=>{window.alert(`Cannot getRepository: ${t}`),t.toString().includes("timeout")&&this.setState({showSlowConnectionWarning:!0})}))))}getPanelsOrRows(){const t=this.renderHosts().filter((t=>t));return t.length?t:this.t("All items are filtered out")}renderSlowConnectionWarning(){return this.state.showSlowConnectionWarning?(0,b.jsx)(l.A,{readTimeoutMs:this.state.readTimeoutMs,t:this.t,onClose:async t=>{this.setState({showSlowConnectionWarning:!1}),t&&(this.setState({readTimeoutMs:t}),await this.readInfo())}}):null}renderHosts(){return this.state.hosts.map((t=>{var e;if(this.state.filterText&&!t.common.name.toLowerCase().includes(this.state.filterText.toLowerCase()))return null;const s=this.state.viewMode?pt:ct;return(0,b.jsx)(s,{adminInstance:this.props.adminInstance,alive:this.state.alive[t._id],available:(null===(e=this.state.repository["js-controller"])||void 0===e?void 0:e.version)||"-",executeCommandRemove:()=>this.props.executeCommand(`host remove ${t.common.name}`),expertMode:this.props.expertMode,host:t,hostData:this.state.hostsData[t._id],hostId:t._id,hostsWorker:this.props.hostsWorker,isCurrentHost:this.props.currentHost===t._id,jsControllerInfo:this.state.repository["js-controller"],lang:this.props.lang,noTranslation:this.props.noTranslation,onUpdating:this.props.onUpdating,showAdaptersWarning:this.props.showAdaptersWarning,socket:this.props.socket,systemConfig:this.props.systemConfig,t:this.t,theme:this.props.theme,themeType:this.props.themeType,toggleTranslation:this.props.toggleTranslation},t._id)}))}renderTableHeader(){return(0,b.jsxs)("div",{style:ut.tabHeaderWrapper,children:[(0,b.jsx)("div",{style:ut.tabHeaderFirstItem,children:this.t("Name:")}),(0,b.jsxs)("div",{style:ut.tabFlex,children:[(0,b.jsx)(i.Box,{component:"div",sx:a.Utils.getStyle(this.props.theme,ut.tabHeaderItem,ut.hidden800),children:"CPU"}),(0,b.jsx)(i.Box,{component:"div",sx:a.Utils.getStyle(this.props.theme,ut.tabHeaderItem,ut.hidden800),children:"RAM"}),(0,b.jsx)(i.Box,{component:"div",sx:a.Utils.getStyle(this.props.theme,ut.tabHeaderItem,ut.hidden800),children:this.t("Uptime")}),(0,b.jsxs)(i.Box,{component:"div",sx:a.Utils.getStyle(this.props.theme,ut.tabHeaderItem,ut.hidden1100),children:[this.t("Installed"),(0,b.jsx)("div",{style:ut.jsController,children:"js-controller"})]}),(0,b.jsxs)(i.Box,{component:"div",sx:a.Utils.getStyle(this.props.theme,ut.tabHeaderItem,ut.hidden1100),children:[this.t("Available"),(0,b.jsx)("div",{style:ut.jsController,children:"js-controller"})]}),(0,b.jsx)(i.Box,{component:"div",sx:a.Utils.getStyle(this.props.theme,ut.tabHeaderItem,ut.hidden600),children:this.t("Events")}),(0,b.jsx)("div",{style:{...ut.tabHeaderItemButton,width:this.props.expertMode?292:244}})]})]})}render(){return this.state.hosts.length?(0,b.jsxs)(a.TabContainer,{children:[(0,b.jsx)("style",{children:"\n @keyframes newValueAnimationHostDark {\n 0% {\n color: #00f900;\n }\n 80% {\n color: #008000;\n }\n 100% {\n color: #fff;\n }\n }\n @keyframes newValueAnimationHostLight {\n 0% {\n color: #00f900;\n }\n 80% {\n color: #008000;\n }\n 100% {\n color: #fff;\n }\n }\n .newValueHost-dark {\n animation: newValueAnimationHostDark 2s ease-in-out;\n }\n .newValueHost-light {\n animation: newValueAnimationHostLight 2s ease-in-out;\n }\n @keyframes colors {\n 0% {\n left: -51px;\n }\n 100% {\n left: 101%;\n }\n }\n @keyframes warning {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0.7;\n }\n }\n @keyframes red {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0.8;\n }\n }\n @keyframes onBlink-keys-dark {\n 0% {\n color: #264d72;\n }\n 80% {\n color: #3679be;\n }\n 100% {\n color: #fff;\n }\n }\n @keyframes onBlink-keys-light {\n 0% {\n color: #3679be;\n }\n 80% {\n color: #264d72;\n }\n 100% {\n color: #000;\n }\n }\n .onBlick-light {\n animation: onBlink-keys-light 2s ease-in-out;\n animation-iteration-count: 2;\n font-size: 12px;\n margin-left: 4px;\n }\n .onBlick-dark {\n animation: onBlink-keys-dark 2s ease-in-out;\n animation-iteration-count: 2;\n font-size: 12px;\n margin-left: 4px;\n }\n @keyframes height {\n 0% {\n height: 0;\n },\n 100% {\n height: 160px;\n }\n }\n"}),this.renderSlowConnectionWarning(),(0,b.jsxs)(a.TabHeader,{children:[(0,b.jsx)(i.Tooltip,{title:this.t("Show / hide List"),slotProps:{popper:{sx:ut.tooltip}},children:(0,b.jsx)(i.IconButton,{size:"large",onClick:()=>{(window._localStorage||window.localStorage).setItem("Hosts.viewMode",this.state.viewMode?"false":"true"),this.setState({viewMode:!this.state.viewMode})},children:this.state.viewMode?(0,b.jsx)(r.ViewModule,{}):(0,b.jsx)(r.ViewList,{})})}),(0,b.jsx)(i.Tooltip,{title:this.t("Reload"),slotProps:{popper:{sx:ut.tooltip}},children:(0,b.jsx)(i.IconButton,{size:"large",onClick:()=>this.forceUpdate(),children:(0,b.jsx)(r.Refresh,{})})}),(0,b.jsx)("div",{style:ut.grow}),this.state.hosts.length>2?(0,b.jsx)(i.TextField,{variant:"standard",label:this.t("Filter"),style:{margin:"5px 0"},value:this.state.filterText,onChange:t=>{(window._localStorage||window.localStorage).setItem("Hosts.viewMode",t.target.value),this.setState({filterText:t.target.value})},slotProps:{input:{endAdornment:this.state.filterText?(0,b.jsx)(i.InputAdornment,{position:"end",children:(0,b.jsx)(i.IconButton,{size:"small",onClick:()=>{(window._localStorage||window.localStorage).setItem("Hosts.viewMode",""),this.setState({filterText:""})},children:(0,b.jsx)(r.Close,{})})}):null}}}):null,(0,b.jsx)("div",{style:ut.grow})]}),(0,b.jsxs)(a.TabContent,{overflow:"auto",children:[a.Utils.isStableRepository(this.props.systemConfig.common.activeRepo)?null:(0,b.jsx)(i.Box,{component:"div",sx:ut.notStableRepo,children:this.t('Active repo is "%s"',this.props.systemConfig.common.activeRepo)}),(0,b.jsxs)("div",{style:this.state.viewMode?ut.cards:void 0,children:[!this.state.viewMode&&this.renderTableHeader(),this.getPanelsOrRows()]})]})]}):(0,b.jsx)(i.LinearProgress,{})}}const ft=(0,a.withWidth)()(gt)}}]);
|
|
2
|
+
//# sourceMappingURL=8038.64137a64.chunk.js.map
|