@wdslib/go-utils 0.2.92 → 0.2.93

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(/&gt;/g,">").replace(/&lt;/g,"<"))},p=(e,t)=>{e instanceof Map?e.forEach((e=>{t([e])})):Array.isArray(e)&&e.forEach((e=>{t(e.children)}))},m=(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)},f=(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=f(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)},k=e=>{let t=window.goFetchList;t&&t[e]&&delete t[e]},C="anov@2019:helloX",A="anov@2020:helloX";function V(e){let t=r.enc.Utf8.parse(C),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 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(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(x);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 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(e){console.error("初始化 IndexedDB 时出错:",e)}}static getInstance(){return R.instance||(R.instance=new R),R.instance}setLogLevel(e){this.logLevel=e}getColor(e){switch(e){case P.FATAL:return"";case P.ERROR:return"";case P.WARN:return"";case P.INFO:return"";case P.DEBUG:return"";case P.TRACE:return"";default:return""}}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}`);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}`)}}}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=R.getInstance(),$=(e,t)=>"string"!=typeof e?Promise.reject(new Error("URL should be a string")):s(e,t),q=s();let L=s();function z(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 q({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 q(e)).data}}catch(e){throw console.error("请求数据发生错误-Error:",e),e}}))}(s)}catch(e){throw console.error("获取数据:Error:",e),e}}))}function H(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 q({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?H(t,e,i,r):z(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 q({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 L({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 q(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 console.warn("1请求已经执行!"),Promise.reject("数据已经请求!")}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)&&k(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),m(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),m(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:m,update:f,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!==m&&(v.forkValue=m),void 0!==f&&(v.update=f),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 this.addUrlParamsToGlobalVars(),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)=>{var d;switch(e.type){case"link":window.open(e.link,e.target);break;case"page":if(null===(d=null==e?void 0:e.params)||void 0===d?void 0:d.length)for(let t=0;t<e.params.length;t++){const i=e.params[t],r=a.find((e=>e.mapField==i.mapField));r&&(i.value=r.value)}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)}},me=(e,i,r,o,a,n,s,l,d,c)=>{const{cid:u,actions:h,index:p}=a,{eventName:m,mode:f}=h,g=2===f;((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))}))}})(m,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)=>(console.log(e,"globalEvents"),e.filter((e=>e.id===t&&e.eventType===i&&(!o||parseInt(e.index||"0")+1===parseInt(r||"0"))))))(e,u,m,p,g);for(const e of v)pe(e,a,o,g,n,ce.getAllVariables(),d,s,l)},fe=(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:fe(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 class{randomNum(e,t){return Math.floor(Math.random()*(t-e+1))+e}generateRandomIntArray(e,t,i,r){const o=[];for(let r=0;r<e;r++){const e=this.randomNum(t,i);o.push(e)}return r&&"asc"===r?o.sort(((e,t)=>e-t)):r&&"desc"===r?o.sort(((e,t)=>t-e)):o}randomString(e,t){const i="abcdefghijklmnopqrstuvwxyz",r=this.randomNum(e,t);let o="";for(let e=0;e<r;e++){const e=Math.floor(26*Math.random());o+=i.charAt(e)}return o}generateRandomNameArray(e,t,i){const r=[];for(let o=0;o<e;o++){const e=this.randomString(t,i);r.push(e)}return r}pick(e){return e[Math.floor(Math.random()*e.length)]}};class De{constructor(){this.names=["line","pie","bar"]}static getInstance(){return De.instance||(De.instance=new De),De.instance}createLine(){const e=[],t=we.pick([!0,!1]);let i=we.randomNum(3,20);const r=we.pick([null,null,null,{}]);let o=we.pick(["asc","desc",void 0,void 0,void 0]);for(let a=0;a<we.randomNum(1,9);a++)e.push({data:we.generateRandomIntArray(i,0,300,o),type:"line",smooth:t,symbolSize:we.randomNum(1,10),lineStyle:{width:we.randomNum(1,4)},areaStyle:r});return{xAxis:{type:"category",show:!1,boundaryGap:!1,data:we.generateRandomNameArray(i,3,6)},grid:{left:0,top:0,bottom:0,right:0},yAxis:{show:!1,type:"value"},series:e}}}De.instance=null;const Ne=De.getInstance();const ke=new class{constructor(){this.directions=["row","column"],this.direction="column",this.splitNumbers=24,this.margin=[20,20]}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,H as agentData,k as delFetchStatus,ke as displayGenerator,ee as editItem,me as emitEvent,K as fetchDataByGlobal,Y as fetchDataByType,Z as filterData,b as findItemDeep,y as findItemDeep2,z as getData,G as getDataForApi,W as getDataForSource,X as getDataForStatic,J as getDataForZb,B as getDataForZbCQ,u as getSessionData,l as getStandardData,f as getStringVars,he as getVarDefaultVal,ce as globalVars,v as hasVar,d as isJSON,m 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 e from"axios";import t,{uniq as r}from"lodash";import i from"crypto-js";function a(e,t,r,i){return new(r||(r=Promise))((function(a,o){function n(e){try{l(i.next(e))}catch(e){o(e)}}function s(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(n,s)}l((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class o{constructor(){this.requests=[],console.log("RequestTracker")}static getInstance(){return o.instance||(o.instance=new o),o.instance}addRequest(e){if(this.isDuplicateRequest(e)){let t=this.findRequest(e);this.cancelRequest(t)}this.requests.push(e)}findRequest(e){let t;for(const r of this.requests)if(this.areRequestsEqual(r,e)){t=r;break}return t}removeRequest(e){const t=this.requests.indexOf(e);-1!==t&&this.requests.splice(t,1)}cancelRequest(e){e.cancelToken.cancel("Request canceled"),this.removeRequest(e)}isDuplicateRequest(e){return this.requests.some((t=>this.areRequestsEqual(t,e)))}areRequestsEqual(e,t){return e.url===t.url&&JSON.stringify(e.data)===JSON.stringify(t.data)&&JSON.stringify(e.params)===JSON.stringify(t.params)&&e.method===t.method}}const n=o.getInstance(),s=3e3,l=3e3,d=(t="",r)=>{let i,a=e.create({baseURL:t,timeout:s,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}});return a.interceptors.request.use((function(t){let{url:r,params:a,headers:o,data:s,method:l}=t;const d=e.CancelToken.source();return i={url:r,params:a,headers:o,data:s,method:l,cancelToken:d},t.cancelToken=d.token,n.addRequest(i),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(e){return Promise.reject(e)})),a.interceptors.response.use((function(e){return 200===e.status||e.data.code,r&&r(e),n.removeRequest(i),e.data}),(function(e){return r&&(n.removeRequest(i),r(null==e?void 0:e.response)),Promise.reject(e.response)})),a};function c(e,t=!1){return t?u(e)?e:JSON.stringify(e):u(e)?JSON.parse(e):e}const u=e=>{if("string"==typeof e)try{const t=JSON.parse(e);return"object"==typeof t&&null!==t}catch(e){return!1}return!1},h=(e,t)=>{try{const r=JSON.stringify(t);sessionStorage.setItem(e,r)}catch(t){console.error(`Error setting session data for key ${e}:`,t)}},p=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},m=e=>{for(const t of e)t.code&&(t.code=t.code.replace(/&gt;/g,">").replace(/&lt;/g,"<"))},f=(e,t)=>{e instanceof Map?e.forEach((e=>{t([e])})):Array.isArray(e)&&e.forEach((e=>{t(e.children)}))},g=(e,t)=>{const r=e=>{var i,a,o;if(e)for(const n of e){const e=null===(o=null===(a=null===(i=null==n?void 0:n.tmpData)||void 0===i?void 0:i.source)||void 0===a?void 0:a.converse)||void 0===o?void 0:o.data;(null==e?void 0:e.length)&&m(e),t(n),n.children?r(n.children):n.dynamicChildren?f(n.dynamicChildren,r):n.stateChildren&&r(n.stateChildren)}};r(e)},v=(e,t,r,i)=>{const a=e.match(/({{[\w]*}})|((@)[\w]*)/gm);if(a){const e=a.map((e=>e.replace(/{{|}}|@/gm,"")));for(const a of e)if(a&&t&&!(t.findIndex((e=>e.mapField===a))<0))return r&&i&&y(i,a,r.cid),!0}return!1},y=(e,t,r)=>{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(!r)throw new Error("ID is required");Array.isArray(e[t])||(e[t]=[]),e[t].includes(r)||e[t].push(r)},b=(e,t,r)=>{var i;let a=!1;const o=null==t?void 0:t.converse;if(o&&o.use&&o.data.length)for(const t of o.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))&&(a=v(n.inputSql||n.url||(null===(i=n.headers)||void 0===i?void 0:i.value)||n.params,r)),a},w=(e,r,i=!1)=>{let a=null;const o=e=>{for(const n of e){if(n.cid===r){a=n,i&&t.remove(e,(e=>e.cid===r));break}if(n.children&&o(n.children),n.dynamicChildren&&Array.isArray(n.dynamicChildren))for(const[,e]of Array.from(n.dynamicChildren))o(e);n.stateChildren&&o(n.stateChildren)}};return o(e),a},D=(e,r,i)=>{let a=!1;const o=e=>{for(let n=0;n<e.length;n++){if(e[n].cid==r){a=e[n],i&&t.remove(e,(e=>e.cid==r));break}if(e[n].children)o(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 r=t[e][1];o(r)}}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 r=t[e][1];o(r)}}}else e[n].stateChildren&&o(e[n].stateChildren)}};return o(e),a||!1};function N(e,t,r){const i={};r&&r.forEach((e=>{(null==e?void 0:e.name)&&(i[e.name]=e.value||e.originvalue)}));try{return new Function("data","vars",e)(t,i)}catch(e){return console.error(e),t}}function k(e,r){let i=t.cloneDeep(r);try{return new Function("data",e)(i)}catch(e){return console.error(e),i}}const S=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)},A=e=>{let t=window.goFetchList;t&&t[e]&&delete t[e]},C="anov@2019:helloX",x="anov@2020:helloX";function O(e){let t=i.enc.Utf8.parse(C),r=i.enc.Utf8.parse(x);return i.AES.encrypt(e,t,{iv:r,mode:i.mode.CBC,padding:i.pad.Pkcs7}).toString()}function V(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 r=t.reduce(((e,t)=>e+t),0),i=Math.random()*r;let a=0;for(let r=0;r<e.length;r++)if(a+=t[r],i<a)return e[r];return e[0]}const T=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"]),F=URL.createObjectURL(T);function E(e,t,r={},i="worker"){return a(this,void 0,void 0,(function*(){try{if("window"==i){let[i,a]=[["data"],[t]];"object"==typeof r&&Object.keys(r).forEach((e=>{i.push(e),a.push(r[e])}));const o=new Function(...i,e);return{success:!0,data:o(...a)}}{let[i,o,n]=[t,r,""];"object"==typeof i&&(i=JSON.stringify(t)),"object"==typeof r&&(o=JSON.stringify(r)),Object.keys(r).forEach((e=>n+=`${e},`));let s=`let data=eval(${i}); \n             let app=${JSON.stringify({})};`;s+=n?`let {${n}} = eval(${o}); `:"",s+=`${e}`;let l=yield function(e,t=5e3){return a(this,void 0,void 0,(function*(){let r=new Worker(F);return new Promise(((i,a)=>{const o=()=>{clearTimeout(s),r.removeEventListener("message",n),r.terminate(),r=null},n=e=>{let{code:t,result:r,err:n}=e.data;o(),1===t?i(r):a(n)};r.postMessage({code:e}),r.addEventListener("message",n);let s=setTimeout((()=>{o(),a("timeout")}),t)}))}))}(s);return{success:!0,data:l}}}catch(e){return{success:!1,error:e,data:t}}}))}var R,I,j,P;!function(e){e.StaticFile="staticFile",e.DataSource="datasource"}(R||(R={})),function(e){e.json="application/json;charset=UTF-8",e.form="application/x-www-form-urlencoded; charset=UTF-8"}(I||(I={})),function(e){e.get="GET",e.post="POST",e.put="PUT",e.patch="PATCH",e.delete="DELETE"}(j||(j={}));class q{constructor(e){this.db=null,this.dbName=e.databaseName,this.tableName=e.tableName,this.keyPath=e.keyPath}static getInstance(e){return q.instance||(q.instance=new q(e)),q.instance}init(){return a(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{const r=indexedDB.open(this.dbName,1);r.onerror=e=>{t(e.target.error)},r.onupgradeneeded=e=>{this.db=e.target.result,this.db.objectStoreNames.contains(this.tableName)||this.db.createObjectStore(this.tableName,{keyPath:this.keyPath})},r.onsuccess=t=>{this.db=t.target.result,e()}}))}))}addRecord(e){return a(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,r)=>{const i=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).add(e);i.onsuccess=()=>{t()},i.onerror=e=>{r(e.target.error)}}))}))}deleteRecord(e){return a(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,r)=>{const i=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).delete(e);i.onsuccess=()=>{t()},i.onerror=e=>{r(e.target.error)}}))}))}updateRecord(e){return a(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,r)=>{const i=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).put(e);i.onsuccess=()=>{t()},i.onerror=e=>{r(e.target.error)}}))}))}getRecord(e){return a(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,r)=>{const i=this.db.transaction([this.tableName],"readonly").objectStore(this.tableName).get(e);i.onsuccess=()=>{t(i.result)},i.onerror=e=>{r(e.target.error)}}))}))}getAllRecords(){return a(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((e,t)=>{const r=this.db.transaction([this.tableName],"readonly").objectStore(this.tableName).getAll();r.onsuccess=()=>{e(r.result)},r.onerror=e=>{t(e.target.error)}}))}))}}q.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 M={databaseName:"GODB",tableName:"go-log",keyPath:"time"};class U{constructor(){this.logLevel=P.INFO,this.indexedDBInstance=q.getInstance(M);try{this.indexedDBInstance.init(),console.log("IndexedDB 初始化成功。")}catch(e){console.error("初始化 IndexedDB 时出错:",e)}}static getInstance(){return U.instance||(U.instance=new U),U.instance}setLogLevel(e){this.logLevel=e}getColor(e){switch(e){case P.FATAL:return"";case P.ERROR:return"";case P.WARN:return"";case P.INFO:return"";case P.DEBUG:return"";case P.TRACE:return"";default:return""}}log(e,t){if(t<=this.logLevel){const r=(new Date).toISOString(),i=`[${r}] [${P[t]}]`,a=this.getColor(t);if(null===window||void 0===window?void 0:window.goDev)console.log(`${a}${i} ${e}`);else{let t=p("anov-go-userInfo"),o=p("anov-go-proid"),n=` [操作人:${null==t?void 0:t.userName} 项目ID:${o}] `;const s={time:r,value:`${e}`};try{this.indexedDBInstance.addRecord(s)}catch(e){console.error("添加记录时出错:",e)}console.log(`${a}${i} ${n} ${e}`)}}}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.getInstance(),L=(e,t)=>"string"!=typeof e?Promise.reject(new Error("URL should be a string")):d(e,t),z=d();let H=d();function J(e,r="get",i={},o={}){return a(this,void 0,void 0,(function*(){try{const n={method:j[r],url:e,headers:o,timeout:l};["post","put"].includes(r.toLowerCase())?n.data=t.cloneDeep(i):n.params=t.cloneDeep(i);return/.json$/.test(e)?function(e){return a(this,void 0,void 0,(function*(){try{return(yield z({method:"get",url:e})).data}catch(e){throw console.error("JSON 数据请求:",e),e}}))}(e):function(e){return a(this,void 0,void 0,(function*(){try{return{code:2e4,data:(yield z(e)).data}}catch(e){throw console.error("请求数据发生错误-Error:",e),e}}))}(n)}catch(e){throw console.error("获取数据:Error:",e),e}}))}function G(e,t,r,i){return a(this,void 0,void 0,(function*(){try{const a=window.anUrl||"",o=a+(window.agentPath||"/ds/v1/api-proxy/v1/query"),n=c(r,!0);return yield z({url:o,method:"post",headers:{"Content-Type":"application/json;charset=UTF-8"},data:{body:"post"===e?n:void 0,headers:u(i)?JSON.parse(i):i,method:e,url:t}})}catch(e){throw console.error("代理请求数据:Error:",e),e}}))}function B(e,t,r,i,o){return a(this,void 0,void 0,(function*(){return o?G(t,e,r,i):J(e,t,r,i)}))}function W(e,t="",r){var i,a,o,n;const l=`${null!==(a=null===(i=null===window||void 0===window?void 0:window.BaseUrl)||void 0===i?void 0:i.replace("/management",""))&&void 0!==a?a:""}/ds/data-engine/v1/${e}/zb-query?${`token=${(null===(o=ae("YZH_EXCHANGE_TOKEN"))||void 0===o?void 0:o.YZH_EXCHANGE_TOKEN)||(null===(n=null===window||void 0===window?void 0:window.yzhAuth)||void 0===n?void 0:n.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 z({method:"POST",url:l,data:{headers:r,param:d},timeout:s})}const X=(e,t)=>a(void 0,void 0,void 0,(function*(){const r=window.BaseUrl,{dateType:i="",endPeriod:a="",metricsName:o=e,startPeriod:n=""}=t;return H({method:"GET",url:`${r}ds/v1/metrics/v1/data-alarm?dateType=${i}&endPeriod=${a}&metricsName=${o}&startPeriod=${n}`,timeout:s})})),_=(e,t,r)=>a(void 0,void 0,void 0,(function*(){var i;const a=(null===(i=window.BaseUrl)||void 0===i?void 0:i.replace("/management",""))||"";t.newEncryption=!0;const o={staticFile:{method:"get",params:t,url:`${a}/ds/v1/file/v1/${e}/query`},datasource:{method:"post",url:`${a}/ds/v1/database/v1/${e}/query`,data:Object.assign({},t)}}[r];if(!o)throw new Error("Invalid data type provided");return z(Object.assign({timeout:s},o))})),Q=e=>new Promise(((t,r)=>{let i;i=e.originData&&Object.keys(e.originData).length?e.originData:e.data,void 0!==i?t({data:i}):r("Failed to retrieve cdata")})),Y=(e,t,r)=>{try{switch(t){case"api":{let t=se(e,r);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=ne(e.inputSql,r);return{dsName:e.dsName,dsType:"1",sql:O(t),filter:e.sqlFilter}}case"staticFile":return{dsName:e.dsName,dsType:e.dsType,sql:""};case"indicator":return{zbId:e.zbId,params:ne(e.params,r),headers:ne(e.headers,r)};case"indicatorCQ":return{zbName:e.zbName,params:ne(e.params,r)};case"packData":return{};default:throw new Error("Invalid type")}}catch(t){console.log("准备请求数据发生错误",t,e)}},K=(e,t)=>a(void 0,void 0,void 0,(function*(){try{switch(t){case"api":return yield B(e.url,e.requestType,e.params,e.headers,e.agency);case"static":return yield Q(e.data);case"datasource":return yield _(e.dsName,{dsType:e.dsType,sql:e.sql,filter:e.filter},"datasource");case"staticFile":return yield _(e.dsName,{dsType:e.dsType,sql:e.sql},"staticFile");case"indicator":return yield W(e.zbId,e.params,e.headers);case"indicatorCQ":return yield X(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})}))}})),Z=(e,t,r,i=[],o=!1)=>a(void 0,void 0,void 0,(function*(){const a=t||e.tmpData.source.dataType,n=e.tmpData.source["indicatorCQ"==a?"indicator":a];if("globalData"===a){const e=i.find((e=>e.key===n.id||e.key===n.key)),t=p(n.id);if(t&&!o)return t.data;if(e){let t=yield ee(e,r),i={key:n.id,data:t};return h(n.id,i),t}return}const s=Y(n,a,r),l=yield K(s,a);return(null==l?void 0:l.data)?l.data:l})),ee=(e,t)=>a(void 0,void 0,void 0,(function*(){let r=Object.assign({},{tmpData:{source:e.value}});const i=r.tmpData.source.type,a=r.tmpData.source[i],o=Y(a,i,t),n=yield K(o,i);return yield te(n.data,r,!0,t)})),te=(e,r,i=!0,o)=>a(void 0,void 0,void 0,(function*(){try{const{converse:n,mapFields:s}=r.tmpData.source;return n&&n.use&&i?yield new Promise(((r,i)=>{const s=function(e,r,i,o,n){return a(this,void 0,void 0,(function*(){let i,a=e,{use:n,data:s}=t.cloneDeep(r);if(n)for(let e=0;e<s.length;e++)if(s[e].use){let r=s[e].dependVars,n={};o&&n&&r&&r.length&&r.map((e=>{let r=t.cloneDeep(o).filter((t=>{let r=t.mapField==e;return r&&(n[e]=t.value),r}));r&&0!=r.length||(n[e]="")})),i=yield E(s[e].code,a,n,s[e].mode?s[e].mode:"worker"),a=i.data}return a}))}(e,n,0,o);r(s)})):yield new Promise(((t,r)=>{t(e)}))}catch(t){return console.error("执行过滤器发生错误:"+t),yield new Promise(((t,r)=>{t(e)}))}})),re=(e,t,r)=>{const{source:i}=e.tmpData,a=i.type;r?("static"===a&&i[a]&&(i[a].originData=r),"indicatorCQ"===a?i.indicator.data=t:i[a].data=t):"indicatorCQ"===a?i.indicator.data=t:i[a].data=t,e.source=t},ie=(e,t,r=[],i,o,n)=>a(void 0,void 0,void 0,(function*(){try{let a=e.tmpData.source.type,s=yield Z(e,a,r,i,n||!1);if(null==s||!s)return o&&o({error:!0}),Promise.resolve({error:!0});let l=yield te(s,e,t,r);return re(e,l),o&&o(l),(null==e?void 0:e.cid)&&A(e.cid),Promise.resolve(l)}catch(e){return o&&o(e),$.error("Error in updateComData"),console.error("Error in updateComData:",e),Promise.reject(e)}})),ae=e=>{const t={};if(e&&e.includes("?")){const r=e.split("?")[1].split("&");for(let e of r){const[r,i]=e.split("=").map(decodeURIComponent);t[r]=i}}return t},oe=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}},ne=(e,t)=>{if(!t)return oe(e);if("string"==typeof e){if(""===e.trim())return"";try{if("string"!=typeof JSON.parse(e))return ne(JSON.parse(e),t);{let r=e.replace(/@(\w+)|{{(\w+)}}/g,((e,r,i)=>{const a=r||i,o=t.find((e=>e.mapField===a));return o?o.value||o.originalValue||"":e}));return oe(r)}}catch(r){let i=e.replace(/@(\w+)|{{(\w+)}}/g,((e,r,i)=>{const a=r||i,o=t.find((e=>e.mapField===a));return o?o.value:e}));return oe(i)}}else{if(Array.isArray(e))return e.map((e=>ne(e,t)));if("object"==typeof e&&null!==e){const r={};for(let i in e)r[i]=ne(e[i],t);return oe(r)}}return oe(e)},se=(e,t)=>{const r=e.agency,i=e,{url:a=null,headers:o,params:n,requestType:s}=i,l=a?ne(a,t):void 0,d=o&&o.use?ne(o.value,t):{};return{url:l,requestType:s,params:n?ne(n,t):{},headers:d,agency:r}},le=(e,t,r,i,o)=>a(void 0,void 0,void 0,(function*(){if(e&&e.length)for(const a of e){b(t,a.value,r)&&(yield ie({tmpData:{source:{type:"globalData",globalData:{id:a.key}}}},!0,r,e,(e=>{console.log("数据更新成功-变量改变全局数据跟新")}),!0),g(i,(t=>{var i,n,s;if("globalData"===(null===(n=null===(i=null==t?void 0:t.tmpData)||void 0===i?void 0:i.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===a.key&&ie(t,!0,r,e,(e=>{o(t,e)}),!1)}})))}})),de=(e,t,r,i,o)=>a(void 0,void 0,void 0,(function*(){e&&(yield ie({tmpData:{source:{type:"globalData",globalData:{id:e.key}}}},!0,t,r,(e=>{console.log("数据更新成功-数据源编辑")}),!0),g(i,(i=>{var a,n,s;if("globalData"===(null===(n=null===(a=null==i?void 0:i.tmpData)||void 0===a?void 0:a.source)||void 0===n?void 0:n.type)){(null===(s=null==i?void 0:i.tmpData)||void 0===s?void 0:s.source.globalData).id===e.key&&ie(i,!0,t,r,(e=>{o(i,e)}),!1)}})))}));class ce{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?k(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 i;const a=Object.assign({},this,e);this.des=a.des,this.field=a.field,this.mapping=a.mapping,this.type=a.type,this.originalValue=a.originalValue,this.converter=a.converter,this.converterCode=a.converterCode,this.fork=a.fork,this.delayUpdate=null==a?void 0:a.delayUpdate,this.model=null==a?void 0:a.model,e.id&&(this.id?"string"==typeof this.id?e.id instanceof Array?this.id=r([this.id,...e.id]):this.id=[this.id,e.id]:this.id instanceof Array&&(e.id instanceof Array?this.id=r([...this.id,...e.id]):this.id=r([...this.id,e.id])):this.id=e.id),e.fork&&(this.model=5,this.forkValue=null!==(i=e.forkValue)&&void 0!==i?i:this.forkValue,this.originalValue=this.getForkedValue()),t&&t(this)}updateWidthOriginalValue(e,t){var r;this.originalValue=e,this.fork&&(this.forkValue=null!==(r=this.forkValue)&&void 0!==r?r:this.forkValue,this.originalValue=this.getForkedValue()),t&&t(this)}renew(e){e&&e(this)}static create(e,t){return new ce(e,t)}}class ue{constructor(){this.variables=new Map,this.globalObservers=[],this.url=window.location.search,this.list=[]}clearVars(){this.list=[],this.variables.clear()}togglePropertyState(e,t,r){try{let i=this.getVariable(e);if(!i)throw new Error("没有找到相应的变量!");i.togglePropertyState(t),this.addToObjectArray(this.list,i),r&&r()}catch(e){console.error(e)}}static getInstance(){return ue.instance||(ue.instance=new ue),ue.instance}getFullUrl(){this.url=window.location.search}getAllUrlParams(){const e=new URLSearchParams(window.location.search),t={};for(const[r,i]of e.entries())t[r]=i;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),r=[];for(const i of t)r.push({mapField:i,originalValue:e[i],model:4});if(r.length)for(const e of r)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 r=this.getVariable(e.mapField);return this.sameValue(r,e)?r:(this.editVariable(e,t),!1)}const r=ce.create(e,this.variables);return this.variables.set(r.mapField,r),this.addToObjectArray(this.list,r),t&&t(r),this.notifyGlobalObservers(r),r}toJSON(e){try{return!!e&&JSON.stringify(e)}catch(e){return!1}}sameValue(e,t){if(e.mapfield!==t.mapfield)return!1;for(const r in t)if(!(["mapfield","field","key","value","name","globalVariables"].includes(r)||r in e&&e[r]==t[r]))return!1;return!0}creatVarJson(e){const{des:t,field:r,id:i,key:a,mapping:o,mapField:n,type:s,value:l,originalValue:d,model:c,converter:u,converterCode:h,fork:p,forkValue:m,update:f,delayUpdate:g}=e,v={};return void 0!==t&&(v.des=t),void 0!==r&&(v.field=r),void 0!==i&&(v.id=i),void 0!==a&&(v.key=a),void 0!==o&&(v.mapping=o),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!==m&&(v.forkValue=m),void 0!==f&&(v.update=f),void 0!==g&&(v.delayUpdate=g),v}addToObjectArray(e,t){let r=!1;for(let i=0;i<e.length;i++)if(e[i].mapField==t.mapField){e[i]=this.creatVarJson(t),r=!0;break}r||e.push(t)}editVariable(e,t){const r=this.getVariable(e.mapField);if(r&&this.isVariableNameExist(e.mapField)){if(this.sameValue(r,e))return}const i=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}};r?r.updateValue(e,i):this.addVariable(e,i)}getForkList(e){let t=this.isMapFieldInForkValues(e);return t||[]}editVariableForValue(e,t,r){const i=this.getVariable(e),a=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),r&&r(e),e.isUpdating=!1}};i&&i.updateWidthOriginalValue(t,a)}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 r=this.getVariable(e);return t==r.id&&!r.id.includes(t)&&[{key:e}]}if(Array.isArray(e)){const r=e.filter((e=>{let r=this.getVariable(e);return this.isVariableNameExist(e)&&t!=r.id&&!(r.id&&r.id.includes(t))})).map((e=>({key:e})));return!!r.length&&r}return!1}getVariable(e){return this.variables.get(e)}getVariableForId(e){var r;let i=[];for(const[,t]of this.variables)(t.id===e||(null===(r=t.id)||void 0===r?void 0:r.includes(e)))&&i.push(t);return t.uniq(i)}getAllVariables(e=!1){return this.addUrlParamsToGlobalVars(),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)}))}}ue.instance=null;const he=ue.getInstance(),pe=(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))),me=(e,t,r,i)=>{const a=((e,t,r,i)=>{var a;let o;if(pe(e,null==t?void 0:t.field)||pe(e,null==t?void 0:t.forkValue))o=e[null==t?void 0:t.field]||"";else if(pe(e.data,null==t?void 0:t.field)||pe(e.data,null==t?void 0:t.forkValue))o=e.data[null==t?void 0:t.field]||"";else{const e=w(r,i),n=(null===(a=null==e?void 0:e.tmpData)||void 0===a?void 0:a.actions)||[];for(const e of n){const r=e.vars.find((e=>(null==e?void 0:e.mapField)===(null==t?void 0:t.mapField)));if(r){o=r.value;break}}}return o})(e,t,r,i);return void 0!==a?a:t.value},fe=(e,t,r,i,a,o,n,s,l)=>{var d;switch(e.type){case"link":let c=ne(e.link,o);window.open(c,e.target);break;case"page":if(null===(d=null==e?void 0:e.params)||void 0===d?void 0:d.length)for(let t=0;t<e.params.length;t++){const r=e.params[t],i=o.find((e=>e.mapField==r.mapField));i&&(r.value=i.value)}l&&l(e);break;case"dynamic":((e,t,r,i,a)=>{const o=e.dynamic||[];for(const n of o){if(e.id!==t.cid)continue;const o=w(r,n.pid);o&&(o.activeDynamic=n.name,o.isShow=n.visible||!i||e.index===t.index-1,a({cid:o.cid,flag:n.visible}))}})(e,t,r,i,a);break;case"toggle":((e,t,r,i,a)=>{const o=e.children||[];for(const r of o){const o=r.visible&&(!i||e.index===t.index-1);a({cid:r.cid,flag:o})}})(e,t,0,i,a);break;case"update":((e,t,r,i,a)=>{const o=e.children||[];for(const e of o){const o=w(t,e.cid);o&&ie(o,!0,r,i,(e=>{a({cid:o.cid,data:e})}))}})(e,r,o,n,s)}},ge=(e,r,i,a,o,n,s,l,d,c)=>{const{cid:u,actions:h,index:p}=o,{eventName:m,mode:f}=h,g=2===f;((e,r,i,a,o,n)=>{let s=he.getVariableForId(r.cid);if(null==s?void 0:s.length)for(const l of s)if(l.type==e){let e=me(r,l,i,a);he.editVariableForValue(l.mapField,e,(()=>{let e=o[l.mapField]||[],r=he.getForkList(l.mapField);if(r)for(const i of r){let r=o[i.mapField];e=t.concat(e,r)}n&&n(l,t.uniq(e))}))}})(m,o,a,u,i,((e,t)=>{if(le(d,e.mapFile,he.getAllVariables(),a,((e,t)=>{s({cid:e.cid,data:t})})),null==t?void 0:t.length)for(const r of t){e.eventSourceId=r;const t=w(a,r);!(null==e?void 0:e.delayUpdate)&&t&&ie(t,!0,he.getAllVariables(),d,(e=>{s({cid:t.cid,data:e})}))}}));const v=((e,t,r,i,a)=>e.filter((e=>e.id===t&&e.eventType===r&&(!a||parseInt(e.index||"0")+1===parseInt(i||"0")))))(e,u,m,p,g);for(const e of v)fe(e,o,a,g,n,he.getAllVariables(),d,s,l)},ve=(e,t={})=>{let r={},i={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(r,i,t),r},ye=(e,r)=>{let{option:i,actions:a,data:o,optionDes:n,actionsDes:s,source:l,theme:d}=((e,r)=>{let{option:i,actions:a,data:o,optionDes:n,actionsDes:s,source:l,theme:d}=t.cloneDeep(r[e]);return{option:i,actions:a,data:o,optionDes:n,actionsDes:s,source:l,theme:d}})(e,r);return{iconClass:null,isAssembly:null,source:o,cid:(Math.random().toString().substr(3,10)+Date.now()).toString(),isLock:!1,isShow:!0,tmpData:{option:i,source:ve(o,l),actions:a},baseData:we(),dynamic:null,filePath:"",origin:"anov-ui",name:"",componentType:"",viewComName:e,optionComName:"AnOptionPanel",dataComName:"AnSourcePanel",eventComName:"AnActionsPanel",assemblyDeveloper:"",devEmail:"",version:"",devDept:""}},be=(e,r,i)=>{let a=ye(e,r);return i?t.merge(a,i):a},we=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 De{constructor(e,t,r){this.theme=null,this.plant=null,this.list=[],this.titleHeqadeHeight=70,this.clearance=3,this.checkComponentIntersection=(e,t,r=10)=>{const i=e.left,a=e.left+e.width,o=e.top,n=e.top+e.height,s=t.left,l=t.left+t.width,d=t.top,c=t.top+t.height,u=i<l&&a>s&&o<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<r&&p<r},this.calculateCombinedComponent=e=>{if(0===e.length)return{left:0,top:0,width:0,height:0};let t=e[0].left,r=e[0].top,i=e[0].left+e[0].width,a=e[0].top+e[0].height;for(let o=1;o<e.length;o++){const n=e[o];t=Math.min(t,n.left),r=Math.min(r,n.top),i=Math.max(i,n.left+n.width),a=Math.max(a,n.top+n.height)}return{left:t,top:r,width:i-t,height:a-r}},this.getAnTextNormaltText=e=>{var t,r;try{return null===(r=null===(t=null==e?void 0:e.tmpData)||void 0===t?void 0:t.option)||void 0===r?void 0:r.text}catch(e){return console.error("配置优化(ConfigOptimizer):",e),""}},this.initProp(e),this.upgradePlant(),this.staticComponentData=t,this.upgradeHeaderComponent(),r&&Object.assign(this,r)}isStringOrObject(e){return"string"==typeof e?"string":"object"==typeof e&&null!==e&&"object"}initProp(e){try{let t,r=this.isStringOrObject(e);if(r&&"string"===r)t=JSON.parse(e);else{if(!r||"object"!==r)throw new Error(`initProp fn error :-- 传入参数${e}不合法!`);t=e}if(t){this.originData=t;const{theme:e,plant:r,list:i}=t;this.theme=e,this.plant=r,this.list=i,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 r=e.baseData,i=t.baseData;const a=Math.max(0,Math.min(r.left+r.width,i.left+i.width)-Math.max(r.left,i.left)),o=Math.max(0,Math.min(r.top+r.height,i.top+i.height)-Math.max(r.top,i.top));return a>0&&o>0}filterFileGroup(){this.list=t.cloneDeep(this.list).map((e=>{var t,r;if(1===(null===(t=null==e?void 0:e.children)||void 0===t?void 0:t.length)&&!(null===(r=null==e?void 0:e.children[0])||void 0===r?void 0:r.children)){const t=e.children[0],{left:r,top:i}=e.baseData;return t.baseData.left=r,t.baseData.top=i,t}return e}))}getText(e,t,r){const i=document.createElement("canvas").getContext("2d");if(!i)throw new Error("Failed to get 2D context from canvas.");i.font=`${r}px ${t}`;return i.measureText(e).width}calculateMaxWidths(e){const t=Math.min(...e.map((e=>e.width))),r=[];let i=[],a=e[0].width;for(const o of e){const e=o.width;Math.abs(e-a)<=t?i.push(e):(i.length>0&&r.push(i),i=[e]),a=e}i.length>0&&r.push(i);const o=[];for(const e of r){const t=Math.max(...e);o.push(t)}return o}findClosestValue(e,t){let r=t[0],i=Math.abs(e-r);for(const a of t){const t=Math.abs(e-a);t<i&&(i=t,r=a)}return r}adjustHeightAndTop(e,t){const r=t-e.height;return Object.assign(Object.assign({},e),{height:t,top:e.top-r/2})}findNearestComponent(e,r,i){let a=null,o=1/0;r.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===r.cid||"AnTextNormal"===e.viewComName||i&&i.includes(e.cid)))),s=t.cloneDeep(r).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 r=t.top-s.top;r<o&&r<100&&(o=r,a=e)}}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return a}findNearestComponentForPoint(e,t,r){let i=null,a=1/0;t.tmpData.option.textNormal.text;try{const o=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||r&&r.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of o){const t=e.baseData;let r=this.getDistance(n.left,n.top+n.height,t.left,t.top);r<a&&r<n.width&&(a=r,i=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return i}findNearestComponentForTitlePoint(e,t,r){let i=null,a=1/0;t.tmpData.option.textNormal.text;try{const o=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||r&&r.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of o){const t=e.baseData;let r=this.getDistance(n.left,n.top+n.height,t.left,t.top);r<a&&r<n.width&&t.top-n.top>100&&(a=r,i=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return i}findNearestTitleForPoint(e,t,r){let i=null,a=1/0;t.tmpData.option.textNormal.text;try{const o=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||r&&r.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of o){const t=e.baseData;let r=t.top-n.top;r<a&&r<n.width&&t.top-n.top>100&&(a=r,i=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return i}getDistance(e,t,r,i){return Math.sqrt(Math.pow(r-e,2)+Math.pow(i-t,2))}findNearestComponent2(e,r,i){let a=null,o=1/0,n=t.cloneDeep(e).sort(((e,t)=>e.baseData.top-t.baseData.top));try{const e=n.filter((e=>!(e.cid===r.cid||"AnTextNormal"===e.viewComName||i&&i.includes(e.cid)))),s=t.cloneDeep(r).baseData,l=s.top+s.height;for(const t of e){const e=t.baseData,r=e.top+e.height;if(s.left<e.left+e.width&&s.left+s.width>e.left){const e=r-l;e>=0&&e<o&&(o=e,a=t)}}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return a}verticalDistance(e,t){e.left,e.width;const r=e.top+e.height,i=(t.left,t.width,t.top);return Math.abs(r-i)}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=[],r=new Set;for(const i of e){if(r.has(i.cid))continue;let a=[];for(const t of e){if(!r.has(t.cid)&&i.cid!=t.cid){this.checkComponentIntersection(i.baseData,t.baseData)&&(r.add(t.cid),r.add(i.cid),a.push(t))}}t.push([i,...a])}let i=[];for(const e of t)for(const t of e){let r=this.getAnTextNormaltText(t);this.extractAmount(r).every((e=>e))&&i.push(e)}return i}createAnOdometer(){var e,r;let i=this.judgeAnOdometer();for(const a of i){let i,o,n,s=this.calculateCombinedComponent(a.map((e=>e.baseData)));for(const e of a){let r=this.getAnTextNormaltText(e),a=this.extractAmount(r);a.every((e=>!e))&&(i=r),a.every((e=>e))&&(o=a[0],n=a[1]),t.remove(this.list,(t=>t.cid==e.cid))}let l=be("AnIndicatorNormal",this.staticComponentData,t.cloneDeep({baseData:s}));(null===(r=null===(e=null==l?void 0:l.tmpData)||void 0===e?void 0:e.source)||void 0===r?void 0:r.static)&&(l.tmpData.source.static.data={text:i,num:o,unit:n},l.tmpData.source.static.originData={text:i,num:o,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 r=this.list[e];if("AnDeckTitle3"==r.viewComName){let e=this.findClosestValue(r.baseData.width,t);r.baseData.width=e>300?e:300,r.baseData=this.adjustHeightAndTop(r.baseData,this.titleHeqadeHeight)}}this.removeErroneousComponents()}containsFractionStructure(e){return/\b\d+\/\d+\b/.test(e)}removeErroneousComponents(){let e=this.getAnDeckTitle3(),t=[];for(let r=0;r<e.length;r++){const i=e[r];let a=i.tmpData.option.textNormal.text;if(this.containsFractionStructure(a))for(let r=0;r<e.length;r++){const a=e[r];if(i.cid!=a.cid){this.areComponentsIntersecting(i,a)&&t.push(i.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)),r=[],i=[];for(let a=0;a<e.length;a++){const o=e[a];let n=this.findNearestComponentForPoint(t,o,r);if(n&&n.cid&&r.push(n.cid),n){o.baseData.left=n.baseData.left;let t=this.upgradeComponentHeight(o,e,i);t&&t>=30&&(n.baseData=Object.assign({},n.baseData,{top:o.baseData.top+o.baseData.height+this.clearance}))}}}catch(e){console.error("配置优化(ConfigOptimizer):",e)}}upgradeComponentHeight(e,r,i=[]){const a=e;let o=this.findNearestTitleForPoint(t.cloneDeep(r),a);return o?o.baseData.top-a.baseData.top-this.titleHeqadeHeight:1080-a.baseData.top-this.titleHeqadeHeight}getData(){return this.originData.list=this.list,this.originData.plant=this.plant,this.originData}}const Ne=new class{randomNum(e,t){return Math.floor(Math.random()*(t-e+1))+e}generateRandomIntArray(e,t,r,i){const a=[];for(let i=0;i<e;i++){const e=this.randomNum(t,r);a.push(e)}return i&&"asc"===i?a.sort(((e,t)=>e-t)):i&&"desc"===i?a.sort(((e,t)=>t-e)):a}randomString(e,t){const r="abcdefghijklmnopqrstuvwxyz",i=this.randomNum(e,t);let a="";for(let e=0;e<i;e++){const e=Math.floor(26*Math.random());a+=r.charAt(e)}return a}generateRandomNameArray(e,t,r){const i=[];for(let a=0;a<e;a++){const e=this.randomString(t,r);i.push(e)}return i}pick(e,t){const r=void 0!==t?e.filter((e=>e!==t)):e;return r[Math.floor(Math.random()*r.length)]}},ke=()=>{const e=[],t=Ne.pick([!0,!1]);let r=Ne.randomNum(3,20);const i=Ne.pick([null,null,null,{}]);let a=Ne.pick(["asc","desc",void 0,void 0,void 0]);for(let o=0;o<Ne.randomNum(1,9);o++)e.push({data:Ne.generateRandomIntArray(r,0,300,a),type:"line",smooth:t,symbolSize:Ne.randomNum(1,10),lineStyle:{width:Ne.randomNum(1,4)},areaStyle:i});return{xAxis:{type:"category",show:!1,boundaryGap:!1,data:Ne.generateRandomNameArray(r,3,6)},grid:{left:0,top:0,bottom:0,right:0},yAxis:{show:!1,type:"value"},series:e}},Se=(e,t)=>{let r={type:e,show:!1};return"category"===e&&(r.data=Ne.generateRandomNameArray(t,3,6)),r},Ae=()=>{const e=[],t=Ne.pick([!0,!1]);let r=Ne.randomNum(3,20);const i=Ne.pick([null,null,null,{}]);let a=Ne.pick(["asc","desc",void 0,void 0,void 0]),o=Ne.randomNum(1,9),n=Ne.pick([!0,!1]);for(let s=0;s<o;s++){let o={data:Ne.generateRandomIntArray(r,0,300,a),type:"bar",smooth:t,stack:n,areaStyle:i};e.push(o)}let s=Ne.pick(["value","category"]),l=Ne.pick(["value","category"],s);return{xAxis:Se(s,r),grid:{left:0,top:0,bottom:0,right:0},yAxis:Se(l,r),series:e}},Ce=()=>{const e=[];let t=Ne.randomNum(3,20);Ne.pick([null,null,null,{}]);let r=Ne.pick(["asc","desc",void 0,void 0,void 0]),i=Ne.pick([1,2]),a=[Ne.pick(["10%","20%","30%","40%","50%","60%","70%","80%"]),Ne.pick(["90%","100%"])];return e.push({data:Ne.generateRandomIntArray(t,3,20,r),type:"pie",radius:1==i?"100%":a,roseType:1==i?Ne.pick(["area",null,null]):null,padAngle:1==i?0:Ne.randomNum(1,5),startAngle:1==i?Ne.pick([0,180]):0,endAngle:360,label:{show:!1},itemStyle:{borderRadius:3}}),{grid:{left:0,top:0,bottom:0,right:0},series:e}},xe=()=>{const e=[];Ne.pick([!0,!1]),Ne.randomNum(3,20),Ne.pick([null,null,null,{}]),Ne.pick(["asc","desc",void 0,void 0,void 0]);for(let t=0;t<Ne.randomNum(1,20);t++){let t=Ne.randomNum(3,Ne.randomNum(3,20)),r=[];for(let e=0;e<t;e++){let e=[];for(let t=0;t<2;t++)e.push(Ne.randomNum(1,30));r.push(e)}e.push({type:"scatter",symbolSize:Ne.randomNum(3,30),data:r})}return{xAxis:{show:!1},grid:{left:0,top:0,bottom:0,right:0},yAxis:{show:!1,type:"value"},series:e}},Oe=()=>{const e=[],t=Ne.pick(["polygon","circle"]);let r=Ne.randomNum(1e4,99999),i=Ne.randomNum(3,10),a=[];for(let e=0;e<i;e++)a.push({name:Ne.randomString(4,8),max:r});for(let t=0;t<Ne.randomNum(2,10);t++)e.push({value:Ne.generateRandomIntArray(i,1e4,r),name:Ne.randomString(4,8)});return{radar:{shape:t,indicator:a,axisName:{show:!1},radius:"100%"},grid:{left:0,top:0,bottom:0,right:0},series:[{type:"radar",symbol:"none",lineStyle:{width:1},data:e}]}},Ve=()=>{const e=[];for(let t=0;t<Ne.randomNum(4,15);t++)e.push({value:Ne.randomNum(1,100),name:Ne.randomString(4,8)});return{grid:{left:0,top:0,bottom:0,right:0},series:[{type:"funnel",left:"0%",top:0,bottom:0,width:"100%",min:0,minSize:"0%",maxSize:"100%",label:{show:!1,position:"inside"},sort:Ne.pick(["descending","ascending"]),gap:2,lineStyle:{width:1},data:e}]}};let Te=Ne.randomNum(5,20);const Fe={width:Te};Ne.pick([!0,!1])&&(Fe.color=[[.3,"#67e0e3"],[.7,"#37a2da"],[1,"#fd666d"]]);class Ee{constructor(){this.names=["line","bar","pie","scatter","radar","funnel","gauge"]}static getInstance(){return Ee.instance||(Ee.instance=new Ee),Ee.instance}createLine(){switch(Ne.pick(this.names)){case"line":return{type:"line",typeNum:1,option:ke()};case"bar":return{type:"bar",typeNum:2,option:Ae()};case"pie":return{type:"pie",typeNum:3,option:Ce()};case"scatter":return{type:"scatter",typeNum:4,option:xe()};case"radar":return{type:"radar",typeNum:5,option:Oe()};case"funnel":return{type:"funnel",typeNum:6,option:Ve()};case"gauge":return{type:"gauge",typeNum:7,option:{grid:{left:0,top:0,bottom:0,right:0},series:[{type:"gauge",radius:"100%",detail:{formatter:"{value}"},progress:{show:Ne.pick([!0,!1]),width:Te},axisLine:{lineStyle:Fe},data:[{value:Ne.randomNum(1,100),name:"SCORE"}]}]}}}}}Ee.instance=null;const Re=Ee.getInstance();const Ie=new class{constructor(){this.directions=["row","row"],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,r=(null==e?void 0:e.colNum)?null==e?void 0:e.colNum:this.splitNumbers,i=e.wrapWidth/r,a=e.wrapHeight/t;let o=V(this.directions);o&&(this.direction=o);let n=[];if("row"===this.direction){let e=V([3,4]);n=this.simulateRandomSegments(24,4,12,e)}else{let e=V([2,3]);n=this.simulateRandomSegments(24,4,6,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:i,hStep:a});else{let t=s[e-1].x;s.push({x:n[e-1]+t,y:0,w:n[e],h:24,i:e,wStep:i,hStep:a})}let e=V([2,3]),t=this.simulateRandomSegments(24,6,12,e);for(let e=0;e<s.length;e++){const r=s[e];for(let o=0;o<t.length;o++){const n=t[o];l.push({x:r.x,y:n,w:r.w,h:n,i:10*e+o,wStep:i,hStep:a})}}}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:i,hStep:a});else{let t=s[e-1].y;s.push({x:0,y:n[e-1]+t,w:24,h:n[e],i:e,wStep:i,hStep:a})}for(let e=0;e<s.length;e++){const t=s[e];let r=V([1,2,3,4]),o=this.simulateRandomSegments(24,5,12,r),n=[];for(let r=0;r<o.length;r++){const s=o[r];if(0==r)n.push({x:0,y:t.y,w:s,h:t.h,i:10*e+r,wStep:i,hStep:a}),l.push({x:0,y:t.y,w:s,h:t.h,i:10*e+r,wStep:i,hStep:a});else{let d=n[r-1].x;n.push({x:o[r-1]+d,y:t.y,w:s,h:t.h,i:10*e+r,wStep:i,hStep:a}),l.push({x:o[r-1]+d,y:t.y,w:s,h:t.h,i:10*e+r,wStep:i,hStep:a})}}}}return{layouts:l.map((t=>{let{option:r,typeNum:i}=Re.createLine(),a=t.x*t.wStep+t.w*t.wStep/2,o=t.y*t.hStep+t.h*t.hStep/2,n=t.w*t.wStep,s=t.h*t.hStep,l=e.wrapWidth,d=e.wrapHeight;return t.chartsOption=r,t.typeNum=i,t.txt=i+" "+a/l+" "+o/d+" "+n/l+" "+s/d,console.log(t.txt),t})),option:{colNum:r,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,r,i){const a=[];let o=e,n=i;for(;n>0;)if(1===n)a.push(o),n--;else{const e=Math.min(r,o-t*(n-1)),i=Math.floor(Math.random()*(e-t+1))+t;a.push(i),o-=i,n--}return a}simulateRandomSegments2(e,t,r,i){const a=[];let o=e,n=i;for(;n>0;)if(1==n){const t=e-a.reduce(((e,t)=>e+t),0);a.push(t),n--}else{let e=Math.floor(Math.random()*r),i=Math.max(t,e),s=o-t*n;const l=Math.min(i,s);a.push(l),o-=l,n--}return a}};export{De as ConfigOptimizer,ue as GlobalVariables,L as Http,$ as Log,G as agentData,A as delFetchStatus,Ie as displayGenerator,re as editItem,ge as emitEvent,ee as fetchDataByGlobal,Z as fetchDataByType,te as filterData,w as findItemDeep,D as findItemDeep2,J as getData,B as getDataForApi,_ as getDataForSource,Q as getDataForStatic,W as getDataForZb,X as getDataForZbCQ,p as getSessionData,c as getStandardData,v as getStringVars,me as getVarDefaultVal,he as globalVars,b as hasVar,u as isJSON,g as recursion,ne as replaceVariable,N as safeEval,k as safeEvalForCode,S as setFetchStatus,h as setSessionData,le as updataGlobalDataSourceForVar,ie as updateComData,de as updateGlobalDataSource};
@@ -0,0 +1,17 @@
1
+ export declare const createBar: () => {
2
+ xAxis: any;
3
+ grid: {
4
+ left: number;
5
+ top: number;
6
+ bottom: number;
7
+ right: number;
8
+ };
9
+ yAxis: any;
10
+ series: {
11
+ data: number[];
12
+ type: string;
13
+ smooth: boolean;
14
+ stack: boolean;
15
+ areaStyle: {} | null;
16
+ }[];
17
+ };
@@ -0,0 +1,31 @@
1
+ export declare const createFunnel: () => {
2
+ grid: {
3
+ left: number;
4
+ top: number;
5
+ bottom: number;
6
+ right: number;
7
+ };
8
+ series: {
9
+ type: string;
10
+ left: string;
11
+ top: number;
12
+ bottom: number;
13
+ width: string;
14
+ min: number;
15
+ minSize: string;
16
+ maxSize: string;
17
+ label: {
18
+ show: boolean;
19
+ position: string;
20
+ };
21
+ sort: string;
22
+ gap: number;
23
+ lineStyle: {
24
+ width: number;
25
+ };
26
+ data: {
27
+ value: number;
28
+ name: string;
29
+ }[];
30
+ }[];
31
+ };
@@ -0,0 +1,26 @@
1
+ export declare const createGauge: () => {
2
+ grid: {
3
+ left: number;
4
+ top: number;
5
+ bottom: number;
6
+ right: number;
7
+ };
8
+ series: {
9
+ type: string;
10
+ radius: string;
11
+ detail: {
12
+ formatter: string;
13
+ };
14
+ progress: {
15
+ show: boolean;
16
+ width: number;
17
+ };
18
+ axisLine: {
19
+ lineStyle: any;
20
+ };
21
+ data: {
22
+ value: number;
23
+ name: string;
24
+ }[];
25
+ }[];
26
+ };
@@ -0,0 +1,28 @@
1
+ export declare const createLine: () => {
2
+ xAxis: {
3
+ type: string;
4
+ show: boolean;
5
+ boundaryGap: boolean;
6
+ data: string[];
7
+ };
8
+ grid: {
9
+ left: number;
10
+ top: number;
11
+ bottom: number;
12
+ right: number;
13
+ };
14
+ yAxis: {
15
+ show: boolean;
16
+ type: string;
17
+ };
18
+ series: {
19
+ data: number[];
20
+ type: string;
21
+ smooth: boolean;
22
+ symbolSize: number;
23
+ lineStyle: {
24
+ width: number;
25
+ };
26
+ areaStyle: {} | null;
27
+ }[];
28
+ };
@@ -0,0 +1,23 @@
1
+ export declare const createPie: () => {
2
+ grid: {
3
+ left: number;
4
+ top: number;
5
+ bottom: number;
6
+ right: number;
7
+ };
8
+ series: {
9
+ data: number[];
10
+ type: string;
11
+ radius: string | string[];
12
+ roseType: string | null;
13
+ padAngle: number;
14
+ startAngle: number;
15
+ endAngle: number;
16
+ label: {
17
+ show: boolean;
18
+ };
19
+ itemStyle: {
20
+ borderRadius: number;
21
+ };
22
+ }[];
23
+ };
@@ -0,0 +1,30 @@
1
+ export declare const createRadar: () => {
2
+ radar: {
3
+ shape: string;
4
+ indicator: {
5
+ name: string;
6
+ max: number;
7
+ }[];
8
+ axisName: {
9
+ show: boolean;
10
+ };
11
+ radius: string;
12
+ };
13
+ grid: {
14
+ left: number;
15
+ top: number;
16
+ bottom: number;
17
+ right: number;
18
+ };
19
+ series: {
20
+ type: string;
21
+ symbol: string;
22
+ lineStyle: {
23
+ width: number;
24
+ };
25
+ data: {
26
+ value: number[];
27
+ name: string;
28
+ }[];
29
+ }[];
30
+ };
@@ -0,0 +1,20 @@
1
+ export declare const createScatter: () => {
2
+ xAxis: {
3
+ show: boolean;
4
+ };
5
+ grid: {
6
+ left: number;
7
+ top: number;
8
+ bottom: number;
9
+ right: number;
10
+ };
11
+ yAxis: {
12
+ show: boolean;
13
+ type: string;
14
+ };
15
+ series: {
16
+ type: string;
17
+ symbolSize: number;
18
+ data: number[][];
19
+ }[];
20
+ };
@@ -4,33 +4,202 @@ export declare class CreateComponentForEcharts {
4
4
  private constructor();
5
5
  static getInstance(): CreateComponentForEcharts;
6
6
  createLine(): {
7
- xAxis: {
8
- type: string;
9
- show: boolean;
10
- boundaryGap: boolean;
11
- data: string[];
7
+ type: string;
8
+ typeNum: number;
9
+ option: {
10
+ xAxis: {
11
+ type: string;
12
+ show: boolean;
13
+ boundaryGap: boolean;
14
+ data: string[];
15
+ };
16
+ grid: {
17
+ left: number;
18
+ top: number;
19
+ bottom: number;
20
+ right: number;
21
+ };
22
+ yAxis: {
23
+ show: boolean;
24
+ type: string;
25
+ };
26
+ series: {
27
+ data: number[];
28
+ type: string;
29
+ smooth: boolean;
30
+ symbolSize: number;
31
+ lineStyle: {
32
+ width: number;
33
+ };
34
+ areaStyle: {} | null;
35
+ }[];
36
+ };
37
+ } | {
38
+ type: string;
39
+ typeNum: number;
40
+ option: {
41
+ xAxis: any;
42
+ grid: {
43
+ left: number;
44
+ top: number;
45
+ bottom: number;
46
+ right: number;
47
+ };
48
+ yAxis: any;
49
+ series: {
50
+ data: number[];
51
+ type: string;
52
+ smooth: boolean;
53
+ stack: boolean;
54
+ areaStyle: {} | null;
55
+ }[];
56
+ };
57
+ } | {
58
+ type: string;
59
+ typeNum: number;
60
+ option: {
61
+ grid: {
62
+ left: number;
63
+ top: number;
64
+ bottom: number;
65
+ right: number;
66
+ };
67
+ series: {
68
+ data: number[];
69
+ type: string;
70
+ radius: string | string[];
71
+ roseType: string | null;
72
+ padAngle: number;
73
+ startAngle: number;
74
+ endAngle: number;
75
+ label: {
76
+ show: boolean;
77
+ };
78
+ itemStyle: {
79
+ borderRadius: number;
80
+ };
81
+ }[];
82
+ };
83
+ } | {
84
+ type: string;
85
+ typeNum: number;
86
+ option: {
87
+ xAxis: {
88
+ show: boolean;
89
+ };
90
+ grid: {
91
+ left: number;
92
+ top: number;
93
+ bottom: number;
94
+ right: number;
95
+ };
96
+ yAxis: {
97
+ show: boolean;
98
+ type: string;
99
+ };
100
+ series: {
101
+ type: string;
102
+ symbolSize: number;
103
+ data: number[][];
104
+ }[];
105
+ };
106
+ } | {
107
+ type: string;
108
+ typeNum: number;
109
+ option: {
110
+ radar: {
111
+ shape: string;
112
+ indicator: {
113
+ name: string;
114
+ max: number;
115
+ }[];
116
+ axisName: {
117
+ show: boolean;
118
+ };
119
+ radius: string;
120
+ };
121
+ grid: {
122
+ left: number;
123
+ top: number;
124
+ bottom: number;
125
+ right: number;
126
+ };
127
+ series: {
128
+ type: string;
129
+ symbol: string;
130
+ lineStyle: {
131
+ width: number;
132
+ };
133
+ data: {
134
+ value: number[];
135
+ name: string;
136
+ }[];
137
+ }[];
12
138
  };
13
- grid: {
14
- left: number;
15
- top: number;
16
- bottom: number;
17
- right: number;
139
+ } | {
140
+ type: string;
141
+ typeNum: number;
142
+ option: {
143
+ grid: {
144
+ left: number;
145
+ top: number;
146
+ bottom: number;
147
+ right: number;
148
+ };
149
+ series: {
150
+ type: string;
151
+ left: string;
152
+ top: number;
153
+ bottom: number;
154
+ width: string;
155
+ min: number;
156
+ minSize: string;
157
+ maxSize: string;
158
+ label: {
159
+ show: boolean;
160
+ position: string;
161
+ };
162
+ sort: string;
163
+ gap: number;
164
+ lineStyle: {
165
+ width: number;
166
+ };
167
+ data: {
168
+ value: number;
169
+ name: string;
170
+ }[];
171
+ }[];
18
172
  };
19
- yAxis: {
20
- show: boolean;
21
- type: string;
173
+ } | {
174
+ type: string;
175
+ typeNum: number;
176
+ option: {
177
+ grid: {
178
+ left: number;
179
+ top: number;
180
+ bottom: number;
181
+ right: number;
182
+ };
183
+ series: {
184
+ type: string;
185
+ radius: string;
186
+ detail: {
187
+ formatter: string;
188
+ };
189
+ progress: {
190
+ show: boolean;
191
+ width: number;
192
+ };
193
+ axisLine: {
194
+ lineStyle: any;
195
+ };
196
+ data: {
197
+ value: number;
198
+ name: string;
199
+ }[];
200
+ }[];
22
201
  };
23
- series: {
24
- data: number[];
25
- type: string;
26
- smooth: boolean;
27
- symbolSize: number;
28
- lineStyle: {
29
- width: number;
30
- };
31
- areaStyle: {} | null;
32
- }[];
33
- };
202
+ } | undefined;
34
203
  }
35
204
  declare const chartsGenerator: CreateComponentForEcharts;
36
205
  export { chartsGenerator };
@@ -1,9 +1,9 @@
1
1
  declare class GoMock {
2
2
  randomNum(min: number, max: number): number;
3
- generateRandomIntArray(length: number, min: number, max: number, sort?: 'asc' | 'desc' | undefined): number[];
3
+ generateRandomIntArray(length: number, min: number, max: number, sort?: 'asc' | 'desc' | any): number[];
4
4
  randomString(min: number, max: number): string;
5
5
  generateRandomNameArray(length: number, min: number, max: number): string[];
6
- pick<T>(options: T[]): T;
6
+ pick<T>(options: T[], exclude?: T): T;
7
7
  }
8
8
  declare const goMock: GoMock;
9
9
  export { goMock };
@@ -0,0 +1,23 @@
1
+ import { CancelToken } from 'axios';
2
+ interface RequestInfo {
3
+ url: string;
4
+ headers: any;
5
+ data: any;
6
+ params: any;
7
+ method: string;
8
+ cancelToken: CancelToken;
9
+ }
10
+ declare class RequestTracker {
11
+ private static instance;
12
+ private requests;
13
+ private constructor();
14
+ static getInstance(): RequestTracker;
15
+ addRequest(request: RequestInfo): void;
16
+ findRequest(request: RequestInfo): RequestInfo;
17
+ removeRequest(request: RequestInfo): void;
18
+ cancelRequest(request: RequestInfo): void;
19
+ isDuplicateRequest(request: RequestInfo): boolean;
20
+ private areRequestsEqual;
21
+ }
22
+ declare const requestTracker: RequestTracker;
23
+ export { requestTracker };
@@ -1,5 +1,5 @@
1
1
  export declare const ERR_OK = 200;
2
2
  export declare const ERR_OK2 = 20000;
3
- export declare const TIMEOUT = 5000;
4
- export declare const TIMEOUT2 = 5000;
3
+ export declare const TIMEOUT = 3000;
4
+ export declare const TIMEOUT2 = 3000;
5
5
  export declare const STATUS = "status";
@@ -108,6 +108,13 @@ export declare const editItem: (item: GoComponent, data: any, metadata?: any) =>
108
108
  * @returns {Promise<any>} - 返回一个 Promise,在成功时返回更新后的数据,失败时返回错误对象
109
109
  */
110
110
  export declare const updateComData: (element: GoComponent, filterFlag: boolean, globalVars: any[] | undefined, globalSource: GlobalDataSourceItem[], callback?: CallbackFunction, forceRefresh?: boolean) => Promise<any>;
111
+ /**
112
+ * 替换字符串中的变量为对应值
113
+ * @param value - 待替换的值
114
+ * @param globalVars - 包含变量值的全局变量数组
115
+ * @returns 替换后的值
116
+ */
117
+ export declare const replaceVariable: (value: any, globalVars: Record<string, any>[]) => any;
111
118
  /**
112
119
  * 根据变量改变更新全局数据源及引用该数据源的组件
113
120
  * @param globalSource - 全局数据源
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdslib/go-utils",
3
- "version": "0.2.92",
3
+ "version": "0.2.93",
4
4
  "description": "go-core utils",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/types/index.d.ts",