iobroker.admin 7.6.1 → 7.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/README.md +3 -3
  2. package/adminWww/assets/{AdapterUpdateDialog-B6BExP8V.js → AdapterUpdateDialog-CdDzwRjx.js} +1 -1
  3. package/adminWww/assets/{Adapters-DIBIni4y.js → Adapters-BtSoe3ny.js} +1 -1
  4. package/adminWww/assets/{Config-YHxbcu7T.js → Config-DV-y10Fh.js} +1 -1
  5. package/adminWww/assets/{CustomModal-JqPz2I5-.js → CustomModal-CYOPWjwy.js} +1 -1
  6. package/adminWww/assets/CustomTab-cprIlE4B.js +1 -0
  7. package/adminWww/assets/{EasyMode-yY-I2xyh.js → EasyMode-Cd88-W7q.js} +1 -1
  8. package/adminWww/assets/{Enums-C5YwAYy_.js → Enums-nUibAZSg.js} +1 -1
  9. package/adminWww/assets/{Fields-DQnvUINT.js → Fields-vrlzBhCD.js} +1 -1
  10. package/adminWww/assets/{Files-D1MaiYKO.js → Files-DClcJEP9.js} +1 -1
  11. package/adminWww/assets/{Hosts-CdegJCob.js → Hosts-DLnI_Hxs.js} +1 -1
  12. package/adminWww/assets/{Instances-C53butsI.js → Instances-BaExCFtw.js} +1 -1
  13. package/adminWww/assets/{Intro-DK6ZJQFo.js → Intro-wT4JOxpS.js} +1 -1
  14. package/adminWww/assets/{Logs-D826DvR0.js → Logs-CSsFxtVG.js} +1 -1
  15. package/adminWww/assets/{Objects-CftJaIUZ.js → Objects-Bbrov7BJ.js} +3 -3
  16. package/adminWww/assets/{State-B-a9_a_1.js → State-CmEur1zC.js} +1 -1
  17. package/adminWww/assets/Users-CPHL5ErP.js +1 -0
  18. package/adminWww/assets/{bootstrap-CNGEzxvg.js → bootstrap-CoF0Rq1_.js} +108 -121
  19. package/adminWww/assets/index-8HslT92O.js +14 -0
  20. package/adminWww/assets/{index-7bHQZDF7.js → index-DO87nxhY.js} +2 -2
  21. package/adminWww/assets/{sentry-DA_P_z-O.js → sentry-Cc5WioqD.js} +1 -1
  22. package/adminWww/assets/{zh-cn-CqrEZCay.js → zh-cn-CzBq9Ifq.js} +1 -1
  23. package/adminWww/index.html +1 -1
  24. package/adminWww/mf-manifest.json +1 -1
  25. package/adminWww/remoteEntry.js +2 -2
  26. package/io-package.json +14 -14
  27. package/package.json +4 -4
  28. package/adminWww/assets/Users-DSiszZ5p.js +0 -1
@@ -1,4 +1,4 @@
1
- import{j as y}from"./DefaultPropsProvider-Beyggw1o.js";import{i as at,R as vh}from"./iobroker_admin__loadShare__react__loadShare__-T96CJO0k.js";import{w as Wn,f as rn,u as $x,J as gh,i as w,a as X,v as Gl,x as Yx,D as mh,y as Xx,z as qt,B as ks,U as jt,K as qx,M as Cd,R as yh,I as G,E as ty,N as Td,O as Zx,P as Ad,Q as Kx,b as Ca,V as ey,q as Jx,W as Rs,X as Qx}from"./bootstrap-CNGEzxvg.js";import{a as tw,i as ew}from"./iobroker_admin__mf_v__runtimeInit__mf_v__-VDoBF19b.js";import{c as rw,d as iw,e as nw,f as Md}from"./index-CFcKrkeG.js";import{a as aw}from"./_commonjsHelpers-BosuxZz1.js";import{h as Ul}from"./zh-cn-CqrEZCay.js";import{C as ow}from"./CustomModal-JqPz2I5-.js";import"./iobroker_admin__loadShare__prop_mf_2_types__loadShare__-C8Lvs8Es.js";import"./emotion-serialize.esm-BUa21YfQ.js";import"./iobroker_admin__loadShare___mf_0_emotion_mf_1_react__loadShare__-gw2iqPBS.js";import"./ace-BAuRYJjv.js";import"./FilledInput-Bfz0Aef-.js";import"./preload-helper-C1FmrZbK.js";import"./blueGrey-BKTirx-Z.js";import"./emotion-cache.browser.esm-B8BFze5o.js";import"./iobroker_admin__loadShare__leaflet__loadShare__-FMqZHPyC.js";import"./extends-CF3RwP-h.js";import"./iconBase-CxzgaDaB.js";const Ut={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"hidden"},headingIcon:{marginRight:5,width:32,height:32},titleEnabled:{float:"right",fontSize:16,color:"#7ff57f",textTransform:"uppercase",fontWeight:"bold",paddingLeft:20},scrollDiv:{width:"100%",height:"100%",overflow:"auto"},enabledControl:{width:130,display:"inline-block",verticalAlign:"top"},customControls:{width:"calc(100% - 130px)",maxWidth:800,display:"inline-block",verticalAlign:"top",paddingTop:16},accordionOdd:{},accordionEven:{backgroundColor:"rgba(128, 128, 128, 0.1)"},accordionHeaderOdd:{backgroundColor:"rgba(128, 128, 128, 0.2)"},accordionHeaderEven:{backgroundColor:"rgba(128, 128, 128, 0.3)"},accordionHeaderEnabledOdd:{backgroundColor:"rgba(128, 255, 128, 0.2)"},accordionHeaderEnabledEven:{backgroundColor:"rgba(128, 255, 128, 0.2)"},enabledVisible:{display:"inline-block"},enabledInvisible:{display:"none"}},sw=".";class Ls extends at.Component{changedIds;scrollDivRef;jsonConfigs;refTemplate;customObj;commonConfig={};cb;cachedNewValues;constructor(t){super(t);let e;try{e=JSON.parse((window._localStorage||window.localStorage).getItem("App.customsExpanded")||"[]")}catch{e=[]}this.changedIds=[],this.state={loaded:!1,expanded:e,newValues:{},confirmed:!1,showConfirmation:!1,maxOids:0,systemConfig:this.props.systemConfig},this.scrollDivRef=at.createRef(),this.jsonConfigs={},this.refTemplate={},this.props.customsInstances.map(i=>this.refTemplate[i]=at.createRef()),this.customObj=this.props.objectIDs.length>1?{common:{custom:{}},native:{}}:rn.deepClone(this.props.objects[this.props.objectIDs[0]]||null),this.customObj&&this.loadAllCustoms().then(()=>{this.commonConfig=this.getCommonConfig(),this.setState({loaded:!0,newValues:{}})})}async componentDidMount(){this.state.systemConfig||this.setState({systemConfig:await this.props.socket.getCompactSystemConfig()}),this.props.registerSaveFunc&&this.props.registerSaveFunc(this.onSave)}componentWillUnmount(){this.props.registerSaveFunc&&this.props.registerSaveFunc()}async loadAllCustoms(){const t=[];for(const e of this.props.customsInstances){if(e==="_")continue;const i=e.replace(/\.\d+$/,"").replace("system.adapter.","");this.jsonConfigs[i]===void 0&&(this.jsonConfigs[i]=null,t.push(this.getCustomTemplate(i)))}await Promise.all(t),this.props.customsInstances.forEach(e=>{var n,a;const i=e.replace(/\.\d+$/,"").replace("system.adapter.","");this.jsonConfigs[i]&&(this.jsonConfigs[i].instanceObjs=this.jsonConfigs[i].instanceObjs||{},this.jsonConfigs[i].instanceObjs[e]={_id:e,common:JSON.parse(JSON.stringify((n=this.props.objects[`system.adapter.${e}`])==null?void 0:n.common)),native:JSON.parse(JSON.stringify((a=this.props.objects[`system.adapter.${e}`])==null?void 0:a.native)),type:"instance",instanceObjects:[],objects:[]})})}async getCustomTemplate(t){var i;const e=this.props.objects[`system.adapter.${t}`]?rn.deepClone(this.props.objects[`system.adapter.${t}`]):null;if(!e){console.error(`Cannot find adapter "${t}"`);return}if(rn.fixAdminUI(e),((i=e.common)==null?void 0:i.adminUI.custom)==="json")try{const n=await this.props.socket.fileExists(`${t}.admin`,"jsonCustom.json5");let a,o;n?o=await this.props.socket.readFile(`${t}.admin`,"jsonCustom.json5"):o=await this.props.socket.readFile(`${t}.admin`,"jsonCustom.json"),o.file!==void 0?a=o.file:a=o;let s;try{s=$x.parse(a),this.jsonConfigs[t]=this.jsonConfigs[t]||{},this.jsonConfigs[t].json=s}catch(l){console.error(`Cannot parse jsonConfig of ${t}: ${l}`),window.alert(`Cannot parse jsonConfig of ${t}: ${l}`)}await gh.loadI18n(this.props.socket,s.i18n,t);return}catch(n){console.error(`Cannot load jsonConfig of ${t}: ${n}`),window.alert(`Cannot load jsonConfig of ${t}: ${n}`)}console.error(`Adapter ${t} is not yet supported by this version of admin`),window.alert(`Adapter ${t} is not yet supported by this version of admin`)}_executeCustom(t,e,i,n,a,o,s){if(s.includes(o))return;s.push(o);let l=[],u;if(t&&typeof t=="object"?(l=t.alsoDependsOn||[],typeof l=="string"&&(l=[l]),u=t.func):u=t,l.forEach(h=>{if(!a[h])console.error(`[JsonConfigComponent] attribute "${h}" does not exist!`);else if(!a[h].defaultFunc)console.error(`[JsonConfigComponent] attribute "${h}" is not required to be includes in "alsoDependsOn" while has static value!`);else{const c=this._executeCustom(a[h].defaultFunc,e,i,n,a,h,s);c!==void 0&&(e[h]=c)}}),!u)e[o]=a[o].default===void 0?null:a[o].default;else try{const h=new Function("data","originalData","_system","instanceObj","customObj","_socket",u.includes("return")?u:`return ${u}`);e[o]=h(e||this.props.data,this.props.originalData,this.props.systemConfig,n,i,this.props.socket)}catch(h){console.error(`Cannot execute ${t}: ${h}`),e[o]=!a[o]||a[o].default===void 0?null:a[o].default}return e[o]}static flattenItems(t,e={}){return t&&Object.keys(t).forEach(i=>{t[i].items?Ls.flattenItems(t[i].items,e):e[i]=t[i]}),e}getDefaultValues(t,e){const i={enabled:!1},n=t.split(".")[0];if(this.jsonConfigs[n]&&!this.jsonConfigs[n].disabled){const a=Ls.flattenItems(this.jsonConfigs[n].json.items);if(a){const o=[],s=Object.keys(a).filter(l=>a[l]);s.forEach(l=>{!a[l].defaultFunc&&a[l].default!==void 0&&(i[l]=a[l].default)}),s.forEach(l=>{a[l].defaultFunc&&this._executeCustom(a[l].defaultFunc,i,e,this.jsonConfigs[n].instanceObjs[t],a,l,o)})}}return i}getCommonConfig(){const t=this.props.objectIDs||[],e=this.props.objects,i={};return this.props.customsInstances.forEach(n=>{const a=n.split(".")[0];this.jsonConfigs[a]&&this.jsonConfigs[a].disabled||(i[n]={},t.forEach(o=>{var u;const s=e[o],l=(u=s==null?void 0:s.common)!=null&&u.custom&&s.common.custom[n]||null;if(l)Object.keys(l).forEach(h=>{h.startsWith("_")||(i[n][h]===void 0?i[n][h]=l[h]:i[n][h]!==l[h]&&(Array.isArray(i[n][h])||(i[n][h]=[i[n][h]]),i[n][h].includes(l[h])||i[n][h].push(l[h])))});else{const h=this.getDefaultValues(n,s);h.enabled=!1,Object.keys(h).forEach(c=>{c.startsWith("_")||(i[n][c]===void 0?i[n][c]=h[c]:i[n][c]!==h[c]&&(Array.isArray(i[n][c])||(i[n][c]=[i[n][c]]),i[n][c].includes(h[c])||i[n][c].push(h[c])))})}}),Object.keys(i[n]).forEach(o=>{Array.isArray(i[n][o])&&i[n][o].sort()}))}),i}isChanged(t){return t=t||this.state.newValues,Object.keys(t).find(e=>t[e]===null||t[e]&&Object.keys(t[e]).find(i=>!i.startsWith("_")))}combineNewAndOld(t,e=!1){const i={...this.commonConfig[t]||{},...this.state.newValues[t]||{}};return e&&Object.keys(i).forEach(n=>{n.startsWith("_")&&delete i[n]}),this.state.newValues[t]===null&&(i.enabled=!1),i}renderOneCustom(t,e,i,n){var f,d;const a=t.split(".")[0],o=`${sw}/adapter/${a}/${this.props.objects[`system.adapter.${a}`].common.icon}`,s=this.state.newValues[t]!==void 0&&(!this.state.newValues[t]||this.state.newValues[t].enabled!==void 0)?!!(this.state.newValues[t]&&this.state.newValues[t].enabled):this.state.newValues[t]===null?!1:this.commonConfig[t].enabled,l=Array.isArray(s)&&(!this.state.newValues[t]||this.state.newValues[t].enabled===void 0),u=(d=(f=this.jsonConfigs[a])==null?void 0:f.json)==null?void 0:d.disabled,h=this.combineNewAndOld(t);if(u&&this.jsonConfigs[a].json.hidden===!0||typeof this.jsonConfigs[a].json.hidden=="string"&&this._executeCustom(this.jsonConfigs[a].json.hidden,h,i,e,this.jsonConfigs[a].json.items,"enabled",[]))return null;let c=null;return u&&this.jsonConfigs[a].json.help&&(typeof this.jsonConfigs[a].json.help=="object"?c=this.jsonConfigs[a].json.help[this.props.lang]||this.jsonConfigs[a].json.help.en:c=this.props.t(this.jsonConfigs[a].json.help)),y.jsxs(w.Accordion,{id:`Accordion_${t}`,style:n%2?Ut.accordionOdd:Ut.accordionEven,expanded:this.state.expanded.includes(t),ref:this.refTemplate[t],onChange:()=>{const p=[...this.state.expanded],v=p.indexOf(t);v===-1?p.push(t):p.splice(v,1),(window._localStorage||window.localStorage).setItem("App.customsExpanded",JSON.stringify(p)),v===-1&&(window._localStorage||window.localStorage).setItem("App.customsLastExpanded",t),this.setState({expanded:p})},children:[y.jsxs(w.AccordionSummary,{expandIcon:y.jsx(X.ExpandMore,{}),"data-id":t,style:n%2?s?Ut.accordionHeaderEnabledOdd:Ut.accordionHeaderOdd:s?Ut.accordionHeaderEnabledEven:Ut.accordionHeaderEven,children:[y.jsx("img",{src:o,style:Ut.headingIcon,alt:""}),y.jsx(w.Typography,{style:Ut.heading,children:this.props.t("Settings %s",t)}),y.jsx("div",{className:"titleEnabled",style:{...Ut.titleEnabled,...s?Ut.enabledVisible:Ut.enabledInvisible},children:this.props.t("Enabled")})]}),y.jsxs(w.AccordionDetails,{children:[y.jsx("div",{style:Ut.enabledControl,children:y.jsx(w.FormControlLabel,{style:Ut.formControl,control:y.jsx(w.Checkbox,{indeterminate:l,checked:!!s,disabled:!!u,onChange:p=>{this.cachedNewValues=this.cachedNewValues||this.state.newValues;const v=rn.deepClone(this.cachedNewValues);v[t]=v[t]||{},l||p.target.checked?v[t].enabled=!0:s&&this.commonConfig[t].enabled?v[t]=null:delete v[t],this.cachedNewValues=v,this.setState({newValues:v,hasChanges:this.isChanged(v)},()=>{this.cachedNewValues=void 0,this.props.onChange&&this.props.onChange(!!this.state.hasChanges)})}}),label:this.props.t("Enabled")})}),y.jsxs("div",{style:Ut.customControls,children:[!u&&(s||l)&&this.state.systemConfig?y.jsx(gh,{instanceObj:e,customObj:i,custom:!0,adapterName:a,instance:parseInt((t==null?void 0:t.split(".").pop())??"0",10)||0,socket:this.props.socket,themeName:this.props.themeName,themeType:this.props.themeType,theme:this.props.theme,multiEdit:this.props.objectIDs.length>1,schema:this.jsonConfigs[a].json,data:h,isFloatComma:this.props.systemConfig.common.isFloatComma,dateFormat:this.props.systemConfig.common.dateFormat,onError:p=>this.setState({error:p},()=>this.props.onError&&this.props.onError(p)),onValueChange:(p,v)=>{var m;this.cachedNewValues=this.cachedNewValues||this.state.newValues,console.log(`${p} => ${v}`);const g=rn.deepClone(this.cachedNewValues);g[t]=g[t]||{},JSON.stringify(Gl.getValue((m=this.commonConfig)==null?void 0:m[t],p))===JSON.stringify(v)?(Gl.setValue(g[t],p,null),Object.keys(g[t]).length||delete g[t]):Gl.setValue(g[t],p,v),this.cachedNewValues=g,this.setState({newValues:g,hasChanges:this.isChanged(g)},()=>{this.cachedNewValues=void 0,this.props.onChange&&this.props.onChange(!!this.state.hasChanges)})}}):null,c]})]})]},t)}renderErrorMessage(){return!!this.state.error&&y.jsx(Yx,{title:this.props.t("Error"),text:this.state.error?"Error":"",onClose:()=>this.setState({error:!1})})}getObject(t,e,i){return t[i]?Promise.resolve(t[i]):this.props.socket.getObject(i).then(n=>(e[i]=rn.deepClone(n),t[i]=n,n))}saveOneState(t,e,i,n){if(i=i||{},n=n||{},t!=null&&t.length){const a=this.state.maxOids||t.length;this.state.maxOids===null&&this.setState({maxOids:t.length},()=>this.props.onProgress(!0)),this.setState({progress:Math.round((a-t.length)/a*50)});const o=t.shift();this.getObject(i,n,o).then(s=>{var u,h,c;if(!s){window.alert(`Invalid object ${o}`);return}(u=s.common)!=null&&u.custom&&Object.keys(s.common.custom).forEach(f=>{(!s.common.custom[f]||!s.common.custom[f].enabled)&&(s.common.custom[f]=null)});const l=Object.keys(this.state.newValues);for(let f=0;f<l.length;f++){const d=l[f],p=this.combineNewAndOld(d,!0);if(p.enabled===!1)(c=(h=s.common)==null?void 0:h.custom)!=null&&c[d]&&(s.common.custom[d]=null);else if(p.enabled){if(s.common=s.common||{},Array.isArray(p.enabled)&&(!s.common.custom||!s.common.custom[d]||!s.common.custom[d].enabled)){s.common.custom&&s.common.custom[d]&&(s.common.custom[d]=null);continue}if(s.common.custom=s.common.custom||{},!s.common.custom[d]||!s.common.custom[d].enabled){const g=this.getDefaultValues(d,s);s.common.custom[d]=JSON.parse(JSON.stringify(g||{})),Object.keys(s.common.custom[d]).forEach(m=>{m.startsWith("_")&&delete s.common.custom[d][m]})}const v=this.props.objectIDs.length>1;s.common.custom[d].enabled=!0,Object.keys(p).forEach(g=>{if(!g.startsWith("_")){if(Array.isArray(p[g])&&v)return;s.common.custom[d][g]=p[g]}})}}setTimeout(()=>this.saveOneState(t,e,i,n),0)})}else{const a=Object.keys(i);if(!a.length)this.setState({maxOids:0},()=>this.props.onProgress(!1)),e&&e();else{this.setState({progress:Math.round((this.state.maxOids-a.length)/this.state.maxOids*50)+50});const o=a.shift();if(JSON.stringify(i[o].common)!==JSON.stringify(n[o].common)){this.changedIds.includes(o)||this.changedIds.push(o),this.props.socket.setObject(o,i[o]).then(async()=>{delete i[o],delete n[o],this.props.objects[o]=await this.props.socket.getObject(o),setTimeout(()=>this.saveOneState(t,e,i,n),0)});return}delete i[o],delete n[o],setTimeout(()=>this.saveOneState(t,e,i,n),0)}}}renderConfirmationDialog(){return this.state.showConfirmation?y.jsx(mh,{text:this.props.t("The changes will be applied to %s states. Are you sure?",this.props.objectIDs.length.toString()),ok:this.props.t("Yes"),onClose:t=>{t?this.setState({showConfirmation:!1,confirmed:!0},()=>{const e=this.cb;this.cb=void 0,this.onSave(e)}):(this.cb=void 0,this.setState({showConfirmation:!1}))}}):null}onSave=t=>{this.props.objectIDs.length>10&&!this.state.confirmed?(this.cb=t,this.setState({showConfirmation:!0})):this.saveOneState([...this.props.objectIDs],()=>{this.cachedNewValues={},this.commonConfig=this.getCommonConfig(),this.setState({confirmed:!1,hasChanges:void 0,newValues:{}},()=>{this.props.reportChangedIds(this.changedIds),this.props.onChange(!1,!0),t&&setTimeout(()=>t(),100)})})};render(){if(this.customObj===null)return y.jsx("div",{style:{color:"#F55",fontSize:32},children:this.props.t("Object does not exist!")});if(!this.state.loaded)return y.jsx(w.LinearProgress,{});let t=0;return y.jsxs(w.Paper,{style:Ut.paper,children:[this.state.maxOids>1&&y.jsx(w.LinearProgress,{color:"secondary",variant:"determinate",value:this.state.progress}),y.jsx("div",{style:Ut.scrollDiv,ref:this.scrollDivRef,children:this.state.maxOids===0&&Object.values(this.jsonConfigs).map(e=>e?Object.keys(e.instanceObjs).map(i=>this.renderOneCustom(i,e.instanceObjs[i],this.customObj,t++)):null)}),this.renderErrorMessage(),this.renderConfirmationDialog()]})}}const lw=Wn()(Ls),{loadShare:uw}=ew,{initPromise:hw}=tw,cw=hw.then(r=>uw("date-fns/locale",{customShareInfo:{shareConfig:{singleton:!0,strictVersion:!1,requiredVersion:"*"}}})),fw=await cw.then(r=>r());var we=fw;const Os={en:we.enUS,fr:we.fr,ru:we.ru,de:we.de,es:we.es,br:we.ptBR,nl:we.nl,it:we.it,pt:we.pt,pl:we.pl,uk:we.uk,"zh-cn":we.zhCN},rt={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"hidden"},tableDiv:r=>({height:`calc(100% - ${parseInt(r.mixins.toolbar.minHeight,10)+8}px)`,overflow:"hidden",width:"100%"}),container:{height:"100%"},table:r=>({minWidth:960,width:"100%","& td:nth-of-type(5)":{overflow:"hidden",whiteSpace:"nowrap"},"& tr:nth-child(even)":{backgroundColor:r.palette.mode==="dark"?"#383838":"#b2b2b2"}}),row:{userSelect:"none",position:"relative","&:hover":{opacity:.7},"& td":{position:"relative"}},updatedRow:{animation:"updated 1s"},rowInterpolated:{opacity:.5},selectHistoryControl:{width:130},selectRelativeTime:{marginLeft:10,width:200},notAliveInstance:{opacity:.5},customRange:r=>({color:r.palette.primary.main}),rowSelected:r=>({backgroundColor:r.palette.secondary.main,color:r.palette.secondary.contrastText,"& td":{color:r.palette.secondary.contrastText,backgroundColor:r.palette.secondary.main}}),rowFocused:r=>({position:"absolute",pointerEvents:"none",top:0,bottom:0,left:0,right:0,m:"3px",border:`1px dotted ${r.palette.action.active}`}),grow:{flexGrow:1},msInput:{width:50,pt:"10px",ml:"5px","& label":{mt:"15px"}},cellAckTrue:r=>({color:r.palette.mode==="dark"?"#66ff7f":"#04a821"}),cellAckFalse:{color:"#FF6666"},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"}},toolbarTimeGrid:{position:"relative",marginLeft:8,paddingLeft:8,paddingRight:8,paddingTop:4,paddingBottom:4,border:"1px dotted #AAAAAA",borderRadius:8,display:"flex"},toolbarTimeLabel:{position:"absolute",padding:8,fontSize:"0.8rem",left:2,top:-9},noLoadingProgress:{width:"100%",height:4},colValue:{},colAck:{},colFrom:{},colLastChange:{},colTs:{}};class Es extends at.Component{adminInstance;supportedFeaturesPromises;unit;timeTimer;readSupportedFeaturesTimeout;rangeValues;rangeRef;subscribes;localStorage;constructor(t){super(t),this.localStorage=window._localStorage||window.localStorage;let e=this.localStorage.getItem("App.relativeRange")||"absolute";const i=parseInt(this.localStorage.getItem("App.absoluteStart"),10)||0,n=parseInt(this.localStorage.getItem("App.absoluteEnd"),10)||0,a=this.localStorage.getItem("App.historySelected")||"",o=parseInt(this.localStorage.getItem("App.historyLastSelected"),10)||null,s=this.localStorage.getItem("App.historyLastSelectedColumn")||null;(!i||!n)&&(!e||e==="absolute")&&(e="30"),i&&n&&(e="absolute");let l;try{l=JSON.parse(a)}catch{l=[]}this.state={start:i,end:n,values:null,relativeRange:e,selected:l,lastSelected:o,lastSelectedColumn:s,historyInstance:"",updateOpened:!1,insertOpened:!1,historyInstances:null,lcVisible:!0,ackVisible:!0,fromVisible:!0,supportedFeatures:[],ampm:!1,edit:{}},this.adminInstance=parseInt(window.location.search.slice(1),10)||0,this.supportedFeaturesPromises={},this.unit=this.props.obj.common&&this.props.obj.common.unit?` ${this.props.obj.common.unit}`:"",this.timeTimer=void 0,this.subscribes=[],this.prepareData().then(()=>this.readHistoryRange()).then(()=>{e!=="absolute"?this.setRelativeInterval(this.state.relativeRange,!0):this.readHistory()})}readSupportedFeatures(t){return t=t||this.state.historyInstance,t?this.supportedFeaturesPromises[t]instanceof Promise?this.supportedFeaturesPromises[t]:(this.supportedFeaturesPromises[t]=new Promise(e=>{this.readSupportedFeaturesTimeout&&clearTimeout(this.readSupportedFeaturesTimeout),this.readSupportedFeaturesTimeout=setTimeout(()=>{this.readSupportedFeaturesTimeout=void 0,e([])},2e3),this.props.socket.sendTo(t,"features",null).then(i=>{this.readSupportedFeaturesTimeout?(clearTimeout(this.readSupportedFeaturesTimeout),this.readSupportedFeaturesTimeout=void 0,e(i?i.supportedFeatures||[]:[])):this.setState({supportedFeatures:i?i.supportedFeatures||[]:[]})})}),this.supportedFeaturesPromises[t]):Promise.resolve([])}async componentDidMount(){await this.props.socket.subscribeState(this.props.obj._id,this.onChange)}componentWillUnmount(){this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=void 0);for(let t=0;t<this.subscribes.length;t++)this.props.socket.unsubscribeState(this.subscribes[t],this.onChange);this.subscribes=[],this.props.socket.unsubscribeState(this.props.obj._id,this.onChange)}onChange=(t,e)=>{if(t===this.props.obj._id&&e&&this.state.values&&(!this.state.values.length||this.state.values[this.state.values.length-1].ts<e.ts)){const i=[...this.state.values,e];this.setState({values:i})}else if(t.startsWith("system.adapter.")&&t.endsWith(".alive")){const i=t.substring(15,t.length-6),n=this.state.historyInstances,a=n.findIndex(o=>o.id===i);if(a!==-1&&n[a].alive!==!!(e!=null&&e.val)){const o=JSON.parse(JSON.stringify(n));o[a].alive=!!(e!=null&&e.val),this.setState({historyInstances:o},()=>{o[a].alive&&this.state.historyInstance===i&&this.readHistoryRange().then(()=>this.readHistory())})}}};async prepareData(){var o;const t=await this.getHistoryInstances(),e=await this.props.socket.getCompactSystemConfig(),i=(o=e==null?void 0:e.common)==null?void 0:o.defaultHistory;let n=this.localStorage.getItem("App.historyInstance")||"";if((!n||!t.find(s=>s.id===n&&s.alive))&&(n=i),!n||!t.find(s=>s.id===n&&s.alive)){const s=t.find(l=>l.alive);s&&(n=s.id)}!n&&t.length&&(n=i);const a=await this.readSupportedFeatures(n);await new Promise(s=>{this.setState({ampm:(e.common.dateFormat||"").includes("/"),historyInstances:t,historyInstance:n,supportedFeatures:a},()=>s())})}getHistoryInstances(){const t=[],e=[];return this.props.customsInstances.forEach(i=>{const n=this.props.objects[`system.adapter.${i}`];if(n&&n.common&&n.common.getHistory){const a={id:i,alive:!1};t.push(a),e.push(`system.adapter.${i}.alive`)}}),e.length?this.props.socket.getForeignStates(e).then(async i=>{Object.keys(i).forEach(n=>{var o;const a=t.find(s=>n.endsWith(`${s.id}.alive`));a&&(a.alive=!!((o=i[n])!=null&&o.val))}),this.subscribes=e;for(let n=0;n<e.length;n++)await this.props.socket.subscribeState(e[n],this.onChange);return t}):Promise.resolve(t)}readHistory(t,e){var i;return t=t||this.state.start,e=e||this.state.end,!this.state.historyInstance||!((i=this.state.historyInstances)!=null&&i.find(n=>n.id===this.state.historyInstance&&n.alive))?null:(this.setState({loading:!0}),this.props.socket.getHistory(this.props.obj._id,{instance:this.state.historyInstance,start:t,end:e,from:!0,ack:!0,q:!0,addId:!1,aggregate:"none",returnNewestEntries:!0}).then(n=>{const a=[],o=this.rangeValues;let s=!1,l=!1,u=!1;if(o&&o.length&&(!n||!n.length||o[0].ts<n[0].ts)&&(a.push(o[0]),a.push({ts:o[0].ts+1,e:!0}),console.log(`add ${new Date(o[0].ts).toISOString()}: ${o[0].val}`),!l&&o[0].ack!==void 0&&(l=!0),!u&&o[0].from&&(u=!0)),n!=null&&n.length)for(let h=0;h<n.length;h++)n[h]&&(!a.length||a[a.length-1].ts<n[h].ts)?(a.push(n[h]),n[h].from&&(n[h].from.startsWith("system.adapter.")?n[h].from=n[h].from.substring(15):n[h].from.startsWith("system.host.")&&(n[h].from=n[h].from.substring(7))),!s&&n[h].lc&&(s=!0),!l&&n[h].ack!==void 0&&(l=!0),!u&&n[h].from&&(u=!0),console.log(`add value ${new Date(n[h].ts).toISOString()}: ${n[h].val}`)):a[a.length-1].ts===n[h].ts&&a[a.length-1].val!==n[h].ts&&console.error("Strange data!");else a.push({noDataForPeriod:!0});a.length||a.push({noData:!0}),this.setState({loading:!1,values:a,lcVisible:s,fromVisible:u,ackVisible:l})}))}readHistoryRange(){var i;const t=new Date,e=new Date(2e3,0,1);return!this.state.historyInstance||!((i=this.state.historyInstances)!=null&&i.find(n=>n.id===this.state.historyInstance&&n.alive))?Promise.resolve():(this.setState({loading:!0}),this.props.socket.getHistory(this.props.obj._id,{instance:this.state.historyInstance,start:e.getTime(),end:t.getTime(),limit:1,from:!1,ack:!1,q:!1,addId:!1,aggregate:"none"}).then(n=>{n.length?((n[0].val===null||n[0].ts===e.getTime())&&n.shift(),n.forEach(a=>a.i=!0),this.rangeValues=n,this.setState({loading:!1})):(this.rangeValues=[],this.setState({loading:!1}))}))}onToggleSelect(t,e,i){let n=[...this.state.selected];const a=n.indexOf(e);if(t.shiftKey&&this.state.lastSelected){let o=-1,s=-1;n=[];for(let l=0;l<this.state.values.length&&!(this.state.values[l].ts===e&&(o=l,s!==o&&n.push(this.state.values[l].ts),o!==-1&&s!==-1)||this.state.values[l].ts===this.state.lastSelected&&(s=l,s!==o&&n.push(this.state.values[l].ts),o!==-1&&s!==-1));l++)(o!==-1||s!==-1)&&n.push(this.state.values[l].ts)}else t.ctrlKey?(a!==-1?n.splice(a,1):n.push(e),n.sort()):n=[e];this.localStorage.setItem("App.historyLastSelected",e.toString()),this.localStorage.setItem("App.historyLastSelectedColumn",i),this.localStorage.setItem("App.historySelected",JSON.stringify(n)),this.setState({selected:n,lastSelected:e,lastSelectedColumn:i})}getTableRows(){const t=[];for(let e=this.state.values.length-1;e>=0;e--){const i=this.state.values[e],n=i.ts;if(i.e)t.push(y.jsxs(w.TableRow,{sx:{...rt.row,...rt.updatedRow,...rt.rowInterpolated},hover:!0,children:[y.jsx(w.TableCell,{}),y.jsx(w.TableCell,{children:"..."}),this.state.ackVisible?y.jsx(w.TableCell,{}):null,this.state.fromVisible?y.jsx(w.TableCell,{}):null,this.state.lcVisible?y.jsx(w.TableCell,{}):null]},n));else if(i.noData||i.noDataForPeriod)t.push(y.jsxs(w.TableRow,{sx:{...rt.row,...rt.updatedRow,...rt.rowNoData},hover:!0,children:[y.jsx(w.TableCell,{}),y.jsx(w.TableCell,{children:i.noData?this.props.t("No data in history"):this.props.t("No data in history for selected period")}),this.state.ackVisible?y.jsx(w.TableCell,{}):null,this.state.fromVisible?y.jsx(w.TableCell,{}):null,this.state.lcVisible?y.jsx(w.TableCell,{}):null]},i.noData?"nodata":""));else{const a=i.i,o=this.state.lastSelected===n;let s=i.val;this.props.isFloatComma&&this.props.obj.common.type==="number"&&s&&(s=s.toString().replace(".",",")),s===null&&(s="null"),s===void 0&&(s="_");const l=this.state.selected.includes(n);t.push(y.jsxs(w.TableRow,{sx:{...rt.row,...rt.updatedRow,...a?rt.rowInterpolated:void 0,...l?rt.rowSelected:void 0},children:[y.jsxs(w.TableCell,{onClick:u=>!a&&this.onToggleSelect(u,n,"ts"),children:[`${Es.formatTimestamp(i.ts)}`,o&&this.state.lastSelectedColumn==="ts"?y.jsx(w.Box,{component:"div",sx:rt.rowFocused}):""]}),y.jsxs(w.TableCell,{onClick:u=>!a&&this.onToggleSelect(u,n,"val"),children:[s+this.unit,o&&this.state.lastSelectedColumn==="val"?y.jsx(w.Box,{component:"div",sx:rt.rowFocused}):""]}),this.state.ackVisible?y.jsxs(w.TableCell,{onClick:u=>!a&&this.onToggleSelect(u,n,"ack"),sx:i.ack?rt.cellAckTrue:rt.cellAckFalse,children:[i.ack?"true":"false",o&&this.state.lastSelectedColumn==="ack"?y.jsx(w.Box,{component:"div",sx:rt.rowFocused}):""]}):null,this.state.fromVisible?y.jsxs(w.TableCell,{onClick:u=>!a&&this.onToggleSelect(u,n,"from"),children:[i.from||"",o&&this.state.lastSelectedColumn==="from"?y.jsx(w.Box,{component:"div",sx:rt.rowFocused}):""]}):null,this.state.lcVisible?y.jsxs(w.TableCell,{onClick:u=>!a&&this.onToggleSelect(u,n,"lc"),children:[i.lc?`${new Date(i.lc).toLocaleDateString()} ${new Date(i.lc).toLocaleTimeString()}.${(i.ts%1e3).toString().padStart(3,"0")}`:"",o&&this.state.lastSelectedColumn==="lc"?y.jsx(w.Box,{component:"div",sx:rt.rowFocused}):""]}):null]},n.toString()+(i.val||"").toString()))}}return t}shiftTime(){const t=new Date,e=6e4-t.getSeconds()-(1e3-t.getMilliseconds());t.getMilliseconds()&&t.setMilliseconds(1e3),t.getSeconds()&&t.setSeconds(60);const i=t.getTime();let n;const a=this.state.relativeRange;if(a==="day")t.setHours(0),t.setMinutes(0),t.setSeconds(0),n=t.getTime();else if(a==="week"){t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0);const o=t.getDay()||7;o!==1&&t.setHours(-24*(o-1)),n=t.getTime()}else if(a==="2weeks"){t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setDate(t.getDate()-7);const o=t.getDay()||7;o!==1&&t.setHours(-24*(o-1)),n=t.getTime()}else a==="month"?(t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setDate(1),n=t.getTime()):a==="year"?(t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setDate(1),t.setMonth(0),n=t.getTime()):a==="12months"?(t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setFullYear(t.getFullYear()-1),n=t.getTime()):n=i-parseInt(a,10)*6e4;this.setState({start:n,end:i},()=>this.readHistory()),this.timeTimer=setTimeout(()=>{this.timeTimer=void 0,this.shiftTime()},e||6e4)}setRelativeInterval(t,e){if(e||(this.localStorage.setItem("App.relativeRange",t.toString()),this.setState({relativeRange:t})),t==="absolute"){this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=void 0);return}this.localStorage.removeItem("App.absoluteStart"),this.localStorage.removeItem("App.absolute");const i=new Date;if(!this.timeTimer){const o=6e4-i.getSeconds()-(1e3-i.getMilliseconds());this.timeTimer=setTimeout(()=>{this.timeTimer=void 0,this.shiftTime()},o||6e4)}i.getMilliseconds()&&i.setMilliseconds(1e3),i.getSeconds()&&i.setSeconds(60);const n=i.getTime();let a;if(t==="day")i.setHours(0),i.setMinutes(0),i.setSeconds(0),a=i.getTime();else if(t==="week"){i.setHours(0),i.setMinutes(0),i.setSeconds(0);const o=i.getDay()||7;o!==1&&i.setHours(-24*(o-1)),a=i.getTime()}else if(t==="2weeks"){i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setDate(i.getDate()-7);const o=i.getDay()||7;o!==1&&i.setHours(-24*(o-1)),a=i.getTime()}else t==="month"?(i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setDate(1),a=i.getTime()):t==="year"?(i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setDate(1),i.setMonth(0),a=i.getTime()):t==="12months"?(i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setFullYear(i.getFullYear()-1),a=i.getTime()):(t=Number(t),a=n-t*6e4);this.setState({start:a,end:n},()=>this.readHistory())}renderTable(){var t;if(!this.state.historyInstance)return y.jsx("div",{style:{marginTop:20,fontSize:24},children:this.props.t("History instance not selected")});if(!((t=this.state.historyInstances)!=null&&t.find(e=>e.id===this.state.historyInstance&&e.alive)))return y.jsx("div",{style:{marginTop:20,fontSize:24},children:this.props.t("History instance not alive")});if(this.state.values){const e=[200,"auto"],i=[190,100];return this.state.ackVisible&&(e.push(50),i.push(50)),this.state.fromVisible&&(e.push(150),i.push(150)),this.state.lcVisible&&(e.push(200),i.push(190)),y.jsx(w.TableContainer,{style:rt.container,children:y.jsxs(Xx,{stickyHeader:!0,sx:rt.table,initialWidths:e,minWidths:i,dblTitle:this.props.t("ra_Double click to reset table layout"),children:[y.jsx(w.TableHead,{children:y.jsxs(w.TableRow,{children:[y.jsx(w.TableCell,{style:rt.colTs,children:this.props.t("Timestamp")}),y.jsx(w.TableCell,{style:rt.colValue,children:this.props.t("Value")}),this.state.ackVisible?y.jsx(w.TableCell,{style:rt.colAck,children:this.props.t("Ack")}):null,this.state.fromVisible?y.jsx(w.TableCell,{style:rt.colFrom,children:this.props.t("From")}):null,this.state.lcVisible?y.jsx(w.TableCell,{style:rt.colLastChange,children:this.props.t("lc")}):null]})}),y.jsx(w.TableBody,{children:this.getTableRows()})]})})}return y.jsx(w.LinearProgress,{})}renderDialogConfirm(){return y.jsxs(w.Dialog,{open:!!this.state.areYouSure,onClose:()=>this.setState({areYouSure:!1}),"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[y.jsx(w.DialogTitle,{id:"alert-dialog-title"}),y.jsxs(w.DialogContent,{children:[y.jsx(w.DialogContentText,{id:"alert-dialog-description",children:this.props.t("Are you sure?")}),y.jsx(w.FormControlLabel,{control:y.jsx(w.Checkbox,{value:this.state.suppressMessage,onChange:()=>this.setState({suppressMessage:!0})}),label:this.props.t("Suppress for 5 minutes")})]}),y.jsxs(w.DialogActions,{children:[y.jsx(w.Button,{variant:"contained",onClick:()=>this.setState({areYouSure:!1,suppressMessage:this.state.suppressMessage&&Date.now()},()=>this.onDelete()),color:"primary",autoFocus:!0,startIcon:y.jsx(X.Delete,{}),children:this.props.t("Delete")}),y.jsx(w.Button,{variant:"contained",onClick:()=>this.setState({areYouSure:!1}),color:"secondary",startIcon:y.jsx(X.Close,{}),children:this.props.t("Cancel")})]})]})}onDelete(){const t=this.state.selected.map(e=>({state:{ts:e},id:this.props.obj._id}));this.props.socket.sendTo(this.state.historyInstance,"delete",t).then(()=>this.readHistory())}onUpdate(){let t=this.state.edit.val;this.props.obj.common&&(this.props.obj.common.type==="number"?typeof t!="number"&&(t=parseFloat(t.toString().replace(",","."))):this.props.obj.common.type==="boolean"&&(t=t==="true"||t==="TRUE"||t===!0||t==="1"||t===1));const e={val:t,ack:this.state.edit.ack,ts:this.state.selected[0],from:`system.adapter.admin.${this.adminInstance}`,q:this.state.edit.q};for(const[i,n]of Object.entries(e))n===void 0&&delete e[i];!this.state.lcVisible&&e.lc&&delete e.lc,this.props.socket.sendTo(this.state.historyInstance,"update",[{id:this.props.obj._id,state:e}]).then(()=>this.readHistory())}onInsert(){let t=this.state.edit.val;this.props.obj.common&&(this.props.obj.common.type==="number"?t=parseFloat(t.toString().replace(",",".")):this.props.obj.common.type==="boolean"&&(t=t==="true"||t==="TRUE"||t===!0||t==="1"||t===1));const e=this.state.edit.date;e.setHours(this.state.edit.time.getHours()),e.setMinutes(this.state.edit.time.getMinutes()),e.setSeconds(this.state.edit.time.getSeconds()),e.setMilliseconds(parseInt(this.state.edit.ms,10));const i={ts:e.getTime(),val:t,ack:this.state.edit.ack,from:`system.adapter.admin.${this.adminInstance}`,q:this.state.edit.q||0};!this.state.lcVisible&&i.lc&&delete i.lc;for(const[n,a]of Object.entries(i))a===void 0&&delete i[n];this.props.socket.sendTo(this.state.historyInstance,"insert",[{id:this.props.obj._id,state:i}]).then(()=>this.readHistory())}updateEdit(t,e){const i=JSON.parse(JSON.stringify(this.state.edit));i.time=new Date(i.time),i.date=new Date(i.date),i[t]=e,this.setState({edit:i})}renderEditDialog(){return y.jsxs(w.Dialog,{open:this.state.updateOpened||this.state.insertOpened,onClose:()=>this.setState({updateOpened:!1,insertOpened:!1}),"aria-labelledby":"edit-dialog-title","aria-describedby":"edit-dialog-description",children:[y.jsx(w.DialogTitle,{id:"edit-dialog-title",children:this.state.updateOpened?this.props.t("Update entry"):this.props.t("Insert entry")}),y.jsx(w.DialogContent,{children:y.jsxs("form",{noValidate:!0,autoComplete:"off",children:[typeof this.state.edit.val=="boolean"?y.jsx(w.FormControlLabel,{control:y.jsx(w.Checkbox,{checked:this.state.edit.val,onChange:t=>this.updateEdit("val",t.target.checked)}),label:this.props.t("Value")}):y.jsx(w.TextField,{variant:"standard",label:this.props.t("Value"),value:this.state.edit.val,onChange:t=>this.updateEdit("val",t.target.value)}),y.jsx("br",{}),y.jsx(w.FormControlLabel,{control:y.jsx(w.Checkbox,{checked:this.state.edit.ack,onChange:t=>this.updateEdit("ack",t.target.checked)}),label:this.props.t("Acknowledged")}),this.state.insertOpened?y.jsx(qt.LocalizationProvider,{dateAdapter:ks,adapterLocale:Os[this.props.lang],children:y.jsxs("div",{style:rt.toolbarTimeGrid,children:[y.jsx("div",{style:rt.toolbarTimeLabel,children:this.props.t("Time")}),y.jsx(qt.DatePicker,{sx:rt.toolbarDate,value:this.state.edit.date,onChange:t=>this.updateEdit("date",t)}),y.jsx(qt.TimePicker,{sx:rt.toolbarTime,ampm:this.state.ampm,views:["hours","minutes","seconds"],value:this.state.edit.time,onChange:t=>this.updateEdit("time",t)}),y.jsx(w.TextField,{variant:"standard",sx:rt.msInput,helperText:this.props.t("ms"),type:"number",slotProps:{htmlInput:{max:999,min:0}},value:this.state.edit.ms,onChange:t=>this.updateEdit("ms",t.target.value)})]})}):null]})}),y.jsxs(w.DialogActions,{children:[y.jsx(w.Button,{variant:"contained",disabled:this.state.edit.val==="",onClick:()=>{const t=this.state.updateOpened;this.setState({updateOpened:!1,insertOpened:!1},()=>t?this.onUpdate():this.onInsert())},color:"primary",autoFocus:!0,children:this.state.updateOpened?this.props.t("Update"):this.props.t("Add")}),y.jsx(w.Button,{variant:"contained",onClick:()=>this.setState({updateOpened:!1,insertOpened:!1}),color:"grey",children:this.props.t("Cancel")})]})]})}setStartDate(t){const e=t.getTime();this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=void 0),this.localStorage.setItem("App.relativeRange","absolute"),this.localStorage.setItem("App.absoluteStart",e.toString()),this.localStorage.setItem("App.absoluteEnd",this.state.end.toString()),this.setState({start:e,relativeRange:"absolute"},()=>this.readHistory())}setEndDate(t){const e=t.getTime();this.localStorage.setItem("App.relativeRange","absolute"),this.localStorage.setItem("App.absoluteStart",this.state.start.toString()),this.localStorage.setItem("App.absoluteEnd",e.toString()),this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=void 0),this.setState({end:e,relativeRange:"absolute"},()=>this.readHistory())}renderToolbar(){var t,e;return y.jsxs(w.Toolbar,{children:[y.jsxs(w.FormControl,{variant:"standard",style:rt.selectHistoryControl,children:[y.jsx(w.InputLabel,{children:this.props.t("History instance")}),y.jsx(w.Select,{variant:"standard",value:this.state.historyInstance||"",onChange:i=>{const n=i.target.value;this.localStorage.setItem("App.historyInstance",n),this.readSupportedFeatures(n).then(a=>this.setState({historyInstance:n,supportedFeatures:a},()=>this.readHistory()))},children:(t=this.state.historyInstances)==null?void 0:t.map(i=>y.jsx(w.MenuItem,{value:i.id,style:i.alive?void 0:rt.notAliveInstance,children:i.id},i.id))})]}),y.jsxs(w.FormControl,{variant:"standard",style:rt.selectRelativeTime,children:[y.jsx(w.InputLabel,{children:this.props.t("Relative")}),y.jsxs(w.Select,{variant:"standard",ref:this.rangeRef,value:this.state.relativeRange,onChange:i=>this.setRelativeInterval(i.target.value),children:[y.jsx(w.MenuItem,{value:"absolute",sx:rt.customRange,children:this.props.t("custom range")},"custom"),y.jsx(w.MenuItem,{value:10,children:this.props.t("last 10 minutes")},"1"),y.jsx(w.MenuItem,{value:30,children:this.props.t("last 30 minutes")},"2"),y.jsx(w.MenuItem,{value:60,children:this.props.t("last hour")},"3"),y.jsx(w.MenuItem,{value:"day",children:this.props.t("this day")},"4"),y.jsx(w.MenuItem,{value:24*60,children:this.props.t("last 24 hours")},"5"),y.jsx(w.MenuItem,{value:"week",children:this.props.t("this week")},"6"),y.jsx(w.MenuItem,{value:24*60*7,children:this.props.t("last week")},"7"),y.jsx(w.MenuItem,{value:"2weeks",children:this.props.t("this 2 weeks")},"8"),y.jsx(w.MenuItem,{value:24*60*14,children:this.props.t("last 2 weeks")},"9"),y.jsx(w.MenuItem,{value:"month",children:this.props.t("this month")},"10"),y.jsx(w.MenuItem,{value:30*24*60,children:this.props.t("last 30 days")},"11"),y.jsx(w.MenuItem,{value:"year",children:this.props.t("this year")},"12"),y.jsx(w.MenuItem,{value:"12months",children:this.props.t("last 12 months")},"13")]})]}),y.jsxs(qt.LocalizationProvider,{dateAdapter:ks,adapterLocale:Os[this.props.lang],children:[y.jsxs("div",{style:rt.toolbarTimeGrid,children:[y.jsx("div",{style:{...rt.toolbarTimeLabel,opacity:this.state.relativeRange!=="absolute"?.5:void 0},children:this.props.t("Start time")}),y.jsx(qt.DatePicker,{sx:rt.toolbarDate,disabled:this.state.relativeRange!=="absolute",value:new Date(this.state.start),onChange:i=>this.setStartDate(i)}),y.jsx(qt.TimePicker,{disabled:this.state.relativeRange!=="absolute",sx:rt.toolbarTime,ampm:this.state.ampm,value:new Date(this.state.start),onChange:i=>this.setStartDate(i)})]}),y.jsxs("div",{style:rt.toolbarTimeGrid,children:[y.jsx("div",{style:{...rt.toolbarTimeLabel,opacity:this.state.relativeRange!=="absolute"?.5:void 0},children:this.props.t("End time")}),y.jsx(qt.DatePicker,{disabled:this.state.relativeRange!=="absolute",sx:rt.toolbarDate,value:new Date(this.state.end),onChange:i=>this.setEndDate(i)}),y.jsx(qt.TimePicker,{disabled:this.state.relativeRange!=="absolute",sx:rt.toolbarTime,ampm:this.state.ampm,value:new Date(this.state.end),onChange:i=>this.setEndDate(i)})]})]}),y.jsx(w.Box,{component:"div",sx:rt.grow}),(e=this.state.values)!=null&&e.length?y.jsx(w.IconButton,{size:"large",onClick:()=>this.exportData(),title:this.props.t("Save data as csv"),children:y.jsx(rw,{})}):null,this.state.supportedFeatures.includes("insert")&&this.props.expertMode?y.jsx(w.IconButton,{size:"large",onClick:()=>{const i=new Date,n={ack:this.state.values[this.state.values.length-1].ack,val:this.state.values[this.state.values.length-1].val,date:new Date(i),ms:0,time:new Date(i),q:0};this.setState({edit:n,insertOpened:!0})},children:y.jsx(iw,{})}):null,this.state.supportedFeatures.includes("update")&&this.props.expertMode?y.jsx(w.IconButton,{size:"large",disabled:this.state.selected.length!==1,onClick:()=>{const i=JSON.parse(JSON.stringify(this.state.values.find(a=>a.ts===this.state.lastSelected))),n=new Date(i.ts);i.date=new Date(n),i.time=new Date(n),this.setState({edit:i,updateOpened:!0})},children:y.jsx(X.Edit,{})}):null,this.state.supportedFeatures.includes("delete")&&this.props.expertMode?y.jsx(w.IconButton,{size:"large",disabled:!this.state.selected.length,onClick:()=>{typeof this.state.suppressMessage=="number"&&Date.now()-this.state.suppressMessage<3e5?this.onDelete():this.setState({areYouSure:!0})},children:y.jsx(X.Delete,{})}):null]})}exportData(){let t=window.document.getElementById("export-file");t||(t=document.createElement("a"),t.setAttribute("id","export-file"),t.style.display="none",document.body.appendChild(t));const e=["timestamp;value;acknowledged;from;"];this.state.values.forEach(i=>!i.i&&!i.e&&e.push([Es.formatTimestamp(i.ts),i.val===null||i.val===void 0?"null":i.val.toString(),i.ack?"true":"false",i.from||""].join(";"))),t.setAttribute("href",`data:text/plain;charset=utf-8,${encodeURIComponent(e.join(`
1
+ import{j as y}from"./DefaultPropsProvider-Beyggw1o.js";import{i as at,R as vh}from"./iobroker_admin__loadShare__react__loadShare__-T96CJO0k.js";import{w as Wn,f as rn,J as gh,i as w,a as X,u as Gl,v as $x,D as mh,x as Yx,y as qt,z as ks,U as jt,B as Xx,M as Cd,R as yh,I as G,E as ty,K as Td,N as qx,O as Ad,P as Zx,b as Ca,Q as ey,q as Kx,V as Rs,W as Jx}from"./bootstrap-CoF0Rq1_.js";import{l as Qx}from"./index-8HslT92O.js";import{a as tw,i as ew}from"./iobroker_admin__mf_v__runtimeInit__mf_v__-VDoBF19b.js";import{c as rw,d as iw,e as nw,f as Md}from"./index-CFcKrkeG.js";import{a as aw}from"./_commonjsHelpers-BosuxZz1.js";import{h as Ul}from"./zh-cn-CzBq9Ifq.js";import{C as ow}from"./CustomModal-CYOPWjwy.js";import"./iobroker_admin__loadShare__prop_mf_2_types__loadShare__-C8Lvs8Es.js";import"./emotion-serialize.esm-BUa21YfQ.js";import"./iobroker_admin__loadShare___mf_0_emotion_mf_1_react__loadShare__-gw2iqPBS.js";import"./ace-BAuRYJjv.js";import"./FilledInput-Bfz0Aef-.js";import"./preload-helper-C1FmrZbK.js";import"./blueGrey-BKTirx-Z.js";import"./emotion-cache.browser.esm-B8BFze5o.js";import"./iobroker_admin__loadShare__leaflet__loadShare__-FMqZHPyC.js";import"./extends-CF3RwP-h.js";import"./iconBase-CxzgaDaB.js";const Ut={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"hidden"},headingIcon:{marginRight:5,width:32,height:32},titleEnabled:{float:"right",fontSize:16,color:"#7ff57f",textTransform:"uppercase",fontWeight:"bold",paddingLeft:20},scrollDiv:{width:"100%",height:"100%",overflow:"auto"},enabledControl:{width:130,display:"inline-block",verticalAlign:"top"},customControls:{width:"calc(100% - 130px)",maxWidth:800,display:"inline-block",verticalAlign:"top",paddingTop:16},accordionOdd:{},accordionEven:{backgroundColor:"rgba(128, 128, 128, 0.1)"},accordionHeaderOdd:{backgroundColor:"rgba(128, 128, 128, 0.2)"},accordionHeaderEven:{backgroundColor:"rgba(128, 128, 128, 0.3)"},accordionHeaderEnabledOdd:{backgroundColor:"rgba(128, 255, 128, 0.2)"},accordionHeaderEnabledEven:{backgroundColor:"rgba(128, 255, 128, 0.2)"},enabledVisible:{display:"inline-block"},enabledInvisible:{display:"none"}},sw=".";class Ls extends at.Component{changedIds;scrollDivRef;jsonConfigs;refTemplate;customObj;commonConfig={};cb;cachedNewValues;constructor(t){super(t);let e;try{e=JSON.parse((window._localStorage||window.localStorage).getItem("App.customsExpanded")||"[]")}catch{e=[]}this.changedIds=[],this.state={loaded:!1,expanded:e,newValues:{},confirmed:!1,showConfirmation:!1,maxOids:0,systemConfig:this.props.systemConfig},this.scrollDivRef=at.createRef(),this.jsonConfigs={},this.refTemplate={},this.props.customsInstances.map(i=>this.refTemplate[i]=at.createRef()),this.customObj=this.props.objectIDs.length>1?{common:{custom:{}},native:{}}:rn.deepClone(this.props.objects[this.props.objectIDs[0]]||null),this.customObj&&this.loadAllCustoms().then(()=>{this.commonConfig=this.getCommonConfig(),this.setState({loaded:!0,newValues:{}})})}async componentDidMount(){this.state.systemConfig||this.setState({systemConfig:await this.props.socket.getCompactSystemConfig()}),this.props.registerSaveFunc&&this.props.registerSaveFunc(this.onSave)}componentWillUnmount(){this.props.registerSaveFunc&&this.props.registerSaveFunc()}async loadAllCustoms(){const t=[];for(const e of this.props.customsInstances){if(e==="_")continue;const i=e.replace(/\.\d+$/,"").replace("system.adapter.","");this.jsonConfigs[i]===void 0&&(this.jsonConfigs[i]=null,t.push(this.getCustomTemplate(i)))}await Promise.all(t),this.props.customsInstances.forEach(e=>{var n,a;const i=e.replace(/\.\d+$/,"").replace("system.adapter.","");this.jsonConfigs[i]&&(this.jsonConfigs[i].instanceObjs=this.jsonConfigs[i].instanceObjs||{},this.jsonConfigs[i].instanceObjs[e]={_id:e,common:JSON.parse(JSON.stringify((n=this.props.objects[`system.adapter.${e}`])==null?void 0:n.common)),native:JSON.parse(JSON.stringify((a=this.props.objects[`system.adapter.${e}`])==null?void 0:a.native)),type:"instance",instanceObjects:[],objects:[]})})}async getCustomTemplate(t){var i;const e=this.props.objects[`system.adapter.${t}`]?rn.deepClone(this.props.objects[`system.adapter.${t}`]):null;if(!e){console.error(`Cannot find adapter "${t}"`);return}if(rn.fixAdminUI(e),((i=e.common)==null?void 0:i.adminUI.custom)==="json")try{const n=await this.props.socket.fileExists(`${t}.admin`,"jsonCustom.json5");let a,o;n?o=await this.props.socket.readFile(`${t}.admin`,"jsonCustom.json5"):o=await this.props.socket.readFile(`${t}.admin`,"jsonCustom.json"),o.file!==void 0?a=o.file:a=o;let s;try{s=Qx.parse(a),this.jsonConfigs[t]=this.jsonConfigs[t]||{},this.jsonConfigs[t].json=s}catch(l){console.error(`Cannot parse jsonConfig of ${t}: ${l}`),window.alert(`Cannot parse jsonConfig of ${t}: ${l}`)}await gh.loadI18n(this.props.socket,s.i18n,t);return}catch(n){console.error(`Cannot load jsonConfig of ${t}: ${n}`),window.alert(`Cannot load jsonConfig of ${t}: ${n}`)}console.error(`Adapter ${t} is not yet supported by this version of admin`),window.alert(`Adapter ${t} is not yet supported by this version of admin`)}_executeCustom(t,e,i,n,a,o,s){if(s.includes(o))return;s.push(o);let l=[],u;if(t&&typeof t=="object"?(l=t.alsoDependsOn||[],typeof l=="string"&&(l=[l]),u=t.func):u=t,l.forEach(h=>{if(!a[h])console.error(`[JsonConfigComponent] attribute "${h}" does not exist!`);else if(!a[h].defaultFunc)console.error(`[JsonConfigComponent] attribute "${h}" is not required to be includes in "alsoDependsOn" while has static value!`);else{const c=this._executeCustom(a[h].defaultFunc,e,i,n,a,h,s);c!==void 0&&(e[h]=c)}}),!u)e[o]=a[o].default===void 0?null:a[o].default;else try{const h=new Function("data","originalData","_system","instanceObj","customObj","_socket",u.includes("return")?u:`return ${u}`);e[o]=h(e||this.props.data,this.props.originalData,this.props.systemConfig,n,i,this.props.socket)}catch(h){console.error(`Cannot execute ${t}: ${h}`),e[o]=!a[o]||a[o].default===void 0?null:a[o].default}return e[o]}static flattenItems(t,e={}){return t&&Object.keys(t).forEach(i=>{t[i].items?Ls.flattenItems(t[i].items,e):e[i]=t[i]}),e}getDefaultValues(t,e){const i={enabled:!1},n=t.split(".")[0];if(this.jsonConfigs[n]&&!this.jsonConfigs[n].disabled){const a=Ls.flattenItems(this.jsonConfigs[n].json.items);if(a){const o=[],s=Object.keys(a).filter(l=>a[l]);s.forEach(l=>{!a[l].defaultFunc&&a[l].default!==void 0&&(i[l]=a[l].default)}),s.forEach(l=>{a[l].defaultFunc&&this._executeCustom(a[l].defaultFunc,i,e,this.jsonConfigs[n].instanceObjs[t],a,l,o)})}}return i}getCommonConfig(){const t=this.props.objectIDs||[],e=this.props.objects,i={};return this.props.customsInstances.forEach(n=>{const a=n.split(".")[0];this.jsonConfigs[a]&&this.jsonConfigs[a].disabled||(i[n]={},t.forEach(o=>{var u;const s=e[o],l=(u=s==null?void 0:s.common)!=null&&u.custom&&s.common.custom[n]||null;if(l)Object.keys(l).forEach(h=>{h.startsWith("_")||(i[n][h]===void 0?i[n][h]=l[h]:i[n][h]!==l[h]&&(Array.isArray(i[n][h])||(i[n][h]=[i[n][h]]),i[n][h].includes(l[h])||i[n][h].push(l[h])))});else{const h=this.getDefaultValues(n,s);h.enabled=!1,Object.keys(h).forEach(c=>{c.startsWith("_")||(i[n][c]===void 0?i[n][c]=h[c]:i[n][c]!==h[c]&&(Array.isArray(i[n][c])||(i[n][c]=[i[n][c]]),i[n][c].includes(h[c])||i[n][c].push(h[c])))})}}),Object.keys(i[n]).forEach(o=>{Array.isArray(i[n][o])&&i[n][o].sort()}))}),i}isChanged(t){return t=t||this.state.newValues,Object.keys(t).find(e=>t[e]===null||t[e]&&Object.keys(t[e]).find(i=>!i.startsWith("_")))}combineNewAndOld(t,e=!1){const i={...this.commonConfig[t]||{},...this.state.newValues[t]||{}};return e&&Object.keys(i).forEach(n=>{n.startsWith("_")&&delete i[n]}),this.state.newValues[t]===null&&(i.enabled=!1),i}renderOneCustom(t,e,i,n){var f,d;const a=t.split(".")[0],o=`${sw}/adapter/${a}/${this.props.objects[`system.adapter.${a}`].common.icon}`,s=this.state.newValues[t]!==void 0&&(!this.state.newValues[t]||this.state.newValues[t].enabled!==void 0)?!!(this.state.newValues[t]&&this.state.newValues[t].enabled):this.state.newValues[t]===null?!1:this.commonConfig[t].enabled,l=Array.isArray(s)&&(!this.state.newValues[t]||this.state.newValues[t].enabled===void 0),u=(d=(f=this.jsonConfigs[a])==null?void 0:f.json)==null?void 0:d.disabled,h=this.combineNewAndOld(t);if(u&&this.jsonConfigs[a].json.hidden===!0||typeof this.jsonConfigs[a].json.hidden=="string"&&this._executeCustom(this.jsonConfigs[a].json.hidden,h,i,e,this.jsonConfigs[a].json.items,"enabled",[]))return null;let c=null;return u&&this.jsonConfigs[a].json.help&&(typeof this.jsonConfigs[a].json.help=="object"?c=this.jsonConfigs[a].json.help[this.props.lang]||this.jsonConfigs[a].json.help.en:c=this.props.t(this.jsonConfigs[a].json.help)),y.jsxs(w.Accordion,{id:`Accordion_${t}`,style:n%2?Ut.accordionOdd:Ut.accordionEven,expanded:this.state.expanded.includes(t),ref:this.refTemplate[t],onChange:()=>{const p=[...this.state.expanded],v=p.indexOf(t);v===-1?p.push(t):p.splice(v,1),(window._localStorage||window.localStorage).setItem("App.customsExpanded",JSON.stringify(p)),v===-1&&(window._localStorage||window.localStorage).setItem("App.customsLastExpanded",t),this.setState({expanded:p})},children:[y.jsxs(w.AccordionSummary,{expandIcon:y.jsx(X.ExpandMore,{}),"data-id":t,style:n%2?s?Ut.accordionHeaderEnabledOdd:Ut.accordionHeaderOdd:s?Ut.accordionHeaderEnabledEven:Ut.accordionHeaderEven,children:[y.jsx("img",{src:o,style:Ut.headingIcon,alt:""}),y.jsx(w.Typography,{style:Ut.heading,children:this.props.t("Settings %s",t)}),y.jsx("div",{className:"titleEnabled",style:{...Ut.titleEnabled,...s?Ut.enabledVisible:Ut.enabledInvisible},children:this.props.t("Enabled")})]}),y.jsxs(w.AccordionDetails,{children:[y.jsx("div",{style:Ut.enabledControl,children:y.jsx(w.FormControlLabel,{style:Ut.formControl,control:y.jsx(w.Checkbox,{indeterminate:l,checked:!!s,disabled:!!u,onChange:p=>{this.cachedNewValues=this.cachedNewValues||this.state.newValues;const v=rn.deepClone(this.cachedNewValues);v[t]=v[t]||{},l||p.target.checked?v[t].enabled=!0:s&&this.commonConfig[t].enabled?v[t]=null:delete v[t],this.cachedNewValues=v,this.setState({newValues:v,hasChanges:this.isChanged(v)},()=>{this.cachedNewValues=void 0,this.props.onChange&&this.props.onChange(!!this.state.hasChanges)})}}),label:this.props.t("Enabled")})}),y.jsxs("div",{style:Ut.customControls,children:[!u&&(s||l)&&this.state.systemConfig?y.jsx(gh,{instanceObj:e,customObj:i,custom:!0,adapterName:a,instance:parseInt((t==null?void 0:t.split(".").pop())??"0",10)||0,socket:this.props.socket,themeName:this.props.themeName,themeType:this.props.themeType,theme:this.props.theme,multiEdit:this.props.objectIDs.length>1,schema:this.jsonConfigs[a].json,data:h,isFloatComma:this.props.systemConfig.common.isFloatComma,dateFormat:this.props.systemConfig.common.dateFormat,onError:p=>this.setState({error:p},()=>this.props.onError&&this.props.onError(p)),onValueChange:(p,v)=>{var m;this.cachedNewValues=this.cachedNewValues||this.state.newValues,console.log(`${p} => ${v}`);const g=rn.deepClone(this.cachedNewValues);g[t]=g[t]||{},JSON.stringify(Gl.getValue((m=this.commonConfig)==null?void 0:m[t],p))===JSON.stringify(v)?(Gl.setValue(g[t],p,null),Object.keys(g[t]).length||delete g[t]):Gl.setValue(g[t],p,v),this.cachedNewValues=g,this.setState({newValues:g,hasChanges:this.isChanged(g)},()=>{this.cachedNewValues=void 0,this.props.onChange&&this.props.onChange(!!this.state.hasChanges)})}}):null,c]})]})]},t)}renderErrorMessage(){return!!this.state.error&&y.jsx($x,{title:this.props.t("Error"),text:this.state.error?"Error":"",onClose:()=>this.setState({error:!1})})}getObject(t,e,i){return t[i]?Promise.resolve(t[i]):this.props.socket.getObject(i).then(n=>(e[i]=rn.deepClone(n),t[i]=n,n))}saveOneState(t,e,i,n){if(i=i||{},n=n||{},t!=null&&t.length){const a=this.state.maxOids||t.length;this.state.maxOids===null&&this.setState({maxOids:t.length},()=>this.props.onProgress(!0)),this.setState({progress:Math.round((a-t.length)/a*50)});const o=t.shift();this.getObject(i,n,o).then(s=>{var u,h,c;if(!s){window.alert(`Invalid object ${o}`);return}(u=s.common)!=null&&u.custom&&Object.keys(s.common.custom).forEach(f=>{(!s.common.custom[f]||!s.common.custom[f].enabled)&&(s.common.custom[f]=null)});const l=Object.keys(this.state.newValues);for(let f=0;f<l.length;f++){const d=l[f],p=this.combineNewAndOld(d,!0);if(p.enabled===!1)(c=(h=s.common)==null?void 0:h.custom)!=null&&c[d]&&(s.common.custom[d]=null);else if(p.enabled){if(s.common=s.common||{},Array.isArray(p.enabled)&&(!s.common.custom||!s.common.custom[d]||!s.common.custom[d].enabled)){s.common.custom&&s.common.custom[d]&&(s.common.custom[d]=null);continue}if(s.common.custom=s.common.custom||{},!s.common.custom[d]||!s.common.custom[d].enabled){const g=this.getDefaultValues(d,s);s.common.custom[d]=JSON.parse(JSON.stringify(g||{})),Object.keys(s.common.custom[d]).forEach(m=>{m.startsWith("_")&&delete s.common.custom[d][m]})}const v=this.props.objectIDs.length>1;s.common.custom[d].enabled=!0,Object.keys(p).forEach(g=>{if(!g.startsWith("_")){if(Array.isArray(p[g])&&v)return;s.common.custom[d][g]=p[g]}})}}setTimeout(()=>this.saveOneState(t,e,i,n),0)})}else{const a=Object.keys(i);if(!a.length)this.setState({maxOids:0},()=>this.props.onProgress(!1)),e&&e();else{this.setState({progress:Math.round((this.state.maxOids-a.length)/this.state.maxOids*50)+50});const o=a.shift();if(JSON.stringify(i[o].common)!==JSON.stringify(n[o].common)){this.changedIds.includes(o)||this.changedIds.push(o),this.props.socket.setObject(o,i[o]).then(async()=>{delete i[o],delete n[o],this.props.objects[o]=await this.props.socket.getObject(o),setTimeout(()=>this.saveOneState(t,e,i,n),0)});return}delete i[o],delete n[o],setTimeout(()=>this.saveOneState(t,e,i,n),0)}}}renderConfirmationDialog(){return this.state.showConfirmation?y.jsx(mh,{text:this.props.t("The changes will be applied to %s states. Are you sure?",this.props.objectIDs.length.toString()),ok:this.props.t("Yes"),onClose:t=>{t?this.setState({showConfirmation:!1,confirmed:!0},()=>{const e=this.cb;this.cb=void 0,this.onSave(e)}):(this.cb=void 0,this.setState({showConfirmation:!1}))}}):null}onSave=t=>{this.props.objectIDs.length>10&&!this.state.confirmed?(this.cb=t,this.setState({showConfirmation:!0})):this.saveOneState([...this.props.objectIDs],()=>{this.cachedNewValues={},this.commonConfig=this.getCommonConfig(),this.setState({confirmed:!1,hasChanges:void 0,newValues:{}},()=>{this.props.reportChangedIds(this.changedIds),this.props.onChange(!1,!0),t&&setTimeout(()=>t(),100)})})};render(){if(this.customObj===null)return y.jsx("div",{style:{color:"#F55",fontSize:32},children:this.props.t("Object does not exist!")});if(!this.state.loaded)return y.jsx(w.LinearProgress,{});let t=0;return y.jsxs(w.Paper,{style:Ut.paper,children:[this.state.maxOids>1&&y.jsx(w.LinearProgress,{color:"secondary",variant:"determinate",value:this.state.progress}),y.jsx("div",{style:Ut.scrollDiv,ref:this.scrollDivRef,children:this.state.maxOids===0&&Object.values(this.jsonConfigs).map(e=>e?Object.keys(e.instanceObjs).map(i=>this.renderOneCustom(i,e.instanceObjs[i],this.customObj,t++)):null)}),this.renderErrorMessage(),this.renderConfirmationDialog()]})}}const lw=Wn()(Ls),{loadShare:uw}=ew,{initPromise:hw}=tw,cw=hw.then(r=>uw("date-fns/locale",{customShareInfo:{shareConfig:{singleton:!0,strictVersion:!1,requiredVersion:"*"}}})),fw=await cw.then(r=>r());var we=fw;const Os={en:we.enUS,fr:we.fr,ru:we.ru,de:we.de,es:we.es,br:we.ptBR,nl:we.nl,it:we.it,pt:we.pt,pl:we.pl,uk:we.uk,"zh-cn":we.zhCN},rt={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"hidden"},tableDiv:r=>({height:`calc(100% - ${parseInt(r.mixins.toolbar.minHeight,10)+8}px)`,overflow:"hidden",width:"100%"}),container:{height:"100%"},table:r=>({minWidth:960,width:"100%","& td:nth-of-type(5)":{overflow:"hidden",whiteSpace:"nowrap"},"& tr:nth-child(even)":{backgroundColor:r.palette.mode==="dark"?"#383838":"#b2b2b2"}}),row:{userSelect:"none",position:"relative","&:hover":{opacity:.7},"& td":{position:"relative"}},updatedRow:{animation:"updated 1s"},rowInterpolated:{opacity:.5},selectHistoryControl:{width:130},selectRelativeTime:{marginLeft:10,width:200},notAliveInstance:{opacity:.5},customRange:r=>({color:r.palette.primary.main}),rowSelected:r=>({backgroundColor:r.palette.secondary.main,color:r.palette.secondary.contrastText,"& td":{color:r.palette.secondary.contrastText,backgroundColor:r.palette.secondary.main}}),rowFocused:r=>({position:"absolute",pointerEvents:"none",top:0,bottom:0,left:0,right:0,m:"3px",border:`1px dotted ${r.palette.action.active}`}),grow:{flexGrow:1},msInput:{width:50,pt:"10px",ml:"5px","& label":{mt:"15px"}},cellAckTrue:r=>({color:r.palette.mode==="dark"?"#66ff7f":"#04a821"}),cellAckFalse:{color:"#FF6666"},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"}},toolbarTimeGrid:{position:"relative",marginLeft:8,paddingLeft:8,paddingRight:8,paddingTop:4,paddingBottom:4,border:"1px dotted #AAAAAA",borderRadius:8,display:"flex"},toolbarTimeLabel:{position:"absolute",padding:8,fontSize:"0.8rem",left:2,top:-9},noLoadingProgress:{width:"100%",height:4},colValue:{},colAck:{},colFrom:{},colLastChange:{},colTs:{}};class Es extends at.Component{adminInstance;supportedFeaturesPromises;unit;timeTimer;readSupportedFeaturesTimeout;rangeValues;rangeRef;subscribes;localStorage;constructor(t){super(t),this.localStorage=window._localStorage||window.localStorage;let e=this.localStorage.getItem("App.relativeRange")||"absolute";const i=parseInt(this.localStorage.getItem("App.absoluteStart"),10)||0,n=parseInt(this.localStorage.getItem("App.absoluteEnd"),10)||0,a=this.localStorage.getItem("App.historySelected")||"",o=parseInt(this.localStorage.getItem("App.historyLastSelected"),10)||null,s=this.localStorage.getItem("App.historyLastSelectedColumn")||null;(!i||!n)&&(!e||e==="absolute")&&(e="30"),i&&n&&(e="absolute");let l;try{l=JSON.parse(a)}catch{l=[]}this.state={start:i,end:n,values:null,relativeRange:e,selected:l,lastSelected:o,lastSelectedColumn:s,historyInstance:"",updateOpened:!1,insertOpened:!1,historyInstances:null,lcVisible:!0,ackVisible:!0,fromVisible:!0,supportedFeatures:[],ampm:!1,edit:{}},this.adminInstance=parseInt(window.location.search.slice(1),10)||0,this.supportedFeaturesPromises={},this.unit=this.props.obj.common&&this.props.obj.common.unit?` ${this.props.obj.common.unit}`:"",this.timeTimer=void 0,this.subscribes=[],this.prepareData().then(()=>this.readHistoryRange()).then(()=>{e!=="absolute"?this.setRelativeInterval(this.state.relativeRange,!0):this.readHistory()})}readSupportedFeatures(t){return t=t||this.state.historyInstance,t?this.supportedFeaturesPromises[t]instanceof Promise?this.supportedFeaturesPromises[t]:(this.supportedFeaturesPromises[t]=new Promise(e=>{this.readSupportedFeaturesTimeout&&clearTimeout(this.readSupportedFeaturesTimeout),this.readSupportedFeaturesTimeout=setTimeout(()=>{this.readSupportedFeaturesTimeout=void 0,e([])},2e3),this.props.socket.sendTo(t,"features",null).then(i=>{this.readSupportedFeaturesTimeout?(clearTimeout(this.readSupportedFeaturesTimeout),this.readSupportedFeaturesTimeout=void 0,e(i?i.supportedFeatures||[]:[])):this.setState({supportedFeatures:i?i.supportedFeatures||[]:[]})})}),this.supportedFeaturesPromises[t]):Promise.resolve([])}async componentDidMount(){await this.props.socket.subscribeState(this.props.obj._id,this.onChange)}componentWillUnmount(){this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=void 0);for(let t=0;t<this.subscribes.length;t++)this.props.socket.unsubscribeState(this.subscribes[t],this.onChange);this.subscribes=[],this.props.socket.unsubscribeState(this.props.obj._id,this.onChange)}onChange=(t,e)=>{if(t===this.props.obj._id&&e&&this.state.values&&(!this.state.values.length||this.state.values[this.state.values.length-1].ts<e.ts)){const i=[...this.state.values,e];this.setState({values:i})}else if(t.startsWith("system.adapter.")&&t.endsWith(".alive")){const i=t.substring(15,t.length-6),n=this.state.historyInstances,a=n.findIndex(o=>o.id===i);if(a!==-1&&n[a].alive!==!!(e!=null&&e.val)){const o=JSON.parse(JSON.stringify(n));o[a].alive=!!(e!=null&&e.val),this.setState({historyInstances:o},()=>{o[a].alive&&this.state.historyInstance===i&&this.readHistoryRange().then(()=>this.readHistory())})}}};async prepareData(){var o;const t=await this.getHistoryInstances(),e=await this.props.socket.getCompactSystemConfig(),i=(o=e==null?void 0:e.common)==null?void 0:o.defaultHistory;let n=this.localStorage.getItem("App.historyInstance")||"";if((!n||!t.find(s=>s.id===n&&s.alive))&&(n=i),!n||!t.find(s=>s.id===n&&s.alive)){const s=t.find(l=>l.alive);s&&(n=s.id)}!n&&t.length&&(n=i);const a=await this.readSupportedFeatures(n);await new Promise(s=>{this.setState({ampm:(e.common.dateFormat||"").includes("/"),historyInstances:t,historyInstance:n,supportedFeatures:a},()=>s())})}getHistoryInstances(){const t=[],e=[];return this.props.customsInstances.forEach(i=>{const n=this.props.objects[`system.adapter.${i}`];if(n&&n.common&&n.common.getHistory){const a={id:i,alive:!1};t.push(a),e.push(`system.adapter.${i}.alive`)}}),e.length?this.props.socket.getForeignStates(e).then(async i=>{Object.keys(i).forEach(n=>{var o;const a=t.find(s=>n.endsWith(`${s.id}.alive`));a&&(a.alive=!!((o=i[n])!=null&&o.val))}),this.subscribes=e;for(let n=0;n<e.length;n++)await this.props.socket.subscribeState(e[n],this.onChange);return t}):Promise.resolve(t)}readHistory(t,e){var i;return t=t||this.state.start,e=e||this.state.end,!this.state.historyInstance||!((i=this.state.historyInstances)!=null&&i.find(n=>n.id===this.state.historyInstance&&n.alive))?null:(this.setState({loading:!0}),this.props.socket.getHistory(this.props.obj._id,{instance:this.state.historyInstance,start:t,end:e,from:!0,ack:!0,q:!0,addId:!1,aggregate:"none",returnNewestEntries:!0}).then(n=>{const a=[],o=this.rangeValues;let s=!1,l=!1,u=!1;if(o&&o.length&&(!n||!n.length||o[0].ts<n[0].ts)&&(a.push(o[0]),a.push({ts:o[0].ts+1,e:!0}),console.log(`add ${new Date(o[0].ts).toISOString()}: ${o[0].val}`),!l&&o[0].ack!==void 0&&(l=!0),!u&&o[0].from&&(u=!0)),n!=null&&n.length)for(let h=0;h<n.length;h++)n[h]&&(!a.length||a[a.length-1].ts<n[h].ts)?(a.push(n[h]),n[h].from&&(n[h].from.startsWith("system.adapter.")?n[h].from=n[h].from.substring(15):n[h].from.startsWith("system.host.")&&(n[h].from=n[h].from.substring(7))),!s&&n[h].lc&&(s=!0),!l&&n[h].ack!==void 0&&(l=!0),!u&&n[h].from&&(u=!0),console.log(`add value ${new Date(n[h].ts).toISOString()}: ${n[h].val}`)):a[a.length-1].ts===n[h].ts&&a[a.length-1].val!==n[h].ts&&console.error("Strange data!");else a.push({noDataForPeriod:!0});a.length||a.push({noData:!0}),this.setState({loading:!1,values:a,lcVisible:s,fromVisible:u,ackVisible:l})}))}readHistoryRange(){var i;const t=new Date,e=new Date(2e3,0,1);return!this.state.historyInstance||!((i=this.state.historyInstances)!=null&&i.find(n=>n.id===this.state.historyInstance&&n.alive))?Promise.resolve():(this.setState({loading:!0}),this.props.socket.getHistory(this.props.obj._id,{instance:this.state.historyInstance,start:e.getTime(),end:t.getTime(),limit:1,from:!1,ack:!1,q:!1,addId:!1,aggregate:"none"}).then(n=>{n.length?((n[0].val===null||n[0].ts===e.getTime())&&n.shift(),n.forEach(a=>a.i=!0),this.rangeValues=n,this.setState({loading:!1})):(this.rangeValues=[],this.setState({loading:!1}))}))}onToggleSelect(t,e,i){let n=[...this.state.selected];const a=n.indexOf(e);if(t.shiftKey&&this.state.lastSelected){let o=-1,s=-1;n=[];for(let l=0;l<this.state.values.length&&!(this.state.values[l].ts===e&&(o=l,s!==o&&n.push(this.state.values[l].ts),o!==-1&&s!==-1)||this.state.values[l].ts===this.state.lastSelected&&(s=l,s!==o&&n.push(this.state.values[l].ts),o!==-1&&s!==-1));l++)(o!==-1||s!==-1)&&n.push(this.state.values[l].ts)}else t.ctrlKey?(a!==-1?n.splice(a,1):n.push(e),n.sort()):n=[e];this.localStorage.setItem("App.historyLastSelected",e.toString()),this.localStorage.setItem("App.historyLastSelectedColumn",i),this.localStorage.setItem("App.historySelected",JSON.stringify(n)),this.setState({selected:n,lastSelected:e,lastSelectedColumn:i})}getTableRows(){const t=[];for(let e=this.state.values.length-1;e>=0;e--){const i=this.state.values[e],n=i.ts;if(i.e)t.push(y.jsxs(w.TableRow,{sx:{...rt.row,...rt.updatedRow,...rt.rowInterpolated},hover:!0,children:[y.jsx(w.TableCell,{}),y.jsx(w.TableCell,{children:"..."}),this.state.ackVisible?y.jsx(w.TableCell,{}):null,this.state.fromVisible?y.jsx(w.TableCell,{}):null,this.state.lcVisible?y.jsx(w.TableCell,{}):null]},n));else if(i.noData||i.noDataForPeriod)t.push(y.jsxs(w.TableRow,{sx:{...rt.row,...rt.updatedRow,...rt.rowNoData},hover:!0,children:[y.jsx(w.TableCell,{}),y.jsx(w.TableCell,{children:i.noData?this.props.t("No data in history"):this.props.t("No data in history for selected period")}),this.state.ackVisible?y.jsx(w.TableCell,{}):null,this.state.fromVisible?y.jsx(w.TableCell,{}):null,this.state.lcVisible?y.jsx(w.TableCell,{}):null]},i.noData?"nodata":""));else{const a=i.i,o=this.state.lastSelected===n;let s=i.val;this.props.isFloatComma&&this.props.obj.common.type==="number"&&s&&(s=s.toString().replace(".",",")),s===null&&(s="null"),s===void 0&&(s="_");const l=this.state.selected.includes(n);t.push(y.jsxs(w.TableRow,{sx:{...rt.row,...rt.updatedRow,...a?rt.rowInterpolated:void 0,...l?rt.rowSelected:void 0},children:[y.jsxs(w.TableCell,{onClick:u=>!a&&this.onToggleSelect(u,n,"ts"),children:[`${Es.formatTimestamp(i.ts)}`,o&&this.state.lastSelectedColumn==="ts"?y.jsx(w.Box,{component:"div",sx:rt.rowFocused}):""]}),y.jsxs(w.TableCell,{onClick:u=>!a&&this.onToggleSelect(u,n,"val"),children:[s+this.unit,o&&this.state.lastSelectedColumn==="val"?y.jsx(w.Box,{component:"div",sx:rt.rowFocused}):""]}),this.state.ackVisible?y.jsxs(w.TableCell,{onClick:u=>!a&&this.onToggleSelect(u,n,"ack"),sx:i.ack?rt.cellAckTrue:rt.cellAckFalse,children:[i.ack?"true":"false",o&&this.state.lastSelectedColumn==="ack"?y.jsx(w.Box,{component:"div",sx:rt.rowFocused}):""]}):null,this.state.fromVisible?y.jsxs(w.TableCell,{onClick:u=>!a&&this.onToggleSelect(u,n,"from"),children:[i.from||"",o&&this.state.lastSelectedColumn==="from"?y.jsx(w.Box,{component:"div",sx:rt.rowFocused}):""]}):null,this.state.lcVisible?y.jsxs(w.TableCell,{onClick:u=>!a&&this.onToggleSelect(u,n,"lc"),children:[i.lc?`${new Date(i.lc).toLocaleDateString()} ${new Date(i.lc).toLocaleTimeString()}.${(i.ts%1e3).toString().padStart(3,"0")}`:"",o&&this.state.lastSelectedColumn==="lc"?y.jsx(w.Box,{component:"div",sx:rt.rowFocused}):""]}):null]},n.toString()+(i.val||"").toString()))}}return t}shiftTime(){const t=new Date,e=6e4-t.getSeconds()-(1e3-t.getMilliseconds());t.getMilliseconds()&&t.setMilliseconds(1e3),t.getSeconds()&&t.setSeconds(60);const i=t.getTime();let n;const a=this.state.relativeRange;if(a==="day")t.setHours(0),t.setMinutes(0),t.setSeconds(0),n=t.getTime();else if(a==="week"){t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0);const o=t.getDay()||7;o!==1&&t.setHours(-24*(o-1)),n=t.getTime()}else if(a==="2weeks"){t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setDate(t.getDate()-7);const o=t.getDay()||7;o!==1&&t.setHours(-24*(o-1)),n=t.getTime()}else a==="month"?(t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setDate(1),n=t.getTime()):a==="year"?(t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setDate(1),t.setMonth(0),n=t.getTime()):a==="12months"?(t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setFullYear(t.getFullYear()-1),n=t.getTime()):n=i-parseInt(a,10)*6e4;this.setState({start:n,end:i},()=>this.readHistory()),this.timeTimer=setTimeout(()=>{this.timeTimer=void 0,this.shiftTime()},e||6e4)}setRelativeInterval(t,e){if(e||(this.localStorage.setItem("App.relativeRange",t.toString()),this.setState({relativeRange:t})),t==="absolute"){this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=void 0);return}this.localStorage.removeItem("App.absoluteStart"),this.localStorage.removeItem("App.absolute");const i=new Date;if(!this.timeTimer){const o=6e4-i.getSeconds()-(1e3-i.getMilliseconds());this.timeTimer=setTimeout(()=>{this.timeTimer=void 0,this.shiftTime()},o||6e4)}i.getMilliseconds()&&i.setMilliseconds(1e3),i.getSeconds()&&i.setSeconds(60);const n=i.getTime();let a;if(t==="day")i.setHours(0),i.setMinutes(0),i.setSeconds(0),a=i.getTime();else if(t==="week"){i.setHours(0),i.setMinutes(0),i.setSeconds(0);const o=i.getDay()||7;o!==1&&i.setHours(-24*(o-1)),a=i.getTime()}else if(t==="2weeks"){i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setDate(i.getDate()-7);const o=i.getDay()||7;o!==1&&i.setHours(-24*(o-1)),a=i.getTime()}else t==="month"?(i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setDate(1),a=i.getTime()):t==="year"?(i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setDate(1),i.setMonth(0),a=i.getTime()):t==="12months"?(i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setFullYear(i.getFullYear()-1),a=i.getTime()):(t=Number(t),a=n-t*6e4);this.setState({start:a,end:n},()=>this.readHistory())}renderTable(){var t;if(!this.state.historyInstance)return y.jsx("div",{style:{marginTop:20,fontSize:24},children:this.props.t("History instance not selected")});if(!((t=this.state.historyInstances)!=null&&t.find(e=>e.id===this.state.historyInstance&&e.alive)))return y.jsx("div",{style:{marginTop:20,fontSize:24},children:this.props.t("History instance not alive")});if(this.state.values){const e=[200,"auto"],i=[190,100];return this.state.ackVisible&&(e.push(50),i.push(50)),this.state.fromVisible&&(e.push(150),i.push(150)),this.state.lcVisible&&(e.push(200),i.push(190)),y.jsx(w.TableContainer,{style:rt.container,children:y.jsxs(Yx,{stickyHeader:!0,sx:rt.table,initialWidths:e,minWidths:i,dblTitle:this.props.t("ra_Double click to reset table layout"),children:[y.jsx(w.TableHead,{children:y.jsxs(w.TableRow,{children:[y.jsx(w.TableCell,{style:rt.colTs,children:this.props.t("Timestamp")}),y.jsx(w.TableCell,{style:rt.colValue,children:this.props.t("Value")}),this.state.ackVisible?y.jsx(w.TableCell,{style:rt.colAck,children:this.props.t("Ack")}):null,this.state.fromVisible?y.jsx(w.TableCell,{style:rt.colFrom,children:this.props.t("From")}):null,this.state.lcVisible?y.jsx(w.TableCell,{style:rt.colLastChange,children:this.props.t("lc")}):null]})}),y.jsx(w.TableBody,{children:this.getTableRows()})]})})}return y.jsx(w.LinearProgress,{})}renderDialogConfirm(){return y.jsxs(w.Dialog,{open:!!this.state.areYouSure,onClose:()=>this.setState({areYouSure:!1}),"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[y.jsx(w.DialogTitle,{id:"alert-dialog-title"}),y.jsxs(w.DialogContent,{children:[y.jsx(w.DialogContentText,{id:"alert-dialog-description",children:this.props.t("Are you sure?")}),y.jsx(w.FormControlLabel,{control:y.jsx(w.Checkbox,{value:this.state.suppressMessage,onChange:()=>this.setState({suppressMessage:!0})}),label:this.props.t("Suppress for 5 minutes")})]}),y.jsxs(w.DialogActions,{children:[y.jsx(w.Button,{variant:"contained",onClick:()=>this.setState({areYouSure:!1,suppressMessage:this.state.suppressMessage&&Date.now()},()=>this.onDelete()),color:"primary",autoFocus:!0,startIcon:y.jsx(X.Delete,{}),children:this.props.t("Delete")}),y.jsx(w.Button,{variant:"contained",onClick:()=>this.setState({areYouSure:!1}),color:"secondary",startIcon:y.jsx(X.Close,{}),children:this.props.t("Cancel")})]})]})}onDelete(){const t=this.state.selected.map(e=>({state:{ts:e},id:this.props.obj._id}));this.props.socket.sendTo(this.state.historyInstance,"delete",t).then(()=>this.readHistory())}onUpdate(){let t=this.state.edit.val;this.props.obj.common&&(this.props.obj.common.type==="number"?typeof t!="number"&&(t=parseFloat(t.toString().replace(",","."))):this.props.obj.common.type==="boolean"&&(t=t==="true"||t==="TRUE"||t===!0||t==="1"||t===1));const e={val:t,ack:this.state.edit.ack,ts:this.state.selected[0],from:`system.adapter.admin.${this.adminInstance}`,q:this.state.edit.q};for(const[i,n]of Object.entries(e))n===void 0&&delete e[i];!this.state.lcVisible&&e.lc&&delete e.lc,this.props.socket.sendTo(this.state.historyInstance,"update",[{id:this.props.obj._id,state:e}]).then(()=>this.readHistory())}onInsert(){let t=this.state.edit.val;this.props.obj.common&&(this.props.obj.common.type==="number"?t=parseFloat(t.toString().replace(",",".")):this.props.obj.common.type==="boolean"&&(t=t==="true"||t==="TRUE"||t===!0||t==="1"||t===1));const e=this.state.edit.date;e.setHours(this.state.edit.time.getHours()),e.setMinutes(this.state.edit.time.getMinutes()),e.setSeconds(this.state.edit.time.getSeconds()),e.setMilliseconds(parseInt(this.state.edit.ms,10));const i={ts:e.getTime(),val:t,ack:this.state.edit.ack,from:`system.adapter.admin.${this.adminInstance}`,q:this.state.edit.q||0};!this.state.lcVisible&&i.lc&&delete i.lc;for(const[n,a]of Object.entries(i))a===void 0&&delete i[n];this.props.socket.sendTo(this.state.historyInstance,"insert",[{id:this.props.obj._id,state:i}]).then(()=>this.readHistory())}updateEdit(t,e){const i=JSON.parse(JSON.stringify(this.state.edit));i.time=new Date(i.time),i.date=new Date(i.date),i[t]=e,this.setState({edit:i})}renderEditDialog(){return y.jsxs(w.Dialog,{open:this.state.updateOpened||this.state.insertOpened,onClose:()=>this.setState({updateOpened:!1,insertOpened:!1}),"aria-labelledby":"edit-dialog-title","aria-describedby":"edit-dialog-description",children:[y.jsx(w.DialogTitle,{id:"edit-dialog-title",children:this.state.updateOpened?this.props.t("Update entry"):this.props.t("Insert entry")}),y.jsx(w.DialogContent,{children:y.jsxs("form",{noValidate:!0,autoComplete:"off",children:[typeof this.state.edit.val=="boolean"?y.jsx(w.FormControlLabel,{control:y.jsx(w.Checkbox,{checked:this.state.edit.val,onChange:t=>this.updateEdit("val",t.target.checked)}),label:this.props.t("Value")}):y.jsx(w.TextField,{variant:"standard",label:this.props.t("Value"),value:this.state.edit.val,onChange:t=>this.updateEdit("val",t.target.value)}),y.jsx("br",{}),y.jsx(w.FormControlLabel,{control:y.jsx(w.Checkbox,{checked:this.state.edit.ack,onChange:t=>this.updateEdit("ack",t.target.checked)}),label:this.props.t("Acknowledged")}),this.state.insertOpened?y.jsx(qt.LocalizationProvider,{dateAdapter:ks,adapterLocale:Os[this.props.lang],children:y.jsxs("div",{style:rt.toolbarTimeGrid,children:[y.jsx("div",{style:rt.toolbarTimeLabel,children:this.props.t("Time")}),y.jsx(qt.DatePicker,{sx:rt.toolbarDate,value:this.state.edit.date,onChange:t=>this.updateEdit("date",t)}),y.jsx(qt.TimePicker,{sx:rt.toolbarTime,ampm:this.state.ampm,views:["hours","minutes","seconds"],value:this.state.edit.time,onChange:t=>this.updateEdit("time",t)}),y.jsx(w.TextField,{variant:"standard",sx:rt.msInput,helperText:this.props.t("ms"),type:"number",slotProps:{htmlInput:{max:999,min:0}},value:this.state.edit.ms,onChange:t=>this.updateEdit("ms",t.target.value)})]})}):null]})}),y.jsxs(w.DialogActions,{children:[y.jsx(w.Button,{variant:"contained",disabled:this.state.edit.val==="",onClick:()=>{const t=this.state.updateOpened;this.setState({updateOpened:!1,insertOpened:!1},()=>t?this.onUpdate():this.onInsert())},color:"primary",autoFocus:!0,children:this.state.updateOpened?this.props.t("Update"):this.props.t("Add")}),y.jsx(w.Button,{variant:"contained",onClick:()=>this.setState({updateOpened:!1,insertOpened:!1}),color:"grey",children:this.props.t("Cancel")})]})]})}setStartDate(t){const e=t.getTime();this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=void 0),this.localStorage.setItem("App.relativeRange","absolute"),this.localStorage.setItem("App.absoluteStart",e.toString()),this.localStorage.setItem("App.absoluteEnd",this.state.end.toString()),this.setState({start:e,relativeRange:"absolute"},()=>this.readHistory())}setEndDate(t){const e=t.getTime();this.localStorage.setItem("App.relativeRange","absolute"),this.localStorage.setItem("App.absoluteStart",this.state.start.toString()),this.localStorage.setItem("App.absoluteEnd",e.toString()),this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=void 0),this.setState({end:e,relativeRange:"absolute"},()=>this.readHistory())}renderToolbar(){var t,e;return y.jsxs(w.Toolbar,{children:[y.jsxs(w.FormControl,{variant:"standard",style:rt.selectHistoryControl,children:[y.jsx(w.InputLabel,{children:this.props.t("History instance")}),y.jsx(w.Select,{variant:"standard",value:this.state.historyInstance||"",onChange:i=>{const n=i.target.value;this.localStorage.setItem("App.historyInstance",n),this.readSupportedFeatures(n).then(a=>this.setState({historyInstance:n,supportedFeatures:a},()=>this.readHistory()))},children:(t=this.state.historyInstances)==null?void 0:t.map(i=>y.jsx(w.MenuItem,{value:i.id,style:i.alive?void 0:rt.notAliveInstance,children:i.id},i.id))})]}),y.jsxs(w.FormControl,{variant:"standard",style:rt.selectRelativeTime,children:[y.jsx(w.InputLabel,{children:this.props.t("Relative")}),y.jsxs(w.Select,{variant:"standard",ref:this.rangeRef,value:this.state.relativeRange,onChange:i=>this.setRelativeInterval(i.target.value),children:[y.jsx(w.MenuItem,{value:"absolute",sx:rt.customRange,children:this.props.t("custom range")},"custom"),y.jsx(w.MenuItem,{value:10,children:this.props.t("last 10 minutes")},"1"),y.jsx(w.MenuItem,{value:30,children:this.props.t("last 30 minutes")},"2"),y.jsx(w.MenuItem,{value:60,children:this.props.t("last hour")},"3"),y.jsx(w.MenuItem,{value:"day",children:this.props.t("this day")},"4"),y.jsx(w.MenuItem,{value:24*60,children:this.props.t("last 24 hours")},"5"),y.jsx(w.MenuItem,{value:"week",children:this.props.t("this week")},"6"),y.jsx(w.MenuItem,{value:24*60*7,children:this.props.t("last week")},"7"),y.jsx(w.MenuItem,{value:"2weeks",children:this.props.t("this 2 weeks")},"8"),y.jsx(w.MenuItem,{value:24*60*14,children:this.props.t("last 2 weeks")},"9"),y.jsx(w.MenuItem,{value:"month",children:this.props.t("this month")},"10"),y.jsx(w.MenuItem,{value:30*24*60,children:this.props.t("last 30 days")},"11"),y.jsx(w.MenuItem,{value:"year",children:this.props.t("this year")},"12"),y.jsx(w.MenuItem,{value:"12months",children:this.props.t("last 12 months")},"13")]})]}),y.jsxs(qt.LocalizationProvider,{dateAdapter:ks,adapterLocale:Os[this.props.lang],children:[y.jsxs("div",{style:rt.toolbarTimeGrid,children:[y.jsx("div",{style:{...rt.toolbarTimeLabel,opacity:this.state.relativeRange!=="absolute"?.5:void 0},children:this.props.t("Start time")}),y.jsx(qt.DatePicker,{sx:rt.toolbarDate,disabled:this.state.relativeRange!=="absolute",value:new Date(this.state.start),onChange:i=>this.setStartDate(i)}),y.jsx(qt.TimePicker,{disabled:this.state.relativeRange!=="absolute",sx:rt.toolbarTime,ampm:this.state.ampm,value:new Date(this.state.start),onChange:i=>this.setStartDate(i)})]}),y.jsxs("div",{style:rt.toolbarTimeGrid,children:[y.jsx("div",{style:{...rt.toolbarTimeLabel,opacity:this.state.relativeRange!=="absolute"?.5:void 0},children:this.props.t("End time")}),y.jsx(qt.DatePicker,{disabled:this.state.relativeRange!=="absolute",sx:rt.toolbarDate,value:new Date(this.state.end),onChange:i=>this.setEndDate(i)}),y.jsx(qt.TimePicker,{disabled:this.state.relativeRange!=="absolute",sx:rt.toolbarTime,ampm:this.state.ampm,value:new Date(this.state.end),onChange:i=>this.setEndDate(i)})]})]}),y.jsx(w.Box,{component:"div",sx:rt.grow}),(e=this.state.values)!=null&&e.length?y.jsx(w.IconButton,{size:"large",onClick:()=>this.exportData(),title:this.props.t("Save data as csv"),children:y.jsx(rw,{})}):null,this.state.supportedFeatures.includes("insert")&&this.props.expertMode?y.jsx(w.IconButton,{size:"large",onClick:()=>{const i=new Date,n={ack:this.state.values[this.state.values.length-1].ack,val:this.state.values[this.state.values.length-1].val,date:new Date(i),ms:0,time:new Date(i),q:0};this.setState({edit:n,insertOpened:!0})},children:y.jsx(iw,{})}):null,this.state.supportedFeatures.includes("update")&&this.props.expertMode?y.jsx(w.IconButton,{size:"large",disabled:this.state.selected.length!==1,onClick:()=>{const i=JSON.parse(JSON.stringify(this.state.values.find(a=>a.ts===this.state.lastSelected))),n=new Date(i.ts);i.date=new Date(n),i.time=new Date(n),this.setState({edit:i,updateOpened:!0})},children:y.jsx(X.Edit,{})}):null,this.state.supportedFeatures.includes("delete")&&this.props.expertMode?y.jsx(w.IconButton,{size:"large",disabled:!this.state.selected.length,onClick:()=>{typeof this.state.suppressMessage=="number"&&Date.now()-this.state.suppressMessage<3e5?this.onDelete():this.setState({areYouSure:!0})},children:y.jsx(X.Delete,{})}):null]})}exportData(){let t=window.document.getElementById("export-file");t||(t=document.createElement("a"),t.setAttribute("id","export-file"),t.style.display="none",document.body.appendChild(t));const e=["timestamp;value;acknowledged;from;"];this.state.values.forEach(i=>!i.i&&!i.e&&e.push([Es.formatTimestamp(i.ts),i.val===null||i.val===void 0?"null":i.val.toString(),i.ack?"true":"false",i.from||""].join(";"))),t.setAttribute("href",`data:text/plain;charset=utf-8,${encodeURIComponent(e.join(`
2
2
  `))}`),t.setAttribute("download",`${jt.getObjectName({[this.props.obj._id]:this.props.obj},this.props.obj._id,this.props.lang)}.csv`),t.click(),document.body.removeChild(t)}render(){return this.state.historyInstances?y.jsxs(w.Paper,{style:rt.paper,children:[this.state.loading?y.jsx(w.LinearProgress,{}):y.jsx("div",{style:rt.noLoadingProgress}),this.renderToolbar(),y.jsx(w.Box,{component:"div",sx:rt.tableDiv,children:this.renderTable()}),this.renderDialogConfirm(),this.renderEditDialog()]}):y.jsx(w.LinearProgress,{})}static formatTimestamp(t){return`${new Date(t).toLocaleDateString()} ${new Date(t).toLocaleTimeString()}.${(t%1e3).toString().padStart(3,"0")}`}}const dw=Wn()(Es);var ry={};/*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -12,7 +12,7 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
12
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */var _h=function(r,t){return _h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])},_h(r,t)};function F(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");_h(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var bh=function(){return bh=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++){e=arguments[i];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},bh.apply(this,arguments)};function pw(r,t){var e={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(r,i[n])&&(e[i[n]]=r[i[n]]);return e}function vw(r,t,e,i){var n=arguments.length,a=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,t,e,i);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(n<3?o(a):n>3?o(t,e,a):o(t,e))||a);return n>3&&a&&Object.defineProperty(t,e,a),a}function gw(r,t){return function(e,i){t(e,i,r)}}function mw(r,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,t)}function yw(r,t,e,i){function n(a){return a instanceof e?a:new e(function(o){o(a)})}return new(e||(e=Promise))(function(a,o){function s(h){try{u(i.next(h))}catch(c){o(c)}}function l(h){try{u(i.throw(h))}catch(c){o(c)}}function u(h){h.done?a(h.value):n(h.value).then(s,l)}u((i=i.apply(r,t||[])).next())})}function _w(r,t){var e={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,n,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(u){return function(h){return l([u,h])}}function l(u){if(i)throw new TypeError("Generator is already executing.");for(;e;)try{if(i=1,n&&(a=u[0]&2?n.return:u[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,u[1])).done)return a;switch(n=0,a&&(u=[u[0]&2,a.value]),u[0]){case 0:case 1:a=u;break;case 4:return e.label++,{value:u[1],done:!1};case 5:e.label++,n=u[1],u=[0];continue;case 7:u=e.ops.pop(),e.trys.pop();continue;default:if(a=e.trys,!(a=a.length>0&&a[a.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!a||u[1]>a[0]&&u[1]<a[3])){e.label=u[1];break}if(u[0]===6&&e.label<a[1]){e.label=a[1],a=u;break}if(a&&e.label<a[2]){e.label=a[2],e.ops.push(u);break}a[2]&&e.ops.pop(),e.trys.pop();continue}u=t.call(r,e)}catch(h){u=[6,h],n=0}finally{i=a=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}var Oc=Object.create?function(r,t,e,i){i===void 0&&(i=e),Object.defineProperty(r,i,{enumerable:!0,get:function(){return t[e]}})}:function(r,t,e,i){i===void 0&&(i=e),r[i]=t[e]};function bw(r,t){for(var e in r)e!=="default"&&!Object.prototype.hasOwnProperty.call(t,e)&&Oc(t,r,e)}function xh(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],i=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function iy(r,t){var e=typeof Symbol=="function"&&r[Symbol.iterator];if(!e)return r;var i=e.call(r),n,a=[],o;try{for(;(t===void 0||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(s){o={error:s}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return a}function xw(){for(var r=[],t=0;t<arguments.length;t++)r=r.concat(iy(arguments[t]));return r}function ww(){for(var r=0,t=0,e=arguments.length;t<e;t++)r+=arguments[t].length;for(var i=Array(r),n=0,t=0;t<e;t++)for(var a=arguments[t],o=0,s=a.length;o<s;o++,n++)i[n]=a[o];return i}function Sw(r,t,e){if(e||arguments.length===2)for(var i=0,n=t.length,a;i<n;i++)(a||!(i in t))&&(a||(a=Array.prototype.slice.call(t,0,i)),a[i]=t[i]);return r.concat(a||t)}function Xa(r){return this instanceof Xa?(this.v=r,this):new Xa(r)}function Cw(r,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=e.apply(r,t||[]),n,a=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(f){i[f]&&(n[f]=function(d){return new Promise(function(p,v){a.push([f,d,p,v])>1||s(f,d)})})}function s(f,d){try{l(i[f](d))}catch(p){c(a[0][3],p)}}function l(f){f.value instanceof Xa?Promise.resolve(f.value.v).then(u,h):c(a[0][2],f)}function u(f){s("next",f)}function h(f){s("throw",f)}function c(f,d){f(d),a.shift(),a.length&&s(a[0][0],a[0][1])}}function Tw(r){var t,e;return t={},i("next"),i("throw",function(n){throw n}),i("return"),t[Symbol.iterator]=function(){return this},t;function i(n,a){t[n]=r[n]?function(o){return(e=!e)?{value:Xa(r[n](o)),done:n==="return"}:a?a(o):o}:a}}function Aw(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=r[Symbol.asyncIterator],e;return t?t.call(r):(r=typeof xh=="function"?xh(r):r[Symbol.iterator](),e={},i("next"),i("throw"),i("return"),e[Symbol.asyncIterator]=function(){return this},e);function i(a){e[a]=r[a]&&function(o){return new Promise(function(s,l){o=r[a](o),n(s,l,o.done,o.value)})}}function n(a,o,s,l){Promise.resolve(l).then(function(u){a({value:u,done:s})},o)}}function Mw(r,t){return Object.defineProperty?Object.defineProperty(r,"raw",{value:t}):r.raw=t,r}var Dw=Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t};function Iw(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var e in r)e!=="default"&&Object.prototype.hasOwnProperty.call(r,e)&&Oc(t,r,e);return Dw(t,r),t}function Pw(r){return r&&r.__esModule?r:{default:r}}function kw(r,t,e,i){if(e==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?i:e==="a"?i.call(r):i?i.value:t.get(r)}function Rw(r,t,e,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(r,e):n?n.value=e:t.set(r,e),e}const Lw=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return bh},__asyncDelegator:Tw,__asyncGenerator:Cw,__asyncValues:Aw,__await:Xa,__awaiter:yw,__classPrivateFieldGet:kw,__classPrivateFieldSet:Rw,__createBinding:Oc,__decorate:vw,__exportStar:bw,__extends:F,__generator:_w,__importDefault:Pw,__importStar:Iw,__makeTemplateObject:Mw,__metadata:mw,__param:gw,__read:iy,__rest:pw,__spread:xw,__spreadArray:Sw,__spreadArrays:ww,__values:xh},Symbol.toStringTag,{value:"Module"})),ny=aw(Lw);var fr={},dr={},$l={},Dd;function Ow(){return Dd||(Dd=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var t=1,e=function(){return"".concat(t++)};r.default=e}($l)),$l}var Kn={},Jn={},Yl={},Id;function ay(){return Id||(Id=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var t=function(i){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:60,a=null;return function(){for(var o=this,s=arguments.length,l=new Array(s),u=0;u<s;u++)l[u]=arguments[u];clearTimeout(a),a=setTimeout(function(){i.apply(o,l)},n)}};r.default=t}(Yl)),Yl}var pr={},Pd;function Ec(){if(Pd)return pr;Pd=1,Object.defineProperty(pr,"__esModule",{value:!0}),pr.SizeSensorId=pr.SensorTabIndex=pr.SensorClassName=void 0;var r="size-sensor-id";pr.SizeSensorId=r;var t="size-sensor-object";pr.SensorClassName=t;var e="-1";return pr.SensorTabIndex=e,pr}var kd;function Ew(){if(kd)return Jn;kd=1,Object.defineProperty(Jn,"__esModule",{value:!0}),Jn.createSensor=void 0;var r=e(ay()),t=Ec();function e(n){return n&&n.__esModule?n:{default:n}}var i=function(a,o){var s=void 0,l=[],u=function(){getComputedStyle(a).position==="static"&&(a.style.position="relative");var v=document.createElement("object");return v.onload=function(){v.contentDocument.defaultView.addEventListener("resize",h),h()},v.style.display="block",v.style.position="absolute",v.style.top="0",v.style.left="0",v.style.height="100%",v.style.width="100%",v.style.overflow="hidden",v.style.pointerEvents="none",v.style.zIndex="-1",v.style.opacity="0",v.setAttribute("class",t.SensorClassName),v.setAttribute("tabindex",t.SensorTabIndex),v.type="text/html",a.appendChild(v),v.data="about:blank",v},h=(0,r.default)(function(){l.forEach(function(p){p(a)})}),c=function(v){s||(s=u()),l.indexOf(v)===-1&&l.push(v)},f=function(){s&&s.parentNode&&(s.contentDocument&&s.contentDocument.defaultView.removeEventListener("resize",h),s.parentNode.removeChild(s),a.removeAttribute(t.SizeSensorId),s=void 0,l=[],o&&o())},d=function(v){var g=l.indexOf(v);g!==-1&&l.splice(g,1),l.length===0&&s&&f()};return{element:a,bind:c,destroy:f,unbind:d}};return Jn.createSensor=i,Jn}var Qn={},Rd;function jw(){if(Rd)return Qn;Rd=1,Object.defineProperty(Qn,"__esModule",{value:!0}),Qn.createSensor=void 0;var r=Ec(),t=e(ay());function e(n){return n&&n.__esModule?n:{default:n}}var i=function(a,o){var s=void 0,l=[],u=(0,t.default)(function(){l.forEach(function(p){p(a)})}),h=function(){var v=new ResizeObserver(u);return v.observe(a),u(),v},c=function(v){s||(s=h()),l.indexOf(v)===-1&&l.push(v)},f=function(){s.disconnect(),l=[],s=void 0,a.removeAttribute(r.SizeSensorId),o&&o()},d=function(v){var g=l.indexOf(v);g!==-1&&l.splice(g,1),l.length===0&&s&&f()};return{element:a,bind:c,destroy:f,unbind:d}};return Qn.createSensor=i,Qn}var Ld;function Nw(){if(Ld)return Kn;Ld=1,Object.defineProperty(Kn,"__esModule",{value:!0}),Kn.createSensor=void 0;var r=Ew(),t=jw(),e=typeof ResizeObserver<"u"?t.createSensor:r.createSensor;return Kn.createSensor=e,Kn}var Od;function Fw(){if(Od)return dr;Od=1,Object.defineProperty(dr,"__esModule",{value:!0}),dr.removeSensor=dr.getSensor=dr.Sensors=void 0;var r=i(Ow()),t=Nw(),e=Ec();function i(l){return l&&l.__esModule?l:{default:l}}var n={};dr.Sensors=n;function a(l){l&&n[l]&&delete n[l]}var o=function(u){var h=u.getAttribute(e.SizeSensorId);if(h&&n[h])return n[h];var c=(0,r.default)();u.setAttribute(e.SizeSensorId,c);var f=(0,t.createSensor)(u,function(){return a(c)});return n[c]=f,f};dr.getSensor=o;var s=function(u){var h=u.element.getAttribute(e.SizeSensorId);u.destroy(),a(h)};return dr.removeSensor=s,dr}var Ed;function Bw(){if(Ed)return fr;Ed=1,Object.defineProperty(fr,"__esModule",{value:!0}),fr.ver=fr.clear=fr.bind=void 0;var r=Fw(),t=function(a,o){var s=(0,r.getSensor)(a);return s.bind(o),function(){s.unbind(o)}};fr.bind=t;var e=function(a){var o=(0,r.getSensor)(a);(0,r.removeSensor)(o)};fr.clear=e;var i="1.0.2";return fr.ver=i,fr}var ta={},jd;function zw(){if(jd)return ta;jd=1,Object.defineProperty(ta,"__esModule",{value:!0}),ta.pick=void 0;function r(t,e){var i={};return e.forEach(function(n){i[n]=t[n]}),i}return ta.pick=r,ta}var ea={},Nd;function Vw(){if(Nd)return ea;Nd=1,Object.defineProperty(ea,"__esModule",{value:!0}),ea.isFunction=void 0;function r(t){return typeof t=="function"}return ea.isFunction=r,ea}var ra={},Fd;function Hw(){if(Fd)return ra;Fd=1,Object.defineProperty(ra,"__esModule",{value:!0}),ra.isString=void 0;function r(t){return typeof t=="string"}return ra.isString=r,ra}var ia={},Bd;function Ww(){if(Bd)return ia;Bd=1,Object.defineProperty(ia,"__esModule",{value:!0}),ia.isEqual=void 0;var r=ny,t=r.__importDefault(qx);return ia.isEqual=t.default,ia}Object.defineProperty(ry,"__esModule",{value:!0});var Er=ny,zd=Er.__importStar(at),Vd=Bw(),Hd=zw(),Xl=Vw(),Wd=Hw(),nn=Ww(),Gw=function(r){Er.__extends(t,r);function t(e){var i=r.call(this,e)||this;return i.echarts=e.echarts,i.ele=null,i.isInitialResize=!0,i}return t.prototype.componentDidMount=function(){this.renderNewEcharts()},t.prototype.componentDidUpdate=function(e){var i=this.props.shouldSetOption;if(!((0,Xl.isFunction)(i)&&!i(e,this.props))){if(!(0,nn.isEqual)(e.theme,this.props.theme)||!(0,nn.isEqual)(e.opts,this.props.opts)){this.dispose(),this.renderNewEcharts();return}var n=this.getEchartsInstance();(0,nn.isEqual)(e.onEvents,this.props.onEvents)||(this.offEvents(n,e.onEvents),this.bindEvents(n,this.props.onEvents));var a=["option","notMerge","replaceMerge","lazyUpdate","showLoading","loadingOption"];(0,nn.isEqual)((0,Hd.pick)(this.props,a),(0,Hd.pick)(e,a))||this.updateEChartsOption(),(!(0,nn.isEqual)(e.style,this.props.style)||!(0,nn.isEqual)(e.className,this.props.className))&&this.resize()}},t.prototype.componentWillUnmount=function(){this.dispose()},t.prototype.initEchartsInstance=function(){return Er.__awaiter(this,void 0,void 0,function(){var e=this;return Er.__generator(this,function(i){return[2,new Promise(function(n){e.echarts.init(e.ele,e.props.theme,e.props.opts);var a=e.getEchartsInstance();a.on("finished",function(){var o=e.ele.clientWidth,s=e.ele.clientHeight;e.echarts.dispose(e.ele);var l=Er.__assign({width:o,height:s},e.props.opts);n(e.echarts.init(e.ele,e.props.theme,l))})})]})})},t.prototype.getEchartsInstance=function(){return this.echarts.getInstanceByDom(this.ele)},t.prototype.dispose=function(){if(this.ele){try{(0,Vd.clear)(this.ele)}catch(e){console.warn(e)}this.echarts.dispose(this.ele)}},t.prototype.renderNewEcharts=function(){return Er.__awaiter(this,void 0,void 0,function(){var e,i,n,a,o,s,l=this;return Er.__generator(this,function(u){switch(u.label){case 0:return e=this.props,i=e.onEvents,n=e.onChartReady,a=e.autoResize,o=a===void 0?!0:a,[4,this.initEchartsInstance()];case 1:return u.sent(),s=this.updateEChartsOption(),this.bindEvents(s,i||{}),(0,Xl.isFunction)(n)&&n(s),this.ele&&o&&(0,Vd.bind)(this.ele,function(){l.resize()}),[2]}})})},t.prototype.bindEvents=function(e,i){function n(o,s){(0,Wd.isString)(o)&&(0,Xl.isFunction)(s)&&e.on(o,function(l){s(l,e)})}for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&n(a,i[a])},t.prototype.offEvents=function(e,i){if(i)for(var n in i)(0,Wd.isString)(n)&&e.off(n)},t.prototype.updateEChartsOption=function(){var e=this.props,i=e.option,n=e.notMerge,a=n===void 0?!1:n,o=e.replaceMerge,s=o===void 0?null:o,l=e.lazyUpdate,u=l===void 0?!1:l,h=e.showLoading,c=e.loadingOption,f=c===void 0?null:c,d=this.getEchartsInstance();return d.setOption(i,{notMerge:a,replaceMerge:s,lazyUpdate:u}),h?d.showLoading(f):d.hideLoading(),d},t.prototype.resize=function(){var e=this.getEchartsInstance();if(!this.isInitialResize)try{e.resize({width:"auto",height:"auto"})}catch(i){console.warn(i)}this.isInitialResize=!1},t.prototype.render=function(){var e=this,i=this.props,n=i.style,a=i.className,o=a===void 0?"":a,s=Er.__assign({height:300},n);return zd.default.createElement("div",{ref:function(l){e.ele=l},style:s,className:"echarts-for-react ".concat(o)})},t}(zd.PureComponent),Uw=ry.default=Gw,$w=function(){function r(){this.firefox=!1,this.ie=!1,this.edge=!1,this.newEdge=!1,this.weChat=!1}return r}(),Yw=function(){function r(){this.browser=new $w,this.node=!1,this.wxa=!1,this.worker=!1,this.svgSupported=!1,this.touchEventsSupported=!1,this.pointerEventsSupported=!1,this.domSupported=!1,this.transformSupported=!1,this.transform3dSupported=!1,this.hasGlobalWindow=typeof window<"u"}return r}(),J=new Yw;typeof wx=="object"&&typeof wx.getSystemInfoSync=="function"?(J.wxa=!0,J.touchEventsSupported=!0):typeof document>"u"&&typeof self<"u"?J.worker=!0:!J.hasGlobalWindow||"Deno"in window?(J.node=!0,J.svgSupported=!0):Xw(navigator.userAgent,J);function Xw(r,t){var e=t.browser,i=r.match(/Firefox\/([\d.]+)/),n=r.match(/MSIE\s([\d.]+)/)||r.match(/Trident\/.+?rv:(([\d.]+))/),a=r.match(/Edge?\/([\d.]+)/),o=/micromessenger/i.test(r);i&&(e.firefox=!0,e.version=i[1]),n&&(e.ie=!0,e.version=n[1]),a&&(e.edge=!0,e.version=a[1],e.newEdge=+a[1].split(".")[0]>18),o&&(e.weChat=!0),t.svgSupported=typeof SVGRect<"u",t.touchEventsSupported="ontouchstart"in window&&!e.ie&&!e.edge,t.pointerEventsSupported="onpointerdown"in window&&(e.edge||e.ie&&+e.version>=11),t.domSupported=typeof document<"u";var s=document.documentElement.style;t.transform3dSupported=(e.ie&&"transition"in s||e.edge||"WebKitCSSMatrix"in window&&"m11"in new WebKitCSSMatrix||"MozPerspective"in s)&&!("OTransition"in s),t.transformSupported=t.transform3dSupported||e.ie&&+e.version>=9}var jc=12,oy="sans-serif",qr=jc+"px "+oy,qw=20,Zw=100,Kw="007LLmW'55;N0500LLLLLLLLLL00NNNLzWW\\\\WQb\\0FWLg\\bWb\\WQ\\WrWWQ000CL5LLFLL0LL**F*gLLLL5F0LF\\FFF5.5N";function Jw(r){var t={};if(typeof JSON>"u")return t;for(var e=0;e<r.length;e++){var i=String.fromCharCode(e+32),n=(r.charCodeAt(e)-qw)/Zw;t[i]=n}return t}var Qw=Jw(Kw),Zr={createCanvas:function(){return typeof document<"u"&&document.createElement("canvas")},measureText:function(){var r,t;return function(e,i){if(!r){var n=Zr.createCanvas();r=n&&n.getContext("2d")}if(r)return t!==i&&(t=r.font=i||qr),r.measureText(e);e=e||"",i=i||qr;var a=/((?:\d+)?\.?\d*)px/.exec(i),o=a&&+a[1]||jc,s=0;if(i.indexOf("mono")>=0)s=o*e.length;else for(var l=0;l<e.length;l++){var u=Qw[e[l]];s+=u==null?o:u*o}return{width:s}}}(),loadImage:function(r,t,e){var i=new Image;return i.onload=t,i.onerror=e,i.src=r,i}};function sy(r){for(var t in Zr)r[t]&&(Zr[t]=r[t])}var ly=sr(["Function","RegExp","Date","Error","CanvasGradient","CanvasPattern","Image","Canvas"],function(r,t){return r["[object "+t+"]"]=!0,r},{}),uy=sr(["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64"],function(r,t){return r["[object "+t+"Array]"]=!0,r},{}),Gn=Object.prototype.toString,ol=Array.prototype,t1=ol.forEach,e1=ol.filter,Nc=ol.slice,r1=ol.map,Gd=function(){}.constructor,Eo=Gd?Gd.prototype:null,Fc="__proto__",i1=2311;function Bc(){return i1++}function zc(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];typeof console<"u"&&console.error.apply(console,r)}function it(r){if(r==null||typeof r!="object")return r;var t=r,e=Gn.call(r);if(e==="[object Array]"){if(!In(r)){t=[];for(var i=0,n=r.length;i<n;i++)t[i]=it(r[i])}}else if(uy[e]){if(!In(r)){var a=r.constructor;if(a.from)t=a.from(r);else{t=new a(r.length);for(var i=0,n=r.length;i<n;i++)t[i]=r[i]}}}else if(!ly[e]&&!In(r)&&!Hi(r)){t={};for(var o in r)r.hasOwnProperty(o)&&o!==Fc&&(t[o]=it(r[o]))}return t}function st(r,t,e){if(!Z(t)||!Z(r))return e?it(t):r;for(var i in t)if(t.hasOwnProperty(i)&&i!==Fc){var n=r[i],a=t[i];Z(a)&&Z(n)&&!H(a)&&!H(n)&&!Hi(a)&&!Hi(n)&&!wh(a)&&!wh(n)&&!In(a)&&!In(n)?st(n,a,e):(e||!(i in r))&&(r[i]=it(t[i]))}return r}function n1(r,t){for(var e=r[0],i=1,n=r.length;i<n;i++)e=st(e,r[i],t);return e}function N(r,t){if(Object.assign)Object.assign(r,t);else for(var e in t)t.hasOwnProperty(e)&&e!==Fc&&(r[e]=t[e]);return r}function lt(r,t,e){for(var i=vt(t),n=0,a=i.length;n<a;n++){var o=i[n];(e?t[o]!=null:r[o]==null)&&(r[o]=t[o])}return r}var a1=Zr.createCanvas;function pt(r,t){if(r){if(r.indexOf)return r.indexOf(t);for(var e=0,i=r.length;e<i;e++)if(r[e]===t)return e}return-1}function Vc(r,t){var e=r.prototype;function i(){}i.prototype=t.prototype,r.prototype=new i;for(var n in e)e.hasOwnProperty(n)&&(r.prototype[n]=e[n]);r.prototype.constructor=r,r.superClass=t}function xe(r,t,e){if(r="prototype"in r?r.prototype:r,t="prototype"in t?t.prototype:t,Object.getOwnPropertyNames)for(var i=Object.getOwnPropertyNames(t),n=0;n<i.length;n++){var a=i[n];a!=="constructor"&&(e?t[a]!=null:r[a]==null)&&(r[a]=t[a])}else lt(r,t,e)}function ae(r){return!r||typeof r=="string"?!1:typeof r.length=="number"}function A(r,t,e){if(r&&t)if(r.forEach&&r.forEach===t1)r.forEach(t,e);else if(r.length===+r.length)for(var i=0,n=r.length;i<n;i++)t.call(e,r[i],i,r);else for(var a in r)r.hasOwnProperty(a)&&t.call(e,r[a],a,r)}function V(r,t,e){if(!r)return[];if(!t)return ll(r);if(r.map&&r.map===r1)return r.map(t,e);for(var i=[],n=0,a=r.length;n<a;n++)i.push(t.call(e,r[n],n,r));return i}function sr(r,t,e,i){if(r&&t){for(var n=0,a=r.length;n<a;n++)e=t.call(i,e,r[n],n,r);return e}}function It(r,t,e){if(!r)return[];if(!t)return ll(r);if(r.filter&&r.filter===e1)return r.filter(t,e);for(var i=[],n=0,a=r.length;n<a;n++)t.call(e,r[n],n,r)&&i.push(r[n]);return i}function o1(r,t,e){if(r&&t){for(var i=0,n=r.length;i<n;i++)if(t.call(e,r[i],i,r))return r[i]}}function vt(r){if(!r)return[];if(Object.keys)return Object.keys(r);var t=[];for(var e in r)r.hasOwnProperty(e)&&t.push(e);return t}function s1(r,t){for(var e=[],i=2;i<arguments.length;i++)e[i-2]=arguments[i];return function(){return r.apply(t,e.concat(Nc.call(arguments)))}}var ct=Eo&&tt(Eo.bind)?Eo.call.bind(Eo.bind):s1;function Ct(r){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];return function(){return r.apply(this,t.concat(Nc.call(arguments)))}}function H(r){return Array.isArray?Array.isArray(r):Gn.call(r)==="[object Array]"}function tt(r){return typeof r=="function"}function U(r){return typeof r=="string"}function js(r){return Gn.call(r)==="[object String]"}function At(r){return typeof r=="number"}function Z(r){var t=typeof r;return t==="function"||!!r&&t==="object"}function wh(r){return!!ly[Gn.call(r)]}function oe(r){return!!uy[Gn.call(r)]}function Hi(r){return typeof r=="object"&&typeof r.nodeType=="number"&&typeof r.ownerDocument=="object"}function sl(r){return r.colorStops!=null}function l1(r){return r.image!=null}function u1(r){return Gn.call(r)==="[object RegExp]"}function qa(r){return r!==r}function On(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];for(var e=0,i=r.length;e<i;e++)if(r[e]!=null)return r[e]}function Q(r,t){return r??t}function La(r,t,e){return r??t??e}function ll(r){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];return Nc.apply(r,t)}function Hc(r){if(typeof r=="number")return[r,r,r,r];var t=r.length;return t===2?[r[0],r[1],r[0],r[1]]:t===3?[r[0],r[1],r[2],r[1]]:r}function be(r,t){if(!r)throw new Error(t)}function Ge(r){return r==null?null:typeof r.trim=="function"?r.trim():r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}var hy="__ec_primitive__";function Ns(r){r[hy]=!0}function In(r){return r[hy]}var h1=function(){function r(){this.data={}}return r.prototype.delete=function(t){var e=this.has(t);return e&&delete this.data[t],e},r.prototype.has=function(t){return this.data.hasOwnProperty(t)},r.prototype.get=function(t){return this.data[t]},r.prototype.set=function(t,e){return this.data[t]=e,this},r.prototype.keys=function(){return vt(this.data)},r.prototype.forEach=function(t){var e=this.data;for(var i in e)e.hasOwnProperty(i)&&t(e[i],i)},r}(),cy=typeof Map=="function";function c1(){return cy?new Map:new h1}var fy=function(){function r(t){var e=H(t);this.data=c1();var i=this;t instanceof r?t.each(n):t&&A(t,n);function n(a,o){e?i.set(a,o):i.set(o,a)}}return r.prototype.hasKey=function(t){return this.data.has(t)},r.prototype.get=function(t){return this.data.get(t)},r.prototype.set=function(t,e){return this.data.set(t,e),e},r.prototype.each=function(t,e){this.data.forEach(function(i,n){t.call(e,i,n)})},r.prototype.keys=function(){var t=this.data.keys();return cy?Array.from(t):t},r.prototype.removeKey=function(t){this.data.delete(t)},r}();function nt(r){return new fy(r)}function dy(r,t){for(var e=new r.constructor(r.length+t.length),i=0;i<r.length;i++)e[i]=r[i];for(var n=r.length,i=0;i<t.length;i++)e[i+n]=t[i];return e}function _o(r,t){var e;if(Object.create)e=Object.create(r);else{var i=function(){};i.prototype=r,e=new i}return t&&N(e,t),e}function f1(r){var t=r.style;t.webkitUserSelect="none",t.userSelect="none",t.webkitTapHighlightColor="rgba(0,0,0,0)",t["-webkit-touch-callout"]="none"}function Wi(r,t){return r.hasOwnProperty(t)}function Gt(){}var Oa=180/Math.PI;const d1=Object.freeze(Object.defineProperty({__proto__:null,HashMap:fy,RADIAN_TO_DEGREE:Oa,assert:be,bind:ct,clone:it,concatArray:dy,createCanvas:a1,createHashMap:nt,createObject:_o,curry:Ct,defaults:lt,disableUserSelect:f1,each:A,eqNaN:qa,extend:N,filter:It,find:o1,guid:Bc,hasOwn:Wi,indexOf:pt,inherits:Vc,isArray:H,isArrayLike:ae,isBuiltInObject:wh,isDom:Hi,isFunction:tt,isGradientObject:sl,isImagePatternObject:l1,isNumber:At,isObject:Z,isPrimitive:In,isRegExp:u1,isString:U,isStringSafe:js,isTypedArray:oe,keys:vt,logError:zc,map:V,merge:st,mergeAll:n1,mixin:xe,noop:Gt,normalizeCssArray:Hc,reduce:sr,retrieve:On,retrieve2:Q,retrieve3:La,setAsPrimitive:Ns,slice:ll,trim:Ge},Symbol.toStringTag,{value:"Module"}));function Zi(r,t){return r==null&&(r=0),t==null&&(t=0),[r,t]}function p1(r,t){return r[0]=t[0],r[1]=t[1],r}function py(r){return[r[0],r[1]]}function v1(r,t,e){return r[0]=t,r[1]=e,r}function Sh(r,t,e){return r[0]=t[0]+e[0],r[1]=t[1]+e[1],r}function g1(r,t,e,i){return r[0]=t[0]+e[0]*i,r[1]=t[1]+e[1]*i,r}function vy(r,t,e){return r[0]=t[0]-e[0],r[1]=t[1]-e[1],r}function Wc(r){return Math.sqrt(Gc(r))}var m1=Wc;function Gc(r){return r[0]*r[0]+r[1]*r[1]}var y1=Gc;function _1(r,t,e){return r[0]=t[0]*e[0],r[1]=t[1]*e[1],r}function b1(r,t,e){return r[0]=t[0]/e[0],r[1]=t[1]/e[1],r}function x1(r,t){return r[0]*t[0]+r[1]*t[1]}function gs(r,t,e){return r[0]=t[0]*e,r[1]=t[1]*e,r}function gy(r,t){var e=Wc(t);return e===0?(r[0]=0,r[1]=0):(r[0]=t[0]/e,r[1]=t[1]/e),r}function Fs(r,t){return Math.sqrt((r[0]-t[0])*(r[0]-t[0])+(r[1]-t[1])*(r[1]-t[1]))}var my=Fs;function yy(r,t){return(r[0]-t[0])*(r[0]-t[0])+(r[1]-t[1])*(r[1]-t[1])}var Ei=yy;function w1(r,t){return r[0]=-t[0],r[1]=-t[1],r}function S1(r,t,e,i){return r[0]=t[0]+i*(e[0]-t[0]),r[1]=t[1]+i*(e[1]-t[1]),r}function ie(r,t,e){var i=t[0],n=t[1];return r[0]=e[0]*i+e[2]*n+e[4],r[1]=e[1]*i+e[3]*n+e[5],r}function Br(r,t,e){return r[0]=Math.min(t[0],e[0]),r[1]=Math.min(t[1],e[1]),r}function zr(r,t,e){return r[0]=Math.max(t[0],e[0]),r[1]=Math.max(t[1],e[1]),r}const C1=Object.freeze(Object.defineProperty({__proto__:null,add:Sh,applyTransform:ie,clone:py,copy:p1,create:Zi,dist:my,distSquare:Ei,distance:Fs,distanceSquare:yy,div:b1,dot:x1,len:Wc,lenSquare:Gc,length:m1,lengthSquare:y1,lerp:S1,max:zr,min:Br,mul:_1,negate:w1,normalize:gy,scale:gs,scaleAndAdd:g1,set:v1,sub:vy},Symbol.toStringTag,{value:"Module"}));var an=function(){function r(t,e){this.target=t,this.topTarget=e&&e.topTarget}return r}(),T1=function(){function r(t){this.handler=t,t.on("mousedown",this._dragStart,this),t.on("mousemove",this._drag,this),t.on("mouseup",this._dragEnd,this)}return r.prototype._dragStart=function(t){for(var e=t.target;e&&!e.draggable;)e=e.parent||e.__hostTarget;e&&(this._draggingTarget=e,e.dragging=!0,this._x=t.offsetX,this._y=t.offsetY,this.handler.dispatchToElement(new an(e,t),"dragstart",t.event))},r.prototype._drag=function(t){var e=this._draggingTarget;if(e){var i=t.offsetX,n=t.offsetY,a=i-this._x,o=n-this._y;this._x=i,this._y=n,e.drift(a,o,t),this.handler.dispatchToElement(new an(e,t),"drag",t.event);var s=this.handler.findHover(i,n,e).target,l=this._dropTarget;this._dropTarget=s,e!==s&&(l&&s!==l&&this.handler.dispatchToElement(new an(l,t),"dragleave",t.event),s&&s!==l&&this.handler.dispatchToElement(new an(s,t),"dragenter",t.event))}},r.prototype._dragEnd=function(t){var e=this._draggingTarget;e&&(e.dragging=!1),this.handler.dispatchToElement(new an(e,t),"dragend",t.event),this._dropTarget&&this.handler.dispatchToElement(new an(this._dropTarget,t),"drop",t.event),this._draggingTarget=null,this._dropTarget=null},r}(),ur=function(){function r(t){t&&(this._$eventProcessor=t)}return r.prototype.on=function(t,e,i,n){this._$handlers||(this._$handlers={});var a=this._$handlers;if(typeof e=="function"&&(n=i,i=e,e=null),!i||!t)return this;var o=this._$eventProcessor;e!=null&&o&&o.normalizeQuery&&(e=o.normalizeQuery(e)),a[t]||(a[t]=[]);for(var s=0;s<a[t].length;s++)if(a[t][s].h===i)return this;var l={h:i,query:e,ctx:n||this,callAtLast:i.zrEventfulCallAtLast},u=a[t].length-1,h=a[t][u];return h&&h.callAtLast?a[t].splice(u,0,l):a[t].push(l),this},r.prototype.isSilent=function(t){var e=this._$handlers;return!e||!e[t]||!e[t].length},r.prototype.off=function(t,e){var i=this._$handlers;if(!i)return this;if(!t)return this._$handlers={},this;if(e){if(i[t]){for(var n=[],a=0,o=i[t].length;a<o;a++)i[t][a].h!==e&&n.push(i[t][a]);i[t]=n}i[t]&&i[t].length===0&&delete i[t]}else delete i[t];return this},r.prototype.trigger=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];if(!this._$handlers)return this;var n=this._$handlers[t],a=this._$eventProcessor;if(n)for(var o=e.length,s=n.length,l=0;l<s;l++){var u=n[l];if(!(a&&a.filter&&u.query!=null&&!a.filter(t,u.query)))switch(o){case 0:u.h.call(u.ctx);break;case 1:u.h.call(u.ctx,e[0]);break;case 2:u.h.call(u.ctx,e[0],e[1]);break;default:u.h.apply(u.ctx,e);break}}return a&&a.afterTrigger&&a.afterTrigger(t),this},r.prototype.triggerWithContext=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];if(!this._$handlers)return this;var n=this._$handlers[t],a=this._$eventProcessor;if(n)for(var o=e.length,s=e[o-1],l=n.length,u=0;u<l;u++){var h=n[u];if(!(a&&a.filter&&h.query!=null&&!a.filter(t,h.query)))switch(o){case 0:h.h.call(s);break;case 1:h.h.call(s,e[0]);break;case 2:h.h.call(s,e[0],e[1]);break;default:h.h.apply(s,e.slice(1,o-1));break}}return a&&a.afterTrigger&&a.afterTrigger(t),this},r}(),A1=Math.log(2);function Ch(r,t,e,i,n,a){var o=i+"-"+n,s=r.length;if(a.hasOwnProperty(o))return a[o];if(t===1){var l=Math.round(Math.log((1<<s)-1&~n)/A1);return r[e][l]}for(var u=i|1<<e,h=e+1;i&1<<h;)h++;for(var c=0,f=0,d=0;f<s;f++){var p=1<<f;p&n||(c+=(d%2?-1:1)*r[e][f]*Ch(r,t-1,h,u,n|p,a),d++)}return a[o]=c,c}function Ud(r,t){var e=[[r[0],r[1],1,0,0,0,-t[0]*r[0],-t[0]*r[1]],[0,0,0,r[0],r[1],1,-t[1]*r[0],-t[1]*r[1]],[r[2],r[3],1,0,0,0,-t[2]*r[2],-t[2]*r[3]],[0,0,0,r[2],r[3],1,-t[3]*r[2],-t[3]*r[3]],[r[4],r[5],1,0,0,0,-t[4]*r[4],-t[4]*r[5]],[0,0,0,r[4],r[5],1,-t[5]*r[4],-t[5]*r[5]],[r[6],r[7],1,0,0,0,-t[6]*r[6],-t[6]*r[7]],[0,0,0,r[6],r[7],1,-t[7]*r[6],-t[7]*r[7]]],i={},n=Ch(e,8,0,0,0,i);if(n!==0){for(var a=[],o=0;o<8;o++)for(var s=0;s<8;s++)a[s]==null&&(a[s]=0),a[s]+=((o+s)%2?-1:1)*Ch(e,7,o===0?1:0,1<<o,1<<s,i)/n*t[o];return function(l,u,h){var c=u*a[6]+h*a[7]+1;l[0]=(u*a[0]+h*a[1]+a[2])/c,l[1]=(u*a[3]+h*a[4]+a[5])/c}}}var $d="___zrEVENTSAVED",ql=[];function M1(r,t,e,i,n){return Th(ql,t,i,n,!0)&&Th(r,e,ql[0],ql[1])}function Th(r,t,e,i,n){if(t.getBoundingClientRect&&J.domSupported&&!_y(t)){var a=t[$d]||(t[$d]={}),o=D1(t,a),s=I1(o,a,n);if(s)return s(r,e,i),!0}return!1}function D1(r,t){var e=t.markers;if(e)return e;e=t.markers=[];for(var i=["left","right"],n=["top","bottom"],a=0;a<4;a++){var o=document.createElement("div"),s=o.style,l=a%2,u=(a>>1)%2;s.cssText=["position: absolute","visibility: hidden","padding: 0","margin: 0","border-width: 0","user-select: none","width:0","height:0",i[l]+":0",n[u]+":0",i[1-l]+":auto",n[1-u]+":auto",""].join("!important;"),r.appendChild(o),e.push(o)}return e}function I1(r,t,e){for(var i=e?"invTrans":"trans",n=t[i],a=t.srcCoords,o=[],s=[],l=!0,u=0;u<4;u++){var h=r[u].getBoundingClientRect(),c=2*u,f=h.left,d=h.top;o.push(f,d),l=l&&a&&f===a[c]&&d===a[c+1],s.push(r[u].offsetLeft,r[u].offsetTop)}return l&&n?n:(t.srcCoords=o,t[i]=e?Ud(s,o):Ud(o,s))}function _y(r){return r.nodeName.toUpperCase()==="CANVAS"}var P1=/([&<>"'])/g,k1={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function Kt(r){return r==null?"":(r+"").replace(P1,function(t,e){return k1[e]})}var R1=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Zl=[],L1=J.browser.firefox&&+J.browser.version.split(".")[0]<39;function Ah(r,t,e,i){return e=e||{},i?Yd(r,t,e):L1&&t.layerX!=null&&t.layerX!==t.offsetX?(e.zrX=t.layerX,e.zrY=t.layerY):t.offsetX!=null?(e.zrX=t.offsetX,e.zrY=t.offsetY):Yd(r,t,e),e}function Yd(r,t,e){if(J.domSupported&&r.getBoundingClientRect){var i=t.clientX,n=t.clientY;if(_y(r)){var a=r.getBoundingClientRect();e.zrX=i-a.left,e.zrY=n-a.top;return}else if(Th(Zl,r,i,n)){e.zrX=Zl[0],e.zrY=Zl[1];return}}e.zrX=e.zrY=0}function Uc(r){return r||window.event}function Ae(r,t,e){if(t=Uc(t),t.zrX!=null)return t;var i=t.type,n=i&&i.indexOf("touch")>=0;if(n){var o=i!=="touchend"?t.targetTouches[0]:t.changedTouches[0];o&&Ah(r,o,t,e)}else{Ah(r,t,t,e);var a=O1(t);t.zrDelta=a?a/120:-(t.detail||0)/3}var s=t.button;return t.which==null&&s!==void 0&&R1.test(t.type)&&(t.which=s&1?1:s&2?3:s&4?2:0),t}function O1(r){var t=r.wheelDelta;if(t)return t;var e=r.deltaX,i=r.deltaY;if(e==null||i==null)return t;var n=Math.abs(i!==0?i:e),a=i>0?-1:i<0?1:e>0?-1:1;return 3*n*a}function Mh(r,t,e,i){r.addEventListener(t,e,i)}function E1(r,t,e,i){r.removeEventListener(t,e,i)}var by=function(r){r.preventDefault(),r.stopPropagation(),r.cancelBubble=!0},j1=function(){function r(){this._track=[]}return r.prototype.recognize=function(t,e,i){return this._doTrack(t,e,i),this._recognize(t)},r.prototype.clear=function(){return this._track.length=0,this},r.prototype._doTrack=function(t,e,i){var n=t.touches;if(n){for(var a={points:[],touches:[],target:e,event:t},o=0,s=n.length;o<s;o++){var l=n[o],u=Ah(i,l,{});a.points.push([u.zrX,u.zrY]),a.touches.push(l)}this._track.push(a)}},r.prototype._recognize=function(t){for(var e in Kl)if(Kl.hasOwnProperty(e)){var i=Kl[e](this._track,t);if(i)return i}},r}();function Xd(r){var t=r[1][0]-r[0][0],e=r[1][1]-r[0][1];return Math.sqrt(t*t+e*e)}function N1(r){return[(r[0][0]+r[1][0])/2,(r[0][1]+r[1][1])/2]}var Kl={pinch:function(r,t){var e=r.length;if(e){var i=(r[e-1]||{}).points,n=(r[e-2]||{}).points||i;if(n&&n.length>1&&i&&i.length>1){var a=Xd(i)/Xd(n);!isFinite(a)&&(a=1),t.pinchScale=a;var o=N1(i);return t.pinchX=o[0],t.pinchY=o[1],{type:"pinch",target:r[0].target,event:t}}}}};function xr(){return[1,0,0,1,0,0]}function bo(r){return r[0]=1,r[1]=0,r[2]=0,r[3]=1,r[4]=0,r[5]=0,r}function $c(r,t){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r}function Ur(r,t,e){var i=t[0]*e[0]+t[2]*e[1],n=t[1]*e[0]+t[3]*e[1],a=t[0]*e[2]+t[2]*e[3],o=t[1]*e[2]+t[3]*e[3],s=t[0]*e[4]+t[2]*e[5]+t[4],l=t[1]*e[4]+t[3]*e[5]+t[5];return r[0]=i,r[1]=n,r[2]=a,r[3]=o,r[4]=s,r[5]=l,r}function En(r,t,e){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4]+e[0],r[5]=t[5]+e[1],r}function xo(r,t,e,i){i===void 0&&(i=[0,0]);var n=t[0],a=t[2],o=t[4],s=t[1],l=t[3],u=t[5],h=Math.sin(e),c=Math.cos(e);return r[0]=n*c+s*h,r[1]=-n*h+s*c,r[2]=a*c+l*h,r[3]=-a*h+c*l,r[4]=c*(o-i[0])+h*(u-i[1])+i[0],r[5]=c*(u-i[1])-h*(o-i[0])+i[1],r}function xy(r,t,e){var i=e[0],n=e[1];return r[0]=t[0]*i,r[1]=t[1]*n,r[2]=t[2]*i,r[3]=t[3]*n,r[4]=t[4]*i,r[5]=t[5]*n,r}function wo(r,t){var e=t[0],i=t[2],n=t[4],a=t[1],o=t[3],s=t[5],l=e*o-a*i;return l?(l=1/l,r[0]=o*l,r[1]=-a*l,r[2]=-i*l,r[3]=e*l,r[4]=(i*s-o*n)*l,r[5]=(a*n-e*s)*l,r):null}function F1(r){var t=xr();return $c(t,r),t}const B1=Object.freeze(Object.defineProperty({__proto__:null,clone:F1,copy:$c,create:xr,identity:bo,invert:wo,mul:Ur,rotate:xo,scale:xy,translate:En},Symbol.toStringTag,{value:"Module"}));var wt=function(){function r(t,e){this.x=t||0,this.y=e||0}return r.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this},r.prototype.clone=function(){return new r(this.x,this.y)},r.prototype.set=function(t,e){return this.x=t,this.y=e,this},r.prototype.equal=function(t){return t.x===this.x&&t.y===this.y},r.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this},r.prototype.scale=function(t){this.x*=t,this.y*=t},r.prototype.scaleAndAdd=function(t,e){this.x+=t.x*e,this.y+=t.y*e},r.prototype.sub=function(t){return this.x-=t.x,this.y-=t.y,this},r.prototype.dot=function(t){return this.x*t.x+this.y*t.y},r.prototype.len=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},r.prototype.lenSquare=function(){return this.x*this.x+this.y*this.y},r.prototype.normalize=function(){var t=this.len();return this.x/=t,this.y/=t,this},r.prototype.distance=function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},r.prototype.distanceSquare=function(t){var e=this.x-t.x,i=this.y-t.y;return e*e+i*i},r.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this},r.prototype.transform=function(t){if(t){var e=this.x,i=this.y;return this.x=t[0]*e+t[2]*i+t[4],this.y=t[1]*e+t[3]*i+t[5],this}},r.prototype.toArray=function(t){return t[0]=this.x,t[1]=this.y,t},r.prototype.fromArray=function(t){this.x=t[0],this.y=t[1]},r.set=function(t,e,i){t.x=e,t.y=i},r.copy=function(t,e){t.x=e.x,t.y=e.y},r.len=function(t){return Math.sqrt(t.x*t.x+t.y*t.y)},r.lenSquare=function(t){return t.x*t.x+t.y*t.y},r.dot=function(t,e){return t.x*e.x+t.y*e.y},r.add=function(t,e,i){t.x=e.x+i.x,t.y=e.y+i.y},r.sub=function(t,e,i){t.x=e.x-i.x,t.y=e.y-i.y},r.scale=function(t,e,i){t.x=e.x*i,t.y=e.y*i},r.scaleAndAdd=function(t,e,i,n){t.x=e.x+i.x*n,t.y=e.y+i.y*n},r.lerp=function(t,e,i,n){var a=1-n;t.x=a*e.x+n*i.x,t.y=a*e.y+n*i.y},r}(),jo=Math.min,No=Math.max,oi=new wt,si=new wt,li=new wt,ui=new wt,na=new wt,aa=new wt,mt=function(){function r(t,e,i,n){i<0&&(t=t+i,i=-i),n<0&&(e=e+n,n=-n),this.x=t,this.y=e,this.width=i,this.height=n}return r.prototype.union=function(t){var e=jo(t.x,this.x),i=jo(t.y,this.y);isFinite(this.x)&&isFinite(this.width)?this.width=No(t.x+t.width,this.x+this.width)-e:this.width=t.width,isFinite(this.y)&&isFinite(this.height)?this.height=No(t.y+t.height,this.y+this.height)-i:this.height=t.height,this.x=e,this.y=i},r.prototype.applyTransform=function(t){r.applyTransform(this,this,t)},r.prototype.calculateTransform=function(t){var e=this,i=t.width/e.width,n=t.height/e.height,a=xr();return En(a,a,[-e.x,-e.y]),xy(a,a,[i,n]),En(a,a,[t.x,t.y]),a},r.prototype.intersect=function(t,e){if(!t)return!1;t instanceof r||(t=r.create(t));var i=this,n=i.x,a=i.x+i.width,o=i.y,s=i.y+i.height,l=t.x,u=t.x+t.width,h=t.y,c=t.y+t.height,f=!(a<l||u<n||s<h||c<o);if(e){var d=1/0,p=0,v=Math.abs(a-l),g=Math.abs(u-n),m=Math.abs(s-h),_=Math.abs(c-o),b=Math.min(v,g),x=Math.min(m,_);a<l||u<n?b>p&&(p=b,v<g?wt.set(aa,-v,0):wt.set(aa,g,0)):b<d&&(d=b,v<g?wt.set(na,v,0):wt.set(na,-g,0)),s<h||c<o?x>p&&(p=x,m<_?wt.set(aa,0,-m):wt.set(aa,0,_)):b<d&&(d=b,m<_?wt.set(na,0,m):wt.set(na,0,-_))}return e&&wt.copy(e,f?na:aa),f},r.prototype.contain=function(t,e){var i=this;return t>=i.x&&t<=i.x+i.width&&e>=i.y&&e<=i.y+i.height},r.prototype.clone=function(){return new r(this.x,this.y,this.width,this.height)},r.prototype.copy=function(t){r.copy(this,t)},r.prototype.plain=function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},r.prototype.isFinite=function(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)},r.prototype.isZero=function(){return this.width===0||this.height===0},r.create=function(t){return new r(t.x,t.y,t.width,t.height)},r.copy=function(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},r.applyTransform=function(t,e,i){if(!i){t!==e&&r.copy(t,e);return}if(i[1]<1e-5&&i[1]>-1e-5&&i[2]<1e-5&&i[2]>-1e-5){var n=i[0],a=i[3],o=i[4],s=i[5];t.x=e.x*n+o,t.y=e.y*a+s,t.width=e.width*n,t.height=e.height*a,t.width<0&&(t.x+=t.width,t.width=-t.width),t.height<0&&(t.y+=t.height,t.height=-t.height);return}oi.x=li.x=e.x,oi.y=ui.y=e.y,si.x=ui.x=e.x+e.width,si.y=li.y=e.y+e.height,oi.transform(i),ui.transform(i),si.transform(i),li.transform(i),t.x=jo(oi.x,si.x,li.x,ui.x),t.y=jo(oi.y,si.y,li.y,ui.y);var l=No(oi.x,si.x,li.x,ui.x),u=No(oi.y,si.y,li.y,ui.y);t.width=l-t.x,t.height=u-t.y},r}(),wy="silent";function z1(r,t,e){return{type:r,event:e,target:t.target,topTarget:t.topTarget,cancelBubble:!1,offsetX:e.zrX,offsetY:e.zrY,gestureEvent:e.gestureEvent,pinchX:e.pinchX,pinchY:e.pinchY,pinchScale:e.pinchScale,wheelDelta:e.zrDelta,zrByTouch:e.zrByTouch,which:e.which,stop:V1}}function V1(){by(this.event)}var H1=function(r){F(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.handler=null,e}return t.prototype.dispose=function(){},t.prototype.setCursor=function(){},t}(ur),oa=function(){function r(t,e){this.x=t,this.y=e}return r}(),W1=["click","dblclick","mousewheel","mouseout","mouseup","mousedown","mousemove","contextmenu"],Jl=new mt(0,0,0,0),Sy=function(r){F(t,r);function t(e,i,n,a,o){var s=r.call(this)||this;return s._hovered=new oa(0,0),s.storage=e,s.painter=i,s.painterRoot=a,s._pointerSize=o,n=n||new H1,s.proxy=null,s.setHandlerProxy(n),s._draggingMgr=new T1(s),s}return t.prototype.setHandlerProxy=function(e){this.proxy&&this.proxy.dispose(),e&&(A(W1,function(i){e.on&&e.on(i,this[i],this)},this),e.handler=this),this.proxy=e},t.prototype.mousemove=function(e){var i=e.zrX,n=e.zrY,a=Cy(this,i,n),o=this._hovered,s=o.target;s&&!s.__zr&&(o=this.findHover(o.x,o.y),s=o.target);var l=this._hovered=a?new oa(i,n):this.findHover(i,n),u=l.target,h=this.proxy;h.setCursor&&h.setCursor(u?u.cursor:"default"),s&&u!==s&&this.dispatchToElement(o,"mouseout",e),this.dispatchToElement(l,"mousemove",e),u&&u!==s&&this.dispatchToElement(l,"mouseover",e)},t.prototype.mouseout=function(e){var i=e.zrEventControl;i!=="only_globalout"&&this.dispatchToElement(this._hovered,"mouseout",e),i!=="no_globalout"&&this.trigger("globalout",{type:"globalout",event:e})},t.prototype.resize=function(){this._hovered=new oa(0,0)},t.prototype.dispatch=function(e,i){var n=this[e];n&&n.call(this,i)},t.prototype.dispose=function(){this.proxy.dispose(),this.storage=null,this.proxy=null,this.painter=null},t.prototype.setCursorStyle=function(e){var i=this.proxy;i.setCursor&&i.setCursor(e)},t.prototype.dispatchToElement=function(e,i,n){e=e||{};var a=e.target;if(!(a&&a.silent)){for(var o="on"+i,s=z1(i,e,n);a&&(a[o]&&(s.cancelBubble=!!a[o].call(a,s)),a.trigger(i,s),a=a.__hostTarget?a.__hostTarget:a.parent,!s.cancelBubble););s.cancelBubble||(this.trigger(i,s),this.painter&&this.painter.eachOtherLayer&&this.painter.eachOtherLayer(function(l){typeof l[o]=="function"&&l[o].call(l,s),l.trigger&&l.trigger(i,s)}))}},t.prototype.findHover=function(e,i,n){var a=this.storage.getDisplayList(),o=new oa(e,i);if(qd(a,o,e,i,n),this._pointerSize&&!o.target){for(var s=[],l=this._pointerSize,u=l/2,h=new mt(e-u,i-u,l,l),c=a.length-1;c>=0;c--){var f=a[c];f!==n&&!f.ignore&&!f.ignoreCoarsePointer&&(!f.parent||!f.parent.ignoreCoarsePointer)&&(Jl.copy(f.getBoundingRect()),f.transform&&Jl.applyTransform(f.transform),Jl.intersect(h)&&s.push(f))}if(s.length)for(var d=4,p=Math.PI/12,v=Math.PI*2,g=0;g<u;g+=d)for(var m=0;m<v;m+=p){var _=e+g*Math.cos(m),b=i+g*Math.sin(m);if(qd(s,o,_,b,n),o.target)return o}}return o},t.prototype.processGesture=function(e,i){this._gestureMgr||(this._gestureMgr=new j1);var n=this._gestureMgr;i==="start"&&n.clear();var a=n.recognize(e,this.findHover(e.zrX,e.zrY,null).target,this.proxy.dom);if(i==="end"&&n.clear(),a){var o=a.type;e.gestureEvent=o;var s=new oa;s.target=a.target,this.dispatchToElement(s,o,a.event)}},t}(ur);A(["click","mousedown","mouseup","mousewheel","dblclick","contextmenu"],function(r){Sy.prototype[r]=function(t){var e=t.zrX,i=t.zrY,n=Cy(this,e,i),a,o;if((r!=="mouseup"||!n)&&(a=this.findHover(e,i),o=a.target),r==="mousedown")this._downEl=o,this._downPoint=[t.zrX,t.zrY],this._upEl=o;else if(r==="mouseup")this._upEl=o;else if(r==="click"){if(this._downEl!==this._upEl||!this._downPoint||my(this._downPoint,[t.zrX,t.zrY])>4)return;this._downPoint=null}this.dispatchToElement(a,r,t)}});function G1(r,t,e){if(r[r.rectHover?"rectContain":"contain"](t,e)){for(var i=r,n=void 0,a=!1;i;){if(i.ignoreClip&&(a=!0),!a){var o=i.getClipPath();if(o&&!o.contain(t,e))return!1}i.silent&&(n=!0);var s=i.__hostTarget;i=s||i.parent}return n?wy:!0}return!1}function qd(r,t,e,i,n){for(var a=r.length-1;a>=0;a--){var o=r[a],s=void 0;if(o!==n&&!o.ignore&&(s=G1(o,e,i))&&(!t.topTarget&&(t.topTarget=o),s!==wy)){t.target=o;break}}}function Cy(r,t,e){var i=r.painter;return t<0||t>i.getWidth()||e<0||e>i.getHeight()}var Ty=32,sa=7;function U1(r){for(var t=0;r>=Ty;)t|=r&1,r>>=1;return r+t}function Zd(r,t,e,i){var n=t+1;if(n===e)return 1;if(i(r[n++],r[t])<0){for(;n<e&&i(r[n],r[n-1])<0;)n++;$1(r,t,n)}else for(;n<e&&i(r[n],r[n-1])>=0;)n++;return n-t}function $1(r,t,e){for(e--;t<e;){var i=r[t];r[t++]=r[e],r[e--]=i}}function Kd(r,t,e,i,n){for(i===t&&i++;i<e;i++){for(var a=r[i],o=t,s=i,l;o<s;)l=o+s>>>1,n(a,r[l])<0?s=l:o=l+1;var u=i-o;switch(u){case 3:r[o+3]=r[o+2];case 2:r[o+2]=r[o+1];case 1:r[o+1]=r[o];break;default:for(;u>0;)r[o+u]=r[o+u-1],u--}r[o]=a}}function Ql(r,t,e,i,n,a){var o=0,s=0,l=1;if(a(r,t[e+n])>0){for(s=i-n;l<s&&a(r,t[e+n+l])>0;)o=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s),o+=n,l+=n}else{for(s=n+1;l<s&&a(r,t[e+n-l])<=0;)o=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s);var u=o;o=n-l,l=n-u}for(o++;o<l;){var h=o+(l-o>>>1);a(r,t[e+h])>0?o=h+1:l=h}return l}function tu(r,t,e,i,n,a){var o=0,s=0,l=1;if(a(r,t[e+n])<0){for(s=n+1;l<s&&a(r,t[e+n-l])<0;)o=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s);var u=o;o=n-l,l=n-u}else{for(s=i-n;l<s&&a(r,t[e+n+l])>=0;)o=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s),o+=n,l+=n}for(o++;o<l;){var h=o+(l-o>>>1);a(r,t[e+h])<0?l=h:o=h+1}return l}function Y1(r,t){var e=sa,i,n,a=0,o=[];i=[],n=[];function s(d,p){i[a]=d,n[a]=p,a+=1}function l(){for(;a>1;){var d=a-2;if(d>=1&&n[d-1]<=n[d]+n[d+1]||d>=2&&n[d-2]<=n[d]+n[d-1])n[d-1]<n[d+1]&&d--;else if(n[d]>n[d+1])break;h(d)}}function u(){for(;a>1;){var d=a-2;d>0&&n[d-1]<n[d+1]&&d--,h(d)}}function h(d){var p=i[d],v=n[d],g=i[d+1],m=n[d+1];n[d]=v+m,d===a-3&&(i[d+1]=i[d+2],n[d+1]=n[d+2]),a--;var _=tu(r[g],r,p,v,0,t);p+=_,v-=_,v!==0&&(m=Ql(r[p+v-1],r,g,m,m-1,t),m!==0&&(v<=m?c(p,v,g,m):f(p,v,g,m)))}function c(d,p,v,g){var m=0;for(m=0;m<p;m++)o[m]=r[d+m];var _=0,b=v,x=d;if(r[x++]=r[b++],--g===0){for(m=0;m<p;m++)r[x+m]=o[_+m];return}if(p===1){for(m=0;m<g;m++)r[x+m]=r[b+m];r[x+g]=o[_];return}for(var C=e,S,T,M;;){S=0,T=0,M=!1;do if(t(r[b],o[_])<0){if(r[x++]=r[b++],T++,S=0,--g===0){M=!0;break}}else if(r[x++]=o[_++],S++,T=0,--p===1){M=!0;break}while((S|T)<C);if(M)break;do{if(S=tu(r[b],o,_,p,0,t),S!==0){for(m=0;m<S;m++)r[x+m]=o[_+m];if(x+=S,_+=S,p-=S,p<=1){M=!0;break}}if(r[x++]=r[b++],--g===0){M=!0;break}if(T=Ql(o[_],r,b,g,0,t),T!==0){for(m=0;m<T;m++)r[x+m]=r[b+m];if(x+=T,b+=T,g-=T,g===0){M=!0;break}}if(r[x++]=o[_++],--p===1){M=!0;break}C--}while(S>=sa||T>=sa);if(M)break;C<0&&(C=0),C+=2}if(e=C,e<1&&(e=1),p===1){for(m=0;m<g;m++)r[x+m]=r[b+m];r[x+g]=o[_]}else{if(p===0)throw new Error;for(m=0;m<p;m++)r[x+m]=o[_+m]}}function f(d,p,v,g){var m=0;for(m=0;m<g;m++)o[m]=r[v+m];var _=d+p-1,b=g-1,x=v+g-1,C=0,S=0;if(r[x--]=r[_--],--p===0){for(C=x-(g-1),m=0;m<g;m++)r[C+m]=o[m];return}if(g===1){for(x-=p,_-=p,S=x+1,C=_+1,m=p-1;m>=0;m--)r[S+m]=r[C+m];r[x]=o[b];return}for(var T=e;;){var M=0,D=0,I=!1;do if(t(o[b],r[_])<0){if(r[x--]=r[_--],M++,D=0,--p===0){I=!0;break}}else if(r[x--]=o[b--],D++,M=0,--g===1){I=!0;break}while((M|D)<T);if(I)break;do{if(M=p-tu(o[b],r,d,p,p-1,t),M!==0){for(x-=M,_-=M,p-=M,S=x+1,C=_+1,m=M-1;m>=0;m--)r[S+m]=r[C+m];if(p===0){I=!0;break}}if(r[x--]=o[b--],--g===1){I=!0;break}if(D=g-Ql(r[_],o,0,g,g-1,t),D!==0){for(x-=D,b-=D,g-=D,S=x+1,C=b+1,m=0;m<D;m++)r[S+m]=o[C+m];if(g<=1){I=!0;break}}if(r[x--]=r[_--],--p===0){I=!0;break}T--}while(M>=sa||D>=sa);if(I)break;T<0&&(T=0),T+=2}if(e=T,e<1&&(e=1),g===1){for(x-=p,_-=p,S=x+1,C=_+1,m=p-1;m>=0;m--)r[S+m]=r[C+m];r[x]=o[b]}else{if(g===0)throw new Error;for(C=x-(g-1),m=0;m<g;m++)r[C+m]=o[m]}}return{mergeRuns:l,forceMergeRuns:u,pushRun:s}}function ms(r,t,e,i){e||(e=0),i||(i=r.length);var n=i-e;if(!(n<2)){var a=0;if(n<Ty){a=Zd(r,e,i,t),Kd(r,e,i,e+a,t);return}var o=Y1(r,t),s=U1(n);do{if(a=Zd(r,e,i,t),a<s){var l=n;l>s&&(l=s),Kd(r,e,e+l,e+a,t),a=l}o.pushRun(e,a),o.mergeRuns(),n-=a,e+=a}while(n!==0);o.forceMergeRuns()}}var ji=1,ys=2,Ta=4,Jd=!1;function eu(){Jd||(Jd=!0,console.warn("z / z2 / zlevel of displayable is invalid, which may cause unexpected errors"))}function Qd(r,t){return r.zlevel===t.zlevel?r.z===t.z?r.z2-t.z2:r.z-t.z:r.zlevel-t.zlevel}var X1=function(){function r(){this._roots=[],this._displayList=[],this._displayListLen=0,this.displayableSortFunc=Qd}return r.prototype.traverse=function(t,e){for(var i=0;i<this._roots.length;i++)this._roots[i].traverse(t,e)},r.prototype.getDisplayList=function(t,e){e=e||!1;var i=this._displayList;return(t||!i.length)&&this.updateDisplayList(e),i},r.prototype.updateDisplayList=function(t){this._displayListLen=0;for(var e=this._roots,i=this._displayList,n=0,a=e.length;n<a;n++)this._updateAndAddDisplayable(e[n],null,t);i.length=this._displayListLen,ms(i,Qd)},r.prototype._updateAndAddDisplayable=function(t,e,i){if(!(t.ignore&&!i)){t.beforeUpdate(),t.update(),t.afterUpdate();var n=t.getClipPath();if(t.ignoreClip)e=null;else if(n){e?e=e.slice():e=[];for(var a=n,o=t;a;)a.parent=o,a.updateTransform(),e.push(a),o=a,a=a.getClipPath()}if(t.childrenRef){for(var s=t.childrenRef(),l=0;l<s.length;l++){var u=s[l];t.__dirty&&(u.__dirty|=ji),this._updateAndAddDisplayable(u,e,i)}t.__dirty=0}else{var h=t;e&&e.length?h.__clipPaths=e:h.__clipPaths&&h.__clipPaths.length>0&&(h.__clipPaths=[]),isNaN(h.z)&&(eu(),h.z=0),isNaN(h.z2)&&(eu(),h.z2=0),isNaN(h.zlevel)&&(eu(),h.zlevel=0),this._displayList[this._displayListLen++]=h}var c=t.getDecalElement&&t.getDecalElement();c&&this._updateAndAddDisplayable(c,e,i);var f=t.getTextGuideLine();f&&this._updateAndAddDisplayable(f,e,i);var d=t.getTextContent();d&&this._updateAndAddDisplayable(d,e,i)}},r.prototype.addRoot=function(t){t.__zr&&t.__zr.storage===this||this._roots.push(t)},r.prototype.delRoot=function(t){if(t instanceof Array){for(var e=0,i=t.length;e<i;e++)this.delRoot(t[e]);return}var n=pt(this._roots,t);n>=0&&this._roots.splice(n,1)},r.prototype.delAllRoots=function(){this._roots=[],this._displayList=[],this._displayListLen=0},r.prototype.getRoots=function(){return this._roots},r.prototype.dispose=function(){this._displayList=null,this._roots=null},r}(),Dh;Dh=J.hasGlobalWindow&&(window.requestAnimationFrame&&window.requestAnimationFrame.bind(window)||window.msRequestAnimationFrame&&window.msRequestAnimationFrame.bind(window)||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame)||function(r){return setTimeout(r,16)};var Ea={linear:function(r){return r},quadraticIn:function(r){return r*r},quadraticOut:function(r){return r*(2-r)},quadraticInOut:function(r){return(r*=2)<1?.5*r*r:-.5*(--r*(r-2)-1)},cubicIn:function(r){return r*r*r},cubicOut:function(r){return--r*r*r+1},cubicInOut:function(r){return(r*=2)<1?.5*r*r*r:.5*((r-=2)*r*r+2)},quarticIn:function(r){return r*r*r*r},quarticOut:function(r){return 1- --r*r*r*r},quarticInOut:function(r){return(r*=2)<1?.5*r*r*r*r:-.5*((r-=2)*r*r*r-2)},quinticIn:function(r){return r*r*r*r*r},quinticOut:function(r){return--r*r*r*r*r+1},quinticInOut:function(r){return(r*=2)<1?.5*r*r*r*r*r:.5*((r-=2)*r*r*r*r+2)},sinusoidalIn:function(r){return 1-Math.cos(r*Math.PI/2)},sinusoidalOut:function(r){return Math.sin(r*Math.PI/2)},sinusoidalInOut:function(r){return .5*(1-Math.cos(Math.PI*r))},exponentialIn:function(r){return r===0?0:Math.pow(1024,r-1)},exponentialOut:function(r){return r===1?1:1-Math.pow(2,-10*r)},exponentialInOut:function(r){return r===0?0:r===1?1:(r*=2)<1?.5*Math.pow(1024,r-1):.5*(-Math.pow(2,-10*(r-1))+2)},circularIn:function(r){return 1-Math.sqrt(1-r*r)},circularOut:function(r){return Math.sqrt(1- --r*r)},circularInOut:function(r){return(r*=2)<1?-.5*(Math.sqrt(1-r*r)-1):.5*(Math.sqrt(1-(r-=2)*r)+1)},elasticIn:function(r){var t,e=.1,i=.4;return r===0?0:r===1?1:(!e||e<1?(e=1,t=i/4):t=i*Math.asin(1/e)/(2*Math.PI),-(e*Math.pow(2,10*(r-=1))*Math.sin((r-t)*(2*Math.PI)/i)))},elasticOut:function(r){var t,e=.1,i=.4;return r===0?0:r===1?1:(!e||e<1?(e=1,t=i/4):t=i*Math.asin(1/e)/(2*Math.PI),e*Math.pow(2,-10*r)*Math.sin((r-t)*(2*Math.PI)/i)+1)},elasticInOut:function(r){var t,e=.1,i=.4;return r===0?0:r===1?1:(!e||e<1?(e=1,t=i/4):t=i*Math.asin(1/e)/(2*Math.PI),(r*=2)<1?-.5*(e*Math.pow(2,10*(r-=1))*Math.sin((r-t)*(2*Math.PI)/i)):e*Math.pow(2,-10*(r-=1))*Math.sin((r-t)*(2*Math.PI)/i)*.5+1)},backIn:function(r){var t=1.70158;return r*r*((t+1)*r-t)},backOut:function(r){var t=1.70158;return--r*r*((t+1)*r+t)+1},backInOut:function(r){var t=2.5949095;return(r*=2)<1?.5*(r*r*((t+1)*r-t)):.5*((r-=2)*r*((t+1)*r+t)+2)},bounceIn:function(r){return 1-Ea.bounceOut(1-r)},bounceOut:function(r){return r<1/2.75?7.5625*r*r:r<2/2.75?7.5625*(r-=1.5/2.75)*r+.75:r<2.5/2.75?7.5625*(r-=2.25/2.75)*r+.9375:7.5625*(r-=2.625/2.75)*r+.984375},bounceInOut:function(r){return r<.5?Ea.bounceIn(r*2)*.5:Ea.bounceOut(r*2-1)*.5+.5}},Fo=Math.pow,$r=Math.sqrt,Ay=1e-8,My=1e-4,tp=$r(3),Bo=1/3,nr=Zi(),Ie=Zi(),Pn=Zi();function Vr(r){return r>-1e-8&&r<Ay}function Dy(r){return r>Ay||r<-1e-8}function Wt(r,t,e,i,n){var a=1-n;return a*a*(a*r+3*n*t)+n*n*(n*i+3*a*e)}function ep(r,t,e,i,n){var a=1-n;return 3*(((t-r)*a+2*(e-t)*n)*a+(i-e)*n*n)}function Bs(r,t,e,i,n,a){var o=i+3*(t-e)-r,s=3*(e-t*2+r),l=3*(t-r),u=r-n,h=s*s-3*o*l,c=s*l-9*o*u,f=l*l-3*s*u,d=0;if(Vr(h)&&Vr(c))if(Vr(s))a[0]=0;else{var p=-l/s;p>=0&&p<=1&&(a[d++]=p)}else{var v=c*c-4*h*f;if(Vr(v)){var g=c/h,p=-s/o+g,m=-g/2;p>=0&&p<=1&&(a[d++]=p),m>=0&&m<=1&&(a[d++]=m)}else if(v>0){var _=$r(v),b=h*s+1.5*o*(-c+_),x=h*s+1.5*o*(-c-_);b<0?b=-Fo(-b,Bo):b=Fo(b,Bo),x<0?x=-Fo(-x,Bo):x=Fo(x,Bo);var p=(-s-(b+x))/(3*o);p>=0&&p<=1&&(a[d++]=p)}else{var C=(2*h*s-3*o*c)/(2*$r(h*h*h)),S=Math.acos(C)/3,T=$r(h),M=Math.cos(S),p=(-s-2*T*M)/(3*o),m=(-s+T*(M+tp*Math.sin(S)))/(3*o),D=(-s+T*(M-tp*Math.sin(S)))/(3*o);p>=0&&p<=1&&(a[d++]=p),m>=0&&m<=1&&(a[d++]=m),D>=0&&D<=1&&(a[d++]=D)}}return d}function Iy(r,t,e,i,n){var a=6*e-12*t+6*r,o=9*t+3*i-3*r-9*e,s=3*t-3*r,l=0;if(Vr(o)){if(Dy(a)){var u=-s/a;u>=0&&u<=1&&(n[l++]=u)}}else{var h=a*a-4*o*s;if(Vr(h))n[0]=-a/(2*o);else if(h>0){var c=$r(h),u=(-a+c)/(2*o),f=(-a-c)/(2*o);u>=0&&u<=1&&(n[l++]=u),f>=0&&f<=1&&(n[l++]=f)}}return l}function zs(r,t,e,i,n,a){var o=(t-r)*n+r,s=(e-t)*n+t,l=(i-e)*n+e,u=(s-o)*n+o,h=(l-s)*n+s,c=(h-u)*n+u;a[0]=r,a[1]=o,a[2]=u,a[3]=c,a[4]=c,a[5]=h,a[6]=l,a[7]=i}function q1(r,t,e,i,n,a,o,s,l,u,h){var c,f=.005,d=1/0,p,v,g,m;nr[0]=l,nr[1]=u;for(var _=0;_<1;_+=.05)Ie[0]=Wt(r,e,n,o,_),Ie[1]=Wt(t,i,a,s,_),g=Ei(nr,Ie),g<d&&(c=_,d=g);d=1/0;for(var b=0;b<32&&!(f<My);b++)p=c-f,v=c+f,Ie[0]=Wt(r,e,n,o,p),Ie[1]=Wt(t,i,a,s,p),g=Ei(Ie,nr),p>=0&&g<d?(c=p,d=g):(Pn[0]=Wt(r,e,n,o,v),Pn[1]=Wt(t,i,a,s,v),m=Ei(Pn,nr),v<=1&&m<d?(c=v,d=m):f*=.5);return $r(d)}function Z1(r,t,e,i,n,a,o,s,l){for(var u=r,h=t,c=0,f=1/l,d=1;d<=l;d++){var p=d*f,v=Wt(r,e,n,o,p),g=Wt(t,i,a,s,p),m=v-u,_=g-h;c+=Math.sqrt(m*m+_*_),u=v,h=g}return c}function ce(r,t,e,i){var n=1-i;return n*(n*r+2*i*t)+i*i*e}function rp(r,t,e,i){return 2*((1-i)*(t-r)+i*(e-t))}function K1(r,t,e,i,n){var a=r-2*t+e,o=2*(t-r),s=r-i,l=0;if(Vr(a)){if(Dy(o)){var u=-s/o;u>=0&&u<=1&&(n[l++]=u)}}else{var h=o*o-4*a*s;if(Vr(h)){var u=-o/(2*a);u>=0&&u<=1&&(n[l++]=u)}else if(h>0){var c=$r(h),u=(-o+c)/(2*a),f=(-o-c)/(2*a);u>=0&&u<=1&&(n[l++]=u),f>=0&&f<=1&&(n[l++]=f)}}return l}function Py(r,t,e){var i=r+e-2*t;return i===0?.5:(r-t)/i}function Vs(r,t,e,i,n){var a=(t-r)*i+r,o=(e-t)*i+t,s=(o-a)*i+a;n[0]=r,n[1]=a,n[2]=s,n[3]=s,n[4]=o,n[5]=e}function J1(r,t,e,i,n,a,o,s,l){var u,h=.005,c=1/0;nr[0]=o,nr[1]=s;for(var f=0;f<1;f+=.05){Ie[0]=ce(r,e,n,f),Ie[1]=ce(t,i,a,f);var d=Ei(nr,Ie);d<c&&(u=f,c=d)}c=1/0;for(var p=0;p<32&&!(h<My);p++){var v=u-h,g=u+h;Ie[0]=ce(r,e,n,v),Ie[1]=ce(t,i,a,v);var d=Ei(Ie,nr);if(v>=0&&d<c)u=v,c=d;else{Pn[0]=ce(r,e,n,g),Pn[1]=ce(t,i,a,g);var m=Ei(Pn,nr);g<=1&&m<c?(u=g,c=m):h*=.5}}return $r(c)}function Q1(r,t,e,i,n,a,o){for(var s=r,l=t,u=0,h=1/o,c=1;c<=o;c++){var f=c*h,d=ce(r,e,n,f),p=ce(t,i,a,f),v=d-s,g=p-l;u+=Math.sqrt(v*v+g*g),s=d,l=p}return u}var tS=/cubic-bezier\(([0-9,\.e ]+)\)/;function Yc(r){var t=r&&tS.exec(r);if(t){var e=t[1].split(","),i=+Ge(e[0]),n=+Ge(e[1]),a=+Ge(e[2]),o=+Ge(e[3]);if(isNaN(i+n+a+o))return;var s=[];return function(l){return l<=0?0:l>=1?1:Bs(0,i,a,1,l,s)&&Wt(0,n,o,1,s[0])}}}var eS=function(){function r(t){this._inited=!1,this._startTime=0,this._pausedTime=0,this._paused=!1,this._life=t.life||1e3,this._delay=t.delay||0,this.loop=t.loop||!1,this.onframe=t.onframe||Gt,this.ondestroy=t.ondestroy||Gt,this.onrestart=t.onrestart||Gt,t.easing&&this.setEasing(t.easing)}return r.prototype.step=function(t,e){if(this._inited||(this._startTime=t+this._delay,this._inited=!0),this._paused){this._pausedTime+=e;return}var i=this._life,n=t-this._startTime-this._pausedTime,a=n/i;a<0&&(a=0),a=Math.min(a,1);var o=this.easingFunc,s=o?o(a):a;if(this.onframe(s),a===1)if(this.loop){var l=n%i;this._startTime=t-l,this._pausedTime=0,this.onrestart()}else return!0;return!1},r.prototype.pause=function(){this._paused=!0},r.prototype.resume=function(){this._paused=!1},r.prototype.setEasing=function(t){this.easing=t,this.easingFunc=tt(t)?t:Ea[t]||Yc(t)},r}(),ky=function(){function r(t){this.value=t}return r}(),rS=function(){function r(){this._len=0}return r.prototype.insert=function(t){var e=new ky(t);return this.insertEntry(e),e},r.prototype.insertEntry=function(t){this.head?(this.tail.next=t,t.prev=this.tail,t.next=null,this.tail=t):this.head=this.tail=t,this._len++},r.prototype.remove=function(t){var e=t.prev,i=t.next;e?e.next=i:this.head=i,i?i.prev=e:this.tail=e,t.next=t.prev=null,this._len--},r.prototype.len=function(){return this._len},r.prototype.clear=function(){this.head=this.tail=null,this._len=0},r}(),So=function(){function r(t){this._list=new rS,this._maxSize=10,this._map={},this._maxSize=t}return r.prototype.put=function(t,e){var i=this._list,n=this._map,a=null;if(n[t]==null){var o=i.len(),s=this._lastRemovedEntry;if(o>=this._maxSize&&o>0){var l=i.head;i.remove(l),delete n[l.key],a=l.value,this._lastRemovedEntry=l}s?s.value=e:s=new ky(e),s.key=t,i.insertEntry(s),n[t]=s}return a},r.prototype.get=function(t){var e=this._map[t],i=this._list;if(e!=null)return e!==i.tail&&(i.remove(e),i.insertEntry(e)),e.value},r.prototype.clear=function(){this._list.clear(),this._map={}},r.prototype.len=function(){return this._list.len()},r}(),ip={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function Ue(r){return r=Math.round(r),r<0?0:r>255?255:r}function iS(r){return r=Math.round(r),r<0?0:r>360?360:r}function Za(r){return r<0?0:r>1?1:r}function ru(r){var t=r;return t.length&&t.charAt(t.length-1)==="%"?Ue(parseFloat(t)/100*255):Ue(parseInt(t,10))}function Ni(r){var t=r;return t.length&&t.charAt(t.length-1)==="%"?Za(parseFloat(t)/100):Za(parseFloat(t))}function iu(r,t,e){return e<0?e+=1:e>1&&(e-=1),e*6<1?r+(t-r)*e*6:e*2<1?t:e*3<2?r+(t-r)*(2/3-e)*6:r}function Hr(r,t,e){return r+(t-r)*e}function Te(r,t,e,i,n){return r[0]=t,r[1]=e,r[2]=i,r[3]=n,r}function Ih(r,t){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r}var Ry=new So(20),zo=null;function on(r,t){zo&&Ih(zo,t),zo=Ry.put(r,zo||t.slice())}function me(r,t){if(r){t=t||[];var e=Ry.get(r);if(e)return Ih(t,e);r=r+"";var i=r.replace(/ /g,"").toLowerCase();if(i in ip)return Ih(t,ip[i]),on(r,t),t;var n=i.length;if(i.charAt(0)==="#"){if(n===4||n===5){var a=parseInt(i.slice(1,4),16);if(!(a>=0&&a<=4095)){Te(t,0,0,0,1);return}return Te(t,(a&3840)>>4|(a&3840)>>8,a&240|(a&240)>>4,a&15|(a&15)<<4,n===5?parseInt(i.slice(4),16)/15:1),on(r,t),t}else if(n===7||n===9){var a=parseInt(i.slice(1,7),16);if(!(a>=0&&a<=16777215)){Te(t,0,0,0,1);return}return Te(t,(a&16711680)>>16,(a&65280)>>8,a&255,n===9?parseInt(i.slice(7),16)/255:1),on(r,t),t}return}var o=i.indexOf("("),s=i.indexOf(")");if(o!==-1&&s+1===n){var l=i.substr(0,o),u=i.substr(o+1,s-(o+1)).split(","),h=1;switch(l){case"rgba":if(u.length!==4)return u.length===3?Te(t,+u[0],+u[1],+u[2],1):Te(t,0,0,0,1);h=Ni(u.pop());case"rgb":if(u.length>=3)return Te(t,ru(u[0]),ru(u[1]),ru(u[2]),u.length===3?h:Ni(u[3])),on(r,t),t;Te(t,0,0,0,1);return;case"hsla":if(u.length!==4){Te(t,0,0,0,1);return}return u[3]=Ni(u[3]),Ph(u,t),on(r,t),t;case"hsl":if(u.length!==3){Te(t,0,0,0,1);return}return Ph(u,t),on(r,t),t;default:return}}Te(t,0,0,0,1)}}function Ph(r,t){var e=(parseFloat(r[0])%360+360)%360/360,i=Ni(r[1]),n=Ni(r[2]),a=n<=.5?n*(i+1):n+i-n*i,o=n*2-a;return t=t||[],Te(t,Ue(iu(o,a,e+1/3)*255),Ue(iu(o,a,e)*255),Ue(iu(o,a,e-1/3)*255),1),r.length===4&&(t[3]=r[3]),t}function nS(r){if(r){var t=r[0]/255,e=r[1]/255,i=r[2]/255,n=Math.min(t,e,i),a=Math.max(t,e,i),o=a-n,s=(a+n)/2,l,u;if(o===0)l=0,u=0;else{s<.5?u=o/(a+n):u=o/(2-a-n);var h=((a-t)/6+o/2)/o,c=((a-e)/6+o/2)/o,f=((a-i)/6+o/2)/o;t===a?l=f-c:e===a?l=1/3+h-f:i===a&&(l=2/3+c-h),l<0&&(l+=1),l>1&&(l-=1)}var d=[l*360,u,s];return r[3]!=null&&d.push(r[3]),d}}function kh(r,t){var e=me(r);if(e){for(var i=0;i<3;i++)t<0?e[i]=e[i]*(1-t)|0:e[i]=(255-e[i])*t+e[i]|0,e[i]>255?e[i]=255:e[i]<0&&(e[i]=0);return Ki(e,e.length===4?"rgba":"rgb")}}function aS(r){var t=me(r);if(t)return((1<<24)+(t[0]<<16)+(t[1]<<8)+ +t[2]).toString(16).slice(1)}function Ly(r,t,e){if(!(!(t&&t.length)||!(r>=0&&r<=1))){e=e||[];var i=r*(t.length-1),n=Math.floor(i),a=Math.ceil(i),o=t[n],s=t[a],l=i-n;return e[0]=Ue(Hr(o[0],s[0],l)),e[1]=Ue(Hr(o[1],s[1],l)),e[2]=Ue(Hr(o[2],s[2],l)),e[3]=Za(Hr(o[3],s[3],l)),e}}var oS=Ly;function Xc(r,t,e){if(!(!(t&&t.length)||!(r>=0&&r<=1))){var i=r*(t.length-1),n=Math.floor(i),a=Math.ceil(i),o=me(t[n]),s=me(t[a]),l=i-n,u=Ki([Ue(Hr(o[0],s[0],l)),Ue(Hr(o[1],s[1],l)),Ue(Hr(o[2],s[2],l)),Za(Hr(o[3],s[3],l))],"rgba");return e?{color:u,leftIndex:n,rightIndex:a,value:i}:u}}var sS=Xc;function lS(r,t,e,i){var n=me(r);if(r)return n=nS(n),t!=null&&(n[0]=iS(t)),e!=null&&(n[1]=Ni(e)),i!=null&&(n[2]=Ni(i)),Ki(Ph(n),"rgba")}function uS(r,t){var e=me(r);if(e&&t!=null)return e[3]=Za(t),Ki(e,"rgba")}function Ki(r,t){if(!(!r||!r.length)){var e=r[0]+","+r[1]+","+r[2];return(t==="rgba"||t==="hsva"||t==="hsla")&&(e+=","+r[3]),t+"("+e+")"}}function Ka(r,t){var e=me(r);return e?(.299*e[0]+.587*e[1]+.114*e[2])*e[3]/255+(1-e[3])*t:0}function hS(){return Ki([Math.round(Math.random()*255),Math.round(Math.random()*255),Math.round(Math.random()*255)],"rgb")}var np=new So(100);function Hs(r){if(U(r)){var t=np.get(r);return t||(t=kh(r,-.1),np.put(r,t)),t}else if(sl(r)){var e=N({},r);return e.colorStops=V(r.colorStops,function(i){return{offset:i.offset,color:kh(i.color,-.1)}}),e}return r}const cS=Object.freeze(Object.defineProperty({__proto__:null,fastLerp:Ly,fastMapToColor:oS,lerp:Xc,lift:kh,liftColor:Hs,lum:Ka,mapToColor:sS,modifyAlpha:uS,modifyHSL:lS,parse:me,random:hS,stringify:Ki,toHex:aS},Symbol.toStringTag,{value:"Module"}));var Ws=Math.round;function Ja(r){var t;if(!r||r==="transparent")r="none";else if(typeof r=="string"&&r.indexOf("rgba")>-1){var e=me(r);e&&(r="rgb("+e[0]+","+e[1]+","+e[2]+")",t=e[3])}return{color:r,opacity:t??1}}var fS=1e-4;function Wr(r){return r<fS&&r>-1e-4}function Vo(r){return Ws(r*1e3)/1e3}function Rh(r){return Ws(r*1e4)/1e4}function dS(r){return"matrix("+Vo(r[0])+","+Vo(r[1])+","+Vo(r[2])+","+Vo(r[3])+","+Rh(r[4])+","+Rh(r[5])+")"}var pS={left:"start",right:"end",center:"middle",middle:"middle"};function vS(r,t,e){return e==="top"?r+=t/2:e==="bottom"&&(r-=t/2),r}function gS(r){return r&&(r.shadowBlur||r.shadowOffsetX||r.shadowOffsetY)}function mS(r){var t=r.style,e=r.getGlobalScale();return[t.shadowColor,(t.shadowBlur||0).toFixed(2),(t.shadowOffsetX||0).toFixed(2),(t.shadowOffsetY||0).toFixed(2),e[0],e[1]].join(",")}function Oy(r){return r&&!!r.image}function yS(r){return r&&!!r.svgElement}function qc(r){return Oy(r)||yS(r)}function Ey(r){return r.type==="linear"}function jy(r){return r.type==="radial"}function Ny(r){return r&&(r.type==="linear"||r.type==="radial")}function ul(r){return"url(#"+r+")"}function Fy(r){var t=r.getGlobalScale(),e=Math.max(t[0],t[1]);return Math.max(Math.ceil(Math.log(e)/Math.log(10)),1)}function By(r){var t=r.x||0,e=r.y||0,i=(r.rotation||0)*Oa,n=Q(r.scaleX,1),a=Q(r.scaleY,1),o=r.skewX||0,s=r.skewY||0,l=[];return(t||e)&&l.push("translate("+t+"px,"+e+"px)"),i&&l.push("rotate("+i+")"),(n!==1||a!==1)&&l.push("scale("+n+","+a+")"),(o||s)&&l.push("skew("+Ws(o*Oa)+"deg, "+Ws(s*Oa)+"deg)"),l.join(" ")}var _S=function(){return J.hasGlobalWindow&&tt(window.btoa)?function(r){return window.btoa(unescape(encodeURIComponent(r)))}:typeof Buffer<"u"?function(r){return Buffer.from(r).toString("base64")}:function(r){return null}}(),Lh=Array.prototype.slice;function yr(r,t,e){return(t-r)*e+r}function nu(r,t,e,i){for(var n=t.length,a=0;a<n;a++)r[a]=yr(t[a],e[a],i);return r}function bS(r,t,e,i){for(var n=t.length,a=n&&t[0].length,o=0;o<n;o++){r[o]||(r[o]=[]);for(var s=0;s<a;s++)r[o][s]=yr(t[o][s],e[o][s],i)}return r}function Ho(r,t,e,i){for(var n=t.length,a=0;a<n;a++)r[a]=t[a]+e[a]*i;return r}function ap(r,t,e,i){for(var n=t.length,a=n&&t[0].length,o=0;o<n;o++){r[o]||(r[o]=[]);for(var s=0;s<a;s++)r[o][s]=t[o][s]+e[o][s]*i}return r}function xS(r,t){for(var e=r.length,i=t.length,n=e>i?t:r,a=Math.min(e,i),o=n[a-1]||{color:[0,0,0,0],offset:0},s=a;s<Math.max(e,i);s++)n.push({offset:o.offset,color:o.color.slice()})}function wS(r,t,e){var i=r,n=t;if(!(!i.push||!n.push)){var a=i.length,o=n.length;if(a!==o){var s=a>o;if(s)i.length=o;else for(var l=a;l<o;l++)i.push(e===1?n[l]:Lh.call(n[l]))}for(var u=i[0]&&i[0].length,l=0;l<i.length;l++)if(e===1)isNaN(i[l])&&(i[l]=n[l]);else for(var h=0;h<u;h++)isNaN(i[l][h])&&(i[l][h]=n[l][h])}}function _s(r){if(ae(r)){var t=r.length;if(ae(r[0])){for(var e=[],i=0;i<t;i++)e.push(Lh.call(r[i]));return e}return Lh.call(r)}return r}function bs(r){return r[0]=Math.floor(r[0])||0,r[1]=Math.floor(r[1])||0,r[2]=Math.floor(r[2])||0,r[3]=r[3]==null?1:r[3],"rgba("+r.join(",")+")"}function SS(r){return ae(r&&r[0])?2:1}var Wo=0,xs=1,zy=2,Aa=3,Oh=4,Eh=5,op=6;function sp(r){return r===Oh||r===Eh}function Go(r){return r===xs||r===zy}var la=[0,0,0,0],CS=function(){function r(t){this.keyframes=[],this.discrete=!1,this._invalid=!1,this._needsSort=!1,this._lastFr=0,this._lastFrP=0,this.propName=t}return r.prototype.isFinished=function(){return this._finished},r.prototype.setFinished=function(){this._finished=!0,this._additiveTrack&&this._additiveTrack.setFinished()},r.prototype.needsAnimate=function(){return this.keyframes.length>=1},r.prototype.getAdditiveTrack=function(){return this._additiveTrack},r.prototype.addKeyframe=function(t,e,i){this._needsSort=!0;var n=this.keyframes,a=n.length,o=!1,s=op,l=e;if(ae(e)){var u=SS(e);s=u,(u===1&&!At(e[0])||u===2&&!At(e[0][0]))&&(o=!0)}else if(At(e)&&!qa(e))s=Wo;else if(U(e))if(!isNaN(+e))s=Wo;else{var h=me(e);h&&(l=h,s=Aa)}else if(sl(e)){var c=N({},l);c.colorStops=V(e.colorStops,function(d){return{offset:d.offset,color:me(d.color)}}),Ey(e)?s=Oh:jy(e)&&(s=Eh),l=c}a===0?this.valType=s:(s!==this.valType||s===op)&&(o=!0),this.discrete=this.discrete||o;var f={time:t,value:l,rawValue:e,percent:0};return i&&(f.easing=i,f.easingFunc=tt(i)?i:Ea[i]||Yc(i)),n.push(f),f},r.prototype.prepare=function(t,e){var i=this.keyframes;this._needsSort&&i.sort(function(v,g){return v.time-g.time});for(var n=this.valType,a=i.length,o=i[a-1],s=this.discrete,l=Go(n),u=sp(n),h=0;h<a;h++){var c=i[h],f=c.value,d=o.value;c.percent=c.time/t,s||(l&&h!==a-1?wS(f,d,n):u&&xS(f.colorStops,d.colorStops))}if(!s&&n!==Eh&&e&&this.needsAnimate()&&e.needsAnimate()&&n===e.valType&&!e._finished){this._additiveTrack=e;for(var p=i[0].value,h=0;h<a;h++)n===Wo?i[h].additiveValue=i[h].value-p:n===Aa?i[h].additiveValue=Ho([],i[h].value,p,-1):Go(n)&&(i[h].additiveValue=n===xs?Ho([],i[h].value,p,-1):ap([],i[h].value,p,-1))}},r.prototype.step=function(t,e){if(!this._finished){this._additiveTrack&&this._additiveTrack._finished&&(this._additiveTrack=null);var i=this._additiveTrack!=null,n=i?"additiveValue":"value",a=this.valType,o=this.keyframes,s=o.length,l=this.propName,u=a===Aa,h,c=this._lastFr,f=Math.min,d,p;if(s===1)d=p=o[0];else{if(e<0)h=0;else if(e<this._lastFrP){var v=f(c+1,s-1);for(h=v;h>=0&&!(o[h].percent<=e);h--);h=f(h,s-2)}else{for(h=c;h<s&&!(o[h].percent>e);h++);h=f(h-1,s-2)}p=o[h+1],d=o[h]}if(d&&p){this._lastFr=h,this._lastFrP=e;var g=p.percent-d.percent,m=g===0?1:f((e-d.percent)/g,1);p.easingFunc&&(m=p.easingFunc(m));var _=i?this._additiveValue:u?la:t[l];if((Go(a)||u)&&!_&&(_=this._additiveValue=[]),this.discrete)t[l]=m<1?d.rawValue:p.rawValue;else if(Go(a))a===xs?nu(_,d[n],p[n],m):bS(_,d[n],p[n],m);else if(sp(a)){var b=d[n],x=p[n],C=a===Oh;t[l]={type:C?"linear":"radial",x:yr(b.x,x.x,m),y:yr(b.y,x.y,m),colorStops:V(b.colorStops,function(T,M){var D=x.colorStops[M];return{offset:yr(T.offset,D.offset,m),color:bs(nu([],T.color,D.color,m))}}),global:x.global},C?(t[l].x2=yr(b.x2,x.x2,m),t[l].y2=yr(b.y2,x.y2,m)):t[l].r=yr(b.r,x.r,m)}else if(u)nu(_,d[n],p[n],m),i||(t[l]=bs(_));else{var S=yr(d[n],p[n],m);i?this._additiveValue=S:t[l]=S}i&&this._addToTarget(t)}}},r.prototype._addToTarget=function(t){var e=this.valType,i=this.propName,n=this._additiveValue;e===Wo?t[i]=t[i]+n:e===Aa?(me(t[i],la),Ho(la,la,n,1),t[i]=bs(la)):e===xs?Ho(t[i],t[i],n,1):e===zy&&ap(t[i],t[i],n,1)},r}(),Zc=function(){function r(t,e,i,n){if(this._tracks={},this._trackKeys=[],this._maxTime=0,this._started=0,this._clip=null,this._target=t,this._loop=e,e&&n){zc("Can' use additive animation on looped animation.");return}this._additiveAnimators=n,this._allowDiscrete=i}return r.prototype.getMaxTime=function(){return this._maxTime},r.prototype.getDelay=function(){return this._delay},r.prototype.getLoop=function(){return this._loop},r.prototype.getTarget=function(){return this._target},r.prototype.changeTarget=function(t){this._target=t},r.prototype.when=function(t,e,i){return this.whenWithKeys(t,e,vt(e),i)},r.prototype.whenWithKeys=function(t,e,i,n){for(var a=this._tracks,o=0;o<i.length;o++){var s=i[o],l=a[s];if(!l){l=a[s]=new CS(s);var u=void 0,h=this._getAdditiveTrack(s);if(h){var c=h.keyframes,f=c[c.length-1];u=f&&f.value,h.valType===Aa&&u&&(u=bs(u))}else u=this._target[s];if(u==null)continue;t>0&&l.addKeyframe(0,_s(u),n),this._trackKeys.push(s)}l.addKeyframe(t,_s(e[s]),n)}return this._maxTime=Math.max(this._maxTime,t),this},r.prototype.pause=function(){this._clip.pause(),this._paused=!0},r.prototype.resume=function(){this._clip.resume(),this._paused=!1},r.prototype.isPaused=function(){return!!this._paused},r.prototype.duration=function(t){return this._maxTime=t,this._force=!0,this},r.prototype._doneCallback=function(){this._setTracksFinished(),this._clip=null;var t=this._doneCbs;if(t)for(var e=t.length,i=0;i<e;i++)t[i].call(this)},r.prototype._abortedCallback=function(){this._setTracksFinished();var t=this.animation,e=this._abortedCbs;if(t&&t.removeClip(this._clip),this._clip=null,e)for(var i=0;i<e.length;i++)e[i].call(this)},r.prototype._setTracksFinished=function(){for(var t=this._tracks,e=this._trackKeys,i=0;i<e.length;i++)t[e[i]].setFinished()},r.prototype._getAdditiveTrack=function(t){var e,i=this._additiveAnimators;if(i)for(var n=0;n<i.length;n++){var a=i[n].getTrack(t);a&&(e=a)}return e},r.prototype.start=function(t){if(!(this._started>0)){this._started=1;for(var e=this,i=[],n=this._maxTime||0,a=0;a<this._trackKeys.length;a++){var o=this._trackKeys[a],s=this._tracks[o],l=this._getAdditiveTrack(o),u=s.keyframes,h=u.length;if(s.prepare(n,l),s.needsAnimate())if(!this._allowDiscrete&&s.discrete){var c=u[h-1];c&&(e._target[s.propName]=c.rawValue),s.setFinished()}else i.push(s)}if(i.length||this._force){var f=new eS({life:n,loop:this._loop,delay:this._delay||0,onframe:function(d){e._started=2;var p=e._additiveAnimators;if(p){for(var v=!1,g=0;g<p.length;g++)if(p[g]._clip){v=!0;break}v||(e._additiveAnimators=null)}for(var g=0;g<i.length;g++)i[g].step(e._target,d);var m=e._onframeCbs;if(m)for(var g=0;g<m.length;g++)m[g](e._target,d)},ondestroy:function(){e._doneCallback()}});this._clip=f,this.animation&&this.animation.addClip(f),t&&f.setEasing(t)}else this._doneCallback();return this}},r.prototype.stop=function(t){if(this._clip){var e=this._clip;t&&e.onframe(1),this._abortedCallback()}},r.prototype.delay=function(t){return this._delay=t,this},r.prototype.during=function(t){return t&&(this._onframeCbs||(this._onframeCbs=[]),this._onframeCbs.push(t)),this},r.prototype.done=function(t){return t&&(this._doneCbs||(this._doneCbs=[]),this._doneCbs.push(t)),this},r.prototype.aborted=function(t){return t&&(this._abortedCbs||(this._abortedCbs=[]),this._abortedCbs.push(t)),this},r.prototype.getClip=function(){return this._clip},r.prototype.getTrack=function(t){return this._tracks[t]},r.prototype.getTracks=function(){var t=this;return V(this._trackKeys,function(e){return t._tracks[e]})},r.prototype.stopTracks=function(t,e){if(!t.length||!this._clip)return!0;for(var i=this._tracks,n=this._trackKeys,a=0;a<t.length;a++){var o=i[t[a]];o&&!o.isFinished()&&(e?o.step(this._target,1):this._started===1&&o.step(this._target,0),o.setFinished())}for(var s=!0,a=0;a<n.length;a++)if(!i[n[a]].isFinished()){s=!1;break}return s&&this._abortedCallback(),s},r.prototype.saveTo=function(t,e,i){if(t){e=e||this._trackKeys;for(var n=0;n<e.length;n++){var a=e[n],o=this._tracks[a];if(!(!o||o.isFinished())){var s=o.keyframes,l=s[i?0:s.length-1];l&&(t[a]=_s(l.rawValue))}}}},r.prototype.__changeFinalValue=function(t,e){e=e||vt(t);for(var i=0;i<e.length;i++){var n=e[i],a=this._tracks[n];if(a){var o=a.keyframes;if(o.length>1){var s=o.pop();a.addKeyframe(s.time,t[n]),a.prepare(this._maxTime,a.getAdditiveTrack())}}}},r}();function Cn(){return new Date().getTime()}var TS=function(r){F(t,r);function t(e){var i=r.call(this)||this;return i._running=!1,i._time=0,i._pausedTime=0,i._pauseStart=0,i._paused=!1,e=e||{},i.stage=e.stage||{},i}return t.prototype.addClip=function(e){e.animation&&this.removeClip(e),this._head?(this._tail.next=e,e.prev=this._tail,e.next=null,this._tail=e):this._head=this._tail=e,e.animation=this},t.prototype.addAnimator=function(e){e.animation=this;var i=e.getClip();i&&this.addClip(i)},t.prototype.removeClip=function(e){if(e.animation){var i=e.prev,n=e.next;i?i.next=n:this._head=n,n?n.prev=i:this._tail=i,e.next=e.prev=e.animation=null}},t.prototype.removeAnimator=function(e){var i=e.getClip();i&&this.removeClip(i),e.animation=null},t.prototype.update=function(e){for(var i=Cn()-this._pausedTime,n=i-this._time,a=this._head;a;){var o=a.next,s=a.step(i,n);s&&(a.ondestroy(),this.removeClip(a)),a=o}this._time=i,e||(this.trigger("frame",n),this.stage.update&&this.stage.update())},t.prototype._startLoop=function(){var e=this;this._running=!0;function i(){e._running&&(Dh(i),!e._paused&&e.update())}Dh(i)},t.prototype.start=function(){this._running||(this._time=Cn(),this._pausedTime=0,this._startLoop())},t.prototype.stop=function(){this._running=!1},t.prototype.pause=function(){this._paused||(this._pauseStart=Cn(),this._paused=!0)},t.prototype.resume=function(){this._paused&&(this._pausedTime+=Cn()-this._pauseStart,this._paused=!1)},t.prototype.clear=function(){for(var e=this._head;e;){var i=e.next;e.prev=e.next=e.animation=null,e=i}this._head=this._tail=null},t.prototype.isFinished=function(){return this._head==null},t.prototype.animate=function(e,i){i=i||{},this.start();var n=new Zc(e,i.loop);return this.addAnimator(n),n},t}(ur),AS=300,au=J.domSupported,ou=function(){var r=["click","dblclick","mousewheel","wheel","mouseout","mouseup","mousedown","mousemove","contextmenu"],t=["touchstart","touchend","touchmove"],e={pointerdown:1,pointerup:1,pointermove:1,pointerout:1},i=V(r,function(n){var a=n.replace("mouse","pointer");return e.hasOwnProperty(a)?a:n});return{mouse:r,touch:t,pointer:i}}(),lp={mouse:["mousemove","mouseup"],pointer:["pointermove","pointerup"]},up=!1;function jh(r){var t=r.pointerType;return t==="pen"||t==="touch"}function MS(r){r.touching=!0,r.touchTimer!=null&&(clearTimeout(r.touchTimer),r.touchTimer=null),r.touchTimer=setTimeout(function(){r.touching=!1,r.touchTimer=null},700)}function su(r){r&&(r.zrByTouch=!0)}function DS(r,t){return Ae(r.dom,new IS(r,t),!0)}function Vy(r,t){for(var e=t,i=!1;e&&e.nodeType!==9&&!(i=e.domBelongToZr||e!==t&&e===r.painterRoot);)e=e.parentNode;return i}var IS=function(){function r(t,e){this.stopPropagation=Gt,this.stopImmediatePropagation=Gt,this.preventDefault=Gt,this.type=e.type,this.target=this.currentTarget=t.dom,this.pointerType=e.pointerType,this.clientX=e.clientX,this.clientY=e.clientY}return r}(),Ve={mousedown:function(r){r=Ae(this.dom,r),this.__mayPointerCapture=[r.zrX,r.zrY],this.trigger("mousedown",r)},mousemove:function(r){r=Ae(this.dom,r);var t=this.__mayPointerCapture;t&&(r.zrX!==t[0]||r.zrY!==t[1])&&this.__togglePointerCapture(!0),this.trigger("mousemove",r)},mouseup:function(r){r=Ae(this.dom,r),this.__togglePointerCapture(!1),this.trigger("mouseup",r)},mouseout:function(r){r=Ae(this.dom,r);var t=r.toElement||r.relatedTarget;Vy(this,t)||(this.__pointerCapturing&&(r.zrEventControl="no_globalout"),this.trigger("mouseout",r))},wheel:function(r){up=!0,r=Ae(this.dom,r),this.trigger("mousewheel",r)},mousewheel:function(r){up||(r=Ae(this.dom,r),this.trigger("mousewheel",r))},touchstart:function(r){r=Ae(this.dom,r),su(r),this.__lastTouchMoment=new Date,this.handler.processGesture(r,"start"),Ve.mousemove.call(this,r),Ve.mousedown.call(this,r)},touchmove:function(r){r=Ae(this.dom,r),su(r),this.handler.processGesture(r,"change"),Ve.mousemove.call(this,r)},touchend:function(r){r=Ae(this.dom,r),su(r),this.handler.processGesture(r,"end"),Ve.mouseup.call(this,r),+new Date-+this.__lastTouchMoment<AS&&Ve.click.call(this,r)},pointerdown:function(r){Ve.mousedown.call(this,r)},pointermove:function(r){jh(r)||Ve.mousemove.call(this,r)},pointerup:function(r){Ve.mouseup.call(this,r)},pointerout:function(r){jh(r)||Ve.mouseout.call(this,r)}};A(["click","dblclick","contextmenu"],function(r){Ve[r]=function(t){t=Ae(this.dom,t),this.trigger(r,t)}});var Nh={pointermove:function(r){jh(r)||Nh.mousemove.call(this,r)},pointerup:function(r){Nh.mouseup.call(this,r)},mousemove:function(r){this.trigger("mousemove",r)},mouseup:function(r){var t=this.__pointerCapturing;this.__togglePointerCapture(!1),this.trigger("mouseup",r),t&&(r.zrEventControl="only_globalout",this.trigger("mouseout",r))}};function PS(r,t){var e=t.domHandlers;J.pointerEventsSupported?A(ou.pointer,function(i){ws(t,i,function(n){e[i].call(r,n)})}):(J.touchEventsSupported&&A(ou.touch,function(i){ws(t,i,function(n){e[i].call(r,n),MS(t)})}),A(ou.mouse,function(i){ws(t,i,function(n){n=Uc(n),t.touching||e[i].call(r,n)})}))}function kS(r,t){J.pointerEventsSupported?A(lp.pointer,e):J.touchEventsSupported||A(lp.mouse,e);function e(i){function n(a){a=Uc(a),Vy(r,a.target)||(a=DS(r,a),t.domHandlers[i].call(r,a))}ws(t,i,n,{capture:!0})}}function ws(r,t,e,i){r.mounted[t]=e,r.listenerOpts[t]=i,Mh(r.domTarget,t,e,i)}function lu(r){var t=r.mounted;for(var e in t)t.hasOwnProperty(e)&&E1(r.domTarget,e,t[e],r.listenerOpts[e]);r.mounted={}}var hp=function(){function r(t,e){this.mounted={},this.listenerOpts={},this.touching=!1,this.domTarget=t,this.domHandlers=e}return r}(),RS=function(r){F(t,r);function t(e,i){var n=r.call(this)||this;return n.__pointerCapturing=!1,n.dom=e,n.painterRoot=i,n._localHandlerScope=new hp(e,Ve),au&&(n._globalHandlerScope=new hp(document,Nh)),PS(n,n._localHandlerScope),n}return t.prototype.dispose=function(){lu(this._localHandlerScope),au&&lu(this._globalHandlerScope)},t.prototype.setCursor=function(e){this.dom.style&&(this.dom.style.cursor=e||"default")},t.prototype.__togglePointerCapture=function(e){if(this.__mayPointerCapture=null,au&&+this.__pointerCapturing^+e){this.__pointerCapturing=e;var i=this._globalHandlerScope;e?kS(this,i):lu(i)}},t}(ur),Hy=1;J.hasGlobalWindow&&(Hy=Math.max(window.devicePixelRatio||window.screen&&window.screen.deviceXDPI/window.screen.logicalXDPI||1,1));var cp=Hy,Fh=.4,Bh="#333",zh="#ccc",LS="#eee",fp=bo,OS=5e-5;function hi(r){return r>OS||r<-5e-5}var ci=[],sn=[],uu=xr(),hu=Math.abs,Kc=function(){function r(){}return r.prototype.getLocalTransform=function(t){return r.getLocalTransform(this,t)},r.prototype.setPosition=function(t){this.x=t[0],this.y=t[1]},r.prototype.setScale=function(t){this.scaleX=t[0],this.scaleY=t[1]},r.prototype.setSkew=function(t){this.skewX=t[0],this.skewY=t[1]},r.prototype.setOrigin=function(t){this.originX=t[0],this.originY=t[1]},r.prototype.needLocalTransform=function(){return hi(this.rotation)||hi(this.x)||hi(this.y)||hi(this.scaleX-1)||hi(this.scaleY-1)||hi(this.skewX)||hi(this.skewY)},r.prototype.updateTransform=function(){var t=this.parent&&this.parent.transform,e=this.needLocalTransform(),i=this.transform;if(!(e||t)){i&&(fp(i),this.invTransform=null);return}i=i||xr(),e?this.getLocalTransform(i):fp(i),t&&(e?Ur(i,t,i):$c(i,t)),this.transform=i,this._resolveGlobalScaleRatio(i)},r.prototype._resolveGlobalScaleRatio=function(t){var e=this.globalScaleRatio;if(e!=null&&e!==1){this.getGlobalScale(ci);var i=ci[0]<0?-1:1,n=ci[1]<0?-1:1,a=((ci[0]-i)*e+i)/ci[0]||0,o=((ci[1]-n)*e+n)/ci[1]||0;t[0]*=a,t[1]*=a,t[2]*=o,t[3]*=o}this.invTransform=this.invTransform||xr(),wo(this.invTransform,t)},r.prototype.getComputedTransform=function(){for(var t=this,e=[];t;)e.push(t),t=t.parent;for(;t=e.pop();)t.updateTransform();return this.transform},r.prototype.setLocalTransform=function(t){if(t){var e=t[0]*t[0]+t[1]*t[1],i=t[2]*t[2]+t[3]*t[3],n=Math.atan2(t[1],t[0]),a=Math.PI/2+n-Math.atan2(t[3],t[2]);i=Math.sqrt(i)*Math.cos(a),e=Math.sqrt(e),this.skewX=a,this.skewY=0,this.rotation=-n,this.x=+t[4],this.y=+t[5],this.scaleX=e,this.scaleY=i,this.originX=0,this.originY=0}},r.prototype.decomposeTransform=function(){if(this.transform){var t=this.parent,e=this.transform;t&&t.transform&&(t.invTransform=t.invTransform||xr(),Ur(sn,t.invTransform,e),e=sn);var i=this.originX,n=this.originY;(i||n)&&(uu[4]=i,uu[5]=n,Ur(sn,e,uu),sn[4]-=i,sn[5]-=n,e=sn),this.setLocalTransform(e)}},r.prototype.getGlobalScale=function(t){var e=this.transform;return t=t||[],e?(t[0]=Math.sqrt(e[0]*e[0]+e[1]*e[1]),t[1]=Math.sqrt(e[2]*e[2]+e[3]*e[3]),e[0]<0&&(t[0]=-t[0]),e[3]<0&&(t[1]=-t[1]),t):(t[0]=1,t[1]=1,t)},r.prototype.transformCoordToLocal=function(t,e){var i=[t,e],n=this.invTransform;return n&&ie(i,i,n),i},r.prototype.transformCoordToGlobal=function(t,e){var i=[t,e],n=this.transform;return n&&ie(i,i,n),i},r.prototype.getLineScale=function(){var t=this.transform;return t&&hu(t[0]-1)>1e-10&&hu(t[3]-1)>1e-10?Math.sqrt(hu(t[0]*t[3]-t[2]*t[1])):1},r.prototype.copyTransform=function(t){Wy(this,t)},r.getLocalTransform=function(t,e){e=e||[];var i=t.originX||0,n=t.originY||0,a=t.scaleX,o=t.scaleY,s=t.anchorX,l=t.anchorY,u=t.rotation||0,h=t.x,c=t.y,f=t.skewX?Math.tan(t.skewX):0,d=t.skewY?Math.tan(-t.skewY):0;if(i||n||s||l){var p=i+s,v=n+l;e[4]=-p*a-f*v*o,e[5]=-v*o-d*p*a}else e[4]=e[5]=0;return e[0]=a,e[3]=o,e[1]=d*a,e[2]=f*o,u&&xo(e,e,u),e[4]+=i+h,e[5]+=n+c,e},r.initDefaultProps=function(){var t=r.prototype;t.scaleX=t.scaleY=t.globalScaleRatio=1,t.x=t.y=t.originX=t.originY=t.skewX=t.skewY=t.rotation=t.anchorX=t.anchorY=0}(),r}(),Qa=["x","y","originX","originY","anchorX","anchorY","rotation","scaleX","scaleY","skewX","skewY"];function Wy(r,t){for(var e=0;e<Qa.length;e++){var i=Qa[e];r[i]=t[i]}}var dp={};function ye(r,t){t=t||qr;var e=dp[t];e||(e=dp[t]=new So(500));var i=e.get(r);return i==null&&(i=Zr.measureText(r,t).width,e.put(r,i)),i}function pp(r,t,e,i){var n=ye(r,t),a=cl(t),o=Ma(0,n,e),s=xn(0,a,i),l=new mt(o,s,n,a);return l}function hl(r,t,e,i){var n=((r||"")+"").split(`
15
+ ***************************************************************************** */var _h=function(r,t){return _h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])},_h(r,t)};function F(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");_h(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var bh=function(){return bh=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++){e=arguments[i];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},bh.apply(this,arguments)};function pw(r,t){var e={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(r,i[n])&&(e[i[n]]=r[i[n]]);return e}function vw(r,t,e,i){var n=arguments.length,a=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,t,e,i);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(n<3?o(a):n>3?o(t,e,a):o(t,e))||a);return n>3&&a&&Object.defineProperty(t,e,a),a}function gw(r,t){return function(e,i){t(e,i,r)}}function mw(r,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,t)}function yw(r,t,e,i){function n(a){return a instanceof e?a:new e(function(o){o(a)})}return new(e||(e=Promise))(function(a,o){function s(h){try{u(i.next(h))}catch(c){o(c)}}function l(h){try{u(i.throw(h))}catch(c){o(c)}}function u(h){h.done?a(h.value):n(h.value).then(s,l)}u((i=i.apply(r,t||[])).next())})}function _w(r,t){var e={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,n,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(u){return function(h){return l([u,h])}}function l(u){if(i)throw new TypeError("Generator is already executing.");for(;e;)try{if(i=1,n&&(a=u[0]&2?n.return:u[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,u[1])).done)return a;switch(n=0,a&&(u=[u[0]&2,a.value]),u[0]){case 0:case 1:a=u;break;case 4:return e.label++,{value:u[1],done:!1};case 5:e.label++,n=u[1],u=[0];continue;case 7:u=e.ops.pop(),e.trys.pop();continue;default:if(a=e.trys,!(a=a.length>0&&a[a.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!a||u[1]>a[0]&&u[1]<a[3])){e.label=u[1];break}if(u[0]===6&&e.label<a[1]){e.label=a[1],a=u;break}if(a&&e.label<a[2]){e.label=a[2],e.ops.push(u);break}a[2]&&e.ops.pop(),e.trys.pop();continue}u=t.call(r,e)}catch(h){u=[6,h],n=0}finally{i=a=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}var Oc=Object.create?function(r,t,e,i){i===void 0&&(i=e),Object.defineProperty(r,i,{enumerable:!0,get:function(){return t[e]}})}:function(r,t,e,i){i===void 0&&(i=e),r[i]=t[e]};function bw(r,t){for(var e in r)e!=="default"&&!Object.prototype.hasOwnProperty.call(t,e)&&Oc(t,r,e)}function xh(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],i=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function iy(r,t){var e=typeof Symbol=="function"&&r[Symbol.iterator];if(!e)return r;var i=e.call(r),n,a=[],o;try{for(;(t===void 0||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(s){o={error:s}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return a}function xw(){for(var r=[],t=0;t<arguments.length;t++)r=r.concat(iy(arguments[t]));return r}function ww(){for(var r=0,t=0,e=arguments.length;t<e;t++)r+=arguments[t].length;for(var i=Array(r),n=0,t=0;t<e;t++)for(var a=arguments[t],o=0,s=a.length;o<s;o++,n++)i[n]=a[o];return i}function Sw(r,t,e){if(e||arguments.length===2)for(var i=0,n=t.length,a;i<n;i++)(a||!(i in t))&&(a||(a=Array.prototype.slice.call(t,0,i)),a[i]=t[i]);return r.concat(a||t)}function Xa(r){return this instanceof Xa?(this.v=r,this):new Xa(r)}function Cw(r,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=e.apply(r,t||[]),n,a=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(f){i[f]&&(n[f]=function(d){return new Promise(function(p,v){a.push([f,d,p,v])>1||s(f,d)})})}function s(f,d){try{l(i[f](d))}catch(p){c(a[0][3],p)}}function l(f){f.value instanceof Xa?Promise.resolve(f.value.v).then(u,h):c(a[0][2],f)}function u(f){s("next",f)}function h(f){s("throw",f)}function c(f,d){f(d),a.shift(),a.length&&s(a[0][0],a[0][1])}}function Tw(r){var t,e;return t={},i("next"),i("throw",function(n){throw n}),i("return"),t[Symbol.iterator]=function(){return this},t;function i(n,a){t[n]=r[n]?function(o){return(e=!e)?{value:Xa(r[n](o)),done:n==="return"}:a?a(o):o}:a}}function Aw(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=r[Symbol.asyncIterator],e;return t?t.call(r):(r=typeof xh=="function"?xh(r):r[Symbol.iterator](),e={},i("next"),i("throw"),i("return"),e[Symbol.asyncIterator]=function(){return this},e);function i(a){e[a]=r[a]&&function(o){return new Promise(function(s,l){o=r[a](o),n(s,l,o.done,o.value)})}}function n(a,o,s,l){Promise.resolve(l).then(function(u){a({value:u,done:s})},o)}}function Mw(r,t){return Object.defineProperty?Object.defineProperty(r,"raw",{value:t}):r.raw=t,r}var Dw=Object.create?function(r,t){Object.defineProperty(r,"default",{enumerable:!0,value:t})}:function(r,t){r.default=t};function Iw(r){if(r&&r.__esModule)return r;var t={};if(r!=null)for(var e in r)e!=="default"&&Object.prototype.hasOwnProperty.call(r,e)&&Oc(t,r,e);return Dw(t,r),t}function Pw(r){return r&&r.__esModule?r:{default:r}}function kw(r,t,e,i){if(e==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?r!==t||!i:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?i:e==="a"?i.call(r):i?i.value:t.get(r)}function Rw(r,t,e,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?r!==t||!n:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(r,e):n?n.value=e:t.set(r,e),e}const Lw=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return bh},__asyncDelegator:Tw,__asyncGenerator:Cw,__asyncValues:Aw,__await:Xa,__awaiter:yw,__classPrivateFieldGet:kw,__classPrivateFieldSet:Rw,__createBinding:Oc,__decorate:vw,__exportStar:bw,__extends:F,__generator:_w,__importDefault:Pw,__importStar:Iw,__makeTemplateObject:Mw,__metadata:mw,__param:gw,__read:iy,__rest:pw,__spread:xw,__spreadArray:Sw,__spreadArrays:ww,__values:xh},Symbol.toStringTag,{value:"Module"})),ny=aw(Lw);var fr={},dr={},$l={},Dd;function Ow(){return Dd||(Dd=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var t=1,e=function(){return"".concat(t++)};r.default=e}($l)),$l}var Kn={},Jn={},Yl={},Id;function ay(){return Id||(Id=1,function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var t=function(i){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:60,a=null;return function(){for(var o=this,s=arguments.length,l=new Array(s),u=0;u<s;u++)l[u]=arguments[u];clearTimeout(a),a=setTimeout(function(){i.apply(o,l)},n)}};r.default=t}(Yl)),Yl}var pr={},Pd;function Ec(){if(Pd)return pr;Pd=1,Object.defineProperty(pr,"__esModule",{value:!0}),pr.SizeSensorId=pr.SensorTabIndex=pr.SensorClassName=void 0;var r="size-sensor-id";pr.SizeSensorId=r;var t="size-sensor-object";pr.SensorClassName=t;var e="-1";return pr.SensorTabIndex=e,pr}var kd;function Ew(){if(kd)return Jn;kd=1,Object.defineProperty(Jn,"__esModule",{value:!0}),Jn.createSensor=void 0;var r=e(ay()),t=Ec();function e(n){return n&&n.__esModule?n:{default:n}}var i=function(a,o){var s=void 0,l=[],u=function(){getComputedStyle(a).position==="static"&&(a.style.position="relative");var v=document.createElement("object");return v.onload=function(){v.contentDocument.defaultView.addEventListener("resize",h),h()},v.style.display="block",v.style.position="absolute",v.style.top="0",v.style.left="0",v.style.height="100%",v.style.width="100%",v.style.overflow="hidden",v.style.pointerEvents="none",v.style.zIndex="-1",v.style.opacity="0",v.setAttribute("class",t.SensorClassName),v.setAttribute("tabindex",t.SensorTabIndex),v.type="text/html",a.appendChild(v),v.data="about:blank",v},h=(0,r.default)(function(){l.forEach(function(p){p(a)})}),c=function(v){s||(s=u()),l.indexOf(v)===-1&&l.push(v)},f=function(){s&&s.parentNode&&(s.contentDocument&&s.contentDocument.defaultView.removeEventListener("resize",h),s.parentNode.removeChild(s),a.removeAttribute(t.SizeSensorId),s=void 0,l=[],o&&o())},d=function(v){var g=l.indexOf(v);g!==-1&&l.splice(g,1),l.length===0&&s&&f()};return{element:a,bind:c,destroy:f,unbind:d}};return Jn.createSensor=i,Jn}var Qn={},Rd;function jw(){if(Rd)return Qn;Rd=1,Object.defineProperty(Qn,"__esModule",{value:!0}),Qn.createSensor=void 0;var r=Ec(),t=e(ay());function e(n){return n&&n.__esModule?n:{default:n}}var i=function(a,o){var s=void 0,l=[],u=(0,t.default)(function(){l.forEach(function(p){p(a)})}),h=function(){var v=new ResizeObserver(u);return v.observe(a),u(),v},c=function(v){s||(s=h()),l.indexOf(v)===-1&&l.push(v)},f=function(){s.disconnect(),l=[],s=void 0,a.removeAttribute(r.SizeSensorId),o&&o()},d=function(v){var g=l.indexOf(v);g!==-1&&l.splice(g,1),l.length===0&&s&&f()};return{element:a,bind:c,destroy:f,unbind:d}};return Qn.createSensor=i,Qn}var Ld;function Nw(){if(Ld)return Kn;Ld=1,Object.defineProperty(Kn,"__esModule",{value:!0}),Kn.createSensor=void 0;var r=Ew(),t=jw(),e=typeof ResizeObserver<"u"?t.createSensor:r.createSensor;return Kn.createSensor=e,Kn}var Od;function Fw(){if(Od)return dr;Od=1,Object.defineProperty(dr,"__esModule",{value:!0}),dr.removeSensor=dr.getSensor=dr.Sensors=void 0;var r=i(Ow()),t=Nw(),e=Ec();function i(l){return l&&l.__esModule?l:{default:l}}var n={};dr.Sensors=n;function a(l){l&&n[l]&&delete n[l]}var o=function(u){var h=u.getAttribute(e.SizeSensorId);if(h&&n[h])return n[h];var c=(0,r.default)();u.setAttribute(e.SizeSensorId,c);var f=(0,t.createSensor)(u,function(){return a(c)});return n[c]=f,f};dr.getSensor=o;var s=function(u){var h=u.element.getAttribute(e.SizeSensorId);u.destroy(),a(h)};return dr.removeSensor=s,dr}var Ed;function Bw(){if(Ed)return fr;Ed=1,Object.defineProperty(fr,"__esModule",{value:!0}),fr.ver=fr.clear=fr.bind=void 0;var r=Fw(),t=function(a,o){var s=(0,r.getSensor)(a);return s.bind(o),function(){s.unbind(o)}};fr.bind=t;var e=function(a){var o=(0,r.getSensor)(a);(0,r.removeSensor)(o)};fr.clear=e;var i="1.0.2";return fr.ver=i,fr}var ta={},jd;function zw(){if(jd)return ta;jd=1,Object.defineProperty(ta,"__esModule",{value:!0}),ta.pick=void 0;function r(t,e){var i={};return e.forEach(function(n){i[n]=t[n]}),i}return ta.pick=r,ta}var ea={},Nd;function Vw(){if(Nd)return ea;Nd=1,Object.defineProperty(ea,"__esModule",{value:!0}),ea.isFunction=void 0;function r(t){return typeof t=="function"}return ea.isFunction=r,ea}var ra={},Fd;function Hw(){if(Fd)return ra;Fd=1,Object.defineProperty(ra,"__esModule",{value:!0}),ra.isString=void 0;function r(t){return typeof t=="string"}return ra.isString=r,ra}var ia={},Bd;function Ww(){if(Bd)return ia;Bd=1,Object.defineProperty(ia,"__esModule",{value:!0}),ia.isEqual=void 0;var r=ny,t=r.__importDefault(Xx);return ia.isEqual=t.default,ia}Object.defineProperty(ry,"__esModule",{value:!0});var Er=ny,zd=Er.__importStar(at),Vd=Bw(),Hd=zw(),Xl=Vw(),Wd=Hw(),nn=Ww(),Gw=function(r){Er.__extends(t,r);function t(e){var i=r.call(this,e)||this;return i.echarts=e.echarts,i.ele=null,i.isInitialResize=!0,i}return t.prototype.componentDidMount=function(){this.renderNewEcharts()},t.prototype.componentDidUpdate=function(e){var i=this.props.shouldSetOption;if(!((0,Xl.isFunction)(i)&&!i(e,this.props))){if(!(0,nn.isEqual)(e.theme,this.props.theme)||!(0,nn.isEqual)(e.opts,this.props.opts)){this.dispose(),this.renderNewEcharts();return}var n=this.getEchartsInstance();(0,nn.isEqual)(e.onEvents,this.props.onEvents)||(this.offEvents(n,e.onEvents),this.bindEvents(n,this.props.onEvents));var a=["option","notMerge","replaceMerge","lazyUpdate","showLoading","loadingOption"];(0,nn.isEqual)((0,Hd.pick)(this.props,a),(0,Hd.pick)(e,a))||this.updateEChartsOption(),(!(0,nn.isEqual)(e.style,this.props.style)||!(0,nn.isEqual)(e.className,this.props.className))&&this.resize()}},t.prototype.componentWillUnmount=function(){this.dispose()},t.prototype.initEchartsInstance=function(){return Er.__awaiter(this,void 0,void 0,function(){var e=this;return Er.__generator(this,function(i){return[2,new Promise(function(n){e.echarts.init(e.ele,e.props.theme,e.props.opts);var a=e.getEchartsInstance();a.on("finished",function(){var o=e.ele.clientWidth,s=e.ele.clientHeight;e.echarts.dispose(e.ele);var l=Er.__assign({width:o,height:s},e.props.opts);n(e.echarts.init(e.ele,e.props.theme,l))})})]})})},t.prototype.getEchartsInstance=function(){return this.echarts.getInstanceByDom(this.ele)},t.prototype.dispose=function(){if(this.ele){try{(0,Vd.clear)(this.ele)}catch(e){console.warn(e)}this.echarts.dispose(this.ele)}},t.prototype.renderNewEcharts=function(){return Er.__awaiter(this,void 0,void 0,function(){var e,i,n,a,o,s,l=this;return Er.__generator(this,function(u){switch(u.label){case 0:return e=this.props,i=e.onEvents,n=e.onChartReady,a=e.autoResize,o=a===void 0?!0:a,[4,this.initEchartsInstance()];case 1:return u.sent(),s=this.updateEChartsOption(),this.bindEvents(s,i||{}),(0,Xl.isFunction)(n)&&n(s),this.ele&&o&&(0,Vd.bind)(this.ele,function(){l.resize()}),[2]}})})},t.prototype.bindEvents=function(e,i){function n(o,s){(0,Wd.isString)(o)&&(0,Xl.isFunction)(s)&&e.on(o,function(l){s(l,e)})}for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&n(a,i[a])},t.prototype.offEvents=function(e,i){if(i)for(var n in i)(0,Wd.isString)(n)&&e.off(n)},t.prototype.updateEChartsOption=function(){var e=this.props,i=e.option,n=e.notMerge,a=n===void 0?!1:n,o=e.replaceMerge,s=o===void 0?null:o,l=e.lazyUpdate,u=l===void 0?!1:l,h=e.showLoading,c=e.loadingOption,f=c===void 0?null:c,d=this.getEchartsInstance();return d.setOption(i,{notMerge:a,replaceMerge:s,lazyUpdate:u}),h?d.showLoading(f):d.hideLoading(),d},t.prototype.resize=function(){var e=this.getEchartsInstance();if(!this.isInitialResize)try{e.resize({width:"auto",height:"auto"})}catch(i){console.warn(i)}this.isInitialResize=!1},t.prototype.render=function(){var e=this,i=this.props,n=i.style,a=i.className,o=a===void 0?"":a,s=Er.__assign({height:300},n);return zd.default.createElement("div",{ref:function(l){e.ele=l},style:s,className:"echarts-for-react ".concat(o)})},t}(zd.PureComponent),Uw=ry.default=Gw,$w=function(){function r(){this.firefox=!1,this.ie=!1,this.edge=!1,this.newEdge=!1,this.weChat=!1}return r}(),Yw=function(){function r(){this.browser=new $w,this.node=!1,this.wxa=!1,this.worker=!1,this.svgSupported=!1,this.touchEventsSupported=!1,this.pointerEventsSupported=!1,this.domSupported=!1,this.transformSupported=!1,this.transform3dSupported=!1,this.hasGlobalWindow=typeof window<"u"}return r}(),J=new Yw;typeof wx=="object"&&typeof wx.getSystemInfoSync=="function"?(J.wxa=!0,J.touchEventsSupported=!0):typeof document>"u"&&typeof self<"u"?J.worker=!0:!J.hasGlobalWindow||"Deno"in window?(J.node=!0,J.svgSupported=!0):Xw(navigator.userAgent,J);function Xw(r,t){var e=t.browser,i=r.match(/Firefox\/([\d.]+)/),n=r.match(/MSIE\s([\d.]+)/)||r.match(/Trident\/.+?rv:(([\d.]+))/),a=r.match(/Edge?\/([\d.]+)/),o=/micromessenger/i.test(r);i&&(e.firefox=!0,e.version=i[1]),n&&(e.ie=!0,e.version=n[1]),a&&(e.edge=!0,e.version=a[1],e.newEdge=+a[1].split(".")[0]>18),o&&(e.weChat=!0),t.svgSupported=typeof SVGRect<"u",t.touchEventsSupported="ontouchstart"in window&&!e.ie&&!e.edge,t.pointerEventsSupported="onpointerdown"in window&&(e.edge||e.ie&&+e.version>=11),t.domSupported=typeof document<"u";var s=document.documentElement.style;t.transform3dSupported=(e.ie&&"transition"in s||e.edge||"WebKitCSSMatrix"in window&&"m11"in new WebKitCSSMatrix||"MozPerspective"in s)&&!("OTransition"in s),t.transformSupported=t.transform3dSupported||e.ie&&+e.version>=9}var jc=12,oy="sans-serif",qr=jc+"px "+oy,qw=20,Zw=100,Kw="007LLmW'55;N0500LLLLLLLLLL00NNNLzWW\\\\WQb\\0FWLg\\bWb\\WQ\\WrWWQ000CL5LLFLL0LL**F*gLLLL5F0LF\\FFF5.5N";function Jw(r){var t={};if(typeof JSON>"u")return t;for(var e=0;e<r.length;e++){var i=String.fromCharCode(e+32),n=(r.charCodeAt(e)-qw)/Zw;t[i]=n}return t}var Qw=Jw(Kw),Zr={createCanvas:function(){return typeof document<"u"&&document.createElement("canvas")},measureText:function(){var r,t;return function(e,i){if(!r){var n=Zr.createCanvas();r=n&&n.getContext("2d")}if(r)return t!==i&&(t=r.font=i||qr),r.measureText(e);e=e||"",i=i||qr;var a=/((?:\d+)?\.?\d*)px/.exec(i),o=a&&+a[1]||jc,s=0;if(i.indexOf("mono")>=0)s=o*e.length;else for(var l=0;l<e.length;l++){var u=Qw[e[l]];s+=u==null?o:u*o}return{width:s}}}(),loadImage:function(r,t,e){var i=new Image;return i.onload=t,i.onerror=e,i.src=r,i}};function sy(r){for(var t in Zr)r[t]&&(Zr[t]=r[t])}var ly=sr(["Function","RegExp","Date","Error","CanvasGradient","CanvasPattern","Image","Canvas"],function(r,t){return r["[object "+t+"]"]=!0,r},{}),uy=sr(["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64"],function(r,t){return r["[object "+t+"Array]"]=!0,r},{}),Gn=Object.prototype.toString,ol=Array.prototype,t1=ol.forEach,e1=ol.filter,Nc=ol.slice,r1=ol.map,Gd=function(){}.constructor,Eo=Gd?Gd.prototype:null,Fc="__proto__",i1=2311;function Bc(){return i1++}function zc(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];typeof console<"u"&&console.error.apply(console,r)}function it(r){if(r==null||typeof r!="object")return r;var t=r,e=Gn.call(r);if(e==="[object Array]"){if(!In(r)){t=[];for(var i=0,n=r.length;i<n;i++)t[i]=it(r[i])}}else if(uy[e]){if(!In(r)){var a=r.constructor;if(a.from)t=a.from(r);else{t=new a(r.length);for(var i=0,n=r.length;i<n;i++)t[i]=r[i]}}}else if(!ly[e]&&!In(r)&&!Hi(r)){t={};for(var o in r)r.hasOwnProperty(o)&&o!==Fc&&(t[o]=it(r[o]))}return t}function st(r,t,e){if(!Z(t)||!Z(r))return e?it(t):r;for(var i in t)if(t.hasOwnProperty(i)&&i!==Fc){var n=r[i],a=t[i];Z(a)&&Z(n)&&!H(a)&&!H(n)&&!Hi(a)&&!Hi(n)&&!wh(a)&&!wh(n)&&!In(a)&&!In(n)?st(n,a,e):(e||!(i in r))&&(r[i]=it(t[i]))}return r}function n1(r,t){for(var e=r[0],i=1,n=r.length;i<n;i++)e=st(e,r[i],t);return e}function N(r,t){if(Object.assign)Object.assign(r,t);else for(var e in t)t.hasOwnProperty(e)&&e!==Fc&&(r[e]=t[e]);return r}function lt(r,t,e){for(var i=vt(t),n=0,a=i.length;n<a;n++){var o=i[n];(e?t[o]!=null:r[o]==null)&&(r[o]=t[o])}return r}var a1=Zr.createCanvas;function pt(r,t){if(r){if(r.indexOf)return r.indexOf(t);for(var e=0,i=r.length;e<i;e++)if(r[e]===t)return e}return-1}function Vc(r,t){var e=r.prototype;function i(){}i.prototype=t.prototype,r.prototype=new i;for(var n in e)e.hasOwnProperty(n)&&(r.prototype[n]=e[n]);r.prototype.constructor=r,r.superClass=t}function xe(r,t,e){if(r="prototype"in r?r.prototype:r,t="prototype"in t?t.prototype:t,Object.getOwnPropertyNames)for(var i=Object.getOwnPropertyNames(t),n=0;n<i.length;n++){var a=i[n];a!=="constructor"&&(e?t[a]!=null:r[a]==null)&&(r[a]=t[a])}else lt(r,t,e)}function ae(r){return!r||typeof r=="string"?!1:typeof r.length=="number"}function A(r,t,e){if(r&&t)if(r.forEach&&r.forEach===t1)r.forEach(t,e);else if(r.length===+r.length)for(var i=0,n=r.length;i<n;i++)t.call(e,r[i],i,r);else for(var a in r)r.hasOwnProperty(a)&&t.call(e,r[a],a,r)}function V(r,t,e){if(!r)return[];if(!t)return ll(r);if(r.map&&r.map===r1)return r.map(t,e);for(var i=[],n=0,a=r.length;n<a;n++)i.push(t.call(e,r[n],n,r));return i}function sr(r,t,e,i){if(r&&t){for(var n=0,a=r.length;n<a;n++)e=t.call(i,e,r[n],n,r);return e}}function It(r,t,e){if(!r)return[];if(!t)return ll(r);if(r.filter&&r.filter===e1)return r.filter(t,e);for(var i=[],n=0,a=r.length;n<a;n++)t.call(e,r[n],n,r)&&i.push(r[n]);return i}function o1(r,t,e){if(r&&t){for(var i=0,n=r.length;i<n;i++)if(t.call(e,r[i],i,r))return r[i]}}function vt(r){if(!r)return[];if(Object.keys)return Object.keys(r);var t=[];for(var e in r)r.hasOwnProperty(e)&&t.push(e);return t}function s1(r,t){for(var e=[],i=2;i<arguments.length;i++)e[i-2]=arguments[i];return function(){return r.apply(t,e.concat(Nc.call(arguments)))}}var ct=Eo&&tt(Eo.bind)?Eo.call.bind(Eo.bind):s1;function Ct(r){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];return function(){return r.apply(this,t.concat(Nc.call(arguments)))}}function H(r){return Array.isArray?Array.isArray(r):Gn.call(r)==="[object Array]"}function tt(r){return typeof r=="function"}function U(r){return typeof r=="string"}function js(r){return Gn.call(r)==="[object String]"}function At(r){return typeof r=="number"}function Z(r){var t=typeof r;return t==="function"||!!r&&t==="object"}function wh(r){return!!ly[Gn.call(r)]}function oe(r){return!!uy[Gn.call(r)]}function Hi(r){return typeof r=="object"&&typeof r.nodeType=="number"&&typeof r.ownerDocument=="object"}function sl(r){return r.colorStops!=null}function l1(r){return r.image!=null}function u1(r){return Gn.call(r)==="[object RegExp]"}function qa(r){return r!==r}function On(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];for(var e=0,i=r.length;e<i;e++)if(r[e]!=null)return r[e]}function Q(r,t){return r??t}function La(r,t,e){return r??t??e}function ll(r){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];return Nc.apply(r,t)}function Hc(r){if(typeof r=="number")return[r,r,r,r];var t=r.length;return t===2?[r[0],r[1],r[0],r[1]]:t===3?[r[0],r[1],r[2],r[1]]:r}function be(r,t){if(!r)throw new Error(t)}function Ge(r){return r==null?null:typeof r.trim=="function"?r.trim():r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}var hy="__ec_primitive__";function Ns(r){r[hy]=!0}function In(r){return r[hy]}var h1=function(){function r(){this.data={}}return r.prototype.delete=function(t){var e=this.has(t);return e&&delete this.data[t],e},r.prototype.has=function(t){return this.data.hasOwnProperty(t)},r.prototype.get=function(t){return this.data[t]},r.prototype.set=function(t,e){return this.data[t]=e,this},r.prototype.keys=function(){return vt(this.data)},r.prototype.forEach=function(t){var e=this.data;for(var i in e)e.hasOwnProperty(i)&&t(e[i],i)},r}(),cy=typeof Map=="function";function c1(){return cy?new Map:new h1}var fy=function(){function r(t){var e=H(t);this.data=c1();var i=this;t instanceof r?t.each(n):t&&A(t,n);function n(a,o){e?i.set(a,o):i.set(o,a)}}return r.prototype.hasKey=function(t){return this.data.has(t)},r.prototype.get=function(t){return this.data.get(t)},r.prototype.set=function(t,e){return this.data.set(t,e),e},r.prototype.each=function(t,e){this.data.forEach(function(i,n){t.call(e,i,n)})},r.prototype.keys=function(){var t=this.data.keys();return cy?Array.from(t):t},r.prototype.removeKey=function(t){this.data.delete(t)},r}();function nt(r){return new fy(r)}function dy(r,t){for(var e=new r.constructor(r.length+t.length),i=0;i<r.length;i++)e[i]=r[i];for(var n=r.length,i=0;i<t.length;i++)e[i+n]=t[i];return e}function _o(r,t){var e;if(Object.create)e=Object.create(r);else{var i=function(){};i.prototype=r,e=new i}return t&&N(e,t),e}function f1(r){var t=r.style;t.webkitUserSelect="none",t.userSelect="none",t.webkitTapHighlightColor="rgba(0,0,0,0)",t["-webkit-touch-callout"]="none"}function Wi(r,t){return r.hasOwnProperty(t)}function Gt(){}var Oa=180/Math.PI;const d1=Object.freeze(Object.defineProperty({__proto__:null,HashMap:fy,RADIAN_TO_DEGREE:Oa,assert:be,bind:ct,clone:it,concatArray:dy,createCanvas:a1,createHashMap:nt,createObject:_o,curry:Ct,defaults:lt,disableUserSelect:f1,each:A,eqNaN:qa,extend:N,filter:It,find:o1,guid:Bc,hasOwn:Wi,indexOf:pt,inherits:Vc,isArray:H,isArrayLike:ae,isBuiltInObject:wh,isDom:Hi,isFunction:tt,isGradientObject:sl,isImagePatternObject:l1,isNumber:At,isObject:Z,isPrimitive:In,isRegExp:u1,isString:U,isStringSafe:js,isTypedArray:oe,keys:vt,logError:zc,map:V,merge:st,mergeAll:n1,mixin:xe,noop:Gt,normalizeCssArray:Hc,reduce:sr,retrieve:On,retrieve2:Q,retrieve3:La,setAsPrimitive:Ns,slice:ll,trim:Ge},Symbol.toStringTag,{value:"Module"}));function Zi(r,t){return r==null&&(r=0),t==null&&(t=0),[r,t]}function p1(r,t){return r[0]=t[0],r[1]=t[1],r}function py(r){return[r[0],r[1]]}function v1(r,t,e){return r[0]=t,r[1]=e,r}function Sh(r,t,e){return r[0]=t[0]+e[0],r[1]=t[1]+e[1],r}function g1(r,t,e,i){return r[0]=t[0]+e[0]*i,r[1]=t[1]+e[1]*i,r}function vy(r,t,e){return r[0]=t[0]-e[0],r[1]=t[1]-e[1],r}function Wc(r){return Math.sqrt(Gc(r))}var m1=Wc;function Gc(r){return r[0]*r[0]+r[1]*r[1]}var y1=Gc;function _1(r,t,e){return r[0]=t[0]*e[0],r[1]=t[1]*e[1],r}function b1(r,t,e){return r[0]=t[0]/e[0],r[1]=t[1]/e[1],r}function x1(r,t){return r[0]*t[0]+r[1]*t[1]}function gs(r,t,e){return r[0]=t[0]*e,r[1]=t[1]*e,r}function gy(r,t){var e=Wc(t);return e===0?(r[0]=0,r[1]=0):(r[0]=t[0]/e,r[1]=t[1]/e),r}function Fs(r,t){return Math.sqrt((r[0]-t[0])*(r[0]-t[0])+(r[1]-t[1])*(r[1]-t[1]))}var my=Fs;function yy(r,t){return(r[0]-t[0])*(r[0]-t[0])+(r[1]-t[1])*(r[1]-t[1])}var Ei=yy;function w1(r,t){return r[0]=-t[0],r[1]=-t[1],r}function S1(r,t,e,i){return r[0]=t[0]+i*(e[0]-t[0]),r[1]=t[1]+i*(e[1]-t[1]),r}function ie(r,t,e){var i=t[0],n=t[1];return r[0]=e[0]*i+e[2]*n+e[4],r[1]=e[1]*i+e[3]*n+e[5],r}function Br(r,t,e){return r[0]=Math.min(t[0],e[0]),r[1]=Math.min(t[1],e[1]),r}function zr(r,t,e){return r[0]=Math.max(t[0],e[0]),r[1]=Math.max(t[1],e[1]),r}const C1=Object.freeze(Object.defineProperty({__proto__:null,add:Sh,applyTransform:ie,clone:py,copy:p1,create:Zi,dist:my,distSquare:Ei,distance:Fs,distanceSquare:yy,div:b1,dot:x1,len:Wc,lenSquare:Gc,length:m1,lengthSquare:y1,lerp:S1,max:zr,min:Br,mul:_1,negate:w1,normalize:gy,scale:gs,scaleAndAdd:g1,set:v1,sub:vy},Symbol.toStringTag,{value:"Module"}));var an=function(){function r(t,e){this.target=t,this.topTarget=e&&e.topTarget}return r}(),T1=function(){function r(t){this.handler=t,t.on("mousedown",this._dragStart,this),t.on("mousemove",this._drag,this),t.on("mouseup",this._dragEnd,this)}return r.prototype._dragStart=function(t){for(var e=t.target;e&&!e.draggable;)e=e.parent||e.__hostTarget;e&&(this._draggingTarget=e,e.dragging=!0,this._x=t.offsetX,this._y=t.offsetY,this.handler.dispatchToElement(new an(e,t),"dragstart",t.event))},r.prototype._drag=function(t){var e=this._draggingTarget;if(e){var i=t.offsetX,n=t.offsetY,a=i-this._x,o=n-this._y;this._x=i,this._y=n,e.drift(a,o,t),this.handler.dispatchToElement(new an(e,t),"drag",t.event);var s=this.handler.findHover(i,n,e).target,l=this._dropTarget;this._dropTarget=s,e!==s&&(l&&s!==l&&this.handler.dispatchToElement(new an(l,t),"dragleave",t.event),s&&s!==l&&this.handler.dispatchToElement(new an(s,t),"dragenter",t.event))}},r.prototype._dragEnd=function(t){var e=this._draggingTarget;e&&(e.dragging=!1),this.handler.dispatchToElement(new an(e,t),"dragend",t.event),this._dropTarget&&this.handler.dispatchToElement(new an(this._dropTarget,t),"drop",t.event),this._draggingTarget=null,this._dropTarget=null},r}(),ur=function(){function r(t){t&&(this._$eventProcessor=t)}return r.prototype.on=function(t,e,i,n){this._$handlers||(this._$handlers={});var a=this._$handlers;if(typeof e=="function"&&(n=i,i=e,e=null),!i||!t)return this;var o=this._$eventProcessor;e!=null&&o&&o.normalizeQuery&&(e=o.normalizeQuery(e)),a[t]||(a[t]=[]);for(var s=0;s<a[t].length;s++)if(a[t][s].h===i)return this;var l={h:i,query:e,ctx:n||this,callAtLast:i.zrEventfulCallAtLast},u=a[t].length-1,h=a[t][u];return h&&h.callAtLast?a[t].splice(u,0,l):a[t].push(l),this},r.prototype.isSilent=function(t){var e=this._$handlers;return!e||!e[t]||!e[t].length},r.prototype.off=function(t,e){var i=this._$handlers;if(!i)return this;if(!t)return this._$handlers={},this;if(e){if(i[t]){for(var n=[],a=0,o=i[t].length;a<o;a++)i[t][a].h!==e&&n.push(i[t][a]);i[t]=n}i[t]&&i[t].length===0&&delete i[t]}else delete i[t];return this},r.prototype.trigger=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];if(!this._$handlers)return this;var n=this._$handlers[t],a=this._$eventProcessor;if(n)for(var o=e.length,s=n.length,l=0;l<s;l++){var u=n[l];if(!(a&&a.filter&&u.query!=null&&!a.filter(t,u.query)))switch(o){case 0:u.h.call(u.ctx);break;case 1:u.h.call(u.ctx,e[0]);break;case 2:u.h.call(u.ctx,e[0],e[1]);break;default:u.h.apply(u.ctx,e);break}}return a&&a.afterTrigger&&a.afterTrigger(t),this},r.prototype.triggerWithContext=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];if(!this._$handlers)return this;var n=this._$handlers[t],a=this._$eventProcessor;if(n)for(var o=e.length,s=e[o-1],l=n.length,u=0;u<l;u++){var h=n[u];if(!(a&&a.filter&&h.query!=null&&!a.filter(t,h.query)))switch(o){case 0:h.h.call(s);break;case 1:h.h.call(s,e[0]);break;case 2:h.h.call(s,e[0],e[1]);break;default:h.h.apply(s,e.slice(1,o-1));break}}return a&&a.afterTrigger&&a.afterTrigger(t),this},r}(),A1=Math.log(2);function Ch(r,t,e,i,n,a){var o=i+"-"+n,s=r.length;if(a.hasOwnProperty(o))return a[o];if(t===1){var l=Math.round(Math.log((1<<s)-1&~n)/A1);return r[e][l]}for(var u=i|1<<e,h=e+1;i&1<<h;)h++;for(var c=0,f=0,d=0;f<s;f++){var p=1<<f;p&n||(c+=(d%2?-1:1)*r[e][f]*Ch(r,t-1,h,u,n|p,a),d++)}return a[o]=c,c}function Ud(r,t){var e=[[r[0],r[1],1,0,0,0,-t[0]*r[0],-t[0]*r[1]],[0,0,0,r[0],r[1],1,-t[1]*r[0],-t[1]*r[1]],[r[2],r[3],1,0,0,0,-t[2]*r[2],-t[2]*r[3]],[0,0,0,r[2],r[3],1,-t[3]*r[2],-t[3]*r[3]],[r[4],r[5],1,0,0,0,-t[4]*r[4],-t[4]*r[5]],[0,0,0,r[4],r[5],1,-t[5]*r[4],-t[5]*r[5]],[r[6],r[7],1,0,0,0,-t[6]*r[6],-t[6]*r[7]],[0,0,0,r[6],r[7],1,-t[7]*r[6],-t[7]*r[7]]],i={},n=Ch(e,8,0,0,0,i);if(n!==0){for(var a=[],o=0;o<8;o++)for(var s=0;s<8;s++)a[s]==null&&(a[s]=0),a[s]+=((o+s)%2?-1:1)*Ch(e,7,o===0?1:0,1<<o,1<<s,i)/n*t[o];return function(l,u,h){var c=u*a[6]+h*a[7]+1;l[0]=(u*a[0]+h*a[1]+a[2])/c,l[1]=(u*a[3]+h*a[4]+a[5])/c}}}var $d="___zrEVENTSAVED",ql=[];function M1(r,t,e,i,n){return Th(ql,t,i,n,!0)&&Th(r,e,ql[0],ql[1])}function Th(r,t,e,i,n){if(t.getBoundingClientRect&&J.domSupported&&!_y(t)){var a=t[$d]||(t[$d]={}),o=D1(t,a),s=I1(o,a,n);if(s)return s(r,e,i),!0}return!1}function D1(r,t){var e=t.markers;if(e)return e;e=t.markers=[];for(var i=["left","right"],n=["top","bottom"],a=0;a<4;a++){var o=document.createElement("div"),s=o.style,l=a%2,u=(a>>1)%2;s.cssText=["position: absolute","visibility: hidden","padding: 0","margin: 0","border-width: 0","user-select: none","width:0","height:0",i[l]+":0",n[u]+":0",i[1-l]+":auto",n[1-u]+":auto",""].join("!important;"),r.appendChild(o),e.push(o)}return e}function I1(r,t,e){for(var i=e?"invTrans":"trans",n=t[i],a=t.srcCoords,o=[],s=[],l=!0,u=0;u<4;u++){var h=r[u].getBoundingClientRect(),c=2*u,f=h.left,d=h.top;o.push(f,d),l=l&&a&&f===a[c]&&d===a[c+1],s.push(r[u].offsetLeft,r[u].offsetTop)}return l&&n?n:(t.srcCoords=o,t[i]=e?Ud(s,o):Ud(o,s))}function _y(r){return r.nodeName.toUpperCase()==="CANVAS"}var P1=/([&<>"'])/g,k1={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function Kt(r){return r==null?"":(r+"").replace(P1,function(t,e){return k1[e]})}var R1=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Zl=[],L1=J.browser.firefox&&+J.browser.version.split(".")[0]<39;function Ah(r,t,e,i){return e=e||{},i?Yd(r,t,e):L1&&t.layerX!=null&&t.layerX!==t.offsetX?(e.zrX=t.layerX,e.zrY=t.layerY):t.offsetX!=null?(e.zrX=t.offsetX,e.zrY=t.offsetY):Yd(r,t,e),e}function Yd(r,t,e){if(J.domSupported&&r.getBoundingClientRect){var i=t.clientX,n=t.clientY;if(_y(r)){var a=r.getBoundingClientRect();e.zrX=i-a.left,e.zrY=n-a.top;return}else if(Th(Zl,r,i,n)){e.zrX=Zl[0],e.zrY=Zl[1];return}}e.zrX=e.zrY=0}function Uc(r){return r||window.event}function Ae(r,t,e){if(t=Uc(t),t.zrX!=null)return t;var i=t.type,n=i&&i.indexOf("touch")>=0;if(n){var o=i!=="touchend"?t.targetTouches[0]:t.changedTouches[0];o&&Ah(r,o,t,e)}else{Ah(r,t,t,e);var a=O1(t);t.zrDelta=a?a/120:-(t.detail||0)/3}var s=t.button;return t.which==null&&s!==void 0&&R1.test(t.type)&&(t.which=s&1?1:s&2?3:s&4?2:0),t}function O1(r){var t=r.wheelDelta;if(t)return t;var e=r.deltaX,i=r.deltaY;if(e==null||i==null)return t;var n=Math.abs(i!==0?i:e),a=i>0?-1:i<0?1:e>0?-1:1;return 3*n*a}function Mh(r,t,e,i){r.addEventListener(t,e,i)}function E1(r,t,e,i){r.removeEventListener(t,e,i)}var by=function(r){r.preventDefault(),r.stopPropagation(),r.cancelBubble=!0},j1=function(){function r(){this._track=[]}return r.prototype.recognize=function(t,e,i){return this._doTrack(t,e,i),this._recognize(t)},r.prototype.clear=function(){return this._track.length=0,this},r.prototype._doTrack=function(t,e,i){var n=t.touches;if(n){for(var a={points:[],touches:[],target:e,event:t},o=0,s=n.length;o<s;o++){var l=n[o],u=Ah(i,l,{});a.points.push([u.zrX,u.zrY]),a.touches.push(l)}this._track.push(a)}},r.prototype._recognize=function(t){for(var e in Kl)if(Kl.hasOwnProperty(e)){var i=Kl[e](this._track,t);if(i)return i}},r}();function Xd(r){var t=r[1][0]-r[0][0],e=r[1][1]-r[0][1];return Math.sqrt(t*t+e*e)}function N1(r){return[(r[0][0]+r[1][0])/2,(r[0][1]+r[1][1])/2]}var Kl={pinch:function(r,t){var e=r.length;if(e){var i=(r[e-1]||{}).points,n=(r[e-2]||{}).points||i;if(n&&n.length>1&&i&&i.length>1){var a=Xd(i)/Xd(n);!isFinite(a)&&(a=1),t.pinchScale=a;var o=N1(i);return t.pinchX=o[0],t.pinchY=o[1],{type:"pinch",target:r[0].target,event:t}}}}};function xr(){return[1,0,0,1,0,0]}function bo(r){return r[0]=1,r[1]=0,r[2]=0,r[3]=1,r[4]=0,r[5]=0,r}function $c(r,t){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r}function Ur(r,t,e){var i=t[0]*e[0]+t[2]*e[1],n=t[1]*e[0]+t[3]*e[1],a=t[0]*e[2]+t[2]*e[3],o=t[1]*e[2]+t[3]*e[3],s=t[0]*e[4]+t[2]*e[5]+t[4],l=t[1]*e[4]+t[3]*e[5]+t[5];return r[0]=i,r[1]=n,r[2]=a,r[3]=o,r[4]=s,r[5]=l,r}function En(r,t,e){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4]+e[0],r[5]=t[5]+e[1],r}function xo(r,t,e,i){i===void 0&&(i=[0,0]);var n=t[0],a=t[2],o=t[4],s=t[1],l=t[3],u=t[5],h=Math.sin(e),c=Math.cos(e);return r[0]=n*c+s*h,r[1]=-n*h+s*c,r[2]=a*c+l*h,r[3]=-a*h+c*l,r[4]=c*(o-i[0])+h*(u-i[1])+i[0],r[5]=c*(u-i[1])-h*(o-i[0])+i[1],r}function xy(r,t,e){var i=e[0],n=e[1];return r[0]=t[0]*i,r[1]=t[1]*n,r[2]=t[2]*i,r[3]=t[3]*n,r[4]=t[4]*i,r[5]=t[5]*n,r}function wo(r,t){var e=t[0],i=t[2],n=t[4],a=t[1],o=t[3],s=t[5],l=e*o-a*i;return l?(l=1/l,r[0]=o*l,r[1]=-a*l,r[2]=-i*l,r[3]=e*l,r[4]=(i*s-o*n)*l,r[5]=(a*n-e*s)*l,r):null}function F1(r){var t=xr();return $c(t,r),t}const B1=Object.freeze(Object.defineProperty({__proto__:null,clone:F1,copy:$c,create:xr,identity:bo,invert:wo,mul:Ur,rotate:xo,scale:xy,translate:En},Symbol.toStringTag,{value:"Module"}));var wt=function(){function r(t,e){this.x=t||0,this.y=e||0}return r.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this},r.prototype.clone=function(){return new r(this.x,this.y)},r.prototype.set=function(t,e){return this.x=t,this.y=e,this},r.prototype.equal=function(t){return t.x===this.x&&t.y===this.y},r.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this},r.prototype.scale=function(t){this.x*=t,this.y*=t},r.prototype.scaleAndAdd=function(t,e){this.x+=t.x*e,this.y+=t.y*e},r.prototype.sub=function(t){return this.x-=t.x,this.y-=t.y,this},r.prototype.dot=function(t){return this.x*t.x+this.y*t.y},r.prototype.len=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},r.prototype.lenSquare=function(){return this.x*this.x+this.y*this.y},r.prototype.normalize=function(){var t=this.len();return this.x/=t,this.y/=t,this},r.prototype.distance=function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},r.prototype.distanceSquare=function(t){var e=this.x-t.x,i=this.y-t.y;return e*e+i*i},r.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this},r.prototype.transform=function(t){if(t){var e=this.x,i=this.y;return this.x=t[0]*e+t[2]*i+t[4],this.y=t[1]*e+t[3]*i+t[5],this}},r.prototype.toArray=function(t){return t[0]=this.x,t[1]=this.y,t},r.prototype.fromArray=function(t){this.x=t[0],this.y=t[1]},r.set=function(t,e,i){t.x=e,t.y=i},r.copy=function(t,e){t.x=e.x,t.y=e.y},r.len=function(t){return Math.sqrt(t.x*t.x+t.y*t.y)},r.lenSquare=function(t){return t.x*t.x+t.y*t.y},r.dot=function(t,e){return t.x*e.x+t.y*e.y},r.add=function(t,e,i){t.x=e.x+i.x,t.y=e.y+i.y},r.sub=function(t,e,i){t.x=e.x-i.x,t.y=e.y-i.y},r.scale=function(t,e,i){t.x=e.x*i,t.y=e.y*i},r.scaleAndAdd=function(t,e,i,n){t.x=e.x+i.x*n,t.y=e.y+i.y*n},r.lerp=function(t,e,i,n){var a=1-n;t.x=a*e.x+n*i.x,t.y=a*e.y+n*i.y},r}(),jo=Math.min,No=Math.max,oi=new wt,si=new wt,li=new wt,ui=new wt,na=new wt,aa=new wt,mt=function(){function r(t,e,i,n){i<0&&(t=t+i,i=-i),n<0&&(e=e+n,n=-n),this.x=t,this.y=e,this.width=i,this.height=n}return r.prototype.union=function(t){var e=jo(t.x,this.x),i=jo(t.y,this.y);isFinite(this.x)&&isFinite(this.width)?this.width=No(t.x+t.width,this.x+this.width)-e:this.width=t.width,isFinite(this.y)&&isFinite(this.height)?this.height=No(t.y+t.height,this.y+this.height)-i:this.height=t.height,this.x=e,this.y=i},r.prototype.applyTransform=function(t){r.applyTransform(this,this,t)},r.prototype.calculateTransform=function(t){var e=this,i=t.width/e.width,n=t.height/e.height,a=xr();return En(a,a,[-e.x,-e.y]),xy(a,a,[i,n]),En(a,a,[t.x,t.y]),a},r.prototype.intersect=function(t,e){if(!t)return!1;t instanceof r||(t=r.create(t));var i=this,n=i.x,a=i.x+i.width,o=i.y,s=i.y+i.height,l=t.x,u=t.x+t.width,h=t.y,c=t.y+t.height,f=!(a<l||u<n||s<h||c<o);if(e){var d=1/0,p=0,v=Math.abs(a-l),g=Math.abs(u-n),m=Math.abs(s-h),_=Math.abs(c-o),b=Math.min(v,g),x=Math.min(m,_);a<l||u<n?b>p&&(p=b,v<g?wt.set(aa,-v,0):wt.set(aa,g,0)):b<d&&(d=b,v<g?wt.set(na,v,0):wt.set(na,-g,0)),s<h||c<o?x>p&&(p=x,m<_?wt.set(aa,0,-m):wt.set(aa,0,_)):b<d&&(d=b,m<_?wt.set(na,0,m):wt.set(na,0,-_))}return e&&wt.copy(e,f?na:aa),f},r.prototype.contain=function(t,e){var i=this;return t>=i.x&&t<=i.x+i.width&&e>=i.y&&e<=i.y+i.height},r.prototype.clone=function(){return new r(this.x,this.y,this.width,this.height)},r.prototype.copy=function(t){r.copy(this,t)},r.prototype.plain=function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},r.prototype.isFinite=function(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)},r.prototype.isZero=function(){return this.width===0||this.height===0},r.create=function(t){return new r(t.x,t.y,t.width,t.height)},r.copy=function(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},r.applyTransform=function(t,e,i){if(!i){t!==e&&r.copy(t,e);return}if(i[1]<1e-5&&i[1]>-1e-5&&i[2]<1e-5&&i[2]>-1e-5){var n=i[0],a=i[3],o=i[4],s=i[5];t.x=e.x*n+o,t.y=e.y*a+s,t.width=e.width*n,t.height=e.height*a,t.width<0&&(t.x+=t.width,t.width=-t.width),t.height<0&&(t.y+=t.height,t.height=-t.height);return}oi.x=li.x=e.x,oi.y=ui.y=e.y,si.x=ui.x=e.x+e.width,si.y=li.y=e.y+e.height,oi.transform(i),ui.transform(i),si.transform(i),li.transform(i),t.x=jo(oi.x,si.x,li.x,ui.x),t.y=jo(oi.y,si.y,li.y,ui.y);var l=No(oi.x,si.x,li.x,ui.x),u=No(oi.y,si.y,li.y,ui.y);t.width=l-t.x,t.height=u-t.y},r}(),wy="silent";function z1(r,t,e){return{type:r,event:e,target:t.target,topTarget:t.topTarget,cancelBubble:!1,offsetX:e.zrX,offsetY:e.zrY,gestureEvent:e.gestureEvent,pinchX:e.pinchX,pinchY:e.pinchY,pinchScale:e.pinchScale,wheelDelta:e.zrDelta,zrByTouch:e.zrByTouch,which:e.which,stop:V1}}function V1(){by(this.event)}var H1=function(r){F(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.handler=null,e}return t.prototype.dispose=function(){},t.prototype.setCursor=function(){},t}(ur),oa=function(){function r(t,e){this.x=t,this.y=e}return r}(),W1=["click","dblclick","mousewheel","mouseout","mouseup","mousedown","mousemove","contextmenu"],Jl=new mt(0,0,0,0),Sy=function(r){F(t,r);function t(e,i,n,a,o){var s=r.call(this)||this;return s._hovered=new oa(0,0),s.storage=e,s.painter=i,s.painterRoot=a,s._pointerSize=o,n=n||new H1,s.proxy=null,s.setHandlerProxy(n),s._draggingMgr=new T1(s),s}return t.prototype.setHandlerProxy=function(e){this.proxy&&this.proxy.dispose(),e&&(A(W1,function(i){e.on&&e.on(i,this[i],this)},this),e.handler=this),this.proxy=e},t.prototype.mousemove=function(e){var i=e.zrX,n=e.zrY,a=Cy(this,i,n),o=this._hovered,s=o.target;s&&!s.__zr&&(o=this.findHover(o.x,o.y),s=o.target);var l=this._hovered=a?new oa(i,n):this.findHover(i,n),u=l.target,h=this.proxy;h.setCursor&&h.setCursor(u?u.cursor:"default"),s&&u!==s&&this.dispatchToElement(o,"mouseout",e),this.dispatchToElement(l,"mousemove",e),u&&u!==s&&this.dispatchToElement(l,"mouseover",e)},t.prototype.mouseout=function(e){var i=e.zrEventControl;i!=="only_globalout"&&this.dispatchToElement(this._hovered,"mouseout",e),i!=="no_globalout"&&this.trigger("globalout",{type:"globalout",event:e})},t.prototype.resize=function(){this._hovered=new oa(0,0)},t.prototype.dispatch=function(e,i){var n=this[e];n&&n.call(this,i)},t.prototype.dispose=function(){this.proxy.dispose(),this.storage=null,this.proxy=null,this.painter=null},t.prototype.setCursorStyle=function(e){var i=this.proxy;i.setCursor&&i.setCursor(e)},t.prototype.dispatchToElement=function(e,i,n){e=e||{};var a=e.target;if(!(a&&a.silent)){for(var o="on"+i,s=z1(i,e,n);a&&(a[o]&&(s.cancelBubble=!!a[o].call(a,s)),a.trigger(i,s),a=a.__hostTarget?a.__hostTarget:a.parent,!s.cancelBubble););s.cancelBubble||(this.trigger(i,s),this.painter&&this.painter.eachOtherLayer&&this.painter.eachOtherLayer(function(l){typeof l[o]=="function"&&l[o].call(l,s),l.trigger&&l.trigger(i,s)}))}},t.prototype.findHover=function(e,i,n){var a=this.storage.getDisplayList(),o=new oa(e,i);if(qd(a,o,e,i,n),this._pointerSize&&!o.target){for(var s=[],l=this._pointerSize,u=l/2,h=new mt(e-u,i-u,l,l),c=a.length-1;c>=0;c--){var f=a[c];f!==n&&!f.ignore&&!f.ignoreCoarsePointer&&(!f.parent||!f.parent.ignoreCoarsePointer)&&(Jl.copy(f.getBoundingRect()),f.transform&&Jl.applyTransform(f.transform),Jl.intersect(h)&&s.push(f))}if(s.length)for(var d=4,p=Math.PI/12,v=Math.PI*2,g=0;g<u;g+=d)for(var m=0;m<v;m+=p){var _=e+g*Math.cos(m),b=i+g*Math.sin(m);if(qd(s,o,_,b,n),o.target)return o}}return o},t.prototype.processGesture=function(e,i){this._gestureMgr||(this._gestureMgr=new j1);var n=this._gestureMgr;i==="start"&&n.clear();var a=n.recognize(e,this.findHover(e.zrX,e.zrY,null).target,this.proxy.dom);if(i==="end"&&n.clear(),a){var o=a.type;e.gestureEvent=o;var s=new oa;s.target=a.target,this.dispatchToElement(s,o,a.event)}},t}(ur);A(["click","mousedown","mouseup","mousewheel","dblclick","contextmenu"],function(r){Sy.prototype[r]=function(t){var e=t.zrX,i=t.zrY,n=Cy(this,e,i),a,o;if((r!=="mouseup"||!n)&&(a=this.findHover(e,i),o=a.target),r==="mousedown")this._downEl=o,this._downPoint=[t.zrX,t.zrY],this._upEl=o;else if(r==="mouseup")this._upEl=o;else if(r==="click"){if(this._downEl!==this._upEl||!this._downPoint||my(this._downPoint,[t.zrX,t.zrY])>4)return;this._downPoint=null}this.dispatchToElement(a,r,t)}});function G1(r,t,e){if(r[r.rectHover?"rectContain":"contain"](t,e)){for(var i=r,n=void 0,a=!1;i;){if(i.ignoreClip&&(a=!0),!a){var o=i.getClipPath();if(o&&!o.contain(t,e))return!1}i.silent&&(n=!0);var s=i.__hostTarget;i=s||i.parent}return n?wy:!0}return!1}function qd(r,t,e,i,n){for(var a=r.length-1;a>=0;a--){var o=r[a],s=void 0;if(o!==n&&!o.ignore&&(s=G1(o,e,i))&&(!t.topTarget&&(t.topTarget=o),s!==wy)){t.target=o;break}}}function Cy(r,t,e){var i=r.painter;return t<0||t>i.getWidth()||e<0||e>i.getHeight()}var Ty=32,sa=7;function U1(r){for(var t=0;r>=Ty;)t|=r&1,r>>=1;return r+t}function Zd(r,t,e,i){var n=t+1;if(n===e)return 1;if(i(r[n++],r[t])<0){for(;n<e&&i(r[n],r[n-1])<0;)n++;$1(r,t,n)}else for(;n<e&&i(r[n],r[n-1])>=0;)n++;return n-t}function $1(r,t,e){for(e--;t<e;){var i=r[t];r[t++]=r[e],r[e--]=i}}function Kd(r,t,e,i,n){for(i===t&&i++;i<e;i++){for(var a=r[i],o=t,s=i,l;o<s;)l=o+s>>>1,n(a,r[l])<0?s=l:o=l+1;var u=i-o;switch(u){case 3:r[o+3]=r[o+2];case 2:r[o+2]=r[o+1];case 1:r[o+1]=r[o];break;default:for(;u>0;)r[o+u]=r[o+u-1],u--}r[o]=a}}function Ql(r,t,e,i,n,a){var o=0,s=0,l=1;if(a(r,t[e+n])>0){for(s=i-n;l<s&&a(r,t[e+n+l])>0;)o=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s),o+=n,l+=n}else{for(s=n+1;l<s&&a(r,t[e+n-l])<=0;)o=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s);var u=o;o=n-l,l=n-u}for(o++;o<l;){var h=o+(l-o>>>1);a(r,t[e+h])>0?o=h+1:l=h}return l}function tu(r,t,e,i,n,a){var o=0,s=0,l=1;if(a(r,t[e+n])<0){for(s=n+1;l<s&&a(r,t[e+n-l])<0;)o=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s);var u=o;o=n-l,l=n-u}else{for(s=i-n;l<s&&a(r,t[e+n+l])>=0;)o=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s),o+=n,l+=n}for(o++;o<l;){var h=o+(l-o>>>1);a(r,t[e+h])<0?l=h:o=h+1}return l}function Y1(r,t){var e=sa,i,n,a=0,o=[];i=[],n=[];function s(d,p){i[a]=d,n[a]=p,a+=1}function l(){for(;a>1;){var d=a-2;if(d>=1&&n[d-1]<=n[d]+n[d+1]||d>=2&&n[d-2]<=n[d]+n[d-1])n[d-1]<n[d+1]&&d--;else if(n[d]>n[d+1])break;h(d)}}function u(){for(;a>1;){var d=a-2;d>0&&n[d-1]<n[d+1]&&d--,h(d)}}function h(d){var p=i[d],v=n[d],g=i[d+1],m=n[d+1];n[d]=v+m,d===a-3&&(i[d+1]=i[d+2],n[d+1]=n[d+2]),a--;var _=tu(r[g],r,p,v,0,t);p+=_,v-=_,v!==0&&(m=Ql(r[p+v-1],r,g,m,m-1,t),m!==0&&(v<=m?c(p,v,g,m):f(p,v,g,m)))}function c(d,p,v,g){var m=0;for(m=0;m<p;m++)o[m]=r[d+m];var _=0,b=v,x=d;if(r[x++]=r[b++],--g===0){for(m=0;m<p;m++)r[x+m]=o[_+m];return}if(p===1){for(m=0;m<g;m++)r[x+m]=r[b+m];r[x+g]=o[_];return}for(var C=e,S,T,M;;){S=0,T=0,M=!1;do if(t(r[b],o[_])<0){if(r[x++]=r[b++],T++,S=0,--g===0){M=!0;break}}else if(r[x++]=o[_++],S++,T=0,--p===1){M=!0;break}while((S|T)<C);if(M)break;do{if(S=tu(r[b],o,_,p,0,t),S!==0){for(m=0;m<S;m++)r[x+m]=o[_+m];if(x+=S,_+=S,p-=S,p<=1){M=!0;break}}if(r[x++]=r[b++],--g===0){M=!0;break}if(T=Ql(o[_],r,b,g,0,t),T!==0){for(m=0;m<T;m++)r[x+m]=r[b+m];if(x+=T,b+=T,g-=T,g===0){M=!0;break}}if(r[x++]=o[_++],--p===1){M=!0;break}C--}while(S>=sa||T>=sa);if(M)break;C<0&&(C=0),C+=2}if(e=C,e<1&&(e=1),p===1){for(m=0;m<g;m++)r[x+m]=r[b+m];r[x+g]=o[_]}else{if(p===0)throw new Error;for(m=0;m<p;m++)r[x+m]=o[_+m]}}function f(d,p,v,g){var m=0;for(m=0;m<g;m++)o[m]=r[v+m];var _=d+p-1,b=g-1,x=v+g-1,C=0,S=0;if(r[x--]=r[_--],--p===0){for(C=x-(g-1),m=0;m<g;m++)r[C+m]=o[m];return}if(g===1){for(x-=p,_-=p,S=x+1,C=_+1,m=p-1;m>=0;m--)r[S+m]=r[C+m];r[x]=o[b];return}for(var T=e;;){var M=0,D=0,I=!1;do if(t(o[b],r[_])<0){if(r[x--]=r[_--],M++,D=0,--p===0){I=!0;break}}else if(r[x--]=o[b--],D++,M=0,--g===1){I=!0;break}while((M|D)<T);if(I)break;do{if(M=p-tu(o[b],r,d,p,p-1,t),M!==0){for(x-=M,_-=M,p-=M,S=x+1,C=_+1,m=M-1;m>=0;m--)r[S+m]=r[C+m];if(p===0){I=!0;break}}if(r[x--]=o[b--],--g===1){I=!0;break}if(D=g-Ql(r[_],o,0,g,g-1,t),D!==0){for(x-=D,b-=D,g-=D,S=x+1,C=b+1,m=0;m<D;m++)r[S+m]=o[C+m];if(g<=1){I=!0;break}}if(r[x--]=r[_--],--p===0){I=!0;break}T--}while(M>=sa||D>=sa);if(I)break;T<0&&(T=0),T+=2}if(e=T,e<1&&(e=1),g===1){for(x-=p,_-=p,S=x+1,C=_+1,m=p-1;m>=0;m--)r[S+m]=r[C+m];r[x]=o[b]}else{if(g===0)throw new Error;for(C=x-(g-1),m=0;m<g;m++)r[C+m]=o[m]}}return{mergeRuns:l,forceMergeRuns:u,pushRun:s}}function ms(r,t,e,i){e||(e=0),i||(i=r.length);var n=i-e;if(!(n<2)){var a=0;if(n<Ty){a=Zd(r,e,i,t),Kd(r,e,i,e+a,t);return}var o=Y1(r,t),s=U1(n);do{if(a=Zd(r,e,i,t),a<s){var l=n;l>s&&(l=s),Kd(r,e,e+l,e+a,t),a=l}o.pushRun(e,a),o.mergeRuns(),n-=a,e+=a}while(n!==0);o.forceMergeRuns()}}var ji=1,ys=2,Ta=4,Jd=!1;function eu(){Jd||(Jd=!0,console.warn("z / z2 / zlevel of displayable is invalid, which may cause unexpected errors"))}function Qd(r,t){return r.zlevel===t.zlevel?r.z===t.z?r.z2-t.z2:r.z-t.z:r.zlevel-t.zlevel}var X1=function(){function r(){this._roots=[],this._displayList=[],this._displayListLen=0,this.displayableSortFunc=Qd}return r.prototype.traverse=function(t,e){for(var i=0;i<this._roots.length;i++)this._roots[i].traverse(t,e)},r.prototype.getDisplayList=function(t,e){e=e||!1;var i=this._displayList;return(t||!i.length)&&this.updateDisplayList(e),i},r.prototype.updateDisplayList=function(t){this._displayListLen=0;for(var e=this._roots,i=this._displayList,n=0,a=e.length;n<a;n++)this._updateAndAddDisplayable(e[n],null,t);i.length=this._displayListLen,ms(i,Qd)},r.prototype._updateAndAddDisplayable=function(t,e,i){if(!(t.ignore&&!i)){t.beforeUpdate(),t.update(),t.afterUpdate();var n=t.getClipPath();if(t.ignoreClip)e=null;else if(n){e?e=e.slice():e=[];for(var a=n,o=t;a;)a.parent=o,a.updateTransform(),e.push(a),o=a,a=a.getClipPath()}if(t.childrenRef){for(var s=t.childrenRef(),l=0;l<s.length;l++){var u=s[l];t.__dirty&&(u.__dirty|=ji),this._updateAndAddDisplayable(u,e,i)}t.__dirty=0}else{var h=t;e&&e.length?h.__clipPaths=e:h.__clipPaths&&h.__clipPaths.length>0&&(h.__clipPaths=[]),isNaN(h.z)&&(eu(),h.z=0),isNaN(h.z2)&&(eu(),h.z2=0),isNaN(h.zlevel)&&(eu(),h.zlevel=0),this._displayList[this._displayListLen++]=h}var c=t.getDecalElement&&t.getDecalElement();c&&this._updateAndAddDisplayable(c,e,i);var f=t.getTextGuideLine();f&&this._updateAndAddDisplayable(f,e,i);var d=t.getTextContent();d&&this._updateAndAddDisplayable(d,e,i)}},r.prototype.addRoot=function(t){t.__zr&&t.__zr.storage===this||this._roots.push(t)},r.prototype.delRoot=function(t){if(t instanceof Array){for(var e=0,i=t.length;e<i;e++)this.delRoot(t[e]);return}var n=pt(this._roots,t);n>=0&&this._roots.splice(n,1)},r.prototype.delAllRoots=function(){this._roots=[],this._displayList=[],this._displayListLen=0},r.prototype.getRoots=function(){return this._roots},r.prototype.dispose=function(){this._displayList=null,this._roots=null},r}(),Dh;Dh=J.hasGlobalWindow&&(window.requestAnimationFrame&&window.requestAnimationFrame.bind(window)||window.msRequestAnimationFrame&&window.msRequestAnimationFrame.bind(window)||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame)||function(r){return setTimeout(r,16)};var Ea={linear:function(r){return r},quadraticIn:function(r){return r*r},quadraticOut:function(r){return r*(2-r)},quadraticInOut:function(r){return(r*=2)<1?.5*r*r:-.5*(--r*(r-2)-1)},cubicIn:function(r){return r*r*r},cubicOut:function(r){return--r*r*r+1},cubicInOut:function(r){return(r*=2)<1?.5*r*r*r:.5*((r-=2)*r*r+2)},quarticIn:function(r){return r*r*r*r},quarticOut:function(r){return 1- --r*r*r*r},quarticInOut:function(r){return(r*=2)<1?.5*r*r*r*r:-.5*((r-=2)*r*r*r-2)},quinticIn:function(r){return r*r*r*r*r},quinticOut:function(r){return--r*r*r*r*r+1},quinticInOut:function(r){return(r*=2)<1?.5*r*r*r*r*r:.5*((r-=2)*r*r*r*r+2)},sinusoidalIn:function(r){return 1-Math.cos(r*Math.PI/2)},sinusoidalOut:function(r){return Math.sin(r*Math.PI/2)},sinusoidalInOut:function(r){return .5*(1-Math.cos(Math.PI*r))},exponentialIn:function(r){return r===0?0:Math.pow(1024,r-1)},exponentialOut:function(r){return r===1?1:1-Math.pow(2,-10*r)},exponentialInOut:function(r){return r===0?0:r===1?1:(r*=2)<1?.5*Math.pow(1024,r-1):.5*(-Math.pow(2,-10*(r-1))+2)},circularIn:function(r){return 1-Math.sqrt(1-r*r)},circularOut:function(r){return Math.sqrt(1- --r*r)},circularInOut:function(r){return(r*=2)<1?-.5*(Math.sqrt(1-r*r)-1):.5*(Math.sqrt(1-(r-=2)*r)+1)},elasticIn:function(r){var t,e=.1,i=.4;return r===0?0:r===1?1:(!e||e<1?(e=1,t=i/4):t=i*Math.asin(1/e)/(2*Math.PI),-(e*Math.pow(2,10*(r-=1))*Math.sin((r-t)*(2*Math.PI)/i)))},elasticOut:function(r){var t,e=.1,i=.4;return r===0?0:r===1?1:(!e||e<1?(e=1,t=i/4):t=i*Math.asin(1/e)/(2*Math.PI),e*Math.pow(2,-10*r)*Math.sin((r-t)*(2*Math.PI)/i)+1)},elasticInOut:function(r){var t,e=.1,i=.4;return r===0?0:r===1?1:(!e||e<1?(e=1,t=i/4):t=i*Math.asin(1/e)/(2*Math.PI),(r*=2)<1?-.5*(e*Math.pow(2,10*(r-=1))*Math.sin((r-t)*(2*Math.PI)/i)):e*Math.pow(2,-10*(r-=1))*Math.sin((r-t)*(2*Math.PI)/i)*.5+1)},backIn:function(r){var t=1.70158;return r*r*((t+1)*r-t)},backOut:function(r){var t=1.70158;return--r*r*((t+1)*r+t)+1},backInOut:function(r){var t=2.5949095;return(r*=2)<1?.5*(r*r*((t+1)*r-t)):.5*((r-=2)*r*((t+1)*r+t)+2)},bounceIn:function(r){return 1-Ea.bounceOut(1-r)},bounceOut:function(r){return r<1/2.75?7.5625*r*r:r<2/2.75?7.5625*(r-=1.5/2.75)*r+.75:r<2.5/2.75?7.5625*(r-=2.25/2.75)*r+.9375:7.5625*(r-=2.625/2.75)*r+.984375},bounceInOut:function(r){return r<.5?Ea.bounceIn(r*2)*.5:Ea.bounceOut(r*2-1)*.5+.5}},Fo=Math.pow,$r=Math.sqrt,Ay=1e-8,My=1e-4,tp=$r(3),Bo=1/3,nr=Zi(),Ie=Zi(),Pn=Zi();function Vr(r){return r>-1e-8&&r<Ay}function Dy(r){return r>Ay||r<-1e-8}function Wt(r,t,e,i,n){var a=1-n;return a*a*(a*r+3*n*t)+n*n*(n*i+3*a*e)}function ep(r,t,e,i,n){var a=1-n;return 3*(((t-r)*a+2*(e-t)*n)*a+(i-e)*n*n)}function Bs(r,t,e,i,n,a){var o=i+3*(t-e)-r,s=3*(e-t*2+r),l=3*(t-r),u=r-n,h=s*s-3*o*l,c=s*l-9*o*u,f=l*l-3*s*u,d=0;if(Vr(h)&&Vr(c))if(Vr(s))a[0]=0;else{var p=-l/s;p>=0&&p<=1&&(a[d++]=p)}else{var v=c*c-4*h*f;if(Vr(v)){var g=c/h,p=-s/o+g,m=-g/2;p>=0&&p<=1&&(a[d++]=p),m>=0&&m<=1&&(a[d++]=m)}else if(v>0){var _=$r(v),b=h*s+1.5*o*(-c+_),x=h*s+1.5*o*(-c-_);b<0?b=-Fo(-b,Bo):b=Fo(b,Bo),x<0?x=-Fo(-x,Bo):x=Fo(x,Bo);var p=(-s-(b+x))/(3*o);p>=0&&p<=1&&(a[d++]=p)}else{var C=(2*h*s-3*o*c)/(2*$r(h*h*h)),S=Math.acos(C)/3,T=$r(h),M=Math.cos(S),p=(-s-2*T*M)/(3*o),m=(-s+T*(M+tp*Math.sin(S)))/(3*o),D=(-s+T*(M-tp*Math.sin(S)))/(3*o);p>=0&&p<=1&&(a[d++]=p),m>=0&&m<=1&&(a[d++]=m),D>=0&&D<=1&&(a[d++]=D)}}return d}function Iy(r,t,e,i,n){var a=6*e-12*t+6*r,o=9*t+3*i-3*r-9*e,s=3*t-3*r,l=0;if(Vr(o)){if(Dy(a)){var u=-s/a;u>=0&&u<=1&&(n[l++]=u)}}else{var h=a*a-4*o*s;if(Vr(h))n[0]=-a/(2*o);else if(h>0){var c=$r(h),u=(-a+c)/(2*o),f=(-a-c)/(2*o);u>=0&&u<=1&&(n[l++]=u),f>=0&&f<=1&&(n[l++]=f)}}return l}function zs(r,t,e,i,n,a){var o=(t-r)*n+r,s=(e-t)*n+t,l=(i-e)*n+e,u=(s-o)*n+o,h=(l-s)*n+s,c=(h-u)*n+u;a[0]=r,a[1]=o,a[2]=u,a[3]=c,a[4]=c,a[5]=h,a[6]=l,a[7]=i}function q1(r,t,e,i,n,a,o,s,l,u,h){var c,f=.005,d=1/0,p,v,g,m;nr[0]=l,nr[1]=u;for(var _=0;_<1;_+=.05)Ie[0]=Wt(r,e,n,o,_),Ie[1]=Wt(t,i,a,s,_),g=Ei(nr,Ie),g<d&&(c=_,d=g);d=1/0;for(var b=0;b<32&&!(f<My);b++)p=c-f,v=c+f,Ie[0]=Wt(r,e,n,o,p),Ie[1]=Wt(t,i,a,s,p),g=Ei(Ie,nr),p>=0&&g<d?(c=p,d=g):(Pn[0]=Wt(r,e,n,o,v),Pn[1]=Wt(t,i,a,s,v),m=Ei(Pn,nr),v<=1&&m<d?(c=v,d=m):f*=.5);return $r(d)}function Z1(r,t,e,i,n,a,o,s,l){for(var u=r,h=t,c=0,f=1/l,d=1;d<=l;d++){var p=d*f,v=Wt(r,e,n,o,p),g=Wt(t,i,a,s,p),m=v-u,_=g-h;c+=Math.sqrt(m*m+_*_),u=v,h=g}return c}function ce(r,t,e,i){var n=1-i;return n*(n*r+2*i*t)+i*i*e}function rp(r,t,e,i){return 2*((1-i)*(t-r)+i*(e-t))}function K1(r,t,e,i,n){var a=r-2*t+e,o=2*(t-r),s=r-i,l=0;if(Vr(a)){if(Dy(o)){var u=-s/o;u>=0&&u<=1&&(n[l++]=u)}}else{var h=o*o-4*a*s;if(Vr(h)){var u=-o/(2*a);u>=0&&u<=1&&(n[l++]=u)}else if(h>0){var c=$r(h),u=(-o+c)/(2*a),f=(-o-c)/(2*a);u>=0&&u<=1&&(n[l++]=u),f>=0&&f<=1&&(n[l++]=f)}}return l}function Py(r,t,e){var i=r+e-2*t;return i===0?.5:(r-t)/i}function Vs(r,t,e,i,n){var a=(t-r)*i+r,o=(e-t)*i+t,s=(o-a)*i+a;n[0]=r,n[1]=a,n[2]=s,n[3]=s,n[4]=o,n[5]=e}function J1(r,t,e,i,n,a,o,s,l){var u,h=.005,c=1/0;nr[0]=o,nr[1]=s;for(var f=0;f<1;f+=.05){Ie[0]=ce(r,e,n,f),Ie[1]=ce(t,i,a,f);var d=Ei(nr,Ie);d<c&&(u=f,c=d)}c=1/0;for(var p=0;p<32&&!(h<My);p++){var v=u-h,g=u+h;Ie[0]=ce(r,e,n,v),Ie[1]=ce(t,i,a,v);var d=Ei(Ie,nr);if(v>=0&&d<c)u=v,c=d;else{Pn[0]=ce(r,e,n,g),Pn[1]=ce(t,i,a,g);var m=Ei(Pn,nr);g<=1&&m<c?(u=g,c=m):h*=.5}}return $r(c)}function Q1(r,t,e,i,n,a,o){for(var s=r,l=t,u=0,h=1/o,c=1;c<=o;c++){var f=c*h,d=ce(r,e,n,f),p=ce(t,i,a,f),v=d-s,g=p-l;u+=Math.sqrt(v*v+g*g),s=d,l=p}return u}var tS=/cubic-bezier\(([0-9,\.e ]+)\)/;function Yc(r){var t=r&&tS.exec(r);if(t){var e=t[1].split(","),i=+Ge(e[0]),n=+Ge(e[1]),a=+Ge(e[2]),o=+Ge(e[3]);if(isNaN(i+n+a+o))return;var s=[];return function(l){return l<=0?0:l>=1?1:Bs(0,i,a,1,l,s)&&Wt(0,n,o,1,s[0])}}}var eS=function(){function r(t){this._inited=!1,this._startTime=0,this._pausedTime=0,this._paused=!1,this._life=t.life||1e3,this._delay=t.delay||0,this.loop=t.loop||!1,this.onframe=t.onframe||Gt,this.ondestroy=t.ondestroy||Gt,this.onrestart=t.onrestart||Gt,t.easing&&this.setEasing(t.easing)}return r.prototype.step=function(t,e){if(this._inited||(this._startTime=t+this._delay,this._inited=!0),this._paused){this._pausedTime+=e;return}var i=this._life,n=t-this._startTime-this._pausedTime,a=n/i;a<0&&(a=0),a=Math.min(a,1);var o=this.easingFunc,s=o?o(a):a;if(this.onframe(s),a===1)if(this.loop){var l=n%i;this._startTime=t-l,this._pausedTime=0,this.onrestart()}else return!0;return!1},r.prototype.pause=function(){this._paused=!0},r.prototype.resume=function(){this._paused=!1},r.prototype.setEasing=function(t){this.easing=t,this.easingFunc=tt(t)?t:Ea[t]||Yc(t)},r}(),ky=function(){function r(t){this.value=t}return r}(),rS=function(){function r(){this._len=0}return r.prototype.insert=function(t){var e=new ky(t);return this.insertEntry(e),e},r.prototype.insertEntry=function(t){this.head?(this.tail.next=t,t.prev=this.tail,t.next=null,this.tail=t):this.head=this.tail=t,this._len++},r.prototype.remove=function(t){var e=t.prev,i=t.next;e?e.next=i:this.head=i,i?i.prev=e:this.tail=e,t.next=t.prev=null,this._len--},r.prototype.len=function(){return this._len},r.prototype.clear=function(){this.head=this.tail=null,this._len=0},r}(),So=function(){function r(t){this._list=new rS,this._maxSize=10,this._map={},this._maxSize=t}return r.prototype.put=function(t,e){var i=this._list,n=this._map,a=null;if(n[t]==null){var o=i.len(),s=this._lastRemovedEntry;if(o>=this._maxSize&&o>0){var l=i.head;i.remove(l),delete n[l.key],a=l.value,this._lastRemovedEntry=l}s?s.value=e:s=new ky(e),s.key=t,i.insertEntry(s),n[t]=s}return a},r.prototype.get=function(t){var e=this._map[t],i=this._list;if(e!=null)return e!==i.tail&&(i.remove(e),i.insertEntry(e)),e.value},r.prototype.clear=function(){this._list.clear(),this._map={}},r.prototype.len=function(){return this._list.len()},r}(),ip={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function Ue(r){return r=Math.round(r),r<0?0:r>255?255:r}function iS(r){return r=Math.round(r),r<0?0:r>360?360:r}function Za(r){return r<0?0:r>1?1:r}function ru(r){var t=r;return t.length&&t.charAt(t.length-1)==="%"?Ue(parseFloat(t)/100*255):Ue(parseInt(t,10))}function Ni(r){var t=r;return t.length&&t.charAt(t.length-1)==="%"?Za(parseFloat(t)/100):Za(parseFloat(t))}function iu(r,t,e){return e<0?e+=1:e>1&&(e-=1),e*6<1?r+(t-r)*e*6:e*2<1?t:e*3<2?r+(t-r)*(2/3-e)*6:r}function Hr(r,t,e){return r+(t-r)*e}function Te(r,t,e,i,n){return r[0]=t,r[1]=e,r[2]=i,r[3]=n,r}function Ih(r,t){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r}var Ry=new So(20),zo=null;function on(r,t){zo&&Ih(zo,t),zo=Ry.put(r,zo||t.slice())}function me(r,t){if(r){t=t||[];var e=Ry.get(r);if(e)return Ih(t,e);r=r+"";var i=r.replace(/ /g,"").toLowerCase();if(i in ip)return Ih(t,ip[i]),on(r,t),t;var n=i.length;if(i.charAt(0)==="#"){if(n===4||n===5){var a=parseInt(i.slice(1,4),16);if(!(a>=0&&a<=4095)){Te(t,0,0,0,1);return}return Te(t,(a&3840)>>4|(a&3840)>>8,a&240|(a&240)>>4,a&15|(a&15)<<4,n===5?parseInt(i.slice(4),16)/15:1),on(r,t),t}else if(n===7||n===9){var a=parseInt(i.slice(1,7),16);if(!(a>=0&&a<=16777215)){Te(t,0,0,0,1);return}return Te(t,(a&16711680)>>16,(a&65280)>>8,a&255,n===9?parseInt(i.slice(7),16)/255:1),on(r,t),t}return}var o=i.indexOf("("),s=i.indexOf(")");if(o!==-1&&s+1===n){var l=i.substr(0,o),u=i.substr(o+1,s-(o+1)).split(","),h=1;switch(l){case"rgba":if(u.length!==4)return u.length===3?Te(t,+u[0],+u[1],+u[2],1):Te(t,0,0,0,1);h=Ni(u.pop());case"rgb":if(u.length>=3)return Te(t,ru(u[0]),ru(u[1]),ru(u[2]),u.length===3?h:Ni(u[3])),on(r,t),t;Te(t,0,0,0,1);return;case"hsla":if(u.length!==4){Te(t,0,0,0,1);return}return u[3]=Ni(u[3]),Ph(u,t),on(r,t),t;case"hsl":if(u.length!==3){Te(t,0,0,0,1);return}return Ph(u,t),on(r,t),t;default:return}}Te(t,0,0,0,1)}}function Ph(r,t){var e=(parseFloat(r[0])%360+360)%360/360,i=Ni(r[1]),n=Ni(r[2]),a=n<=.5?n*(i+1):n+i-n*i,o=n*2-a;return t=t||[],Te(t,Ue(iu(o,a,e+1/3)*255),Ue(iu(o,a,e)*255),Ue(iu(o,a,e-1/3)*255),1),r.length===4&&(t[3]=r[3]),t}function nS(r){if(r){var t=r[0]/255,e=r[1]/255,i=r[2]/255,n=Math.min(t,e,i),a=Math.max(t,e,i),o=a-n,s=(a+n)/2,l,u;if(o===0)l=0,u=0;else{s<.5?u=o/(a+n):u=o/(2-a-n);var h=((a-t)/6+o/2)/o,c=((a-e)/6+o/2)/o,f=((a-i)/6+o/2)/o;t===a?l=f-c:e===a?l=1/3+h-f:i===a&&(l=2/3+c-h),l<0&&(l+=1),l>1&&(l-=1)}var d=[l*360,u,s];return r[3]!=null&&d.push(r[3]),d}}function kh(r,t){var e=me(r);if(e){for(var i=0;i<3;i++)t<0?e[i]=e[i]*(1-t)|0:e[i]=(255-e[i])*t+e[i]|0,e[i]>255?e[i]=255:e[i]<0&&(e[i]=0);return Ki(e,e.length===4?"rgba":"rgb")}}function aS(r){var t=me(r);if(t)return((1<<24)+(t[0]<<16)+(t[1]<<8)+ +t[2]).toString(16).slice(1)}function Ly(r,t,e){if(!(!(t&&t.length)||!(r>=0&&r<=1))){e=e||[];var i=r*(t.length-1),n=Math.floor(i),a=Math.ceil(i),o=t[n],s=t[a],l=i-n;return e[0]=Ue(Hr(o[0],s[0],l)),e[1]=Ue(Hr(o[1],s[1],l)),e[2]=Ue(Hr(o[2],s[2],l)),e[3]=Za(Hr(o[3],s[3],l)),e}}var oS=Ly;function Xc(r,t,e){if(!(!(t&&t.length)||!(r>=0&&r<=1))){var i=r*(t.length-1),n=Math.floor(i),a=Math.ceil(i),o=me(t[n]),s=me(t[a]),l=i-n,u=Ki([Ue(Hr(o[0],s[0],l)),Ue(Hr(o[1],s[1],l)),Ue(Hr(o[2],s[2],l)),Za(Hr(o[3],s[3],l))],"rgba");return e?{color:u,leftIndex:n,rightIndex:a,value:i}:u}}var sS=Xc;function lS(r,t,e,i){var n=me(r);if(r)return n=nS(n),t!=null&&(n[0]=iS(t)),e!=null&&(n[1]=Ni(e)),i!=null&&(n[2]=Ni(i)),Ki(Ph(n),"rgba")}function uS(r,t){var e=me(r);if(e&&t!=null)return e[3]=Za(t),Ki(e,"rgba")}function Ki(r,t){if(!(!r||!r.length)){var e=r[0]+","+r[1]+","+r[2];return(t==="rgba"||t==="hsva"||t==="hsla")&&(e+=","+r[3]),t+"("+e+")"}}function Ka(r,t){var e=me(r);return e?(.299*e[0]+.587*e[1]+.114*e[2])*e[3]/255+(1-e[3])*t:0}function hS(){return Ki([Math.round(Math.random()*255),Math.round(Math.random()*255),Math.round(Math.random()*255)],"rgb")}var np=new So(100);function Hs(r){if(U(r)){var t=np.get(r);return t||(t=kh(r,-.1),np.put(r,t)),t}else if(sl(r)){var e=N({},r);return e.colorStops=V(r.colorStops,function(i){return{offset:i.offset,color:kh(i.color,-.1)}}),e}return r}const cS=Object.freeze(Object.defineProperty({__proto__:null,fastLerp:Ly,fastMapToColor:oS,lerp:Xc,lift:kh,liftColor:Hs,lum:Ka,mapToColor:sS,modifyAlpha:uS,modifyHSL:lS,parse:me,random:hS,stringify:Ki,toHex:aS},Symbol.toStringTag,{value:"Module"}));var Ws=Math.round;function Ja(r){var t;if(!r||r==="transparent")r="none";else if(typeof r=="string"&&r.indexOf("rgba")>-1){var e=me(r);e&&(r="rgb("+e[0]+","+e[1]+","+e[2]+")",t=e[3])}return{color:r,opacity:t??1}}var fS=1e-4;function Wr(r){return r<fS&&r>-1e-4}function Vo(r){return Ws(r*1e3)/1e3}function Rh(r){return Ws(r*1e4)/1e4}function dS(r){return"matrix("+Vo(r[0])+","+Vo(r[1])+","+Vo(r[2])+","+Vo(r[3])+","+Rh(r[4])+","+Rh(r[5])+")"}var pS={left:"start",right:"end",center:"middle",middle:"middle"};function vS(r,t,e){return e==="top"?r+=t/2:e==="bottom"&&(r-=t/2),r}function gS(r){return r&&(r.shadowBlur||r.shadowOffsetX||r.shadowOffsetY)}function mS(r){var t=r.style,e=r.getGlobalScale();return[t.shadowColor,(t.shadowBlur||0).toFixed(2),(t.shadowOffsetX||0).toFixed(2),(t.shadowOffsetY||0).toFixed(2),e[0],e[1]].join(",")}function Oy(r){return r&&!!r.image}function yS(r){return r&&!!r.svgElement}function qc(r){return Oy(r)||yS(r)}function Ey(r){return r.type==="linear"}function jy(r){return r.type==="radial"}function Ny(r){return r&&(r.type==="linear"||r.type==="radial")}function ul(r){return"url(#"+r+")"}function Fy(r){var t=r.getGlobalScale(),e=Math.max(t[0],t[1]);return Math.max(Math.ceil(Math.log(e)/Math.log(10)),1)}function By(r){var t=r.x||0,e=r.y||0,i=(r.rotation||0)*Oa,n=Q(r.scaleX,1),a=Q(r.scaleY,1),o=r.skewX||0,s=r.skewY||0,l=[];return(t||e)&&l.push("translate("+t+"px,"+e+"px)"),i&&l.push("rotate("+i+")"),(n!==1||a!==1)&&l.push("scale("+n+","+a+")"),(o||s)&&l.push("skew("+Ws(o*Oa)+"deg, "+Ws(s*Oa)+"deg)"),l.join(" ")}var _S=function(){return J.hasGlobalWindow&&tt(window.btoa)?function(r){return window.btoa(unescape(encodeURIComponent(r)))}:typeof Buffer<"u"?function(r){return Buffer.from(r).toString("base64")}:function(r){return null}}(),Lh=Array.prototype.slice;function yr(r,t,e){return(t-r)*e+r}function nu(r,t,e,i){for(var n=t.length,a=0;a<n;a++)r[a]=yr(t[a],e[a],i);return r}function bS(r,t,e,i){for(var n=t.length,a=n&&t[0].length,o=0;o<n;o++){r[o]||(r[o]=[]);for(var s=0;s<a;s++)r[o][s]=yr(t[o][s],e[o][s],i)}return r}function Ho(r,t,e,i){for(var n=t.length,a=0;a<n;a++)r[a]=t[a]+e[a]*i;return r}function ap(r,t,e,i){for(var n=t.length,a=n&&t[0].length,o=0;o<n;o++){r[o]||(r[o]=[]);for(var s=0;s<a;s++)r[o][s]=t[o][s]+e[o][s]*i}return r}function xS(r,t){for(var e=r.length,i=t.length,n=e>i?t:r,a=Math.min(e,i),o=n[a-1]||{color:[0,0,0,0],offset:0},s=a;s<Math.max(e,i);s++)n.push({offset:o.offset,color:o.color.slice()})}function wS(r,t,e){var i=r,n=t;if(!(!i.push||!n.push)){var a=i.length,o=n.length;if(a!==o){var s=a>o;if(s)i.length=o;else for(var l=a;l<o;l++)i.push(e===1?n[l]:Lh.call(n[l]))}for(var u=i[0]&&i[0].length,l=0;l<i.length;l++)if(e===1)isNaN(i[l])&&(i[l]=n[l]);else for(var h=0;h<u;h++)isNaN(i[l][h])&&(i[l][h]=n[l][h])}}function _s(r){if(ae(r)){var t=r.length;if(ae(r[0])){for(var e=[],i=0;i<t;i++)e.push(Lh.call(r[i]));return e}return Lh.call(r)}return r}function bs(r){return r[0]=Math.floor(r[0])||0,r[1]=Math.floor(r[1])||0,r[2]=Math.floor(r[2])||0,r[3]=r[3]==null?1:r[3],"rgba("+r.join(",")+")"}function SS(r){return ae(r&&r[0])?2:1}var Wo=0,xs=1,zy=2,Aa=3,Oh=4,Eh=5,op=6;function sp(r){return r===Oh||r===Eh}function Go(r){return r===xs||r===zy}var la=[0,0,0,0],CS=function(){function r(t){this.keyframes=[],this.discrete=!1,this._invalid=!1,this._needsSort=!1,this._lastFr=0,this._lastFrP=0,this.propName=t}return r.prototype.isFinished=function(){return this._finished},r.prototype.setFinished=function(){this._finished=!0,this._additiveTrack&&this._additiveTrack.setFinished()},r.prototype.needsAnimate=function(){return this.keyframes.length>=1},r.prototype.getAdditiveTrack=function(){return this._additiveTrack},r.prototype.addKeyframe=function(t,e,i){this._needsSort=!0;var n=this.keyframes,a=n.length,o=!1,s=op,l=e;if(ae(e)){var u=SS(e);s=u,(u===1&&!At(e[0])||u===2&&!At(e[0][0]))&&(o=!0)}else if(At(e)&&!qa(e))s=Wo;else if(U(e))if(!isNaN(+e))s=Wo;else{var h=me(e);h&&(l=h,s=Aa)}else if(sl(e)){var c=N({},l);c.colorStops=V(e.colorStops,function(d){return{offset:d.offset,color:me(d.color)}}),Ey(e)?s=Oh:jy(e)&&(s=Eh),l=c}a===0?this.valType=s:(s!==this.valType||s===op)&&(o=!0),this.discrete=this.discrete||o;var f={time:t,value:l,rawValue:e,percent:0};return i&&(f.easing=i,f.easingFunc=tt(i)?i:Ea[i]||Yc(i)),n.push(f),f},r.prototype.prepare=function(t,e){var i=this.keyframes;this._needsSort&&i.sort(function(v,g){return v.time-g.time});for(var n=this.valType,a=i.length,o=i[a-1],s=this.discrete,l=Go(n),u=sp(n),h=0;h<a;h++){var c=i[h],f=c.value,d=o.value;c.percent=c.time/t,s||(l&&h!==a-1?wS(f,d,n):u&&xS(f.colorStops,d.colorStops))}if(!s&&n!==Eh&&e&&this.needsAnimate()&&e.needsAnimate()&&n===e.valType&&!e._finished){this._additiveTrack=e;for(var p=i[0].value,h=0;h<a;h++)n===Wo?i[h].additiveValue=i[h].value-p:n===Aa?i[h].additiveValue=Ho([],i[h].value,p,-1):Go(n)&&(i[h].additiveValue=n===xs?Ho([],i[h].value,p,-1):ap([],i[h].value,p,-1))}},r.prototype.step=function(t,e){if(!this._finished){this._additiveTrack&&this._additiveTrack._finished&&(this._additiveTrack=null);var i=this._additiveTrack!=null,n=i?"additiveValue":"value",a=this.valType,o=this.keyframes,s=o.length,l=this.propName,u=a===Aa,h,c=this._lastFr,f=Math.min,d,p;if(s===1)d=p=o[0];else{if(e<0)h=0;else if(e<this._lastFrP){var v=f(c+1,s-1);for(h=v;h>=0&&!(o[h].percent<=e);h--);h=f(h,s-2)}else{for(h=c;h<s&&!(o[h].percent>e);h++);h=f(h-1,s-2)}p=o[h+1],d=o[h]}if(d&&p){this._lastFr=h,this._lastFrP=e;var g=p.percent-d.percent,m=g===0?1:f((e-d.percent)/g,1);p.easingFunc&&(m=p.easingFunc(m));var _=i?this._additiveValue:u?la:t[l];if((Go(a)||u)&&!_&&(_=this._additiveValue=[]),this.discrete)t[l]=m<1?d.rawValue:p.rawValue;else if(Go(a))a===xs?nu(_,d[n],p[n],m):bS(_,d[n],p[n],m);else if(sp(a)){var b=d[n],x=p[n],C=a===Oh;t[l]={type:C?"linear":"radial",x:yr(b.x,x.x,m),y:yr(b.y,x.y,m),colorStops:V(b.colorStops,function(T,M){var D=x.colorStops[M];return{offset:yr(T.offset,D.offset,m),color:bs(nu([],T.color,D.color,m))}}),global:x.global},C?(t[l].x2=yr(b.x2,x.x2,m),t[l].y2=yr(b.y2,x.y2,m)):t[l].r=yr(b.r,x.r,m)}else if(u)nu(_,d[n],p[n],m),i||(t[l]=bs(_));else{var S=yr(d[n],p[n],m);i?this._additiveValue=S:t[l]=S}i&&this._addToTarget(t)}}},r.prototype._addToTarget=function(t){var e=this.valType,i=this.propName,n=this._additiveValue;e===Wo?t[i]=t[i]+n:e===Aa?(me(t[i],la),Ho(la,la,n,1),t[i]=bs(la)):e===xs?Ho(t[i],t[i],n,1):e===zy&&ap(t[i],t[i],n,1)},r}(),Zc=function(){function r(t,e,i,n){if(this._tracks={},this._trackKeys=[],this._maxTime=0,this._started=0,this._clip=null,this._target=t,this._loop=e,e&&n){zc("Can' use additive animation on looped animation.");return}this._additiveAnimators=n,this._allowDiscrete=i}return r.prototype.getMaxTime=function(){return this._maxTime},r.prototype.getDelay=function(){return this._delay},r.prototype.getLoop=function(){return this._loop},r.prototype.getTarget=function(){return this._target},r.prototype.changeTarget=function(t){this._target=t},r.prototype.when=function(t,e,i){return this.whenWithKeys(t,e,vt(e),i)},r.prototype.whenWithKeys=function(t,e,i,n){for(var a=this._tracks,o=0;o<i.length;o++){var s=i[o],l=a[s];if(!l){l=a[s]=new CS(s);var u=void 0,h=this._getAdditiveTrack(s);if(h){var c=h.keyframes,f=c[c.length-1];u=f&&f.value,h.valType===Aa&&u&&(u=bs(u))}else u=this._target[s];if(u==null)continue;t>0&&l.addKeyframe(0,_s(u),n),this._trackKeys.push(s)}l.addKeyframe(t,_s(e[s]),n)}return this._maxTime=Math.max(this._maxTime,t),this},r.prototype.pause=function(){this._clip.pause(),this._paused=!0},r.prototype.resume=function(){this._clip.resume(),this._paused=!1},r.prototype.isPaused=function(){return!!this._paused},r.prototype.duration=function(t){return this._maxTime=t,this._force=!0,this},r.prototype._doneCallback=function(){this._setTracksFinished(),this._clip=null;var t=this._doneCbs;if(t)for(var e=t.length,i=0;i<e;i++)t[i].call(this)},r.prototype._abortedCallback=function(){this._setTracksFinished();var t=this.animation,e=this._abortedCbs;if(t&&t.removeClip(this._clip),this._clip=null,e)for(var i=0;i<e.length;i++)e[i].call(this)},r.prototype._setTracksFinished=function(){for(var t=this._tracks,e=this._trackKeys,i=0;i<e.length;i++)t[e[i]].setFinished()},r.prototype._getAdditiveTrack=function(t){var e,i=this._additiveAnimators;if(i)for(var n=0;n<i.length;n++){var a=i[n].getTrack(t);a&&(e=a)}return e},r.prototype.start=function(t){if(!(this._started>0)){this._started=1;for(var e=this,i=[],n=this._maxTime||0,a=0;a<this._trackKeys.length;a++){var o=this._trackKeys[a],s=this._tracks[o],l=this._getAdditiveTrack(o),u=s.keyframes,h=u.length;if(s.prepare(n,l),s.needsAnimate())if(!this._allowDiscrete&&s.discrete){var c=u[h-1];c&&(e._target[s.propName]=c.rawValue),s.setFinished()}else i.push(s)}if(i.length||this._force){var f=new eS({life:n,loop:this._loop,delay:this._delay||0,onframe:function(d){e._started=2;var p=e._additiveAnimators;if(p){for(var v=!1,g=0;g<p.length;g++)if(p[g]._clip){v=!0;break}v||(e._additiveAnimators=null)}for(var g=0;g<i.length;g++)i[g].step(e._target,d);var m=e._onframeCbs;if(m)for(var g=0;g<m.length;g++)m[g](e._target,d)},ondestroy:function(){e._doneCallback()}});this._clip=f,this.animation&&this.animation.addClip(f),t&&f.setEasing(t)}else this._doneCallback();return this}},r.prototype.stop=function(t){if(this._clip){var e=this._clip;t&&e.onframe(1),this._abortedCallback()}},r.prototype.delay=function(t){return this._delay=t,this},r.prototype.during=function(t){return t&&(this._onframeCbs||(this._onframeCbs=[]),this._onframeCbs.push(t)),this},r.prototype.done=function(t){return t&&(this._doneCbs||(this._doneCbs=[]),this._doneCbs.push(t)),this},r.prototype.aborted=function(t){return t&&(this._abortedCbs||(this._abortedCbs=[]),this._abortedCbs.push(t)),this},r.prototype.getClip=function(){return this._clip},r.prototype.getTrack=function(t){return this._tracks[t]},r.prototype.getTracks=function(){var t=this;return V(this._trackKeys,function(e){return t._tracks[e]})},r.prototype.stopTracks=function(t,e){if(!t.length||!this._clip)return!0;for(var i=this._tracks,n=this._trackKeys,a=0;a<t.length;a++){var o=i[t[a]];o&&!o.isFinished()&&(e?o.step(this._target,1):this._started===1&&o.step(this._target,0),o.setFinished())}for(var s=!0,a=0;a<n.length;a++)if(!i[n[a]].isFinished()){s=!1;break}return s&&this._abortedCallback(),s},r.prototype.saveTo=function(t,e,i){if(t){e=e||this._trackKeys;for(var n=0;n<e.length;n++){var a=e[n],o=this._tracks[a];if(!(!o||o.isFinished())){var s=o.keyframes,l=s[i?0:s.length-1];l&&(t[a]=_s(l.rawValue))}}}},r.prototype.__changeFinalValue=function(t,e){e=e||vt(t);for(var i=0;i<e.length;i++){var n=e[i],a=this._tracks[n];if(a){var o=a.keyframes;if(o.length>1){var s=o.pop();a.addKeyframe(s.time,t[n]),a.prepare(this._maxTime,a.getAdditiveTrack())}}}},r}();function Cn(){return new Date().getTime()}var TS=function(r){F(t,r);function t(e){var i=r.call(this)||this;return i._running=!1,i._time=0,i._pausedTime=0,i._pauseStart=0,i._paused=!1,e=e||{},i.stage=e.stage||{},i}return t.prototype.addClip=function(e){e.animation&&this.removeClip(e),this._head?(this._tail.next=e,e.prev=this._tail,e.next=null,this._tail=e):this._head=this._tail=e,e.animation=this},t.prototype.addAnimator=function(e){e.animation=this;var i=e.getClip();i&&this.addClip(i)},t.prototype.removeClip=function(e){if(e.animation){var i=e.prev,n=e.next;i?i.next=n:this._head=n,n?n.prev=i:this._tail=i,e.next=e.prev=e.animation=null}},t.prototype.removeAnimator=function(e){var i=e.getClip();i&&this.removeClip(i),e.animation=null},t.prototype.update=function(e){for(var i=Cn()-this._pausedTime,n=i-this._time,a=this._head;a;){var o=a.next,s=a.step(i,n);s&&(a.ondestroy(),this.removeClip(a)),a=o}this._time=i,e||(this.trigger("frame",n),this.stage.update&&this.stage.update())},t.prototype._startLoop=function(){var e=this;this._running=!0;function i(){e._running&&(Dh(i),!e._paused&&e.update())}Dh(i)},t.prototype.start=function(){this._running||(this._time=Cn(),this._pausedTime=0,this._startLoop())},t.prototype.stop=function(){this._running=!1},t.prototype.pause=function(){this._paused||(this._pauseStart=Cn(),this._paused=!0)},t.prototype.resume=function(){this._paused&&(this._pausedTime+=Cn()-this._pauseStart,this._paused=!1)},t.prototype.clear=function(){for(var e=this._head;e;){var i=e.next;e.prev=e.next=e.animation=null,e=i}this._head=this._tail=null},t.prototype.isFinished=function(){return this._head==null},t.prototype.animate=function(e,i){i=i||{},this.start();var n=new Zc(e,i.loop);return this.addAnimator(n),n},t}(ur),AS=300,au=J.domSupported,ou=function(){var r=["click","dblclick","mousewheel","wheel","mouseout","mouseup","mousedown","mousemove","contextmenu"],t=["touchstart","touchend","touchmove"],e={pointerdown:1,pointerup:1,pointermove:1,pointerout:1},i=V(r,function(n){var a=n.replace("mouse","pointer");return e.hasOwnProperty(a)?a:n});return{mouse:r,touch:t,pointer:i}}(),lp={mouse:["mousemove","mouseup"],pointer:["pointermove","pointerup"]},up=!1;function jh(r){var t=r.pointerType;return t==="pen"||t==="touch"}function MS(r){r.touching=!0,r.touchTimer!=null&&(clearTimeout(r.touchTimer),r.touchTimer=null),r.touchTimer=setTimeout(function(){r.touching=!1,r.touchTimer=null},700)}function su(r){r&&(r.zrByTouch=!0)}function DS(r,t){return Ae(r.dom,new IS(r,t),!0)}function Vy(r,t){for(var e=t,i=!1;e&&e.nodeType!==9&&!(i=e.domBelongToZr||e!==t&&e===r.painterRoot);)e=e.parentNode;return i}var IS=function(){function r(t,e){this.stopPropagation=Gt,this.stopImmediatePropagation=Gt,this.preventDefault=Gt,this.type=e.type,this.target=this.currentTarget=t.dom,this.pointerType=e.pointerType,this.clientX=e.clientX,this.clientY=e.clientY}return r}(),Ve={mousedown:function(r){r=Ae(this.dom,r),this.__mayPointerCapture=[r.zrX,r.zrY],this.trigger("mousedown",r)},mousemove:function(r){r=Ae(this.dom,r);var t=this.__mayPointerCapture;t&&(r.zrX!==t[0]||r.zrY!==t[1])&&this.__togglePointerCapture(!0),this.trigger("mousemove",r)},mouseup:function(r){r=Ae(this.dom,r),this.__togglePointerCapture(!1),this.trigger("mouseup",r)},mouseout:function(r){r=Ae(this.dom,r);var t=r.toElement||r.relatedTarget;Vy(this,t)||(this.__pointerCapturing&&(r.zrEventControl="no_globalout"),this.trigger("mouseout",r))},wheel:function(r){up=!0,r=Ae(this.dom,r),this.trigger("mousewheel",r)},mousewheel:function(r){up||(r=Ae(this.dom,r),this.trigger("mousewheel",r))},touchstart:function(r){r=Ae(this.dom,r),su(r),this.__lastTouchMoment=new Date,this.handler.processGesture(r,"start"),Ve.mousemove.call(this,r),Ve.mousedown.call(this,r)},touchmove:function(r){r=Ae(this.dom,r),su(r),this.handler.processGesture(r,"change"),Ve.mousemove.call(this,r)},touchend:function(r){r=Ae(this.dom,r),su(r),this.handler.processGesture(r,"end"),Ve.mouseup.call(this,r),+new Date-+this.__lastTouchMoment<AS&&Ve.click.call(this,r)},pointerdown:function(r){Ve.mousedown.call(this,r)},pointermove:function(r){jh(r)||Ve.mousemove.call(this,r)},pointerup:function(r){Ve.mouseup.call(this,r)},pointerout:function(r){jh(r)||Ve.mouseout.call(this,r)}};A(["click","dblclick","contextmenu"],function(r){Ve[r]=function(t){t=Ae(this.dom,t),this.trigger(r,t)}});var Nh={pointermove:function(r){jh(r)||Nh.mousemove.call(this,r)},pointerup:function(r){Nh.mouseup.call(this,r)},mousemove:function(r){this.trigger("mousemove",r)},mouseup:function(r){var t=this.__pointerCapturing;this.__togglePointerCapture(!1),this.trigger("mouseup",r),t&&(r.zrEventControl="only_globalout",this.trigger("mouseout",r))}};function PS(r,t){var e=t.domHandlers;J.pointerEventsSupported?A(ou.pointer,function(i){ws(t,i,function(n){e[i].call(r,n)})}):(J.touchEventsSupported&&A(ou.touch,function(i){ws(t,i,function(n){e[i].call(r,n),MS(t)})}),A(ou.mouse,function(i){ws(t,i,function(n){n=Uc(n),t.touching||e[i].call(r,n)})}))}function kS(r,t){J.pointerEventsSupported?A(lp.pointer,e):J.touchEventsSupported||A(lp.mouse,e);function e(i){function n(a){a=Uc(a),Vy(r,a.target)||(a=DS(r,a),t.domHandlers[i].call(r,a))}ws(t,i,n,{capture:!0})}}function ws(r,t,e,i){r.mounted[t]=e,r.listenerOpts[t]=i,Mh(r.domTarget,t,e,i)}function lu(r){var t=r.mounted;for(var e in t)t.hasOwnProperty(e)&&E1(r.domTarget,e,t[e],r.listenerOpts[e]);r.mounted={}}var hp=function(){function r(t,e){this.mounted={},this.listenerOpts={},this.touching=!1,this.domTarget=t,this.domHandlers=e}return r}(),RS=function(r){F(t,r);function t(e,i){var n=r.call(this)||this;return n.__pointerCapturing=!1,n.dom=e,n.painterRoot=i,n._localHandlerScope=new hp(e,Ve),au&&(n._globalHandlerScope=new hp(document,Nh)),PS(n,n._localHandlerScope),n}return t.prototype.dispose=function(){lu(this._localHandlerScope),au&&lu(this._globalHandlerScope)},t.prototype.setCursor=function(e){this.dom.style&&(this.dom.style.cursor=e||"default")},t.prototype.__togglePointerCapture=function(e){if(this.__mayPointerCapture=null,au&&+this.__pointerCapturing^+e){this.__pointerCapturing=e;var i=this._globalHandlerScope;e?kS(this,i):lu(i)}},t}(ur),Hy=1;J.hasGlobalWindow&&(Hy=Math.max(window.devicePixelRatio||window.screen&&window.screen.deviceXDPI/window.screen.logicalXDPI||1,1));var cp=Hy,Fh=.4,Bh="#333",zh="#ccc",LS="#eee",fp=bo,OS=5e-5;function hi(r){return r>OS||r<-5e-5}var ci=[],sn=[],uu=xr(),hu=Math.abs,Kc=function(){function r(){}return r.prototype.getLocalTransform=function(t){return r.getLocalTransform(this,t)},r.prototype.setPosition=function(t){this.x=t[0],this.y=t[1]},r.prototype.setScale=function(t){this.scaleX=t[0],this.scaleY=t[1]},r.prototype.setSkew=function(t){this.skewX=t[0],this.skewY=t[1]},r.prototype.setOrigin=function(t){this.originX=t[0],this.originY=t[1]},r.prototype.needLocalTransform=function(){return hi(this.rotation)||hi(this.x)||hi(this.y)||hi(this.scaleX-1)||hi(this.scaleY-1)||hi(this.skewX)||hi(this.skewY)},r.prototype.updateTransform=function(){var t=this.parent&&this.parent.transform,e=this.needLocalTransform(),i=this.transform;if(!(e||t)){i&&(fp(i),this.invTransform=null);return}i=i||xr(),e?this.getLocalTransform(i):fp(i),t&&(e?Ur(i,t,i):$c(i,t)),this.transform=i,this._resolveGlobalScaleRatio(i)},r.prototype._resolveGlobalScaleRatio=function(t){var e=this.globalScaleRatio;if(e!=null&&e!==1){this.getGlobalScale(ci);var i=ci[0]<0?-1:1,n=ci[1]<0?-1:1,a=((ci[0]-i)*e+i)/ci[0]||0,o=((ci[1]-n)*e+n)/ci[1]||0;t[0]*=a,t[1]*=a,t[2]*=o,t[3]*=o}this.invTransform=this.invTransform||xr(),wo(this.invTransform,t)},r.prototype.getComputedTransform=function(){for(var t=this,e=[];t;)e.push(t),t=t.parent;for(;t=e.pop();)t.updateTransform();return this.transform},r.prototype.setLocalTransform=function(t){if(t){var e=t[0]*t[0]+t[1]*t[1],i=t[2]*t[2]+t[3]*t[3],n=Math.atan2(t[1],t[0]),a=Math.PI/2+n-Math.atan2(t[3],t[2]);i=Math.sqrt(i)*Math.cos(a),e=Math.sqrt(e),this.skewX=a,this.skewY=0,this.rotation=-n,this.x=+t[4],this.y=+t[5],this.scaleX=e,this.scaleY=i,this.originX=0,this.originY=0}},r.prototype.decomposeTransform=function(){if(this.transform){var t=this.parent,e=this.transform;t&&t.transform&&(t.invTransform=t.invTransform||xr(),Ur(sn,t.invTransform,e),e=sn);var i=this.originX,n=this.originY;(i||n)&&(uu[4]=i,uu[5]=n,Ur(sn,e,uu),sn[4]-=i,sn[5]-=n,e=sn),this.setLocalTransform(e)}},r.prototype.getGlobalScale=function(t){var e=this.transform;return t=t||[],e?(t[0]=Math.sqrt(e[0]*e[0]+e[1]*e[1]),t[1]=Math.sqrt(e[2]*e[2]+e[3]*e[3]),e[0]<0&&(t[0]=-t[0]),e[3]<0&&(t[1]=-t[1]),t):(t[0]=1,t[1]=1,t)},r.prototype.transformCoordToLocal=function(t,e){var i=[t,e],n=this.invTransform;return n&&ie(i,i,n),i},r.prototype.transformCoordToGlobal=function(t,e){var i=[t,e],n=this.transform;return n&&ie(i,i,n),i},r.prototype.getLineScale=function(){var t=this.transform;return t&&hu(t[0]-1)>1e-10&&hu(t[3]-1)>1e-10?Math.sqrt(hu(t[0]*t[3]-t[2]*t[1])):1},r.prototype.copyTransform=function(t){Wy(this,t)},r.getLocalTransform=function(t,e){e=e||[];var i=t.originX||0,n=t.originY||0,a=t.scaleX,o=t.scaleY,s=t.anchorX,l=t.anchorY,u=t.rotation||0,h=t.x,c=t.y,f=t.skewX?Math.tan(t.skewX):0,d=t.skewY?Math.tan(-t.skewY):0;if(i||n||s||l){var p=i+s,v=n+l;e[4]=-p*a-f*v*o,e[5]=-v*o-d*p*a}else e[4]=e[5]=0;return e[0]=a,e[3]=o,e[1]=d*a,e[2]=f*o,u&&xo(e,e,u),e[4]+=i+h,e[5]+=n+c,e},r.initDefaultProps=function(){var t=r.prototype;t.scaleX=t.scaleY=t.globalScaleRatio=1,t.x=t.y=t.originX=t.originY=t.skewX=t.skewY=t.rotation=t.anchorX=t.anchorY=0}(),r}(),Qa=["x","y","originX","originY","anchorX","anchorY","rotation","scaleX","scaleY","skewX","skewY"];function Wy(r,t){for(var e=0;e<Qa.length;e++){var i=Qa[e];r[i]=t[i]}}var dp={};function ye(r,t){t=t||qr;var e=dp[t];e||(e=dp[t]=new So(500));var i=e.get(r);return i==null&&(i=Zr.measureText(r,t).width,e.put(r,i)),i}function pp(r,t,e,i){var n=ye(r,t),a=cl(t),o=Ma(0,n,e),s=xn(0,a,i),l=new mt(o,s,n,a);return l}function hl(r,t,e,i){var n=((r||"")+"").split(`
16
16
  `),a=n.length;if(a===1)return pp(n[0],t,e,i);for(var o=new mt(0,0,0,0),s=0;s<n.length;s++){var l=pp(n[s],t,e,i);s===0?o.copy(l):o.union(l)}return o}function Ma(r,t,e){return e==="right"?r-=t:e==="center"&&(r-=t/2),r}function xn(r,t,e){return e==="middle"?r-=t/2:e==="bottom"&&(r-=t),r}function cl(r){return ye("国",r)}function Kr(r,t){return typeof r=="string"?r.lastIndexOf("%")>=0?parseFloat(r)/100*t:parseFloat(r):r}function Gy(r,t,e){var i=t.position||"inside",n=t.distance!=null?t.distance:5,a=e.height,o=e.width,s=a/2,l=e.x,u=e.y,h="left",c="top";if(i instanceof Array)l+=Kr(i[0],e.width),u+=Kr(i[1],e.height),h=null,c=null;else switch(i){case"left":l-=n,u+=s,h="right",c="middle";break;case"right":l+=n+o,u+=s,c="middle";break;case"top":l+=o/2,u-=n,h="center",c="bottom";break;case"bottom":l+=o/2,u+=a+n,h="center";break;case"inside":l+=o/2,u+=s,h="center",c="middle";break;case"insideLeft":l+=n,u+=s,c="middle";break;case"insideRight":l+=o-n,u+=s,h="right",c="middle";break;case"insideTop":l+=o/2,u+=n,h="center";break;case"insideBottom":l+=o/2,u+=a-n,h="center",c="bottom";break;case"insideTopLeft":l+=n,u+=n;break;case"insideTopRight":l+=o-n,u+=n,h="right";break;case"insideBottomLeft":l+=n,u+=a-n,c="bottom";break;case"insideBottomRight":l+=o-n,u+=a-n,h="right",c="bottom";break}return r=r||{},r.x=l,r.y=u,r.align=h,r.verticalAlign=c,r}var cu="__zr_normal__",fu=Qa.concat(["ignore"]),ES=sr(Qa,function(r,t){return r[t]=!0,r},{ignore:!1}),ln={},jS=new mt(0,0,0,0),fl=function(){function r(t){this.id=Bc(),this.animators=[],this.currentStates=[],this.states={},this._init(t)}return r.prototype._init=function(t){this.attr(t)},r.prototype.drift=function(t,e,i){switch(this.draggable){case"horizontal":e=0;break;case"vertical":t=0;break}var n=this.transform;n||(n=this.transform=[1,0,0,1,0,0]),n[4]+=t,n[5]+=e,this.decomposeTransform(),this.markRedraw()},r.prototype.beforeUpdate=function(){},r.prototype.afterUpdate=function(){},r.prototype.update=function(){this.updateTransform(),this.__dirty&&this.updateInnerText()},r.prototype.updateInnerText=function(t){var e=this._textContent;if(e&&(!e.ignore||t)){this.textConfig||(this.textConfig={});var i=this.textConfig,n=i.local,a=e.innerTransformable,o=void 0,s=void 0,l=!1;a.parent=n?this:null;var u=!1;if(a.copyTransform(e),i.position!=null){var h=jS;i.layoutRect?h.copy(i.layoutRect):h.copy(this.getBoundingRect()),n||h.applyTransform(this.transform),this.calculateTextPosition?this.calculateTextPosition(ln,i,h):Gy(ln,i,h),a.x=ln.x,a.y=ln.y,o=ln.align,s=ln.verticalAlign;var c=i.origin;if(c&&i.rotation!=null){var f=void 0,d=void 0;c==="center"?(f=h.width*.5,d=h.height*.5):(f=Kr(c[0],h.width),d=Kr(c[1],h.height)),u=!0,a.originX=-a.x+f+(n?0:h.x),a.originY=-a.y+d+(n?0:h.y)}}i.rotation!=null&&(a.rotation=i.rotation);var p=i.offset;p&&(a.x+=p[0],a.y+=p[1],u||(a.originX=-p[0],a.originY=-p[1]));var v=i.inside==null?typeof i.position=="string"&&i.position.indexOf("inside")>=0:i.inside,g=this._innerTextDefaultStyle||(this._innerTextDefaultStyle={}),m=void 0,_=void 0,b=void 0;v&&this.canBeInsideText()?(m=i.insideFill,_=i.insideStroke,(m==null||m==="auto")&&(m=this.getInsideTextFill()),(_==null||_==="auto")&&(_=this.getInsideTextStroke(m),b=!0)):(m=i.outsideFill,_=i.outsideStroke,(m==null||m==="auto")&&(m=this.getOutsideFill()),(_==null||_==="auto")&&(_=this.getOutsideStroke(m),b=!0)),m=m||"#000",(m!==g.fill||_!==g.stroke||b!==g.autoStroke||o!==g.align||s!==g.verticalAlign)&&(l=!0,g.fill=m,g.stroke=_,g.autoStroke=b,g.align=o,g.verticalAlign=s,e.setDefaultTextStyle(g)),e.__dirty|=ji,l&&e.dirtyStyle(!0)}},r.prototype.canBeInsideText=function(){return!0},r.prototype.getInsideTextFill=function(){return"#fff"},r.prototype.getInsideTextStroke=function(t){return"#000"},r.prototype.getOutsideFill=function(){return this.__zr&&this.__zr.isDarkMode()?zh:Bh},r.prototype.getOutsideStroke=function(t){var e=this.__zr&&this.__zr.getBackgroundColor(),i=typeof e=="string"&&me(e);i||(i=[255,255,255,1]);for(var n=i[3],a=this.__zr.isDarkMode(),o=0;o<3;o++)i[o]=i[o]*n+(a?0:255)*(1-n);return i[3]=1,Ki(i,"rgba")},r.prototype.traverse=function(t,e){},r.prototype.attrKV=function(t,e){t==="textConfig"?this.setTextConfig(e):t==="textContent"?this.setTextContent(e):t==="clipPath"?this.setClipPath(e):t==="extra"?(this.extra=this.extra||{},N(this.extra,e)):this[t]=e},r.prototype.hide=function(){this.ignore=!0,this.markRedraw()},r.prototype.show=function(){this.ignore=!1,this.markRedraw()},r.prototype.attr=function(t,e){if(typeof t=="string")this.attrKV(t,e);else if(Z(t))for(var i=t,n=vt(i),a=0;a<n.length;a++){var o=n[a];this.attrKV(o,t[o])}return this.markRedraw(),this},r.prototype.saveCurrentToNormalState=function(t){this._innerSaveToNormal(t);for(var e=this._normalState,i=0;i<this.animators.length;i++){var n=this.animators[i],a=n.__fromStateTransition;if(!(n.getLoop()||a&&a!==cu)){var o=n.targetName,s=o?e[o]:e;n.saveTo(s)}}},r.prototype._innerSaveToNormal=function(t){var e=this._normalState;e||(e=this._normalState={}),t.textConfig&&!e.textConfig&&(e.textConfig=this.textConfig),this._savePrimaryToNormal(t,e,fu)},r.prototype._savePrimaryToNormal=function(t,e,i){for(var n=0;n<i.length;n++){var a=i[n];t[a]!=null&&!(a in e)&&(e[a]=this[a])}},r.prototype.hasState=function(){return this.currentStates.length>0},r.prototype.getState=function(t){return this.states[t]},r.prototype.ensureState=function(t){var e=this.states;return e[t]||(e[t]={}),e[t]},r.prototype.clearStates=function(t){this.useState(cu,!1,t)},r.prototype.useState=function(t,e,i,n){var a=t===cu,o=this.hasState();if(!(!o&&a)){var s=this.currentStates,l=this.stateTransition;if(!(pt(s,t)>=0&&(e||s.length===1))){var u;if(this.stateProxy&&!a&&(u=this.stateProxy(t)),u||(u=this.states&&this.states[t]),!u&&!a){zc("State "+t+" not exists.");return}a||this.saveCurrentToNormalState(u);var h=!!(u&&u.hoverLayer||n);h&&this._toggleHoverLayerFlag(!0),this._applyStateObj(t,u,this._normalState,e,!i&&!this.__inHover&&l&&l.duration>0,l);var c=this._textContent,f=this._textGuide;return c&&c.useState(t,e,i,h),f&&f.useState(t,e,i,h),a?(this.currentStates=[],this._normalState={}):e?this.currentStates.push(t):this.currentStates=[t],this._updateAnimationTargets(),this.markRedraw(),!h&&this.__inHover&&(this._toggleHoverLayerFlag(!1),this.__dirty&=-2),u}}},r.prototype.useStates=function(t,e,i){if(!t.length)this.clearStates();else{var n=[],a=this.currentStates,o=t.length,s=o===a.length;if(s){for(var l=0;l<o;l++)if(t[l]!==a[l]){s=!1;break}}if(s)return;for(var l=0;l<o;l++){var u=t[l],h=void 0;this.stateProxy&&(h=this.stateProxy(u,t)),h||(h=this.states[u]),h&&n.push(h)}var c=n[o-1],f=!!(c&&c.hoverLayer||i);f&&this._toggleHoverLayerFlag(!0);var d=this._mergeStates(n),p=this.stateTransition;this.saveCurrentToNormalState(d),this._applyStateObj(t.join(","),d,this._normalState,!1,!e&&!this.__inHover&&p&&p.duration>0,p);var v=this._textContent,g=this._textGuide;v&&v.useStates(t,e,f),g&&g.useStates(t,e,f),this._updateAnimationTargets(),this.currentStates=t.slice(),this.markRedraw(),!f&&this.__inHover&&(this._toggleHoverLayerFlag(!1),this.__dirty&=-2)}},r.prototype.isSilent=function(){for(var t=this.silent,e=this.parent;!t&&e;){if(e.silent){t=!0;break}e=e.parent}return t},r.prototype._updateAnimationTargets=function(){for(var t=0;t<this.animators.length;t++){var e=this.animators[t];e.targetName&&e.changeTarget(this[e.targetName])}},r.prototype.removeState=function(t){var e=pt(this.currentStates,t);if(e>=0){var i=this.currentStates.slice();i.splice(e,1),this.useStates(i)}},r.prototype.replaceState=function(t,e,i){var n=this.currentStates.slice(),a=pt(n,t),o=pt(n,e)>=0;a>=0?o?n.splice(a,1):n[a]=e:i&&!o&&n.push(e),this.useStates(n)},r.prototype.toggleState=function(t,e){e?this.useState(t,!0):this.removeState(t)},r.prototype._mergeStates=function(t){for(var e={},i,n=0;n<t.length;n++){var a=t[n];N(e,a),a.textConfig&&(i=i||{},N(i,a.textConfig))}return i&&(e.textConfig=i),e},r.prototype._applyStateObj=function(t,e,i,n,a,o){var s=!(e&&n);e&&e.textConfig?(this.textConfig=N({},n?this.textConfig:i.textConfig),N(this.textConfig,e.textConfig)):s&&i.textConfig&&(this.textConfig=i.textConfig);for(var l={},u=!1,h=0;h<fu.length;h++){var c=fu[h],f=a&&ES[c];e&&e[c]!=null?f?(u=!0,l[c]=e[c]):this[c]=e[c]:s&&i[c]!=null&&(f?(u=!0,l[c]=i[c]):this[c]=i[c])}if(!a)for(var h=0;h<this.animators.length;h++){var d=this.animators[h],p=d.targetName;d.getLoop()||d.__changeFinalValue(p?(e||i)[p]:e||i)}u&&this._transitionState(t,l,o)},r.prototype._attachComponent=function(t){if(!(t.__zr&&!t.__hostTarget)&&t!==this){var e=this.__zr;e&&t.addSelfToZr(e),t.__zr=e,t.__hostTarget=this}},r.prototype._detachComponent=function(t){t.__zr&&t.removeSelfFromZr(t.__zr),t.__zr=null,t.__hostTarget=null},r.prototype.getClipPath=function(){return this._clipPath},r.prototype.setClipPath=function(t){this._clipPath&&this._clipPath!==t&&this.removeClipPath(),this._attachComponent(t),this._clipPath=t,this.markRedraw()},r.prototype.removeClipPath=function(){var t=this._clipPath;t&&(this._detachComponent(t),this._clipPath=null,this.markRedraw())},r.prototype.getTextContent=function(){return this._textContent},r.prototype.setTextContent=function(t){var e=this._textContent;e!==t&&(e&&e!==t&&this.removeTextContent(),t.innerTransformable=new Kc,this._attachComponent(t),this._textContent=t,this.markRedraw())},r.prototype.setTextConfig=function(t){this.textConfig||(this.textConfig={}),N(this.textConfig,t),this.markRedraw()},r.prototype.removeTextConfig=function(){this.textConfig=null,this.markRedraw()},r.prototype.removeTextContent=function(){var t=this._textContent;t&&(t.innerTransformable=null,this._detachComponent(t),this._textContent=null,this._innerTextDefaultStyle=null,this.markRedraw())},r.prototype.getTextGuideLine=function(){return this._textGuide},r.prototype.setTextGuideLine=function(t){this._textGuide&&this._textGuide!==t&&this.removeTextGuideLine(),this._attachComponent(t),this._textGuide=t,this.markRedraw()},r.prototype.removeTextGuideLine=function(){var t=this._textGuide;t&&(this._detachComponent(t),this._textGuide=null,this.markRedraw())},r.prototype.markRedraw=function(){this.__dirty|=ji;var t=this.__zr;t&&(this.__inHover?t.refreshHover():t.refresh()),this.__hostTarget&&this.__hostTarget.markRedraw()},r.prototype.dirty=function(){this.markRedraw()},r.prototype._toggleHoverLayerFlag=function(t){this.__inHover=t;var e=this._textContent,i=this._textGuide;e&&(e.__inHover=t),i&&(i.__inHover=t)},r.prototype.addSelfToZr=function(t){if(this.__zr!==t){this.__zr=t;var e=this.animators;if(e)for(var i=0;i<e.length;i++)t.animation.addAnimator(e[i]);this._clipPath&&this._clipPath.addSelfToZr(t),this._textContent&&this._textContent.addSelfToZr(t),this._textGuide&&this._textGuide.addSelfToZr(t)}},r.prototype.removeSelfFromZr=function(t){if(this.__zr){this.__zr=null;var e=this.animators;if(e)for(var i=0;i<e.length;i++)t.animation.removeAnimator(e[i]);this._clipPath&&this._clipPath.removeSelfFromZr(t),this._textContent&&this._textContent.removeSelfFromZr(t),this._textGuide&&this._textGuide.removeSelfFromZr(t)}},r.prototype.animate=function(t,e,i){var n=t?this[t]:this,a=new Zc(n,e,i);return t&&(a.targetName=t),this.addAnimator(a,t),a},r.prototype.addAnimator=function(t,e){var i=this.__zr,n=this;t.during(function(){n.updateDuringAnimation(e)}).done(function(){var a=n.animators,o=pt(a,t);o>=0&&a.splice(o,1)}),this.animators.push(t),i&&i.animation.addAnimator(t),i&&i.wakeUp()},r.prototype.updateDuringAnimation=function(t){this.markRedraw()},r.prototype.stopAnimation=function(t,e){for(var i=this.animators,n=i.length,a=[],o=0;o<n;o++){var s=i[o];!t||t===s.scope?s.stop(e):a.push(s)}return this.animators=a,this},r.prototype.animateTo=function(t,e,i){du(this,t,e,i)},r.prototype.animateFrom=function(t,e,i){du(this,t,e,i,!0)},r.prototype._transitionState=function(t,e,i,n){for(var a=du(this,e,i,n),o=0;o<a.length;o++)a[o].__fromStateTransition=t},r.prototype.getBoundingRect=function(){return null},r.prototype.getPaintRect=function(){return null},r.initDefaultProps=function(){var t=r.prototype;t.type="element",t.name="",t.ignore=t.silent=t.isGroup=t.draggable=t.dragging=t.ignoreClip=t.__inHover=!1,t.__dirty=ji;function e(i,n,a,o){Object.defineProperty(t,i,{get:function(){if(!this[n]){var l=this[n]=[];s(this,l)}return this[n]},set:function(l){this[a]=l[0],this[o]=l[1],this[n]=l,s(this,l)}});function s(l,u){Object.defineProperty(u,0,{get:function(){return l[a]},set:function(h){l[a]=h}}),Object.defineProperty(u,1,{get:function(){return l[o]},set:function(h){l[o]=h}})}}Object.defineProperty&&(e("position","_legacyPos","x","y"),e("scale","_legacyScale","scaleX","scaleY"),e("origin","_legacyOrigin","originX","originY"))}(),r}();xe(fl,ur);xe(fl,Kc);function du(r,t,e,i,n){e=e||{};var a=[];Uy(r,"",r,t,e,i,a,n);var o=a.length,s=!1,l=e.done,u=e.aborted,h=function(){s=!0,o--,o<=0&&(s?l&&l():u&&u())},c=function(){o--,o<=0&&(s?l&&l():u&&u())};o||l&&l(),a.length>0&&e.during&&a[0].during(function(p,v){e.during(v)});for(var f=0;f<a.length;f++){var d=a[f];h&&d.done(h),c&&d.aborted(c),e.force&&d.duration(e.duration),d.start(e.easing)}return a}function pu(r,t,e){for(var i=0;i<e;i++)r[i]=t[i]}function NS(r){return ae(r[0])}function FS(r,t,e){if(ae(t[e]))if(ae(r[e])||(r[e]=[]),oe(t[e])){var i=t[e].length;r[e].length!==i&&(r[e]=new t[e].constructor(i),pu(r[e],t[e],i))}else{var n=t[e],a=r[e],o=n.length;if(NS(n))for(var s=n[0].length,l=0;l<o;l++)a[l]?pu(a[l],n[l],s):a[l]=Array.prototype.slice.call(n[l]);else pu(a,n,o);a.length=n.length}else r[e]=t[e]}function BS(r,t){return r===t||ae(r)&&ae(t)&&zS(r,t)}function zS(r,t){var e=r.length;if(e!==t.length)return!1;for(var i=0;i<e;i++)if(r[i]!==t[i])return!1;return!0}function Uy(r,t,e,i,n,a,o,s){for(var l=vt(i),u=n.duration,h=n.delay,c=n.additive,f=n.setToFinal,d=!Z(a),p=r.animators,v=[],g=0;g<l.length;g++){var m=l[g],_=i[m];if(_!=null&&e[m]!=null&&(d||a[m]))if(Z(_)&&!ae(_)&&!sl(_)){if(t){s||(e[m]=_,r.updateDuringAnimation(t));continue}Uy(r,m,e[m],_,n,a&&a[m],o,s)}else v.push(m);else s||(e[m]=_,r.updateDuringAnimation(t),v.push(m))}var b=v.length;if(!c&&b)for(var x=0;x<p.length;x++){var C=p[x];if(C.targetName===t){var S=C.stopTracks(v);if(S){var T=pt(p,C);p.splice(T,1)}}}if(n.force||(v=It(v,function(P){return!BS(i[P],e[P])}),b=v.length),b>0||n.force&&!o.length){var M=void 0,D=void 0,I=void 0;if(s){D={},f&&(M={});for(var x=0;x<b;x++){var m=v[x];D[m]=e[m],f?M[m]=i[m]:e[m]=i[m]}}else if(f){I={};for(var x=0;x<b;x++){var m=v[x];I[m]=_s(e[m]),FS(e,i,m)}}var C=new Zc(e,!1,!1,c?It(p,function(k){return k.targetName===t}):null);C.targetName=t,n.scope&&(C.scope=n.scope),f&&M&&C.whenWithKeys(0,M,v),I&&C.whenWithKeys(0,I,v),C.whenWithKeys(u??500,s?D:i,v).delay(h||0),r.addAnimator(C,t),o.push(C)}}var Bt=function(r){F(t,r);function t(e){var i=r.call(this)||this;return i.isGroup=!0,i._children=[],i.attr(e),i}return t.prototype.childrenRef=function(){return this._children},t.prototype.children=function(){return this._children.slice()},t.prototype.childAt=function(e){return this._children[e]},t.prototype.childOfName=function(e){for(var i=this._children,n=0;n<i.length;n++)if(i[n].name===e)return i[n]},t.prototype.childCount=function(){return this._children.length},t.prototype.add=function(e){return e&&e!==this&&e.parent!==this&&(this._children.push(e),this._doAdd(e)),this},t.prototype.addBefore=function(e,i){if(e&&e!==this&&e.parent!==this&&i&&i.parent===this){var n=this._children,a=n.indexOf(i);a>=0&&(n.splice(a,0,e),this._doAdd(e))}return this},t.prototype.replace=function(e,i){var n=pt(this._children,e);return n>=0&&this.replaceAt(i,n),this},t.prototype.replaceAt=function(e,i){var n=this._children,a=n[i];if(e&&e!==this&&e.parent!==this&&e!==a){n[i]=e,a.parent=null;var o=this.__zr;o&&a.removeSelfFromZr(o),this._doAdd(e)}return this},t.prototype._doAdd=function(e){e.parent&&e.parent.remove(e),e.parent=this;var i=this.__zr;i&&i!==e.__zr&&e.addSelfToZr(i),i&&i.refresh()},t.prototype.remove=function(e){var i=this.__zr,n=this._children,a=pt(n,e);return a<0?this:(n.splice(a,1),e.parent=null,i&&e.removeSelfFromZr(i),i&&i.refresh(),this)},t.prototype.removeAll=function(){for(var e=this._children,i=this.__zr,n=0;n<e.length;n++){var a=e[n];i&&a.removeSelfFromZr(i),a.parent=null}return e.length=0,this},t.prototype.eachChild=function(e,i){for(var n=this._children,a=0;a<n.length;a++){var o=n[a];e.call(i,o,a)}return this},t.prototype.traverse=function(e,i){for(var n=0;n<this._children.length;n++){var a=this._children[n],o=e.call(i,a);a.isGroup&&!o&&a.traverse(e,i)}return this},t.prototype.addSelfToZr=function(e){r.prototype.addSelfToZr.call(this,e);for(var i=0;i<this._children.length;i++){var n=this._children[i];n.addSelfToZr(e)}},t.prototype.removeSelfFromZr=function(e){r.prototype.removeSelfFromZr.call(this,e);for(var i=0;i<this._children.length;i++){var n=this._children[i];n.removeSelfFromZr(e)}},t.prototype.getBoundingRect=function(e){for(var i=new mt(0,0,0,0),n=e||this._children,a=[],o=null,s=0;s<n.length;s++){var l=n[s];if(!(l.ignore||l.invisible)){var u=l.getBoundingRect(),h=l.getLocalTransform(a);h?(mt.applyTransform(i,u,h),o=o||i.clone(),o.union(i)):(o=o||u.clone(),o.union(u))}}return o||i},t}(fl);Bt.prototype.type="group";/*!
17
17
  * ZRender, a high performance 2d drawing library.
18
18
  *
@@ -57,4 +57,4 @@ yyyy`);var i=Le(t),n=e?"getUTC":"get",a=i[n+"FullYear"](),o=i[n+"Month"]()+1,s=i
57
57
  `:"";function i(n){var a=n.children,o=n.tag,s=n.attrs,l=n.text;return XL(o,s)+(o!=="style"?Kt(l):l||"")+(a?""+e+V(a,function(u){return i(u)}).join(e)+e:"")+qL(o)}return i(r)}function ZL(r,t,e){e=e||{};var i=e.newline?`
58
58
  `:"",n=" {"+i,a=i+"}",o=V(vt(r),function(l){return l+n+V(vt(r[l]),function(u){return u+":"+r[l][u]+";"}).join(i)+a}).join(i),s=V(vt(t),function(l){return"@keyframes "+l+n+V(vt(t[l]),function(u){return u+n+V(vt(t[l][u]),function(h){var c=t[l][u][h];return h==="d"&&(c='path("'+c+'")'),h+":"+c+";"}).join(i)+a}).join(i)+a}).join(i);return!o&&!s?"":["<![CDATA[",o,s,"]]>"].join(i)}function Rc(r){return{zrId:r,shadowCache:{},patternCache:{},gradientCache:{},clipPathCache:{},defs:{},cssNodes:{},cssAnims:{},cssStyleCache:{},cssAnimIdx:0,shadowIdx:0,gradientIdx:0,patternIdx:0,clipPathIdx:0}}function Bm(r,t,e,i){return Nt("svg","root",{width:r,height:t,xmlns:Px,"xmlns:xlink":kx,version:"1.1",baseProfile:"full",viewBox:i?"0 0 "+r+" "+t:!1},e)}var KL=0;function Lx(){return KL++}var zm={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"},Di="transform-origin";function JL(r,t,e){var i=N({},r.shape);N(i,t),r.buildPath(e,i);var n=new Ix;return n.reset(Fy(r)),e.rebuildPath(n,1),n.generateStr(),n.getStr()}function QL(r,t){var e=t.originX,i=t.originY;(e||i)&&(r[Di]=e+"px "+i+"px")}var tO={fill:"fill",opacity:"opacity",lineWidth:"stroke-width",lineDashOffset:"stroke-dashoffset"};function Ox(r,t){var e=t.zrId+"-ani-"+t.cssAnimIdx++;return t.cssAnims[e]=r,e}function eO(r,t,e){var i=r.shape.paths,n={},a,o;if(A(i,function(l){var u=Rc(e.zrId);u.animation=!0,Wl(l,{},u,!0);var h=u.cssAnims,c=u.cssNodes,f=vt(h),d=f.length;if(d){o=f[d-1];var p=h[o];for(var v in p){var g=p[v];n[v]=n[v]||{d:""},n[v].d+=g.d||""}for(var m in c){var _=c[m].animation;_.indexOf(o)>=0&&(a=_)}}}),!!a){t.d=!1;var s=Ox(n,e);return a.replace(o,s)}}function Vm(r){return U(r)?zm[r]?"cubic-bezier("+zm[r]+")":Yc(r)?r:"":""}function Wl(r,t,e,i){var n=r.animators,a=n.length,o=[];if(r instanceof hf){var s=eO(r,t,e);if(s)o.push(s);else if(!a)return}else if(!a)return;for(var l={},u=0;u<a;u++){var h=n[u],c=[h.getMaxTime()/1e3+"s"],f=Vm(h.getClip().easing),d=h.getDelay();f?c.push(f):c.push("linear"),d&&c.push(d/1e3+"s"),h.getLoop()&&c.push("infinite");var p=c.join(" ");l[p]=l[p]||[p,[]],l[p][1].push(h)}function v(_){var b=_[1],x=b.length,C={},S={},T={},M="animation-timing-function";function D(Lt,xt,z){for(var Y=Lt.getTracks(),K=Lt.getMaxTime(),Ot=0;Ot<Y.length;Ot++){var St=Y[Ot];if(St.needsAnimate()){var se=St.keyframes,je=St.propName;if(z&&(je=z(je)),je)for(var ei=0;ei<se.length;ei++){var Tr=se[ei],ri=Math.round(Tr.time/K*100)+"%",qn=Vm(Tr.easing),Zn=Tr.rawValue;(U(Zn)||At(Zn))&&(xt[ri]=xt[ri]||{},xt[ri][je]=Tr.rawValue,qn&&(xt[ri][M]=qn))}}}}for(var I=0;I<x;I++){var P=b[I],k=P.targetName;k?k==="shape"&&D(P,S):!i&&D(P,C)}for(var R in C){var L={};Wy(L,r),N(L,C[R]);var j=By(L),E=C[R][M];T[R]=j?{transform:j}:{},QL(T[R],L),E&&(T[R][M]=E)}var q,W=!0;for(var R in S){T[R]=T[R]||{};var $=!q,E=S[R][M];$&&(q=new Jr);var et=q.len();q.reset(),T[R].d=JL(r,S[R],q);var ut=q.len();if(!$&&et!==ut){W=!1;break}E&&(T[R][M]=E)}if(!W)for(var R in T)delete T[R].d;if(!i)for(var I=0;I<x;I++){var P=b[I],k=P.targetName;k==="style"&&D(P,T,function(Y){return tO[Y]})}for(var ot=vt(T),ft=!0,gt,I=1;I<ot.length;I++){var B=ot[I-1],Rt=ot[I];if(T[B][Di]!==T[Rt][Di]){ft=!1;break}gt=T[B][Di]}if(ft&&gt){for(var R in T)T[R][Di]&&delete T[R][Di];t[Di]=gt}if(It(ot,function(Lt){return vt(T[Lt]).length>0}).length){var Mt=Ox(T,e);return Mt+" "+_[0]+" both"}}for(var g in l){var s=v(l[g]);s&&o.push(s)}if(o.length){var m=e.zrId+"-cls-"+Lx();e.cssNodes["."+m]={animation:o.join(",")},t.class=m}}function rO(r,t,e){if(!r.ignore)if(r.isSilent()){var i={"pointer-events":"none"};Hm(i,t,e)}else{var n=r.states.emphasis&&r.states.emphasis.style?r.states.emphasis.style:{},a=n.fill;if(!a){var o=r.style&&r.style.fill,s=r.states.select&&r.states.select.style&&r.states.select.style.fill,l=r.currentStates.indexOf("select")>=0&&s||o;l&&(a=Hs(l))}var u=n.lineWidth;if(u){var h=!n.strokeNoScale&&r.transform?r.transform[0]:1;u=u/h}var i={cursor:"pointer"};a&&(i.fill=a),n.stroke&&(i.stroke=n.stroke),u&&(i["stroke-width"]=u),Hm(i,t,e)}}function Hm(r,t,e,i){var n=JSON.stringify(r),a=e.cssStyleCache[n];a||(a=e.zrId+"-cls-"+Lx(),e.cssStyleCache[n]=a,e.cssNodes["."+a+":hover"]=r),t.class=t.class?t.class+" "+a:a}var go=Math.round;function Ex(r){return r&&U(r.src)}function jx(r){return r&&tt(r.toDataURL)}function dd(r,t,e,i){UL(function(n,a){var o=n==="fill"||n==="stroke";o&&Ny(a)?Fx(t,r,n,i):o&&qc(a)?Bx(e,r,n,i):r[n]=a,o&&i.ssr&&a==="none"&&(r["pointer-events"]="visible")},t,e,!1),uO(e,r,i)}function pd(r,t){var e=Yy(t);e&&(e.each(function(i,n){i!=null&&(r[(Fm+n).toLowerCase()]=i+"")}),t.isSilent()&&(r[Fm+"silent"]="true"))}function Wm(r){return Wr(r[0]-1)&&Wr(r[1])&&Wr(r[2])&&Wr(r[3]-1)}function iO(r){return Wr(r[4])&&Wr(r[5])}function vd(r,t,e){if(t&&!(iO(t)&&Wm(t))){var i=1e4;r.transform=Wm(t)?"translate("+go(t[4]*i)/i+" "+go(t[5]*i)/i+")":dS(t)}}function Gm(r,t,e){for(var i=r.points,n=[],a=0;a<i.length;a++)n.push(go(i[a][0]*e)/e),n.push(go(i[a][1]*e)/e);t.points=n.join(" ")}function Um(r){return!r.smooth}function nO(r){var t=V(r,function(e){return typeof e=="string"?[e,e]:e});return function(e,i,n){for(var a=0;a<t.length;a++){var o=t[a],s=e[o[0]];s!=null&&(i[o[1]]=go(s*n)/n)}}}var aO={circle:[nO(["cx","cy","r"])],polyline:[Gm,Um],polygon:[Gm,Um]};function oO(r){for(var t=r.animators,e=0;e<t.length;e++)if(t[e].targetName==="shape")return!0;return!1}function Nx(r,t){var e=r.style,i=r.shape,n=aO[r.type],a={},o=t.animation,s="path",l=r.style.strokePercent,u=t.compress&&Fy(r)||4;if(n&&!t.willUpdate&&!(n[1]&&!n[1](i))&&!(o&&oO(r))&&!(l<1)){s=r.type;var h=Math.pow(10,u);n[0](i,a,h)}else{var c=!r.path||r.shapeChanged();r.path||r.createPathProxy();var f=r.path;c&&(f.beginPath(),r.buildPath(f,r.shape),r.pathUpdated());var d=f.getVersion(),p=r,v=p.__svgPathBuilder;(p.__svgPathVersion!==d||!v||l!==p.__svgPathStrokePercent)&&(v||(v=p.__svgPathBuilder=new Ix),v.reset(u),f.rebuildPath(v,l),v.generateStr(),p.__svgPathVersion=d,p.__svgPathStrokePercent=l),a.d=v.getStr()}return vd(a,r.transform),dd(a,e,r,t),pd(a,r),t.animation&&Wl(r,a,t),t.emphasis&&rO(r,a,t),Nt(s,r.id+"",a)}function sO(r,t){var e=r.style,i=e.image;if(i&&!U(i)&&(Ex(i)?i=i.src:jx(i)&&(i=i.toDataURL())),!!i){var n=e.x||0,a=e.y||0,o=e.width,s=e.height,l={href:i,width:o,height:s};return n&&(l.x=n),a&&(l.y=a),vd(l,r.transform),dd(l,e,r,t),pd(l,r),t.animation&&Wl(r,l,t),Nt("image",r.id+"",l)}}function lO(r,t){var e=r.style,i=e.text;if(i!=null&&(i+=""),!(!i||isNaN(e.x)||isNaN(e.y))){var n=e.font||qr,a=e.x||0,o=vS(e.y||0,cl(n),e.textBaseline),s=pS[e.textAlign]||e.textAlign,l={"dominant-baseline":"central","text-anchor":s};if(g0(e)){var u="",h=e.fontStyle,c=v0(e.fontSize);if(!parseFloat(c))return;var f=e.fontFamily||oy,d=e.fontWeight;u+="font-size:"+c+";font-family:"+f+";",h&&h!=="normal"&&(u+="font-style:"+h+";"),d&&d!=="normal"&&(u+="font-weight:"+d+";"),l.style=u}else l.style="font: "+n;return i.match(/\s/)&&(l["xml:space"]="preserve"),a&&(l.x=a),o&&(l.y=o),vd(l,r.transform),dd(l,e,r,t),pd(l,r),t.animation&&Wl(r,l,t),Nt("text",r.id+"",l,void 0,i)}}function $m(r,t){if(r instanceof bt)return Nx(r,t);if(r instanceof Ze)return sO(r,t);if(r instanceof no)return lO(r,t)}function uO(r,t,e){var i=r.style;if(gS(i)){var n=mS(r),a=e.shadowCache,o=a[n];if(!o){var s=r.getGlobalScale(),l=s[0],u=s[1];if(!l||!u)return;var h=i.shadowOffsetX||0,c=i.shadowOffsetY||0,f=i.shadowBlur,d=Ja(i.shadowColor),p=d.opacity,v=d.color,g=f/2/l,m=f/2/u,_=g+" "+m;o=e.zrId+"-s"+e.shadowIdx++,e.defs[o]=Nt("filter",o,{id:o,x:"-100%",y:"-100%",width:"300%",height:"300%"},[Nt("feDropShadow","",{dx:h/l,dy:c/u,stdDeviation:_,"flood-color":v,"flood-opacity":p})]),a[n]=o}t.filter=ul(o)}}function Fx(r,t,e,i){var n=r[e],a,o={gradientUnits:n.global?"userSpaceOnUse":"objectBoundingBox"};if(Ey(n))a="linearGradient",o.x1=n.x,o.y1=n.y,o.x2=n.x2,o.y2=n.y2;else if(jy(n))a="radialGradient",o.cx=Q(n.x,.5),o.cy=Q(n.y,.5),o.r=Q(n.r,.5);else return;for(var s=n.colorStops,l=[],u=0,h=s.length;u<h;++u){var c=Rh(s[u].offset)*100+"%",f=s[u].color,d=Ja(f),p=d.color,v=d.opacity,g={offset:c};g["stop-color"]=p,v<1&&(g["stop-opacity"]=v),l.push(Nt("stop",u+"",g))}var m=Nt(a,"",o,l),_=fd(m),b=i.gradientCache,x=b[_];x||(x=i.zrId+"-g"+i.gradientIdx++,b[_]=x,o.id=x,i.defs[x]=Nt(a,x,o,l)),t[e]=ul(x)}function Bx(r,t,e,i){var n=r.style[e],a=r.getBoundingRect(),o={},s=n.repeat,l=s==="no-repeat",u=s==="repeat-x",h=s==="repeat-y",c;if(Oy(n)){var f=n.imageWidth,d=n.imageHeight,p=void 0,v=n.image;if(U(v)?p=v:Ex(v)?p=v.src:jx(v)&&(p=v.toDataURL()),typeof Image>"u"){var g="Image width/height must been given explictly in svg-ssr renderer.";be(f,g),be(d,g)}else if(f==null||d==null){var m=function(I,P){if(I){var k=I.elm,R=f||P.width,L=d||P.height;I.tag==="pattern"&&(u?(L=1,R/=a.width):h&&(R=1,L/=a.height)),I.attrs.width=R,I.attrs.height=L,k&&(k.setAttribute("width",R),k.setAttribute("height",L))}},_=af(p,null,r,function(I){l||m(S,I),m(c,I)});_&&_.width&&_.height&&(f=f||_.width,d=d||_.height)}c=Nt("image","img",{href:p,width:f,height:d}),o.width=f,o.height=d}else n.svgElement&&(c=it(n.svgElement),o.width=n.svgWidth,o.height=n.svgHeight);if(c){var b,x;l?b=x=1:u?(x=1,b=o.width/a.width):h?(b=1,x=o.height/a.height):o.patternUnits="userSpaceOnUse",b!=null&&!isNaN(b)&&(o.width=b),x!=null&&!isNaN(x)&&(o.height=x);var C=By(n);C&&(o.patternTransform=C);var S=Nt("pattern","",o,[c]),T=fd(S),M=i.patternCache,D=M[T];D||(D=i.zrId+"-p"+i.patternIdx++,M[T]=D,o.id=D,S=i.defs[D]=Nt("pattern",D,o,[c])),t[e]=ul(D)}}function hO(r,t,e){var i=e.clipPathCache,n=e.defs,a=i[r.id];if(!a){a=e.zrId+"-c"+e.clipPathIdx++;var o={id:a};i[r.id]=a,n[a]=Nt("clipPath",a,o,[Nx(r,e)])}t["clip-path"]=ul(a)}function Ym(r){return document.createTextNode(r)}function ki(r,t,e){r.insertBefore(t,e)}function Xm(r,t){r.removeChild(t)}function qm(r,t){r.appendChild(t)}function zx(r){return r.parentNode}function Vx(r){return r.nextSibling}function ph(r,t){r.textContent=t}var Zm=58,cO=120,fO=Nt("","");function Lc(r){return r===void 0}function ir(r){return r!==void 0}function dO(r,t,e){for(var i={},n=t;n<=e;++n){var a=r[n].key;a!==void 0&&(i[a]=n)}return i}function Ra(r,t){var e=r.key===t.key,i=r.tag===t.tag;return i&&e}function mo(r){var t,e=r.children,i=r.tag;if(ir(i)){var n=r.elm=Rx(i);if(gd(fO,r),H(e))for(t=0;t<e.length;++t){var a=e[t];a!=null&&qm(n,mo(a))}else ir(r.text)&&!Z(r.text)&&qm(n,Ym(r.text))}else r.elm=Ym(r.text);return r.elm}function Hx(r,t,e,i,n){for(;i<=n;++i){var a=e[i];a!=null&&ki(r,mo(a),t)}}function al(r,t,e,i){for(;e<=i;++e){var n=t[e];if(n!=null)if(ir(n.tag)){var a=zx(n.elm);Xm(a,n.elm)}else Xm(r,n.elm)}}function gd(r,t){var e,i=t.elm,n=r&&r.attrs||{},a=t.attrs||{};if(n!==a){for(e in a){var o=a[e],s=n[e];s!==o&&(o===!0?i.setAttribute(e,""):o===!1?i.removeAttribute(e):e==="style"?i.style.cssText=o:e.charCodeAt(0)!==cO?i.setAttribute(e,o):e==="xmlns:xlink"||e==="xmlns"?i.setAttributeNS($L,e,o):e.charCodeAt(3)===Zm?i.setAttributeNS(YL,e,o):e.charCodeAt(5)===Zm?i.setAttributeNS(kx,e,o):i.setAttribute(e,o))}for(e in n)e in a||i.removeAttribute(e)}}function pO(r,t,e){for(var i=0,n=0,a=t.length-1,o=t[0],s=t[a],l=e.length-1,u=e[0],h=e[l],c,f,d,p;i<=a&&n<=l;)o==null?o=t[++i]:s==null?s=t[--a]:u==null?u=e[++n]:h==null?h=e[--l]:Ra(o,u)?(Sn(o,u),o=t[++i],u=e[++n]):Ra(s,h)?(Sn(s,h),s=t[--a],h=e[--l]):Ra(o,h)?(Sn(o,h),ki(r,o.elm,Vx(s.elm)),o=t[++i],h=e[--l]):Ra(s,u)?(Sn(s,u),ki(r,s.elm,o.elm),s=t[--a],u=e[++n]):(Lc(c)&&(c=dO(t,i,a)),f=c[u.key],Lc(f)?ki(r,mo(u),o.elm):(d=t[f],d.tag!==u.tag?ki(r,mo(u),o.elm):(Sn(d,u),t[f]=void 0,ki(r,d.elm,o.elm))),u=e[++n]);(i<=a||n<=l)&&(i>a?(p=e[l+1]==null?null:e[l+1].elm,Hx(r,p,e,n,l)):al(r,t,i,a))}function Sn(r,t){var e=t.elm=r.elm,i=r.children,n=t.children;r!==t&&(gd(r,t),Lc(t.text)?ir(i)&&ir(n)?i!==n&&pO(e,i,n):ir(n)?(ir(r.text)&&ph(e,""),Hx(e,null,n,0,n.length-1)):ir(i)?al(e,i,0,i.length-1):ir(r.text)&&ph(e,""):r.text!==t.text&&(ir(i)&&al(e,i,0,i.length-1),ph(e,t.text)))}function vO(r,t){if(Ra(r,t))Sn(r,t);else{var e=r.elm,i=zx(e);mo(t),i!==null&&(ki(i,t.elm,Vx(e)),al(i,[r],0,0))}return t}var gO=0,mO=function(){function r(t,e,i){if(this.type="svg",this.refreshHover=Km(),this.configLayer=Km(),this.storage=e,this._opts=i=N({},i),this.root=t,this._id="zr"+gO++,this._oldVNode=Bm(i.width,i.height),t&&!i.ssr){var n=this._viewport=document.createElement("div");n.style.cssText="position:relative;overflow:hidden";var a=this._svgDom=this._oldVNode.elm=Rx("svg");gd(null,this._oldVNode),n.appendChild(a),t.appendChild(n)}this.resize(i.width,i.height)}return r.prototype.getType=function(){return this.type},r.prototype.getViewportRoot=function(){return this._viewport},r.prototype.getViewportRootOffset=function(){var t=this.getViewportRoot();if(t)return{offsetLeft:t.offsetLeft||0,offsetTop:t.offsetTop||0}},r.prototype.getSvgDom=function(){return this._svgDom},r.prototype.refresh=function(){if(this.root){var t=this.renderToVNode({willUpdate:!0});t.attrs.style="position:absolute;left:0;top:0;user-select:none",vO(this._oldVNode,t),this._oldVNode=t}},r.prototype.renderOneToVNode=function(t){return $m(t,Rc(this._id))},r.prototype.renderToVNode=function(t){t=t||{};var e=this.storage.getDisplayList(!0),i=this._width,n=this._height,a=Rc(this._id);a.animation=t.animation,a.willUpdate=t.willUpdate,a.compress=t.compress,a.emphasis=t.emphasis,a.ssr=this._opts.ssr;var o=[],s=this._bgVNode=yO(i,n,this._backgroundColor,a);s&&o.push(s);var l=t.compress?null:this._mainVNode=Nt("g","main",{},[]);this._paintList(e,a,l?l.children:o),l&&o.push(l);var u=V(vt(a.defs),function(f){return a.defs[f]});if(u.length&&o.push(Nt("defs","defs",{},u)),t.animation){var h=ZL(a.cssNodes,a.cssAnims,{newline:!0});if(h){var c=Nt("style","stl",{},[],h);o.push(c)}}return Bm(i,n,o,t.useViewBox)},r.prototype.renderToString=function(t){return t=t||{},fd(this.renderToVNode({animation:Q(t.cssAnimation,!0),emphasis:Q(t.cssEmphasis,!0),willUpdate:!1,compress:!0,useViewBox:Q(t.useViewBox,!0)}),{newline:!0})},r.prototype.setBackgroundColor=function(t){this._backgroundColor=t},r.prototype.getSvgRoot=function(){return this._mainVNode&&this._mainVNode.elm},r.prototype._paintList=function(t,e,i){for(var n=t.length,a=[],o=0,s,l,u=0,h=0;h<n;h++){var c=t[h];if(!c.invisible){var f=c.__clipPaths,d=f&&f.length||0,p=l&&l.length||0,v=void 0;for(v=Math.max(d-1,p-1);v>=0&&!(f&&l&&f[v]===l[v]);v--);for(var g=p-1;g>v;g--)o--,s=a[o-1];for(var m=v+1;m<d;m++){var _={};hO(f[m],_,e);var b=Nt("g","clip-g-"+u++,_,[]);(s?s.children:i).push(b),a[o++]=b,s=b}l=f;var x=$m(c,e);x&&(s?s.children:i).push(x)}}},r.prototype.resize=function(t,e){var i=this._opts,n=this.root,a=this._viewport;if(t!=null&&(i.width=t),e!=null&&(i.height=e),n&&a&&(a.style.display="none",t=Xv(n,0,i),e=Xv(n,1,i),a.style.display=""),this._width!==t||this._height!==e){if(this._width=t,this._height=e,a){var o=a.style;o.width=t+"px",o.height=e+"px"}if(qc(this._backgroundColor))this.refresh();else{var s=this._svgDom;s&&(s.setAttribute("width",t),s.setAttribute("height",e));var l=this._bgVNode&&this._bgVNode.elm;l&&(l.setAttribute("width",t),l.setAttribute("height",e))}}},r.prototype.getWidth=function(){return this._width},r.prototype.getHeight=function(){return this._height},r.prototype.dispose=function(){this.root&&(this.root.innerHTML=""),this._svgDom=this._viewport=this.storage=this._oldVNode=this._bgVNode=this._mainVNode=null},r.prototype.clear=function(){this._svgDom&&(this._svgDom.innerHTML=null),this._oldVNode=null},r.prototype.toDataURL=function(t){var e=this.renderToString(),i="data:image/svg+xml;";return t?(e=_S(e),e&&i+"base64,"+e):i+"charset=UTF-8,"+encodeURIComponent(e)},r}();function Km(r){return function(){}}function yO(r,t,e,i){var n;if(e&&e!=="none")if(n=Nt("rect","bg",{width:r,height:t,x:"0",y:"0"}),Ny(e))Fx({fill:e},n.attrs,"fill",i);else if(qc(e))Bx({style:{fill:e},dirty:Gt,getBoundingRect:function(){return{width:r,height:t}}},n.attrs,"fill",i);else{var a=Ja(e),o=a.color,s=a.opacity;n.attrs.fill=o,s<1&&(n.attrs["fill-opacity"]=s)}return n}function _O(r){r.registerPainter("svg",mO)}const bO=""+new URL("echarts-BDq-rBJC.png",import.meta.url).href;Yi([BL,sL,IL,AL,gR,GP,_O]);const Et={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"hidden",width:"100%"},chart:{width:"100%",overflow:"hidden"},chartWithToolbar:r=>({height:`calc(100% - ${parseInt(r.mixins.toolbar.minHeight,10)+8}px)`}),chartWithoutToolbar:{height:"100%"},selectHistoryControl:{width:130},selectRelativeTime:{marginLeft:10,width:200},notAliveInstance:{opacity:.5},customRange:r=>({color:r.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}},he=80,Mi=25;class xO extends at.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(t){if(super(t),this.localStorage=window._localStorage||window.localStorage,this.props.from)this.start=this.props.from;else{const a=new Date;a.setHours(a.getHours()-24*7),this.start=a.getTime()}this.props.end?this.end=this.props.end:this.end=Date.now();let e=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)&&(!e||e==="absolute")&&(e="30"),n&&i&&(e="absolute"),this.state={historyInstance:this.props.historyInstance||"",historyInstances:null,defaultHistory:"",chartHeight:300,chartWidth:500,ampm:!1,relativeRange:e,splitLine:this.localStorage.getItem("App.splitLine")==="true",min:i,max:n,maxYLen:0,stepType:"",echartsJump:!1},this.echartsReact=null,this.rangeRef=at.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=at.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 t=0;t<this.subscribes.length;t++)this.props.socket.unsubscribeState(this.subscribes[t],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.componentDidUpdate()})};onChange=(t,e)=>{if(t===this.props.obj._id&&e&&this.rangeValues&&(!this.rangeValues.length||this.rangeValues[this.rangeValues.length-1].ts<e.ts))(!this.state.max||e.ts-this.state.max<12e4)&&(this.chartValues&&this.chartValues.push({val:e.val,ts:e.ts}),this.rangeValues.push({val:e.val,ts:e.ts}),e.ts>=this.chart.min&&e.ts<=this.chart.max+3e5&&this.updateChart());else if(t.startsWith("system.adapter.")&&t.endsWith(".alive")&&this.state.historyInstances){const i=t.substring(15,t.length-6),n=this.state.historyInstances,a=n.findIndex(o=>o.id===i);if(a!==-1&&n[a].alive!==!!(e!=null&&e.val)){const o=JSON.parse(JSON.stringify(n));o[a].alive=!!(e!=null&&e.val),this.setState({historyInstances:o},()=>{o[a].alive&&this.state.historyInstance===i&&this.readHistoryRange().then(()=>this.updateChart())})}}};async prepareData(){var s;if(this.props.noToolbar){const l=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(u=>{this.setState({defaultHistory:this.props.defaultHistory,historyInstance:this.props.defaultHistory,historyInstances:[{id:this.props.defaultHistory,alive:!!(l!=null&&l.val)}]},()=>u(null))});return}let t=await this.getHistoryInstances();const e=await this.props.socket.getCompactSystemConfig();let i=[];this.props.showJumpToEchart&&(i=await this.props.socket.getAdapterInstances("echarts",!0));const n=!!i.find(l=>l._id.startsWith("system.adapter.echarts.")),a=e&&e.common&&e.common.defaultHistory;this.props.obj.common.custom&&(t=t.filter(l=>this.props.obj.common.custom[l.id]));let o=this.localStorage.getItem("App.historyInstance")||"";if((!o||!t.find(l=>l.id===o&&l.alive))&&(o=a),!o||!t.find(l=>l.id===o&&l.alive)){const l=t.find(u=>u.alive);l&&(o=l.id)}!o&&t.length&&(o=a),this.setState({ampm:e.common.dateFormat.includes("/"),historyInstances:t,defaultHistory:a,historyInstance:o,echartsJump:n,stepType:this.props.obj.common.custom&&((s=this.props.obj.common.custom[o])==null?void 0:s.chartStep)||""})}getHistoryInstances(){if(this.props.historyInstance)return Promise.resolve([]);const t=[],e=[];return this.props.customsInstances.forEach(i=>{var a;const n=this.props.objects[`system.adapter.${i}`];if((a=n==null?void 0:n.common)!=null&&a.getHistory){const o={id:i,alive:!1};t.push(o),e.push(`system.adapter.${i}.alive`)}}),e.length?this.props.socket.getForeignStates(e).then(async i=>{Object.keys(i).forEach(n=>{var o;const a=t.find(s=>n.endsWith(`${s.id}.alive`));a&&(a.alive=!!((o=i[n])!=null&&o.val))}),this.subscribes=e;for(let n=0;n<e.length;n++)await this.props.socket.subscribeState(e[n],this.onChange);return t}):Promise.resolve(t)}readHistoryRange(){var i;const t=new Date,e=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:e.getTime(),end:t.getTime(),limit:1,from:!1,ack:!1,q:!1,addId:!1,aggregate:"none"}).then(n=>{var a;n&&((a=n[0])==null?void 0:a.val)===null&&n.shift(),this.rangeValues=n}):Promise.resolve()}readHistory(t,e){var n;if(!this.state.historyInstance||!((n=this.state.historyInstances)!=null&&n.find(a=>a.id===this.state.historyInstance&&a.alive)))return Promise.resolve([]);const i={instance:this.state.historyInstance,start:t,end:e,from:!1,ack:!1,q:!1,addId:!1,aggregate:"none",returnNewestEntries:!0};return e-t>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(a=>{const o=[];let s=0;const l=this.rangeValues;let u=null,h=null;for(let c=0;c<a.length;c++){if(l)for(;s<l.length&&l[s].ts<a[c].ts;)o.push(l[s]),s++;!o.length||o[o.length-1].ts<a[c].ts?o.push(a[c]):o[o.length-1].ts===a[c].ts&&o[o.length-1].val!==a[c].ts&&console.error("Strange data!"),(u===null||a[c].val<u)&&(u=a[c].val),(h===null||a[c].val>h)&&(h=a[c].val)}if(l)for(;s<l.length;)o.push(l[s]),console.log(`add range ${new Date(l[s].ts).toISOString()}: ${l[s].val}`),s++;return o.sort((c,f)=>c.ts>f.ts?1:c.ts<f.ts?-1:0),this.chartValues=o,this.minY=u,this.maxY=h,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(t){t=t||this.chartValues;const e=[];if(!t.length)return[];for(let i=0;i<t.length;i++){const n={value:[t[i].ts,t[i].val]};t[i].i&&(n.exact=!1),e.push(n)}return this.chart.min||(this.chart.min=t[0].ts,this.chart.max=t[t.length-1].ts),e}getOption(){let t;if(this.minY!==null&&this.minY!==void 0&&(t=(this.minY.toString()+this.unit).length*9+12),this.maxY!==null&&this.maxY!==void 0){const a=(this.maxY.toString()+this.unit).length*9+12;a>t&&(t=a)}if(this.state.maxYLen){const a=this.state.maxYLen*9+12;a>t&&(t=a)}const e={xAxisIndex:0,type:"line",step:this.state.stepType==="stepStart"?"start":this.state.stepType==="stepMiddle"?"middle":this.state.stepType==="stepEnd"?"end":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:a=>{let o;return this.props.isFloatComma?o=a.toString().replace(",",".")+this.unit:o=a+this.unit,this.state.maxYLen<o.length&&(this.maxYLenTimeout&&clearTimeout(this.maxYLenTimeout),this.maxYLenTimeout=setTimeout(s=>{this.maxYLenTimeout=null,this.setState({maxYLen:s})},200,o.length)),o},showMaxLabel:!0,showMinLabel:!0},axisTick:{alignWithLabel:!0}};if(this.props.obj.common.type==="boolean")e.step="end",i.axisLabel.showMaxLabel=!1,i.axisLabel.formatter=a=>a===1?"TRUE":"FALSE",i.max=1.5,i.interval=1,t=50;else if(this.props.obj.common.type==="number"&&this.props.obj.common.states){e.step="end",i.axisLabel.showMaxLabel=!1;const a=this.props.obj.common.states;i.axisLabel.formatter=l=>a[l]!==void 0?a[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 s="";for(let l=0;l<o.length;l++)typeof a[o[l]]=="string"&&a[o[l]].length>s.length&&(s=a[o[l]]);t=(s.length*9||50)+12}const n=this.chart.withSeconds?Math.round((this.state.chartWidth-Mi-he)/100):Math.round((this.state.chartWidth-Mi-he)/60);return{backgroundColor:"transparent",title:{text:this.props.noToolbar?"":jt.getObjectNameFromObj(this.props.obj,this.props.lang),padding:[10,0,0,t?t+10:he+10]},grid:{left:t||he,top:8,right:this.props.noToolbar?5:Mi,bottom:40},tooltip:{trigger:"axis",formatter:a=>{const o=a[0],s=new Date(o.value[0]);let l=o.value[1];return l!==null&&this.props.isFloatComma&&(l=l.toString().replace(".",",")),`${o.exact===!1?"i":""}${s.toLocaleString()}.${s.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:a=>{const o=new Date(a);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")}
59
59
  ${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")}
60
- ${o.getFullYear()}`}}},yAxis:i,toolbox:{left:"right",feature:this.props.noToolbar?void 0:{saveAsImage:{title:this.props.t("Save as image"),show:!0}}},series:[e]}}static getDerivedStateFromProps(t,e){return null}updateChart(t,e,i,n){t&&(this.start=t),e&&(this.end=e),t=t||this.start,e=e||this.end,this.readTimeout&&clearTimeout(this.readTimeout),this.readTimeout=setTimeout(()=>{var o;this.readTimeout=null;const a=this.chart.max-this.chart.min;a!==this.chart.diff&&(this.chart.diff=a,this.chart.withTime=this.chart.diff<36e5*24*7,this.chart.withSeconds=this.chart.diff<6e4*30),i?this.readHistory(t,e).then(s=>{var l;typeof((l=this.echartsReact)==null?void 0:l.getEchartsInstance)=="function"&&this.echartsReact.getEchartsInstance().setOption({series:[{data:this.convertData(s)}],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(t){var e;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((e=this.echartsReact)==null?void 0:e.getEchartsInstance)=="function"&&(this.echartsReact.getEchartsInstance().setOption({xAxis:{min:this.chart.min,max:this.chart.max}}),t&&this.updateChart(this.chart.min,this.chart.max,!0))}shiftTime(){const t=new Date,e=6e4-t.getSeconds()-(1e3-t.getMilliseconds());t.getMilliseconds()&&t.setMilliseconds(1e3),t.getSeconds()&&t.setSeconds(60);const i=t.getTime();let n;const a=this.state.relativeRange;if(a==="day")t.setHours(0),t.setMinutes(0),t.setSeconds(0),n=t.getTime();else if(a==="week"){t.setHours(0),t.setMinutes(0),t.setSeconds(0);const o=t.getDay()||7;o!==1&&t.setHours(-24*(o-1)),n=t.getTime()}else if(a==="2weeks"){t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setDate(t.getDate()-7);const o=t.getDay()||7;o!==1&&t.setHours(-24*(o-1)),n=t.getTime()}else a==="month"?(t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setDate(1),n=t.getTime()):a==="year"?(t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setDate(1),t.setMonth(0),n=t.getTime()):a==="12months"?(t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setFullYear(t.getFullYear()-1),n=t.getTime()):n=i-parseInt(a,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()},e||6e4)}setRelativeInterval(t,e,i){if(e||(this.localStorage.setItem("App.relativeRange",t),this.setState({relativeRange:t})),t==="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 a=6e4-n.getSeconds()-(1e3-n.getMilliseconds());this.timeTimer=setTimeout(()=>{this.timeTimer=null,this.shiftTime()},a||6e4)}if(n.getMilliseconds()&&n.setMilliseconds(1e3),n.getSeconds()&&n.setSeconds(60),this.chart.max=n.getTime(),t==="day")n.setHours(0),n.setMinutes(0),n.setSeconds(0),this.chart.min=n.getTime();else if(t==="week"){n.setHours(0),n.setMinutes(0),n.setSeconds(0);const a=n.getDay()||7;a!==1&&n.setHours(-24*(a-1)),this.chart.min=n.getTime()}else if(t==="2weeks"){n.setHours(0),n.setMinutes(0),n.setSeconds(0),n.setDate(n.getDate()-7);const a=n.getDay()||7;a!==1&&n.setHours(-24*(a-1)),this.chart.min=n.getTime()}else t==="month"?(n.setHours(0),n.setMinutes(0),n.setSeconds(0),n.setDate(1),this.chart.min=n.getTime()):t==="year"?(n.setHours(0),n.setMinutes(0),n.setSeconds(0),n.setDate(1),n.setMonth(0),this.chart.min=n.getTime()):t==="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(t,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 t=this.echartsReact.getEchartsInstance().getZr();t._iobInstalled||(t._iobInstalled=!0,t.on("mousedown",e=>{console.log("mouse down"),this.mouseDown=!0,this.chart.lastX=e.offsetX}),t.on("mouseup",()=>{console.log("mouse up"),this.mouseDown=!1,this.setNewRange(!0)}),t.on("mousewheel",e=>{let i=this.chart.max-this.chart.min;const n=this.state.chartWidth-Mi-he,o=(e.offsetX-he)/n,s=i,l=e.wheelDelta>0?1.1:.9;i*=l;const u=s-i;this.chart.max+=u*(1-o),this.chart.min-=u*o,this.setNewRange()}),t.on("mousemove",e=>{if(this.mouseDown){const i=this.chart.lastX-(e.offsetX-he);this.chart.lastX=e.offsetX-he;const n=this.chart.max-this.chart.min,a=this.state.chartWidth-Mi-he,o=Math.round(i*n/a);this.chart.min+=o,this.chart.max+=o,this.setNewRange()}}),t.on("touchstart",e=>{e.preventDefault(),this.mouseDown=!0;const i=e.touches||e.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)}),t.on("touchend",e=>{e.preventDefault(),this.mouseDown=!1,this.setNewRange(!0)}),t.on("touchmove",e=>{e.preventDefault();const i=e.touches||e.originalEvent.touches;if(!i)return;const n=i[i.length-1].pageX-he;if(this.mouseDown)if(i.length>1){const a=Math.abs(i[0].pageX-i[1].pageX);if(this.chart.lastWidth!==null&&a!==this.chart.lastWidth){let o=this.chart.max-this.chart.min;const s=this.state.chartWidth-Mi-he,l=a>this.chart.lastWidth?1.1:.9,h=(i[0].pageX>i[1].pageX?i[1].pageX-he+a/2:i[0].pageX-he+a/2)/s,c=o;o*=l;const f=c-o;this.chart.max+=f*(1-h),this.chart.min-=f*h,this.setNewRange()}this.chart.lastWidth=a}else{const a=this.chart.lastX-n,o=this.chart.max-this.chart.min,s=this.state.chartWidth-Mi-he,l=Math.round(a*o/s);this.chart.min+=l,this.chart.max+=l,this.setNewRange()}this.chart.lastX=n}))}renderChart(){var t;return this.state.historyInstance?(t=this.state.historyInstances)!=null&&t.find(e=>e.id===this.state.historyInstance&&e.alive)?this.chartValues?y.jsx(Uw,{ref:e=>this.echartsReact=e,echarts:gP,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()}}):y.jsx(w.LinearProgress,{}):y.jsx("div",{style:{marginTop:20,fontSize:24,marginLeft:24},children:this.props.t("History instance not alive")}):y.jsx("div",{style:{marginTop:20,fontSize:24,marginLeft:24},children:this.props.t("History instance not selected")})}componentDidUpdate(){if(this.divRef.current){const t=this.divRef.current.offsetWidth,e=this.divRef.current.offsetHeight;this.state.chartHeight!==e&&(this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.updateTimer=null,this.setState({chartHeight:e,chartWidth:t})},100))}}setStartDate(t){const e=t.getTime();this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=null),this.localStorage.setItem("App.relativeRange","absolute"),this.localStorage.setItem("App.absoluteStart",e.toString()),this.localStorage.setItem("App.absoluteEnd",this.state.max.toString()),this.chart.min=e,this.setState({min:e,relativeRange:"absolute"},()=>this.updateChart(this.chart.min,this.chart.max,!0))}setEndDate(t){const e=t.getTime();this.localStorage.setItem("App.relativeRange","absolute"),this.localStorage.setItem("App.absoluteStart",this.state.min.toString()),this.localStorage.setItem("App.absoluteEnd",e.toString()),this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=null),this.chart.max=e,this.setState({max:e,relativeRange:"absolute"},()=>this.updateChart(this.chart.min,this.chart.max,!0))}openEcharts(){const t=[`id=${window.encodeURIComponent(this.props.obj._id)}`,`instance=${window.encodeURIComponent(this.state.historyInstance)}`,"menuOpened=false"];this.state.relativeRange==="absolute"?(t.push(`start=${this.chart.min}`),t.push(`end=${this.chart.max}`)):t.push(`range=${this.state.relativeRange}`),window.open(`${window.location.protocol}//${window.location.host}/adapter/echarts/tab.html#${t.join("&")}`,"echarts")}async onStepChanged(t){const e=await this.props.socket.getObject(this.props.obj._id);e.common.custom&&e.common.custom[this.state.historyInstance]&&e.common.custom[this.state.historyInstance].chartStep!==t&&(e.common.custom[this.state.historyInstance].chartStep=t,await this.props.socket.setObject(e._id,e)),this.setState({stepType:t,showStepMenu:null})}renderToolbar(){return this.props.noToolbar?null:y.jsxs(w.Toolbar,{children:[!this.props.historyInstance&&y.jsxs(w.FormControl,{variant:"standard",style:Et.selectHistoryControl,children:[y.jsx(w.InputLabel,{children:this.props.t("History instance")}),y.jsx(w.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=>y.jsx(w.MenuItem,{value:t.id,style:t.alive?void 0:Et.notAliveInstance,children:t.id},t.id))})]}),y.jsxs(w.FormControl,{variant:"standard",style:Et.selectRelativeTime,children:[y.jsx(w.InputLabel,{children:this.props.t("Relative")}),y.jsxs(w.Select,{variant:"standard",ref:this.rangeRef,value:this.state.relativeRange,onChange:t=>this.setRelativeInterval(t.target.value),children:[y.jsx(w.MenuItem,{value:"absolute",sx:Et.customRange,children:this.props.t("custom range")},"custom"),y.jsx(w.MenuItem,{value:10,children:this.props.t("last 10 minutes")},"1"),y.jsx(w.MenuItem,{value:30,children:this.props.t("last 30 minutes")},"2"),y.jsx(w.MenuItem,{value:60,children:this.props.t("last hour")},"3"),y.jsx(w.MenuItem,{value:"day",children:this.props.t("this day")},"4"),y.jsx(w.MenuItem,{value:24*60,children:this.props.t("last 24 hours")},"5"),y.jsx(w.MenuItem,{value:"week",children:this.props.t("this week")},"6"),y.jsx(w.MenuItem,{value:24*60*7,children:this.props.t("last week")},"7"),y.jsx(w.MenuItem,{value:"2weeks",children:this.props.t("this 2 weeks")},"8"),y.jsx(w.MenuItem,{value:24*60*14,children:this.props.t("last 2 weeks")},"9"),y.jsx(w.MenuItem,{value:"month",children:this.props.t("this month")},"10"),y.jsx(w.MenuItem,{value:30*24*60,children:this.props.t("last 30 days")},"11"),y.jsx(w.MenuItem,{value:"year",children:this.props.t("this year")},"12"),y.jsx(w.MenuItem,{value:"12months",children:this.props.t("last 12 months")},"13")]})]}),y.jsxs(qt.LocalizationProvider,{dateAdapter:ks,adapterLocale:Os[this.props.lang],children:[y.jsxs("div",{style:Et.toolbarTimeGrid,children:[y.jsx("div",{style:{...Et.toolbarTimeLabel,opacity:this.state.relativeRange!=="absolute"?.5:void 0},children:this.props.t("Start time")}),y.jsx(qt.DatePicker,{sx:Et.toolbarDate,disabled:this.state.relativeRange!=="absolute",value:new Date(this.state.min),onChange:t=>this.setStartDate(t)}),y.jsx(qt.TimePicker,{disabled:this.state.relativeRange!=="absolute",sx:Et.toolbarTime,ampm:this.state.ampm,value:new Date(this.state.min),onChange:t=>this.setStartDate(t)})]}),y.jsxs("div",{style:Et.toolbarTimeGrid,children:[y.jsx("div",{style:{...Et.toolbarTimeLabel,opacity:this.state.relativeRange!=="absolute"?.5:void 0},children:this.props.t("End time")}),y.jsx(qt.DatePicker,{disabled:this.state.relativeRange!=="absolute",sx:Et.toolbarDate,value:new Date(this.state.max),onChange:t=>this.setEndDate(t)}),y.jsx(qt.TimePicker,{disabled:this.state.relativeRange!=="absolute",sx:Et.toolbarTime,ampm:this.state.ampm,value:new Date(this.state.max),onChange:t=>this.setEndDate(t)})]})]}),y.jsx("div",{style:Et.grow}),y.jsx(w.Button,{style:{marginRight:10},variant:"outlined",onClick:t=>this.setState({showStepMenu:t.target}),children:this.state.stepType?this.props.t(this.state.stepType):this.props.t("Step type")}),this.state.showStepMenu?y.jsxs(w.Menu,{open:!0,anchorEl:this.state.showStepMenu,onClose:()=>this.setState({showStepMenu:null}),children:[y.jsx(w.MenuItem,{selected:this.state.stepType==="",onClick:()=>this.onStepChanged(""),children:this.props.t("None")}),y.jsx(w.MenuItem,{selected:this.state.stepType==="stepStart",onClick:()=>this.onStepChanged("stepStart"),children:this.props.t("stepStart")})]}):null,this.props.showJumpToEchart&&this.state.echartsJump&&y.jsx(w.Fab,{style:Et.echartsButton,size:"small",onClick:()=>this.openEcharts(),title:this.props.t("Open charts in new window"),children:y.jsx("img",{src:bO,alt:"echarts",style:Et.buttonIcon})}),y.jsxs(w.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:[y.jsx(nw,{style:Et.splitLineButtonIcon}),this.props.t("Show lines")]})]})}render(){return!this.state.historyInstances&&!this.state.defaultHistory?y.jsx(w.LinearProgress,{}):y.jsxs(w.Paper,{style:Et.paper,children:[this.renderToolbar(),y.jsx("div",{ref:this.divRef,style:jt.getStyle(this.props.theme,Et.chart,this.props.noToolbar?Et.chartWithoutToolbar:Et.chartWithToolbar),children:this.renderChart()})]})}}const Wx=Wn()(xO),rr={dialog:{height:"100%"},paper:{height:"calc(100% - 64px)"},content:{textAlign:"center",overflow:"hidden"},tabPanel:r=>({width:"100%",overflow:"hidden",height:`calc(100% - ${r.mixins.toolbar.minHeight}px)`}),tabSelected:r=>({color:r.palette.mode==="dark"?r.palette.secondary.contrastText:"#FFFFFF !important"}),tabsIndicator:r=>({backgroundColor:r.palette.secondary.main})};class wO extends Cd{chartAvailable;saveFunc=null;constructor(t){super(t);let e=parseInt((window._localStorage||window.localStorage).getItem("App.objectCustomTab")||"0",10);if(this.chartAvailable=this.isChartAvailable(),this.chartAvailable){const i=yh.getLocation();i.arg==="chart"?e=2:i.arg==="table"&&(e=1)}else e=0;this.state={hasChanges:!1,currentTab:e,confirmDialog:!1,mobile:Cd.isMobile(),progressRunning:!1,showWarning:this.props.allVisibleObjects}}isChartAvailable(){var e,i;let t=this.props.objectIDs.length===1;if(t){const n=this.props.objectIDs[0];(i=(e=this.props.objects[n])==null?void 0:e.common)!=null&&i.custom?t=!!Object.keys(this.props.objects[n].common.custom).find(a=>{const o=this.props.objects[`system.adapter.${a}`];return o&&o.common&&o.common.getHistory}):t=!1}return t}renderCharts(){return y.jsx(Wx,{id:"custom-tabpanel-chart",isFloatComma:this.props.isFloatComma,showJumpToEchart:!0,t:this.props.t,lang:this.props.lang,expertMode:this.props.expertMode,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 y.jsx(dw,{id:"custom-tabpanel-history",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,themeName:this.props.themeName,objects:this.props.objects})}renderCustomEditor(){return y.jsx(lw,{id:"custom-tabpanel-settings",registerSaveFunc:t=>this.saveFunc=t,t:this.props.t,allVisibleObjects:this.props.allVisibleObjects,lang:this.props.lang,expertMode:this.props.expertMode,socket:this.props.socket,objectIDs:this.props.objectIDs,customsInstances:this.props.customsInstances,objects:this.props.objects,onProgress:t=>this.setState({progressRunning:t}),reportChangedIds:this.props.reportChangedIds,onChange:(t,e)=>{this.setState({hasChanges:t},()=>{if(e){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?y.jsx(mh,{title:G.t("You have unsaved changes"),text:G.t("Discard?"),ok:G.t("Yes"),cancel:G.t("Cancel"),onClose:t=>this.setState({confirmDialog:!1},()=>t&&this.props.onClose())}):null}onClose(){this.state.hasChanges?this.setState({confirmDialog:!0}):this.props.onClose()}renderWarningDialog(){return this.state.showWarning?y.jsx(mh,{text:y.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:t=>{this.setState({showWarning:!1}),t||this.onClose()}}):null}render(){var e,i;const t=(i=(e=this.props.objects[this.props.objectIDs[0]])==null?void 0:e.common)==null?void 0:i.type;return y.jsxs(w.Dialog,{sx:{"&.MuiDialog-scrollPaper":rr.dialog,"& .MuiDialog-paper":rr.paper},scroll:"paper",open:!0,onClose:()=>this.props.onClose(),fullWidth:!0,maxWidth:"xl","aria-labelledby":"form-dialog-title",children:[this.renderDialogConfirm(),this.renderWarningDialog(),y.jsx(w.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])}),y.jsxs(w.DialogContent,{style:rr.content,children:[y.jsx(w.AppBar,{position:"static",children:y.jsxs(w.Tabs,{value:this.state.currentTab,onChange:(n,a)=>{yh.doNavigate(null,null,null,a===1?"table":a===2?"chart":"config"),this.setState({currentTab:a}),(window._localStorage||window.localStorage).setItem("App.objectCustomTab",a)},sx:{"& .MuiTabs-indicator":rr.tabsIndicator},indicatorColor:"secondary",children:[y.jsx(w.Tab,{disabled:this.state.progressRunning,label:this.props.t("Custom settings"),id:"custom-settings-tab","aria-controls":"custom-tabpanel-settings",sx:{"&.Mui-selected":rr.tabSelected}}),this.props.objectIDs.length===1&&this.chartAvailable?y.jsx(w.Tab,{disabled:this.state.progressRunning,label:this.props.t("History data"),id:"history-data-tab","aria-controls":"custom-tabpanel-history",sx:{"&.Mui-selected":rr.tabSelected}}):null,(t==="number"||t==="boolean")&&this.props.objectIDs.length===1&&this.chartAvailable?y.jsx(w.Tab,{disabled:this.state.progressRunning,label:this.props.t("Chart"),id:"chart-tab","aria-controls":"custom-tabpanel-chart",sx:{"&.Mui-selected":rr.tabSelected}}):null]})}),this.state.currentTab===0?y.jsx(w.Box,{component:"div",sx:rr.tabPanel,children:this.renderCustomEditor()}):null,this.props.objectIDs.length===1&&this.chartAvailable&&this.state.currentTab===1?y.jsx(w.Box,{component:"div",sx:rr.tabPanel,children:this.renderTable()}):null,(t==="number"||t==="boolean")&&this.props.objectIDs.length===1&&this.chartAvailable&&this.state.currentTab===2?y.jsx(w.Box,{component:"div",sx:rr.tabPanel,children:this.renderCharts()}):null]}),y.jsxs(w.DialogActions,{children:[this.state.currentTab===0&&y.jsx(w.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(y.jsx(X.Save,{}),this.props.t("Save"))}),this.state.currentTab===0&&y.jsx(w.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(y.jsx(X.Save,{}),this.props.t("Save & close"),y.jsx(X.Close,{}))}),y.jsx(w.Button,{id:"object-custom-dialog-close",disabled:this.state.progressRunning,variant:"contained",onClick:()=>this.onClose(),color:"grey",children:this.getButtonTitle(y.jsx(X.Close,{}),this.props.t("Close"))})]})]})}}const ve={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 Dn extends at.Component{propsValue;chartFrom;ack;inputRef=vh.createRef();q;expire;constructor(t){super(t);let e=this.props.type;e||(e=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)e="states";else if(e==="string"||e==="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,e="json"}catch{}}else e==="number"&&(i=parseFloat(this.propsValue)||0);this.state={type:e,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=vh.createRef(),this.chartFrom=Date.now()-36e5*2}componentDidMount(){var t,e,i;this.props.defaultHistory&&((e=(t=this.props.object)==null?void 0:t.common)!=null&&e.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 a=this.inputRef.current,o=a.value||"",s=a.type;a.type==="number"&&(a.type="text"),a.setSelectionRange(0,o.length),s==="number"&&(a.type=s)}},200)}onUpdate(t){t&&(t.stopPropagation(),t.preventDefault());let e=this.state.targetValue;if(this.state.type==="states")if(e==="null")e=null;else{const i=this.props.type||typeof this.state.targetValue;e=typeof e=="object"?e.value:e,i==="number"?typeof e=="string"&&(e=parseFloat(e.replace(",","."))||0):i==="boolean"&&(e=e===!0||e==="true"||e==="1"||e==="ON"||e==="on")}else this.state.type==="number"?e==="null"?e=null:typeof e=="string"&&(e=parseFloat(e.replace(",","."))||0):this.state.type==="boolean"&&(e==="null"?e=null:e=e===!0||e==="true"||e==="1"||e==="ON"||e==="on");this.props.onClose({val:e,ack:this.ack,q:this.q,expire:parseInt(this.expire,10)||void 0})}static isNumberValid(t){const{common:e,value:i}=t;if(i==="")return!1;const n=Number(i);return typeof e.min=="number"&&n<e.min?!1:!(typeof e.max=="number"&&n>e.max)}renderTimePicker(){return y.jsxs(qt.LocalizationProvider,{adapterLocale:Os[this.props.lang],dateAdapter:ks,children:[y.jsx(qt.DatePicker,{value:Number(this.state.targetValue),onChange:t=>{t&&this.setState({targetValue:Math.round(t.getTime())})}}),y.jsx(qt.TimePicker,{value:Number(this.state.targetValue),views:["hours","minutes","seconds"],onChange:t=>{t&&this.setState({targetValue:Math.round(t.getTime())})}})]})}renderChart(){return y.jsx(Wx,{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,dateFormat:this.props.dateFormat,defaultHistory:this.props.defaultHistory})}static checkJsonError(t){try{return JSON.parse(t),!1}catch{return!0}}renderJsonEditor(){return y.jsx(ty,{error:this.state.jsonError,editValueMode:!0,themeType:this.props.themeType,defaultValue:(this.propsValue||"").toString(),onChange:t=>this.setState({targetValue:t,jsonError:Dn.checkJsonError(t)})})}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 t=Object.keys(this.props.states).map(e=>({label:this.props.states[e],value:e}));return y.jsx(w.Autocomplete,{style:ve.formControl,disablePortal:!0,defaultValue:this.props.states[this.propsValue]!==void 0?this.props.states[this.propsValue]:this.propsValue,options:t,noOptionsText:"",freeSolo:!0,getOptionLabel:e=>(e==null?void 0:e.label)||(e!=null?e.toString():""),onChange:(e,i)=>this.setState({targetValue:i}),onInputChange:(e,i)=>this.setState({targetValue:i}),onKeyUp:e=>e.key==="Enter"&&this.onUpdate(e),renderInput:e=>y.jsx(w.TextField,{...e,label:this.props.t("Value"),variant:"standard"})})}return y.jsxs(w.FormControl,{variant:"standard",style:ve.formControl,children:[y.jsx(w.InputLabel,{children:this.props.t("Value")}),y.jsx(w.Select,{variant:"standard",defaultValue:this.propsValue,onChange:t=>this.setState({targetValue:t.target.value}),children:Object.keys(this.props.states).map((t,e)=>y.jsx(w.MenuItem,{value:t,children:this.props.states[t]},e))})]})}render(){var e,i,n;const t=y.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[y.jsx(w.FormControlLabel,{style:{...ve.formControl,...this.props.expertMode?void 0:ve.ackCheckbox},control:y.jsx(w.Checkbox,{defaultChecked:!1,onChange:a=>this.ack=a.target.checked}),label:this.props.t("Acknowledged")}),y.jsx(w.Tooltip,{title:this.props.t("Acknowledged explanation"),slotProps:{popper:{sx:ve.tooltip}},children:y.jsx(X.Info,{color:"primary"})})]});return y.jsxs(w.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"?ve.dialog:void 0},children:[y.jsxs(w.DialogTitle,{id:"edit-value-dialog-title",children:[this.props.t("Write value"),((e=this.props.object.common)==null?void 0:e.write)===!1?y.jsxs("span",{style:ve.readOnlyText,children:["(",this.props.t("read only"),")"]}):null,this.state.chart?y.jsx(w.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:y.jsx(X.ShowChart,{})}):null,this.state.type==="json"?y.jsx(w.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?y.jsx(X.FullscreenExit,{}):y.jsx(X.Fullscreen,{})}):null]}),y.jsx(w.DialogContent,{children:y.jsx("form",{noValidate:!0,autoComplete:"off",onSubmit:()=>!1,style:{...ve.dialogForm,height:"100%"},children:y.jsxs(w.Grid2,{container:!0,direction:"row",spacing:2,style:{height:"100%"},children:[y.jsx(w.Grid2,{size:{xs:this.state.chart&&this.state.chartEnabled?6:12},style:{height:"100%"},children:y.jsxs(w.Grid2,{container:!0,direction:"column",spacing:2,style:{marginTop:0,height:"100%"},children:[this.props.expertMode?y.jsx(w.Grid2,{children:y.jsxs(w.Grid2,{container:!0,direction:"row",spacing:2,style:{marginTop:0},children:[this.props.expertMode?y.jsx(w.Grid2,{children:y.jsxs(w.FormControl,{style:ve.formControl,children:[y.jsx(w.InputLabel,{style:{marginTop:10,marginLeft:-14},children:this.props.t("Value type")}),y.jsxs(w.Select,{variant:"standard",value:this.state.type,onChange:a=>{this.setState({type:a.target.value,valid:a.target.value==="number"?Dn.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:Dn.checkJsonError((this.state.targetValue||"").toString())})})},children:[y.jsx(w.MenuItem,{value:"string",children:"String"}),y.jsx(w.MenuItem,{value:"number",children:"Number"}),y.jsx(w.MenuItem,{value:"boolean",children:"Boolean"}),y.jsx(w.MenuItem,{value:"json",children:"JSON"}),this.props.states?y.jsx(w.MenuItem,{value:"states",children:"States"}):null]})]})}):null,this.state.type==="json"?y.jsx(w.Grid2,{flex:1}):null]})}):null,y.jsx(w.Grid2,{flex:this.state.type==="json"&&this.state.fullScreen?1:void 0,style:{paddingTop:0},children:this.state.type==="boolean"?y.jsx(w.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:y.jsxs(w.Grid2,{component:"label",container:!0,alignItems:"center",spacing:1,children:[y.jsxs(w.Grid2,{style:{marginRight:10},children:[this.props.t("Value"),":"]}),y.jsx(w.Grid2,{children:"FALSE"}),y.jsx(w.Grid2,{children:y.jsx(w.Switch,{autoFocus:!0,defaultChecked:this.propsValue==="null"||this.propsValue==="undefined"?!1:!!this.propsValue,onKeyUp:a=>a.key==="Enter"&&this.onUpdate(a),onChange:a=>this.setState({targetValue:a.target.checked})})}),y.jsx(w.Grid2,{children:"TRUE"})]})}):this.state.type==="number"?y.jsx(w.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:a=>a.key==="Enter"&&this.state.valid&&this.onUpdate(a),onChange:a=>{this.setState({targetValue:a.target.value,valid:Dn.isNumberValid({value:a.target.value,common:this.props.object.common})})}}):this.state.type==="json"?this.renderJsonEditor():this.state.type==="states"?this.renderStates():y.jsx(w.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:a=>a.ctrlKey&&a.key==="Enter"&&this.onUpdate(a),defaultValue:this.propsValue.toString(),onChange:a=>this.setState({targetValue:a.target.value})})}),(this.props.role==="date"||(i=this.props.role)!=null&&i.startsWith("date."))&&this.state.type==="number"?y.jsx(w.Grid2,{style:{display:"flex",gap:"5px"},size:{xs:6},children:this.renderTimePicker()}):null,this.props.expertMode?y.jsx(w.Grid2,{children:t}):null,this.props.expertMode?y.jsxs(w.Grid2,{children:[y.jsxs(w.FormControl,{variant:"standard",style:ve.quality,children:[y.jsx(w.InputLabel,{children:this.props.t("Quality")}),y.jsxs(w.Select,{variant:"standard",defaultValue:0,onChange:a=>this.q=Number(a.target.value),children:[y.jsx(w.MenuItem,{value:0,children:"0x00 - good"}),y.jsx(w.MenuItem,{value:1,children:"0x01 - general problem"}),y.jsx(w.MenuItem,{value:2,children:"0x02 - no connection problem"}),y.jsx(w.MenuItem,{value:16,children:"0x10 - substitute value from controller"}),y.jsx(w.MenuItem,{value:32,children:"0x20 - substitute initial value"}),y.jsx(w.MenuItem,{value:64,children:"0x40 - substitute value from device or instance"}),y.jsx(w.MenuItem,{value:128,children:"0x80 - substitute value from sensor"}),y.jsx(w.MenuItem,{value:17,children:"0x11 - general problem by instance"}),y.jsx(w.MenuItem,{value:65,children:"0x41 - general problem by device"}),y.jsx(w.MenuItem,{value:129,children:"0x81 - general problem by sensor"}),y.jsx(w.MenuItem,{value:18,children:"0x12 - instance not connected"}),y.jsx(w.MenuItem,{value:66,children:"0x42 - device not connected"}),y.jsx(w.MenuItem,{value:130,children:"0x82 - sensor not connected"}),y.jsx(w.MenuItem,{value:68,children:"0x44 - device reports error"}),y.jsx(w.MenuItem,{value:132,children:"0x84 - sensor reports error"})]})]}),y.jsx(w.TextField,{variant:"standard",title:this.props.t("0 - no expiration"),sx:{"&.MuiTextField-root":ve.expire},label:this.props.t("Expire"),type:"number",slotProps:{htmlInput:{min:0}},helperText:this.props.t("in seconds"),defaultValue:this.expire,onChange:a=>this.expire=Number(a.target.value)})]}):null]})}),this.state.chart&&this.state.chartEnabled&&this.state.type!=="json"?y.jsx(w.Grid2,{size:{xs:6},style:{minHeight:300},sx:{display:{sm:"none",md:"inline-block"}},children:this.renderChart()}):null]})})}),y.jsxs(w.DialogActions,{sx:ve.wrapperButton,children:[this.props.expertMode?null:t,this.props.expertMode?null:y.jsx("div",{style:{flexGrow:1}}),y.jsx(w.Button,{variant:"contained",disabled:!this.state.valid,onClick:a=>this.onUpdate(a),color:"primary",startIcon:this.props.width!=="xs"?y.jsx(X.Check,{}):void 0,style:((n=this.props.object.common)==null?void 0:n.write)===!1?ve.readOnly:void 0,children:this.props.width!=="xs"?this.props.t("Set value"):y.jsx(X.Check,{fontSize:"large"})}),y.jsx(w.Button,{variant:"contained",onClick:()=>this.props.onClose(),color:"grey",startIcon:this.props.width!=="xs"?y.jsx(X.Close,{}):void 0,children:this.props.width!=="xs"?this.props.t("Cancel"):y.jsx(X.Close,{fontSize:"large"})})]})]})}}const O={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,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 SO(r,t){return{"@keyframes newStateEditorAnimation":{"0%":{color:r.palette.mode==="dark"?"#27cf00":"#174e00"},"100%":{color:t||(r.palette.mode==="dark"?"#ffffff":"#000000")}}}}const yo=[{role:"button",type:"boolean",r:!1,w:!0},{role:"button.close.blind",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.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.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:"string"},{role:"date",type:"number"},{role:"date.end",type:"string"},{role:"date.end",type:"number"},{role:"date.forecast.1",type:"string"},{role:"date.start",type:"string"},{role:"date.start",type:"number"},{role:"date.sunrise",type:"string"},{role:"date.sunrise",type:"number"},{role:"date.sunset",type:"string"},{role:"date.sunset",type:"number"},{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.name",type:"string",w:!1},{role:"info.port",type:"string",w:!1},{role:"info.port",type:"number",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.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.saturation",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:"string"},{role:"list",type:"array"},{role:"location",type:"string"},{role:"media.add",type:"string"},{role:"media.bitrate",type:"string"},{role:"media.bitrate",type:"number"},{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.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:"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.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:"url",type:"string"},{role:"url.audio",type:"string"},{role:"url.blank",type:"string"},{role:"url.cam",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.clouds",type:"number",w:!1},{role:"value.current",type:"number",w:!1},{role:"value.curtain",type:"number",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.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.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.prepitation.forecast.0",type:"number",w:!1},{role:"value.prepitation.forecast.1",type:"number",w:!1},{role:"value.prepitation.forecast.1",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:"waether.title",type:"string",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.state.forecast.1",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 Ht extends at.Component{originalObj;subscribed=!1;updateTimer=null;constructor(t){super(t);const e=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";i==="alias"&&!e&&(i="common"),this.props.aliasTab&&e&&(i="alias");const n=this.props.obj,a=n.common&&"type"in n.common&&"alias"in n.common?n.common.alias.read:void 0,o=n.common&&"type"in n.common&&"alias"in n.common?n.common.alias.write:void 0;this.state={text:JSON.stringify(this.props.obj,null,2),error:!1,customError:!1,changed:!1,readError:this.checkFunction(a,!1),writeError:this.checkFunction(o,!0),tab:i,showCopyDialog:"",showCommonDeleteMessage:!1,selectId:!1,selectRead:!1,selectWrite:!1,newId:"",lang:G.getLanguage(),value:void 0},Ul.locale(this.state.lang),this.originalObj=JSON.stringify(this.props.obj,null,2)}async componentDidMount(){var i,n,a;const t=((n=(i=this.props.obj)==null?void 0:i.common)==null?void 0:n.editSchemas)||((a=this.props.obj)==null?void 0:a.editSchemas),e=[];if(t)if(typeof t=="object"){const o=Object.keys(t);for(let s=0;s<o.length;s++)try{const l=await Td(t[o[s]],this.props.socket);if(l.key=o[s],l&&typeof l=="object"&&e.push(l),l.icon)try{const u=Zx(l.icon);if(u.type!=="base64"&&u.type!=="http"){const h=await Td(u,this.props.socket);h&&(l.icon=h)}}catch(u){console.warn(`Cannot get icon for schema from "${l.icon}": ${u}`),l.icon=void 0}}catch(l){console.warn(`Cannot get edit schema for "${t[o[s]]}": ${l}`)}e.length&&(e.sort((s,l)=>s.order!==void 0&&l.order!==void 0?s.order-l.order:s.order!==void 0?-1:l.order!==void 0||s.key>l.key?1:-1),this.setState({customEditTabs:e}))}else console.warn(`Invalid edit schema for "${t}": expected object, but got ${typeof t}`);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"&&!e.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)}componentWillUnmount(){this.updateTimer&&(clearInterval(this.updateTimer),this.updateTimer=null),this.subscribeOnState(!1),this.props.socket.unsubscribeObject(this.props.obj._id,this.onObjectUpdated)}onObjectUpdated=(t,e)=>{this.originalObj!==JSON.stringify(e,null,2)&&(this.originalObj=JSON.stringify(e,null,2),this.state.changed?this.forceUpdate():this.setState({text:this.originalObj}))};checkFunction(t,e){var a,o,s,l;if(!t||t.includes("JSON.parse("))return"";let i;try{i=JSON.parse(this.state.text)}catch{}let n;try{n=new Function("val",t.includes("return")?t:`return ${t}`)}catch{return this.props.t("Cannot parse code!")}if((a=i==null?void 0:i.common)!=null&&a.type&&((l=(s=this.props.objects[(o=i.common.alias)==null?void 0:o.id])==null?void 0:s.common)!=null&&l.type)){const u=e?i.common.type:this.props.objects[i.common.alias.id].common.type,h=e?this.props.objects[i.common.alias.id].common.type:i.common.type;if(u&&h){let c=null;if(u==="boolean"?c=!0:u==="number"?c=1:(u==="string"||u==="mixed")&&(c="string"),c!==null)try{const f=n(c);return h==="mixed"?"":f!==null&&typeof f!==h?this.props.t("Type of result is not as expected: %s",h):""}catch(f){return`${this.props.t("Cannot execute function")}: ${f.toString()}`}}}return""}prepareObject(t){var e,i,n,a;t=t||this.state.text;try{const o=JSON.parse(t);return o._id=this.props.obj._id,(e=o.common)!=null&&e.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)),((a=o.common)==null?void 0:a.step)!==void 0&&typeof o.common.step!="number"&&(o.common.step=parseFloat(o.common.step)),o}catch{return null}}onChange(t,e){var a,o,s,l;const i=this.prepareObject(t),n={text:t};if(i){n.changed=this.originalObj!==JSON.stringify(i,null,2),n.showCommonDeleteMessage=!1;const u=JSON.parse(this.originalObj);i.common&&Object.keys(u.common||{}).forEach(h=>{i.common[h]===void 0&&(n.showCommonDeleteMessage=!0)}),n.error=!1,n.readError=this.checkFunction((o=(a=i.common)==null?void 0:a.alias)==null?void 0:o.read,!1),n.writeError=this.checkFunction((l=(s=i.common)==null?void 0:s.alias)==null?void 0:l.write,!0)}else n.showCommonDeleteMessage=!1,n.error=!0;this.setState(n,()=>e&&e())}onUpdate(){var t,e,i,n;try{const a=JSON.parse(this.state.text);a._id=this.props.obj._id,(t=a.common)!=null&&t.alias&&(a.common.alias.id||delete a.common.alias.id,(!a.common.alias.read&&a.common.alias.read!==void 0||a.common.alias.read==="val")&&delete a.common.alias.read,(!a.common.alias.write&&a.common.alias.write!==void 0||a.common.alias.write==="val")&&delete a.common.alias.write,!a.common.alias.id&&!a.common.alias.read&&!a.common.alias.write&&delete a.common.alias),((e=a.common)==null?void 0:e.min)!==void 0&&typeof a.common.min!="number"&&(a.common.min=parseFloat(a.common.min)),((i=a.common)==null?void 0:i.max)!==void 0&&typeof a.common.max!="number"&&(a.common.max=parseFloat(a.common.max)),((n=a.common)==null?void 0:n.step)!==void 0&&typeof a.common.step!="number"&&(a.common.step=parseFloat(a.common.step)),this.props.onClose(a)}catch{console.error(`Cannot parse: ${this.state.text}`)}}static getPartOfObject(t,e){return e?Ad(JSON.parse(t),e.split(".")):JSON.parse(t)}static setPartOfObject(t,e,i){let n=JSON.parse(t);return n===void 0?t:(n=Kx(n,i.split("."),e),JSON.stringify(n,null,2))}renderCustomPanel(){var i;const t=(i=this.state.customEditTabs)==null?void 0:i.find(n=>n.key===this.state.tab);if(!t)return null;let e;try{e=Ht.getPartOfObject(this.state.text,t.path)}catch(n){return console.error(`Cannot get data for ${t.path}: ${n}`),y.jsx("div",{children:G.t("Cannot get data for %s: %s",t.path,n)})}return e?y.jsx(gh,{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:t.json,data:e,onChange:n=>{try{const a=Ht.setPartOfObject(this.state.text,n,t.path);this.onChange(a)}catch(a){console.error(`Cannot set data for ${t.path}: ${a}`)}},adapterName:"",instance:0,onError:n=>{console.warn(`Error in JSON editor: ${n}`),this.state.customError!==n&&this.setState({customError:n})}}):y.jsx("div",{children:G.t("Cannot get data for %s",t.path)})}renderCustomTab(t,e){var a;let i;if(!e||!Ad(e,(a=t.path)==null?void 0:a.split(".")))return null;t.color&&(i={backgroundColor:t.color,color:jt.invertColor(t.color,!0)});const n=t.label&&typeof t.label=="object"?t.label[this.state.lang]||t.label.en:t.noTranslation?t.label||t.key:this.props.t(t.label||t.key);return y.jsx(w.Tab,{disabled:this.state.error||this.state.customError,value:t.key,label:n,style:i,iconPosition:"start",icon:t.icon?y.jsx(Ca,{src:t.icon,style:O.funcIcon}):void 0})}renderStateTab(){return this.props.obj.type!=="state"||this.props.obj.common.type==="file"?null:y.jsx(w.Tab,{disabled:this.state.customError||this.state.error,value:"state",label:this.props.t("State")})}renderStatePanel(){var a;if(this.state.value===void 0||this.state.value===null)return y.jsx("div",{children:this.props.t("State does not exist")});if(typeof this.state.value!="object")return y.jsxs("div",{style:{maxWidth:700},children:[y.jsx("div",{children:this.props.t("State is invalid")}),y.jsx("div",{children:y.jsx("pre",{children:JSON.stringify(this.state.value,null,4)})})]});let t;const e={},i=this.state.value.val,n=typeof i;if(i===void 0)t="[undef]",e.color="#bc6400",e.fontStyle="italic";else if(i===null)t="(null)",e.color="#0047b1",e.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(jt.isStringInteger(i))t=new Date(parseInt(i,10)).toString();else try{const o=new Date(i);jt.isValidDate(o)&&(t=o.toString())}catch{}else i&&n==="number"&&(i>946681200&&i<9466812e5?t=new Date(i*1e3).toString():i>9466812e8&&(t=new Date(i).toString()));return t||(n==="number"?Number.isInteger(i)||(t=(Math.round(i*1e9)/1e9).toString(),this.props.isFloatComma&&(t=t.toString().replace(".",","))):n==="boolean"?(t=i?G.t("true"):G.t("false"),e.color=i?"#139800":"#cd6b55"):n==="object"?t=JSON.stringify(i):n==="string"&&i.startsWith("data:image/")?t=y.jsx("img",{src:i,alt:"img",style:O.stateImage}):t=i.toString()),Object.assign(e,SO(this.props.theme,e.color)),y.jsxs(w.Box,{style:{...O.divWithoutTitle,padding:"24px 24px 0 24px",fontSize:16,maxWidth:400},sx:{"& .value-line:hover":{backgroundColor:"#00000030"}},children:[y.jsxs("div",{className:"value-line",style:{...O.stateRow,marginBottom:24},children:[y.jsxs("div",{style:O.stateTitle,children:[G.t("ra_tooltip_value"),":"]}),y.jsxs(w.Box,{component:"div",sx:e,style:O.stateValue,children:[t,(a=this.props.obj.common)!=null&&a.unit?y.jsx("span",{style:O.stateUnit,children:this.props.obj.common.unit}):null]},typeof t=="string"?t:"image")]}),y.jsxs("div",{style:O.stateRow,className:"value-line",children:[y.jsxs("div",{style:O.stateTitle,children:[G.t("Type"),":"]}),y.jsx("div",{style:O.stateValue,children:n})]}),y.jsxs("div",{style:O.stateRow,className:"value-line",children:[y.jsxs("div",{style:O.stateTitle,children:[G.t("ra_tooltip_ts"),":"]}),y.jsx(w.Tooltip,{title:new Date(this.state.value.ts).toLocaleString(),slotProps:{popper:{sx:O.tooltip}},children:y.jsx("div",{style:O.stateValue,children:y.jsx("span",{style:O.stateTime,children:Ul(this.state.value.ts).fromNow()})})})]}),y.jsxs("div",{style:O.stateRow,className:"value-line",children:[y.jsxs("div",{style:O.stateTitle,children:[G.t("ra_tooltip_ack"),":"]}),y.jsxs("div",{style:{...O.stateValue,color:this.state.value.ack?"green":"red"},children:[this.state.value.ack?G.t("Acknowledged"):G.t("Command"),this.state.value.ack?" (true)":" (false)"]})]}),y.jsxs("div",{style:O.stateRow,className:"value-line",children:[y.jsxs("div",{style:O.stateTitle,children:[G.t("ra_tooltip_lc"),":"]}),y.jsx(w.Tooltip,{title:new Date(this.state.value.lc).toLocaleString(),slotProps:{popper:{sx:O.tooltip}},children:y.jsx("div",{style:O.stateValue,children:y.jsx("span",{style:O.stateTime,children:Ul(this.state.value.lc).fromNow()})})})]}),y.jsxs("div",{style:O.stateRow,className:"value-line",children:[y.jsxs("div",{style:O.stateTitle,children:[G.t("ra_tooltip_quality"),":"]}),y.jsx("div",{style:O.stateValue,children:jt.quality2text(this.state.value.q||0).join(", ")})]}),y.jsxs("div",{style:O.stateRow,className:"value-line",children:[y.jsxs("div",{style:O.stateTitle,children:[G.t("ra_tooltip_from"),":"]}),y.jsx("div",{style:O.stateValue,children:this.state.value.from})]}),y.jsxs("div",{style:O.stateRow,className:"value-line",children:[y.jsxs("div",{style:O.stateTitle,children:[G.t("ra_tooltip_user"),":"]}),y.jsx("div",{style:O.stateValue,children:this.state.value.user||"--"})]}),this.state.value.expire?y.jsxs("div",{style:O.stateRow,className:"value-line",children:[y.jsxs("div",{style:O.stateTitle,children:[G.t("ra_tooltip_expire"),":"]}),y.jsxs("div",{style:O.stateValue,children:[this.state.value.expire," ",G.t("sc_seconds")]})]}):null,this.state.value.c?y.jsxs("div",{style:O.stateRow,className:"value-line",children:[y.jsxs("div",{style:O.stateTitle,children:[G.t("ra_tooltip_comment"),":"]}),y.jsx("div",{style:O.stateValue,children:this.state.value.c})]}):null]})}onStateChange=(t,e)=>{JSON.stringify(e)!==JSON.stringify(this.state.value)&&this.setState({value:e})};subscribeOnState(t){t?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))}renderTabs(t){var e;return y.jsxs(w.Tabs,{style:O.tabsPadding,value:this.state.tab,onChange:(i,n)=>{var a,o,s;if((window._localStorage||window.localStorage).setItem(`${this.props.dialogName||"App"}.editTab`,n),n==="object"){try{const l=JSON.parse(this.state.text);let u=!1;((a=l.common)==null?void 0:a.min)!==void 0&&typeof l.common.min!="number"&&(l.common.min=parseFloat(l.common.min),u=!0),((o=l.common)==null?void 0:o.max)!==void 0&&typeof l.common.max!="number"&&(l.common.max=parseFloat(l.common.max),u=!0),((s=l.common)==null?void 0:s.step)!==void 0&&typeof l.common.step!="number"&&(l.common.step=parseFloat(l.common.step),u=!0),u&&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:[y.jsx(w.Tab,{value:"common",disabled:this.state.customError||this.state.error,label:this.props.t("common")}),y.jsx(w.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"&&y.jsx(w.Tab,{disabled:this.state.customError||this.state.error,value:"alias",label:this.props.t("Alias")}),(e=this.state.customEditTabs)==null?void 0:e.map(i=>this.renderCustomTab(i,t))]})}renderSelectDialog(){var i,n,a,o;if(!this.state.selectId&&!this.state.selectRead&&!this.state.selectWrite)return null;let t="",e;try{e=JSON.parse(this.state.text);const s=e.common&&"type"in e.common&&"alias"in e.common?(i=e.common.alias)==null?void 0:i.read:"",l=e.common&&"type"in e.common&&"alias"in e.common?(n=e.common.alias)==null?void 0:n.write:"";this.state.selectId?t=((o=(a=e.common)==null?void 0:a.alias)==null?void 0:o.id)||"":this.state.selectRead?t=s??"":this.state.selectWrite&&(t=l??"")}catch{console.error(`Cannot parse ${this.state.text}`)}return y.jsx(ey,{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:t,onOk:s=>{const l=this.state.selectRead,u=this.state.selectWrite,h=this.state.selectId,c=Array.isArray(s)?s[0]:s;this.setState({selectId:!1,selectRead:!1,selectWrite:!1},()=>{l?this.setAliasItem(e,"id.read",c):u?this.setAliasItem(e,"id.write",c):h&&this.setAliasItem(e,"id",c)})},onClose:()=>this.setState({selectId:!1,selectRead:!1,selectWrite:!1})},"selectDialog")}setAliasItem(t,e,i,n){t.common=t.common||{};const a=t.common.alias||{};e==="id.read"?a.id&&typeof a.id=="object"?a.id.read=i:a.id={read:i,write:i}:e==="id.write"?a.id&&typeof a.id=="object"?a.id.write=i:a.id={read:i,write:i}:a[e]=i,t.common.alias=a,this.onChange(JSON.stringify(t,null,2),n)}setCommonItem(t,e,i){t.common[e]=i,this.onChange(JSON.stringify(t,null,2))}removeCommonItem(t,e){delete t.common[e],this.onChange(JSON.stringify(t,null,2))}static buttonAddKey(t,e){return y.jsx("div",{style:O.marginBlock,children:y.jsx(w.Button,{style:O.buttonAdd,variant:"contained",color:"secondary",startIcon:y.jsx(X.Add,{}),onClick:e,children:G.t(t)})})}buttonRemoveKey(t,e){const{t:i}=this.props;return y.jsx(w.Tooltip,{title:i("Remove attribute %s",i(t)),slotProps:{popper:{sx:O.tooltip}},children:y.jsx(w.Box,{component:"div",sx:O.close,onClick:e})})}static filterRoles(t,e){const i=[];return t.forEach(n=>(n.type==="mixed"||n.type)===e&&!i.includes(n.role)&&i.push(n.role)),yo.forEach(n=>(n.type==="mixed"||n.type)===e&&!i.includes(n.role)&&i.push(n.role)),i.sort(),i}renderCommonEdit(){try{const t=JSON.parse(this.state.text),e=["number","string","boolean","array","object","mixed"],i=!1,{t:n,obj:a}=this.props,o=a.type==="state",s=a.type==="channel"||a.type==="device"||o,l=Ht.filterRoles(this.props.roleArray,t.common.type);let u;if(t.common.icon&&(u=t.type==="instance"||t.type==="adapter"?`./adapter/${t.common.name}/${t.common.icon}`:t.common.icon,!u.startsWith(".")&&!u.startsWith("/")&&!u.startsWith("data:"))){const f=a._id.split(".");f[0]==="system"?u=`adapter/${f[2]}${u.startsWith("/")?"":"/"}${u}`:u=`adapter/${f[0]}${u.startsWith("/")?"":"/"}${u}`}const h=typeof t.common.desc=="object"&&t.common.desc?t.common.desc[G.getLanguage()]||t.common.desc.en||"":t.common.desc||"",c=jt.getObjectNameFromObj(t,G.getLanguage(),{},!1,!0);return y.jsxs(w.Box,{style:O.commonTabWrapper,onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),f.stopPropagation(),this.onUpdate())},children:[y.jsxs(w.Box,{style:{...O.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 t.common.name<"u"?y.jsx(w.TextField,{variant:"standard",disabled:i,label:n("Name"),style:{...O.textField,marginTop:8},fullWidth:!0,slotProps:{input:{endAdornment:c?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>this.setCommonItem(t,"name",""),children:y.jsx(X.Close,{})})}):null}},value:c,onChange:f=>this.setCommonItem(t,"name",f.target.value)}):Ht.buttonAddKey("Name",()=>this.setCommonItem(t,"name","")),typeof t.common.desc<"u"?y.jsxs(w.Box,{component:"div",sx:O.flex,children:[y.jsx(w.TextField,{variant:"standard",disabled:i,label:n("Description"),style:{...O.textField,marginTop:8},fullWidth:!0,slotProps:{input:{endAdornment:h?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>this.setCommonItem(t,"desc",""),children:y.jsx(X.Close,{})})}):null}},value:h,onChange:f=>this.setCommonItem(t,"desc",f.target.value)}),this.buttonRemoveKey("Description",()=>this.removeCommonItem(t,"desc"))]}):Ht.buttonAddKey("Description",()=>this.setCommonItem(t,"desc","")),o?typeof t.common.type<"u"?y.jsxs(w.Box,{component:"div",sx:O.flex,children:[y.jsxs(w.FormControl,{style:O.marginBlock,fullWidth:!0,children:[y.jsx(w.InputLabel,{style:{transform:"scale(0.75)"},children:n("State type")}),y.jsx(w.Select,{variant:"standard",disabled:i,value:t.common.type,onChange:f=>this.setCommonItem(t,"type",f.target.value),children:e.map(f=>y.jsxs(w.MenuItem,{value:f,children:[n(f),y.jsxs("span",{style:O.typeNameEng,children:["(",f,")"]})]},f))})]}),this.buttonRemoveKey("State type",()=>this.removeCommonItem(t,"type"))]}):Ht.buttonAddKey("State type",()=>this.setCommonItem(t,"type","string")):null,y.jsxs(w.Box,{component:"div",sx:{...O.flex,flexWrap:this.props.width==="xs"?"wrap":void 0},children:[o?typeof t.common.read<"u"?y.jsxs(w.Box,{component:"div",sx:O.flex,children:[y.jsx(w.FormControlLabel,{style:O.marginBlock,control:y.jsx(w.Checkbox,{disabled:i,checked:t.common.read,onChange:f=>this.setCommonItem(t,"read",f.target.checked)}),label:n("Readable")}),this.buttonRemoveKey("Readable",()=>this.removeCommonItem(t,"read"))]}):Ht.buttonAddKey("Readable",()=>this.setCommonItem(t,"read",!0)):null,o?typeof t.common.write<"u"?y.jsxs(w.Box,{component:"div",sx:O.flex,children:[y.jsx(w.FormControlLabel,{style:O.marginBlock,control:y.jsx(w.Checkbox,{disabled:i,checked:t.common.write,onChange:f=>this.setCommonItem(t,"write",f.target.checked)}),label:n("Writeable")}),this.buttonRemoveKey("Writeable",()=>this.removeCommonItem(t,"write"))]}):Ht.buttonAddKey("Writeable",()=>this.setCommonItem(t,"write",!0)):null]}),s?typeof t.common.role<"u"?y.jsxs(w.Box,{component:"div",sx:O.flex,children:[y.jsx(w.Autocomplete,{style:O.marginBlock,fullWidth:!0,disabled:i,value:t.common.role,onChange:(f,d)=>{const p=yo.find(v=>v.role===d);p&&(p.w!==void 0&&p.r!==void 0?(this.setCommonItem(t,"write",p.w),this.setCommonItem(t,"read",p.r)):p.w!==void 0?this.setCommonItem(t,"write",p.w):p.r!==void 0&&this.setCommonItem(t,"read",p.r)),d.startsWith("level")||d.startsWith("indicator")||d.startsWith("sensor")||d.startsWith("weather")?t.common.write&&this.setCommonItem(t,"write",!1):d.startsWith("value")||d.startsWith("indicator")||d.startsWith("sensor")||d.startsWith("weather")?t.common.write&&this.setCommonItem(t,"write",!1):d.startsWith("level")||d.startsWith("switch")?t.common.write&&this.setCommonItem(t,"write",!0):d.startsWith("button")&&t.common.read&&this.setCommonItem(t,"read",!1),this.setCommonItem(t,"role",d)},options:l,renderInput:f=>y.jsx(w.TextField,{variant:"standard",...f,label:n("Role")})}),this.buttonRemoveKey("Role",()=>this.removeCommonItem(t,"role"))]}):Ht.buttonAddKey("Role",()=>this.setCommonItem(t,"role","")):null,typeof t.common.color<"u"?y.jsxs(w.Box,{component:"div",sx:O.flex,children:[y.jsx(w.TextField,{variant:"standard",disabled:i,style:{...O.marginBlock,...O.color},label:n("Color"),type:"color",slotProps:{input:{endAdornment:t.common.color?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>this.setCommonItem(t,"color",""),children:y.jsx(X.Close,{})})}):null}},value:t.common.color,onChange:f=>this.setCommonItem(t,"color",f.target.value)}),this.buttonRemoveKey("Color",()=>this.removeCommonItem(t,"color"))]}):Ht.buttonAddKey("Color",()=>this.setCommonItem(t,"color","")),y.jsxs(w.Box,{component:"div",sx:{...O.flex,flexWrap:this.props.width==="xs"?"wrap":void 0,gap:this.props.width==="xs"?"10px":void 0},children:[t.common.type==="number"?typeof t.common.min<"u"?y.jsxs(w.Box,{component:"div",sx:O.flex,children:[y.jsx(w.TextField,{variant:"standard",disabled:i,className:{...O.marginBlock,...O.color},label:n("Min"),value:t.common.min,onChange:f=>this.setCommonItem(t,"min",f.target.value)}),this.buttonRemoveKey("Min",()=>this.removeCommonItem(t,"min"))]}):y.jsx(w.Box,{component:"div",sx:O.flex,children:Ht.buttonAddKey("Min",()=>this.setCommonItem(t,"min",0))}):null,t.common.type==="number"?typeof t.common.max<"u"?y.jsxs(w.Box,{component:"div",sx:O.flex,children:[y.jsx(w.TextField,{variant:"standard",disabled:i,className:{...O.marginBlock,...O.color},label:n("Max"),value:t.common.max,onChange:f=>this.setCommonItem(t,"max",f.target.value)}),this.buttonRemoveKey("Max",()=>this.removeCommonItem(t,"max"))]}):y.jsx(w.Box,{component:"div",sx:O.flex,children:Ht.buttonAddKey("Max",()=>this.setCommonItem(t,"max",100))}):null,t.common.type==="number"?typeof t.common.step<"u"?y.jsxs(w.Box,{component:"div",sx:O.flex,children:[y.jsx(w.TextField,{variant:"standard",disabled:i,className:{...O.marginBlock,...O.color},label:n("Step"),value:t.common.step,onChange:f=>this.setCommonItem(t,"step",f.target.value)}),this.buttonRemoveKey("Step",()=>this.removeCommonItem(t,"step"))]}):y.jsx(w.Box,{component:"div",sx:O.flex,children:Ht.buttonAddKey("Step",()=>this.setCommonItem(t,"step",1))}):null]}),t.common.type==="number"?typeof t.common.unit<"u"?y.jsxs(w.Box,{component:"div",sx:O.flex,children:[y.jsx(w.TextField,{variant:"standard",disabled:i,className:{...O.marginBlock,...O.color},label:n("Unit"),slotProps:{input:{endAdornment:t.common.unit?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>this.setCommonItem(t,"unit",""),children:y.jsx(X.Close,{})})}):null}},value:t.common.unit,onChange:f=>this.setCommonItem(t,"unit",f.target.value)}),this.buttonRemoveKey("Unit",()=>this.removeCommonItem(t,"unit"))]}):y.jsx("div",{style:O.flexDrop,children:Ht.buttonAddKey("Unit",()=>this.setCommonItem(t,"unit",""))}):null]}),typeof t.common.icon<"u"?y.jsxs(w.Box,{component:"div",sx:O.flex,style:{flexGrow:1,minWidth:158},children:[y.jsx(Jx,{disabled:i,maxSize:10*1024,icon:u,removeIconFunc:()=>this.setCommonItem(t,"icon",""),onChange:f=>this.setCommonItem(t,"icon",f)}),this.buttonRemoveKey("Icon",()=>this.removeCommonItem(t,"icon"))]}):y.jsx(w.Box,{component:"div",sx:O.flex,children:Ht.buttonAddKey("Icon",()=>this.setCommonItem(t,"icon",""))})]})}catch{return y.jsx("div",{children:this.props.t("Cannot parse JSON!")})}}renderAliasEdit(){var t,e,i,n,a,o,s,l,u,h,c,f,d,p,v,g,m,_,b,x,C,S,T,M,D,I,P,k,R,L,j,E,q,W,$,et,ut,ot,ft,gt;try{const B=JSON.parse(this.state.text),Rt=((e=(t=B.common)==null?void 0:t.alias)==null?void 0:e.read)!==void 0||((n=(i=B.common)==null?void 0:i.alias)==null?void 0:n.write)!==void 0;return y.jsxs(w.Grid2,{container:!0,direction:"column",style:O.marginTop,children:[y.jsx(w.Grid2,{children:y.jsx(w.FormControlLabel,{control:y.jsx(w.Checkbox,{checked:typeof((o=(a=B.common)==null?void 0:a.alias)==null?void 0:o.id)=="object",onChange:()=>{var Mt,Lt,xt,z,Y,K,Ot;typeof((Lt=(Mt=B.common)==null?void 0:Mt.alias)==null?void 0:Lt.id)=="object"?this.setAliasItem(B,"id",((Y=(z=(xt=B.common)==null?void 0:xt.alias)==null?void 0:z.id)==null?void 0:Y.read)||""):this.setAliasItem(B,"id.read",((Ot=(K=B.common)==null?void 0:K.alias)==null?void 0:Ot.id)||"")}}),label:this.props.t("Different IDs for read and write")})}),typeof((l=(s=B.common)==null?void 0:s.alias)==null?void 0:l.id)!="object"?y.jsxs(w.Grid2,{children:[y.jsx(w.TextField,{variant:"standard",label:this.props.t("Alias state"),value:((h=(u=B.common)==null?void 0:u.alias)==null?void 0:h.id)||"",style:O.aliasIdEdit,slotProps:{input:{endAdornment:(f=(c=B.common)==null?void 0:c.alias)!=null&&f.id?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"large",onClick:()=>this.setAliasItem(B,"id",""),children:y.jsx(X.Close,{})})}):null}},onChange:Mt=>this.setAliasItem(B,"id",Mt.target.value),margin:"normal"}),y.jsx(w.Fab,{style:O.button,size:"small",onClick:()=>this.setState({selectId:!0,selectRead:!1,selectWrite:!1}),children:"..."})]}):null,typeof((p=(d=B.common)==null?void 0:d.alias)==null?void 0:p.id)=="object"?y.jsxs(w.Grid2,{children:[y.jsx(w.TextField,{variant:"standard",label:this.props.t("Alias read state"),value:((m=(g=(v=B.common)==null?void 0:v.alias)==null?void 0:g.id)==null?void 0:m.read)||"",style:O.aliasIdEdit,slotProps:{input:{endAdornment:(x=(b=(_=B.common)==null?void 0:_.alias)==null?void 0:b.id)!=null&&x.read?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"large",onClick:()=>this.setAliasItem(B,"id.read",""),children:y.jsx(X.Close,{})})}):null}},onChange:Mt=>this.setAliasItem(B,"id.read",Mt.target.value),margin:"normal"}),y.jsx(w.Fab,{style:O.button,size:"small",onClick:()=>this.setState({selectId:!1,selectRead:!0,selectWrite:!1}),children:"..."})]}):null,typeof((S=(C=B.common)==null?void 0:C.alias)==null?void 0:S.id)=="object"?y.jsxs(w.Grid2,{children:[y.jsx(w.TextField,{variant:"standard",label:this.props.t("Alias write state"),value:((D=(M=(T=B.common)==null?void 0:T.alias)==null?void 0:M.id)==null?void 0:D.write)||"",style:O.aliasIdEdit,slotProps:{input:{endAdornment:(k=(P=(I=B.common)==null?void 0:I.alias)==null?void 0:P.id)!=null&&k.write?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"large",onClick:()=>this.setAliasItem(B,"id.write",""),children:y.jsx(X.Close,{})})}):null}},onChange:Mt=>this.setAliasItem(B,"id.write",Mt.target.value),margin:"normal"}),y.jsx(w.Fab,{style:O.button,size:"small",onClick:()=>this.setState({selectId:!1,selectRead:!1,selectWrite:!0}),children:"..."})]}):null,y.jsx(w.Grid2,{style:O.marginTop,children:y.jsx(w.FormControlLabel,{control:y.jsx(w.Checkbox,{checked:((L=(R=B.common)==null?void 0:R.alias)==null?void 0:L.read)!==void 0||((E=(j=B.common)==null?void 0:j.alias)==null?void 0:E.write)!==void 0,onChange:()=>{Rt?(delete B.common.alias.read,delete B.common.alias.write):(B.common=B.common||{},B.common.alias=B.common.alias||{},B.common.alias.read="val",B.common.alias.write="val"),this.onChange(JSON.stringify(B,null,2))}}),label:this.props.t("Use convert functions")})}),Rt?y.jsx(w.Grid2,{children:y.jsx(w.TextField,{variant:"standard",label:this.props.t("Read converter"),value:((W=(q=B.common)==null?void 0:q.alias)==null?void 0:W.read)||"val",style:O.funcEdit,error:!!this.state.readError,slotProps:{input:{endAdornment:(et=($=B.common)==null?void 0:$.alias)!=null&&et.read?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"large",onClick:()=>this.setAliasItem(B,"read",""),children:y.jsx(X.Close,{})})}):null,startAdornment:y.jsx(w.InputAdornment,{position:"start",children:y.jsx(Rs,{style:O.funcIcon})})}},onChange:Mt=>this.setAliasItem(B,"read",Mt.target.value),helperText:this.state.readError||`${this.props.t("JS function like")} "val / 5 + 21"`,margin:"normal"})}):null,Rt?y.jsx(w.Grid2,{children:y.jsx(w.TextField,{variant:"standard",label:this.props.t("Write converter"),error:!!this.state.writeError,value:((ot=(ut=B.common)==null?void 0:ut.alias)==null?void 0:ot.write)||"val",helperText:this.state.writeError||`${this.props.t("JS function like")} "(val - 21) * 5"`,style:O.funcEdit,slotProps:{input:{endAdornment:(gt=(ft=B.common)==null?void 0:ft.alias)!=null&&gt.write?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"large",onClick:()=>this.setAliasItem(B,"write",""),children:y.jsx(X.Close,{})})}):null,startAdornment:y.jsx(w.InputAdornment,{position:"start",children:y.jsx(Rs,{style:O.funcIcon})})}},onChange:Mt=>this.setAliasItem(B,"write",Mt.target.value),margin:"normal"})}):null]})}catch{return y.jsx("div",{children:this.props.t("Cannot parse JSON!")})}}onCopy(t){jt.copyToClipboard(this.state.text,t),window.alert(this.props.t("ra_Copied"))}onClone(t,e){const i=JSON.parse(JSON.stringify(this.props.objects[t]));delete i.from,delete i.ts,delete i.user,i._id=e,this.props.objects[i._id]=i,this.props.onNewObject(i)}renderCopyDialog(){return this.state.showCopyDialog?y.jsxs(w.Dialog,{open:!0,maxWidth:"md",fullWidth:!0,onClose:()=>this.setState({showCopyDialog:""}),children:[y.jsx(w.DialogTitle,{children:this.props.t("Enter new ID for this object")}),y.jsx(w.DialogContent,{children:y.jsx(w.TextField,{variant:"standard",autoFocus:!0,fullWidth:!0,label:this.props.t("New object ID"),value:this.state.newId,slotProps:{input:{endAdornment:this.state.newId?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>this.setState({newId:""}),children:y.jsx(X.Close,{})})}):null}},onKeyDown:t=>{t.key==="Enter"&&!this.props.objects[this.state.newId]&&(this.setState({showCopyDialog:""}),this.onClone(this.state.showCopyDialog,this.state.newId))},onChange:t=>this.setState({newId:t.target.value})})}),y.jsxs(w.DialogActions,{children:[y.jsx(w.Button,{disabled:!!this.props.objects[this.state.newId],onClick:()=>{this.setState({showCopyDialog:""}),this.onClone(this.state.showCopyDialog,this.state.newId)},color:"primary",startIcon:y.jsx(X.FileCopy,{}),children:this.props.t("Clone")}),y.jsx(w.Button,{color:"grey",onClick:()=>this.setState({showCopyDialog:""}),startIcon:y.jsx(X.Close,{}),children:this.props.t("Cancel")})]})]}):null}renderPanelObject(t){return y.jsxs("div",{style:{...O.divWithoutTitle,...t?O.divWithoutTitleAndTab:void 0,...this.state.error?O.error:void 0},onKeyDown:e=>{e.ctrlKey&&e.key==="Enter"&&(e.preventDefault(),e.stopPropagation(),this.onUpdate())},children:[y.jsx(ty,{value:this.state.text,onChange:e=>this.onChange(e),name:"UNIQUE_ID_OF_DIV",themeType:this.props.themeType}),this.state.showCommonDeleteMessage?y.jsx("div",{style:O.commonDeleteTip,children:G.t("common_delete_tip")}):null]})}render(){const t=this.props.obj,e=t._id.startsWith("alias.0")&&t.type==="state";let i=O.dialog;window.innerWidth>1920&&(i={...i,maxWidth:"calc(100% - 150px)"});let n;try{n=JSON.parse(this.state.text)}catch{}return y.jsxs(w.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:[y.jsxs(w.DialogTitle,{id:"edit-value-dialog-title",style:{width:"calc(100% - 32px)",overflow:"hidden",textOverflow:"ellipsis"},children:[this.props.t("Edit object:")," ",y.jsx(w.Box,{component:"span",style:O.id,sx:{fontSize:{xs:10}},children:this.props.obj._id})]}),this.renderTabs(n),this.renderCopyDialog(),y.jsxs(w.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(e):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()]}),y.jsxs(w.DialogActions,{sx:O.wrapperButton,children:[y.jsx(w.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:y.jsx(X.FileCopy,{fontSize:this.props.width==="xs"?"large":void 0})}),y.jsx("div",{style:{flexGrow:1}}),this.state.tab==="object"&&y.jsx(w.Button,{color:"grey",onClick:a=>this.onCopy(a),disabled:this.state.error,title:this.props.width==="xs"?this.props.t("Copy into clipboard"):"",startIcon:this.props.width==="xs"?void 0:y.jsx(Md,{}),children:this.props.width==="xs"?y.jsx(Md,{fontSize:32}):this.props.t("Copy into clipboard")}),y.jsx(w.Button,{variant:"contained",disabled:this.state.error||!this.state.changed||this.state.customError,onClick:()=>this.onUpdate(),startIcon:this.props.width==="xs"?void 0:y.jsx(X.Check,{}),color:"primary",children:this.props.width==="xs"?y.jsx(X.Check,{fontSize:"large"}):this.props.t("Write")}),y.jsx(w.Button,{color:"grey",variant:"contained",onClick:()=>this.props.onClose(),startIcon:this.props.width==="xs"?void 0:y.jsx(X.Close,{}),children:this.props.width==="xs"?y.jsx(X.Close,{fontSize:"large"}):this.props.t("Cancel")})]})]})}}class md extends at.Component{object=null;constructor(t){super(t),this.state={role:null,initRole:null,roleInput:null}}componentDidMount(){this.props.socket.getObject(this.props.id).then(t=>{var i;this.object=t;const e=((i=t==null?void 0:t.common)==null?void 0:i.role)||null;this.setState({role:e,initRole:e,roleInput:e})}).catch(t=>console.error(t))}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(t,e){const i=[];return t.forEach(n=>(n.type==="mixed"||n.type)===e&&!i.includes(n.role)&&i.push(n.role)),yo.forEach(n=>(n.type==="mixed"||n.type)===e&&!i.includes(n.role)&&i.push(n.role)),i.sort(),i}render(){return y.jsxs(w.Dialog,{open:!0,maxWidth:"sm",fullWidth:!0,onClose:()=>this.props.onClose(),"aria-labelledby":"edit-role-dialog-title","aria-describedby":"edit-role-dialog-description",children:[y.jsx(w.DialogTitle,{id:"edit-role-dialog-title",children:this.object?this.props.t("Update role for %s",this.object._id):null}),y.jsx(w.DialogContent,{children:y.jsx(w.Autocomplete,{freeSolo:!0,options:md.filterRoles(this.props.roleArray,this.props.commonType),style:{width:"100%"},value:this.state.role,onChange:(t,e)=>this.setState({role:e,roleInput:e}),onInputChange:(t,e)=>this.setState({roleInput:e}),renderInput:t=>y.jsx(w.TextField,{variant:"standard",...t,label:this.props.t("Role")})})}),y.jsxs(w.DialogActions,{children:[y.jsx(w.Button,{disabled:this.state.initRole===this.state.roleInput,variant:"contained",onClick:()=>this.onUpdate(),color:"primary",startIcon:y.jsx(X.Check,{}),children:this.props.t("Apply")}),y.jsx(w.Button,{variant:"contained",onClick:()=>this.props.onClose(),color:"grey",startIcon:y.jsx(X.Close,{}),children:this.props.t("Cancel")})]})]},"objectBrowserEditRole")}}const CO=["array","boolean","file","json","mixed","number","object","string"],TO={boolean:!1,string:"",number:0},Be={state:{name:"State",value:"state"},channel:{name:"Channel",value:"channel"},device:{name:"Device",value:"device"},folder:{name:"Folder",value:"folder"}},AO=({onClose:r,onApply:t,selected:e,setObject:i,objects:n,expertMode:a,initialType:o,initialStateType:s})=>{var T;const l={state:G.t("New state"),channel:G.t("New channel"),device:G.t("New device"),folder:G.t("New folder")},u=[],h=(T=n[e])==null?void 0:T.type;n[e]?h==="channel"?(u.push(Be.state),o=o||"state"):h==="device"?(o=o||"channel",u.push(Be.state),u.push(Be.channel)):h==="state"?o=o||"":(u.push(Be.state),u.push(Be.channel),u.push(Be.device),e.startsWith("0_userdata.")||e.startsWith("alias.0.")||e==="0_userdata"||e==="alias.0"?(u.push(Be.folder),o=o||"folder"):o=o||"state"):(u.push(Be.folder),o=o||"folder",a&&(e.startsWith("mqtt.")||e.startsWith("javascript."))&&(u.push(Be.state),u.push(Be.channel),u.push(Be.device)));const c=(window._localStorage||window.localStorage).getItem("App.lastObjectType");c&&u.find(M=>M.value===c)&&(o=c);function f(M){return`${e}.${M.toString().replace(jt.FORBIDDEN_CHARS,"_").replace(/\s/g,"_").replace(/\./g,"_")}`}const[d,p]=at.useState(o),[v,g]=at.useState(l[o]),[m,_]=at.useState(s||(window._localStorage||window.localStorage).getItem("App.lastStateType")||"string"),[b,x]=at.useState(!n[f(l.state)]),C=()=>{const M={common:{name:v,desc:G.t("Manually created")},type:d};d==="state"?(M.common={...M.common,role:"state",type:m,read:!0,write:!0,def:TO[m]},M.native={}):d!=="folder"?M.common={...M.common,role:"",icon:""}:delete M.common.desc,i(`${e}.${v.split(" ").join("_")}`,M).then(()=>t())},S=G.getLanguage();return y.jsxs(w.Dialog,{open:!0,fullWidth:!0,maxWidth:"md",disableEscapeKeyDown:!1,onClose:r,children:[y.jsx(w.DialogTitle,{children:y.jsxs("div",{style:{margin:10,fontSize:20,display:"flex",alignItems:"center",gap:8},children:[y.jsx(X.AddBox,{}),G.t("Add new object:"),y.jsxs("span",{style:{fontStyle:"italic"},children:[e,".",v]})]})}),y.jsx(w.DialogContent,{children:y.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[y.jsx(w.TextField,{variant:"standard",label:G.t("Parent"),style:{margin:"5px 0"},disabled:!0,value:e}),y.jsxs(w.FormControl,{variant:"standard",style:{marginTop:10,marginBottom:16},children:[y.jsx(w.InputLabel,{children:G.t("Type")}),y.jsx(w.Select,{variant:"standard",value:d,onChange:M=>{(window._localStorage||window.localStorage).setItem("App.lastObjectType",M.target.value),v===l[d]&&(g(l[M.target.value]),x(!!n[f(l[M.target.value])])),p(M.target.value)},children:u.map(M=>y.jsxs(w.MenuItem,{value:M.value,children:[G.t(M.name),S!=="en"&&y.jsxs("span",{style:{fontSize:"smaller",opacity:.6,marginLeft:4},children:["(",M.value,")"]})]},M.value))})]}),d==="state"&&y.jsxs(w.FormControl,{style:{marginTop:10,marginBottom:16},children:[y.jsx(w.InputLabel,{style:{left:-14},children:G.t("State type")}),y.jsx(w.Select,{style:{marginTop:6},variant:"standard",value:m,onChange:M=>{(window._localStorage||window.localStorage).setItem("App.lastStateType",M.target.value),_(M.target.value)},children:CO.map(M=>y.jsxs(w.MenuItem,{value:M,children:[G.t(M),S!=="en"&&G.t(M)!==M&&y.jsxs("span",{style:{fontSize:"smaller",opacity:.6,marginLeft:4},children:["(",M,")"]})]},M))})]}),y.jsx(w.TextField,{variant:"standard",label:G.t("Name"),style:{margin:"5px 0"},autoFocus:!0,value:v,onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),v&&C())},slotProps:{input:{endAdornment:v?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>g(""),children:y.jsx(X.Close,{})})}):null}},onChange:M=>{x(!n[f(M.target.value)]),g(M.target.value)}})]})}),y.jsxs(w.DialogActions,{children:[y.jsx(w.Button,{id:"add-new-object-dialog-add",startIcon:y.jsx(X.Check,{}),disabled:!v||!d||!b||d==="state"&&!m,onClick:()=>C(),variant:"contained",color:"primary",children:G.t("add")}),y.jsx(w.Button,{id:"add-new-object-dialog-cancel",color:"grey",onClick:r,variant:"contained",startIcon:y.jsx(X.Close,{}),children:G.t("ra_Cancel")})]})]})},MO=[{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 Jm(r,t,e){return r|=t&e,r&=t|~e&65535,r}const Qm=({value:r,setValue:t,t:e,differentValues:i,applyToChildren:n,mask:a,setMask:o,disabled:s})=>{at.useEffect(()=>{if(n){let u=0;for(let h=0;h<i.length;h++)u|=r^i[h];o(u)}else o(0)},[i,n,o,r]);let l=r;return y.jsx("div",{style:{display:"flex",width:"fit-content",margin:20,border:"1px solid",borderLeft:0},children:MO.map(u=>{const h=Object.keys(u)[0];return y.jsxs("div",{style:{width:150,height:150,display:"flex",flexDirection:"column",alignItems:"center",borderLeft:"1px solid"},children:[y.jsx("div",{style:{height:50,display:"flex",alignItems:"center",fontSize:18,borderBottom:"1px solid silver",width:"100%",justifyContent:"center"},children:e(h)}),y.jsx("div",{style:{display:"flex",width:"100%"},children:u[h].map((c,f)=>{let d=!1;l-c.valueNum>=0&&(l-=c.valueNum,d=!0);const p=a&c.valueNum;return y.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,alignItems:"center",borderRight:f===0?"1px solid":0},children:[y.jsx("div",{style:{height:50,borderBottom:"1px solid",width:"100%",justifyContent:"center",display:"flex",alignItems:"center",color:"silver"},children:e(c.name)}),y.jsx("div",{style:{height:50,display:"flex"},children:y.jsx(w.Checkbox,{disabled:s,checked:d,color:p?"primary":"secondary",indeterminate:!!p,style:p?{opacity:.5}:void 0,onChange:v=>{p&&(a&=~c.valueNum&65535,o(a));let g=r;v.target.checked?g|=c.valueNum:g&=~c.valueNum&65535,t(g)}})})]},c.valueNum)})})]},h)})})},DO=({onClose:r,onApply:t,selected:e,extendObject:i,objects:n,t:a,modalEmptyId:o,themeType:s,theme:l})=>{const[u,h]=at.useState(null),[c,f]=at.useState(null),[d,p]=at.useState([]),[v,g]=at.useState([]),[m,_]=at.useState(!1),[b,x]=at.useState(!1),[C,S]=at.useState(0),[T,M]=at.useState(null),[D,I]=at.useState(null),[P,k]=at.useState(!1),[R,L]=at.useState(!1),[j,E]=at.useState([]),[q,W]=at.useState([]),[$,et]=at.useState(0),[ut,ot]=at.useState(0),[ft,gt]=at.useState([]),[B,Rt]=at.useState(!1),[Mt,Lt]=at.useState(!0),xt=a("different");return at.useEffect(()=>{var bd,xd,wd,Sd;let z=0;const Y=[],K=[],Ot=e||o,St=`${Ot}.`,se=Object.keys(n).sort();let je=!1;const ei=[],Tr=[],ri=G.getLanguage();let qn=!1,Zn=!1,tn=null,en=null,ii=null,ni=null;const _d=[];for(let ai=0;ai<se.length;ai++){const Ar=se[ai],ht=n[Ar];if(ht&&(Ar===Ot||Ar.startsWith(St))){if(z++,_d.push(Ar),!ht.acl)continue;ii===null&&ht.acl.object!==void 0&&(ii=ht.acl.object),ni===null&&ht.acl.state!==void 0&&(ni=ht.acl.state),tn===null&&ht.acl.owner!==void 0&&(tn=ht.acl.owner),en===null&&ht.acl.ownerGroup!==void 0&&(en=ht.acl.ownerGroup),!P&&tn!==ht.acl.owner&&ht.acl.owner!==void 0&&(qn=!0),!R&&en!==ht.acl.ownerGroup&&ht.acl.ownerGroup!==void 0&&(Zn=!0),ht.acl.state!==void 0&&ni!==ht.acl.state&&!Y.includes(ht.acl.state)&&Y.push(ht.acl.state),ht.acl.object!==void 0&&ii!==ht.acl.object&&!K.includes(ht.acl.object)&&K.push(ht.acl.object),ht.type==="state"&&(je=!0)}Ar.startsWith("system.group.")&&(ht==null?void 0:ht.type)==="group"?ei.push({name:jt.getObjectNameFromObj(ht,ri).replace("system.group.",""),value:Ar,icon:(bd=ht.common)==null?void 0:bd.icon,color:(xd=ht.common)==null?void 0:xd.color}):Ar.startsWith("system.user.")&&(ht==null?void 0:ht.type)==="user"&&Tr.push({name:jt.getObjectNameFromObj(ht,ri).replace("system.user.",""),value:Ar,icon:(wd=ht.common)==null?void 0:wd.icon,color:(Sd=ht.common)==null?void 0:Sd.color})}tn=tn||n["system.config"].common.defaultNewAcl.owner,en=en||n["system.config"].common.defaultNewAcl.ownerGroup,ii=ii||n["system.config"].common.defaultNewAcl.object,M(Number.isNaN(ii)?n["system.config"].common.defaultNewAcl.object:ii),je&&(ni=ni||n["system.config"].common.defaultNewAcl.state,I(Number.isNaN(ni)?n["system.config"].common.defaultNewAcl.state:ni));const Gx=Tr.find(ai=>ai.value===tn),Ux=ei.find(ai=>ai.value===en);h(Gx),f(Ux),k(qn),L(Zn),p(Tr),g(ei),je&&x(!0),o&&_(!0),S(z),E(Y),W(K),gt(_d)},[n,e,R,P,o]),at.useEffect(()=>{m?(R&&(c.value!=="different"&&f({name:xt,value:"different"}),v.find(z=>z.value==="different")||g(z=>[{name:xt,value:"different"},...z])),P&&((!u||u.value!=="different")&&h({name:xt,value:"different"}),d.find(z=>z.value==="different")||p(z=>[{name:xt,value:"different"},...z]))):(u&&u.value==="different"&&h(n[e].acl.owner),c&&c.value==="different"&&f(n[e].acl.ownerGroup),g(z=>z.filter(({value:Y})=>Y!=="different")),p(z=>z.filter(({value:Y})=>Y!=="different")))},[d,m,P,R,n,e,c,u,xt,v]),ft.length?y.jsx(ow,{theme:l,titleButtonApply:"apply",overflowHidden:!0,disableApply:Mt,progress:B,onClose:r,onApply:()=>{Rt(!0),setTimeout(()=>{if(m){const z=~$&65535,Y=~ut&65535;for(let K=0;K<ft.length;K++){const Ot=ft[K],St=n[Ot],se=jt.clone(St.acl||{});se.object=Jm(St.acl.object,T,z),u&&u.value!=="different"&&(se.owner=u.value),c&&c.value!=="different"&&(se.ownerGroup=c.value),St.type==="state"&&(se.state=Jm(St.acl.state,D,Y)),i(Ot,{acl:se})}}else{const z=jt.clone(n[e].acl||{});z.object=T,z.owner=u?u.value:"system.user.admin",z.ownerGroup=c?c.value:"system.group.administrator",n[e].type==="state"&&(z.state=D),i(e,{acl:z})}Rt(!1),t()},200)},children:y.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[y.jsx("div",{style:{margin:10,fontSize:20},children:a("Access control list: %s",e||o)}),y.jsxs("div",{style:{display:"flex"},children:[y.jsxs(w.FormControl,{variant:"standard",fullWidth:!0,style:{marginRight:10},children:[y.jsx(w.InputLabel,{children:a("Owner user")}),y.jsx(w.Select,{variant:"standard",disabled:B,value:u?u.value:"",renderValue:()=>y.jsxs("span",{children:[u!=null&&u.icon?y.jsx(Ca,{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:jt.getInvertedColor(u==null?void 0:u.color,s)},onChange:z=>{const Y=d.find(K=>K.value===z.target.value);h(Y),Lt(!1)},children:d.map(z=>y.jsxs(w.MenuItem,{style:z.value==="different"?{opacity:.5}:{color:z.color||void 0,backgroundColor:jt.getInvertedColor(z.color,s)},value:z.value,children:[z.icon?y.jsx(Ca,{src:z.icon,style:{width:16,height:16,marginRight:8}}):null,z.name]},z.value))})]}),y.jsxs(w.FormControl,{variant:"standard",fullWidth:!0,children:[y.jsx(w.InputLabel,{children:a("Owner group")}),y.jsx(w.Select,{variant:"standard",disabled:B,value:c?c.value:"",renderValue:()=>y.jsxs("span",{children:[c!=null&&c.icon?y.jsx(Ca,{src:c.icon,style:{width:16,height:16,marginRight:8}}):null,c?c.name:""]}),style:(c==null?void 0:c.value)==="different"?{opacity:.5}:{color:(c==null?void 0:c.color)||void 0,backgroundColor:jt.getInvertedColor(c==null?void 0:c.color,s)},onChange:z=>{const Y=v.find(K=>K.value===z.target.value);f(Y),Lt(!1)},children:v.map(z=>y.jsxs(w.MenuItem,{value:z.value,style:z.value==="different"?{opacity:.5}:{color:z.color||void 0,backgroundColor:jt.getInvertedColor(z.color,s)},children:[z.icon?y.jsx(Ca,{src:z.icon,style:{width:16,height:16,marginRight:8}}):null,z.name]},z.value))})]})]}),y.jsxs("div",{style:{display:"flex",margin:10,alignItems:"center",fontSize:10,marginLeft:0,color:"silver"},children:[y.jsx("div",{style:m?null:{color:"green"},children:a("to apply one item")}),y.jsx(w.Switch,{disabled:B||!!o||C===1,checked:!!o||m,onChange:z=>{_(z.target.checked),Lt(!1)},color:"primary"}),y.jsxs("div",{style:m?{color:"green"}:null,children:[a("to apply with children")," ",o||C>1?`(${C} ${a("object(s)")})`:""]})]}),B&&y.jsx(w.LinearProgress,{}),y.jsxs("div",{style:{overflowY:"auto"},children:[y.jsxs("div",{children:[y.jsx("h2",{children:a("Object rights")}),y.jsx(Qm,{mask:ut,disabled:B,setMask:ot,applyToChildren:m,differentValues:q,t:a,setValue:z=>{M(z),Lt(!1)},value:T})]}),b&&y.jsxs("div",{children:[y.jsx("h2",{children:a("States rights")}),y.jsx(Qm,{mask:$,disabled:B,setMask:et,applyToChildren:m,differentValues:m?j:[],t:a,setValue:z=>{I(z),Lt(!1)},value:D})]})]})]})}):y.jsx(w.LinearProgress,{})},bn={dialog:{height:"100%",maxHeight:"100%",maxWidth:"100%"},content:{textAlign:"center"},error:r=>({color:r.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 IO extends at.Component{audioRef;constructor(t){super(t);const e=this.props.obj._id.split(".");this.state={error:"",image:null,text:null,binary:null,fileName:`${e[e.length-2]}.${e[e.length-1]}`},this.audioRef=vh.createRef()}componentDidMount(){this.props.socket.getBinaryState(this.props.obj._id).then(t=>{let e=this.props.obj._id.toLowerCase().split(".").pop();const i=jt.detectMimeType(t);if(i&&(e=i),e==="jpg")this.setState({image:!0,binary:t,mime:"image/jpeg"});else if(e==="svg")this.setState({image:!0,binary:t,mime:"image/svg+xml"});else if(e==="png"||e==="bmp")this.setState({image:!0,binary:t,mime:`image/${e}`});else if(e==="mp3")this.setState({audio:!0,binary:t,mime:"audio/mpeg"});else if(e==="ogg")this.setState({audio:!0,binary:t,mime:"audio/ogg"});else if(e==="txt"||e==="log")try{const n=btoa(t);this.setState({text:n,binary:t,mime:"text/plain"})}catch{}}).catch(t=>this.setState({error:t}))}render(){return y.jsxs(w.Dialog,{style:bn.dialog,open:!0,maxWidth:this.state.audio?"sm":"md",onClose:()=>this.props.onClose(),fullWidth:!0,"aria-labelledby":"object-view-dialog-title",children:[y.jsx(w.DialogTitle,{id:"object-view-dialog-title",children:this.props.t("View file in state: %s",this.props.obj._id)}),y.jsxs(w.DialogContent,{style:bn.content,children:[this.state.error?y.jsx(w.Box,{component:"div",sx:bn.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?y.jsx("audio",{ref:this.audioRef,src:`data:${this.state.mime};base64,${this.state.binary}`}):null,this.state.audio?y.jsx(w.Fab,{color:"primary",onClick:()=>this.audioRef.current&&this.audioRef.current.play(),children:y.jsx(X.PlayArrow,{})}):null,this.state.image?y.jsx("img",{src:`data:${this.state.mime};base64,${this.state.binary}`,alt:this.props.obj._id,style:bn.image}):null,this.state.text!==null?y.jsx("pre",{style:bn.text,children:this.state.text}):null]}),y.jsxs(w.DialogActions,{children:[y.jsxs("a",{style:bn.download,download:this.state.fileName,href:`data:${this.state.mime};base64,${this.state.binary}`,children:[y.jsx(X.GetApp,{style:{paddingRight:8,height:12}}),y.jsx("span",{children:this.props.t("Download")})]}),y.jsx(w.Button,{variant:"contained",onClick:()=>this.props.onClose(),startIcon:y.jsx(X.Close,{}),color:"grey",children:this.props.t("Close")})]})]})}}const PO=Wn()(IO),zt={funcIcon:{width:16,height:16},formControlLabel:{marginBottom:16},color:{width:70},typeNameEng:{marginLeft:8,opacity:.7,fontStyle:"italic",fontSize:"smaller"},usedInAlias:{},addNewAlias:r=>({backgroundColor:r.palette.primary.main})},kO=["array","boolean","file","json","mixed","number","object","string"];class Ya extends at.Component{aliasIDs;constructor(t){var n;super(t);const e=[],i=this.props.obj._id;this.aliasIDs=Object.keys(this.props.objects).filter(a=>a.startsWith("alias.0"));for(let a=0;a<this.aliasIDs.length;a++){const o=(n=this.props.objects[this.aliasIDs[a]].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))&&e.push(this.aliasIDs[a])}this.state={usedInAliases:e,showAddNewAlias:!e.length,newAliasId:this.props.obj._id,newAliasName:Ya.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:Ya.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}}static getText(t){return t?typeof t=="object"?t[G.getLanguage()]||t.en||"":t.toString():""}static filterRoles(t,e){const i=[];return yo.forEach(n=>(n.type==="mixed"||n.type===e)&&!i.includes(n.role)&&i.push(n.role)),t.forEach(n=>(n.type==="mixed"||n.type)===e&&!i.includes(n.role)&&i.push(n.role)),i.sort(),i}renderAddNewAlias(){return this.state.showAddNewAlias?y.jsxs(w.Dialog,{open:!0,onClose:()=>this.setState({showAddNewAlias:!1}),children:[y.jsx(w.DialogTitle,{children:G.t("Create new alias: %s",`alias.0.${this.state.newAliasId}`)}),y.jsxs(w.DialogContent,{children:[y.jsx(w.TextField,{style:zt.formControlLabel,variant:"standard",value:this.state.newAliasId,slotProps:{input:{endAdornment:this.state.newAliasId?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>this.setState({newAliasId:""}),children:y.jsx(X.Close,{})})}):null}},onChange:t=>this.setState({newAliasId:t.target.value}),label:G.t("Alias ID"),helperText:`alias.0.${this.state.newAliasId}`,fullWidth:!0}),y.jsx(w.TextField,{style:zt.formControlLabel,variant:"standard",value:this.state.newAliasName,slotProps:{input:{endAdornment:this.state.newAliasName?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>this.setState({newAliasName:""}),children:y.jsx(X.Close,{})})}):null}},onChange:t=>this.setState({newAliasName:t.target.value}),label:G.t("Alias name"),fullWidth:!0}),y.jsx(w.TextField,{style:zt.formControlLabel,variant:"standard",value:this.state.newAliasDesc,slotProps:{input:{endAdornment:this.state.newAliasDesc?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>this.setState({newAliasDesc:""}),children:y.jsx(X.Close,{})})}):null}},onChange:t=>this.setState({newAliasDesc:t.target.value}),label:G.t("Alias description"),fullWidth:!0}),y.jsxs(w.FormControl,{style:zt.formControlLabel,fullWidth:!0,children:[y.jsx(w.InputLabel,{children:G.t("State type")}),y.jsx(w.Select,{variant:"standard",value:this.state.newAliasType,onChange:t=>this.setState({newAliasType:t.target.value}),children:kO.map(t=>y.jsxs(w.MenuItem,{value:t,children:[G.t(t),y.jsxs("span",{style:zt.typeNameEng,children:["(",t,")"]})]},t))})]}),this.state.newAliasType==="number"?y.jsx(w.TextField,{style:zt.formControlLabel,variant:"standard",value:this.state.newAliasUnit||"",slotProps:{input:{endAdornment:this.state.newAliasUnit?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>this.setState({newAliasUnit:""}),children:y.jsx(X.Close,{})})}):null}},onChange:t=>this.setState({newAliasUnit:t.target.value}),label:G.t("Alias units"),fullWidth:!0}):null,this.state.newAliasType==="number"?y.jsx(w.TextField,{variant:"standard",value:this.state.newAliasMin,type:"number",error:this.state.newAliasMin?isNaN(parseFloat(this.state.newAliasMin)):!1,onChange:t=>this.setState({newAliasMin:t.target.value}),label:G.t("Min"),style:{width:"calc(50% - 4px)",marginBottom:16,marginRight:8}}):null,this.state.newAliasType==="number"?y.jsx(w.TextField,{variant:"standard",value:this.state.newAliasMax,type:"number",error:this.state.newAliasMax?isNaN(parseFloat(this.state.newAliasMax)):!1,onChange:t=>this.setState({newAliasMax:t.target.value}),label:G.t("Max"),fullWidth:!0,style:{width:"calc(50% - 4px)",marginBottom:16}}):null,y.jsx(w.TextField,{variant:"standard",style:{...zt.formControlLabel,...zt.color},label:G.t("Color"),type:"color",value:this.state.newAliasColor,onChange:t=>this.setState({newAliasColor:t.target.value})}),y.jsx(w.Autocomplete,{style:{...zt.formControlLabel},fullWidth:!0,value:this.state.newAliasRole,onChange:(t,e)=>{const i=yo.find(n=>n.role===e);if(i){if(i.w!==void 0&&i.r!==void 0){this.setState({newAliasRole:e,newAliasRead:i.r,newAliasWrite:i.w});return}if(i.w!==void 0){this.setState({newAliasRole:e,newAliasWrite:i.w});return}if(i.r!==void 0){this.setState({newAliasRole:e,newAliasRead:i.r});return}}if(e.startsWith("value")||e.startsWith("indicator")||e.startsWith("sensor")||e.startsWith("weather")){if(this.state.newAliasWrite){this.setState({newAliasRole:e,newAliasWrite:!1});return}}else if(e.startsWith("level")||e.startsWith("switch")){if(!this.state.newAliasWrite){this.setState({newAliasRole:e,newAliasWrite:!0});return}}else if(e.startsWith("button")&&this.state.newAliasRead){this.setState({newAliasRole:e,newAliasRead:!1});return}this.setState({newAliasRole:e})},options:Ya.filterRoles(this.props.roleArray,this.state.newAliasType),renderInput:t=>y.jsx(w.TextField,{variant:"standard",...t,label:G.t("Role")})}),y.jsx(w.FormControlLabel,{style:{...zt.formControlLabel,marginLeft:16},control:y.jsx(w.Checkbox,{indeterminate:this.state.newAliasRead===void 0||this.state.newAliasRead===null,checked:this.state.newAliasRead,onChange:t=>{const e={newAliasRead:t.target.checked};e.newAliasRead===!1&&this.state.newAliasWrite===!1&&(e.newAliasWrite=!0),this.setState(e)}}),label:G.t("Alias read")}),y.jsx(w.FormControlLabel,{style:zt.formControlLabel,control:y.jsx(w.Checkbox,{indeterminate:this.state.newAliasWrite===void 0||this.state.newAliasWrite===null,checked:this.state.newAliasWrite,onChange:t=>{const e={newAliasWrite:t.target.checked};e.newAliasRead===!1&&this.state.newAliasWrite===!1&&(e.newAliasRead=!0),this.setState(e)}}),label:G.t("Alias write")}),y.jsx(w.FormControlLabel,{style:zt.formControlLabel,control:y.jsx(w.Checkbox,{checked:this.state.newAliasUseFormula,onChange:t=>this.setState({newAliasUseFormula:t.target.checked})}),label:G.t("Use convert functions")}),this.state.newAliasUseFormula&&this.state.newAliasRead?y.jsx(w.TextField,{style:zt.formControlLabel,variant:"standard",value:this.state.newAliasReadFormula,onChange:t=>this.setState({newAliasReadFormula:t.target.value}),label:G.t("Read formula"),helperText:`${G.t("JS function like")} "val / 5 + 21"`,slotProps:{input:{endAdornment:this.state.newAliasReadFormula&&this.state.newAliasReadFormula!=="val"?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>this.setState({newAliasReadFormula:"val"}),children:y.jsx(X.Close,{})})}):null,startAdornment:y.jsx(w.InputAdornment,{position:"start",children:y.jsx(Rs,{style:zt.funcIcon})})}},fullWidth:!0}):null,this.state.newAliasUseFormula&&this.state.newAliasWrite?y.jsx(w.TextField,{style:zt.formControlLabel,variant:"standard",value:this.state.newAliasWriteFormula,onChange:t=>this.setState({newAliasWriteFormula:t.target.value}),label:G.t("Write formula"),slotProps:{input:{endAdornment:this.state.newAliasWriteFormula&&this.state.newAliasWriteFormula!=="val"?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>this.setState({newAliasWriteFormula:"val"}),children:y.jsx(X.Close,{})})}):null,startAdornment:y.jsx(w.InputAdornment,{position:"start",children:y.jsx(Rs,{style:zt.funcIcon})})}},helperText:`${G.t("JS function like")} "val / 5 + 21"`,fullWidth:!0}):null]}),y.jsxs(w.DialogActions,{children:[y.jsx(w.Button,{variant:"contained",disabled:!this.state.newAliasId||!!this.props.objects[`alias.0.${this.state.newAliasId}`],onClick:async()=>{const t={_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&&(t.common.desc=this.state.newAliasDesc),this.state.newAliasType&&(t.common.type=this.state.newAliasType),this.state.newAliasType==="number"&&this.state.newAliasUnit&&(t.common.unit=this.state.newAliasUnit),this.state.newAliasRole&&(t.common.role=this.state.newAliasRole),this.state.newAliasType==="number"&&this.state.newAliasMin&&(t.common.min=parseFloat(this.state.newAliasMin)),this.state.newAliasType==="number"&&this.state.newAliasMax&&(t.common.max=parseFloat(this.state.newAliasMax)),this.state.newAliasRole&&(t.common.role=this.state.newAliasRole),this.state.newAliasRead!==void 0&&this.state.newAliasRead!==null&&(t.common.read=this.state.newAliasRead),this.state.newAliasWrite!==void 0&&this.state.newAliasWrite!==null&&(t.common.write=this.state.newAliasWrite),this.state.newAliasColor&&(t.common.color=this.state.newAliasColor),this.state.newAliasIcon&&(t.common.icon=this.state.newAliasIcon),this.state.newAliasUseFormula&&(t.common.read!==!1&&this.state.newAliasReadFormula&&this.state.newAliasReadFormula!=="val"&&(t.common.alias.read=this.state.newAliasReadFormula),t.common.write!==!1&&this.state.newAliasWriteFormula&&this.state.newAliasWriteFormula!=="val"&&(t.common.alias.write=this.state.newAliasWriteFormula)),await this.props.socket.setObject(t._id,t),this.setState({showAddNewAlias:!1}),this.props.onRedirect(t._id,2e3),this.props.onClose()},startIcon:y.jsx(X.AddLink,{}),color:"primary",children:this.props.t("Create")}),y.jsx(w.Button,{variant:"contained",onClick:()=>this.setState({showAddNewAlias:!1}),startIcon:y.jsx(X.Close,{}),color:"grey",children:this.props.t("Close")})]})]}):null}render(){return y.jsxs(w.Dialog,{open:!0,maxWidth:"sm",onClose:()=>this.props.onClose(),fullWidth:!0,"aria-labelledby":"object-alias-dialog-title",children:[this.renderAddNewAlias(),y.jsx(w.DialogTitle,{id:"object-alias-dialog-title",children:this.state.usedInAliases.length?G.t("This object is used in aliases"):G.t("This object does not used in any aliases yet")}),y.jsx(w.DialogContent,{children:y.jsxs(w.MenuList,{style:{maxWidth:400},children:[this.state.usedInAliases.map(t=>y.jsxs(w.MenuItem,{style:zt.usedInAlias,onClick:()=>this.props.onRedirect(t),children:[y.jsx(w.ListItemIcon,{children:y.jsx(X.Link,{fontSize:"small"})}),y.jsx(w.ListItemText,{children:t})]},t)),y.jsxs(w.MenuItem,{onClick:()=>this.setState({showAddNewAlias:!0}),sx:zt.addNewAlias,children:[y.jsx(w.ListItemIcon,{children:y.jsx(X.AddLink,{fontSize:"small"})}),y.jsx(w.ListItemText,{children:G.t("Create alias from this ID")})]})]})}),y.jsx(w.DialogActions,{children:y.jsx(w.Button,{variant:"contained",onClick:()=>this.props.onClose(),startIcon:y.jsx(X.Close,{}),color:"grey",children:this.props.t("Close")})})]},"editAlias")}}const RO=Wn()(Ya);class yd extends at.Component{checkTimer=null;objects={};constructor(t){super(t);const e=this.props.id.split("."),i=e.pop()||"";this.state={name:i,parentId:e.join("."),renameAllChildren:!0,newExists:!0,showParentDialog:!1,showHistoryWarning:!1,withHistory:[]}}componentWillUnmount(){this.checkTimer&&(clearTimeout(this.checkTimer),this.checkTimer=null)}static calculateNewId(t,e,i){const n=t.split("."),a=e.split(".");let o=0;for(;n[o]===a[o];)o++;const s=i.split(".");return s.splice(0,o+1),`${e}.${s.join(".")}`}async getInstancesWithHistory(){const t=await this.props.socket.getAdapterInstances();return t==null?void 0:t.filter(e=>e.common.getHistory).map(e=>e._id.replace("system.adapter.",""))}async checkHistory(){this.objects={};const t=await this.getInstancesWithHistory(),e=[];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(a=>t.includes(a)&&!i.common.custom[a].aliasId)&&e.push(i._id)}),e.length?(this.setState({showHistoryWarning:!0,withHistory:e}),!1):!0}showHistoryWarning(){return this.state.showHistoryWarning?y.jsxs(w.Dialog,{open:!0,onClose:()=>this.setState({showHistoryWarning:!1}),children:[y.jsx(w.DialogTitle,{children:this.props.t("Found states with history")}),y.jsxs(w.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(", ")}`,y.jsx("div",{children:this.props.t("move_states_with_history_warning")})]}),y.jsxs(w.DialogActions,{children:[y.jsx(w.Button,{variant:"contained",color:"primary",onClick:async()=>{const t=`${this.state.parentId}.${this.state.name}`;await this.renameCopyObject(this.props.id,t,this.props.childrenIds.length&&this.state.renameAllChildren,!1),this.props.onClose()},startIcon:y.jsx(X.Check,{}),children:this.props.t("Confirm")}),y.jsx(w.Button,{color:"grey",variant:"contained",startIcon:y.jsx(X.Close,{}),onClick:()=>this.setState({showHistoryWarning:!1}),children:this.props.t("ra_Cancel")})]})]}):null}async renameCopyObject(t,e,i,n){var s;if(t===e)return;let a;try{a=((s=this.objects)==null?void 0:s[t])||await this.props.socket.getObject(t)}catch{}let o;if((a==null?void 0:a.type)==="state"&&(o=await this.props.socket.getState(t)),i)for(const l of this.props.childrenIds){const u=yd.calculateNewId(t,e,l);await this.renameCopyObject(l,u,!1,n)}a&&(await this.props.socket.setObject(e,a),o&&await this.props.socket.setState(e,o),n||await this.props.socket.delObject(t))}checkIfNewExists(){const t=`${this.state.parentId}.${this.state.name}`;this.checkTimer&&(clearTimeout(this.checkTimer),this.checkTimer=null),this.props.id===t?this.state.newExists||(this.checkTimer=setTimeout(()=>{this.checkTimer=null,this.setState({newExists:!0})},50)):this.checkTimer=setTimeout(async()=>{this.checkTimer=null;try{const e=await this.props.socket.getObject(t);e&&!this.state.newExists?this.setState({newExists:!0}):!e&&this.state.newExists&&this.setState({newExists:!1})}catch{this.state.newExists&&this.setState({newExists:!1})}},300)}renderParentSelectorDialog(){return this.state.showParentDialog?y.jsx(ey,{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:t=>this.props.expertMode?!0:t._id.startsWith("0_userdata.0")||t._id.startsWith("javascript."),theme:this.props.theme,onSelectConfirm:(t,e)=>{let i;return Array.isArray(t)?i=t[0]:i=t,i.split(".").length<=1||e[i]&&(e[i].type==="state"||i.startsWith("system."))?Promise.resolve(!1):Promise.resolve(!0)},onClose:()=>this.setState({showParentDialog:!1}),onOk:t=>{let e;Array.isArray(t)?e=t[0]:e=t,e&&e.split(".").length>1&&this.setState({parentId:e})}}):null}render(){const t=`${this.state.parentId}.${this.state.name}`;return y.jsxs(w.Dialog,{open:!0,maxWidth:"md",fullWidth:!0,onClose:()=>this.props.onClose(),children:[this.renderParentSelectorDialog(),this.showHistoryWarning(),y.jsxs(w.DialogTitle,{children:[y.jsxs("span",{style:{opacity:.6,marginRight:8},children:[this.props.t("Rename or copy object")," -"]}),y.jsx("span",{style:{fontWeight:"bold"},children:this.props.id})]}),y.jsxs(w.DialogContent,{children:[y.jsxs("div",{style:{display:"flex",gap:8,alignItems:"end",opacity:.7},children:[y.jsx(w.TextField,{fullWidth:!0,variant:"standard",label:this.props.t("Parent ID"),value:`${this.state.parentId}.`,slotProps:{input:{readOnly:!0}}}),y.jsx(w.Button,{variant:"outlined",style:{maxWidth:40,width:40,height:32},onClick:()=>this.setState({showParentDialog:!0}),children:"..."})]}),y.jsx(w.TextField,{value:this.state.name,onChange:e=>{const i=e.target.value.replace(jt.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?y.jsx(w.FormControlLabel,{control:y.jsx(w.Checkbox,{checked:this.state.renameAllChildren,onChange:()=>{this.setState({renameAllChildren:!this.state.renameAllChildren})}}),label:this.props.t("Rename all children")}):null,y.jsxs("div",{children:[y.jsxs("span",{style:{opacity:.6,marginRight:8,fontSize:16},children:[this.props.t("New object ID"),":"]}),y.jsx("span",{style:{fontWeight:"bold",fontSize:16},children:t})]})]}),y.jsxs(w.DialogActions,{children:[y.jsx(w.Button,{disabled:!this.state.name||t===this.props.id,color:"primary",variant:"outlined",onClick:async()=>{await this.renameCopyObject(this.props.id,t,this.props.childrenIds.length&&this.state.renameAllChildren,!0),this.props.onClose()},children:this.props.t("Create a copy")}),y.jsx(w.Button,{disabled:!this.state.name||t===this.props.id,color:"primary",variant:"contained",onClick:async()=>{await this.checkHistory()&&(await this.renameCopyObject(this.props.id,t,this.props.childrenIds.length&&this.state.renameAllChildren,!1),this.props.onClose())},children:t!==this.props.id&&this.state.newExists?this.props.t("Replace"):this.props.t("Rename")}),y.jsx(w.Button,{variant:"contained",color:"grey",onClick:()=>this.props.onClose(),startIcon:y.jsx(X.Close,{}),children:this.props.t("ra_Cancel")})]})]})}}const LO=X.Delete,vs={buttonAll:{color:"#FF0000"},id:{fontStyle:"italic"},buttonText:{whiteSpace:"nowrap"}};class OO extends at.Component{dialogName;filters;t;wordCache;constructor(t){super(t),this.dialogName="AdminObjects";const e=(window._localStorage||window.localStorage).getItem(`${this.dialogName||"App"}.filters`)||"{}";try{this.filters=JSON.parse(e)}catch{this.filters={}}const i=(window._localStorage||window.localStorage).getItem(`${this.dialogName||"App"}.selected`)||"";this.state={selected:i,name:"",toast:"",deleteObjectShow:null},this.t=this.translate,this.wordCache={}}translate=(t,e,i)=>e!==void 0?this.props.t(t,e,i):(this.wordCache[t]||(this.wordCache[t]=this.props.t(t)),this.wordCache[t]);onDelete(t){const e=this.state.deleteObjectShow.id;t?(this.props.socket.delObjects(e,!0).then(()=>this.setState({toast:this.t("All deleted")})).catch(i=>window.alert(`Cannot delete object: ${i}`)),this.setState({deleteObjectShow:null})):(this.props.socket.delObject(e,!1).catch(i=>window.alert(`Cannot delete object: ${i}`)),this.setState({deleteObjectShow:null}))}renderToast(){return y.jsx(w.Snackbar,{anchorOrigin:{vertical:"bottom",horizontal:"right"},open:!!this.state.toast,autoHideDuration:3e3,onClose:()=>this.setState({toast:""}),message:this.state.toast,action:y.jsx(w.IconButton,{size:"small","aria-label":"close",color:"inherit",onClick:()=>this.setState({toast:""}),children:y.jsx(X.Cancel,{fontSize:"small"})})},"toast")}renderDeleteDialog(){return this.state.deleteObjectShow?y.jsxs(w.Dialog,{maxWidth:"md",open:!0,onClose:()=>this.setState({deleteObjectShow:null}),"aria-labelledby":"delete-object-dialog-title","aria-describedby":"delete-object-dialog-description",children:[y.jsxs(w.DialogTitle,{id:"delete-object-dialog-title",children:[this.state.deleteObjectShow.hasChildren?this.t("Delete object(s)"):this.t("Delete object"),":"," ",y.jsx("span",{style:vs.id,children:this.state.deleteObjectShow.id})]}),y.jsx(w.DialogContent,{children:y.jsx(w.DialogContentText,{children:this.t("Are you sure?")})}),y.jsxs(w.DialogActions,{children:[this.state.deleteObjectShow.hasChildren?y.jsx(w.Button,{variant:"contained",color:"grey",sx:{"& .MuiButton-text":vs.buttonText},onClick:()=>this.onDelete(!0),startIcon:y.jsx(LO,{style:vs.buttonAll}),children:this.t("Delete with children",this.state.deleteObjectShow.childrenCount)}):null,this.state.deleteObjectShow.exists?y.jsx(w.Button,{variant:"contained",sx:{"& .MuiButton-text":vs.buttonText},onClick:()=>this.onDelete(!1),color:"primary",startIcon:y.jsx(X.Delete,{}),autoFocus:!0,children:this.t("Delete one item")}):null,y.jsx(w.Button,{variant:"contained",color:"grey",onClick:()=>this.setState({deleteObjectShow:null}),startIcon:y.jsx(X.Cancel,{}),children:this.t("ra_Cancel")})]})]},"delete"):null}render(){return[this.renderToast(),y.jsx(Qx,{dialogName:"admin",objectsWorker:this.props.objectsWorker,prefix:this.props.prefix,defaultFilters:this.filters,statesOnly:this.props.statesOnly,style:{width:"100%",height:"100%"},socket:this.props.socket,selected:this.state.selected,name:this.state.name,expertMode:this.props.expertMode,isFloatComma:this.props.isFloatComma,dateFormat:this.props.dateFormat,t:this.t,lang:this.props.lang,themeName:this.props.themeName,themeType:this.props.themeType,theme:this.props.theme,objectCustomDialog:wO,objectBrowserValue:Dn,objectBrowserEditObject:Ht,objectBrowserEditRole:md,objectBrowserViewFile:PO,objectBrowserAliasEditor:RO,objectMoveRenameDialog:yd,router:yh,enableStateValueEdit:!0,onObjectDelete:(t,e,i,n)=>this.setState({deleteObjectShow:{id:t,hasChildren:e,exists:i,childrenCount:n}}),onFilterChanged:t=>{this.filters=t,(window._localStorage||window.localStorage).setItem(`${this.dialogName||"App"}.filters`,JSON.stringify(t))},onSelect:t=>{Array.isArray(t)?(window._localStorage||window.localStorage).setItem(`${this.dialogName||"App"}.selected`,t[0]||""):(window._localStorage||window.localStorage).setItem(`${this.dialogName||"App"}.selected`,t||"")},objectEditBoolean:!0,objectAddBoolean:!0,objectStatesView:!0,objectImportExport:!0,objectEditOfAccessControl:!0,modalNewObject:t=>y.jsx(AO,{objects:t.objects,expertMode:this.props.expertMode,setObject:(e,i)=>this.props.socket.setObject(e,i).catch(n=>window.alert(n)),selected:t.state.modalNewObj.id,initialType:t.state.modalNewObj.initialType,initialStateType:t.state.modalNewObj.initialStateType,onClose:()=>t.setState({modalNewObj:null}),onApply:()=>t.setState({modalNewObj:null})}),modalEditOfAccessControl:(t,e)=>y.jsx(DO,{theme:this.props.theme,themeType:this.props.themeType,extendObject:(i,n)=>{this.props.socket.extendObject(i,n).catch(a=>window.alert(a)),e.aclTooltip=null},selected:t.state.selected[0],modalEmptyId:e.obj?"":e.id,objects:t.objects,t:this.t,onClose:()=>t.setState({modalEditOfAccess:!1,modalEditOfAccessObjData:null}),onApply:()=>t.setState({modalEditOfAccess:!1,modalEditOfAccessObjData:null})})},"browser"),this.renderDeleteDialog()]}}const tE=Wn()(OO);export{tE as default};
60
+ ${o.getFullYear()}`}}},yAxis:i,toolbox:{left:"right",feature:this.props.noToolbar?void 0:{saveAsImage:{title:this.props.t("Save as image"),show:!0}}},series:[e]}}static getDerivedStateFromProps(t,e){return null}updateChart(t,e,i,n){t&&(this.start=t),e&&(this.end=e),t=t||this.start,e=e||this.end,this.readTimeout&&clearTimeout(this.readTimeout),this.readTimeout=setTimeout(()=>{var o;this.readTimeout=null;const a=this.chart.max-this.chart.min;a!==this.chart.diff&&(this.chart.diff=a,this.chart.withTime=this.chart.diff<36e5*24*7,this.chart.withSeconds=this.chart.diff<6e4*30),i?this.readHistory(t,e).then(s=>{var l;typeof((l=this.echartsReact)==null?void 0:l.getEchartsInstance)=="function"&&this.echartsReact.getEchartsInstance().setOption({series:[{data:this.convertData(s)}],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(t){var e;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((e=this.echartsReact)==null?void 0:e.getEchartsInstance)=="function"&&(this.echartsReact.getEchartsInstance().setOption({xAxis:{min:this.chart.min,max:this.chart.max}}),t&&this.updateChart(this.chart.min,this.chart.max,!0))}shiftTime(){const t=new Date,e=6e4-t.getSeconds()-(1e3-t.getMilliseconds());t.getMilliseconds()&&t.setMilliseconds(1e3),t.getSeconds()&&t.setSeconds(60);const i=t.getTime();let n;const a=this.state.relativeRange;if(a==="day")t.setHours(0),t.setMinutes(0),t.setSeconds(0),n=t.getTime();else if(a==="week"){t.setHours(0),t.setMinutes(0),t.setSeconds(0);const o=t.getDay()||7;o!==1&&t.setHours(-24*(o-1)),n=t.getTime()}else if(a==="2weeks"){t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setDate(t.getDate()-7);const o=t.getDay()||7;o!==1&&t.setHours(-24*(o-1)),n=t.getTime()}else a==="month"?(t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setDate(1),n=t.getTime()):a==="year"?(t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setDate(1),t.setMonth(0),n=t.getTime()):a==="12months"?(t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setFullYear(t.getFullYear()-1),n=t.getTime()):n=i-parseInt(a,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()},e||6e4)}setRelativeInterval(t,e,i){if(e||(this.localStorage.setItem("App.relativeRange",t),this.setState({relativeRange:t})),t==="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 a=6e4-n.getSeconds()-(1e3-n.getMilliseconds());this.timeTimer=setTimeout(()=>{this.timeTimer=null,this.shiftTime()},a||6e4)}if(n.getMilliseconds()&&n.setMilliseconds(1e3),n.getSeconds()&&n.setSeconds(60),this.chart.max=n.getTime(),t==="day")n.setHours(0),n.setMinutes(0),n.setSeconds(0),this.chart.min=n.getTime();else if(t==="week"){n.setHours(0),n.setMinutes(0),n.setSeconds(0);const a=n.getDay()||7;a!==1&&n.setHours(-24*(a-1)),this.chart.min=n.getTime()}else if(t==="2weeks"){n.setHours(0),n.setMinutes(0),n.setSeconds(0),n.setDate(n.getDate()-7);const a=n.getDay()||7;a!==1&&n.setHours(-24*(a-1)),this.chart.min=n.getTime()}else t==="month"?(n.setHours(0),n.setMinutes(0),n.setSeconds(0),n.setDate(1),this.chart.min=n.getTime()):t==="year"?(n.setHours(0),n.setMinutes(0),n.setSeconds(0),n.setDate(1),n.setMonth(0),this.chart.min=n.getTime()):t==="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(t,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 t=this.echartsReact.getEchartsInstance().getZr();t._iobInstalled||(t._iobInstalled=!0,t.on("mousedown",e=>{console.log("mouse down"),this.mouseDown=!0,this.chart.lastX=e.offsetX}),t.on("mouseup",()=>{console.log("mouse up"),this.mouseDown=!1,this.setNewRange(!0)}),t.on("mousewheel",e=>{let i=this.chart.max-this.chart.min;const n=this.state.chartWidth-Mi-he,o=(e.offsetX-he)/n,s=i,l=e.wheelDelta>0?1.1:.9;i*=l;const u=s-i;this.chart.max+=u*(1-o),this.chart.min-=u*o,this.setNewRange()}),t.on("mousemove",e=>{if(this.mouseDown){const i=this.chart.lastX-(e.offsetX-he);this.chart.lastX=e.offsetX-he;const n=this.chart.max-this.chart.min,a=this.state.chartWidth-Mi-he,o=Math.round(i*n/a);this.chart.min+=o,this.chart.max+=o,this.setNewRange()}}),t.on("touchstart",e=>{e.preventDefault(),this.mouseDown=!0;const i=e.touches||e.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)}),t.on("touchend",e=>{e.preventDefault(),this.mouseDown=!1,this.setNewRange(!0)}),t.on("touchmove",e=>{e.preventDefault();const i=e.touches||e.originalEvent.touches;if(!i)return;const n=i[i.length-1].pageX-he;if(this.mouseDown)if(i.length>1){const a=Math.abs(i[0].pageX-i[1].pageX);if(this.chart.lastWidth!==null&&a!==this.chart.lastWidth){let o=this.chart.max-this.chart.min;const s=this.state.chartWidth-Mi-he,l=a>this.chart.lastWidth?1.1:.9,h=(i[0].pageX>i[1].pageX?i[1].pageX-he+a/2:i[0].pageX-he+a/2)/s,c=o;o*=l;const f=c-o;this.chart.max+=f*(1-h),this.chart.min-=f*h,this.setNewRange()}this.chart.lastWidth=a}else{const a=this.chart.lastX-n,o=this.chart.max-this.chart.min,s=this.state.chartWidth-Mi-he,l=Math.round(a*o/s);this.chart.min+=l,this.chart.max+=l,this.setNewRange()}this.chart.lastX=n}))}renderChart(){var t;return this.state.historyInstance?(t=this.state.historyInstances)!=null&&t.find(e=>e.id===this.state.historyInstance&&e.alive)?this.chartValues?y.jsx(Uw,{ref:e=>this.echartsReact=e,echarts:gP,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()}}):y.jsx(w.LinearProgress,{}):y.jsx("div",{style:{marginTop:20,fontSize:24,marginLeft:24},children:this.props.t("History instance not alive")}):y.jsx("div",{style:{marginTop:20,fontSize:24,marginLeft:24},children:this.props.t("History instance not selected")})}componentDidUpdate(){if(this.divRef.current){const t=this.divRef.current.offsetWidth,e=this.divRef.current.offsetHeight;this.state.chartHeight!==e&&(this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.updateTimer=null,this.setState({chartHeight:e,chartWidth:t})},100))}}setStartDate(t){const e=t.getTime();this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=null),this.localStorage.setItem("App.relativeRange","absolute"),this.localStorage.setItem("App.absoluteStart",e.toString()),this.localStorage.setItem("App.absoluteEnd",this.state.max.toString()),this.chart.min=e,this.setState({min:e,relativeRange:"absolute"},()=>this.updateChart(this.chart.min,this.chart.max,!0))}setEndDate(t){const e=t.getTime();this.localStorage.setItem("App.relativeRange","absolute"),this.localStorage.setItem("App.absoluteStart",this.state.min.toString()),this.localStorage.setItem("App.absoluteEnd",e.toString()),this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=null),this.chart.max=e,this.setState({max:e,relativeRange:"absolute"},()=>this.updateChart(this.chart.min,this.chart.max,!0))}openEcharts(){const t=[`id=${window.encodeURIComponent(this.props.obj._id)}`,`instance=${window.encodeURIComponent(this.state.historyInstance)}`,"menuOpened=false"];this.state.relativeRange==="absolute"?(t.push(`start=${this.chart.min}`),t.push(`end=${this.chart.max}`)):t.push(`range=${this.state.relativeRange}`),window.open(`${window.location.protocol}//${window.location.host}/adapter/echarts/tab.html#${t.join("&")}`,"echarts")}async onStepChanged(t){const e=await this.props.socket.getObject(this.props.obj._id);e.common.custom&&e.common.custom[this.state.historyInstance]&&e.common.custom[this.state.historyInstance].chartStep!==t&&(e.common.custom[this.state.historyInstance].chartStep=t,await this.props.socket.setObject(e._id,e)),this.setState({stepType:t,showStepMenu:null})}renderToolbar(){return this.props.noToolbar?null:y.jsxs(w.Toolbar,{children:[!this.props.historyInstance&&y.jsxs(w.FormControl,{variant:"standard",style:Et.selectHistoryControl,children:[y.jsx(w.InputLabel,{children:this.props.t("History instance")}),y.jsx(w.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=>y.jsx(w.MenuItem,{value:t.id,style:t.alive?void 0:Et.notAliveInstance,children:t.id},t.id))})]}),y.jsxs(w.FormControl,{variant:"standard",style:Et.selectRelativeTime,children:[y.jsx(w.InputLabel,{children:this.props.t("Relative")}),y.jsxs(w.Select,{variant:"standard",ref:this.rangeRef,value:this.state.relativeRange,onChange:t=>this.setRelativeInterval(t.target.value),children:[y.jsx(w.MenuItem,{value:"absolute",sx:Et.customRange,children:this.props.t("custom range")},"custom"),y.jsx(w.MenuItem,{value:10,children:this.props.t("last 10 minutes")},"1"),y.jsx(w.MenuItem,{value:30,children:this.props.t("last 30 minutes")},"2"),y.jsx(w.MenuItem,{value:60,children:this.props.t("last hour")},"3"),y.jsx(w.MenuItem,{value:"day",children:this.props.t("this day")},"4"),y.jsx(w.MenuItem,{value:24*60,children:this.props.t("last 24 hours")},"5"),y.jsx(w.MenuItem,{value:"week",children:this.props.t("this week")},"6"),y.jsx(w.MenuItem,{value:24*60*7,children:this.props.t("last week")},"7"),y.jsx(w.MenuItem,{value:"2weeks",children:this.props.t("this 2 weeks")},"8"),y.jsx(w.MenuItem,{value:24*60*14,children:this.props.t("last 2 weeks")},"9"),y.jsx(w.MenuItem,{value:"month",children:this.props.t("this month")},"10"),y.jsx(w.MenuItem,{value:30*24*60,children:this.props.t("last 30 days")},"11"),y.jsx(w.MenuItem,{value:"year",children:this.props.t("this year")},"12"),y.jsx(w.MenuItem,{value:"12months",children:this.props.t("last 12 months")},"13")]})]}),y.jsxs(qt.LocalizationProvider,{dateAdapter:ks,adapterLocale:Os[this.props.lang],children:[y.jsxs("div",{style:Et.toolbarTimeGrid,children:[y.jsx("div",{style:{...Et.toolbarTimeLabel,opacity:this.state.relativeRange!=="absolute"?.5:void 0},children:this.props.t("Start time")}),y.jsx(qt.DatePicker,{sx:Et.toolbarDate,disabled:this.state.relativeRange!=="absolute",value:new Date(this.state.min),onChange:t=>this.setStartDate(t)}),y.jsx(qt.TimePicker,{disabled:this.state.relativeRange!=="absolute",sx:Et.toolbarTime,ampm:this.state.ampm,value:new Date(this.state.min),onChange:t=>this.setStartDate(t)})]}),y.jsxs("div",{style:Et.toolbarTimeGrid,children:[y.jsx("div",{style:{...Et.toolbarTimeLabel,opacity:this.state.relativeRange!=="absolute"?.5:void 0},children:this.props.t("End time")}),y.jsx(qt.DatePicker,{disabled:this.state.relativeRange!=="absolute",sx:Et.toolbarDate,value:new Date(this.state.max),onChange:t=>this.setEndDate(t)}),y.jsx(qt.TimePicker,{disabled:this.state.relativeRange!=="absolute",sx:Et.toolbarTime,ampm:this.state.ampm,value:new Date(this.state.max),onChange:t=>this.setEndDate(t)})]})]}),y.jsx("div",{style:Et.grow}),y.jsx(w.Button,{style:{marginRight:10},variant:"outlined",onClick:t=>this.setState({showStepMenu:t.target}),children:this.state.stepType?this.props.t(this.state.stepType):this.props.t("Step type")}),this.state.showStepMenu?y.jsxs(w.Menu,{open:!0,anchorEl:this.state.showStepMenu,onClose:()=>this.setState({showStepMenu:null}),children:[y.jsx(w.MenuItem,{selected:this.state.stepType==="",onClick:()=>this.onStepChanged(""),children:this.props.t("None")}),y.jsx(w.MenuItem,{selected:this.state.stepType==="stepStart",onClick:()=>this.onStepChanged("stepStart"),children:this.props.t("stepStart")})]}):null,this.props.showJumpToEchart&&this.state.echartsJump&&y.jsx(w.Fab,{style:Et.echartsButton,size:"small",onClick:()=>this.openEcharts(),title:this.props.t("Open charts in new window"),children:y.jsx("img",{src:bO,alt:"echarts",style:Et.buttonIcon})}),y.jsxs(w.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:[y.jsx(nw,{style:Et.splitLineButtonIcon}),this.props.t("Show lines")]})]})}render(){return!this.state.historyInstances&&!this.state.defaultHistory?y.jsx(w.LinearProgress,{}):y.jsxs(w.Paper,{style:Et.paper,children:[this.renderToolbar(),y.jsx("div",{ref:this.divRef,style:jt.getStyle(this.props.theme,Et.chart,this.props.noToolbar?Et.chartWithoutToolbar:Et.chartWithToolbar),children:this.renderChart()})]})}}const Wx=Wn()(xO),rr={dialog:{height:"100%"},paper:{height:"calc(100% - 64px)"},content:{textAlign:"center",overflow:"hidden"},tabPanel:r=>({width:"100%",overflow:"hidden",height:`calc(100% - ${r.mixins.toolbar.minHeight}px)`}),tabSelected:r=>({color:r.palette.mode==="dark"?r.palette.secondary.contrastText:"#FFFFFF !important"}),tabsIndicator:r=>({backgroundColor:r.palette.secondary.main})};class wO extends Cd{chartAvailable;saveFunc=null;constructor(t){super(t);let e=parseInt((window._localStorage||window.localStorage).getItem("App.objectCustomTab")||"0",10);if(this.chartAvailable=this.isChartAvailable(),this.chartAvailable){const i=yh.getLocation();i.arg==="chart"?e=2:i.arg==="table"&&(e=1)}else e=0;this.state={hasChanges:!1,currentTab:e,confirmDialog:!1,mobile:Cd.isMobile(),progressRunning:!1,showWarning:this.props.allVisibleObjects}}isChartAvailable(){var e,i;let t=this.props.objectIDs.length===1;if(t){const n=this.props.objectIDs[0];(i=(e=this.props.objects[n])==null?void 0:e.common)!=null&&i.custom?t=!!Object.keys(this.props.objects[n].common.custom).find(a=>{const o=this.props.objects[`system.adapter.${a}`];return o&&o.common&&o.common.getHistory}):t=!1}return t}renderCharts(){return y.jsx(Wx,{id:"custom-tabpanel-chart",isFloatComma:this.props.isFloatComma,showJumpToEchart:!0,t:this.props.t,lang:this.props.lang,expertMode:this.props.expertMode,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 y.jsx(dw,{id:"custom-tabpanel-history",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,themeName:this.props.themeName,objects:this.props.objects})}renderCustomEditor(){return y.jsx(lw,{id:"custom-tabpanel-settings",registerSaveFunc:t=>this.saveFunc=t,t:this.props.t,allVisibleObjects:this.props.allVisibleObjects,lang:this.props.lang,expertMode:this.props.expertMode,socket:this.props.socket,objectIDs:this.props.objectIDs,customsInstances:this.props.customsInstances,objects:this.props.objects,onProgress:t=>this.setState({progressRunning:t}),reportChangedIds:this.props.reportChangedIds,onChange:(t,e)=>{this.setState({hasChanges:t},()=>{if(e){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?y.jsx(mh,{title:G.t("You have unsaved changes"),text:G.t("Discard?"),ok:G.t("Yes"),cancel:G.t("Cancel"),onClose:t=>this.setState({confirmDialog:!1},()=>t&&this.props.onClose())}):null}onClose(){this.state.hasChanges?this.setState({confirmDialog:!0}):this.props.onClose()}renderWarningDialog(){return this.state.showWarning?y.jsx(mh,{text:y.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:t=>{this.setState({showWarning:!1}),t||this.onClose()}}):null}render(){var e,i;const t=(i=(e=this.props.objects[this.props.objectIDs[0]])==null?void 0:e.common)==null?void 0:i.type;return y.jsxs(w.Dialog,{sx:{"&.MuiDialog-scrollPaper":rr.dialog,"& .MuiDialog-paper":rr.paper},scroll:"paper",open:!0,onClose:()=>this.props.onClose(),fullWidth:!0,maxWidth:"xl","aria-labelledby":"form-dialog-title",children:[this.renderDialogConfirm(),this.renderWarningDialog(),y.jsx(w.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])}),y.jsxs(w.DialogContent,{style:rr.content,children:[y.jsx(w.AppBar,{position:"static",children:y.jsxs(w.Tabs,{value:this.state.currentTab,onChange:(n,a)=>{yh.doNavigate(null,null,null,a===1?"table":a===2?"chart":"config"),this.setState({currentTab:a}),(window._localStorage||window.localStorage).setItem("App.objectCustomTab",a)},sx:{"& .MuiTabs-indicator":rr.tabsIndicator},indicatorColor:"secondary",children:[y.jsx(w.Tab,{disabled:this.state.progressRunning,label:this.props.t("Custom settings"),id:"custom-settings-tab","aria-controls":"custom-tabpanel-settings",sx:{"&.Mui-selected":rr.tabSelected}}),this.props.objectIDs.length===1&&this.chartAvailable?y.jsx(w.Tab,{disabled:this.state.progressRunning,label:this.props.t("History data"),id:"history-data-tab","aria-controls":"custom-tabpanel-history",sx:{"&.Mui-selected":rr.tabSelected}}):null,(t==="number"||t==="boolean")&&this.props.objectIDs.length===1&&this.chartAvailable?y.jsx(w.Tab,{disabled:this.state.progressRunning,label:this.props.t("Chart"),id:"chart-tab","aria-controls":"custom-tabpanel-chart",sx:{"&.Mui-selected":rr.tabSelected}}):null]})}),this.state.currentTab===0?y.jsx(w.Box,{component:"div",sx:rr.tabPanel,children:this.renderCustomEditor()}):null,this.props.objectIDs.length===1&&this.chartAvailable&&this.state.currentTab===1?y.jsx(w.Box,{component:"div",sx:rr.tabPanel,children:this.renderTable()}):null,(t==="number"||t==="boolean")&&this.props.objectIDs.length===1&&this.chartAvailable&&this.state.currentTab===2?y.jsx(w.Box,{component:"div",sx:rr.tabPanel,children:this.renderCharts()}):null]}),y.jsxs(w.DialogActions,{children:[this.state.currentTab===0&&y.jsx(w.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(y.jsx(X.Save,{}),this.props.t("Save"))}),this.state.currentTab===0&&y.jsx(w.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(y.jsx(X.Save,{}),this.props.t("Save & close"),y.jsx(X.Close,{}))}),y.jsx(w.Button,{id:"object-custom-dialog-close",disabled:this.state.progressRunning,variant:"contained",onClick:()=>this.onClose(),color:"grey",children:this.getButtonTitle(y.jsx(X.Close,{}),this.props.t("Close"))})]})]})}}const ve={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 Dn extends at.Component{propsValue;chartFrom;ack;inputRef=vh.createRef();q;expire;constructor(t){super(t);let e=this.props.type;e||(e=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)e="states";else if(e==="string"||e==="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,e="json"}catch{}}else e==="number"&&(i=parseFloat(this.propsValue)||0);this.state={type:e,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=vh.createRef(),this.chartFrom=Date.now()-36e5*2}componentDidMount(){var t,e,i;this.props.defaultHistory&&((e=(t=this.props.object)==null?void 0:t.common)!=null&&e.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 a=this.inputRef.current,o=a.value||"",s=a.type;a.type==="number"&&(a.type="text"),a.setSelectionRange(0,o.length),s==="number"&&(a.type=s)}},200)}onUpdate(t){t&&(t.stopPropagation(),t.preventDefault());let e=this.state.targetValue;if(this.state.type==="states")if(e==="null")e=null;else{const i=this.props.type||typeof this.state.targetValue;e=typeof e=="object"?e.value:e,i==="number"?typeof e=="string"&&(e=parseFloat(e.replace(",","."))||0):i==="boolean"&&(e=e===!0||e==="true"||e==="1"||e==="ON"||e==="on")}else this.state.type==="number"?e==="null"?e=null:typeof e=="string"&&(e=parseFloat(e.replace(",","."))||0):this.state.type==="boolean"&&(e==="null"?e=null:e=e===!0||e==="true"||e==="1"||e==="ON"||e==="on");this.props.onClose({val:e,ack:this.ack,q:this.q,expire:parseInt(this.expire,10)||void 0})}static isNumberValid(t){const{common:e,value:i}=t;if(i==="")return!1;const n=Number(i);return typeof e.min=="number"&&n<e.min?!1:!(typeof e.max=="number"&&n>e.max)}renderTimePicker(){return y.jsxs(qt.LocalizationProvider,{adapterLocale:Os[this.props.lang],dateAdapter:ks,children:[y.jsx(qt.DatePicker,{value:Number(this.state.targetValue),onChange:t=>{t&&this.setState({targetValue:Math.round(t.getTime())})}}),y.jsx(qt.TimePicker,{value:Number(this.state.targetValue),views:["hours","minutes","seconds"],onChange:t=>{t&&this.setState({targetValue:Math.round(t.getTime())})}})]})}renderChart(){return y.jsx(Wx,{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,dateFormat:this.props.dateFormat,defaultHistory:this.props.defaultHistory})}static checkJsonError(t){try{return JSON.parse(t),!1}catch{return!0}}renderJsonEditor(){return y.jsx(ty,{error:this.state.jsonError,editValueMode:!0,themeType:this.props.themeType,defaultValue:(this.propsValue||"").toString(),onChange:t=>this.setState({targetValue:t,jsonError:Dn.checkJsonError(t)})})}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 t=Object.keys(this.props.states).map(e=>({label:this.props.states[e],value:e}));return y.jsx(w.Autocomplete,{style:ve.formControl,disablePortal:!0,defaultValue:this.props.states[this.propsValue]!==void 0?this.props.states[this.propsValue]:this.propsValue,options:t,noOptionsText:"",freeSolo:!0,getOptionLabel:e=>(e==null?void 0:e.label)||(e!=null?e.toString():""),onChange:(e,i)=>this.setState({targetValue:i}),onInputChange:(e,i)=>this.setState({targetValue:i}),onKeyUp:e=>e.key==="Enter"&&this.onUpdate(e),renderInput:e=>y.jsx(w.TextField,{...e,label:this.props.t("Value"),variant:"standard"})})}return y.jsxs(w.FormControl,{variant:"standard",style:ve.formControl,children:[y.jsx(w.InputLabel,{children:this.props.t("Value")}),y.jsx(w.Select,{variant:"standard",defaultValue:this.propsValue,onChange:t=>this.setState({targetValue:t.target.value}),children:Object.keys(this.props.states).map((t,e)=>y.jsx(w.MenuItem,{value:t,children:this.props.states[t]},e))})]})}render(){var e,i,n;const t=y.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[y.jsx(w.FormControlLabel,{style:{...ve.formControl,...this.props.expertMode?void 0:ve.ackCheckbox},control:y.jsx(w.Checkbox,{defaultChecked:!1,onChange:a=>this.ack=a.target.checked}),label:this.props.t("Acknowledged")}),y.jsx(w.Tooltip,{title:this.props.t("Acknowledged explanation"),slotProps:{popper:{sx:ve.tooltip}},children:y.jsx(X.Info,{color:"primary"})})]});return y.jsxs(w.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"?ve.dialog:void 0},children:[y.jsxs(w.DialogTitle,{id:"edit-value-dialog-title",children:[this.props.t("Write value"),((e=this.props.object.common)==null?void 0:e.write)===!1?y.jsxs("span",{style:ve.readOnlyText,children:["(",this.props.t("read only"),")"]}):null,this.state.chart?y.jsx(w.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:y.jsx(X.ShowChart,{})}):null,this.state.type==="json"?y.jsx(w.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?y.jsx(X.FullscreenExit,{}):y.jsx(X.Fullscreen,{})}):null]}),y.jsx(w.DialogContent,{children:y.jsx("form",{noValidate:!0,autoComplete:"off",onSubmit:()=>!1,style:{...ve.dialogForm,height:"100%"},children:y.jsxs(w.Grid2,{container:!0,direction:"row",spacing:2,style:{height:"100%"},children:[y.jsx(w.Grid2,{size:{xs:this.state.chart&&this.state.chartEnabled?6:12},style:{height:"100%"},children:y.jsxs(w.Grid2,{container:!0,direction:"column",spacing:2,style:{marginTop:0,height:"100%"},children:[this.props.expertMode?y.jsx(w.Grid2,{children:y.jsxs(w.Grid2,{container:!0,direction:"row",spacing:2,style:{marginTop:0},children:[this.props.expertMode?y.jsx(w.Grid2,{children:y.jsxs(w.FormControl,{style:ve.formControl,children:[y.jsx(w.InputLabel,{style:{marginTop:10,marginLeft:-14},children:this.props.t("Value type")}),y.jsxs(w.Select,{variant:"standard",value:this.state.type,onChange:a=>{this.setState({type:a.target.value,valid:a.target.value==="number"?Dn.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:Dn.checkJsonError((this.state.targetValue||"").toString())})})},children:[y.jsx(w.MenuItem,{value:"string",children:"String"}),y.jsx(w.MenuItem,{value:"number",children:"Number"}),y.jsx(w.MenuItem,{value:"boolean",children:"Boolean"}),y.jsx(w.MenuItem,{value:"json",children:"JSON"}),this.props.states?y.jsx(w.MenuItem,{value:"states",children:"States"}):null]})]})}):null,this.state.type==="json"?y.jsx(w.Grid2,{flex:1}):null]})}):null,y.jsx(w.Grid2,{flex:this.state.type==="json"&&this.state.fullScreen?1:void 0,style:{paddingTop:0},children:this.state.type==="boolean"?y.jsx(w.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:y.jsxs(w.Grid2,{component:"label",container:!0,alignItems:"center",spacing:1,children:[y.jsxs(w.Grid2,{style:{marginRight:10},children:[this.props.t("Value"),":"]}),y.jsx(w.Grid2,{children:"FALSE"}),y.jsx(w.Grid2,{children:y.jsx(w.Switch,{autoFocus:!0,defaultChecked:this.propsValue==="null"||this.propsValue==="undefined"?!1:!!this.propsValue,onKeyUp:a=>a.key==="Enter"&&this.onUpdate(a),onChange:a=>this.setState({targetValue:a.target.checked})})}),y.jsx(w.Grid2,{children:"TRUE"})]})}):this.state.type==="number"?y.jsx(w.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:a=>a.key==="Enter"&&this.state.valid&&this.onUpdate(a),onChange:a=>{this.setState({targetValue:a.target.value,valid:Dn.isNumberValid({value:a.target.value,common:this.props.object.common})})}}):this.state.type==="json"?this.renderJsonEditor():this.state.type==="states"?this.renderStates():y.jsx(w.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:a=>a.ctrlKey&&a.key==="Enter"&&this.onUpdate(a),defaultValue:this.propsValue.toString(),onChange:a=>this.setState({targetValue:a.target.value})})}),(this.props.role==="date"||(i=this.props.role)!=null&&i.startsWith("date."))&&this.state.type==="number"?y.jsx(w.Grid2,{style:{display:"flex",gap:"5px"},size:{xs:6},children:this.renderTimePicker()}):null,this.props.expertMode?y.jsx(w.Grid2,{children:t}):null,this.props.expertMode?y.jsxs(w.Grid2,{children:[y.jsxs(w.FormControl,{variant:"standard",style:ve.quality,children:[y.jsx(w.InputLabel,{children:this.props.t("Quality")}),y.jsxs(w.Select,{variant:"standard",defaultValue:0,onChange:a=>this.q=Number(a.target.value),children:[y.jsx(w.MenuItem,{value:0,children:"0x00 - good"}),y.jsx(w.MenuItem,{value:1,children:"0x01 - general problem"}),y.jsx(w.MenuItem,{value:2,children:"0x02 - no connection problem"}),y.jsx(w.MenuItem,{value:16,children:"0x10 - substitute value from controller"}),y.jsx(w.MenuItem,{value:32,children:"0x20 - substitute initial value"}),y.jsx(w.MenuItem,{value:64,children:"0x40 - substitute value from device or instance"}),y.jsx(w.MenuItem,{value:128,children:"0x80 - substitute value from sensor"}),y.jsx(w.MenuItem,{value:17,children:"0x11 - general problem by instance"}),y.jsx(w.MenuItem,{value:65,children:"0x41 - general problem by device"}),y.jsx(w.MenuItem,{value:129,children:"0x81 - general problem by sensor"}),y.jsx(w.MenuItem,{value:18,children:"0x12 - instance not connected"}),y.jsx(w.MenuItem,{value:66,children:"0x42 - device not connected"}),y.jsx(w.MenuItem,{value:130,children:"0x82 - sensor not connected"}),y.jsx(w.MenuItem,{value:68,children:"0x44 - device reports error"}),y.jsx(w.MenuItem,{value:132,children:"0x84 - sensor reports error"})]})]}),y.jsx(w.TextField,{variant:"standard",title:this.props.t("0 - no expiration"),sx:{"&.MuiTextField-root":ve.expire},label:this.props.t("Expire"),type:"number",slotProps:{htmlInput:{min:0}},helperText:this.props.t("in seconds"),defaultValue:this.expire,onChange:a=>this.expire=Number(a.target.value)})]}):null]})}),this.state.chart&&this.state.chartEnabled&&this.state.type!=="json"?y.jsx(w.Grid2,{size:{xs:6},style:{minHeight:300},sx:{display:{sm:"none",md:"inline-block"}},children:this.renderChart()}):null]})})}),y.jsxs(w.DialogActions,{sx:ve.wrapperButton,children:[this.props.expertMode?null:t,this.props.expertMode?null:y.jsx("div",{style:{flexGrow:1}}),y.jsx(w.Button,{variant:"contained",disabled:!this.state.valid,onClick:a=>this.onUpdate(a),color:"primary",startIcon:this.props.width!=="xs"?y.jsx(X.Check,{}):void 0,style:((n=this.props.object.common)==null?void 0:n.write)===!1?ve.readOnly:void 0,children:this.props.width!=="xs"?this.props.t("Set value"):y.jsx(X.Check,{fontSize:"large"})}),y.jsx(w.Button,{variant:"contained",onClick:()=>this.props.onClose(),color:"grey",startIcon:this.props.width!=="xs"?y.jsx(X.Close,{}):void 0,children:this.props.width!=="xs"?this.props.t("Cancel"):y.jsx(X.Close,{fontSize:"large"})})]})]})}}const O={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,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 SO(r,t){return{"@keyframes newStateEditorAnimation":{"0%":{color:r.palette.mode==="dark"?"#27cf00":"#174e00"},"100%":{color:t||(r.palette.mode==="dark"?"#ffffff":"#000000")}}}}const yo=[{role:"button",type:"boolean",r:!1,w:!0},{role:"button.close.blind",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.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.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:"string"},{role:"date",type:"number"},{role:"date.end",type:"string"},{role:"date.end",type:"number"},{role:"date.forecast.1",type:"string"},{role:"date.start",type:"string"},{role:"date.start",type:"number"},{role:"date.sunrise",type:"string"},{role:"date.sunrise",type:"number"},{role:"date.sunset",type:"string"},{role:"date.sunset",type:"number"},{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.name",type:"string",w:!1},{role:"info.port",type:"string",w:!1},{role:"info.port",type:"number",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.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.saturation",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:"string"},{role:"list",type:"array"},{role:"location",type:"string"},{role:"media.add",type:"string"},{role:"media.bitrate",type:"string"},{role:"media.bitrate",type:"number"},{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.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:"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.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:"url",type:"string"},{role:"url.audio",type:"string"},{role:"url.blank",type:"string"},{role:"url.cam",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.clouds",type:"number",w:!1},{role:"value.current",type:"number",w:!1},{role:"value.curtain",type:"number",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.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.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.prepitation.forecast.0",type:"number",w:!1},{role:"value.prepitation.forecast.1",type:"number",w:!1},{role:"value.prepitation.forecast.1",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:"waether.title",type:"string",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.state.forecast.1",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 Ht extends at.Component{originalObj;subscribed=!1;updateTimer=null;constructor(t){super(t);const e=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";i==="alias"&&!e&&(i="common"),this.props.aliasTab&&e&&(i="alias");const n=this.props.obj,a=n.common&&"type"in n.common&&"alias"in n.common?n.common.alias.read:void 0,o=n.common&&"type"in n.common&&"alias"in n.common?n.common.alias.write:void 0;this.state={text:JSON.stringify(this.props.obj,null,2),error:!1,customError:!1,changed:!1,readError:this.checkFunction(a,!1),writeError:this.checkFunction(o,!0),tab:i,showCopyDialog:"",showCommonDeleteMessage:!1,selectId:!1,selectRead:!1,selectWrite:!1,newId:"",lang:G.getLanguage(),value:void 0},Ul.locale(this.state.lang),this.originalObj=JSON.stringify(this.props.obj,null,2)}async componentDidMount(){var i,n,a;const t=((n=(i=this.props.obj)==null?void 0:i.common)==null?void 0:n.editSchemas)||((a=this.props.obj)==null?void 0:a.editSchemas),e=[];if(t)if(typeof t=="object"){const o=Object.keys(t);for(let s=0;s<o.length;s++)try{const l=await Td(t[o[s]],this.props.socket);if(l.key=o[s],l&&typeof l=="object"&&e.push(l),l.icon)try{const u=qx(l.icon);if(u.type!=="base64"&&u.type!=="http"){const h=await Td(u,this.props.socket);h&&(l.icon=h)}}catch(u){console.warn(`Cannot get icon for schema from "${l.icon}": ${u}`),l.icon=void 0}}catch(l){console.warn(`Cannot get edit schema for "${t[o[s]]}": ${l}`)}e.length&&(e.sort((s,l)=>s.order!==void 0&&l.order!==void 0?s.order-l.order:s.order!==void 0?-1:l.order!==void 0||s.key>l.key?1:-1),this.setState({customEditTabs:e}))}else console.warn(`Invalid edit schema for "${t}": expected object, but got ${typeof t}`);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"&&!e.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)}componentWillUnmount(){this.updateTimer&&(clearInterval(this.updateTimer),this.updateTimer=null),this.subscribeOnState(!1),this.props.socket.unsubscribeObject(this.props.obj._id,this.onObjectUpdated)}onObjectUpdated=(t,e)=>{this.originalObj!==JSON.stringify(e,null,2)&&(this.originalObj=JSON.stringify(e,null,2),this.state.changed?this.forceUpdate():this.setState({text:this.originalObj}))};checkFunction(t,e){var a,o,s,l;if(!t||t.includes("JSON.parse("))return"";let i;try{i=JSON.parse(this.state.text)}catch{}let n;try{n=new Function("val",t.includes("return")?t:`return ${t}`)}catch{return this.props.t("Cannot parse code!")}if((a=i==null?void 0:i.common)!=null&&a.type&&((l=(s=this.props.objects[(o=i.common.alias)==null?void 0:o.id])==null?void 0:s.common)!=null&&l.type)){const u=e?i.common.type:this.props.objects[i.common.alias.id].common.type,h=e?this.props.objects[i.common.alias.id].common.type:i.common.type;if(u&&h){let c=null;if(u==="boolean"?c=!0:u==="number"?c=1:(u==="string"||u==="mixed")&&(c="string"),c!==null)try{const f=n(c);return h==="mixed"?"":f!==null&&typeof f!==h?this.props.t("Type of result is not as expected: %s",h):""}catch(f){return`${this.props.t("Cannot execute function")}: ${f.toString()}`}}}return""}prepareObject(t){var e,i,n,a;t=t||this.state.text;try{const o=JSON.parse(t);return o._id=this.props.obj._id,(e=o.common)!=null&&e.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)),((a=o.common)==null?void 0:a.step)!==void 0&&typeof o.common.step!="number"&&(o.common.step=parseFloat(o.common.step)),o}catch{return null}}onChange(t,e){var a,o,s,l;const i=this.prepareObject(t),n={text:t};if(i){n.changed=this.originalObj!==JSON.stringify(i,null,2),n.showCommonDeleteMessage=!1;const u=JSON.parse(this.originalObj);i.common&&Object.keys(u.common||{}).forEach(h=>{i.common[h]===void 0&&(n.showCommonDeleteMessage=!0)}),n.error=!1,n.readError=this.checkFunction((o=(a=i.common)==null?void 0:a.alias)==null?void 0:o.read,!1),n.writeError=this.checkFunction((l=(s=i.common)==null?void 0:s.alias)==null?void 0:l.write,!0)}else n.showCommonDeleteMessage=!1,n.error=!0;this.setState(n,()=>e&&e())}onUpdate(){var t,e,i,n;try{const a=JSON.parse(this.state.text);a._id=this.props.obj._id,(t=a.common)!=null&&t.alias&&(a.common.alias.id||delete a.common.alias.id,(!a.common.alias.read&&a.common.alias.read!==void 0||a.common.alias.read==="val")&&delete a.common.alias.read,(!a.common.alias.write&&a.common.alias.write!==void 0||a.common.alias.write==="val")&&delete a.common.alias.write,!a.common.alias.id&&!a.common.alias.read&&!a.common.alias.write&&delete a.common.alias),((e=a.common)==null?void 0:e.min)!==void 0&&typeof a.common.min!="number"&&(a.common.min=parseFloat(a.common.min)),((i=a.common)==null?void 0:i.max)!==void 0&&typeof a.common.max!="number"&&(a.common.max=parseFloat(a.common.max)),((n=a.common)==null?void 0:n.step)!==void 0&&typeof a.common.step!="number"&&(a.common.step=parseFloat(a.common.step)),this.props.onClose(a)}catch{console.error(`Cannot parse: ${this.state.text}`)}}static getPartOfObject(t,e){return e?Ad(JSON.parse(t),e.split(".")):JSON.parse(t)}static setPartOfObject(t,e,i){let n=JSON.parse(t);return n===void 0?t:(n=Zx(n,i.split("."),e),JSON.stringify(n,null,2))}renderCustomPanel(){var i;const t=(i=this.state.customEditTabs)==null?void 0:i.find(n=>n.key===this.state.tab);if(!t)return null;let e;try{e=Ht.getPartOfObject(this.state.text,t.path)}catch(n){return console.error(`Cannot get data for ${t.path}: ${n}`),y.jsx("div",{children:G.t("Cannot get data for %s: %s",t.path,n)})}return e?y.jsx(gh,{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:t.json,data:e,onChange:n=>{try{const a=Ht.setPartOfObject(this.state.text,n,t.path);this.onChange(a)}catch(a){console.error(`Cannot set data for ${t.path}: ${a}`)}},adapterName:"",instance:0,onError:n=>{console.warn(`Error in JSON editor: ${n}`),this.state.customError!==n&&this.setState({customError:n})}}):y.jsx("div",{children:G.t("Cannot get data for %s",t.path)})}renderCustomTab(t,e){var a;let i;if(!e||!Ad(e,(a=t.path)==null?void 0:a.split(".")))return null;t.color&&(i={backgroundColor:t.color,color:jt.invertColor(t.color,!0)});const n=t.label&&typeof t.label=="object"?t.label[this.state.lang]||t.label.en:t.noTranslation?t.label||t.key:this.props.t(t.label||t.key);return y.jsx(w.Tab,{disabled:this.state.error||this.state.customError,value:t.key,label:n,style:i,iconPosition:"start",icon:t.icon?y.jsx(Ca,{src:t.icon,style:O.funcIcon}):void 0})}renderStateTab(){return this.props.obj.type!=="state"||this.props.obj.common.type==="file"?null:y.jsx(w.Tab,{disabled:this.state.customError||this.state.error,value:"state",label:this.props.t("State")})}renderStatePanel(){var a;if(this.state.value===void 0||this.state.value===null)return y.jsx("div",{children:this.props.t("State does not exist")});if(typeof this.state.value!="object")return y.jsxs("div",{style:{maxWidth:700},children:[y.jsx("div",{children:this.props.t("State is invalid")}),y.jsx("div",{children:y.jsx("pre",{children:JSON.stringify(this.state.value,null,4)})})]});let t;const e={},i=this.state.value.val,n=typeof i;if(i===void 0)t="[undef]",e.color="#bc6400",e.fontStyle="italic";else if(i===null)t="(null)",e.color="#0047b1",e.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(jt.isStringInteger(i))t=new Date(parseInt(i,10)).toString();else try{const o=new Date(i);jt.isValidDate(o)&&(t=o.toString())}catch{}else i&&n==="number"&&(i>946681200&&i<9466812e5?t=new Date(i*1e3).toString():i>9466812e8&&(t=new Date(i).toString()));return t||(n==="number"?Number.isInteger(i)||(t=(Math.round(i*1e9)/1e9).toString(),this.props.isFloatComma&&(t=t.toString().replace(".",","))):n==="boolean"?(t=i?G.t("true"):G.t("false"),e.color=i?"#139800":"#cd6b55"):n==="object"?t=JSON.stringify(i):n==="string"&&i.startsWith("data:image/")?t=y.jsx("img",{src:i,alt:"img",style:O.stateImage}):t=i.toString()),Object.assign(e,SO(this.props.theme,e.color)),y.jsxs(w.Box,{style:{...O.divWithoutTitle,padding:"24px 24px 0 24px",fontSize:16,maxWidth:400},sx:{"& .value-line:hover":{backgroundColor:"#00000030"}},children:[y.jsxs("div",{className:"value-line",style:{...O.stateRow,marginBottom:24},children:[y.jsxs("div",{style:O.stateTitle,children:[G.t("ra_tooltip_value"),":"]}),y.jsxs(w.Box,{component:"div",sx:e,style:O.stateValue,children:[t,(a=this.props.obj.common)!=null&&a.unit?y.jsx("span",{style:O.stateUnit,children:this.props.obj.common.unit}):null]},typeof t=="string"?t:"image")]}),y.jsxs("div",{style:O.stateRow,className:"value-line",children:[y.jsxs("div",{style:O.stateTitle,children:[G.t("Type"),":"]}),y.jsx("div",{style:O.stateValue,children:n})]}),y.jsxs("div",{style:O.stateRow,className:"value-line",children:[y.jsxs("div",{style:O.stateTitle,children:[G.t("ra_tooltip_ts"),":"]}),y.jsx(w.Tooltip,{title:new Date(this.state.value.ts).toLocaleString(),slotProps:{popper:{sx:O.tooltip}},children:y.jsx("div",{style:O.stateValue,children:y.jsx("span",{style:O.stateTime,children:Ul(this.state.value.ts).fromNow()})})})]}),y.jsxs("div",{style:O.stateRow,className:"value-line",children:[y.jsxs("div",{style:O.stateTitle,children:[G.t("ra_tooltip_ack"),":"]}),y.jsxs("div",{style:{...O.stateValue,color:this.state.value.ack?"green":"red"},children:[this.state.value.ack?G.t("Acknowledged"):G.t("Command"),this.state.value.ack?" (true)":" (false)"]})]}),y.jsxs("div",{style:O.stateRow,className:"value-line",children:[y.jsxs("div",{style:O.stateTitle,children:[G.t("ra_tooltip_lc"),":"]}),y.jsx(w.Tooltip,{title:new Date(this.state.value.lc).toLocaleString(),slotProps:{popper:{sx:O.tooltip}},children:y.jsx("div",{style:O.stateValue,children:y.jsx("span",{style:O.stateTime,children:Ul(this.state.value.lc).fromNow()})})})]}),y.jsxs("div",{style:O.stateRow,className:"value-line",children:[y.jsxs("div",{style:O.stateTitle,children:[G.t("ra_tooltip_quality"),":"]}),y.jsx("div",{style:O.stateValue,children:jt.quality2text(this.state.value.q||0).join(", ")})]}),y.jsxs("div",{style:O.stateRow,className:"value-line",children:[y.jsxs("div",{style:O.stateTitle,children:[G.t("ra_tooltip_from"),":"]}),y.jsx("div",{style:O.stateValue,children:this.state.value.from})]}),y.jsxs("div",{style:O.stateRow,className:"value-line",children:[y.jsxs("div",{style:O.stateTitle,children:[G.t("ra_tooltip_user"),":"]}),y.jsx("div",{style:O.stateValue,children:this.state.value.user||"--"})]}),this.state.value.expire?y.jsxs("div",{style:O.stateRow,className:"value-line",children:[y.jsxs("div",{style:O.stateTitle,children:[G.t("ra_tooltip_expire"),":"]}),y.jsxs("div",{style:O.stateValue,children:[this.state.value.expire," ",G.t("sc_seconds")]})]}):null,this.state.value.c?y.jsxs("div",{style:O.stateRow,className:"value-line",children:[y.jsxs("div",{style:O.stateTitle,children:[G.t("ra_tooltip_comment"),":"]}),y.jsx("div",{style:O.stateValue,children:this.state.value.c})]}):null]})}onStateChange=(t,e)=>{JSON.stringify(e)!==JSON.stringify(this.state.value)&&this.setState({value:e})};subscribeOnState(t){t?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))}renderTabs(t){var e;return y.jsxs(w.Tabs,{style:O.tabsPadding,value:this.state.tab,onChange:(i,n)=>{var a,o,s;if((window._localStorage||window.localStorage).setItem(`${this.props.dialogName||"App"}.editTab`,n),n==="object"){try{const l=JSON.parse(this.state.text);let u=!1;((a=l.common)==null?void 0:a.min)!==void 0&&typeof l.common.min!="number"&&(l.common.min=parseFloat(l.common.min),u=!0),((o=l.common)==null?void 0:o.max)!==void 0&&typeof l.common.max!="number"&&(l.common.max=parseFloat(l.common.max),u=!0),((s=l.common)==null?void 0:s.step)!==void 0&&typeof l.common.step!="number"&&(l.common.step=parseFloat(l.common.step),u=!0),u&&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:[y.jsx(w.Tab,{value:"common",disabled:this.state.customError||this.state.error,label:this.props.t("common")}),y.jsx(w.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"&&y.jsx(w.Tab,{disabled:this.state.customError||this.state.error,value:"alias",label:this.props.t("Alias")}),(e=this.state.customEditTabs)==null?void 0:e.map(i=>this.renderCustomTab(i,t))]})}renderSelectDialog(){var i,n,a,o;if(!this.state.selectId&&!this.state.selectRead&&!this.state.selectWrite)return null;let t="",e;try{e=JSON.parse(this.state.text);const s=e.common&&"type"in e.common&&"alias"in e.common?(i=e.common.alias)==null?void 0:i.read:"",l=e.common&&"type"in e.common&&"alias"in e.common?(n=e.common.alias)==null?void 0:n.write:"";this.state.selectId?t=((o=(a=e.common)==null?void 0:a.alias)==null?void 0:o.id)||"":this.state.selectRead?t=s??"":this.state.selectWrite&&(t=l??"")}catch{console.error(`Cannot parse ${this.state.text}`)}return y.jsx(ey,{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:t,onOk:s=>{const l=this.state.selectRead,u=this.state.selectWrite,h=this.state.selectId,c=Array.isArray(s)?s[0]:s;this.setState({selectId:!1,selectRead:!1,selectWrite:!1},()=>{l?this.setAliasItem(e,"id.read",c):u?this.setAliasItem(e,"id.write",c):h&&this.setAliasItem(e,"id",c)})},onClose:()=>this.setState({selectId:!1,selectRead:!1,selectWrite:!1})},"selectDialog")}setAliasItem(t,e,i,n){t.common=t.common||{};const a=t.common.alias||{};e==="id.read"?a.id&&typeof a.id=="object"?a.id.read=i:a.id={read:i,write:i}:e==="id.write"?a.id&&typeof a.id=="object"?a.id.write=i:a.id={read:i,write:i}:a[e]=i,t.common.alias=a,this.onChange(JSON.stringify(t,null,2),n)}setCommonItem(t,e,i){t.common[e]=i,this.onChange(JSON.stringify(t,null,2))}removeCommonItem(t,e){delete t.common[e],this.onChange(JSON.stringify(t,null,2))}static buttonAddKey(t,e){return y.jsx("div",{style:O.marginBlock,children:y.jsx(w.Button,{style:O.buttonAdd,variant:"contained",color:"secondary",startIcon:y.jsx(X.Add,{}),onClick:e,children:G.t(t)})})}buttonRemoveKey(t,e){const{t:i}=this.props;return y.jsx(w.Tooltip,{title:i("Remove attribute %s",i(t)),slotProps:{popper:{sx:O.tooltip}},children:y.jsx(w.Box,{component:"div",sx:O.close,onClick:e})})}static filterRoles(t,e){const i=[];return t.forEach(n=>(n.type==="mixed"||n.type)===e&&!i.includes(n.role)&&i.push(n.role)),yo.forEach(n=>(n.type==="mixed"||n.type)===e&&!i.includes(n.role)&&i.push(n.role)),i.sort(),i}renderCommonEdit(){try{const t=JSON.parse(this.state.text),e=["number","string","boolean","array","object","mixed"],i=!1,{t:n,obj:a}=this.props,o=a.type==="state",s=a.type==="channel"||a.type==="device"||o,l=Ht.filterRoles(this.props.roleArray,t.common.type);let u;if(t.common.icon&&(u=t.type==="instance"||t.type==="adapter"?`./adapter/${t.common.name}/${t.common.icon}`:t.common.icon,!u.startsWith(".")&&!u.startsWith("/")&&!u.startsWith("data:"))){const f=a._id.split(".");f[0]==="system"?u=`adapter/${f[2]}${u.startsWith("/")?"":"/"}${u}`:u=`adapter/${f[0]}${u.startsWith("/")?"":"/"}${u}`}const h=typeof t.common.desc=="object"&&t.common.desc?t.common.desc[G.getLanguage()]||t.common.desc.en||"":t.common.desc||"",c=jt.getObjectNameFromObj(t,G.getLanguage(),{},!1,!0);return y.jsxs(w.Box,{style:O.commonTabWrapper,onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),f.stopPropagation(),this.onUpdate())},children:[y.jsxs(w.Box,{style:{...O.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 t.common.name<"u"?y.jsx(w.TextField,{variant:"standard",disabled:i,label:n("Name"),style:{...O.textField,marginTop:8},fullWidth:!0,slotProps:{input:{endAdornment:c?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>this.setCommonItem(t,"name",""),children:y.jsx(X.Close,{})})}):null}},value:c,onChange:f=>this.setCommonItem(t,"name",f.target.value)}):Ht.buttonAddKey("Name",()=>this.setCommonItem(t,"name","")),typeof t.common.desc<"u"?y.jsxs(w.Box,{component:"div",sx:O.flex,children:[y.jsx(w.TextField,{variant:"standard",disabled:i,label:n("Description"),style:{...O.textField,marginTop:8},fullWidth:!0,slotProps:{input:{endAdornment:h?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>this.setCommonItem(t,"desc",""),children:y.jsx(X.Close,{})})}):null}},value:h,onChange:f=>this.setCommonItem(t,"desc",f.target.value)}),this.buttonRemoveKey("Description",()=>this.removeCommonItem(t,"desc"))]}):Ht.buttonAddKey("Description",()=>this.setCommonItem(t,"desc","")),o?typeof t.common.type<"u"?y.jsxs(w.Box,{component:"div",sx:O.flex,children:[y.jsxs(w.FormControl,{style:O.marginBlock,fullWidth:!0,children:[y.jsx(w.InputLabel,{style:{transform:"scale(0.75)"},children:n("State type")}),y.jsx(w.Select,{variant:"standard",disabled:i,value:t.common.type,onChange:f=>this.setCommonItem(t,"type",f.target.value),children:e.map(f=>y.jsxs(w.MenuItem,{value:f,children:[n(f),y.jsxs("span",{style:O.typeNameEng,children:["(",f,")"]})]},f))})]}),this.buttonRemoveKey("State type",()=>this.removeCommonItem(t,"type"))]}):Ht.buttonAddKey("State type",()=>this.setCommonItem(t,"type","string")):null,y.jsxs(w.Box,{component:"div",sx:{...O.flex,flexWrap:this.props.width==="xs"?"wrap":void 0},children:[o?typeof t.common.read<"u"?y.jsxs(w.Box,{component:"div",sx:O.flex,children:[y.jsx(w.FormControlLabel,{style:O.marginBlock,control:y.jsx(w.Checkbox,{disabled:i,checked:t.common.read,onChange:f=>this.setCommonItem(t,"read",f.target.checked)}),label:n("Readable")}),this.buttonRemoveKey("Readable",()=>this.removeCommonItem(t,"read"))]}):Ht.buttonAddKey("Readable",()=>this.setCommonItem(t,"read",!0)):null,o?typeof t.common.write<"u"?y.jsxs(w.Box,{component:"div",sx:O.flex,children:[y.jsx(w.FormControlLabel,{style:O.marginBlock,control:y.jsx(w.Checkbox,{disabled:i,checked:t.common.write,onChange:f=>this.setCommonItem(t,"write",f.target.checked)}),label:n("Writeable")}),this.buttonRemoveKey("Writeable",()=>this.removeCommonItem(t,"write"))]}):Ht.buttonAddKey("Writeable",()=>this.setCommonItem(t,"write",!0)):null]}),s?typeof t.common.role<"u"?y.jsxs(w.Box,{component:"div",sx:O.flex,children:[y.jsx(w.Autocomplete,{style:O.marginBlock,fullWidth:!0,disabled:i,value:t.common.role,onChange:(f,d)=>{const p=yo.find(v=>v.role===d);p&&(p.w!==void 0&&p.r!==void 0?(this.setCommonItem(t,"write",p.w),this.setCommonItem(t,"read",p.r)):p.w!==void 0?this.setCommonItem(t,"write",p.w):p.r!==void 0&&this.setCommonItem(t,"read",p.r)),d.startsWith("level")||d.startsWith("indicator")||d.startsWith("sensor")||d.startsWith("weather")?t.common.write&&this.setCommonItem(t,"write",!1):d.startsWith("value")||d.startsWith("indicator")||d.startsWith("sensor")||d.startsWith("weather")?t.common.write&&this.setCommonItem(t,"write",!1):d.startsWith("level")||d.startsWith("switch")?t.common.write&&this.setCommonItem(t,"write",!0):d.startsWith("button")&&t.common.read&&this.setCommonItem(t,"read",!1),this.setCommonItem(t,"role",d)},options:l,renderInput:f=>y.jsx(w.TextField,{variant:"standard",...f,label:n("Role")})}),this.buttonRemoveKey("Role",()=>this.removeCommonItem(t,"role"))]}):Ht.buttonAddKey("Role",()=>this.setCommonItem(t,"role","")):null,typeof t.common.color<"u"?y.jsxs(w.Box,{component:"div",sx:O.flex,children:[y.jsx(w.TextField,{variant:"standard",disabled:i,style:{...O.marginBlock,...O.color},label:n("Color"),type:"color",slotProps:{input:{endAdornment:t.common.color?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>this.setCommonItem(t,"color",""),children:y.jsx(X.Close,{})})}):null}},value:t.common.color,onChange:f=>this.setCommonItem(t,"color",f.target.value)}),this.buttonRemoveKey("Color",()=>this.removeCommonItem(t,"color"))]}):Ht.buttonAddKey("Color",()=>this.setCommonItem(t,"color","")),y.jsxs(w.Box,{component:"div",sx:{...O.flex,flexWrap:this.props.width==="xs"?"wrap":void 0,gap:this.props.width==="xs"?"10px":void 0},children:[t.common.type==="number"?typeof t.common.min<"u"?y.jsxs(w.Box,{component:"div",sx:O.flex,children:[y.jsx(w.TextField,{variant:"standard",disabled:i,className:{...O.marginBlock,...O.color},label:n("Min"),value:t.common.min,onChange:f=>this.setCommonItem(t,"min",f.target.value)}),this.buttonRemoveKey("Min",()=>this.removeCommonItem(t,"min"))]}):y.jsx(w.Box,{component:"div",sx:O.flex,children:Ht.buttonAddKey("Min",()=>this.setCommonItem(t,"min",0))}):null,t.common.type==="number"?typeof t.common.max<"u"?y.jsxs(w.Box,{component:"div",sx:O.flex,children:[y.jsx(w.TextField,{variant:"standard",disabled:i,className:{...O.marginBlock,...O.color},label:n("Max"),value:t.common.max,onChange:f=>this.setCommonItem(t,"max",f.target.value)}),this.buttonRemoveKey("Max",()=>this.removeCommonItem(t,"max"))]}):y.jsx(w.Box,{component:"div",sx:O.flex,children:Ht.buttonAddKey("Max",()=>this.setCommonItem(t,"max",100))}):null,t.common.type==="number"?typeof t.common.step<"u"?y.jsxs(w.Box,{component:"div",sx:O.flex,children:[y.jsx(w.TextField,{variant:"standard",disabled:i,className:{...O.marginBlock,...O.color},label:n("Step"),value:t.common.step,onChange:f=>this.setCommonItem(t,"step",f.target.value)}),this.buttonRemoveKey("Step",()=>this.removeCommonItem(t,"step"))]}):y.jsx(w.Box,{component:"div",sx:O.flex,children:Ht.buttonAddKey("Step",()=>this.setCommonItem(t,"step",1))}):null]}),t.common.type==="number"?typeof t.common.unit<"u"?y.jsxs(w.Box,{component:"div",sx:O.flex,children:[y.jsx(w.TextField,{variant:"standard",disabled:i,className:{...O.marginBlock,...O.color},label:n("Unit"),slotProps:{input:{endAdornment:t.common.unit?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>this.setCommonItem(t,"unit",""),children:y.jsx(X.Close,{})})}):null}},value:t.common.unit,onChange:f=>this.setCommonItem(t,"unit",f.target.value)}),this.buttonRemoveKey("Unit",()=>this.removeCommonItem(t,"unit"))]}):y.jsx("div",{style:O.flexDrop,children:Ht.buttonAddKey("Unit",()=>this.setCommonItem(t,"unit",""))}):null]}),typeof t.common.icon<"u"?y.jsxs(w.Box,{component:"div",sx:O.flex,style:{flexGrow:1,minWidth:158},children:[y.jsx(Kx,{disabled:i,maxSize:10*1024,icon:u,removeIconFunc:()=>this.setCommonItem(t,"icon",""),onChange:f=>this.setCommonItem(t,"icon",f)}),this.buttonRemoveKey("Icon",()=>this.removeCommonItem(t,"icon"))]}):y.jsx(w.Box,{component:"div",sx:O.flex,children:Ht.buttonAddKey("Icon",()=>this.setCommonItem(t,"icon",""))})]})}catch{return y.jsx("div",{children:this.props.t("Cannot parse JSON!")})}}renderAliasEdit(){var t,e,i,n,a,o,s,l,u,h,c,f,d,p,v,g,m,_,b,x,C,S,T,M,D,I,P,k,R,L,j,E,q,W,$,et,ut,ot,ft,gt;try{const B=JSON.parse(this.state.text),Rt=((e=(t=B.common)==null?void 0:t.alias)==null?void 0:e.read)!==void 0||((n=(i=B.common)==null?void 0:i.alias)==null?void 0:n.write)!==void 0;return y.jsxs(w.Grid2,{container:!0,direction:"column",style:O.marginTop,children:[y.jsx(w.Grid2,{children:y.jsx(w.FormControlLabel,{control:y.jsx(w.Checkbox,{checked:typeof((o=(a=B.common)==null?void 0:a.alias)==null?void 0:o.id)=="object",onChange:()=>{var Mt,Lt,xt,z,Y,K,Ot;typeof((Lt=(Mt=B.common)==null?void 0:Mt.alias)==null?void 0:Lt.id)=="object"?this.setAliasItem(B,"id",((Y=(z=(xt=B.common)==null?void 0:xt.alias)==null?void 0:z.id)==null?void 0:Y.read)||""):this.setAliasItem(B,"id.read",((Ot=(K=B.common)==null?void 0:K.alias)==null?void 0:Ot.id)||"")}}),label:this.props.t("Different IDs for read and write")})}),typeof((l=(s=B.common)==null?void 0:s.alias)==null?void 0:l.id)!="object"?y.jsxs(w.Grid2,{children:[y.jsx(w.TextField,{variant:"standard",label:this.props.t("Alias state"),value:((h=(u=B.common)==null?void 0:u.alias)==null?void 0:h.id)||"",style:O.aliasIdEdit,slotProps:{input:{endAdornment:(f=(c=B.common)==null?void 0:c.alias)!=null&&f.id?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"large",onClick:()=>this.setAliasItem(B,"id",""),children:y.jsx(X.Close,{})})}):null}},onChange:Mt=>this.setAliasItem(B,"id",Mt.target.value),margin:"normal"}),y.jsx(w.Fab,{style:O.button,size:"small",onClick:()=>this.setState({selectId:!0,selectRead:!1,selectWrite:!1}),children:"..."})]}):null,typeof((p=(d=B.common)==null?void 0:d.alias)==null?void 0:p.id)=="object"?y.jsxs(w.Grid2,{children:[y.jsx(w.TextField,{variant:"standard",label:this.props.t("Alias read state"),value:((m=(g=(v=B.common)==null?void 0:v.alias)==null?void 0:g.id)==null?void 0:m.read)||"",style:O.aliasIdEdit,slotProps:{input:{endAdornment:(x=(b=(_=B.common)==null?void 0:_.alias)==null?void 0:b.id)!=null&&x.read?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"large",onClick:()=>this.setAliasItem(B,"id.read",""),children:y.jsx(X.Close,{})})}):null}},onChange:Mt=>this.setAliasItem(B,"id.read",Mt.target.value),margin:"normal"}),y.jsx(w.Fab,{style:O.button,size:"small",onClick:()=>this.setState({selectId:!1,selectRead:!0,selectWrite:!1}),children:"..."})]}):null,typeof((S=(C=B.common)==null?void 0:C.alias)==null?void 0:S.id)=="object"?y.jsxs(w.Grid2,{children:[y.jsx(w.TextField,{variant:"standard",label:this.props.t("Alias write state"),value:((D=(M=(T=B.common)==null?void 0:T.alias)==null?void 0:M.id)==null?void 0:D.write)||"",style:O.aliasIdEdit,slotProps:{input:{endAdornment:(k=(P=(I=B.common)==null?void 0:I.alias)==null?void 0:P.id)!=null&&k.write?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"large",onClick:()=>this.setAliasItem(B,"id.write",""),children:y.jsx(X.Close,{})})}):null}},onChange:Mt=>this.setAliasItem(B,"id.write",Mt.target.value),margin:"normal"}),y.jsx(w.Fab,{style:O.button,size:"small",onClick:()=>this.setState({selectId:!1,selectRead:!1,selectWrite:!0}),children:"..."})]}):null,y.jsx(w.Grid2,{style:O.marginTop,children:y.jsx(w.FormControlLabel,{control:y.jsx(w.Checkbox,{checked:((L=(R=B.common)==null?void 0:R.alias)==null?void 0:L.read)!==void 0||((E=(j=B.common)==null?void 0:j.alias)==null?void 0:E.write)!==void 0,onChange:()=>{Rt?(delete B.common.alias.read,delete B.common.alias.write):(B.common=B.common||{},B.common.alias=B.common.alias||{},B.common.alias.read="val",B.common.alias.write="val"),this.onChange(JSON.stringify(B,null,2))}}),label:this.props.t("Use convert functions")})}),Rt?y.jsx(w.Grid2,{children:y.jsx(w.TextField,{variant:"standard",label:this.props.t("Read converter"),value:((W=(q=B.common)==null?void 0:q.alias)==null?void 0:W.read)||"val",style:O.funcEdit,error:!!this.state.readError,slotProps:{input:{endAdornment:(et=($=B.common)==null?void 0:$.alias)!=null&&et.read?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"large",onClick:()=>this.setAliasItem(B,"read",""),children:y.jsx(X.Close,{})})}):null,startAdornment:y.jsx(w.InputAdornment,{position:"start",children:y.jsx(Rs,{style:O.funcIcon})})}},onChange:Mt=>this.setAliasItem(B,"read",Mt.target.value),helperText:this.state.readError||`${this.props.t("JS function like")} "val / 5 + 21"`,margin:"normal"})}):null,Rt?y.jsx(w.Grid2,{children:y.jsx(w.TextField,{variant:"standard",label:this.props.t("Write converter"),error:!!this.state.writeError,value:((ot=(ut=B.common)==null?void 0:ut.alias)==null?void 0:ot.write)||"val",helperText:this.state.writeError||`${this.props.t("JS function like")} "(val - 21) * 5"`,style:O.funcEdit,slotProps:{input:{endAdornment:(gt=(ft=B.common)==null?void 0:ft.alias)!=null&&gt.write?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"large",onClick:()=>this.setAliasItem(B,"write",""),children:y.jsx(X.Close,{})})}):null,startAdornment:y.jsx(w.InputAdornment,{position:"start",children:y.jsx(Rs,{style:O.funcIcon})})}},onChange:Mt=>this.setAliasItem(B,"write",Mt.target.value),margin:"normal"})}):null]})}catch{return y.jsx("div",{children:this.props.t("Cannot parse JSON!")})}}onCopy(t){jt.copyToClipboard(this.state.text,t),window.alert(this.props.t("ra_Copied"))}onClone(t,e){const i=JSON.parse(JSON.stringify(this.props.objects[t]));delete i.from,delete i.ts,delete i.user,i._id=e,this.props.objects[i._id]=i,this.props.onNewObject(i)}renderCopyDialog(){return this.state.showCopyDialog?y.jsxs(w.Dialog,{open:!0,maxWidth:"md",fullWidth:!0,onClose:()=>this.setState({showCopyDialog:""}),children:[y.jsx(w.DialogTitle,{children:this.props.t("Enter new ID for this object")}),y.jsx(w.DialogContent,{children:y.jsx(w.TextField,{variant:"standard",autoFocus:!0,fullWidth:!0,label:this.props.t("New object ID"),value:this.state.newId,slotProps:{input:{endAdornment:this.state.newId?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>this.setState({newId:""}),children:y.jsx(X.Close,{})})}):null}},onKeyDown:t=>{t.key==="Enter"&&!this.props.objects[this.state.newId]&&(this.setState({showCopyDialog:""}),this.onClone(this.state.showCopyDialog,this.state.newId))},onChange:t=>this.setState({newId:t.target.value})})}),y.jsxs(w.DialogActions,{children:[y.jsx(w.Button,{disabled:!!this.props.objects[this.state.newId],onClick:()=>{this.setState({showCopyDialog:""}),this.onClone(this.state.showCopyDialog,this.state.newId)},color:"primary",startIcon:y.jsx(X.FileCopy,{}),children:this.props.t("Clone")}),y.jsx(w.Button,{color:"grey",onClick:()=>this.setState({showCopyDialog:""}),startIcon:y.jsx(X.Close,{}),children:this.props.t("Cancel")})]})]}):null}renderPanelObject(t){return y.jsxs("div",{style:{...O.divWithoutTitle,...t?O.divWithoutTitleAndTab:void 0,...this.state.error?O.error:void 0},onKeyDown:e=>{e.ctrlKey&&e.key==="Enter"&&(e.preventDefault(),e.stopPropagation(),this.onUpdate())},children:[y.jsx(ty,{value:this.state.text,onChange:e=>this.onChange(e),name:"UNIQUE_ID_OF_DIV",themeType:this.props.themeType}),this.state.showCommonDeleteMessage?y.jsx("div",{style:O.commonDeleteTip,children:G.t("common_delete_tip")}):null]})}render(){const t=this.props.obj,e=t._id.startsWith("alias.0")&&t.type==="state";let i=O.dialog;window.innerWidth>1920&&(i={...i,maxWidth:"calc(100% - 150px)"});let n;try{n=JSON.parse(this.state.text)}catch{}return y.jsxs(w.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:[y.jsxs(w.DialogTitle,{id:"edit-value-dialog-title",style:{width:"calc(100% - 32px)",overflow:"hidden",textOverflow:"ellipsis"},children:[this.props.t("Edit object:")," ",y.jsx(w.Box,{component:"span",style:O.id,sx:{fontSize:{xs:10}},children:this.props.obj._id})]}),this.renderTabs(n),this.renderCopyDialog(),y.jsxs(w.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(e):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()]}),y.jsxs(w.DialogActions,{sx:O.wrapperButton,children:[y.jsx(w.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:y.jsx(X.FileCopy,{fontSize:this.props.width==="xs"?"large":void 0})}),y.jsx("div",{style:{flexGrow:1}}),this.state.tab==="object"&&y.jsx(w.Button,{color:"grey",onClick:a=>this.onCopy(a),disabled:this.state.error,title:this.props.width==="xs"?this.props.t("Copy into clipboard"):"",startIcon:this.props.width==="xs"?void 0:y.jsx(Md,{}),children:this.props.width==="xs"?y.jsx(Md,{fontSize:32}):this.props.t("Copy into clipboard")}),y.jsx(w.Button,{variant:"contained",disabled:this.state.error||!this.state.changed||this.state.customError,onClick:()=>this.onUpdate(),startIcon:this.props.width==="xs"?void 0:y.jsx(X.Check,{}),color:"primary",children:this.props.width==="xs"?y.jsx(X.Check,{fontSize:"large"}):this.props.t("Write")}),y.jsx(w.Button,{color:"grey",variant:"contained",onClick:()=>this.props.onClose(),startIcon:this.props.width==="xs"?void 0:y.jsx(X.Close,{}),children:this.props.width==="xs"?y.jsx(X.Close,{fontSize:"large"}):this.props.t("Cancel")})]})]})}}class md extends at.Component{object=null;constructor(t){super(t),this.state={role:null,initRole:null,roleInput:null}}componentDidMount(){this.props.socket.getObject(this.props.id).then(t=>{var i;this.object=t;const e=((i=t==null?void 0:t.common)==null?void 0:i.role)||null;this.setState({role:e,initRole:e,roleInput:e})}).catch(t=>console.error(t))}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(t,e){const i=[];return t.forEach(n=>(n.type==="mixed"||n.type)===e&&!i.includes(n.role)&&i.push(n.role)),yo.forEach(n=>(n.type==="mixed"||n.type)===e&&!i.includes(n.role)&&i.push(n.role)),i.sort(),i}render(){return y.jsxs(w.Dialog,{open:!0,maxWidth:"sm",fullWidth:!0,onClose:()=>this.props.onClose(),"aria-labelledby":"edit-role-dialog-title","aria-describedby":"edit-role-dialog-description",children:[y.jsx(w.DialogTitle,{id:"edit-role-dialog-title",children:this.object?this.props.t("Update role for %s",this.object._id):null}),y.jsx(w.DialogContent,{children:y.jsx(w.Autocomplete,{freeSolo:!0,options:md.filterRoles(this.props.roleArray,this.props.commonType),style:{width:"100%"},value:this.state.role,onChange:(t,e)=>this.setState({role:e,roleInput:e}),onInputChange:(t,e)=>this.setState({roleInput:e}),renderInput:t=>y.jsx(w.TextField,{variant:"standard",...t,label:this.props.t("Role")})})}),y.jsxs(w.DialogActions,{children:[y.jsx(w.Button,{disabled:this.state.initRole===this.state.roleInput,variant:"contained",onClick:()=>this.onUpdate(),color:"primary",startIcon:y.jsx(X.Check,{}),children:this.props.t("Apply")}),y.jsx(w.Button,{variant:"contained",onClick:()=>this.props.onClose(),color:"grey",startIcon:y.jsx(X.Close,{}),children:this.props.t("Cancel")})]})]},"objectBrowserEditRole")}}const CO=["array","boolean","file","json","mixed","number","object","string"],TO={boolean:!1,string:"",number:0},Be={state:{name:"State",value:"state"},channel:{name:"Channel",value:"channel"},device:{name:"Device",value:"device"},folder:{name:"Folder",value:"folder"}},AO=({onClose:r,onApply:t,selected:e,setObject:i,objects:n,expertMode:a,initialType:o,initialStateType:s})=>{var T;const l={state:G.t("New state"),channel:G.t("New channel"),device:G.t("New device"),folder:G.t("New folder")},u=[],h=(T=n[e])==null?void 0:T.type;n[e]?h==="channel"?(u.push(Be.state),o=o||"state"):h==="device"?(o=o||"channel",u.push(Be.state),u.push(Be.channel)):h==="state"?o=o||"":(u.push(Be.state),u.push(Be.channel),u.push(Be.device),e.startsWith("0_userdata.")||e.startsWith("alias.0.")||e==="0_userdata"||e==="alias.0"?(u.push(Be.folder),o=o||"folder"):o=o||"state"):(u.push(Be.folder),o=o||"folder",a&&(e.startsWith("mqtt.")||e.startsWith("javascript."))&&(u.push(Be.state),u.push(Be.channel),u.push(Be.device)));const c=(window._localStorage||window.localStorage).getItem("App.lastObjectType");c&&u.find(M=>M.value===c)&&(o=c);function f(M){return`${e}.${M.toString().replace(jt.FORBIDDEN_CHARS,"_").replace(/\s/g,"_").replace(/\./g,"_")}`}const[d,p]=at.useState(o),[v,g]=at.useState(l[o]),[m,_]=at.useState(s||(window._localStorage||window.localStorage).getItem("App.lastStateType")||"string"),[b,x]=at.useState(!n[f(l.state)]),C=()=>{const M={common:{name:v,desc:G.t("Manually created")},type:d};d==="state"?(M.common={...M.common,role:"state",type:m,read:!0,write:!0,def:TO[m]},M.native={}):d!=="folder"?M.common={...M.common,role:"",icon:""}:delete M.common.desc,i(`${e}.${v.split(" ").join("_")}`,M).then(()=>t())},S=G.getLanguage();return y.jsxs(w.Dialog,{open:!0,fullWidth:!0,maxWidth:"md",disableEscapeKeyDown:!1,onClose:r,children:[y.jsx(w.DialogTitle,{children:y.jsxs("div",{style:{margin:10,fontSize:20,display:"flex",alignItems:"center",gap:8},children:[y.jsx(X.AddBox,{}),G.t("Add new object:"),y.jsxs("span",{style:{fontStyle:"italic"},children:[e,".",v]})]})}),y.jsx(w.DialogContent,{children:y.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[y.jsx(w.TextField,{variant:"standard",label:G.t("Parent"),style:{margin:"5px 0"},disabled:!0,value:e}),y.jsxs(w.FormControl,{variant:"standard",style:{marginTop:10,marginBottom:16},children:[y.jsx(w.InputLabel,{children:G.t("Type")}),y.jsx(w.Select,{variant:"standard",value:d,onChange:M=>{(window._localStorage||window.localStorage).setItem("App.lastObjectType",M.target.value),v===l[d]&&(g(l[M.target.value]),x(!!n[f(l[M.target.value])])),p(M.target.value)},children:u.map(M=>y.jsxs(w.MenuItem,{value:M.value,children:[G.t(M.name),S!=="en"&&y.jsxs("span",{style:{fontSize:"smaller",opacity:.6,marginLeft:4},children:["(",M.value,")"]})]},M.value))})]}),d==="state"&&y.jsxs(w.FormControl,{style:{marginTop:10,marginBottom:16},children:[y.jsx(w.InputLabel,{style:{left:-14},children:G.t("State type")}),y.jsx(w.Select,{style:{marginTop:6},variant:"standard",value:m,onChange:M=>{(window._localStorage||window.localStorage).setItem("App.lastStateType",M.target.value),_(M.target.value)},children:CO.map(M=>y.jsxs(w.MenuItem,{value:M,children:[G.t(M),S!=="en"&&G.t(M)!==M&&y.jsxs("span",{style:{fontSize:"smaller",opacity:.6,marginLeft:4},children:["(",M,")"]})]},M))})]}),y.jsx(w.TextField,{variant:"standard",label:G.t("Name"),style:{margin:"5px 0"},autoFocus:!0,value:v,onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),v&&C())},slotProps:{input:{endAdornment:v?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>g(""),children:y.jsx(X.Close,{})})}):null}},onChange:M=>{x(!n[f(M.target.value)]),g(M.target.value)}})]})}),y.jsxs(w.DialogActions,{children:[y.jsx(w.Button,{id:"add-new-object-dialog-add",startIcon:y.jsx(X.Check,{}),disabled:!v||!d||!b||d==="state"&&!m,onClick:()=>C(),variant:"contained",color:"primary",children:G.t("add")}),y.jsx(w.Button,{id:"add-new-object-dialog-cancel",color:"grey",onClick:r,variant:"contained",startIcon:y.jsx(X.Close,{}),children:G.t("ra_Cancel")})]})]})},MO=[{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 Jm(r,t,e){return r|=t&e,r&=t|~e&65535,r}const Qm=({value:r,setValue:t,t:e,differentValues:i,applyToChildren:n,mask:a,setMask:o,disabled:s})=>{at.useEffect(()=>{if(n){let u=0;for(let h=0;h<i.length;h++)u|=r^i[h];o(u)}else o(0)},[i,n,o,r]);let l=r;return y.jsx("div",{style:{display:"flex",width:"fit-content",margin:20,border:"1px solid",borderLeft:0},children:MO.map(u=>{const h=Object.keys(u)[0];return y.jsxs("div",{style:{width:150,height:150,display:"flex",flexDirection:"column",alignItems:"center",borderLeft:"1px solid"},children:[y.jsx("div",{style:{height:50,display:"flex",alignItems:"center",fontSize:18,borderBottom:"1px solid silver",width:"100%",justifyContent:"center"},children:e(h)}),y.jsx("div",{style:{display:"flex",width:"100%"},children:u[h].map((c,f)=>{let d=!1;l-c.valueNum>=0&&(l-=c.valueNum,d=!0);const p=a&c.valueNum;return y.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,alignItems:"center",borderRight:f===0?"1px solid":0},children:[y.jsx("div",{style:{height:50,borderBottom:"1px solid",width:"100%",justifyContent:"center",display:"flex",alignItems:"center",color:"silver"},children:e(c.name)}),y.jsx("div",{style:{height:50,display:"flex"},children:y.jsx(w.Checkbox,{disabled:s,checked:d,color:p?"primary":"secondary",indeterminate:!!p,style:p?{opacity:.5}:void 0,onChange:v=>{p&&(a&=~c.valueNum&65535,o(a));let g=r;v.target.checked?g|=c.valueNum:g&=~c.valueNum&65535,t(g)}})})]},c.valueNum)})})]},h)})})},DO=({onClose:r,onApply:t,selected:e,extendObject:i,objects:n,t:a,modalEmptyId:o,themeType:s,theme:l})=>{const[u,h]=at.useState(null),[c,f]=at.useState(null),[d,p]=at.useState([]),[v,g]=at.useState([]),[m,_]=at.useState(!1),[b,x]=at.useState(!1),[C,S]=at.useState(0),[T,M]=at.useState(null),[D,I]=at.useState(null),[P,k]=at.useState(!1),[R,L]=at.useState(!1),[j,E]=at.useState([]),[q,W]=at.useState([]),[$,et]=at.useState(0),[ut,ot]=at.useState(0),[ft,gt]=at.useState([]),[B,Rt]=at.useState(!1),[Mt,Lt]=at.useState(!0),xt=a("different");return at.useEffect(()=>{var bd,xd,wd,Sd;let z=0;const Y=[],K=[],Ot=e||o,St=`${Ot}.`,se=Object.keys(n).sort();let je=!1;const ei=[],Tr=[],ri=G.getLanguage();let qn=!1,Zn=!1,tn=null,en=null,ii=null,ni=null;const _d=[];for(let ai=0;ai<se.length;ai++){const Ar=se[ai],ht=n[Ar];if(ht&&(Ar===Ot||Ar.startsWith(St))){if(z++,_d.push(Ar),!ht.acl)continue;ii===null&&ht.acl.object!==void 0&&(ii=ht.acl.object),ni===null&&ht.acl.state!==void 0&&(ni=ht.acl.state),tn===null&&ht.acl.owner!==void 0&&(tn=ht.acl.owner),en===null&&ht.acl.ownerGroup!==void 0&&(en=ht.acl.ownerGroup),!P&&tn!==ht.acl.owner&&ht.acl.owner!==void 0&&(qn=!0),!R&&en!==ht.acl.ownerGroup&&ht.acl.ownerGroup!==void 0&&(Zn=!0),ht.acl.state!==void 0&&ni!==ht.acl.state&&!Y.includes(ht.acl.state)&&Y.push(ht.acl.state),ht.acl.object!==void 0&&ii!==ht.acl.object&&!K.includes(ht.acl.object)&&K.push(ht.acl.object),ht.type==="state"&&(je=!0)}Ar.startsWith("system.group.")&&(ht==null?void 0:ht.type)==="group"?ei.push({name:jt.getObjectNameFromObj(ht,ri).replace("system.group.",""),value:Ar,icon:(bd=ht.common)==null?void 0:bd.icon,color:(xd=ht.common)==null?void 0:xd.color}):Ar.startsWith("system.user.")&&(ht==null?void 0:ht.type)==="user"&&Tr.push({name:jt.getObjectNameFromObj(ht,ri).replace("system.user.",""),value:Ar,icon:(wd=ht.common)==null?void 0:wd.icon,color:(Sd=ht.common)==null?void 0:Sd.color})}tn=tn||n["system.config"].common.defaultNewAcl.owner,en=en||n["system.config"].common.defaultNewAcl.ownerGroup,ii=ii||n["system.config"].common.defaultNewAcl.object,M(Number.isNaN(ii)?n["system.config"].common.defaultNewAcl.object:ii),je&&(ni=ni||n["system.config"].common.defaultNewAcl.state,I(Number.isNaN(ni)?n["system.config"].common.defaultNewAcl.state:ni));const Gx=Tr.find(ai=>ai.value===tn),Ux=ei.find(ai=>ai.value===en);h(Gx),f(Ux),k(qn),L(Zn),p(Tr),g(ei),je&&x(!0),o&&_(!0),S(z),E(Y),W(K),gt(_d)},[n,e,R,P,o]),at.useEffect(()=>{m?(R&&(c.value!=="different"&&f({name:xt,value:"different"}),v.find(z=>z.value==="different")||g(z=>[{name:xt,value:"different"},...z])),P&&((!u||u.value!=="different")&&h({name:xt,value:"different"}),d.find(z=>z.value==="different")||p(z=>[{name:xt,value:"different"},...z]))):(u&&u.value==="different"&&h(n[e].acl.owner),c&&c.value==="different"&&f(n[e].acl.ownerGroup),g(z=>z.filter(({value:Y})=>Y!=="different")),p(z=>z.filter(({value:Y})=>Y!=="different")))},[d,m,P,R,n,e,c,u,xt,v]),ft.length?y.jsx(ow,{theme:l,titleButtonApply:"apply",overflowHidden:!0,disableApply:Mt,progress:B,onClose:r,onApply:()=>{Rt(!0),setTimeout(()=>{if(m){const z=~$&65535,Y=~ut&65535;for(let K=0;K<ft.length;K++){const Ot=ft[K],St=n[Ot],se=jt.clone(St.acl||{});se.object=Jm(St.acl.object,T,z),u&&u.value!=="different"&&(se.owner=u.value),c&&c.value!=="different"&&(se.ownerGroup=c.value),St.type==="state"&&(se.state=Jm(St.acl.state,D,Y)),i(Ot,{acl:se})}}else{const z=jt.clone(n[e].acl||{});z.object=T,z.owner=u?u.value:"system.user.admin",z.ownerGroup=c?c.value:"system.group.administrator",n[e].type==="state"&&(z.state=D),i(e,{acl:z})}Rt(!1),t()},200)},children:y.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[y.jsx("div",{style:{margin:10,fontSize:20},children:a("Access control list: %s",e||o)}),y.jsxs("div",{style:{display:"flex"},children:[y.jsxs(w.FormControl,{variant:"standard",fullWidth:!0,style:{marginRight:10},children:[y.jsx(w.InputLabel,{children:a("Owner user")}),y.jsx(w.Select,{variant:"standard",disabled:B,value:u?u.value:"",renderValue:()=>y.jsxs("span",{children:[u!=null&&u.icon?y.jsx(Ca,{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:jt.getInvertedColor(u==null?void 0:u.color,s)},onChange:z=>{const Y=d.find(K=>K.value===z.target.value);h(Y),Lt(!1)},children:d.map(z=>y.jsxs(w.MenuItem,{style:z.value==="different"?{opacity:.5}:{color:z.color||void 0,backgroundColor:jt.getInvertedColor(z.color,s)},value:z.value,children:[z.icon?y.jsx(Ca,{src:z.icon,style:{width:16,height:16,marginRight:8}}):null,z.name]},z.value))})]}),y.jsxs(w.FormControl,{variant:"standard",fullWidth:!0,children:[y.jsx(w.InputLabel,{children:a("Owner group")}),y.jsx(w.Select,{variant:"standard",disabled:B,value:c?c.value:"",renderValue:()=>y.jsxs("span",{children:[c!=null&&c.icon?y.jsx(Ca,{src:c.icon,style:{width:16,height:16,marginRight:8}}):null,c?c.name:""]}),style:(c==null?void 0:c.value)==="different"?{opacity:.5}:{color:(c==null?void 0:c.color)||void 0,backgroundColor:jt.getInvertedColor(c==null?void 0:c.color,s)},onChange:z=>{const Y=v.find(K=>K.value===z.target.value);f(Y),Lt(!1)},children:v.map(z=>y.jsxs(w.MenuItem,{value:z.value,style:z.value==="different"?{opacity:.5}:{color:z.color||void 0,backgroundColor:jt.getInvertedColor(z.color,s)},children:[z.icon?y.jsx(Ca,{src:z.icon,style:{width:16,height:16,marginRight:8}}):null,z.name]},z.value))})]})]}),y.jsxs("div",{style:{display:"flex",margin:10,alignItems:"center",fontSize:10,marginLeft:0,color:"silver"},children:[y.jsx("div",{style:m?null:{color:"green"},children:a("to apply one item")}),y.jsx(w.Switch,{disabled:B||!!o||C===1,checked:!!o||m,onChange:z=>{_(z.target.checked),Lt(!1)},color:"primary"}),y.jsxs("div",{style:m?{color:"green"}:null,children:[a("to apply with children")," ",o||C>1?`(${C} ${a("object(s)")})`:""]})]}),B&&y.jsx(w.LinearProgress,{}),y.jsxs("div",{style:{overflowY:"auto"},children:[y.jsxs("div",{children:[y.jsx("h2",{children:a("Object rights")}),y.jsx(Qm,{mask:ut,disabled:B,setMask:ot,applyToChildren:m,differentValues:q,t:a,setValue:z=>{M(z),Lt(!1)},value:T})]}),b&&y.jsxs("div",{children:[y.jsx("h2",{children:a("States rights")}),y.jsx(Qm,{mask:$,disabled:B,setMask:et,applyToChildren:m,differentValues:m?j:[],t:a,setValue:z=>{I(z),Lt(!1)},value:D})]})]})]})}):y.jsx(w.LinearProgress,{})},bn={dialog:{height:"100%",maxHeight:"100%",maxWidth:"100%"},content:{textAlign:"center"},error:r=>({color:r.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 IO extends at.Component{audioRef;constructor(t){super(t);const e=this.props.obj._id.split(".");this.state={error:"",image:null,text:null,binary:null,fileName:`${e[e.length-2]}.${e[e.length-1]}`},this.audioRef=vh.createRef()}componentDidMount(){this.props.socket.getBinaryState(this.props.obj._id).then(t=>{let e=this.props.obj._id.toLowerCase().split(".").pop();const i=jt.detectMimeType(t);if(i&&(e=i),e==="jpg")this.setState({image:!0,binary:t,mime:"image/jpeg"});else if(e==="svg")this.setState({image:!0,binary:t,mime:"image/svg+xml"});else if(e==="png"||e==="bmp")this.setState({image:!0,binary:t,mime:`image/${e}`});else if(e==="mp3")this.setState({audio:!0,binary:t,mime:"audio/mpeg"});else if(e==="ogg")this.setState({audio:!0,binary:t,mime:"audio/ogg"});else if(e==="txt"||e==="log")try{const n=btoa(t);this.setState({text:n,binary:t,mime:"text/plain"})}catch{}}).catch(t=>this.setState({error:t}))}render(){return y.jsxs(w.Dialog,{style:bn.dialog,open:!0,maxWidth:this.state.audio?"sm":"md",onClose:()=>this.props.onClose(),fullWidth:!0,"aria-labelledby":"object-view-dialog-title",children:[y.jsx(w.DialogTitle,{id:"object-view-dialog-title",children:this.props.t("View file in state: %s",this.props.obj._id)}),y.jsxs(w.DialogContent,{style:bn.content,children:[this.state.error?y.jsx(w.Box,{component:"div",sx:bn.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?y.jsx("audio",{ref:this.audioRef,src:`data:${this.state.mime};base64,${this.state.binary}`}):null,this.state.audio?y.jsx(w.Fab,{color:"primary",onClick:()=>this.audioRef.current&&this.audioRef.current.play(),children:y.jsx(X.PlayArrow,{})}):null,this.state.image?y.jsx("img",{src:`data:${this.state.mime};base64,${this.state.binary}`,alt:this.props.obj._id,style:bn.image}):null,this.state.text!==null?y.jsx("pre",{style:bn.text,children:this.state.text}):null]}),y.jsxs(w.DialogActions,{children:[y.jsxs("a",{style:bn.download,download:this.state.fileName,href:`data:${this.state.mime};base64,${this.state.binary}`,children:[y.jsx(X.GetApp,{style:{paddingRight:8,height:12}}),y.jsx("span",{children:this.props.t("Download")})]}),y.jsx(w.Button,{variant:"contained",onClick:()=>this.props.onClose(),startIcon:y.jsx(X.Close,{}),color:"grey",children:this.props.t("Close")})]})]})}}const PO=Wn()(IO),zt={funcIcon:{width:16,height:16},formControlLabel:{marginBottom:16},color:{width:70},typeNameEng:{marginLeft:8,opacity:.7,fontStyle:"italic",fontSize:"smaller"},usedInAlias:{},addNewAlias:r=>({backgroundColor:r.palette.primary.main})},kO=["array","boolean","file","json","mixed","number","object","string"];class Ya extends at.Component{aliasIDs;constructor(t){var n;super(t);const e=[],i=this.props.obj._id;this.aliasIDs=Object.keys(this.props.objects).filter(a=>a.startsWith("alias.0"));for(let a=0;a<this.aliasIDs.length;a++){const o=(n=this.props.objects[this.aliasIDs[a]].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))&&e.push(this.aliasIDs[a])}this.state={usedInAliases:e,showAddNewAlias:!e.length,newAliasId:this.props.obj._id,newAliasName:Ya.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:Ya.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}}static getText(t){return t?typeof t=="object"?t[G.getLanguage()]||t.en||"":t.toString():""}static filterRoles(t,e){const i=[];return yo.forEach(n=>(n.type==="mixed"||n.type===e)&&!i.includes(n.role)&&i.push(n.role)),t.forEach(n=>(n.type==="mixed"||n.type)===e&&!i.includes(n.role)&&i.push(n.role)),i.sort(),i}renderAddNewAlias(){return this.state.showAddNewAlias?y.jsxs(w.Dialog,{open:!0,onClose:()=>this.setState({showAddNewAlias:!1}),children:[y.jsx(w.DialogTitle,{children:G.t("Create new alias: %s",`alias.0.${this.state.newAliasId}`)}),y.jsxs(w.DialogContent,{children:[y.jsx(w.TextField,{style:zt.formControlLabel,variant:"standard",value:this.state.newAliasId,slotProps:{input:{endAdornment:this.state.newAliasId?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>this.setState({newAliasId:""}),children:y.jsx(X.Close,{})})}):null}},onChange:t=>this.setState({newAliasId:t.target.value}),label:G.t("Alias ID"),helperText:`alias.0.${this.state.newAliasId}`,fullWidth:!0}),y.jsx(w.TextField,{style:zt.formControlLabel,variant:"standard",value:this.state.newAliasName,slotProps:{input:{endAdornment:this.state.newAliasName?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>this.setState({newAliasName:""}),children:y.jsx(X.Close,{})})}):null}},onChange:t=>this.setState({newAliasName:t.target.value}),label:G.t("Alias name"),fullWidth:!0}),y.jsx(w.TextField,{style:zt.formControlLabel,variant:"standard",value:this.state.newAliasDesc,slotProps:{input:{endAdornment:this.state.newAliasDesc?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>this.setState({newAliasDesc:""}),children:y.jsx(X.Close,{})})}):null}},onChange:t=>this.setState({newAliasDesc:t.target.value}),label:G.t("Alias description"),fullWidth:!0}),y.jsxs(w.FormControl,{style:zt.formControlLabel,fullWidth:!0,children:[y.jsx(w.InputLabel,{children:G.t("State type")}),y.jsx(w.Select,{variant:"standard",value:this.state.newAliasType,onChange:t=>this.setState({newAliasType:t.target.value}),children:kO.map(t=>y.jsxs(w.MenuItem,{value:t,children:[G.t(t),y.jsxs("span",{style:zt.typeNameEng,children:["(",t,")"]})]},t))})]}),this.state.newAliasType==="number"?y.jsx(w.TextField,{style:zt.formControlLabel,variant:"standard",value:this.state.newAliasUnit||"",slotProps:{input:{endAdornment:this.state.newAliasUnit?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>this.setState({newAliasUnit:""}),children:y.jsx(X.Close,{})})}):null}},onChange:t=>this.setState({newAliasUnit:t.target.value}),label:G.t("Alias units"),fullWidth:!0}):null,this.state.newAliasType==="number"?y.jsx(w.TextField,{variant:"standard",value:this.state.newAliasMin,type:"number",error:this.state.newAliasMin?isNaN(parseFloat(this.state.newAliasMin)):!1,onChange:t=>this.setState({newAliasMin:t.target.value}),label:G.t("Min"),style:{width:"calc(50% - 4px)",marginBottom:16,marginRight:8}}):null,this.state.newAliasType==="number"?y.jsx(w.TextField,{variant:"standard",value:this.state.newAliasMax,type:"number",error:this.state.newAliasMax?isNaN(parseFloat(this.state.newAliasMax)):!1,onChange:t=>this.setState({newAliasMax:t.target.value}),label:G.t("Max"),fullWidth:!0,style:{width:"calc(50% - 4px)",marginBottom:16}}):null,y.jsx(w.TextField,{variant:"standard",style:{...zt.formControlLabel,...zt.color},label:G.t("Color"),type:"color",value:this.state.newAliasColor,onChange:t=>this.setState({newAliasColor:t.target.value})}),y.jsx(w.Autocomplete,{style:{...zt.formControlLabel},fullWidth:!0,value:this.state.newAliasRole,onChange:(t,e)=>{const i=yo.find(n=>n.role===e);if(i){if(i.w!==void 0&&i.r!==void 0){this.setState({newAliasRole:e,newAliasRead:i.r,newAliasWrite:i.w});return}if(i.w!==void 0){this.setState({newAliasRole:e,newAliasWrite:i.w});return}if(i.r!==void 0){this.setState({newAliasRole:e,newAliasRead:i.r});return}}if(e.startsWith("value")||e.startsWith("indicator")||e.startsWith("sensor")||e.startsWith("weather")){if(this.state.newAliasWrite){this.setState({newAliasRole:e,newAliasWrite:!1});return}}else if(e.startsWith("level")||e.startsWith("switch")){if(!this.state.newAliasWrite){this.setState({newAliasRole:e,newAliasWrite:!0});return}}else if(e.startsWith("button")&&this.state.newAliasRead){this.setState({newAliasRole:e,newAliasRead:!1});return}this.setState({newAliasRole:e})},options:Ya.filterRoles(this.props.roleArray,this.state.newAliasType),renderInput:t=>y.jsx(w.TextField,{variant:"standard",...t,label:G.t("Role")})}),y.jsx(w.FormControlLabel,{style:{...zt.formControlLabel,marginLeft:16},control:y.jsx(w.Checkbox,{indeterminate:this.state.newAliasRead===void 0||this.state.newAliasRead===null,checked:this.state.newAliasRead,onChange:t=>{const e={newAliasRead:t.target.checked};e.newAliasRead===!1&&this.state.newAliasWrite===!1&&(e.newAliasWrite=!0),this.setState(e)}}),label:G.t("Alias read")}),y.jsx(w.FormControlLabel,{style:zt.formControlLabel,control:y.jsx(w.Checkbox,{indeterminate:this.state.newAliasWrite===void 0||this.state.newAliasWrite===null,checked:this.state.newAliasWrite,onChange:t=>{const e={newAliasWrite:t.target.checked};e.newAliasRead===!1&&this.state.newAliasWrite===!1&&(e.newAliasRead=!0),this.setState(e)}}),label:G.t("Alias write")}),y.jsx(w.FormControlLabel,{style:zt.formControlLabel,control:y.jsx(w.Checkbox,{checked:this.state.newAliasUseFormula,onChange:t=>this.setState({newAliasUseFormula:t.target.checked})}),label:G.t("Use convert functions")}),this.state.newAliasUseFormula&&this.state.newAliasRead?y.jsx(w.TextField,{style:zt.formControlLabel,variant:"standard",value:this.state.newAliasReadFormula,onChange:t=>this.setState({newAliasReadFormula:t.target.value}),label:G.t("Read formula"),helperText:`${G.t("JS function like")} "val / 5 + 21"`,slotProps:{input:{endAdornment:this.state.newAliasReadFormula&&this.state.newAliasReadFormula!=="val"?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>this.setState({newAliasReadFormula:"val"}),children:y.jsx(X.Close,{})})}):null,startAdornment:y.jsx(w.InputAdornment,{position:"start",children:y.jsx(Rs,{style:zt.funcIcon})})}},fullWidth:!0}):null,this.state.newAliasUseFormula&&this.state.newAliasWrite?y.jsx(w.TextField,{style:zt.formControlLabel,variant:"standard",value:this.state.newAliasWriteFormula,onChange:t=>this.setState({newAliasWriteFormula:t.target.value}),label:G.t("Write formula"),slotProps:{input:{endAdornment:this.state.newAliasWriteFormula&&this.state.newAliasWriteFormula!=="val"?y.jsx(w.InputAdornment,{position:"end",children:y.jsx(w.IconButton,{size:"small",onClick:()=>this.setState({newAliasWriteFormula:"val"}),children:y.jsx(X.Close,{})})}):null,startAdornment:y.jsx(w.InputAdornment,{position:"start",children:y.jsx(Rs,{style:zt.funcIcon})})}},helperText:`${G.t("JS function like")} "val / 5 + 21"`,fullWidth:!0}):null]}),y.jsxs(w.DialogActions,{children:[y.jsx(w.Button,{variant:"contained",disabled:!this.state.newAliasId||!!this.props.objects[`alias.0.${this.state.newAliasId}`],onClick:async()=>{const t={_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&&(t.common.desc=this.state.newAliasDesc),this.state.newAliasType&&(t.common.type=this.state.newAliasType),this.state.newAliasType==="number"&&this.state.newAliasUnit&&(t.common.unit=this.state.newAliasUnit),this.state.newAliasRole&&(t.common.role=this.state.newAliasRole),this.state.newAliasType==="number"&&this.state.newAliasMin&&(t.common.min=parseFloat(this.state.newAliasMin)),this.state.newAliasType==="number"&&this.state.newAliasMax&&(t.common.max=parseFloat(this.state.newAliasMax)),this.state.newAliasRole&&(t.common.role=this.state.newAliasRole),this.state.newAliasRead!==void 0&&this.state.newAliasRead!==null&&(t.common.read=this.state.newAliasRead),this.state.newAliasWrite!==void 0&&this.state.newAliasWrite!==null&&(t.common.write=this.state.newAliasWrite),this.state.newAliasColor&&(t.common.color=this.state.newAliasColor),this.state.newAliasIcon&&(t.common.icon=this.state.newAliasIcon),this.state.newAliasUseFormula&&(t.common.read!==!1&&this.state.newAliasReadFormula&&this.state.newAliasReadFormula!=="val"&&(t.common.alias.read=this.state.newAliasReadFormula),t.common.write!==!1&&this.state.newAliasWriteFormula&&this.state.newAliasWriteFormula!=="val"&&(t.common.alias.write=this.state.newAliasWriteFormula)),await this.props.socket.setObject(t._id,t),this.setState({showAddNewAlias:!1}),this.props.onRedirect(t._id,2e3),this.props.onClose()},startIcon:y.jsx(X.AddLink,{}),color:"primary",children:this.props.t("Create")}),y.jsx(w.Button,{variant:"contained",onClick:()=>this.setState({showAddNewAlias:!1}),startIcon:y.jsx(X.Close,{}),color:"grey",children:this.props.t("Close")})]})]}):null}render(){return y.jsxs(w.Dialog,{open:!0,maxWidth:"sm",onClose:()=>this.props.onClose(),fullWidth:!0,"aria-labelledby":"object-alias-dialog-title",children:[this.renderAddNewAlias(),y.jsx(w.DialogTitle,{id:"object-alias-dialog-title",children:this.state.usedInAliases.length?G.t("This object is used in aliases"):G.t("This object does not used in any aliases yet")}),y.jsx(w.DialogContent,{children:y.jsxs(w.MenuList,{style:{maxWidth:400},children:[this.state.usedInAliases.map(t=>y.jsxs(w.MenuItem,{style:zt.usedInAlias,onClick:()=>this.props.onRedirect(t),children:[y.jsx(w.ListItemIcon,{children:y.jsx(X.Link,{fontSize:"small"})}),y.jsx(w.ListItemText,{children:t})]},t)),y.jsxs(w.MenuItem,{onClick:()=>this.setState({showAddNewAlias:!0}),sx:zt.addNewAlias,children:[y.jsx(w.ListItemIcon,{children:y.jsx(X.AddLink,{fontSize:"small"})}),y.jsx(w.ListItemText,{children:G.t("Create alias from this ID")})]})]})}),y.jsx(w.DialogActions,{children:y.jsx(w.Button,{variant:"contained",onClick:()=>this.props.onClose(),startIcon:y.jsx(X.Close,{}),color:"grey",children:this.props.t("Close")})})]},"editAlias")}}const RO=Wn()(Ya);class yd extends at.Component{checkTimer=null;objects={};constructor(t){super(t);const e=this.props.id.split("."),i=e.pop()||"";this.state={name:i,parentId:e.join("."),renameAllChildren:!0,newExists:!0,showParentDialog:!1,showHistoryWarning:!1,withHistory:[]}}componentWillUnmount(){this.checkTimer&&(clearTimeout(this.checkTimer),this.checkTimer=null)}static calculateNewId(t,e,i){const n=t.split("."),a=e.split(".");let o=0;for(;n[o]===a[o];)o++;const s=i.split(".");return s.splice(0,o+1),`${e}.${s.join(".")}`}async getInstancesWithHistory(){const t=await this.props.socket.getAdapterInstances();return t==null?void 0:t.filter(e=>e.common.getHistory).map(e=>e._id.replace("system.adapter.",""))}async checkHistory(){this.objects={};const t=await this.getInstancesWithHistory(),e=[];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(a=>t.includes(a)&&!i.common.custom[a].aliasId)&&e.push(i._id)}),e.length?(this.setState({showHistoryWarning:!0,withHistory:e}),!1):!0}showHistoryWarning(){return this.state.showHistoryWarning?y.jsxs(w.Dialog,{open:!0,onClose:()=>this.setState({showHistoryWarning:!1}),children:[y.jsx(w.DialogTitle,{children:this.props.t("Found states with history")}),y.jsxs(w.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(", ")}`,y.jsx("div",{children:this.props.t("move_states_with_history_warning")})]}),y.jsxs(w.DialogActions,{children:[y.jsx(w.Button,{variant:"contained",color:"primary",onClick:async()=>{const t=`${this.state.parentId}.${this.state.name}`;await this.renameCopyObject(this.props.id,t,this.props.childrenIds.length&&this.state.renameAllChildren,!1),this.props.onClose()},startIcon:y.jsx(X.Check,{}),children:this.props.t("Confirm")}),y.jsx(w.Button,{color:"grey",variant:"contained",startIcon:y.jsx(X.Close,{}),onClick:()=>this.setState({showHistoryWarning:!1}),children:this.props.t("ra_Cancel")})]})]}):null}async renameCopyObject(t,e,i,n){var s;if(t===e)return;let a;try{a=((s=this.objects)==null?void 0:s[t])||await this.props.socket.getObject(t)}catch{}let o;if((a==null?void 0:a.type)==="state"&&(o=await this.props.socket.getState(t)),i)for(const l of this.props.childrenIds){const u=yd.calculateNewId(t,e,l);await this.renameCopyObject(l,u,!1,n)}a&&(await this.props.socket.setObject(e,a),o&&await this.props.socket.setState(e,o),n||await this.props.socket.delObject(t))}checkIfNewExists(){const t=`${this.state.parentId}.${this.state.name}`;this.checkTimer&&(clearTimeout(this.checkTimer),this.checkTimer=null),this.props.id===t?this.state.newExists||(this.checkTimer=setTimeout(()=>{this.checkTimer=null,this.setState({newExists:!0})},50)):this.checkTimer=setTimeout(async()=>{this.checkTimer=null;try{const e=await this.props.socket.getObject(t);e&&!this.state.newExists?this.setState({newExists:!0}):!e&&this.state.newExists&&this.setState({newExists:!1})}catch{this.state.newExists&&this.setState({newExists:!1})}},300)}renderParentSelectorDialog(){return this.state.showParentDialog?y.jsx(ey,{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:t=>this.props.expertMode?!0:t._id.startsWith("0_userdata.0")||t._id.startsWith("javascript."),theme:this.props.theme,onSelectConfirm:(t,e)=>{let i;return Array.isArray(t)?i=t[0]:i=t,i.split(".").length<=1||e[i]&&(e[i].type==="state"||i.startsWith("system."))?Promise.resolve(!1):Promise.resolve(!0)},onClose:()=>this.setState({showParentDialog:!1}),onOk:t=>{let e;Array.isArray(t)?e=t[0]:e=t,e&&e.split(".").length>1&&this.setState({parentId:e})}}):null}render(){const t=`${this.state.parentId}.${this.state.name}`;return y.jsxs(w.Dialog,{open:!0,maxWidth:"md",fullWidth:!0,onClose:()=>this.props.onClose(),children:[this.renderParentSelectorDialog(),this.showHistoryWarning(),y.jsxs(w.DialogTitle,{children:[y.jsxs("span",{style:{opacity:.6,marginRight:8},children:[this.props.t("Rename or copy object")," -"]}),y.jsx("span",{style:{fontWeight:"bold"},children:this.props.id})]}),y.jsxs(w.DialogContent,{children:[y.jsxs("div",{style:{display:"flex",gap:8,alignItems:"end",opacity:.7},children:[y.jsx(w.TextField,{fullWidth:!0,variant:"standard",label:this.props.t("Parent ID"),value:`${this.state.parentId}.`,slotProps:{input:{readOnly:!0}}}),y.jsx(w.Button,{variant:"outlined",style:{maxWidth:40,width:40,height:32},onClick:()=>this.setState({showParentDialog:!0}),children:"..."})]}),y.jsx(w.TextField,{value:this.state.name,onChange:e=>{const i=e.target.value.replace(jt.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?y.jsx(w.FormControlLabel,{control:y.jsx(w.Checkbox,{checked:this.state.renameAllChildren,onChange:()=>{this.setState({renameAllChildren:!this.state.renameAllChildren})}}),label:this.props.t("Rename all children")}):null,y.jsxs("div",{children:[y.jsxs("span",{style:{opacity:.6,marginRight:8,fontSize:16},children:[this.props.t("New object ID"),":"]}),y.jsx("span",{style:{fontWeight:"bold",fontSize:16},children:t})]})]}),y.jsxs(w.DialogActions,{children:[y.jsx(w.Button,{disabled:!this.state.name||t===this.props.id,color:"primary",variant:"outlined",onClick:async()=>{await this.renameCopyObject(this.props.id,t,this.props.childrenIds.length&&this.state.renameAllChildren,!0),this.props.onClose()},children:this.props.t("Create a copy")}),y.jsx(w.Button,{disabled:!this.state.name||t===this.props.id,color:"primary",variant:"contained",onClick:async()=>{await this.checkHistory()&&(await this.renameCopyObject(this.props.id,t,this.props.childrenIds.length&&this.state.renameAllChildren,!1),this.props.onClose())},children:t!==this.props.id&&this.state.newExists?this.props.t("Replace"):this.props.t("Rename")}),y.jsx(w.Button,{variant:"contained",color:"grey",onClick:()=>this.props.onClose(),startIcon:y.jsx(X.Close,{}),children:this.props.t("ra_Cancel")})]})]})}}const LO=X.Delete,vs={buttonAll:{color:"#FF0000"},id:{fontStyle:"italic"},buttonText:{whiteSpace:"nowrap"}};class OO extends at.Component{dialogName;filters;t;wordCache;constructor(t){super(t),this.dialogName="AdminObjects";const e=(window._localStorage||window.localStorage).getItem(`${this.dialogName||"App"}.filters`)||"{}";try{this.filters=JSON.parse(e)}catch{this.filters={}}const i=(window._localStorage||window.localStorage).getItem(`${this.dialogName||"App"}.selected`)||"";this.state={selected:i,name:"",toast:"",deleteObjectShow:null},this.t=this.translate,this.wordCache={}}translate=(t,e,i)=>e!==void 0?this.props.t(t,e,i):(this.wordCache[t]||(this.wordCache[t]=this.props.t(t)),this.wordCache[t]);onDelete(t){const e=this.state.deleteObjectShow.id;t?(this.props.socket.delObjects(e,!0).then(()=>this.setState({toast:this.t("All deleted")})).catch(i=>window.alert(`Cannot delete object: ${i}`)),this.setState({deleteObjectShow:null})):(this.props.socket.delObject(e,!1).catch(i=>window.alert(`Cannot delete object: ${i}`)),this.setState({deleteObjectShow:null}))}renderToast(){return y.jsx(w.Snackbar,{anchorOrigin:{vertical:"bottom",horizontal:"right"},open:!!this.state.toast,autoHideDuration:3e3,onClose:()=>this.setState({toast:""}),message:this.state.toast,action:y.jsx(w.IconButton,{size:"small","aria-label":"close",color:"inherit",onClick:()=>this.setState({toast:""}),children:y.jsx(X.Cancel,{fontSize:"small"})})},"toast")}renderDeleteDialog(){return this.state.deleteObjectShow?y.jsxs(w.Dialog,{maxWidth:"md",open:!0,onClose:()=>this.setState({deleteObjectShow:null}),"aria-labelledby":"delete-object-dialog-title","aria-describedby":"delete-object-dialog-description",children:[y.jsxs(w.DialogTitle,{id:"delete-object-dialog-title",children:[this.state.deleteObjectShow.hasChildren?this.t("Delete object(s)"):this.t("Delete object"),":"," ",y.jsx("span",{style:vs.id,children:this.state.deleteObjectShow.id})]}),y.jsx(w.DialogContent,{children:y.jsx(w.DialogContentText,{children:this.t("Are you sure?")})}),y.jsxs(w.DialogActions,{children:[this.state.deleteObjectShow.hasChildren?y.jsx(w.Button,{variant:"contained",color:"grey",sx:{"& .MuiButton-text":vs.buttonText},onClick:()=>this.onDelete(!0),startIcon:y.jsx(LO,{style:vs.buttonAll}),children:this.t("Delete with children",this.state.deleteObjectShow.childrenCount)}):null,this.state.deleteObjectShow.exists?y.jsx(w.Button,{variant:"contained",sx:{"& .MuiButton-text":vs.buttonText},onClick:()=>this.onDelete(!1),color:"primary",startIcon:y.jsx(X.Delete,{}),autoFocus:!0,children:this.t("Delete one item")}):null,y.jsx(w.Button,{variant:"contained",color:"grey",onClick:()=>this.setState({deleteObjectShow:null}),startIcon:y.jsx(X.Cancel,{}),children:this.t("ra_Cancel")})]})]},"delete"):null}render(){return[this.renderToast(),y.jsx(Jx,{dialogName:"admin",objectsWorker:this.props.objectsWorker,prefix:this.props.prefix,defaultFilters:this.filters,statesOnly:this.props.statesOnly,style:{width:"100%",height:"100%"},socket:this.props.socket,selected:this.state.selected,name:this.state.name,expertMode:this.props.expertMode,isFloatComma:this.props.isFloatComma,dateFormat:this.props.dateFormat,t:this.t,lang:this.props.lang,themeName:this.props.themeName,themeType:this.props.themeType,theme:this.props.theme,objectCustomDialog:wO,objectBrowserValue:Dn,objectBrowserEditObject:Ht,objectBrowserEditRole:md,objectBrowserViewFile:PO,objectBrowserAliasEditor:RO,objectMoveRenameDialog:yd,router:yh,enableStateValueEdit:!0,onObjectDelete:(t,e,i,n)=>this.setState({deleteObjectShow:{id:t,hasChildren:e,exists:i,childrenCount:n}}),onFilterChanged:t=>{this.filters=t,(window._localStorage||window.localStorage).setItem(`${this.dialogName||"App"}.filters`,JSON.stringify(t))},onSelect:t=>{Array.isArray(t)?(window._localStorage||window.localStorage).setItem(`${this.dialogName||"App"}.selected`,t[0]||""):(window._localStorage||window.localStorage).setItem(`${this.dialogName||"App"}.selected`,t||"")},objectEditBoolean:!0,objectAddBoolean:!0,objectStatesView:!0,objectImportExport:!0,objectEditOfAccessControl:!0,modalNewObject:t=>y.jsx(AO,{objects:t.objects,expertMode:this.props.expertMode,setObject:(e,i)=>this.props.socket.setObject(e,i).catch(n=>window.alert(n)),selected:t.state.modalNewObj.id,initialType:t.state.modalNewObj.initialType,initialStateType:t.state.modalNewObj.initialStateType,onClose:()=>t.setState({modalNewObj:null}),onApply:()=>t.setState({modalNewObj:null})}),modalEditOfAccessControl:(t,e)=>y.jsx(DO,{theme:this.props.theme,themeType:this.props.themeType,extendObject:(i,n)=>{this.props.socket.extendObject(i,n).catch(a=>window.alert(a)),e.aclTooltip=null},selected:t.state.selected[0],modalEmptyId:e.obj?"":e.id,objects:t.objects,t:this.t,onClose:()=>t.setState({modalEditOfAccess:!1,modalEditOfAccessObjData:null}),onApply:()=>t.setState({modalEditOfAccess:!1,modalEditOfAccessObjData:null})})},"browser"),this.renderDeleteDialog()]}}const eE=Wn()(OO);export{eE as default};