iobroker.eos-admin 7.9.40 → 7.9.41
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/adminWww/assets/Adapters-B5_jQ7DE.js +2 -2
- package/adminWww/assets/Instances-YdaGnS5a.js +1 -1
- package/adminWww/assets/Objects-DPan0bzw.js +1 -1
- package/adminWww/assets/index-D2ymscJA.js +1 -1
- package/adminWww/js/eos-branding.js +12 -13
- package/adminWww/js/eos-objects-state-tools.js +10 -5
- package/adminWww/js/eos-security-ui.js +33 -23
- package/build/lib/web.js +9 -1
- package/build/main.js +13 -2
- package/docs/NEXOWATT_EOS_BRANDING_DE.md +29 -29
- package/docs/NEXOWATT_EOS_UI_LOGO_LOGIN_V6_DE.md +9 -9
- package/docs/NEXOWATT_EOS_UI_PERFORMANCE_V5_DE.md +25 -25
- package/docs/NEXOWATT_EOS_UI_V12_HEADER_LOGO_NAV_CLEANUP_DE.md +16 -16
- package/docs/NEXOWATT_EOS_UI_V12_HEADER_NAV_LOGO_FIX_DE.md +16 -16
- package/docs/NEXOWATT_EOS_UI_V15_DE.md +8 -8
- package/docs/NEXOWATT_EOS_UI_V16_DE.md +9 -9
- package/docs/NEXOWATT_EOS_UI_V17_DE.md +24 -24
- package/docs/NEXOWATT_EOS_UI_V6_FIXES_DE.md +13 -13
- package/docs/NEXOWATT_EOS_UI_V6_LOGIN_LOGO_404_FIX_DE.md +9 -9
- package/docs/NEXOWATT_EOS_UI_V6_LOGO_LOGIN_FIX_DE.md +10 -10
- package/docs/NEXOWATT_EOS_UI_V7_RESTORE_LOGO_SCOPE_FIX_DE.md +18 -18
- package/io-package.json +18 -4
- package/package.json +1 -1
|
@@ -36,7 +36,7 @@ yyyy`);var i=Mo(e),n=t?"getUTC":"get",r=i[n+"FullYear"](),o=i[n+"Month"]()+1,a=i
|
|
|
36
36
|
`:"";function i(n){var r=n.children,o=n.tag,a=n.attrs,l=n.text;return nme(o,a)+(o!=="style"?Cs(l):l||"")+(r?""+t+Ne(r,function(h){return i(h)}).join(t)+t:"")+sme(o)}return i(s)}function rme(s,e,t){t=t||{};var i=t.newline?`
|
|
37
37
|
`:"",n=" {"+i,r=i+"}",o=Ne(Gt(s),function(l){return l+n+Ne(Gt(s[l]),function(h){return h+":"+s[l][h]+";"}).join(i)+r}).join(i),a=Ne(Gt(e),function(l){return"@keyframes "+l+n+Ne(Gt(e[l]),function(h){return h+n+Ne(Gt(e[l][h]),function(c){var u=e[l][h][c];return c==="d"&&(u='path("'+u+'")'),c+":"+u+";"}).join(i)+r}).join(i)+r}).join(i);return!o&&!a?"":["<![CDATA[",o,a,"]]>"].join(i)}function VN(s){return{zrId:s,shadowCache:{},patternCache:{},gradientCache:{},clipPathCache:{},defs:{},cssNodes:{},cssAnims:{},cssStyleCache:{},cssAnimIdx:0,shadowIdx:0,gradientIdx:0,patternIdx:0,clipPathIdx:0}}function QB(s,e,t,i){return yn("svg","root",{width:s,height:e,xmlns:WY,"xmlns:xlink":HY,version:"1.1",baseProfile:"full",viewBox:i?"0 0 "+s+" "+e:!1},t)}var ome=0;function jY(){return ome++}var JB={cubicIn:"0.32,0,0.67,0",cubicOut:"0.33,1,0.68,1",cubicInOut:"0.65,0,0.35,1",quadraticIn:"0.11,0,0.5,0",quadraticOut:"0.5,1,0.89,1",quadraticInOut:"0.45,0,0.55,1",quarticIn:"0.5,0,0.75,0",quarticOut:"0.25,1,0.5,1",quarticInOut:"0.76,0,0.24,1",quinticIn:"0.64,0,0.78,0",quinticOut:"0.22,1,0.36,1",quinticInOut:"0.83,0,0.17,1",sinusoidalIn:"0.12,0,0.39,0",sinusoidalOut:"0.61,1,0.88,1",sinusoidalInOut:"0.37,0,0.63,1",exponentialIn:"0.7,0,0.84,0",exponentialOut:"0.16,1,0.3,1",exponentialInOut:"0.87,0,0.13,1",circularIn:"0.55,0,1,0.45",circularOut:"0,0.55,0.45,1",circularInOut:"0.85,0,0.15,1"},ld="transform-origin";function ame(s,e,t){var i=we({},s.shape);we(i,e),s.buildPath(t,i);var n=new VY;return n.reset(Y$(s)),t.rebuildPath(n,1),n.generateStr(),n.getStr()}function lme(s,e){var t=e.originX,i=e.originY;(t||i)&&(s[ld]=t+"px "+i+"px")}var hme={fill:"fill",opacity:"opacity",lineWidth:"stroke-width",lineDashOffset:"stroke-dashoffset"};function UY(s,e){var t=e.zrId+"-ani-"+e.cssAnimIdx++;return e.cssAnims[t]=s,t}function cme(s,e,t){var i=s.shape.paths,n={},r,o;if(V(i,function(l){var h=VN(t.zrId);h.animation=!0,dD(l,{},h,!0);var c=h.cssAnims,u=h.cssNodes,d=Gt(c),f=d.length;if(f){o=d[f-1];var g=c[o];for(var p in g){var m=g[p];n[p]=n[p]||{d:""},n[p].d+=m.d||""}for(var v in u){var _=u[v].animation;_.indexOf(o)>=0&&(r=_)}}}),!!r){e.d=!1;var a=UY(n,t);return r.replace(o,a)}}function eV(s){return Be(s)?JB[s]?"cubic-bezier("+JB[s]+")":c5(s)?s:"":""}function dD(s,e,t,i){var n=s.animators,r=n.length,o=[];if(s instanceof k5){var a=cme(s,e,t);if(a)o.push(a);else if(!r)return}else if(!r)return;for(var l={},h=0;h<r;h++){var c=n[h],u=[c.getMaxTime()/1e3+"s"],d=eV(c.getClip().easing),f=c.getDelay();d?u.push(d):u.push("linear"),f&&u.push(f/1e3+"s"),c.getLoop()&&u.push("infinite");var g=u.join(" ");l[g]=l[g]||[g,[]],l[g][1].push(c)}function p(_){var b=_[1],y=b.length,C={},x={},S={},k="animation-timing-function";function T(tt,st,ve){for(var ge=tt.getTracks(),Oe=tt.getMaxTime(),Ci=0;Ci<ge.length;Ci++){var Ht=ge[Ci];if(Ht.needsAnimate()){var In=Ht.keyframes,Ms=Ht.propName;if(ve&&(Ms=ve(Ms)),Ms)for(var ir=0;ir<In.length;ir++){var Or=In[ir],lo=Math.round(Or.time/Oe*100)+"%",ic=eV(Or.easing),nc=Or.rawValue;(Be(nc)||ki(nc))&&(st[lo]=st[lo]||{},st[lo][Ms]=Or.rawValue,ic&&(st[lo][k]=ic))}}}}for(var I=0;I<y;I++){var N=b[I],A=N.targetName;A?A==="shape"&&T(N,x):!i&&T(N,C)}for(var R in C){var P={};eG(P,s),we(P,C[R]);var B=X$(P),z=C[R][k];S[R]=B?{transform:B}:{},lme(S[R],P),z&&(S[R][k]=z)}var U,K=!0;for(var R in x){S[R]=S[R]||{};var X=!U,z=x[R][k];X&&(U=new hu);var ne=U.len();U.reset(),S[R].d=ame(s,x[R],U);var oe=U.len();if(!X&&ne!==oe){K=!1;break}z&&(S[R][k]=z)}if(!K)for(var R in S)delete S[R].d;if(!i)for(var I=0;I<y;I++){var N=b[I],A=N.targetName;A==="style"&&T(N,S,function(ge){return hme[ge]})}for(var ue=Gt(S),de=!0,De,I=1;I<ue.length;I++){var Q=ue[I-1],Xe=ue[I];if(S[Q][ld]!==S[Xe][ld]){de=!1;break}De=S[Q][ld]}if(de&&De){for(var R in S)S[R][ld]&&delete S[R][ld];e[ld]=De}if(Xi(ue,function(tt){return Gt(S[tt]).length>0}).length){var Pe=UY(S,t);return Pe+" "+_[0]+" both"}}for(var m in l){var a=p(l[m]);a&&o.push(a)}if(o.length){var v=t.zrId+"-cls-"+jY();t.cssNodes["."+v]={animation:o.join(",")},e.class=v}}function ume(s,e,t){if(!s.ignore)if(s.isSilent()){var i={"pointer-events":"none"};tV(i,e,t)}else{var n=s.states.emphasis&&s.states.emphasis.style?s.states.emphasis.style:{},r=n.fill;if(!r){var o=s.style&&s.style.fill,a=s.states.select&&s.states.select.style&&s.states.select.style.fill,l=s.currentStates.indexOf("select")>=0&&a||o;l&&(r=SS(l))}var h=n.lineWidth;if(h){var c=!n.strokeNoScale&&s.transform?s.transform[0]:1;h=h/c}var i={cursor:"pointer"};r&&(i.fill=r),n.stroke&&(i.stroke=n.stroke),h&&(i["stroke-width"]=h),tV(i,e,t)}}function tV(s,e,t,i){var n=JSON.stringify(s),r=t.cssStyleCache[n];r||(r=t.zrId+"-cls-"+jY(),t.cssStyleCache[n]=r,t.cssNodes["."+r+":hover"]=s),e.class=e.class?e.class+" "+r:r}var Ob=Math.round;function $Y(s){return s&&Be(s.src)}function GY(s){return s&&ut(s.toDataURL)}function I4(s,e,t,i){eme(function(n,r){var o=n==="fill"||n==="stroke";o&&K$(r)?KY(e,s,n,i):o&&d5(r)?YY(t,s,n,i):s[n]=r,o&&i.ssr&&r==="none"&&(s["pointer-events"]="visible")},e,t,!1),_me(t,s,i)}function E4(s,e){var t=sG(e);t&&(t.each(function(i,n){i!=null&&(s[(ZB+n).toLowerCase()]=i+"")}),e.isSilent()&&(s[ZB+"silent"]="true"))}function iV(s){return Oc(s[0]-1)&&Oc(s[1])&&Oc(s[2])&&Oc(s[3]-1)}function dme(s){return Oc(s[4])&&Oc(s[5])}function N4(s,e,t){if(e&&!(dme(e)&&iV(e))){var i=1e4;s.transform=iV(e)?"translate("+Ob(e[4]*i)/i+" "+Ob(e[5]*i)/i+")":xse(e)}}function nV(s,e,t){for(var i=s.points,n=[],r=0;r<i.length;r++)n.push(Ob(i[r][0]*t)/t),n.push(Ob(i[r][1]*t)/t);e.points=n.join(" ")}function sV(s){return!s.smooth}function fme(s){var e=Ne(s,function(t){return typeof t=="string"?[t,t]:t});return function(t,i,n){for(var r=0;r<e.length;r++){var o=e[r],a=t[o[0]];a!=null&&(i[o[1]]=Ob(a*n)/n)}}}var gme={circle:[fme(["cx","cy","r"])],polyline:[nV,sV],polygon:[nV,sV]};function pme(s){for(var e=s.animators,t=0;t<e.length;t++)if(e[t].targetName==="shape")return!0;return!1}function qY(s,e){var t=s.style,i=s.shape,n=gme[s.type],r={},o=e.animation,a="path",l=s.style.strokePercent,h=e.compress&&Y$(s)||4;if(n&&!e.willUpdate&&!(n[1]&&!n[1](i))&&!(o&&pme(s))&&!(l<1)){a=s.type;var c=Math.pow(10,h);n[0](i,r,c)}else{var u=!s.path||s.shapeChanged();s.path||s.createPathProxy();var d=s.path;u&&(d.beginPath(),s.buildPath(d,s.shape),s.pathUpdated());var f=d.getVersion(),g=s,p=g.__svgPathBuilder;(g.__svgPathVersion!==f||!p||l!==g.__svgPathStrokePercent)&&(p||(p=g.__svgPathBuilder=new VY),p.reset(h),d.rebuildPath(p,l),p.generateStr(),g.__svgPathVersion=f,g.__svgPathStrokePercent=l),r.d=p.getStr()}return N4(r,s.transform),I4(r,t,s,e),E4(r,s),e.animation&&dD(s,r,e),e.emphasis&&ume(s,r,e),yn(a,s.id+"",r)}function mme(s,e){var t=s.style,i=t.image;if(i&&!Be(i)&&($Y(i)?i=i.src:GY(i)&&(i=i.toDataURL())),!!i){var n=t.x||0,r=t.y||0,o=t.width,a=t.height,l={href:i,width:o,height:a};return n&&(l.x=n),r&&(l.y=r),N4(l,s.transform),I4(l,t,s,e),E4(l,s),e.animation&&dD(s,l,e),yn("image",s.id+"",l)}}function vme(s,e){var t=s.style,i=t.text;if(i!=null&&(i+=""),!(!i||isNaN(t.x)||isNaN(t.y))){var n=t.font||ou,r=t.x||0,o=kse(t.y||0,Rk(n),t.textBaseline),a=Lse[t.textAlign]||t.textAlign,l={"dominant-baseline":"central","text-anchor":a};if(DG(t)){var h="",c=t.fontStyle,u=kG(t.fontSize);if(!parseFloat(u))return;var d=t.fontFamily||_$,f=t.fontWeight;h+="font-size:"+u+";font-family:"+d+";",c&&c!=="normal"&&(h+="font-style:"+c+";"),f&&f!=="normal"&&(h+="font-weight:"+f+";"),l.style=h}else l.style="font: "+n;return i.match(/\s/)&&(l["xml:space"]="preserve"),r&&(l.x=r),o&&(l.y=o),N4(l,s.transform),I4(l,t,s,e),E4(l,s),e.animation&&dD(s,l,e),yn("text",s.id+"",l,void 0,i)}}function rV(s,e){if(s instanceof hi)return qY(s,e);if(s instanceof La)return mme(s,e);if(s instanceof Lb)return vme(s,e)}function _me(s,e,t){var i=s.style;if(Dse(i)){var n=Tse(s),r=t.shadowCache,o=r[n];if(!o){var a=s.getGlobalScale(),l=a[0],h=a[1];if(!l||!h)return;var c=i.shadowOffsetX||0,u=i.shadowOffsetY||0,d=i.shadowBlur,f=bb(i.shadowColor),g=f.opacity,p=f.color,m=d/2/l,v=d/2/h,_=m+" "+v;o=t.zrId+"-s"+t.shadowIdx++,t.defs[o]=yn("filter",o,{id:o,x:"-100%",y:"-100%",width:"300%",height:"300%"},[yn("feDropShadow","",{dx:c/l,dy:u/h,stdDeviation:_,"flood-color":p,"flood-opacity":g})]),r[n]=o}e.filter=Mk(o)}}function KY(s,e,t,i){var n=s[t],r,o={gradientUnits:n.global?"userSpaceOnUse":"objectBoundingBox"};if(G$(n))r="linearGradient",o.x1=n.x,o.y1=n.y,o.x2=n.x2,o.y2=n.y2;else if(q$(n))r="radialGradient",o.cx=ct(n.x,.5),o.cy=ct(n.y,.5),o.r=ct(n.r,.5);else return;for(var a=n.colorStops,l=[],h=0,c=a.length;h<c;++h){var u=VE(a[h].offset)*100+"%",d=a[h].color,f=bb(d),g=f.color,p=f.opacity,m={offset:u};m["stop-color"]=g,p<1&&(m["stop-opacity"]=p),l.push(yn("stop",h+"",m))}var v=yn(r,"",o,l),_=T4(v),b=i.gradientCache,y=b[_];y||(y=i.zrId+"-g"+i.gradientIdx++,b[_]=y,o.id=y,i.defs[y]=yn(r,y,o,l)),e[t]=Mk(y)}function YY(s,e,t,i){var n=s.style[t],r=s.getBoundingRect(),o={},a=n.repeat,l=a==="no-repeat",h=a==="repeat-x",c=a==="repeat-y",u;if($$(n)){var d=n.imageWidth,f=n.imageHeight,g=void 0,p=n.image;if(Be(p)?g=p:$Y(p)?g=p.src:GY(p)&&(g=p.toDataURL()),typeof Image>"u"){var m="Image width/height must been given explictly in svg-ssr renderer.";ro(d,m),ro(f,m)}else if(d==null||f==null){var v=function(I,N){if(I){var A=I.elm,R=d||N.width,P=f||N.height;I.tag==="pattern"&&(h?(P=1,R/=r.width):c&&(R=1,P/=r.height)),I.attrs.width=R,I.attrs.height=P,A&&(A.setAttribute("width",R),A.setAttribute("height",P))}},_=y5(g,null,s,function(I){l||v(x,I),v(u,I)});_&&_.width&&_.height&&(d=d||_.width,f=f||_.height)}u=yn("image","img",{href:g,width:d,height:f}),o.width=d,o.height=f}else n.svgElement&&(u=mt(n.svgElement),o.width=n.svgWidth,o.height=n.svgHeight);if(u){var b,y;l?b=y=1:h?(y=1,b=o.width/r.width):c?(b=1,y=o.height/r.height):o.patternUnits="userSpaceOnUse",b!=null&&!isNaN(b)&&(o.width=b),y!=null&&!isNaN(y)&&(o.height=y);var C=X$(n);C&&(o.patternTransform=C);var x=yn("pattern","",o,[u]),S=T4(x),k=i.patternCache,T=k[S];T||(T=i.zrId+"-p"+i.patternIdx++,k[S]=T,o.id=T,x=i.defs[T]=yn("pattern",T,o,[u])),e[t]=Mk(T)}}function bme(s,e,t){var i=t.clipPathCache,n=t.defs,r=i[s.id];if(!r){r=t.zrId+"-c"+t.clipPathIdx++;var o={id:r};i[s.id]=r,n[r]=yn("clipPath",r,o,[qY(s,t)])}e["clip-path"]=Mk(r)}function oV(s){return document.createTextNode(s)}function _d(s,e,t){s.insertBefore(e,t)}function aV(s,e){s.removeChild(e)}function lV(s,e){s.appendChild(e)}function XY(s){return s.parentNode}function ZY(s){return s.nextSibling}function q2(s,e){s.textContent=e}var hV=58,wme=120,yme=yn("","");function WN(s){return s===void 0}function Ya(s){return s!==void 0}function Cme(s,e,t){for(var i={},n=e;n<=t;++n){var r=s[n].key;r!==void 0&&(i[r]=n)}return i}function z_(s,e){var t=s.key===e.key,i=s.tag===e.tag;return i&&t}function Fb(s){var e,t=s.children,i=s.tag;if(Ya(i)){var n=s.elm=zY(i);if(M4(yme,s),Me(t))for(e=0;e<t.length;++e){var r=t[e];r!=null&&lV(n,Fb(r))}else Ya(s.text)&&!Ue(s.text)&&lV(n,oV(s.text))}else s.elm=oV(s.text);return s.elm}function QY(s,e,t,i,n){for(;i<=n;++i){var r=t[i];r!=null&&_d(s,Fb(r),e)}}function WS(s,e,t,i){for(;t<=i;++t){var n=e[t];if(n!=null)if(Ya(n.tag)){var r=XY(n.elm);aV(r,n.elm)}else aV(s,n.elm)}}function M4(s,e){var t,i=e.elm,n=s&&s.attrs||{},r=e.attrs||{};if(n!==r){for(t in r){var o=r[t],a=n[t];a!==o&&(o===!0?i.setAttribute(t,""):o===!1?i.removeAttribute(t):t==="style"?i.style.cssText=o:t.charCodeAt(0)!==wme?i.setAttribute(t,o):t==="xmlns:xlink"||t==="xmlns"?i.setAttributeNS(tme,t,o):t.charCodeAt(3)===hV?i.setAttributeNS(ime,t,o):t.charCodeAt(5)===hV?i.setAttributeNS(HY,t,o):i.setAttribute(t,o))}for(t in n)t in r||i.removeAttribute(t)}}function Sme(s,e,t){for(var i=0,n=0,r=e.length-1,o=e[0],a=e[r],l=t.length-1,h=t[0],c=t[l],u,d,f,g;i<=r&&n<=l;)o==null?o=e[++i]:a==null?a=e[--r]:h==null?h=t[++n]:c==null?c=t[--l]:z_(o,h)?(Cp(o,h),o=e[++i],h=t[++n]):z_(a,c)?(Cp(a,c),a=e[--r],c=t[--l]):z_(o,c)?(Cp(o,c),_d(s,o.elm,ZY(a.elm)),o=e[++i],c=t[--l]):z_(a,h)?(Cp(a,h),_d(s,a.elm,o.elm),a=e[--r],h=t[++n]):(WN(u)&&(u=Cme(e,i,r)),d=u[h.key],WN(d)?_d(s,Fb(h),o.elm):(f=e[d],f.tag!==h.tag?_d(s,Fb(h),o.elm):(Cp(f,h),e[d]=void 0,_d(s,f.elm,o.elm))),h=t[++n]);(i<=r||n<=l)&&(i>r?(g=t[l+1]==null?null:t[l+1].elm,QY(s,g,t,n,l)):WS(s,e,i,r))}function Cp(s,e){var t=e.elm=s.elm,i=s.children,n=e.children;s!==e&&(M4(s,e),WN(e.text)?Ya(i)&&Ya(n)?i!==n&&Sme(t,i,n):Ya(n)?(Ya(s.text)&&q2(t,""),QY(t,null,n,0,n.length-1)):Ya(i)?WS(t,i,0,i.length-1):Ya(s.text)&&q2(t,""):s.text!==e.text&&(Ya(i)&&WS(t,i,0,i.length-1),q2(t,e.text)))}function xme(s,e){if(z_(s,e))Cp(s,e);else{var t=s.elm,i=XY(t);Fb(e),i!==null&&(_d(i,e.elm,ZY(t)),WS(i,[s],0,0))}return e}var Lme=0,kme=(function(){function s(e,t,i){if(this.type="svg",this.refreshHover=cV(),this.configLayer=cV(),this.storage=t,this._opts=i=we({},i),this.root=e,this._id="zr"+Lme++,this._oldVNode=QB(i.width,i.height),e&&!i.ssr){var n=this._viewport=document.createElement("div");n.style.cssText="position:relative;overflow:hidden";var r=this._svgDom=this._oldVNode.elm=zY("svg");M4(null,this._oldVNode),n.appendChild(r),e.appendChild(n)}this.resize(i.width,i.height)}return s.prototype.getType=function(){return this.type},s.prototype.getViewportRoot=function(){return this._viewport},s.prototype.getViewportRootOffset=function(){var e=this.getViewportRoot();if(e)return{offsetLeft:e.offsetLeft||0,offsetTop:e.offsetTop||0}},s.prototype.getSvgDom=function(){return this._svgDom},s.prototype.refresh=function(){if(this.root){var e=this.renderToVNode({willUpdate:!0});e.attrs.style="position:absolute;left:0;top:0;user-select:none",xme(this._oldVNode,e),this._oldVNode=e}},s.prototype.renderOneToVNode=function(e){return rV(e,VN(this._id))},s.prototype.renderToVNode=function(e){e=e||{};var t=this.storage.getDisplayList(!0),i=this._width,n=this._height,r=VN(this._id);r.animation=e.animation,r.willUpdate=e.willUpdate,r.compress=e.compress,r.emphasis=e.emphasis,r.ssr=this._opts.ssr;var o=[],a=this._bgVNode=Dme(i,n,this._backgroundColor,r);a&&o.push(a);var l=e.compress?null:this._mainVNode=yn("g","main",{},[]);this._paintList(t,r,l?l.children:o),l&&o.push(l);var h=Ne(Gt(r.defs),function(d){return r.defs[d]});if(h.length&&o.push(yn("defs","defs",{},h)),e.animation){var c=rme(r.cssNodes,r.cssAnims,{newline:!0});if(c){var u=yn("style","stl",{},[],c);o.push(u)}}return QB(i,n,o,e.useViewBox)},s.prototype.renderToString=function(e){return e=e||{},T4(this.renderToVNode({animation:ct(e.cssAnimation,!0),emphasis:ct(e.cssEmphasis,!0),willUpdate:!1,compress:!0,useViewBox:ct(e.useViewBox,!0)}),{newline:!0})},s.prototype.setBackgroundColor=function(e){this._backgroundColor=e},s.prototype.getSvgRoot=function(){return this._mainVNode&&this._mainVNode.elm},s.prototype._paintList=function(e,t,i){for(var n=e.length,r=[],o=0,a,l,h=0,c=0;c<n;c++){var u=e[c];if(!u.invisible){var d=u.__clipPaths,f=d&&d.length||0,g=l&&l.length||0,p=void 0;for(p=Math.max(f-1,g-1);p>=0&&!(d&&l&&d[p]===l[p]);p--);for(var m=g-1;m>p;m--)o--,a=r[o-1];for(var v=p+1;v<f;v++){var _={};bme(d[v],_,t);var b=yn("g","clip-g-"+h++,_,[]);(a?a.children:i).push(b),r[o++]=b,a=b}l=d;var y=rV(u,t);y&&(a?a.children:i).push(y)}}},s.prototype.resize=function(e,t){var i=this._opts,n=this.root,r=this._viewport;if(e!=null&&(i.width=e),t!=null&&(i.height=t),n&&r&&(r.style.display="none",e=a6(n,0,i),t=a6(n,1,i),r.style.display=""),this._width!==e||this._height!==t){if(this._width=e,this._height=t,r){var o=r.style;o.width=e+"px",o.height=t+"px"}if(d5(this._backgroundColor))this.refresh();else{var a=this._svgDom;a&&(a.setAttribute("width",e),a.setAttribute("height",t));var l=this._bgVNode&&this._bgVNode.elm;l&&(l.setAttribute("width",e),l.setAttribute("height",t))}}},s.prototype.getWidth=function(){return this._width},s.prototype.getHeight=function(){return this._height},s.prototype.dispose=function(){this.root&&(this.root.innerHTML=""),this._svgDom=this._viewport=this.storage=this._oldVNode=this._bgVNode=this._mainVNode=null},s.prototype.clear=function(){this._svgDom&&(this._svgDom.innerHTML=null),this._oldVNode=null},s.prototype.toDataURL=function(e){var t=this.renderToString(),i="data:image/svg+xml;";return e?(t=Ese(t),t&&i+"base64,"+t):i+"charset=UTF-8,"+encodeURIComponent(t)},s})();function cV(s){return function(){}}function Dme(s,e,t,i){var n;if(t&&t!=="none")if(n=yn("rect","bg",{width:s,height:e,x:"0",y:"0"}),K$(t))KY({fill:t},n.attrs,"fill",i);else if(d5(t))YY({style:{fill:t},dirty:ts,getBoundingRect:function(){return{width:s,height:e}}},n.attrs,"fill",i);else{var r=bb(t),o=r.color,a=r.opacity;n.attrs.fill=o,a<1&&(n.attrs["fill-opacity"]=a)}return n}function Tme(s){s.registerPainter("svg",kme)}const Ime=""+new URL("echarts-BDq-rBJC.png",import.meta.url).href;$f([Kpe,mpe,Bpe,Ppe,Lge,Jde,Tme]);const on={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"hidden",width:"100%"},chart:{width:"100%",overflow:"hidden"},chartWithToolbar:s=>({height:`calc(100% - ${parseInt(s.mixins.toolbar.minHeight,10)+8}px)`}),chartWithoutToolbar:{height:"100%"},selectHistoryControl:{width:130},selectRelativeTime:{marginLeft:10,width:200},notAliveInstance:{opacity:.5},customRange:s=>({color:s.palette.primary.main}),splitLineButtonIcon:{marginRight:8},grow:{flexGrow:1},toolbarDate:{width:124,mt:"9px","& fieldset":{display:"none"},"& input":{padding:"8px 0 0 0"},"& .MuiInputAdornment-root":{ml:0,mt:"7px"}},toolbarTime:{width:84,mt:"9px","& fieldset":{display:"none"},"& input":{padding:"8px 0 0 0"},"& .MuiInputAdornment-root":{ml:0,mt:"7px"}},toolbarTimeLabel:{position:"absolute",padding:8,fontSize:"0.8rem",left:2,top:-9},toolbarTimeGrid:{position:"relative",marginLeft:8,paddingLeft:8,paddingRight:8,paddingTop:4,paddingBottom:4,border:"1px dotted #AAAAAA",borderRadius:8,display:"flex"},buttonIcon:{width:24,height:24},echartsButton:{marginRight:8,height:34,width:34}},ar=80,Qu=25;class JY extends Te.Component{echartsReact;rangeRef;readTimeout=null;chartValues;rangeValues;subscribes;unit;divRef;chart;timerResize=null;updateTimer=null;minY;maxY;timeTimer=null;maxYLenTimeout=null;mouseDown;start;end;localStorage;constructor(e){if(super(e),this.localStorage=window._localStorage||window.localStorage,this.props.from)this.start=this.props.from;else{const r=new Date;r.setHours(r.getHours()-168),this.start=r.getTime()}this.props.end?this.end=this.props.end:this.end=Date.now();let t=this.localStorage.getItem("App.relativeRange")||"30";const i=parseInt(this.localStorage.getItem("App.absoluteStart"),10)||0,n=parseInt(this.localStorage.getItem("App.absoluteEnd"),10)||0;(!i||!n)&&(!t||t==="absolute")&&(t="30"),n&&i&&(t="absolute"),this.state={historyInstance:this.props.historyInstance||"",historyInstances:null,defaultHistory:"",chartHeight:300,chartWidth:500,windowWidth:window.innerWidth,ampm:!1,relativeRange:t,splitLine:this.localStorage.getItem("App.splitLine")==="true",min:i,max:n,maxYLen:0,stepType:"",echartsJump:!1},this.echartsReact=null,this.rangeRef=Te.createRef(),this.readTimeout=null,this.chartValues=null,this.rangeValues=null,this.subscribes=[],this.unit=this.props.obj.common&&this.props.obj.common.unit?` ${this.props.obj.common.unit}`:"",this.divRef=Te.createRef(),this.chart={}}componentDidMount(){this.props.socket.subscribeState(this.props.obj._id,this.onChange),window.addEventListener("resize",this.onResize),this.prepareData().then(()=>!this.props.noToolbar&&this.readHistoryRange()).then(()=>this.setRelativeInterval(this.state.relativeRange,!0,()=>this.forceUpdate()))}componentWillUnmount(){this.readTimeout&&(clearTimeout(this.readTimeout),this.readTimeout=null),this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=null),this.maxYLenTimeout&&(clearTimeout(this.maxYLenTimeout),this.maxYLenTimeout=null),this.timerResize&&(clearTimeout(this.timerResize),this.timerResize=null),this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null),this.echartsReact&&this.echartsReact.getEchartsInstance().dispose();for(let e=0;e<this.subscribes.length;e++)this.props.socket.unsubscribeState(this.subscribes[e],this.onChange);this.subscribes=[],this.props.socket.unsubscribeState(this.props.obj._id,this.onChange),window.removeEventListener("resize",this.onResize)}onResize=()=>{this.timerResize&&clearTimeout(this.timerResize),this.timerResize=setTimeout(()=>{this.timerResize=null,this.setState({windowWidth:window.innerWidth}),this.componentDidUpdate()})};onChange=(e,t)=>{if(e===this.props.obj._id&&t&&this.rangeValues&&(!this.rangeValues.length||this.rangeValues[this.rangeValues.length-1].ts<t.ts))(!this.state.max||t.ts-this.state.max<12e4)&&(this.chartValues&&this.chartValues.push({val:t.val,ts:t.ts}),this.rangeValues.push({val:t.val,ts:t.ts}),t.ts>=this.chart.min&&t.ts<=this.chart.max+3e5&&this.updateChart());else if(e.startsWith("system.adapter.")&&e.endsWith(".alive")&&this.state.historyInstances){const i=e.substring(15,e.length-6),n=this.state.historyInstances,r=n.findIndex(o=>o.id===i);if(r!==-1&&n[r].alive!==!!(t!=null&&t.val)){const o=JSON.parse(JSON.stringify(n));o[r].alive=!!(t!=null&&t.val),this.setState({historyInstances:o},()=>{o[r].alive&&this.state.historyInstance===i&&this.readHistoryRange().then(()=>this.updateChart())})}}};async prepareData(){var a,l;if(this.props.noToolbar){const h=this.props.defaultHistory&&await this.props.socket.getState(`system.adapter.${this.props.defaultHistory}.alive`);this.subscribes.length||(this.subscribes=[`system.adapter.${this.props.defaultHistory}.alive`],await this.props.socket.subscribeState(`system.adapter.${this.props.defaultHistory}.alive`,this.onChange)),await new Promise(c=>{this.setState({defaultHistory:this.props.defaultHistory,historyInstance:this.props.defaultHistory,historyInstances:[{id:this.props.defaultHistory,alive:!!(h!=null&&h.val)}]},()=>c(null))});return}let e=await this.getHistoryInstances();const t=await this.props.socket.getCompactSystemConfig();let i=[];this.props.showJumpToEchart&&(i=await this.props.socket.getAdapterInstances("echarts",!0));const n=!!i.find(h=>h._id.startsWith("system.adapter.echarts.")),r=(a=t==null?void 0:t.common)==null?void 0:a.defaultHistory;this.props.obj.common.custom&&(e=e.filter(h=>this.props.obj.common.custom[h.id]));let o=this.localStorage.getItem("App.historyInstance")||"";if((!o||!e.find(h=>h.id===o&&h.alive))&&(o=r),!o||!e.find(h=>h.id===o&&h.alive)){const h=e.find(c=>c.alive);h&&(o=h.id)}!o&&e.length&&(o=r),this.setState({ampm:t.common.dateFormat.includes("/"),historyInstances:e,defaultHistory:r,historyInstance:o,echartsJump:n,stepType:this.props.obj.common.custom&&((l=this.props.obj.common.custom[o])==null?void 0:l.chartStep)||""})}getHistoryInstances(){if(this.props.historyInstance)return Promise.resolve([]);const e=[],t=[];return this.props.customsInstances.forEach(i=>{var r;const n=this.props.objects[`system.adapter.${i}`];if((r=n==null?void 0:n.common)!=null&&r.getHistory){const o={id:i,alive:!1};e.push(o),t.push(`system.adapter.${i}.alive`)}}),t.length?this.props.socket.getForeignStates(t).then(async i=>{Object.keys(i).forEach(n=>{var o;const r=e.find(a=>n.endsWith(`${a.id}.alive`));r&&(r.alive=!!((o=i[n])!=null&&o.val))}),this.subscribes=t;for(let n=0;n<t.length;n++)await this.props.socket.subscribeState(t[n],this.onChange);return e}):Promise.resolve(e)}readHistoryRange(){var i;const e=new Date,t=new Date(2e3,0,1);return(i=this.state.historyInstances)!=null&&i.find(n=>n.id===this.state.historyInstance&&n.alive)?this.props.socket.getHistory(this.props.obj._id,{instance:this.state.historyInstance,start:t.getTime(),end:e.getTime(),limit:1,from:!1,ack:!1,q:!1,addId:!1,aggregate:"none"}).then(n=>{var r;n&&((r=n[0])==null?void 0:r.val)===null&&n.shift(),this.rangeValues=n}):Promise.resolve()}readHistory(e,t){var n;if(!this.state.historyInstance||!((n=this.state.historyInstances)!=null&&n.find(r=>r.id===this.state.historyInstance&&r.alive)))return Promise.resolve([]);const i={instance:this.state.historyInstance,start:e,end:t,from:!1,ack:!1,q:!1,addId:!1,aggregate:"none",returnNewestEntries:!0};return t-e>6e4*24&&!(this.props.obj.common.type==="boolean"||this.props.obj.common.type==="number"&&this.props.obj.common.states)&&(i.aggregate="minmax"),this.props.socket.getHistory(this.props.obj._id,i).then(r=>{const o=[];let a=0;const l=this.rangeValues;let h=null,c=null;for(let u=0;u<r.length;u++){if(l)for(;a<l.length&&l[a].ts<r[u].ts;)o.push(l[a]),a++;!o.length||o[o.length-1].ts<r[u].ts?o.push(r[u]):o[o.length-1].ts===r[u].ts&&o[o.length-1].val!==r[u].ts&&console.error("Strange data!"),(h===null||r[u].val<h)&&(h=r[u].val),(c===null||r[u].val>c)&&(c=r[u].val)}if(l)for(;a<l.length;)o.push(l[a]),console.log(`add range ${new Date(l[a].ts).toISOString()}: ${l[a].val}`),a++;return o.sort((u,d)=>u.ts>d.ts?1:u.ts<d.ts?-1:0),this.chartValues=o,this.minY=h,this.maxY=c,this.minY<10?this.minY=Math.round(this.minY*10)/10:this.minY=Math.ceil(this.minY),this.maxY<10?this.maxY=Math.round(this.maxY*10)/10:this.maxY=Math.ceil(this.maxY),o})}convertData(e){e=e||this.chartValues;const t=[];if(!e.length)return[];for(let i=0;i<e.length;i++){const n={value:[e[i].ts,e[i].val]};e[i].i&&(n.exact=!1),t.push(n)}return this.chart.min||(this.chart.min=e[0].ts,this.chart.max=e[e.length-1].ts),t}getOption(){let e;if(this.minY!==null&&this.minY!==void 0&&(e=(this.minY.toString()+this.unit).length*9+12),this.maxY!==null&&this.maxY!==void 0){const r=(this.maxY.toString()+this.unit).length*9+12;r>e&&(e=r)}if(this.state.maxYLen){const r=this.state.maxYLen*9+12;r>e&&(e=r)}const t={xAxisIndex:0,type:"line",step:this.state.stepType==="stepStart"?"end":this.state.stepType==="stepMiddle"?"middle":this.state.stepType==="stepEnd"?"start":void 0,showSymbol:!1,hoverAnimation:!0,animation:!1,data:this.convertData(),lineStyle:{color:"#4dabf5"},areaStyle:{}},i={type:"value",boundaryGap:[0,"100%"],splitLine:{show:this.props.noToolbar||!!this.state.splitLine},splitNumber:Math.round(this.state.chartHeight/50),axisLabel:{formatter:r=>{let o;return this.props.isFloatComma?o=r.toString().replace(",",".")+this.unit:o=r+this.unit,this.state.maxYLen<o.length&&(this.maxYLenTimeout&&clearTimeout(this.maxYLenTimeout),this.maxYLenTimeout=setTimeout(a=>{this.maxYLenTimeout=null,this.setState({maxYLen:a})},200,o.length)),o},showMaxLabel:!0,showMinLabel:!0},axisTick:{alignWithLabel:!0}};if(this.props.obj.common.type==="boolean")t.step="end",i.axisLabel.showMaxLabel=!1,i.axisLabel.formatter=r=>r===1?"TRUE":"FALSE",i.max=1.5,i.interval=1,e=50;else if(this.props.obj.common.type==="number"&&this.props.obj.common.states){t.step="end",i.axisLabel.showMaxLabel=!1;const r=this.props.obj.common.states;i.axisLabel.formatter=l=>r[l]!==void 0?r[l]:l;const o=Object.keys(this.props.obj.common.states);o.sort(),i.max=parseFloat(o[o.length-1])+.5,i.interval=1;let a="";for(let l=0;l<o.length;l++)typeof r[o[l]]=="string"&&r[o[l]].length>a.length&&(a=r[o[l]]);e=(a.length*9||50)+12}const n=this.chart.withSeconds?Math.round((this.state.chartWidth-Qu-ar)/100):Math.round((this.state.chartWidth-Qu-ar)/60);return{backgroundColor:"transparent",title:{text:this.props.noToolbar?"":ee.Utils.getObjectNameFromObj(this.props.obj,this.props.lang),padding:[10,0,0,e?e+10:ar+10]},grid:{left:e||ar,top:8,right:this.props.noToolbar?5:Qu,bottom:40},tooltip:{trigger:"axis",formatter:r=>{const o=r[0],a=new Date(o.value[0]);let l=o.value[1];return l!==null&&this.props.isFloatComma&&(l=l.toString().replace(".",",")),`${o.exact===!1?"i":""}${a.toLocaleString()}.${a.getMilliseconds().toString().padStart(3,"0")}: ${l}${this.unit}`},axisPointer:{animation:!0}},xAxis:{splitLine:{show:!1},splitNumber:n,min:this.chart.min,max:this.chart.max,axisTick:{alignWithLabel:!0},axisLabel:{formatter:r=>{const o=new Date(r);return this.chart.withSeconds?`${o.getHours().toString().padStart(2,"0")}:${o.getMinutes().toString().padStart(2,"0")}:${o.getSeconds().toString().padStart(2,"0")}`:this.chart.withTime?`${o.getHours().toString().padStart(2,"0")}:${o.getMinutes().toString().padStart(2,"0")}
|
|
38
38
|
${o.getDate().toString().padStart(2,"0")}.${(o.getMonth()+1).toString().padStart(2,"0")}`:`${o.getDate().toString().padStart(2,"0")}.${(o.getMonth()+1).toString().padStart(2,"0")}
|
|
39
|
-
${o.getFullYear()}`}}},yAxis:i,toolbox:{left:"right",feature:this.props.noToolbar?void 0:{saveAsImage:{title:this.props.t("Save as image"),show:!0}}},series:[t]}}static getDerivedStateFromProps(e,t){return null}updateChart(e,t,i,n){e&&(this.start=e),t&&(this.end=t),e=e||this.start,t=t||this.end,this.readTimeout&&clearTimeout(this.readTimeout),this.readTimeout=setTimeout(()=>{var o;this.readTimeout=null;const r=this.chart.max-this.chart.min;r!==this.chart.diff&&(this.chart.diff=r,this.chart.withTime=this.chart.diff<36e5*24*7,this.chart.withSeconds=this.chart.diff<6e4*30),i?this.readHistory(e,t).then(a=>{var l;typeof((l=this.echartsReact)==null?void 0:l.getEchartsInstance)=="function"&&this.echartsReact.getEchartsInstance().setOption({series:[{data:this.convertData(a)}],xAxis:{min:this.chart.min,max:this.chart.max}}),n&&n()}):(typeof((o=this.echartsReact)==null?void 0:o.getEchartsInstance)=="function"&&this.echartsReact.getEchartsInstance().setOption({series:[{data:this.convertData()}],xAxis:{min:this.chart.min,max:this.chart.max}}),n&&n())},400)}setNewRange(e){var t;this.chart.diff=this.chart.max-this.chart.min,this.chart.withTime=this.chart.diff<36e5*24*7,this.chart.withSeconds=this.chart.diff<6e4*30,this.state.relativeRange!=="absolute"?(this.setState({relativeRange:"absolute"}),this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=null)):typeof((t=this.echartsReact)==null?void 0:t.getEchartsInstance)=="function"&&(this.echartsReact.getEchartsInstance().setOption({xAxis:{min:this.chart.min,max:this.chart.max}}),e&&this.updateChart(this.chart.min,this.chart.max,!0))}shiftTime(){const e=new Date,t=6e4-e.getSeconds()-(1e3-e.getMilliseconds());e.getMilliseconds()&&e.setMilliseconds(1e3),e.getSeconds()&&e.setSeconds(60);const i=e.getTime();let n;const r=this.state.relativeRange;if(r==="day")e.setHours(0),e.setMinutes(0),e.setSeconds(0),n=e.getTime();else if(r==="week"){e.setHours(0),e.setMinutes(0),e.setSeconds(0);const o=e.getDay()||7;o!==1&&e.setHours(-24*(o-1)),n=e.getTime()}else if(r==="2weeks"){e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setDate(e.getDate()-7);const o=e.getDay()||7;o!==1&&e.setHours(-24*(o-1)),n=e.getTime()}else r==="month"?(e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setDate(1),n=e.getTime()):r==="year"?(e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setDate(1),e.setMonth(0),n=e.getTime()):r==="12months"?(e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setFullYear(e.getFullYear()-1),n=e.getTime()):n=i-parseInt(r,10)*6e4;this.chart.min=n,this.chart.max=i,this.setState({min:n,max:i},()=>this.updateChart(this.chart.min,this.chart.max,!0)),this.timeTimer=setTimeout(()=>{this.timeTimer=null,this.shiftTime()},t||6e4)}setRelativeInterval(e,t,i){if(t||(this.localStorage.setItem("App.relativeRange",e),this.setState({relativeRange:e})),e==="absolute"){this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=null),this.updateChart(this.chart.min,this.chart.max,!0,i);return}this.localStorage.removeItem("App.absoluteStart"),this.localStorage.removeItem("App.absoluteEnd");const n=new Date;if(!this.timeTimer){const r=6e4-n.getSeconds()-(1e3-n.getMilliseconds());this.timeTimer=setTimeout(()=>{this.timeTimer=null,this.shiftTime()},r||6e4)}if(n.getMilliseconds()&&n.setMilliseconds(1e3),n.getSeconds()&&n.setSeconds(60),this.chart.max=n.getTime(),e==="day")n.setHours(0),n.setMinutes(0),n.setSeconds(0),this.chart.min=n.getTime();else if(e==="week"){n.setHours(0),n.setMinutes(0),n.setSeconds(0);const r=n.getDay()||7;r!==1&&n.setHours(-24*(r-1)),this.chart.min=n.getTime()}else if(e==="2weeks"){n.setHours(0),n.setMinutes(0),n.setSeconds(0),n.setDate(n.getDate()-7);const r=n.getDay()||7;r!==1&&n.setHours(-24*(r-1)),this.chart.min=n.getTime()}else e==="month"?(n.setHours(0),n.setMinutes(0),n.setSeconds(0),n.setDate(1),this.chart.min=n.getTime()):e==="year"?(n.setHours(0),n.setMinutes(0),n.setSeconds(0),n.setDate(1),n.setMonth(0),this.chart.min=n.getTime()):e==="12months"?(n.setHours(0),n.setMinutes(0),n.setSeconds(0),n.setFullYear(n.getFullYear()-1),this.chart.min=n.getTime()):this.chart.min=this.chart.max-parseInt(e,10)*6e4;this.setState({min:this.chart.min,max:this.chart.max},()=>this.updateChart(this.chart.min,this.chart.max,!0,i))}installEventHandlers(){if(!this.echartsReact||typeof this.echartsReact.getEchartsInstance!="function")return;const e=this.echartsReact.getEchartsInstance().getZr();e._iobInstalled||(e._iobInstalled=!0,e.on("mousedown",t=>{console.log("mouse down"),this.mouseDown=!0,this.chart.lastX=t.offsetX}),e.on("mouseup",()=>{console.log("mouse up"),this.mouseDown=!1,this.setNewRange(!0)}),e.on("mousewheel",t=>{let i=this.chart.max-this.chart.min;const n=this.state.chartWidth-Qu-ar,o=(t.offsetX-ar)/n,a=i,l=t.wheelDelta>0?1.1:.9;i*=l;const h=a-i;this.chart.max+=h*(1-o),this.chart.min-=h*o,this.setNewRange()}),e.on("mousemove",t=>{if(this.mouseDown){const i=this.chart.lastX-(t.offsetX-ar);this.chart.lastX=t.offsetX-ar;const n=this.chart.max-this.chart.min,r=this.state.chartWidth-Qu-ar,o=Math.round(i*n/r);this.chart.min+=o,this.chart.max+=o,this.setNewRange()}}),e.on("touchstart",t=>{t.preventDefault(),this.mouseDown=!0;const i=t.touches||t.originalEvent.touches;i&&(this.chart.lastX=i[i.length-1].pageX,i.length>1?this.chart.lastWidth=Math.abs(i[0].pageX-i[1].pageX):this.chart.lastWidth=null)}),e.on("touchend",t=>{t.preventDefault(),this.mouseDown=!1,this.setNewRange(!0)}),e.on("touchmove",t=>{t.preventDefault();const i=t.touches||t.originalEvent.touches;if(!i)return;const n=i[i.length-1].pageX-ar;if(this.mouseDown)if(i.length>1){const r=Math.abs(i[0].pageX-i[1].pageX);if(this.chart.lastWidth!==null&&r!==this.chart.lastWidth){let o=this.chart.max-this.chart.min;const a=this.state.chartWidth-Qu-ar,l=r>this.chart.lastWidth?1.1:.9,c=(i[0].pageX>i[1].pageX?i[1].pageX-ar+r/2:i[0].pageX-ar+r/2)/a,u=o;o*=l;const d=u-o;this.chart.max+=d*(1-c),this.chart.min-=d*c,this.setNewRange()}this.chart.lastWidth=r}else{const r=this.chart.lastX-n,o=this.chart.max-this.chart.min,a=this.state.chartWidth-Qu-ar,l=Math.round(r*o/a);this.chart.min+=l,this.chart.max+=l,this.setNewRange()}this.chart.lastX=n}))}renderChart(){var e;return this.state.historyInstance?(e=this.state.historyInstances)!=null&&e.find(t=>t.id===this.state.historyInstance&&t.alive)?this.chartValues?L.jsx(nne,{ref:t=>this.echartsReact=t,echarts:Lde,option:this.getOption(),notMerge:!0,lazyUpdate:!0,theme:this.props.themeType==="dark"?"dark":"",style:{height:`${this.state.chartHeight}px`,width:"100%"},opts:{renderer:"svg"},onEvents:{rendered:()=>this.installEventHandlers()}}):L.jsx(E.LinearProgress,{}):L.jsx("div",{style:{marginTop:20,fontSize:24,marginLeft:24},children:this.props.t("History instance not alive")}):L.jsx("div",{style:{marginTop:20,fontSize:24,marginLeft:24},children:this.props.t("History instance not selected")})}componentDidUpdate(){if(this.divRef.current){const e=this.divRef.current.offsetWidth,t=this.divRef.current.offsetHeight;this.state.chartHeight!==t&&(this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.updateTimer=null,this.setState({chartHeight:t,chartWidth:e})},100))}}setStartDate(e){const t=e.getTime();this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=null),this.localStorage.setItem("App.relativeRange","absolute"),this.localStorage.setItem("App.absoluteStart",t.toString()),this.localStorage.setItem("App.absoluteEnd",this.state.max.toString()),this.chart.min=t,this.setState({min:t,relativeRange:"absolute"},()=>this.updateChart(this.chart.min,this.chart.max,!0))}setEndDate(e){const t=e.getTime();this.localStorage.setItem("App.relativeRange","absolute"),this.localStorage.setItem("App.absoluteStart",this.state.min.toString()),this.localStorage.setItem("App.absoluteEnd",t.toString()),this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=null),this.chart.max=t,this.setState({max:t,relativeRange:"absolute"},()=>this.updateChart(this.chart.min,this.chart.max,!0))}openEcharts(){const e=[`id=${window.encodeURIComponent(this.props.obj._id)}`,`instance=${window.encodeURIComponent(this.state.historyInstance)}`,"menuOpened=false"];this.state.relativeRange==="absolute"?(e.push(`start=${this.chart.min}`),e.push(`end=${this.chart.max}`)):e.push(`range=${this.state.relativeRange}`),window.open(`${window.location.protocol}//${window.location.host}/adapter/echarts/tab.html#${e.join("&")}`,"echarts")}async onStepChanged(e){const t=await this.props.socket.getObject(this.props.obj._id);t.common.custom&&t.common.custom[this.state.historyInstance]&&t.common.custom[this.state.historyInstance].chartStep!==e&&(t.common.custom[this.state.historyInstance].chartStep=e,await this.props.socket.setObject(t._id,t)),this.setState({stepType:e,showStepMenu:null})}renderToolbar(){if(this.props.noToolbar)return null;const e=this.state.windowWidth<960;return L.jsxs(E.Toolbar,{children:[!this.props.historyInstance&&L.jsxs(E.FormControl,{variant:"standard",style:on.selectHistoryControl,children:[L.jsx(E.InputLabel,{children:this.props.t("History instance")}),L.jsx(E.Select,{variant:"standard",value:this.state.historyInstance,onChange:t=>{this.localStorage.setItem("App.historyInstance",t.target.value),this.setState({historyInstance:t.target.value})},children:this.state.historyInstances.map(t=>L.jsx(E.MenuItem,{value:t.id,style:t.alive?void 0:on.notAliveInstance,children:t.id},t.id))})]}),L.jsxs(E.FormControl,{variant:"standard",style:on.selectRelativeTime,children:[L.jsx(E.InputLabel,{children:this.props.t("Relative")}),L.jsxs(E.Select,{variant:"standard",ref:this.rangeRef,value:this.state.relativeRange,onChange:t=>this.setRelativeInterval(t.target.value),children:[L.jsx(E.MenuItem,{value:"absolute",sx:on.customRange,children:this.props.t("custom range")},"custom"),L.jsx(E.MenuItem,{value:10,children:this.props.t("last 10 minutes")},"1"),L.jsx(E.MenuItem,{value:30,children:this.props.t("last 30 minutes")},"2"),L.jsx(E.MenuItem,{value:60,children:this.props.t("last hour")},"3"),L.jsx(E.MenuItem,{value:"day",children:this.props.t("this day")},"4"),L.jsx(E.MenuItem,{value:1440,children:this.props.t("last 24 hours")},"5"),L.jsx(E.MenuItem,{value:"week",children:this.props.t("this week")},"6"),L.jsx(E.MenuItem,{value:1440*7,children:this.props.t("last week")},"7"),L.jsx(E.MenuItem,{value:"2weeks",children:this.props.t("this 2 weeks")},"8"),L.jsx(E.MenuItem,{value:1440*14,children:this.props.t("last 2 weeks")},"9"),L.jsx(E.MenuItem,{value:"month",children:this.props.t("this month")},"10"),L.jsx(E.MenuItem,{value:720*60,children:this.props.t("last 30 days")},"11"),L.jsx(E.MenuItem,{value:"year",children:this.props.t("this year")},"12"),L.jsx(E.MenuItem,{value:"12months",children:this.props.t("last 12 months")},"13")]})]}),L.jsxs(_s.LocalizationProvider,{dateAdapter:dS,adapterLocale:gS[this.props.lang],children:[L.jsxs("div",{style:on.toolbarTimeGrid,children:[L.jsx("div",{style:{...on.toolbarTimeLabel,opacity:this.state.relativeRange!=="absolute"?.5:void 0},children:this.props.t("Start time")}),L.jsx(_s.DatePicker,{sx:on.toolbarDate,disabled:this.state.relativeRange!=="absolute",value:new Date(this.state.min),onChange:t=>this.setStartDate(t)}),L.jsx(_s.TimePicker,{disabled:this.state.relativeRange!=="absolute",sx:on.toolbarTime,ampm:this.state.ampm,value:new Date(this.state.min),onChange:t=>this.setStartDate(t)})]}),L.jsxs("div",{style:on.toolbarTimeGrid,children:[L.jsx("div",{style:{...on.toolbarTimeLabel,opacity:this.state.relativeRange!=="absolute"?.5:void 0},children:this.props.t("End time")}),L.jsx(_s.DatePicker,{disabled:this.state.relativeRange!=="absolute",sx:on.toolbarDate,value:new Date(this.state.max),onChange:t=>this.setEndDate(t)}),L.jsx(_s.TimePicker,{disabled:this.state.relativeRange!=="absolute",sx:on.toolbarTime,ampm:this.state.ampm,value:new Date(this.state.max),onChange:t=>this.setEndDate(t)})]})]}),L.jsx("div",{style:on.grow}),L.jsx(E.Button,{style:{marginRight:10},variant:"outlined",onClick:t=>this.setState({showStepMenu:t.target}),children:e?this.state.stepType===""?L.jsx(Ie.Remove,{}):this.state.stepType==="stepStart"?L.jsx(Ie.KeyboardArrowRight,{}):this.state.stepType==="stepMiddle"?L.jsx(Ie.MoreHoriz,{}):this.state.stepType==="stepEnd"?L.jsx(Ie.KeyboardArrowLeft,{}):this.props.t("Step type"):this.state.stepType?this.props.t(this.state.stepType):this.props.t("Step type")}),this.state.showStepMenu?L.jsxs(E.Menu,{open:!0,anchorEl:this.state.showStepMenu,onClose:()=>this.setState({showStepMenu:null}),children:[L.jsx(E.MenuItem,{selected:this.state.stepType==="",onClick:()=>this.onStepChanged(""),children:e?L.jsx(Ie.Remove,{}):this.props.t("None")}),L.jsx(E.MenuItem,{selected:this.state.stepType==="stepStart",onClick:()=>this.onStepChanged("stepStart"),children:e?L.jsx(Ie.KeyboardArrowRight,{}):this.props.t("stepStart")}),L.jsx(E.MenuItem,{selected:this.state.stepType==="stepMiddle",onClick:()=>this.onStepChanged("stepMiddle"),children:e?L.jsx(Ie.MoreHoriz,{}):this.props.t("stepMiddle")}),L.jsx(E.MenuItem,{selected:this.state.stepType==="stepEnd",onClick:()=>this.onStepChanged("stepEnd"),children:e?L.jsx(Ie.KeyboardArrowLeft,{}):this.props.t("stepEnd")})]}):null,this.props.showJumpToEchart&&this.state.echartsJump&&L.jsx(E.Fab,{style:on.echartsButton,size:"small",onClick:()=>this.openEcharts(),title:this.props.t("Open charts in new window"),children:L.jsx("img",{src:Ime,alt:"echarts",style:on.buttonIcon})}),L.jsxs(E.Fab,{variant:"extended",size:"small",color:this.state.splitLine?"primary":"default","aria-label":"show lines",onClick:()=>{this.localStorage.setItem("App.splitLine",this.state.splitLine?"false":"true"),this.setState({splitLine:!this.state.splitLine})},children:[L.jsx(yie,{style:on.splitLineButtonIcon}),this.props.t("Show lines")]})]})}render(){return!this.state.historyInstances&&!this.state.defaultHistory?L.jsx(E.LinearProgress,{}):L.jsxs(E.Paper,{style:on.paper,children:[this.renderToolbar(),L.jsx("div",{ref:this.divRef,style:ee.Utils.getStyle(this.props.theme,on.chart,this.props.noToolbar?on.chartWithoutToolbar:on.chartWithToolbar),children:this.renderChart()})]})}}const Pa={dialog:{height:"100%"},paper:{height:"calc(100% - 64px)"},content:{textAlign:"center",overflow:"hidden"},tabPanel:s=>({width:"100%",overflow:"hidden",height:`calc(100% - ${s.mixins.toolbar.minHeight}px)`}),tabSelected:s=>({color:s.palette.mode==="dark"?s.palette.secondary.contrastText:"#FFFFFF !important"}),tabsIndicator:s=>({backgroundColor:s.palette.secondary.main})};class Eme extends F7{chartAvailable;saveFunc=null;constructor(e){super(e);let t=parseInt((window._localStorage||window.localStorage).getItem("App.objectCustomTab")||"0",10);if(this.chartAvailable=this.isChartAvailable(),this.chartAvailable){const i=ee.Router.getLocation();i.arg==="chart"?t=2:i.arg==="table"&&(t=1)}else t=0;this.state={hasChanges:!1,currentTab:t,confirmDialog:!1,mobile:F7.isMobile(),progressRunning:!1,showWarning:this.props.allVisibleObjects}}isChartAvailable(){var t,i;let e=this.props.objectIDs.length===1;if(e){const n=this.props.objectIDs[0];(i=(t=this.props.objects[n])==null?void 0:t.common)!=null&&i.custom?e=!!Object.keys(this.props.objects[n].common.custom).find(r=>{const o=this.props.objects[`system.adapter.${r}`];return o&&o.common&&o.common.getHistory}):e=!1}return e}renderCharts(){return L.jsx(JY,{isFloatComma:this.props.isFloatComma,showJumpToEchart:!0,t:this.props.t,lang:this.props.lang,socket:this.props.socket,obj:this.props.objects[this.props.objectIDs[0]],customsInstances:this.props.customsInstances,themeType:this.props.themeType,theme:this.props.theme,objects:this.props.objects})}renderTable(){return L.jsx(pS,{t:this.props.t,isFloatComma:this.props.isFloatComma,lang:this.props.lang,expertMode:this.props.expertMode,socket:this.props.socket,obj:this.props.objects[this.props.objectIDs[0]],customsInstances:this.props.customsInstances,objects:this.props.objects})}renderCustomEditor(){return L.jsx(fS,{registerSaveFunc:e=>this.saveFunc=e,t:this.props.t,lang:this.props.lang,socket:this.props.socket,objectIDs:this.props.objectIDs,customsInstances:this.props.customsInstances,objects:this.props.objects,onProgress:e=>this.setState({progressRunning:e}),reportChangedIds:this.props.reportChangedIds,onChange:(e,t)=>{this.setState({hasChanges:e},()=>{if(t){const i=this.isChartAvailable();i!==this.chartAvailable&&(this.chartAvailable=i,this.forceUpdate())}})},theme:this.props.theme,themeName:this.props.themeName,themeType:this.props.themeType,systemConfig:this.props.systemConfig})}renderDialogConfirm(){return this.state.confirmDialog?L.jsx(ee.DialogConfirm,{title:ee.I18n.t("You have unsaved changes"),text:ee.I18n.t("Discard?"),ok:ee.I18n.t("Yes"),cancel:ee.I18n.t("Cancel"),onClose:e=>this.setState({confirmDialog:!1},()=>e&&this.props.onClose())}):null}onClose(){this.state.hasChanges?this.setState({confirmDialog:!0}):this.props.onClose()}renderWarningDialog(){return this.state.showWarning?L.jsx(ee.DialogConfirm,{text:L.jsx("div",{style:{color:"#F00"},children:this.props.t("Your are intend to edit ALL objects. Are you sure?")}),ok:this.props.t("Yes"),onClose:e=>{this.setState({showWarning:!1}),e||this.onClose()}}):null}render(){var t,i;const e=(i=(t=this.props.objects[this.props.objectIDs[0]])==null?void 0:t.common)==null?void 0:i.type;return L.jsxs(E.Dialog,{sx:{"&.MuiDialog-scrollPaper":Pa.dialog,"& .MuiDialog-paper":Pa.paper},scroll:"paper",open:!0,onClose:()=>this.props.onClose(),fullWidth:!0,maxWidth:"xl","aria-labelledby":"form-dialog-title",children:[this.renderDialogConfirm(),this.renderWarningDialog(),L.jsx(E.DialogTitle,{children:this.props.objectIDs.length>1?this.props.t("Edit config for %s states",this.props.objectIDs.length):this.props.t("Edit config: %s",this.props.objectIDs[0])}),L.jsxs(E.DialogContent,{style:Pa.content,children:[L.jsx(E.AppBar,{position:"static",children:L.jsxs(E.Tabs,{value:this.state.currentTab,onChange:(n,r)=>{ee.Router.doNavigate(null,null,null,r===1?"table":r===2?"chart":"config"),this.setState({currentTab:r}),(window._localStorage||window.localStorage).setItem("App.objectCustomTab",r)},sx:{"& .MuiTabs-indicator":Pa.tabsIndicator},indicatorColor:"secondary",children:[L.jsx(E.Tab,{disabled:this.state.progressRunning,label:this.props.t("Custom settings"),id:"custom-settings-tab","aria-controls":"custom-tabpanel-settings",sx:{"&.Mui-selected":Pa.tabSelected}}),this.props.objectIDs.length===1&&this.chartAvailable?L.jsx(E.Tab,{disabled:this.state.progressRunning,label:this.props.t("History data"),id:"history-data-tab","aria-controls":"custom-tabpanel-history",sx:{"&.Mui-selected":Pa.tabSelected}}):null,(e==="number"||e==="boolean")&&this.props.objectIDs.length===1&&this.chartAvailable?L.jsx(E.Tab,{disabled:this.state.progressRunning,label:this.props.t("Chart"),id:"chart-tab","aria-controls":"custom-tabpanel-chart",sx:{"&.Mui-selected":Pa.tabSelected}}):null]})}),this.state.currentTab===0?L.jsx(E.Box,{component:"div",sx:Pa.tabPanel,children:this.renderCustomEditor()}):null,this.props.objectIDs.length===1&&this.chartAvailable&&this.state.currentTab===1?L.jsx(E.Box,{component:"div",sx:Pa.tabPanel,children:this.renderTable()}):null,(e==="number"||e==="boolean")&&this.props.objectIDs.length===1&&this.chartAvailable&&this.state.currentTab===2?L.jsx(E.Box,{component:"div",sx:Pa.tabPanel,children:this.renderCharts()}):null]}),L.jsxs(E.DialogActions,{children:[this.state.currentTab===0&&L.jsx(E.Button,{id:"object-custom-dialog-save",variant:"contained",color:"primary",disabled:!this.state.hasChanges||this.state.progressRunning,onClick:()=>this.saveFunc&&this.saveFunc(),children:this.getButtonTitle(L.jsx(Ie.Save,{}),this.props.t("Save"))}),this.state.currentTab===0&&L.jsx(E.Button,{id:"object-custom-dialog-save-close",variant:"contained",color:"primary",disabled:!this.state.hasChanges||this.state.progressRunning,onClick:()=>{this.saveFunc?this.saveFunc(n=>!n&&this.onClose()):this.onClose()},children:this.getButtonTitle(L.jsx(Ie.Save,{}),this.props.t("Save & close"),L.jsx(Ie.Close,{}))}),L.jsx(E.Button,{id:"object-custom-dialog-close",disabled:this.state.progressRunning,variant:"contained",onClick:()=>this.onClose(),color:"grey",children:this.getButtonTitle(L.jsx(Ie.Close,{}),this.props.t("Close"))})]})]})}}const Br={formControl:{minWidth:100},quality:{width:"calc(100% - 88px)"},expire:{ml:1,width:80},readOnly:{backgroundColor:"#b74848"},readOnlyText:{color:"#b74848",marginLeft:8},wrapperButton:{"@media screen and (max-width: 465px)":{"& *":{fontSize:12}},"@media screen and (max-width: 380px)":{"& *":{fontSize:11}}},ackCheckbox:{marginLeft:4},dialog:{minHeight:window.clientHeight-50>500?500:window.clientHeight-50},tooltip:{pointerEvents:"none"}};class Ep extends Te.Component{propsValue;chartFrom;ack;inputRef=uS.createRef();q;expire;constructor(e){super(e);let t=this.props.type;t||(t=typeof this.props.value);let i=this.props.value;if(this.propsValue=i,this.propsValue===null?this.propsValue="null":this.propsValue===void 0&&(this.propsValue="undefined"),this.props.states)t="states";else if(t==="string"||t==="json"){if(i&&typeof i=="string"&&(i.startsWith("[")&&i.endsWith("]")||i.startsWith("{")&&i.endsWith("}")))try{i=JSON.parse(i),i=JSON.stringify(i,null,2),this.propsValue=i,t="json"}catch{}}else t==="number"&&(i=parseFloat(this.propsValue)||0);this.state={type:t,chart:!1,chartEnabled:(window._localStorage||window.localStorage).getItem("App.chartSetValue")!=="false",fullScreen:(window._localStorage||window.localStorage).getItem("App.fullScreen")==="true",targetValue:i,valid:!0,jsonError:!1},this.ack=!1,this.q=0,this.expire=0,this.inputRef=uS.createRef(),this.chartFrom=Date.now()-36e5*2}componentDidMount(){var e,t,i;this.props.defaultHistory&&((t=(e=this.props.object)==null?void 0:e.common)!=null&&t.custom)&&((i=this.props.object.common.custom[this.props.defaultHistory])!=null&&i.enabled)&&this.props.socket.getState(`system.adapter.${this.props.defaultHistory}.alive`).then(n=>this.setState({chart:!!(n!=null&&n.val)})),setTimeout(()=>{var n;if((n=this.inputRef)!=null&&n.current){const r=this.inputRef.current,o=r.value||"",a=r.type;r.type==="number"&&(r.type="text"),r.setSelectionRange(0,o.length),a==="number"&&(r.type=a)}},200)}onUpdate(e){e&&(e.stopPropagation(),e.preventDefault());let t=this.state.targetValue;if(this.state.type==="states")if(t==="null")t=null;else{const i=this.props.type||typeof this.state.targetValue;t=typeof t=="object"?t.value:t,i==="number"?typeof t=="string"&&(t=parseFloat(t.replace(",","."))||0):i==="boolean"&&(t=t===!0||t==="true"||t==="1"||t==="ON"||t==="on")}else this.state.type==="number"?t==="null"?t=null:typeof t=="string"&&(t=parseFloat(t.replace(",","."))||0):this.state.type==="boolean"&&(t==="null"?t=null:t=t===!0||t==="true"||t==="1"||t==="ON"||t==="on");this.props.onClose({val:t,ack:this.ack,q:this.q,expire:parseInt(this.expire,10)||void 0})}static isNumberValid(e){const{common:t,value:i}=e;if(i==="")return!1;const n=Number(i);return typeof t.min=="number"&&n<t.min?!1:!(typeof t.max=="number"&&n>t.max)}renderTimePicker(){return L.jsxs(_s.LocalizationProvider,{adapterLocale:gS[this.props.lang],dateAdapter:dS,children:[L.jsx(_s.DatePicker,{value:Number(this.state.targetValue),onChange:e=>{e&&this.setState({targetValue:Math.round(e.getTime())})}}),L.jsx(_s.TimePicker,{value:Number(this.state.targetValue),views:["hours","minutes","seconds"],onChange:e=>{e&&this.setState({targetValue:Math.round(e.getTime())})}})]})}renderChart(){return L.jsx(JY,{t:this.props.t,isFloatComma:this.props.isFloatComma,showJumpToEchart:!1,lang:this.props.lang,socket:this.props.socket,obj:this.props.object,themeType:this.props.themeType,theme:this.props.theme,from:this.chartFrom,end:Date.now(),noToolbar:!0,defaultHistory:this.props.defaultHistory,customsInstances:[],objects:void 0,historyInstance:""})}static checkJsonError(e){try{return JSON.parse(e),!1}catch{return!0}}renderJsonEditor(){return L.jsx(f$,{error:this.state.jsonError,editValueMode:!0,themeType:this.props.themeType,defaultValue:(this.propsValue||"").toString(),onChange:e=>this.setState({targetValue:e,jsonError:Ep.checkJsonError(e)})})}renderStates(){if(!this.props.states)return null;if(this.props.type==="number"&&this.props.object.common.max!==void 0&&this.props.object.common.min!==void 0){const e=Object.keys(this.props.states).map(t=>({label:this.props.states[t],value:t}));return L.jsx(E.Autocomplete,{style:Br.formControl,disablePortal:!0,defaultValue:this.props.states[this.propsValue]!==void 0?this.props.states[this.propsValue]:this.propsValue,options:e,noOptionsText:"",freeSolo:!0,getOptionLabel:t=>(t==null?void 0:t.label)||(t!=null?t.toString():""),onChange:(t,i)=>this.setState({targetValue:i}),onInputChange:(t,i)=>this.setState({targetValue:i}),onKeyUp:t=>t.key==="Enter"&&this.onUpdate(t),renderInput:t=>L.jsx(E.TextField,{...t,label:this.props.t("Value"),variant:"standard"})})}return L.jsxs(E.FormControl,{variant:"standard",style:Br.formControl,children:[L.jsx(E.InputLabel,{children:this.props.t("Value")}),L.jsx(E.Select,{variant:"standard",defaultValue:this.propsValue,onChange:e=>this.setState({targetValue:e.target.value}),children:Object.keys(this.props.states).map((e,t)=>L.jsx(E.MenuItem,{value:e,children:this.props.states[e]},t))})]})}render(){var t,i,n;const e=L.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[L.jsx(E.FormControlLabel,{style:{...Br.formControl,...this.props.expertMode?void 0:Br.ackCheckbox},control:L.jsx(E.Checkbox,{defaultChecked:!1,onChange:r=>this.ack=r.target.checked}),label:this.props.t("Acknowledged")}),L.jsx(E.Tooltip,{title:this.props.t("Acknowledged explanation"),slotProps:{popper:{sx:Br.tooltip}},children:L.jsx(Ie.Info,{color:"primary"})})]});return L.jsxs(E.Dialog,{open:!0,maxWidth:this.state.type==="number"||this.state.type==="boolean"||this.state.type==="states"?this.state.chart&&this.state.chartEnabled?"lg":void 0:"md",fullWidth:this.state.type==="json"&&this.state.fullScreen||this.state.type!=="number"&&this.state.type!=="boolean"&&this.state.type!=="states"||this.state.chart&&this.state.chartEnabled,fullScreen:this.state.type==="json"&&this.state.fullScreen,onClose:()=>this.props.onClose(),"aria-labelledby":"edit-value-dialog-title","aria-describedby":"edit-value-dialog-description",sx:{"&. MuiDialog-paper":this.state.type==="json"?Br.dialog:void 0},children:[L.jsxs(E.DialogTitle,{id:"edit-value-dialog-title",children:[this.props.t("Write value"),((t=this.props.object.common)==null?void 0:t.write)===!1?L.jsxs("span",{style:Br.readOnlyText,children:["(",this.props.t("read only"),")"]}):null,this.state.chart?L.jsx(E.Fab,{style:{float:"right"},size:"small",color:this.state.chartEnabled?"primary":"default",onClick:()=>{(window._localStorage||window.localStorage).setItem("App.chartSetValue",this.state.chartEnabled?"false":"true"),this.setState({chartEnabled:!this.state.chartEnabled})},children:L.jsx(Ie.ShowChart,{})}):null,this.state.type==="json"?L.jsx(E.IconButton,{style:{float:"right"},onClick:()=>{(window._localStorage||window.localStorage).setItem("App.fullScreen",this.state.fullScreen?"false":"true"),this.setState({fullScreen:!this.state.fullScreen})},children:this.state.fullScreen?L.jsx(Ie.FullscreenExit,{}):L.jsx(Ie.Fullscreen,{})}):null]}),L.jsx(E.DialogContent,{children:L.jsx("form",{noValidate:!0,autoComplete:"off",onSubmit:()=>!1,style:{...Br.dialogForm,height:"100%"},children:L.jsxs(E.Grid2,{container:!0,direction:"row",spacing:2,style:{height:"100%"},children:[L.jsx(E.Grid2,{size:{xs:this.state.chart&&this.state.chartEnabled?6:12},style:{height:"100%"},children:L.jsxs(E.Grid2,{container:!0,direction:"column",spacing:2,style:{marginTop:0,height:"100%"},children:[this.props.expertMode?L.jsx(E.Grid2,{children:L.jsxs(E.Grid2,{container:!0,direction:"row",spacing:2,style:{marginTop:0},children:[this.props.expertMode?L.jsx(E.Grid2,{children:L.jsxs(E.FormControl,{style:Br.formControl,children:[L.jsx(E.InputLabel,{style:{marginTop:10,marginLeft:-14},children:this.props.t("Value type")}),L.jsxs(E.Select,{variant:"standard",value:this.state.type,onChange:r=>{this.setState({type:r.target.value,valid:r.target.value==="number"?Ep.isNumberValid({value:this.state.targetValue,common:this.props.object.common}):!0,jsonError:!1},()=>{this.state.type==="json"&&this.setState({targetValue:(this.state.targetValue||"").toString(),jsonError:Ep.checkJsonError((this.state.targetValue||"").toString())})})},children:[L.jsx(E.MenuItem,{value:"string",children:"String"}),L.jsx(E.MenuItem,{value:"number",children:"Number"}),L.jsx(E.MenuItem,{value:"boolean",children:"Boolean"}),L.jsx(E.MenuItem,{value:"object",children:"JSON/Object"}),this.props.states?L.jsx(E.MenuItem,{value:"states",children:"States"}):null]})]})}):null,this.state.type==="json"?L.jsx(E.Grid2,{flex:1}):null]})}):null,L.jsx(E.Grid2,{flex:this.state.type==="json"&&this.state.fullScreen?1:void 0,style:{paddingTop:0},children:this.state.type==="boolean"?L.jsx(E.Typography,{component:"div",style:this.props.expertMode?{marginTop:20,width:"100%",backgroundColor:this.props.themeType==="dark"?"#595959":"#dadada",borderRadius:5,padding:5}:void 0,children:L.jsxs(E.Grid2,{component:"label",container:!0,alignItems:"center",spacing:1,children:[L.jsxs(E.Grid2,{style:{marginRight:10},children:[this.props.t("Value"),":"]}),L.jsx(E.Grid2,{children:"FALSE"}),L.jsx(E.Grid2,{children:L.jsx(E.Switch,{autoFocus:!0,defaultChecked:this.propsValue==="null"||this.propsValue==="undefined"?!1:!!this.propsValue,onKeyUp:r=>r.key==="Enter"&&this.onUpdate(r),onChange:r=>this.setState({targetValue:r.target.checked})})}),L.jsx(E.Grid2,{children:"TRUE"})]})}):this.state.type==="number"?L.jsx(E.TextField,{variant:"standard",fullWidth:!0,autoFocus:!0,error:!this.state.valid,type:"number",slotProps:{htmlInput:{step:this.props.object.common.step,min:this.props.object.common.min,max:this.props.object.common.max}},inputRef:this.inputRef,helperText:this.props.t("Press ENTER to write the value, when focused"),value:this.state.targetValue.toString(),label:this.props.t("Value")+(this.props.object.common.min!==void 0||this.props.object.common.unit==="%"?`, ${this.props.t("min:")} ${this.props.object.common.min!==void 0?this.props.object.common.min:0}`:"")+(this.props.object.common.max!==void 0||this.props.object.common.unit==="%"?`, ${this.props.t("max:")} ${this.props.object.common.max!==void 0?this.props.object.common.max:100}`:""),onKeyUp:r=>r.key==="Enter"&&this.state.valid&&this.onUpdate(r),onChange:r=>{this.setState({targetValue:r.target.value,valid:Ep.isNumberValid({value:r.target.value,common:this.props.object.common})})}}):this.state.type==="json"?this.renderJsonEditor():this.state.type==="states"?this.renderStates():L.jsx(E.TextField,{variant:"standard",fullWidth:!0,inputRef:this.inputRef,autoFocus:!0,helperText:this.props.t("Press CTRL+ENTER to write the value, when focused"),label:this.props.t("Value"),multiline:!0,onKeyDown:r=>r.ctrlKey&&r.key==="Enter"&&this.onUpdate(r),defaultValue:this.propsValue.toString(),onChange:r=>this.setState({targetValue:r.target.value})})}),(this.props.role==="date"||(i=this.props.role)!=null&&i.startsWith("date."))&&this.state.type==="number"?L.jsx(E.Grid2,{style:{display:"flex",gap:"5px"},size:{xs:6},children:this.renderTimePicker()}):null,this.props.expertMode?L.jsx(E.Grid2,{children:e}):null,this.props.expertMode?L.jsxs(E.Grid2,{children:[L.jsxs(E.FormControl,{variant:"standard",style:Br.quality,children:[L.jsx(E.InputLabel,{children:this.props.t("Quality")}),L.jsxs(E.Select,{variant:"standard",defaultValue:0,onChange:r=>this.q=Number(r.target.value),children:[L.jsx(E.MenuItem,{value:0,children:"0x00 - good"}),L.jsx(E.MenuItem,{value:1,children:"0x01 - general problem"}),L.jsx(E.MenuItem,{value:2,children:"0x02 - no connection problem"}),L.jsx(E.MenuItem,{value:16,children:"0x10 - substitute value from controller"}),L.jsx(E.MenuItem,{value:32,children:"0x20 - substitute initial value"}),L.jsx(E.MenuItem,{value:64,children:"0x40 - substitute value from device or instance"}),L.jsx(E.MenuItem,{value:128,children:"0x80 - substitute value from sensor"}),L.jsx(E.MenuItem,{value:17,children:"0x11 - general problem by instance"}),L.jsx(E.MenuItem,{value:65,children:"0x41 - general problem by device"}),L.jsx(E.MenuItem,{value:129,children:"0x81 - general problem by sensor"}),L.jsx(E.MenuItem,{value:18,children:"0x12 - instance not connected"}),L.jsx(E.MenuItem,{value:66,children:"0x42 - device not connected"}),L.jsx(E.MenuItem,{value:130,children:"0x82 - sensor not connected"}),L.jsx(E.MenuItem,{value:68,children:"0x44 - device reports error"}),L.jsx(E.MenuItem,{value:132,children:"0x84 - sensor reports error"})]})]}),L.jsx(E.TextField,{variant:"standard",title:this.props.t("0 - no expiration"),sx:{"&.MuiTextField-root":Br.expire},label:this.props.t("Expire"),type:"number",slotProps:{htmlInput:{min:0}},helperText:this.props.t("in seconds"),defaultValue:this.expire,onChange:r=>this.expire=Number(r.target.value)})]}):null]})}),this.state.chart&&this.state.chartEnabled&&this.state.type!=="json"?L.jsx(E.Grid2,{size:{xs:6},style:{minHeight:300},sx:{display:{sm:"none",md:"inline-block"}},children:this.renderChart()}):null]})})}),L.jsxs(E.DialogActions,{sx:Br.wrapperButton,children:[this.props.expertMode?null:e,this.props.expertMode?null:L.jsx("div",{style:{flexGrow:1}}),L.jsx(E.Button,{variant:"contained",disabled:!this.state.valid,onClick:r=>this.onUpdate(r),color:"primary",startIcon:this.props.width!=="xs"?L.jsx(Ie.Check,{}):void 0,style:((n=this.props.object.common)==null?void 0:n.write)===!1?Br.readOnly:void 0,children:this.props.width!=="xs"?this.props.t("Set value"):L.jsx(Ie.Check,{fontSize:"large"})}),L.jsx(E.Button,{variant:"contained",onClick:()=>this.props.onClose(),color:"grey",startIcon:this.props.width!=="xs"?L.jsx(Ie.Close,{}):void 0,children:this.props.width!=="xs"?this.props.t("Cancel"):L.jsx(Ie.Close,{fontSize:"large"})})]})]})}}const se={divWithoutTitle:{width:"100%",height:"100%",border:"2px solid #00000000"},divWithoutTitleAndTab:{height:"calc(100% - 48px)"},error:{border:"2px solid #FF0000"},id:{fontStyle:"italic"},dialog:{height:"calc(100% - 64px)"},aliasIdEdit:{width:368},button:{marginTop:20,marginLeft:8},funcDivEdit:{width:"100%"},funcEditName:{display:"inline-block",width:85},funcEdit:{width:400},funcIcon:{width:16,height:16},marginTop:{marginTop:20},commonTabWrapper:{flexFlow:"wrap",display:"flex",gap:8},commonWrapper:{width:500,minWidth:300},flexDrop:{width:"100%",maxWidth:500,margin:"auto",display:"flex"},marginBlock:{marginTop:20},buttonAdd:{minWidth:150},textField:{width:"100%"},flex:{display:"flex","& > div":{mr:"8px"}},close:{width:"20px",height:"20px",opacity:"0.9",cursor:"pointer",position:"relative",top:20,marginTop:"10px",transition:"all 0.6s ease","&:hover":{transform:"rotate(90deg)"},"&:before":{position:"absolute",left:"9px",content:'""',height:"20px",width:"3px",backgroundColor:"#ff4f4f",transform:"rotate(45deg)"},"&:after":{position:"absolute",left:"9px",content:'""',height:"20px",width:"3px",backgroundColor:"#ff4f4f",transform:"rotate(-45deg)"}},color:{width:70},buttonRemoveWrapper:{position:"absolute",zIndex:222,right:0},tabsPadding:{padding:"0px 24px"},wrapperButton:{"@media screen and (max-width: 465px)":{"& *":{fontSize:10}},"@media screen and (max-width: 380px)":{"& *":{fontSize:9}}},commonDeleteTip:{color:"#fa4a4a"},typeNameEng:{marginLeft:8,opacity:.7,fontStyle:"italic",fontSize:"smaller"},tooltip:{pointerEvents:"none"},stateRow:{width:"100%",display:"flex",justifyContent:"space-between",padding:3},stateTitle:{minWidth:150,fontWeight:"bold"},stateUnit:{opacity:.7,marginLeft:4},stateValue:{animation:"newStateEditorAnimation 2s ease-in-out"},stateTime:{fontStyle:"italic"},stateImage:{maxWidth:200,maxHeight:200}};function Nme(s,e){return{"@keyframes newStateEditorAnimation":{"0%":{color:s.palette.mode==="dark"?"#27cf00":"#174e00"},"100%":{color:e||(s.palette.mode==="dark"?"#ffffff":"#000000")}}}}const Bb=[{role:"button",type:"boolean",r:!1,w:!0},{role:"button.close.blind",type:"boolean",r:!1,w:!0},{role:"button.close.tilt",type:"boolean",r:!1,w:!0},{role:"button.fastforward",type:"boolean",r:!1,w:!0},{role:"button.forward",type:"boolean",r:!1,w:!0},{role:"button.long",type:"boolean",r:!1,w:!0},{role:"button.mode",type:"boolean",r:!1,w:!0},{role:"button.mode.auto",type:"boolean",r:!1,w:!0},{role:"button.mode.manual",type:"boolean",r:!1,w:!0},{role:"button.mode.silent",type:"boolean",r:!1,w:!0},{role:"button.next",type:"boolean",r:!1,w:!0},{role:"button.open.blind",type:"boolean",r:!1,w:!0},{role:"button.open.door",type:"boolean",r:!1,w:!0},{role:"button.open.tilt",type:"boolean",r:!1,w:!0},{role:"button.open.window",type:"boolean",r:!1,w:!0},{role:"button.pause",type:"boolean",w:!0},{role:"button.play",type:"boolean",w:!0},{role:"button.press",type:"boolean",r:!1,w:!0},{role:"button.press",type:"boolean",r:!0,w:!1},{role:"button.prev",type:"boolean",w:!0},{role:"button.resume",type:"boolean",r:!1,w:!0},{role:"button.start",type:"boolean",r:!1,w:!0},{role:"button.pause",type:"boolean",r:!1,w:!0},{role:"button.stop",type:"boolean",r:!1,w:!0},{role:"button.stop.tilt",type:"boolean",r:!1,w:!0},{role:"button.volume.up",type:"boolean",r:!1,w:!0},{role:"chart",type:"string"},{role:"date",type:"number"},{role:"date",type:"string"},{role:"date.end",type:"number"},{role:"date.end",type:"string"},{role:"date.forecast.1",type:"string"},{role:"date.start",type:"number"},{role:"date.start",type:"string"},{role:"date.sunrise",type:"number"},{role:"date.sunrise",type:"string"},{role:"date.sunset",type:"number"},{role:"date.sunset",type:"string"},{role:"dayofweek",type:"number"},{role:"html",type:"string"},{role:"indicator",type:"boolean",w:!1},{role:"indicator.alarm",type:"boolean",w:!1},{role:"indicator.alarm.fire",type:"boolean",w:!1},{role:"indicator.alarm.flood",type:"boolean",w:!1},{role:"indicator.alarm.health",type:"boolean",w:!1},{role:"indicator.alarm.secure",type:"boolean",w:!1},{role:"indicator.connected",type:"boolean",w:!1},{role:"indicator.maintenance",type:"boolean",w:!1},{role:"indicator.maintenance.alarm",type:"boolean",w:!1},{role:"indicator.maintenance.lowbat",type:"boolean",w:!1},{role:"indicator.maintenance.waste",type:"boolean",w:!1},{role:"indicator.reachable",type:"boolean",w:!1},{role:"info.address",type:"string",w:!1},{role:"info.display",type:"string",w:!1},{role:"info.firmware",type:"string",w:!1},{role:"info.hardware",type:"string",w:!1},{role:"info.ip",type:"string",w:!1},{role:"info.mac",type:"string",w:!1},{role:"info.model",type:"string",w:!1},{role:"info.name",type:"string",w:!1},{role:"info.port",type:"number",w:!1},{role:"info.port",type:"string",w:!1},{role:"info.serial",type:"string",w:!1},{role:"info.standby",type:"string",w:!1},{role:"info.status",w:!1},{role:"json",type:"string"},{role:"level",type:"number",w:!0},{role:"level.bass",type:"number",w:!0},{role:"level.blind",type:"number",w:!0},{role:"level.brightness",type:"number",w:!0},{role:"level.color.blue",type:"number",w:!0},{role:"level.color.hue",type:"number",w:!0},{role:"level.color.luminance",type:"number",w:!0},{role:"level.color.red",type:"number",w:!0},{role:"level.color.rgb",type:"string",w:!0},{role:"level.color.rgbw",type:"string",w:!0},{role:"level.color.saturation",type:"number",w:!0},{role:"level.color.temperature",type:"number",w:!0},{role:"level.curtain",type:"number",w:!0},{role:"level.mode.airconditioner",type:"number",w:!0},{role:"level.mode.cleanup",type:"number",w:!0},{role:"level.mode.fan",type:"number",w:!0},{role:"level.mode.swing",type:"number",w:!0},{role:"level.mode.thermostat",type:"number",w:!0},{role:"level.mode.work",type:"number",w:!0},{role:"level.temperature",type:"number",w:!0},{role:"level.tilt",type:"number",w:!0},{role:"level.timer",type:"number",w:!0},{role:"level.treble",type:"number",w:!0},{role:"level.valve",type:"number",w:!0},{role:"level.volume",type:"number",w:!0},{role:"level.volume.group",type:"number",w:!0},{role:"list",type:"array"},{role:"list",type:"string"},{role:"location",type:"string"},{role:"media.add",type:"string"},{role:"media.bitrate",type:"number"},{role:"media.bitrate",type:"string"},{role:"media.broadcastDate",type:"string"},{role:"media.browser",type:"string"},{role:"media.clear",type:"boolean"},{role:"media.content",type:"string"},{role:"media.cover",type:"string"},{role:"media.cover.big",type:"string"},{role:"media.cover.small",type:"string"},{role:"media.date",type:"string"},{role:"media.duration",type:"number"},{role:"media.duration",type:"string"},{role:"media.duration.text",type:"string"},{role:"media.elapsed",type:"number"},{role:"media.elapsed",type:"string"},{role:"media.elapsed.text",type:"string"},{role:"media.episode",type:"number"},{role:"media.episode",type:"string"},{role:"media.genre",type:"string"},{role:"media.input",type:"string"},{role:"media.jump",type:"string"},{role:"media.link",type:"string"},{role:"media.mode.repeat",type:"string"},{role:"media.mode.shuffle",type:"string"},{role:"media.mute",type:"string"},{role:"media.mute.group",type:"string"},{role:"media.playid",type:"string"},{role:"media.playlist",type:"string"},{role:"media.season",type:"string"},{role:"media.seek",type:"string"},{role:"media.state",type:"string"},{role:"media.titel",type:"string"},{role:"media.track",type:"string"},{role:"media.tts",type:"string"},{role:"media.url",type:"string"},{role:"media.url.announcement",type:"string"},{role:"medien.artist",type:"string"},{role:"sensor.alarm",type:"boolean",w:!1},{role:"sensor.alarm.fire",type:"boolean",w:!1},{role:"sensor.alarm.flood",type:"boolean",w:!1},{role:"sensor.alarm.power",type:"boolean",w:!1},{role:"sensor.alarm.secure",type:"boolean",w:!1},{role:"sensor.contact",type:"boolean",w:!1},{role:"sensor.door",type:"boolean",w:!1},{role:"sensor.light",type:"boolean",w:!1},{role:"sensor.lock",type:"boolean",w:!1},{role:"sensor.motion",type:"boolean",w:!1},{role:"sensor.noise",type:"boolean",w:!1},{role:"sensor.rain",type:"boolean",w:!1},{role:"sensor.window",type:"boolean",w:!1},{role:"state",type:"mixed"},{role:"string.date",type:"number"},{role:"switch",type:"boolean",w:!0},{role:"switch.enable",type:"boolean",w:!0},{role:"switch.gate",type:"boolean",w:!0},{role:"switch.gate",type:"boolean",w:!0},{role:"switch.light",type:"boolean",w:!0},{role:"switch.lock",type:"boolean",w:!0},{role:"switch.lock.door",type:"boolean",w:!0},{role:"switch.lock.window",type:"boolean",w:!0},{role:"switch.mode",type:"boolean",w:!0},{role:"switch.mode.auto",type:"boolean",w:!0},{role:"switch.mode.boost",type:"boolean",w:!0},{role:"switch.mode.color",type:"boolean",w:!0},{role:"switch.mode.manual",type:"boolean",w:!0},{role:"switch.mode.moonlight",type:"boolean",w:!0},{role:"switch.mode.party",type:"boolean",w:!0},{role:"switch.mode.silent",type:"boolean",w:!0},{role:"switch.power",type:"boolean",w:!0},{role:"switch.power.zone",type:"boolean",w:!0},{role:"text",type:"string"},{role:"text.phone",type:"string"},{role:"text.url",type:"string"},{role:"time.interval",type:"number"},{role:"time.span",type:"number"},{role:"time.timeout",type:"number"},{role:"url",type:"string"},{role:"url.audio",type:"string"},{role:"url.blank",type:"string"},{role:"url.cam",type:"string"},{role:"url.icon",type:"string"},{role:"url.same",type:"string"},{role:"value",type:"number",w:!1},{role:"value.battery",type:"number",w:!1},{role:"value.blind",type:"number",w:!1},{role:"value.blood.sugar",type:"number",w:!1},{role:"value.brightness",type:"number",w:!1},{role:"value.co2",type:"number",w:!1},{role:"value.clouds",type:"number",w:!1},{role:"value.current",type:"number",w:!1},{role:"value.curtain",type:"number",w:!1},{role:"value.date",type:"string",w:!1},{role:"value.datetime",type:"string",w:!1},{role:"value.default",type:"number",w:!1},{role:"value.direction",type:"number",w:!1},{role:"value.direction.max.wind",type:"number",w:!1},{role:"value.direction.min.wind",type:"number",w:!1},{role:"value.direction.wind",type:"number",w:!1},{role:"value.direction.wind.forecast.0",type:"number",w:!1},{role:"value.direction.wind.forecast.1",type:"number",w:!1},{role:"value.distance",type:"number",w:!1},{role:"value.energy",type:"number",w:!1},{role:"value.fill",type:"number",w:!1},{role:"value.gate",type:"number",w:!1},{role:"value.gps",type:"number",w:!1},{role:"value.gps.accuracy",type:"number",w:!1},{role:"value.gps.elevation",type:"number",w:!1},{role:"value.gps.latitude",type:"number",w:!1},{role:"value.gps.longitude",type:"number",w:!1},{role:"value.gps.radius",type:"number",w:!1},{role:"value.health.bmi",type:"number",w:!1},{role:"value.health.bpm",type:"number",w:!1},{role:"value.health.calories",type:"number",w:!1},{role:"value.health.fat",type:"number",w:!1},{role:"value.health.steps",type:"number",w:!1},{role:"value.health.weight",type:"number",w:!1},{role:"value.humidity",type:"number",w:!1},{role:"value.humidity",type:"number",w:!1},{role:"value.humidity.max",type:"number",w:!1},{role:"value.humidity.min",type:"number",w:!1},{role:"value.interval",type:"number",w:!1},{role:"value.lock",type:"number",w:!1},{role:"value.min",type:"number",w:!1},{role:"value.position",type:"number",w:!1},{role:"value.power",type:"number",w:!1},{role:"value.power.consumption",type:"number",w:!1},{role:"value.power.production",type:"number",w:!1},{role:"value.power.reactive",type:"number",w:!1},{role:"value.precipitation",type:"number",w:!1},{role:"value.precipitation.chance",type:"number",w:!1},{role:"value.precipitation.day.forecast.0",type:"number",w:!1},{role:"value.precipitation.forecast.0",type:"number",w:!1},{role:"value.precipitation.forecast.0",type:"number",w:!1},{role:"value.precipitation.forecast.1",type:"number",w:!1},{role:"value.precipitation.forecast.1",type:"number",w:!1},{role:"value.precipitation.hour",type:"number",w:!1},{role:"value.precipitation.night.forecast.0",type:"number",w:!1},{role:"value.precipitation.today",type:"number",w:!1},{role:"value.precipitation.type",type:"number",w:!1},{role:"value.pressure",type:"number",w:!1},{role:"value.pressure.forecast.0",type:"number",w:!1},{role:"value.pressure.forecast.1",type:"number",w:!1},{role:"value.radiation",type:"number",w:!1},{role:"value.rain",type:"number",w:!1},{role:"value.rain.hour",type:"number",w:!1},{role:"value.rain.today",type:"number",w:!1},{role:"value.severity",type:"number",w:!1},{role:"value.snow",type:"number",w:!1},{role:"value.snow.hour",type:"number",w:!1},{role:"value.snow.today",type:"number",w:!1},{role:"value.snowline",type:"number",w:!1},{role:"value.speed",type:"number",w:!1},{role:"value.speed.max.wind",type:"number",w:!1},{role:"value.speed.min.wind",type:"number",w:!1},{role:"value.speed.wind",type:"number",w:!1},{role:"value.speed.wind.forecast.0",type:"number",w:!1},{role:"value.speed.wind.gust",type:"number",w:!1},{role:"value.state",type:"number",w:!1},{role:"value.sun.azimuth",type:"number",w:!1},{role:"value.sun.elevation",type:"number",w:!1},{role:"value.temperature",type:"number",w:!1},{role:"value.temperature",type:"number",w:!1},{role:"value.temperature.dewpoint",type:"number",w:!1},{role:"value.temperature.feelslike",type:"number",w:!1},{role:"value.temperature.max",type:"number",w:!1},{role:"value.temperature.max.forecast.0",type:"number",w:!1},{role:"value.temperature.min",type:"number",w:!1},{role:"value.temperature.min.forecast.0",type:"number",w:!1},{role:"value.temperature.min.forecast.1",type:"number",w:!1},{role:"value.temperature.windchill",type:"number",w:!1},{role:"value.tilt",type:"number",w:!1},{role:"value.time",type:"number",w:!1},{role:"value.uv",type:"number",w:!1},{role:"value.valve",type:"number",w:!1},{role:"value.voltage",type:"number",w:!1},{role:"value.warning",type:"number",w:!1},{role:"value.waste",type:"number",w:!1},{role:"value.water",type:"number",w:!1},{role:"weather.chart.url",type:"string",w:!1},{role:"weather.chart.url.forecast",type:"string",w:!1},{role:"weather.direction.wind",type:"number",w:!1},{role:"weather.direction.wind.forecast.0",type:"number",w:!1},{role:"weather.html",type:"string",w:!1},{role:"weather.icon",type:"string",w:!1},{role:"weather.icon.forecast.1",type:"string",w:!1},{role:"weather.icon.name",type:"string",w:!1},{role:"weather.icon.wind",type:"string",w:!1},{role:"weather.json",type:"string",w:!1},{role:"weather.state",type:"number",w:!1},{role:"weather.state",type:"string",w:!1},{role:"weather.state.forecast.0",type:"string",w:!1},{role:"weather.sunrise",type:"string",w:!1},{role:"weather.sunset",type:"string",w:!1},{role:"weather.state.forecast.1",type:"string",w:!1},{role:"weather.temperature",type:"number",w:!1},{role:"weather.title",type:"string",w:!1},{role:"weather.title.forecast.0",type:"string",w:!1},{role:"weather.title.short",type:"string",w:!1},{role:"weather.type",type:"number",w:!1},{role:"weather.type",type:"string",w:!1}];class $n extends Te.Component{originalObj;subscribed=!1;updateTimer=null;constructor(e){super(e);const t=this.props.obj._id.startsWith("alias.0")&&this.props.obj.type==="state";let i=(window._localStorage||window.localStorage).getItem(`${this.props.dialogName||"App"}.editTab`)||"object";const n=ee.Router.getLocation();n.tab==="tab-objects"&&n.dialog==="edit"&&n.id===this.props.obj._id&&n.arg&&(i=n.arg),i==="alias"&&!t&&(i="common"),this.props.aliasTab&&t&&(i="alias");const r=this.props.obj,o=r.common&&"type"in r.common&&"alias"in r.common?r.common.alias.read:void 0,a=r.common&&"type"in r.common&&"alias"in r.common?r.common.alias.write:void 0;this.state={text:JSON.stringify(this.props.obj,null,2),error:!1,customError:!1,changed:!1,readError:this.checkFunction(o,!1),writeError:this.checkFunction(a,!0),tab:i,showCopyDialog:"",showCommonDeleteMessage:!1,selectId:!1,selectRead:!1,selectWrite:!1,newId:"",lang:ee.I18n.getLanguage(),value:void 0},xT.locale(this.state.lang),this.originalObj=JSON.stringify(this.props.obj,null,2)}async componentDidMount(){var i,n,r;const e=((n=(i=this.props.obj)==null?void 0:i.common)==null?void 0:n.editSchemas)||((r=this.props.obj)==null?void 0:r.editSchemas),t=[];if(e)if(typeof e=="object"){const o=Object.keys(e);for(let a=0;a<o.length;a++)try{const l=await ee.iobUriRead(e[o[a]],this.props.socket);if(l.key=o[a],l&&typeof l=="object"&&t.push(l),l.icon)try{const h=ee.iobUriParse(l.icon);if(h.type!=="base64"&&h.type!=="http"){const c=await ee.iobUriRead(h,this.props.socket);c&&(l.icon=c)}}catch(h){console.warn(`Cannot get icon for schema from "${l.icon}": ${h}`),l.icon=void 0}}catch(l){console.warn(`Cannot get edit schema for "${e[o[a]]}": ${l}`)}t.length&&(t.sort((a,l)=>a.order!==void 0&&l.order!==void 0?a.order-l.order:a.order!==void 0?-1:l.order!==void 0||a.key>l.key?1:-1),this.setState({customEditTabs:t}))}else console.warn(`Invalid edit schema for "${e}": expected object, but got ${typeof e}`);this.state.tab==="alias"&&(!this.props.obj._id.startsWith("alias.0")||this.props.obj.type!=="state")?this.setState({tab:"object"}):this.state.tab==="state"&&this.props.obj.type!=="state"?this.setState({tab:"object"}):this.state.tab!=="object"&&this.state.tab!=="common"&&this.state.tab!=="alias"&&this.state.tab!=="state"&&!t.find(o=>o.key===this.state.tab)&&this.setState({tab:"object"}),this.state.tab==="state"&&this.subscribeOnState(!0),this.props.socket.subscribeObject(this.props.obj._id,this.onObjectUpdated),this.isRouted()&&setTimeout(()=>{this.isRouted()&&ee.Router.getLocation().arg!==this.state.tab&&ee.Router.doNavigate(null,null,null,this.state.tab)},0)}componentWillUnmount(){this.updateTimer&&(clearInterval(this.updateTimer),this.updateTimer=null),this.subscribeOnState(!1),this.props.socket.unsubscribeObject(this.props.obj._id,this.onObjectUpdated)}onObjectUpdated=(e,t)=>{this.originalObj!==JSON.stringify(t,null,2)&&(this.originalObj=JSON.stringify(t,null,2),this.state.changed?this.forceUpdate():this.setState({text:this.originalObj}))};checkFunction(e,t){var r,o,a,l;if(!e||e.includes("JSON.parse("))return"";let i;try{i=JSON.parse(this.state.text)}catch{}let n;try{n=new Function("val",e.includes("return")?e:`return ${e}`)}catch{return this.props.t("Cannot parse code!")}if((r=i==null?void 0:i.common)!=null&&r.type&&((l=(a=this.props.objects[(o=i.common.alias)==null?void 0:o.id])==null?void 0:a.common)!=null&&l.type)){const h=t?i.common.type:this.props.objects[i.common.alias.id].common.type,c=t?this.props.objects[i.common.alias.id].common.type:i.common.type;if(h&&c){let u=null;if(h==="boolean"?u=!0:h==="number"?u=1:(h==="string"||h==="mixed")&&(u="string"),u!==null)try{const d=n(u);return c==="mixed"?"":d!==null&&typeof d!==c?this.props.t("Type of result is not as expected: %s",c):""}catch(d){return`${this.props.t("Cannot execute function")}: ${d.toString()}`}}}return""}prepareObject(e){var t,i,n,r;e=e||this.state.text;try{const o=JSON.parse(e);return o._id=this.props.obj._id,(t=o.common)!=null&&t.alias&&(o.common.alias.id||delete o.common.alias.id,(!o.common.alias.read&&o.common.alias.read!==void 0||o.common.alias.read==="val")&&delete o.common.alias.read,(!o.common.alias.write&&o.common.alias.write!==void 0||o.common.alias.write==="val")&&delete o.common.alias.write,!o.common.alias.id&&!o.common.alias.read&&!o.common.alias.write&&delete o.common.alias),((i=o.common)==null?void 0:i.min)!==void 0&&typeof o.common.min!="number"&&(o.common.min=parseFloat(o.common.min)),((n=o.common)==null?void 0:n.max)!==void 0&&typeof o.common.max!="number"&&(o.common.max=parseFloat(o.common.max)),((r=o.common)==null?void 0:r.step)!==void 0&&typeof o.common.step!="number"&&(o.common.step=parseFloat(o.common.step)),o}catch{return null}}onChange(e,t){var r,o,a,l;const i=this.prepareObject(e),n={text:e};if(i){n.changed=this.originalObj!==JSON.stringify(i,null,2),n.showCommonDeleteMessage=!1;const h=JSON.parse(this.originalObj);i.common&&Object.keys(h.common||{}).forEach(c=>{i.common[c]===void 0&&(n.showCommonDeleteMessage=!0)}),n.error=!1,n.readError=this.checkFunction((o=(r=i.common)==null?void 0:r.alias)==null?void 0:o.read,!1),n.writeError=this.checkFunction((l=(a=i.common)==null?void 0:a.alias)==null?void 0:l.write,!0)}else n.showCommonDeleteMessage=!1,n.error=!0;this.setState(n,()=>t&&t())}onUpdate(){var e,t,i,n;try{const r=JSON.parse(this.state.text);r._id=this.props.obj._id,(e=r.common)!=null&&e.alias&&(r.common.alias.id||delete r.common.alias.id,(!r.common.alias.read&&r.common.alias.read!==void 0||r.common.alias.read==="val")&&delete r.common.alias.read,(!r.common.alias.write&&r.common.alias.write!==void 0||r.common.alias.write==="val")&&delete r.common.alias.write,!r.common.alias.id&&!r.common.alias.read&&!r.common.alias.write&&delete r.common.alias),((t=r.common)==null?void 0:t.min)!==void 0&&typeof r.common.min!="number"&&(r.common.min=parseFloat(r.common.min)),((i=r.common)==null?void 0:i.max)!==void 0&&typeof r.common.max!="number"&&(r.common.max=parseFloat(r.common.max)),((n=r.common)==null?void 0:n.step)!==void 0&&typeof r.common.step!="number"&&(r.common.step=parseFloat(r.common.step)),this.props.onClose(r)}catch{console.error(`Cannot parse: ${this.state.text}`)}}static getPartOfObject(e,t){return t?ee.getAttrInObject(JSON.parse(e),t.split(".")):JSON.parse(e)}static setPartOfObject(e,t,i){let n=JSON.parse(e);return n===void 0?e:(n=ee.setAttrInObject(n,i.split("."),t),JSON.stringify(n,null,2))}renderCustomPanel(){var i;const e=(i=this.state.customEditTabs)==null?void 0:i.find(n=>n.key===this.state.tab);if(!e)return null;let t;try{t=$n.getPartOfObject(this.state.text,e.path)}catch(n){return console.error(`Cannot get data for ${e.path}: ${n}`),L.jsx("div",{children:ee.I18n.t("Cannot get data for %s: %s",e.path,n)})}return t?L.jsx(_p.JsonConfigComponent,{theme:this.props.theme,socket:this.props.socket,themeName:this.props.theme.palette.mode,themeType:this.props.theme.palette.mode,dateFormat:this.props.dateFormat,isFloatComma:this.props.isFloatComma,schema:e.json,data:t,onChange:n=>{try{const r=$n.setPartOfObject(this.state.text,n,e.path);this.onChange(r)}catch(r){console.error(`Cannot set data for ${e.path}: ${r}`)}},adapterName:"",instance:0,onError:n=>{console.warn(`Error in JSON editor: ${n}`),this.state.customError!==n&&this.setState({customError:n})}}):L.jsx("div",{children:ee.I18n.t("Cannot get data for %s",e.path)})}renderCustomTab(e,t){var r;let i;if(!t||!ee.getAttrInObject(t,(r=e.path)==null?void 0:r.split(".")))return null;e.color&&(i={backgroundColor:e.color,color:ee.Utils.invertColor(e.color,!0)});const n=e.label&&typeof e.label=="object"?e.label[this.state.lang]||e.label.en:e.noTranslation?e.label||e.key:this.props.t(e.label||e.key);return L.jsx(E.Tab,{disabled:this.state.error||this.state.customError,value:e.key,label:n,style:i,iconPosition:"start",icon:e.icon?L.jsx(ee.Icon,{src:e.icon,style:se.funcIcon}):void 0})}renderStateTab(){return this.props.obj.type!=="state"||this.props.obj.common.type==="file"?null:L.jsx(E.Tab,{disabled:this.state.customError||this.state.error,value:"state",label:this.props.t("State")})}renderStatePanel(){var r;if(this.state.value===void 0||this.state.value===null)return L.jsx("div",{children:this.props.t("State does not exist")});if(typeof this.state.value!="object")return L.jsxs("div",{style:{maxWidth:700},children:[L.jsx("div",{children:this.props.t("State is invalid")}),L.jsx("div",{children:L.jsx("pre",{children:JSON.stringify(this.state.value,null,4)})})]});let e;const t={},i=this.state.value.val,n=typeof i;if(i===void 0)e="[undef]",t.color="#bc6400",t.fontStyle="italic";else if(i===null)e="(null)",t.color="#0047b1",t.fontStyle="italic";else if(typeof this.props.obj.common.role=="string"&&this.props.obj.common.role.match(/^value\.time|^date/))if(i&&n==="string")if(ee.Utils.isStringInteger(i))e=new Date(parseInt(i,10)).toString();else try{const o=new Date(i);ee.Utils.isValidDate(o)&&(e=o.toString())}catch{}else i&&n==="number"&&(i>946681200&&i<9466812e5?e=new Date(i*1e3).toString():i>9466812e8&&(e=new Date(i).toString()));return e||(n==="number"?Number.isInteger(i)||(e=(Math.round(i*1e9)/1e9).toString(),this.props.isFloatComma&&(e=e.toString().replace(".",","))):n==="boolean"?(e=i?ee.I18n.t("true"):ee.I18n.t("false"),t.color=i?"#139800":"#cd6b55"):n==="object"?e=JSON.stringify(i):n==="string"&&i.startsWith("data:image/")?e=L.jsx("img",{src:i,alt:"img",style:se.stateImage}):e=i.toString()),Object.assign(t,Nme(this.props.theme,t.color)),L.jsxs(E.Box,{style:{...se.divWithoutTitle,padding:"24px 24px 0 24px",fontSize:16,maxWidth:400},sx:{"& .value-line:hover":{backgroundColor:"#00000030"}},children:[L.jsxs("div",{className:"value-line",style:{...se.stateRow,marginBottom:24},children:[L.jsxs("div",{style:se.stateTitle,children:[ee.I18n.t("ra_tooltip_value"),":"]}),L.jsxs(E.Box,{component:"div",sx:t,style:se.stateValue,children:[e,(r=this.props.obj.common)!=null&&r.unit?L.jsx("span",{style:se.stateUnit,children:this.props.obj.common.unit}):null]},typeof e=="string"?e:"image")]}),L.jsxs("div",{style:se.stateRow,className:"value-line",children:[L.jsxs("div",{style:se.stateTitle,children:[ee.I18n.t("Type"),":"]}),L.jsx("div",{style:se.stateValue,children:n})]}),L.jsxs("div",{style:se.stateRow,className:"value-line",children:[L.jsxs("div",{style:se.stateTitle,children:[ee.I18n.t("ra_tooltip_ts"),":"]}),L.jsx(E.Tooltip,{title:new Date(this.state.value.ts).toLocaleString(),slotProps:{popper:{sx:se.tooltip}},children:L.jsx("div",{style:se.stateValue,children:L.jsx("span",{style:se.stateTime,children:xT(this.state.value.ts).fromNow()})})})]}),L.jsxs("div",{style:se.stateRow,className:"value-line",children:[L.jsxs("div",{style:se.stateTitle,children:[ee.I18n.t("ra_tooltip_ack"),":"]}),L.jsxs("div",{style:{...se.stateValue,color:this.state.value.ack?"green":"red"},children:[this.state.value.ack?ee.I18n.t("Acknowledged"):ee.I18n.t("Command"),this.state.value.ack?" (true)":" (false)"]})]}),L.jsxs("div",{style:se.stateRow,className:"value-line",children:[L.jsxs("div",{style:se.stateTitle,children:[ee.I18n.t("ra_tooltip_lc"),":"]}),L.jsx(E.Tooltip,{title:new Date(this.state.value.lc).toLocaleString(),slotProps:{popper:{sx:se.tooltip}},children:L.jsx("div",{style:se.stateValue,children:L.jsx("span",{style:se.stateTime,children:xT(this.state.value.lc).fromNow()})})})]}),L.jsxs("div",{style:se.stateRow,className:"value-line",children:[L.jsxs("div",{style:se.stateTitle,children:[ee.I18n.t("ra_tooltip_quality"),":"]}),L.jsx("div",{style:se.stateValue,children:ee.Utils.quality2text(this.state.value.q||0).join(", ")})]}),L.jsxs("div",{style:se.stateRow,className:"value-line",children:[L.jsxs("div",{style:se.stateTitle,children:[ee.I18n.t("ra_tooltip_from"),":"]}),L.jsx("div",{style:se.stateValue,children:this.state.value.from})]}),L.jsxs("div",{style:se.stateRow,className:"value-line",children:[L.jsxs("div",{style:se.stateTitle,children:[ee.I18n.t("ra_tooltip_user"),":"]}),L.jsx("div",{style:se.stateValue,children:this.state.value.user||"--"})]}),this.state.value.expire?L.jsxs("div",{style:se.stateRow,className:"value-line",children:[L.jsxs("div",{style:se.stateTitle,children:[ee.I18n.t("ra_tooltip_expire"),":"]}),L.jsxs("div",{style:se.stateValue,children:[this.state.value.expire," ",ee.I18n.t("sc_seconds")]})]}):null,this.state.value.c?L.jsxs("div",{style:se.stateRow,className:"value-line",children:[L.jsxs("div",{style:se.stateTitle,children:[ee.I18n.t("ra_tooltip_comment"),":"]}),L.jsx("div",{style:se.stateValue,children:this.state.value.c})]}):null]})}onStateChange=(e,t)=>{JSON.stringify(t)!==JSON.stringify(this.state.value)&&this.setState({value:t})};subscribeOnState(e){e?this.subscribed||(this.updateTimer||(this.updateTimer=setInterval(()=>{this.forceUpdate()},5e3)),this.subscribed=!0,this.props.socket.subscribeState(this.props.obj._id,this.onStateChange)):this.subscribed&&(this.updateTimer&&(clearInterval(this.updateTimer),this.updateTimer=null),this.subscribed=!1,this.props.socket.unsubscribeState(this.props.obj._id,this.onStateChange))}isRouted(){const e=ee.Router.getLocation();return e.tab==="tab-objects"&&e.dialog==="edit"&&e.id===this.props.obj._id}renderTabs(e){var t;return L.jsxs(E.Tabs,{style:se.tabsPadding,value:this.state.tab,onChange:(i,n)=>{var r,o,a;if((window._localStorage||window.localStorage).setItem(`${this.props.dialogName||"App"}.editTab`,n),this.isRouted()&&ee.Router.doNavigate(null,null,null,n),n==="object"){try{const l=JSON.parse(this.state.text);let h=!1;((r=l.common)==null?void 0:r.min)!==void 0&&typeof l.common.min!="number"&&(l.common.min=parseFloat(l.common.min),h=!0),((o=l.common)==null?void 0:o.max)!==void 0&&typeof l.common.max!="number"&&(l.common.max=parseFloat(l.common.max),h=!0),((a=l.common)==null?void 0:a.step)!==void 0&&typeof l.common.step!="number"&&(l.common.step=parseFloat(l.common.step),h=!0),h&&this.setState({text:JSON.stringify(l,null,2)})}catch{}this.subscribeOnState(!1)}else n==="state"?this.subscribeOnState(!0):this.subscribeOnState(!1);this.setState({tab:n})},children:[L.jsx(E.Tab,{value:"common",disabled:this.state.customError||this.state.error,label:this.props.t("common")}),L.jsx(E.Tab,{value:"object",disabled:this.state.customError,label:this.props.t("Object data")}),this.renderStateTab(),this.props.obj._id.startsWith("alias.0")&&this.props.obj.type==="state"&&L.jsx(E.Tab,{disabled:this.state.customError||this.state.error,value:"alias",label:this.props.t("Alias")}),(t=this.state.customEditTabs)==null?void 0:t.map(i=>this.renderCustomTab(i,e))]})}renderSelectDialog(){var i,n,r,o;if(!this.state.selectId&&!this.state.selectRead&&!this.state.selectWrite)return null;let e="",t;try{t=JSON.parse(this.state.text);const a=t.common&&"type"in t.common&&"alias"in t.common?(i=t.common.alias)==null?void 0:i.read:"",l=t.common&&"type"in t.common&&"alias"in t.common?(n=t.common.alias)==null?void 0:n.write:"";this.state.selectId?e=((o=(r=t.common)==null?void 0:r.alias)==null?void 0:o.id)||"":this.state.selectRead?e=a??"":this.state.selectWrite&&(e=l??"")}catch{console.error(`Cannot parse ${this.state.text}`)}return L.jsx(ee.DialogSelectID,{imagePrefix:".",dateFormat:this.props.dateFormat,theme:this.props.theme,isFloatComma:this.props.isFloatComma,socket:this.props.socket,dialogName:"aliasesEdit",title:`${this.props.t("Select for")} ${this.props.obj._id}`,selected:e,onOk:a=>{const l=this.state.selectRead,h=this.state.selectWrite,c=this.state.selectId,u=Array.isArray(a)?a[0]:a;this.setState({selectId:!1,selectRead:!1,selectWrite:!1},()=>{l?this.setAliasItem(t,"id.read",u):h?this.setAliasItem(t,"id.write",u):c&&this.setAliasItem(t,"id",u)})},onClose:()=>this.setState({selectId:!1,selectRead:!1,selectWrite:!1})},"selectDialog")}setAliasItem(e,t,i,n){e.common=e.common||{};const r=e.common.alias||{};t==="id.read"?r.id&&typeof r.id=="object"?r.id.read=i:r.id={read:i,write:i}:t==="id.write"?r.id&&typeof r.id=="object"?r.id.write=i:r.id={read:i,write:i}:r[t]=i,e.common.alias=r,this.onChange(JSON.stringify(e,null,2),n)}setCommonItem(e,t,i){e.common[t]=i,this.onChange(JSON.stringify(e,null,2))}removeCommonItem(e,t){delete e.common[t],this.onChange(JSON.stringify(e,null,2))}static buttonAddKey(e,t){return L.jsx("div",{style:se.marginBlock,children:L.jsx(E.Button,{style:se.buttonAdd,variant:"contained",color:"secondary",startIcon:L.jsx(Ie.Add,{}),onClick:t,children:ee.I18n.t(e)})})}buttonRemoveKey(e,t,i){const{t:n}=this.props;return L.jsx(E.Tooltip,{title:n("Remove attribute %s",n(e)),slotProps:{popper:{sx:se.tooltip}},children:L.jsx(E.Box,{component:"div",sx:se.close,style:i,onClick:t})})}static filterRoles(e,t){const i=[];return e.forEach(n=>(n.type==="mixed"||n.type)===t&&!i.includes(n.role)&&i.push(n.role)),Bb.forEach(n=>(n.type==="mixed"||n.type)===t&&!i.includes(n.role)&&i.push(n.role)),i.sort(),i}renderCommonEdit(){try{const e=JSON.parse(this.state.text),t=["number","string","boolean","array","object","mixed"],i=!1,{t:n,obj:r}=this.props,o=r.type==="state",a=r.type==="channel"||r.type==="device"||o,l=$n.filterRoles(this.props.roleArray,e.common.type);let h;if(e.common.icon&&(h=e.type==="instance"||e.type==="adapter"?`./adapter/${e.common.name}/${e.common.icon}`:e.common.icon,!h.startsWith(".")&&!h.startsWith("/")&&!h.startsWith("data:"))){const d=r._id.split(".");d[0]==="system"?h=`adapter/${d[2]}${h.startsWith("/")?"":"/"}${h}`:h=`adapter/${d[0]}${h.startsWith("/")?"":"/"}${h}`}const c=typeof e.common.desc=="object"&&e.common.desc?e.common.desc[ee.I18n.getLanguage()]||e.common.desc.en||"":e.common.desc||"",u=ee.Utils.getObjectNameFromObj(e,ee.I18n.getLanguage(),{},!1,!0);return L.jsxs(E.Box,{style:se.commonTabWrapper,onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),d.stopPropagation(),this.onUpdate())},children:[L.jsxs(E.Box,{style:{...se.commonWrapper,width:this.props.width==="xs"?"100%":void 0,minWidth:this.props.width==="xs"?"100%":void 0,gap:this.props.width==="xs"?10:8,display:this.props.width==="xs"?"flex":void 0,flexDirection:this.props.width==="xs"?"column":void 0},children:[typeof e.common.name<"u"?L.jsx(E.TextField,{variant:"standard",disabled:i,label:n("Name"),style:{...se.textField,marginTop:8},fullWidth:!0,slotProps:{input:{endAdornment:u?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.Tooltip,{title:ee.I18n.t("Clear text"),slotProps:{popper:{sx:se.tooltip}},children:L.jsx(E.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setCommonItem(e,"name",""),children:L.jsx(Ie.Close,{})})})}):null}},value:u,onChange:d=>this.setCommonItem(e,"name",d.target.value)}):$n.buttonAddKey("Name",()=>this.setCommonItem(e,"name","")),typeof e.common.desc<"u"?L.jsxs(E.Box,{component:"div",sx:se.flex,children:[L.jsx(E.TextField,{variant:"standard",disabled:i,label:n("Description"),style:{...se.textField,marginTop:8},fullWidth:!0,slotProps:{input:{endAdornment:c?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.Tooltip,{title:ee.I18n.t("Clear text"),slotProps:{popper:{sx:se.tooltip}},children:L.jsx(E.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setCommonItem(e,"desc",""),children:L.jsx(Ie.Close,{})})})}):null}},value:c,onChange:d=>this.setCommonItem(e,"desc",d.target.value)}),this.buttonRemoveKey("Description",()=>this.removeCommonItem(e,"desc"))]}):$n.buttonAddKey("Description",()=>this.setCommonItem(e,"desc","")),o?typeof e.common.type<"u"?L.jsxs(E.Box,{component:"div",sx:se.flex,children:[L.jsxs(E.FormControl,{style:se.marginBlock,fullWidth:!0,children:[L.jsx(E.InputLabel,{style:{transform:"scale(0.75)"},children:n("State type")}),L.jsx(E.Select,{variant:"standard",disabled:i,value:e.common.type,onChange:d=>this.setCommonItem(e,"type",d.target.value),children:t.map(d=>L.jsxs(E.MenuItem,{value:d,children:[n(d),L.jsxs("span",{style:se.typeNameEng,children:["(",d,")"]})]},d))})]}),this.buttonRemoveKey("State type",()=>this.removeCommonItem(e,"type"),{marginTop:20})]}):$n.buttonAddKey("State type",()=>this.setCommonItem(e,"type","string")):null,L.jsxs(E.Box,{component:"div",sx:{...se.flex,flexWrap:this.props.width==="xs"?"wrap":void 0},children:[o?typeof e.common.read<"u"?L.jsxs(E.Box,{component:"div",sx:se.flex,children:[L.jsx(E.FormControlLabel,{style:se.marginBlock,control:L.jsx(E.Checkbox,{disabled:i,checked:e.common.read,onChange:d=>this.setCommonItem(e,"read",d.target.checked)}),label:n("Readable")}),this.buttonRemoveKey("Readable",()=>this.removeCommonItem(e,"read"))]}):$n.buttonAddKey("Readable",()=>this.setCommonItem(e,"read",!0)):null,o?typeof e.common.write<"u"?L.jsxs(E.Box,{component:"div",sx:se.flex,children:[L.jsx(E.FormControlLabel,{style:se.marginBlock,control:L.jsx(E.Checkbox,{disabled:i,checked:e.common.write,onChange:d=>this.setCommonItem(e,"write",d.target.checked)}),label:n("Writeable")}),this.buttonRemoveKey("Writeable",()=>this.removeCommonItem(e,"write"))]}):$n.buttonAddKey("Writeable",()=>this.setCommonItem(e,"write",!0)):null]}),a?typeof e.common.role<"u"?L.jsxs(E.Box,{component:"div",sx:se.flex,children:[L.jsx(E.Autocomplete,{style:se.marginBlock,fullWidth:!0,disabled:i,value:e.common.role,onChange:(d,f)=>{const g=Bb.find(p=>p.role===f);g&&(g.w!==void 0&&g.r!==void 0?(this.setCommonItem(e,"write",g.w),this.setCommonItem(e,"read",g.r)):g.w!==void 0?this.setCommonItem(e,"write",g.w):g.r!==void 0&&this.setCommonItem(e,"read",g.r)),f.startsWith("level")||f.startsWith("indicator")||f.startsWith("sensor")||f.startsWith("weather")?e.common.write&&this.setCommonItem(e,"write",!1):f.startsWith("value")||f.startsWith("indicator")||f.startsWith("sensor")||f.startsWith("weather")?e.common.write&&this.setCommonItem(e,"write",!1):f.startsWith("level")||f.startsWith("switch")?e.common.write&&this.setCommonItem(e,"write",!0):f.startsWith("button")&&e.common.read&&this.setCommonItem(e,"read",!1),this.setCommonItem(e,"role",f)},options:l,renderInput:d=>L.jsx(E.TextField,{variant:"standard",...d,label:n("Role")})}),this.buttonRemoveKey("Role",()=>this.removeCommonItem(e,"role"),{marginTop:20})]}):$n.buttonAddKey("Role",()=>this.setCommonItem(e,"role","")):null,typeof e.common.color<"u"?L.jsxs(E.Box,{component:"div",sx:se.flex,children:[L.jsx(E.TextField,{variant:"standard",disabled:i,style:{...se.marginBlock,...se.color},label:n("Color"),type:"color",slotProps:{input:{endAdornment:e.common.color?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.Tooltip,{title:ee.I18n.t("Clear field"),slotProps:{popper:{sx:se.tooltip}},children:L.jsx(E.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setCommonItem(e,"color",""),children:L.jsx(Ie.Close,{})})})}):null}},value:e.common.color,onChange:d=>this.setCommonItem(e,"color",d.target.value)}),this.buttonRemoveKey("Color",()=>this.removeCommonItem(e,"color"))]}):$n.buttonAddKey("Color",()=>this.setCommonItem(e,"color","")),L.jsxs(E.Box,{component:"div",sx:{...se.flex,flexWrap:this.props.width==="xs"?"wrap":void 0,gap:this.props.width==="xs"?"10px":void 0},children:[e.common.type==="number"?typeof e.common.min<"u"?L.jsxs(E.Box,{component:"div",sx:se.flex,children:[L.jsx(E.TextField,{variant:"standard",disabled:i,className:{...se.marginBlock,...se.color},label:n("Min"),value:e.common.min,onChange:d=>this.setCommonItem(e,"min",d.target.value)}),this.buttonRemoveKey("Min",()=>this.removeCommonItem(e,"min"))]}):L.jsx(E.Box,{component:"div",sx:se.flex,children:$n.buttonAddKey("Min",()=>this.setCommonItem(e,"min",0))}):null,e.common.type==="number"?typeof e.common.max<"u"?L.jsxs(E.Box,{component:"div",sx:se.flex,children:[L.jsx(E.TextField,{variant:"standard",disabled:i,className:{...se.marginBlock,...se.color},label:n("Max"),value:e.common.max,onChange:d=>this.setCommonItem(e,"max",d.target.value)}),this.buttonRemoveKey("Max",()=>this.removeCommonItem(e,"max"))]}):L.jsx(E.Box,{component:"div",sx:se.flex,children:$n.buttonAddKey("Max",()=>this.setCommonItem(e,"max",100))}):null,e.common.type==="number"?typeof e.common.step<"u"?L.jsxs(E.Box,{component:"div",sx:se.flex,children:[L.jsx(E.TextField,{variant:"standard",disabled:i,className:{...se.marginBlock,...se.color},label:n("Step"),value:e.common.step,onChange:d=>this.setCommonItem(e,"step",d.target.value)}),this.buttonRemoveKey("Step",()=>this.removeCommonItem(e,"step"))]}):L.jsx(E.Box,{component:"div",sx:se.flex,children:$n.buttonAddKey("Step",()=>this.setCommonItem(e,"step",1))}):null]}),e.common.type==="number"?typeof e.common.unit<"u"?L.jsxs(E.Box,{component:"div",sx:se.flex,children:[L.jsx(E.TextField,{variant:"standard",disabled:i,className:{...se.marginBlock,...se.color},label:n("Unit"),slotProps:{input:{endAdornment:e.common.unit?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.Tooltip,{title:ee.I18n.t("Clear field"),slotProps:{popper:{sx:se.tooltip}},children:L.jsx(E.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setCommonItem(e,"unit",""),children:L.jsx(Ie.Close,{})})})}):null}},value:e.common.unit,onChange:d=>this.setCommonItem(e,"unit",d.target.value)}),this.buttonRemoveKey("Unit",()=>this.removeCommonItem(e,"unit"))]}):L.jsx("div",{style:se.flexDrop,children:$n.buttonAddKey("Unit",()=>this.setCommonItem(e,"unit",""))}):null]}),typeof e.common.icon<"u"?L.jsxs(E.Box,{component:"div",sx:se.flex,style:{flexGrow:1,minWidth:158},children:[L.jsx(ee.UploadImage,{disabled:i,maxSize:10*1024,icon:h,removeIconFunc:()=>this.setCommonItem(e,"icon",""),onChange:d=>this.setCommonItem(e,"icon",d)}),this.buttonRemoveKey("Icon",()=>this.removeCommonItem(e,"icon"))]}):L.jsx(E.Box,{component:"div",sx:se.flex,children:$n.buttonAddKey("Icon",()=>this.setCommonItem(e,"icon",""))})]})}catch{return L.jsx("div",{children:this.props.t("Cannot parse JSON!")})}}renderAliasEdit(){var e,t,i,n,r,o,a,l,h,c,u,d,f,g,p,m,v,_,b,y,C,x,S,k,T,I,N,A,R,P,B,z,U,K,X,ne,oe,ue,de,De;try{const Q=JSON.parse(this.state.text),Xe=((t=(e=Q.common)==null?void 0:e.alias)==null?void 0:t.read)!==void 0||((n=(i=Q.common)==null?void 0:i.alias)==null?void 0:n.write)!==void 0;return L.jsxs(E.Grid2,{container:!0,direction:"column",style:se.marginTop,children:[L.jsx(E.Grid2,{children:L.jsx(E.FormControlLabel,{control:L.jsx(E.Checkbox,{checked:typeof((o=(r=Q.common)==null?void 0:r.alias)==null?void 0:o.id)=="object",onChange:()=>{var Pe,tt,st,ve,ge,Oe,Ci;typeof((tt=(Pe=Q.common)==null?void 0:Pe.alias)==null?void 0:tt.id)=="object"?this.setAliasItem(Q,"id",((ge=(ve=(st=Q.common)==null?void 0:st.alias)==null?void 0:ve.id)==null?void 0:ge.read)||""):this.setAliasItem(Q,"id.read",((Ci=(Oe=Q.common)==null?void 0:Oe.alias)==null?void 0:Ci.id)||"")}}),label:this.props.t("Different IDs for read and write")})}),typeof((l=(a=Q.common)==null?void 0:a.alias)==null?void 0:l.id)!="object"?L.jsxs(E.Grid2,{children:[L.jsx(E.TextField,{variant:"standard",label:this.props.t("Alias state"),value:((c=(h=Q.common)==null?void 0:h.alias)==null?void 0:c.id)||"",style:se.aliasIdEdit,slotProps:{input:{endAdornment:(d=(u=Q.common)==null?void 0:u.alias)!=null&&d.id?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.Tooltip,{title:ee.I18n.t("Clear field"),slotProps:{popper:{sx:se.tooltip}},children:L.jsx(E.IconButton,{tabIndex:-1,size:"large",onClick:()=>this.setAliasItem(Q,"id",""),children:L.jsx(Ie.Close,{})})})}):null}},onChange:Pe=>this.setAliasItem(Q,"id",Pe.target.value),margin:"normal"}),L.jsx(E.Fab,{style:se.button,size:"small",onClick:()=>this.setState({selectId:!0,selectRead:!1,selectWrite:!1}),children:"..."})]}):null,typeof((g=(f=Q.common)==null?void 0:f.alias)==null?void 0:g.id)=="object"?L.jsxs(E.Grid2,{children:[L.jsx(E.TextField,{variant:"standard",label:this.props.t("Alias read state"),value:((v=(m=(p=Q.common)==null?void 0:p.alias)==null?void 0:m.id)==null?void 0:v.read)||"",style:se.aliasIdEdit,slotProps:{input:{endAdornment:(y=(b=(_=Q.common)==null?void 0:_.alias)==null?void 0:b.id)!=null&&y.read?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.Tooltip,{title:ee.I18n.t("Clear field"),slotProps:{popper:{sx:se.tooltip}},children:L.jsx(E.IconButton,{size:"large",tabIndex:-1,onClick:()=>this.setAliasItem(Q,"id.read",""),children:L.jsx(Ie.Close,{})})})}):null}},onChange:Pe=>this.setAliasItem(Q,"id.read",Pe.target.value),margin:"normal"}),L.jsx(E.Fab,{style:se.button,size:"small",onClick:()=>this.setState({selectId:!1,selectRead:!0,selectWrite:!1}),children:"..."})]}):null,typeof((x=(C=Q.common)==null?void 0:C.alias)==null?void 0:x.id)=="object"?L.jsxs(E.Grid2,{children:[L.jsx(E.TextField,{variant:"standard",label:this.props.t("Alias write state"),value:((T=(k=(S=Q.common)==null?void 0:S.alias)==null?void 0:k.id)==null?void 0:T.write)||"",style:se.aliasIdEdit,slotProps:{input:{endAdornment:(A=(N=(I=Q.common)==null?void 0:I.alias)==null?void 0:N.id)!=null&&A.write?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.Tooltip,{title:ee.I18n.t("Clear field"),slotProps:{popper:{sx:se.tooltip}},children:L.jsx(E.IconButton,{size:"large",tabIndex:-1,onClick:()=>this.setAliasItem(Q,"id.write",""),children:L.jsx(Ie.Close,{})})})}):null}},onChange:Pe=>this.setAliasItem(Q,"id.write",Pe.target.value),margin:"normal"}),L.jsx(E.Fab,{style:se.button,size:"small",onClick:()=>this.setState({selectId:!1,selectRead:!1,selectWrite:!0}),children:"..."})]}):null,L.jsx(E.Grid2,{style:se.marginTop,children:L.jsx(E.FormControlLabel,{control:L.jsx(E.Checkbox,{checked:((P=(R=Q.common)==null?void 0:R.alias)==null?void 0:P.read)!==void 0||((z=(B=Q.common)==null?void 0:B.alias)==null?void 0:z.write)!==void 0,onChange:()=>{Xe?(delete Q.common.alias.read,delete Q.common.alias.write):(Q.common=Q.common||{},Q.common.alias=Q.common.alias||{},Q.common.alias.read="val",Q.common.alias.write="val"),this.onChange(JSON.stringify(Q,null,2))}}),label:this.props.t("Use convert functions")})}),Xe?L.jsx(E.Grid2,{children:L.jsx(E.TextField,{variant:"standard",label:this.props.t("Read converter"),value:((K=(U=Q.common)==null?void 0:U.alias)==null?void 0:K.read)||"val",style:se.funcEdit,error:!!this.state.readError,slotProps:{input:{endAdornment:(ne=(X=Q.common)==null?void 0:X.alias)!=null&&ne.read?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.Tooltip,{title:ee.I18n.t("Clear field"),slotProps:{popper:{sx:se.tooltip}},children:L.jsx(E.IconButton,{size:"large",tabIndex:-1,onClick:()=>this.setAliasItem(Q,"read",""),children:L.jsx(Ie.Close,{})})})}):null,startAdornment:L.jsx(E.InputAdornment,{position:"start",children:L.jsx(ee.IconFx,{style:se.funcIcon})})}},onChange:Pe=>this.setAliasItem(Q,"read",Pe.target.value),helperText:this.state.readError||`${this.props.t("JS function like")} "val / 5 + 21"`,margin:"normal"})}):null,Xe?L.jsx(E.Grid2,{children:L.jsx(E.TextField,{variant:"standard",label:this.props.t("Write converter"),error:!!this.state.writeError,value:((ue=(oe=Q.common)==null?void 0:oe.alias)==null?void 0:ue.write)||"val",helperText:this.state.writeError||`${this.props.t("JS function like")} "(val - 21) * 5"`,style:se.funcEdit,slotProps:{input:{endAdornment:(De=(de=Q.common)==null?void 0:de.alias)!=null&&De.write?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.Tooltip,{title:ee.I18n.t("Clear field"),slotProps:{popper:{sx:se.tooltip}},children:L.jsx(E.IconButton,{size:"large",tabIndex:-1,onClick:()=>this.setAliasItem(Q,"write",""),children:L.jsx(Ie.Close,{})})})}):null,startAdornment:L.jsx(E.InputAdornment,{position:"start",children:L.jsx(ee.IconFx,{style:se.funcIcon})})}},onChange:Pe=>this.setAliasItem(Q,"write",Pe.target.value),margin:"normal"})}):null]})}catch{return L.jsx("div",{children:this.props.t("Cannot parse JSON!")})}}onCopy(e){ee.Utils.copyToClipboard(this.state.text,e),window.alert(this.props.t("ra_Copied"))}onClone(e,t){const i=JSON.parse(JSON.stringify(this.props.objects[e]));delete i.from,delete i.ts,delete i.user,i._id=t,this.props.objects[i._id]=i,this.props.onNewObject(i)}renderCopyDialog(){return this.state.showCopyDialog?L.jsxs(E.Dialog,{open:!0,maxWidth:"md",fullWidth:!0,onClose:()=>this.setState({showCopyDialog:""}),children:[L.jsx(E.DialogTitle,{children:this.props.t("Enter new ID for this object")}),L.jsx(E.DialogContent,{children:L.jsx(E.TextField,{variant:"standard",autoFocus:!0,fullWidth:!0,label:this.props.t("New object ID"),value:this.state.newId,slotProps:{input:{endAdornment:this.state.newId?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.Tooltip,{title:ee.I18n.t("Clear field"),slotProps:{popper:{sx:se.tooltip}},children:L.jsx(E.IconButton,{size:"small",tabIndex:-1,onClick:()=>this.setState({newId:""}),children:L.jsx(Ie.Close,{})})})}):null}},onKeyDown:e=>{e.key==="Enter"&&!this.props.objects[this.state.newId]&&(this.setState({showCopyDialog:""}),this.onClone(this.state.showCopyDialog,this.state.newId))},onChange:e=>this.setState({newId:e.target.value})})}),L.jsxs(E.DialogActions,{children:[L.jsx(E.Button,{disabled:!!this.props.objects[this.state.newId],onClick:()=>{this.setState({showCopyDialog:""}),this.onClone(this.state.showCopyDialog,this.state.newId)},color:"primary",startIcon:L.jsx(Ie.FileCopy,{}),children:this.props.t("Clone")}),L.jsx(E.Button,{color:"grey",onClick:()=>this.setState({showCopyDialog:""}),startIcon:L.jsx(Ie.Close,{}),children:this.props.t("Cancel")})]})]}):null}renderPanelObject(e){return L.jsxs("div",{style:{...se.divWithoutTitle,...e?se.divWithoutTitleAndTab:void 0,...this.state.error?se.error:void 0},onKeyDown:t=>{t.ctrlKey&&t.key==="Enter"&&(t.preventDefault(),t.stopPropagation(),this.onUpdate())},children:[L.jsx(f$,{value:this.state.text,onChange:t=>this.onChange(t),name:"UNIQUE_ID_OF_DIV",themeType:this.props.themeType}),this.state.showCommonDeleteMessage?L.jsx("div",{style:se.commonDeleteTip,children:ee.I18n.t("common_delete_tip")}):null]})}render(){const e=this.props.obj,t=e._id.startsWith("alias.0")&&e.type==="state";let i=se.dialog;window.innerWidth>1920&&(i={...i,maxWidth:"calc(100% - 150px)"});let n;try{n=JSON.parse(this.state.text)}catch{}return L.jsxs(E.Dialog,{sx:{"& .MuiPaper-root":i},open:!0,maxWidth:"xl",fullWidth:!0,fullScreen:!1,onClose:()=>this.props.onClose(),"aria-labelledby":"edit-value-dialog-title","aria-describedby":"edit-value-dialog-description",children:[L.jsxs(E.DialogTitle,{id:"edit-value-dialog-title",style:{width:"calc(100% - 32px)",overflow:"hidden",textOverflow:"ellipsis"},children:[this.props.t("Edit object:")," ",L.jsx(E.Box,{component:"span",style:se.id,sx:{fontSize:{xs:10}},children:this.props.obj._id})]}),this.renderTabs(n),this.renderCopyDialog(),L.jsxs(E.DialogContent,{sx:{p:this.props.width==="xs"&&this.state.tab==="object"?"6px":this.state.tab==="object"||this.state.tab==="common"||this.state.tab==="alias"?"0 24px":"0 6px",overflow:this.state.tab==="object"||this.state.tab==="common"||this.state.tab==="alias"?void 0:"hidden"},children:[this.state.tab==="object"?this.renderPanelObject(t):null,this.state.tab==="alias"&&this.props.obj._id.startsWith("alias.0")&&this.props.obj.type==="state"?this.renderAliasEdit():null,this.state.tab==="common"?this.renderCommonEdit():null,this.state.tab==="state"?this.renderStatePanel():null,this.renderCustomPanel(),this.renderSelectDialog()]}),L.jsxs(E.DialogActions,{sx:se.wrapperButton,children:[L.jsx(E.Button,{color:"grey",onClick:()=>this.setState({showCopyDialog:this.props.obj._id,newId:this.props.obj._id}),disabled:this.state.error||this.state.changed,title:this.props.t("Create a copy of this object"),children:L.jsx(Ie.FileCopy,{fontSize:this.props.width==="xs"?"large":void 0})}),L.jsx("div",{style:{flexGrow:1}}),this.state.tab==="object"&&L.jsx(E.Button,{color:"grey",onClick:r=>this.onCopy(r),disabled:this.state.error,title:this.props.width==="xs"?this.props.t("Copy into clipboard"):"",startIcon:this.props.width==="xs"?void 0:L.jsx(B7,{}),children:this.props.width==="xs"?L.jsx(B7,{fontSize:32}):this.props.t("Copy into clipboard")}),L.jsx(E.Button,{variant:"contained",disabled:this.state.error||!this.state.changed||this.state.customError,onClick:()=>this.onUpdate(),startIcon:this.props.width==="xs"?void 0:L.jsx(Ie.Check,{}),color:"primary",children:this.props.width==="xs"?L.jsx(Ie.Check,{fontSize:"large"}):this.props.t("Write")}),L.jsx(E.Button,{color:"grey",variant:"contained",onClick:()=>this.props.onClose(),startIcon:this.props.width==="xs"?void 0:L.jsx(Ie.Close,{}),children:this.props.width==="xs"?L.jsx(Ie.Close,{fontSize:"large"}):this.props.t("Cancel")})]})]})}}class A4 extends Te.Component{object=null;constructor(e){super(e),this.state={role:null,initRole:null,roleInput:null}}componentDidMount(){this.props.socket.getObject(this.props.id).then(e=>{var i;this.object=e;const t=((i=e==null?void 0:e.common)==null?void 0:i.role)||null;this.setState({role:t,initRole:t,roleInput:t})}).catch(e=>console.error(e))}onUpdate(){this.object.common=this.object.common||{},this.object.common.role=this.state.roleInput,this.props.socket.setObject(this.object._id,this.object).then(()=>this.props.onClose(this.object))}static filterRoles(e,t){const i=[];return e.forEach(n=>(n.type==="mixed"||n.type)===t&&!i.includes(n.role)&&i.push(n.role)),Bb.forEach(n=>(n.type==="mixed"||n.type)===t&&!i.includes(n.role)&&i.push(n.role)),i.sort(),i}render(){return L.jsxs(E.Dialog,{open:!0,maxWidth:"sm",fullWidth:!0,onClose:()=>this.props.onClose(),"aria-labelledby":"edit-role-dialog-title","aria-describedby":"edit-role-dialog-description",children:[L.jsx(E.DialogTitle,{id:"edit-role-dialog-title",children:this.object?this.props.t("Update role for %s",this.object._id):null}),L.jsx(E.DialogContent,{children:L.jsx(E.Autocomplete,{freeSolo:!0,options:A4.filterRoles(this.props.roleArray,this.props.commonType),style:{width:"100%"},value:this.state.role,onChange:(e,t)=>this.setState({role:t,roleInput:t}),onInputChange:(e,t)=>this.setState({roleInput:t}),renderInput:e=>L.jsx(E.TextField,{variant:"standard",...e,label:this.props.t("Role")})})}),L.jsxs(E.DialogActions,{children:[L.jsx(E.Button,{disabled:this.state.initRole===this.state.roleInput,variant:"contained",onClick:()=>this.onUpdate(),color:"primary",startIcon:L.jsx(Ie.Check,{}),children:this.props.t("Apply")}),L.jsx(E.Button,{variant:"contained",onClick:()=>this.props.onClose(),color:"grey",startIcon:L.jsx(Ie.Close,{}),children:this.props.t("Cancel")})]})]},"objectBrowserEditRole")}}const Mme=["array","boolean","file","json","mixed","number","object","string"],Ame={boolean:!1,string:"",number:0},zo={state:{name:"State",value:"state"},channel:{name:"Channel",value:"channel"},device:{name:"Device",value:"device"},folder:{name:"Folder",value:"folder"}},Rme=({onClose:s,onApply:e,selected:t,setObject:i,objects:n,expertMode:r,initialType:o,initialStateType:a})=>{var S;const l={state:ee.I18n.t("New state"),channel:ee.I18n.t("New channel"),device:ee.I18n.t("New device"),folder:ee.I18n.t("New folder")},h=[],c=(S=n[t])==null?void 0:S.type;n[t]?c==="channel"?(h.push(zo.state),o=o||"state"):c==="device"?(o=o||"channel",h.push(zo.state),h.push(zo.channel)):c==="state"?o=o||"":(h.push(zo.state),h.push(zo.channel),h.push(zo.device),t.startsWith("0_userdata.")||t.startsWith("alias.0.")||t==="0_userdata"||t==="alias.0"?(h.push(zo.folder),o=o||"folder"):o=o||"state"):(h.push(zo.folder),o=o||"folder",r&&(t.startsWith("mqtt.")||t.startsWith("javascript."))&&(h.push(zo.state),h.push(zo.channel),h.push(zo.device)));const u=(window._localStorage||window.localStorage).getItem("App.lastObjectType");u&&h.find(k=>k.value===u)&&(o=u);function d(k){return`${t}.${k.toString().replace(ee.Utils.FORBIDDEN_CHARS,"_").replace(/\s/g,"_").replace(/\./g,"_")}`}const[f,g]=Te.useState(o),[p,m]=Te.useState(l[o]),[v,_]=Te.useState(a||(window._localStorage||window.localStorage).getItem("App.lastStateType")||"string"),[b,y]=Te.useState(!n[d(l.state)]),C=()=>{const k={common:{name:p,desc:ee.I18n.t("Manually created")},type:f};f==="state"?(k.common={...k.common,role:"state",type:v,read:!0,write:!0,def:Ame[v]},k.native={}):f!=="folder"?k.common={...k.common,role:"",icon:""}:delete k.common.desc,i(`${t}.${p.split(" ").join("_")}`,k).then(()=>e())},x=ee.I18n.getLanguage();return L.jsxs(E.Dialog,{open:!0,fullWidth:!0,maxWidth:"md",disableEscapeKeyDown:!1,onClose:s,children:[L.jsx(E.DialogTitle,{children:L.jsxs("div",{style:{margin:10,fontSize:20,display:"flex",alignItems:"center",gap:8},children:[L.jsx(Ie.AddBox,{}),ee.I18n.t("Add new object:"),L.jsxs("span",{style:{fontStyle:"italic"},children:[t,".",p]})]})}),L.jsx(E.DialogContent,{children:L.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[L.jsx(E.TextField,{variant:"standard",label:ee.I18n.t("Parent"),style:{margin:"5px 0"},disabled:!0,value:t}),L.jsxs(E.FormControl,{variant:"standard",style:{marginTop:10,marginBottom:16},children:[L.jsx(E.InputLabel,{children:ee.I18n.t("Type")}),L.jsx(E.Select,{variant:"standard",value:f,onChange:k=>{(window._localStorage||window.localStorage).setItem("App.lastObjectType",k.target.value),p===l[f]&&(m(l[k.target.value]),y(!!n[d(l[k.target.value])])),g(k.target.value)},children:h.map(k=>L.jsxs(E.MenuItem,{value:k.value,children:[ee.I18n.t(k.name),x!=="en"&&L.jsxs("span",{style:{fontSize:"smaller",opacity:.6,marginLeft:4},children:["(",k.value,")"]})]},k.value))})]}),f==="state"&&L.jsxs(E.FormControl,{style:{marginTop:10,marginBottom:16},children:[L.jsx(E.InputLabel,{style:{left:-14},children:ee.I18n.t("State type")}),L.jsx(E.Select,{style:{marginTop:6},variant:"standard",value:v,onChange:k=>{(window._localStorage||window.localStorage).setItem("App.lastStateType",k.target.value),_(k.target.value)},children:Mme.map(k=>L.jsxs(E.MenuItem,{value:k,children:[ee.I18n.t(k),x!=="en"&&ee.I18n.t(k)!==k&&L.jsxs("span",{style:{fontSize:"smaller",opacity:.6,marginLeft:4},children:["(",k,")"]})]},k))})]}),L.jsx(E.TextField,{variant:"standard",label:ee.I18n.t("Name"),style:{margin:"5px 0"},autoFocus:!0,value:p,onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),p&&C())},slotProps:{input:{endAdornment:p?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.IconButton,{tabIndex:-1,size:"small",onClick:()=>m(""),children:L.jsx(Ie.Close,{})})}):null}},onChange:k=>{y(!n[d(k.target.value)]),m(k.target.value)}})]})}),L.jsxs(E.DialogActions,{children:[L.jsx(E.Button,{id:"add-new-object-dialog-add",startIcon:L.jsx(Ie.Check,{}),disabled:!p||!f||!b||f==="state"&&!v,onClick:()=>C(),variant:"contained",color:"primary",children:ee.I18n.t("add")}),L.jsx(E.Button,{id:"add-new-object-dialog-cancel",color:"grey",onClick:s,variant:"contained",startIcon:L.jsx(Ie.Close,{}),children:ee.I18n.t("ra_Cancel")})]})]})},Pme=[{Owner:[{name:"read",valueNum:1024,title:"read owner"},{name:"write",valueNum:512,title:"write owner"}]},{Group:[{name:"read",valueNum:64,title:"read group"},{name:"write",valueNum:32,title:"write group"}]},{Everyone:[{name:"read",valueNum:4,title:"read everyone"},{name:"write",valueNum:2,title:"write everyone"}]}];function uV(s,e,t){return s|=e&t,s&=e|~t&65535,s}const dV=({value:s,setValue:e,t,differentValues:i,applyToChildren:n,mask:r,setMask:o,disabled:a})=>{Te.useEffect(()=>{if(n){let h=0;for(let c=0;c<i.length;c++)h|=s^i[c];o(h)}else o(0)},[i,n,o,s]);let l=s;return L.jsx("div",{style:{display:"flex",width:"fit-content",margin:20,border:"1px solid",borderLeft:0},children:Pme.map(h=>{const c=Object.keys(h)[0];return L.jsxs("div",{style:{width:150,height:150,display:"flex",flexDirection:"column",alignItems:"center",borderLeft:"1px solid"},children:[L.jsx("div",{style:{height:50,display:"flex",alignItems:"center",fontSize:18,borderBottom:"1px solid silver",width:"100%",justifyContent:"center"},children:t(c)}),L.jsx("div",{style:{display:"flex",width:"100%"},children:h[c].map((u,d)=>{let f=!1;l-u.valueNum>=0&&(l-=u.valueNum,f=!0);const g=r&u.valueNum;return L.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,alignItems:"center",borderRight:d===0?"1px solid":0},children:[L.jsx("div",{style:{height:50,borderBottom:"1px solid",width:"100%",justifyContent:"center",display:"flex",alignItems:"center",color:"silver"},children:t(u.name)}),L.jsx("div",{style:{height:50,display:"flex"},children:L.jsx(E.Checkbox,{disabled:a,checked:f,color:g?"primary":"secondary",indeterminate:!!g,style:g?{opacity:.5}:void 0,onChange:p=>{g&&(r&=~u.valueNum&65535,o(r));let m=s;p.target.checked?m|=u.valueNum:m&=~u.valueNum&65535,e(m)}})})]},u.valueNum)})})]},c)})})},Ome=({onClose:s,onApply:e,selected:t,extendObject:i,objects:n,t:r,modalEmptyId:o,themeType:a,theme:l})=>{const[h,c]=Te.useState(null),[u,d]=Te.useState(null),[f,g]=Te.useState([]),[p,m]=Te.useState([]),[v,_]=Te.useState(!1),[b,y]=Te.useState(!1),[C,x]=Te.useState(0),[S,k]=Te.useState(null),[T,I]=Te.useState(null),[N,A]=Te.useState(!1),[R,P]=Te.useState(!1),[B,z]=Te.useState([]),[U,K]=Te.useState([]),[X,ne]=Te.useState(0),[oe,ue]=Te.useState(0),[de,De]=Te.useState([]),[Q,Xe]=Te.useState(!1),[Pe,tt]=Te.useState(!0),st=r("different");return Te.useEffect(()=>{var Rv,Pg,Pv,Iu;let ve=0;const ge=[],Oe=[],Ci=t||o,Ht=`${Ci}.`,In=Object.keys(n).sort();let Ms=!1;const ir=[],Or=[],lo=ee.I18n.getLanguage();let ic=!1,nc=!1,sc=null,Ia=null,Fr=null,nr=null;const Ol=[];for(let ho=0;ho<In.length;ho++){const En=In[ho],bt=n[En];if(bt&&(En===Ci||En.startsWith(Ht))){if(ve++,Ol.push(En),!bt.acl)continue;Fr===null&&bt.acl.object!==void 0&&(Fr=bt.acl.object),nr===null&&bt.acl.state!==void 0&&(nr=bt.acl.state),sc===null&&bt.acl.owner!==void 0&&(sc=bt.acl.owner),Ia===null&&bt.acl.ownerGroup!==void 0&&(Ia=bt.acl.ownerGroup),!N&&sc!==bt.acl.owner&&bt.acl.owner!==void 0&&(ic=!0),!R&&Ia!==bt.acl.ownerGroup&&bt.acl.ownerGroup!==void 0&&(nc=!0),bt.acl.state!==void 0&&nr!==bt.acl.state&&!ge.includes(bt.acl.state)&&ge.push(bt.acl.state),bt.acl.object!==void 0&&Fr!==bt.acl.object&&!Oe.includes(bt.acl.object)&&Oe.push(bt.acl.object),bt.type==="state"&&(Ms=!0)}En.startsWith("system.group.")&&(bt==null?void 0:bt.type)==="group"?ir.push({name:ee.Utils.getObjectNameFromObj(bt,lo).replace("system.group.",""),value:En,icon:(Rv=bt.common)==null?void 0:Rv.icon,color:(Pg=bt.common)==null?void 0:Pg.color}):En.startsWith("system.user.")&&(bt==null?void 0:bt.type)==="user"&&Or.push({name:ee.Utils.getObjectNameFromObj(bt,lo).replace("system.user.",""),value:En,icon:(Pv=bt.common)==null?void 0:Pv.icon,color:(Iu=bt.common)==null?void 0:Iu.color})}sc=sc||n["system.config"].common.defaultNewAcl.owner,Ia=Ia||n["system.config"].common.defaultNewAcl.ownerGroup,Fr=Fr||n["system.config"].common.defaultNewAcl.object,k(Number.isNaN(Fr)?n["system.config"].common.defaultNewAcl.object:Fr),Ms&&(nr=nr||n["system.config"].common.defaultNewAcl.state,I(Number.isNaN(nr)?n["system.config"].common.defaultNewAcl.state:nr));const Ww=Or.find(ho=>ho.value===sc),Hw=ir.find(ho=>ho.value===Ia);c(Ww),d(Hw),A(ic),P(nc),g(Or),m(ir),Ms&&y(!0),o&&_(!0),x(ve),z(ge),K(Oe),De(Ol)},[n,t,R,N,o]),Te.useEffect(()=>{v?(R&&(u.value!=="different"&&d({name:st,value:"different"}),p.find(ve=>ve.value==="different")||m(ve=>[{name:st,value:"different"},...ve])),N&&((!h||h.value!=="different")&&c({name:st,value:"different"}),f.find(ve=>ve.value==="different")||g(ve=>[{name:st,value:"different"},...ve]))):(h&&h.value==="different"&&c(n[t].acl.owner),u&&u.value==="different"&&d(n[t].acl.ownerGroup),m(ve=>ve.filter(({value:ge})=>ge!=="different")),g(ve=>ve.filter(({value:ge})=>ge!=="different")))},[f,v,N,R,n,t,u,h,st,p]),de.length?L.jsx(Sie,{theme:l,titleButtonApply:"apply",overflowHidden:!0,disableApply:Pe,progress:Q,onClose:s,onApply:()=>{Xe(!0),setTimeout(()=>{if(v){const ve=~X&65535,ge=~oe&65535;for(let Oe=0;Oe<de.length;Oe++){const Ci=de[Oe],Ht=n[Ci],In=ee.Utils.clone(Ht.acl||{});In.object=uV(Ht.acl.object,S,ve),h&&h.value!=="different"&&(In.owner=h.value),u&&u.value!=="different"&&(In.ownerGroup=u.value),Ht.type==="state"&&(In.state=uV(Ht.acl.state,T,ge)),i(Ci,{acl:In})}}else{const ve=ee.Utils.clone(n[t].acl||{});ve.object=S,ve.owner=h?h.value:"system.user.admin",ve.ownerGroup=u?u.value:"system.group.administrator",n[t].type==="state"&&(ve.state=T),i(t,{acl:ve})}Xe(!1),e()},200)},children:L.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[L.jsx("div",{style:{margin:10,fontSize:20},children:r("Access control list: %s",t||o)}),L.jsxs("div",{style:{display:"flex"},children:[L.jsxs(E.FormControl,{variant:"standard",fullWidth:!0,style:{marginRight:10},children:[L.jsx(E.InputLabel,{children:r("Owner user")}),L.jsx(E.Select,{variant:"standard",disabled:Q,value:h?h.value:"",renderValue:()=>L.jsxs("span",{children:[h!=null&&h.icon?L.jsx(ee.Icon,{src:h.icon,style:{width:16,height:16,marginRight:8}}):null,h?h.name:""]}),style:(h==null?void 0:h.value)==="different"?{opacity:.5}:{color:(h==null?void 0:h.color)||void 0,backgroundColor:ee.Utils.getInvertedColor(h==null?void 0:h.color,a)},onChange:ve=>{const ge=f.find(Oe=>Oe.value===ve.target.value);c(ge),tt(!1)},children:f.map(ve=>L.jsxs(E.MenuItem,{style:ve.value==="different"?{opacity:.5}:{color:ve.color||void 0,backgroundColor:ee.Utils.getInvertedColor(ve.color,a)},value:ve.value,children:[ve.icon?L.jsx(ee.Icon,{src:ve.icon,style:{width:16,height:16,marginRight:8}}):null,ve.name]},ve.value))})]}),L.jsxs(E.FormControl,{variant:"standard",fullWidth:!0,children:[L.jsx(E.InputLabel,{children:r("Owner group")}),L.jsx(E.Select,{variant:"standard",disabled:Q,value:u?u.value:"",renderValue:()=>L.jsxs("span",{children:[u!=null&&u.icon?L.jsx(ee.Icon,{src:u.icon,style:{width:16,height:16,marginRight:8}}):null,u?u.name:""]}),style:(u==null?void 0:u.value)==="different"?{opacity:.5}:{color:(u==null?void 0:u.color)||void 0,backgroundColor:ee.Utils.getInvertedColor(u==null?void 0:u.color,a)},onChange:ve=>{const ge=p.find(Oe=>Oe.value===ve.target.value);d(ge),tt(!1)},children:p.map(ve=>L.jsxs(E.MenuItem,{value:ve.value,style:ve.value==="different"?{opacity:.5}:{color:ve.color||void 0,backgroundColor:ee.Utils.getInvertedColor(ve.color,a)},children:[ve.icon?L.jsx(ee.Icon,{src:ve.icon,style:{width:16,height:16,marginRight:8}}):null,ve.name]},ve.value))})]})]}),L.jsxs("div",{style:{display:"flex",margin:10,alignItems:"center",fontSize:10,marginLeft:0,color:"silver"},children:[L.jsx("div",{style:v?null:{color:"green"},children:r("to apply one item")}),L.jsx(E.Switch,{disabled:Q||!!o||C===1,checked:!!o||v,onChange:ve=>{_(ve.target.checked),tt(!1)},color:"primary"}),L.jsxs("div",{style:v?{color:"green"}:null,children:[r("to apply with children")," ",o||C>1?`(${C} ${r("object(s)")})`:""]})]}),Q&&L.jsx(E.LinearProgress,{}),L.jsxs("div",{style:{overflowY:"auto"},children:[L.jsxs("div",{children:[L.jsx("h2",{children:r("Object rights")}),L.jsx(dV,{mask:oe,disabled:Q,setMask:ue,applyToChildren:v,differentValues:U,t:r,setValue:ve=>{k(ve),tt(!1)},value:S})]}),b&&L.jsxs("div",{children:[L.jsx("h2",{children:r("States rights")}),L.jsx(dV,{mask:X,disabled:Q,setMask:ne,applyToChildren:v,differentValues:v?B:[],t:r,setValue:ve=>{I(ve),tt(!1)},value:T})]})]})]})}):L.jsx(E.LinearProgress,{})},tp={dialog:{height:"100%",maxHeight:"100%",maxWidth:"100%"},content:{textAlign:"center"},error:s=>({color:s.palette.mode==="dark"?"#ff7777":"#c20000"}),image:{height:"100%",width:"auto"},text:{fontFamily:"Lucida Console, Courier, monospace",width:"100%"},download:{textDecoration:"none",textTransform:"uppercase",fontSize:14,color:"white",border:"1px solid white",borderRadius:5,padding:"8px 16px",marginRight:8}};class Fme extends Te.Component{audioRef;constructor(e){super(e);const t=this.props.obj._id.split(".");this.state={error:"",image:null,text:null,binary:null,fileName:`${t[t.length-2]}.${t[t.length-1]}`},this.audioRef=uS.createRef()}componentDidMount(){this.props.socket.getBinaryState(this.props.obj._id).then(e=>{let t=this.props.obj._id.toLowerCase().split(".").pop();const i=ee.Utils.detectMimeType(e);if(i&&(t=i),t==="jpg")this.setState({image:!0,binary:e,mime:"image/jpeg"});else if(t==="svg")this.setState({image:!0,binary:e,mime:"image/svg+xml"});else if(t==="png"||t==="bmp")this.setState({image:!0,binary:e,mime:`image/${t}`});else if(t==="mp3")this.setState({audio:!0,binary:e,mime:"audio/mpeg"});else if(t==="ogg")this.setState({audio:!0,binary:e,mime:"audio/ogg"});else if(t==="txt"||t==="log")try{const n=btoa(e);this.setState({text:n,binary:e,mime:"text/plain"})}catch{}}).catch(e=>this.setState({error:e}))}render(){return L.jsxs(E.Dialog,{style:tp.dialog,open:!0,maxWidth:this.state.audio?"sm":"md",onClose:()=>this.props.onClose(),fullWidth:!0,"aria-labelledby":"object-view-dialog-title",children:[L.jsx(E.DialogTitle,{id:"object-view-dialog-title",children:this.props.t("View file in state: %s",this.props.obj._id)}),L.jsxs(E.DialogContent,{style:tp.content,children:[this.state.error?L.jsx(E.Box,{component:"div",sx:tp.error,children:this.state.error==="State is not binary"?this.props.t("No file stored yet"):this.props.t(this.state.error)}):null,this.state.audio?L.jsx("audio",{ref:this.audioRef,src:`data:${this.state.mime};base64,${this.state.binary}`}):null,this.state.audio?L.jsx(E.Fab,{color:"primary",onClick:()=>this.audioRef.current&&this.audioRef.current.play(),children:L.jsx(Ie.PlayArrow,{})}):null,this.state.image?L.jsx("img",{src:`data:${this.state.mime};base64,${this.state.binary}`,alt:this.props.obj._id,style:tp.image}):null,this.state.text!==null?L.jsx("pre",{style:tp.text,children:this.state.text}):null]}),L.jsxs(E.DialogActions,{children:[L.jsxs("a",{style:tp.download,download:this.state.fileName,href:`data:${this.state.mime};base64,${this.state.binary}`,children:[L.jsx(Ie.GetApp,{style:{paddingRight:8,height:12}}),L.jsx("span",{children:this.props.t("Download")})]}),L.jsx(E.Button,{variant:"contained",onClick:()=>this.props.onClose(),startIcon:L.jsx(Ie.Close,{}),color:"grey",children:this.props.t("Close")})]})]})}}const _n={funcIcon:{width:16,height:16},formControlLabel:{marginBottom:16},color:{width:70},typeNameEng:{marginLeft:8,opacity:.7,fontStyle:"italic",fontSize:"smaller"},usedInAlias:{},addNewAlias:s=>({backgroundColor:s.palette.primary.main})},Bme=["array","boolean","file","json","mixed","number","object","string"];class g1 extends Te.Component{aliasIDs;constructor(e){var n;super(e);const t=[],i=this.props.obj._id;this.aliasIDs=Object.keys(this.props.objects).filter(r=>r.startsWith("alias.0"));for(let r=0;r<this.aliasIDs.length;r++){const o=(n=this.props.objects[this.aliasIDs[r]].common)==null?void 0:n.alias;((o==null?void 0:o.id)===i||typeof(o==null?void 0:o.id)=="object"&&(o.id.read===i||o.id.write===i))&&t.push(this.aliasIDs[r])}this.state={usedInAliases:t,showAddNewAlias:!t.length,newAliasId:this.props.obj._id,newAliasName:g1.getText(this.props.obj.common.name||this.props.obj._id)||"",newAliasRole:this.props.obj.common.role||"",newAliasRead:this.props.obj.common.read,newAliasWrite:this.props.obj.common.write,newAliasUnit:this.props.obj.common.unit,newAliasDesc:g1.getText(this.props.obj.common.desc)||"",newAliasType:this.props.obj.common.type,newAliasMin:this.props.obj.common.min===void 0?"":this.props.obj.common.min.toString(),newAliasMax:this.props.obj.common.max===void 0?"":this.props.obj.common.max.toString(),newAliasUseFormula:!1,newAliasReadFormula:"val",newAliasWriteFormula:"val",newAliasColor:this.props.obj.common.color,newAliasIcon:this.props.obj.common.icon,newAliasCopyStates:!!this.props.obj.common.states}}static getText(e){return e?typeof e=="object"?e[ee.I18n.getLanguage()]||e.en||"":e.toString():""}static filterRoles(e,t){const i=[];return Bb.forEach(n=>(n.type==="mixed"||n.type===t)&&!i.includes(n.role)&&i.push(n.role)),e.forEach(n=>(n.type==="mixed"||n.type)===t&&!i.includes(n.role)&&i.push(n.role)),i.sort(),i}renderAddNewAlias(){return this.state.showAddNewAlias?L.jsxs(E.Dialog,{open:!0,onClose:()=>this.setState({showAddNewAlias:!1}),children:[L.jsx(E.DialogTitle,{children:ee.I18n.t("Create new alias: %s",`alias.0.${this.state.newAliasId}`)}),L.jsxs(E.DialogContent,{children:[L.jsx(E.TextField,{style:_n.formControlLabel,variant:"standard",value:this.state.newAliasId,slotProps:{input:{endAdornment:this.state.newAliasId?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setState({newAliasId:""}),children:L.jsx(Ie.Close,{})})}):null}},onChange:e=>this.setState({newAliasId:e.target.value}),label:ee.I18n.t("Alias ID"),helperText:`alias.0.${this.state.newAliasId}`,fullWidth:!0}),L.jsx(E.TextField,{style:_n.formControlLabel,variant:"standard",value:this.state.newAliasName,slotProps:{input:{endAdornment:this.state.newAliasName?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setState({newAliasName:""}),children:L.jsx(Ie.Close,{})})}):null}},onChange:e=>this.setState({newAliasName:e.target.value}),label:ee.I18n.t("Alias name"),fullWidth:!0}),L.jsx(E.TextField,{style:_n.formControlLabel,variant:"standard",value:this.state.newAliasDesc,slotProps:{input:{endAdornment:this.state.newAliasDesc?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setState({newAliasDesc:""}),children:L.jsx(Ie.Close,{})})}):null}},onChange:e=>this.setState({newAliasDesc:e.target.value}),label:ee.I18n.t("Alias description"),fullWidth:!0}),L.jsxs(E.FormControl,{style:_n.formControlLabel,fullWidth:!0,children:[L.jsx(E.InputLabel,{children:ee.I18n.t("State type")}),L.jsx(E.Select,{variant:"standard",value:this.state.newAliasType,onChange:e=>this.setState({newAliasType:e.target.value}),children:Bme.map(e=>L.jsxs(E.MenuItem,{value:e,children:[ee.I18n.t(e),L.jsxs("span",{style:_n.typeNameEng,children:["(",e,")"]})]},e))})]}),this.state.newAliasType==="number"?L.jsx(E.TextField,{style:_n.formControlLabel,variant:"standard",value:this.state.newAliasUnit||"",slotProps:{input:{endAdornment:this.state.newAliasUnit?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setState({newAliasUnit:""}),children:L.jsx(Ie.Close,{})})}):null}},onChange:e=>this.setState({newAliasUnit:e.target.value}),label:ee.I18n.t("Alias units"),fullWidth:!0}):null,this.state.newAliasType==="number"?L.jsx(E.TextField,{variant:"standard",value:this.state.newAliasMin,type:"number",error:this.state.newAliasMin?isNaN(parseFloat(this.state.newAliasMin)):!1,onChange:e=>this.setState({newAliasMin:e.target.value}),label:ee.I18n.t("Min"),style:{width:"calc(50% - 4px)",marginBottom:16,marginRight:8}}):null,this.state.newAliasType==="number"?L.jsx(E.TextField,{variant:"standard",value:this.state.newAliasMax,type:"number",error:this.state.newAliasMax?isNaN(parseFloat(this.state.newAliasMax)):!1,onChange:e=>this.setState({newAliasMax:e.target.value}),label:ee.I18n.t("Max"),fullWidth:!0,style:{width:"calc(50% - 4px)",marginBottom:16}}):null,L.jsx(E.TextField,{variant:"standard",style:{..._n.formControlLabel,..._n.color},label:ee.I18n.t("Color"),type:"color",value:this.state.newAliasColor,onChange:e=>this.setState({newAliasColor:e.target.value})}),L.jsx(E.Autocomplete,{style:{..._n.formControlLabel},fullWidth:!0,value:this.state.newAliasRole,onChange:(e,t)=>{const i=Bb.find(n=>n.role===t);if(i){if(i.w!==void 0&&i.r!==void 0){this.setState({newAliasRole:t,newAliasRead:i.r,newAliasWrite:i.w});return}if(i.w!==void 0){this.setState({newAliasRole:t,newAliasWrite:i.w});return}if(i.r!==void 0){this.setState({newAliasRole:t,newAliasRead:i.r});return}}if(t.startsWith("value")||t.startsWith("indicator")||t.startsWith("sensor")||t.startsWith("weather")){if(this.state.newAliasWrite){this.setState({newAliasRole:t,newAliasWrite:!1});return}}else if(t.startsWith("level")||t.startsWith("switch")){if(!this.state.newAliasWrite){this.setState({newAliasRole:t,newAliasWrite:!0});return}}else if(t.startsWith("button")&&this.state.newAliasRead){this.setState({newAliasRole:t,newAliasRead:!1});return}this.setState({newAliasRole:t})},options:g1.filterRoles(this.props.roleArray,this.state.newAliasType),renderInput:e=>L.jsx(E.TextField,{variant:"standard",...e,label:ee.I18n.t("Role")})}),L.jsx(E.FormControlLabel,{style:{..._n.formControlLabel,marginLeft:16},control:L.jsx(E.Checkbox,{indeterminate:this.state.newAliasRead===void 0||this.state.newAliasRead===null,checked:this.state.newAliasRead,onChange:e=>{const t={newAliasRead:e.target.checked};t.newAliasRead===!1&&this.state.newAliasWrite===!1&&(t.newAliasWrite=!0),this.setState(t)}}),label:ee.I18n.t("Alias read")}),L.jsx(E.FormControlLabel,{style:_n.formControlLabel,control:L.jsx(E.Checkbox,{indeterminate:this.state.newAliasWrite===void 0||this.state.newAliasWrite===null,checked:this.state.newAliasWrite,onChange:e=>{const t={newAliasWrite:e.target.checked};t.newAliasRead===!1&&this.state.newAliasWrite===!1&&(t.newAliasRead=!0),this.setState(t)}}),label:ee.I18n.t("Alias write")}),this.props.obj.common.states?L.jsx(E.FormControlLabel,{style:_n.formControlLabel,control:L.jsx(E.Checkbox,{checked:this.state.newAliasCopyStates,onChange:e=>this.setState({newAliasCopyStates:e.target.checked})}),label:ee.I18n.t("Copy states")}):null,L.jsx(E.FormControlLabel,{style:_n.formControlLabel,control:L.jsx(E.Checkbox,{checked:this.state.newAliasUseFormula,onChange:e=>this.setState({newAliasUseFormula:e.target.checked})}),label:ee.I18n.t("Use convert functions")}),this.state.newAliasUseFormula&&this.state.newAliasRead?L.jsx(E.TextField,{style:_n.formControlLabel,variant:"standard",value:this.state.newAliasReadFormula,onChange:e=>this.setState({newAliasReadFormula:e.target.value}),label:ee.I18n.t("Read formula"),helperText:`${ee.I18n.t("JS function like")} "val / 5 + 21"`,slotProps:{input:{endAdornment:this.state.newAliasReadFormula&&this.state.newAliasReadFormula!=="val"?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setState({newAliasReadFormula:"val"}),children:L.jsx(Ie.Close,{})})}):null,startAdornment:L.jsx(E.InputAdornment,{position:"start",children:L.jsx(ee.IconFx,{style:_n.funcIcon})})}},fullWidth:!0}):null,this.state.newAliasUseFormula&&this.state.newAliasWrite?L.jsx(E.TextField,{style:_n.formControlLabel,variant:"standard",value:this.state.newAliasWriteFormula,onChange:e=>this.setState({newAliasWriteFormula:e.target.value}),label:ee.I18n.t("Write formula"),slotProps:{input:{endAdornment:this.state.newAliasWriteFormula&&this.state.newAliasWriteFormula!=="val"?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setState({newAliasWriteFormula:"val"}),children:L.jsx(Ie.Close,{})})}):null,startAdornment:L.jsx(E.InputAdornment,{position:"start",children:L.jsx(ee.IconFx,{style:_n.funcIcon})})}},helperText:`${ee.I18n.t("JS function like")} "val / 5 + 21"`,fullWidth:!0}):null]}),L.jsxs(E.DialogActions,{children:[L.jsx(E.Button,{variant:"contained",disabled:!this.state.newAliasId||!!this.props.objects[`alias.0.${this.state.newAliasId}`],onClick:async()=>{const e={_id:`alias.0.${this.state.newAliasId}`,type:"state",common:{name:this.state.newAliasName,type:this.props.obj.common.type,alias:{id:this.props.obj._id}},native:{}};this.state.newAliasDesc&&(e.common.desc=this.state.newAliasDesc),this.state.newAliasType&&(e.common.type=this.state.newAliasType),this.state.newAliasType==="number"&&this.state.newAliasUnit&&(e.common.unit=this.state.newAliasUnit),this.state.newAliasRole&&(e.common.role=this.state.newAliasRole),this.state.newAliasType==="number"&&this.state.newAliasMin&&(e.common.min=parseFloat(this.state.newAliasMin)),this.state.newAliasType==="number"&&this.state.newAliasMax&&(e.common.max=parseFloat(this.state.newAliasMax)),this.state.newAliasRole&&(e.common.role=this.state.newAliasRole),this.state.newAliasRead!==void 0&&this.state.newAliasRead!==null&&(e.common.read=this.state.newAliasRead),this.state.newAliasWrite!==void 0&&this.state.newAliasWrite!==null&&(e.common.write=this.state.newAliasWrite),this.state.newAliasColor&&(e.common.color=this.state.newAliasColor),this.state.newAliasIcon&&(e.common.icon=this.state.newAliasIcon),this.state.newAliasCopyStates&&this.props.obj.common.states&&(e.common.states=this.props.obj.common.states),this.state.newAliasUseFormula&&(e.common.read!==!1&&this.state.newAliasReadFormula&&this.state.newAliasReadFormula!=="val"&&(e.common.alias.read=this.state.newAliasReadFormula),e.common.write!==!1&&this.state.newAliasWriteFormula&&this.state.newAliasWriteFormula!=="val"&&(e.common.alias.write=this.state.newAliasWriteFormula)),await this.props.socket.setObject(e._id,e),this.setState({showAddNewAlias:!1}),this.props.onRedirect(e._id,2e3),this.props.onClose()},startIcon:L.jsx(Ie.AddLink,{}),color:"primary",children:this.props.t("Create")}),L.jsx(E.Button,{variant:"contained",onClick:()=>this.setState({showAddNewAlias:!1}),startIcon:L.jsx(Ie.Close,{}),color:"grey",children:this.props.t("Close")})]})]}):null}render(){return L.jsxs(E.Dialog,{open:!0,maxWidth:"sm",onClose:()=>this.props.onClose(),fullWidth:!0,"aria-labelledby":"object-alias-dialog-title",children:[this.renderAddNewAlias(),L.jsx(E.DialogTitle,{id:"object-alias-dialog-title",children:this.state.usedInAliases.length?ee.I18n.t("This object is used in aliases"):ee.I18n.t("This object does not used in any aliases yet")}),L.jsx(E.DialogContent,{children:L.jsxs(E.MenuList,{style:{maxWidth:400},children:[this.state.usedInAliases.map(e=>L.jsxs(E.MenuItem,{style:_n.usedInAlias,onClick:()=>this.props.onRedirect(e),children:[L.jsx(E.ListItemIcon,{children:L.jsx(Ie.Link,{fontSize:"small"})}),L.jsx(E.ListItemText,{children:e})]},e)),L.jsxs(E.MenuItem,{onClick:()=>this.setState({showAddNewAlias:!0}),sx:_n.addNewAlias,children:[L.jsx(E.ListItemIcon,{children:L.jsx(Ie.AddLink,{fontSize:"small"})}),L.jsx(E.ListItemText,{children:ee.I18n.t("Create alias from this ID")})]})]})}),L.jsx(E.DialogActions,{children:L.jsx(E.Button,{variant:"contained",onClick:()=>this.props.onClose(),startIcon:L.jsx(Ie.Close,{}),color:"grey",children:this.props.t("Close")})})]},"editAlias")}}class R4 extends Te.Component{checkTimer=null;objects={};constructor(e){super(e);const t=this.props.id.split("."),i=t.pop()||"";this.state={name:i,parentId:t.join("."),renameAllChildren:!0,newExists:!0,showParentDialog:!1,showHistoryWarning:!1,withHistory:[]}}componentWillUnmount(){this.checkTimer&&(clearTimeout(this.checkTimer),this.checkTimer=null)}static calculateNewId(e,t,i){const n=e.split("."),r=t.split(".");let o=0;for(;n[o]===r[o];)o++;const a=i.split(".");return a.splice(0,o+1),`${t}.${a.join(".")}`}async getInstancesWithHistory(){const e=await this.props.socket.getAdapterInstances();return e==null?void 0:e.filter(t=>t.common.getHistory).map(t=>t._id.replace("system.adapter.",""))}async checkHistory(){this.objects={};const e=await this.getInstancesWithHistory(),t=[];try{const i=await this.props.socket.getObject(this.props.id);i&&(this.objects[i._id]=i)}catch{}for(const i of this.props.childrenIds)try{const n=await this.props.socket.getObject(i);n&&(this.objects[n._id]=n)}catch{}return Object.values(this.objects).forEach(i=>{var n;(n=i.common)!=null&&n.custom&&Object.keys(i.common.custom).find(r=>e.includes(r)&&!i.common.custom[r].aliasId)&&t.push(i._id)}),t.length?(this.setState({showHistoryWarning:!0,withHistory:t}),!1):!0}showHistoryWarning(){return this.state.showHistoryWarning?L.jsxs(E.Dialog,{open:!0,onClose:()=>this.setState({showHistoryWarning:!1}),children:[L.jsx(E.DialogTitle,{children:this.props.t("Found states with history")}),L.jsxs(E.DialogContent,{children:[this.state.withHistory.length>2?this.props.t("You want to move %s states with enabled history",this.state.withHistory.length):`${this.props.t("Following states have history enabled")}: ${this.state.withHistory.join(", ")}`,L.jsx("div",{children:this.props.t("move_states_with_history_warning")})]}),L.jsxs(E.DialogActions,{children:[L.jsx(E.Button,{variant:"contained",color:"primary",onClick:async()=>{const e=`${this.state.parentId}.${this.state.name}`;await this.renameCopyObject(this.props.id,e,this.props.childrenIds.length&&this.state.renameAllChildren,!1),this.props.onClose()},startIcon:L.jsx(Ie.Check,{}),children:this.props.t("Confirm")}),L.jsx(E.Button,{color:"grey",variant:"contained",startIcon:L.jsx(Ie.Close,{}),onClick:()=>this.setState({showHistoryWarning:!1}),children:this.props.t("ra_Cancel")})]})]}):null}async renameCopyObject(e,t,i,n){var a;if(e===t)return;let r;try{r=((a=this.objects)==null?void 0:a[e])||await this.props.socket.getObject(e)}catch{}let o;if((r==null?void 0:r.type)==="state"&&(o=await this.props.socket.getState(e)),i)for(const l of this.props.childrenIds){const h=R4.calculateNewId(e,t,l);await this.renameCopyObject(l,h,!1,n)}r&&(await this.props.socket.setObject(t,r),o&&await this.props.socket.setState(t,o),n||await this.props.socket.delObject(e))}checkIfNewExists(){const e=`${this.state.parentId}.${this.state.name}`;this.checkTimer&&(clearTimeout(this.checkTimer),this.checkTimer=null),this.props.id===e?this.state.newExists||(this.checkTimer=setTimeout(()=>{this.checkTimer=null,this.setState({newExists:!0})},50)):this.checkTimer=setTimeout(async()=>{this.checkTimer=null;try{const t=await this.props.socket.getObject(e);t&&!this.state.newExists?this.setState({newExists:!0}):!t&&this.state.newExists&&this.setState({newExists:!1})}catch{this.state.newExists&&this.setState({newExists:!1})}},300)}renderParentSelectorDialog(){return this.state.showParentDialog?L.jsx(ee.SelectID,{foldersFirst:!0,imagePrefix:"../..",expertMode:this.props.expertMode,socket:this.props.socket,columns:["name","type","role","room","func"],types:["folder","channel","device","meta"],notEditable:!0,selected:this.state.parentId,allowNonObjects:!0,filterFunc:e=>this.props.expertMode?!0:e._id.startsWith("0_userdata.0")||e._id.startsWith("javascript."),theme:this.props.theme,onSelectConfirm:(e,t)=>{let i;return Array.isArray(e)?i=e[0]:i=e,i.split(".").length<=1||t[i]&&(t[i].type==="state"||i.startsWith("system."))?Promise.resolve(!1):Promise.resolve(!0)},onClose:()=>this.setState({showParentDialog:!1}),onOk:e=>{let t;Array.isArray(e)?t=e[0]:t=e,t&&t.split(".").length>1&&this.setState({parentId:t})}}):null}render(){const e=`${this.state.parentId}.${this.state.name}`;return L.jsxs(E.Dialog,{open:!0,maxWidth:"md",fullWidth:!0,onClose:()=>this.props.onClose(),children:[this.renderParentSelectorDialog(),this.showHistoryWarning(),L.jsxs(E.DialogTitle,{children:[L.jsxs("span",{style:{opacity:.6,marginRight:8},children:[this.props.t("Rename or copy object")," -"]}),L.jsx("span",{style:{fontWeight:"bold"},children:this.props.id})]}),L.jsxs(E.DialogContent,{children:[L.jsxs("div",{style:{display:"flex",gap:8,alignItems:"end",opacity:.7},children:[L.jsx(E.TextField,{fullWidth:!0,variant:"standard",label:this.props.t("Parent ID"),value:`${this.state.parentId}.`,slotProps:{input:{readOnly:!0}}}),L.jsx(E.Button,{variant:"outlined",style:{maxWidth:40,width:40,height:32},onClick:()=>this.setState({showParentDialog:!0}),children:"..."})]}),L.jsx(E.TextField,{value:this.state.name,onChange:t=>{const i=t.target.value.replace(ee.Utils.FORBIDDEN_CHARS,"_").replace(/\./g,"_").replace(/\s/g,"_").replace(/,/g,"_").replace(/__/g,"_").replace(/__/g,"_");this.setState({name:i},()=>this.checkIfNewExists())},style:{marginTop:20},autoFocus:!0,variant:"standard",fullWidth:!0,label:this.props.t("New object ID")}),this.props.childrenIds.length?L.jsx(E.FormControlLabel,{control:L.jsx(E.Checkbox,{checked:this.state.renameAllChildren,onChange:()=>{this.setState({renameAllChildren:!this.state.renameAllChildren})}}),label:this.props.t("Rename all children")}):null,L.jsxs("div",{children:[L.jsxs("span",{style:{opacity:.6,marginRight:8,fontSize:16},children:[this.props.t("New object ID"),":"]}),L.jsx("span",{style:{fontWeight:"bold",fontSize:16},children:e})]})]}),L.jsxs(E.DialogActions,{children:[L.jsx(E.Button,{disabled:!this.state.name||e===this.props.id,color:"primary",variant:"outlined",onClick:async()=>{await this.renameCopyObject(this.props.id,e,this.props.childrenIds.length&&this.state.renameAllChildren,!0),this.props.onClose()},children:this.props.t("Create a copy")}),L.jsx(E.Button,{disabled:!this.state.name||e===this.props.id,color:"primary",variant:"contained",onClick:async()=>{await this.checkHistory()&&(await this.renameCopyObject(this.props.id,e,this.props.childrenIds.length&&this.state.renameAllChildren,!1),this.props.onClose())},children:e!==this.props.id&&this.state.newExists?this.props.t("Replace"):this.props.t("Rename")}),L.jsx(E.Button,{variant:"contained",color:"grey",onClick:()=>this.props.onClose(),startIcon:L.jsx(Ie.Close,{}),children:this.props.t("ra_Cancel")})]})]})}}function Vme(s){if(s.length===0)throw new Error("Invalid tail call");return[s.slice(0,s.length-1),s[s.length-1]]}function Ei(s,e,t=(i,n)=>i===n){if(s===e)return!0;if(!s||!e||s.length!==e.length)return!1;for(let i=0,n=s.length;i<n;i++)if(!t(s[i],e[i]))return!1;return!0}function Wme(s,e){const t=s.length-1;e<t&&(s[e]=s[t]),s.pop()}function Hme(s,e,t){return eX(s.length,i=>t(s[i],e))}function eX(s,e){let t=0,i=s-1;for(;t<=i;){const n=(t+i)/2|0,r=e(n);if(r<0)t=n+1;else if(r>0)i=n-1;else return n}return-(t+1)}function*P4(s,e){let t,i;for(const n of s)i!==void 0&&e(i,n)?t.push(n):(t&&(yield t),t=[n]),i=n;t&&(yield t)}function tX(s,e){for(let t=0;t<=s.length;t++)e(t===0?void 0:s[t-1],t===s.length?void 0:s[t])}function zme(s,e){for(let t=0;t<s.length;t++)e(t===0?void 0:s[t-1],s[t],t+1===s.length?void 0:s[t+1])}function O4(s){return s.filter(e=>!!e)}function fV(s){let e=0;for(let t=0;t<s.length;t++)s[t]&&(s[e]=s[t],e+=1);s.length=e}function jme(s){return!Array.isArray(s)||s.length===0}function fD(s){return Array.isArray(s)&&s.length>0}function Kf(s,e=t=>t){const t=new Set;return s.filter(i=>{const n=e(i);return t.has(n)?!1:(t.add(n),!0)})}function qn(s,e){let t=typeof e=="number"?s:0;typeof e=="number"?t=s:(t=0,e=s);const i=[];if(t<=e)for(let n=t;n<e;n++)i.push(n);else for(let n=t;n>e;n--)i.push(n);return i}function gD(s,e,t){const i=s.slice(0,e),n=s.slice(e);return i.concat(t,n)}function K2(s,e){const t=s.indexOf(e);t>-1&&(s.splice(t,1),s.unshift(e))}function xy(s,e){const t=s.indexOf(e);t>-1&&(s.splice(t,1),s.push(e))}function HN(s,e){for(const t of e)s.push(t)}function Ume(s,e,t){const i=iX(s,e),n=s.length,r=t.length;s.length=n+r;for(let o=n-1;o>=i;o--)s[o+r]=s[o];for(let o=0;o<r;o++)s[o+i]=t[o]}function HS(s,e,t,i){const n=iX(s,e);let r=s.splice(n,t);return r===void 0&&(r=[]),Ume(s,n,i),r}function iX(s,e){return e<0?Math.max(e+s.length,0):Math.min(e,s.length)}var Vb;(function(s){function e(r){return r<0}s.isLessThan=e;function t(r){return r<=0}s.isLessThanOrEqual=t;function i(r){return r>0}s.isGreaterThan=i;function n(r){return r===0}s.isNeitherLessOrGreaterThan=n,s.greaterThan=1,s.lessThan=-1,s.neitherLessOrGreaterThan=0})(Vb||(Vb={}));function Ir(s,e){return(t,i)=>e(s(t),s(i))}function $me(...s){return(e,t)=>{for(const i of s){const n=i(e,t);if(!Vb.isNeitherLessOrGreaterThan(n))return n}return Vb.neitherLessOrGreaterThan}}const Fh=(s,e)=>s-e,Gme=(s,e)=>Fh(s?1:0,e?1:0);function qme(s){return(e,t)=>-s(e,t)}class Uh{constructor(e){this.firstIdx=0,this.items=e,this.lastIdx=this.items.length-1}get length(){return this.lastIdx-this.firstIdx+1}takeWhile(e){let t=this.firstIdx;for(;t<this.items.length&&e(this.items[t]);)t++;const i=t===this.firstIdx?null:this.items.slice(this.firstIdx,t);return this.firstIdx=t,i}takeFromEndWhile(e){let t=this.lastIdx;for(;t>=0&&e(this.items[t]);)t--;const i=t===this.lastIdx?null:this.items.slice(t+1,this.lastIdx+1);return this.lastIdx=t,i}peek(){if(this.length!==0)return this.items[this.firstIdx]}dequeue(){const e=this.items[this.firstIdx];return this.firstIdx++,e}takeCount(e){const t=this.items.slice(this.firstIdx,this.firstIdx+e);return this.firstIdx+=e,t}}const Yp=class Yp{constructor(e){this.iterate=e}toArray(){const e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(e){return new Yp(t=>this.iterate(i=>e(i)?t(i):!0))}map(e){return new Yp(t=>this.iterate(i=>t(e(i))))}findLast(e){let t;return this.iterate(i=>(e(i)&&(t=i),!0)),t}findLastMaxBy(e){let t,i=!0;return this.iterate(n=>((i||Vb.isGreaterThan(e(n,t)))&&(i=!1,t=n),!0)),t}};Yp.empty=new Yp(e=>{});let mf=Yp;class Kme{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Km.isErrorNoTelemetry(e)?new Km(e.message+`
|
|
39
|
+
${o.getFullYear()}`}}},yAxis:i,toolbox:{left:"right",feature:this.props.noToolbar?void 0:{saveAsImage:{title:this.props.t("Save as image"),show:!0}}},series:[t]}}static getDerivedStateFromProps(e,t){return null}updateChart(e,t,i,n){e&&(this.start=e),t&&(this.end=t),e=e||this.start,t=t||this.end,this.readTimeout&&clearTimeout(this.readTimeout),this.readTimeout=setTimeout(()=>{var o;this.readTimeout=null;const r=this.chart.max-this.chart.min;r!==this.chart.diff&&(this.chart.diff=r,this.chart.withTime=this.chart.diff<36e5*24*7,this.chart.withSeconds=this.chart.diff<6e4*30),i?this.readHistory(e,t).then(a=>{var l;typeof((l=this.echartsReact)==null?void 0:l.getEchartsInstance)=="function"&&this.echartsReact.getEchartsInstance().setOption({series:[{data:this.convertData(a)}],xAxis:{min:this.chart.min,max:this.chart.max}}),n&&n()}):(typeof((o=this.echartsReact)==null?void 0:o.getEchartsInstance)=="function"&&this.echartsReact.getEchartsInstance().setOption({series:[{data:this.convertData()}],xAxis:{min:this.chart.min,max:this.chart.max}}),n&&n())},400)}setNewRange(e){var t;this.chart.diff=this.chart.max-this.chart.min,this.chart.withTime=this.chart.diff<36e5*24*7,this.chart.withSeconds=this.chart.diff<6e4*30,this.state.relativeRange!=="absolute"?(this.setState({relativeRange:"absolute"}),this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=null)):typeof((t=this.echartsReact)==null?void 0:t.getEchartsInstance)=="function"&&(this.echartsReact.getEchartsInstance().setOption({xAxis:{min:this.chart.min,max:this.chart.max}}),e&&this.updateChart(this.chart.min,this.chart.max,!0))}shiftTime(){const e=new Date,t=6e4-e.getSeconds()-(1e3-e.getMilliseconds());e.getMilliseconds()&&e.setMilliseconds(1e3),e.getSeconds()&&e.setSeconds(60);const i=e.getTime();let n;const r=this.state.relativeRange;if(r==="day")e.setHours(0),e.setMinutes(0),e.setSeconds(0),n=e.getTime();else if(r==="week"){e.setHours(0),e.setMinutes(0),e.setSeconds(0);const o=e.getDay()||7;o!==1&&e.setHours(-24*(o-1)),n=e.getTime()}else if(r==="2weeks"){e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setDate(e.getDate()-7);const o=e.getDay()||7;o!==1&&e.setHours(-24*(o-1)),n=e.getTime()}else r==="month"?(e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setDate(1),n=e.getTime()):r==="year"?(e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setDate(1),e.setMonth(0),n=e.getTime()):r==="12months"?(e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setFullYear(e.getFullYear()-1),n=e.getTime()):n=i-parseInt(r,10)*6e4;this.chart.min=n,this.chart.max=i,this.setState({min:n,max:i},()=>this.updateChart(this.chart.min,this.chart.max,!0)),this.timeTimer=setTimeout(()=>{this.timeTimer=null,this.shiftTime()},t||6e4)}setRelativeInterval(e,t,i){if(t||(this.localStorage.setItem("App.relativeRange",e),this.setState({relativeRange:e})),e==="absolute"){this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=null),this.updateChart(this.chart.min,this.chart.max,!0,i);return}this.localStorage.removeItem("App.absoluteStart"),this.localStorage.removeItem("App.absoluteEnd");const n=new Date;if(!this.timeTimer){const r=6e4-n.getSeconds()-(1e3-n.getMilliseconds());this.timeTimer=setTimeout(()=>{this.timeTimer=null,this.shiftTime()},r||6e4)}if(n.getMilliseconds()&&n.setMilliseconds(1e3),n.getSeconds()&&n.setSeconds(60),this.chart.max=n.getTime(),e==="day")n.setHours(0),n.setMinutes(0),n.setSeconds(0),this.chart.min=n.getTime();else if(e==="week"){n.setHours(0),n.setMinutes(0),n.setSeconds(0);const r=n.getDay()||7;r!==1&&n.setHours(-24*(r-1)),this.chart.min=n.getTime()}else if(e==="2weeks"){n.setHours(0),n.setMinutes(0),n.setSeconds(0),n.setDate(n.getDate()-7);const r=n.getDay()||7;r!==1&&n.setHours(-24*(r-1)),this.chart.min=n.getTime()}else e==="month"?(n.setHours(0),n.setMinutes(0),n.setSeconds(0),n.setDate(1),this.chart.min=n.getTime()):e==="year"?(n.setHours(0),n.setMinutes(0),n.setSeconds(0),n.setDate(1),n.setMonth(0),this.chart.min=n.getTime()):e==="12months"?(n.setHours(0),n.setMinutes(0),n.setSeconds(0),n.setFullYear(n.getFullYear()-1),this.chart.min=n.getTime()):this.chart.min=this.chart.max-parseInt(e,10)*6e4;this.setState({min:this.chart.min,max:this.chart.max},()=>this.updateChart(this.chart.min,this.chart.max,!0,i))}installEventHandlers(){if(!this.echartsReact||typeof this.echartsReact.getEchartsInstance!="function")return;const e=this.echartsReact.getEchartsInstance().getZr();e._iobInstalled||(e._iobInstalled=!0,e.on("mousedown",t=>{console.log("mouse down"),this.mouseDown=!0,this.chart.lastX=t.offsetX}),e.on("mouseup",()=>{console.log("mouse up"),this.mouseDown=!1,this.setNewRange(!0)}),e.on("mousewheel",t=>{let i=this.chart.max-this.chart.min;const n=this.state.chartWidth-Qu-ar,o=(t.offsetX-ar)/n,a=i,l=t.wheelDelta>0?1.1:.9;i*=l;const h=a-i;this.chart.max+=h*(1-o),this.chart.min-=h*o,this.setNewRange()}),e.on("mousemove",t=>{if(this.mouseDown){const i=this.chart.lastX-(t.offsetX-ar);this.chart.lastX=t.offsetX-ar;const n=this.chart.max-this.chart.min,r=this.state.chartWidth-Qu-ar,o=Math.round(i*n/r);this.chart.min+=o,this.chart.max+=o,this.setNewRange()}}),e.on("touchstart",t=>{t.preventDefault(),this.mouseDown=!0;const i=t.touches||t.originalEvent.touches;i&&(this.chart.lastX=i[i.length-1].pageX,i.length>1?this.chart.lastWidth=Math.abs(i[0].pageX-i[1].pageX):this.chart.lastWidth=null)}),e.on("touchend",t=>{t.preventDefault(),this.mouseDown=!1,this.setNewRange(!0)}),e.on("touchmove",t=>{t.preventDefault();const i=t.touches||t.originalEvent.touches;if(!i)return;const n=i[i.length-1].pageX-ar;if(this.mouseDown)if(i.length>1){const r=Math.abs(i[0].pageX-i[1].pageX);if(this.chart.lastWidth!==null&&r!==this.chart.lastWidth){let o=this.chart.max-this.chart.min;const a=this.state.chartWidth-Qu-ar,l=r>this.chart.lastWidth?1.1:.9,c=(i[0].pageX>i[1].pageX?i[1].pageX-ar+r/2:i[0].pageX-ar+r/2)/a,u=o;o*=l;const d=u-o;this.chart.max+=d*(1-c),this.chart.min-=d*c,this.setNewRange()}this.chart.lastWidth=r}else{const r=this.chart.lastX-n,o=this.chart.max-this.chart.min,a=this.state.chartWidth-Qu-ar,l=Math.round(r*o/a);this.chart.min+=l,this.chart.max+=l,this.setNewRange()}this.chart.lastX=n}))}renderChart(){var e;return this.state.historyInstance?(e=this.state.historyInstances)!=null&&e.find(t=>t.id===this.state.historyInstance&&t.alive)?this.chartValues?L.jsx(nne,{ref:t=>this.echartsReact=t,echarts:Lde,option:this.getOption(),notMerge:!0,lazyUpdate:!0,theme:this.props.themeType==="dark"?"dark":"",style:{height:`${this.state.chartHeight}px`,width:"100%"},opts:{renderer:"svg"},onEvents:{rendered:()=>this.installEventHandlers()}}):L.jsx(E.LinearProgress,{}):L.jsx("div",{style:{marginTop:20,fontSize:24,marginLeft:24},children:this.props.t("History instance not alive")}):L.jsx("div",{style:{marginTop:20,fontSize:24,marginLeft:24},children:this.props.t("History instance not selected")})}componentDidUpdate(){if(this.divRef.current){const e=this.divRef.current.offsetWidth,t=this.divRef.current.offsetHeight;this.state.chartHeight!==t&&(this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.updateTimer=null,this.setState({chartHeight:t,chartWidth:e})},100))}}setStartDate(e){const t=e.getTime();this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=null),this.localStorage.setItem("App.relativeRange","absolute"),this.localStorage.setItem("App.absoluteStart",t.toString()),this.localStorage.setItem("App.absoluteEnd",this.state.max.toString()),this.chart.min=t,this.setState({min:t,relativeRange:"absolute"},()=>this.updateChart(this.chart.min,this.chart.max,!0))}setEndDate(e){const t=e.getTime();this.localStorage.setItem("App.relativeRange","absolute"),this.localStorage.setItem("App.absoluteStart",this.state.min.toString()),this.localStorage.setItem("App.absoluteEnd",t.toString()),this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=null),this.chart.max=t,this.setState({max:t,relativeRange:"absolute"},()=>this.updateChart(this.chart.min,this.chart.max,!0))}openEcharts(){const e=[`id=${window.encodeURIComponent(this.props.obj._id)}`,`instance=${window.encodeURIComponent(this.state.historyInstance)}`,"menuOpened=false"];this.state.relativeRange==="absolute"?(e.push(`start=${this.chart.min}`),e.push(`end=${this.chart.max}`)):e.push(`range=${this.state.relativeRange}`),window.open(`${window.location.protocol}//${window.location.host}/adapter/echarts/tab.html#${e.join("&")}`,"echarts")}async onStepChanged(e){const t=await this.props.socket.getObject(this.props.obj._id);t.common.custom&&t.common.custom[this.state.historyInstance]&&t.common.custom[this.state.historyInstance].chartStep!==e&&(t.common.custom[this.state.historyInstance].chartStep=e,await this.props.socket.setObject(t._id,t)),this.setState({stepType:e,showStepMenu:null})}renderToolbar(){if(this.props.noToolbar)return null;const e=this.state.windowWidth<960;return L.jsxs(E.Toolbar,{children:[!this.props.historyInstance&&L.jsxs(E.FormControl,{variant:"standard",style:on.selectHistoryControl,children:[L.jsx(E.InputLabel,{children:this.props.t("History instance")}),L.jsx(E.Select,{variant:"standard",value:this.state.historyInstance,onChange:t=>{this.localStorage.setItem("App.historyInstance",t.target.value),this.setState({historyInstance:t.target.value})},children:this.state.historyInstances.map(t=>L.jsx(E.MenuItem,{value:t.id,style:t.alive?void 0:on.notAliveInstance,children:t.id},t.id))})]}),L.jsxs(E.FormControl,{variant:"standard",style:on.selectRelativeTime,children:[L.jsx(E.InputLabel,{children:this.props.t("Relative")}),L.jsxs(E.Select,{variant:"standard",ref:this.rangeRef,value:this.state.relativeRange,onChange:t=>this.setRelativeInterval(t.target.value),children:[L.jsx(E.MenuItem,{value:"absolute",sx:on.customRange,children:this.props.t("custom range")},"custom"),L.jsx(E.MenuItem,{value:10,children:this.props.t("last 10 minutes")},"1"),L.jsx(E.MenuItem,{value:30,children:this.props.t("last 30 minutes")},"2"),L.jsx(E.MenuItem,{value:60,children:this.props.t("last hour")},"3"),L.jsx(E.MenuItem,{value:"day",children:this.props.t("this day")},"4"),L.jsx(E.MenuItem,{value:1440,children:this.props.t("last 24 hours")},"5"),L.jsx(E.MenuItem,{value:"week",children:this.props.t("this week")},"6"),L.jsx(E.MenuItem,{value:1440*7,children:this.props.t("last week")},"7"),L.jsx(E.MenuItem,{value:"2weeks",children:this.props.t("this 2 weeks")},"8"),L.jsx(E.MenuItem,{value:1440*14,children:this.props.t("last 2 weeks")},"9"),L.jsx(E.MenuItem,{value:"month",children:this.props.t("this month")},"10"),L.jsx(E.MenuItem,{value:720*60,children:this.props.t("last 30 days")},"11"),L.jsx(E.MenuItem,{value:"year",children:this.props.t("this year")},"12"),L.jsx(E.MenuItem,{value:"12months",children:this.props.t("last 12 months")},"13")]})]}),L.jsxs(_s.LocalizationProvider,{dateAdapter:dS,adapterLocale:gS[this.props.lang],children:[L.jsxs("div",{style:on.toolbarTimeGrid,children:[L.jsx("div",{style:{...on.toolbarTimeLabel,opacity:this.state.relativeRange!=="absolute"?.5:void 0},children:this.props.t("Start time")}),L.jsx(_s.DatePicker,{sx:on.toolbarDate,disabled:this.state.relativeRange!=="absolute",value:new Date(this.state.min),onChange:t=>this.setStartDate(t)}),L.jsx(_s.TimePicker,{disabled:this.state.relativeRange!=="absolute",sx:on.toolbarTime,ampm:this.state.ampm,value:new Date(this.state.min),onChange:t=>this.setStartDate(t)})]}),L.jsxs("div",{style:on.toolbarTimeGrid,children:[L.jsx("div",{style:{...on.toolbarTimeLabel,opacity:this.state.relativeRange!=="absolute"?.5:void 0},children:this.props.t("End time")}),L.jsx(_s.DatePicker,{disabled:this.state.relativeRange!=="absolute",sx:on.toolbarDate,value:new Date(this.state.max),onChange:t=>this.setEndDate(t)}),L.jsx(_s.TimePicker,{disabled:this.state.relativeRange!=="absolute",sx:on.toolbarTime,ampm:this.state.ampm,value:new Date(this.state.max),onChange:t=>this.setEndDate(t)})]})]}),L.jsx("div",{style:on.grow}),L.jsx(E.Button,{style:{marginRight:10},variant:"outlined",onClick:t=>this.setState({showStepMenu:t.target}),children:e?this.state.stepType===""?L.jsx(Ie.Remove,{}):this.state.stepType==="stepStart"?L.jsx(Ie.KeyboardArrowRight,{}):this.state.stepType==="stepMiddle"?L.jsx(Ie.MoreHoriz,{}):this.state.stepType==="stepEnd"?L.jsx(Ie.KeyboardArrowLeft,{}):this.props.t("Step type"):this.state.stepType?this.props.t(this.state.stepType):this.props.t("Step type")}),this.state.showStepMenu?L.jsxs(E.Menu,{open:!0,anchorEl:this.state.showStepMenu,onClose:()=>this.setState({showStepMenu:null}),children:[L.jsx(E.MenuItem,{selected:this.state.stepType==="",onClick:()=>this.onStepChanged(""),children:e?L.jsx(Ie.Remove,{}):this.props.t("None")}),L.jsx(E.MenuItem,{selected:this.state.stepType==="stepStart",onClick:()=>this.onStepChanged("stepStart"),children:e?L.jsx(Ie.KeyboardArrowRight,{}):this.props.t("stepStart")}),L.jsx(E.MenuItem,{selected:this.state.stepType==="stepMiddle",onClick:()=>this.onStepChanged("stepMiddle"),children:e?L.jsx(Ie.MoreHoriz,{}):this.props.t("stepMiddle")}),L.jsx(E.MenuItem,{selected:this.state.stepType==="stepEnd",onClick:()=>this.onStepChanged("stepEnd"),children:e?L.jsx(Ie.KeyboardArrowLeft,{}):this.props.t("stepEnd")})]}):null,this.props.showJumpToEchart&&this.state.echartsJump&&L.jsx(E.Fab,{style:on.echartsButton,size:"small",onClick:()=>this.openEcharts(),title:this.props.t("Open charts in new window"),children:L.jsx("img",{src:Ime,alt:"echarts",style:on.buttonIcon})}),L.jsxs(E.Fab,{variant:"extended",size:"small",color:this.state.splitLine?"primary":"default","aria-label":"show lines",onClick:()=>{this.localStorage.setItem("App.splitLine",this.state.splitLine?"false":"true"),this.setState({splitLine:!this.state.splitLine})},children:[L.jsx(yie,{style:on.splitLineButtonIcon}),this.props.t("Show lines")]})]})}render(){return!this.state.historyInstances&&!this.state.defaultHistory?L.jsx(E.LinearProgress,{}):L.jsxs(E.Paper,{style:on.paper,children:[this.renderToolbar(),L.jsx("div",{ref:this.divRef,style:ee.Utils.getStyle(this.props.theme,on.chart,this.props.noToolbar?on.chartWithoutToolbar:on.chartWithToolbar),children:this.renderChart()})]})}}const Pa={dialog:{height:"100%"},paper:{height:"calc(100% - 64px)"},content:{textAlign:"center",overflow:"hidden"},tabPanel:s=>({width:"100%",overflow:"hidden",height:`calc(100% - ${s.mixins.toolbar.minHeight}px)`}),tabSelected:s=>({color:s.palette.mode==="dark"?s.palette.secondary.contrastText:"#FFFFFF !important"}),tabsIndicator:s=>({backgroundColor:s.palette.secondary.main})};class Eme extends F7{chartAvailable;saveFunc=null;constructor(e){super(e);let t=parseInt((window._localStorage||window.localStorage).getItem("App.objectCustomTab")||"0",10);if(this.chartAvailable=this.isChartAvailable(),this.chartAvailable){const i=ee.Router.getLocation();i.arg==="chart"?t=2:i.arg==="table"&&(t=1)}else t=0;this.state={hasChanges:!1,currentTab:t,confirmDialog:!1,mobile:F7.isMobile(),progressRunning:!1,showWarning:this.props.allVisibleObjects}}isChartAvailable(){var t,i;let e=this.props.objectIDs.length===1;if(e){const n=this.props.objectIDs[0];(i=(t=this.props.objects[n])==null?void 0:t.common)!=null&&i.custom?e=!!Object.keys(this.props.objects[n].common.custom).find(r=>{const o=this.props.objects[`system.adapter.${r}`];return o&&o.common&&o.common.getHistory}):e=!1}return e}renderCharts(){return L.jsx(JY,{isFloatComma:this.props.isFloatComma,showJumpToEchart:!0,t:this.props.t,lang:this.props.lang,socket:this.props.socket,obj:this.props.objects[this.props.objectIDs[0]],customsInstances:this.props.customsInstances,themeType:this.props.themeType,theme:this.props.theme,objects:this.props.objects})}renderTable(){return L.jsx(pS,{t:this.props.t,isFloatComma:this.props.isFloatComma,lang:this.props.lang,expertMode:this.props.expertMode,socket:this.props.socket,obj:this.props.objects[this.props.objectIDs[0]],customsInstances:this.props.customsInstances,objects:this.props.objects})}renderCustomEditor(){return L.jsx(fS,{registerSaveFunc:e=>this.saveFunc=e,t:this.props.t,lang:this.props.lang,socket:this.props.socket,objectIDs:this.props.objectIDs,customsInstances:this.props.customsInstances,objects:this.props.objects,onProgress:e=>this.setState({progressRunning:e}),reportChangedIds:this.props.reportChangedIds,onChange:(e,t)=>{this.setState({hasChanges:e},()=>{if(t){const i=this.isChartAvailable();i!==this.chartAvailable&&(this.chartAvailable=i,this.forceUpdate())}})},theme:this.props.theme,themeName:this.props.themeName,themeType:this.props.themeType,systemConfig:this.props.systemConfig})}renderDialogConfirm(){return this.state.confirmDialog?L.jsx(ee.DialogConfirm,{title:ee.I18n.t("You have unsaved changes"),text:ee.I18n.t("Discard?"),ok:ee.I18n.t("Yes"),cancel:ee.I18n.t("Cancel"),onClose:e=>this.setState({confirmDialog:!1},()=>e&&this.props.onClose())}):null}onClose(){this.state.hasChanges?this.setState({confirmDialog:!0}):this.props.onClose()}renderWarningDialog(){return this.state.showWarning?L.jsx(ee.DialogConfirm,{text:L.jsx("div",{style:{color:"#F00"},children:this.props.t("Your are intend to edit ALL objects. Are you sure?")}),ok:this.props.t("Yes"),onClose:e=>{this.setState({showWarning:!1}),e||this.onClose()}}):null}render(){var t,i;const e=(i=(t=this.props.objects[this.props.objectIDs[0]])==null?void 0:t.common)==null?void 0:i.type;return L.jsxs(E.Dialog,{sx:{"&.MuiDialog-scrollPaper":Pa.dialog,"& .MuiDialog-paper":Pa.paper},scroll:"paper",open:!0,onClose:()=>this.props.onClose(),fullWidth:!0,maxWidth:"xl","aria-labelledby":"form-dialog-title",children:[this.renderDialogConfirm(),this.renderWarningDialog(),L.jsx(E.DialogTitle,{children:this.props.objectIDs.length>1?this.props.t("Edit config for %s states",this.props.objectIDs.length):this.props.t("Edit config: %s",this.props.objectIDs[0])}),L.jsxs(E.DialogContent,{style:Pa.content,children:[L.jsx(E.AppBar,{position:"static",children:L.jsxs(E.Tabs,{value:this.state.currentTab,onChange:(n,r)=>{ee.Router.doNavigate(null,null,null,r===1?"table":r===2?"chart":"config"),this.setState({currentTab:r}),(window._localStorage||window.localStorage).setItem("App.objectCustomTab",r)},sx:{"& .MuiTabs-indicator":Pa.tabsIndicator},indicatorColor:"secondary",children:[L.jsx(E.Tab,{disabled:this.state.progressRunning,label:this.props.t("Custom settings"),id:"custom-settings-tab","aria-controls":"custom-tabpanel-settings",sx:{"&.Mui-selected":Pa.tabSelected}}),this.props.objectIDs.length===1&&this.chartAvailable?L.jsx(E.Tab,{disabled:this.state.progressRunning,label:this.props.t("History data"),id:"history-data-tab","aria-controls":"custom-tabpanel-history",sx:{"&.Mui-selected":Pa.tabSelected}}):null,(e==="number"||e==="boolean")&&this.props.objectIDs.length===1&&this.chartAvailable?L.jsx(E.Tab,{disabled:this.state.progressRunning,label:this.props.t("Chart"),id:"chart-tab","aria-controls":"custom-tabpanel-chart",sx:{"&.Mui-selected":Pa.tabSelected}}):null]})}),this.state.currentTab===0?L.jsx(E.Box,{component:"div",sx:Pa.tabPanel,children:this.renderCustomEditor()}):null,this.props.objectIDs.length===1&&this.chartAvailable&&this.state.currentTab===1?L.jsx(E.Box,{component:"div",sx:Pa.tabPanel,children:this.renderTable()}):null,(e==="number"||e==="boolean")&&this.props.objectIDs.length===1&&this.chartAvailable&&this.state.currentTab===2?L.jsx(E.Box,{component:"div",sx:Pa.tabPanel,children:this.renderCharts()}):null]}),L.jsxs(E.DialogActions,{children:[this.state.currentTab===0&&L.jsx(E.Button,{id:"object-custom-dialog-save",variant:"contained",color:"primary",disabled:!this.state.hasChanges||this.state.progressRunning,onClick:()=>this.saveFunc&&this.saveFunc(),children:this.getButtonTitle(L.jsx(Ie.Save,{}),this.props.t("Save"))}),this.state.currentTab===0&&L.jsx(E.Button,{id:"object-custom-dialog-save-close",variant:"contained",color:"primary",disabled:!this.state.hasChanges||this.state.progressRunning,onClick:()=>{this.saveFunc?this.saveFunc(n=>!n&&this.onClose()):this.onClose()},children:this.getButtonTitle(L.jsx(Ie.Save,{}),this.props.t("Save & close"),L.jsx(Ie.Close,{}))}),L.jsx(E.Button,{id:"object-custom-dialog-close",disabled:this.state.progressRunning,variant:"contained",onClick:()=>this.onClose(),color:"grey",children:this.getButtonTitle(L.jsx(Ie.Close,{}),this.props.t("Close"))})]})]})}}const Br={formControl:{minWidth:100},quality:{width:"calc(100% - 88px)"},expire:{ml:1,width:80},readOnly:{backgroundColor:"#b74848"},readOnlyText:{color:"#b74848",marginLeft:8},wrapperButton:{"@media screen and (max-width: 465px)":{"& *":{fontSize:12}},"@media screen and (max-width: 380px)":{"& *":{fontSize:11}}},ackCheckbox:{marginLeft:4},dialog:{minHeight:window.clientHeight-50>500?500:window.clientHeight-50},tooltip:{pointerEvents:"none"}};class Ep extends Te.Component{propsValue;chartFrom;ack;inputRef=uS.createRef();q;expire;constructor(e){super(e);let t=this.props.type;t||(t=typeof this.props.value);let i=this.props.value;if(this.propsValue=i,this.propsValue===null?this.propsValue="null":this.propsValue===void 0&&(this.propsValue="undefined"),this.props.states)t="states";else if(t==="string"||t==="json"){if(i&&typeof i=="string"&&(i.startsWith("[")&&i.endsWith("]")||i.startsWith("{")&&i.endsWith("}")))try{i=JSON.parse(i),i=JSON.stringify(i,null,2),this.propsValue=i,t="json"}catch{}}else t==="number"&&(i=parseFloat(this.propsValue)||0);this.state={type:t,chart:!1,chartEnabled:(window._localStorage||window.localStorage).getItem("App.chartSetValue")!=="false",fullScreen:(window._localStorage||window.localStorage).getItem("App.fullScreen")==="true",targetValue:i,valid:!0,jsonError:!1},this.ack=!1,this.q=0,this.expire=0,this.inputRef=uS.createRef(),this.chartFrom=Date.now()-36e5*2}componentDidMount(){var e,t,i;this.props.defaultHistory&&((t=(e=this.props.object)==null?void 0:e.common)!=null&&t.custom)&&((i=this.props.object.common.custom[this.props.defaultHistory])!=null&&i.enabled)&&this.props.socket.getState(`system.adapter.${this.props.defaultHistory}.alive`).then(n=>this.setState({chart:!!(n!=null&&n.val)})),setTimeout(()=>{var n;if((n=this.inputRef)!=null&&n.current){const r=this.inputRef.current,o=r.value||"",a=r.type;r.type==="number"&&(r.type="text"),r.setSelectionRange(0,o.length),a==="number"&&(r.type=a)}},200)}onUpdate(e){e&&(e.stopPropagation(),e.preventDefault());let t=this.state.targetValue;if(this.state.type==="states")if(t==="null")t=null;else{const i=this.props.type||typeof this.state.targetValue;t=typeof t=="object"?t.value:t,i==="number"?typeof t=="string"&&(t=parseFloat(t.replace(",","."))||0):i==="boolean"&&(t=t===!0||t==="true"||t==="1"||t==="ON"||t==="on")}else this.state.type==="number"?t==="null"?t=null:typeof t=="string"&&(t=parseFloat(t.replace(",","."))||0):this.state.type==="boolean"&&(t==="null"?t=null:t=t===!0||t==="true"||t==="1"||t==="ON"||t==="on");this.props.socket.setState(this.props.object._id,{val:t,ack:this.ack,q:this.q,expire:parseInt(this.expire,10)||void 0}).then(()=>this.props.onClose()).catch(i=>window.alert(`Cannot write state "${this.props.object._id}": ${i}`))}static isNumberValid(e){const{common:t,value:i}=e;if(i==="")return!1;const n=Number(i);return typeof t.min=="number"&&n<t.min?!1:!(typeof t.max=="number"&&n>t.max)}renderTimePicker(){return L.jsxs(_s.LocalizationProvider,{adapterLocale:gS[this.props.lang],dateAdapter:dS,children:[L.jsx(_s.DatePicker,{value:Number(this.state.targetValue),onChange:e=>{e&&this.setState({targetValue:Math.round(e.getTime())})}}),L.jsx(_s.TimePicker,{value:Number(this.state.targetValue),views:["hours","minutes","seconds"],onChange:e=>{e&&this.setState({targetValue:Math.round(e.getTime())})}})]})}renderChart(){return L.jsx(JY,{t:this.props.t,isFloatComma:this.props.isFloatComma,showJumpToEchart:!1,lang:this.props.lang,socket:this.props.socket,obj:this.props.object,themeType:this.props.themeType,theme:this.props.theme,from:this.chartFrom,end:Date.now(),noToolbar:!0,defaultHistory:this.props.defaultHistory,customsInstances:[],objects:void 0,historyInstance:""})}static checkJsonError(e){try{return JSON.parse(e),!1}catch{return!0}}renderJsonEditor(){return L.jsx(f$,{error:this.state.jsonError,editValueMode:!0,themeType:this.props.themeType,defaultValue:(this.propsValue||"").toString(),onChange:e=>this.setState({targetValue:e,jsonError:Ep.checkJsonError(e)})})}renderStates(){if(!this.props.states)return null;if(this.props.type==="number"&&this.props.object.common.max!==void 0&&this.props.object.common.min!==void 0){const e=Object.keys(this.props.states).map(t=>({label:this.props.states[t],value:t}));return L.jsx(E.Autocomplete,{style:Br.formControl,disablePortal:!0,defaultValue:this.props.states[this.propsValue]!==void 0?this.props.states[this.propsValue]:this.propsValue,options:e,noOptionsText:"",freeSolo:!0,getOptionLabel:t=>(t==null?void 0:t.label)||(t!=null?t.toString():""),onChange:(t,i)=>this.setState({targetValue:i}),onInputChange:(t,i)=>this.setState({targetValue:i}),onKeyUp:t=>t.key==="Enter"&&this.onUpdate(t),renderInput:t=>L.jsx(E.TextField,{...t,label:this.props.t("Value"),variant:"standard"})})}return L.jsxs(E.FormControl,{variant:"standard",style:Br.formControl,children:[L.jsx(E.InputLabel,{children:this.props.t("Value")}),L.jsx(E.Select,{variant:"standard",defaultValue:this.propsValue,onChange:e=>this.setState({targetValue:e.target.value}),children:Object.keys(this.props.states).map((e,t)=>L.jsx(E.MenuItem,{value:e,children:this.props.states[e]},t))})]})}render(){var t,i,n;const e=L.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[L.jsx(E.FormControlLabel,{style:{...Br.formControl,...this.props.expertMode?void 0:Br.ackCheckbox},control:L.jsx(E.Checkbox,{defaultChecked:!1,onChange:r=>this.ack=r.target.checked}),label:this.props.t("Acknowledged")}),L.jsx(E.Tooltip,{title:this.props.t("Acknowledged explanation"),slotProps:{popper:{sx:Br.tooltip}},children:L.jsx(Ie.Info,{color:"primary"})})]});return L.jsxs(E.Dialog,{open:!0,maxWidth:this.state.type==="number"||this.state.type==="boolean"||this.state.type==="states"?this.state.chart&&this.state.chartEnabled?"lg":void 0:"md",fullWidth:this.state.type==="json"&&this.state.fullScreen||this.state.type!=="number"&&this.state.type!=="boolean"&&this.state.type!=="states"||this.state.chart&&this.state.chartEnabled,fullScreen:this.state.type==="json"&&this.state.fullScreen,onClose:()=>this.props.onClose(),"aria-labelledby":"edit-value-dialog-title","aria-describedby":"edit-value-dialog-description",sx:{"&. MuiDialog-paper":this.state.type==="json"?Br.dialog:void 0},children:[L.jsxs(E.DialogTitle,{id:"edit-value-dialog-title",children:[this.props.t("Write value"),((t=this.props.object.common)==null?void 0:t.write)===!1?L.jsxs("span",{style:Br.readOnlyText,children:["(",this.props.t("read only"),")"]}):null,this.state.chart?L.jsx(E.Fab,{style:{float:"right"},size:"small",color:this.state.chartEnabled?"primary":"default",onClick:()=>{(window._localStorage||window.localStorage).setItem("App.chartSetValue",this.state.chartEnabled?"false":"true"),this.setState({chartEnabled:!this.state.chartEnabled})},children:L.jsx(Ie.ShowChart,{})}):null,this.state.type==="json"?L.jsx(E.IconButton,{style:{float:"right"},onClick:()=>{(window._localStorage||window.localStorage).setItem("App.fullScreen",this.state.fullScreen?"false":"true"),this.setState({fullScreen:!this.state.fullScreen})},children:this.state.fullScreen?L.jsx(Ie.FullscreenExit,{}):L.jsx(Ie.Fullscreen,{})}):null]}),L.jsx(E.DialogContent,{children:L.jsx("form",{noValidate:!0,autoComplete:"off",onSubmit:()=>!1,style:{...Br.dialogForm,height:"100%"},children:L.jsxs(E.Grid2,{container:!0,direction:"row",spacing:2,style:{height:"100%"},children:[L.jsx(E.Grid2,{size:{xs:this.state.chart&&this.state.chartEnabled?6:12},style:{height:"100%"},children:L.jsxs(E.Grid2,{container:!0,direction:"column",spacing:2,style:{marginTop:0,height:"100%"},children:[this.props.expertMode?L.jsx(E.Grid2,{children:L.jsxs(E.Grid2,{container:!0,direction:"row",spacing:2,style:{marginTop:0},children:[this.props.expertMode?L.jsx(E.Grid2,{children:L.jsxs(E.FormControl,{style:Br.formControl,children:[L.jsx(E.InputLabel,{style:{marginTop:10,marginLeft:-14},children:this.props.t("Value type")}),L.jsxs(E.Select,{variant:"standard",value:this.state.type,onChange:r=>{this.setState({type:r.target.value,valid:r.target.value==="number"?Ep.isNumberValid({value:this.state.targetValue,common:this.props.object.common}):!0,jsonError:!1},()=>{this.state.type==="json"&&this.setState({targetValue:(this.state.targetValue||"").toString(),jsonError:Ep.checkJsonError((this.state.targetValue||"").toString())})})},children:[L.jsx(E.MenuItem,{value:"string",children:"String"}),L.jsx(E.MenuItem,{value:"number",children:"Number"}),L.jsx(E.MenuItem,{value:"boolean",children:"Boolean"}),L.jsx(E.MenuItem,{value:"object",children:"JSON/Object"}),this.props.states?L.jsx(E.MenuItem,{value:"states",children:"States"}):null]})]})}):null,this.state.type==="json"?L.jsx(E.Grid2,{flex:1}):null]})}):null,L.jsx(E.Grid2,{flex:this.state.type==="json"&&this.state.fullScreen?1:void 0,style:{paddingTop:0},children:this.state.type==="boolean"?L.jsx(E.Typography,{component:"div",style:this.props.expertMode?{marginTop:20,width:"100%",backgroundColor:this.props.themeType==="dark"?"#595959":"#dadada",borderRadius:5,padding:5}:void 0,children:L.jsxs(E.Grid2,{component:"label",container:!0,alignItems:"center",spacing:1,children:[L.jsxs(E.Grid2,{style:{marginRight:10},children:[this.props.t("Value"),":"]}),L.jsx(E.Grid2,{children:"FALSE"}),L.jsx(E.Grid2,{children:L.jsx(E.Switch,{autoFocus:!0,defaultChecked:this.propsValue==="null"||this.propsValue==="undefined"?!1:!!this.propsValue,onKeyUp:r=>r.key==="Enter"&&this.onUpdate(r),onChange:r=>this.setState({targetValue:r.target.checked})})}),L.jsx(E.Grid2,{children:"TRUE"})]})}):this.state.type==="number"?L.jsx(E.TextField,{variant:"standard",fullWidth:!0,autoFocus:!0,error:!this.state.valid,type:"number",slotProps:{htmlInput:{step:this.props.object.common.step,min:this.props.object.common.min,max:this.props.object.common.max}},inputRef:this.inputRef,helperText:this.props.t("Press ENTER to write the value, when focused"),value:this.state.targetValue.toString(),label:this.props.t("Value")+(this.props.object.common.min!==void 0||this.props.object.common.unit==="%"?`, ${this.props.t("min:")} ${this.props.object.common.min!==void 0?this.props.object.common.min:0}`:"")+(this.props.object.common.max!==void 0||this.props.object.common.unit==="%"?`, ${this.props.t("max:")} ${this.props.object.common.max!==void 0?this.props.object.common.max:100}`:""),onKeyUp:r=>r.key==="Enter"&&this.state.valid&&this.onUpdate(r),onChange:r=>{this.setState({targetValue:r.target.value,valid:Ep.isNumberValid({value:r.target.value,common:this.props.object.common})})}}):this.state.type==="json"?this.renderJsonEditor():this.state.type==="states"?this.renderStates():L.jsx(E.TextField,{variant:"standard",fullWidth:!0,inputRef:this.inputRef,autoFocus:!0,helperText:this.props.t("Press CTRL+ENTER to write the value, when focused"),label:this.props.t("Value"),multiline:!0,onKeyDown:r=>r.ctrlKey&&r.key==="Enter"&&this.onUpdate(r),defaultValue:this.propsValue.toString(),onChange:r=>this.setState({targetValue:r.target.value})})}),(this.props.role==="date"||(i=this.props.role)!=null&&i.startsWith("date."))&&this.state.type==="number"?L.jsx(E.Grid2,{style:{display:"flex",gap:"5px"},size:{xs:6},children:this.renderTimePicker()}):null,this.props.expertMode?L.jsx(E.Grid2,{children:e}):null,this.props.expertMode?L.jsxs(E.Grid2,{children:[L.jsxs(E.FormControl,{variant:"standard",style:Br.quality,children:[L.jsx(E.InputLabel,{children:this.props.t("Quality")}),L.jsxs(E.Select,{variant:"standard",defaultValue:0,onChange:r=>this.q=Number(r.target.value),children:[L.jsx(E.MenuItem,{value:0,children:"0x00 - good"}),L.jsx(E.MenuItem,{value:1,children:"0x01 - general problem"}),L.jsx(E.MenuItem,{value:2,children:"0x02 - no connection problem"}),L.jsx(E.MenuItem,{value:16,children:"0x10 - substitute value from controller"}),L.jsx(E.MenuItem,{value:32,children:"0x20 - substitute initial value"}),L.jsx(E.MenuItem,{value:64,children:"0x40 - substitute value from device or instance"}),L.jsx(E.MenuItem,{value:128,children:"0x80 - substitute value from sensor"}),L.jsx(E.MenuItem,{value:17,children:"0x11 - general problem by instance"}),L.jsx(E.MenuItem,{value:65,children:"0x41 - general problem by device"}),L.jsx(E.MenuItem,{value:129,children:"0x81 - general problem by sensor"}),L.jsx(E.MenuItem,{value:18,children:"0x12 - instance not connected"}),L.jsx(E.MenuItem,{value:66,children:"0x42 - device not connected"}),L.jsx(E.MenuItem,{value:130,children:"0x82 - sensor not connected"}),L.jsx(E.MenuItem,{value:68,children:"0x44 - device reports error"}),L.jsx(E.MenuItem,{value:132,children:"0x84 - sensor reports error"})]})]}),L.jsx(E.TextField,{variant:"standard",title:this.props.t("0 - no expiration"),sx:{"&.MuiTextField-root":Br.expire},label:this.props.t("Expire"),type:"number",slotProps:{htmlInput:{min:0}},helperText:this.props.t("in seconds"),defaultValue:this.expire,onChange:r=>this.expire=Number(r.target.value)})]}):null]})}),this.state.chart&&this.state.chartEnabled&&this.state.type!=="json"?L.jsx(E.Grid2,{size:{xs:6},style:{minHeight:300},sx:{display:{sm:"none",md:"inline-block"}},children:this.renderChart()}):null]})})}),L.jsxs(E.DialogActions,{sx:Br.wrapperButton,children:[this.props.expertMode?null:e,this.props.expertMode?null:L.jsx("div",{style:{flexGrow:1}}),L.jsx(E.Button,{variant:"contained",disabled:!this.state.valid,onClick:r=>this.onUpdate(r),color:"primary",startIcon:this.props.width!=="xs"?L.jsx(Ie.Check,{}):void 0,style:((n=this.props.object.common)==null?void 0:n.write)===!1?Br.readOnly:void 0,children:this.props.width!=="xs"?this.props.t("Set value"):L.jsx(Ie.Check,{fontSize:"large"})}),L.jsx(E.Button,{variant:"contained",onClick:()=>this.props.onClose(),color:"grey",startIcon:this.props.width!=="xs"?L.jsx(Ie.Close,{}):void 0,children:this.props.width!=="xs"?this.props.t("Cancel"):L.jsx(Ie.Close,{fontSize:"large"})})]})]})}}const se={divWithoutTitle:{width:"100%",height:"100%",border:"2px solid #00000000"},divWithoutTitleAndTab:{height:"calc(100% - 48px)"},error:{border:"2px solid #FF0000"},id:{fontStyle:"italic"},dialog:{height:"calc(100% - 64px)"},aliasIdEdit:{width:368},button:{marginTop:20,marginLeft:8},funcDivEdit:{width:"100%"},funcEditName:{display:"inline-block",width:85},funcEdit:{width:400},funcIcon:{width:16,height:16},marginTop:{marginTop:20},commonTabWrapper:{flexFlow:"wrap",display:"flex",gap:8},commonWrapper:{width:500,minWidth:300},flexDrop:{width:"100%",maxWidth:500,margin:"auto",display:"flex"},marginBlock:{marginTop:20},buttonAdd:{minWidth:150},textField:{width:"100%"},flex:{display:"flex","& > div":{mr:"8px"}},close:{width:"20px",height:"20px",opacity:"0.9",cursor:"pointer",position:"relative",top:20,marginTop:"10px",transition:"all 0.6s ease","&:hover":{transform:"rotate(90deg)"},"&:before":{position:"absolute",left:"9px",content:'""',height:"20px",width:"3px",backgroundColor:"#ff4f4f",transform:"rotate(45deg)"},"&:after":{position:"absolute",left:"9px",content:'""',height:"20px",width:"3px",backgroundColor:"#ff4f4f",transform:"rotate(-45deg)"}},color:{width:70},buttonRemoveWrapper:{position:"absolute",zIndex:222,right:0},tabsPadding:{padding:"0px 24px"},wrapperButton:{"@media screen and (max-width: 465px)":{"& *":{fontSize:10}},"@media screen and (max-width: 380px)":{"& *":{fontSize:9}}},commonDeleteTip:{color:"#fa4a4a"},typeNameEng:{marginLeft:8,opacity:.7,fontStyle:"italic",fontSize:"smaller"},tooltip:{pointerEvents:"none"},stateRow:{width:"100%",display:"flex",justifyContent:"space-between",padding:3},stateTitle:{minWidth:150,fontWeight:"bold"},stateUnit:{opacity:.7,marginLeft:4},stateValue:{animation:"newStateEditorAnimation 2s ease-in-out"},stateTime:{fontStyle:"italic"},stateImage:{maxWidth:200,maxHeight:200}};function Nme(s,e){return{"@keyframes newStateEditorAnimation":{"0%":{color:s.palette.mode==="dark"?"#27cf00":"#174e00"},"100%":{color:e||(s.palette.mode==="dark"?"#ffffff":"#000000")}}}}const Bb=[{role:"button",type:"boolean",r:!1,w:!0},{role:"button.close.blind",type:"boolean",r:!1,w:!0},{role:"button.close.tilt",type:"boolean",r:!1,w:!0},{role:"button.fastforward",type:"boolean",r:!1,w:!0},{role:"button.forward",type:"boolean",r:!1,w:!0},{role:"button.long",type:"boolean",r:!1,w:!0},{role:"button.mode",type:"boolean",r:!1,w:!0},{role:"button.mode.auto",type:"boolean",r:!1,w:!0},{role:"button.mode.manual",type:"boolean",r:!1,w:!0},{role:"button.mode.silent",type:"boolean",r:!1,w:!0},{role:"button.next",type:"boolean",r:!1,w:!0},{role:"button.open.blind",type:"boolean",r:!1,w:!0},{role:"button.open.door",type:"boolean",r:!1,w:!0},{role:"button.open.tilt",type:"boolean",r:!1,w:!0},{role:"button.open.window",type:"boolean",r:!1,w:!0},{role:"button.pause",type:"boolean",w:!0},{role:"button.play",type:"boolean",w:!0},{role:"button.press",type:"boolean",r:!1,w:!0},{role:"button.press",type:"boolean",r:!0,w:!1},{role:"button.prev",type:"boolean",w:!0},{role:"button.resume",type:"boolean",r:!1,w:!0},{role:"button.start",type:"boolean",r:!1,w:!0},{role:"button.pause",type:"boolean",r:!1,w:!0},{role:"button.stop",type:"boolean",r:!1,w:!0},{role:"button.stop.tilt",type:"boolean",r:!1,w:!0},{role:"button.volume.up",type:"boolean",r:!1,w:!0},{role:"chart",type:"string"},{role:"date",type:"number"},{role:"date",type:"string"},{role:"date.end",type:"number"},{role:"date.end",type:"string"},{role:"date.forecast.1",type:"string"},{role:"date.start",type:"number"},{role:"date.start",type:"string"},{role:"date.sunrise",type:"number"},{role:"date.sunrise",type:"string"},{role:"date.sunset",type:"number"},{role:"date.sunset",type:"string"},{role:"dayofweek",type:"number"},{role:"html",type:"string"},{role:"indicator",type:"boolean",w:!1},{role:"indicator.alarm",type:"boolean",w:!1},{role:"indicator.alarm.fire",type:"boolean",w:!1},{role:"indicator.alarm.flood",type:"boolean",w:!1},{role:"indicator.alarm.health",type:"boolean",w:!1},{role:"indicator.alarm.secure",type:"boolean",w:!1},{role:"indicator.connected",type:"boolean",w:!1},{role:"indicator.maintenance",type:"boolean",w:!1},{role:"indicator.maintenance.alarm",type:"boolean",w:!1},{role:"indicator.maintenance.lowbat",type:"boolean",w:!1},{role:"indicator.maintenance.waste",type:"boolean",w:!1},{role:"indicator.reachable",type:"boolean",w:!1},{role:"info.address",type:"string",w:!1},{role:"info.display",type:"string",w:!1},{role:"info.firmware",type:"string",w:!1},{role:"info.hardware",type:"string",w:!1},{role:"info.ip",type:"string",w:!1},{role:"info.mac",type:"string",w:!1},{role:"info.model",type:"string",w:!1},{role:"info.name",type:"string",w:!1},{role:"info.port",type:"number",w:!1},{role:"info.port",type:"string",w:!1},{role:"info.serial",type:"string",w:!1},{role:"info.standby",type:"string",w:!1},{role:"info.status",w:!1},{role:"json",type:"string"},{role:"level",type:"number",w:!0},{role:"level.bass",type:"number",w:!0},{role:"level.blind",type:"number",w:!0},{role:"level.brightness",type:"number",w:!0},{role:"level.color.blue",type:"number",w:!0},{role:"level.color.hue",type:"number",w:!0},{role:"level.color.luminance",type:"number",w:!0},{role:"level.color.red",type:"number",w:!0},{role:"level.color.rgb",type:"string",w:!0},{role:"level.color.rgbw",type:"string",w:!0},{role:"level.color.saturation",type:"number",w:!0},{role:"level.color.temperature",type:"number",w:!0},{role:"level.curtain",type:"number",w:!0},{role:"level.mode.airconditioner",type:"number",w:!0},{role:"level.mode.cleanup",type:"number",w:!0},{role:"level.mode.fan",type:"number",w:!0},{role:"level.mode.swing",type:"number",w:!0},{role:"level.mode.thermostat",type:"number",w:!0},{role:"level.mode.work",type:"number",w:!0},{role:"level.temperature",type:"number",w:!0},{role:"level.tilt",type:"number",w:!0},{role:"level.timer",type:"number",w:!0},{role:"level.treble",type:"number",w:!0},{role:"level.valve",type:"number",w:!0},{role:"level.volume",type:"number",w:!0},{role:"level.volume.group",type:"number",w:!0},{role:"list",type:"array"},{role:"list",type:"string"},{role:"location",type:"string"},{role:"media.add",type:"string"},{role:"media.bitrate",type:"number"},{role:"media.bitrate",type:"string"},{role:"media.broadcastDate",type:"string"},{role:"media.browser",type:"string"},{role:"media.clear",type:"boolean"},{role:"media.content",type:"string"},{role:"media.cover",type:"string"},{role:"media.cover.big",type:"string"},{role:"media.cover.small",type:"string"},{role:"media.date",type:"string"},{role:"media.duration",type:"number"},{role:"media.duration",type:"string"},{role:"media.duration.text",type:"string"},{role:"media.elapsed",type:"number"},{role:"media.elapsed",type:"string"},{role:"media.elapsed.text",type:"string"},{role:"media.episode",type:"number"},{role:"media.episode",type:"string"},{role:"media.genre",type:"string"},{role:"media.input",type:"string"},{role:"media.jump",type:"string"},{role:"media.link",type:"string"},{role:"media.mode.repeat",type:"string"},{role:"media.mode.shuffle",type:"string"},{role:"media.mute",type:"string"},{role:"media.mute.group",type:"string"},{role:"media.playid",type:"string"},{role:"media.playlist",type:"string"},{role:"media.season",type:"string"},{role:"media.seek",type:"string"},{role:"media.state",type:"string"},{role:"media.titel",type:"string"},{role:"media.track",type:"string"},{role:"media.tts",type:"string"},{role:"media.url",type:"string"},{role:"media.url.announcement",type:"string"},{role:"medien.artist",type:"string"},{role:"sensor.alarm",type:"boolean",w:!1},{role:"sensor.alarm.fire",type:"boolean",w:!1},{role:"sensor.alarm.flood",type:"boolean",w:!1},{role:"sensor.alarm.power",type:"boolean",w:!1},{role:"sensor.alarm.secure",type:"boolean",w:!1},{role:"sensor.contact",type:"boolean",w:!1},{role:"sensor.door",type:"boolean",w:!1},{role:"sensor.light",type:"boolean",w:!1},{role:"sensor.lock",type:"boolean",w:!1},{role:"sensor.motion",type:"boolean",w:!1},{role:"sensor.noise",type:"boolean",w:!1},{role:"sensor.rain",type:"boolean",w:!1},{role:"sensor.window",type:"boolean",w:!1},{role:"state",type:"mixed"},{role:"string.date",type:"number"},{role:"switch",type:"boolean",w:!0},{role:"switch.enable",type:"boolean",w:!0},{role:"switch.gate",type:"boolean",w:!0},{role:"switch.gate",type:"boolean",w:!0},{role:"switch.light",type:"boolean",w:!0},{role:"switch.lock",type:"boolean",w:!0},{role:"switch.lock.door",type:"boolean",w:!0},{role:"switch.lock.window",type:"boolean",w:!0},{role:"switch.mode",type:"boolean",w:!0},{role:"switch.mode.auto",type:"boolean",w:!0},{role:"switch.mode.boost",type:"boolean",w:!0},{role:"switch.mode.color",type:"boolean",w:!0},{role:"switch.mode.manual",type:"boolean",w:!0},{role:"switch.mode.moonlight",type:"boolean",w:!0},{role:"switch.mode.party",type:"boolean",w:!0},{role:"switch.mode.silent",type:"boolean",w:!0},{role:"switch.power",type:"boolean",w:!0},{role:"switch.power.zone",type:"boolean",w:!0},{role:"text",type:"string"},{role:"text.phone",type:"string"},{role:"text.url",type:"string"},{role:"time.interval",type:"number"},{role:"time.span",type:"number"},{role:"time.timeout",type:"number"},{role:"url",type:"string"},{role:"url.audio",type:"string"},{role:"url.blank",type:"string"},{role:"url.cam",type:"string"},{role:"url.icon",type:"string"},{role:"url.same",type:"string"},{role:"value",type:"number",w:!1},{role:"value.battery",type:"number",w:!1},{role:"value.blind",type:"number",w:!1},{role:"value.blood.sugar",type:"number",w:!1},{role:"value.brightness",type:"number",w:!1},{role:"value.co2",type:"number",w:!1},{role:"value.clouds",type:"number",w:!1},{role:"value.current",type:"number",w:!1},{role:"value.curtain",type:"number",w:!1},{role:"value.date",type:"string",w:!1},{role:"value.datetime",type:"string",w:!1},{role:"value.default",type:"number",w:!1},{role:"value.direction",type:"number",w:!1},{role:"value.direction.max.wind",type:"number",w:!1},{role:"value.direction.min.wind",type:"number",w:!1},{role:"value.direction.wind",type:"number",w:!1},{role:"value.direction.wind.forecast.0",type:"number",w:!1},{role:"value.direction.wind.forecast.1",type:"number",w:!1},{role:"value.distance",type:"number",w:!1},{role:"value.energy",type:"number",w:!1},{role:"value.fill",type:"number",w:!1},{role:"value.gate",type:"number",w:!1},{role:"value.gps",type:"number",w:!1},{role:"value.gps.accuracy",type:"number",w:!1},{role:"value.gps.elevation",type:"number",w:!1},{role:"value.gps.latitude",type:"number",w:!1},{role:"value.gps.longitude",type:"number",w:!1},{role:"value.gps.radius",type:"number",w:!1},{role:"value.health.bmi",type:"number",w:!1},{role:"value.health.bpm",type:"number",w:!1},{role:"value.health.calories",type:"number",w:!1},{role:"value.health.fat",type:"number",w:!1},{role:"value.health.steps",type:"number",w:!1},{role:"value.health.weight",type:"number",w:!1},{role:"value.humidity",type:"number",w:!1},{role:"value.humidity",type:"number",w:!1},{role:"value.humidity.max",type:"number",w:!1},{role:"value.humidity.min",type:"number",w:!1},{role:"value.interval",type:"number",w:!1},{role:"value.lock",type:"number",w:!1},{role:"value.min",type:"number",w:!1},{role:"value.position",type:"number",w:!1},{role:"value.power",type:"number",w:!1},{role:"value.power.consumption",type:"number",w:!1},{role:"value.power.production",type:"number",w:!1},{role:"value.power.reactive",type:"number",w:!1},{role:"value.precipitation",type:"number",w:!1},{role:"value.precipitation.chance",type:"number",w:!1},{role:"value.precipitation.day.forecast.0",type:"number",w:!1},{role:"value.precipitation.forecast.0",type:"number",w:!1},{role:"value.precipitation.forecast.0",type:"number",w:!1},{role:"value.precipitation.forecast.1",type:"number",w:!1},{role:"value.precipitation.forecast.1",type:"number",w:!1},{role:"value.precipitation.hour",type:"number",w:!1},{role:"value.precipitation.night.forecast.0",type:"number",w:!1},{role:"value.precipitation.today",type:"number",w:!1},{role:"value.precipitation.type",type:"number",w:!1},{role:"value.pressure",type:"number",w:!1},{role:"value.pressure.forecast.0",type:"number",w:!1},{role:"value.pressure.forecast.1",type:"number",w:!1},{role:"value.radiation",type:"number",w:!1},{role:"value.rain",type:"number",w:!1},{role:"value.rain.hour",type:"number",w:!1},{role:"value.rain.today",type:"number",w:!1},{role:"value.severity",type:"number",w:!1},{role:"value.snow",type:"number",w:!1},{role:"value.snow.hour",type:"number",w:!1},{role:"value.snow.today",type:"number",w:!1},{role:"value.snowline",type:"number",w:!1},{role:"value.speed",type:"number",w:!1},{role:"value.speed.max.wind",type:"number",w:!1},{role:"value.speed.min.wind",type:"number",w:!1},{role:"value.speed.wind",type:"number",w:!1},{role:"value.speed.wind.forecast.0",type:"number",w:!1},{role:"value.speed.wind.gust",type:"number",w:!1},{role:"value.state",type:"number",w:!1},{role:"value.sun.azimuth",type:"number",w:!1},{role:"value.sun.elevation",type:"number",w:!1},{role:"value.temperature",type:"number",w:!1},{role:"value.temperature",type:"number",w:!1},{role:"value.temperature.dewpoint",type:"number",w:!1},{role:"value.temperature.feelslike",type:"number",w:!1},{role:"value.temperature.max",type:"number",w:!1},{role:"value.temperature.max.forecast.0",type:"number",w:!1},{role:"value.temperature.min",type:"number",w:!1},{role:"value.temperature.min.forecast.0",type:"number",w:!1},{role:"value.temperature.min.forecast.1",type:"number",w:!1},{role:"value.temperature.windchill",type:"number",w:!1},{role:"value.tilt",type:"number",w:!1},{role:"value.time",type:"number",w:!1},{role:"value.uv",type:"number",w:!1},{role:"value.valve",type:"number",w:!1},{role:"value.voltage",type:"number",w:!1},{role:"value.warning",type:"number",w:!1},{role:"value.waste",type:"number",w:!1},{role:"value.water",type:"number",w:!1},{role:"weather.chart.url",type:"string",w:!1},{role:"weather.chart.url.forecast",type:"string",w:!1},{role:"weather.direction.wind",type:"number",w:!1},{role:"weather.direction.wind.forecast.0",type:"number",w:!1},{role:"weather.html",type:"string",w:!1},{role:"weather.icon",type:"string",w:!1},{role:"weather.icon.forecast.1",type:"string",w:!1},{role:"weather.icon.name",type:"string",w:!1},{role:"weather.icon.wind",type:"string",w:!1},{role:"weather.json",type:"string",w:!1},{role:"weather.state",type:"number",w:!1},{role:"weather.state",type:"string",w:!1},{role:"weather.state.forecast.0",type:"string",w:!1},{role:"weather.sunrise",type:"string",w:!1},{role:"weather.sunset",type:"string",w:!1},{role:"weather.state.forecast.1",type:"string",w:!1},{role:"weather.temperature",type:"number",w:!1},{role:"weather.title",type:"string",w:!1},{role:"weather.title.forecast.0",type:"string",w:!1},{role:"weather.title.short",type:"string",w:!1},{role:"weather.type",type:"number",w:!1},{role:"weather.type",type:"string",w:!1}];class $n extends Te.Component{originalObj;subscribed=!1;updateTimer=null;constructor(e){super(e);const t=this.props.obj._id.startsWith("alias.0")&&this.props.obj.type==="state";let i=(window._localStorage||window.localStorage).getItem(`${this.props.dialogName||"App"}.editTab`)||"object";const n=ee.Router.getLocation();n.tab==="tab-objects"&&n.dialog==="edit"&&n.id===this.props.obj._id&&n.arg&&(i=n.arg),i==="alias"&&!t&&(i="common"),this.props.aliasTab&&t&&(i="alias");const r=this.props.obj,o=r.common&&"type"in r.common&&"alias"in r.common?r.common.alias.read:void 0,a=r.common&&"type"in r.common&&"alias"in r.common?r.common.alias.write:void 0;this.state={text:JSON.stringify(this.props.obj,null,2),error:!1,customError:!1,changed:!1,readError:this.checkFunction(o,!1),writeError:this.checkFunction(a,!0),tab:i,showCopyDialog:"",showCommonDeleteMessage:!1,selectId:!1,selectRead:!1,selectWrite:!1,newId:"",lang:ee.I18n.getLanguage(),value:void 0},xT.locale(this.state.lang),this.originalObj=JSON.stringify(this.props.obj,null,2)}async componentDidMount(){var i,n,r;const e=((n=(i=this.props.obj)==null?void 0:i.common)==null?void 0:n.editSchemas)||((r=this.props.obj)==null?void 0:r.editSchemas),t=[];if(e)if(typeof e=="object"){const o=Object.keys(e);for(let a=0;a<o.length;a++)try{const l=await ee.iobUriRead(e[o[a]],this.props.socket);if(l.key=o[a],l&&typeof l=="object"&&t.push(l),l.icon)try{const h=ee.iobUriParse(l.icon);if(h.type!=="base64"&&h.type!=="http"){const c=await ee.iobUriRead(h,this.props.socket);c&&(l.icon=c)}}catch(h){console.warn(`Cannot get icon for schema from "${l.icon}": ${h}`),l.icon=void 0}}catch(l){console.warn(`Cannot get edit schema for "${e[o[a]]}": ${l}`)}t.length&&(t.sort((a,l)=>a.order!==void 0&&l.order!==void 0?a.order-l.order:a.order!==void 0?-1:l.order!==void 0||a.key>l.key?1:-1),this.setState({customEditTabs:t}))}else console.warn(`Invalid edit schema for "${e}": expected object, but got ${typeof e}`);this.state.tab==="alias"&&(!this.props.obj._id.startsWith("alias.0")||this.props.obj.type!=="state")?this.setState({tab:"object"}):this.state.tab==="state"&&this.props.obj.type!=="state"?this.setState({tab:"object"}):this.state.tab!=="object"&&this.state.tab!=="common"&&this.state.tab!=="alias"&&this.state.tab!=="state"&&!t.find(o=>o.key===this.state.tab)&&this.setState({tab:"object"}),this.state.tab==="state"&&this.subscribeOnState(!0),this.props.socket.subscribeObject(this.props.obj._id,this.onObjectUpdated),this.isRouted()&&setTimeout(()=>{this.isRouted()&&ee.Router.getLocation().arg!==this.state.tab&&ee.Router.doNavigate(null,null,null,this.state.tab)},0)}componentWillUnmount(){this.updateTimer&&(clearInterval(this.updateTimer),this.updateTimer=null),this.subscribeOnState(!1),this.props.socket.unsubscribeObject(this.props.obj._id,this.onObjectUpdated)}onObjectUpdated=(e,t)=>{this.originalObj!==JSON.stringify(t,null,2)&&(this.originalObj=JSON.stringify(t,null,2),this.state.changed?this.forceUpdate():this.setState({text:this.originalObj}))};checkFunction(e,t){var r,o,a,l;if(!e||e.includes("JSON.parse("))return"";let i;try{i=JSON.parse(this.state.text)}catch{}let n;try{n=new Function("val",e.includes("return")?e:`return ${e}`)}catch{return this.props.t("Cannot parse code!")}if((r=i==null?void 0:i.common)!=null&&r.type&&((l=(a=this.props.objects[(o=i.common.alias)==null?void 0:o.id])==null?void 0:a.common)!=null&&l.type)){const h=t?i.common.type:this.props.objects[i.common.alias.id].common.type,c=t?this.props.objects[i.common.alias.id].common.type:i.common.type;if(h&&c){let u=null;if(h==="boolean"?u=!0:h==="number"?u=1:(h==="string"||h==="mixed")&&(u="string"),u!==null)try{const d=n(u);return c==="mixed"?"":d!==null&&typeof d!==c?this.props.t("Type of result is not as expected: %s",c):""}catch(d){return`${this.props.t("Cannot execute function")}: ${d.toString()}`}}}return""}prepareObject(e){var t,i,n,r;e=e||this.state.text;try{const o=JSON.parse(e);return o._id=this.props.obj._id,(t=o.common)!=null&&t.alias&&(o.common.alias.id||delete o.common.alias.id,(!o.common.alias.read&&o.common.alias.read!==void 0||o.common.alias.read==="val")&&delete o.common.alias.read,(!o.common.alias.write&&o.common.alias.write!==void 0||o.common.alias.write==="val")&&delete o.common.alias.write,!o.common.alias.id&&!o.common.alias.read&&!o.common.alias.write&&delete o.common.alias),((i=o.common)==null?void 0:i.min)!==void 0&&typeof o.common.min!="number"&&(o.common.min=parseFloat(o.common.min)),((n=o.common)==null?void 0:n.max)!==void 0&&typeof o.common.max!="number"&&(o.common.max=parseFloat(o.common.max)),((r=o.common)==null?void 0:r.step)!==void 0&&typeof o.common.step!="number"&&(o.common.step=parseFloat(o.common.step)),o}catch{return null}}onChange(e,t){var r,o,a,l;const i=this.prepareObject(e),n={text:e};if(i){n.changed=this.originalObj!==JSON.stringify(i,null,2),n.showCommonDeleteMessage=!1;const h=JSON.parse(this.originalObj);i.common&&Object.keys(h.common||{}).forEach(c=>{i.common[c]===void 0&&(n.showCommonDeleteMessage=!0)}),n.error=!1,n.readError=this.checkFunction((o=(r=i.common)==null?void 0:r.alias)==null?void 0:o.read,!1),n.writeError=this.checkFunction((l=(a=i.common)==null?void 0:a.alias)==null?void 0:l.write,!0)}else n.showCommonDeleteMessage=!1,n.error=!0;this.setState(n,()=>t&&t())}onUpdate(){var e,t,i,n;try{const r=JSON.parse(this.state.text);r._id=this.props.obj._id,(e=r.common)!=null&&e.alias&&(r.common.alias.id||delete r.common.alias.id,(!r.common.alias.read&&r.common.alias.read!==void 0||r.common.alias.read==="val")&&delete r.common.alias.read,(!r.common.alias.write&&r.common.alias.write!==void 0||r.common.alias.write==="val")&&delete r.common.alias.write,!r.common.alias.id&&!r.common.alias.read&&!r.common.alias.write&&delete r.common.alias),((t=r.common)==null?void 0:t.min)!==void 0&&typeof r.common.min!="number"&&(r.common.min=parseFloat(r.common.min)),((i=r.common)==null?void 0:i.max)!==void 0&&typeof r.common.max!="number"&&(r.common.max=parseFloat(r.common.max)),((n=r.common)==null?void 0:n.step)!==void 0&&typeof r.common.step!="number"&&(r.common.step=parseFloat(r.common.step)),this.props.onClose(r)}catch{console.error(`Cannot parse: ${this.state.text}`)}}static getPartOfObject(e,t){return t?ee.getAttrInObject(JSON.parse(e),t.split(".")):JSON.parse(e)}static setPartOfObject(e,t,i){let n=JSON.parse(e);return n===void 0?e:(n=ee.setAttrInObject(n,i.split("."),t),JSON.stringify(n,null,2))}renderCustomPanel(){var i;const e=(i=this.state.customEditTabs)==null?void 0:i.find(n=>n.key===this.state.tab);if(!e)return null;let t;try{t=$n.getPartOfObject(this.state.text,e.path)}catch(n){return console.error(`Cannot get data for ${e.path}: ${n}`),L.jsx("div",{children:ee.I18n.t("Cannot get data for %s: %s",e.path,n)})}return t?L.jsx(_p.JsonConfigComponent,{theme:this.props.theme,socket:this.props.socket,themeName:this.props.theme.palette.mode,themeType:this.props.theme.palette.mode,dateFormat:this.props.dateFormat,isFloatComma:this.props.isFloatComma,schema:e.json,data:t,onChange:n=>{try{const r=$n.setPartOfObject(this.state.text,n,e.path);this.onChange(r)}catch(r){console.error(`Cannot set data for ${e.path}: ${r}`)}},adapterName:"",instance:0,onError:n=>{console.warn(`Error in JSON editor: ${n}`),this.state.customError!==n&&this.setState({customError:n})}}):L.jsx("div",{children:ee.I18n.t("Cannot get data for %s",e.path)})}renderCustomTab(e,t){var r;let i;if(!t||!ee.getAttrInObject(t,(r=e.path)==null?void 0:r.split(".")))return null;e.color&&(i={backgroundColor:e.color,color:ee.Utils.invertColor(e.color,!0)});const n=e.label&&typeof e.label=="object"?e.label[this.state.lang]||e.label.en:e.noTranslation?e.label||e.key:this.props.t(e.label||e.key);return L.jsx(E.Tab,{disabled:this.state.error||this.state.customError,value:e.key,label:n,style:i,iconPosition:"start",icon:e.icon?L.jsx(ee.Icon,{src:e.icon,style:se.funcIcon}):void 0})}renderStateTab(){return this.props.obj.type!=="state"||this.props.obj.common.type==="file"?null:L.jsx(E.Tab,{disabled:this.state.customError||this.state.error,value:"state",label:this.props.t("State")})}renderStatePanel(){var r;if(this.state.value===void 0||this.state.value===null)return L.jsx("div",{children:this.props.t("State does not exist")});if(typeof this.state.value!="object")return L.jsxs("div",{style:{maxWidth:700},children:[L.jsx("div",{children:this.props.t("State is invalid")}),L.jsx("div",{children:L.jsx("pre",{children:JSON.stringify(this.state.value,null,4)})})]});let e;const t={},i=this.state.value.val,n=typeof i;if(i===void 0)e="[undef]",t.color="#bc6400",t.fontStyle="italic";else if(i===null)e="(null)",t.color="#0047b1",t.fontStyle="italic";else if(typeof this.props.obj.common.role=="string"&&this.props.obj.common.role.match(/^value\.time|^date/))if(i&&n==="string")if(ee.Utils.isStringInteger(i))e=new Date(parseInt(i,10)).toString();else try{const o=new Date(i);ee.Utils.isValidDate(o)&&(e=o.toString())}catch{}else i&&n==="number"&&(i>946681200&&i<9466812e5?e=new Date(i*1e3).toString():i>9466812e8&&(e=new Date(i).toString()));return e||(n==="number"?Number.isInteger(i)||(e=(Math.round(i*1e9)/1e9).toString(),this.props.isFloatComma&&(e=e.toString().replace(".",","))):n==="boolean"?(e=i?ee.I18n.t("true"):ee.I18n.t("false"),t.color=i?"#139800":"#cd6b55"):n==="object"?e=JSON.stringify(i):n==="string"&&i.startsWith("data:image/")?e=L.jsx("img",{src:i,alt:"img",style:se.stateImage}):e=i.toString()),Object.assign(t,Nme(this.props.theme,t.color)),L.jsxs(E.Box,{style:{...se.divWithoutTitle,padding:"24px 24px 0 24px",fontSize:16,maxWidth:400},sx:{"& .value-line:hover":{backgroundColor:"#00000030"}},children:[L.jsxs("div",{className:"value-line",style:{...se.stateRow,marginBottom:24},children:[L.jsxs("div",{style:se.stateTitle,children:[ee.I18n.t("ra_tooltip_value"),":"]}),L.jsxs(E.Box,{component:"div",sx:t,style:se.stateValue,children:[e,(r=this.props.obj.common)!=null&&r.unit?L.jsx("span",{style:se.stateUnit,children:this.props.obj.common.unit}):null]},typeof e=="string"?e:"image")]}),L.jsxs("div",{style:se.stateRow,className:"value-line",children:[L.jsxs("div",{style:se.stateTitle,children:[ee.I18n.t("Type"),":"]}),L.jsx("div",{style:se.stateValue,children:n})]}),L.jsxs("div",{style:se.stateRow,className:"value-line",children:[L.jsxs("div",{style:se.stateTitle,children:[ee.I18n.t("ra_tooltip_ts"),":"]}),L.jsx(E.Tooltip,{title:new Date(this.state.value.ts).toLocaleString(),slotProps:{popper:{sx:se.tooltip}},children:L.jsx("div",{style:se.stateValue,children:L.jsx("span",{style:se.stateTime,children:xT(this.state.value.ts).fromNow()})})})]}),L.jsxs("div",{style:se.stateRow,className:"value-line",children:[L.jsxs("div",{style:se.stateTitle,children:[ee.I18n.t("ra_tooltip_ack"),":"]}),L.jsxs("div",{style:{...se.stateValue,color:this.state.value.ack?"green":"red"},children:[this.state.value.ack?ee.I18n.t("Acknowledged"):ee.I18n.t("Command"),this.state.value.ack?" (true)":" (false)"]})]}),L.jsxs("div",{style:se.stateRow,className:"value-line",children:[L.jsxs("div",{style:se.stateTitle,children:[ee.I18n.t("ra_tooltip_lc"),":"]}),L.jsx(E.Tooltip,{title:new Date(this.state.value.lc).toLocaleString(),slotProps:{popper:{sx:se.tooltip}},children:L.jsx("div",{style:se.stateValue,children:L.jsx("span",{style:se.stateTime,children:xT(this.state.value.lc).fromNow()})})})]}),L.jsxs("div",{style:se.stateRow,className:"value-line",children:[L.jsxs("div",{style:se.stateTitle,children:[ee.I18n.t("ra_tooltip_quality"),":"]}),L.jsx("div",{style:se.stateValue,children:ee.Utils.quality2text(this.state.value.q||0).join(", ")})]}),L.jsxs("div",{style:se.stateRow,className:"value-line",children:[L.jsxs("div",{style:se.stateTitle,children:[ee.I18n.t("ra_tooltip_from"),":"]}),L.jsx("div",{style:se.stateValue,children:this.state.value.from})]}),L.jsxs("div",{style:se.stateRow,className:"value-line",children:[L.jsxs("div",{style:se.stateTitle,children:[ee.I18n.t("ra_tooltip_user"),":"]}),L.jsx("div",{style:se.stateValue,children:this.state.value.user||"--"})]}),this.state.value.expire?L.jsxs("div",{style:se.stateRow,className:"value-line",children:[L.jsxs("div",{style:se.stateTitle,children:[ee.I18n.t("ra_tooltip_expire"),":"]}),L.jsxs("div",{style:se.stateValue,children:[this.state.value.expire," ",ee.I18n.t("sc_seconds")]})]}):null,this.state.value.c?L.jsxs("div",{style:se.stateRow,className:"value-line",children:[L.jsxs("div",{style:se.stateTitle,children:[ee.I18n.t("ra_tooltip_comment"),":"]}),L.jsx("div",{style:se.stateValue,children:this.state.value.c})]}):null]})}onStateChange=(e,t)=>{JSON.stringify(t)!==JSON.stringify(this.state.value)&&this.setState({value:t})};subscribeOnState(e){e?this.subscribed||(this.updateTimer||(this.updateTimer=setInterval(()=>{this.forceUpdate()},5e3)),this.subscribed=!0,this.props.socket.subscribeState(this.props.obj._id,this.onStateChange)):this.subscribed&&(this.updateTimer&&(clearInterval(this.updateTimer),this.updateTimer=null),this.subscribed=!1,this.props.socket.unsubscribeState(this.props.obj._id,this.onStateChange))}isRouted(){const e=ee.Router.getLocation();return e.tab==="tab-objects"&&e.dialog==="edit"&&e.id===this.props.obj._id}renderTabs(e){var t;return L.jsxs(E.Tabs,{style:se.tabsPadding,value:this.state.tab,onChange:(i,n)=>{var r,o,a;if((window._localStorage||window.localStorage).setItem(`${this.props.dialogName||"App"}.editTab`,n),this.isRouted()&&ee.Router.doNavigate(null,null,null,n),n==="object"){try{const l=JSON.parse(this.state.text);let h=!1;((r=l.common)==null?void 0:r.min)!==void 0&&typeof l.common.min!="number"&&(l.common.min=parseFloat(l.common.min),h=!0),((o=l.common)==null?void 0:o.max)!==void 0&&typeof l.common.max!="number"&&(l.common.max=parseFloat(l.common.max),h=!0),((a=l.common)==null?void 0:a.step)!==void 0&&typeof l.common.step!="number"&&(l.common.step=parseFloat(l.common.step),h=!0),h&&this.setState({text:JSON.stringify(l,null,2)})}catch{}this.subscribeOnState(!1)}else n==="state"?this.subscribeOnState(!0):this.subscribeOnState(!1);this.setState({tab:n})},children:[L.jsx(E.Tab,{value:"common",disabled:this.state.customError||this.state.error,label:this.props.t("common")}),L.jsx(E.Tab,{value:"object",disabled:this.state.customError,label:this.props.t("Object data")}),this.renderStateTab(),this.props.obj._id.startsWith("alias.0")&&this.props.obj.type==="state"&&L.jsx(E.Tab,{disabled:this.state.customError||this.state.error,value:"alias",label:this.props.t("Alias")}),(t=this.state.customEditTabs)==null?void 0:t.map(i=>this.renderCustomTab(i,e))]})}renderSelectDialog(){var i,n,r,o;if(!this.state.selectId&&!this.state.selectRead&&!this.state.selectWrite)return null;let e="",t;try{t=JSON.parse(this.state.text);const a=t.common&&"type"in t.common&&"alias"in t.common?(i=t.common.alias)==null?void 0:i.read:"",l=t.common&&"type"in t.common&&"alias"in t.common?(n=t.common.alias)==null?void 0:n.write:"";this.state.selectId?e=((o=(r=t.common)==null?void 0:r.alias)==null?void 0:o.id)||"":this.state.selectRead?e=a??"":this.state.selectWrite&&(e=l??"")}catch{console.error(`Cannot parse ${this.state.text}`)}return L.jsx(ee.DialogSelectID,{imagePrefix:".",dateFormat:this.props.dateFormat,theme:this.props.theme,isFloatComma:this.props.isFloatComma,socket:this.props.socket,dialogName:"aliasesEdit",title:`${this.props.t("Select for")} ${this.props.obj._id}`,selected:e,onOk:a=>{const l=this.state.selectRead,h=this.state.selectWrite,c=this.state.selectId,u=Array.isArray(a)?a[0]:a;this.setState({selectId:!1,selectRead:!1,selectWrite:!1},()=>{l?this.setAliasItem(t,"id.read",u):h?this.setAliasItem(t,"id.write",u):c&&this.setAliasItem(t,"id",u)})},onClose:()=>this.setState({selectId:!1,selectRead:!1,selectWrite:!1})},"selectDialog")}setAliasItem(e,t,i,n){e.common=e.common||{};const r=e.common.alias||{};t==="id.read"?r.id&&typeof r.id=="object"?r.id.read=i:r.id={read:i,write:i}:t==="id.write"?r.id&&typeof r.id=="object"?r.id.write=i:r.id={read:i,write:i}:r[t]=i,e.common.alias=r,this.onChange(JSON.stringify(e,null,2),n)}setCommonItem(e,t,i){e.common[t]=i,this.onChange(JSON.stringify(e,null,2))}removeCommonItem(e,t){delete e.common[t],this.onChange(JSON.stringify(e,null,2))}static buttonAddKey(e,t){return L.jsx("div",{style:se.marginBlock,children:L.jsx(E.Button,{style:se.buttonAdd,variant:"contained",color:"secondary",startIcon:L.jsx(Ie.Add,{}),onClick:t,children:ee.I18n.t(e)})})}buttonRemoveKey(e,t,i){const{t:n}=this.props;return L.jsx(E.Tooltip,{title:n("Remove attribute %s",n(e)),slotProps:{popper:{sx:se.tooltip}},children:L.jsx(E.Box,{component:"div",sx:se.close,style:i,onClick:t})})}static filterRoles(e,t){const i=[];return e.forEach(n=>(n.type==="mixed"||n.type)===t&&!i.includes(n.role)&&i.push(n.role)),Bb.forEach(n=>(n.type==="mixed"||n.type)===t&&!i.includes(n.role)&&i.push(n.role)),i.sort(),i}renderCommonEdit(){try{const e=JSON.parse(this.state.text),t=["number","string","boolean","array","object","mixed"],i=!1,{t:n,obj:r}=this.props,o=r.type==="state",a=r.type==="channel"||r.type==="device"||o,l=$n.filterRoles(this.props.roleArray,e.common.type);let h;if(e.common.icon&&(h=e.type==="instance"||e.type==="adapter"?`./adapter/${e.common.name}/${e.common.icon}`:e.common.icon,!h.startsWith(".")&&!h.startsWith("/")&&!h.startsWith("data:"))){const d=r._id.split(".");d[0]==="system"?h=`adapter/${d[2]}${h.startsWith("/")?"":"/"}${h}`:h=`adapter/${d[0]}${h.startsWith("/")?"":"/"}${h}`}const c=typeof e.common.desc=="object"&&e.common.desc?e.common.desc[ee.I18n.getLanguage()]||e.common.desc.en||"":e.common.desc||"",u=ee.Utils.getObjectNameFromObj(e,ee.I18n.getLanguage(),{},!1,!0);return L.jsxs(E.Box,{style:se.commonTabWrapper,onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),d.stopPropagation(),this.onUpdate())},children:[L.jsxs(E.Box,{style:{...se.commonWrapper,width:this.props.width==="xs"?"100%":void 0,minWidth:this.props.width==="xs"?"100%":void 0,gap:this.props.width==="xs"?10:8,display:this.props.width==="xs"?"flex":void 0,flexDirection:this.props.width==="xs"?"column":void 0},children:[typeof e.common.name<"u"?L.jsx(E.TextField,{variant:"standard",disabled:i,label:n("Name"),style:{...se.textField,marginTop:8},fullWidth:!0,slotProps:{input:{endAdornment:u?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.Tooltip,{title:ee.I18n.t("Clear text"),slotProps:{popper:{sx:se.tooltip}},children:L.jsx(E.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setCommonItem(e,"name",""),children:L.jsx(Ie.Close,{})})})}):null}},value:u,onChange:d=>this.setCommonItem(e,"name",d.target.value)}):$n.buttonAddKey("Name",()=>this.setCommonItem(e,"name","")),typeof e.common.desc<"u"?L.jsxs(E.Box,{component:"div",sx:se.flex,children:[L.jsx(E.TextField,{variant:"standard",disabled:i,label:n("Description"),style:{...se.textField,marginTop:8},fullWidth:!0,slotProps:{input:{endAdornment:c?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.Tooltip,{title:ee.I18n.t("Clear text"),slotProps:{popper:{sx:se.tooltip}},children:L.jsx(E.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setCommonItem(e,"desc",""),children:L.jsx(Ie.Close,{})})})}):null}},value:c,onChange:d=>this.setCommonItem(e,"desc",d.target.value)}),this.buttonRemoveKey("Description",()=>this.removeCommonItem(e,"desc"))]}):$n.buttonAddKey("Description",()=>this.setCommonItem(e,"desc","")),o?typeof e.common.type<"u"?L.jsxs(E.Box,{component:"div",sx:se.flex,children:[L.jsxs(E.FormControl,{style:se.marginBlock,fullWidth:!0,children:[L.jsx(E.InputLabel,{style:{transform:"scale(0.75)"},children:n("State type")}),L.jsx(E.Select,{variant:"standard",disabled:i,value:e.common.type,onChange:d=>this.setCommonItem(e,"type",d.target.value),children:t.map(d=>L.jsxs(E.MenuItem,{value:d,children:[n(d),L.jsxs("span",{style:se.typeNameEng,children:["(",d,")"]})]},d))})]}),this.buttonRemoveKey("State type",()=>this.removeCommonItem(e,"type"),{marginTop:20})]}):$n.buttonAddKey("State type",()=>this.setCommonItem(e,"type","string")):null,L.jsxs(E.Box,{component:"div",sx:{...se.flex,flexWrap:this.props.width==="xs"?"wrap":void 0},children:[o?typeof e.common.read<"u"?L.jsxs(E.Box,{component:"div",sx:se.flex,children:[L.jsx(E.FormControlLabel,{style:se.marginBlock,control:L.jsx(E.Checkbox,{disabled:i,checked:e.common.read,onChange:d=>this.setCommonItem(e,"read",d.target.checked)}),label:n("Readable")}),this.buttonRemoveKey("Readable",()=>this.removeCommonItem(e,"read"))]}):$n.buttonAddKey("Readable",()=>this.setCommonItem(e,"read",!0)):null,o?typeof e.common.write<"u"?L.jsxs(E.Box,{component:"div",sx:se.flex,children:[L.jsx(E.FormControlLabel,{style:se.marginBlock,control:L.jsx(E.Checkbox,{disabled:i,checked:e.common.write,onChange:d=>this.setCommonItem(e,"write",d.target.checked)}),label:n("Writeable")}),this.buttonRemoveKey("Writeable",()=>this.removeCommonItem(e,"write"))]}):$n.buttonAddKey("Writeable",()=>this.setCommonItem(e,"write",!0)):null]}),a?typeof e.common.role<"u"?L.jsxs(E.Box,{component:"div",sx:se.flex,children:[L.jsx(E.Autocomplete,{style:se.marginBlock,fullWidth:!0,disabled:i,value:e.common.role,onChange:(d,f)=>{const g=Bb.find(p=>p.role===f);g&&(g.w!==void 0&&g.r!==void 0?(this.setCommonItem(e,"write",g.w),this.setCommonItem(e,"read",g.r)):g.w!==void 0?this.setCommonItem(e,"write",g.w):g.r!==void 0&&this.setCommonItem(e,"read",g.r)),f.startsWith("level")||f.startsWith("indicator")||f.startsWith("sensor")||f.startsWith("weather")?e.common.write&&this.setCommonItem(e,"write",!1):f.startsWith("value")||f.startsWith("indicator")||f.startsWith("sensor")||f.startsWith("weather")?e.common.write&&this.setCommonItem(e,"write",!1):f.startsWith("level")||f.startsWith("switch")?e.common.write&&this.setCommonItem(e,"write",!0):f.startsWith("button")&&e.common.read&&this.setCommonItem(e,"read",!1),this.setCommonItem(e,"role",f)},options:l,renderInput:d=>L.jsx(E.TextField,{variant:"standard",...d,label:n("Role")})}),this.buttonRemoveKey("Role",()=>this.removeCommonItem(e,"role"),{marginTop:20})]}):$n.buttonAddKey("Role",()=>this.setCommonItem(e,"role","")):null,typeof e.common.color<"u"?L.jsxs(E.Box,{component:"div",sx:se.flex,children:[L.jsx(E.TextField,{variant:"standard",disabled:i,style:{...se.marginBlock,...se.color},label:n("Color"),type:"color",slotProps:{input:{endAdornment:e.common.color?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.Tooltip,{title:ee.I18n.t("Clear field"),slotProps:{popper:{sx:se.tooltip}},children:L.jsx(E.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setCommonItem(e,"color",""),children:L.jsx(Ie.Close,{})})})}):null}},value:e.common.color,onChange:d=>this.setCommonItem(e,"color",d.target.value)}),this.buttonRemoveKey("Color",()=>this.removeCommonItem(e,"color"))]}):$n.buttonAddKey("Color",()=>this.setCommonItem(e,"color","")),L.jsxs(E.Box,{component:"div",sx:{...se.flex,flexWrap:this.props.width==="xs"?"wrap":void 0,gap:this.props.width==="xs"?"10px":void 0},children:[e.common.type==="number"?typeof e.common.min<"u"?L.jsxs(E.Box,{component:"div",sx:se.flex,children:[L.jsx(E.TextField,{variant:"standard",disabled:i,className:{...se.marginBlock,...se.color},label:n("Min"),value:e.common.min,onChange:d=>this.setCommonItem(e,"min",d.target.value)}),this.buttonRemoveKey("Min",()=>this.removeCommonItem(e,"min"))]}):L.jsx(E.Box,{component:"div",sx:se.flex,children:$n.buttonAddKey("Min",()=>this.setCommonItem(e,"min",0))}):null,e.common.type==="number"?typeof e.common.max<"u"?L.jsxs(E.Box,{component:"div",sx:se.flex,children:[L.jsx(E.TextField,{variant:"standard",disabled:i,className:{...se.marginBlock,...se.color},label:n("Max"),value:e.common.max,onChange:d=>this.setCommonItem(e,"max",d.target.value)}),this.buttonRemoveKey("Max",()=>this.removeCommonItem(e,"max"))]}):L.jsx(E.Box,{component:"div",sx:se.flex,children:$n.buttonAddKey("Max",()=>this.setCommonItem(e,"max",100))}):null,e.common.type==="number"?typeof e.common.step<"u"?L.jsxs(E.Box,{component:"div",sx:se.flex,children:[L.jsx(E.TextField,{variant:"standard",disabled:i,className:{...se.marginBlock,...se.color},label:n("Step"),value:e.common.step,onChange:d=>this.setCommonItem(e,"step",d.target.value)}),this.buttonRemoveKey("Step",()=>this.removeCommonItem(e,"step"))]}):L.jsx(E.Box,{component:"div",sx:se.flex,children:$n.buttonAddKey("Step",()=>this.setCommonItem(e,"step",1))}):null]}),e.common.type==="number"?typeof e.common.unit<"u"?L.jsxs(E.Box,{component:"div",sx:se.flex,children:[L.jsx(E.TextField,{variant:"standard",disabled:i,className:{...se.marginBlock,...se.color},label:n("Unit"),slotProps:{input:{endAdornment:e.common.unit?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.Tooltip,{title:ee.I18n.t("Clear field"),slotProps:{popper:{sx:se.tooltip}},children:L.jsx(E.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setCommonItem(e,"unit",""),children:L.jsx(Ie.Close,{})})})}):null}},value:e.common.unit,onChange:d=>this.setCommonItem(e,"unit",d.target.value)}),this.buttonRemoveKey("Unit",()=>this.removeCommonItem(e,"unit"))]}):L.jsx("div",{style:se.flexDrop,children:$n.buttonAddKey("Unit",()=>this.setCommonItem(e,"unit",""))}):null]}),typeof e.common.icon<"u"?L.jsxs(E.Box,{component:"div",sx:se.flex,style:{flexGrow:1,minWidth:158},children:[L.jsx(ee.UploadImage,{disabled:i,maxSize:10*1024,icon:h,removeIconFunc:()=>this.setCommonItem(e,"icon",""),onChange:d=>this.setCommonItem(e,"icon",d)}),this.buttonRemoveKey("Icon",()=>this.removeCommonItem(e,"icon"))]}):L.jsx(E.Box,{component:"div",sx:se.flex,children:$n.buttonAddKey("Icon",()=>this.setCommonItem(e,"icon",""))})]})}catch{return L.jsx("div",{children:this.props.t("Cannot parse JSON!")})}}renderAliasEdit(){var e,t,i,n,r,o,a,l,h,c,u,d,f,g,p,m,v,_,b,y,C,x,S,k,T,I,N,A,R,P,B,z,U,K,X,ne,oe,ue,de,De;try{const Q=JSON.parse(this.state.text),Xe=((t=(e=Q.common)==null?void 0:e.alias)==null?void 0:t.read)!==void 0||((n=(i=Q.common)==null?void 0:i.alias)==null?void 0:n.write)!==void 0;return L.jsxs(E.Grid2,{container:!0,direction:"column",style:se.marginTop,children:[L.jsx(E.Grid2,{children:L.jsx(E.FormControlLabel,{control:L.jsx(E.Checkbox,{checked:typeof((o=(r=Q.common)==null?void 0:r.alias)==null?void 0:o.id)=="object",onChange:()=>{var Pe,tt,st,ve,ge,Oe,Ci;typeof((tt=(Pe=Q.common)==null?void 0:Pe.alias)==null?void 0:tt.id)=="object"?this.setAliasItem(Q,"id",((ge=(ve=(st=Q.common)==null?void 0:st.alias)==null?void 0:ve.id)==null?void 0:ge.read)||""):this.setAliasItem(Q,"id.read",((Ci=(Oe=Q.common)==null?void 0:Oe.alias)==null?void 0:Ci.id)||"")}}),label:this.props.t("Different IDs for read and write")})}),typeof((l=(a=Q.common)==null?void 0:a.alias)==null?void 0:l.id)!="object"?L.jsxs(E.Grid2,{children:[L.jsx(E.TextField,{variant:"standard",label:this.props.t("Alias state"),value:((c=(h=Q.common)==null?void 0:h.alias)==null?void 0:c.id)||"",style:se.aliasIdEdit,slotProps:{input:{endAdornment:(d=(u=Q.common)==null?void 0:u.alias)!=null&&d.id?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.Tooltip,{title:ee.I18n.t("Clear field"),slotProps:{popper:{sx:se.tooltip}},children:L.jsx(E.IconButton,{tabIndex:-1,size:"large",onClick:()=>this.setAliasItem(Q,"id",""),children:L.jsx(Ie.Close,{})})})}):null}},onChange:Pe=>this.setAliasItem(Q,"id",Pe.target.value),margin:"normal"}),L.jsx(E.Fab,{style:se.button,size:"small",onClick:()=>this.setState({selectId:!0,selectRead:!1,selectWrite:!1}),children:"..."})]}):null,typeof((g=(f=Q.common)==null?void 0:f.alias)==null?void 0:g.id)=="object"?L.jsxs(E.Grid2,{children:[L.jsx(E.TextField,{variant:"standard",label:this.props.t("Alias read state"),value:((v=(m=(p=Q.common)==null?void 0:p.alias)==null?void 0:m.id)==null?void 0:v.read)||"",style:se.aliasIdEdit,slotProps:{input:{endAdornment:(y=(b=(_=Q.common)==null?void 0:_.alias)==null?void 0:b.id)!=null&&y.read?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.Tooltip,{title:ee.I18n.t("Clear field"),slotProps:{popper:{sx:se.tooltip}},children:L.jsx(E.IconButton,{size:"large",tabIndex:-1,onClick:()=>this.setAliasItem(Q,"id.read",""),children:L.jsx(Ie.Close,{})})})}):null}},onChange:Pe=>this.setAliasItem(Q,"id.read",Pe.target.value),margin:"normal"}),L.jsx(E.Fab,{style:se.button,size:"small",onClick:()=>this.setState({selectId:!1,selectRead:!0,selectWrite:!1}),children:"..."})]}):null,typeof((x=(C=Q.common)==null?void 0:C.alias)==null?void 0:x.id)=="object"?L.jsxs(E.Grid2,{children:[L.jsx(E.TextField,{variant:"standard",label:this.props.t("Alias write state"),value:((T=(k=(S=Q.common)==null?void 0:S.alias)==null?void 0:k.id)==null?void 0:T.write)||"",style:se.aliasIdEdit,slotProps:{input:{endAdornment:(A=(N=(I=Q.common)==null?void 0:I.alias)==null?void 0:N.id)!=null&&A.write?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.Tooltip,{title:ee.I18n.t("Clear field"),slotProps:{popper:{sx:se.tooltip}},children:L.jsx(E.IconButton,{size:"large",tabIndex:-1,onClick:()=>this.setAliasItem(Q,"id.write",""),children:L.jsx(Ie.Close,{})})})}):null}},onChange:Pe=>this.setAliasItem(Q,"id.write",Pe.target.value),margin:"normal"}),L.jsx(E.Fab,{style:se.button,size:"small",onClick:()=>this.setState({selectId:!1,selectRead:!1,selectWrite:!0}),children:"..."})]}):null,L.jsx(E.Grid2,{style:se.marginTop,children:L.jsx(E.FormControlLabel,{control:L.jsx(E.Checkbox,{checked:((P=(R=Q.common)==null?void 0:R.alias)==null?void 0:P.read)!==void 0||((z=(B=Q.common)==null?void 0:B.alias)==null?void 0:z.write)!==void 0,onChange:()=>{Xe?(delete Q.common.alias.read,delete Q.common.alias.write):(Q.common=Q.common||{},Q.common.alias=Q.common.alias||{},Q.common.alias.read="val",Q.common.alias.write="val"),this.onChange(JSON.stringify(Q,null,2))}}),label:this.props.t("Use convert functions")})}),Xe?L.jsx(E.Grid2,{children:L.jsx(E.TextField,{variant:"standard",label:this.props.t("Read converter"),value:((K=(U=Q.common)==null?void 0:U.alias)==null?void 0:K.read)||"val",style:se.funcEdit,error:!!this.state.readError,slotProps:{input:{endAdornment:(ne=(X=Q.common)==null?void 0:X.alias)!=null&&ne.read?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.Tooltip,{title:ee.I18n.t("Clear field"),slotProps:{popper:{sx:se.tooltip}},children:L.jsx(E.IconButton,{size:"large",tabIndex:-1,onClick:()=>this.setAliasItem(Q,"read",""),children:L.jsx(Ie.Close,{})})})}):null,startAdornment:L.jsx(E.InputAdornment,{position:"start",children:L.jsx(ee.IconFx,{style:se.funcIcon})})}},onChange:Pe=>this.setAliasItem(Q,"read",Pe.target.value),helperText:this.state.readError||`${this.props.t("JS function like")} "val / 5 + 21"`,margin:"normal"})}):null,Xe?L.jsx(E.Grid2,{children:L.jsx(E.TextField,{variant:"standard",label:this.props.t("Write converter"),error:!!this.state.writeError,value:((ue=(oe=Q.common)==null?void 0:oe.alias)==null?void 0:ue.write)||"val",helperText:this.state.writeError||`${this.props.t("JS function like")} "(val - 21) * 5"`,style:se.funcEdit,slotProps:{input:{endAdornment:(De=(de=Q.common)==null?void 0:de.alias)!=null&&De.write?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.Tooltip,{title:ee.I18n.t("Clear field"),slotProps:{popper:{sx:se.tooltip}},children:L.jsx(E.IconButton,{size:"large",tabIndex:-1,onClick:()=>this.setAliasItem(Q,"write",""),children:L.jsx(Ie.Close,{})})})}):null,startAdornment:L.jsx(E.InputAdornment,{position:"start",children:L.jsx(ee.IconFx,{style:se.funcIcon})})}},onChange:Pe=>this.setAliasItem(Q,"write",Pe.target.value),margin:"normal"})}):null]})}catch{return L.jsx("div",{children:this.props.t("Cannot parse JSON!")})}}onCopy(e){ee.Utils.copyToClipboard(this.state.text,e),window.alert(this.props.t("ra_Copied"))}onClone(e,t){const i=JSON.parse(JSON.stringify(this.props.objects[e]));delete i.from,delete i.ts,delete i.user,i._id=t,this.props.objects[i._id]=i,this.props.onNewObject(i)}renderCopyDialog(){return this.state.showCopyDialog?L.jsxs(E.Dialog,{open:!0,maxWidth:"md",fullWidth:!0,onClose:()=>this.setState({showCopyDialog:""}),children:[L.jsx(E.DialogTitle,{children:this.props.t("Enter new ID for this object")}),L.jsx(E.DialogContent,{children:L.jsx(E.TextField,{variant:"standard",autoFocus:!0,fullWidth:!0,label:this.props.t("New object ID"),value:this.state.newId,slotProps:{input:{endAdornment:this.state.newId?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.Tooltip,{title:ee.I18n.t("Clear field"),slotProps:{popper:{sx:se.tooltip}},children:L.jsx(E.IconButton,{size:"small",tabIndex:-1,onClick:()=>this.setState({newId:""}),children:L.jsx(Ie.Close,{})})})}):null}},onKeyDown:e=>{e.key==="Enter"&&!this.props.objects[this.state.newId]&&(this.setState({showCopyDialog:""}),this.onClone(this.state.showCopyDialog,this.state.newId))},onChange:e=>this.setState({newId:e.target.value})})}),L.jsxs(E.DialogActions,{children:[L.jsx(E.Button,{disabled:!!this.props.objects[this.state.newId],onClick:()=>{this.setState({showCopyDialog:""}),this.onClone(this.state.showCopyDialog,this.state.newId)},color:"primary",startIcon:L.jsx(Ie.FileCopy,{}),children:this.props.t("Clone")}),L.jsx(E.Button,{color:"grey",onClick:()=>this.setState({showCopyDialog:""}),startIcon:L.jsx(Ie.Close,{}),children:this.props.t("Cancel")})]})]}):null}renderPanelObject(e){return L.jsxs("div",{style:{...se.divWithoutTitle,...e?se.divWithoutTitleAndTab:void 0,...this.state.error?se.error:void 0},onKeyDown:t=>{t.ctrlKey&&t.key==="Enter"&&(t.preventDefault(),t.stopPropagation(),this.onUpdate())},children:[L.jsx(f$,{value:this.state.text,onChange:t=>this.onChange(t),name:"UNIQUE_ID_OF_DIV",themeType:this.props.themeType}),this.state.showCommonDeleteMessage?L.jsx("div",{style:se.commonDeleteTip,children:ee.I18n.t("common_delete_tip")}):null]})}render(){const e=this.props.obj,t=e._id.startsWith("alias.0")&&e.type==="state";let i=se.dialog;window.innerWidth>1920&&(i={...i,maxWidth:"calc(100% - 150px)"});let n;try{n=JSON.parse(this.state.text)}catch{}return L.jsxs(E.Dialog,{sx:{"& .MuiPaper-root":i},open:!0,maxWidth:"xl",fullWidth:!0,fullScreen:!1,onClose:()=>this.props.onClose(),"aria-labelledby":"edit-value-dialog-title","aria-describedby":"edit-value-dialog-description",children:[L.jsxs(E.DialogTitle,{id:"edit-value-dialog-title",style:{width:"calc(100% - 32px)",overflow:"hidden",textOverflow:"ellipsis"},children:[this.props.t("Edit object:")," ",L.jsx(E.Box,{component:"span",style:se.id,sx:{fontSize:{xs:10}},children:this.props.obj._id})]}),this.renderTabs(n),this.renderCopyDialog(),L.jsxs(E.DialogContent,{sx:{p:this.props.width==="xs"&&this.state.tab==="object"?"6px":this.state.tab==="object"||this.state.tab==="common"||this.state.tab==="alias"?"0 24px":"0 6px",overflow:this.state.tab==="object"||this.state.tab==="common"||this.state.tab==="alias"?void 0:"hidden"},children:[this.state.tab==="object"?this.renderPanelObject(t):null,this.state.tab==="alias"&&this.props.obj._id.startsWith("alias.0")&&this.props.obj.type==="state"?this.renderAliasEdit():null,this.state.tab==="common"?this.renderCommonEdit():null,this.state.tab==="state"?this.renderStatePanel():null,this.renderCustomPanel(),this.renderSelectDialog()]}),L.jsxs(E.DialogActions,{sx:se.wrapperButton,children:[L.jsx(E.Button,{color:"grey",onClick:()=>this.setState({showCopyDialog:this.props.obj._id,newId:this.props.obj._id}),disabled:this.state.error||this.state.changed,title:this.props.t("Create a copy of this object"),children:L.jsx(Ie.FileCopy,{fontSize:this.props.width==="xs"?"large":void 0})}),L.jsx("div",{style:{flexGrow:1}}),this.state.tab==="object"&&L.jsx(E.Button,{color:"grey",onClick:r=>this.onCopy(r),disabled:this.state.error,title:this.props.width==="xs"?this.props.t("Copy into clipboard"):"",startIcon:this.props.width==="xs"?void 0:L.jsx(B7,{}),children:this.props.width==="xs"?L.jsx(B7,{fontSize:32}):this.props.t("Copy into clipboard")}),L.jsx(E.Button,{variant:"contained",disabled:this.state.error||!this.state.changed||this.state.customError,onClick:()=>this.onUpdate(),startIcon:this.props.width==="xs"?void 0:L.jsx(Ie.Check,{}),color:"primary",children:this.props.width==="xs"?L.jsx(Ie.Check,{fontSize:"large"}):this.props.t("Write")}),L.jsx(E.Button,{color:"grey",variant:"contained",onClick:()=>this.props.onClose(),startIcon:this.props.width==="xs"?void 0:L.jsx(Ie.Close,{}),children:this.props.width==="xs"?L.jsx(Ie.Close,{fontSize:"large"}):this.props.t("Cancel")})]})]})}}class A4 extends Te.Component{object=null;constructor(e){super(e),this.state={role:null,initRole:null,roleInput:null}}componentDidMount(){this.props.socket.getObject(this.props.id).then(e=>{var i;this.object=e;const t=((i=e==null?void 0:e.common)==null?void 0:i.role)||null;this.setState({role:t,initRole:t,roleInput:t})}).catch(e=>console.error(e))}onUpdate(){this.object.common=this.object.common||{},this.object.common.role=this.state.roleInput,this.props.socket.setObject(this.object._id,this.object).then(()=>this.props.onClose(this.object))}static filterRoles(e,t){const i=[];return e.forEach(n=>(n.type==="mixed"||n.type)===t&&!i.includes(n.role)&&i.push(n.role)),Bb.forEach(n=>(n.type==="mixed"||n.type)===t&&!i.includes(n.role)&&i.push(n.role)),i.sort(),i}render(){return L.jsxs(E.Dialog,{open:!0,maxWidth:"sm",fullWidth:!0,onClose:()=>this.props.onClose(),"aria-labelledby":"edit-role-dialog-title","aria-describedby":"edit-role-dialog-description",children:[L.jsx(E.DialogTitle,{id:"edit-role-dialog-title",children:this.object?this.props.t("Update role for %s",this.object._id):null}),L.jsx(E.DialogContent,{children:L.jsx(E.Autocomplete,{freeSolo:!0,options:A4.filterRoles(this.props.roleArray,this.props.commonType),style:{width:"100%"},value:this.state.role,onChange:(e,t)=>this.setState({role:t,roleInput:t}),onInputChange:(e,t)=>this.setState({roleInput:t}),renderInput:e=>L.jsx(E.TextField,{variant:"standard",...e,label:this.props.t("Role")})})}),L.jsxs(E.DialogActions,{children:[L.jsx(E.Button,{disabled:this.state.initRole===this.state.roleInput,variant:"contained",onClick:()=>this.onUpdate(),color:"primary",startIcon:L.jsx(Ie.Check,{}),children:this.props.t("Apply")}),L.jsx(E.Button,{variant:"contained",onClick:()=>this.props.onClose(),color:"grey",startIcon:L.jsx(Ie.Close,{}),children:this.props.t("Cancel")})]})]},"objectBrowserEditRole")}}const Mme=["array","boolean","file","json","mixed","number","object","string"],Ame={boolean:!1,string:"",number:0},zo={state:{name:"State",value:"state"},channel:{name:"Channel",value:"channel"},device:{name:"Device",value:"device"},folder:{name:"Folder",value:"folder"}},Rme=({onClose:s,onApply:e,selected:t,setObject:i,objects:n,expertMode:r,initialType:o,initialStateType:a})=>{var S;const l={state:ee.I18n.t("New state"),channel:ee.I18n.t("New channel"),device:ee.I18n.t("New device"),folder:ee.I18n.t("New folder")},h=[],c=(S=n[t])==null?void 0:S.type;n[t]?c==="channel"?(h.push(zo.state),o=o||"state"):c==="device"?(o=o||"channel",h.push(zo.state),h.push(zo.channel)):c==="state"?o=o||"":(h.push(zo.state),h.push(zo.channel),h.push(zo.device),t.startsWith("0_userdata.")||t.startsWith("alias.0.")||t==="0_userdata"||t==="alias.0"?(h.push(zo.folder),o=o||"folder"):o=o||"state"):(h.push(zo.folder),o=o||"folder",r&&(t.startsWith("mqtt.")||t.startsWith("javascript."))&&(h.push(zo.state),h.push(zo.channel),h.push(zo.device)));const u=(window._localStorage||window.localStorage).getItem("App.lastObjectType");u&&h.find(k=>k.value===u)&&(o=u);function d(k){return`${t}.${k.toString().replace(ee.Utils.FORBIDDEN_CHARS,"_").replace(/\s/g,"_").replace(/\./g,"_")}`}const[f,g]=Te.useState(o),[p,m]=Te.useState(l[o]),[v,_]=Te.useState(a||(window._localStorage||window.localStorage).getItem("App.lastStateType")||"string"),[b,y]=Te.useState(!n[d(l.state)]),C=()=>{const k={common:{name:p,desc:ee.I18n.t("Manually created")},type:f};f==="state"?(k.common={...k.common,role:"state",type:v,read:!0,write:!0,def:Ame[v]},k.native={}):f!=="folder"?k.common={...k.common,role:"",icon:""}:delete k.common.desc,i(`${t}.${p.split(" ").join("_")}`,k).then(()=>e())},x=ee.I18n.getLanguage();return L.jsxs(E.Dialog,{open:!0,fullWidth:!0,maxWidth:"md",disableEscapeKeyDown:!1,onClose:s,children:[L.jsx(E.DialogTitle,{children:L.jsxs("div",{style:{margin:10,fontSize:20,display:"flex",alignItems:"center",gap:8},children:[L.jsx(Ie.AddBox,{}),ee.I18n.t("Add new object:"),L.jsxs("span",{style:{fontStyle:"italic"},children:[t,".",p]})]})}),L.jsx(E.DialogContent,{children:L.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[L.jsx(E.TextField,{variant:"standard",label:ee.I18n.t("Parent"),style:{margin:"5px 0"},disabled:!0,value:t}),L.jsxs(E.FormControl,{variant:"standard",style:{marginTop:10,marginBottom:16},children:[L.jsx(E.InputLabel,{children:ee.I18n.t("Type")}),L.jsx(E.Select,{variant:"standard",value:f,onChange:k=>{(window._localStorage||window.localStorage).setItem("App.lastObjectType",k.target.value),p===l[f]&&(m(l[k.target.value]),y(!!n[d(l[k.target.value])])),g(k.target.value)},children:h.map(k=>L.jsxs(E.MenuItem,{value:k.value,children:[ee.I18n.t(k.name),x!=="en"&&L.jsxs("span",{style:{fontSize:"smaller",opacity:.6,marginLeft:4},children:["(",k.value,")"]})]},k.value))})]}),f==="state"&&L.jsxs(E.FormControl,{style:{marginTop:10,marginBottom:16},children:[L.jsx(E.InputLabel,{style:{left:-14},children:ee.I18n.t("State type")}),L.jsx(E.Select,{style:{marginTop:6},variant:"standard",value:v,onChange:k=>{(window._localStorage||window.localStorage).setItem("App.lastStateType",k.target.value),_(k.target.value)},children:Mme.map(k=>L.jsxs(E.MenuItem,{value:k,children:[ee.I18n.t(k),x!=="en"&&ee.I18n.t(k)!==k&&L.jsxs("span",{style:{fontSize:"smaller",opacity:.6,marginLeft:4},children:["(",k,")"]})]},k))})]}),L.jsx(E.TextField,{variant:"standard",label:ee.I18n.t("Name"),style:{margin:"5px 0"},autoFocus:!0,value:p,onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),p&&C())},slotProps:{input:{endAdornment:p?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.IconButton,{tabIndex:-1,size:"small",onClick:()=>m(""),children:L.jsx(Ie.Close,{})})}):null}},onChange:k=>{y(!n[d(k.target.value)]),m(k.target.value)}})]})}),L.jsxs(E.DialogActions,{children:[L.jsx(E.Button,{id:"add-new-object-dialog-add",startIcon:L.jsx(Ie.Check,{}),disabled:!p||!f||!b||f==="state"&&!v,onClick:()=>C(),variant:"contained",color:"primary",children:ee.I18n.t("add")}),L.jsx(E.Button,{id:"add-new-object-dialog-cancel",color:"grey",onClick:s,variant:"contained",startIcon:L.jsx(Ie.Close,{}),children:ee.I18n.t("ra_Cancel")})]})]})},Pme=[{Owner:[{name:"read",valueNum:1024,title:"read owner"},{name:"write",valueNum:512,title:"write owner"}]},{Group:[{name:"read",valueNum:64,title:"read group"},{name:"write",valueNum:32,title:"write group"}]},{Everyone:[{name:"read",valueNum:4,title:"read everyone"},{name:"write",valueNum:2,title:"write everyone"}]}];function uV(s,e,t){return s|=e&t,s&=e|~t&65535,s}const dV=({value:s,setValue:e,t,differentValues:i,applyToChildren:n,mask:r,setMask:o,disabled:a})=>{Te.useEffect(()=>{if(n){let h=0;for(let c=0;c<i.length;c++)h|=s^i[c];o(h)}else o(0)},[i,n,o,s]);let l=s;return L.jsx("div",{style:{display:"flex",width:"fit-content",margin:20,border:"1px solid",borderLeft:0},children:Pme.map(h=>{const c=Object.keys(h)[0];return L.jsxs("div",{style:{width:150,height:150,display:"flex",flexDirection:"column",alignItems:"center",borderLeft:"1px solid"},children:[L.jsx("div",{style:{height:50,display:"flex",alignItems:"center",fontSize:18,borderBottom:"1px solid silver",width:"100%",justifyContent:"center"},children:t(c)}),L.jsx("div",{style:{display:"flex",width:"100%"},children:h[c].map((u,d)=>{let f=!1;l-u.valueNum>=0&&(l-=u.valueNum,f=!0);const g=r&u.valueNum;return L.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,alignItems:"center",borderRight:d===0?"1px solid":0},children:[L.jsx("div",{style:{height:50,borderBottom:"1px solid",width:"100%",justifyContent:"center",display:"flex",alignItems:"center",color:"silver"},children:t(u.name)}),L.jsx("div",{style:{height:50,display:"flex"},children:L.jsx(E.Checkbox,{disabled:a,checked:f,color:g?"primary":"secondary",indeterminate:!!g,style:g?{opacity:.5}:void 0,onChange:p=>{g&&(r&=~u.valueNum&65535,o(r));let m=s;p.target.checked?m|=u.valueNum:m&=~u.valueNum&65535,e(m)}})})]},u.valueNum)})})]},c)})})},Ome=({onClose:s,onApply:e,selected:t,extendObject:i,objects:n,t:r,modalEmptyId:o,themeType:a,theme:l})=>{const[h,c]=Te.useState(null),[u,d]=Te.useState(null),[f,g]=Te.useState([]),[p,m]=Te.useState([]),[v,_]=Te.useState(!1),[b,y]=Te.useState(!1),[C,x]=Te.useState(0),[S,k]=Te.useState(null),[T,I]=Te.useState(null),[N,A]=Te.useState(!1),[R,P]=Te.useState(!1),[B,z]=Te.useState([]),[U,K]=Te.useState([]),[X,ne]=Te.useState(0),[oe,ue]=Te.useState(0),[de,De]=Te.useState([]),[Q,Xe]=Te.useState(!1),[Pe,tt]=Te.useState(!0),st=r("different");return Te.useEffect(()=>{var Rv,Pg,Pv,Iu;let ve=0;const ge=[],Oe=[],Ci=t||o,Ht=`${Ci}.`,In=Object.keys(n).sort();let Ms=!1;const ir=[],Or=[],lo=ee.I18n.getLanguage();let ic=!1,nc=!1,sc=null,Ia=null,Fr=null,nr=null;const Ol=[];for(let ho=0;ho<In.length;ho++){const En=In[ho],bt=n[En];if(bt&&(En===Ci||En.startsWith(Ht))){if(ve++,Ol.push(En),!bt.acl)continue;Fr===null&&bt.acl.object!==void 0&&(Fr=bt.acl.object),nr===null&&bt.acl.state!==void 0&&(nr=bt.acl.state),sc===null&&bt.acl.owner!==void 0&&(sc=bt.acl.owner),Ia===null&&bt.acl.ownerGroup!==void 0&&(Ia=bt.acl.ownerGroup),!N&&sc!==bt.acl.owner&&bt.acl.owner!==void 0&&(ic=!0),!R&&Ia!==bt.acl.ownerGroup&&bt.acl.ownerGroup!==void 0&&(nc=!0),bt.acl.state!==void 0&&nr!==bt.acl.state&&!ge.includes(bt.acl.state)&&ge.push(bt.acl.state),bt.acl.object!==void 0&&Fr!==bt.acl.object&&!Oe.includes(bt.acl.object)&&Oe.push(bt.acl.object),bt.type==="state"&&(Ms=!0)}En.startsWith("system.group.")&&(bt==null?void 0:bt.type)==="group"?ir.push({name:ee.Utils.getObjectNameFromObj(bt,lo).replace("system.group.",""),value:En,icon:(Rv=bt.common)==null?void 0:Rv.icon,color:(Pg=bt.common)==null?void 0:Pg.color}):En.startsWith("system.user.")&&(bt==null?void 0:bt.type)==="user"&&Or.push({name:ee.Utils.getObjectNameFromObj(bt,lo).replace("system.user.",""),value:En,icon:(Pv=bt.common)==null?void 0:Pv.icon,color:(Iu=bt.common)==null?void 0:Iu.color})}sc=sc||n["system.config"].common.defaultNewAcl.owner,Ia=Ia||n["system.config"].common.defaultNewAcl.ownerGroup,Fr=Fr||n["system.config"].common.defaultNewAcl.object,k(Number.isNaN(Fr)?n["system.config"].common.defaultNewAcl.object:Fr),Ms&&(nr=nr||n["system.config"].common.defaultNewAcl.state,I(Number.isNaN(nr)?n["system.config"].common.defaultNewAcl.state:nr));const Ww=Or.find(ho=>ho.value===sc),Hw=ir.find(ho=>ho.value===Ia);c(Ww),d(Hw),A(ic),P(nc),g(Or),m(ir),Ms&&y(!0),o&&_(!0),x(ve),z(ge),K(Oe),De(Ol)},[n,t,R,N,o]),Te.useEffect(()=>{v?(R&&(u.value!=="different"&&d({name:st,value:"different"}),p.find(ve=>ve.value==="different")||m(ve=>[{name:st,value:"different"},...ve])),N&&((!h||h.value!=="different")&&c({name:st,value:"different"}),f.find(ve=>ve.value==="different")||g(ve=>[{name:st,value:"different"},...ve]))):(h&&h.value==="different"&&c(n[t].acl.owner),u&&u.value==="different"&&d(n[t].acl.ownerGroup),m(ve=>ve.filter(({value:ge})=>ge!=="different")),g(ve=>ve.filter(({value:ge})=>ge!=="different")))},[f,v,N,R,n,t,u,h,st,p]),de.length?L.jsx(Sie,{theme:l,titleButtonApply:"apply",overflowHidden:!0,disableApply:Pe,progress:Q,onClose:s,onApply:()=>{Xe(!0),setTimeout(()=>{if(v){const ve=~X&65535,ge=~oe&65535;for(let Oe=0;Oe<de.length;Oe++){const Ci=de[Oe],Ht=n[Ci],In=ee.Utils.clone(Ht.acl||{});In.object=uV(Ht.acl.object,S,ve),h&&h.value!=="different"&&(In.owner=h.value),u&&u.value!=="different"&&(In.ownerGroup=u.value),Ht.type==="state"&&(In.state=uV(Ht.acl.state,T,ge)),i(Ci,{acl:In})}}else{const ve=ee.Utils.clone(n[t].acl||{});ve.object=S,ve.owner=h?h.value:"system.user.admin",ve.ownerGroup=u?u.value:"system.group.administrator",n[t].type==="state"&&(ve.state=T),i(t,{acl:ve})}Xe(!1),e()},200)},children:L.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[L.jsx("div",{style:{margin:10,fontSize:20},children:r("Access control list: %s",t||o)}),L.jsxs("div",{style:{display:"flex"},children:[L.jsxs(E.FormControl,{variant:"standard",fullWidth:!0,style:{marginRight:10},children:[L.jsx(E.InputLabel,{children:r("Owner user")}),L.jsx(E.Select,{variant:"standard",disabled:Q,value:h?h.value:"",renderValue:()=>L.jsxs("span",{children:[h!=null&&h.icon?L.jsx(ee.Icon,{src:h.icon,style:{width:16,height:16,marginRight:8}}):null,h?h.name:""]}),style:(h==null?void 0:h.value)==="different"?{opacity:.5}:{color:(h==null?void 0:h.color)||void 0,backgroundColor:ee.Utils.getInvertedColor(h==null?void 0:h.color,a)},onChange:ve=>{const ge=f.find(Oe=>Oe.value===ve.target.value);c(ge),tt(!1)},children:f.map(ve=>L.jsxs(E.MenuItem,{style:ve.value==="different"?{opacity:.5}:{color:ve.color||void 0,backgroundColor:ee.Utils.getInvertedColor(ve.color,a)},value:ve.value,children:[ve.icon?L.jsx(ee.Icon,{src:ve.icon,style:{width:16,height:16,marginRight:8}}):null,ve.name]},ve.value))})]}),L.jsxs(E.FormControl,{variant:"standard",fullWidth:!0,children:[L.jsx(E.InputLabel,{children:r("Owner group")}),L.jsx(E.Select,{variant:"standard",disabled:Q,value:u?u.value:"",renderValue:()=>L.jsxs("span",{children:[u!=null&&u.icon?L.jsx(ee.Icon,{src:u.icon,style:{width:16,height:16,marginRight:8}}):null,u?u.name:""]}),style:(u==null?void 0:u.value)==="different"?{opacity:.5}:{color:(u==null?void 0:u.color)||void 0,backgroundColor:ee.Utils.getInvertedColor(u==null?void 0:u.color,a)},onChange:ve=>{const ge=p.find(Oe=>Oe.value===ve.target.value);d(ge),tt(!1)},children:p.map(ve=>L.jsxs(E.MenuItem,{value:ve.value,style:ve.value==="different"?{opacity:.5}:{color:ve.color||void 0,backgroundColor:ee.Utils.getInvertedColor(ve.color,a)},children:[ve.icon?L.jsx(ee.Icon,{src:ve.icon,style:{width:16,height:16,marginRight:8}}):null,ve.name]},ve.value))})]})]}),L.jsxs("div",{style:{display:"flex",margin:10,alignItems:"center",fontSize:10,marginLeft:0,color:"silver"},children:[L.jsx("div",{style:v?null:{color:"green"},children:r("to apply one item")}),L.jsx(E.Switch,{disabled:Q||!!o||C===1,checked:!!o||v,onChange:ve=>{_(ve.target.checked),tt(!1)},color:"primary"}),L.jsxs("div",{style:v?{color:"green"}:null,children:[r("to apply with children")," ",o||C>1?`(${C} ${r("object(s)")})`:""]})]}),Q&&L.jsx(E.LinearProgress,{}),L.jsxs("div",{style:{overflowY:"auto"},children:[L.jsxs("div",{children:[L.jsx("h2",{children:r("Object rights")}),L.jsx(dV,{mask:oe,disabled:Q,setMask:ue,applyToChildren:v,differentValues:U,t:r,setValue:ve=>{k(ve),tt(!1)},value:S})]}),b&&L.jsxs("div",{children:[L.jsx("h2",{children:r("States rights")}),L.jsx(dV,{mask:X,disabled:Q,setMask:ne,applyToChildren:v,differentValues:v?B:[],t:r,setValue:ve=>{I(ve),tt(!1)},value:T})]})]})]})}):L.jsx(E.LinearProgress,{})},tp={dialog:{height:"100%",maxHeight:"100%",maxWidth:"100%"},content:{textAlign:"center"},error:s=>({color:s.palette.mode==="dark"?"#ff7777":"#c20000"}),image:{height:"100%",width:"auto"},text:{fontFamily:"Lucida Console, Courier, monospace",width:"100%"},download:{textDecoration:"none",textTransform:"uppercase",fontSize:14,color:"white",border:"1px solid white",borderRadius:5,padding:"8px 16px",marginRight:8}};class Fme extends Te.Component{audioRef;constructor(e){super(e);const t=this.props.obj._id.split(".");this.state={error:"",image:null,text:null,binary:null,fileName:`${t[t.length-2]}.${t[t.length-1]}`},this.audioRef=uS.createRef()}componentDidMount(){this.props.socket.getBinaryState(this.props.obj._id).then(e=>{let t=this.props.obj._id.toLowerCase().split(".").pop();const i=ee.Utils.detectMimeType(e);if(i&&(t=i),t==="jpg")this.setState({image:!0,binary:e,mime:"image/jpeg"});else if(t==="svg")this.setState({image:!0,binary:e,mime:"image/svg+xml"});else if(t==="png"||t==="bmp")this.setState({image:!0,binary:e,mime:`image/${t}`});else if(t==="mp3")this.setState({audio:!0,binary:e,mime:"audio/mpeg"});else if(t==="ogg")this.setState({audio:!0,binary:e,mime:"audio/ogg"});else if(t==="txt"||t==="log")try{const n=btoa(e);this.setState({text:n,binary:e,mime:"text/plain"})}catch{}}).catch(e=>this.setState({error:e}))}render(){return L.jsxs(E.Dialog,{style:tp.dialog,open:!0,maxWidth:this.state.audio?"sm":"md",onClose:()=>this.props.onClose(),fullWidth:!0,"aria-labelledby":"object-view-dialog-title",children:[L.jsx(E.DialogTitle,{id:"object-view-dialog-title",children:this.props.t("View file in state: %s",this.props.obj._id)}),L.jsxs(E.DialogContent,{style:tp.content,children:[this.state.error?L.jsx(E.Box,{component:"div",sx:tp.error,children:this.state.error==="State is not binary"?this.props.t("No file stored yet"):this.props.t(this.state.error)}):null,this.state.audio?L.jsx("audio",{ref:this.audioRef,src:`data:${this.state.mime};base64,${this.state.binary}`}):null,this.state.audio?L.jsx(E.Fab,{color:"primary",onClick:()=>this.audioRef.current&&this.audioRef.current.play(),children:L.jsx(Ie.PlayArrow,{})}):null,this.state.image?L.jsx("img",{src:`data:${this.state.mime};base64,${this.state.binary}`,alt:this.props.obj._id,style:tp.image}):null,this.state.text!==null?L.jsx("pre",{style:tp.text,children:this.state.text}):null]}),L.jsxs(E.DialogActions,{children:[L.jsxs("a",{style:tp.download,download:this.state.fileName,href:`data:${this.state.mime};base64,${this.state.binary}`,children:[L.jsx(Ie.GetApp,{style:{paddingRight:8,height:12}}),L.jsx("span",{children:this.props.t("Download")})]}),L.jsx(E.Button,{variant:"contained",onClick:()=>this.props.onClose(),startIcon:L.jsx(Ie.Close,{}),color:"grey",children:this.props.t("Close")})]})]})}}const _n={funcIcon:{width:16,height:16},formControlLabel:{marginBottom:16},color:{width:70},typeNameEng:{marginLeft:8,opacity:.7,fontStyle:"italic",fontSize:"smaller"},usedInAlias:{},addNewAlias:s=>({backgroundColor:s.palette.primary.main})},Bme=["array","boolean","file","json","mixed","number","object","string"];class g1 extends Te.Component{aliasIDs;constructor(e){var n;super(e);const t=[],i=this.props.obj._id;this.aliasIDs=Object.keys(this.props.objects).filter(r=>r.startsWith("alias.0"));for(let r=0;r<this.aliasIDs.length;r++){const o=(n=this.props.objects[this.aliasIDs[r]].common)==null?void 0:n.alias;((o==null?void 0:o.id)===i||typeof(o==null?void 0:o.id)=="object"&&(o.id.read===i||o.id.write===i))&&t.push(this.aliasIDs[r])}this.state={usedInAliases:t,showAddNewAlias:!t.length,newAliasId:this.props.obj._id,newAliasName:g1.getText(this.props.obj.common.name||this.props.obj._id)||"",newAliasRole:this.props.obj.common.role||"",newAliasRead:this.props.obj.common.read,newAliasWrite:this.props.obj.common.write,newAliasUnit:this.props.obj.common.unit,newAliasDesc:g1.getText(this.props.obj.common.desc)||"",newAliasType:this.props.obj.common.type,newAliasMin:this.props.obj.common.min===void 0?"":this.props.obj.common.min.toString(),newAliasMax:this.props.obj.common.max===void 0?"":this.props.obj.common.max.toString(),newAliasUseFormula:!1,newAliasReadFormula:"val",newAliasWriteFormula:"val",newAliasColor:this.props.obj.common.color,newAliasIcon:this.props.obj.common.icon,newAliasCopyStates:!!this.props.obj.common.states}}static getText(e){return e?typeof e=="object"?e[ee.I18n.getLanguage()]||e.en||"":e.toString():""}static filterRoles(e,t){const i=[];return Bb.forEach(n=>(n.type==="mixed"||n.type===t)&&!i.includes(n.role)&&i.push(n.role)),e.forEach(n=>(n.type==="mixed"||n.type)===t&&!i.includes(n.role)&&i.push(n.role)),i.sort(),i}renderAddNewAlias(){return this.state.showAddNewAlias?L.jsxs(E.Dialog,{open:!0,onClose:()=>this.setState({showAddNewAlias:!1}),children:[L.jsx(E.DialogTitle,{children:ee.I18n.t("Create new alias: %s",`alias.0.${this.state.newAliasId}`)}),L.jsxs(E.DialogContent,{children:[L.jsx(E.TextField,{style:_n.formControlLabel,variant:"standard",value:this.state.newAliasId,slotProps:{input:{endAdornment:this.state.newAliasId?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setState({newAliasId:""}),children:L.jsx(Ie.Close,{})})}):null}},onChange:e=>this.setState({newAliasId:e.target.value}),label:ee.I18n.t("Alias ID"),helperText:`alias.0.${this.state.newAliasId}`,fullWidth:!0}),L.jsx(E.TextField,{style:_n.formControlLabel,variant:"standard",value:this.state.newAliasName,slotProps:{input:{endAdornment:this.state.newAliasName?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setState({newAliasName:""}),children:L.jsx(Ie.Close,{})})}):null}},onChange:e=>this.setState({newAliasName:e.target.value}),label:ee.I18n.t("Alias name"),fullWidth:!0}),L.jsx(E.TextField,{style:_n.formControlLabel,variant:"standard",value:this.state.newAliasDesc,slotProps:{input:{endAdornment:this.state.newAliasDesc?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setState({newAliasDesc:""}),children:L.jsx(Ie.Close,{})})}):null}},onChange:e=>this.setState({newAliasDesc:e.target.value}),label:ee.I18n.t("Alias description"),fullWidth:!0}),L.jsxs(E.FormControl,{style:_n.formControlLabel,fullWidth:!0,children:[L.jsx(E.InputLabel,{children:ee.I18n.t("State type")}),L.jsx(E.Select,{variant:"standard",value:this.state.newAliasType,onChange:e=>this.setState({newAliasType:e.target.value}),children:Bme.map(e=>L.jsxs(E.MenuItem,{value:e,children:[ee.I18n.t(e),L.jsxs("span",{style:_n.typeNameEng,children:["(",e,")"]})]},e))})]}),this.state.newAliasType==="number"?L.jsx(E.TextField,{style:_n.formControlLabel,variant:"standard",value:this.state.newAliasUnit||"",slotProps:{input:{endAdornment:this.state.newAliasUnit?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setState({newAliasUnit:""}),children:L.jsx(Ie.Close,{})})}):null}},onChange:e=>this.setState({newAliasUnit:e.target.value}),label:ee.I18n.t("Alias units"),fullWidth:!0}):null,this.state.newAliasType==="number"?L.jsx(E.TextField,{variant:"standard",value:this.state.newAliasMin,type:"number",error:this.state.newAliasMin?isNaN(parseFloat(this.state.newAliasMin)):!1,onChange:e=>this.setState({newAliasMin:e.target.value}),label:ee.I18n.t("Min"),style:{width:"calc(50% - 4px)",marginBottom:16,marginRight:8}}):null,this.state.newAliasType==="number"?L.jsx(E.TextField,{variant:"standard",value:this.state.newAliasMax,type:"number",error:this.state.newAliasMax?isNaN(parseFloat(this.state.newAliasMax)):!1,onChange:e=>this.setState({newAliasMax:e.target.value}),label:ee.I18n.t("Max"),fullWidth:!0,style:{width:"calc(50% - 4px)",marginBottom:16}}):null,L.jsx(E.TextField,{variant:"standard",style:{..._n.formControlLabel,..._n.color},label:ee.I18n.t("Color"),type:"color",value:this.state.newAliasColor,onChange:e=>this.setState({newAliasColor:e.target.value})}),L.jsx(E.Autocomplete,{style:{..._n.formControlLabel},fullWidth:!0,value:this.state.newAliasRole,onChange:(e,t)=>{const i=Bb.find(n=>n.role===t);if(i){if(i.w!==void 0&&i.r!==void 0){this.setState({newAliasRole:t,newAliasRead:i.r,newAliasWrite:i.w});return}if(i.w!==void 0){this.setState({newAliasRole:t,newAliasWrite:i.w});return}if(i.r!==void 0){this.setState({newAliasRole:t,newAliasRead:i.r});return}}if(t.startsWith("value")||t.startsWith("indicator")||t.startsWith("sensor")||t.startsWith("weather")){if(this.state.newAliasWrite){this.setState({newAliasRole:t,newAliasWrite:!1});return}}else if(t.startsWith("level")||t.startsWith("switch")){if(!this.state.newAliasWrite){this.setState({newAliasRole:t,newAliasWrite:!0});return}}else if(t.startsWith("button")&&this.state.newAliasRead){this.setState({newAliasRole:t,newAliasRead:!1});return}this.setState({newAliasRole:t})},options:g1.filterRoles(this.props.roleArray,this.state.newAliasType),renderInput:e=>L.jsx(E.TextField,{variant:"standard",...e,label:ee.I18n.t("Role")})}),L.jsx(E.FormControlLabel,{style:{..._n.formControlLabel,marginLeft:16},control:L.jsx(E.Checkbox,{indeterminate:this.state.newAliasRead===void 0||this.state.newAliasRead===null,checked:this.state.newAliasRead,onChange:e=>{const t={newAliasRead:e.target.checked};t.newAliasRead===!1&&this.state.newAliasWrite===!1&&(t.newAliasWrite=!0),this.setState(t)}}),label:ee.I18n.t("Alias read")}),L.jsx(E.FormControlLabel,{style:_n.formControlLabel,control:L.jsx(E.Checkbox,{indeterminate:this.state.newAliasWrite===void 0||this.state.newAliasWrite===null,checked:this.state.newAliasWrite,onChange:e=>{const t={newAliasWrite:e.target.checked};t.newAliasRead===!1&&this.state.newAliasWrite===!1&&(t.newAliasRead=!0),this.setState(t)}}),label:ee.I18n.t("Alias write")}),this.props.obj.common.states?L.jsx(E.FormControlLabel,{style:_n.formControlLabel,control:L.jsx(E.Checkbox,{checked:this.state.newAliasCopyStates,onChange:e=>this.setState({newAliasCopyStates:e.target.checked})}),label:ee.I18n.t("Copy states")}):null,L.jsx(E.FormControlLabel,{style:_n.formControlLabel,control:L.jsx(E.Checkbox,{checked:this.state.newAliasUseFormula,onChange:e=>this.setState({newAliasUseFormula:e.target.checked})}),label:ee.I18n.t("Use convert functions")}),this.state.newAliasUseFormula&&this.state.newAliasRead?L.jsx(E.TextField,{style:_n.formControlLabel,variant:"standard",value:this.state.newAliasReadFormula,onChange:e=>this.setState({newAliasReadFormula:e.target.value}),label:ee.I18n.t("Read formula"),helperText:`${ee.I18n.t("JS function like")} "val / 5 + 21"`,slotProps:{input:{endAdornment:this.state.newAliasReadFormula&&this.state.newAliasReadFormula!=="val"?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setState({newAliasReadFormula:"val"}),children:L.jsx(Ie.Close,{})})}):null,startAdornment:L.jsx(E.InputAdornment,{position:"start",children:L.jsx(ee.IconFx,{style:_n.funcIcon})})}},fullWidth:!0}):null,this.state.newAliasUseFormula&&this.state.newAliasWrite?L.jsx(E.TextField,{style:_n.formControlLabel,variant:"standard",value:this.state.newAliasWriteFormula,onChange:e=>this.setState({newAliasWriteFormula:e.target.value}),label:ee.I18n.t("Write formula"),slotProps:{input:{endAdornment:this.state.newAliasWriteFormula&&this.state.newAliasWriteFormula!=="val"?L.jsx(E.InputAdornment,{position:"end",children:L.jsx(E.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setState({newAliasWriteFormula:"val"}),children:L.jsx(Ie.Close,{})})}):null,startAdornment:L.jsx(E.InputAdornment,{position:"start",children:L.jsx(ee.IconFx,{style:_n.funcIcon})})}},helperText:`${ee.I18n.t("JS function like")} "val / 5 + 21"`,fullWidth:!0}):null]}),L.jsxs(E.DialogActions,{children:[L.jsx(E.Button,{variant:"contained",disabled:!this.state.newAliasId||!!this.props.objects[`alias.0.${this.state.newAliasId}`],onClick:async()=>{const e={_id:`alias.0.${this.state.newAliasId}`,type:"state",common:{name:this.state.newAliasName,type:this.props.obj.common.type,alias:{id:this.props.obj._id}},native:{}};this.state.newAliasDesc&&(e.common.desc=this.state.newAliasDesc),this.state.newAliasType&&(e.common.type=this.state.newAliasType),this.state.newAliasType==="number"&&this.state.newAliasUnit&&(e.common.unit=this.state.newAliasUnit),this.state.newAliasRole&&(e.common.role=this.state.newAliasRole),this.state.newAliasType==="number"&&this.state.newAliasMin&&(e.common.min=parseFloat(this.state.newAliasMin)),this.state.newAliasType==="number"&&this.state.newAliasMax&&(e.common.max=parseFloat(this.state.newAliasMax)),this.state.newAliasRole&&(e.common.role=this.state.newAliasRole),this.state.newAliasRead!==void 0&&this.state.newAliasRead!==null&&(e.common.read=this.state.newAliasRead),this.state.newAliasWrite!==void 0&&this.state.newAliasWrite!==null&&(e.common.write=this.state.newAliasWrite),this.state.newAliasColor&&(e.common.color=this.state.newAliasColor),this.state.newAliasIcon&&(e.common.icon=this.state.newAliasIcon),this.state.newAliasCopyStates&&this.props.obj.common.states&&(e.common.states=this.props.obj.common.states),this.state.newAliasUseFormula&&(e.common.read!==!1&&this.state.newAliasReadFormula&&this.state.newAliasReadFormula!=="val"&&(e.common.alias.read=this.state.newAliasReadFormula),e.common.write!==!1&&this.state.newAliasWriteFormula&&this.state.newAliasWriteFormula!=="val"&&(e.common.alias.write=this.state.newAliasWriteFormula)),await this.props.socket.setObject(e._id,e),this.setState({showAddNewAlias:!1}),this.props.onRedirect(e._id,2e3),this.props.onClose()},startIcon:L.jsx(Ie.AddLink,{}),color:"primary",children:this.props.t("Create")}),L.jsx(E.Button,{variant:"contained",onClick:()=>this.setState({showAddNewAlias:!1}),startIcon:L.jsx(Ie.Close,{}),color:"grey",children:this.props.t("Close")})]})]}):null}render(){return L.jsxs(E.Dialog,{open:!0,maxWidth:"sm",onClose:()=>this.props.onClose(),fullWidth:!0,"aria-labelledby":"object-alias-dialog-title",children:[this.renderAddNewAlias(),L.jsx(E.DialogTitle,{id:"object-alias-dialog-title",children:this.state.usedInAliases.length?ee.I18n.t("This object is used in aliases"):ee.I18n.t("This object does not used in any aliases yet")}),L.jsx(E.DialogContent,{children:L.jsxs(E.MenuList,{style:{maxWidth:400},children:[this.state.usedInAliases.map(e=>L.jsxs(E.MenuItem,{style:_n.usedInAlias,onClick:()=>this.props.onRedirect(e),children:[L.jsx(E.ListItemIcon,{children:L.jsx(Ie.Link,{fontSize:"small"})}),L.jsx(E.ListItemText,{children:e})]},e)),L.jsxs(E.MenuItem,{onClick:()=>this.setState({showAddNewAlias:!0}),sx:_n.addNewAlias,children:[L.jsx(E.ListItemIcon,{children:L.jsx(Ie.AddLink,{fontSize:"small"})}),L.jsx(E.ListItemText,{children:ee.I18n.t("Create alias from this ID")})]})]})}),L.jsx(E.DialogActions,{children:L.jsx(E.Button,{variant:"contained",onClick:()=>this.props.onClose(),startIcon:L.jsx(Ie.Close,{}),color:"grey",children:this.props.t("Close")})})]},"editAlias")}}class R4 extends Te.Component{checkTimer=null;objects={};constructor(e){super(e);const t=this.props.id.split("."),i=t.pop()||"";this.state={name:i,parentId:t.join("."),renameAllChildren:!0,newExists:!0,showParentDialog:!1,showHistoryWarning:!1,withHistory:[]}}componentWillUnmount(){this.checkTimer&&(clearTimeout(this.checkTimer),this.checkTimer=null)}static calculateNewId(e,t,i){const n=e.split("."),r=t.split(".");let o=0;for(;n[o]===r[o];)o++;const a=i.split(".");return a.splice(0,o+1),`${t}.${a.join(".")}`}async getInstancesWithHistory(){const e=await this.props.socket.getAdapterInstances();return e==null?void 0:e.filter(t=>t.common.getHistory).map(t=>t._id.replace("system.adapter.",""))}async checkHistory(){this.objects={};const e=await this.getInstancesWithHistory(),t=[];try{const i=await this.props.socket.getObject(this.props.id);i&&(this.objects[i._id]=i)}catch{}for(const i of this.props.childrenIds)try{const n=await this.props.socket.getObject(i);n&&(this.objects[n._id]=n)}catch{}return Object.values(this.objects).forEach(i=>{var n;(n=i.common)!=null&&n.custom&&Object.keys(i.common.custom).find(r=>e.includes(r)&&!i.common.custom[r].aliasId)&&t.push(i._id)}),t.length?(this.setState({showHistoryWarning:!0,withHistory:t}),!1):!0}showHistoryWarning(){return this.state.showHistoryWarning?L.jsxs(E.Dialog,{open:!0,onClose:()=>this.setState({showHistoryWarning:!1}),children:[L.jsx(E.DialogTitle,{children:this.props.t("Found states with history")}),L.jsxs(E.DialogContent,{children:[this.state.withHistory.length>2?this.props.t("You want to move %s states with enabled history",this.state.withHistory.length):`${this.props.t("Following states have history enabled")}: ${this.state.withHistory.join(", ")}`,L.jsx("div",{children:this.props.t("move_states_with_history_warning")})]}),L.jsxs(E.DialogActions,{children:[L.jsx(E.Button,{variant:"contained",color:"primary",onClick:async()=>{const e=`${this.state.parentId}.${this.state.name}`;await this.renameCopyObject(this.props.id,e,this.props.childrenIds.length&&this.state.renameAllChildren,!1),this.props.onClose()},startIcon:L.jsx(Ie.Check,{}),children:this.props.t("Confirm")}),L.jsx(E.Button,{color:"grey",variant:"contained",startIcon:L.jsx(Ie.Close,{}),onClick:()=>this.setState({showHistoryWarning:!1}),children:this.props.t("ra_Cancel")})]})]}):null}async renameCopyObject(e,t,i,n){var a;if(e===t)return;let r;try{r=((a=this.objects)==null?void 0:a[e])||await this.props.socket.getObject(e)}catch{}let o;if((r==null?void 0:r.type)==="state"&&(o=await this.props.socket.getState(e)),i)for(const l of this.props.childrenIds){const h=R4.calculateNewId(e,t,l);await this.renameCopyObject(l,h,!1,n)}r&&(await this.props.socket.setObject(t,r),o&&await this.props.socket.setState(t,o),n||await this.props.socket.delObject(e))}checkIfNewExists(){const e=`${this.state.parentId}.${this.state.name}`;this.checkTimer&&(clearTimeout(this.checkTimer),this.checkTimer=null),this.props.id===e?this.state.newExists||(this.checkTimer=setTimeout(()=>{this.checkTimer=null,this.setState({newExists:!0})},50)):this.checkTimer=setTimeout(async()=>{this.checkTimer=null;try{const t=await this.props.socket.getObject(e);t&&!this.state.newExists?this.setState({newExists:!0}):!t&&this.state.newExists&&this.setState({newExists:!1})}catch{this.state.newExists&&this.setState({newExists:!1})}},300)}renderParentSelectorDialog(){return this.state.showParentDialog?L.jsx(ee.SelectID,{foldersFirst:!0,imagePrefix:"../..",expertMode:this.props.expertMode,socket:this.props.socket,columns:["name","type","role","room","func"],types:["folder","channel","device","meta"],notEditable:!0,selected:this.state.parentId,allowNonObjects:!0,filterFunc:e=>this.props.expertMode?!0:e._id.startsWith("0_userdata.0")||e._id.startsWith("javascript."),theme:this.props.theme,onSelectConfirm:(e,t)=>{let i;return Array.isArray(e)?i=e[0]:i=e,i.split(".").length<=1||t[i]&&(t[i].type==="state"||i.startsWith("system."))?Promise.resolve(!1):Promise.resolve(!0)},onClose:()=>this.setState({showParentDialog:!1}),onOk:e=>{let t;Array.isArray(e)?t=e[0]:t=e,t&&t.split(".").length>1&&this.setState({parentId:t})}}):null}render(){const e=`${this.state.parentId}.${this.state.name}`;return L.jsxs(E.Dialog,{open:!0,maxWidth:"md",fullWidth:!0,onClose:()=>this.props.onClose(),children:[this.renderParentSelectorDialog(),this.showHistoryWarning(),L.jsxs(E.DialogTitle,{children:[L.jsxs("span",{style:{opacity:.6,marginRight:8},children:[this.props.t("Rename or copy object")," -"]}),L.jsx("span",{style:{fontWeight:"bold"},children:this.props.id})]}),L.jsxs(E.DialogContent,{children:[L.jsxs("div",{style:{display:"flex",gap:8,alignItems:"end",opacity:.7},children:[L.jsx(E.TextField,{fullWidth:!0,variant:"standard",label:this.props.t("Parent ID"),value:`${this.state.parentId}.`,slotProps:{input:{readOnly:!0}}}),L.jsx(E.Button,{variant:"outlined",style:{maxWidth:40,width:40,height:32},onClick:()=>this.setState({showParentDialog:!0}),children:"..."})]}),L.jsx(E.TextField,{value:this.state.name,onChange:t=>{const i=t.target.value.replace(ee.Utils.FORBIDDEN_CHARS,"_").replace(/\./g,"_").replace(/\s/g,"_").replace(/,/g,"_").replace(/__/g,"_").replace(/__/g,"_");this.setState({name:i},()=>this.checkIfNewExists())},style:{marginTop:20},autoFocus:!0,variant:"standard",fullWidth:!0,label:this.props.t("New object ID")}),this.props.childrenIds.length?L.jsx(E.FormControlLabel,{control:L.jsx(E.Checkbox,{checked:this.state.renameAllChildren,onChange:()=>{this.setState({renameAllChildren:!this.state.renameAllChildren})}}),label:this.props.t("Rename all children")}):null,L.jsxs("div",{children:[L.jsxs("span",{style:{opacity:.6,marginRight:8,fontSize:16},children:[this.props.t("New object ID"),":"]}),L.jsx("span",{style:{fontWeight:"bold",fontSize:16},children:e})]})]}),L.jsxs(E.DialogActions,{children:[L.jsx(E.Button,{disabled:!this.state.name||e===this.props.id,color:"primary",variant:"outlined",onClick:async()=>{await this.renameCopyObject(this.props.id,e,this.props.childrenIds.length&&this.state.renameAllChildren,!0),this.props.onClose()},children:this.props.t("Create a copy")}),L.jsx(E.Button,{disabled:!this.state.name||e===this.props.id,color:"primary",variant:"contained",onClick:async()=>{await this.checkHistory()&&(await this.renameCopyObject(this.props.id,e,this.props.childrenIds.length&&this.state.renameAllChildren,!1),this.props.onClose())},children:e!==this.props.id&&this.state.newExists?this.props.t("Replace"):this.props.t("Rename")}),L.jsx(E.Button,{variant:"contained",color:"grey",onClick:()=>this.props.onClose(),startIcon:L.jsx(Ie.Close,{}),children:this.props.t("ra_Cancel")})]})]})}}function Vme(s){if(s.length===0)throw new Error("Invalid tail call");return[s.slice(0,s.length-1),s[s.length-1]]}function Ei(s,e,t=(i,n)=>i===n){if(s===e)return!0;if(!s||!e||s.length!==e.length)return!1;for(let i=0,n=s.length;i<n;i++)if(!t(s[i],e[i]))return!1;return!0}function Wme(s,e){const t=s.length-1;e<t&&(s[e]=s[t]),s.pop()}function Hme(s,e,t){return eX(s.length,i=>t(s[i],e))}function eX(s,e){let t=0,i=s-1;for(;t<=i;){const n=(t+i)/2|0,r=e(n);if(r<0)t=n+1;else if(r>0)i=n-1;else return n}return-(t+1)}function*P4(s,e){let t,i;for(const n of s)i!==void 0&&e(i,n)?t.push(n):(t&&(yield t),t=[n]),i=n;t&&(yield t)}function tX(s,e){for(let t=0;t<=s.length;t++)e(t===0?void 0:s[t-1],t===s.length?void 0:s[t])}function zme(s,e){for(let t=0;t<s.length;t++)e(t===0?void 0:s[t-1],s[t],t+1===s.length?void 0:s[t+1])}function O4(s){return s.filter(e=>!!e)}function fV(s){let e=0;for(let t=0;t<s.length;t++)s[t]&&(s[e]=s[t],e+=1);s.length=e}function jme(s){return!Array.isArray(s)||s.length===0}function fD(s){return Array.isArray(s)&&s.length>0}function Kf(s,e=t=>t){const t=new Set;return s.filter(i=>{const n=e(i);return t.has(n)?!1:(t.add(n),!0)})}function qn(s,e){let t=typeof e=="number"?s:0;typeof e=="number"?t=s:(t=0,e=s);const i=[];if(t<=e)for(let n=t;n<e;n++)i.push(n);else for(let n=t;n>e;n--)i.push(n);return i}function gD(s,e,t){const i=s.slice(0,e),n=s.slice(e);return i.concat(t,n)}function K2(s,e){const t=s.indexOf(e);t>-1&&(s.splice(t,1),s.unshift(e))}function xy(s,e){const t=s.indexOf(e);t>-1&&(s.splice(t,1),s.push(e))}function HN(s,e){for(const t of e)s.push(t)}function Ume(s,e,t){const i=iX(s,e),n=s.length,r=t.length;s.length=n+r;for(let o=n-1;o>=i;o--)s[o+r]=s[o];for(let o=0;o<r;o++)s[o+i]=t[o]}function HS(s,e,t,i){const n=iX(s,e);let r=s.splice(n,t);return r===void 0&&(r=[]),Ume(s,n,i),r}function iX(s,e){return e<0?Math.max(e+s.length,0):Math.min(e,s.length)}var Vb;(function(s){function e(r){return r<0}s.isLessThan=e;function t(r){return r<=0}s.isLessThanOrEqual=t;function i(r){return r>0}s.isGreaterThan=i;function n(r){return r===0}s.isNeitherLessOrGreaterThan=n,s.greaterThan=1,s.lessThan=-1,s.neitherLessOrGreaterThan=0})(Vb||(Vb={}));function Ir(s,e){return(t,i)=>e(s(t),s(i))}function $me(...s){return(e,t)=>{for(const i of s){const n=i(e,t);if(!Vb.isNeitherLessOrGreaterThan(n))return n}return Vb.neitherLessOrGreaterThan}}const Fh=(s,e)=>s-e,Gme=(s,e)=>Fh(s?1:0,e?1:0);function qme(s){return(e,t)=>-s(e,t)}class Uh{constructor(e){this.firstIdx=0,this.items=e,this.lastIdx=this.items.length-1}get length(){return this.lastIdx-this.firstIdx+1}takeWhile(e){let t=this.firstIdx;for(;t<this.items.length&&e(this.items[t]);)t++;const i=t===this.firstIdx?null:this.items.slice(this.firstIdx,t);return this.firstIdx=t,i}takeFromEndWhile(e){let t=this.lastIdx;for(;t>=0&&e(this.items[t]);)t--;const i=t===this.lastIdx?null:this.items.slice(t+1,this.lastIdx+1);return this.lastIdx=t,i}peek(){if(this.length!==0)return this.items[this.firstIdx]}dequeue(){const e=this.items[this.firstIdx];return this.firstIdx++,e}takeCount(e){const t=this.items.slice(this.firstIdx,this.firstIdx+e);return this.firstIdx+=e,t}}const Yp=class Yp{constructor(e){this.iterate=e}toArray(){const e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(e){return new Yp(t=>this.iterate(i=>e(i)?t(i):!0))}map(e){return new Yp(t=>this.iterate(i=>t(e(i))))}findLast(e){let t;return this.iterate(i=>(e(i)&&(t=i),!0)),t}findLastMaxBy(e){let t,i=!0;return this.iterate(n=>((i||Vb.isGreaterThan(e(n,t)))&&(i=!1,t=n),!0)),t}};Yp.empty=new Yp(e=>{});let mf=Yp;class Kme{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Km.isErrorNoTelemetry(e)?new Km(e.message+`
|
|
40
40
|
|
|
41
41
|
`+e.stack):new Error(e.message+`
|
|
42
42
|
|