@wdslib/go-utils 0.2.9 → 0.2.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"axios";import t,{uniq as i}from"lodash";import r from"crypto-js";function o(e,t,i,r){return new(i||(i=Promise))((function(o,a){function n(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(n,s)}l((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const a=5e3,n=5e3,s=(t="",i)=>{let r=e.create({baseURL:t,timeout:a,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}});return r.interceptors.request.use((function(e){return sessionStorage.getItem("anov-go-token")&&"null"!=sessionStorage.getItem("anov-go-token")&&(e.headers["X-ANOV-ACCESS-TOKEN"]=sessionStorage.getItem("anov-go-token")),sessionStorage.getItem("unify-access-token")&&"null"!=sessionStorage.getItem("unify-access-token")&&(e.headers["X-UNIFY-ACCESS-TOKEN"]=sessionStorage.getItem("unify-access-token")),sessionStorage.getItem("dgcc_authorization")&&"null"!=sessionStorage.getItem("dgcc_authorization")&&(e.headers.dgcc_authorization=sessionStorage.getItem("dgcc_authorization")),"post"===e.method?(e.headers["Content-Type"]="application/json;",e):"get"===e.method?e:"put"===e.method?(e.headers["Content-Type"]="application/json; charset=UTF-8",e):"delete"===e.method?e:void 0}),(function(e){return Promise.reject(e)})),r.interceptors.response.use((function(e){return 200===e.status||e.data.code,i&&i(e),e.data}),(function(e){return i&&i(null==e?void 0:e.response),Promise.reject(e.response)})),r};function l(e,t=!1){return t?d(e)?e:JSON.stringify(e):d(e)?JSON.parse(e):e}const d=e=>{if("string"==typeof e)try{const t=JSON.parse(e);return"object"==typeof t&&null!==t}catch(e){return!1}return!1},c=(e,t)=>{try{const i=JSON.stringify(t);sessionStorage.setItem(e,i)}catch(t){console.error(`Error setting session data for key ${e}:`,t)}},u=e=>{const t=sessionStorage.getItem(e);if(t)try{return JSON.parse(t)}catch(t){console.error(`Error parsing session data for key ${e}:`,t)}return null},h=e=>{for(const t of e)t.code&&(t.code=t.code.replace(/>/g,">").replace(/</g,"<"))},p=(e,t)=>{e instanceof Map?e.forEach((e=>{t([e])})):Array.isArray(e)&&e.forEach((e=>{t(e.children)}))},f=(e,t)=>{const i=e=>{var r,o,a;if(e)for(const n of e){const e=null===(a=null===(o=null===(r=null==n?void 0:n.tmpData)||void 0===r?void 0:r.source)||void 0===o?void 0:o.converse)||void 0===a?void 0:a.data;(null==e?void 0:e.length)&&h(e),t(n),n.children?i(n.children):n.dynamicChildren?p(n.dynamicChildren,i):n.stateChildren&&i(n.stateChildren)}};i(e)},m=(e,t,i,r)=>{const o=e.match(/({{[\w]*}})|((@)[\w]*)/gm);if(o){const e=o.map((e=>e.replace(/{{|}}|@/gm,"")));for(const o of e)if(o&&t&&!(t.findIndex((e=>e.mapField===o))<0))return i&&r&&g(r,o,i.cid),!0}return!1},g=(e,t,i)=>{if(!e)throw new Error("Share variable tree is not defined");if("string"!=typeof t)throw new Error("Variable name should be a string");if(!i)throw new Error("ID is required");Array.isArray(e[t])||(e[t]=[]),e[t].includes(i)||e[t].push(i)},v=(e,t,i)=>{var r;let o=!1;const a=null==t?void 0:t.converse;if(a&&a.use&&a.data.length)for(const t of a.data)if((null==t?void 0:t.dependVars)&&t.dependVars.includes(e))return!0;const n=null==t?void 0:t[null==t?void 0:t.type];return((null==n?void 0:n.inputSql)||(null==n?void 0:n.url)||(null==n?void 0:n.headers)||(null==n?void 0:n.params))&&(o=m(n.inputSql||n.url||(null===(r=n.headers)||void 0===r?void 0:r.value)||n.params,i)),o},b=(e,i,r=!1)=>{let o=null;const a=e=>{for(const n of e){if(n.cid===i){o=n,r&&t.remove(e,(e=>e.cid===i));break}if(n.children&&a(n.children),n.dynamicChildren&&Array.isArray(n.dynamicChildren))for(const[,e]of Array.from(n.dynamicChildren))a(e);n.stateChildren&&a(n.stateChildren)}};return a(e),o},y=(e,i,r)=>{let o=!1;const a=e=>{for(let n=0;n<e.length;n++){if(e[n].cid==i){o=e[n],r&&t.remove(e,(e=>e.cid==i));break}if(e[n].children)a(e[n].children);else if(e[n].dynamicChildren){if(e[n].dynamicChildren instanceof Map){let t=Array.from(e[n].dynamicChildren);for(let e=0;e<t.length;e++)if(t[e]instanceof Array){let i=t[e][1];a(i)}}else if(e[n].dynamicChildren instanceof Array){let t=e[n].dynamicChildren;for(let e=0;e<t.length;e++)if(t[e]instanceof Array){let i=t[e][1];a(i)}}}else e[n].stateChildren&&a(e[n].stateChildren)}};return a(e),o||!1};function w(e,t,i){const r={};i&&i.forEach((e=>{(null==e?void 0:e.name)&&(r[e.name]=e.value||e.originvalue)}));try{return new Function("data","vars",e)(t,r)}catch(e){return console.error(e),t}}function D(e,i){let r=t.cloneDeep(i);try{return new Function("data",e)(r)}catch(e){return console.error(e),r}}const N=e=>{let t=window.goFetchList;return t||(window.goFetchList={},t=window.goFetchList),t[e]?!t[e]&&void 0:(t[e]={id:e,time:(new Date).getTime()},!0)},C=e=>{let t=window.goFetchList;t&&t[e]&&delete t[e]},k="anov@2019:helloX",A="anov@2020:helloX";function V(e){let t=r.enc.Utf8.parse(k),i=r.enc.Utf8.parse(A);return r.AES.encrypt(e,t,{iv:i,mode:r.mode.CBC,padding:r.pad.Pkcs7}).toString()}function O(e,t){if(0===e.length)throw new Error("Array is empty.");if(!t)return e[Math.floor(Math.random()*e.length)];if(t.length!==e.length)throw new Error("Length of probabilities array must match length of array.");const i=t.reduce(((e,t)=>e+t),0),r=Math.random()*i;let o=0;for(let i=0;i<e.length;i++)if(o+=t[i],r<o)return e[i];return e[0]}const x=new Blob(["\nfunction proxyObj(originObj) {\n const exposeObj = new Proxy(originObj, {\n has: (target, key) => {\n if (['fetch', 'XMLHttpRequest', 'postMessage'].indexOf(key) >= 0) {\n throw new Error('Illegal operation for key'+key)\n } else {\n return target[key]\n }\n },\n })\n return exposeObj\n}\nfunction compileCode(src) {\n src = 'with (exposeObj) {'+src+'}'\n //console.log(src)\n return new Function('exposeObj', src)\n}\nfunction run(code) {\n let proxy = proxyObj({})\n let result = compileCode(code)(proxy)\n return result\n}\n\nonmessage = (e) => {\n try {\n let result = run(e.data.code)\n postMessage({\n code: 1,\n result,\n })\n } catch (err) {\n postMessage({\n code: -1,\n err,\n })\n }\n}\n"]),S=URL.createObjectURL(x);function F(e,t,i={},r="worker"){return o(this,void 0,void 0,(function*(){try{if("window"==r){let[r,o]=[["data"],[t]];"object"==typeof i&&Object.keys(i).forEach((e=>{r.push(e),o.push(i[e])}));const a=new Function(...r,e);return{success:!0,data:a(...o)}}{let[r,a,n]=[t,i,""];"object"==typeof r&&(r=JSON.stringify(t)),"object"==typeof i&&(a=JSON.stringify(i)),Object.keys(i).forEach((e=>n+=`${e},`));let s=`let data=eval(${r}); \n let app=${JSON.stringify({})};`;s+=n?`let {${n}} = eval(${a}); `:"",s+=`${e}`;let l=yield function(e,t=5e3){return o(this,void 0,void 0,(function*(){let i=new Worker(S);return new Promise(((r,o)=>{const a=()=>{clearTimeout(s),i.removeEventListener("message",n),i.terminate(),i=null},n=e=>{let{code:t,result:i,err:n}=e.data;a(),1===t?r(i):o(n)};i.postMessage({code:e}),i.addEventListener("message",n);let s=setTimeout((()=>{a(),o("timeout")}),t)}))}))}(s);return{success:!0,data:l}}}catch(e){return{success:!1,error:e,data:t}}}))}var T,E,j,P;!function(e){e.StaticFile="staticFile",e.DataSource="datasource"}(T||(T={})),function(e){e.json="application/json;charset=UTF-8",e.form="application/x-www-form-urlencoded; charset=UTF-8"}(E||(E={})),function(e){e.get="GET",e.post="POST",e.put="PUT",e.patch="PATCH",e.delete="DELETE"}(j||(j={}));class I{constructor(e){this.db=null,this.dbName=e.databaseName,this.tableName=e.tableName,this.keyPath=e.keyPath}static getInstance(e){return I.instance||(I.instance=new I(e)),I.instance}init(){return o(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{const i=indexedDB.open(this.dbName,1);i.onerror=e=>{t(e.target.error)},i.onupgradeneeded=e=>{this.db=e.target.result,this.db.objectStoreNames.contains(this.tableName)||this.db.createObjectStore(this.tableName,{keyPath:this.keyPath})},i.onsuccess=t=>{this.db=t.target.result,e()}}))}))}addRecord(e){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,i)=>{const r=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).add(e);r.onsuccess=()=>{t()},r.onerror=e=>{i(e.target.error)}}))}))}deleteRecord(e){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,i)=>{const r=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).delete(e);r.onsuccess=()=>{t()},r.onerror=e=>{i(e.target.error)}}))}))}updateRecord(e){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,i)=>{const r=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).put(e);r.onsuccess=()=>{t()},r.onerror=e=>{i(e.target.error)}}))}))}getRecord(e){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,i)=>{const r=this.db.transaction([this.tableName],"readonly").objectStore(this.tableName).get(e);r.onsuccess=()=>{t(r.result)},r.onerror=e=>{i(e.target.error)}}))}))}getAllRecords(){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((e,t)=>{const i=this.db.transaction([this.tableName],"readonly").objectStore(this.tableName).getAll();i.onsuccess=()=>{e(i.result)},i.onerror=e=>{t(e.target.error)}}))}))}}I.instance=null,function(e){e[e.FATAL=0]="FATAL",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.DEBUG=4]="DEBUG",e[e.TRACE=5]="TRACE"}(P||(P={}));const R={databaseName:"GODB",tableName:"go-log",keyPath:"time"};class M{constructor(){this.logLevel=P.INFO,this.indexedDBInstance=I.getInstance(R);try{this.indexedDBInstance.init(),console.log("IndexedDB 初始化成功。")}catch(e){console.error("初始化 IndexedDB 时出错:",e)}}static getInstance(){return M.instance||(M.instance=new M),M.instance}setLogLevel(e){this.logLevel=e}getColor(e){switch(e){case P.FATAL:return"[31;1m";case P.ERROR:return"[31m";case P.WARN:return"[33m";case P.INFO:return"[32m";case P.DEBUG:return"[36m";case P.TRACE:return"[34m";default:return"[0m"}}log(e,t){if(t<=this.logLevel){const i=(new Date).toISOString(),r=`[${i}] [${P[t]}]`,o=this.getColor(t);if(null===window||void 0===window?void 0:window.goDev)console.log(`${o}${r} ${e}[0m`);else{let t=u("anov-go-userInfo"),a=u("anov-go-proid"),n=` [操作人:${null==t?void 0:t.userName} 项目ID:${a}] `;const s={time:i,value:`${e}`};try{this.indexedDBInstance.addRecord(s)}catch(e){console.error("添加记录时出错:",e)}console.log(`${o}${r} ${n} ${e}[0m`)}}}fatal(e){this.log(e,P.FATAL)}error(e){this.log(e,P.ERROR)}warn(e){this.log(e,P.WARN)}info(e){this.log(e,P.INFO)}debug(e){this.log(e,P.DEBUG)}trace(e){this.log(e,P.TRACE)}}const U=M.getInstance(),$=(e,t)=>"string"!=typeof e?Promise.reject(new Error("URL should be a string")):s(e,t),L=s();let q=s();function H(e,i="get",r={},a={}){return o(this,void 0,void 0,(function*(){try{const s={method:j[i],url:e,headers:a,timeout:n};["post","put"].includes(i.toLowerCase())?s.data=t.cloneDeep(r):s.params=t.cloneDeep(r);return/.json$/.test(e)?function(e){return o(this,void 0,void 0,(function*(){try{return(yield L({method:"get",url:e})).data}catch(e){throw console.error("JSON 数据请求:",e),e}}))}(e):function(e){return o(this,void 0,void 0,(function*(){try{return{code:2e4,data:(yield L(e)).data}}catch(e){throw console.error("请求数据发生错误-Error:",e),e}}))}(s)}catch(e){throw console.error("获取数据:Error:",e),e}}))}function z(e,t,i,r){return o(this,void 0,void 0,(function*(){try{const o=window.anUrl||"",a=o+(window.agentPath||"/ds/v1/api-proxy/v1/query"),n=l(i,!0);return yield L({url:a,method:"post",headers:{"Content-Type":"application/json;charset=UTF-8"},data:{body:"post"===e?n:void 0,headers:d(r)?JSON.parse(r):r,method:e,url:t}})}catch(e){throw console.error("代理请求数据:Error:",e),e}}))}function G(e,t,i,r,a){return o(this,void 0,void 0,(function*(){return a?z(t,e,i,r):H(e,t,i,r)}))}function J(e,t="",i){var r,o,n,s;const l=`${null!==(o=null===(r=null===window||void 0===window?void 0:window.BaseUrl)||void 0===r?void 0:r.replace("/management",""))&&void 0!==o?o:""}/ds/data-engine/v1/${e}/zb-query?${`token=${(null===(n=ie("YZH_EXCHANGE_TOKEN"))||void 0===n?void 0:n.YZH_EXCHANGE_TOKEN)||(null===(s=null===window||void 0===window?void 0:window.yzhAuth)||void 0===s?void 0:s.getToken())}&passid=${null===window||void 0===window?void 0:window.gdPassid}`}${(null===window||void 0===window?void 0:window.BASE_RELEASE)?"&preview=1":""}`;let d={};try{d=t?JSON.parse(t):{}}catch(e){d=t||{}}return L({method:"POST",url:l,data:{headers:i,param:d},timeout:a})}const B=(e,t)=>o(void 0,void 0,void 0,(function*(){const i=window.BaseUrl,{dateType:r="",endPeriod:o="",metricsName:n=e,startPeriod:s=""}=t;return q({method:"GET",url:`${i}ds/v1/metrics/v1/data-alarm?dateType=${r}&endPeriod=${o}&metricsName=${n}&startPeriod=${s}`,timeout:a})})),W=(e,t,i)=>o(void 0,void 0,void 0,(function*(){var r;const o=(null===(r=window.BaseUrl)||void 0===r?void 0:r.replace("/management",""))||"";t.newEncryption=!0;const n={staticFile:{method:"get",params:t,url:`${o}/ds/v1/file/v1/${e}/query`},datasource:{method:"post",url:`${o}/ds/v1/database/v1/${e}/query`,data:Object.assign({},t)}}[i];if(!n)throw new Error("Invalid data type provided");return L(Object.assign({timeout:a},n))})),X=e=>new Promise(((t,i)=>{let r;r=e.originData&&Object.keys(e.originData).length?e.originData:e.data,void 0!==r?t({data:r}):i("Failed to retrieve cdata")})),_=(e,t,i)=>{try{switch(t){case"api":{let t=ae(e,i);return{requestType:t.requestType,url:t.url,params:t.params,headers:t.headers,agency:t.agency}}case"static":return{data:e};case"datasource":{const t=oe(e.inputSql,i);return{dsName:e.dsName,dsType:"1",sql:V(t),filter:e.sqlFilter}}case"staticFile":return{dsName:e.dsName,dsType:e.dsType,sql:""};case"indicator":return{zbId:e.zbId,params:oe(e.params,i),headers:oe(e.headers,i)};case"indicatorCQ":return{zbName:e.zbName,params:oe(e.params,i)};case"packData":return{};default:throw new Error("Invalid type")}}catch(t){console.log("准备请求数据发生错误",t,e)}},Q=(e,t)=>o(void 0,void 0,void 0,(function*(){try{switch(t){case"api":return yield G(e.url,e.requestType,e.params,e.headers,e.agency);case"static":return yield X(e.data);case"datasource":return yield W(e.dsName,{dsType:e.dsType,sql:e.sql,filter:e.filter},"datasource");case"staticFile":return yield W(e.dsName,{dsType:e.dsType,sql:e.sql},"staticFile");case"indicator":return yield J(e.zbId,e.params,e.headers);case"indicatorCQ":return yield B(e.zbName,e.params);case"packData":return{};default:throw new Error("Invalid type")}}catch(e){return console.warn(e,"执行请求并获取数据发生错误"),yield new Promise(((e,t)=>{e({error:!0})}))}})),Y=(e,t,i,r=[],a=!1)=>o(void 0,void 0,void 0,(function*(){const o=t||e.tmpData.source.dataType,n=e.tmpData.source["indicatorCQ"==o?"indicator":o];if("globalData"===o){const e=r.find((e=>e.key===n.id||e.key===n.key)),t=u(n.id);if(t&&!a)return t.data;if(e){let t=yield K(e,i),r={key:n.id,data:t};return c(n.id,r),t}return}const s=_(n,o,i),l=yield Q(s,o);return(null==l?void 0:l.data)?l.data:l})),K=(e,t)=>o(void 0,void 0,void 0,(function*(){let i=Object.assign({},{tmpData:{source:e.value}});const r=i.tmpData.source.type,o=i.tmpData.source[r],a=_(o,r,t),n=yield Q(a,r);return yield Z(n.data,i,!0,t)})),Z=(e,i,r=!0,a)=>o(void 0,void 0,void 0,(function*(){try{const{converse:n,mapFields:s}=i.tmpData.source;return n&&n.use&&r?yield new Promise(((i,r)=>{const s=function(e,i,r,a,n){return o(this,void 0,void 0,(function*(){let r,o=e,{use:n,data:s}=t.cloneDeep(i);if(n)for(let e=0;e<s.length;e++)if(s[e].use){let i=s[e].dependVars,n={};a&&n&&i&&i.length&&i.map((e=>{let i=t.cloneDeep(a).filter((t=>{let i=t.mapField==e;return i&&(n[e]=t.value),i}));i&&0!=i.length||(n[e]="")})),r=yield F(s[e].code,o,n,s[e].mode?s[e].mode:"worker"),o=r.data}return o}))}(e,n,0,a);i(s)})):yield new Promise(((t,i)=>{t(e)}))}catch(t){return console.error("执行过滤器发生错误:"+t),yield new Promise(((t,i)=>{t(e)}))}})),ee=(e,t,i)=>{const{source:r}=e.tmpData,o=r.type;i?("static"===o&&r[o]&&(r[o].originData=i),"indicatorCQ"===o?r.indicator.data=t:r[o].data=t):"indicatorCQ"===o?r.indicator.data=t:r[o].data=t,e.source=t},te=(e,t,i=[],r,a,n)=>o(void 0,void 0,void 0,(function*(){try{if(null==e?void 0:e.cid){if(!N(e.cid))return void console.warn("请求已经执行!")}let o=e.tmpData.source.type,s=yield Y(e,o,i,r,n||!1);if(null==s||!s)return a&&a({error:!0}),Promise.resolve({error:!0});let l=yield Z(s,e,t,i);return ee(e,l),a&&a(l),(null==e?void 0:e.cid)&&C(e.cid),Promise.resolve(l)}catch(e){return a&&a(e),U.error("Error in updateComData"),console.error("Error in updateComData:",e),Promise.reject(e)}})),ie=e=>{const t={};if(e&&e.includes("?")){const i=e.split("?")[1].split("&");for(let e of i){const[i,r]=e.split("=").map(decodeURIComponent);t[i]=r}}return t},re=e=>{try{return(null==e?void 0:e.value)&&"string"==typeof e.value?JSON.parse(e.value):"string"==typeof e?JSON.parse(e):e}catch(t){return e}},oe=(e,t)=>{if(!t)return re(e);if("string"==typeof e){if(""===e.trim())return"";try{if("string"!=typeof JSON.parse(e))return oe(JSON.parse(e),t);{let i=e.replace(/@(\w+)|{{(\w+)}}/g,((e,i,r)=>{const o=i||r,a=t.find((e=>e.mapField===o));return a?a.value||a.originalValue||"":e}));return re(i)}}catch(i){let r=e.replace(/@(\w+)|{{(\w+)}}/g,((e,i,r)=>{const o=i||r,a=t.find((e=>e.mapField===o));return a?a.value||a.originalValue||"":e}));return re(r)}}else{if(Array.isArray(e))return e.map((e=>oe(e,t)));if("object"==typeof e&&null!==e){const i={};for(let r in e)i[r]=oe(e[r],t);return re(i)}}return re(e)},ae=(e,t)=>{const i=e.agency,r=e,{url:o=null,headers:a,params:n,requestType:s}=r,l=o?oe(o,t):void 0,d=a&&a.use?oe(a.value,t):{};return{url:l,requestType:s,params:n?oe(n,t):{},headers:d,agency:i}},ne=(e,t,i,r,a)=>o(void 0,void 0,void 0,(function*(){if(e&&e.length)for(const o of e){v(t,o.value,i)&&(yield te({tmpData:{source:{type:"globalData",globalData:{id:o.key}}}},!0,i,e,(e=>{console.log("数据更新成功-变量改变全局数据跟新")}),!0),f(r,(t=>{var r,n,s;if("globalData"===(null===(n=null===(r=null==t?void 0:t.tmpData)||void 0===r?void 0:r.source)||void 0===n?void 0:n.type)){(null===(s=null==t?void 0:t.tmpData)||void 0===s?void 0:s.source.globalData).id===o.key&&te(t,!0,i,e,(e=>{a(t,e)}),!1)}})))}})),se=(e,t,i,r,a)=>o(void 0,void 0,void 0,(function*(){e&&(yield te({tmpData:{source:{type:"globalData",globalData:{id:e.key}}}},!0,t,i,(e=>{console.log("数据更新成功-数据源编辑")}),!0),f(r,(r=>{var o,n,s;if("globalData"===(null===(n=null===(o=null==r?void 0:r.tmpData)||void 0===o?void 0:o.source)||void 0===n?void 0:n.type)){(null===(s=null==r?void 0:r.tmpData)||void 0===s?void 0:s.source.globalData).id===e.key&&te(r,!0,t,i,(e=>{a(r,e)}),!1)}})))}));class le{constructor(e,t){this.isUpdating=!1,this.des=e.des,this.field=e.field,this.id=e.id,this.key=e.key,this.mapping=e.mapping,this.mapField=e.mapField,this.type=e.type,this.originalValue=e.originalValue,this.model=(null==e?void 0:e.model)?null==e?void 0:e.model:1,this.converter=e.converter,this.converterCode=e.converterCode,this.fork=e.fork,this.delayUpdate=!!(null==e?void 0:e.delayUpdate),t&&(this.globalVariables=t),e.fork&&(this.model=5,this.forkValue=e.forkValue,this.originalValue=this.getForkedValue())}get value(){return this.fork&&(this.originalValue=this.getForkedValue()),this.converter&&this.converterCode?D(this.converterCode,this.originalValue):this.originalValue}togglePropertyState(e){let t=Object.prototype.hasOwnProperty.call(this,e);this[e]=!t||!e}getForkedValue(){if(this.forkValue&&Array.isArray(this.forkValue))return this.forkValue.map((e=>{const t=this.globalVariables.get(e);return t?t.value:null}));if(this.forkValue){const e=this.globalVariables.get(this.forkValue);return e?e.value:null}return null}updateValue(e,t){var r;const o=Object.assign({},this,e);this.des=o.des,this.field=o.field,this.mapping=o.mapping,this.type=o.type,this.originalValue=o.originalValue,this.converter=o.converter,this.converterCode=o.converterCode,this.fork=o.fork,this.delayUpdate=null==o?void 0:o.delayUpdate,this.model=null==o?void 0:o.model,e.id&&(this.id?"string"==typeof this.id?e.id instanceof Array?this.id=i([this.id,...e.id]):this.id=[this.id,e.id]:this.id instanceof Array&&(e.id instanceof Array?this.id=i([...this.id,...e.id]):this.id=i([...this.id,e.id])):this.id=e.id),e.fork&&(this.model=5,this.forkValue=null!==(r=e.forkValue)&&void 0!==r?r:this.forkValue,this.originalValue=this.getForkedValue()),t&&t(this)}updateWidthOriginalValue(e,t){var i;this.originalValue=e,this.fork&&(this.forkValue=null!==(i=this.forkValue)&&void 0!==i?i:this.forkValue,this.originalValue=this.getForkedValue()),t&&t(this)}renew(e){e&&e(this)}static create(e,t){return new le(e,t)}}class de{constructor(){this.variables=new Map,this.globalObservers=[],this.url=window.location.search,this.list=[]}clearVars(){this.list=[],this.variables.clear()}togglePropertyState(e,t,i){try{let r=this.getVariable(e);if(!r)throw new Error("没有找到相应的变量!");r.togglePropertyState(t),this.addToObjectArray(this.list,r),i&&i()}catch(e){console.error(e)}}static getInstance(){return de.instance||(de.instance=new de),de.instance}getFullUrl(){this.url=window.location.search}getAllUrlParams(){const e=new URLSearchParams(window.location.search),t={};for(const[i,r]of e.entries())t[i]=r;return t}delVariable(e,t){this.variables.delete(e),this.list=this.list.filter((t=>t.mapField!=e)),t&&t()}addUrlParamsToGlobalVars(){this.getFullUrl();let e=this.getAllUrlParams(),t=Object.keys(e),i=[];for(const r of t)i.push({mapField:r,originalValue:e[r],model:4});if(i.length)for(const e of i)this.addVariable(e)}addVariables(e){Array.isArray(e)?e.map(((e,t)=>{this.addVariable(e)})):this.addVariable(e),this.addUrlParamsToGlobalVars()}addVariable(e,t){if(!e||!(null==e?void 0:e.mapField))return console.error(e+"参数不合法!"),!1;if(this.isVariableNameExist(e.mapField)){let i=this.getVariable(e.mapField);return this.sameValue(i,e)?i:(this.editVariable(e,t),!1)}const i=le.create(e,this.variables);return this.variables.set(i.mapField,i),this.addToObjectArray(this.list,i),t&&t(i),this.notifyGlobalObservers(i),i}toJSON(e){try{return!!e&&JSON.stringify(e)}catch(e){return!1}}sameValue(e,t){if(e.mapfield!==t.mapfield)return!1;for(const i in t)if(!(["mapfield","field","key","value","name","globalVariables"].includes(i)||i in e&&e[i]==t[i]))return!1;return!0}creatVarJson(e){const{des:t,field:i,id:r,key:o,mapping:a,mapField:n,type:s,value:l,originalValue:d,model:c,converter:u,converterCode:h,fork:p,forkValue:f,update:m,delayUpdate:g}=e,v={};return void 0!==t&&(v.des=t),void 0!==i&&(v.field=i),void 0!==r&&(v.id=r),void 0!==o&&(v.key=o),void 0!==a&&(v.mapping=a),void 0!==n&&(v.mapField=n),void 0!==s&&(v.type=s),void 0!==l&&(v.value=l),void 0!==d&&(v.originalValue=d),void 0!==c&&(v.model=c),void 0!==u&&(v.converter=u),void 0!==h&&(v.converterCode=h),void 0!==p&&(v.fork=p),void 0!==f&&(v.forkValue=f),void 0!==m&&(v.update=m),void 0!==g&&(v.delayUpdate=g),v}addToObjectArray(e,t){let i=!1;for(let r=0;r<e.length;r++)if(e[r].mapField==t.mapField){e[r]=this.creatVarJson(t),i=!0;break}i||e.push(t)}editVariable(e,t){const i=this.getVariable(e.mapField);if(i&&this.isVariableNameExist(e.mapField)){if(this.sameValue(i,e))return}const r=e=>{if(!e.isUpdating){e.isUpdating=!0,this.notifyGlobalObservers(e);this.isMapFieldInForkValues(e.mapField).forEach((e=>{let t=this.getVariable(e.mapField);t&&t.renew((e=>{this.addToObjectArray(this.list,e),this.notifyGlobalObservers(e)}))})),this.addToObjectArray(this.list,e),t&&t(e),e.isUpdating=!1}};i?i.updateValue(e,r):this.addVariable(e,r)}getForkList(e){let t=this.isMapFieldInForkValues(e);return t||[]}editVariableForValue(e,t,i){const r=this.getVariable(e),o=e=>{if(!e.isUpdating){e.isUpdating=!0,this.notifyGlobalObservers(e);this.isMapFieldInForkValues(e.mapField).forEach((e=>{let t=this.getVariable(e.mapField);t&&t.renew((e=>{this.addToObjectArray(this.list,e),this.notifyGlobalObservers(e)}))})),this.addToObjectArray(this.list,e),i&&i(e),e.isUpdating=!1}};r&&r.updateWidthOriginalValue(t,o)}isMapFieldInForkValues(e){return this.getAllVariables().filter((e=>e.fork&&e.forkValue)).filter((t=>t.forkValue==e||Array.from(t.forkValue).includes(e)))}isVariableNameExist(e){return this.variables.has(e)}checkExist(e,t){if("string"==typeof e&&this.isVariableNameExist(e)){let i=this.getVariable(e);return t==i.id&&!i.id.includes(t)&&[{key:e}]}if(Array.isArray(e)){const i=e.filter((e=>{let i=this.getVariable(e);return this.isVariableNameExist(e)&&t!=i.id&&!(i.id&&i.id.includes(t))})).map((e=>({key:e})));return!!i.length&&i}return!1}getVariable(e){return this.variables.get(e)}getVariableForId(e){var i;let r=[];for(const[,t]of this.variables)(t.id===e||(null===(i=t.id)||void 0===i?void 0:i.includes(e)))&&r.push(t);return t.uniq(r)}getAllVariables(e=!1){return e?(this.list=Array.from(this.variables.values()),this.list):[...this.list]}restoreVariables(e){e.forEach((e=>{this.addVariable(e)}))}registerGlobalObserver(e){this.globalObservers.push(e)}notifyGlobalObservers(e){this.globalObservers.forEach((t=>{t.update(e)}))}}de.instance=null;const ce=de.getInstance(),ue=(e,t)=>Array.isArray(t)?t.some((t=>e&&(void 0!==e[t]||e.hasOwnProperty(t)))):"string"==typeof t&&(e&&(void 0!==e[t]||e.hasOwnProperty(t))),he=(e,t,i,r)=>{const o=((e,t,i,r)=>{var o;let a;if(ue(e,null==t?void 0:t.field)||ue(e,null==t?void 0:t.forkValue))a=e[null==t?void 0:t.field]||"";else if(ue(e.data,null==t?void 0:t.field)||ue(e.data,null==t?void 0:t.forkValue))a=e.data[null==t?void 0:t.field]||"";else{const e=b(i,r),n=(null===(o=null==e?void 0:e.tmpData)||void 0===o?void 0:o.actions)||[];for(const e of n){const i=e.vars.find((e=>(null==e?void 0:e.mapField)===(null==t?void 0:t.mapField)));if(i){a=i.value;break}}}return a})(e,t,i,r);return void 0!==o?o:t.value},pe=(e,t,i,r,o,a,n,s,l)=>{switch(e.type){case"link":window.open(e.link,e.target);break;case"page":l&&l(e);break;case"dynamic":((e,t,i,r,o)=>{const a=e.dynamic||[];for(const n of a){if(e.id!==t.cid)continue;const a=b(i,n.pid);a&&(a.activeDynamic=n.name,a.isShow=n.visible||!r||e.index===t.index-1,o({cid:a.cid,flag:n.visible}))}})(e,t,i,r,o);break;case"toggle":((e,t,i,r,o)=>{const a=e.children||[];for(const i of a){const a=i.visible&&(!r||e.index===t.index-1);o({cid:i.cid,flag:a})}})(e,t,0,r,o);break;case"update":((e,t,i,r,o)=>{const a=e.children||[];for(const e of a){const a=b(t,e.cid);a&&te(a,!0,i,r,(e=>{o({cid:a.cid,data:e})}))}})(e,i,a,n,s)}},fe=(e,i,r,o,a,n,s,l,d,c)=>{const{cid:u,actions:h,index:p}=a,{eventName:f,mode:m}=h,g=2===m;((e,i,r,o,a,n)=>{let s=ce.getVariableForId(i.cid);if(console.log("changeVarNew"),null==s?void 0:s.length)for(const l of s)if(l.type==e){let e=he(i,l,r,o);ce.editVariableForValue(l.mapField,e,(()=>{let e=a[l.mapField]||[],i=ce.getForkList(l.mapField);if(i)for(const r of i){let i=a[r.mapField];e=t.concat(e,i)}n&&n(l,t.uniq(e))}))}})(f,a,o,u,r,((e,t)=>{if(ne(d,e.mapFile,ce.getAllVariables(),o,((e,t)=>{s({cid:e.cid,data:t})})),null==t?void 0:t.length)for(const i of t){e.eventSourceId=i;const t=b(o,i);!(null==e?void 0:e.delayUpdate)&&t&&te(t,!0,ce.getAllVariables(),d,(e=>{s({cid:t.cid,data:e})}))}}));const v=((e,t,i,r,o)=>e.filter((e=>e.id===t&&e.eventType===i&&(!o||parseInt(e.index||"0")+1===parseInt(r||"0")))))(e,u,f,p,g);for(const e of v)pe(e,a,o,g,n,ce.getAllVariables(),d,s,l)},me=(e,t={})=>{let i={},r={type:"static",converse:{use:!1,data:[]},static:{data:e},api:{requestType:"get",url:"",headers:{use:!1,value:""},params:"",agency:!1,cookie:!0,autoUpdate:{open:!1,time:10},data:""}};return Object.assign(i,r,t),i},ge=(e,i)=>{let{option:r,actions:o,data:a,optionDes:n,actionsDes:s,source:l,theme:d}=((e,i)=>{let{option:r,actions:o,data:a,optionDes:n,actionsDes:s,source:l,theme:d}=t.cloneDeep(i[e]);return{option:r,actions:o,data:a,optionDes:n,actionsDes:s,source:l,theme:d}})(e,i);return{iconClass:null,isAssembly:null,source:a,cid:(Math.random().toString().substr(3,10)+Date.now()).toString(),isLock:!1,isShow:!0,tmpData:{option:r,source:me(a,l),actions:o},baseData:be(),dynamic:null,filePath:"",origin:"anov-ui",name:"",componentType:"",viewComName:e,optionComName:"AnOptionPanel",dataComName:"AnSourcePanel",eventComName:"AnActionsPanel",assemblyDeveloper:"",devEmail:"",version:"",devDept:""}},ve=(e,i,r)=>{let o=ge(e,i);return r?t.merge(o,r):o},be=e=>{let t={left:0,top:0,width:100,height:100,angle:0,penetrate:0,opacity:100,perspective:100,rotateX:0,rotateY:0,rotateZ:0,transformOriginX:"center",transformOriginY:"center",transformSwitch:!1};return e?Object.assign(t,e):t};class ye{constructor(e,t,i){this.theme=null,this.plant=null,this.list=[],this.titleHeqadeHeight=70,this.clearance=3,this.checkComponentIntersection=(e,t,i=10)=>{const r=e.left,o=e.left+e.width,a=e.top,n=e.top+e.height,s=t.left,l=t.left+t.width,d=t.top,c=t.top+t.height,u=r<l&&o>s&&a<c&&n>d,h=Math.abs(e.left+e.width/2-(t.left+t.width/2)),p=Math.abs(e.top+e.height/2-(t.top+t.height/2));return u||h<i&&p<i},this.calculateCombinedComponent=e=>{if(0===e.length)return{left:0,top:0,width:0,height:0};let t=e[0].left,i=e[0].top,r=e[0].left+e[0].width,o=e[0].top+e[0].height;for(let a=1;a<e.length;a++){const n=e[a];t=Math.min(t,n.left),i=Math.min(i,n.top),r=Math.max(r,n.left+n.width),o=Math.max(o,n.top+n.height)}return{left:t,top:i,width:r-t,height:o-i}},this.getAnTextNormaltText=e=>{var t,i;try{return null===(i=null===(t=null==e?void 0:e.tmpData)||void 0===t?void 0:t.option)||void 0===i?void 0:i.text}catch(e){return console.error("配置优化(ConfigOptimizer):",e),""}},this.initProp(e),this.upgradePlant(),this.staticComponentData=t,this.upgradeHeaderComponent(),i&&Object.assign(this,i)}isStringOrObject(e){return"string"==typeof e?"string":"object"==typeof e&&null!==e&&"object"}initProp(e){try{let t,i=this.isStringOrObject(e);if(i&&"string"===i)t=JSON.parse(e);else{if(!i||"object"!==i)throw new Error(`initProp fn error :-- 传入参数${e}不合法!`);t=e}if(t){this.originData=t;const{theme:e,plant:i,list:r}=t;this.theme=e,this.plant=i,this.list=r,this.filterFileGroup()}}catch(e){console.error("配置优化(ConfigOptimizer):",e)}}upgradePlant(){this.plant&&(this.plant.option.bg={type:1,code:"70942ec525344c96aa32b81b2c9155f6",path:"/anov-prod/resources/page/png/bg22 科技星球背景.png",thumb:"/anov-prod/resources/page/thumbnail/1e48f8fb26ec4edfb1a0f499627e84fc.png"})}areComponentsIntersecting(e,t){let i=e.baseData,r=t.baseData;const o=Math.max(0,Math.min(i.left+i.width,r.left+r.width)-Math.max(i.left,r.left)),a=Math.max(0,Math.min(i.top+i.height,r.top+r.height)-Math.max(i.top,r.top));return o>0&&a>0}filterFileGroup(){this.list=t.cloneDeep(this.list).map((e=>{var t,i;if(1===(null===(t=null==e?void 0:e.children)||void 0===t?void 0:t.length)&&!(null===(i=null==e?void 0:e.children[0])||void 0===i?void 0:i.children)){const t=e.children[0],{left:i,top:r}=e.baseData;return t.baseData.left=i,t.baseData.top=r,t}return e}))}getText(e,t,i){const r=document.createElement("canvas").getContext("2d");if(!r)throw new Error("Failed to get 2D context from canvas.");r.font=`${i}px ${t}`;return r.measureText(e).width}calculateMaxWidths(e){const t=Math.min(...e.map((e=>e.width))),i=[];let r=[],o=e[0].width;for(const a of e){const e=a.width;Math.abs(e-o)<=t?r.push(e):(r.length>0&&i.push(r),r=[e]),o=e}r.length>0&&i.push(r);const a=[];for(const e of i){const t=Math.max(...e);a.push(t)}return a}findClosestValue(e,t){let i=t[0],r=Math.abs(e-i);for(const o of t){const t=Math.abs(e-o);t<r&&(r=t,i=o)}return i}adjustHeightAndTop(e,t){const i=t-e.height;return Object.assign(Object.assign({},e),{height:t,top:e.top-i/2})}findNearestComponent(e,i,r){let o=null,a=1/0;i.tmpData.option.textNormal.text;try{const n=t.cloneDeep(e).sort(((e,t)=>e.baseData.top-t.baseData.top)).sort(((e,t)=>e.baseData.left-t.baseData.left)).filter((e=>!(e.cid===i.cid||"AnTextNormal"===e.viewComName||r&&r.includes(e.cid)))),s=t.cloneDeep(i).baseData;s.top,s.height;for(const e of n){const t=e.baseData;t.top,t.height;if(s.left<t.left+t.width&&s.left+s.width>t.left){const i=t.top-s.top;i<a&&i<100&&(a=i,o=e)}}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return o}findNearestComponentForPoint(e,t,i){let r=null,o=1/0;t.tmpData.option.textNormal.text;try{const a=e.sort(((e,t)=>e.baseData.top-t.baseData.top)).sort(((e,t)=>e.baseData.left-t.baseData.left)).filter((e=>!(e.cid===t.cid||"AnTextNormal"===e.viewComName||i&&i.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let i=this.getDistance(n.left,n.top+n.height,t.left,t.top);i<o&&i<n.width&&(o=i,r=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return r}findNearestComponentForTitlePoint(e,t,i){let r=null,o=1/0;t.tmpData.option.textNormal.text;try{const a=e.sort(((e,t)=>e.baseData.top-t.baseData.top)).sort(((e,t)=>e.baseData.left-t.baseData.left)).filter((e=>!(e.cid===t.cid||"AnTextNormal"===e.viewComName||i&&i.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let i=this.getDistance(n.left,n.top+n.height,t.left,t.top);i<o&&i<n.width&&t.top-n.top>100&&(o=i,r=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return r}findNearestTitleForPoint(e,t,i){let r=null,o=1/0;t.tmpData.option.textNormal.text;try{const a=e.sort(((e,t)=>e.baseData.top-t.baseData.top)).sort(((e,t)=>e.baseData.left-t.baseData.left)).filter((e=>!(e.cid===t.cid||"AnTextNormal"===e.viewComName||i&&i.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let i=t.top-n.top;i<o&&i<n.width&&t.top-n.top>100&&(o=i,r=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return r}getDistance(e,t,i,r){return Math.sqrt(Math.pow(i-e,2)+Math.pow(r-t,2))}findNearestComponent2(e,i,r){let o=null,a=1/0,n=t.cloneDeep(e).sort(((e,t)=>e.baseData.top-t.baseData.top));try{const e=n.filter((e=>!(e.cid===i.cid||"AnTextNormal"===e.viewComName||r&&r.includes(e.cid)))),s=t.cloneDeep(i).baseData,l=s.top+s.height;for(const t of e){const e=t.baseData,i=e.top+e.height;if(s.left<e.left+e.width&&s.left+s.width>e.left){const e=i-l;e>=0&&e<a&&(a=e,o=t)}}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return o}verticalDistance(e,t){e.left,e.width;const i=e.top+e.height,r=(t.left,t.width,t.top);return Math.abs(i-r)}extractAmount(e){const t=e.match(/(\d{1,3}(?:,\d{3})*)(\D+)/);if(t){const e=t[1].replace(/,/g,"");return[parseInt(e,10),t[2].trim()]}return[!1,!1]}getAnTextNormal(){return this.list.filter((e=>"AnTextNormal"==e.viewComName))}getAnDeckTitle3(){return this.list.filter((e=>"AnDeckTitle3"==e.viewComName)).sort(((e,t)=>e.baseData.left-t.baseData.left))}judgeAnOdometer(){let e=this.getAnTextNormal().sort(((e,t)=>e.baseData.left-t.baseData.left)),t=[],i=new Set;for(const r of e){if(i.has(r.cid))continue;let o=[];for(const t of e){if(!i.has(t.cid)&&r.cid!=t.cid){this.checkComponentIntersection(r.baseData,t.baseData)&&(i.add(t.cid),i.add(r.cid),o.push(t))}}t.push([r,...o])}let r=[];for(const e of t)for(const t of e){let i=this.getAnTextNormaltText(t);this.extractAmount(i).every((e=>e))&&r.push(e)}return r}createAnOdometer(){var e,i;let r=this.judgeAnOdometer();for(const o of r){let r,a,n,s=this.calculateCombinedComponent(o.map((e=>e.baseData)));for(const e of o){let i=this.getAnTextNormaltText(e),o=this.extractAmount(i);o.every((e=>!e))&&(r=i),o.every((e=>e))&&(a=o[0],n=o[1]),t.remove(this.list,(t=>t.cid==e.cid))}let l=ve("AnIndicatorNormal",this.staticComponentData,t.cloneDeep({baseData:s}));(null===(i=null===(e=null==l?void 0:l.tmpData)||void 0===e?void 0:e.source)||void 0===i?void 0:i.static)&&(l.tmpData.source.static.data={text:r,num:a,unit:n},l.tmpData.source.static.originData={text:r,num:a,unit:n}),this.list.push(l)}}upgradeHeaderComponent(){for(let e=0;e<this.list.length;e++){const t=this.list[e];"AnDeckHeader3"==t.viewComName&&(t.baseData.left=0,t.baseData.top=0)}}upgradeTitleComponent(){let e=this.getAnDeckTitle3().map((e=>e.baseData)),t=this.calculateMaxWidths(e);for(let e=0;e<this.list.length;e++){const i=this.list[e];if("AnDeckTitle3"==i.viewComName){let e=this.findClosestValue(i.baseData.width,t);i.baseData.width=e>300?e:300,i.baseData=this.adjustHeightAndTop(i.baseData,this.titleHeqadeHeight)}}this.removeErroneousComponents()}containsFractionStructure(e){return/\b\d+\/\d+\b/.test(e)}removeErroneousComponents(){let e=this.getAnDeckTitle3(),t=[];for(let i=0;i<e.length;i++){const r=e[i];let o=r.tmpData.option.textNormal.text;if(this.containsFractionStructure(o))for(let i=0;i<e.length;i++){const o=e[i];if(r.cid!=o.cid){this.areComponentsIntersecting(r,o)&&t.push(r.cid)}}}this.list=this.list.filter((e=>!t.includes(e.cid)))}upgradeGroupComponent(){try{let e=this.getAnDeckTitle3(),t=this.list.filter((e=>"AnDeckTitle3"!=e.viewComName&&"AnDeckHeader3"!=e.viewComName&&"AnTextNormal"!=e.viewComName)),i=[],r=[];for(let o=0;o<e.length;o++){const a=e[o];let n=this.findNearestComponentForPoint(t,a,i);if(n&&n.cid&&i.push(n.cid),n){a.baseData.left=n.baseData.left;let t=this.upgradeComponentHeight(a,e,r);t&&t>=30&&(n.baseData=Object.assign({},n.baseData,{top:a.baseData.top+a.baseData.height+this.clearance}))}}}catch(e){console.error("配置优化(ConfigOptimizer):",e)}}upgradeComponentHeight(e,i,r=[]){const o=e;let a=this.findNearestTitleForPoint(t.cloneDeep(i),o);return a?a.baseData.top-o.baseData.top-this.titleHeqadeHeight:1080-o.baseData.top-this.titleHeqadeHeight}getData(){return this.originData.list=this.list,this.originData.plant=this.plant,this.originData}}const we=new(require("mockjs"));class De{constructor(){this.names=["Line"],console.log(1)}static getInstance(){return De.instance||(De.instance=new De),De.instance}createLine(){return{xAxis:{type:"category",data:we.generateRandomNameArray(7,3,6)},yAxis:{type:"value"},series:[{data:we.generateRandomIntArray(7,100,300),type:"line"}]}}}De.instance=null;const Ne=De.getInstance();const Ce=new class{constructor(){this.directions=["row","column"],this.direction="column",this.splitNumbers=24,this.margin=[0,0]}baseLayout(e){const t=(null==e?void 0:e.maRrows)?null==e?void 0:e.maRrows:this.splitNumbers,i=(null==e?void 0:e.colNum)?null==e?void 0:e.colNum:this.splitNumbers,r=e.wrapWidth/i,o=e.wrapHeight/t;let a=O(this.directions);a&&(this.direction=a);let n=[];if("row"===this.direction){let e=O([2,3,4]);n=this.simulateRandomSegments(24,4,12,e)}else{let e=O([2,3]);n=this.simulateRandomSegments(24,4,12,e)}let s=[],l=[];if("row"===this.direction){for(let e=0;e<n.length;e++)if(0==e)s.push({x:0,y:0,w:n[e],h:24,i:e,wStep:r,hStep:o});else{let t=s[e-1].x;s.push({x:n[e-1]+t,y:0,w:n[e],h:24,i:e,wStep:r,hStep:o})}for(let e=0;e<s.length;e++){const t=s[e];let i=O([2,3]),a=this.simulateRandomSegments(24,6,12,i);for(let i=0;i<a.length;i++){const n=a[i];l.push({x:t.x,y:n,w:t.w,h:n,i:10*e+i,wStep:r,hStep:o})}}}else{for(let e=0;e<n.length;e++)if(0==e)s.push({x:0,y:0,w:24,h:n[e],i:e,wStep:r,hStep:o});else{let t=s[e-1].y;s.push({x:0,y:n[e-1]+t,w:24,h:n[e],i:e,wStep:r,hStep:o})}for(let e=0;e<s.length;e++){const t=s[e];let i=O([1,2,3,4]),a=this.simulateRandomSegments(24,5,12,i),n=[];for(let i=0;i<a.length;i++){const s=a[i];if(0==i)n.push({x:0,y:t.y,w:s,h:t.h,i:10*e+i,wStep:r,hStep:o}),l.push({x:0,y:t.y,w:s,h:t.h,i:10*e+i,wStep:r,hStep:o});else{let d=n[i-1].x;n.push({x:a[i-1]+d,y:t.y,w:s,h:t.h,i:10*e+i,wStep:r,hStep:o}),l.push({x:a[i-1]+d,y:t.y,w:s,h:t.h,i:10*e+i,wStep:r,hStep:o})}}}}return{layouts:l.map((e=>(e.chartsOption=Ne.createLine(),e))),option:{colNum:i,margin:(null==e?void 0:e.margin)?null==e?void 0:e.margin:this.margin,isDraggable:!!(null==e?void 0:e.isDraggable)&&(null==e?void 0:e.isDraggable),isResizable:!!(null==e?void 0:e.isResizable)&&(null==e?void 0:e.isResizable),verticalCompact:!(null==e?void 0:e.verticalCompact)||(null==e?void 0:e.verticalCompact),useCssTransforms:!(null==e?void 0:e.useCssTransforms)||(null==e?void 0:e.useCssTransforms),rowHeight:e.wrapHeight/t,maRrows:t}}}simulateRandomSegments(e,t,i,r){const o=[];let a=e,n=r;for(;n>0;)if(1===n)o.push(a),n--;else{const e=Math.min(i,a-t*(n-1)),r=Math.floor(Math.random()*(e-t+1))+t;o.push(r),a-=r,n--}return o}simulateRandomSegments2(e,t,i,r){const o=[];let a=e,n=r;for(;n>0;)if(1==n){const t=e-o.reduce(((e,t)=>e+t),0);o.push(t),n--}else{let e=Math.floor(Math.random()*i),r=Math.max(t,e),s=a-t*n;const l=Math.min(r,s);o.push(l),a-=l,n--}return o}};export{ye as ConfigOptimizer,de as GlobalVariables,$ as Http,U as Log,z as agentData,C as delFetchStatus,Ce as displayGenerator,ee as editItem,fe as emitEvent,K as fetchDataByGlobal,Y as fetchDataByType,Z as filterData,b as findItemDeep,y as findItemDeep2,H as getData,G as getDataForApi,W as getDataForSource,X as getDataForStatic,J as getDataForZb,B as getDataForZbCQ,u as getSessionData,l as getStandardData,m as getStringVars,he as getVarDefaultVal,ce as globalVars,v as hasVar,d as isJSON,f as recursion,w as safeEval,D as safeEvalForCode,N as setFetchStatus,c as setSessionData,ne as updataGlobalDataSourceForVar,te as updateComData,se as updateGlobalDataSource};
|
|
1
|
+
import t from"axios";import e,{uniq as i}from"lodash";import r from"crypto-js";function o(t,e,i,r){return new(i||(i=Promise))((function(o,a){function n(t){try{l(r.next(t))}catch(t){a(t)}}function s(t){try{l(r.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(n,s)}l((r=r.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const a=5e3,n=5e3,s=(e="",i)=>{let r=t.create({baseURL:e,timeout:a,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}});return r.interceptors.request.use((function(t){return sessionStorage.getItem("anov-go-token")&&"null"!=sessionStorage.getItem("anov-go-token")&&(t.headers["X-ANOV-ACCESS-TOKEN"]=sessionStorage.getItem("anov-go-token")),sessionStorage.getItem("unify-access-token")&&"null"!=sessionStorage.getItem("unify-access-token")&&(t.headers["X-UNIFY-ACCESS-TOKEN"]=sessionStorage.getItem("unify-access-token")),sessionStorage.getItem("dgcc_authorization")&&"null"!=sessionStorage.getItem("dgcc_authorization")&&(t.headers.dgcc_authorization=sessionStorage.getItem("dgcc_authorization")),"post"===t.method?(t.headers["Content-Type"]="application/json;",t):"get"===t.method?t:"put"===t.method?(t.headers["Content-Type"]="application/json; charset=UTF-8",t):"delete"===t.method?t:void 0}),(function(t){return Promise.reject(t)})),r.interceptors.response.use((function(t){return 200===t.status||t.data.code,i&&i(t),t.data}),(function(t){return i&&i(null==t?void 0:t.response),Promise.reject(t.response)})),r};function l(t,e=!1){return e?d(t)?t:JSON.stringify(t):d(t)?JSON.parse(t):t}const d=t=>{if("string"==typeof t)try{const e=JSON.parse(t);return"object"==typeof e&&null!==e}catch(t){return!1}return!1},c=(t,e)=>{try{const i=JSON.stringify(e);sessionStorage.setItem(t,i)}catch(e){console.error(`Error setting session data for key ${t}:`,e)}},u=t=>{const e=sessionStorage.getItem(t);if(e)try{return JSON.parse(e)}catch(e){console.error(`Error parsing session data for key ${t}:`,e)}return null},h=t=>{for(const e of t)e.code&&(e.code=e.code.replace(/>/g,">").replace(/</g,"<"))},p=(t,e)=>{t instanceof Map?t.forEach((t=>{e([t])})):Array.isArray(t)&&t.forEach((t=>{e(t.children)}))},f=(t,e)=>{const i=t=>{var r,o,a;if(t)for(const n of t){const t=null===(a=null===(o=null===(r=null==n?void 0:n.tmpData)||void 0===r?void 0:r.source)||void 0===o?void 0:o.converse)||void 0===a?void 0:a.data;(null==t?void 0:t.length)&&h(t),e(n),n.children?i(n.children):n.dynamicChildren?p(n.dynamicChildren,i):n.stateChildren&&i(n.stateChildren)}};i(t)},m=(t,e,i,r)=>{const o=t.match(/({{[\w]*}})|((@)[\w]*)/gm);if(o){const t=o.map((t=>t.replace(/{{|}}|@/gm,"")));for(const o of t)if(o&&e&&!(e.findIndex((t=>t.mapField===o))<0))return i&&r&&g(r,o,i.cid),!0}return!1},g=(t,e,i)=>{if(!t)throw new Error("Share variable tree is not defined");if("string"!=typeof e)throw new Error("Variable name should be a string");if(!i)throw new Error("ID is required");Array.isArray(t[e])||(t[e]=[]),t[e].includes(i)||t[e].push(i)},v=(t,e,i)=>{var r;let o=!1;const a=null==e?void 0:e.converse;if(a&&a.use&&a.data.length)for(const e of a.data)if((null==e?void 0:e.dependVars)&&e.dependVars.includes(t))return!0;const n=null==e?void 0:e[null==e?void 0:e.type];return((null==n?void 0:n.inputSql)||(null==n?void 0:n.url)||(null==n?void 0:n.headers)||(null==n?void 0:n.params))&&(o=m(n.inputSql||n.url||(null===(r=n.headers)||void 0===r?void 0:r.value)||n.params,i)),o},b=(t,i,r=!1)=>{let o=null;const a=t=>{for(const n of t){if(n.cid===i){o=n,r&&e.remove(t,(t=>t.cid===i));break}if(n.children&&a(n.children),n.dynamicChildren&&Array.isArray(n.dynamicChildren))for(const[,t]of Array.from(n.dynamicChildren))a(t);n.stateChildren&&a(n.stateChildren)}};return a(t),o},y=(t,i,r)=>{let o=!1;const a=t=>{for(let n=0;n<t.length;n++){if(t[n].cid==i){o=t[n],r&&e.remove(t,(t=>t.cid==i));break}if(t[n].children)a(t[n].children);else if(t[n].dynamicChildren){if(t[n].dynamicChildren instanceof Map){let e=Array.from(t[n].dynamicChildren);for(let t=0;t<e.length;t++)if(e[t]instanceof Array){let i=e[t][1];a(i)}}else if(t[n].dynamicChildren instanceof Array){let e=t[n].dynamicChildren;for(let t=0;t<e.length;t++)if(e[t]instanceof Array){let i=e[t][1];a(i)}}}else t[n].stateChildren&&a(t[n].stateChildren)}};return a(t),o||!1};function w(t,e,i){const r={};i&&i.forEach((t=>{(null==t?void 0:t.name)&&(r[t.name]=t.value||t.originvalue)}));try{return new Function("data","vars",t)(e,r)}catch(t){return console.error(t),e}}function D(t,i){let r=e.cloneDeep(i);try{return new Function("data",t)(r)}catch(t){return console.error(t),r}}const N=t=>{let e=window.goFetchList;return e||(window.goFetchList={},e=window.goFetchList),e[t]?!e[t]&&void 0:(e[t]={id:t,time:(new Date).getTime()},!0)},C=t=>{let e=window.goFetchList;e&&e[t]&&delete e[t]},k="anov@2019:helloX",A="anov@2020:helloX";function V(t){let e=r.enc.Utf8.parse(k),i=r.enc.Utf8.parse(A);return r.AES.encrypt(t,e,{iv:i,mode:r.mode.CBC,padding:r.pad.Pkcs7}).toString()}function O(t,e){if(0===t.length)throw new Error("Array is empty.");if(!e)return t[Math.floor(Math.random()*t.length)];if(e.length!==t.length)throw new Error("Length of probabilities array must match length of array.");const i=e.reduce(((t,e)=>t+e),0),r=Math.random()*i;let o=0;for(let i=0;i<t.length;i++)if(o+=e[i],r<o)return t[i];return t[0]}const S=new Blob(["\nfunction proxyObj(originObj) {\n const exposeObj = new Proxy(originObj, {\n has: (target, key) => {\n if (['fetch', 'XMLHttpRequest', 'postMessage'].indexOf(key) >= 0) {\n throw new Error('Illegal operation for key'+key)\n } else {\n return target[key]\n }\n },\n })\n return exposeObj\n}\nfunction compileCode(src) {\n src = 'with (exposeObj) {'+src+'}'\n //console.log(src)\n return new Function('exposeObj', src)\n}\nfunction run(code) {\n let proxy = proxyObj({})\n let result = compileCode(code)(proxy)\n return result\n}\n\nonmessage = (e) => {\n try {\n let result = run(e.data.code)\n postMessage({\n code: 1,\n result,\n })\n } catch (err) {\n postMessage({\n code: -1,\n err,\n })\n }\n}\n"]),x=URL.createObjectURL(S);function F(t,e,i={},r="worker"){return o(this,void 0,void 0,(function*(){try{if("window"==r){let[r,o]=[["data"],[e]];"object"==typeof i&&Object.keys(i).forEach((t=>{r.push(t),o.push(i[t])}));const a=new Function(...r,t);return{success:!0,data:a(...o)}}{let[r,a,n]=[e,i,""];"object"==typeof r&&(r=JSON.stringify(e)),"object"==typeof i&&(a=JSON.stringify(i)),Object.keys(i).forEach((t=>n+=`${t},`));let s=`let data=eval(${r}); \n let app=${JSON.stringify({})};`;s+=n?`let {${n}} = eval(${a}); `:"",s+=`${t}`;let l=yield function(t,e=5e3){return o(this,void 0,void 0,(function*(){let i=new Worker(x);return new Promise(((r,o)=>{const a=()=>{clearTimeout(s),i.removeEventListener("message",n),i.terminate(),i=null},n=t=>{let{code:e,result:i,err:n}=t.data;a(),1===e?r(i):o(n)};i.postMessage({code:t}),i.addEventListener("message",n);let s=setTimeout((()=>{a(),o("timeout")}),e)}))}))}(s);return{success:!0,data:l}}}catch(t){return{success:!1,error:t,data:e}}}))}var T,E,j,P;!function(t){t.StaticFile="staticFile",t.DataSource="datasource"}(T||(T={})),function(t){t.json="application/json;charset=UTF-8",t.form="application/x-www-form-urlencoded; charset=UTF-8"}(E||(E={})),function(t){t.get="GET",t.post="POST",t.put="PUT",t.patch="PATCH",t.delete="DELETE"}(j||(j={}));class I{constructor(t){this.db=null,this.dbName=t.databaseName,this.tableName=t.tableName,this.keyPath=t.keyPath}static getInstance(t){return I.instance||(I.instance=new I(t)),I.instance}init(){return o(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{const i=indexedDB.open(this.dbName,1);i.onerror=t=>{e(t.target.error)},i.onupgradeneeded=t=>{this.db=t.target.result,this.db.objectStoreNames.contains(this.tableName)||this.db.createObjectStore(this.tableName,{keyPath:this.keyPath})},i.onsuccess=e=>{this.db=e.target.result,t()}}))}))}addRecord(t){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((e,i)=>{const r=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).add(t);r.onsuccess=()=>{e()},r.onerror=t=>{i(t.target.error)}}))}))}deleteRecord(t){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((e,i)=>{const r=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).delete(t);r.onsuccess=()=>{e()},r.onerror=t=>{i(t.target.error)}}))}))}updateRecord(t){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((e,i)=>{const r=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).put(t);r.onsuccess=()=>{e()},r.onerror=t=>{i(t.target.error)}}))}))}getRecord(t){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((e,i)=>{const r=this.db.transaction([this.tableName],"readonly").objectStore(this.tableName).get(t);r.onsuccess=()=>{e(r.result)},r.onerror=t=>{i(t.target.error)}}))}))}getAllRecords(){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,e)=>{const i=this.db.transaction([this.tableName],"readonly").objectStore(this.tableName).getAll();i.onsuccess=()=>{t(i.result)},i.onerror=t=>{e(t.target.error)}}))}))}}I.instance=null,function(t){t[t.FATAL=0]="FATAL",t[t.ERROR=1]="ERROR",t[t.WARN=2]="WARN",t[t.INFO=3]="INFO",t[t.DEBUG=4]="DEBUG",t[t.TRACE=5]="TRACE"}(P||(P={}));const M={databaseName:"GODB",tableName:"go-log",keyPath:"time"};class R{constructor(){this.logLevel=P.INFO,this.indexedDBInstance=I.getInstance(M);try{this.indexedDBInstance.init(),console.log("IndexedDB 初始化成功。")}catch(t){console.error("初始化 IndexedDB 时出错:",t)}}static getInstance(){return R.instance||(R.instance=new R),R.instance}setLogLevel(t){this.logLevel=t}getColor(t){switch(t){case P.FATAL:return"[31;1m";case P.ERROR:return"[31m";case P.WARN:return"[33m";case P.INFO:return"[32m";case P.DEBUG:return"[36m";case P.TRACE:return"[34m";default:return"[0m"}}log(t,e){if(e<=this.logLevel){const i=(new Date).toISOString(),r=`[${i}] [${P[e]}]`,o=this.getColor(e);if(null===window||void 0===window?void 0:window.goDev)console.log(`${o}${r} ${t}[0m`);else{let e=u("anov-go-userInfo"),a=u("anov-go-proid"),n=` [操作人:${null==e?void 0:e.userName} 项目ID:${a}] `;const s={time:i,value:`${t}`};try{this.indexedDBInstance.addRecord(s)}catch(t){console.error("添加记录时出错:",t)}console.log(`${o}${r} ${n} ${t}[0m`)}}}fatal(t){this.log(t,P.FATAL)}error(t){this.log(t,P.ERROR)}warn(t){this.log(t,P.WARN)}info(t){this.log(t,P.INFO)}debug(t){this.log(t,P.DEBUG)}trace(t){this.log(t,P.TRACE)}}const U=R.getInstance(),$=(t,e)=>"string"!=typeof t?Promise.reject(new Error("URL should be a string")):s(t,e),q=s();let L=s();function H(t,i="get",r={},a={}){return o(this,void 0,void 0,(function*(){try{const s={method:j[i],url:t,headers:a,timeout:n};["post","put"].includes(i.toLowerCase())?s.data=e.cloneDeep(r):s.params=e.cloneDeep(r);return/.json$/.test(t)?function(t){return o(this,void 0,void 0,(function*(){try{return(yield q({method:"get",url:t})).data}catch(t){throw console.error("JSON 数据请求:",t),t}}))}(t):function(t){return o(this,void 0,void 0,(function*(){try{return{code:2e4,data:(yield q(t)).data}}catch(t){throw console.error("请求数据发生错误-Error:",t),t}}))}(s)}catch(t){throw console.error("获取数据:Error:",t),t}}))}function z(t,e,i,r){return o(this,void 0,void 0,(function*(){try{const o=window.anUrl||"",a=o+(window.agentPath||"/ds/v1/api-proxy/v1/query"),n=l(i,!0);return yield q({url:a,method:"post",headers:{"Content-Type":"application/json;charset=UTF-8"},data:{body:"post"===t?n:void 0,headers:d(r)?JSON.parse(r):r,method:t,url:e}})}catch(t){throw console.error("代理请求数据:Error:",t),t}}))}function G(t,e,i,r,a){return o(this,void 0,void 0,(function*(){return a?z(e,t,i,r):H(t,e,i,r)}))}function J(t,e="",i){var r,o,n,s;const l=`${null!==(o=null===(r=null===window||void 0===window?void 0:window.BaseUrl)||void 0===r?void 0:r.replace("/management",""))&&void 0!==o?o:""}/ds/data-engine/v1/${t}/zb-query?${`token=${(null===(n=it("YZH_EXCHANGE_TOKEN"))||void 0===n?void 0:n.YZH_EXCHANGE_TOKEN)||(null===(s=null===window||void 0===window?void 0:window.yzhAuth)||void 0===s?void 0:s.getToken())}&passid=${null===window||void 0===window?void 0:window.gdPassid}`}${(null===window||void 0===window?void 0:window.BASE_RELEASE)?"&preview=1":""}`;let d={};try{d=e?JSON.parse(e):{}}catch(t){d=e||{}}return q({method:"POST",url:l,data:{headers:i,param:d},timeout:a})}const B=(t,e)=>o(void 0,void 0,void 0,(function*(){const i=window.BaseUrl,{dateType:r="",endPeriod:o="",metricsName:n=t,startPeriod:s=""}=e;return L({method:"GET",url:`${i}ds/v1/metrics/v1/data-alarm?dateType=${r}&endPeriod=${o}&metricsName=${n}&startPeriod=${s}`,timeout:a})})),W=(t,e,i)=>o(void 0,void 0,void 0,(function*(){var r;const o=(null===(r=window.BaseUrl)||void 0===r?void 0:r.replace("/management",""))||"";e.newEncryption=!0;const n={staticFile:{method:"get",params:e,url:`${o}/ds/v1/file/v1/${t}/query`},datasource:{method:"post",url:`${o}/ds/v1/database/v1/${t}/query`,data:Object.assign({},e)}}[i];if(!n)throw new Error("Invalid data type provided");return q(Object.assign({timeout:a},n))})),X=t=>new Promise(((e,i)=>{let r;r=t.originData&&Object.keys(t.originData).length?t.originData:t.data,void 0!==r?e({data:r}):i("Failed to retrieve cdata")})),_=(t,e,i)=>{try{switch(e){case"api":{let e=at(t,i);return{requestType:e.requestType,url:e.url,params:e.params,headers:e.headers,agency:e.agency}}case"static":return{data:t};case"datasource":{const e=ot(t.inputSql,i);return{dsName:t.dsName,dsType:"1",sql:V(e),filter:t.sqlFilter}}case"staticFile":return{dsName:t.dsName,dsType:t.dsType,sql:""};case"indicator":return{zbId:t.zbId,params:ot(t.params,i),headers:ot(t.headers,i)};case"indicatorCQ":return{zbName:t.zbName,params:ot(t.params,i)};case"packData":return{};default:throw new Error("Invalid type")}}catch(e){console.log("准备请求数据发生错误",e,t)}},Q=(t,e)=>o(void 0,void 0,void 0,(function*(){try{switch(e){case"api":return yield G(t.url,t.requestType,t.params,t.headers,t.agency);case"static":return yield X(t.data);case"datasource":return yield W(t.dsName,{dsType:t.dsType,sql:t.sql,filter:t.filter},"datasource");case"staticFile":return yield W(t.dsName,{dsType:t.dsType,sql:t.sql},"staticFile");case"indicator":return yield J(t.zbId,t.params,t.headers);case"indicatorCQ":return yield B(t.zbName,t.params);case"packData":return{};default:throw new Error("Invalid type")}}catch(t){return console.warn(t,"执行请求并获取数据发生错误"),yield new Promise(((t,e)=>{t({error:!0})}))}})),Y=(t,e,i,r=[],a=!1)=>o(void 0,void 0,void 0,(function*(){const o=e||t.tmpData.source.dataType,n=t.tmpData.source["indicatorCQ"==o?"indicator":o];if("globalData"===o){const t=r.find((t=>t.key===n.id||t.key===n.key)),e=u(n.id);if(e&&!a)return e.data;if(t){let e=yield K(t,i),r={key:n.id,data:e};return c(n.id,r),e}return}const s=_(n,o,i),l=yield Q(s,o);return(null==l?void 0:l.data)?l.data:l})),K=(t,e)=>o(void 0,void 0,void 0,(function*(){let i=Object.assign({},{tmpData:{source:t.value}});const r=i.tmpData.source.type,o=i.tmpData.source[r],a=_(o,r,e),n=yield Q(a,r);return yield Z(n.data,i,!0,e)})),Z=(t,i,r=!0,a)=>o(void 0,void 0,void 0,(function*(){try{const{converse:n,mapFields:s}=i.tmpData.source;return n&&n.use&&r?yield new Promise(((i,r)=>{const s=function(t,i,r,a,n){return o(this,void 0,void 0,(function*(){let r,o=t,{use:n,data:s}=e.cloneDeep(i);if(n)for(let t=0;t<s.length;t++)if(s[t].use){let i=s[t].dependVars,n={};a&&n&&i&&i.length&&i.map((t=>{let i=e.cloneDeep(a).filter((e=>{let i=e.mapField==t;return i&&(n[t]=e.value),i}));i&&0!=i.length||(n[t]="")})),r=yield F(s[t].code,o,n,s[t].mode?s[t].mode:"worker"),o=r.data}return o}))}(t,n,0,a);i(s)})):yield new Promise(((e,i)=>{e(t)}))}catch(e){return console.error("执行过滤器发生错误:"+e),yield new Promise(((e,i)=>{e(t)}))}})),tt=(t,e,i)=>{const{source:r}=t.tmpData,o=r.type;i?("static"===o&&r[o]&&(r[o].originData=i),"indicatorCQ"===o?r.indicator.data=e:r[o].data=e):"indicatorCQ"===o?r.indicator.data=e:r[o].data=e,t.source=e},et=(t,e,i=[],r,a,n)=>o(void 0,void 0,void 0,(function*(){try{if(null==t?void 0:t.cid){if(!N(t.cid))return void console.warn("请求已经执行!")}let o=t.tmpData.source.type,s=yield Y(t,o,i,r,n||!1);if(null==s||!s)return a&&a({error:!0}),Promise.resolve({error:!0});let l=yield Z(s,t,e,i);return tt(t,l),a&&a(l),(null==t?void 0:t.cid)&&C(t.cid),Promise.resolve(l)}catch(t){return a&&a(t),U.error("Error in updateComData"),console.error("Error in updateComData:",t),Promise.reject(t)}})),it=t=>{const e={};if(t&&t.includes("?")){const i=t.split("?")[1].split("&");for(let t of i){const[i,r]=t.split("=").map(decodeURIComponent);e[i]=r}}return e},rt=t=>{try{return(null==t?void 0:t.value)&&"string"==typeof t.value?JSON.parse(t.value):"string"==typeof t?JSON.parse(t):t}catch(e){return t}},ot=(t,e)=>{if(!e)return rt(t);if("string"==typeof t){if(""===t.trim())return"";try{if("string"!=typeof JSON.parse(t))return ot(JSON.parse(t),e);{let i=t.replace(/@(\w+)|{{(\w+)}}/g,((t,i,r)=>{const o=i||r,a=e.find((t=>t.mapField===o));return a?a.value||a.originalValue||"":t}));return rt(i)}}catch(i){let r=t.replace(/@(\w+)|{{(\w+)}}/g,((t,i,r)=>{const o=i||r,a=e.find((t=>t.mapField===o));return a?a.value||a.originalValue||"":t}));return rt(r)}}else{if(Array.isArray(t))return t.map((t=>ot(t,e)));if("object"==typeof t&&null!==t){const i={};for(let r in t)i[r]=ot(t[r],e);return rt(i)}}return rt(t)},at=(t,e)=>{const i=t.agency,r=t,{url:o=null,headers:a,params:n,requestType:s}=r,l=o?ot(o,e):void 0,d=a&&a.use?ot(a.value,e):{};return{url:l,requestType:s,params:n?ot(n,e):{},headers:d,agency:i}},nt=(t,e,i,r,a)=>o(void 0,void 0,void 0,(function*(){if(t&&t.length)for(const o of t){v(e,o.value,i)&&(yield et({tmpData:{source:{type:"globalData",globalData:{id:o.key}}}},!0,i,t,(t=>{console.log("数据更新成功-变量改变全局数据跟新")}),!0),f(r,(e=>{var r,n,s;if("globalData"===(null===(n=null===(r=null==e?void 0:e.tmpData)||void 0===r?void 0:r.source)||void 0===n?void 0:n.type)){(null===(s=null==e?void 0:e.tmpData)||void 0===s?void 0:s.source.globalData).id===o.key&&et(e,!0,i,t,(t=>{a(e,t)}),!1)}})))}})),st=(t,e,i,r,a)=>o(void 0,void 0,void 0,(function*(){t&&(yield et({tmpData:{source:{type:"globalData",globalData:{id:t.key}}}},!0,e,i,(t=>{console.log("数据更新成功-数据源编辑")}),!0),f(r,(r=>{var o,n,s;if("globalData"===(null===(n=null===(o=null==r?void 0:r.tmpData)||void 0===o?void 0:o.source)||void 0===n?void 0:n.type)){(null===(s=null==r?void 0:r.tmpData)||void 0===s?void 0:s.source.globalData).id===t.key&&et(r,!0,e,i,(t=>{a(r,t)}),!1)}})))}));class lt{constructor(t,e){this.isUpdating=!1,this.des=t.des,this.field=t.field,this.id=t.id,this.key=t.key,this.mapping=t.mapping,this.mapField=t.mapField,this.type=t.type,this.originalValue=t.originalValue,this.model=(null==t?void 0:t.model)?null==t?void 0:t.model:1,this.converter=t.converter,this.converterCode=t.converterCode,this.fork=t.fork,this.delayUpdate=!!(null==t?void 0:t.delayUpdate),e&&(this.globalVariables=e),t.fork&&(this.model=5,this.forkValue=t.forkValue,this.originalValue=this.getForkedValue())}get value(){return this.fork&&(this.originalValue=this.getForkedValue()),this.converter&&this.converterCode?D(this.converterCode,this.originalValue):this.originalValue}togglePropertyState(t){let e=Object.prototype.hasOwnProperty.call(this,t);this[t]=!e||!t}getForkedValue(){if(this.forkValue&&Array.isArray(this.forkValue))return this.forkValue.map((t=>{const e=this.globalVariables.get(t);return e?e.value:null}));if(this.forkValue){const t=this.globalVariables.get(this.forkValue);return t?t.value:null}return null}updateValue(t,e){var r;const o=Object.assign({},this,t);this.des=o.des,this.field=o.field,this.mapping=o.mapping,this.type=o.type,this.originalValue=o.originalValue,this.converter=o.converter,this.converterCode=o.converterCode,this.fork=o.fork,this.delayUpdate=null==o?void 0:o.delayUpdate,this.model=null==o?void 0:o.model,t.id&&(this.id?"string"==typeof this.id?t.id instanceof Array?this.id=i([this.id,...t.id]):this.id=[this.id,t.id]:this.id instanceof Array&&(t.id instanceof Array?this.id=i([...this.id,...t.id]):this.id=i([...this.id,t.id])):this.id=t.id),t.fork&&(this.model=5,this.forkValue=null!==(r=t.forkValue)&&void 0!==r?r:this.forkValue,this.originalValue=this.getForkedValue()),e&&e(this)}updateWidthOriginalValue(t,e){var i;this.originalValue=t,this.fork&&(this.forkValue=null!==(i=this.forkValue)&&void 0!==i?i:this.forkValue,this.originalValue=this.getForkedValue()),e&&e(this)}renew(t){t&&t(this)}static create(t,e){return new lt(t,e)}}class dt{constructor(){this.variables=new Map,this.globalObservers=[],this.url=window.location.search,this.list=[]}clearVars(){this.list=[],this.variables.clear()}togglePropertyState(t,e,i){try{let r=this.getVariable(t);if(!r)throw new Error("没有找到相应的变量!");r.togglePropertyState(e),this.addToObjectArray(this.list,r),i&&i()}catch(t){console.error(t)}}static getInstance(){return dt.instance||(dt.instance=new dt),dt.instance}getFullUrl(){this.url=window.location.search}getAllUrlParams(){const t=new URLSearchParams(window.location.search),e={};for(const[i,r]of t.entries())e[i]=r;return e}delVariable(t,e){this.variables.delete(t),this.list=this.list.filter((e=>e.mapField!=t)),e&&e()}addUrlParamsToGlobalVars(){this.getFullUrl();let t=this.getAllUrlParams(),e=Object.keys(t),i=[];for(const r of e)i.push({mapField:r,originalValue:t[r],model:4});if(i.length)for(const t of i)this.addVariable(t)}addVariables(t){Array.isArray(t)?t.map(((t,e)=>{this.addVariable(t)})):this.addVariable(t),this.addUrlParamsToGlobalVars()}addVariable(t,e){if(!t||!(null==t?void 0:t.mapField))return console.error(t+"参数不合法!"),!1;if(this.isVariableNameExist(t.mapField)){let i=this.getVariable(t.mapField);return this.sameValue(i,t)?i:(this.editVariable(t,e),!1)}const i=lt.create(t,this.variables);return this.variables.set(i.mapField,i),this.addToObjectArray(this.list,i),e&&e(i),this.notifyGlobalObservers(i),i}toJSON(t){try{return!!t&&JSON.stringify(t)}catch(t){return!1}}sameValue(t,e){if(t.mapfield!==e.mapfield)return!1;for(const i in e)if(!(["mapfield","field","key","value","name","globalVariables"].includes(i)||i in t&&t[i]==e[i]))return!1;return!0}creatVarJson(t){const{des:e,field:i,id:r,key:o,mapping:a,mapField:n,type:s,value:l,originalValue:d,model:c,converter:u,converterCode:h,fork:p,forkValue:f,update:m,delayUpdate:g}=t,v={};return void 0!==e&&(v.des=e),void 0!==i&&(v.field=i),void 0!==r&&(v.id=r),void 0!==o&&(v.key=o),void 0!==a&&(v.mapping=a),void 0!==n&&(v.mapField=n),void 0!==s&&(v.type=s),void 0!==l&&(v.value=l),void 0!==d&&(v.originalValue=d),void 0!==c&&(v.model=c),void 0!==u&&(v.converter=u),void 0!==h&&(v.converterCode=h),void 0!==p&&(v.fork=p),void 0!==f&&(v.forkValue=f),void 0!==m&&(v.update=m),void 0!==g&&(v.delayUpdate=g),v}addToObjectArray(t,e){let i=!1;for(let r=0;r<t.length;r++)if(t[r].mapField==e.mapField){t[r]=this.creatVarJson(e),i=!0;break}i||t.push(e)}editVariable(t,e){const i=this.getVariable(t.mapField);if(i&&this.isVariableNameExist(t.mapField)){if(this.sameValue(i,t))return}const r=t=>{if(!t.isUpdating){t.isUpdating=!0,this.notifyGlobalObservers(t);this.isMapFieldInForkValues(t.mapField).forEach((t=>{let e=this.getVariable(t.mapField);e&&e.renew((t=>{this.addToObjectArray(this.list,t),this.notifyGlobalObservers(t)}))})),this.addToObjectArray(this.list,t),e&&e(t),t.isUpdating=!1}};i?i.updateValue(t,r):this.addVariable(t,r)}getForkList(t){let e=this.isMapFieldInForkValues(t);return e||[]}editVariableForValue(t,e,i){const r=this.getVariable(t),o=t=>{if(!t.isUpdating){t.isUpdating=!0,this.notifyGlobalObservers(t);this.isMapFieldInForkValues(t.mapField).forEach((t=>{let e=this.getVariable(t.mapField);e&&e.renew((t=>{this.addToObjectArray(this.list,t),this.notifyGlobalObservers(t)}))})),this.addToObjectArray(this.list,t),i&&i(t),t.isUpdating=!1}};r&&r.updateWidthOriginalValue(e,o)}isMapFieldInForkValues(t){return this.getAllVariables().filter((t=>t.fork&&t.forkValue)).filter((e=>e.forkValue==t||Array.from(e.forkValue).includes(t)))}isVariableNameExist(t){return this.variables.has(t)}checkExist(t,e){if("string"==typeof t&&this.isVariableNameExist(t)){let i=this.getVariable(t);return e==i.id&&!i.id.includes(e)&&[{key:t}]}if(Array.isArray(t)){const i=t.filter((t=>{let i=this.getVariable(t);return this.isVariableNameExist(t)&&e!=i.id&&!(i.id&&i.id.includes(e))})).map((t=>({key:t})));return!!i.length&&i}return!1}getVariable(t){return this.variables.get(t)}getVariableForId(t){var i;let r=[];for(const[,e]of this.variables)(e.id===t||(null===(i=e.id)||void 0===i?void 0:i.includes(t)))&&r.push(e);return e.uniq(r)}getAllVariables(t=!1){return t?(this.list=Array.from(this.variables.values()),this.list):[...this.list]}restoreVariables(t){t.forEach((t=>{this.addVariable(t)}))}registerGlobalObserver(t){this.globalObservers.push(t)}notifyGlobalObservers(t){this.globalObservers.forEach((e=>{e.update(t)}))}}dt.instance=null;const ct=dt.getInstance(),ut=(t,e)=>Array.isArray(e)?e.some((e=>t&&(void 0!==t[e]||t.hasOwnProperty(e)))):"string"==typeof e&&(t&&(void 0!==t[e]||t.hasOwnProperty(e))),ht=(t,e,i,r)=>{const o=((t,e,i,r)=>{var o;let a;if(ut(t,null==e?void 0:e.field)||ut(t,null==e?void 0:e.forkValue))a=t[null==e?void 0:e.field]||"";else if(ut(t.data,null==e?void 0:e.field)||ut(t.data,null==e?void 0:e.forkValue))a=t.data[null==e?void 0:e.field]||"";else{const t=b(i,r),n=(null===(o=null==t?void 0:t.tmpData)||void 0===o?void 0:o.actions)||[];for(const t of n){const i=t.vars.find((t=>(null==t?void 0:t.mapField)===(null==e?void 0:e.mapField)));if(i){a=i.value;break}}}return a})(t,e,i,r);return void 0!==o?o:e.value},pt=(t,e,i,r,o,a,n,s,l)=>{switch(t.type){case"link":window.open(t.link,t.target);break;case"page":l&&l(t);break;case"dynamic":((t,e,i,r,o)=>{const a=t.dynamic||[];for(const n of a){if(t.id!==e.cid)continue;const a=b(i,n.pid);a&&(a.activeDynamic=n.name,a.isShow=n.visible||!r||t.index===e.index-1,o({cid:a.cid,flag:n.visible}))}})(t,e,i,r,o);break;case"toggle":((t,e,i,r,o)=>{const a=t.children||[];for(const i of a){const a=i.visible&&(!r||t.index===e.index-1);o({cid:i.cid,flag:a})}})(t,e,0,r,o);break;case"update":((t,e,i,r,o)=>{const a=t.children||[];for(const t of a){const a=b(e,t.cid);a&&et(a,!0,i,r,(t=>{o({cid:a.cid,data:t})}))}})(t,i,a,n,s)}},ft=(t,i,r,o,a,n,s,l,d,c)=>{const{cid:u,actions:h,index:p}=a,{eventName:f,mode:m}=h,g=2===m;((t,i,r,o,a,n)=>{let s=ct.getVariableForId(i.cid);if(console.log("changeVarNew"),null==s?void 0:s.length)for(const l of s)if(l.type==t){let t=ht(i,l,r,o);ct.editVariableForValue(l.mapField,t,(()=>{let t=a[l.mapField]||[],i=ct.getForkList(l.mapField);if(i)for(const r of i){let i=a[r.mapField];t=e.concat(t,i)}n&&n(l,e.uniq(t))}))}})(f,a,o,u,r,((t,e)=>{if(nt(d,t.mapFile,ct.getAllVariables(),o,((t,e)=>{s({cid:t.cid,data:e})})),null==e?void 0:e.length)for(const i of e){t.eventSourceId=i;const e=b(o,i);!(null==t?void 0:t.delayUpdate)&&e&&et(e,!0,ct.getAllVariables(),d,(t=>{s({cid:e.cid,data:t})}))}}));const v=((t,e,i,r,o)=>t.filter((t=>t.id===e&&t.eventType===i&&(!o||parseInt(t.index||"0")+1===parseInt(r||"0")))))(t,u,f,p,g);for(const t of v)pt(t,a,o,g,n,ct.getAllVariables(),d,s,l)},mt=(t,e={})=>{let i={},r={type:"static",converse:{use:!1,data:[]},static:{data:t},api:{requestType:"get",url:"",headers:{use:!1,value:""},params:"",agency:!1,cookie:!0,autoUpdate:{open:!1,time:10},data:""}};return Object.assign(i,r,e),i},gt=(t,i)=>{let{option:r,actions:o,data:a,optionDes:n,actionsDes:s,source:l,theme:d}=((t,i)=>{let{option:r,actions:o,data:a,optionDes:n,actionsDes:s,source:l,theme:d}=e.cloneDeep(i[t]);return{option:r,actions:o,data:a,optionDes:n,actionsDes:s,source:l,theme:d}})(t,i);return{iconClass:null,isAssembly:null,source:a,cid:(Math.random().toString().substr(3,10)+Date.now()).toString(),isLock:!1,isShow:!0,tmpData:{option:r,source:mt(a,l),actions:o},baseData:bt(),dynamic:null,filePath:"",origin:"anov-ui",name:"",componentType:"",viewComName:t,optionComName:"AnOptionPanel",dataComName:"AnSourcePanel",eventComName:"AnActionsPanel",assemblyDeveloper:"",devEmail:"",version:"",devDept:""}},vt=(t,i,r)=>{let o=gt(t,i);return r?e.merge(o,r):o},bt=t=>{let e={left:0,top:0,width:100,height:100,angle:0,penetrate:0,opacity:100,perspective:100,rotateX:0,rotateY:0,rotateZ:0,transformOriginX:"center",transformOriginY:"center",transformSwitch:!1};return t?Object.assign(e,t):e};class yt{constructor(t,e,i){this.theme=null,this.plant=null,this.list=[],this.titleHeqadeHeight=70,this.clearance=3,this.checkComponentIntersection=(t,e,i=10)=>{const r=t.left,o=t.left+t.width,a=t.top,n=t.top+t.height,s=e.left,l=e.left+e.width,d=e.top,c=e.top+e.height,u=r<l&&o>s&&a<c&&n>d,h=Math.abs(t.left+t.width/2-(e.left+e.width/2)),p=Math.abs(t.top+t.height/2-(e.top+e.height/2));return u||h<i&&p<i},this.calculateCombinedComponent=t=>{if(0===t.length)return{left:0,top:0,width:0,height:0};let e=t[0].left,i=t[0].top,r=t[0].left+t[0].width,o=t[0].top+t[0].height;for(let a=1;a<t.length;a++){const n=t[a];e=Math.min(e,n.left),i=Math.min(i,n.top),r=Math.max(r,n.left+n.width),o=Math.max(o,n.top+n.height)}return{left:e,top:i,width:r-e,height:o-i}},this.getAnTextNormaltText=t=>{var e,i;try{return null===(i=null===(e=null==t?void 0:t.tmpData)||void 0===e?void 0:e.option)||void 0===i?void 0:i.text}catch(t){return console.error("配置优化(ConfigOptimizer):",t),""}},this.initProp(t),this.upgradePlant(),this.staticComponentData=e,this.upgradeHeaderComponent(),i&&Object.assign(this,i)}isStringOrObject(t){return"string"==typeof t?"string":"object"==typeof t&&null!==t&&"object"}initProp(t){try{let e,i=this.isStringOrObject(t);if(i&&"string"===i)e=JSON.parse(t);else{if(!i||"object"!==i)throw new Error(`initProp fn error :-- 传入参数${t}不合法!`);e=t}if(e){this.originData=e;const{theme:t,plant:i,list:r}=e;this.theme=t,this.plant=i,this.list=r,this.filterFileGroup()}}catch(t){console.error("配置优化(ConfigOptimizer):",t)}}upgradePlant(){this.plant&&(this.plant.option.bg={type:1,code:"70942ec525344c96aa32b81b2c9155f6",path:"/anov-prod/resources/page/png/bg22 科技星球背景.png",thumb:"/anov-prod/resources/page/thumbnail/1e48f8fb26ec4edfb1a0f499627e84fc.png"})}areComponentsIntersecting(t,e){let i=t.baseData,r=e.baseData;const o=Math.max(0,Math.min(i.left+i.width,r.left+r.width)-Math.max(i.left,r.left)),a=Math.max(0,Math.min(i.top+i.height,r.top+r.height)-Math.max(i.top,r.top));return o>0&&a>0}filterFileGroup(){this.list=e.cloneDeep(this.list).map((t=>{var e,i;if(1===(null===(e=null==t?void 0:t.children)||void 0===e?void 0:e.length)&&!(null===(i=null==t?void 0:t.children[0])||void 0===i?void 0:i.children)){const e=t.children[0],{left:i,top:r}=t.baseData;return e.baseData.left=i,e.baseData.top=r,e}return t}))}getText(t,e,i){const r=document.createElement("canvas").getContext("2d");if(!r)throw new Error("Failed to get 2D context from canvas.");r.font=`${i}px ${e}`;return r.measureText(t).width}calculateMaxWidths(t){const e=Math.min(...t.map((t=>t.width))),i=[];let r=[],o=t[0].width;for(const a of t){const t=a.width;Math.abs(t-o)<=e?r.push(t):(r.length>0&&i.push(r),r=[t]),o=t}r.length>0&&i.push(r);const a=[];for(const t of i){const e=Math.max(...t);a.push(e)}return a}findClosestValue(t,e){let i=e[0],r=Math.abs(t-i);for(const o of e){const e=Math.abs(t-o);e<r&&(r=e,i=o)}return i}adjustHeightAndTop(t,e){const i=e-t.height;return Object.assign(Object.assign({},t),{height:e,top:t.top-i/2})}findNearestComponent(t,i,r){let o=null,a=1/0;i.tmpData.option.textNormal.text;try{const n=e.cloneDeep(t).sort(((t,e)=>t.baseData.top-e.baseData.top)).sort(((t,e)=>t.baseData.left-e.baseData.left)).filter((t=>!(t.cid===i.cid||"AnTextNormal"===t.viewComName||r&&r.includes(t.cid)))),s=e.cloneDeep(i).baseData;s.top,s.height;for(const t of n){const e=t.baseData;e.top,e.height;if(s.left<e.left+e.width&&s.left+s.width>e.left){const i=e.top-s.top;i<a&&i<100&&(a=i,o=t)}}}catch(t){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",t)}return o}findNearestComponentForPoint(t,e,i){let r=null,o=1/0;e.tmpData.option.textNormal.text;try{const a=t.sort(((t,e)=>t.baseData.top-e.baseData.top)).sort(((t,e)=>t.baseData.left-e.baseData.left)).filter((t=>!(t.cid===e.cid||"AnTextNormal"===t.viewComName||i&&i.includes(t.cid)))),n=e.baseData;n.top,n.height;for(const t of a){const e=t.baseData;let i=this.getDistance(n.left,n.top+n.height,e.left,e.top);i<o&&i<n.width&&(o=i,r=t)}}catch(t){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",t)}return r}findNearestComponentForTitlePoint(t,e,i){let r=null,o=1/0;e.tmpData.option.textNormal.text;try{const a=t.sort(((t,e)=>t.baseData.top-e.baseData.top)).sort(((t,e)=>t.baseData.left-e.baseData.left)).filter((t=>!(t.cid===e.cid||"AnTextNormal"===t.viewComName||i&&i.includes(t.cid)))),n=e.baseData;n.top,n.height;for(const t of a){const e=t.baseData;let i=this.getDistance(n.left,n.top+n.height,e.left,e.top);i<o&&i<n.width&&e.top-n.top>100&&(o=i,r=t)}}catch(t){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",t)}return r}findNearestTitleForPoint(t,e,i){let r=null,o=1/0;e.tmpData.option.textNormal.text;try{const a=t.sort(((t,e)=>t.baseData.top-e.baseData.top)).sort(((t,e)=>t.baseData.left-e.baseData.left)).filter((t=>!(t.cid===e.cid||"AnTextNormal"===t.viewComName||i&&i.includes(t.cid)))),n=e.baseData;n.top,n.height;for(const t of a){const e=t.baseData;let i=e.top-n.top;i<o&&i<n.width&&e.top-n.top>100&&(o=i,r=t)}}catch(t){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",t)}return r}getDistance(t,e,i,r){return Math.sqrt(Math.pow(i-t,2)+Math.pow(r-e,2))}findNearestComponent2(t,i,r){let o=null,a=1/0,n=e.cloneDeep(t).sort(((t,e)=>t.baseData.top-e.baseData.top));try{const t=n.filter((t=>!(t.cid===i.cid||"AnTextNormal"===t.viewComName||r&&r.includes(t.cid)))),s=e.cloneDeep(i).baseData,l=s.top+s.height;for(const e of t){const t=e.baseData,i=t.top+t.height;if(s.left<t.left+t.width&&s.left+s.width>t.left){const t=i-l;t>=0&&t<a&&(a=t,o=e)}}}catch(t){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",t)}return o}verticalDistance(t,e){t.left,t.width;const i=t.top+t.height,r=(e.left,e.width,e.top);return Math.abs(i-r)}extractAmount(t){const e=t.match(/(\d{1,3}(?:,\d{3})*)(\D+)/);if(e){const t=e[1].replace(/,/g,"");return[parseInt(t,10),e[2].trim()]}return[!1,!1]}getAnTextNormal(){return this.list.filter((t=>"AnTextNormal"==t.viewComName))}getAnDeckTitle3(){return this.list.filter((t=>"AnDeckTitle3"==t.viewComName)).sort(((t,e)=>t.baseData.left-e.baseData.left))}judgeAnOdometer(){let t=this.getAnTextNormal().sort(((t,e)=>t.baseData.left-e.baseData.left)),e=[],i=new Set;for(const r of t){if(i.has(r.cid))continue;let o=[];for(const e of t){if(!i.has(e.cid)&&r.cid!=e.cid){this.checkComponentIntersection(r.baseData,e.baseData)&&(i.add(e.cid),i.add(r.cid),o.push(e))}}e.push([r,...o])}let r=[];for(const t of e)for(const e of t){let i=this.getAnTextNormaltText(e);this.extractAmount(i).every((t=>t))&&r.push(t)}return r}createAnOdometer(){var t,i;let r=this.judgeAnOdometer();for(const o of r){let r,a,n,s=this.calculateCombinedComponent(o.map((t=>t.baseData)));for(const t of o){let i=this.getAnTextNormaltText(t),o=this.extractAmount(i);o.every((t=>!t))&&(r=i),o.every((t=>t))&&(a=o[0],n=o[1]),e.remove(this.list,(e=>e.cid==t.cid))}let l=vt("AnIndicatorNormal",this.staticComponentData,e.cloneDeep({baseData:s}));(null===(i=null===(t=null==l?void 0:l.tmpData)||void 0===t?void 0:t.source)||void 0===i?void 0:i.static)&&(l.tmpData.source.static.data={text:r,num:a,unit:n},l.tmpData.source.static.originData={text:r,num:a,unit:n}),this.list.push(l)}}upgradeHeaderComponent(){for(let t=0;t<this.list.length;t++){const e=this.list[t];"AnDeckHeader3"==e.viewComName&&(e.baseData.left=0,e.baseData.top=0)}}upgradeTitleComponent(){let t=this.getAnDeckTitle3().map((t=>t.baseData)),e=this.calculateMaxWidths(t);for(let t=0;t<this.list.length;t++){const i=this.list[t];if("AnDeckTitle3"==i.viewComName){let t=this.findClosestValue(i.baseData.width,e);i.baseData.width=t>300?t:300,i.baseData=this.adjustHeightAndTop(i.baseData,this.titleHeqadeHeight)}}this.removeErroneousComponents()}containsFractionStructure(t){return/\b\d+\/\d+\b/.test(t)}removeErroneousComponents(){let t=this.getAnDeckTitle3(),e=[];for(let i=0;i<t.length;i++){const r=t[i];let o=r.tmpData.option.textNormal.text;if(this.containsFractionStructure(o))for(let i=0;i<t.length;i++){const o=t[i];if(r.cid!=o.cid){this.areComponentsIntersecting(r,o)&&e.push(r.cid)}}}this.list=this.list.filter((t=>!e.includes(t.cid)))}upgradeGroupComponent(){try{let t=this.getAnDeckTitle3(),e=this.list.filter((t=>"AnDeckTitle3"!=t.viewComName&&"AnDeckHeader3"!=t.viewComName&&"AnTextNormal"!=t.viewComName)),i=[],r=[];for(let o=0;o<t.length;o++){const a=t[o];let n=this.findNearestComponentForPoint(e,a,i);if(n&&n.cid&&i.push(n.cid),n){a.baseData.left=n.baseData.left;let e=this.upgradeComponentHeight(a,t,r);e&&e>=30&&(n.baseData=Object.assign({},n.baseData,{top:a.baseData.top+a.baseData.height+this.clearance}))}}}catch(t){console.error("配置优化(ConfigOptimizer):",t)}}upgradeComponentHeight(t,i,r=[]){const o=t;let a=this.findNearestTitleForPoint(e.cloneDeep(i),o);return a?a.baseData.top-o.baseData.top-this.titleHeqadeHeight:1080-o.baseData.top-this.titleHeqadeHeight}getData(){return this.originData.list=this.list,this.originData.plant=this.plant,this.originData}}const wt=new class{randomNum(t,e){return Math.floor(Math.random()*(e-t+1))+t}generateRandomIntArray(t,e,i){const r=[];for(let o=0;o<t;o++){const t=this.randomNum(e,i);r.push(t)}return r}randomString(t,e){const i="abcdefghijklmnopqrstuvwxyz",r=this.randomNum(t,e);let o="";for(let t=0;t<r;t++){const t=Math.floor(26*Math.random());o+=i.charAt(t)}return o}generateRandomNameArray(t,e,i){const r=[];for(let o=0;o<t;o++){const t=this.randomString(e,i);r.push(t)}return r}pick(t){return t[Math.floor(Math.random()*t.length)]}};class Dt{constructor(){this.names=["line","pie","bar"],console.log(12)}static getInstance(){return Dt.instance||(Dt.instance=new Dt),Dt.instance}createLine(){const t=[],e=wt.pick([!0,!1]);let i=wt.randomNum(3,9);const r=wt.pick([null,null,null,{}]);for(let o=0;o<wt.randomNum(1,9);o++)t.push({data:wt.generateRandomIntArray(i,0,300),type:"line",smooth:e,areaStyle:r});return{xAxis:{type:"category",show:!1,boundaryGap:!1,data:wt.generateRandomNameArray(i,3,6)},grid:{left:0,top:0,bottom:0,right:0},yAxis:{show:!1,type:"value"},series:t}}}Dt.instance=null;const Nt=Dt.getInstance();const Ct=new class{constructor(){this.directions=["row","column"],this.direction="column",this.splitNumbers=24,this.margin=[0,0]}baseLayout(t){const e=(null==t?void 0:t.maRrows)?null==t?void 0:t.maRrows:this.splitNumbers,i=(null==t?void 0:t.colNum)?null==t?void 0:t.colNum:this.splitNumbers,r=t.wrapWidth/i,o=t.wrapHeight/e;let a=O(this.directions);a&&(this.direction=a);let n=[];if("row"===this.direction){let t=O([2,3,4]);n=this.simulateRandomSegments(24,4,12,t)}else{let t=O([2,3]);n=this.simulateRandomSegments(24,4,12,t)}let s=[],l=[];if("row"===this.direction){for(let t=0;t<n.length;t++)if(0==t)s.push({x:0,y:0,w:n[t],h:24,i:t,wStep:r,hStep:o});else{let e=s[t-1].x;s.push({x:n[t-1]+e,y:0,w:n[t],h:24,i:t,wStep:r,hStep:o})}for(let t=0;t<s.length;t++){const e=s[t];let i=O([2,3]),a=this.simulateRandomSegments(24,6,12,i);for(let i=0;i<a.length;i++){const n=a[i];l.push({x:e.x,y:n,w:e.w,h:n,i:10*t+i,wStep:r,hStep:o})}}}else{for(let t=0;t<n.length;t++)if(0==t)s.push({x:0,y:0,w:24,h:n[t],i:t,wStep:r,hStep:o});else{let e=s[t-1].y;s.push({x:0,y:n[t-1]+e,w:24,h:n[t],i:t,wStep:r,hStep:o})}for(let t=0;t<s.length;t++){const e=s[t];let i=O([1,2,3,4]),a=this.simulateRandomSegments(24,5,12,i),n=[];for(let i=0;i<a.length;i++){const s=a[i];if(0==i)n.push({x:0,y:e.y,w:s,h:e.h,i:10*t+i,wStep:r,hStep:o}),l.push({x:0,y:e.y,w:s,h:e.h,i:10*t+i,wStep:r,hStep:o});else{let d=n[i-1].x;n.push({x:a[i-1]+d,y:e.y,w:s,h:e.h,i:10*t+i,wStep:r,hStep:o}),l.push({x:a[i-1]+d,y:e.y,w:s,h:e.h,i:10*t+i,wStep:r,hStep:o})}}}}return{layouts:l.map((t=>(t.chartsOption=Nt.createLine(),t))),option:{colNum:i,margin:(null==t?void 0:t.margin)?null==t?void 0:t.margin:this.margin,isDraggable:!!(null==t?void 0:t.isDraggable)&&(null==t?void 0:t.isDraggable),isResizable:!!(null==t?void 0:t.isResizable)&&(null==t?void 0:t.isResizable),verticalCompact:!(null==t?void 0:t.verticalCompact)||(null==t?void 0:t.verticalCompact),useCssTransforms:!(null==t?void 0:t.useCssTransforms)||(null==t?void 0:t.useCssTransforms),rowHeight:t.wrapHeight/e,maRrows:e}}}simulateRandomSegments(t,e,i,r){const o=[];let a=t,n=r;for(;n>0;)if(1===n)o.push(a),n--;else{const t=Math.min(i,a-e*(n-1)),r=Math.floor(Math.random()*(t-e+1))+e;o.push(r),a-=r,n--}return o}simulateRandomSegments2(t,e,i,r){const o=[];let a=t,n=r;for(;n>0;)if(1==n){const e=t-o.reduce(((t,e)=>t+e),0);o.push(e),n--}else{let t=Math.floor(Math.random()*i),r=Math.max(e,t),s=a-e*n;const l=Math.min(r,s);o.push(l),a-=l,n--}return o}};export{yt as ConfigOptimizer,dt as GlobalVariables,$ as Http,U as Log,z as agentData,C as delFetchStatus,Ct as displayGenerator,tt as editItem,ft as emitEvent,K as fetchDataByGlobal,Y as fetchDataByType,Z as filterData,b as findItemDeep,y as findItemDeep2,H as getData,G as getDataForApi,W as getDataForSource,X as getDataForStatic,J as getDataForZb,B as getDataForZbCQ,u as getSessionData,l as getStandardData,m as getStringVars,ht as getVarDefaultVal,ct as globalVars,v as hasVar,d as isJSON,f as recursion,w as safeEval,D as safeEvalForCode,N as setFetchStatus,c as setSessionData,nt as updataGlobalDataSourceForVar,et as updateComData,st as updateGlobalDataSource};
|
|
@@ -6,14 +6,25 @@ export declare class CreateComponentForEcharts {
|
|
|
6
6
|
createLine(): {
|
|
7
7
|
xAxis: {
|
|
8
8
|
type: string;
|
|
9
|
-
|
|
9
|
+
show: boolean;
|
|
10
|
+
boundaryGap: boolean;
|
|
11
|
+
data: string[];
|
|
12
|
+
};
|
|
13
|
+
grid: {
|
|
14
|
+
left: number;
|
|
15
|
+
top: number;
|
|
16
|
+
bottom: number;
|
|
17
|
+
right: number;
|
|
10
18
|
};
|
|
11
19
|
yAxis: {
|
|
20
|
+
show: boolean;
|
|
12
21
|
type: string;
|
|
13
22
|
};
|
|
14
23
|
series: {
|
|
15
|
-
data:
|
|
24
|
+
data: number[];
|
|
16
25
|
type: string;
|
|
26
|
+
smooth: boolean;
|
|
27
|
+
areaStyle: {} | null;
|
|
17
28
|
}[];
|
|
18
29
|
};
|
|
19
30
|
}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
declare
|
|
1
|
+
declare class GoMock {
|
|
2
|
+
randomNum(min: number, max: number): number;
|
|
3
|
+
generateRandomIntArray(length: number, min: number, max: number): number[];
|
|
4
|
+
randomString(min: number, max: number): string;
|
|
5
|
+
generateRandomNameArray(length: number, min: number, max: number): string[];
|
|
6
|
+
pick<T>(options: T[]): T;
|
|
7
|
+
}
|
|
8
|
+
declare const goMock: GoMock;
|
|
2
9
|
export { goMock };
|