iobroker.modbus 7.0.3 → 7.0.4
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
CHANGED
|
@@ -315,8 +315,9 @@ There are some programs in folder `test` to test the TCP communication:
|
|
|
315
315
|
### **WORK IN PROGRESS**
|
|
316
316
|
-->
|
|
317
317
|
## Changelog
|
|
318
|
-
### 7.0.
|
|
318
|
+
### 7.0.4 (2025-10-08)
|
|
319
319
|
* (bluefox) Added migration procedure from 6 to 7
|
|
320
|
+
* (bluefox) Corrected serial communication
|
|
320
321
|
|
|
321
322
|
### 7.0.1 (2025-10-07)
|
|
322
323
|
* (bluefox) Redesign of the configuration tabs
|
|
@@ -2606,7 +2606,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
2606
2606
|
`,"autocompletion.css",!1),M.AcePopup=n1,M.$singleLineEditor=s1,M.getAriaId=k}),ace.define("ace/autocomplete/inline_screenreader",["require","exports","module"],function(e,M,j){var z=(function(){function E(N){this.editor=N,this.screenReaderDiv=document.createElement("div"),this.screenReaderDiv.classList.add("ace_screenreader-only"),this.editor.container.appendChild(this.screenReaderDiv)}return E.prototype.setScreenReaderContent=function(N){for(!this.popup&&this.editor.completer&&this.editor.completer.popup&&(this.popup=this.editor.completer.popup,this.popup.renderer.on("afterRender",(function(){var O=this.popup.getRow(),H=this.popup.renderer.$textLayer,A=H.element.childNodes[O-H.config.firstRow];if(A){for(var _="doc-tooltip ",k=0;k<this._lines.length;k++)_+="ace-inline-screenreader-line-".concat(k," ");A.setAttribute("aria-describedby",_)}}).bind(this)));this.screenReaderDiv.firstChild;)this.screenReaderDiv.removeChild(this.screenReaderDiv.firstChild);this._lines=N.split(/\r\n|\r|\n/);var R=this.createCodeBlock();this.screenReaderDiv.appendChild(R)},E.prototype.destroy=function(){this.screenReaderDiv.remove()},E.prototype.createCodeBlock=function(){var N=document.createElement("pre");N.setAttribute("id","ace-inline-screenreader");for(var R=0;R<this._lines.length;R++){var O=document.createElement("code");O.setAttribute("id","ace-inline-screenreader-line-".concat(R));var H=document.createTextNode(this._lines[R]);O.appendChild(H),N.appendChild(O)}return N},E})();M.AceInlineScreenReader=z}),ace.define("ace/autocomplete/inline",["require","exports","module","ace/snippets","ace/autocomplete/inline_screenreader"],function(e,M,j){var z=e("../snippets").snippetManager,E=e("./inline_screenreader").AceInlineScreenReader,N=(function(){function R(){this.editor=null}return R.prototype.show=function(O,H,A){if(A=A||"",O&&this.editor&&this.editor!==O&&(this.hide(),this.editor=null,this.inlineScreenReader=null),!O||!H)return!1;this.inlineScreenReader||(this.inlineScreenReader=new E(O));var _=H.snippet?z.getDisplayTextForSnippet(O,H.snippet):H.value;return H.hideInlinePreview||!_||!_.startsWith(A)?!1:(this.editor=O,this.inlineScreenReader.setScreenReaderContent(_),_=_.slice(A.length),_===""?O.removeGhostText():O.setGhostText(_),!0)},R.prototype.isOpen=function(){return this.editor?!!this.editor.renderer.$ghostText:!1},R.prototype.hide=function(){return this.editor?(this.editor.removeGhostText(),!0):!1},R.prototype.destroy=function(){this.hide(),this.editor=null,this.inlineScreenReader&&(this.inlineScreenReader.destroy(),this.inlineScreenReader=null)},R})();M.AceInline=N}),ace.define("ace/autocomplete/util",["require","exports","module"],function(e,M,j){M.parForEach=function(E,N,R){var O=0,H=E.length;H===0&&R();for(var A=0;A<H;A++)N(E[A],function(_,k){O++,O===H&&R(_,k)})};var z=/[a-zA-Z_0-9\$\-\u00A2-\u2000\u2070-\uFFFF]/;M.retrievePrecedingIdentifier=function(E,N,R){R=R||z;for(var O=[],H=N-1;H>=0&&R.test(E[H]);H--)O.push(E[H]);return O.reverse().join("")},M.retrieveFollowingIdentifier=function(E,N,R){R=R||z;for(var O=[],H=N;H<E.length&&R.test(E[H]);H++)O.push(E[H]);return O},M.getCompletionPrefix=function(E){var N=E.getCursorPosition(),R=E.session.getLine(N.row),O;return E.completers.forEach((function(H){H.identifierRegexps&&H.identifierRegexps.forEach((function(A){!O&&A&&(O=this.retrievePrecedingIdentifier(R,N.column,A))}).bind(this))}).bind(this)),O||this.retrievePrecedingIdentifier(R,N.column)},M.triggerAutocomplete=function(E,R){var R=R??E.session.getPrecedingCharacter();return E.completers.some(function(O){if(O.triggerCharacters&&Array.isArray(O.triggerCharacters))return O.triggerCharacters.includes(R)})}}),ace.define("ace/autocomplete",["require","exports","module","ace/keyboard/hash_handler","ace/autocomplete/popup","ace/autocomplete/inline","ace/autocomplete/popup","ace/autocomplete/util","ace/lib/lang","ace/lib/dom","ace/snippets","ace/config","ace/lib/event","ace/lib/scroll"],function(e,M,j){var z=e("./keyboard/hash_handler").HashHandler,E=e("./autocomplete/popup").AcePopup,N=e("./autocomplete/inline").AceInline,R=e("./autocomplete/popup").getAriaId,O=e("./autocomplete/util"),H=e("./lib/lang"),A=e("./lib/dom"),_=e("./snippets").snippetManager,k=e("./config"),P=e("./lib/event"),B=e("./lib/scroll").preventParentScroll,e1=function(c1,r1){r1.completer&&r1.completer.destroy()},s1=(function(){function c1(){this.autoInsert=!1,this.autoSelect=!0,this.autoShown=!1,this.exactMatch=!1,this.inlineEnabled=!1,this.keyboardHandler=new z,this.keyboardHandler.bindKeys(this.commands),this.parentNode=null,this.setSelectOnHover=!1,this.hasSeen=new Set,this.showLoadingState=!1,this.stickySelectionDelay=500,this.blurListener=this.blurListener.bind(this),this.changeListener=this.changeListener.bind(this),this.mousedownListener=this.mousedownListener.bind(this),this.mousewheelListener=this.mousewheelListener.bind(this),this.onLayoutChange=this.onLayoutChange.bind(this),this.changeTimer=H.delayedCall((function(){this.updateCompletions(!0)}).bind(this)),this.tooltipTimer=H.delayedCall(this.updateDocTooltip.bind(this),50),this.popupTimer=H.delayedCall(this.$updatePopupPosition.bind(this),50),this.stickySelectionTimer=H.delayedCall((function(){this.stickySelection=!0}).bind(this),this.stickySelectionDelay),this.$firstOpenTimer=H.delayedCall((function(){var r1=this.completionProvider&&this.completionProvider.initialPosition;this.autoShown||this.popup&&this.popup.isOpen||!r1||this.editor.completers.length===0||(this.completions=new l1(c1.completionsForLoading),this.openPopup(this.editor,r1.prefix,!1),this.popup.renderer.setStyle("ace_loading",!0))}).bind(this),this.stickySelectionDelay)}return Object.defineProperty(c1,"completionsForLoading",{get:function(){return[{caption:k.nls("autocomplete.loading","Loading..."),value:""}]},enumerable:!1,configurable:!0}),c1.prototype.$init=function(){return this.popup=new E(this.parentNode||document.body||document.documentElement),this.popup.on("click",(function(r1){this.insertMatch(),r1.stop()}).bind(this)),this.popup.focus=this.editor.focus.bind(this.editor),this.popup.on("show",this.$onPopupShow.bind(this)),this.popup.on("hide",this.$onHidePopup.bind(this)),this.popup.on("select",this.$onPopupChange.bind(this)),P.addListener(this.popup.container,"mouseout",this.mouseOutListener.bind(this)),this.popup.on("changeHoverMarker",this.tooltipTimer.bind(null,null)),this.popup.renderer.on("afterRender",this.$onPopupRender.bind(this)),this.popup},c1.prototype.$initInline=function(){if(!(!this.inlineEnabled||this.inlineRenderer))return this.inlineRenderer=new N,this.inlineRenderer},c1.prototype.getPopup=function(){return this.popup||this.$init()},c1.prototype.$onHidePopup=function(){this.inlineRenderer&&this.inlineRenderer.hide(),this.hideDocTooltip(),this.stickySelectionTimer.cancel(),this.popupTimer.cancel(),this.stickySelection=!1},c1.prototype.$seen=function(r1){!this.hasSeen.has(r1)&&r1&&r1.completer&&r1.completer.onSeen&&typeof r1.completer.onSeen=="function"&&(r1.completer.onSeen(this.editor,r1),this.hasSeen.add(r1))},c1.prototype.$onPopupChange=function(r1){if(this.inlineRenderer&&this.inlineEnabled){var o1=r1?null:this.popup.getData(this.popup.getRow());if(this.$updateGhostText(o1),this.popup.isMouseOver&&this.setSelectOnHover){this.tooltipTimer.call(null,null);return}this.popupTimer.schedule(),this.tooltipTimer.schedule()}else this.popupTimer.call(null,null),this.tooltipTimer.call(null,null)},c1.prototype.$updateGhostText=function(r1){var o1=this.base.row,a1=this.base.column,m1=this.editor.getCursorPosition().column,M1=this.editor.session.getLine(o1).slice(a1,m1);this.inlineRenderer.show(this.editor,r1,M1)?this.$seen(r1):this.inlineRenderer.hide()},c1.prototype.$onPopupRender=function(){var r1=this.inlineRenderer&&this.inlineEnabled;if(this.completions&&this.completions.filtered&&this.completions.filtered.length>0)for(var o1=this.popup.getFirstVisibleRow();o1<=this.popup.getLastVisibleRow();o1++){var a1=this.popup.getData(o1);a1&&(!r1||a1.hideInlinePreview)&&this.$seen(a1)}},c1.prototype.$onPopupShow=function(r1){this.$onPopupChange(r1),this.stickySelection=!1,this.stickySelectionDelay>=0&&this.stickySelectionTimer.schedule(this.stickySelectionDelay)},c1.prototype.observeLayoutChanges=function(){if(!(this.$elements||!this.editor)){window.addEventListener("resize",this.onLayoutChange,{passive:!0}),window.addEventListener("wheel",this.mousewheelListener);for(var r1=this.editor.container.parentNode,o1=[];r1;)o1.push(r1),r1.addEventListener("scroll",this.onLayoutChange,{passive:!0}),r1=r1.parentNode;this.$elements=o1}},c1.prototype.unObserveLayoutChanges=function(){var r1=this;window.removeEventListener("resize",this.onLayoutChange,{passive:!0}),window.removeEventListener("wheel",this.mousewheelListener),this.$elements&&this.$elements.forEach(function(o1){o1.removeEventListener("scroll",r1.onLayoutChange,{passive:!0})}),this.$elements=null},c1.prototype.onLayoutChange=function(){if(!this.popup.isOpen)return this.unObserveLayoutChanges();this.$updatePopupPosition(),this.updateDocTooltip()},c1.prototype.$updatePopupPosition=function(){var r1=this.editor,o1=r1.renderer,a1=o1.layerConfig.lineHeight,m1=o1.$cursorLayer.getPixelPosition(this.base,!0);m1.left-=this.popup.getTextLeftOffset();var M1=r1.container.getBoundingClientRect();m1.top+=M1.top-o1.layerConfig.offset,m1.left+=M1.left-r1.renderer.scrollLeft,m1.left+=o1.gutterWidth;var h1={top:m1.top,left:m1.left};o1.$ghostText&&o1.$ghostTextWidget&&this.base.row===o1.$ghostText.position.row&&(h1.top+=o1.$ghostTextWidget.el.offsetHeight);var g1=r1.container.getBoundingClientRect().bottom-a1,d1=g1<h1.top?{top:g1,left:h1.left}:h1;this.popup.tryShow(d1,a1,"bottom")||this.popup.tryShow(m1,a1,"top")||this.popup.show(m1,a1)},c1.prototype.openPopup=function(r1,o1,a1){this.$firstOpenTimer.cancel(),this.popup||this.$init(),this.inlineEnabled&&!this.inlineRenderer&&this.$initInline(),this.popup.autoSelect=this.autoSelect,this.popup.setSelectOnHover(this.setSelectOnHover);var m1=this.popup.getRow(),M1=this.popup.data[m1];this.popup.setData(this.completions.filtered,this.completions.filterText),this.editor.textInput.setAriaOptions&&this.editor.textInput.setAriaOptions({activeDescendant:R(this.popup.getRow()),inline:this.inlineEnabled}),r1.keyBinding.addKeyboardHandler(this.keyboardHandler);var h1;this.stickySelection&&(h1=this.popup.data.indexOf(M1)),(!h1||h1===-1)&&(h1=0),this.popup.setRow(this.autoSelect?h1:-1),h1===m1&&M1!==this.completions.filtered[h1]&&this.$onPopupChange();var g1=this.inlineRenderer&&this.inlineEnabled;if(h1===m1&&g1){var d1=this.popup.getData(this.popup.getRow());this.$updateGhostText(d1)}a1||(this.popup.setTheme(r1.getTheme()),this.popup.setFontSize(r1.getFontSize()),this.$updatePopupPosition(),this.tooltipNode&&this.updateDocTooltip()),this.changeTimer.cancel(),this.observeLayoutChanges()},c1.prototype.detach=function(){this.editor&&(this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler),this.editor.off("changeSelection",this.changeListener),this.editor.off("blur",this.blurListener),this.editor.off("mousedown",this.mousedownListener),this.editor.off("mousewheel",this.mousewheelListener)),this.$firstOpenTimer.cancel(),this.changeTimer.cancel(),this.hideDocTooltip(),this.completionProvider&&this.completionProvider.detach(),this.popup&&this.popup.isOpen&&this.popup.hide(),this.popup&&this.popup.renderer&&this.popup.renderer.off("afterRender",this.$onPopupRender),this.base&&this.base.detach(),this.activated=!1,this.completionProvider=this.completions=this.base=null,this.unObserveLayoutChanges()},c1.prototype.changeListener=function(r1){var o1=this.editor.selection.lead;(o1.row!=this.base.row||o1.column<this.base.column)&&this.detach(),this.activated?this.changeTimer.schedule():this.detach()},c1.prototype.blurListener=function(r1){var o1=document.activeElement,a1=this.editor.textInput.getElement(),m1=r1.relatedTarget&&this.tooltipNode&&this.tooltipNode.contains(r1.relatedTarget),M1=this.popup&&this.popup.container;o1!=a1&&o1.parentNode!=M1&&!m1&&o1!=this.tooltipNode&&r1.relatedTarget!=a1&&this.detach()},c1.prototype.mousedownListener=function(r1){this.detach()},c1.prototype.mousewheelListener=function(r1){this.popup&&!this.popup.isMouseOver&&this.detach()},c1.prototype.mouseOutListener=function(r1){this.popup.isOpen&&this.$updatePopupPosition()},c1.prototype.goTo=function(r1){this.popup.goTo(r1)},c1.prototype.insertMatch=function(r1,o1){if(r1||(r1=this.popup.getData(this.popup.getRow())),!r1)return!1;if(r1.value==="")return this.detach();var a1=this.completions,m1=this.getCompletionProvider().insertMatch(this.editor,r1,a1.filterText,o1);return this.completions==a1&&this.detach(),m1},c1.prototype.showPopup=function(r1,o1){this.editor&&this.detach(),this.activated=!0,this.editor=r1,r1.completer!=this&&(r1.completer&&r1.completer.detach(),r1.completer=this),r1.on("changeSelection",this.changeListener),r1.on("blur",this.blurListener),r1.on("mousedown",this.mousedownListener),r1.on("mousewheel",this.mousewheelListener),this.updateCompletions(!1,o1)},c1.prototype.getCompletionProvider=function(r1){return this.completionProvider||(this.completionProvider=new n1(r1)),this.completionProvider},c1.prototype.gatherCompletions=function(r1,o1){return this.getCompletionProvider().gatherCompletions(r1,o1)},c1.prototype.updateCompletions=function(r1,o1){if(r1&&this.base&&this.completions){var m1=this.editor.getCursorPosition(),M1=this.editor.session.getTextRange({start:this.base,end:m1});if(M1==this.completions.filterText)return;if(this.completions.setFilter(M1),!this.completions.filtered.length)return this.detach();if(this.completions.filtered.length==1&&this.completions.filtered[0].value==M1&&!this.completions.filtered[0].snippet)return this.detach();this.openPopup(this.editor,M1,r1);return}if(o1&&o1.matches){var m1=this.editor.getSelectionRange().start;return this.base=this.editor.session.doc.createAnchor(m1.row,m1.column),this.base.$insertRight=!0,this.completions=new l1(o1.matches),this.getCompletionProvider().completions=this.completions,this.openPopup(this.editor,"",r1)}var a1=this.editor.getSession(),m1=this.editor.getCursorPosition(),M1=O.getCompletionPrefix(this.editor);this.base=a1.doc.createAnchor(m1.row,m1.column-M1.length),this.base.$insertRight=!0;var h1={exactMatch:this.exactMatch,ignoreCaption:this.ignoreCaption};this.getCompletionProvider({prefix:M1,pos:m1}).provideCompletions(this.editor,h1,(function(g1,d1,i1){var p1=d1.filtered,v1=O.getCompletionPrefix(this.editor);if(this.$firstOpenTimer.cancel(),i1){if(!p1.length){var j1=!this.autoShown&&this.emptyMessage;if(typeof j1=="function"&&(j1=this.emptyMessage(v1)),j1){var f1=[{caption:j1,value:""}];this.completions=new l1(f1),this.openPopup(this.editor,v1,r1),this.popup.renderer.setStyle("ace_loading",!1),this.popup.renderer.setStyle("ace_empty-message",!0);return}return this.detach()}if(p1.length==1&&p1[0].value==v1&&!p1[0].snippet)return this.detach();if(this.autoInsert&&!this.autoShown&&p1.length==1)return this.insertMatch(p1[0])}this.completions=!i1&&this.showLoadingState?new l1(c1.completionsForLoading.concat(p1),d1.filterText):d1,this.openPopup(this.editor,v1,r1),this.popup.renderer.setStyle("ace_empty-message",!1),this.popup.renderer.setStyle("ace_loading",!i1)}).bind(this)),this.showLoadingState&&!this.autoShown&&(!this.popup||!this.popup.isOpen)&&this.$firstOpenTimer.delay(this.stickySelectionDelay/2)},c1.prototype.cancelContextMenu=function(){this.editor.$mouseHandler.cancelContextMenu()},c1.prototype.updateDocTooltip=function(){var r1=this.popup,o1=this.completions.filtered,a1=o1&&(o1[r1.getHoveredRow()]||o1[r1.getRow()]),m1=null;if(!a1||!this.editor||!this.popup.isOpen)return this.hideDocTooltip();for(var M1=this.editor.completers.length,h1=0;h1<M1;h1++){var g1=this.editor.completers[h1];if(g1.getDocTooltip&&a1.completerId===g1.id){m1=g1.getDocTooltip(a1);break}}if(!m1&&typeof a1!="string"&&(m1=a1),typeof m1=="string"&&(m1={docText:m1}),!m1||!m1.docHTML&&!m1.docText)return this.hideDocTooltip();this.showDocTooltip(m1)},c1.prototype.showDocTooltip=function(r1){this.tooltipNode||(this.tooltipNode=A.createElement("div"),this.tooltipNode.style.margin="0",this.tooltipNode.style.pointerEvents="auto",this.tooltipNode.style.overscrollBehavior="contain",this.tooltipNode.tabIndex=-1,this.tooltipNode.onblur=this.blurListener.bind(this),this.tooltipNode.onclick=this.onTooltipClick.bind(this),this.tooltipNode.id="doc-tooltip",this.tooltipNode.setAttribute("role","tooltip"),this.tooltipNode.addEventListener("wheel",B));var o1=this.editor.renderer.theme;this.tooltipNode.className="ace_tooltip ace_doc-tooltip "+(o1.isDark?"ace_dark ":"")+(o1.cssClass||"");var a1=this.tooltipNode;r1.docHTML?a1.innerHTML=r1.docHTML:r1.docText&&(a1.textContent=r1.docText),a1.parentNode||this.popup.container.appendChild(this.tooltipNode);var m1=this.popup,M1=m1.container.getBoundingClientRect();a1.style.top=m1.container.style.top,a1.style.bottom=m1.container.style.bottom,a1.style.display="block",window.innerWidth-M1.right<320?M1.left<320?m1.isTopdown?(a1.style.top=M1.bottom+"px",a1.style.left=M1.left+"px",a1.style.right="",a1.style.bottom=""):(a1.style.top=m1.container.offsetTop-a1.offsetHeight+"px",a1.style.left=M1.left+"px",a1.style.right="",a1.style.bottom=""):(a1.style.right=window.innerWidth-M1.left+"px",a1.style.left=""):(a1.style.left=M1.right+1+"px",a1.style.right="")},c1.prototype.hideDocTooltip=function(){if(this.tooltipTimer.cancel(),!!this.tooltipNode){var r1=this.tooltipNode;!this.editor.isFocused()&&document.activeElement==r1&&this.editor.focus(),this.tooltipNode=null,r1.parentNode&&r1.parentNode.removeChild(r1)}},c1.prototype.onTooltipClick=function(r1){for(var o1=r1.target;o1&&o1!=this.tooltipNode;){if(o1.nodeName=="A"&&o1.href){o1.rel="noreferrer",o1.target="_blank";break}o1=o1.parentNode}},c1.prototype.destroy=function(){if(this.detach(),this.popup){this.popup.destroy();var r1=this.popup.container;r1&&r1.parentNode&&r1.parentNode.removeChild(r1)}this.editor&&this.editor.completer==this&&(this.editor.off("destroy",e1),this.editor.completer=null),this.inlineRenderer=this.popup=this.editor=null},c1.for=function(r1){return r1.completer instanceof c1||(r1.completer&&(r1.completer.destroy(),r1.completer=null),k.get("sharedPopups")?(c1.$sharedInstance||(c1.$sharedInstance=new c1),r1.completer=c1.$sharedInstance):(r1.completer=new c1,r1.once("destroy",e1))),r1.completer},c1})();s1.prototype.commands={Up:function(c1){c1.completer.goTo("up")},Down:function(c1){c1.completer.goTo("down")},"Ctrl-Up|Ctrl-Home":function(c1){c1.completer.goTo("start")},"Ctrl-Down|Ctrl-End":function(c1){c1.completer.goTo("end")},Esc:function(c1){c1.completer.detach()},Return:function(c1){return c1.completer.insertMatch()},"Shift-Return":function(c1){c1.completer.insertMatch(null,{deleteSuffix:!0})},Tab:function(c1){var r1=c1.completer.insertMatch();if(r1||c1.tabstopManager)return r1;c1.completer.goTo("down")},Backspace:function(c1){c1.execCommand("backspace");var r1=O.getCompletionPrefix(c1);!r1&&c1.completer&&c1.completer.detach()},PageUp:function(c1){c1.completer.popup.gotoPageUp()},PageDown:function(c1){c1.completer.popup.gotoPageDown()}},s1.startCommand={name:"startAutocomplete",exec:function(c1,r1){var o1=s1.for(c1);o1.autoInsert=!1,o1.autoSelect=!0,o1.autoShown=!1,o1.showPopup(c1,r1),o1.cancelContextMenu()},bindKey:"Ctrl-Space|Ctrl-Shift-Space|Alt-Space"};var n1=(function(){function c1(r1){this.initialPosition=r1,this.active=!0}return c1.prototype.insertByIndex=function(r1,o1,a1){return!this.completions||!this.completions.filtered?!1:this.insertMatch(r1,this.completions.filtered[o1],a1)},c1.prototype.insertMatch=function(r1,o1,a1){if(!o1)return!1;if(r1.startOperation({command:{name:"insertMatch"}}),o1.completer&&o1.completer.insertMatch)o1.completer.insertMatch(r1,o1);else{if(!this.completions)return!1;var m1=this.completions.filterText.length,M1=0;if(o1.range&&o1.range.start.row===o1.range.end.row&&(m1-=this.initialPosition.prefix.length,m1+=this.initialPosition.pos.column-o1.range.start.column,M1+=o1.range.end.column-this.initialPosition.pos.column),m1||M1){var h1;r1.selection.getAllRanges?h1=r1.selection.getAllRanges():h1=[r1.getSelectionRange()];for(var g1=0,d1;d1=h1[g1];g1++)d1.start.column-=m1,d1.end.column+=M1,r1.session.remove(d1)}o1.snippet?_.insertSnippet(r1,o1.snippet):this.$insertString(r1,o1),o1.completer&&o1.completer.onInsert&&typeof o1.completer.onInsert=="function"&&o1.completer.onInsert(r1,o1),o1.command&&o1.command==="startAutocomplete"&&r1.execCommand(o1.command)}return r1.endOperation(),!0},c1.prototype.$insertString=function(r1,o1){var a1=o1.value||o1;r1.execCommand("insertstring",a1)},c1.prototype.gatherCompletions=function(r1,o1){var a1=r1.getSession(),m1=r1.getCursorPosition(),M1=O.getCompletionPrefix(r1),h1=[];this.completers=r1.completers;var g1=r1.completers.length;return r1.completers.forEach(function(d1,i1){d1.getCompletions(r1,a1,m1,M1,function(p1,v1){d1.hideInlinePreview&&(v1=v1.map(function(j1){return Object.assign(j1,{hideInlinePreview:d1.hideInlinePreview})})),!p1&&v1&&(h1=h1.concat(v1)),o1(null,{prefix:O.getCompletionPrefix(r1),matches:h1,finished:--g1===0})})}),!0},c1.prototype.provideCompletions=function(r1,o1,a1){var m1=(function(d1){var i1=d1.prefix,p1=d1.matches;this.completions=new l1(p1),o1.exactMatch&&(this.completions.exactMatch=!0),o1.ignoreCaption&&(this.completions.ignoreCaption=!0),this.completions.setFilter(i1),(d1.finished||this.completions.filtered.length)&&a1(null,this.completions,d1.finished)}).bind(this),M1=!0,h1=null;if(this.gatherCompletions(r1,(function(d1,i1){if(this.active){d1&&(a1(d1,[],!0),this.detach());var p1=i1.prefix;if(p1.indexOf(i1.prefix)===0){if(M1){h1=i1;return}m1(i1)}}}).bind(this)),M1=!1,h1){var g1=h1;h1=null,m1(g1)}},c1.prototype.detach=function(){this.active=!1,this.completers&&this.completers.forEach(function(r1){typeof r1.cancel=="function"&&r1.cancel()})},c1})(),l1=(function(){function c1(r1,o1){this.all=r1,this.filtered=r1,this.filterText=o1||"",this.exactMatch=!1,this.ignoreCaption=!1}return c1.prototype.setFilter=function(r1){if(r1.length>this.filterText&&r1.lastIndexOf(this.filterText,0)===0)var o1=this.filtered;else var o1=this.all;this.filterText=r1,o1=this.filterCompletions(o1,this.filterText),o1=o1.sort(function(m1,M1){return M1.exactMatch-m1.exactMatch||M1.$score-m1.$score||(m1.caption||m1.value).localeCompare(M1.caption||M1.value)});var a1=null;o1=o1.filter(function(m1){var M1=m1.snippet||m1.caption||m1.value;return M1===a1?!1:(a1=M1,!0)}),this.filtered=o1},c1.prototype.filterCompletions=function(r1,o1){var a1=[],m1=o1.toUpperCase(),M1=o1.toLowerCase();e:for(var h1=0,g1;g1=r1[h1];h1++){var d1=!this.ignoreCaption&&g1.caption||g1.value||g1.snippet;if(d1){var i1=-1,p1=0,v1=0,j1,f1;if(this.exactMatch){if(o1!==d1.substr(0,o1.length))continue e}else{var y1=d1.toLowerCase().indexOf(M1);if(y1>-1)v1=y1;else for(var z1=0;z1<o1.length;z1++){var E1=d1.indexOf(M1[z1],i1+1),T1=d1.indexOf(m1[z1],i1+1);if(j1=E1>=0&&(T1<0||E1<T1)?E1:T1,j1<0)continue e;f1=j1-i1-1,f1>0&&(i1===-1&&(v1+=10),v1+=f1,p1|=1<<z1),i1=j1}}g1.matchMask=p1,g1.exactMatch=v1?0:1,g1.$score=(g1.score||0)-v1,a1.push(g1)}}return a1},c1})();M.Autocomplete=s1,M.CompletionProvider=n1,M.FilteredList=l1}),ace.define("ace/autocomplete/text_completer",["require","exports","module","ace/range"],function(e,M,j){function z(O,H){var A=O.getTextRange(N.fromPoints({row:0,column:0},H));return A.split(R).length-1}function E(O,H){var A=z(O,H),_=O.getValue().split(R),k=Object.create(null),P=_[A];return _.forEach(function(B,e1){if(!(!B||B===P)){var s1=Math.abs(A-e1),n1=_.length-s1;k[B]?k[B]=Math.max(n1,k[B]):k[B]=n1}}),k}var N=e("../range").Range,R=/[^a-zA-Z_0-9\$\-\u00C0-\u1FFF\u2C00-\uD7FF\w]+/;M.getCompletions=function(O,H,A,_,k){var P=E(H,A),B=Object.keys(P);k(null,B.map(function(e1){return{caption:e1,value:e1,score:P[e1],meta:"local"}}))}}),ace.define("ace/ext/language_tools",["require","exports","module","ace/snippets","ace/autocomplete","ace/config","ace/lib/lang","ace/autocomplete/util","ace/autocomplete/text_completer","ace/editor","ace/config"],function(e,M,j){var z=e("../snippets").snippetManager,E=e("../autocomplete").Autocomplete,N=e("../config"),R=e("../lib/lang"),O=e("../autocomplete/util"),H=e("../autocomplete/text_completer"),A={getCompletions:function(m1,M1,h1,g1,d1){if(M1.$mode.completer)return M1.$mode.completer.getCompletions(m1,M1,h1,g1,d1);var i1=m1.session.getState(h1.row),p1=M1.$mode.getCompletions(i1,M1,h1,g1);p1=p1.map(function(v1){return v1.completerId=A.id,v1}),d1(null,p1)},id:"keywordCompleter"},_=function(m1){var M1={};return m1.replace(/\${(\d+)(:(.*?))?}/g,function(h1,g1,d1,i1){return M1[g1]=i1||""}).replace(/\$(\d+?)/g,function(h1,g1){return M1[g1]})},k={getCompletions:function(m1,M1,h1,g1,d1){var i1=[],p1=M1.getTokenAt(h1.row,h1.column);p1&&p1.type.match(/(tag-name|tag-open|tag-whitespace|attribute-name|attribute-value)\.xml$/)?i1.push("html-tag"):i1=z.getActiveScopes(m1);var v1=z.snippetMap,j1=[];i1.forEach(function(f1){for(var y1=v1[f1]||[],z1=y1.length;z1--;){var E1=y1[z1],T1=E1.name||E1.tabTrigger;T1&&j1.push({caption:T1,snippet:E1.content,meta:E1.tabTrigger&&!E1.name?E1.tabTrigger+"⇥ ":"snippet",completerId:k.id})}},this),d1(null,j1)},getDocTooltip:function(m1){m1.snippet&&!m1.docHTML&&(m1.docHTML=["<b>",R.escapeHTML(m1.caption),"</b>","<hr></hr>",R.escapeHTML(_(m1.snippet))].join(""))},id:"snippetCompleter"},P=[k,H,A];M.setCompleters=function(m1){P.length=0,m1&&P.push.apply(P,m1)},M.addCompleter=function(m1){P.push(m1)},M.textCompleter=H,M.keyWordCompleter=A,M.snippetCompleter=k;var B={name:"expandSnippet",exec:function(m1){return z.expandWithTab(m1)},bindKey:"Tab"},e1=function(m1,M1){s1(M1.session.$mode)},s1=function(m1){typeof m1=="string"&&(m1=N.$modes[m1]),m1&&(z.files||(z.files={}),n1(m1.$id,m1.snippetFileId),m1.modes&&m1.modes.forEach(s1))},n1=function(m1,M1){!M1||!m1||z.files[m1]||(z.files[m1]={},N.loadModule(M1,function(h1){h1&&(z.files[m1]=h1,!h1.snippets&&h1.snippetText&&(h1.snippets=z.parseSnippetFile(h1.snippetText)),z.register(h1.snippets||[],h1.scope),h1.includeScopes&&(z.snippetMap[h1.scope].includeScopes=h1.includeScopes,h1.includeScopes.forEach(function(g1){s1("ace/mode/"+g1)})))}))},l1=function(m1){var M1=m1.editor,h1=M1.completer&&M1.completer.activated;if(m1.command.name==="backspace")h1&&!O.getCompletionPrefix(M1)&&M1.completer.detach();else if(m1.command.name==="insertstring"&&!h1){c1=m1;var g1=m1.editor.$liveAutocompletionDelay;g1?r1.delay(g1):o1(m1)}},c1,r1=R.delayedCall(function(){o1(c1)},0),o1=function(m1){var M1=m1.editor,h1=O.getCompletionPrefix(M1),g1=m1.args,d1=O.triggerAutocomplete(M1,g1);if(h1&&h1.length>=M1.$liveAutocompletionThreshold||d1){var i1=E.for(M1);i1.autoShown=!0,i1.showPopup(M1)}},a1=e("../editor").Editor;e("../config").defineOptions(a1.prototype,"editor",{enableBasicAutocompletion:{set:function(m1){m1?(this.completers||(this.completers=Array.isArray(m1)?m1:P),this.commands.addCommand(E.startCommand)):this.commands.removeCommand(E.startCommand)},value:!1},enableLiveAutocompletion:{set:function(m1){m1?(this.completers||(this.completers=Array.isArray(m1)?m1:P),this.commands.on("afterExec",l1)):this.commands.off("afterExec",l1)},value:!1},liveAutocompletionDelay:{initialValue:0},liveAutocompletionThreshold:{initialValue:0},enableSnippets:{set:function(m1){m1?(this.commands.addCommand(B),this.on("changeMode",e1),e1(null,this)):(this.commands.removeCommand(B),this.off("changeMode",e1))},value:!1}})}),(function(){ace.require(["ace/ext/language_tools"],function(e){t&&(t.exports=e)})})()})(extLanguage_tools)),extLanguage_tools.exports}requireExtLanguage_tools();const styles$p={jsonError:{border:"1px solid red",minHeight:200},jsonNoError:{border:"1px solid #00000000",minHeight:200}};function Editor(t){return React.createElement(AceEditor,{style:t.error===!0?styles$p.jsonError:t.error===!1?styles$p.jsonNoError:void 0,mode:t.mode||"json",width:"100%",height:"100%",showPrintMargin:t.editValueMode,showGutter:t.editValueMode,highlightActiveLine:t.editValueMode,defaultValue:t.defaultValue,theme:t.themeType==="dark"?"clouds_midnight":"chrome",value:t.value,readOnly:!t.onChange,onChange:o=>{var e;return(e=t.onChange)==null?void 0:e.call(t,o)},name:t.name||"UNIQUE_ID_OF_DIV1",fontSize:t.fontSize||14,setOptions:{enableBasicAutocompletion:!0,enableLiveAutocompletion:!0,enableSnippets:!0,showLineNumbers:t.editValueMode,tabSize:t.editValueMode?2:void 0},editorProps:{$blockScrolling:!0}})}const styles$o={flex:{display:"flex"},button:{height:48,minWidth:48},wrapper:{width:"calc(100vw - 40px)",height:"calc(100vh - 188px)"}};class ConfigJsonEditor extends ConfigGeneric{componentDidMount(){super.componentDidMount();const{data:o,attr:e}=this.props,M=ConfigGeneric.getValue(o,e)||"{}";this.setState({value:M,initialized:!0,jsonError:this.validateJson(M)})}validateJson(o){let e=!1;if(this.props.schema.validateJson!==!1&&(o||!this.props.schema.allowEmpty))try{this.props.schema.json5?lib$1.parse(o):JSON.parse(o)}catch(M){console.log("Error in JSON",M),e=!0}return e}renderItem(o,e){if(!this.state.initialized)return null;const{schema:M,data:j,attr:z}=this.props,{value:E,showSelectId:N}=this.state,R=M.readOnly===!0;return React.createElement(FormControl,{fullWidth:!0,variant:"standard"},React.createElement("div",{style:styles$o.flex},React.createElement(Button,{color:"grey",disabled:e,style:styles$o.button,size:"small",variant:"outlined",onClick:()=>this.setState({showSelectId:!0})},I18n.t("ra_JSON editor"))),N?React.createElement(CustomModal,{title:this.getText(M.label),overflowHidden:!0,applyDisabled:this.state.jsonError&&this.props.schema.doNotApplyWithError||R,onClose:()=>this.setState({showSelectId:!1,value:ConfigGeneric.getValue(j,z)||{}}),onApply:R?void 0:()=>this.setState({showSelectId:!1},()=>this.onChange(z,E))},React.createElement("div",{style:{...styles$o.wrapper,border:this.state.jsonError?"2px solid red":"2px solid transparent"}},React.createElement(Editor,{mode:this.props.schema.json5?"json5":"json",value:typeof E=="object"?JSON.stringify(E):E,onChange:R?void 0:O=>this.setState({value:O,jsonError:this.validateJson(O)}),name:"ConfigJsonEditor",themeType:this.props.oContext.themeType}))):null,M.help||this.state.jsonError?React.createElement(FormHelperText,null,this.state.jsonError?I18n.t("ra_Invalid JSON"):this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}const LANGUAGES=[{value:"en",label:"English"},{value:"de",label:"Deutsch"},{value:"ru",label:"русский"},{value:"pt",label:"Portugues"},{value:"nl",label:"Nederlands"},{value:"fr",label:"français"},{value:"it",label:"Italiano"},{value:"es",label:"Espanol"},{value:"pl",label:"Polski"},{value:"uk",label:"Український"},{value:"zh-cn",label:"简体中文"}];class ConfigLanguage extends ConfigGeneric{componentDidMount(){super.componentDidMount();const o=ConfigGeneric.getValue(this.props.data,this.props.attr),e=[...LANGUAGES];this.props.schema.system?e.unshift({value:"",label:I18n.t("ra_System language")}):e.unshift({value:"",label:I18n.t("ra_none")}),this.setState({value:this.props.schema.system?o||"":o||I18n.getLanguage(),selectOptions:e})}renderItem(o,e){var j,z;if(!this.state.selectOptions)return null;const M=(j=this.state.selectOptions)==null?void 0:j.find(E=>E.value===this.state.value||!E.value&&!this.state.value);return React.createElement(FormControl,{fullWidth:!0,variant:"standard"},this.props.schema.label?React.createElement(InputLabel,null,this.getText(this.props.schema.label)):null,React.createElement(Select,{variant:"standard",error:!!o,disabled:e,value:this.state.value||"_",renderValue:()=>this.getText(M==null?void 0:M.label,this.props.schema.noTranslation),onChange:E=>{let{value:N}=E.target;N==="_"&&(N=""),this.setState({value:N},()=>{const R=this.onChange(this.props.attr,N);if(R instanceof Promise&&R.catch(O=>console.error(O)),this.props.schema.changeGuiLanguage)if(N){if(N===I18n.getLanguage())return;I18n.setLanguage(N),this.props.oContext.changeLanguage&&this.props.oContext.changeLanguage()}else this.props.oContext.socket.getSystemConfig().then(O=>{O.common.language!==I18n.getLanguage()&&O.common.language&&(I18n.setLanguage(O.common.language),this.props.oContext.changeLanguage&&this.props.oContext.changeLanguage())}).catch(O=>console.error(`Cannot read system config: ${O}`))})}},(z=this.state.selectOptions)==null?void 0:z.map(E=>React.createElement(MenuItem,{key:E.value,value:E.value},E.label))),this.props.schema.help?React.createElement(FormHelperText,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}class ConfigLicense extends ConfigGeneric{constructor(e){super(e);_1(this,"scrollRef");this.scrollRef=React.createRef()}scrolledDown(){return this.scrollRef.current?this.scrollRef.current.offsetHeight+this.scrollRef.current.scrollTop>=this.scrollRef.current.scrollHeight:!1}componentDidMount(){super.componentDidMount(),ConfigGeneric.getValue(this.props.data,this.props.attr)||(this.props.schema.licenseUrl?(this.setState({showLicenseDialog:!0,loading:!0,scrolledDown:!1}),fetch(this.props.schema.licenseUrl).then(e=>e.text()).then(e=>this.setState({license:e,loading:!1})).catch(e=>this.setState({license:e.toString(),loading:!1,error:!0,scrolledDown:!1}))):this.setState({showLicenseDialog:!0,scrolledDown:!1}),setTimeout(()=>{this.scrollRef.current&&(this.scrolledDown()?this.setState({scrolledDown:!0}):this.scrollRef.current.addEventListener("scroll",()=>{!this.state.scrolledDown&&this.scrolledDown()&&this.setState({scrolledDown:!0})}))},1e3))}renderItem(e,M){return this.state.showLicenseDialog?React.createElement(Dialog,{maxWidth:"lg",open:!0,onClose:(j,z)=>{z!=="escapeKeyDown"&&z!=="backdropClick"&&this.setState({showLicenseDialog:!1})}},React.createElement(DialogTitle,null,this.props.schema.title?I18n.t(this.props.schema.title):I18n.t("ra_License agreement")),React.createElement(DialogContent,null,this.props.schema.licenseUrl?React.createElement(React.Fragment,null,this.state.loading?React.createElement(LinearProgress,null):null,React.createElement("pre",{ref:this.scrollRef,style:{width:"100%",height:"100%",overflowY:"auto",fontSize:14}},this.state.license)):null,!this.props.schema.licenseUrl&&this.props.schema.texts?React.createElement("div",{ref:this.scrollRef,style:{width:"100%",height:"100%",overflowY:"auto",fontSize:14}},this.props.schema.texts.map((j,z)=>this.props.schema.noTranslation?React.createElement("p",{key:z},j):React.createElement("p",{key:z},I18n.t(j)))):null),React.createElement(DialogActions,null,this.props.schema.checkBox?React.createElement(FormControlLabel,{control:React.createElement(Checkbox,{disabled:M,checked:!!this.state.licenseChecked,onClick:()=>this.setState({licenseChecked:!this.state.licenseChecked})}),label:I18n.t(this.props.schema.checkBox)}):null,React.createElement(Button,{disabled:M||this.state.loading||this.state.error||this.props.schema.checkBox&&!this.state.licenseChecked||!this.state.scrolledDown,onClick:()=>{this.setState({showLicenseDialog:!1});const j=this.onChange(this.props.attr,!0);j instanceof Promise&&j.catch(z=>console.error(`Cannot set value: ${z}`))},color:"primary",variant:"contained",startIcon:React.createElement(Check,null)},this.props.schema.agreeText?I18n.t(this.props.schema.agreeText):I18n.t("ra_Accept license")),React.createElement(Button,{onClick:()=>{this.setState({showLicenseDialog:!1}),setTimeout(()=>this.setState({showLicenseDialog:!0}),2e3)},color:"grey",variant:"contained",startIcon:React.createElement(CloseIcon,null)},I18n.t("ra_Close")))):null}}const styles$n={indeterminate:{opacity:.5},control:{flexDirection:"row",width:"100%"}};class ConfigNumber extends ConfigGeneric{constructor(){super(...arguments);_1(this,"updateTimeout")}componentDidMount(){super.componentDidMount();let e=ConfigGeneric.getValue(this.props.data,this.props.attr);if(e==null&&(e=""),Array.isArray(e)&&this.props.oContext.multiEdit){e=ConfigGeneric.DIFFERENT_VALUE,this.setState({_value:e,oldValue:e});return}this.setState({_value:e.toString(),oldValue:e.toString()})}static getDerivedStateFromProps(e,M){if(e.schema.min!==void 0&&e.schema.min<0||e.schema.max!==void 0&&e.schema.max<0)return null;const j=ConfigGeneric.getValue(e.data,e.attr);return e.oContext.multiEdit&&M._value===ConfigGeneric.DIFFERENT_VALUE?{_value:ConfigGeneric.DIFFERENT_VALUE}:j==null||M.oldValue===null||M.oldValue===void 0||j.toString()!==parseFloat(M._value).toString()&&j.toString()!==M.oldValue.toString()?{_value:j}:null}checkValue(e){if(e==null||(e=e.toString().trim().replace(",","."),e==="-"))return null;const M=e===""?0:parseFloat(e);return e!==""&&Number.isNaN(M)?"ra_Not a number":e!==""&&window.isFinite(M)?this.props.schema.min!==void 0&&M<this.props.schema.min?"ra_Too small":this.props.schema.max!==void 0&&M>this.props.schema.max?"ra_Too big":e===""||e==="-"||Number.isNaN(M)?"ra_Not a number":null:"ra_Not a number"}renderItem(e,M){var E;const j=Array.isArray(this.state._value)||this.state._value===ConfigGeneric.DIFFERENT_VALUE;if(this.state.oldValue!==null&&this.state.oldValue!==void 0?(this.updateTimeout&&clearTimeout(this.updateTimeout),this.updateTimeout=setTimeout(()=>{this.updateTimeout=void 0,this.setState({oldValue:null})},30)):this.updateTimeout&&(clearTimeout(this.updateTimeout),this.updateTimeout=void 0),j){const N=ConfigGeneric.getValue(this.props.data,this.props.attr),R=(N==null?void 0:N.filter(O=>O||O===0).map(O=>({label:O.toString(),value:O})))||[];return R.unshift({label:I18n.t(ConfigGeneric.DIFFERENT_LABEL),value:ConfigGeneric.DIFFERENT_VALUE}),React.createElement(Autocomplete,{style:styles$n.indeterminate,fullWidth:!0,freeSolo:!0,value:R[0],getOptionSelected:(O,H)=>O.label===H.label,onChange:(O,H)=>{const A=this.onChange(this.props.attr,H==null?void 0:H.value,()=>{this.setState({_value:H==null?void 0:H.value,oldValue:this.state._value})});A instanceof Promise&&A.catch(_=>console.error(_))},options:R,getOptionLabel:O=>O.label,renderInput:O=>React.createElement(TextField,{...O,label:this.getText(this.props.schema.label),variant:"standard",slotProps:{htmlInput:{...O.inputProps,readOnly:this.props.schema.readOnly||!1},input:{endAdornment:this.props.schema.unit?this.getText(this.props.schema.unit,this.props.schema.noTranslation):void 0}},error:!!e,placeholder:this.getText(this.props.schema.placeholder),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation),disabled:!!M})})}!e&&this.state._value!==null&&this.state._value!==void 0&&this.state._value&&(e=this.checkValue(this.state._value),e&&(e=I18n.t(e)));const z=parseFloat(((E=this.state._value)==null?void 0:E.toString().replace(",","."))||"");return React.createElement(FormControl,{variant:"standard",style:styles$n.control},React.createElement(TextField,{sx:{"& .up-down":{display:"none"},"&:hover .up-down":{display:"block"}},variant:"standard",type:Number.isNaN(z)?"text":this.props.schema.min!==void 0&&this.props.schema.min>=0?"number":"text",fullWidth:!0,slotProps:{htmlInput:{min:this.props.schema.min,max:this.props.schema.max,step:this.props.schema.step,readOnly:this.props.schema.readOnly||!1},input:{endAdornment:this.props.schema.unit?this.getText(this.props.schema.unit,this.props.schema.noTranslation):null}},value:this.state._value===null||this.state._value===void 0?"":this.state._value,error:!!e,disabled:!!M,onChange:N=>{const R=N.target.value,O=this.checkValue(R);O?this.onError(this.props.attr,I18n.t(O)):this.onError(this.props.attr),this.setState({_value:R,oldValue:this.state._value},()=>{const H=parseFloat(R.toString().replace(",","."));Number.isNaN(H)?this.onChange(this.props.attr,R.toString().replace(",",".")):this.onChange(this.props.attr,H)})},placeholder:this.getText(this.props.schema.placeholder),label:this.getText(this.props.schema.label),helperText:e&&typeof e=="string"?e:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)}))}}class ConfigOAuth2 extends ConfigGeneric{constructor(e){super(e);_1(this,"authWindow");_1(this,"oid");_1(this,"url");_1(this,"onTokensUpdated",(e,M)=>{if(M!=null&&M.val){const j=JSON.parse(M.val);if(new Date(j.access_token_expires_on).getTime()>Date.now()){this.state.accessTokens!==M.val&&this.setState({accessTokens:M.val});return}}this.setState({accessTokens:""})});_1(this,"onMessage",e=>{var M,j,z;if(e.origin==="https://oauth2.iobroker.in"&&(typeof e.data=="string"&&e.data.startsWith(`${this.props.schema.identifier}-authentication:`)||typeof e.message=="string"&&e.message.startsWith(`${this.props.schema.identifier}-authentication:`))){const E=(e.data||e.message).split(":");E[1]==="success"?(this.setState({accessTokens:E[2],success:!0,pressed:!1},()=>this.saveToken(this.state.accessTokens)),(M=this.authWindow)==null||M.postMessage("close",e.origin),this.authWindow=null):(z=(j=this.props).onError)==null||z.call(j,E[2])}});this.state={...this.state,accessTokens:"",success:!1,blocked:!1,running:!1,pressed:!1},this.url=`https://oauth2.iobroker.in/${e.schema.identifier}?redirect=true`,e.schema.scope&&(this.url+=`&scope=${encodeURIComponent(e.schema.scope)}`),this.oid=`${this.props.oContext.adapterName}.${this.props.oContext.instance}.${this.props.schema.saveTokenIn||"oauth2Tokens"}`}async componentDidMount(){super.componentDidMount(),window.addEventListener?window.addEventListener("message",this.onMessage,!1):window.attachEvent("onmessage",this.onMessage,!1),await this.props.oContext.socket.subscribeState(this.oid,this.onTokensUpdated);const e=await this.props.oContext.socket.getState(this.oid);if(e){const M=JSON.parse(e.val);new Date(M.access_token_expires_on).getTime()>Date.now()&&this.setState({accessTokens:e.val})}}componentWillUnmount(){super.componentWillUnmount(),window.removeEventListener?window.removeEventListener("message",this.onMessage,!1):window.detachEvent("onmessage",this.onMessage,!1),this.props.oContext.socket.unsubscribeState(this.oid,this.onTokensUpdated)}saveToken(e){try{e&&!e.startsWith("{")&&(e=atob(e));const M=JSON.parse(e);M.access_token&&M.refresh_token&&M.expires_in&&(M.access_token_expires_on||(M.access_token_expires_on=new Date(Date.now()+M.expires_in*1e3).toISOString()),this.props.oContext.socket.setState(this.oid,JSON.stringify(M),!0).catch(j=>console.log(`Error occurred: ${j.toString()}`)))}catch(M){console.warn(M)}}onOpenUrl(){this.authWindow=window.open(this.url,this.props.schema.identifier),!this.authWindow||this.authWindow.closed||typeof this.authWindow.closed>"u"?this.setState({blocked:!0}):this.setState({pressed:!0})}renderItem(){let e="";if(this.state.accessTokens)try{const z=JSON.parse(this.state.accessTokens);e=new Date(z.access_token_expires_on).toLocaleString()}catch{}let M;this.state.accessTokens?M=this.props.schema.refreshLabel?this.getText(this.props.schema.refreshLabel):I18n.t("ra_Renew %s access",this.props.schema.identifier[0].toUpperCase()+this.props.schema.identifier.slice(1)):M=this.props.schema.label?this.getText(this.props.schema.label):I18n.t("ra_Get %s access",this.props.schema.identifier[0].toUpperCase()+this.props.schema.identifier.slice(1));const j=this.getIcon();return React.createElement("div",{style:{width:"100%",margin:"0 0 1rem 0"}},React.createElement(Button,{disabled:this.state.running,endIcon:j||React.createElement(CloudUpload,null),variant:"contained",onClick:()=>this.onOpenUrl()},M),this.state.blocked?React.createElement("div",{style:{color:"red",fontSize:16,marginTop:20}},I18n.t("ra_Please allow popups in your browser for this page!")):null,this.state.accessTokens?React.createElement("div",{style:{color:"green",fontSize:16,marginTop:20}},this.props.alive?I18n.t("ra_Successfully authorized. Token valid till %s and will be automatically renewed.",e):I18n.t("ra_Successfully authorized. Token valid till %s but it can expire as the instance is not running.",e)):null,this.state.pressed?React.createElement(React.Fragment,null,React.createElement("div",{style:{width:"100%",margin:"1rem 0 1rem 0"}},React.createElement("span",{style:{marginRight:4}},`${I18n.t("ra_If the button above does not work, you can authorize manually this app by visiting this url")}`,":"),React.createElement("br",null),React.createElement("a",{target:this.props.schema.identifier,href:this.url,rel:"noreferrer"},this.url)),React.createElement(TextField,{value:this.state.accessTokens,label:I18n.t("ra_Enter the code from that page here"),variant:"standard",onChange:z=>{let E=z.target.value;E&&!E.startsWith("{")&&(E=atob(E));try{const N=JSON.parse(E);N.access_token&&(N.access_token_expires_on=new Date(Date.now()+(N.expires_in-10)*1e3).toISOString(),this.setState({accessTokens:JSON.stringify(N)},()=>this.saveToken(this.state.accessTokens)))}catch{}},fullWidth:!0})):null)}}const styles$m={flex:{display:"flex"},button:{height:48,marginLeft:4,minWidth:48}};class ConfigObjectId extends ConfigGeneric{componentDidMount(){super.componentDidMount();const{data:o,attr:e}=this.props,M=ConfigGeneric.getValue(o,e)||"";this.setState({value:M,initialized:!0})}renderItem(o,e){if(!this.state.initialized)return null;const M=this.props.oContext.socket,{schema:j,attr:z}=this.props,{value:E,showSelectId:N}=this.state;return React.createElement(FormControl,{fullWidth:!0,variant:"standard"},j.label?React.createElement(InputLabel,{shrink:!0},this.getText(j.label)):null,React.createElement("div",{style:styles$m.flex},React.createElement(TextField,{variant:"standard",fullWidth:!0,value:E,error:!!o,disabled:e,placeholder:this.getText(j.placeholder),label:this.getText(j.label),helperText:this.renderHelp(j.help,j.helpLink,j.noTranslation),onChange:R=>{const O=R.target.value;this.setState({value:O},()=>this.onChange(z,O))}}),React.createElement(Button,{color:"grey",disabled:e,style:styles$m.button,size:"small",variant:"outlined",onClick:()=>this.setState({showSelectId:!0})},"...")),N?React.createElement(DialogSelectID,{imagePrefix:this.props.oContext.imagePrefix===void 0?"../..":this.props.oContext.imagePrefix,dialogName:`admin.${this.props.oContext.adapterName}`,filterFunc:j.filterFunc,themeType:this.props.oContext.themeType,theme:this.props.oContext.theme,types:j.types?Array.isArray(j.types)?j.types:[j.types]:void 0,customFilter:j.customFilter,filters:j.filters,socket:M,selected:E,root:j.root,onClose:()=>this.setState({showSelectId:!1}),onOk:R=>this.setState({showSelectId:!1,value:R},()=>this.onChange(z,R))}):null)}}const styles$l={fullWidth:{width:"100%",display:"inline-block"},halfWidth1:{width:"calc(50% - 5px)",display:"inline-block",marginRight:8},halfWidth2:{width:"calc(50% - 5px)",display:"inline-block"}},PASSWORD_PLACEHOLDER="____ppp____";class ConfigPassword extends ConfigGeneric{componentDidMount(){super.componentDidMount();const o=ConfigGeneric.getValue(this.props.data,this.props.attr);this.setState({_repeat:o?PASSWORD_PLACEHOLDER:"",_visible:!1,value:o?PASSWORD_PLACEHOLDER:"",_notEqual:!1})}onChangePassword(o,e){o===void 0&&(o=this.state.value),e===void 0&&(e=this.state._repeat);const M=!!this.props.schema.repeat&&e!==o;this.setState({value:o,_repeat:e,_notEqual:M},()=>{if(M)this.onError(this.props.attr,I18n.t("ra_Passwords are not equal!"));else{this.onError(this.props.attr);const j=this.onChange(this.props.attr,o);j instanceof Promise&&j.catch(z=>this.onError(this.props.attr,z))}})}renderItem(o,e){if(this.state._notEqual===void 0)return null;const M=React.createElement(TextField,{variant:"standard",fullWidth:!0,type:this.state._visible&&this.state.value!==PASSWORD_PLACEHOLDER?"text":"password",value:this.state.value,error:!!o||this.state._notEqual,disabled:!!e,onChange:j=>this.onChangePassword(j.target.value),label:this.getText(this.props.schema.label),slotProps:{input:{autoComplete:"new-password",endAdornment:this.state.value&&this.state.value!==PASSWORD_PLACEHOLDER&&this.props.schema.visible&&!e&&!this.props.schema.readOnly?React.createElement(InputAdornment,{position:"end"},React.createElement(IconButton,{size:"large",tabIndex:-1,onClick:j=>{j.preventDefault(),j.stopPropagation(),this.setState({_visible:!this.state._visible})},edge:"end"},this.state._visible?React.createElement(VisibilityOff,null):React.createElement(Visibility,null))):void 0},htmlInput:{autoComplete:"new-password",form:{autoComplete:"off"},maxLength:this.props.schema.maxLength||this.props.schema.max||void 0,readOnly:this.props.schema.readOnly||!1}},helperText:this.state._notEqual?I18n.t("ra_Passwords are not equal!"):this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)});if(this.props.schema.repeat&&!this.props.schema.readOnly){const j=this.state._visible?null:React.createElement(TextField,{variant:"standard",fullWidth:!0,type:"password",value:this.state._repeat,error:!!o||this.state._notEqual,disabled:!!e,onChange:z=>this.onChangePassword(void 0,z.target.value),label:`${this.getText(this.props.schema.label)} (${I18n.t("ra_repeat")})`,slotProps:{input:{autoComplete:"new-password"},htmlInput:{autoComplete:"new-password",form:{autoComplete:"off"},maxLength:this.props.schema.maxLength||this.props.schema.max||void 0}},helperText:this.state._notEqual?I18n.t("ra_Passwords are not equal!"):this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)});return React.createElement("div",{style:styles$l.fullWidth},React.createElement("div",{style:styles$l.halfWidth1},M),React.createElement("div",{style:styles$l.halfWidth2},j))}return M}}class ConfigPattern extends ConfigGeneric{renderItem(o,e){return React.createElement(TextField,{variant:"standard",fullWidth:!0,disabled:!!e,slotProps:{input:{endAdornment:this.props.schema.copyToClipboard?React.createElement(IconButton,{tabIndex:-1,size:"small",onClick:()=>{Utils.copyToClipboard(this.getPattern(this.props.schema.pattern,null,this.props.schema.noTranslation)),window.alert(I18n.t("ra_Copied"))}},React.createElement(IconCopy,null)):void 0}},value:this.getPattern(this.props.schema.pattern,null,!0),label:this.getText(this.props.schema.label),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)})}}const styles$k={warning:{"& .Mui-error":{color:"orange"}}};class ConfigPort extends ConfigGeneric{constructor(){super(...arguments);_1(this,"updateTimeout")}async componentDidMount(){super.componentDidMount();let e=ConfigGeneric.getValue(this.props.data,this.props.attr);e==null&&(e=""),this.setState({_value:e.toString(),oldValue:e.toString()});const M=await this.props.oContext.socket.getAdapterInstances(),j=`system.adapter.${this.props.oContext.adapterName}.${this.props.oContext.instance}`,z=await this.props.oContext.socket.getObject(j),E=z==null?void 0:z.common.host,N=[];M.forEach(R=>{var H,A,_,k;if(!R||R._id===j||R.common.host!==E||!((H=R.native)!=null&&H.bind))return;if(R!=null&&R.native&&R.native.secure&&R.native.leEnabled&&R.native.leUpdate){const P=parseInt(R.native.leCheckPort||R.native.lePort,10);P&&N.push({name:`${R._id.replace("system.adapter.","")} (LE)`,port:P,v6bind:R.native.bind.includes(":")?R.native.bind:R.native.v6bind,bind:R.native.bind,enabled:!!((A=R.common)!=null&&A.enabled)})}const O=parseInt((_=R==null?void 0:R.native)==null?void 0:_.port,10);O&&N.push({name:R._id.replace("system.adapter.",""),bind:R.native.bind,v6bind:R.native.bind.includes(":")?R.native.bind:R.native.v6bind,port:O,enabled:!!((k=R.common)!=null&&k.enabled)})}),this.setState({ports:N})}static getDerivedStateFromProps(e,M){const j=ConfigGeneric.getValue(e.data,e.attr);return j==null||M.oldValue===null||M.oldValue===void 0||j.toString()!==parseInt(M._value,10).toString()&&j.toString()!==M.oldValue.toString()?{_value:j}:null}checkValue(e){if(e==null)return null;const M=this.props.schema.min===void 0?20:this.props.schema.min,j=this.props.schema.max||65535;e=e.toString().trim();const z=e===""?0:parseInt(e,10);return e!==""&&Number.isNaN(z)?"ra_Not a number":e!==""&&window.isFinite(Number(e))?z<M?"ra_Too small":z>j?"ra_Too big":e===""||e==="-"||Number.isNaN(z)?"ra_Not a number":null:"ra_Not a number"}renderItem(e,M){this.state.oldValue!==null&&this.state.oldValue!==void 0?(this.updateTimeout&&clearTimeout(this.updateTimeout),this.updateTimeout=setTimeout(()=>{this.updateTimeout=void 0,this.setState({oldValue:null})},30)):this.updateTimeout&&(clearTimeout(this.updateTimeout),this.updateTimeout=void 0);const j=this.props.schema.min===void 0?20:this.props.schema.min,z=this.props.schema.max||65535;let E;if(this.state.ports){const N=parseInt(this.state._value,10);if(N){const R=this.props.data.bind,O=this.state.ports.filter(A=>{if(A.port!==N)return!1;const _=A.bind,k=A.v6bind;return!R||!_||R==="0.0.0.0"||_==="0.0.0.0"||R==="::"||k==="::"||R===_||R===k});let H=O.findIndex(A=>A.port===N&&A.enabled);if(H!==-1){const A=this.state.ports.find(_=>_.port===N&&_.enabled&&O.some(k=>k.name===_.name&&k.bind===_.bind));e=I18n.t("ra_Port is already used by %s",(A==null?void 0:A.name)||O[H].name)}else if(H=O.findIndex(A=>A.port===N&&!A.enabled),H!==-1){E=!0;const A=this.state.ports.find(_=>_.port===N&&!_.enabled&&O.some(k=>k.name===_.name&&k.bind===_.bind));e=I18n.t("ra_Port could be used by %s",(A==null?void 0:A.name)||O[H].name)}}}return!e&&this.state._value!==null&&this.state._value!==void 0&&(e=this.checkValue(this.state._value),typeof e=="string"&&(e=I18n.t(e))),React.createElement(TextField,{variant:"standard",type:"number",fullWidth:!0,slotProps:{htmlInput:{min:j,max:z,readOnly:this.props.schema.readOnly||!1}},value:this.state._value===null||this.state._value===void 0?"":this.state._value,error:!!e,disabled:!!M,sx:E?styles$k.warning:void 0,onChange:N=>{const R=Number(N.target.value.toString().replace(/[^0-9]/g,"")).toString(),O=this.checkValue(R);O?this.onError(this.props.attr,I18n.t(O)):this.onError(this.props.attr),this.setState({_value:R,oldValue:this.state._value},()=>{if(R.trim()===parseInt(R,10).toString()){const H=this.onChange(this.props.attr,parseInt(R,10)||0);H instanceof Promise&&H.catch(A=>{console.error(`Cannot set value for ${this.props.attr}: ${A}`)})}})},placeholder:this.getText(this.props.schema.placeholder),label:this.getText(this.props.schema.label),helperText:e&&typeof e=="string"?e:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)})}}class ConfigRoom extends ConfigGeneric{componentDidMount(){super.componentDidMount();const o=ConfigGeneric.getValue(this.props.data,this.props.attr);this.props.oContext.socket.getEnums("rooms").then(e=>{const M=Object.keys(e).map(j=>({value:this.props.schema.short?j.replace("enum.rooms.",""):j,label:this.getText(e[j].common.name),obj:e[j]}));this.props.schema.allowDeactivate!==!1&&M.unshift({label:I18n.t(ConfigGeneric.NONE_LABEL),value:ConfigGeneric.NONE_VALUE}),this.setState({value:o,selectOptions:M})}).catch(e=>console.error(`Cannot get enums: ${e}`))}renderItem(o,e){if(!this.state.selectOptions)return null;const M=this.state.selectOptions.find(j=>j.value===this.state.value);return React.createElement(FormControl,{variant:"standard",fullWidth:!0},this.props.schema.label?React.createElement(InputLabel,null,this.getText(this.props.schema.label)):null,React.createElement(Select,{variant:"standard",error:!!o,disabled:!!e,value:this.state.value||"_",renderValue:()=>M?M.obj?React.createElement(TextWithIcon,{value:M.obj,themeType:this.props.oContext.themeType,lang:I18n.getLanguage()}):M.label:"",onChange:j=>{this.setState({value:j.target.value==="_"?"":j.target.value},()=>this.onChange(this.props.attr,this.state.value))}},this.state.selectOptions.map(j=>React.createElement(MenuItem,{key:j.value,value:j.value,style:j.value===ConfigGeneric.DIFFERENT_VALUE?{opacity:.5}:{}},j.obj?React.createElement(TextWithIcon,{value:j.obj,themeType:this.props.oContext.themeType,lang:I18n.getLanguage()}):j.label))),this.props.schema.help?React.createElement(FormHelperText,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}const styles$j={noMargin:{"&>div":{marginTop:0}}};class ConfigSelect extends ConfigGeneric{constructor(){super(...arguments);_1(this,"initialValue","")}componentDidMount(){super.componentDidMount();let e=ConfigGeneric.getValue(this.props.data,this.props.attr);this.props.schema.multiple&&(typeof e=="string"?e=[e]:e==null&&(e=[]));const M=[];(this.props.schema.options||[]).forEach(j=>{const z=j;Array.isArray(z.items)?(M.push({label:this.getText(j.label,this.props.schema.noTranslation),value:j.value,group:!0,color:j.color}),z.items.forEach(E=>M.push({label:this.getText(E.label,this.props.schema.noTranslation),value:E.value,hidden:E.hidden,color:j.color}))):M.push({label:this.getText(j.label,this.props.schema.noTranslation),value:j.value,hidden:j.hidden,color:j.color})}),Array.isArray(e)&&!this.props.schema.multiple?(this.initialValue=[...e],M.unshift({label:I18n.t(ConfigGeneric.DIFFERENT_LABEL),value:ConfigGeneric.DIFFERENT_VALUE}),this.setState({value:ConfigGeneric.DIFFERENT_VALUE,selectOptions:M})):this.setState({value:e,selectOptions:M})}_getValue(){let e=this.state.value===null||this.state.value===void 0?ConfigGeneric.getValue(this.props.data,this.props.attr):this.state.value;return this.props.schema.multiple&&(typeof e=="string"?e=[e]:e==null&&(e=[])),e}renderItem(e,M){if(!this.state.selectOptions)return null;const j=(this.state.selectOptions||[]).filter(N=>N.hidden?this.props.custom?!this.executeCustom(N.hidden,this.props.data,this.props.customObj,this.props.oContext.instanceObj,this.props.arrayIndex,this.props.globalData):!this.execute(N.hidden,this.props.schema.default,this.props.data,this.props.arrayIndex,this.props.globalData):!0),z=this._getValue(),E=this.props.schema.multiple?null:j.find(N=>N.value==z);return React.createElement(FormControl,{variant:"standard",fullWidth:!0,sx:this.props.table!==void 0&&styles$j.noMargin,id:`jsonSelect_${this.props.attr}_${this.props.index||this.props.index===0?this.props.index:""}`},this.props.schema.label?React.createElement(InputLabel,null,this.getText(this.props.schema.label)):null,React.createElement(Select,{variant:"standard",error:!!e,multiple:this.props.schema.multiple,disabled:!!M,value:z||"_",renderValue:N=>this.props.schema.multiple?React.createElement("div",{style:{display:"flex",flexWrap:"wrap",gap:.5}},N.map(R=>{const O=j.find(H=>H.value===R);if(O||this.props.schema.showAllValues!==!1){const H=(O==null?void 0:O.label)||R;return React.createElement(Chip,{key:R,label:H})}return null})):E!=null&&E.color?React.createElement("div",{style:{color:E.color}},(E==null?void 0:E.label)===void 0?N:E.label):(E==null?void 0:E.label)===void 0?N:E.label,onChange:N=>{this.setState({value:N.target.value==="_"?"":N.target.value},()=>{let R;this.state.value===ConfigGeneric.DIFFERENT_VALUE?R=this.onChange(this.props.attr,this.initialValue):R=this.onChange(this.props.attr,this.state.value),R instanceof Promise&&R.catch(O=>console.error(O))})}},j.map((N,R)=>N.group?React.createElement(ListSubheader,{key:R,style:{color:N.color}},N.label):React.createElement(MenuItem,{key:R,value:N.value,style:N.value===ConfigGeneric.DIFFERENT_VALUE?{opacity:.5}:{}},this.props.schema.multiple?React.createElement(Checkbox,{checked:z.includes(N.value),onClick:()=>{const O=JSON.parse(JSON.stringify(this._getValue())),H=z.indexOf(N.value);H!==-1?O.splice(H,1):(O.push(N.value),O.sort()),this.setState({value:O},()=>this.onChange(this.props.attr,O))}}):null,React.createElement(ListItemText,{primary:N.label,style:{color:N.color}})))),this.props.schema.help?React.createElement(FormHelperText,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}const styles$i={menuPaper:{maxHeight:800}};class ConfigSelectSendTo extends ConfigGeneric{constructor(){super(...arguments);_1(this,"initialized",!1);_1(this,"localContext")}askInstance(){if(this.props.alive){let e=this.props.schema.data;if(e===void 0&&this.props.schema.jsonData){const M=this.getPattern(this.props.schema.jsonData,null,!0);try{e=JSON.parse(M)}catch{console.error(`Cannot parse json data: ${M}`)}}e===void 0&&(e=null),this.setState({running:!0},()=>{this.props.oContext.socket.sendTo(`${this.props.oContext.adapterName}.${this.props.oContext.instance}`,this.props.schema.command||"send",e).then(M=>this.setState({list:M,running:!1})).catch(M=>{console.error(`Cannot send command: ${M}`)})})}else{const e=ConfigGeneric.getValue(this.props.data,this.props.attr);this.setState({value:e,running:!1})}}getContext(){const e={};return Array.isArray(this.props.schema.alsoDependsOn)&&this.props.schema.alsoDependsOn.forEach(M=>e[M]=ConfigGeneric.getValue(this.props.data,M)),JSON.stringify(e)}_getValue(){let e=this.state.value===null||this.state.value===void 0?ConfigGeneric.getValue(this.props.data,this.props.attr):this.state.value;return this.props.schema.multiple&&(typeof e=="string"?e=[e]:e==null&&(e=[])),e}renderItem(e,M){if(this.props.alive){const N=this.getContext();(N!==this.localContext||!this.initialized)&&(this.localContext=N,setTimeout(()=>this.askInstance(),this.initialized?300:50),this.initialized=!0)}const j=this._getValue();if(!this.props.alive||!this.state.running&&!Array.isArray(this.state.list))return this.props.schema.multiple||this.props.schema.manual===!1?I18n.t("ra_Cannot retrieve options, as instance is offline"):React.createElement(TextField,{variant:"standard",fullWidth:!0,value:j,error:!!e,disabled:!!M,onChange:N=>{const R=N.target.value;this.setState({value:R},()=>this.onChange(this.props.attr,(R||"").trim()))},placeholder:this.getText(this.props.schema.placeholder),label:this.getText(this.props.schema.label),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation),slotProps:{input:{endAdornment:this.state.value&&!this.props.schema.noClearButton?React.createElement(InputAdornment,{position:"end"},React.createElement(IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setState({value:""},()=>this.onChange(this.props.attr,""))},React.createElement(CloseIcon,null))):null}}});if(this.state.running)return React.createElement(CircularProgress,{size:"24"});const z=this.state.list.filter(N=>N.hidden?this.props.custom?!this.executeCustom(N.hidden,this.props.data,this.props.customObj,this.props.oContext.instanceObj,this.props.arrayIndex,this.props.globalData):!this.execute(N.hidden,this.props.schema.default,this.props.data,this.props.arrayIndex,this.props.globalData):!0),E=z.find(N=>N.value===j);return React.createElement(FormControl,{variant:"standard",fullWidth:!0},this.props.schema.label?React.createElement(InputLabel,null,this.getText(this.props.schema.label)):null,React.createElement(Select,{variant:"standard",error:!!e,multiple:this.props.schema.multiple,disabled:!!M,sx:{"&.MuiSelect-paper":this.props.schema.multiple?styles$i.menuPaper:void 0},value:j,renderValue:N=>this.props.schema.multiple?React.createElement(Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5}},N.map(R=>{const O=z.find(H=>H.value===R);if(O||this.props.schema.showAllValues!==!1){const H=(O==null?void 0:O.label)||R;return React.createElement(Chip,{key:R,label:H})}return null})):this.getText((E==null?void 0:E.label)||N,this.props.schema.noTranslation),onChange:N=>{const R=this.onChange(this.props.attr,N.target.value);R instanceof Promise&&R.catch(O=>console.error(`Cannot set value: ${O}`))}},z.map((N,R)=>N.group?React.createElement(ListSubheader,{key:R},this.getText(N.label,this.props.schema.noTranslation)):React.createElement(MenuItem,{key:R,value:N.value},this.props.schema.multiple?React.createElement(Checkbox,{checked:j.includes(N.value),onClick:()=>{const O=JSON.parse(JSON.stringify(this._getValue())),H=j.indexOf(N.value);H!==-1?O.splice(H,1):(O.push(N.value),O.sort()),this.setState({value:O},()=>this.onChange(this.props.attr,O))}}):null,React.createElement(ListItemText,{primary:N.label})))),this.props.schema.help?React.createElement(FormHelperText,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}const styles$h={fullWidth:{width:"100%"}};function ip2int(t){return t.split(".").reduce((o,e)=>(o<<8)+parseInt(e,10),0)>>>0}function findNetworkAddressOfHost(t,o){var j,z;const e=(z=(j=t==null?void 0:t.native)==null?void 0:j.hardware)==null?void 0:z.networkInterfaces;if(!e)return null;let M;return Object.keys(e).forEach(E=>e[E].forEach(N=>{N.internal||o.includes(":")&&N.family!=="IPv6"||o.includes(".")&&!o.match(/[^.\d]/)&&N.family!=="IPv4"||(N.family==="IPv4"&&!N.address.startsWith("172")&&(o==="127.0.0.0"||o==="localhost"||o.match(/[^.\d]/))?M=N.address:M||(N.family==="IPv4"&&o.includes(".")&&(ip2int(o)&ip2int(N.netmask),ip2int(N.address)&ip2int(N.netmask)),M=N.address))})),M||Object.keys(e).forEach(E=>e[E].forEach(N=>{N.internal||o.includes(":")&&N.family!=="IPv6"||o.includes(".")&&!o.match(/[^.\d]/)&&N.family!=="IPv4"||(N.family==="IPv6"&&(o==="127.0.0.0"||o==="localhost"||o.match(/[^.\d]/))?M=N.address:M||(N.family==="IPv4"&&o.includes(".")&&(ip2int(o)&ip2int(N.netmask),ip2int(N.address)&ip2int(N.netmask)),M=N.address))})),M||Object.keys(e).forEach(E=>{e[E].forEach(N=>{N.internal||o.includes(":")&&N.family!=="IPv6"||o.includes(".")&&!o.match(/[^.\d]/)&&N.family!=="IPv4"||(o==="127.0.0.0"||o==="localhost"||o.match(/[^.\d]/),M=N.address)})}),M||Object.keys(e).forEach(E=>{e[E].forEach(N=>{N.internal||(M=N.address)})}),M}class ConfigSendto extends ConfigGeneric{async componentDidMount(){var e;super.componentDidMount();let o=window.location.hostname;if(this.props.schema.openUrl){const M=await this.props.oContext.socket.getCurrentInstance(),j=await this.props.oContext.socket.getObject(`system.adapter.${M}`);if(j){const z=await this.props.oContext.socket.getObject(`system.host.${(e=j==null?void 0:j.common)==null?void 0:e.host}`);if(z){const E=findNetworkAddressOfHost(z,window.location.hostname);if(E)o=`${E}:${window.location.port}`;else{console.warn(`Cannot find suitable IP in host ${j.common.host} for ${j._id}`);return}}}}await new Promise(M=>{this.setState({_error:"",_message:"",hostname:o},M)}),this.props.schema.onLoaded&&this._onClick()}renderErrorDialog(){return this.state._error?React.createElement(DialogError,{text:this.state._error,onClose:()=>this.setState({_error:""})}):null}renderMessageDialog(){return this.state._message?React.createElement(DialogMessage,{text:this.state._message,onClose:()=>this.setState({_message:""})}):null}_onClick(){this.props.oContext.onCommandRunning(!0),this.setState({running:!0});const o=`${window.location.protocol}//${window.location.host}${window.location.pathname.replace(/\/index\.html$/,"")}`,e=`${window.location.protocol}//${this.state.hostname.split(":").length>3?`[${this.state.hostname}]`:this.state.hostname}${window.location.pathname.replace(/\/index\.html$/,"")}`;let M=this.props.schema.data;if(M===void 0&&this.props.schema.jsonData){const z=this.getPattern(this.props.schema.jsonData,{_origin:o,_originIp:e,...this.props.data},!0);try{M=JSON.parse(z)}catch{console.error(`Cannot parse json data: ${z}`)}}M===void 0&&(M=null),this.props.schema.openUrl&&!M&&(M={_origin:o,_originIp:e});let j;this.props.schema.timeout&&(j=setTimeout(()=>{this.props.oContext.onCommandRunning(!1),this.setState({_error:I18n.t("ra_Request timed out"),running:!1})},parseInt(this.props.schema.timeout,10)||1e4)),this.props.oContext.socket.sendTo(`${this.props.oContext.adapterName}.${this.props.oContext.instance}`,this.props.schema.command||"send",M).then(async z=>{var E,N,R,O,H;if(j&&(clearTimeout(j),j=void 0),z!=null&&z.error)if(this.props.schema.error&&this.props.schema.error[z.error]){let A=this.getText(this.props.schema.error[z.error]);(E=z.args)==null||E.forEach(_=>A=A.replace("%s",_)),this.setState({_error:A})}else this.setState({_error:z.error?typeof z.error=="string"?I18n.t(z.error):JSON.stringify(z.error):I18n.t("ra_Error")});else{if(z!=null&&z.command){(R=(N=this.props.oContext).onBackEndCommand)==null||R.call(N,z.command);return}if(z!=null&&z.reloadBrowser&&this.props.schema.reloadBrowser)window.location.reload();else if(z!=null&&z.openUrl&&this.props.schema.openUrl)window.open(z.openUrl,z.window||this.props.schema.window||"_blank");else if(z!=null&&z.result&&((O=this.props.schema.result)!=null&&O[z.result])){let A=this.getText(this.props.schema.result[z.result]);(H=z.args)==null||H.forEach(_=>A=A.replace("%s",_)),window.alert(A)}if(z!=null&&z.native&&this.props.schema.useNative){for(const[A,_]of Object.entries(z.native))await this.onChangeAsync(A,_);setTimeout(()=>this.props.oContext.forceUpdate(Object.keys(z.native),this.props.data),300)}else z!=null&&z.result?window.alert(typeof z.result=="object"?JSON.stringify(z.result):z.result):window.alert(I18n.t("ra_Ok"));z!=null&&z.saveConfig&&this.props.onChange(null,null,null,!0)}}).catch(z=>{this.props.schema.error&&this.props.schema.error[z.toString()]?this.setState({_error:this.getText(this.props.schema.error[z.toString()])}):this.setState({_error:I18n.t(z.toString())||I18n.t("ra_Error")})}).then(()=>{this.props.oContext.onCommandRunning(!1),this.setState({running:!1})})}renderDialogConfirm(){if(!this.state.confirmDialog)return null;const o=this.state.confirmData||this.props.schema.confirm;let e=null;return o.type==="warning"?e=React.createElement(ErrorIcon,null):o.type==="error"?e=React.createElement(ErrorIcon$1,null):o.type==="info"&&(e=React.createElement(IconInfo,null)),React.createElement(DialogConfirm,{title:this.getText(o.title)||I18n.t("ra_Please confirm"),text:this.getText(o.text),ok:this.getText(o.ok)||I18n.t("ra_Ok"),cancel:this.getText(o.cancel)||I18n.t("ra_Cancel"),icon:e||void 0,onClose:M=>this.setState({confirmDialog:!1},()=>M&&this._onClick())})}renderItem(o,e){const M=this.getIcon();return React.createElement("div",{style:styles$h.fullWidth},React.createElement(Button,{variant:this.props.schema.variant||void 0,color:this.props.schema.color||"grey",style:{...styles$h.fullWidth,...this.props.schema.controlStyle||void 0},disabled:e||!this.props.alive,startIcon:M,title:this.props.alive?this.getText(this.props.schema.title)||"":I18n.t("ra_Instance is not alive"),onClick:()=>{this.props.schema.confirm?this.setState({confirmDialog:!0}):this._onClick()}},this.props.schema.showProcess&&this.state.running?React.createElement(CircularProgress,{size:20,style:{marginRight:8}}):null,this.getText(this.props.schema.label,this.props.schema.noTranslation)),this.renderErrorDialog(),this.renderMessageDialog())}}const styles$g={fullWidth:{width:"100%"}};class ConfigSetState extends ConfigGeneric{async _onClick(){var M,j;let o=this.props.schema.val;if(typeof o=="string"&&o.includes("${")){o=this.getPattern(o,null,!0);const z=await this.props.oContext.socket.getObject(this.props.schema.id);((M=z==null?void 0:z.common)==null?void 0:M.type)==="number"?o=parseFloat(o):((j=z==null?void 0:z.common)==null?void 0:j.type)==="boolean"&&(o=o==="true"||o===!0||o==="1"||o===1)}const e=(this.props.schema.id||"").replace(/%INSTANCE%/g,(this.props.oContext.instance||0).toString());try{await this.props.oContext.socket.setState(e,{val:o,ack:!!this.props.schema.ack}),this.props.schema.okText&&window.alert(this.getText(this.props.schema.okText))}catch(z){this.props.schema.error&&this.props.schema.error[z.toString()]?window.alert(this.getText(this.props.schema.error[z.toString()])):window.alert(I18n.t(z.toString())||I18n.t("ra_Error"))}}renderDialogConfirm(){if(!this.state.confirmDialog)return null;const o=this.state.confirmData||this.props.schema.confirm;let e=null;return o.type==="warning"?e=React.createElement(ErrorIcon,null):o.type==="error"?e=React.createElement(ErrorIcon$1,null):o.type==="info"&&(e=React.createElement(IconInfo,null)),React.createElement(DialogConfirm,{title:this.getText(o.title)||I18n.t("ra_Please confirm"),text:this.getText(o.text),ok:this.getText(o.ok)||I18n.t("ra_Ok"),cancel:this.getText(o.cancel)||I18n.t("ra_Cancel"),icon:e,onClose:M=>this.setState({confirmDialog:!1},()=>M&&this._onClick())})}renderItem(o,e){const M=this.getIcon();return React.createElement(Button,{variant:this.props.schema.variant||void 0,color:this.props.schema.color||"grey",style:styles$g.fullWidth,disabled:e,onClick:async()=>{this.props.schema.confirm?this.setState({confirmDialog:!0}):await this._onClick()},startIcon:M||void 0},this.getText(this.props.schema.label,this.props.schema.noTranslation))}}const styles$f={fullWidth:{width:"100%"},slider:{marginLeft:10,marginRight:10,width:"calc(100% - 20px)"}};class ConfigSlider extends ConfigGeneric{componentDidMount(){super.componentDidMount();const o=ConfigGeneric.getValue(this.props.data,this.props.attr);this.setState({_value:o})}static getDerivedStateFromProps(o,e){if(o.schema.min!==void 0&&o.schema.min<0||o.schema.max!==void 0&&o.schema.max<0)return null;const M=ConfigGeneric.getValue(o.data,o.attr);return M==null||M.toString()!==parseFloat(e._value).toString()?{_value:M}:null}renderItem(o,e){const M=this.props.schema.min||0,j=this.props.schema.max||100,z=this.props.schema.unit?this.getText(this.props.schema.unit,this.props.schema.noTranslation):"",E=[{value:M,label:M+z},{value:j,label:j+z}];return React.createElement(Box,{style:styles$f.fullWidth},this.props.schema.label?React.createElement(Typography,{gutterBottom:!0},this.getText(this.props.schema.label)):null,React.createElement(Slider$1,{style:styles$f.slider,value:this.state._value,getAriaValueText:N=>N+z,step:this.props.schema.step||(j-M)/100,valueLabelDisplay:"auto",marks:E,min:M,max:j,disabled:!!e,onChange:N=>{const R=N.target.value;this.setState({_value:R},()=>this.onChange(this.props.attr,R))}}),this.props.schema.help?React.createElement(Typography,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}function getIconByName(t,o){return t==="edit"||t==="rename"?React.createElement(Edit,{style:o}):t==="delete"?React.createElement(DeleteIcon,{style:o}):t==="refresh"?React.createElement(Refresh,{style:o}):t==="newDevice"||t==="new"||t==="add"?React.createElement(AddIcon,{style:o}):t==="discover"||t==="search"?React.createElement(Search,{style:o}):t==="unpairDevice"||t==="unpair"?React.createElement(LinkOff,{style:o}):t==="pairDevice"||t==="pair"?React.createElement(LinkIcon,{style:o}):t==="identify"?React.createElement(NotListedLocation,{style:o}):t==="play"?React.createElement(PlayArrow,{style:o}):t==="stop"?React.createElement(Stop,{style:o}):t==="pause"?React.createElement(Pause,{style:o}):t==="forward"||t==="next"?React.createElement(FastForward,{style:o}):t==="rewind"||t==="previous"?React.createElement(FastRewind,{style:o}):t==="lamp"||t==="light"?React.createElement(Lightbulb,{style:o}):t==="backlight"?React.createElement(Fluorescent,{style:o}):t==="dimmer"?React.createElement(WbIncandescent,{style:o}):t==="socket"?React.createElement(Power,{style:o}):t==="settings"?React.createElement(Settings$c,{style:o}):t==="users"||t==="group"?React.createElement(Group,{style:o}):t==="user"?React.createElement(Person,{style:o}):t==="qrcode"?React.createElement(QrCode,{style:o}):t==="connection"?React.createElement(Wifi,{style:o}):t==="no-connection"?React.createElement(WifiOff,{style:o}):t==="visible"?React.createElement(Visibility,{style:o}):null}function valueBlinkOnce$1(t,o){return typeof o=="string"?{"@keyframes newStateAnimationOnceColor":{"0%":{color:o},"100%":{color:t.palette.mode==="dark"?"#fff":"#000"}},animation:"newStateAnimationOnceColor 2s ease-in-out"}:{"@keyframes newStateAnimationOnce":{"0%":{color:"#00f900"},"80%":{color:t.palette.mode==="dark"?"#518851":"#008000"},"100%":{color:t.palette.mode==="dark"?"#fff":"#000"}},animation:"newStateAnimationOnce 2s ease-in-out"}}class ConfigState extends ConfigGeneric{constructor(){super(...arguments);_1(this,"controlTimeout",null);_1(this,"delayedUpdate",{timer:null,value:null});_1(this,"onStateChanged",(e,M)=>{let j=M?M.val:null;this.state.controlType==="button"||this.state.controlType==="switch"?(j=!!j,this.state.stateValue!==j&&this.setState({stateValue:j})):j!==null&&(this.state.controlType==="slider"||this.state.controlType==="number")?(j=parseFloat(j),console.log(`${Date.now()} Received new value: ${j}`),j!==this.state.stateValue?(this.delayedUpdate.timer&&(clearTimeout(this.delayedUpdate.timer),this.delayedUpdate.timer=null),this.delayedUpdate.value=j,this.delayedUpdate.timer=setTimeout(()=>{this.setState({stateValue:this.delayedUpdate.value})},500)):this.delayedUpdate.timer&&(clearTimeout(this.delayedUpdate.timer),this.delayedUpdate.timer=null)):this.state.stateValue.toString()!==j.toString()&&this.setState({stateValue:j})})}getObjectID(){let e=(this.props.schema.oid||"").toString();return e.includes("${")&&(e=this.getPattern(e,null,!0)),this.props.schema.foreign?e:`${this.props.schema.system?"system.adapter.":""}${this.props.oContext.adapterName}.${this.props.oContext.instance||0}.${e}`}async componentDidMount(){var j,z;super.componentDidMount();const e=await this.props.oContext.socket.getObject(this.getObjectID());if((j=e==null?void 0:e.common)!=null&&j.states&&!this.props.schema.options){if(Array.isArray((z=e==null?void 0:e.common)==null?void 0:z.states)){const E={};e.common.states.forEach((N,R)=>{E[R.toString()]=N}),e.common.states=E}Object.keys(e.common.states).length||(e.common.states=void 0)}const M=this.props.schema.control||this.detectType(e);try{const E=await this.props.oContext.socket.getState(this.getObjectID());this.setState({stateValue:E?E.val:null,controlType:M,obj:e},async()=>{await this.props.oContext.socket.subscribeState(this.getObjectID(),this.onStateChanged)})}catch(E){console.error(`Cannot get state ${this.getObjectID()}: ${E}`),this.setState({controlType:M,obj:e})}}componentWillUnmount(){super.componentWillUnmount(),this.props.oContext.socket.unsubscribeState(this.getObjectID(),this.onStateChanged),this.delayedUpdate.timer&&(clearTimeout(this.delayedUpdate.timer),this.delayedUpdate.timer=null),this.controlTimeout&&(clearTimeout(this.controlTimeout),this.controlTimeout=null,this.props.oContext.socket.setState(this.getObjectID(),this.state.stateValue,!1).catch(e=>console.error(`Cannot control value: ${e.toString()}`)))}detectType(e){if(e||(e={}),e.common||(e.common={}),e.common.type==="boolean"){if(this.props.schema.controlled!==!1){if(e.common.read===!1||this.props.schema.controlled===!0)return"button";if(e.common.write||this.props.schema.controlled===!0)return"switch"}return"text"}return e.common.type==="number"&&this.props.schema.controlled!==!1?e.common.write||this.props.schema.controlled===!0?e.common.states||this.props.schema.options?"select":e.common.max!==void 0?"slider":"input":"text":e.common.write&&this.props.schema.controlled!==!1?e.common.states||this.props.schema.options?"select":"input":"text"}getNormalizedStates(){let e;return this.props.schema.options?e=this.props.schema.options.map(M=>typeof M=="string"?{value:M,label:this.getText(M,this.props.schema.noTranslation)}:{value:M.value,label:this.getText(M.label,this.props.schema.noTranslation),color:M.color}):this.state.obj.common.states?(e=[],Object.keys(this.state.obj.common.states).forEach(M=>{e.push({value:M,label:this.getText(this.state.obj.common.states[M],this.props.schema.noTranslation)})})):e=[],e}renderItem(e,M){var z,E,N,R,O;if(!this.state.obj)return null;let j;if(this.state.controlType==="select"||!this.state.controlType&&(this.state.obj.common.type==="number"||this.state.obj.common.type==="string")&&this.state.obj.common.write!==!1&&(this.props.schema.options||this.state.obj.common.states)){const H=this.getNormalizedStates(),A=H.find(_=>_.value===this.state.stateValue);j=React.createElement(FormControl,{fullWidth:!0},React.createElement(InputLabel,null,"$",this.getText(this.props.schema.label)),React.createElement(Select,{value:this.state.stateValue,disabled:!!this.props.schema.readOnly||M,onChange:_=>{this.setState({stateValue:_.target.value},()=>{let k=this.state.stateValue;this.state.obj.common.type==="number"&&(k=parseFloat(k.toString().replace(",","."))),this.props.oContext.socket.setState(this.getObjectID(),k,!1)})},renderValue:_=>A!=null&&A.color?React.createElement("div",{style:{color:A.color}},A.label):_},H.map(_=>React.createElement(MenuItem,{key:(_.value??"").toString(),value:_.value,style:{color:_.color}},"$",_.label))))}else if(this.state.controlType==="button"||!this.state.controlType&&this.state.obj.common.type==="boolean"&&(this.state.obj.common.write&&this.state.obj.common.read===!1||(z=this.state.obj.common.role)!=null&&z.includes("button"))){let H=null;this.props.schema.falseImage&&(H=getIconByName(this.props.schema.falseImage));const A=this.getText(this.props.schema.falseText||this.props.schema.label,this.props.schema.noTranslation);!A&&H?j=React.createElement(IconButton,{style:this.props.schema.falseTextStyle,disabled:!!this.props.schema.readOnly,onClick:async()=>{this.props.schema.confirm?this.setState({confirmDialog:!0,confirmCallback:async _=>{_&&await this.props.oContext.socket.setState(this.getObjectID(),this.props.schema.buttonValue!==void 0?this.props.schema.buttonValue:!0,!1)}}):await this.props.oContext.socket.setState(this.getObjectID(),this.props.schema.buttonValue!==void 0?this.props.schema.buttonValue:!0,!1)}},H):j=React.createElement(Button,{variant:this.props.schema.variant||"contained",startIcon:H,style:this.props.schema.falseTextStyle,disabled:M||!!this.props.schema.readOnly,onClick:async()=>{this.props.schema.confirm?this.setState({confirmDialog:!0,confirmCallback:async _=>{_&&await this.props.oContext.socket.setState(this.getObjectID(),this.props.schema.buttonValue!==void 0?this.props.schema.buttonValue:!0,!1)}}):await this.props.oContext.socket.setState(this.getObjectID(),this.props.schema.buttonValue!==void 0?this.props.schema.buttonValue:!0,!1)}},A||this.getObjectID().split(".").pop())}else if(this.state.controlType==="input"||!this.state.controlType&&this.state.obj.common.write&&this.state.obj.common.type==="string")j=React.createElement("div",{style:{width:"100%",display:"flex",flexDirection:"row",gap:8,alignItems:"baseline"}},React.createElement(TextField,{style:{flex:1},value:this.state.stateValue,variant:"standard",disabled:!!this.props.schema.readOnly||M,slotProps:{input:{endAdornment:this.getText(this.props.schema.unit,this.props.schema.noTranslation)||this.state.obj.common.unit||void 0},htmlInput:{readOnly:!!this.props.schema.readOnly}},onKeyUp:H=>{this.props.schema.setOnEnterKey&&H.key==="Enter"&&this.props.oContext.socket.setState(this.getObjectID(),this.state.stateValue,!1)},onChange:H=>{this.setState({stateValue:H.target.value},()=>{this.props.schema.setOnEnterKey||this.props.schema.showEnterButton||(this.controlTimeout&&clearTimeout(this.controlTimeout),this.controlTimeout=setTimeout(async()=>{this.controlTimeout=null;let A=this.state.stateValue;this.state.obj.common.type==="number"&&(A=parseFloat(A.toString().replace(",","."))),await this.props.oContext.socket.setState(this.getObjectID(),A,!1)},this.props.schema.controlDelay||0))})},label:this.getText(this.props.schema.label),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)}),this.props.schema.showEnterButton&&!this.props.schema.readOnly&&React.createElement(Button,{variant:"outlined",disabled:M,onClick:()=>{this.props.oContext.socket.setState(this.getObjectID(),this.state.stateValue,!1)}},this.getText(typeof this.props.schema.showEnterButton=="string"?this.props.schema.showEnterButton:"Set")));else{let H;this.props.schema.size==="normal"?H=16:this.props.schema.size==="large"?H=20:typeof this.props.schema.size=="number"&&(H=this.props.schema.size);let A=this.getText(this.props.schema.label,this.props.schema.noTranslation);const _={display:"flex",alignItems:"center",fontSize:H||"1rem",gap:8};this.props.schema.narrow||(_.width="100%",_.justifyContent="space-between"),A.trim()&&!A.trim().endsWith(":")&&this.props.schema.addColon&&(A=`${A.trim()}:`);let k;this.props.schema.blinkOnUpdate&&(k=valueBlinkOnce$1(this.props.oContext.theme,this.props.schema.blinkOnUpdate));let P;this.props.schema.labelIcon&&(P=React.createElement(Icon,{src:this.props.schema.labelIcon,style:{marginRight:4}}));let B;if(A&&P?B=React.createElement("div",{style:{whiteSpace:"nowrap"}},P,A):A?B=React.createElement("div",{style:{whiteSpace:"nowrap"}},A):P&&(B=P),this.state.controlType==="switch"||!this.state.controlType&&this.state.obj.common.type==="boolean"&&(this.state.obj.common.write&&this.state.obj.common.read!==!1||(E=this.state.obj.common.role)!=null&&E.includes("switch"))){let e1=null;const s1=this.getText(this.props.schema.falseText,this.props.schema.noTranslation);this.props.schema.falseImage&&(e1=getIconByName(this.props.schema.falseImage,s1?{marginLeft:8}:void 0));let n1=null;const l1=this.getText(this.props.schema.trueText,this.props.schema.noTranslation);this.props.schema.trueImage&&(n1=getIconByName(this.props.schema.trueImage,l1?{marginRight:8}:void 0)),j=React.createElement(Switch,{checked:!!this.state.stateValue,disabled:!!this.props.schema.readOnly||M,onChange:async()=>{this.props.schema.confirm?this.setState({confirmDialog:!0,confirmCallback:async c1=>{c1&&await this.props.oContext.socket.setState(this.getObjectID(),!this.state.stateValue,!1)}}):await this.props.oContext.socket.setState(this.getObjectID(),!this.state.stateValue,!1)}}),(s1||e1||l1||n1)&&(j=React.createElement("div",{style:{display:"flex",alignItems:"center",fontSize:14}},React.createElement("span",{style:this.props.schema.falseTextStyle},s1,e1),j,React.createElement("span",{style:this.props.schema.trueTextStyle},n1,l1))),B&&(j=React.createElement("div",{style:_},B,j))}else if(this.state.controlType==="slider"||!this.state.controlType&&this.state.obj.common.type==="number"&&(this.state.obj.common.write&&(this.state.obj.common.max!==void 0||this.state.obj.common.unit==="%")||(N=this.state.obj.common.role)!=null&&N.includes("slider")||(R=this.state.obj.common.role)!=null&&R.includes("dimmer")||(O=this.state.obj.common.role)!=null&&O.includes("blind"))){let e1=null;const s1=this.getText(this.props.schema.falseText,this.props.schema.noTranslation);this.props.schema.falseImage&&(e1=getIconByName(this.props.schema.falseImage,s1?{marginLeft:8}:void 0));let n1=null;const l1=this.getText(this.props.schema.trueText,this.props.schema.noTranslation);this.props.schema.trueImage&&(n1=getIconByName(this.props.schema.trueImage,l1?{marginRight:8}:void 0));const c1=this.props.schema.min===void 0?this.state.obj.common.min||0:this.props.schema.min,r1=this.props.schema.max===void 0?this.state.obj.common.max===void 0?100:this.state.obj.common.max:this.props.schema.max,o1=this.props.schema.step===void 0?this.state.obj.common.step||1:this.props.schema.step;j=React.createElement(Slider$1,{style:{width:"100%",flexGrow:1},min:c1,max:r1,disabled:!!this.props.schema.readOnly||M,step:o1,value:this.state.stateValue,valueLabelDisplay:"auto",valueLabelFormat:a1=>`${a1}${this.getText(this.props.schema.unit,this.props.schema.noTranslation)||this.state.obj.common.unit||""}`,onChange:(a1,m1)=>{this.setState({stateValue:m1},()=>{this.controlTimeout&&clearTimeout(this.controlTimeout),this.controlTimeout=setTimeout(async()=>{console.log(`${Date.now()} Send new value: ${this.state.stateValue}`),this.controlTimeout=null,await this.props.oContext.socket.setState(this.getObjectID(),this.state.stateValue,!1)},this.props.schema.controlDelay||0)})}}),(s1||e1||l1||n1)&&(j=React.createElement("div",{style:{display:"flex",width:"100%",flexGrow:1,alignItems:"center"}},React.createElement("span",{style:{marginRight:16,...this.props.schema.falseTextStyle}},s1,e1),j,React.createElement("span",{style:{marginLeft:16,...this.props.schema.trueTextStyle}},n1,l1))),B&&(j=React.createElement("div",{style:_},B,j))}else if(this.state.obj.common.type==="number"&&this.state.obj.common.write&&!this.state.controlType){const e1=this.props.schema.min===void 0?this.state.obj.common.min===void 0?void 0:this.state.obj.common.min:this.props.schema.min,s1=this.props.schema.max===void 0?this.state.obj.common.max===void 0?void 0:this.state.obj.common.max:this.props.schema.max,n1=this.props.schema.step===void 0?this.state.obj.common.step===void 0?void 0:this.state.obj.common.step:this.props.schema.step;j=React.createElement(TextField,{variant:"standard",style:{width:"100%"},value:this.state.stateValue,type:"number",disabled:!!this.props.schema.readOnly||M,slotProps:{htmlInput:{min:e1,max:s1,step:n1,readOnly:!!this.props.schema.readOnly},input:{endAdornment:this.getText(this.props.schema.unit,this.props.schema.noTranslation)||this.state.obj.common.unit||void 0}},onChange:l1=>{this.setState({stateValue:l1.target.value},()=>{this.controlTimeout&&clearTimeout(this.controlTimeout),this.controlTimeout=setTimeout(async()=>{this.controlTimeout=null;const c1=parseFloat(this.state.stateValue);await this.props.oContext.socket.setState(this.getObjectID(),c1,!1)},this.props.schema.controlDelay||0)})},label:this.getText(this.props.schema.label,this.props.schema.noTranslation),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)})}else if(this.state.obj.common.type==="boolean"){let e1=null,s1,n1;this.state.stateValue?(s1=this.getText(this.props.schema.trueText,this.props.schema.noTranslation),this.props.schema.trueImage&&(e1=getIconByName(this.props.schema.falseImage,s1?{marginRight:8}:void 0)),n1=this.props.schema.trueTextStyle):(s1=this.getText(this.props.schema.falseText,this.props.schema.noTranslation),this.props.schema.falseImage&&(e1=getIconByName(this.props.schema.falseImage,s1?{marginLeft:8}:void 0)),n1=this.props.schema.falseTextStyle),n1=Object.assign(_,n1),j=React.createElement("div",{style:n1},B,React.createElement(Box,{style:{display:"flex",alignItems:"center",gap:8},sx:k,key:this.props.schema.blinkOnUpdate?s1:void 0},e1,s1||(this.state.stateValue?I18n.t("ra_true"):I18n.t("ra_false"))))}else{const e1=this.getText(this.props.schema.unit,this.props.schema.noTranslation)||this.state.obj.common.unit;let s1=this.state.stateValue;if(s1!=null&&(this.props.schema.options||this.state.obj.common.states)){const r1=this.getNormalizedStates().find(o1=>o1.value===s1);r1&&(s1=r1.label)}let n1,l1;this.state.controlType==="html"?(l1=(s1||"").toString(),n1=React.createElement("span",{dangerouslySetInnerHTML:{__html:s1}})):this.state.stateValue===null?(n1="null",l1=n1):this.state.stateValue===void 0?(n1="undefined",l1=n1):(n1=s1.toString(),l1=n1),j=React.createElement("div",{style:_},B,React.createElement("div",{style:{display:"flex",alignItems:"baseline",gap:4}},React.createElement(Box,{sx:k,key:this.props.schema.blinkOnUpdate?l1:void 0},n1),e1?React.createElement("span",{style:{opacity:.7,fontSize:"smaller"}},e1):null))}}return j}}const styles$e={fullWidth:t=>({width:"100%",backgroundColor:t.palette.mode==="dark"?"#FFF":"#000",borderStyle:"hidden"}),primary:t=>({backgroundColor:t.palette.primary.main}),secondary:t=>({backgroundColor:t.palette.secondary.main})};class ConfigStaticDivider extends ConfigGeneric{renderItem(){return React.createElement(Box,{component:"hr",sx:Utils.getStyle(this.props.oContext.theme,styles$e.fullWidth,this.props.schema.color==="primary"?styles$e.primary:this.props.schema.color==="secondary"?styles$e.secondary:{backgroundColor:this.props.schema.color||(this.props.oContext.themeType==="dark"?"#333":"#ddd")},{height:this.props.schema.color?this.props.schema.height||2:this.props.schema.height||1})})}}const styles$d={header:t=>({width:"100%",background:t.palette.primary.main,color:t.palette.primary.contrastText,padding:"4px !important",borderRadius:"3px",marginBlockEnd:0,marginBlockStart:0})};class ConfigStaticHeader extends ConfigGeneric{renderItem(){let o="h5";switch((this.props.schema.size||5).toString()){case"1":o="h1";break;case"2":o="h2";break;case"3":o="h3";break;case"4":o="h4";break;case"5":default:o="h5";break}return React.createElement(Box,{component:o,sx:styles$d.header},this.getText(this.props.schema.label||this.props.schema.text,this.props.schema.noTranslation))}}class ConfigStaticImage extends ConfigGeneric{renderItem(){let o=this.props.schema.src;return o&&!o.startsWith(".")&&!o.startsWith("http")&&!o.startsWith(`adapter/${this.props.oContext.adapterName}/`)&&!o.startsWith(`./adapter/${this.props.oContext.adapterName}/`)&&(o=`adapter/${this.props.oContext.adapterName}/${o}`),React.createElement("img",{src:o,style:{cursor:this.props.schema.href?"pointer":void 0,width:"100%",height:"100%"},onClick:this.props.schema.href?()=>this.props.schema.href&&window.open(this.props.schema.href,"_blank"):null,alt:""})}}function valueBlinkOnce(t,o,e){return typeof e=="string"?{"@keyframes newValueAnimationOnceColor":{"0%":{color:o?`${e} !important`:e},"100%":{color:t.palette.mode==="dark"?o?"#fff !important":"#fff":o?"#000 !important":"#000"}},animation:"newValueAnimationOnceColor 2s ease-in-out"}:{"@keyframes newValueAnimationOnce":{"0%":{color:o?"#00f900 !important":"#00f900"},"80%":{color:t.palette.mode==="dark"?o?"#518851 !important":"#518851":o?"#008000 !important":"#008000"},"100%":{color:t.palette.mode==="dark"?o?"#fff !important":"#fff":o?"#000 !important":"#000"}},animation:"newValueAnimationOnce 2s ease-in-out"}}function valueBlink(t,o){return typeof o=="string"?{"@keyframes blinkAnimationColor":{"0%":{color:o},"100%":{color:t.palette.mode==="dark"?"#fff":"#000"}},animation:"blinkAnimationColor 2s ease-in-out infinite"}:{"@keyframes blinkAnimation":{"0%":{color:"#00f900"},"80%":{color:t.palette.mode==="dark"?"#518851":"#008000"},"100%":{color:t.palette.mode==="dark"?"#fff":"#000"}},animation:"blinkAnimation 2s ease-in-out infinite"}}const styles$c={label:{fontWeight:"bold",whiteSpace:"nowrap"},valueImage:{maxHeight:"100%"},valueAndUnit:{display:"flex",gap:4,alignItems:"baseline"},value:{},unit:{fontSize:"smaller",opacity:.7}};class ConfigStaticInfo extends ConfigGeneric{renderItem(o){let e=this.getText(this.props.schema.text||this.props.schema.label,this.props.schema.noTranslation);this.props.schema.addColon&&typeof e=="string"&&!e.trim().endsWith(":")&&(e=`${e.trim()}:`),e&&(e.includes("<a ")||e.includes("<br")||e.includes("<b>")||e.includes("<i>"))&&(e=Utils.renderTextWithA(e));let M;this.props.schema.size==="normal"?M=16:this.props.schema.size==="large"?M=20:typeof this.props.schema.size=="number"&&(M=this.props.schema.size);const j={width:"100%",height:"100%",display:"flex",alignItems:"center",position:"relative",fontSize:M};this.props.schema.narrow?j.gap=8:j.justifyContent="space-between";let z,E;this.props.schema.data&&typeof this.props.schema.data=="object"&&this.props.schema.data.en?E=this.getText(this.props.schema.data):typeof this.props.schema.data=="object"||this.props.schema.data===void 0||this.props.schema.data===null?E=JSON.stringify(this.props.schema.data):typeof this.props.schema.data=="number"?(E=this.props.schema.data.toString(),this.props.oContext.isFloatComma&&(E=E.replace(".",","))):(!this.props.schema.booleanAsCheckbox||typeof this.props.schema.data!="boolean")&&(E=this.props.schema.data.toString());let N=!1;if(this.props.schema.booleanAsCheckbox&&typeof this.props.schema.data=="boolean")z=React.createElement(Checkbox,{checked:!!z,disabled:!0,size:this.props.schema.size==="small"?"small":this.props.schema.size==="large"?"large":void 0});else if(E.startsWith("data:image/"))z=React.createElement("div",{style:{...styles$c.value,...styles$c.valueImage,...this.props.schema.styleValue||void 0}},React.createElement(Icon,{src:E}));else{const A={...styles$c.value,...this.props.schema.styleValue||void 0};this.props.schema.html?z=React.createElement("div",{style:A,dangerouslySetInnerHTML:{__html:E}}):Array.isArray(this.props.schema.data)?(N=!0,z=React.createElement("div",{style:A},this.props.schema.data.map((_,k)=>React.createElement("div",{key:k},typeof _=="object"||_===null||_===void 0?JSON.stringify(_):_)))):E.includes(`
|
|
2607
2607
|
`)?(N=!0,z=React.createElement("div",{style:A},Utils.renderTextWithA(E))):z=React.createElement("div",{style:A},E)}if(this.props.schema.blinkOnUpdate&&this.props.schema.blink){const A=valueBlinkOnce(this.props.oContext.theme,!0,this.props.schema.blinkOnUpdate),_=valueBlink(this.props.oContext.theme,this.props.schema.blink);z=React.createElement(Box,{key:E,sx:{...A,..._}},z)}else if(this.props.schema.blinkOnUpdate){const A=valueBlinkOnce(this.props.oContext.theme,!1,this.props.schema.blinkOnUpdate);z=React.createElement(Box,{key:E,sx:A},z)}else if(this.props.schema.blink){const A=valueBlink(this.props.oContext.theme,this.props.schema.blink);z=React.createElement(Box,{sx:A},z)}this.props.schema.unit&&(z=React.createElement("div",{style:styles$c.valueAndUnit},z,React.createElement("div",{style:{...styles$c.unit,...this.props.schema.styleUnit||void 0}},this.getText(this.props.schema.unit,this.props.schema.noTranslation))));let R;this.props.schema.labelIcon&&(R=React.createElement(Icon,{src:this.props.schema.labelIcon,style:{marginRight:4}}));let O;this.props.schema.copyToClipboard&&(O=React.createElement(IconCopy$1,{className:"staticCopyButton",style:{position:"absolute",top:"calc(50% - 12px)",right:0,cursor:"pointer"},onClick:()=>{Utils.copyToClipboard(E),window.alert(I18n.t("ra_Copied"))}}));const H={"& .staticCopyButton":{display:"none"},"& .staticCopyButton:action":{transform:"scale(0.9)"},"&:hover .staticCopyButton":{display:"block"}};return this.props.schema.highlight&&(H["&:hover"]={backgroundColor:this.props.oContext.themeType==="dark"?"#51515180":"#b8b8b880"}),N&&(j.alignItems="top"),React.createElement(Box,{component:"div",style:j,sx:H},React.createElement("div",{style:{...styles$c.label,...this.props.schema.styleLabel||void 0}},R,e),z,O)}}const styles$b={fullWidth:{height:"100%",width:"100%"},link:t=>({textDecoration:"underline",color:t.palette.mode==="dark"?"#4dabf5":"#254e72",cursor:"pointer"})};function onLink(t,o,e){let M,j="";t?t.toString().startsWith("#")||t.toString().startsWith("/")?(M=o||"_self",j=t):t.startsWith("http://")||t.startsWith("https://")?(M=o||"_blank",j=t):(j=`#tab-instances/config/${e}/${t}`,M=o||"_self"):(j=`#tab-instances/config/${e}`,M=o||"_self"),M==="_self"?setTimeout(z=>{z.startsWith("#")?window.location.hash=z:z.startsWith("/")?j=`${window.location.protocol}:${window.location.host}${j}`:(z.startsWith("http://")||z.startsWith("https://"))&&(window.location.href=z)},100,j):(j.startsWith("#")?j=`${window.location.protocol}:${window.location.host}${window.location.pathname}${j}`:j.startsWith("/")&&(j=`${window.location.protocol}:${window.location.host}${j}`),window.open(j,M))}class ConfigStaticText extends ConfigGeneric{renderItem(o,e){if(this.props.schema.button){const j=this.getIcon();return React.createElement(Button,{variant:this.props.schema.variant||void 0,color:this.props.schema.color||"grey",style:{...styles$b.fullWidth,...this.props.schema.controlStyle||void 0},disabled:e,startIcon:j,onClick:this.props.schema.href?()=>{const z=this.props.schema.href?this.getText(this.props.schema.href,!0):null;z&&(this.props.oContext.onBackEndCommand?this.props.oContext.onBackEndCommand({command:"link",url:z,target:this.props.schema.target,close:this.props.schema.close}):onLink(z,this.props.schema.target,`${this.props.oContext.adapterName}.${this.props.oContext.instance}`))}:null},this.getText(this.props.schema.text||this.props.schema.label,this.props.schema.noTranslation))}let M=this.getText(this.props.schema.text||this.props.schema.label,this.props.schema.noTranslation);return M&&(M.includes("<a ")||M.includes("<br")||M.includes("<b>")||M.includes("<i>"))&&(M=Utils.renderTextWithA(M)),React.createElement(Box,{component:"span",style:{...this.props.schema.controlStyle||void 0},sx:this.props.schema.href?styles$b.link:void 0,onClick:this.props.schema.href?()=>{const j=this.props.schema.href?this.getText(this.props.schema.href,!0):null;j&&(this.props.oContext.onBackEndCommand?this.props.oContext.onBackEndCommand({command:"link",url:j,target:this.props.schema.target||"_blank",close:this.props.schema.close}):onLink(j,this.props.schema.target||"_blank",`${this.props.oContext.adapterName}.${this.props.oContext.instance}`))}:null},M)}}const MAX_SIZE=1024*1024,styles$a={paper:{width:"100%",marginBottom:16,backgroundColor:"rgba(255, 255, 255, 0.1)"},headerText:{width:"100%"},table:{minWidth:750},label:{display:"flex",justifyContent:"space-between"},title:{flex:"1 1 100%"},rootTool:{paddingLeft:16,paddingRight:8},silver:{opacity:.2},flex:{display:"flex",alignItems:"baseline"},filteredOut:{padding:10,display:"flex",textAlign:"center"},buttonEmpty:{width:34,display:"inline-block"},buttonCell:{whiteSpace:"nowrap"},dropZone:{width:"100%",height:100,position:"relative"},dropZoneEmpty:{},uploadDiv:{position:"relative",width:"100%",minHeight:300,opacity:.9,marginTop:30,cursor:"pointer",outline:"none"},uploadDivDragging:{opacity:1,background:"rgba(128,255,128,0.1)"},uploadCenterDiv:{margin:5,border:"3px dashed grey",borderRadius:5,width:"calc(100% - 10px)",height:"calc(100% - 10px)",minHeight:300,position:"relative",display:"flex"},uploadCenterIcon:{paddingTop:10,width:48,height:48},uploadCenterText:{fontSize:16},uploadCenterTextAndIcon:{textAlign:"center",position:"absolute",top:0,bottom:0,left:0,right:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},tooltip:{pointerEvents:"none"}};function objectToArray(t,o,e){o=o||"key";const M=[];return Object.keys(t).forEach(j=>{const z={};z[o]=j,e?(z[e]=t[j],M.push(z)):M.push(Object.assign(z,t[j]))}),M}function arrayToObject(t,o,e){o=o||"key";const M={};return t.forEach(j=>{let z=j[o];z==null&&(z=""),delete j[o],e?M[z]=j[e]:M[z]=j}),M}function encrypt$1(t,o){let e="";for(let M=0;M<o.length;M++)e+=String.fromCharCode(t[M%t.length].charCodeAt(0)^o.charCodeAt(M));return e}function decrypt$1(t,o){let e="";for(let M=0;M<o.length;M++)e+=String.fromCharCode(t[M%t.length].charCodeAt(0)^o.charCodeAt(M));return e}class ConfigTable extends ConfigGeneric{constructor(e){super(e);_1(this,"filterRefs");_1(this,"typingTimer",null);_1(this,"resizeTimeout",null);_1(this,"secret","Zgfr56gFe87jJOM");_1(this,"refDiv");_1(this,"onTableRowError",e=>(M,j)=>{const z={...this.state.tableErrors};z[e]||(z[e]={}),j?z[e][M]=j:(delete z[e][M],Object.keys(z[e]).length===0&&delete z[e]),this.setState({tableErrors:z}),this.props.onError(M,j)});_1(this,"handleRequestSort",(e,M=!1)=>{const{order:j,orderBy:z}=this.state,N=M?j:z===e&&j==="asc"?"desc":"asc",R=this.stableSort(N,e);JSON.stringify(R)!==JSON.stringify(this.state.value)&&this.setState({value:R,order:N,orderBy:e,iteration:this.state.iteration+1e4},()=>this.applyFilter(!1,R))});_1(this,"stableSort",(e,M)=>{const{value:j}=this.state,z=ConfigTable.getComparator(e,M),E=j.map((N,R)=>({el:N,index:R}));return E.sort((N,R)=>{const O=z(N.el,R.el);return O!==0?O:N.index-R.index}),E.map(N=>N.el)});_1(this,"onDelete",e=>()=>{const M=JSON.parse(JSON.stringify(this.state.value));M.splice(e,1);const j={...this.state.tableErrors};j[e]&&(Object.keys(j[e]).forEach(E=>{this.props.onError(E,void 0)}),delete j[e]);const z={};Object.keys(j).forEach(E=>{const N=parseInt(E,10);N>e?z[N-1]=j[N]:z[N]=j[N]}),this.setState({value:M,iteration:this.state.iteration+1e4,tableErrors:z},()=>this.applyFilter(!1,null,()=>this.onChangeWrapper(M)))});_1(this,"onClone",e=>()=>{const M=JSON.parse(JSON.stringify(this.state.value)),j=JSON.parse(JSON.stringify(M[e]));if(typeof this.props.schema.clone=="string"&&typeof j[this.props.schema.clone]=="string"){let z=1,E=j[this.props.schema.clone];const N=E.match(/(\d+)$/);for(N?(E=E.replace(N[0],""),z=parseInt(N[0],10)+1):E+="_";M.find(R=>R[this.props.schema.clone]===E+z.toString());)z++;j[this.props.schema.clone]=`${j[this.props.schema.clone]}_${z}`}M.splice(e,0,j),this.setState({value:M,iteration:this.state.iteration+1e4},()=>this.applyFilter(!1,null,()=>this.onChangeWrapper(M)))});_1(this,"onChangeWrapper",(e,M)=>{this.typingTimer&&clearTimeout(this.typingTimer),this.typingTimer=setTimeout((j,z)=>{this.typingTimer=null;let E;if(this.props.schema.encryptedAttributes){const N=JSON.parse(JSON.stringify(j));if(N.forEach(R=>{this.props.schema.encryptedAttributes.forEach(O=>{R[O]&&(R[O]=encrypt$1(this.secret,R[O]))})}),this.props.schema.objKeyName){const R=arrayToObject(N,this.props.schema.objKeyName,this.props.schema.objValueName);E=this.onChange(this.props.attr,R)}else E=this.onChange(this.props.attr,N)}else if(this.props.schema.objKeyName){const N=arrayToObject(JSON.parse(JSON.stringify(j)),this.props.schema.objKeyName,this.props.schema.objValueName);E=this.onChange(this.props.attr,N)}else E=this.onChange(this.props.attr,j);E instanceof Promise&&E.catch(N=>console.error(`Cannot save: ${N}`)),z&&(this.applyFilter(!1,j),this.handleRequestSort(this.state.orderBy,!0))},300,e,M)});_1(this,"onAdd",()=>{var z;const{schema:e}=this.props,M=JSON.parse(JSON.stringify(this.state.value)),j=(z=e.items)==null?void 0:z.reduce((E,N)=>{let R;return N.defaultFunc?this.props.custom?R=N.defaultFunc?this.executeCustom(N.defaultFunc,this.props.data,this.props.customObj,this.props.oContext.instanceObj,M.length,this.props.data):this.props.schema.default:R=N.defaultFunc?this.execute(N.defaultFunc,this.props.schema.default,this.props.data,M.length,this.props.data):this.props.schema.default:R=N.default===void 0?null:N.default,E[N.attr]=R,E},{});M.push(j),this.setState({value:M},()=>this.applyFilter(!1,null,()=>this.onChangeWrapper(M)))});_1(this,"applyFilter",(e,M,j)=>{M=M||this.state.value;let z=M.map((E,N)=>N);if(Object.keys(this.filterRefs).forEach(E=>{let N=ConfigTable.getFilterValue(this.filterRefs[E]);!e&&N?(N=N.toLowerCase(),z=z.filter(R=>M[R]&&M[R][E]&&M[R][E].toLowerCase().includes(N))):this.filterRefs[E].current&&ConfigTable.setFilterValue(this.filterRefs[E],"")}),z.length===M.length&&(z=null),z===null&&this.state.visibleValue===null){j&&j();return}JSON.stringify(z)!==JSON.stringify(this.state.visibleValue)?this.setState({visibleValue:z},()=>j&&j()):j&&j()});this.filterRefs={},this.props.schema.items=this.props.schema.items||[],this.props.schema.items.forEach(M=>{M.filter&&(this.filterRefs[M.attr]=reactExports.createRef())}),this.refDiv=React.createRef()}async componentDidMount(){super.componentDidMount();const e=ConfigGeneric.getValue(this.props.data,this.props.attr)||[];let M;if(this.props.schema.objKeyName?M=objectToArray(e,this.props.schema.objKeyName,this.props.schema.objValueName):M=e,Array.isArray(M)||(M=[]),this.props.schema.encryptedAttributes){const j=await this.props.oContext.socket.getCompactSystemConfig();this.secret=(j==null?void 0:j.native.secret)||this.secret,e.forEach(z=>{this.props.schema.encryptedAttributes.forEach(E=>{z[E]&&(z[E]=decrypt$1(this.secret,z[E]))})})}this.setState({value:M,visibleValue:null,orderBy:"",order:"asc",iteration:0,filterOn:[],width:0,tableErrors:{}},()=>this.validateUniqueProps())}componentWillUnmount(){this.typingTimer&&(clearTimeout(this.typingTimer),this.typingTimer=null),this.resizeTimeout&&(clearTimeout(this.resizeTimeout),this.resizeTimeout=null),super.componentWillUnmount()}itemTable(e,M,j){var R;const{schema:z}=this.props,E=(R=z.items)==null?void 0:R.find(O=>O.attr===e);if(!E)return null;const N={items:{[e]:E}};return React.createElement(ConfigPanel,{oContext:this.props.oContext,alive:this.props.alive,arrayIndex:j,changed:this.props.changed,common:this.props.common,expertMode:this.props.expertMode,custom:!0,data:M,globalData:this.props.data,index:j+this.state.iteration,onChange:(O,H)=>{const A=JSON.parse(JSON.stringify(this.state.value));A[j][O]=H,this.setState({value:A},()=>{this.validateUniqueProps(),this.onChangeWrapper(A,!0)})},onError:this.onTableRowError(j),originalData:this.props.originalData,schema:N,table:!0,themeName:this.props.themeName})}validateUniqueProps(){if(!this.props.schema.uniqueColumns)return;let e=null,M=null;for(const j of this.props.schema.uniqueColumns){const z=[];this.state.value.find(N=>{const R=N[j];return z.includes(R)?(e||(e=j,M=R),this.onError(j,"is not unique"),!0):(z.push(R),!1)})||this.onError(j,null)}e?this.setState({errorMessage:I18n.t('Non-allowed duplicate entry "%s" in column "%s"',M,e)}):this.setState({errorMessage:""})}static descendingComparator(e,M,j){return M[j]<e[j]?-1:M[j]>e[j]?1:0}static getComparator(e,M){return e==="desc"?(j,z)=>ConfigTable.descendingComparator(j,z,M):(j,z)=>-ConfigTable.descendingComparator(j,z,M)}static getFilterValue(e){var M,j,z;return(z=(j=(M=e==null?void 0:e.current)==null?void 0:M.children[0])==null?void 0:j.children[0])==null?void 0:z.value}static setFilterValue(e,M){return e.current.children[0].children[0].value=M}renderShowHideFilter(e){return e.filter?React.createElement(IconButton,{title:I18n.t("ra_Show/hide filter input"),size:"small",onClick:()=>{const M=[...this.state.filterOn],j=this.state.filterOn.indexOf(e.attr);j===-1?M.push(e.attr):M.splice(j,1),this.setState({filterOn:M},()=>{j&&ConfigTable.getFilterValue(this.filterRefs[e.attr])&&(ConfigTable.setFilterValue(this.filterRefs[e.attr],""),this.applyFilter())})}},this.state.filterOn.includes(e.attr)?React.createElement(IconFilterOff,null):React.createElement(IconFilterOn,null)):null}renderImportExportButtons(e){return React.createElement(React.Fragment,null,!e.noDelete&&e.import?React.createElement(Tooltip,{title:I18n.t("ra_Import data from %s file","CSV"),slotProps:{popper:{sx:styles$a.tooltip}}},React.createElement(IconButton,{size:"small",onClick:()=>this.setState({showImportDialog:!0})},React.createElement(ImportIcon,null))):null,e.export?React.createElement(Tooltip,{title:I18n.t("ra_Export data to %s file","CSV"),slotProps:{popper:{sx:styles$a.tooltip}}},React.createElement(IconButton,{size:"small",onClick:()=>this.onExport()},React.createElement(ExportIcon,null))):null,e.noDelete?null:React.createElement(IconButton,{disabled:!0,size:"small"},React.createElement(DeleteIcon,null)))}renderAddButton(e){return React.createElement(Tooltip,{title:e?I18n.t("ra_Cannot add items with set filter"):I18n.t("ra_Add row"),slotProps:{popper:{sx:styles$a.tooltip}}},React.createElement("span",null,React.createElement(IconButton,{size:"small",color:"primary",disabled:!!e&&!this.props.schema.allowAddByFilter,onClick:this.onAdd},React.createElement(AddIcon,null))))}enhancedTableHead(e,M){var N;const{schema:j}=this.props,{order:z,orderBy:E}=this.state;return React.createElement(TableHead,null,React.createElement(TableRow,null,(N=j.items)==null?void 0:N.map((R,O)=>this.renderOneFilter({schema:j,style:{width:R.width},showAddButton:!O&&!j.noDelete,headCell:R,order:z,orderBy:E,index:O,doAnyFilterSet:M})),!j.noDelete&&React.createElement(TableCell,{style:{paddingLeft:20,paddingRight:20,width:e,textAlign:"right"},padding:"checkbox"},this.renderImportExportButtons(j))))}onExport(){const{schema:e}=this.props,{value:M}=this.state,z=[e.items.map(R=>R.attr).join(";")];M.forEach(R=>{const O=[];e.items.forEach(H=>{R[H.attr]&&typeof R[H.attr]=="string"&&R[H.attr].includes(";")?O.push(`"${R[H.attr]}"`):O.push(R[H.attr]===void 0||R[H.attr]===null?"":R[H.attr])}),z.push(O.join(";"))});const E=document.createElement("a");E.setAttribute("href",`data:text/csv;charset=utf-8,${encodeURIComponent(z.join(`
|
|
2608
2608
|
`))}`);const N=new Date;E.setAttribute("download",`${N.getFullYear()}_${(N.getMonth()+1).toString().padStart(2,"0")}_${N.getDate().toString().padStart(2,"0")}_${this.props.oContext.adapterName}.${this.props.oContext.instance}_${this.props.attr}.csv`),E.style.display="none",document.body.appendChild(E),E.click(),document.body.removeChild(E)}onImport(e){var N;const M=e.split(`
|
|
2609
|
-
`).map(R=>R.replace("\r","").trim()),{schema:j}=this.props,z=M.shift().split(";").filter(R=>R&&j.items.find(O=>O.attr===R)),E=[];M.forEach(R=>{const O=R.split(";"),H={};for(let A=0;A<O.length;A++){let _=O[A];if(_.startsWith('"')){for(_=_.substring(1);A<O.length&&!_.endsWith('"');)_+=`;${O[++A]}`;_=_.substring(0,_.length-1)}let k=_;if(_==="true")k=!0;else if(_==="false")k=!1;else if(window.isFinite(_)){const P=this.props.schema.items.find(B=>B.attr===z[A]);P&&P.type==="number"?k=parseFloat(_):k=_}else k=_;H[z[A]]=k}E.push(H)}),E.length?(N=this.state.value)!=null&&N.length?this.setState({showTypeOfImportDialog:E,showImportDialog:!1}):this.setState({value:E,showImportDialog:!1}):window.alert("ra_No data found in file")}isAnyFilterSet(){return!!Object.keys(this.filterRefs).find(e=>ConfigTable.getFilterValue(this.filterRefs[e]))}onMoveUp(e){const M=JSON.parse(JSON.stringify(this.state.value)),j=M[e];M.splice(e,1),M.splice(e-1,0,j),this.setState({value:M,iteration:this.state.iteration+1e4},()=>this.applyFilter(!1,null,()=>this.onChangeWrapper(M)))}onMoveDown(e){const M=JSON.parse(JSON.stringify(this.state.value)),j=M[e];M.splice(e,1),M.splice(e+1,0,j),this.setState({value:M,iteration:this.state.iteration+1e4},()=>this.applyFilter(!1,null,()=>this.onChangeWrapper(M)))}onDrop(e){const M=e[0],j=new FileReader;j.onabort=()=>console.log("file reading was aborted"),j.onerror=()=>console.log("file reading has failed"),j.onload=()=>{if(M.size>MAX_SIZE){window.alert(I18n.t("ra_File is too big. Max %sk allowed. Try use SVG.",Math.round(MAX_SIZE/1024)));return}const z=new Uint8Array(j.result).reduce((E,N)=>E+String.fromCharCode(N),"");this.onImport(z)},j.readAsArrayBuffer(M)}showTypeOfImportDialog(){return this.state.showTypeOfImportDialog?React.createElement(Dialog,{open:!0,onClose:()=>this.setState({showTypeOfImportDialog:!1}),maxWidth:"md"},React.createElement(DialogTitle,null,I18n.t("ra_Append or replace?")),React.createElement(DialogContent,null,I18n.t("ra_Append %s entries or replace existing?",this.state.showTypeOfImportDialog.length)),React.createElement(DialogActions,null,React.createElement(Button,{variant:"contained",color:"primary",autoFocus:!0,onClick:()=>{const e=JSON.parse(JSON.stringify(this.state.value));this.state.showTypeOfImportDialog.forEach(M=>e.push(M)),this.setState({value:e,iteration:this.state.iteration+1e4,showTypeOfImportDialog:!1},()=>this.applyFilter(!1,null,()=>this.onChangeWrapper(e)))}},I18n.t("ra_Append")),React.createElement(Button,{variant:"contained",color:"secondary",autoFocus:!0,onClick:()=>{const e=this.state.showTypeOfImportDialog;this.setState({value:e,iteration:this.state.iteration+1e4,showTypeOfImportDialog:!1},()=>this.applyFilter(!1,null,()=>this.onChangeWrapper(e)))}},I18n.t("ra_Replace")))):null}showImportDialog(){return this.state.showImportDialog?React.createElement(Dialog,{open:!0,onClose:()=>this.setState({showImportDialog:!1}),sx:{"& .MuiDialog-paper":{minHeight:500}},maxWidth:"md",fullWidth:!0},React.createElement(DialogTitle,null,I18n.t("ra_Import from %s","CSV")),React.createElement(DialogContent,null,React.createElement(Dropzone,{multiple:!1,accept:{"text/csv":[".csv"]},maxSize:MAX_SIZE,onDragEnter:()=>this.setState({uploadFile:"dragging"}),onDragLeave:()=>this.setState({uploadFile:!0}),onDrop:(e,M)=>{this.setState({uploadFile:!1}),e.length?this.onDrop(e):window.alert(M&&M[0]&&M[0].errors&&M[0].errors[0]&&M[0].errors[0].message||I18n.t("ra_Cannot upload"))}},({getRootProps:e,getInputProps:M})=>React.createElement("div",{style:{...styles$a.uploadDiv,...this.state.uploadFile==="dragging"?styles$a.uploadDivDragging:void 0,...styles$a.dropZone,...this.state.icon?void 0:styles$a.dropZoneEmpty},...e()},React.createElement("input",{...M()}),React.createElement("div",{style:styles$a.uploadCenterDiv},React.createElement("div",{style:styles$a.uploadCenterTextAndIcon},React.createElement(ImportIcon,{style:styles$a.uploadCenterIcon}),React.createElement("div",{style:styles$a.uploadCenterText},this.state.uploadFile==="dragging"?I18n.t("ra_Drop file here"):I18n.t("ra_Place your files here or click here to open the browse dialog"))))))),React.createElement(DialogActions,null,React.createElement(Button,{variant:"contained",onClick:()=>this.setState({showImportDialog:!1}),color:"primary",startIcon:React.createElement(CloseIcon,null)},I18n.t("Cancel")))):null}renderOneFilter(e){return React.createElement(TableCell,{key:`${e.headCell.attr}_${e.index}`,style:e.style,align:"left",sortDirection:e.orderBy===e.headCell.attr?e.order:!1},React.createElement("div",{style:{...styles$a.flex,...e.schema.showFirstAddOnTop?{flexDirection:"column"}:void 0}},e.showAddButton?this.renderAddButton(e.doAnyFilterSet):null,e.headCell.sort&&React.createElement(TableSortLabel,{active:!0,style:e.orderBy!==e.headCell.attr?styles$a.silver:void 0,direction:e.orderBy===e.headCell.attr?e.order:"asc",onClick:()=>this.handleRequestSort(e.headCell.attr)}),e.headCell.filter&&this.state.filterOn.includes(e.headCell.attr)?React.createElement(TextField,{variant:"standard",ref:this.filterRefs[e.headCell.attr],onChange:()=>this.applyFilter(),title:I18n.t("ra_You can filter entries by entering here some text"),slotProps:{input:{endAdornment:ConfigTable.getFilterValue(this.filterRefs[e.headCell.attr])&&React.createElement(InputAdornment,{position:"end"},React.createElement(IconButton,{size:"small",tabIndex:-1,onClick:()=>{ConfigTable.setFilterValue(this.filterRefs[e.headCell.attr],""),this.applyFilter()}},React.createElement(CloseIcon,null)))}},fullWidth:!0,placeholder:this.getText(e.headCell.title)}):React.createElement("span",{style:styles$a.headerText},this.getText(e.headCell.title)),this.renderShowHideFilter(e.headCell)))}enhancedFilterCard(){var N;const{schema:e}=this.props,{order:M,orderBy:j}=this.state;let z;this.props.schema.compact&&(z={paddingTop:1,paddingBottom:1});const E=!e.noDelete&&e.import||e.export;return E||e.items.find(R=>R.sort||R.filter)?React.createElement(Grid2,{size:{xs:e.xs||12,sm:e.sm||void 0,md:e.md||void 0,lg:e.lg||void 0,xl:e.xl||void 0}},React.createElement(Card,null,React.createElement(Paper,{style:styles$a.paper},React.createElement(Accordion,{style:styles$a.paper},React.createElement(AccordionSummary,{expandIcon:React.createElement(ExpandMoreIcon,null)},React.createElement(Typography,null,I18n.t("ra_Filter and Data Actions"))),React.createElement(AccordionDetails,null,React.createElement(Table,null,React.createElement(TableBody,null,((N=e.items)==null?void 0:N.find(R=>R.sort||R.filter))&&e.items.map((R,O)=>React.createElement(TableRow,{key:`${R.attr}_${O}`},this.renderOneFilter({schema:e,style:z,showAddButton:!1,headCell:R,order:M,orderBy:j,index:O,doAnyFilterSet:!1}))),E?React.createElement(TableRow,null,React.createElement(TableCell,{align:"left",style:z},React.createElement("span",{style:styles$a.headerText},I18n.t("ra_Actions"))),React.createElement(TableCell,{style:z},this.renderImportExportButtons(e))):null))))))):null}enhancedBottomCard(){const{schema:e}=this.props;let M;this.props.schema.compact&&(M={paddingTop:1,paddingBottom:1});const j=this.isAnyFilterSet();return React.createElement(Grid2,{size:{xs:e.xs||12,sm:e.sm||void 0,md:e.md||void 0,lg:e.lg||void 0,xl:e.xl||void 0}},React.createElement(Card,null,React.createElement(Paper,{style:styles$a.paper},React.createElement(Table,null,React.createElement(TableBody,null,React.createElement(TableRow,null,React.createElement(TableCell,{colSpan:e.items.length+1,style:M},this.renderAddButton(j))))))))}renderCards(){const{schema:e}=this.props;let{visibleValue:M}=this.state,j;this.props.schema.compact&&(j={paddingTop:1,paddingBottom:1}),M||(M=this.state.value.map((E,N)=>N));const z=this.isAnyFilterSet();return React.createElement(Grid2,{container:!0},this.showImportDialog(),this.showTypeOfImportDialog(),this.enhancedFilterCard(),M.map((E,N)=>{var R;return React.createElement(Grid2,{key:`${E}_${N}`,size:{xs:e.xs||12,sm:e.sm||void 0,md:e.md||void 0,lg:e.lg||void 0,xl:e.xl||void 0}},React.createElement(Card,null,React.createElement(Paper,{style:styles$a.paper},React.createElement(Table,null,React.createElement(TableBody,null,(R=e.items)==null?void 0:R.map(O=>React.createElement(TableRow,{key:`${O.attr}_${E}`},React.createElement(TableCell,{align:"left",style:j},React.createElement("span",{style:styles$a.headerText},this.getText(O.title))),React.createElement(TableCell,{align:"left",style:j},this.itemTable(O.attr,this.state.value[E],E)))),!e.noDelete&&React.createElement(TableRow,null,React.createElement(TableCell,{align:"left",style:j},React.createElement("span",{style:styles$a.headerText},this.getText("Actions"))),React.createElement(TableCell,{align:"left",style:j},!z&&!this.state.orderBy?React.createElement(Tooltip,{title:I18n.t("ra_Move up"),slotProps:{popper:{sx:styles$a.tooltip}}},React.createElement("span",null,React.createElement(IconButton,{size:"small",onClick:()=>this.onMoveUp(E),disabled:N===0},React.createElement(UpIcon,null)))):null,!z&&!this.state.orderBy?React.createElement(Tooltip,{title:I18n.t("ra_Move down"),slotProps:{popper:{sx:styles$a.tooltip}}},React.createElement("span",null,React.createElement(IconButton,{size:"small",onClick:()=>this.onMoveDown(E),disabled:N===M.length-1},React.createElement(DownIcon,null)))):null,React.createElement(Tooltip,{title:I18n.t("ra_Delete current row"),slotProps:{popper:{sx:styles$a.tooltip}}},React.createElement(IconButton,{size:"small",onClick:this.onDelete(E)},React.createElement(DeleteIcon,null))),this.props.schema.clone?React.createElement(Tooltip,{title:I18n.t("ra_Clone current row"),slotProps:{popper:{sx:styles$a.tooltip}}},React.createElement(IconButton,{size:"small",onClick:this.onClone(E)},React.createElement(IconCopy$1,null))):null)))))))}),this.enhancedBottomCard())}renderTable(){const{schema:e}=this.props;let{visibleValue:M}=this.state;M=M||this.state.value.map((E,N)=>N);const j=this.isAnyFilterSet();let z;return this.props.schema.compact&&(z={paddingTop:1,paddingBottom:1}),React.createElement(Paper,{style:styles$a.paper},this.showImportDialog(),this.showTypeOfImportDialog(),e.label?React.createElement("div",{style:styles$a.label},React.createElement(Toolbar,{variant:"dense",style:styles$a.rootTool},React.createElement(Typography,{style:styles$a.title,variant:"h6",id:"tableTitle",component:"div"},this.getText(e.label)))):null,React.createElement(TableContainer,null,React.createElement(Table,{style:styles$a.table,size:"small"},this.enhancedTableHead(!j&&!this.state.orderBy?120:64,j),React.createElement(TableBody,null,M.map((E,N)=>{var R;return React.createElement(TableRow,{hover:!0,key:`${E}_${N}`},(R=e.items)==null?void 0:R.map(O=>React.createElement(TableCell,{key:`${O.attr}_${E}`,align:"left",style:z},this.itemTable(O.attr,this.state.value[E],E))),!e.noDelete&&React.createElement(TableCell,{align:"left",style:{...z,...styles$a.buttonCell}},!j&&!this.state.orderBy?N?React.createElement(Tooltip,{title:I18n.t("ra_Move up"),slotProps:{popper:{sx:styles$a.tooltip}}},React.createElement(IconButton,{size:"small",onClick:()=>this.onMoveUp(E)},React.createElement(UpIcon,null))):React.createElement("div",{style:styles$a.buttonEmpty}):null,!j&&!this.state.orderBy?N<M.length-1?React.createElement(Tooltip,{title:I18n.t("ra_Move down"),slotProps:{popper:{sx:styles$a.tooltip}}},React.createElement(IconButton,{size:"small",onClick:()=>this.onMoveDown(E)},React.createElement(DownIcon,null))):React.createElement("div",{style:styles$a.buttonEmpty}):null,React.createElement(Tooltip,{title:I18n.t("ra_Delete current row"),slotProps:{popper:{sx:styles$a.tooltip}}},React.createElement(IconButton,{size:"small",onClick:this.onDelete(E)},React.createElement(DeleteIcon,null))),this.props.schema.clone?React.createElement(Tooltip,{title:I18n.t("ra_Clone current row"),slotProps:{popper:{sx:styles$a.tooltip}}},React.createElement(IconButton,{size:"small",onClick:this.onClone(E)},React.createElement(IconCopy$1,null))):null))}),!e.noDelete&&M.length>=(e.showSecondAddAt||5)?React.createElement(TableRow,null,React.createElement(TableCell,{colSpan:e.items.length+1,style:{...z}},this.renderAddButton(j))):null)),!M.length&&this.state.value.length?React.createElement("div",{style:styles$a.filteredOut},React.createElement(Typography,{style:styles$a.title,variant:"h6",id:"tableTitle",component:"div"},I18n.t("ra_All items are filtered out"),React.createElement(IconButton,{size:"small",onClick:()=>this.applyFilter(!0)},React.createElement(CloseIcon,null)))):null),e.help?React.createElement(FormHelperText,{style:{paddingLeft:16}},this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null,this.state.errorMessage?React.createElement("div",{style:{display:"flex",padding:"5px"}},React.createElement(ErrorIcon,{color:"error"}),React.createElement("span",{style:{color:"red",alignSelf:"center"}},this.state.errorMessage)):null)}componentDidUpdate(){var e;(e=this.refDiv.current)!=null&&e.clientWidth&&this.refDiv.current.clientWidth!==this.state.width&&(this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{var M;this.resizeTimeout=null,this.setState({width:(M=this.refDiv.current)==null?void 0:M.clientWidth})},50))}getCurrentBreakpoint(){return this.state.width?this.state.width<600?"xs":this.state.width<900?"sm":this.state.width<1200?"md":this.state.width<1536?"lg":"xl":"md"}renderItem(){const{schema:e}=this.props;if(!this.state.value||!Array.isArray(this.state.value))return null;const M=this.getCurrentBreakpoint();let j;return M&&(e.useCardFor||["xs"]).includes(M)?j=this.renderCards():j=this.renderTable(),React.createElement("div",{ref:this.refDiv,style:{width:"100%"}},j)}}const styles$9={indeterminate:{opacity:.5},label:{width:"100%",fontSize:14,marginBottom:2},helper:{width:"100%",fontSize:12},error:{width:"100%",fontSize:12,color:"#FF0000"}};class ConfigText extends ConfigGeneric{constructor(){super(...arguments);_1(this,"updateTimeout",null)}componentDidMount(){super.componentDidMount();let e=ConfigGeneric.getValue(this.props.data,this.props.attr);if(Array.isArray(e)&&this.props.oContext.multiEdit){e=ConfigGeneric.DIFFERENT_VALUE,this.setState({value:e,oldValue:e,jsonError:!1});return}this.setState({value:e,oldValue:e,jsonError:this.validateJson(e)})}validateJson(e){let M=!1;if(this.props.schema.validateJson&&(e||!this.props.schema.allowEmpty))try{JSON.parse(e)}catch(j){console.log("Error in JSON",j),M=!0}return M}static getDerivedStateFromProps(e,M){if(e.oContext.multiEdit&&M.value===ConfigGeneric.DIFFERENT_VALUE)return{value:ConfigGeneric.DIFFERENT_VALUE};let j=ConfigGeneric.getValue(e.data,e.attr);return j!=null&&(j=j.toString()),j==null||j!==M.value&&j!==M.oldValue?{value:j}:null}renderItem(e,M){const j=Array.isArray(this.state.value)||this.state.value===ConfigGeneric.DIFFERENT_VALUE;if(this.props.schema.time){let N="";return typeof this.state.value=="number"?this.state.value&&this.state.value<9466596e5?N=new Date(this.state.value*1e3).toLocaleString():N=new Date(this.state.value).toLocaleString():typeof this.state.value=="string"&&(N=new Date(this.state.value).toLocaleString()),React.createElement(TextField,{variant:"standard",fullWidth:!0,value:N,error:!!e||!!this.state.jsonError,disabled:!!M,slotProps:{htmlInput:{readOnly:!0}},placeholder:this.getText(this.props.schema.placeholder),label:this.getText(this.props.schema.label),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)})}if(this.state.oldValue!==null&&this.state.oldValue!==void 0?(this.updateTimeout&&clearTimeout(this.updateTimeout),this.updateTimeout=setTimeout(()=>{this.updateTimeout=null,this.setState({oldValue:null})},30)):this.updateTimeout&&(clearTimeout(this.updateTimeout),this.updateTimeout=null),j){const N=ConfigGeneric.getValue(this.props.data,this.props.attr),R=(N==null?void 0:N.filter(O=>O||O===0).map(O=>({label:O.toString()||"",value:O})))||[];return R.unshift({label:I18n.t(ConfigGeneric.DIFFERENT_LABEL),value:ConfigGeneric.DIFFERENT_VALUE}),React.createElement(Autocomplete,{style:styles$9.indeterminate,fullWidth:!0,value:R[0],onChange:(O,H)=>{const A=H?H.value:"",_=this.onChange(this.props.attr,A,()=>{this.setState({value:A,oldValue:A,jsonError:this.validateJson(H)})});_ instanceof Promise&&_.catch(k=>console.error(`Cannot set value: ${k}`))},options:R,getOptionLabel:O=>O.label,renderInput:O=>React.createElement(TextField,{variant:"standard",...O,error:!!e,placeholder:this.getText(this.props.schema.placeholder),slotProps:{htmlInput:{...O.inputProps,maxLength:this.props.schema.maxLength||this.props.schema.max||void 0,readOnly:this.props.schema.readOnly||!1}},label:this.getText(this.props.schema.label),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation),disabled:!!M})})}let z,E;if((this.props.schema.readOnly||M)&&this.props.schema.copyToClipboard?(this.props.schema.minRows>1&&(E={position:"absolute",right:3,top:20,zIndex:1e3}),z=React.createElement(IconButton,{tabIndex:-1,style:E,size:"small",onClick:()=>{Utils.copyToClipboard(this.state.value),window.alert(I18n.t("ra_Copied"))}},React.createElement(IconCopy,null))):!this.props.schema.readOnly&&!M&&this.state.value&&!this.props.schema.noClearButton&&(this.props.schema.minRows>1&&(E={position:"absolute",right:3,top:20,zIndex:1e3}),z=React.createElement(IconButton,{style:E,size:"small",tabIndex:-1,onClick:()=>this.setState({value:"",oldValue:this.state.value},()=>this.onChange(this.props.attr,""))},React.createElement(CloseIcon,null)),this.props.schema.minRows<=1&&(z=React.createElement(InputAdornment,{position:"end"},z))),this.props.schema.minRows>1){const N=this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation);return React.createElement("div",{style:{width:"100%",position:"relative"}},this.props.schema.label?React.createElement("div",{style:styles$9.label},this.getText(this.props.schema.label)):null,React.createElement(TextareaAutosize,{style:{width:"100%",resize:"vertical",backgroundColor:this.props.oContext.themeType==="dark"?"#363636":"#cccccc",color:this.props.oContext.themeType==="dark"?"#fff":"#111"},minRows:this.props.schema.minRows,maxRows:this.props.schema.maxRows,value:this.state.value===null||this.state.value===void 0?"":this.state.value,disabled:!!M,readOnly:this.props.schema.readOnly||!1,onChange:R=>{const O=R.target.value;this.setState({value:O,oldValue:this.state.value,jsonError:this.validateJson(O)},()=>this.onChange(this.props.attr,O||""))},placeholder:this.getText(this.props.schema.placeholder)}),N||e||this.state.jsonError?React.createElement("div",{style:e?styles$9.error:styles$9.helper},e||(this.state.jsonError?I18n.t("ra_Invalid JSON"):N)):null)}return React.createElement(TextField,{variant:"standard",fullWidth:!0,value:this.state.value===null||this.state.value===void 0?"":this.state.value,error:!!e||!!this.state.jsonError,disabled:!!M,slotProps:{htmlInput:{maxLength:this.props.schema.maxLength||this.props.schema.max||void 0,readOnly:this.props.schema.readOnly||!1},input:{endAdornment:z}},onChange:N=>{const R=N.target.value;this.setState({value:R,oldValue:this.state.value,jsonError:this.validateJson(R)},()=>this.onChange(this.props.attr,R))},placeholder:this.getText(this.props.schema.placeholder),label:this.getText(this.props.schema.label),helperText:this.state.jsonError?I18n.t("ra_Invalid JSON"):this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)})}}const styles$8={fullWidth:{width:"100%"}};class ConfigTextSendTo extends ConfigGeneric{constructor(){super(...arguments);_1(this,"initialized",!1);_1(this,"localContext")}askInstance(){if(this.props.alive){let e=this.props.schema.data;if(e===void 0&&this.props.schema.jsonData){const M=this.getPattern(this.props.schema.jsonData,null,!0);try{e=JSON.parse(M)}catch{console.error(`Cannot parse json data: ${M}`)}}e===void 0&&(e=null),this.props.oContext.socket.sendTo(`${this.props.oContext.adapterName}.${this.props.oContext.instance}`,this.props.schema.command||"send",e).then(M=>{if(typeof M=="object"){const j=M;this.setState({text:j.text||"",style:j.style,icon:j.icon,iconStyle:j.iconStyle})}else typeof M=="string"&&this.setState({text:M||""})}).catch(M=>console.error(`Cannot send command: ${M}`))}}getLocalContext(){const e={};return Array.isArray(this.props.schema.alsoDependsOn)&&this.props.schema.alsoDependsOn.forEach(M=>e[M]=ConfigGeneric.getValue(this.props.data,M)),JSON.stringify(e)}renderItem(){if(this.props.alive){const M=this.getLocalContext();(M!==this.localContext||!this.initialized)&&(this.localContext=M,setTimeout(()=>this.askInstance(),this.initialized?300:50),this.initialized=!0)}if(this.state.text===void 0)return null;let e=null;return this.state.icon&&(e=getIconByName(this.state.icon,{marginRight:this.state.text?8:void 0,...this.state.iconStyle||void 0}),e||(e=React.createElement(Icon,{src:this.state.icon,style:{marginRight:this.state.text?8:void 0,...this.state.iconStyle||void 0}}))),this.props.schema.container==="text"?React.createElement(TextField,{variant:"standard",fullWidth:!0,slotProps:{input:{endAdornment:this.props.schema.copyToClipboard?React.createElement(IconButton,{tabIndex:-1,size:"small",onClick:()=>{Utils.copyToClipboard(this.state.text),window.alert(I18n.t("ra_Copied"))}},React.createElement(IconCopy,null)):void 0}},value:this.state.text,label:this.getText(this.props.schema.label),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)}):React.createElement("div",{style:{...styles$8.fullWidth,...this.state.style||void 0}},e,this.props.schema.container==="html"?React.createElement("span",{dangerouslySetInnerHTML:{__html:this.state.text||""}}):this.state.text)}}class ConfigTimePicker extends ConfigGeneric{componentDidMount(){super.componentDidMount();const o=ConfigGeneric.getValue(this.props.data,this.props.attr);this.setState({value:o})}renderItem(o,e){const M=this.props.schema.returnFormat!=="HH:mm:ss",j=new Date(Date.parse(`Thu, 01 Jan 1970 ${this.state.value||"00:00:00"}`));return React.createElement(TimePicker,{sx:z=>({width:"100%",borderBottom:`1px solid ${z.palette.text.primary}`,"& fieldset":{display:"none"},"& input":{padding:`${z.spacing(1.5)} 0 4px 0`},"& .MuiInputAdornment-root":{marginLeft:0,marginTop:1},"& label":{transform:"translate(0px, -9px) scale(0.75)"}}),ampm:this.props.oContext.systemConfig.dateFormat.includes("/"),timeSteps:this.props.schema.timeSteps||this.props.schema.timesteps||{hours:1,minutes:5,seconds:5},format:this.props.schema.format||"HH:mm:ss",disabled:!!e,value:j,onChange:z=>{let E;E=z instanceof Date?z.toTimeString().split(" ")[0]:z.toTimeString(),M&&(E=E.split(":").slice(0,2).join(":")),this.setState({value:E},()=>this.onChange(this.props.attr,this.state.value))},views:this.props.schema.views||["hours","minutes","seconds"],label:this.getText(this.props.schema.label)})}}function convertID2Topic(t,o){let e;return o&&t.substring(0,o.length)===o?e=t.substring(o.length+1):e=t,e=e.replace(/\./g,"/").replace(/_/g," "),e}class ConfigTopic extends ConfigGeneric{componentDidMount(){var e;super.componentDidMount();const o=ConfigGeneric.getValue(this.props.data,this.props.attr);if(!o&&((e=this.props.customObj)!=null&&e._id)){const M=convertID2Topic(this.props.customObj._id,`${this.props.oContext.adapterName}.${this.props.oContext.instance}`);this.setState({value:M})}else this.setState({value:o||""})}renderItem(o,e){return React.createElement(TextField,{variant:"standard",fullWidth:!0,slotProps:{htmlInput:{maxLength:this.props.schema.maxLength||this.props.schema.max||void 0}},value:this.state.value,error:!!o,disabled:e,placeholder:this.getText(this.props.schema.placeholder),label:this.getText(this.props.schema.label),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation),onChange:M=>{const j=M.target.value;this.setState({value:j},()=>this.onChange(this.props.attr,j))}})}}class ConfigUUID extends ConfigGeneric{async componentDidMount(){var e;super.componentDidMount();const o=await this.props.oContext.socket.getObject("system.meta.uuid");this.setState({uuid:((e=o==null?void 0:o.native)==null?void 0:e.uuid)||"unknown"})}renderItem(o,e){return React.createElement(TextField,{variant:"standard",fullWidth:!0,error:!!o,disabled:!!e,slotProps:{htmlInput:{readOnly:!0},input:{endAdornment:React.createElement(IconButton,{tabIndex:-1,onClick:()=>{Utils.copyToClipboard(this.state.uuid),window.alert(I18n.t("ra_Copied %s",this.state.uuid))}},React.createElement(IconCopy$1,null))}},value:this.state.uuid||"",label:this.getText(this.props.schema.label)||I18n.t("ra_Serial number (UUID)"),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)})}}const styles$7={icon:{width:16,height:16,marginRight:8}};class ConfigUser extends ConfigGeneric{componentDidMount(){super.componentDidMount(),this.props.oContext.socket.getUsers().then(o=>{const e={},M=I18n.getLanguage();this.props.schema.short?o.forEach(j=>{var z,E;return e[j._id]={color:(z=j.common)==null?void 0:z.color,icon:(E=j.common)==null?void 0:E.icon,name:Utils.getObjectNameFromObj(j,M)}}):o.forEach(j=>{var z,E;return e[j._id.replace(/^system\.user\./,"")]={color:(z=j.common)==null?void 0:z.color,icon:(E=j.common)==null?void 0:E.icon,name:Utils.getObjectNameFromObj(j,M)}}),this.setState({users:e})}).catch(o=>console.error(`Cannot get users: ${o}`))}renderItem(o,e){var j,z;const M=ConfigGeneric.getValue(this.props.data,this.props.attr);return React.createElement(FormControl,{variant:"standard",fullWidth:!0},this.state.users&&this.props.schema.label?React.createElement(InputLabel,null,this.getText(this.props.schema.label)):null,this.state.users?React.createElement(Select,{variant:"standard",error:!!o,disabled:!!e,value:M,renderValue:E=>{var N,R,O;return React.createElement("span",null,this.state.users&&((N=this.state.users[E])!=null&&N.icon)?React.createElement(Icon,{src:this.state.users&&((R=this.state.users[E])==null?void 0:R.icon),style:styles$7.icon}):null,this.state.users&&((O=this.state.users[E])==null?void 0:O.name)||E||"")},style:{color:this.state.users&&((j=this.state.users[M])==null?void 0:j.color)||void 0,backgroundColor:Utils.getInvertedColor(this.state.users&&((z=this.state.users[M])==null?void 0:z.color),this.props.oContext.themeType)},onChange:E=>this.onChange(this.props.attr,E.target.value)},this.state.users&&Object.keys(this.state.users).map(E=>React.createElement(MenuItem,{style:{color:this.state.users[E].color||void 0,backgroundColor:Utils.getInvertedColor(this.state.users[E].color,this.props.oContext.themeType)},key:E,value:E},this.state.users[E].icon?React.createElement(Icon,{src:this.state.users[E].icon,style:styles$7.icon}):null,this.state.users[E].name))):React.createElement(TextField,{variant:"standard",error:!!o,disabled:!!e,value:M,onChange:E=>this.onChange(this.props.attr,E.target.value),label:this.getText(this.props.schema.label)}),this.props.schema.help?React.createElement(FormHelperText,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}const scriptRel="modulepreload",assetsURL=function(t,o){return new URL(t,o).href},seen={},__vitePreload=function t(o,e,M){let j=Promise.resolve();if(e&&e.length>0){let E=function(H){return Promise.all(H.map(A=>Promise.resolve(A).then(_=>({status:"fulfilled",value:_}),_=>({status:"rejected",reason:_}))))};const N=document.getElementsByTagName("link"),R=document.querySelector("meta[property=csp-nonce]"),O=(R==null?void 0:R.nonce)||(R==null?void 0:R.getAttribute("nonce"));j=E(e.map(H=>{if(H=assetsURL(H,M),H in seen)return;seen[H]=!0;const A=H.endsWith(".css"),_=A?'[rel="stylesheet"]':"";if(!!M)for(let B=N.length-1;B>=0;B--){const e1=N[B];if(e1.href===H&&(!A||e1.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${H}"]${_}`))return;const P=document.createElement("link");if(P.rel=A?"stylesheet":scriptRel,A||(P.as="script"),P.crossOrigin="",P.href=H,O&&P.setAttribute("nonce",O),document.head.appendChild(P),A)return new Promise((B,e1)=>{P.addEventListener("load",B),P.addEventListener("error",()=>e1(new Error(`Unable to preload CSS for ${H}`)))})}))}function z(E){const N=new Event("vite:preloadError",{cancelable:!0});if(N.payload=E,window.dispatchEvent(N),!N.defaultPrevented)throw E}return j.then(E=>{for(const N of E||[])N.status==="rejected"&&z(N.reason);return o().catch(z)})};class ConfigQrCode extends ConfigGeneric{async componentDidMount(){super.componentDidMount();const o=await __vitePreload(()=>import("./index-o1BlSTJK.js").then(e=>e.i),[],import.meta.url);this.setState({QRCode:o.default})}renderItem(){const o=this.state.QRCode;return o?React.createElement(o,{value:this.props.schema.data,size:this.props.schema.size,fgColor:this.props.schema.fgColor,bgColor:this.props.schema.bgColor,level:this.props.schema.level}):null}}const components={accordion:ConfigAccordion,alive:ConfigAlive,autocomplete:ConfigAutocomplete,autocompleteSendTo:ConfigAutocompleteSendTo,certCollection:ConfigCertCollection,certificate:ConfigCertificateSelect,certificates:ConfigCertificates,checkbox:ConfigCheckbox,checkDocker:ConfigCheckDocker,checkLicense:ConfigCheckLicense,chip:ConfigChip,chips:ConfigChip,color:ConfigColor,coordinates:ConfigCoordinates,cron:ConfigCRON,custom:ConfigCustom,datePicker:ConfigDatePicker,deviceManager:ConfigDeviceManager,divider:ConfigStaticDivider,file:ConfigFile,fileSelector:ConfigFileSelector,func:ConfigFunc,header:ConfigStaticHeader,image:ConfigImageUpload,imageSendTo:ConfigImageSendTo,infoBox:ConfigInfoBox,instance:ConfigInstanceSelect,interface:ConfigInterface,ip:ConfigIP,jsonEditor:ConfigJsonEditor,language:ConfigLanguage,license:ConfigLicense,number:ConfigNumber,oauth2:ConfigOAuth2,objectId:ConfigObjectId,password:ConfigPassword,pattern:ConfigPattern,port:ConfigPort,qrCode:ConfigQrCode,room:ConfigRoom,select:ConfigSelect,selectSendTo:ConfigSelectSendTo,sendto:ConfigSendto,sendTo:ConfigSendto,setState:ConfigSetState,slider:ConfigSlider,state:ConfigState,staticImage:ConfigStaticImage,staticInfo:ConfigStaticInfo,staticLink:ConfigStaticText,staticText:ConfigStaticText,table:ConfigTable,text:ConfigText,textSendTo:ConfigTextSendTo,timePicker:ConfigTimePicker,topic:ConfigTopic,uuid:ConfigUUID,user:ConfigUser},styles$6={fullWidth:{width:"100%"},paper:{margin:1,width:"auto !important",overflowY:"auto",paddingBottom:1},paperWithIcons:{height:"calc(100vh - 259px) !important"},paperWithoutIcons:{height:"calc(100vh - 235px) !important"},padding:{padding:"10px"},heading:{},primary:t=>({backgroundColor:t.palette.primary.main,color:t.palette.mode==="dark"?"inherit":"#FFF"}),secondary:t=>({backgroundColor:t.palette.secondary.main})};class ConfigPanel extends ConfigGeneric{componentDidMount(){var o;super.componentDidMount(),(o=this.props.schema)!=null&&o.collapsable&&this.setState({expanded:(window._localStorage||window.localStorage).getItem(`${this.props.oContext.adapterName}.${this.props.attr}`)==="true"})}renderItems(o,e){return o?Object.keys(o).map(M=>{if(this.props.oContext.multiEdit&&o[M].noMultiEdit)return null;const j=o[M].type||"panel";let z,E="Use this.props.oContext.socket!";return j==="custom"?(o[M].url?z=ConfigCustom:this.props.oContext.customs&&this.props.oContext.customs[o[M].component]?z=this.props.oContext.customs[o[M].component]:(console.error(`Cannot find custom component: ${o[M].component}`),z=ConfigGeneric),E=this.props.oContext.socket):j==="panel"?z=ConfigPanel:z=components[j]||ConfigGeneric,React.createElement(z,{socket:E,globalData:this.props.globalData,oContext:this.props.oContext,key:`${M}_${this.props.index===void 0?"":this.props.index}`,index:this.props.index,changed:this.props.changed,arrayIndex:this.props.arrayIndex,expertMode:this.props.expertMode,commandRunning:this.props.commandRunning,style:styles$6.panel,common:this.props.common,alive:this.props.alive,themeName:this.props.themeName,data:this.props.data,originalData:this.props.originalData,onError:this.props.onError,onChange:this.props.onChange,disabled:e,customObj:this.props.customObj,custom:this.props.custom,schema:o[M],attr:M,table:this.props.table})}):null}render(){const o=this.props.schema;if(!o)return null;const{disabled:e,hidden:M}=this.calculate(o),j=this.props.schema.items,z=this.props.schema.style||{};if(M){if(o.hideOnlyControl){const N=React.createElement(Grid2,{size:{xs:o.xs||void 0,sm:o.sm||void 0,md:o.md||void 0,lg:o.lg||void 0,xl:o.xl||void 0},sx:Utils.getStyle(this.props.oContext.theme,{marginBottom:0,textAlign:"left"},z,this.props.oContext.themeType==="dark"&&o.darkStyle)});return o.newLine?React.createElement(React.Fragment,null,React.createElement("div",{style:{flexBasis:"100%",height:0}}),N):N}return null}if(this.props.table)return this.renderItems(j,e);if(this.props.custom)return React.createElement(Grid2,{key:`${this.props.attr}_${this.props.index}`,container:!0,style:styles$6.fullWidth,columnSpacing:2,rowSpacing:1,sx:z},this.renderItems(j,e));let E;if(o.collapsable)E=React.createElement(Accordion,{key:`${this.props.attr}_${this.props.index}`,style:styles$6.fullWidth,expanded:!!this.state.expanded,onChange:()=>{(window._localStorage||window.localStorage).setItem(`${this.props.oContext.adapterName}.${this.props.attr}`,this.state.expanded?"false":"true"),this.setState({expanded:!this.state.expanded})}},React.createElement(AccordionSummary,{expandIcon:React.createElement(ExpandMoreIcon,null),sx:Utils.getStyle(this.props.oContext.theme,z,this.props.oContext.themeType&&o.darkStyle,o.color==="primary"?styles$6.primary:o.color==="secondary"&&styles$6.secondary,{width:"100%"})},React.createElement(Typography,{style:styles$6.heading},this.getText(o.label))),React.createElement(AccordionDetails,null,React.createElement(Grid2,{container:!0,columnSpacing:2,rowSpacing:1,sx:{...z,width:"100%",padding:"10px"}},this.renderItems(j,e))));else{const N=Utils.getStyle(this.props.oContext.theme,this.props.style,z,{width:"100%"},this.props.isParentTab&&styles$6.paper,this.props.isParentTab&&(this.props.withoutSaveButtons?this.props.withIcons?{height:"calc(100% - 88px) !important"}:{height:"calc(100% - 64px) !important"}:this.props.withIcons?styles$6.paperWithIcons:styles$6.paperWithoutIcons));E=React.createElement(Box,{component:"div",key:`${this.props.attr}_${this.props.index}`,className:this.props.className,sx:N},React.createElement(Grid2,{container:!0,columnSpacing:2,rowSpacing:1,sx:Utils.getStyle(this.props.oContext.theme,{width:"100%"},this.props.isParentTab&&styles$6.padding,this.props.schema.innerStyle)},this.renderItems(j,e)))}if(!this.props.isParentTab){const N=React.createElement(Grid2,{title:this.getText(o.tooltip),size:{xs:o.xs||void 0,sm:o.sm||void 0,md:o.md||void 0,lg:o.lg||void 0,xl:o.xl||void 0},sx:{marginBottom:0,textAlign:"left",...z}},E);return o.newLine?React.createElement(React.Fragment,null,React.createElement("div",{style:{flexBasis:"100%",height:0}}),N):N}return E}}const styles$5={tabs:{height:"100%",width:"100%"},panel:{width:"100%",display:"block"},panelWithIcons:{height:"calc(100% - 72px)"},panelWithoutIcons:{height:"calc(100% - 48px)"}};class ConfigTabs extends ConfigGeneric{constructor(e){super(e);_1(this,"resizeTimeout",null);_1(this,"refDiv");_1(this,"onTabError",(e,M)=>{const j=this.state.tab;if(!j){this.props.onError(e,M);return}const z={...this.state.tabErrors};z[j]||(z[j]={}),M?z[j][e]=M:(delete z[j][e],Object.keys(z[j]).length===0&&delete z[j]),this.setState({tabErrors:z}),this.props.onError(e,M)});_1(this,"hasTabErrors",e=>!!(this.state.tabErrors[e]&&Object.keys(this.state.tabErrors[e]).length>0));_1(this,"onHashTabsChanged",()=>{const e=(window.location.hash||"").replace(/^#/,"").split("/");if(e.length>3&&e[1]==="config"){const M=e[3],j=parseInt(M,10);let z;j.toString()===M?j>=0&&j<Object.keys(this.props.schema.items).length&&(z=Object.keys(this.props.schema.items)[j]):Object.keys(this.props.schema.items).includes(M)&&(z=M),z!==void 0&&z!==this.state.tab&&((window._localStorage||window.localStorage).setItem(`${this.props.dialogName||"App"}.${this.props.oContext.adapterName}`,z),this.setState({tab:z}))}});let M;if(this.props.root){const j=(window.location.hash||"").replace(/^#/,"").split("/");if(j.length>=3&&j[1]==="config"){const z=j[3],E=parseInt(z,10);z&&E.toString()===z?E>=0&&E<Object.keys(this.props.schema.items).length&&(M=Object.keys(this.props.schema.items)[E]):z&&Object.keys(this.props.schema.items).includes(z)&&(M=z),window.addEventListener("hashchange",this.onHashTabsChanged,!1)}}M===void 0&&(M=(window._localStorage||window.localStorage).getItem(`${this.props.dialogName||"App"}.${this.props.oContext.adapterName}`)||Object.keys(this.props.schema.items)[0],Object.keys(this.props.schema.items).includes(M)||(M=Object.keys(this.props.schema.items)[0])),this.refDiv=React.createRef(),Object.assign(this.state,{tab:M,width:0,openMenu:null,tabErrors:{}})}componentWillUnmount(){this.resizeTimeout&&(clearTimeout(this.resizeTimeout),this.resizeTimeout=null),window.removeEventListener("hashchange",this.onHashTabsChanged,!1),super.componentWillUnmount()}getCurrentBreakpoint(){if(!this.state.width)return"md";if(!this.state.initialBreakpoint){let e;return this.state.width<600?e="xs":this.state.width<900?e="sm":this.state.width<1200?e="md":this.state.width<1536?e="lg":e="xl",setTimeout(()=>{this.setState({initialBreakpoint:e})},50),e}return this.state.initialBreakpoint}componentDidUpdate(){var e;!this.state.initialBreakpoint&&((e=this.refDiv.current)!=null&&e.clientWidth)&&this.refDiv.current.clientWidth!==this.state.width&&(this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{var M;this.resizeTimeout=null,this.setState({width:(M=this.refDiv.current)==null?void 0:M.clientWidth})},50))}onMenuChange(e){(window._localStorage||window.localStorage).setItem(`${this.props.dialogName||"App"}.${this.props.oContext.adapterName}`,e),this.setState({tab:e},()=>{if(this.props.root){const M=(window.location.hash||"").split("/");M.length>=3&&M[1]==="config"&&(M[3]=this.state.tab,window.location.hash=M.join("/"))}})}render(){const e=this.props.schema.items;let M=!1;const j=[];Object.keys(e).map(N=>{let R;if(e[N].expertMode&&!this.props.expertMode)return;if(this.props.custom){if(this.executeCustom(e[N].hidden,this.props.data,this.props.customObj,this.props.oContext.instanceObj,this.props.index,this.props.globalData))return;R=this.executeCustom(e[N].disabled,this.props.data,this.props.customObj,this.props.oContext.instanceObj,this.props.index,this.props.globalData)}else{if(this.execute(e[N].hidden,!1,this.props.data,this.props.index,this.props.globalData))return;R=this.execute(e[N].disabled,!1,this.props.data,this.props.index,this.props.globalData)}const O=this.getIcon(e[N].icon);M=M||!!O,j.push({icon:O,disabled:R,label:this.getText(e[N].label),name:N})}),j.find(N=>N.name===this.state.tab)||setTimeout(()=>this.setState({tab:j[0].name}),50);const z=this.getCurrentBreakpoint();let E;return z==="xs"&&j.length>2?E=React.createElement(Toolbar,{style:{top:2,backgroundColor:this.props.oContext.themeType==="dark"?"#222":"#DDD"},variant:"dense"},React.createElement(IconButton,{onClick:N=>this.setState({openMenu:N.currentTarget})},React.createElement(MenuIcon,null)),this.state.openMenu?React.createElement(Menu,{open:!0,anchorEl:this.state.openMenu,onClose:()=>this.setState({openMenu:null})},j.map(N=>{const R=this.hasTabErrors(N.name);return React.createElement(MenuItem,{disabled:N.disabled,key:N.name,onClick:()=>{this.setState({openMenu:null},()=>this.onMenuChange(N.name))},selected:N.name===this.state.tab,sx:R?{color:"error.main"}:void 0},M?React.createElement(ListItemIcon,null,N.icon):null,React.createElement(Box,{sx:{display:"flex",alignItems:"center",gap:.5,width:"100%"}},N.label,R&&React.createElement(ErrorIcon$1,{sx:{fontSize:16,color:"error.main"}})))})):null):E=React.createElement(Tabs,{variant:"scrollable",scrollButtons:"auto",style:this.props.schema.tabsStyle,value:this.state.tab,onChange:(N,R)=>this.onMenuChange(R)},j.map(N=>{const R=this.hasTabErrors(N.name),O=R?React.createElement(Box,{sx:{display:"flex",alignItems:"center",gap:.5}},N.label,React.createElement(ErrorIcon$1,{sx:{fontSize:16,color:"error.main"}})):N.label;return React.createElement(Tab$1,{id:N.name,wrapped:!0,disabled:N.disabled,key:N.name,value:N.name,iconPosition:this.props.schema.iconPosition||"start",icon:N.icon,label:O,sx:R?{"& .MuiTab-wrapper":{color:"error.main"}}:void 0})})),React.createElement("div",{style:styles$5.tabs,ref:this.refDiv},E,React.createElement(ConfigPanel,{oContext:this.props.oContext,withoutSaveButtons:this.props.withoutSaveButtons,isParentTab:!0,changed:this.props.changed,key:this.state.tab,expertMode:this.props.expertMode,index:1001,arrayIndex:this.props.arrayIndex,globalData:this.props.globalData,commandRunning:this.props.commandRunning,style:{...styles$5.panel,...M?styles$5.panelWithIcons:styles$5.panelWithoutIcons},common:this.props.common,alive:this.props.alive,themeName:this.props.themeName,data:this.props.data,originalData:this.props.originalData,onChange:this.props.onChange,onError:this.onTabError,customObj:this.props.customObj,custom:this.props.custom,schema:e[this.state.tab],table:this.props.table,withIcons:M}))}}const styles$4={root:{width:"100%",height:"100%"}};class JsonConfigComponent extends reactExports.Component{constructor(e){super(e);_1(this,"forceUpdateHandlers");_1(this,"errorTimeout",null);_1(this,"errorCached",null);_1(this,"oContext");_1(this,"onCommandRunning",e=>this.setState({commandRunning:e}));_1(this,"onAlive",(e,M)=>{!!(M!=null&&M.val)!==this.state.alive&&this.setState({alive:!!(M!=null&&M.val)})});_1(this,"onChange",(e,M,j,z)=>{if(this.props.onValueChange)this.props.onValueChange(e,M,z),j&&j();else if(e&&this.props.onChange){const E={changed:JSON.stringify(e)!==this.state.originalData};this.setState(E,()=>{this.props.onChange(e,E.changed,z),j&&j()})}else z&&this.props.onChange(null,null,z)});_1(this,"onError",(e,M)=>{this.errorCached=this.errorCached||JSON.parse(JSON.stringify(this.state.errors));const j=this.errorCached;M?j[e]=M:delete j[e],this.errorTimeout&&clearTimeout(this.errorTimeout),JSON.stringify(j)!==JSON.stringify(this.state.errors)?this.errorTimeout=setTimeout(()=>this.setState({errors:this.errorCached},()=>{this.errorTimeout=null,this.errorCached=null,this.props.onError(!!Object.keys(this.state.errors).length)}),50):this.errorCached=null});_1(this,"changeLanguage",()=>{this.forceUpdate()});_1(this,"forceAttrUpdate",(e,M)=>{Array.isArray(e)?e.forEach(j=>this.forceUpdateHandlers[j]&&this.forceUpdateHandlers[j](M)):this.forceUpdateHandlers[e]&&this.forceUpdateHandlers[e](M)});_1(this,"registerOnForceUpdate",(e,M)=>{M?this.forceUpdateHandlers[e]=M:this.forceUpdateHandlers[e]&&delete this.forceUpdateHandlers[e]});this.state={originalData:JSON.stringify(this.props.data),changed:!1,errors:{},updateData:this.props.updateData||0,systemConfig:null,alive:!1,commandRunning:!1,schema:JSON.parse(JSON.stringify(this.props.schema))},this.forceUpdateHandlers={},this.buildDependencies(this.state.schema),this.readData()}static getDerivedStateFromProps(e,M){return e.updateData!==M.updateData?{updateData:e.updateData,originalData:JSON.stringify(e.data),schema:JSON.parse(JSON.stringify(e.schema))}:null}static async loadI18n(e,M,j){if(M===!0||M&&typeof M=="string"){const z=I18n.getLanguage(),E=typeof M=="string"?M:"i18n";let N=await e.fileExists(`${j}.admin`,`${E}/${z}.json`),R;if(N?R=`${E}/${z}.json`:(N=await e.fileExists(`${j}.admin`,`${E}/${z}/translations.json`),N?R=`${E}/${z}/translations.json`:z!=="en"&&(N=await e.fileExists(`${j}.admin`,`${E}/en.json`),N?R=`${E}/en.json`:(N=await e.fileExists(`${j}.admin`,`${E}/en/translations.json`),N&&(R=`${E}/en/translations.json`)))),R){const O=await e.readFile(`${j}.admin`,R);let H;O.file!==void 0?H=O.file:H=O;try{const A=JSON.parse(H);I18n.extendTranslations(A,z)}catch(A){return console.error(`Cannot parse language file "${j}.admin/${R}: ${A}`),""}return R}return console.warn(`Cannot find i18n for ${j} / ${R}`),""}return M&&typeof M=="object"&&I18n.extendTranslations(M),""}readData(){this.props.socket.getCompactSystemConfig().then(e=>this.props.socket.getState(`system.adapter.${this.props.adapterName}.${this.props.instance}.alive`).then(M=>this.setState({systemConfig:e.common,alive:!!(M&&M.val)},()=>{this.updateContext(!0),this.props.custom||this.props.socket.subscribeState(`system.adapter.${this.props.adapterName}.${this.props.instance}.alive`,this.onAlive)}))).catch(e=>console.error(`Cannot read system config: ${e}`))}flatten(e,M){return M=M||{},e.items&&Object.keys(e.items).forEach(j=>{M[j]=e.items[j],this.flatten(e.items[j],M)}),M}buildDependencies(e){const M=this.flatten(e);Object.keys(M).forEach(j=>{var z,E,N,R,O,H,A,_,k,P;(z=M[j].confirm)!=null&&z.alsoDependsOn&&((E=M[j].confirm)==null||E.alsoDependsOn.forEach(B=>{if(!M[B])console.error(`[JsonConfigComponent] Attribute ${B} does not exist!`),B.startsWith("data.")&&console.warn(`[JsonConfigComponent] please use "${B.replace(/^data\./,"")}" instead of "${B}"`);else{M[B].confirmDependsOn=M[B].confirmDependsOn||[];const e1={...M[j],attr:j};e1.confirm&&(e1.confirm.cancel="Undo"),M[B].confirmDependsOn.push(e1)}})),(N=M[j].onChange)!=null&&N.alsoDependsOn&&((R=M[j].onChange)==null||R.alsoDependsOn.forEach(B=>{if(!M[B])console.error(`[JsonConfigComponent] Attribute ${B} does not exist!`),B.startsWith("data.")&&console.warn(`[JsonConfigComponent] please use "${B.replace(/^data\./,"")}" instead of "${B}"`);else{M[B].onChangeDependsOn=M[B].onChangeDependsOn||[];const e1={...M[j],attr:j};M[B].onChangeDependsOn.push(e1)}})),(O=M[j].hidden)!=null&&O.alsoDependsOn&&((H=M[j].hidden)==null||H.alsoDependsOn.forEach(B=>{if(!M[B])console.error(`[JsonConfigComponent] Attribute ${B} does not exist!`),B.startsWith("data.")&&console.warn(`[JsonConfigComponent] please use "${B.replace(/^data\./,"")}" instead of "${B}"`);else{M[B].hiddenDependsOn=M[B].hiddenDependsOn||[];const e1={...M[j],attr:j};M[B].hiddenDependsOn.push(e1)}})),(A=M[j].label)!=null&&A.alsoDependsOn&&((_=M[j].label)==null||_.alsoDependsOn.forEach(B=>{if(!M[B])console.error(`[JsonConfigComponent] Attribute ${B} does not exist!`),B.startsWith("data.")&&console.warn(`[JsonConfigComponent] please use "${B.replace(/^data\./,"")}" instead of "${B}"`);else{M[B].labelDependsOn=M[B].labelDependsOn||[];const e1={...M[j],attr:j};M[B].labelDependsOn.push(e1)}})),(k=M[j].help)!=null&&k.alsoDependsOn&&((P=M[j].help)==null||P.alsoDependsOn.forEach(B=>{if(!M[B])console.error(`[JsonConfigComponent] Attribute ${B} does not exist!`),B.startsWith("data.")&&console.warn(`[JsonConfigComponent] please use "${B.replace(/^data\./,"")}" instead of "${B}"`);else{M[B].helpDependsOn=M[B].helpDependsOn||[];const e1={...M[j],attr:j};M[B].helpDependsOn.push(e1)}}))})}updateContext(e){this.oContext={DeviceManager:this.props.DeviceManager,adapterName:this.props.adapterName,changeLanguage:this.changeLanguage,common:this.props.common,customs:this.props.customs,dateFormat:this.props.dateFormat,embedded:this.props.embedded,forceUpdate:this.forceAttrUpdate,imagePrefix:this.props.imagePrefix,instance:this.props.instance,instanceObj:this.props.instanceObj,isFloatComma:this.props.isFloatComma,multiEdit:this.props.multiEdit,onBackEndCommand:this.props.onBackEndCommand,onCommandRunning:this.onCommandRunning,onValueChange:this.props.onValueChange,registerOnForceUpdate:this.registerOnForceUpdate,socket:this.props.socket,systemConfig:this.state.systemConfig,theme:this.props.theme,themeType:this.props.themeType,_themeName:this.props.themeName,updateData:this.state.updateData},e&&this.forceUpdate()}renderItem(e){return e.type==="tabs"?React.createElement(ConfigTabs,{withoutSaveButtons:this.props.withoutSaveButtons,oContext:this.oContext,alive:this.state.alive,changed:this.state.changed,commandRunning:this.state.commandRunning,common:this.props.common,custom:this.props.custom,customObj:this.props.customObj,data:this.props.data,onChange:this.onChange,onError:(M,j)=>this.onError(M,j),originalData:JSON.parse(this.state.originalData),root:!0,schema:e,expertMode:this.props.expertMode,themeName:this.props.themeName}):e.type==="panel"||!e.type?React.createElement(ConfigPanel,{withoutSaveButtons:this.props.withoutSaveButtons,oContext:this.oContext,alive:this.state.alive,changed:this.state.changed,commandRunning:this.state.commandRunning,common:this.props.common,custom:this.props.custom,customObj:this.props.customObj,data:this.props.data,expertMode:this.props.expertMode,index:1e3,isParentTab:!this.props.embedded&&!this.props.withoutSaveButtons,onChange:this.onChange,onError:(M,j)=>this.onError(M,j),originalData:JSON.parse(this.state.originalData),root:!0,schema:e,themeName:this.props.themeName}):(console.error(`Unknown item type in root: ${JSON.stringify(e)}`),null)}render(){return!this.state.systemConfig||!this.oContext?React.createElement(LinearProgress,null):(this.oContext._themeName!==this.props.themeName&&(this.oContext._themeName=this.props.themeName,setTimeout(()=>this.updateContext(!0),0)),React.createElement("div",{style:{...!this.props.embedded||this.props.withoutSaveButtons?styles$4.root:void 0,...this.props.style,...this.state.schema.style}},this.renderItem(this.state.schema)))}}const styles$3={root:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},scroll:{height:"calc(100% - 48px)",overflowY:"auto"},exportImportButtons:{position:"absolute",top:5,right:0,zIndex:3},button:{marginRight:"5px"},tooltip:{pointerEvents:"none"}};function decryptLegacy(t,o){let e="";for(let M=0;M<o.length;M++)e+=String.fromCharCode(t[M%t.length].charCodeAt(0)^o.charCodeAt(M));return e}function encryptLegacy(t,o){let e="";for(let M=0;M<o.length;M++)e+=String.fromCharCode(t[M%t.length].charCodeAt(0)^o.charCodeAt(M));return e}function decrypt(t,o){if(typeof o!="string")return o;if(!o.startsWith("$/aes-192-cbc:")||!/^[0-9a-f]{48}$/.test(t))return decryptLegacy(t,o);const e=o.split(":",3),M=window.CryptoJS.enc.Hex.parse(t),j=window.CryptoJS.enc.Hex.parse(e[1]),z=window.CryptoJS.lib.CipherParams.create({ciphertext:window.CryptoJS.enc.Hex.parse(e[2])}),E=window.CryptoJS.AES.decrypt(z,M,{iv:j});return window.CryptoJS.enc.Utf8.stringify(E)}function encrypt(t,o,e){if(typeof o!="string")return o;if(!/^[0-9a-f]{48}$/.test(t))return encryptLegacy(t,o);let M;M=window.CryptoJS.lib.WordArray.random(128/8);const j=window.CryptoJS.enc.Hex.parse(t),z=window.CryptoJS.AES.encrypt(o,j,{iv:M}).ciphertext;return`$/aes-192-cbc:${window.CryptoJS.enc.Hex.stringify(M)}:${z}`}function loadScript(t,o){var e;return document.getElementById(o)?(e=document.getElementById(o))==null?void 0:e.onload:new Promise(M=>{const j=document.createElement("script");j.setAttribute("id",o),j.onload=M,j.src=t,document.getElementsByTagName("head")[0].appendChild(j)})}let JsonConfig$1=class extends Router{constructor(e){super(e);_1(this,"fileSubscribed",[]);_1(this,"fileLangSubscribed","");_1(this,"secret");_1(this,"handleFileSelect",e=>{const M=e.target.files[0];if(M){const j=new FileReader;j.onload=z=>{if(!z.target)return;const E=z.target.result;try{const N=JSON.parse(E);this.setState({data:N,changed:JSON.stringify(N)!==JSON.stringify(this.state.originalData)})}catch{window.alert(I18n.t("[JsonConfig] Failed to parse JSON file"))}},j.readAsText(M)}else window.alert(I18n.t("[JsonConfig] Failed to open JSON File"))});_1(this,"onFileChange",async(e,M,j)=>{var z;if(e===`${this.props.adapterName}.admin`&&j){if(M===this.fileLangSubscribed)try{await JsonConfigComponent.loadI18n(this.props.socket,(z=this.state.schema)==null?void 0:z.i18n,this.props.adapterName),this.setState({hash:`${this.state.hash}1`})}catch{}else if(this.fileSubscribed.includes(M))try{const E=await this.getConfigFile(this.fileSubscribed[0]);this.setState({schema:E,hash:MD5(JSON.stringify(E)).toString()})}catch{}}});this.state={updateData:0,changed:!1,confirmDialog:!1,theme:Theme(e.themeName),saveConfigDialog:!1,hash:"_"},this.secret=e.secret||"",this.getInstanceObject().then(M=>this.getConfigFile().then(j=>JsonConfigComponent.loadI18n(this.props.socket,j==null?void 0:j.i18n,this.props.adapterName).then(z=>{z&&(this.fileLangSubscribed||(this.fileLangSubscribed=z,this.props.socket.subscribeFiles(`${this.props.adapterName}.admin`,this.fileLangSubscribed,this.onFileChange))),M?this.setState({schema:j,data:M.native,common:M.common,hash:MD5(JSON.stringify(j)).toString()}):window.alert(`Instance system.adapter.${this.props.adapterName}.${this.props.instance} not found!`)})))}componentWillUnmount(){super.componentWillUnmount(),this.fileSubscribed.length&&(this.props.socket.unsubscribeFiles(`${this.props.adapterName}.admin`,this.fileSubscribed,this.onFileChange),this.fileSubscribed=[]),this.fileLangSubscribed&&(this.props.socket.unsubscribeFiles(`${this.props.adapterName}.admin`,this.fileLangSubscribed,this.onFileChange),this.fileLangSubscribed="")}getExportImportButtons(){return React.createElement("div",{style:styles$3.exportImportButtons},React.createElement(Tooltip,{title:this.props.t("Import settings from JSON file"),slotProps:{popper:{sx:styles$3.tooltip}}},React.createElement(Fab,{size:"small",sx:{"&.MuiFab-root":styles$3.button},onClick:()=>{const e=document.createElement("input");e.setAttribute("type","file"),e.setAttribute("id","files"),e.setAttribute("opacity",0),e.addEventListener("change",M=>this.handleFileSelect(M),!1),e.click()}},React.createElement(PublishIcon,null))),React.createElement(Tooltip,{title:this.props.t("Export setting to JSON file"),slotProps:{popper:{sx:styles$3.tooltip}}},React.createElement(Fab,{size:"small",sx:{"&.MuiFab-root":styles$3.button},onClick:()=>{this.state.data&&Utils.generateFile(`${this.props.adapterName}.${this.props.instance}.json`,this.state.data)}},React.createElement(PublishIcon,{style:{transform:"rotate(180deg)"}}))))}async getInstanceObject(){var e;try{const M=await this.props.socket.getObject(`system.adapter.${this.props.adapterName}.${this.props.instance}`);if(Array.isArray(M.encryptedNative)){if(!this.secret){const j=await this.props.socket.getSystemConfig();await loadScript("../../lib/js/crypto-js/crypto-js.js","crypto-js"),this.secret=j.native.secret}return(e=M.encryptedNative)==null||e.forEach(j=>{M.native[j]&&(M.native[j]=decrypt(this.secret,M.native[j]))}),M}return M}catch(M){window.alert(`[JsonConfig] Cannot read instance object: ${M}`)}return null}renderDialogConfirm(){return this.state.confirmDialog?React.createElement(DialogConfirm,{title:I18n.t("ra_Please confirm"),text:I18n.t("ra_Some data are not stored. Discard?"),ok:I18n.t("ra_Discard"),cancel:I18n.t("ra_Cancel"),onClose:e=>this.setState({confirmDialog:!1},()=>e&&Router.doNavigate(null))}):null}async scanForInclude(e,M){if(typeof e["#include"]=="string"){const z=await this._getConfigFile(e["#include"],[...M]);return delete e["#include"],z&&(e={...e,...z}),e}const j=Object.keys(e);for(let z=0;z<j.length;z++)e[j[z]]&&typeof e[j[z]]=="object"&&(e[j[z]]=await this.scanForInclude(e[j[z]],M));return e}async getConfigFile(e){return this._getConfigFile(e)}async _getConfigFile(e,M){if(e=e||"jsonConfig.json5",M=M||[],M.includes(e))return window.alert(`[JsonConfig] Circular reference in file: ${e} => ${M.join(" => ")}`),null;M.push(e);try{await this.props.socket.fileExists(`${this.props.adapterName}.admin`,e)||(e="jsonConfig.json");const z=await this.props.socket.readFile(`${this.props.adapterName}.admin`,e);let E="",N="";if(z.file!==void 0&&(N=z.file),typeof N=="string")E=N;else if(N.type==="Buffer"){let R="";const O=new Uint8Array(N.data),H=O.byteLength;for(let A=0;A<H;A++)R+=String.fromCharCode(O[A]);E=R}this.fileSubscribed.includes(e)||(this.fileSubscribed.push(e),await this.props.socket.subscribeFiles(`${this.props.adapterName}.admin`,e,this.onFileChange));try{return await this.scanForInclude(lib$1.parse(E),M)}catch(R){window.alert("[JsonConfig] Cannot parse json5 config!"),console.log(R)}}catch(j){this.state.schema||window.alert(`[JsonConfig] Cannot read file "${e}: ${j}`)}return null}renderSaveConfigDialog(){return this.state.saveConfigDialog?React.createElement(DialogConfirm,{title:I18n.t("ra_Please confirm"),text:I18n.t("Save configuration?"),ok:I18n.t("ra_Save"),cancel:I18n.t("ra_Cancel"),onClose:e=>this.setState({saveConfigDialog:!1},()=>e&&this.onSave(!0))}):null}findAttr(e,M){if(M=M||this.state.schema,M!=null&&M.items){if(e in M.items)return M.items[e];for(const j of Object.values(M.items)){const z=this.findAttr(e,j);if(z)return z}}return null}postProcessing(e,M,j){if(j=j||this.state.schema,!e){console.error(`Data is empty in postProcessing: ${M}, ${JSON.stringify(j)}`);return}const z=e[M];if(j.items)if(j.type==="table"){const E=z;if(!Array.isArray(E))return;for(const N of E)for(const R of j.items)this.postProcessing(N,R.attr,R)}else for(const[E,N]of Object.entries(j.items)){if(N.type==="panel"||N.type==="tabs"||N.type==="accordion")return;this.postProcessing(e,E,N)}else if(M&&typeof z=="string")if(j.type==="text")j.trim!==!1&&(e[M]=z.trim());else if(j.type==="ip")e[M]=z.trim();else if(j.type==="number"){const E=parseFloat(z.toString().replace(",","."));j.min!==void 0&&E<j.min?e[M]=j.min:j.max!==void 0&&E>j.max?e[M]=j.max:e[M]=E}else if(j.type==="port"){const E=parseInt(z.toString(),10);j.min!==void 0&&E<j.min?e[M]=j.min:j.max!==void 0&&E>j.max&&(e[M]=j.max),e[M]!==0&&E<20?e[M]=20:E>65535?e[M]=65535:e[M]=E}else j.type==="checkbox"&&(e[M]=e[M]===!0||e[M]==="true"||e[M]==="on"||e[M]===1||e[M]==="1")}async onSave(e,M){if(e){const j=await this.getInstanceObject();if(!j){console.error("Something went wrong: may be no connection?"),window.alert("Something went wrong: may be no connection?");return}if(!this.state.data||!this.state.schema)return;const z={};for(const N of Object.keys(this.state.data)){const R=this.findAttr(N);(!R||!R.doNotSave||R.type==="state")&&!N.startsWith("_")?ConfigGeneric.setValue(j.native,N,this.state.data[N]):(ConfigGeneric.setValue(j.native,N,null),z[N]=this.state.data[N])}try{const N=JSON.parse(JSON.stringify(j));if(Array.isArray(N.encryptedNative)){await loadScript("../../lib/js/crypto-js/crypto-js.js","crypto-js");for(const R of N.encryptedNative)N.native[R]&&(N.native[R]=encrypt(this.secret,N.native[R]))}await this.props.socket.setObject(N._id,N)}catch(N){window.alert(`[JsonConfig] Cannot set object: ${N}`)}const E={...j.native,...z};console.log(E),this.setState({changed:!1,data:E,updateData:this.state.updateData+1,originalData:E},()=>M&&Router.doNavigate(null))}else this.state.changed?this.setState({confirmDialog:!0}):Router.doNavigate(null)}componentDidUpdate(e,M){M.changed!==this.state.changed&&this.props.configStored(!this.state.changed)}async componentDidMount(){const e=`${window.location.protocol}//${window.location.host}${window.location.pathname}validate_config/${this.props.adapterName}`;console.log(`fetch ${e}`),await fetch(e)}render(){return!this.state.data||!this.state.schema?React.createElement(LinearProgress,null):React.createElement("div",{style:styles$3.root},this.renderDialogConfirm(),this.getExportImportButtons(),this.renderSaveConfigDialog(),React.createElement(JsonConfigComponent,{key:this.state.hash,style:styles$3.scroll,socket:this.props.socket,themeName:this.props.themeName,themeType:this.props.themeType,adapterName:this.props.adapterName,instance:this.props.instance,isFloatComma:this.props.isFloatComma,dateFormat:this.props.dateFormat,schema:this.state.schema,common:this.state.common,expertMode:this.props.expertMode,data:this.state.data,updateData:this.state.updateData,onError:e=>this.setState({error:e}),onChange:(e,M,j)=>{j&&this.state.error&&(window.alert(I18n.t("Cannot save configuration because of error in configuration")),j=!1),j&&!this.state.changed&&!M&&(j=!1),e?this.setState({data:e,changed:M,saveConfigDialog:j}):j!==void 0&&this.setState({saveConfigDialog:j})},DeviceManager:this.props.DeviceManager,theme:this.state.theme}),React.createElement(SaveCloseButtons,{isIFrame:!1,dense:!0,paddingLeft:0,newReact:!0,theme:this.state.theme,noTextOnButtons:this.props.width==="xs"||this.props.width==="sm"||this.props.width==="md",changed:!!(this.state.error||this.state.changed),error:!!this.state.error,onSave:e=>this.onSave(!0,e),onClose:()=>this.onSave(!1)}))}};const schema$1={type:"panel",label:"Connection",items:{_header1:{newLine:!0,type:"header",label:"Address and ID options",xs:12},_showAliasesInfo:{newLine:!0,type:"infoBox",text:"showAliasesExplanation",title:"Using aliases as address",xs:12},showAliases:{newLine:!0,type:"checkbox",label:"Use aliases as address",xs:12},_showDirectAddresses:{newLine:!0,type:"infoBox",text:"directAddressesExplanation",title:"Using direct addresses",xs:12,hidden:"!data.showAliases"},directAddresses:{type:"checkbox",label:"Use direct addresses by aliases",xs:12,hidden:"!data.showAliases"},doNotRoundAddressToWord:{newLine:!0,type:"checkbox",label:"Do not align addresses to word",help:"doNotRoundAddressToWord_help",xs:12},doNotIncludeAdrInId:{type:"checkbox",label:"do not include address in ID",help:"doNotIncludeAdrInId_help",hidden:"!!data.showAliases",xs:12},preserveDotsInId:{type:"checkbox",label:"preserve dots in ID",help:"preserveDotsInId_help",xs:12},removeUnderscorePrefix:{type:"checkbox",label:'Remove leading "_" in ID if address is not included',xs:12,hidden:"!!data.showAliases || !data.doNotIncludeAdrInId"},_header2:{newLine:!0,type:"header",label:"Read/Write settings",xs:12},doNotUseWriteMultipleRegisters:{newLine:!0,type:"checkbox",hidden:'data.slave === "1" || !!data.onlyUseWriteMultipleRegisters',label:'Do not use "Write multiple registers"',help:"Write only with FC5/FC6",xs:12,md:6},onlyUseWriteMultipleRegisters:{type:"checkbox",hidden:'data.slave === "1" || !!data.doNotUseWriteMultipleRegisters',label:'Use only "Write multiple registers"',help:"Write only with FC15/FC16",xs:12,md:6},maxBlock:{newLine:!0,type:"number",label:"Max read request length",unit:"registers",xs:12,hidden:'data.slave === "1"',md:6},maxBoolBlock:{type:"number",label:"Max read request length (booleans)",unit:"registers",xs:12,hidden:'data.slave === "1"',md:6},alwaysUpdate:{newLine:!0,type:"checkbox",label:"Update unchanged states",help:"alwaysUpdate_help",hidden:'data.slave === "1"',xs:12,md:6},round:{type:"number",min:0,max:20,label:"Round Real to",md:6},_headerTimings:{newLine:!0,type:"header",label:"Timings",xs:12,hidden:'data.slave === "1"'},poll:{newLine:!0,type:"number",min:1,label:"Poll delay",unit:"ms",help:"poll_help",xs:12,hidden:'data.slave === "1"'},recon:{type:"number",min:1,label:"Reconnect time",unit:"ms",xs:12,hidden:'data.slave === "1"'},timeout:{type:"number",min:100,label:"Read timeout",unit:"ms",help:"timeout_help",xs:12,hidden:'data.slave === "1"'},pulseTime:{type:"number",label:"Pulse time",unit:"ms",help:"pulsetime_help",xs:12,hidden:'data.slave === "1"'},waitTime:{type:"number",label:"Wait time",unit:"ms",help:"waitTime_help",xs:12,hidden:'data.slave === "1"'},readInterval:{newLine:!0,type:"number",label:"Read interval",unit:"ms",help:"readInterval_help",xs:12,md:6,hidden:'data.slave === "1"'},writeInterval:{type:"number",label:"Write interval",unit:"ms",help:"writeInterval_help",xs:12,md:6,hidden:'data.slave === "1"'},_headerOthers:{newLine:!0,type:"header",label:"Others",xs:12},disableLogging:{type:"checkbox",label:"Disable connection error logging",help:"disableLogging_help"}}};function Settings$b(t){const[o,e]=React.useState(t.native.params.directAddresses),[M,j]=React.useState(t.native.params.showAliases);return jsxRuntimeExports.jsx("div",{style:{width:"calc(100% - 8px)",minHeight:"100%"},children:jsxRuntimeExports.jsx(JsonConfigComponent,{common:t.common,socket:t.socket,themeName:t.themeName,themeType:t.themeType,adapterName:"modbus",instance:t.instance||0,isFloatComma:t.systemConfig.common.isFloatComma,dateFormat:t.systemConfig.common.dateFormat,schema:schema$1,onChange:z=>{const E=JSON.parse(JSON.stringify(t.native));E.params=z,E.params.showAliases!==M&&(j(E.params.showAliases),["disInputs","inputRegs","holdingRegs","coils"].forEach(N=>{E[N].forEach(R=>{E.params.showAliases?(R._address=address2alias$1(N,R._address),E.params.directAddresses&&(R._address=nonDirect2direct(N,R._address))):(E.params.directAddresses&&(R._address=direct2nonDirect(N,R._address)),R._address=alias2address(N,R._address))})})),E.params.directAddresses!==o&&(e(E.params.directAddresses),E.params.showAliases&&["disInputs","coils"].forEach(N=>{E[N].forEach(R=>{E.params.directAddresses?R._address=nonDirect2direct(N,R._address):R._address=direct2nonDirect(N,R._address)})})),t.changeNative(E)},data:t.native.params,onError:()=>{},theme:t.theme,withoutSaveButtons:!0})})}const types=[{value:"",title:""},{value:"uint16be",title:"Unsigned 16 bit (Big Endian)"},{value:"uint16le",title:"Unsigned 16 bit (Little Endian)"},{value:"int16be",title:"Signed 16 bit (Big Endian)"},{value:"int16le",title:"Signed 16 bit (Little Endian)"},{value:"uint32be",title:"Unsigned 32 bit (Big Endian)"},{value:"uint32le",title:"Unsigned 32 bit (Little Endian)"},{value:"uint32sw",title:"Unsigned 32 bit (Big Endian Word Swap)"},{value:"uint32sb",title:"Unsigned 32 bit (Big Endian Byte Swap)"},{value:"int32be",title:"Signed 32 bit (Big Endian)"},{value:"int32le",title:"Signed 32 bit (Little Endian)"},{value:"int32sw",title:"Signed 32 bit (Big Endian Word Swap)"},{value:"int32sb",title:"Signed 32 bit (Big Endian Byte Swap)"},{value:"uint64be",title:"Unsigned 64 bit (Big Endian)"},{value:"uint64le",title:"Unsigned 64 bit (Little Endian)"},{value:"uint8be",title:"Unsigned 8 bit (Big Endian)"},{value:"uint8le",title:"Unsigned 8 bit (Little Endian)"},{value:"int8be",title:"Signed 8 bit (Big Endian)"},{value:"int8le",title:"Signed 8 bit (Little Endian)"},{value:"floatbe",title:"Float (Big Endian)"},{value:"floatle",title:"Float (Little Endian)"},{value:"floatsw",title:"Float (Big Endian Word Swap)"},{value:"floatsb",title:"Float (Big Endian Byte Swap)"},{value:"doublebe",title:"Double (Big Endian)"},{value:"doublele",title:"Double (Little Endian)"},{value:"string",title:"String (Zero-end)"},{value:"stringle",title:"String (Little Endian, Zero-end)"},{value:"string16",title:"String 16 bit (Zero-end)"},{value:"string16le",title:"String 16 bit (Little Endian, Zero-end)"},{value:"rawhex",title:"String with value in hex representation"}],roles=[{value:"",title:""},{value:"value",title:"value"},{value:"level",title:"level"},{value:"state",title:"state"},{value:"switch",title:"switch"},{value:"value.temperature",title:"value.temperature"},{value:"value.humidity",title:"value.humidity"},{value:"value.brightness",title:"value.brightness"},{value:"value.uv",title:"value.uv"},{value:"value.pressure",title:"value.pressure"},{value:"value.battery",title:"value.battery"},{value:"value.valve",title:"value.valve"},{value:"value.time",title:"value.time"},{value:"value.interval",title:"value.interval"},{value:"value.window",title:"value.window"},{value:"button",title:"button"},{value:"indicator",title:"indicator"},{value:"level.dimmer",title:"level.dimmer"},{value:"level.valve",title:"level.valve"},{value:"level.blind",title:"level.blind"},{value:"level.temperature",title:"level.temperature"},{value:"level.interval",title:"level.interval"},{value:"value.power.consumption",title:"value.power.consumption"}];var source={exports:{}},json2tsv={},hasRequiredJson2tsv;function requireJson2tsv(){if(hasRequiredJson2tsv)return json2tsv;hasRequiredJson2tsv=1,Object.defineProperty(json2tsv,"__esModule",{value:!0}),json2tsv.json2tsv=void 0;function t(j){if(!Array.isArray(j))throw new TypeError(`Expected string[][], got ${typeof j}`);for(const z of j){if(!Array.isArray(z))throw new TypeError(`Expected string[][], got ${typeof z}[]`);for(const E of z)if(typeof E!="string")throw new TypeError(`Expected string[][], got ${typeof E}[][]`)}}const o=/[\t\n"]/;function e(j){return o.test(j)}function M(j){return t(j),j.map(z=>z.map(E=>e(E)?`"${E.replace(/"/g,'""')}"`:E).join(" ")).join(`
|
|
2609
|
+
`).map(R=>R.replace("\r","").trim()),{schema:j}=this.props,z=M.shift().split(";").filter(R=>R&&j.items.find(O=>O.attr===R)),E=[];M.forEach(R=>{const O=R.split(";"),H={};for(let A=0;A<O.length;A++){let _=O[A];if(_.startsWith('"')){for(_=_.substring(1);A<O.length&&!_.endsWith('"');)_+=`;${O[++A]}`;_=_.substring(0,_.length-1)}let k=_;if(_==="true")k=!0;else if(_==="false")k=!1;else if(window.isFinite(_)){const P=this.props.schema.items.find(B=>B.attr===z[A]);P&&P.type==="number"?k=parseFloat(_):k=_}else k=_;H[z[A]]=k}E.push(H)}),E.length?(N=this.state.value)!=null&&N.length?this.setState({showTypeOfImportDialog:E,showImportDialog:!1}):this.setState({value:E,showImportDialog:!1}):window.alert("ra_No data found in file")}isAnyFilterSet(){return!!Object.keys(this.filterRefs).find(e=>ConfigTable.getFilterValue(this.filterRefs[e]))}onMoveUp(e){const M=JSON.parse(JSON.stringify(this.state.value)),j=M[e];M.splice(e,1),M.splice(e-1,0,j),this.setState({value:M,iteration:this.state.iteration+1e4},()=>this.applyFilter(!1,null,()=>this.onChangeWrapper(M)))}onMoveDown(e){const M=JSON.parse(JSON.stringify(this.state.value)),j=M[e];M.splice(e,1),M.splice(e+1,0,j),this.setState({value:M,iteration:this.state.iteration+1e4},()=>this.applyFilter(!1,null,()=>this.onChangeWrapper(M)))}onDrop(e){const M=e[0],j=new FileReader;j.onabort=()=>console.log("file reading was aborted"),j.onerror=()=>console.log("file reading has failed"),j.onload=()=>{if(M.size>MAX_SIZE){window.alert(I18n.t("ra_File is too big. Max %sk allowed. Try use SVG.",Math.round(MAX_SIZE/1024)));return}const z=new Uint8Array(j.result).reduce((E,N)=>E+String.fromCharCode(N),"");this.onImport(z)},j.readAsArrayBuffer(M)}showTypeOfImportDialog(){return this.state.showTypeOfImportDialog?React.createElement(Dialog,{open:!0,onClose:()=>this.setState({showTypeOfImportDialog:!1}),maxWidth:"md"},React.createElement(DialogTitle,null,I18n.t("ra_Append or replace?")),React.createElement(DialogContent,null,I18n.t("ra_Append %s entries or replace existing?",this.state.showTypeOfImportDialog.length)),React.createElement(DialogActions,null,React.createElement(Button,{variant:"contained",color:"primary",autoFocus:!0,onClick:()=>{const e=JSON.parse(JSON.stringify(this.state.value));this.state.showTypeOfImportDialog.forEach(M=>e.push(M)),this.setState({value:e,iteration:this.state.iteration+1e4,showTypeOfImportDialog:!1},()=>this.applyFilter(!1,null,()=>this.onChangeWrapper(e)))}},I18n.t("ra_Append")),React.createElement(Button,{variant:"contained",color:"secondary",autoFocus:!0,onClick:()=>{const e=this.state.showTypeOfImportDialog;this.setState({value:e,iteration:this.state.iteration+1e4,showTypeOfImportDialog:!1},()=>this.applyFilter(!1,null,()=>this.onChangeWrapper(e)))}},I18n.t("ra_Replace")))):null}showImportDialog(){return this.state.showImportDialog?React.createElement(Dialog,{open:!0,onClose:()=>this.setState({showImportDialog:!1}),sx:{"& .MuiDialog-paper":{minHeight:500}},maxWidth:"md",fullWidth:!0},React.createElement(DialogTitle,null,I18n.t("ra_Import from %s","CSV")),React.createElement(DialogContent,null,React.createElement(Dropzone,{multiple:!1,accept:{"text/csv":[".csv"]},maxSize:MAX_SIZE,onDragEnter:()=>this.setState({uploadFile:"dragging"}),onDragLeave:()=>this.setState({uploadFile:!0}),onDrop:(e,M)=>{this.setState({uploadFile:!1}),e.length?this.onDrop(e):window.alert(M&&M[0]&&M[0].errors&&M[0].errors[0]&&M[0].errors[0].message||I18n.t("ra_Cannot upload"))}},({getRootProps:e,getInputProps:M})=>React.createElement("div",{style:{...styles$a.uploadDiv,...this.state.uploadFile==="dragging"?styles$a.uploadDivDragging:void 0,...styles$a.dropZone,...this.state.icon?void 0:styles$a.dropZoneEmpty},...e()},React.createElement("input",{...M()}),React.createElement("div",{style:styles$a.uploadCenterDiv},React.createElement("div",{style:styles$a.uploadCenterTextAndIcon},React.createElement(ImportIcon,{style:styles$a.uploadCenterIcon}),React.createElement("div",{style:styles$a.uploadCenterText},this.state.uploadFile==="dragging"?I18n.t("ra_Drop file here"):I18n.t("ra_Place your files here or click here to open the browse dialog"))))))),React.createElement(DialogActions,null,React.createElement(Button,{variant:"contained",onClick:()=>this.setState({showImportDialog:!1}),color:"primary",startIcon:React.createElement(CloseIcon,null)},I18n.t("Cancel")))):null}renderOneFilter(e){return React.createElement(TableCell,{key:`${e.headCell.attr}_${e.index}`,style:e.style,align:"left",sortDirection:e.orderBy===e.headCell.attr?e.order:!1},React.createElement("div",{style:{...styles$a.flex,...e.schema.showFirstAddOnTop?{flexDirection:"column"}:void 0}},e.showAddButton?this.renderAddButton(e.doAnyFilterSet):null,e.headCell.sort&&React.createElement(TableSortLabel,{active:!0,style:e.orderBy!==e.headCell.attr?styles$a.silver:void 0,direction:e.orderBy===e.headCell.attr?e.order:"asc",onClick:()=>this.handleRequestSort(e.headCell.attr)}),e.headCell.filter&&this.state.filterOn.includes(e.headCell.attr)?React.createElement(TextField,{variant:"standard",ref:this.filterRefs[e.headCell.attr],onChange:()=>this.applyFilter(),title:I18n.t("ra_You can filter entries by entering here some text"),slotProps:{input:{endAdornment:ConfigTable.getFilterValue(this.filterRefs[e.headCell.attr])&&React.createElement(InputAdornment,{position:"end"},React.createElement(IconButton,{size:"small",tabIndex:-1,onClick:()=>{ConfigTable.setFilterValue(this.filterRefs[e.headCell.attr],""),this.applyFilter()}},React.createElement(CloseIcon,null)))}},fullWidth:!0,placeholder:this.getText(e.headCell.title)}):React.createElement("span",{style:styles$a.headerText},this.getText(e.headCell.title)),this.renderShowHideFilter(e.headCell)))}enhancedFilterCard(){var N;const{schema:e}=this.props,{order:M,orderBy:j}=this.state;let z;this.props.schema.compact&&(z={paddingTop:1,paddingBottom:1});const E=!e.noDelete&&e.import||e.export;return E||e.items.find(R=>R.sort||R.filter)?React.createElement(Grid2,{size:{xs:e.xs||12,sm:e.sm||void 0,md:e.md||void 0,lg:e.lg||void 0,xl:e.xl||void 0}},React.createElement(Card,null,React.createElement(Paper,{style:styles$a.paper},React.createElement(Accordion,{style:styles$a.paper},React.createElement(AccordionSummary,{expandIcon:React.createElement(ExpandMoreIcon,null)},React.createElement(Typography,null,I18n.t("ra_Filter and Data Actions"))),React.createElement(AccordionDetails,null,React.createElement(Table,null,React.createElement(TableBody,null,((N=e.items)==null?void 0:N.find(R=>R.sort||R.filter))&&e.items.map((R,O)=>React.createElement(TableRow,{key:`${R.attr}_${O}`},this.renderOneFilter({schema:e,style:z,showAddButton:!1,headCell:R,order:M,orderBy:j,index:O,doAnyFilterSet:!1}))),E?React.createElement(TableRow,null,React.createElement(TableCell,{align:"left",style:z},React.createElement("span",{style:styles$a.headerText},I18n.t("ra_Actions"))),React.createElement(TableCell,{style:z},this.renderImportExportButtons(e))):null))))))):null}enhancedBottomCard(){const{schema:e}=this.props;let M;this.props.schema.compact&&(M={paddingTop:1,paddingBottom:1});const j=this.isAnyFilterSet();return React.createElement(Grid2,{size:{xs:e.xs||12,sm:e.sm||void 0,md:e.md||void 0,lg:e.lg||void 0,xl:e.xl||void 0}},React.createElement(Card,null,React.createElement(Paper,{style:styles$a.paper},React.createElement(Table,null,React.createElement(TableBody,null,React.createElement(TableRow,null,React.createElement(TableCell,{colSpan:e.items.length+1,style:M},this.renderAddButton(j))))))))}renderCards(){const{schema:e}=this.props;let{visibleValue:M}=this.state,j;this.props.schema.compact&&(j={paddingTop:1,paddingBottom:1}),M||(M=this.state.value.map((E,N)=>N));const z=this.isAnyFilterSet();return React.createElement(Grid2,{container:!0},this.showImportDialog(),this.showTypeOfImportDialog(),this.enhancedFilterCard(),M.map((E,N)=>{var R;return React.createElement(Grid2,{key:`${E}_${N}`,size:{xs:e.xs||12,sm:e.sm||void 0,md:e.md||void 0,lg:e.lg||void 0,xl:e.xl||void 0}},React.createElement(Card,null,React.createElement(Paper,{style:styles$a.paper},React.createElement(Table,null,React.createElement(TableBody,null,(R=e.items)==null?void 0:R.map(O=>React.createElement(TableRow,{key:`${O.attr}_${E}`},React.createElement(TableCell,{align:"left",style:j},React.createElement("span",{style:styles$a.headerText},this.getText(O.title))),React.createElement(TableCell,{align:"left",style:j},this.itemTable(O.attr,this.state.value[E],E)))),!e.noDelete&&React.createElement(TableRow,null,React.createElement(TableCell,{align:"left",style:j},React.createElement("span",{style:styles$a.headerText},this.getText("Actions"))),React.createElement(TableCell,{align:"left",style:j},!z&&!this.state.orderBy?React.createElement(Tooltip,{title:I18n.t("ra_Move up"),slotProps:{popper:{sx:styles$a.tooltip}}},React.createElement("span",null,React.createElement(IconButton,{size:"small",onClick:()=>this.onMoveUp(E),disabled:N===0},React.createElement(UpIcon,null)))):null,!z&&!this.state.orderBy?React.createElement(Tooltip,{title:I18n.t("ra_Move down"),slotProps:{popper:{sx:styles$a.tooltip}}},React.createElement("span",null,React.createElement(IconButton,{size:"small",onClick:()=>this.onMoveDown(E),disabled:N===M.length-1},React.createElement(DownIcon,null)))):null,React.createElement(Tooltip,{title:I18n.t("ra_Delete current row"),slotProps:{popper:{sx:styles$a.tooltip}}},React.createElement(IconButton,{size:"small",onClick:this.onDelete(E)},React.createElement(DeleteIcon,null))),this.props.schema.clone?React.createElement(Tooltip,{title:I18n.t("ra_Clone current row"),slotProps:{popper:{sx:styles$a.tooltip}}},React.createElement(IconButton,{size:"small",onClick:this.onClone(E)},React.createElement(IconCopy$1,null))):null)))))))}),this.enhancedBottomCard())}renderTable(){const{schema:e}=this.props;let{visibleValue:M}=this.state;M=M||this.state.value.map((E,N)=>N);const j=this.isAnyFilterSet();let z;return this.props.schema.compact&&(z={paddingTop:1,paddingBottom:1}),React.createElement(Paper,{style:styles$a.paper},this.showImportDialog(),this.showTypeOfImportDialog(),e.label?React.createElement("div",{style:styles$a.label},React.createElement(Toolbar,{variant:"dense",style:styles$a.rootTool},React.createElement(Typography,{style:styles$a.title,variant:"h6",id:"tableTitle",component:"div"},this.getText(e.label)))):null,React.createElement(TableContainer,null,React.createElement(Table,{style:styles$a.table,size:"small"},this.enhancedTableHead(!j&&!this.state.orderBy?120:64,j),React.createElement(TableBody,null,M.map((E,N)=>{var R;return React.createElement(TableRow,{hover:!0,key:`${E}_${N}`},(R=e.items)==null?void 0:R.map(O=>React.createElement(TableCell,{key:`${O.attr}_${E}`,align:"left",style:z},this.itemTable(O.attr,this.state.value[E],E))),!e.noDelete&&React.createElement(TableCell,{align:"left",style:{...z,...styles$a.buttonCell}},!j&&!this.state.orderBy?N?React.createElement(Tooltip,{title:I18n.t("ra_Move up"),slotProps:{popper:{sx:styles$a.tooltip}}},React.createElement(IconButton,{size:"small",onClick:()=>this.onMoveUp(E)},React.createElement(UpIcon,null))):React.createElement("div",{style:styles$a.buttonEmpty}):null,!j&&!this.state.orderBy?N<M.length-1?React.createElement(Tooltip,{title:I18n.t("ra_Move down"),slotProps:{popper:{sx:styles$a.tooltip}}},React.createElement(IconButton,{size:"small",onClick:()=>this.onMoveDown(E)},React.createElement(DownIcon,null))):React.createElement("div",{style:styles$a.buttonEmpty}):null,React.createElement(Tooltip,{title:I18n.t("ra_Delete current row"),slotProps:{popper:{sx:styles$a.tooltip}}},React.createElement(IconButton,{size:"small",onClick:this.onDelete(E)},React.createElement(DeleteIcon,null))),this.props.schema.clone?React.createElement(Tooltip,{title:I18n.t("ra_Clone current row"),slotProps:{popper:{sx:styles$a.tooltip}}},React.createElement(IconButton,{size:"small",onClick:this.onClone(E)},React.createElement(IconCopy$1,null))):null))}),!e.noDelete&&M.length>=(e.showSecondAddAt||5)?React.createElement(TableRow,null,React.createElement(TableCell,{colSpan:e.items.length+1,style:{...z}},this.renderAddButton(j))):null)),!M.length&&this.state.value.length?React.createElement("div",{style:styles$a.filteredOut},React.createElement(Typography,{style:styles$a.title,variant:"h6",id:"tableTitle",component:"div"},I18n.t("ra_All items are filtered out"),React.createElement(IconButton,{size:"small",onClick:()=>this.applyFilter(!0)},React.createElement(CloseIcon,null)))):null),e.help?React.createElement(FormHelperText,{style:{paddingLeft:16}},this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null,this.state.errorMessage?React.createElement("div",{style:{display:"flex",padding:"5px"}},React.createElement(ErrorIcon,{color:"error"}),React.createElement("span",{style:{color:"red",alignSelf:"center"}},this.state.errorMessage)):null)}componentDidUpdate(){var e;(e=this.refDiv.current)!=null&&e.clientWidth&&this.refDiv.current.clientWidth!==this.state.width&&(this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{var M;this.resizeTimeout=null,this.setState({width:(M=this.refDiv.current)==null?void 0:M.clientWidth})},50))}getCurrentBreakpoint(){return this.state.width?this.state.width<600?"xs":this.state.width<900?"sm":this.state.width<1200?"md":this.state.width<1536?"lg":"xl":"md"}renderItem(){const{schema:e}=this.props;if(!this.state.value||!Array.isArray(this.state.value))return null;const M=this.getCurrentBreakpoint();let j;return M&&(e.useCardFor||["xs"]).includes(M)?j=this.renderCards():j=this.renderTable(),React.createElement("div",{ref:this.refDiv,style:{width:"100%"}},j)}}const styles$9={indeterminate:{opacity:.5},label:{width:"100%",fontSize:14,marginBottom:2},helper:{width:"100%",fontSize:12},error:{width:"100%",fontSize:12,color:"#FF0000"}};class ConfigText extends ConfigGeneric{constructor(){super(...arguments);_1(this,"updateTimeout",null)}componentDidMount(){super.componentDidMount();let e=ConfigGeneric.getValue(this.props.data,this.props.attr);if(Array.isArray(e)&&this.props.oContext.multiEdit){e=ConfigGeneric.DIFFERENT_VALUE,this.setState({value:e,oldValue:e,jsonError:!1});return}this.setState({value:e,oldValue:e,jsonError:this.validateJson(e)})}validateJson(e){let M=!1;if(this.props.schema.validateJson&&(e||!this.props.schema.allowEmpty))try{JSON.parse(e)}catch(j){console.log("Error in JSON",j),M=!0}return M}static getDerivedStateFromProps(e,M){if(e.oContext.multiEdit&&M.value===ConfigGeneric.DIFFERENT_VALUE)return{value:ConfigGeneric.DIFFERENT_VALUE};let j=ConfigGeneric.getValue(e.data,e.attr);return j!=null&&(j=j.toString()),j==null||j!==M.value&&j!==M.oldValue?{value:j}:null}renderItem(e,M){const j=Array.isArray(this.state.value)||this.state.value===ConfigGeneric.DIFFERENT_VALUE;if(this.props.schema.time){let N="";return typeof this.state.value=="number"?this.state.value&&this.state.value<9466596e5?N=new Date(this.state.value*1e3).toLocaleString():N=new Date(this.state.value).toLocaleString():typeof this.state.value=="string"&&(N=new Date(this.state.value).toLocaleString()),React.createElement(TextField,{variant:"standard",fullWidth:!0,value:N,error:!!e||!!this.state.jsonError,disabled:!!M,slotProps:{htmlInput:{readOnly:!0}},placeholder:this.getText(this.props.schema.placeholder),label:this.getText(this.props.schema.label),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)})}if(this.state.oldValue!==null&&this.state.oldValue!==void 0?(this.updateTimeout&&clearTimeout(this.updateTimeout),this.updateTimeout=setTimeout(()=>{this.updateTimeout=null,this.setState({oldValue:null})},30)):this.updateTimeout&&(clearTimeout(this.updateTimeout),this.updateTimeout=null),j){const N=ConfigGeneric.getValue(this.props.data,this.props.attr),R=(N==null?void 0:N.filter(O=>O||O===0).map(O=>({label:O.toString()||"",value:O})))||[];return R.unshift({label:I18n.t(ConfigGeneric.DIFFERENT_LABEL),value:ConfigGeneric.DIFFERENT_VALUE}),React.createElement(Autocomplete,{style:styles$9.indeterminate,fullWidth:!0,value:R[0],onChange:(O,H)=>{const A=H?H.value:"",_=this.onChange(this.props.attr,A,()=>{this.setState({value:A,oldValue:A,jsonError:this.validateJson(H)})});_ instanceof Promise&&_.catch(k=>console.error(`Cannot set value: ${k}`))},options:R,getOptionLabel:O=>O.label,renderInput:O=>React.createElement(TextField,{variant:"standard",...O,error:!!e,placeholder:this.getText(this.props.schema.placeholder),slotProps:{htmlInput:{...O.inputProps,maxLength:this.props.schema.maxLength||this.props.schema.max||void 0,readOnly:this.props.schema.readOnly||!1}},label:this.getText(this.props.schema.label),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation),disabled:!!M})})}let z,E;if((this.props.schema.readOnly||M)&&this.props.schema.copyToClipboard?(this.props.schema.minRows>1&&(E={position:"absolute",right:3,top:20,zIndex:1e3}),z=React.createElement(IconButton,{tabIndex:-1,style:E,size:"small",onClick:()=>{Utils.copyToClipboard(this.state.value),window.alert(I18n.t("ra_Copied"))}},React.createElement(IconCopy,null))):!this.props.schema.readOnly&&!M&&this.state.value&&!this.props.schema.noClearButton&&(this.props.schema.minRows>1&&(E={position:"absolute",right:3,top:20,zIndex:1e3}),z=React.createElement(IconButton,{style:E,size:"small",tabIndex:-1,onClick:()=>this.setState({value:"",oldValue:this.state.value},()=>this.onChange(this.props.attr,""))},React.createElement(CloseIcon,null)),this.props.schema.minRows<=1&&(z=React.createElement(InputAdornment,{position:"end"},z))),this.props.schema.minRows>1){const N=this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation);return React.createElement("div",{style:{width:"100%",position:"relative"}},this.props.schema.label?React.createElement("div",{style:styles$9.label},this.getText(this.props.schema.label)):null,React.createElement(TextareaAutosize,{style:{width:"100%",resize:"vertical",backgroundColor:this.props.oContext.themeType==="dark"?"#363636":"#cccccc",color:this.props.oContext.themeType==="dark"?"#fff":"#111"},minRows:this.props.schema.minRows,maxRows:this.props.schema.maxRows,value:this.state.value===null||this.state.value===void 0?"":this.state.value,disabled:!!M,readOnly:this.props.schema.readOnly||!1,onChange:R=>{const O=R.target.value;this.setState({value:O,oldValue:this.state.value,jsonError:this.validateJson(O)},()=>this.onChange(this.props.attr,O||""))},placeholder:this.getText(this.props.schema.placeholder)}),N||e||this.state.jsonError?React.createElement("div",{style:e?styles$9.error:styles$9.helper},e||(this.state.jsonError?I18n.t("ra_Invalid JSON"):N)):null)}return React.createElement(TextField,{variant:"standard",fullWidth:!0,value:this.state.value===null||this.state.value===void 0?"":this.state.value,error:!!e||!!this.state.jsonError,disabled:!!M,slotProps:{htmlInput:{maxLength:this.props.schema.maxLength||this.props.schema.max||void 0,readOnly:this.props.schema.readOnly||!1},input:{endAdornment:z}},onChange:N=>{const R=N.target.value;this.setState({value:R,oldValue:this.state.value,jsonError:this.validateJson(R)},()=>this.onChange(this.props.attr,R))},placeholder:this.getText(this.props.schema.placeholder),label:this.getText(this.props.schema.label),helperText:this.state.jsonError?I18n.t("ra_Invalid JSON"):this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)})}}const styles$8={fullWidth:{width:"100%"}};class ConfigTextSendTo extends ConfigGeneric{constructor(){super(...arguments);_1(this,"initialized",!1);_1(this,"localContext")}askInstance(){if(this.props.alive){let e=this.props.schema.data;if(e===void 0&&this.props.schema.jsonData){const M=this.getPattern(this.props.schema.jsonData,null,!0);try{e=JSON.parse(M)}catch{console.error(`Cannot parse json data: ${M}`)}}e===void 0&&(e=null),this.props.oContext.socket.sendTo(`${this.props.oContext.adapterName}.${this.props.oContext.instance}`,this.props.schema.command||"send",e).then(M=>{if(typeof M=="object"){const j=M;this.setState({text:j.text||"",style:j.style,icon:j.icon,iconStyle:j.iconStyle})}else typeof M=="string"&&this.setState({text:M||""})}).catch(M=>console.error(`Cannot send command: ${M}`))}}getLocalContext(){const e={};return Array.isArray(this.props.schema.alsoDependsOn)&&this.props.schema.alsoDependsOn.forEach(M=>e[M]=ConfigGeneric.getValue(this.props.data,M)),JSON.stringify(e)}renderItem(){if(this.props.alive){const M=this.getLocalContext();(M!==this.localContext||!this.initialized)&&(this.localContext=M,setTimeout(()=>this.askInstance(),this.initialized?300:50),this.initialized=!0)}if(this.state.text===void 0)return null;let e=null;return this.state.icon&&(e=getIconByName(this.state.icon,{marginRight:this.state.text?8:void 0,...this.state.iconStyle||void 0}),e||(e=React.createElement(Icon,{src:this.state.icon,style:{marginRight:this.state.text?8:void 0,...this.state.iconStyle||void 0}}))),this.props.schema.container==="text"?React.createElement(TextField,{variant:"standard",fullWidth:!0,slotProps:{input:{endAdornment:this.props.schema.copyToClipboard?React.createElement(IconButton,{tabIndex:-1,size:"small",onClick:()=>{Utils.copyToClipboard(this.state.text),window.alert(I18n.t("ra_Copied"))}},React.createElement(IconCopy,null)):void 0}},value:this.state.text,label:this.getText(this.props.schema.label),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)}):React.createElement("div",{style:{...styles$8.fullWidth,...this.state.style||void 0}},e,this.props.schema.container==="html"?React.createElement("span",{dangerouslySetInnerHTML:{__html:this.state.text||""}}):this.state.text)}}class ConfigTimePicker extends ConfigGeneric{componentDidMount(){super.componentDidMount();const o=ConfigGeneric.getValue(this.props.data,this.props.attr);this.setState({value:o})}renderItem(o,e){const M=this.props.schema.returnFormat!=="HH:mm:ss",j=new Date(Date.parse(`Thu, 01 Jan 1970 ${this.state.value||"00:00:00"}`));return React.createElement(TimePicker,{sx:z=>({width:"100%",borderBottom:`1px solid ${z.palette.text.primary}`,"& fieldset":{display:"none"},"& input":{padding:`${z.spacing(1.5)} 0 4px 0`},"& .MuiInputAdornment-root":{marginLeft:0,marginTop:1},"& label":{transform:"translate(0px, -9px) scale(0.75)"}}),ampm:this.props.oContext.systemConfig.dateFormat.includes("/"),timeSteps:this.props.schema.timeSteps||this.props.schema.timesteps||{hours:1,minutes:5,seconds:5},format:this.props.schema.format||"HH:mm:ss",disabled:!!e,value:j,onChange:z=>{let E;E=z instanceof Date?z.toTimeString().split(" ")[0]:z.toTimeString(),M&&(E=E.split(":").slice(0,2).join(":")),this.setState({value:E},()=>this.onChange(this.props.attr,this.state.value))},views:this.props.schema.views||["hours","minutes","seconds"],label:this.getText(this.props.schema.label)})}}function convertID2Topic(t,o){let e;return o&&t.substring(0,o.length)===o?e=t.substring(o.length+1):e=t,e=e.replace(/\./g,"/").replace(/_/g," "),e}class ConfigTopic extends ConfigGeneric{componentDidMount(){var e;super.componentDidMount();const o=ConfigGeneric.getValue(this.props.data,this.props.attr);if(!o&&((e=this.props.customObj)!=null&&e._id)){const M=convertID2Topic(this.props.customObj._id,`${this.props.oContext.adapterName}.${this.props.oContext.instance}`);this.setState({value:M})}else this.setState({value:o||""})}renderItem(o,e){return React.createElement(TextField,{variant:"standard",fullWidth:!0,slotProps:{htmlInput:{maxLength:this.props.schema.maxLength||this.props.schema.max||void 0}},value:this.state.value,error:!!o,disabled:e,placeholder:this.getText(this.props.schema.placeholder),label:this.getText(this.props.schema.label),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation),onChange:M=>{const j=M.target.value;this.setState({value:j},()=>this.onChange(this.props.attr,j))}})}}class ConfigUUID extends ConfigGeneric{async componentDidMount(){var e;super.componentDidMount();const o=await this.props.oContext.socket.getObject("system.meta.uuid");this.setState({uuid:((e=o==null?void 0:o.native)==null?void 0:e.uuid)||"unknown"})}renderItem(o,e){return React.createElement(TextField,{variant:"standard",fullWidth:!0,error:!!o,disabled:!!e,slotProps:{htmlInput:{readOnly:!0},input:{endAdornment:React.createElement(IconButton,{tabIndex:-1,onClick:()=>{Utils.copyToClipboard(this.state.uuid),window.alert(I18n.t("ra_Copied %s",this.state.uuid))}},React.createElement(IconCopy$1,null))}},value:this.state.uuid||"",label:this.getText(this.props.schema.label)||I18n.t("ra_Serial number (UUID)"),helperText:this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)})}}const styles$7={icon:{width:16,height:16,marginRight:8}};class ConfigUser extends ConfigGeneric{componentDidMount(){super.componentDidMount(),this.props.oContext.socket.getUsers().then(o=>{const e={},M=I18n.getLanguage();this.props.schema.short?o.forEach(j=>{var z,E;return e[j._id]={color:(z=j.common)==null?void 0:z.color,icon:(E=j.common)==null?void 0:E.icon,name:Utils.getObjectNameFromObj(j,M)}}):o.forEach(j=>{var z,E;return e[j._id.replace(/^system\.user\./,"")]={color:(z=j.common)==null?void 0:z.color,icon:(E=j.common)==null?void 0:E.icon,name:Utils.getObjectNameFromObj(j,M)}}),this.setState({users:e})}).catch(o=>console.error(`Cannot get users: ${o}`))}renderItem(o,e){var j,z;const M=ConfigGeneric.getValue(this.props.data,this.props.attr);return React.createElement(FormControl,{variant:"standard",fullWidth:!0},this.state.users&&this.props.schema.label?React.createElement(InputLabel,null,this.getText(this.props.schema.label)):null,this.state.users?React.createElement(Select,{variant:"standard",error:!!o,disabled:!!e,value:M,renderValue:E=>{var N,R,O;return React.createElement("span",null,this.state.users&&((N=this.state.users[E])!=null&&N.icon)?React.createElement(Icon,{src:this.state.users&&((R=this.state.users[E])==null?void 0:R.icon),style:styles$7.icon}):null,this.state.users&&((O=this.state.users[E])==null?void 0:O.name)||E||"")},style:{color:this.state.users&&((j=this.state.users[M])==null?void 0:j.color)||void 0,backgroundColor:Utils.getInvertedColor(this.state.users&&((z=this.state.users[M])==null?void 0:z.color),this.props.oContext.themeType)},onChange:E=>this.onChange(this.props.attr,E.target.value)},this.state.users&&Object.keys(this.state.users).map(E=>React.createElement(MenuItem,{style:{color:this.state.users[E].color||void 0,backgroundColor:Utils.getInvertedColor(this.state.users[E].color,this.props.oContext.themeType)},key:E,value:E},this.state.users[E].icon?React.createElement(Icon,{src:this.state.users[E].icon,style:styles$7.icon}):null,this.state.users[E].name))):React.createElement(TextField,{variant:"standard",error:!!o,disabled:!!e,value:M,onChange:E=>this.onChange(this.props.attr,E.target.value),label:this.getText(this.props.schema.label)}),this.props.schema.help?React.createElement(FormHelperText,null,this.renderHelp(this.props.schema.help,this.props.schema.helpLink,this.props.schema.noTranslation)):null)}}const scriptRel="modulepreload",assetsURL=function(t,o){return new URL(t,o).href},seen={},__vitePreload=function t(o,e,M){let j=Promise.resolve();if(e&&e.length>0){let E=function(H){return Promise.all(H.map(A=>Promise.resolve(A).then(_=>({status:"fulfilled",value:_}),_=>({status:"rejected",reason:_}))))};const N=document.getElementsByTagName("link"),R=document.querySelector("meta[property=csp-nonce]"),O=(R==null?void 0:R.nonce)||(R==null?void 0:R.getAttribute("nonce"));j=E(e.map(H=>{if(H=assetsURL(H,M),H in seen)return;seen[H]=!0;const A=H.endsWith(".css"),_=A?'[rel="stylesheet"]':"";if(!!M)for(let B=N.length-1;B>=0;B--){const e1=N[B];if(e1.href===H&&(!A||e1.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${H}"]${_}`))return;const P=document.createElement("link");if(P.rel=A?"stylesheet":scriptRel,A||(P.as="script"),P.crossOrigin="",P.href=H,O&&P.setAttribute("nonce",O),document.head.appendChild(P),A)return new Promise((B,e1)=>{P.addEventListener("load",B),P.addEventListener("error",()=>e1(new Error(`Unable to preload CSS for ${H}`)))})}))}function z(E){const N=new Event("vite:preloadError",{cancelable:!0});if(N.payload=E,window.dispatchEvent(N),!N.defaultPrevented)throw E}return j.then(E=>{for(const N of E||[])N.status==="rejected"&&z(N.reason);return o().catch(z)})};class ConfigQrCode extends ConfigGeneric{async componentDidMount(){super.componentDidMount();const o=await __vitePreload(()=>import("./index-BABBAJzZ.js").then(e=>e.i),[],import.meta.url);this.setState({QRCode:o.default})}renderItem(){const o=this.state.QRCode;return o?React.createElement(o,{value:this.props.schema.data,size:this.props.schema.size,fgColor:this.props.schema.fgColor,bgColor:this.props.schema.bgColor,level:this.props.schema.level}):null}}const components={accordion:ConfigAccordion,alive:ConfigAlive,autocomplete:ConfigAutocomplete,autocompleteSendTo:ConfigAutocompleteSendTo,certCollection:ConfigCertCollection,certificate:ConfigCertificateSelect,certificates:ConfigCertificates,checkbox:ConfigCheckbox,checkDocker:ConfigCheckDocker,checkLicense:ConfigCheckLicense,chip:ConfigChip,chips:ConfigChip,color:ConfigColor,coordinates:ConfigCoordinates,cron:ConfigCRON,custom:ConfigCustom,datePicker:ConfigDatePicker,deviceManager:ConfigDeviceManager,divider:ConfigStaticDivider,file:ConfigFile,fileSelector:ConfigFileSelector,func:ConfigFunc,header:ConfigStaticHeader,image:ConfigImageUpload,imageSendTo:ConfigImageSendTo,infoBox:ConfigInfoBox,instance:ConfigInstanceSelect,interface:ConfigInterface,ip:ConfigIP,jsonEditor:ConfigJsonEditor,language:ConfigLanguage,license:ConfigLicense,number:ConfigNumber,oauth2:ConfigOAuth2,objectId:ConfigObjectId,password:ConfigPassword,pattern:ConfigPattern,port:ConfigPort,qrCode:ConfigQrCode,room:ConfigRoom,select:ConfigSelect,selectSendTo:ConfigSelectSendTo,sendto:ConfigSendto,sendTo:ConfigSendto,setState:ConfigSetState,slider:ConfigSlider,state:ConfigState,staticImage:ConfigStaticImage,staticInfo:ConfigStaticInfo,staticLink:ConfigStaticText,staticText:ConfigStaticText,table:ConfigTable,text:ConfigText,textSendTo:ConfigTextSendTo,timePicker:ConfigTimePicker,topic:ConfigTopic,uuid:ConfigUUID,user:ConfigUser},styles$6={fullWidth:{width:"100%"},paper:{margin:1,width:"auto !important",overflowY:"auto",paddingBottom:1},paperWithIcons:{height:"calc(100vh - 259px) !important"},paperWithoutIcons:{height:"calc(100vh - 235px) !important"},padding:{padding:"10px"},heading:{},primary:t=>({backgroundColor:t.palette.primary.main,color:t.palette.mode==="dark"?"inherit":"#FFF"}),secondary:t=>({backgroundColor:t.palette.secondary.main})};class ConfigPanel extends ConfigGeneric{componentDidMount(){var o;super.componentDidMount(),(o=this.props.schema)!=null&&o.collapsable&&this.setState({expanded:(window._localStorage||window.localStorage).getItem(`${this.props.oContext.adapterName}.${this.props.attr}`)==="true"})}renderItems(o,e){return o?Object.keys(o).map(M=>{if(this.props.oContext.multiEdit&&o[M].noMultiEdit)return null;const j=o[M].type||"panel";let z,E="Use this.props.oContext.socket!";return j==="custom"?(o[M].url?z=ConfigCustom:this.props.oContext.customs&&this.props.oContext.customs[o[M].component]?z=this.props.oContext.customs[o[M].component]:(console.error(`Cannot find custom component: ${o[M].component}`),z=ConfigGeneric),E=this.props.oContext.socket):j==="panel"?z=ConfigPanel:z=components[j]||ConfigGeneric,React.createElement(z,{socket:E,globalData:this.props.globalData,oContext:this.props.oContext,key:`${M}_${this.props.index===void 0?"":this.props.index}`,index:this.props.index,changed:this.props.changed,arrayIndex:this.props.arrayIndex,expertMode:this.props.expertMode,commandRunning:this.props.commandRunning,style:styles$6.panel,common:this.props.common,alive:this.props.alive,themeName:this.props.themeName,data:this.props.data,originalData:this.props.originalData,onError:this.props.onError,onChange:this.props.onChange,disabled:e,customObj:this.props.customObj,custom:this.props.custom,schema:o[M],attr:M,table:this.props.table})}):null}render(){const o=this.props.schema;if(!o)return null;const{disabled:e,hidden:M}=this.calculate(o),j=this.props.schema.items,z=this.props.schema.style||{};if(M){if(o.hideOnlyControl){const N=React.createElement(Grid2,{size:{xs:o.xs||void 0,sm:o.sm||void 0,md:o.md||void 0,lg:o.lg||void 0,xl:o.xl||void 0},sx:Utils.getStyle(this.props.oContext.theme,{marginBottom:0,textAlign:"left"},z,this.props.oContext.themeType==="dark"&&o.darkStyle)});return o.newLine?React.createElement(React.Fragment,null,React.createElement("div",{style:{flexBasis:"100%",height:0}}),N):N}return null}if(this.props.table)return this.renderItems(j,e);if(this.props.custom)return React.createElement(Grid2,{key:`${this.props.attr}_${this.props.index}`,container:!0,style:styles$6.fullWidth,columnSpacing:2,rowSpacing:1,sx:z},this.renderItems(j,e));let E;if(o.collapsable)E=React.createElement(Accordion,{key:`${this.props.attr}_${this.props.index}`,style:styles$6.fullWidth,expanded:!!this.state.expanded,onChange:()=>{(window._localStorage||window.localStorage).setItem(`${this.props.oContext.adapterName}.${this.props.attr}`,this.state.expanded?"false":"true"),this.setState({expanded:!this.state.expanded})}},React.createElement(AccordionSummary,{expandIcon:React.createElement(ExpandMoreIcon,null),sx:Utils.getStyle(this.props.oContext.theme,z,this.props.oContext.themeType&&o.darkStyle,o.color==="primary"?styles$6.primary:o.color==="secondary"&&styles$6.secondary,{width:"100%"})},React.createElement(Typography,{style:styles$6.heading},this.getText(o.label))),React.createElement(AccordionDetails,null,React.createElement(Grid2,{container:!0,columnSpacing:2,rowSpacing:1,sx:{...z,width:"100%",padding:"10px"}},this.renderItems(j,e))));else{const N=Utils.getStyle(this.props.oContext.theme,this.props.style,z,{width:"100%"},this.props.isParentTab&&styles$6.paper,this.props.isParentTab&&(this.props.withoutSaveButtons?this.props.withIcons?{height:"calc(100% - 88px) !important"}:{height:"calc(100% - 64px) !important"}:this.props.withIcons?styles$6.paperWithIcons:styles$6.paperWithoutIcons));E=React.createElement(Box,{component:"div",key:`${this.props.attr}_${this.props.index}`,className:this.props.className,sx:N},React.createElement(Grid2,{container:!0,columnSpacing:2,rowSpacing:1,sx:Utils.getStyle(this.props.oContext.theme,{width:"100%"},this.props.isParentTab&&styles$6.padding,this.props.schema.innerStyle)},this.renderItems(j,e)))}if(!this.props.isParentTab){const N=React.createElement(Grid2,{title:this.getText(o.tooltip),size:{xs:o.xs||void 0,sm:o.sm||void 0,md:o.md||void 0,lg:o.lg||void 0,xl:o.xl||void 0},sx:{marginBottom:0,textAlign:"left",...z}},E);return o.newLine?React.createElement(React.Fragment,null,React.createElement("div",{style:{flexBasis:"100%",height:0}}),N):N}return E}}const styles$5={tabs:{height:"100%",width:"100%"},panel:{width:"100%",display:"block"},panelWithIcons:{height:"calc(100% - 72px)"},panelWithoutIcons:{height:"calc(100% - 48px)"}};class ConfigTabs extends ConfigGeneric{constructor(e){super(e);_1(this,"resizeTimeout",null);_1(this,"refDiv");_1(this,"onTabError",(e,M)=>{const j=this.state.tab;if(!j){this.props.onError(e,M);return}const z={...this.state.tabErrors};z[j]||(z[j]={}),M?z[j][e]=M:(delete z[j][e],Object.keys(z[j]).length===0&&delete z[j]),this.setState({tabErrors:z}),this.props.onError(e,M)});_1(this,"hasTabErrors",e=>!!(this.state.tabErrors[e]&&Object.keys(this.state.tabErrors[e]).length>0));_1(this,"onHashTabsChanged",()=>{const e=(window.location.hash||"").replace(/^#/,"").split("/");if(e.length>3&&e[1]==="config"){const M=e[3],j=parseInt(M,10);let z;j.toString()===M?j>=0&&j<Object.keys(this.props.schema.items).length&&(z=Object.keys(this.props.schema.items)[j]):Object.keys(this.props.schema.items).includes(M)&&(z=M),z!==void 0&&z!==this.state.tab&&((window._localStorage||window.localStorage).setItem(`${this.props.dialogName||"App"}.${this.props.oContext.adapterName}`,z),this.setState({tab:z}))}});let M;if(this.props.root){const j=(window.location.hash||"").replace(/^#/,"").split("/");if(j.length>=3&&j[1]==="config"){const z=j[3],E=parseInt(z,10);z&&E.toString()===z?E>=0&&E<Object.keys(this.props.schema.items).length&&(M=Object.keys(this.props.schema.items)[E]):z&&Object.keys(this.props.schema.items).includes(z)&&(M=z),window.addEventListener("hashchange",this.onHashTabsChanged,!1)}}M===void 0&&(M=(window._localStorage||window.localStorage).getItem(`${this.props.dialogName||"App"}.${this.props.oContext.adapterName}`)||Object.keys(this.props.schema.items)[0],Object.keys(this.props.schema.items).includes(M)||(M=Object.keys(this.props.schema.items)[0])),this.refDiv=React.createRef(),Object.assign(this.state,{tab:M,width:0,openMenu:null,tabErrors:{}})}componentWillUnmount(){this.resizeTimeout&&(clearTimeout(this.resizeTimeout),this.resizeTimeout=null),window.removeEventListener("hashchange",this.onHashTabsChanged,!1),super.componentWillUnmount()}getCurrentBreakpoint(){if(!this.state.width)return"md";if(!this.state.initialBreakpoint){let e;return this.state.width<600?e="xs":this.state.width<900?e="sm":this.state.width<1200?e="md":this.state.width<1536?e="lg":e="xl",setTimeout(()=>{this.setState({initialBreakpoint:e})},50),e}return this.state.initialBreakpoint}componentDidUpdate(){var e;!this.state.initialBreakpoint&&((e=this.refDiv.current)!=null&&e.clientWidth)&&this.refDiv.current.clientWidth!==this.state.width&&(this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{var M;this.resizeTimeout=null,this.setState({width:(M=this.refDiv.current)==null?void 0:M.clientWidth})},50))}onMenuChange(e){(window._localStorage||window.localStorage).setItem(`${this.props.dialogName||"App"}.${this.props.oContext.adapterName}`,e),this.setState({tab:e},()=>{if(this.props.root){const M=(window.location.hash||"").split("/");M.length>=3&&M[1]==="config"&&(M[3]=this.state.tab,window.location.hash=M.join("/"))}})}render(){const e=this.props.schema.items;let M=!1;const j=[];Object.keys(e).map(N=>{let R;if(e[N].expertMode&&!this.props.expertMode)return;if(this.props.custom){if(this.executeCustom(e[N].hidden,this.props.data,this.props.customObj,this.props.oContext.instanceObj,this.props.index,this.props.globalData))return;R=this.executeCustom(e[N].disabled,this.props.data,this.props.customObj,this.props.oContext.instanceObj,this.props.index,this.props.globalData)}else{if(this.execute(e[N].hidden,!1,this.props.data,this.props.index,this.props.globalData))return;R=this.execute(e[N].disabled,!1,this.props.data,this.props.index,this.props.globalData)}const O=this.getIcon(e[N].icon);M=M||!!O,j.push({icon:O,disabled:R,label:this.getText(e[N].label),name:N})}),j.find(N=>N.name===this.state.tab)||setTimeout(()=>this.setState({tab:j[0].name}),50);const z=this.getCurrentBreakpoint();let E;return z==="xs"&&j.length>2?E=React.createElement(Toolbar,{style:{top:2,backgroundColor:this.props.oContext.themeType==="dark"?"#222":"#DDD"},variant:"dense"},React.createElement(IconButton,{onClick:N=>this.setState({openMenu:N.currentTarget})},React.createElement(MenuIcon,null)),this.state.openMenu?React.createElement(Menu,{open:!0,anchorEl:this.state.openMenu,onClose:()=>this.setState({openMenu:null})},j.map(N=>{const R=this.hasTabErrors(N.name);return React.createElement(MenuItem,{disabled:N.disabled,key:N.name,onClick:()=>{this.setState({openMenu:null},()=>this.onMenuChange(N.name))},selected:N.name===this.state.tab,sx:R?{color:"error.main"}:void 0},M?React.createElement(ListItemIcon,null,N.icon):null,React.createElement(Box,{sx:{display:"flex",alignItems:"center",gap:.5,width:"100%"}},N.label,R&&React.createElement(ErrorIcon$1,{sx:{fontSize:16,color:"error.main"}})))})):null):E=React.createElement(Tabs,{variant:"scrollable",scrollButtons:"auto",style:this.props.schema.tabsStyle,value:this.state.tab,onChange:(N,R)=>this.onMenuChange(R)},j.map(N=>{const R=this.hasTabErrors(N.name),O=R?React.createElement(Box,{sx:{display:"flex",alignItems:"center",gap:.5}},N.label,React.createElement(ErrorIcon$1,{sx:{fontSize:16,color:"error.main"}})):N.label;return React.createElement(Tab$1,{id:N.name,wrapped:!0,disabled:N.disabled,key:N.name,value:N.name,iconPosition:this.props.schema.iconPosition||"start",icon:N.icon,label:O,sx:R?{"& .MuiTab-wrapper":{color:"error.main"}}:void 0})})),React.createElement("div",{style:styles$5.tabs,ref:this.refDiv},E,React.createElement(ConfigPanel,{oContext:this.props.oContext,withoutSaveButtons:this.props.withoutSaveButtons,isParentTab:!0,changed:this.props.changed,key:this.state.tab,expertMode:this.props.expertMode,index:1001,arrayIndex:this.props.arrayIndex,globalData:this.props.globalData,commandRunning:this.props.commandRunning,style:{...styles$5.panel,...M?styles$5.panelWithIcons:styles$5.panelWithoutIcons},common:this.props.common,alive:this.props.alive,themeName:this.props.themeName,data:this.props.data,originalData:this.props.originalData,onChange:this.props.onChange,onError:this.onTabError,customObj:this.props.customObj,custom:this.props.custom,schema:e[this.state.tab],table:this.props.table,withIcons:M}))}}const styles$4={root:{width:"100%",height:"100%"}};class JsonConfigComponent extends reactExports.Component{constructor(e){super(e);_1(this,"forceUpdateHandlers");_1(this,"errorTimeout",null);_1(this,"errorCached",null);_1(this,"oContext");_1(this,"onCommandRunning",e=>this.setState({commandRunning:e}));_1(this,"onAlive",(e,M)=>{!!(M!=null&&M.val)!==this.state.alive&&this.setState({alive:!!(M!=null&&M.val)})});_1(this,"onChange",(e,M,j,z)=>{if(this.props.onValueChange)this.props.onValueChange(e,M,z),j&&j();else if(e&&this.props.onChange){const E={changed:JSON.stringify(e)!==this.state.originalData};this.setState(E,()=>{this.props.onChange(e,E.changed,z),j&&j()})}else z&&this.props.onChange(null,null,z)});_1(this,"onError",(e,M)=>{this.errorCached=this.errorCached||JSON.parse(JSON.stringify(this.state.errors));const j=this.errorCached;M?j[e]=M:delete j[e],this.errorTimeout&&clearTimeout(this.errorTimeout),JSON.stringify(j)!==JSON.stringify(this.state.errors)?this.errorTimeout=setTimeout(()=>this.setState({errors:this.errorCached},()=>{this.errorTimeout=null,this.errorCached=null,this.props.onError(!!Object.keys(this.state.errors).length)}),50):this.errorCached=null});_1(this,"changeLanguage",()=>{this.forceUpdate()});_1(this,"forceAttrUpdate",(e,M)=>{Array.isArray(e)?e.forEach(j=>this.forceUpdateHandlers[j]&&this.forceUpdateHandlers[j](M)):this.forceUpdateHandlers[e]&&this.forceUpdateHandlers[e](M)});_1(this,"registerOnForceUpdate",(e,M)=>{M?this.forceUpdateHandlers[e]=M:this.forceUpdateHandlers[e]&&delete this.forceUpdateHandlers[e]});this.state={originalData:JSON.stringify(this.props.data),changed:!1,errors:{},updateData:this.props.updateData||0,systemConfig:null,alive:!1,commandRunning:!1,schema:JSON.parse(JSON.stringify(this.props.schema))},this.forceUpdateHandlers={},this.buildDependencies(this.state.schema),this.readData()}static getDerivedStateFromProps(e,M){return e.updateData!==M.updateData?{updateData:e.updateData,originalData:JSON.stringify(e.data),schema:JSON.parse(JSON.stringify(e.schema))}:null}static async loadI18n(e,M,j){if(M===!0||M&&typeof M=="string"){const z=I18n.getLanguage(),E=typeof M=="string"?M:"i18n";let N=await e.fileExists(`${j}.admin`,`${E}/${z}.json`),R;if(N?R=`${E}/${z}.json`:(N=await e.fileExists(`${j}.admin`,`${E}/${z}/translations.json`),N?R=`${E}/${z}/translations.json`:z!=="en"&&(N=await e.fileExists(`${j}.admin`,`${E}/en.json`),N?R=`${E}/en.json`:(N=await e.fileExists(`${j}.admin`,`${E}/en/translations.json`),N&&(R=`${E}/en/translations.json`)))),R){const O=await e.readFile(`${j}.admin`,R);let H;O.file!==void 0?H=O.file:H=O;try{const A=JSON.parse(H);I18n.extendTranslations(A,z)}catch(A){return console.error(`Cannot parse language file "${j}.admin/${R}: ${A}`),""}return R}return console.warn(`Cannot find i18n for ${j} / ${R}`),""}return M&&typeof M=="object"&&I18n.extendTranslations(M),""}readData(){this.props.socket.getCompactSystemConfig().then(e=>this.props.socket.getState(`system.adapter.${this.props.adapterName}.${this.props.instance}.alive`).then(M=>this.setState({systemConfig:e.common,alive:!!(M&&M.val)},()=>{this.updateContext(!0),this.props.custom||this.props.socket.subscribeState(`system.adapter.${this.props.adapterName}.${this.props.instance}.alive`,this.onAlive)}))).catch(e=>console.error(`Cannot read system config: ${e}`))}flatten(e,M){return M=M||{},e.items&&Object.keys(e.items).forEach(j=>{M[j]=e.items[j],this.flatten(e.items[j],M)}),M}buildDependencies(e){const M=this.flatten(e);Object.keys(M).forEach(j=>{var z,E,N,R,O,H,A,_,k,P;(z=M[j].confirm)!=null&&z.alsoDependsOn&&((E=M[j].confirm)==null||E.alsoDependsOn.forEach(B=>{if(!M[B])console.error(`[JsonConfigComponent] Attribute ${B} does not exist!`),B.startsWith("data.")&&console.warn(`[JsonConfigComponent] please use "${B.replace(/^data\./,"")}" instead of "${B}"`);else{M[B].confirmDependsOn=M[B].confirmDependsOn||[];const e1={...M[j],attr:j};e1.confirm&&(e1.confirm.cancel="Undo"),M[B].confirmDependsOn.push(e1)}})),(N=M[j].onChange)!=null&&N.alsoDependsOn&&((R=M[j].onChange)==null||R.alsoDependsOn.forEach(B=>{if(!M[B])console.error(`[JsonConfigComponent] Attribute ${B} does not exist!`),B.startsWith("data.")&&console.warn(`[JsonConfigComponent] please use "${B.replace(/^data\./,"")}" instead of "${B}"`);else{M[B].onChangeDependsOn=M[B].onChangeDependsOn||[];const e1={...M[j],attr:j};M[B].onChangeDependsOn.push(e1)}})),(O=M[j].hidden)!=null&&O.alsoDependsOn&&((H=M[j].hidden)==null||H.alsoDependsOn.forEach(B=>{if(!M[B])console.error(`[JsonConfigComponent] Attribute ${B} does not exist!`),B.startsWith("data.")&&console.warn(`[JsonConfigComponent] please use "${B.replace(/^data\./,"")}" instead of "${B}"`);else{M[B].hiddenDependsOn=M[B].hiddenDependsOn||[];const e1={...M[j],attr:j};M[B].hiddenDependsOn.push(e1)}})),(A=M[j].label)!=null&&A.alsoDependsOn&&((_=M[j].label)==null||_.alsoDependsOn.forEach(B=>{if(!M[B])console.error(`[JsonConfigComponent] Attribute ${B} does not exist!`),B.startsWith("data.")&&console.warn(`[JsonConfigComponent] please use "${B.replace(/^data\./,"")}" instead of "${B}"`);else{M[B].labelDependsOn=M[B].labelDependsOn||[];const e1={...M[j],attr:j};M[B].labelDependsOn.push(e1)}})),(k=M[j].help)!=null&&k.alsoDependsOn&&((P=M[j].help)==null||P.alsoDependsOn.forEach(B=>{if(!M[B])console.error(`[JsonConfigComponent] Attribute ${B} does not exist!`),B.startsWith("data.")&&console.warn(`[JsonConfigComponent] please use "${B.replace(/^data\./,"")}" instead of "${B}"`);else{M[B].helpDependsOn=M[B].helpDependsOn||[];const e1={...M[j],attr:j};M[B].helpDependsOn.push(e1)}}))})}updateContext(e){this.oContext={DeviceManager:this.props.DeviceManager,adapterName:this.props.adapterName,changeLanguage:this.changeLanguage,common:this.props.common,customs:this.props.customs,dateFormat:this.props.dateFormat,embedded:this.props.embedded,forceUpdate:this.forceAttrUpdate,imagePrefix:this.props.imagePrefix,instance:this.props.instance,instanceObj:this.props.instanceObj,isFloatComma:this.props.isFloatComma,multiEdit:this.props.multiEdit,onBackEndCommand:this.props.onBackEndCommand,onCommandRunning:this.onCommandRunning,onValueChange:this.props.onValueChange,registerOnForceUpdate:this.registerOnForceUpdate,socket:this.props.socket,systemConfig:this.state.systemConfig,theme:this.props.theme,themeType:this.props.themeType,_themeName:this.props.themeName,updateData:this.state.updateData},e&&this.forceUpdate()}renderItem(e){return e.type==="tabs"?React.createElement(ConfigTabs,{withoutSaveButtons:this.props.withoutSaveButtons,oContext:this.oContext,alive:this.state.alive,changed:this.state.changed,commandRunning:this.state.commandRunning,common:this.props.common,custom:this.props.custom,customObj:this.props.customObj,data:this.props.data,onChange:this.onChange,onError:(M,j)=>this.onError(M,j),originalData:JSON.parse(this.state.originalData),root:!0,schema:e,expertMode:this.props.expertMode,themeName:this.props.themeName}):e.type==="panel"||!e.type?React.createElement(ConfigPanel,{withoutSaveButtons:this.props.withoutSaveButtons,oContext:this.oContext,alive:this.state.alive,changed:this.state.changed,commandRunning:this.state.commandRunning,common:this.props.common,custom:this.props.custom,customObj:this.props.customObj,data:this.props.data,expertMode:this.props.expertMode,index:1e3,isParentTab:!this.props.embedded&&!this.props.withoutSaveButtons,onChange:this.onChange,onError:(M,j)=>this.onError(M,j),originalData:JSON.parse(this.state.originalData),root:!0,schema:e,themeName:this.props.themeName}):(console.error(`Unknown item type in root: ${JSON.stringify(e)}`),null)}render(){return!this.state.systemConfig||!this.oContext?React.createElement(LinearProgress,null):(this.oContext._themeName!==this.props.themeName&&(this.oContext._themeName=this.props.themeName,setTimeout(()=>this.updateContext(!0),0)),React.createElement("div",{style:{...!this.props.embedded||this.props.withoutSaveButtons?styles$4.root:void 0,...this.props.style,...this.state.schema.style}},this.renderItem(this.state.schema)))}}const styles$3={root:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},scroll:{height:"calc(100% - 48px)",overflowY:"auto"},exportImportButtons:{position:"absolute",top:5,right:0,zIndex:3},button:{marginRight:"5px"},tooltip:{pointerEvents:"none"}};function decryptLegacy(t,o){let e="";for(let M=0;M<o.length;M++)e+=String.fromCharCode(t[M%t.length].charCodeAt(0)^o.charCodeAt(M));return e}function encryptLegacy(t,o){let e="";for(let M=0;M<o.length;M++)e+=String.fromCharCode(t[M%t.length].charCodeAt(0)^o.charCodeAt(M));return e}function decrypt(t,o){if(typeof o!="string")return o;if(!o.startsWith("$/aes-192-cbc:")||!/^[0-9a-f]{48}$/.test(t))return decryptLegacy(t,o);const e=o.split(":",3),M=window.CryptoJS.enc.Hex.parse(t),j=window.CryptoJS.enc.Hex.parse(e[1]),z=window.CryptoJS.lib.CipherParams.create({ciphertext:window.CryptoJS.enc.Hex.parse(e[2])}),E=window.CryptoJS.AES.decrypt(z,M,{iv:j});return window.CryptoJS.enc.Utf8.stringify(E)}function encrypt(t,o,e){if(typeof o!="string")return o;if(!/^[0-9a-f]{48}$/.test(t))return encryptLegacy(t,o);let M;M=window.CryptoJS.lib.WordArray.random(128/8);const j=window.CryptoJS.enc.Hex.parse(t),z=window.CryptoJS.AES.encrypt(o,j,{iv:M}).ciphertext;return`$/aes-192-cbc:${window.CryptoJS.enc.Hex.stringify(M)}:${z}`}function loadScript(t,o){var e;return document.getElementById(o)?(e=document.getElementById(o))==null?void 0:e.onload:new Promise(M=>{const j=document.createElement("script");j.setAttribute("id",o),j.onload=M,j.src=t,document.getElementsByTagName("head")[0].appendChild(j)})}let JsonConfig$1=class extends Router{constructor(e){super(e);_1(this,"fileSubscribed",[]);_1(this,"fileLangSubscribed","");_1(this,"secret");_1(this,"handleFileSelect",e=>{const M=e.target.files[0];if(M){const j=new FileReader;j.onload=z=>{if(!z.target)return;const E=z.target.result;try{const N=JSON.parse(E);this.setState({data:N,changed:JSON.stringify(N)!==JSON.stringify(this.state.originalData)})}catch{window.alert(I18n.t("[JsonConfig] Failed to parse JSON file"))}},j.readAsText(M)}else window.alert(I18n.t("[JsonConfig] Failed to open JSON File"))});_1(this,"onFileChange",async(e,M,j)=>{var z;if(e===`${this.props.adapterName}.admin`&&j){if(M===this.fileLangSubscribed)try{await JsonConfigComponent.loadI18n(this.props.socket,(z=this.state.schema)==null?void 0:z.i18n,this.props.adapterName),this.setState({hash:`${this.state.hash}1`})}catch{}else if(this.fileSubscribed.includes(M))try{const E=await this.getConfigFile(this.fileSubscribed[0]);this.setState({schema:E,hash:MD5(JSON.stringify(E)).toString()})}catch{}}});this.state={updateData:0,changed:!1,confirmDialog:!1,theme:Theme(e.themeName),saveConfigDialog:!1,hash:"_"},this.secret=e.secret||"",this.getInstanceObject().then(M=>this.getConfigFile().then(j=>JsonConfigComponent.loadI18n(this.props.socket,j==null?void 0:j.i18n,this.props.adapterName).then(z=>{z&&(this.fileLangSubscribed||(this.fileLangSubscribed=z,this.props.socket.subscribeFiles(`${this.props.adapterName}.admin`,this.fileLangSubscribed,this.onFileChange))),M?this.setState({schema:j,data:M.native,common:M.common,hash:MD5(JSON.stringify(j)).toString()}):window.alert(`Instance system.adapter.${this.props.adapterName}.${this.props.instance} not found!`)})))}componentWillUnmount(){super.componentWillUnmount(),this.fileSubscribed.length&&(this.props.socket.unsubscribeFiles(`${this.props.adapterName}.admin`,this.fileSubscribed,this.onFileChange),this.fileSubscribed=[]),this.fileLangSubscribed&&(this.props.socket.unsubscribeFiles(`${this.props.adapterName}.admin`,this.fileLangSubscribed,this.onFileChange),this.fileLangSubscribed="")}getExportImportButtons(){return React.createElement("div",{style:styles$3.exportImportButtons},React.createElement(Tooltip,{title:this.props.t("Import settings from JSON file"),slotProps:{popper:{sx:styles$3.tooltip}}},React.createElement(Fab,{size:"small",sx:{"&.MuiFab-root":styles$3.button},onClick:()=>{const e=document.createElement("input");e.setAttribute("type","file"),e.setAttribute("id","files"),e.setAttribute("opacity",0),e.addEventListener("change",M=>this.handleFileSelect(M),!1),e.click()}},React.createElement(PublishIcon,null))),React.createElement(Tooltip,{title:this.props.t("Export setting to JSON file"),slotProps:{popper:{sx:styles$3.tooltip}}},React.createElement(Fab,{size:"small",sx:{"&.MuiFab-root":styles$3.button},onClick:()=>{this.state.data&&Utils.generateFile(`${this.props.adapterName}.${this.props.instance}.json`,this.state.data)}},React.createElement(PublishIcon,{style:{transform:"rotate(180deg)"}}))))}async getInstanceObject(){var e;try{const M=await this.props.socket.getObject(`system.adapter.${this.props.adapterName}.${this.props.instance}`);if(Array.isArray(M.encryptedNative)){if(!this.secret){const j=await this.props.socket.getSystemConfig();await loadScript("../../lib/js/crypto-js/crypto-js.js","crypto-js"),this.secret=j.native.secret}return(e=M.encryptedNative)==null||e.forEach(j=>{M.native[j]&&(M.native[j]=decrypt(this.secret,M.native[j]))}),M}return M}catch(M){window.alert(`[JsonConfig] Cannot read instance object: ${M}`)}return null}renderDialogConfirm(){return this.state.confirmDialog?React.createElement(DialogConfirm,{title:I18n.t("ra_Please confirm"),text:I18n.t("ra_Some data are not stored. Discard?"),ok:I18n.t("ra_Discard"),cancel:I18n.t("ra_Cancel"),onClose:e=>this.setState({confirmDialog:!1},()=>e&&Router.doNavigate(null))}):null}async scanForInclude(e,M){if(typeof e["#include"]=="string"){const z=await this._getConfigFile(e["#include"],[...M]);return delete e["#include"],z&&(e={...e,...z}),e}const j=Object.keys(e);for(let z=0;z<j.length;z++)e[j[z]]&&typeof e[j[z]]=="object"&&(e[j[z]]=await this.scanForInclude(e[j[z]],M));return e}async getConfigFile(e){return this._getConfigFile(e)}async _getConfigFile(e,M){if(e=e||"jsonConfig.json5",M=M||[],M.includes(e))return window.alert(`[JsonConfig] Circular reference in file: ${e} => ${M.join(" => ")}`),null;M.push(e);try{await this.props.socket.fileExists(`${this.props.adapterName}.admin`,e)||(e="jsonConfig.json");const z=await this.props.socket.readFile(`${this.props.adapterName}.admin`,e);let E="",N="";if(z.file!==void 0&&(N=z.file),typeof N=="string")E=N;else if(N.type==="Buffer"){let R="";const O=new Uint8Array(N.data),H=O.byteLength;for(let A=0;A<H;A++)R+=String.fromCharCode(O[A]);E=R}this.fileSubscribed.includes(e)||(this.fileSubscribed.push(e),await this.props.socket.subscribeFiles(`${this.props.adapterName}.admin`,e,this.onFileChange));try{return await this.scanForInclude(lib$1.parse(E),M)}catch(R){window.alert("[JsonConfig] Cannot parse json5 config!"),console.log(R)}}catch(j){this.state.schema||window.alert(`[JsonConfig] Cannot read file "${e}: ${j}`)}return null}renderSaveConfigDialog(){return this.state.saveConfigDialog?React.createElement(DialogConfirm,{title:I18n.t("ra_Please confirm"),text:I18n.t("Save configuration?"),ok:I18n.t("ra_Save"),cancel:I18n.t("ra_Cancel"),onClose:e=>this.setState({saveConfigDialog:!1},()=>e&&this.onSave(!0))}):null}findAttr(e,M){if(M=M||this.state.schema,M!=null&&M.items){if(e in M.items)return M.items[e];for(const j of Object.values(M.items)){const z=this.findAttr(e,j);if(z)return z}}return null}postProcessing(e,M,j){if(j=j||this.state.schema,!e){console.error(`Data is empty in postProcessing: ${M}, ${JSON.stringify(j)}`);return}const z=e[M];if(j.items)if(j.type==="table"){const E=z;if(!Array.isArray(E))return;for(const N of E)for(const R of j.items)this.postProcessing(N,R.attr,R)}else for(const[E,N]of Object.entries(j.items)){if(N.type==="panel"||N.type==="tabs"||N.type==="accordion")return;this.postProcessing(e,E,N)}else if(M&&typeof z=="string")if(j.type==="text")j.trim!==!1&&(e[M]=z.trim());else if(j.type==="ip")e[M]=z.trim();else if(j.type==="number"){const E=parseFloat(z.toString().replace(",","."));j.min!==void 0&&E<j.min?e[M]=j.min:j.max!==void 0&&E>j.max?e[M]=j.max:e[M]=E}else if(j.type==="port"){const E=parseInt(z.toString(),10);j.min!==void 0&&E<j.min?e[M]=j.min:j.max!==void 0&&E>j.max&&(e[M]=j.max),e[M]!==0&&E<20?e[M]=20:E>65535?e[M]=65535:e[M]=E}else j.type==="checkbox"&&(e[M]=e[M]===!0||e[M]==="true"||e[M]==="on"||e[M]===1||e[M]==="1")}async onSave(e,M){if(e){const j=await this.getInstanceObject();if(!j){console.error("Something went wrong: may be no connection?"),window.alert("Something went wrong: may be no connection?");return}if(!this.state.data||!this.state.schema)return;const z={};for(const N of Object.keys(this.state.data)){const R=this.findAttr(N);(!R||!R.doNotSave||R.type==="state")&&!N.startsWith("_")?ConfigGeneric.setValue(j.native,N,this.state.data[N]):(ConfigGeneric.setValue(j.native,N,null),z[N]=this.state.data[N])}try{const N=JSON.parse(JSON.stringify(j));if(Array.isArray(N.encryptedNative)){await loadScript("../../lib/js/crypto-js/crypto-js.js","crypto-js");for(const R of N.encryptedNative)N.native[R]&&(N.native[R]=encrypt(this.secret,N.native[R]))}await this.props.socket.setObject(N._id,N)}catch(N){window.alert(`[JsonConfig] Cannot set object: ${N}`)}const E={...j.native,...z};console.log(E),this.setState({changed:!1,data:E,updateData:this.state.updateData+1,originalData:E},()=>M&&Router.doNavigate(null))}else this.state.changed?this.setState({confirmDialog:!0}):Router.doNavigate(null)}componentDidUpdate(e,M){M.changed!==this.state.changed&&this.props.configStored(!this.state.changed)}async componentDidMount(){const e=`${window.location.protocol}//${window.location.host}${window.location.pathname}validate_config/${this.props.adapterName}`;console.log(`fetch ${e}`),await fetch(e)}render(){return!this.state.data||!this.state.schema?React.createElement(LinearProgress,null):React.createElement("div",{style:styles$3.root},this.renderDialogConfirm(),this.getExportImportButtons(),this.renderSaveConfigDialog(),React.createElement(JsonConfigComponent,{key:this.state.hash,style:styles$3.scroll,socket:this.props.socket,themeName:this.props.themeName,themeType:this.props.themeType,adapterName:this.props.adapterName,instance:this.props.instance,isFloatComma:this.props.isFloatComma,dateFormat:this.props.dateFormat,schema:this.state.schema,common:this.state.common,expertMode:this.props.expertMode,data:this.state.data,updateData:this.state.updateData,onError:e=>this.setState({error:e}),onChange:(e,M,j)=>{j&&this.state.error&&(window.alert(I18n.t("Cannot save configuration because of error in configuration")),j=!1),j&&!this.state.changed&&!M&&(j=!1),e?this.setState({data:e,changed:M,saveConfigDialog:j}):j!==void 0&&this.setState({saveConfigDialog:j})},DeviceManager:this.props.DeviceManager,theme:this.state.theme}),React.createElement(SaveCloseButtons,{isIFrame:!1,dense:!0,paddingLeft:0,newReact:!0,theme:this.state.theme,noTextOnButtons:this.props.width==="xs"||this.props.width==="sm"||this.props.width==="md",changed:!!(this.state.error||this.state.changed),error:!!this.state.error,onSave:e=>this.onSave(!0,e),onClose:()=>this.onSave(!1)}))}};const schema$1={type:"panel",label:"Connection",items:{_header1:{newLine:!0,type:"header",label:"Address and ID options",xs:12},_showAliasesInfo:{newLine:!0,type:"infoBox",text:"showAliasesExplanation",title:"Using aliases as address",xs:12},showAliases:{newLine:!0,type:"checkbox",label:"Use aliases as address",xs:12},_showDirectAddresses:{newLine:!0,type:"infoBox",text:"directAddressesExplanation",title:"Using direct addresses",xs:12,hidden:"!data.showAliases"},directAddresses:{type:"checkbox",label:"Use direct addresses by aliases",xs:12,hidden:"!data.showAliases"},doNotRoundAddressToWord:{newLine:!0,type:"checkbox",label:"Do not align addresses to word",help:"doNotRoundAddressToWord_help",xs:12},doNotIncludeAdrInId:{type:"checkbox",label:"do not include address in ID",help:"doNotIncludeAdrInId_help",hidden:"!!data.showAliases",xs:12},preserveDotsInId:{type:"checkbox",label:"preserve dots in ID",help:"preserveDotsInId_help",xs:12},removeUnderscorePrefix:{type:"checkbox",label:'Remove leading "_" in ID if address is not included',xs:12,hidden:"!!data.showAliases || !data.doNotIncludeAdrInId"},_header2:{newLine:!0,type:"header",label:"Read/Write settings",xs:12},doNotUseWriteMultipleRegisters:{newLine:!0,type:"checkbox",hidden:'data.slave === "1" || !!data.onlyUseWriteMultipleRegisters',label:'Do not use "Write multiple registers"',help:"Write only with FC5/FC6",xs:12,md:6},onlyUseWriteMultipleRegisters:{type:"checkbox",hidden:'data.slave === "1" || !!data.doNotUseWriteMultipleRegisters',label:'Use only "Write multiple registers"',help:"Write only with FC15/FC16",xs:12,md:6},maxBlock:{newLine:!0,type:"number",label:"Max read request length",unit:"registers",xs:12,hidden:'data.slave === "1"',md:6},maxBoolBlock:{type:"number",label:"Max read request length (booleans)",unit:"registers",xs:12,hidden:'data.slave === "1"',md:6},alwaysUpdate:{newLine:!0,type:"checkbox",label:"Update unchanged states",help:"alwaysUpdate_help",hidden:'data.slave === "1"',xs:12,md:6},round:{type:"number",min:0,max:20,label:"Round Real to",md:6},_headerTimings:{newLine:!0,type:"header",label:"Timings",xs:12,hidden:'data.slave === "1"'},poll:{newLine:!0,type:"number",min:1,label:"Poll delay",unit:"ms",help:"poll_help",xs:12,hidden:'data.slave === "1"'},recon:{type:"number",min:1,label:"Reconnect time",unit:"ms",xs:12,hidden:'data.slave === "1"'},timeout:{type:"number",min:100,label:"Read timeout",unit:"ms",help:"timeout_help",xs:12,hidden:'data.slave === "1"'},pulseTime:{type:"number",label:"Pulse time",unit:"ms",help:"pulsetime_help",xs:12,hidden:'data.slave === "1"'},waitTime:{type:"number",label:"Wait time",unit:"ms",help:"waitTime_help",xs:12,hidden:'data.slave === "1"'},readInterval:{newLine:!0,type:"number",label:"Read interval",unit:"ms",help:"readInterval_help",xs:12,md:6,hidden:'data.slave === "1"'},writeInterval:{type:"number",label:"Write interval",unit:"ms",help:"writeInterval_help",xs:12,md:6,hidden:'data.slave === "1"'},_headerOthers:{newLine:!0,type:"header",label:"Others",xs:12},disableLogging:{type:"checkbox",label:"Disable connection error logging",help:"disableLogging_help"}}};function Settings$b(t){const[o,e]=React.useState(t.native.params.directAddresses),[M,j]=React.useState(t.native.params.showAliases);return jsxRuntimeExports.jsx("div",{style:{width:"calc(100% - 8px)",minHeight:"100%"},children:jsxRuntimeExports.jsx(JsonConfigComponent,{common:t.common,socket:t.socket,themeName:t.themeName,themeType:t.themeType,adapterName:"modbus",instance:t.instance||0,isFloatComma:t.systemConfig.common.isFloatComma,dateFormat:t.systemConfig.common.dateFormat,schema:schema$1,onChange:z=>{const E=JSON.parse(JSON.stringify(t.native));E.params=z,E.params.showAliases!==M&&(j(E.params.showAliases),["disInputs","inputRegs","holdingRegs","coils"].forEach(N=>{E[N].forEach(R=>{E.params.showAliases?(R._address=address2alias$1(N,R._address),E.params.directAddresses&&(R._address=nonDirect2direct(N,R._address))):(E.params.directAddresses&&(R._address=direct2nonDirect(N,R._address)),R._address=alias2address(N,R._address))})})),E.params.directAddresses!==o&&(e(E.params.directAddresses),E.params.showAliases&&["disInputs","coils"].forEach(N=>{E[N].forEach(R=>{E.params.directAddresses?R._address=nonDirect2direct(N,R._address):R._address=direct2nonDirect(N,R._address)})})),t.changeNative(E)},data:t.native.params,onError:()=>{},theme:t.theme,withoutSaveButtons:!0})})}const types=[{value:"",title:""},{value:"uint16be",title:"Unsigned 16 bit (Big Endian)"},{value:"uint16le",title:"Unsigned 16 bit (Little Endian)"},{value:"int16be",title:"Signed 16 bit (Big Endian)"},{value:"int16le",title:"Signed 16 bit (Little Endian)"},{value:"uint32be",title:"Unsigned 32 bit (Big Endian)"},{value:"uint32le",title:"Unsigned 32 bit (Little Endian)"},{value:"uint32sw",title:"Unsigned 32 bit (Big Endian Word Swap)"},{value:"uint32sb",title:"Unsigned 32 bit (Big Endian Byte Swap)"},{value:"int32be",title:"Signed 32 bit (Big Endian)"},{value:"int32le",title:"Signed 32 bit (Little Endian)"},{value:"int32sw",title:"Signed 32 bit (Big Endian Word Swap)"},{value:"int32sb",title:"Signed 32 bit (Big Endian Byte Swap)"},{value:"uint64be",title:"Unsigned 64 bit (Big Endian)"},{value:"uint64le",title:"Unsigned 64 bit (Little Endian)"},{value:"uint8be",title:"Unsigned 8 bit (Big Endian)"},{value:"uint8le",title:"Unsigned 8 bit (Little Endian)"},{value:"int8be",title:"Signed 8 bit (Big Endian)"},{value:"int8le",title:"Signed 8 bit (Little Endian)"},{value:"floatbe",title:"Float (Big Endian)"},{value:"floatle",title:"Float (Little Endian)"},{value:"floatsw",title:"Float (Big Endian Word Swap)"},{value:"floatsb",title:"Float (Big Endian Byte Swap)"},{value:"doublebe",title:"Double (Big Endian)"},{value:"doublele",title:"Double (Little Endian)"},{value:"string",title:"String (Zero-end)"},{value:"stringle",title:"String (Little Endian, Zero-end)"},{value:"string16",title:"String 16 bit (Zero-end)"},{value:"string16le",title:"String 16 bit (Little Endian, Zero-end)"},{value:"rawhex",title:"String with value in hex representation"}],roles=[{value:"",title:""},{value:"value",title:"value"},{value:"level",title:"level"},{value:"state",title:"state"},{value:"switch",title:"switch"},{value:"value.temperature",title:"value.temperature"},{value:"value.humidity",title:"value.humidity"},{value:"value.brightness",title:"value.brightness"},{value:"value.uv",title:"value.uv"},{value:"value.pressure",title:"value.pressure"},{value:"value.battery",title:"value.battery"},{value:"value.valve",title:"value.valve"},{value:"value.time",title:"value.time"},{value:"value.interval",title:"value.interval"},{value:"value.window",title:"value.window"},{value:"button",title:"button"},{value:"indicator",title:"indicator"},{value:"level.dimmer",title:"level.dimmer"},{value:"level.valve",title:"level.valve"},{value:"level.blind",title:"level.blind"},{value:"level.temperature",title:"level.temperature"},{value:"level.interval",title:"level.interval"},{value:"value.power.consumption",title:"value.power.consumption"}];var source={exports:{}},json2tsv={},hasRequiredJson2tsv;function requireJson2tsv(){if(hasRequiredJson2tsv)return json2tsv;hasRequiredJson2tsv=1,Object.defineProperty(json2tsv,"__esModule",{value:!0}),json2tsv.json2tsv=void 0;function t(j){if(!Array.isArray(j))throw new TypeError(`Expected string[][], got ${typeof j}`);for(const z of j){if(!Array.isArray(z))throw new TypeError(`Expected string[][], got ${typeof z}[]`);for(const E of z)if(typeof E!="string")throw new TypeError(`Expected string[][], got ${typeof E}[][]`)}}const o=/[\t\n"]/;function e(j){return o.test(j)}function M(j){return t(j),j.map(z=>z.map(E=>e(E)?`"${E.replace(/"/g,'""')}"`:E).join(" ")).join(`
|
|
2610
2610
|
`)}return json2tsv.json2tsv=M,json2tsv}var tsv2json={},hasRequiredTsv2json;function requireTsv2json(){if(hasRequiredTsv2json)return tsv2json;hasRequiredTsv2json=1,Object.defineProperty(tsv2json,"__esModule",{value:!0}),tsv2json.tsv2json=void 0;function t(e){const M=[];let j=e[0]==='"',z=j?1:0;function E(N){return e.splice(0,z+1),{cell:M.join(""),lineIsOver:N}}for(;z<e.length;){const N=e[z],R=e[z+1];if(j)N==='"'?R==='"'?(M.push('"'),z++):j=!1:M.push(N);else{if(N==="\r"&&R===`
|
|
2611
2611
|
`)return z++,E(!0);if(N===`
|
|
2612
2612
|
`)return E(!0);if(N===" ")return E(!1);M.push(N)}z++}return E(!0)}function o(e){if(typeof e!="string")throw new TypeError(`Expected string, got ${typeof e}`);if(e==="")return[[]];const M=[...e],j=[];let z=[];for(;M.length>0;){const{cell:E,lineIsOver:N}=t(M);z.push(E),N&&(j.push(z),z=[])}return j}return tsv2json.tsv2json=o,tsv2json}var hasRequiredSource;function requireSource(){return hasRequiredSource||(hasRequiredSource=1,(function(t,o){Object.defineProperty(o,"__esModule",{value:!0}),o.tsv2json=o.json2tsv=void 0;const e=requireJson2tsv();var M=requireJson2tsv();Object.defineProperty(o,"json2tsv",{enumerable:!0,get:function(){return M.json2tsv}});const j=requireTsv2json();var z=requireTsv2json();Object.defineProperty(o,"tsv2json",{enumerable:!0,get:function(){return z.tsv2json}}),o.default={json2tsv:e.json2tsv,tsv2json:j.tsv2json},t.exports={json2tsv:e.json2tsv,tsv2json:j.tsv2json},t.exports.default={json2tsv:e.json2tsv,tsv2json:j.tsv2json}})(source,source.exports)),source.exports}var sourceExports=requireSource();const styles$2={tsvEditor:{width:"100%",height:400}};function TsvDialog(t){const[o,e]=reactExports.useState(""),[M,j]=reactExports.useState(null);reactExports.useEffect(()=>{const E=[];E.push(t.fields.map(N=>N.name)),t.data.forEach(N=>E.push(t.fields.map(R=>{var O;return N[R.name]!==void 0&&N[R.name]!==null&&((O=N[R.name])==null?void 0:O.toString())||""}))),e(sourceExports.json2tsv(E))},[]);const z=()=>{const E=sourceExports.tsv2json(o.endsWith(`
|
|
@@ -2781,4 +2781,4 @@ Każdy alias będzie wewnętrznie mapowany na adres, np. 30011 będzie mapowany
|
|
|
2781
2781
|
- 输入寄存器的地址范围是 30001 到 40000
|
|
2782
2782
|
- 保持寄存器的地址范围是 40001 到 60000
|
|
2783
2783
|
|
|
2784
|
-
每个别名都会在内部映射到地址,例如,30011 将映射到输入寄存器 10,依此类推。`,timeout_help="读取请求的超时时间(以毫秒为单位)。如果这段时间内没有收到从站的响应,连接将被终止。",waitTime_help="轮询两个不同设备 ID 之间的等待时间(以毫秒为单位)。",writeInterval_help="两个写入请求之间的延迟(以毫秒为单位)。默认 0。",zhCnLang={"Add DB":"添加数据库","Add line":"添加行",Address,"Address and ID options":"地址和 ID 选项","All entries will be deleted. Are you sure?":"所有条目将被删除。你确定吗?","Are you sure to delete all items?":"您确定要删除所有项目吗?",'Are you sure to delete item with address "%s"?':"您确定要删除地址为“%s”的项目吗?","Are you sure?":"你确定吗?","Baud rate":"波特率","Binary inputs (read-only)":"二进制输入(只读)","Binary inputs and outputs":"二进制输入和输出",CW,Cancel,"Change all":"全部更改",Close,Coils,Connection,"Connection parameters":"连接参数","Copy to clipboard":"复制到剪贴板","Cyclic write":"循环写","Data bits":"数据位",Delete,"Delete address":"删除地址","Delete all":"删除所有","Delete all entries":"删除所有条目","Delete all items":"删除所有项目","Delete item":"删除项目",Description,"Device ID":"设备编号","Disable connection error logging":"禁用连接错误日志记录","Discrete inputs":"离散输入","Do not align addresses to word":"不要将地址按16位对齐",'Do not use "Write multiple registers"':"不要使用“写入多个寄存器”","Don't show this message in 5 minutes":"5 分钟内不要显示此消息","Edit as TSV (Tab separated values)":"编辑为 TSV(制表符分隔值)","Edit data as TSV":"将数据编辑为 TSV","Edit mode":"编辑模式","Enable polling of data point":"启用数据点轮询",Export,"Export to CSV":"导出为CSV",Factor,Formula,General,"Holding Registers":"持有登记册","IP address of the Modbus TCP server":"Modbus TCP 服务器的 IP 地址",Import,"Import DB file":"导入数据库文件","Import from CSV":"从CSV导入","Import symbols file":"导入符号","Input Registers":"输入寄存器","Input registers (8-64 bit values, read-only)":"输入寄存器(8-64 位值,只读)","Input/output registers (8-64 bit values)":"输入/输出寄存器(8-64 位值)",Inputs,Length,"Listen on all IPs":"侦听所有 IP","Load Symbols":"加载符号",Master,"Max read request length":"最大读取请求长度(浮动)","Max read request length (booleans)":"最大读取请求长度(布尔值)","Modbus device ID of the slave or default device ID for master mode":"Modbus 从站设备 ID 或主站模式的默认设备 ID","Multi device IDs":"多设备ID",Name,Nothing,Offset,Others,"PLC Connection":"PLC连接","PLC IP Address":"PLC IP地址","PLC Rack":"PLC机架:","PLC Slot":"PLC插槽",Parity,"Partner IP Address":"同伴IP地址",Poll,"Poll delay":"轮询延迟",Port,"Pulse time":"脉冲时间","RTU over TCP":"TCP上的RTU","RTU over TCP (Master)":"RTU over TCP(仅限主站)",RW,"Read interval":"读取间隔","Read timeout":"读取超时","Read/Write settings":"读/写设置","Reconnect time":"重新连接延时","Reject unauthorized certificates":"拒绝未经授权的证书",'Remove leading "_" in ID if address is not included':"如果未包含地址,请删除 ID 中的前导“_”",Role,Room,"Round Real to":"舍入为",SF,"SSL CA Certificate":"SSL CA 证书","SSL Certificate":"SSL 证书","SSL Private key":"SSL 私钥",'Say "yes" for the next minute':"在下一分钟说“是”","Select port":"选择串口",Serial,Settings,Slave,"Slave ID":"从机 ID","Slave IP address":"从IP地址","Slave address":"从机地址","Start address":"起始地址","Stop bits":"停止位","Store this value as scaling factor":"将此值存储为比例因子",TCP,"TCP with SSL/TLS":"带有 SSL/TLS 的 TCP","TCP with SSL/TLS (Master)":"带有 SSL/TLS 的 TCP(仅限主服务器)","TCP/Serial RTU":"TCP /串行RTU","TSV was copied to clipboard":"TSV 被复制到剪贴板","Text copied to clipboard. Click to close the window":"文本已复制到剪贴板。点击关闭窗口。",Timings,"Toggle RW":"切换RW","Toggle WP":"切换WP","Toggle extended mode":"切换扩展模式","Toggle poll":"切换民意调查",Type,Unit,"Update unchanged states":"更新未更改状态","Use aliases as address":"使用别名","Use direct addresses by aliases":"通过别名使用直接地址",'Use only "Write multiple registers"':"仅使用“写入多个寄存器”","Using aliases as address":"使用别名作为地址","Using direct addresses":"使用直接地址",WP,"Wait time":"等待时间","Write access allowed":"允许写访问","Write interval":"写间隔","Write only with FC15/FC16":"仅使用 FC15/FC16 写入","Write only with FC5/FC6":"仅使用 FC5/FC6 写入","Write pulses (true → false edge)":"写脉冲(真→假边沿)","You can copy, paste and edit data as TSV.":"您可以将数据复制、粘贴和编辑为 TSV。",aliases_help,alwaysUpdate_help,deviceId,directAddressesExplanation,directAddresses_help,disableLogging_help,"do not include address in ID":"在ID中不包含地址",doNotIncludeAdrInId_help,doNotRoundAddressToWord_help,doNotUseWriteMultipleRegisters_help,formula,ms,poll,poll_help,"preserve dots in ID":"保留ID中的点",preserveDotsInId_help,pulsetime_help,readInterval_help,recon_help,registers,showAliasesExplanation,timeout_help,waitTime_help,writeInterval_help},styles={tabContent:{padding:10,height:"calc(100% - 64px - 48px - 20px)",overflow:"auto"},tabContentIFrame:{padding:10,height:"calc(100% - 64px - 48px - 20px - 38px)",overflow:"auto"},selected:t=>({color:t.palette.mode==="dark"?void 0:"#FFF !important"}),indicator:t=>({backgroundColor:t.palette.mode==="dark"?t.palette.secondary.main:"#FFF"})},tabs=[{name:"connection",title:"Connection"},{name:"settings",title:"Settings"},{name:"discrete-inputs",title:"Discrete inputs",icon:jsxRuntimeExports.jsx(AiOutlineFieldBinary,{style:{width:18,height:18,marginRight:4,display:"inline-block"}}),tooltip:"Binary inputs (read-only)"},{name:"coils",title:"Coils",icon:jsxRuntimeExports.jsx(AiOutlineFieldBinary,{style:{width:18,height:18,marginRight:4,display:"inline-block"}}),tooltip:"Binary inputs and outputs"},{name:"input-registers",title:"Input Registers",icon:jsxRuntimeExports.jsx(TiSortNumerically,{style:{width:18,height:18,marginRight:4,display:"inline-block"}}),tooltip:"Input registers (8-64 bit values, read-only)"},{name:"holding-registers",title:"Holding Registers",icon:jsxRuntimeExports.jsx(TiSortNumerically,{style:{width:18,height:18,marginRight:4,display:"inline-block"}}),tooltip:"Input/output registers (8-64 bit values)"}];function sort(t){t.sort((o,e)=>{o.deviceId=parseInt(o.deviceId,10)||1,e.deviceId=parseInt(e.deviceId,10)||1,o._address=parseInt(o._address,10)||0,e._address=parseInt(e._address,10)||0;const M=o.deviceId<<16|o._address,j=e.deviceId<<16|e._address;return M<j?-1:M>j?1:0})}class App extends GenericApp{constructor(e){const M={...e};M.encryptedFields=["pass"],M.translations={en:enLang,de:deLang,ru:ruLang,pt:ptLang,nl:nlLang,fr:frLang,it:itLang,es:esLang,pl:plLang,uk:ukLang,"zh-cn":zhCnLang},M.Connection=AdminConnection,M.sentryDSN=window.sentryDSN;super(e,M);_1(this,"onAliveChanged",(e,M)=>{!!(M!=null&&M.val)!==this.state.alive&&this.setState({alive:!!(M!=null&&M.val)})});this.state={...this.state,moreLoaded:!1,rooms:null,alive:!1,systemConfig:null}}onPrepareSave(e){return e.disInputs&&sort(e.disInputs),e.coils&&sort(e.coils),e.inputRegs&&sort(e.inputRegs),e.holdingRegs&&sort(e.holdingRegs),!0}async onConnectionReady(){super.onConnectionReady();const e=window.localStorage.getItem(`modbus.${this.instance}.selectedTab`)||"connection";this.socket.getEnums("rooms").then(z=>this.setState({moreLoaded:!0,rooms:z}));const M=await this.socket.getSystemConfig(),j=await this.socket.getState(`system.adapter.modbus.${this.instance}.alive`);this.setState({alive:!!(j!=null&&j.val),selectedTab:e,systemConfig:M}),await this.socket.subscribeState(`system.adapter.modbus.${this.instance}.alive`,this.onAliveChanged)}renderConnection(){return this.state.systemConfig?jsxRuntimeExports.jsx(Connection$b,{common:this.common||{},socket:this.socket,native:this.state.native,instance:this.instance,adapterName:this.adapterName,changeNative:e=>this.setState({native:e,changed:this.getIsChanged(e)}),themeType:this.state.themeType,theme:this.state.theme,themeName:this.state.themeName,systemConfig:this.state.systemConfig}):jsxRuntimeExports.jsx("div",{children:I18n.t("Loading...")})}renderSettings(){return this.state.systemConfig?jsxRuntimeExports.jsx(Settings$b,{common:this.common||{},socket:this.socket,native:this.state.native,instance:this.instance,adapterName:this.adapterName,changeNative:e=>this.setState({native:e,changed:this.getIsChanged(e)}),themeType:this.state.themeType,theme:this.state.theme,themeName:this.state.themeName,systemConfig:this.state.systemConfig}):jsxRuntimeExports.jsx("div",{children:I18n.t("Loading...")})}renderDiscreteInputs(){return jsxRuntimeExports.jsx(DiscreteInputs,{alive:this.state.alive,formulaDisabled:this.state.native.params.slave==="1"||this.state.native.params.slave===1,socket:this.socket,native:this.state.native,instance:this.instance,adapterName:this.adapterName,changed:this.state.changed,onChange:(e,M,j)=>this.updateNativeValue(e,M,j),rooms:this.state.rooms||{},themeType:this.state.themeType})}renderCoils(){return jsxRuntimeExports.jsx(Coils$b,{alive:this.state.alive,formulaDisabled:this.state.native.params.slave==="1"||this.state.native.params.slave===1,socket:this.socket,native:this.state.native,instance:this.instance,adapterName:this.adapterName,changed:this.state.changed,onChange:(e,M,j)=>this.updateNativeValue(e,M,j),rooms:this.state.rooms||{},themeType:this.state.themeType})}renderInputRegisters(){return jsxRuntimeExports.jsx(InputRegisters,{alive:this.state.alive,formulaDisabled:this.state.native.params.slave==="1"||this.state.native.params.slave===1,socket:this.socket,native:this.state.native,instance:this.instance,adapterName:this.adapterName,changed:this.state.changed,onChange:(e,M,j)=>this.updateNativeValue(e,M,j),rooms:this.state.rooms||{},themeType:this.state.themeType})}renderHoldingRegisters(){return jsxRuntimeExports.jsx(HoldingRegisters,{alive:this.state.alive,formulaDisabled:this.state.native.params.slave==="1"||this.state.native.params.slave===1,socket:this.socket,native:this.state.native,instance:this.instance,adapterName:this.adapterName,changed:this.state.changed,onChange:(e,M,j)=>this.updateNativeValue(e,M,j),rooms:this.state.rooms||{},themeType:this.state.themeType})}renderTab(){return this.state.selectedTab==="connection"||!this.state.selectedTab?this.renderConnection():this.state.selectedTab==="settings"?this.renderSettings():this.state.selectedTab==="discrete-inputs"?this.renderDiscreteInputs():this.state.selectedTab==="coils"?this.renderCoils():this.state.selectedTab==="input-registers"?this.renderInputRegisters():this.state.selectedTab==="holding-registers"?this.renderHoldingRegisters():jsxRuntimeExports.jsx("div",{children:I18n.t("Unknown tab")})}render(){return!this.state.loaded||!this.state.moreLoaded?jsxRuntimeExports.jsx(StyledEngineProvider,{injectFirst:!0,children:jsxRuntimeExports.jsx(ThemeProvider,{theme:this.state.theme,children:jsxRuntimeExports.jsx(Loader,{themeType:this.state.themeType})})}):jsxRuntimeExports.jsx(StyledEngineProvider,{injectFirst:!0,children:jsxRuntimeExports.jsx(ThemeProvider,{theme:this.state.theme,children:jsxRuntimeExports.jsxs("div",{className:"App",style:{background:this.state.theme.palette.background.default,color:this.state.theme.palette.text.primary},children:[jsxRuntimeExports.jsx(AppBar,{position:"static",children:jsxRuntimeExports.jsx(Tabs,{indicatorColor:"secondary",value:this.state.selectedTab||tabs[0].name,onChange:(e,M)=>{this.setState({selectedTab:M}),window.localStorage.setItem(`modbus.${this.instance}.selectedTab`,M)},variant:"scrollable",scrollButtons:"auto",sx:{"&.Mui-indicator":styles.indicator},children:tabs.map(e=>jsxRuntimeExports.jsx(Tab$1,{value:e.name,sx:{"&.Mui-selected":styles.selected},label:e.icon?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[e.icon,I18n.t(e.title)]}):I18n.t(e.title),"data-name":e.name,title:e.tooltip?I18n.t(e.tooltip):void 0},e.name))})}),jsxRuntimeExports.jsx("div",{style:this.isIFrame?styles.tabContentIFrame:styles.tabContent,children:this.renderTab()}),this.renderError(),this.renderSaveCloseButtons()]})})})}}window.location.hostname==="localhost"||window.location.hostname==="[::1]"||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/);function unregister(){"serviceWorker"in navigator&&navigator.serviceWorker.ready.then(t=>t.unregister())}const version="7.0.3",pkg={version};window.adapterName="modbus";window.sentryDSN="https://19469f9280bd4b18a3e960e79cb01df2@sentry.iobroker.net/196";console.log(`iobroker.${window.adapterName}@${pkg.version}`);const container=document.getElementById("root");container&&clientExports.createRoot(container).render(jsxRuntimeExports.jsx(App,{}));unregister();export{requirePropTypes as a,getDefaultExportFromCjs as g,requireReact as r};
|
|
2784
|
+
每个别名都会在内部映射到地址,例如,30011 将映射到输入寄存器 10,依此类推。`,timeout_help="读取请求的超时时间(以毫秒为单位)。如果这段时间内没有收到从站的响应,连接将被终止。",waitTime_help="轮询两个不同设备 ID 之间的等待时间(以毫秒为单位)。",writeInterval_help="两个写入请求之间的延迟(以毫秒为单位)。默认 0。",zhCnLang={"Add DB":"添加数据库","Add line":"添加行",Address,"Address and ID options":"地址和 ID 选项","All entries will be deleted. Are you sure?":"所有条目将被删除。你确定吗?","Are you sure to delete all items?":"您确定要删除所有项目吗?",'Are you sure to delete item with address "%s"?':"您确定要删除地址为“%s”的项目吗?","Are you sure?":"你确定吗?","Baud rate":"波特率","Binary inputs (read-only)":"二进制输入(只读)","Binary inputs and outputs":"二进制输入和输出",CW,Cancel,"Change all":"全部更改",Close,Coils,Connection,"Connection parameters":"连接参数","Copy to clipboard":"复制到剪贴板","Cyclic write":"循环写","Data bits":"数据位",Delete,"Delete address":"删除地址","Delete all":"删除所有","Delete all entries":"删除所有条目","Delete all items":"删除所有项目","Delete item":"删除项目",Description,"Device ID":"设备编号","Disable connection error logging":"禁用连接错误日志记录","Discrete inputs":"离散输入","Do not align addresses to word":"不要将地址按16位对齐",'Do not use "Write multiple registers"':"不要使用“写入多个寄存器”","Don't show this message in 5 minutes":"5 分钟内不要显示此消息","Edit as TSV (Tab separated values)":"编辑为 TSV(制表符分隔值)","Edit data as TSV":"将数据编辑为 TSV","Edit mode":"编辑模式","Enable polling of data point":"启用数据点轮询",Export,"Export to CSV":"导出为CSV",Factor,Formula,General,"Holding Registers":"持有登记册","IP address of the Modbus TCP server":"Modbus TCP 服务器的 IP 地址",Import,"Import DB file":"导入数据库文件","Import from CSV":"从CSV导入","Import symbols file":"导入符号","Input Registers":"输入寄存器","Input registers (8-64 bit values, read-only)":"输入寄存器(8-64 位值,只读)","Input/output registers (8-64 bit values)":"输入/输出寄存器(8-64 位值)",Inputs,Length,"Listen on all IPs":"侦听所有 IP","Load Symbols":"加载符号",Master,"Max read request length":"最大读取请求长度(浮动)","Max read request length (booleans)":"最大读取请求长度(布尔值)","Modbus device ID of the slave or default device ID for master mode":"Modbus 从站设备 ID 或主站模式的默认设备 ID","Multi device IDs":"多设备ID",Name,Nothing,Offset,Others,"PLC Connection":"PLC连接","PLC IP Address":"PLC IP地址","PLC Rack":"PLC机架:","PLC Slot":"PLC插槽",Parity,"Partner IP Address":"同伴IP地址",Poll,"Poll delay":"轮询延迟",Port,"Pulse time":"脉冲时间","RTU over TCP":"TCP上的RTU","RTU over TCP (Master)":"RTU over TCP(仅限主站)",RW,"Read interval":"读取间隔","Read timeout":"读取超时","Read/Write settings":"读/写设置","Reconnect time":"重新连接延时","Reject unauthorized certificates":"拒绝未经授权的证书",'Remove leading "_" in ID if address is not included':"如果未包含地址,请删除 ID 中的前导“_”",Role,Room,"Round Real to":"舍入为",SF,"SSL CA Certificate":"SSL CA 证书","SSL Certificate":"SSL 证书","SSL Private key":"SSL 私钥",'Say "yes" for the next minute':"在下一分钟说“是”","Select port":"选择串口",Serial,Settings,Slave,"Slave ID":"从机 ID","Slave IP address":"从IP地址","Slave address":"从机地址","Start address":"起始地址","Stop bits":"停止位","Store this value as scaling factor":"将此值存储为比例因子",TCP,"TCP with SSL/TLS":"带有 SSL/TLS 的 TCP","TCP with SSL/TLS (Master)":"带有 SSL/TLS 的 TCP(仅限主服务器)","TCP/Serial RTU":"TCP /串行RTU","TSV was copied to clipboard":"TSV 被复制到剪贴板","Text copied to clipboard. Click to close the window":"文本已复制到剪贴板。点击关闭窗口。",Timings,"Toggle RW":"切换RW","Toggle WP":"切换WP","Toggle extended mode":"切换扩展模式","Toggle poll":"切换民意调查",Type,Unit,"Update unchanged states":"更新未更改状态","Use aliases as address":"使用别名","Use direct addresses by aliases":"通过别名使用直接地址",'Use only "Write multiple registers"':"仅使用“写入多个寄存器”","Using aliases as address":"使用别名作为地址","Using direct addresses":"使用直接地址",WP,"Wait time":"等待时间","Write access allowed":"允许写访问","Write interval":"写间隔","Write only with FC15/FC16":"仅使用 FC15/FC16 写入","Write only with FC5/FC6":"仅使用 FC5/FC6 写入","Write pulses (true → false edge)":"写脉冲(真→假边沿)","You can copy, paste and edit data as TSV.":"您可以将数据复制、粘贴和编辑为 TSV。",aliases_help,alwaysUpdate_help,deviceId,directAddressesExplanation,directAddresses_help,disableLogging_help,"do not include address in ID":"在ID中不包含地址",doNotIncludeAdrInId_help,doNotRoundAddressToWord_help,doNotUseWriteMultipleRegisters_help,formula,ms,poll,poll_help,"preserve dots in ID":"保留ID中的点",preserveDotsInId_help,pulsetime_help,readInterval_help,recon_help,registers,showAliasesExplanation,timeout_help,waitTime_help,writeInterval_help},styles={tabContent:{padding:10,height:"calc(100% - 64px - 48px - 20px)",overflow:"auto"},tabContentIFrame:{padding:10,height:"calc(100% - 64px - 48px - 20px - 38px)",overflow:"auto"},selected:t=>({color:t.palette.mode==="dark"?void 0:"#FFF !important"}),indicator:t=>({backgroundColor:t.palette.mode==="dark"?t.palette.secondary.main:"#FFF"})},tabs=[{name:"connection",title:"Connection"},{name:"settings",title:"Settings"},{name:"discrete-inputs",title:"Discrete inputs",icon:jsxRuntimeExports.jsx(AiOutlineFieldBinary,{style:{width:18,height:18,marginRight:4,display:"inline-block"}}),tooltip:"Binary inputs (read-only)"},{name:"coils",title:"Coils",icon:jsxRuntimeExports.jsx(AiOutlineFieldBinary,{style:{width:18,height:18,marginRight:4,display:"inline-block"}}),tooltip:"Binary inputs and outputs"},{name:"input-registers",title:"Input Registers",icon:jsxRuntimeExports.jsx(TiSortNumerically,{style:{width:18,height:18,marginRight:4,display:"inline-block"}}),tooltip:"Input registers (8-64 bit values, read-only)"},{name:"holding-registers",title:"Holding Registers",icon:jsxRuntimeExports.jsx(TiSortNumerically,{style:{width:18,height:18,marginRight:4,display:"inline-block"}}),tooltip:"Input/output registers (8-64 bit values)"}];function sort(t){t.sort((o,e)=>{o.deviceId=parseInt(o.deviceId,10)||1,e.deviceId=parseInt(e.deviceId,10)||1,o._address=parseInt(o._address,10)||0,e._address=parseInt(e._address,10)||0;const M=o.deviceId<<16|o._address,j=e.deviceId<<16|e._address;return M<j?-1:M>j?1:0})}class App extends GenericApp{constructor(e){const M={...e};M.encryptedFields=["pass"],M.translations={en:enLang,de:deLang,ru:ruLang,pt:ptLang,nl:nlLang,fr:frLang,it:itLang,es:esLang,pl:plLang,uk:ukLang,"zh-cn":zhCnLang},M.Connection=AdminConnection,M.sentryDSN=window.sentryDSN;super(e,M);_1(this,"onAliveChanged",(e,M)=>{!!(M!=null&&M.val)!==this.state.alive&&this.setState({alive:!!(M!=null&&M.val)})});this.state={...this.state,moreLoaded:!1,rooms:null,alive:!1,systemConfig:null}}onPrepareSave(e){return e.disInputs&&sort(e.disInputs),e.coils&&sort(e.coils),e.inputRegs&&sort(e.inputRegs),e.holdingRegs&&sort(e.holdingRegs),!0}async onConnectionReady(){super.onConnectionReady();const e=window.localStorage.getItem(`modbus.${this.instance}.selectedTab`)||"connection";this.socket.getEnums("rooms").then(z=>this.setState({moreLoaded:!0,rooms:z}));const M=await this.socket.getSystemConfig(),j=await this.socket.getState(`system.adapter.modbus.${this.instance}.alive`);this.setState({alive:!!(j!=null&&j.val),selectedTab:e,systemConfig:M}),await this.socket.subscribeState(`system.adapter.modbus.${this.instance}.alive`,this.onAliveChanged)}renderConnection(){return this.state.systemConfig?jsxRuntimeExports.jsx(Connection$b,{common:this.common||{},socket:this.socket,native:this.state.native,instance:this.instance,adapterName:this.adapterName,changeNative:e=>this.setState({native:e,changed:this.getIsChanged(e)}),themeType:this.state.themeType,theme:this.state.theme,themeName:this.state.themeName,systemConfig:this.state.systemConfig}):jsxRuntimeExports.jsx("div",{children:I18n.t("Loading...")})}renderSettings(){return this.state.systemConfig?jsxRuntimeExports.jsx(Settings$b,{common:this.common||{},socket:this.socket,native:this.state.native,instance:this.instance,adapterName:this.adapterName,changeNative:e=>this.setState({native:e,changed:this.getIsChanged(e)}),themeType:this.state.themeType,theme:this.state.theme,themeName:this.state.themeName,systemConfig:this.state.systemConfig}):jsxRuntimeExports.jsx("div",{children:I18n.t("Loading...")})}renderDiscreteInputs(){return jsxRuntimeExports.jsx(DiscreteInputs,{alive:this.state.alive,formulaDisabled:this.state.native.params.slave==="1"||this.state.native.params.slave===1,socket:this.socket,native:this.state.native,instance:this.instance,adapterName:this.adapterName,changed:this.state.changed,onChange:(e,M,j)=>this.updateNativeValue(e,M,j),rooms:this.state.rooms||{},themeType:this.state.themeType})}renderCoils(){return jsxRuntimeExports.jsx(Coils$b,{alive:this.state.alive,formulaDisabled:this.state.native.params.slave==="1"||this.state.native.params.slave===1,socket:this.socket,native:this.state.native,instance:this.instance,adapterName:this.adapterName,changed:this.state.changed,onChange:(e,M,j)=>this.updateNativeValue(e,M,j),rooms:this.state.rooms||{},themeType:this.state.themeType})}renderInputRegisters(){return jsxRuntimeExports.jsx(InputRegisters,{alive:this.state.alive,formulaDisabled:this.state.native.params.slave==="1"||this.state.native.params.slave===1,socket:this.socket,native:this.state.native,instance:this.instance,adapterName:this.adapterName,changed:this.state.changed,onChange:(e,M,j)=>this.updateNativeValue(e,M,j),rooms:this.state.rooms||{},themeType:this.state.themeType})}renderHoldingRegisters(){return jsxRuntimeExports.jsx(HoldingRegisters,{alive:this.state.alive,formulaDisabled:this.state.native.params.slave==="1"||this.state.native.params.slave===1,socket:this.socket,native:this.state.native,instance:this.instance,adapterName:this.adapterName,changed:this.state.changed,onChange:(e,M,j)=>this.updateNativeValue(e,M,j),rooms:this.state.rooms||{},themeType:this.state.themeType})}renderTab(){return this.state.selectedTab==="connection"||!this.state.selectedTab?this.renderConnection():this.state.selectedTab==="settings"?this.renderSettings():this.state.selectedTab==="discrete-inputs"?this.renderDiscreteInputs():this.state.selectedTab==="coils"?this.renderCoils():this.state.selectedTab==="input-registers"?this.renderInputRegisters():this.state.selectedTab==="holding-registers"?this.renderHoldingRegisters():jsxRuntimeExports.jsx("div",{children:I18n.t("Unknown tab")})}render(){return!this.state.loaded||!this.state.moreLoaded?jsxRuntimeExports.jsx(StyledEngineProvider,{injectFirst:!0,children:jsxRuntimeExports.jsx(ThemeProvider,{theme:this.state.theme,children:jsxRuntimeExports.jsx(Loader,{themeType:this.state.themeType})})}):jsxRuntimeExports.jsx(StyledEngineProvider,{injectFirst:!0,children:jsxRuntimeExports.jsx(ThemeProvider,{theme:this.state.theme,children:jsxRuntimeExports.jsxs("div",{className:"App",style:{background:this.state.theme.palette.background.default,color:this.state.theme.palette.text.primary},children:[jsxRuntimeExports.jsx(AppBar,{position:"static",children:jsxRuntimeExports.jsx(Tabs,{indicatorColor:"secondary",value:this.state.selectedTab||tabs[0].name,onChange:(e,M)=>{this.setState({selectedTab:M}),window.localStorage.setItem(`modbus.${this.instance}.selectedTab`,M)},variant:"scrollable",scrollButtons:"auto",sx:{"&.Mui-indicator":styles.indicator},children:tabs.map(e=>jsxRuntimeExports.jsx(Tab$1,{value:e.name,sx:{"&.Mui-selected":styles.selected},label:e.icon?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[e.icon,I18n.t(e.title)]}):I18n.t(e.title),"data-name":e.name,title:e.tooltip?I18n.t(e.tooltip):void 0},e.name))})}),jsxRuntimeExports.jsx("div",{style:this.isIFrame?styles.tabContentIFrame:styles.tabContent,children:this.renderTab()}),this.renderError(),this.renderSaveCloseButtons()]})})})}}window.location.hostname==="localhost"||window.location.hostname==="[::1]"||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/);function unregister(){"serviceWorker"in navigator&&navigator.serviceWorker.ready.then(t=>t.unregister())}const version="7.0.4",pkg={version};window.adapterName="modbus";window.sentryDSN="https://19469f9280bd4b18a3e960e79cb01df2@sentry.iobroker.net/196";console.log(`iobroker.${window.adapterName}@${pkg.version}`);const container=document.getElementById("root");container&&clientExports.createRoot(container).render(jsxRuntimeExports.jsx(App,{}));unregister();export{requirePropTypes as a,getDefaultExportFromCjs as g,requireReact as r};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as V,a as ee,g as se}from"./index-DhRLKnoM.js";function fe(v,f){for(var a=0;a<f.length;a++){const g=f[a];if(typeof g!="string"&&!Array.isArray(g)){for(const l in g)if(l!=="default"&&!(l in v)){const r=Object.getOwnPropertyDescriptor(g,l);r&&Object.defineProperty(v,l,r.get?r:{enumerable:!0,get:()=>g[l]})}}}return Object.freeze(Object.defineProperty(v,Symbol.toStringTag,{value:"Module"}))}var R={},N,G;function te(){return G||(G=1,N={L:1,M:0,Q:3,H:2}),N}var k,K;function re(){return K||(K=1,k={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8}),k}var I,U;function le(){if(U)return I;U=1;var v=re();function f(a){this.mode=v.MODE_8BIT_BYTE,this.data=a}return f.prototype={getLength:function(a){return this.data.length},write:function(a){for(var g=0;g<this.data.length;g++)a.put(this.data.charCodeAt(g),8)}},I=f,I}var x,F;function he(){if(F)return x;F=1;var v=te();function f(a,g){this.totalCount=a,this.dataCount=g}return f.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],f.getRSBlocks=function(a,g){var l=f.getRsBlockTable(a,g);if(l==null)throw new Error("bad rs block @ typeNumber:"+a+"/errorCorrectLevel:"+g);for(var r=l.length/3,u=new Array,n=0;n<r;n++)for(var t=l[n*3+0],e=l[n*3+1],o=l[n*3+2],i=0;i<t;i++)u.push(new f(e,o));return u},f.getRsBlockTable=function(a,g){switch(g){case v.L:return f.RS_BLOCK_TABLE[(a-1)*4+0];case v.M:return f.RS_BLOCK_TABLE[(a-1)*4+1];case v.Q:return f.RS_BLOCK_TABLE[(a-1)*4+2];case v.H:return f.RS_BLOCK_TABLE[(a-1)*4+3];default:return}},x=f,x}var S,X;function ve(){if(X)return S;X=1;function v(){this.buffer=new Array,this.length=0}return v.prototype={get:function(f){var a=Math.floor(f/8);return(this.buffer[a]>>>7-f%8&1)==1},put:function(f,a){for(var g=0;g<a;g++)this.putBit((f>>>a-g-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(f){var a=Math.floor(this.length/8);this.buffer.length<=a&&this.buffer.push(0),f&&(this.buffer[a]|=128>>>this.length%8),this.length++}},S=v,S}var Q,$;function ne(){if($)return Q;$=1;for(var v={glog:function(a){if(a<1)throw new Error("glog("+a+")");return v.LOG_TABLE[a]},gexp:function(a){for(;a<0;)a+=255;for(;a>=256;)a-=255;return v.EXP_TABLE[a]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},f=0;f<8;f++)v.EXP_TABLE[f]=1<<f;for(var f=8;f<256;f++)v.EXP_TABLE[f]=v.EXP_TABLE[f-4]^v.EXP_TABLE[f-5]^v.EXP_TABLE[f-6]^v.EXP_TABLE[f-8];for(var f=0;f<255;f++)v.LOG_TABLE[v.EXP_TABLE[f]]=f;return Q=v,Q}var H,Y;function ae(){if(Y)return H;Y=1;var v=ne();function f(a,g){if(a.length==null)throw new Error(a.length+"/"+g);for(var l=0;l<a.length&&a[l]==0;)l++;this.num=new Array(a.length-l+g);for(var r=0;r<a.length-l;r++)this.num[r]=a[r+l]}return f.prototype={get:function(a){return this.num[a]},getLength:function(){return this.num.length},multiply:function(a){for(var g=new Array(this.getLength()+a.getLength()-1),l=0;l<this.getLength();l++)for(var r=0;r<a.getLength();r++)g[l+r]^=v.gexp(v.glog(this.get(l))+v.glog(a.get(r)));return new f(g,0)},mod:function(a){if(this.getLength()-a.getLength()<0)return this;for(var g=v.glog(this.get(0))-v.glog(a.get(0)),l=new Array(this.getLength()),r=0;r<this.getLength();r++)l[r]=this.get(r);for(var r=0;r<a.getLength();r++)l[r]^=v.gexp(v.glog(a.get(r))+g);return new f(l,0).mod(a)}},H=f,H}var z,J;function ge(){if(J)return z;J=1;var v=re(),f=ae(),a=ne(),g={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},l={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(r){for(var u=r<<10;l.getBCHDigit(u)-l.getBCHDigit(l.G15)>=0;)u^=l.G15<<l.getBCHDigit(u)-l.getBCHDigit(l.G15);return(r<<10|u)^l.G15_MASK},getBCHTypeNumber:function(r){for(var u=r<<12;l.getBCHDigit(u)-l.getBCHDigit(l.G18)>=0;)u^=l.G18<<l.getBCHDigit(u)-l.getBCHDigit(l.G18);return r<<12|u},getBCHDigit:function(r){for(var u=0;r!=0;)u++,r>>>=1;return u},getPatternPosition:function(r){return l.PATTERN_POSITION_TABLE[r-1]},getMask:function(r,u,n){switch(r){case g.PATTERN000:return(u+n)%2==0;case g.PATTERN001:return u%2==0;case g.PATTERN010:return n%3==0;case g.PATTERN011:return(u+n)%3==0;case g.PATTERN100:return(Math.floor(u/2)+Math.floor(n/3))%2==0;case g.PATTERN101:return u*n%2+u*n%3==0;case g.PATTERN110:return(u*n%2+u*n%3)%2==0;case g.PATTERN111:return(u*n%3+(u+n)%2)%2==0;default:throw new Error("bad maskPattern:"+r)}},getErrorCorrectPolynomial:function(r){for(var u=new f([1],0),n=0;n<r;n++)u=u.multiply(new f([1,a.gexp(n)],0));return u},getLengthInBits:function(r,u){if(1<=u&&u<10)switch(r){case v.MODE_NUMBER:return 10;case v.MODE_ALPHA_NUM:return 9;case v.MODE_8BIT_BYTE:return 8;case v.MODE_KANJI:return 8;default:throw new Error("mode:"+r)}else if(u<27)switch(r){case v.MODE_NUMBER:return 12;case v.MODE_ALPHA_NUM:return 11;case v.MODE_8BIT_BYTE:return 16;case v.MODE_KANJI:return 10;default:throw new Error("mode:"+r)}else if(u<41)switch(r){case v.MODE_NUMBER:return 14;case v.MODE_ALPHA_NUM:return 13;case v.MODE_8BIT_BYTE:return 16;case v.MODE_KANJI:return 12;default:throw new Error("mode:"+r)}else throw new Error("type:"+u)},getLostPoint:function(r){for(var u=r.getModuleCount(),n=0,t=0;t<u;t++)for(var e=0;e<u;e++){for(var o=0,i=r.isDark(t,e),s=-1;s<=1;s++)if(!(t+s<0||u<=t+s))for(var d=-1;d<=1;d++)e+d<0||u<=e+d||s==0&&d==0||i==r.isDark(t+s,e+d)&&o++;o>5&&(n+=3+o-5)}for(var t=0;t<u-1;t++)for(var e=0;e<u-1;e++){var h=0;r.isDark(t,e)&&h++,r.isDark(t+1,e)&&h++,r.isDark(t,e+1)&&h++,r.isDark(t+1,e+1)&&h++,(h==0||h==4)&&(n+=3)}for(var t=0;t<u;t++)for(var e=0;e<u-6;e++)r.isDark(t,e)&&!r.isDark(t,e+1)&&r.isDark(t,e+2)&&r.isDark(t,e+3)&&r.isDark(t,e+4)&&!r.isDark(t,e+5)&&r.isDark(t,e+6)&&(n+=40);for(var e=0;e<u;e++)for(var t=0;t<u-6;t++)r.isDark(t,e)&&!r.isDark(t+1,e)&&r.isDark(t+2,e)&&r.isDark(t+3,e)&&r.isDark(t+4,e)&&!r.isDark(t+5,e)&&r.isDark(t+6,e)&&(n+=40);for(var p=0,e=0;e<u;e++)for(var t=0;t<u;t++)r.isDark(t,e)&&p++;var c=Math.abs(100*p/u/u-50)/5;return n+=c*10,n}};return z=l,z}var q,W;function de(){if(W)return q;W=1;var v=le(),f=he(),a=ve(),g=ge(),l=ae();function r(n,t){this.typeNumber=n,this.errorCorrectLevel=t,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}var u=r.prototype;return u.addData=function(n){var t=new v(n);this.dataList.push(t),this.dataCache=null},u.isDark=function(n,t){if(n<0||this.moduleCount<=n||t<0||this.moduleCount<=t)throw new Error(n+","+t);return this.modules[n][t]},u.getModuleCount=function(){return this.moduleCount},u.make=function(){if(this.typeNumber<1){var n=1;for(n=1;n<40;n++){for(var t=f.getRSBlocks(n,this.errorCorrectLevel),e=new a,o=0,i=0;i<t.length;i++)o+=t[i].dataCount;for(var i=0;i<this.dataList.length;i++){var s=this.dataList[i];e.put(s.mode,4),e.put(s.getLength(),g.getLengthInBits(s.mode,n)),s.write(e)}if(e.getLengthInBits()<=o*8)break}this.typeNumber=n}this.makeImpl(!1,this.getBestMaskPattern())},u.makeImpl=function(n,t){this.moduleCount=this.typeNumber*4+17,this.modules=new Array(this.moduleCount);for(var e=0;e<this.moduleCount;e++){this.modules[e]=new Array(this.moduleCount);for(var o=0;o<this.moduleCount;o++)this.modules[e][o]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(n,t),this.typeNumber>=7&&this.setupTypeNumber(n),this.dataCache==null&&(this.dataCache=r.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,t)},u.setupPositionProbePattern=function(n,t){for(var e=-1;e<=7;e++)if(!(n+e<=-1||this.moduleCount<=n+e))for(var o=-1;o<=7;o++)t+o<=-1||this.moduleCount<=t+o||(0<=e&&e<=6&&(o==0||o==6)||0<=o&&o<=6&&(e==0||e==6)||2<=e&&e<=4&&2<=o&&o<=4?this.modules[n+e][t+o]=!0:this.modules[n+e][t+o]=!1)},u.getBestMaskPattern=function(){for(var n=0,t=0,e=0;e<8;e++){this.makeImpl(!0,e);var o=g.getLostPoint(this);(e==0||n>o)&&(n=o,t=e)}return t},u.createMovieClip=function(n,t,e){var o=n.createEmptyMovieClip(t,e),i=1;this.make();for(var s=0;s<this.modules.length;s++)for(var d=s*i,h=0;h<this.modules[s].length;h++){var p=h*i,c=this.modules[s][h];c&&(o.beginFill(0,100),o.moveTo(p,d),o.lineTo(p+i,d),o.lineTo(p+i,d+i),o.lineTo(p,d+i),o.endFill())}return o},u.setupTimingPattern=function(){for(var n=8;n<this.moduleCount-8;n++)this.modules[n][6]==null&&(this.modules[n][6]=n%2==0);for(var t=8;t<this.moduleCount-8;t++)this.modules[6][t]==null&&(this.modules[6][t]=t%2==0)},u.setupPositionAdjustPattern=function(){for(var n=g.getPatternPosition(this.typeNumber),t=0;t<n.length;t++)for(var e=0;e<n.length;e++){var o=n[t],i=n[e];if(this.modules[o][i]==null)for(var s=-2;s<=2;s++)for(var d=-2;d<=2;d++)s==-2||s==2||d==-2||d==2||s==0&&d==0?this.modules[o+s][i+d]=!0:this.modules[o+s][i+d]=!1}},u.setupTypeNumber=function(n){for(var t=g.getBCHTypeNumber(this.typeNumber),e=0;e<18;e++){var o=!n&&(t>>e&1)==1;this.modules[Math.floor(e/3)][e%3+this.moduleCount-8-3]=o}for(var e=0;e<18;e++){var o=!n&&(t>>e&1)==1;this.modules[e%3+this.moduleCount-8-3][Math.floor(e/3)]=o}},u.setupTypeInfo=function(n,t){for(var e=this.errorCorrectLevel<<3|t,o=g.getBCHTypeInfo(e),i=0;i<15;i++){var s=!n&&(o>>i&1)==1;i<6?this.modules[i][8]=s:i<8?this.modules[i+1][8]=s:this.modules[this.moduleCount-15+i][8]=s}for(var i=0;i<15;i++){var s=!n&&(o>>i&1)==1;i<8?this.modules[8][this.moduleCount-i-1]=s:i<9?this.modules[8][15-i-1+1]=s:this.modules[8][15-i-1]=s}this.modules[this.moduleCount-8][8]=!n},u.mapData=function(n,t){for(var e=-1,o=this.moduleCount-1,i=7,s=0,d=this.moduleCount-1;d>0;d-=2)for(d==6&&d--;;){for(var h=0;h<2;h++)if(this.modules[o][d-h]==null){var p=!1;s<n.length&&(p=(n[s]>>>i&1)==1);var c=g.getMask(t,o,d-h);c&&(p=!p),this.modules[o][d-h]=p,i--,i==-1&&(s++,i=7)}if(o+=e,o<0||this.moduleCount<=o){o-=e,e=-e;break}}},r.PAD0=236,r.PAD1=17,r.createData=function(n,t,e){for(var o=f.getRSBlocks(n,t),i=new a,s=0;s<e.length;s++){var d=e[s];i.put(d.mode,4),i.put(d.getLength(),g.getLengthInBits(d.mode,n)),d.write(i)}for(var h=0,s=0;s<o.length;s++)h+=o[s].dataCount;if(i.getLengthInBits()>h*8)throw new Error("code length overflow. ("+i.getLengthInBits()+">"+h*8+")");for(i.getLengthInBits()+4<=h*8&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=h*8||(i.put(r.PAD0,8),i.getLengthInBits()>=h*8));)i.put(r.PAD1,8);return r.createBytes(i,o)},r.createBytes=function(n,t){for(var e=0,o=0,i=0,s=new Array(t.length),d=new Array(t.length),h=0;h<t.length;h++){var p=t[h].dataCount,c=t[h].totalCount-p;o=Math.max(o,p),i=Math.max(i,c),s[h]=new Array(p);for(var m=0;m<s[h].length;m++)s[h][m]=255&n.buffer[m+e];e+=p;var E=g.getErrorCorrectPolynomial(c),B=new l(s[h],E.getLength()-1),T=B.mod(E);d[h]=new Array(E.getLength()-1);for(var m=0;m<d[h].length;m++){var _=m+T.getLength()-d[h].length;d[h][m]=_>=0?T.get(_):0}}for(var P=0,m=0;m<t.length;m++)P+=t[m].totalCount;for(var C=new Array(P),L=0,m=0;m<o;m++)for(var h=0;h<t.length;h++)m<s[h].length&&(C[L++]=s[h][m]);for(var m=0;m<i;m++)for(var h=0;h<t.length;h++)m<d[h].length&&(C[L++]=d[h][m]);return C},q=r,q}var A={},Z;function pe(){if(Z)return A;Z=1,Object.defineProperty(A,"__esModule",{value:!0});var v=Object.assign||function(e){for(var o=1;o<arguments.length;o++){var i=arguments[o];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s])}return e},f=ee(),a=r(f),g=V(),l=r(g);function r(e){return e&&e.__esModule?e:{default:e}}function u(e,o){var i={};for(var s in e)o.indexOf(s)>=0||Object.prototype.hasOwnProperty.call(e,s)&&(i[s]=e[s]);return i}var n={bgColor:a.default.oneOfType([a.default.object,a.default.string]).isRequired,bgD:a.default.string.isRequired,fgColor:a.default.oneOfType([a.default.object,a.default.string]).isRequired,fgD:a.default.string.isRequired,size:a.default.number.isRequired,title:a.default.string,viewBoxSize:a.default.number.isRequired,xmlns:a.default.string},t=(0,g.forwardRef)(function(e,o){var i=e.bgColor,s=e.bgD,d=e.fgD,h=e.fgColor,p=e.size,c=e.title,m=e.viewBoxSize,E=e.xmlns,B=E===void 0?"http://www.w3.org/2000/svg":E,T=u(e,["bgColor","bgD","fgD","fgColor","size","title","viewBoxSize","xmlns"]);return l.default.createElement("svg",v({},T,{height:p,ref:o,viewBox:"0 0 "+m+" "+m,width:p,xmlns:B}),c?l.default.createElement("title",null,c):null,l.default.createElement("path",{d:s,fill:i}),l.default.createElement("path",{d,fill:h}))});return t.displayName="QRCodeSvg",t.propTypes=n,A.default=t,A}var j;function me(){if(j)return R;j=1,Object.defineProperty(R,"__esModule",{value:!0}),R.QRCode=void 0;var v=Object.assign||function(p){for(var c=1;c<arguments.length;c++){var m=arguments[c];for(var E in m)Object.prototype.hasOwnProperty.call(m,E)&&(p[E]=m[E])}return p},f=ee(),a=i(f),g=te(),l=i(g),r=de(),u=i(r),n=V(),t=i(n),e=pe(),o=i(e);function i(p){return p&&p.__esModule?p:{default:p}}function s(p,c){var m={};for(var E in p)c.indexOf(E)>=0||Object.prototype.hasOwnProperty.call(p,E)&&(m[E]=p[E]);return m}var d={bgColor:a.default.oneOfType([a.default.object,a.default.string]),fgColor:a.default.oneOfType([a.default.object,a.default.string]),level:a.default.string,size:a.default.number,value:a.default.string.isRequired},h=(0,n.forwardRef)(function(p,c){var m=p.bgColor,E=m===void 0?"#FFFFFF":m,B=p.fgColor,T=B===void 0?"#000000":B,_=p.level,P=_===void 0?"L":_,C=p.size,L=C===void 0?256:C,oe=p.value,ue=s(p,["bgColor","fgColor","level","size","value"]),D=new u.default(-1,l.default[P]);D.addData(oe),D.make();var w=D.modules;return t.default.createElement(o.default,v({},ue,{bgColor:E,bgD:w.map(function(y,b){return y.map(function(M,O){return M?"":"M "+O+" "+b+" l 1 0 0 1 -1 0 Z"}).join(" ")}).join(" "),fgColor:T,fgD:w.map(function(y,b){return y.map(function(M,O){return M?"M "+O+" "+b+" l 1 0 0 1 -1 0 Z":""}).join(" ")}).join(" "),ref:c,size:L,viewBoxSize:w.length}))});return R.QRCode=h,h.displayName="QRCode",h.propTypes=d,R.default=h,R}var ie=me();const ce=se(ie),Be=fe({__proto__:null,default:ce},[ie]);export{Be as i};
|
|
1
|
+
import{r as V,a as ee,g as se}from"./index-AZj-felF.js";function fe(v,f){for(var a=0;a<f.length;a++){const g=f[a];if(typeof g!="string"&&!Array.isArray(g)){for(const l in g)if(l!=="default"&&!(l in v)){const r=Object.getOwnPropertyDescriptor(g,l);r&&Object.defineProperty(v,l,r.get?r:{enumerable:!0,get:()=>g[l]})}}}return Object.freeze(Object.defineProperty(v,Symbol.toStringTag,{value:"Module"}))}var R={},N,G;function te(){return G||(G=1,N={L:1,M:0,Q:3,H:2}),N}var k,K;function re(){return K||(K=1,k={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8}),k}var I,U;function le(){if(U)return I;U=1;var v=re();function f(a){this.mode=v.MODE_8BIT_BYTE,this.data=a}return f.prototype={getLength:function(a){return this.data.length},write:function(a){for(var g=0;g<this.data.length;g++)a.put(this.data.charCodeAt(g),8)}},I=f,I}var x,F;function he(){if(F)return x;F=1;var v=te();function f(a,g){this.totalCount=a,this.dataCount=g}return f.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],f.getRSBlocks=function(a,g){var l=f.getRsBlockTable(a,g);if(l==null)throw new Error("bad rs block @ typeNumber:"+a+"/errorCorrectLevel:"+g);for(var r=l.length/3,u=new Array,n=0;n<r;n++)for(var t=l[n*3+0],e=l[n*3+1],o=l[n*3+2],i=0;i<t;i++)u.push(new f(e,o));return u},f.getRsBlockTable=function(a,g){switch(g){case v.L:return f.RS_BLOCK_TABLE[(a-1)*4+0];case v.M:return f.RS_BLOCK_TABLE[(a-1)*4+1];case v.Q:return f.RS_BLOCK_TABLE[(a-1)*4+2];case v.H:return f.RS_BLOCK_TABLE[(a-1)*4+3];default:return}},x=f,x}var S,X;function ve(){if(X)return S;X=1;function v(){this.buffer=new Array,this.length=0}return v.prototype={get:function(f){var a=Math.floor(f/8);return(this.buffer[a]>>>7-f%8&1)==1},put:function(f,a){for(var g=0;g<a;g++)this.putBit((f>>>a-g-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(f){var a=Math.floor(this.length/8);this.buffer.length<=a&&this.buffer.push(0),f&&(this.buffer[a]|=128>>>this.length%8),this.length++}},S=v,S}var Q,$;function ne(){if($)return Q;$=1;for(var v={glog:function(a){if(a<1)throw new Error("glog("+a+")");return v.LOG_TABLE[a]},gexp:function(a){for(;a<0;)a+=255;for(;a>=256;)a-=255;return v.EXP_TABLE[a]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},f=0;f<8;f++)v.EXP_TABLE[f]=1<<f;for(var f=8;f<256;f++)v.EXP_TABLE[f]=v.EXP_TABLE[f-4]^v.EXP_TABLE[f-5]^v.EXP_TABLE[f-6]^v.EXP_TABLE[f-8];for(var f=0;f<255;f++)v.LOG_TABLE[v.EXP_TABLE[f]]=f;return Q=v,Q}var H,Y;function ae(){if(Y)return H;Y=1;var v=ne();function f(a,g){if(a.length==null)throw new Error(a.length+"/"+g);for(var l=0;l<a.length&&a[l]==0;)l++;this.num=new Array(a.length-l+g);for(var r=0;r<a.length-l;r++)this.num[r]=a[r+l]}return f.prototype={get:function(a){return this.num[a]},getLength:function(){return this.num.length},multiply:function(a){for(var g=new Array(this.getLength()+a.getLength()-1),l=0;l<this.getLength();l++)for(var r=0;r<a.getLength();r++)g[l+r]^=v.gexp(v.glog(this.get(l))+v.glog(a.get(r)));return new f(g,0)},mod:function(a){if(this.getLength()-a.getLength()<0)return this;for(var g=v.glog(this.get(0))-v.glog(a.get(0)),l=new Array(this.getLength()),r=0;r<this.getLength();r++)l[r]=this.get(r);for(var r=0;r<a.getLength();r++)l[r]^=v.gexp(v.glog(a.get(r))+g);return new f(l,0).mod(a)}},H=f,H}var z,J;function ge(){if(J)return z;J=1;var v=re(),f=ae(),a=ne(),g={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},l={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(r){for(var u=r<<10;l.getBCHDigit(u)-l.getBCHDigit(l.G15)>=0;)u^=l.G15<<l.getBCHDigit(u)-l.getBCHDigit(l.G15);return(r<<10|u)^l.G15_MASK},getBCHTypeNumber:function(r){for(var u=r<<12;l.getBCHDigit(u)-l.getBCHDigit(l.G18)>=0;)u^=l.G18<<l.getBCHDigit(u)-l.getBCHDigit(l.G18);return r<<12|u},getBCHDigit:function(r){for(var u=0;r!=0;)u++,r>>>=1;return u},getPatternPosition:function(r){return l.PATTERN_POSITION_TABLE[r-1]},getMask:function(r,u,n){switch(r){case g.PATTERN000:return(u+n)%2==0;case g.PATTERN001:return u%2==0;case g.PATTERN010:return n%3==0;case g.PATTERN011:return(u+n)%3==0;case g.PATTERN100:return(Math.floor(u/2)+Math.floor(n/3))%2==0;case g.PATTERN101:return u*n%2+u*n%3==0;case g.PATTERN110:return(u*n%2+u*n%3)%2==0;case g.PATTERN111:return(u*n%3+(u+n)%2)%2==0;default:throw new Error("bad maskPattern:"+r)}},getErrorCorrectPolynomial:function(r){for(var u=new f([1],0),n=0;n<r;n++)u=u.multiply(new f([1,a.gexp(n)],0));return u},getLengthInBits:function(r,u){if(1<=u&&u<10)switch(r){case v.MODE_NUMBER:return 10;case v.MODE_ALPHA_NUM:return 9;case v.MODE_8BIT_BYTE:return 8;case v.MODE_KANJI:return 8;default:throw new Error("mode:"+r)}else if(u<27)switch(r){case v.MODE_NUMBER:return 12;case v.MODE_ALPHA_NUM:return 11;case v.MODE_8BIT_BYTE:return 16;case v.MODE_KANJI:return 10;default:throw new Error("mode:"+r)}else if(u<41)switch(r){case v.MODE_NUMBER:return 14;case v.MODE_ALPHA_NUM:return 13;case v.MODE_8BIT_BYTE:return 16;case v.MODE_KANJI:return 12;default:throw new Error("mode:"+r)}else throw new Error("type:"+u)},getLostPoint:function(r){for(var u=r.getModuleCount(),n=0,t=0;t<u;t++)for(var e=0;e<u;e++){for(var o=0,i=r.isDark(t,e),s=-1;s<=1;s++)if(!(t+s<0||u<=t+s))for(var d=-1;d<=1;d++)e+d<0||u<=e+d||s==0&&d==0||i==r.isDark(t+s,e+d)&&o++;o>5&&(n+=3+o-5)}for(var t=0;t<u-1;t++)for(var e=0;e<u-1;e++){var h=0;r.isDark(t,e)&&h++,r.isDark(t+1,e)&&h++,r.isDark(t,e+1)&&h++,r.isDark(t+1,e+1)&&h++,(h==0||h==4)&&(n+=3)}for(var t=0;t<u;t++)for(var e=0;e<u-6;e++)r.isDark(t,e)&&!r.isDark(t,e+1)&&r.isDark(t,e+2)&&r.isDark(t,e+3)&&r.isDark(t,e+4)&&!r.isDark(t,e+5)&&r.isDark(t,e+6)&&(n+=40);for(var e=0;e<u;e++)for(var t=0;t<u-6;t++)r.isDark(t,e)&&!r.isDark(t+1,e)&&r.isDark(t+2,e)&&r.isDark(t+3,e)&&r.isDark(t+4,e)&&!r.isDark(t+5,e)&&r.isDark(t+6,e)&&(n+=40);for(var p=0,e=0;e<u;e++)for(var t=0;t<u;t++)r.isDark(t,e)&&p++;var c=Math.abs(100*p/u/u-50)/5;return n+=c*10,n}};return z=l,z}var q,W;function de(){if(W)return q;W=1;var v=le(),f=he(),a=ve(),g=ge(),l=ae();function r(n,t){this.typeNumber=n,this.errorCorrectLevel=t,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}var u=r.prototype;return u.addData=function(n){var t=new v(n);this.dataList.push(t),this.dataCache=null},u.isDark=function(n,t){if(n<0||this.moduleCount<=n||t<0||this.moduleCount<=t)throw new Error(n+","+t);return this.modules[n][t]},u.getModuleCount=function(){return this.moduleCount},u.make=function(){if(this.typeNumber<1){var n=1;for(n=1;n<40;n++){for(var t=f.getRSBlocks(n,this.errorCorrectLevel),e=new a,o=0,i=0;i<t.length;i++)o+=t[i].dataCount;for(var i=0;i<this.dataList.length;i++){var s=this.dataList[i];e.put(s.mode,4),e.put(s.getLength(),g.getLengthInBits(s.mode,n)),s.write(e)}if(e.getLengthInBits()<=o*8)break}this.typeNumber=n}this.makeImpl(!1,this.getBestMaskPattern())},u.makeImpl=function(n,t){this.moduleCount=this.typeNumber*4+17,this.modules=new Array(this.moduleCount);for(var e=0;e<this.moduleCount;e++){this.modules[e]=new Array(this.moduleCount);for(var o=0;o<this.moduleCount;o++)this.modules[e][o]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(n,t),this.typeNumber>=7&&this.setupTypeNumber(n),this.dataCache==null&&(this.dataCache=r.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,t)},u.setupPositionProbePattern=function(n,t){for(var e=-1;e<=7;e++)if(!(n+e<=-1||this.moduleCount<=n+e))for(var o=-1;o<=7;o++)t+o<=-1||this.moduleCount<=t+o||(0<=e&&e<=6&&(o==0||o==6)||0<=o&&o<=6&&(e==0||e==6)||2<=e&&e<=4&&2<=o&&o<=4?this.modules[n+e][t+o]=!0:this.modules[n+e][t+o]=!1)},u.getBestMaskPattern=function(){for(var n=0,t=0,e=0;e<8;e++){this.makeImpl(!0,e);var o=g.getLostPoint(this);(e==0||n>o)&&(n=o,t=e)}return t},u.createMovieClip=function(n,t,e){var o=n.createEmptyMovieClip(t,e),i=1;this.make();for(var s=0;s<this.modules.length;s++)for(var d=s*i,h=0;h<this.modules[s].length;h++){var p=h*i,c=this.modules[s][h];c&&(o.beginFill(0,100),o.moveTo(p,d),o.lineTo(p+i,d),o.lineTo(p+i,d+i),o.lineTo(p,d+i),o.endFill())}return o},u.setupTimingPattern=function(){for(var n=8;n<this.moduleCount-8;n++)this.modules[n][6]==null&&(this.modules[n][6]=n%2==0);for(var t=8;t<this.moduleCount-8;t++)this.modules[6][t]==null&&(this.modules[6][t]=t%2==0)},u.setupPositionAdjustPattern=function(){for(var n=g.getPatternPosition(this.typeNumber),t=0;t<n.length;t++)for(var e=0;e<n.length;e++){var o=n[t],i=n[e];if(this.modules[o][i]==null)for(var s=-2;s<=2;s++)for(var d=-2;d<=2;d++)s==-2||s==2||d==-2||d==2||s==0&&d==0?this.modules[o+s][i+d]=!0:this.modules[o+s][i+d]=!1}},u.setupTypeNumber=function(n){for(var t=g.getBCHTypeNumber(this.typeNumber),e=0;e<18;e++){var o=!n&&(t>>e&1)==1;this.modules[Math.floor(e/3)][e%3+this.moduleCount-8-3]=o}for(var e=0;e<18;e++){var o=!n&&(t>>e&1)==1;this.modules[e%3+this.moduleCount-8-3][Math.floor(e/3)]=o}},u.setupTypeInfo=function(n,t){for(var e=this.errorCorrectLevel<<3|t,o=g.getBCHTypeInfo(e),i=0;i<15;i++){var s=!n&&(o>>i&1)==1;i<6?this.modules[i][8]=s:i<8?this.modules[i+1][8]=s:this.modules[this.moduleCount-15+i][8]=s}for(var i=0;i<15;i++){var s=!n&&(o>>i&1)==1;i<8?this.modules[8][this.moduleCount-i-1]=s:i<9?this.modules[8][15-i-1+1]=s:this.modules[8][15-i-1]=s}this.modules[this.moduleCount-8][8]=!n},u.mapData=function(n,t){for(var e=-1,o=this.moduleCount-1,i=7,s=0,d=this.moduleCount-1;d>0;d-=2)for(d==6&&d--;;){for(var h=0;h<2;h++)if(this.modules[o][d-h]==null){var p=!1;s<n.length&&(p=(n[s]>>>i&1)==1);var c=g.getMask(t,o,d-h);c&&(p=!p),this.modules[o][d-h]=p,i--,i==-1&&(s++,i=7)}if(o+=e,o<0||this.moduleCount<=o){o-=e,e=-e;break}}},r.PAD0=236,r.PAD1=17,r.createData=function(n,t,e){for(var o=f.getRSBlocks(n,t),i=new a,s=0;s<e.length;s++){var d=e[s];i.put(d.mode,4),i.put(d.getLength(),g.getLengthInBits(d.mode,n)),d.write(i)}for(var h=0,s=0;s<o.length;s++)h+=o[s].dataCount;if(i.getLengthInBits()>h*8)throw new Error("code length overflow. ("+i.getLengthInBits()+">"+h*8+")");for(i.getLengthInBits()+4<=h*8&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=h*8||(i.put(r.PAD0,8),i.getLengthInBits()>=h*8));)i.put(r.PAD1,8);return r.createBytes(i,o)},r.createBytes=function(n,t){for(var e=0,o=0,i=0,s=new Array(t.length),d=new Array(t.length),h=0;h<t.length;h++){var p=t[h].dataCount,c=t[h].totalCount-p;o=Math.max(o,p),i=Math.max(i,c),s[h]=new Array(p);for(var m=0;m<s[h].length;m++)s[h][m]=255&n.buffer[m+e];e+=p;var E=g.getErrorCorrectPolynomial(c),B=new l(s[h],E.getLength()-1),T=B.mod(E);d[h]=new Array(E.getLength()-1);for(var m=0;m<d[h].length;m++){var _=m+T.getLength()-d[h].length;d[h][m]=_>=0?T.get(_):0}}for(var P=0,m=0;m<t.length;m++)P+=t[m].totalCount;for(var C=new Array(P),L=0,m=0;m<o;m++)for(var h=0;h<t.length;h++)m<s[h].length&&(C[L++]=s[h][m]);for(var m=0;m<i;m++)for(var h=0;h<t.length;h++)m<d[h].length&&(C[L++]=d[h][m]);return C},q=r,q}var A={},Z;function pe(){if(Z)return A;Z=1,Object.defineProperty(A,"__esModule",{value:!0});var v=Object.assign||function(e){for(var o=1;o<arguments.length;o++){var i=arguments[o];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s])}return e},f=ee(),a=r(f),g=V(),l=r(g);function r(e){return e&&e.__esModule?e:{default:e}}function u(e,o){var i={};for(var s in e)o.indexOf(s)>=0||Object.prototype.hasOwnProperty.call(e,s)&&(i[s]=e[s]);return i}var n={bgColor:a.default.oneOfType([a.default.object,a.default.string]).isRequired,bgD:a.default.string.isRequired,fgColor:a.default.oneOfType([a.default.object,a.default.string]).isRequired,fgD:a.default.string.isRequired,size:a.default.number.isRequired,title:a.default.string,viewBoxSize:a.default.number.isRequired,xmlns:a.default.string},t=(0,g.forwardRef)(function(e,o){var i=e.bgColor,s=e.bgD,d=e.fgD,h=e.fgColor,p=e.size,c=e.title,m=e.viewBoxSize,E=e.xmlns,B=E===void 0?"http://www.w3.org/2000/svg":E,T=u(e,["bgColor","bgD","fgD","fgColor","size","title","viewBoxSize","xmlns"]);return l.default.createElement("svg",v({},T,{height:p,ref:o,viewBox:"0 0 "+m+" "+m,width:p,xmlns:B}),c?l.default.createElement("title",null,c):null,l.default.createElement("path",{d:s,fill:i}),l.default.createElement("path",{d,fill:h}))});return t.displayName="QRCodeSvg",t.propTypes=n,A.default=t,A}var j;function me(){if(j)return R;j=1,Object.defineProperty(R,"__esModule",{value:!0}),R.QRCode=void 0;var v=Object.assign||function(p){for(var c=1;c<arguments.length;c++){var m=arguments[c];for(var E in m)Object.prototype.hasOwnProperty.call(m,E)&&(p[E]=m[E])}return p},f=ee(),a=i(f),g=te(),l=i(g),r=de(),u=i(r),n=V(),t=i(n),e=pe(),o=i(e);function i(p){return p&&p.__esModule?p:{default:p}}function s(p,c){var m={};for(var E in p)c.indexOf(E)>=0||Object.prototype.hasOwnProperty.call(p,E)&&(m[E]=p[E]);return m}var d={bgColor:a.default.oneOfType([a.default.object,a.default.string]),fgColor:a.default.oneOfType([a.default.object,a.default.string]),level:a.default.string,size:a.default.number,value:a.default.string.isRequired},h=(0,n.forwardRef)(function(p,c){var m=p.bgColor,E=m===void 0?"#FFFFFF":m,B=p.fgColor,T=B===void 0?"#000000":B,_=p.level,P=_===void 0?"L":_,C=p.size,L=C===void 0?256:C,oe=p.value,ue=s(p,["bgColor","fgColor","level","size","value"]),D=new u.default(-1,l.default[P]);D.addData(oe),D.make();var w=D.modules;return t.default.createElement(o.default,v({},ue,{bgColor:E,bgD:w.map(function(y,b){return y.map(function(M,O){return M?"":"M "+O+" "+b+" l 1 0 0 1 -1 0 Z"}).join(" ")}).join(" "),fgColor:T,fgD:w.map(function(y,b){return y.map(function(M,O){return M?"M "+O+" "+b+" l 1 0 0 1 -1 0 Z":""}).join(" ")}).join(" "),ref:c,size:L,viewBoxSize:w.length}))});return R.QRCode=h,h.displayName="QRCode",h.propTypes=d,R.default=h,R}var ie=me();const ce=se(ie),Be=fe({__proto__:null,default:ce},[ie]);export{Be as i};
|
package/admin/index_m.html
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
/>
|
|
21
21
|
<script type="text/javascript" onerror="setTimeout(function(){window.location.reload()}, 5000)" src="./lib/js/socket.io.js"></script>
|
|
22
22
|
<title>Modbus</title>
|
|
23
|
-
<script type="module" crossorigin src="./assets/index-
|
|
23
|
+
<script type="module" crossorigin src="./assets/index-AZj-felF.js"></script>
|
|
24
24
|
<link rel="stylesheet" crossorigin href="./assets/index-Bk6U_LJW.css">
|
|
25
25
|
</head>
|
|
26
26
|
<body>
|
package/io-package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "modbus",
|
|
4
|
-
"version": "7.0.
|
|
4
|
+
"version": "7.0.4",
|
|
5
5
|
"news": {
|
|
6
|
-
"7.0.
|
|
7
|
-
"en": "Added migration procedure from 6 to 7",
|
|
8
|
-
"de": "Zusätzlicher Migrationsvorgang von 6 bis 7",
|
|
9
|
-
"ru": "Процедура миграции с 6 до 7",
|
|
10
|
-
"pt": "Procedimento de migração adicional de 6 a 7",
|
|
11
|
-
"nl": "Toegevoegde migratieprocedure van 6 tot 7",
|
|
12
|
-
"fr": "Procédure de migration ajoutée de 6 à 7",
|
|
13
|
-
"it": "Procedura di migrazione aggiuntiva da 6 a 7",
|
|
14
|
-
"es": "Procedimiento de migración adicional de 6 a 7",
|
|
15
|
-
"pl": "Dodano procedurę migracji od 6 do 7",
|
|
16
|
-
"uk": "Додано процедуру міграції від 6 до 7",
|
|
17
|
-
"zh-cn": "将移徙程序从6增加到7"
|
|
6
|
+
"7.0.4": {
|
|
7
|
+
"en": "Added migration procedure from 6 to 7\nCorrected serial communication",
|
|
8
|
+
"de": "Zusätzlicher Migrationsvorgang von 6 bis 7\nKorrigierte serielle Kommunikation",
|
|
9
|
+
"ru": "Процедура миграции с 6 до 7\nИсправленная серийная связь",
|
|
10
|
+
"pt": "Procedimento de migração adicional de 6 a 7\nComunicação em série corrigida",
|
|
11
|
+
"nl": "Toegevoegde migratieprocedure van 6 tot 7\nGecorrigeerde seriecommunicatie",
|
|
12
|
+
"fr": "Procédure de migration ajoutée de 6 à 7\nCommunication série corrigée",
|
|
13
|
+
"it": "Procedura di migrazione aggiuntiva da 6 a 7\nComunicazione seriale corretta",
|
|
14
|
+
"es": "Procedimiento de migración adicional de 6 a 7\nComunicación en serie corregida",
|
|
15
|
+
"pl": "Dodano procedurę migracji od 6 do 7\nSkorygowana komunikacja szeregowa",
|
|
16
|
+
"uk": "Додано процедуру міграції від 6 до 7\nВиправлено послідовне спілкування",
|
|
17
|
+
"zh-cn": "将移徙程序从6增加到7\n更正的系列通信"
|
|
18
18
|
},
|
|
19
19
|
"7.0.1": {
|
|
20
20
|
"en": "Redesign of the configuration tabs\nAdded option to remove leading underscores in the object names",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iobroker.modbus",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.4",
|
|
4
4
|
"description": "Connect devices oder Modbus protocol to ioBroker",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "bluefox",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"serialport": "^13.0.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@iobroker/modbus": "^7.0.
|
|
34
|
+
"@iobroker/modbus": "^7.0.20"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@alcalzone/release-script": "^3.8.0",
|