@wdslib/go-utils 0.4.1 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import e from"axios";import t,{uniq as o}from"lodash";import r from"crypto-js";import{setOptionColorByTheme as i}from"@anov/ui/lib/utils/option-theme.js";function a(e,t,o,r){return new(o||(o=Promise))((function(i,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?i(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(n,s)}l((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const n=3e4,s=3e4,l=(t="",o)=>{let r=e.create({baseURL:t,timeout:n,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,o&&o(e),e.data}),(function(e){return o&&o(null==e?void 0:e.response),Promise.reject(e.response)})),r},d=function(e){return a(this,void 0,void 0,(function*(){try{let{fontUrl:t,fontName:o}=e;const r="__custom_font__";let i=document.getElementById(r);if(!i){i=document.createElement("style"),i.id=r;const e=document.head||document.getElementsByTagName("head")[0];yield e.appendChild(i)}i.innerText+=`@font-face{font-family:'${o}';src:url(${t});}`}catch(e){console.warn(e)}}))},c=(e,t="jspaths",o)=>a(void 0,void 0,void 0,(function*(){const r="csspaths"===t?"link":"script",i=document.createElement(r);"jspaths"===t?i.defer=!0:i.rel="stylesheet",i.className=t,i.src=e;(o||document.head||document.getElementsByTagName("head")[0]).appendChild(i),yield new Promise(((e,t)=>{i.addEventListener("load",e),i.addEventListener("error",e)}))})),u=(e,t="jspaths")=>a(void 0,void 0,void 0,(function*(){const o="fonts"===t?d:c;yield Promise.all(e.map((e=>o(e))))})),h=e=>a(void 0,void 0,void 0,(function*(){e.fonts&&e.fonts.length&&(yield u(e.fonts,"fonts"))})),p=({jspaths:e=[],csspaths:o=[],fonts:r=[]})=>a(void 0,void 0,void 0,(function*(){const i=t.uniqBy(r,"fontName");yield Promise.all([u(e,"jspaths"),u(o,"csspaths"),u(i,"fonts")])})),m=()=>{var e;(null==(e=document.getElementById("__custom_font__"))?void 0:e.parentNode)&&e.parentNode.removeChild(e),Array.from(document.getElementsByTagName("script")).filter((e=>"jspaths"==e.className)).forEach((e=>{!function(e){for(var t,o=Array.from(document.getElementsByTagName("script")),r=0;r<o.length;r++)o[r]&&o[r].src&&-1!=o[r].src.indexOf(e)&&(null===(t=o[r])||void 0===t?void 0:t.parentNode)&&o[r].parentNode.removeChild(o[r])}(e.src)})),Array.from(document.getElementsByTagName("link")).filter((e=>"csspaths"==e.className)).forEach((e=>{!function(e){for(var t,o=Array.from(document.getElementsByTagName("link")),r=0;r<o.length;r++)o[r].href,o[r]&&o[r].href&&-1!=o[r].href.indexOf(e)&&(null===(t=o[r])||void 0===t?void 0:t.parentNode)&&o[r].parentNode.removeChild(o[r])}(e.href)}))};const f=(e,t,o)=>{const r=document.createElement("link");switch(r.rel="preload",r.href=e,r.crossorigin="anonymous",t){case"video":r.as="video";break;case"script":r.as="script";break;case"image":r.as="image"}r.onload=()=>{console.log(`success to preload ${e}`),o&&o()},r.onerror=()=>{console.error(`Failed to preload ${e}`)},document.head.appendChild(r)},g=(e,t)=>{try{let o=t||window.location.href;if(-1!=o.indexOf("?")){let t={};return o.slice(o.indexOf("?")+1).split("&").forEach((e=>{let o=e.split("=");t[o[0]]=o[1]})),e?t[e]?t[e]:null:t}return console.log("没有参数"),null}catch(e){console.error(e)}};function v(e,t=!1){try{return t?y(e)?e:JSON.stringify(e):y(e)?JSON.parse(e):e}catch(t){return console.log("转化JSON 发生错我!",e),e}}const y=e=>{if("string"==typeof e)try{const t=JSON.parse(e);return"object"==typeof t&&null!==t}catch(e){return!1}return!1},b=(e,t)=>{try{const o=JSON.stringify(t);sessionStorage.setItem(e,o)}catch(t){console.error(`Error setting session data for key ${e}:`,t)}},w=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},D=e=>{for(const t of e)t.code&&(t.code=t.code.replace(/&gt;/g,">").replace(/&lt;/g,"<"))},N=(e,t)=>{e instanceof Map?e.forEach((e=>{t([e])})):Array.isArray(e)&&e.forEach((e=>{t(e.children)}))},k=(e,t)=>{const o=e=>{var r,i,a;if(e)for(const n of e){const e=null===(a=null===(i=null===(r=null==n?void 0:n.tmpData)||void 0===r?void 0:r.source)||void 0===i?void 0:i.converse)||void 0===a?void 0:a.data;(null==e?void 0:e.length)&&D(e),t(n),n.children?o(n.children):n.dynamicChildren?N(n.dynamicChildren,o):n.stateChildren&&o(n.stateChildren)}};o(e)},S=(e,t)=>a(void 0,void 0,void 0,(function*(){const o=e=>a(void 0,void 0,void 0,(function*(){var r,i,a,n;for(const s of e){(null===(n=null===(a=null===(i=null===(r=null==s?void 0:s.tmpData)||void 0===r?void 0:r.source)||void 0===i?void 0:i.converse)||void 0===a?void 0:a.data)||void 0===n?void 0:n.length)&&(yield D(s.tmpData.source.converse.data)),yield t(s);const e=[s.children,s.dynamicChildren?yield N(s.dynamicChildren,o):null,s.stateChildren].filter(Boolean);for(const t of e)yield o(t)}}));yield o(e)})),A=(e,t,o,r)=>{const i=e.match(/({{[\w]*}})|((@)[\w]*)/gm);if(i){const e=i.map((e=>e.replace(/{{|}}|@/gm,"")));for(const i of e)if(i&&t&&!(t.findIndex((e=>e.mapField===i))<0))return o&&r&&x(r,i,o.cid),!0}return!1},x=(e,t,o)=>{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(!o)throw new Error("ID is required");Array.isArray(e[t])||(e[t]=[]),e[t].includes(o)||e[t].push(o)},C=(e,t,o)=>{var r;let i=!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))&&(i=A(n.inputSql||n.url||(null===(r=n.headers)||void 0===r?void 0:r.value)||n.params,o)),i},O=(e,o,r=!1)=>{let i=null;const a=e=>{for(const n of e){if(n.cid===o){i=n,r&&t.remove(e,(e=>e.cid===o));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),i},I=(e,o,r)=>{let i=!1;const a=e=>{for(let n=0;n<e.length;n++){if(e[n].cid==o){i=e[n],r&&t.remove(e,(e=>e.cid==o));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 o=t[e][1];a(o)}}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 o=t[e][1];a(o)}}}else e[n].stateChildren&&a(e[n].stateChildren)}};return a(e),i||!1};function T(e,t,o){const r={};o&&o.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 V(e,o,r){let i=t.cloneDeep(o);const a={};r&&r.forEach((e=>{(null==e?void 0:e.name)&&(a[e.name]=e.value||e.originvalue)}));try{return new Function("data","vars",e)(i,a)}catch(e){return console.error(e),i}}const F=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)},E=e=>{let t=window.goFetchList;t&&t[e]&&delete t[e]};function j(e){const t=e.match(/\.([^\/\\]+)$/);return t?t[1].toLowerCase():void 0}const P=e=>{const t=[];let o=function(e){return e.endsWith("/")?e.slice(0,-1):e}(window.baseUrl);return k(e,(e=>{var r,i,a,n,s,l,d,c,u;if("AnDeckHeader3"==e.viewComName&&(null===(a=null===(i=null===(r=null==e?void 0:e.tmpData)||void 0===r?void 0:r.option)||void 0===i?void 0:i.bgImage)||void 0===a?void 0:a.path)){let r=j(e.tmpData.option.bgImage.path);t.push({type:r,url:o+e.tmpData.option.bgImage.path})}if("AnVideoNormal"==e.viewComName&&(null===(s=null===(n=null==e?void 0:e.tmpData)||void 0===n?void 0:n.option)||void 0===s?void 0:s.dynamicUrl)){let r=j(null===(d=null===(l=null==e?void 0:e.tmpData)||void 0===l?void 0:l.option)||void 0===d?void 0:d.dynamicUrl);t.push({type:r,url:o+(null===(u=null===(c=null==e?void 0:e.tmpData)||void 0===c?void 0:c.option)||void 0===u?void 0:u.dynamicUrl)})}})),t},$="anov@2019:helloX",R="anov@2020:helloX";function M(e){let t=r.enc.Utf8.parse($),o=r.enc.Utf8.parse(R);return r.AES.encrypt(e,t,{iv:o,mode:r.mode.CBC,padding:r.pad.Pkcs7}).toString()}function B(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 o=t.reduce(((e,t)=>e+t),0),r=Math.random()*o;let i=0;for(let o=0;o<e.length;o++)if(i+=t[o],r<i)return e[o];return e[0]}const U=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"]),q=URL.createObjectURL(U);function L(e,t,o={},r="worker"){return a(this,void 0,void 0,(function*(){try{if("window"==r){if("string"==typeof t)try{t=JSON.parse(t)}catch(e){}let[r,i]=[["data"],[t]];"object"==typeof o&&Object.keys(o).forEach((e=>{r.push(e),i.push(o[e])}));const a=new Function(...r,e)(...i);return console.log(a,"result"),{success:!0,data:a}}{let[r,i,n]=[t,o,""];"object"==typeof r&&(r=JSON.stringify(t)),"object"==typeof o&&(i=JSON.stringify(o)),Object.keys(o).forEach((e=>n+=`${e},`));let s=`let data=eval(${r}); \n             let app=${JSON.stringify({})};`;s+=n?`let {${n}} = eval(${i}); `:"",s+=`${e}`;let l=yield function(e,t=5e3){return a(this,void 0,void 0,(function*(){let o=new Worker(q);return new Promise(((r,i)=>{const a=()=>{clearTimeout(s),o.removeEventListener("message",n),o.terminate(),o=null},n=e=>{let{code:t,result:o,err:n}=e.data;a(),1===t?r(o):i(n)};o.postMessage({code:e}),o.addEventListener("message",n);let s=setTimeout((()=>{a(),i("timeout")}),t)}))}))}(s);return{success:!0,data:l}}}catch(e){return{success:!1,error:e,data:t}}}))}var H,z,J,G;!function(e){e.StaticFile="staticFile",e.DataSource="datasource"}(H||(H={})),function(e){e.json="application/json;charset=UTF-8",e.form="application/x-www-form-urlencoded; charset=UTF-8"}(z||(z={})),function(e){e.get="GET",e.post="POST",e.put="PUT",e.patch="PATCH",e.delete="DELETE"}(J||(J={}));class _{constructor(e){this.db=null,this.dbName=e.databaseName,this.tableName=e.tableName,this.keyPath=e.keyPath}static getInstance(e){return _.instance||(_.instance=new _(e)),_.instance}init(){return a(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{const o=indexedDB.open(this.dbName,1);o.onerror=e=>{t(e.target.error)},o.onupgradeneeded=e=>{this.db=e.target.result,this.db.objectStoreNames.contains(this.tableName)||this.db.createObjectStore(this.tableName,{keyPath:this.keyPath})},o.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,o)=>{const r=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).add(e);r.onsuccess=()=>{t()},r.onerror=e=>{o(e.target.error)}}))}))}deleteRecord(e){return a(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,o)=>{const r=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).delete(e);r.onsuccess=()=>{t()},r.onerror=e=>{o(e.target.error)}}))}))}updateRecord(e){return a(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,o)=>{const r=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).put(e);r.onsuccess=()=>{t()},r.onerror=e=>{o(e.target.error)}}))}))}getRecord(e){return a(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,o)=>{const r=this.db.transaction([this.tableName],"readonly").objectStore(this.tableName).get(e);r.onsuccess=()=>{t(r.result)},r.onerror=e=>{o(e.target.error)}}))}))}getAllRecords(){return a(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((e,t)=>{const o=this.db.transaction([this.tableName],"readonly").objectStore(this.tableName).getAll();o.onsuccess=()=>{e(o.result)},o.onerror=e=>{t(e.target.error)}}))}))}}_.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"}(G||(G={}));const W={databaseName:"GODB",tableName:"go-log",keyPath:"time"};class X{constructor(){this.logLevel=G.INFO,this.indexedDBInstance=_.getInstance(W);try{this.indexedDBInstance.init(),console.log("IndexedDB 初始化成功。")}catch(e){console.error("初始化 IndexedDB 时出错:",e)}}static getInstance(){return X.instance||(X.instance=new X),X.instance}setLogLevel(e){this.logLevel=e}getColor(e){switch(e){case G.FATAL:return"";case G.ERROR:return"";case G.WARN:return"";case G.INFO:return"";case G.DEBUG:return"";case G.TRACE:return"";default:return""}}log(e,t){if(t<=this.logLevel){const o=(new Date).toISOString(),r=`[${o}] [${G[t]}]`,i=this.getColor(t);if(null===window||void 0===window?void 0:window.goDev)console.log(`${i}${r} ${e}`);else{let t=w("anov-go-userInfo"),a=w("anov-go-proid"),n=` [操作人:${null==t?void 0:t.userName} 项目ID:${a}] `;const s={time:o,value:`${e}`};try{this.indexedDBInstance.addRecord(s)}catch(e){console.error("添加记录时出错:",e)}console.log(`${i}${r} ${n} ${e}`)}}}fatal(e){this.log(e,G.FATAL)}error(e){this.log(e,G.ERROR)}warn(e){this.log(e,G.WARN)}info(e){this.log(e,G.INFO)}debug(e){this.log(e,G.DEBUG)}trace(e){this.log(e,G.TRACE)}}const K=X.getInstance(),Q=(e,t)=>"string"!=typeof e?Promise.reject(new Error("URL should be a string")):l(e,t),Y=l();let Z=l();function ee(e,o="get",r={},i={},n){return a(this,void 0,void 0,(function*(){try{const r={method:J[o],url:e,headers:i,timeout:s};let l;["post","put"].includes(o.toLowerCase())?r.data=t.cloneDeep(l):r.params=t.cloneDeep(l),n&&(r.headers.sponsor=n);return/.json$/.test(e)?function(e){return a(this,void 0,void 0,(function*(){try{return yield Y({method:"get",url:e})}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 Y(e)).data}}catch(e){throw console.error("请求数据发生错误-Error:",e),e}}))}(r)}catch(e){throw console.error("获取数据:Error:",e),e}}))}function te(e,t,o,r,i){return a(this,void 0,void 0,(function*(){try{const a=window.anUrl||"",n=a+(window.agentPath||"/ds/v1/api-proxy/v1/query"),s=v(o,!0);return yield Y({url:n,method:"post",headers:{"Content-Type":"application/json;charset=UTF-8",sponsor:i||""},data:{body:"post"===e?s:void 0,headers:y(r)?v(r,!0):r,method:e,url:t}})}catch(e){throw console.error("代理请求数据:Error12:",e),e}}))}function oe(e,t,o,r,i,n){return a(this,void 0,void 0,(function*(){return i?te(t,e,o,r,n):ee(e,t,o,r,n)}))}function re(e,t="",o){var r,i,a,s;const l=`${null!==(i=null===(r=null===window||void 0===window?void 0:window.BaseUrl)||void 0===r?void 0:r.replace("/management",""))&&void 0!==i?i:""}/ds/data-engine/v1/${e}/zb-query?${`token=${(null===(a=fe("YZH_EXCHANGE_TOKEN"))||void 0===a?void 0:a.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 Y({method:"POST",url:l,data:{headers:o,param:d},timeout:n})}function ie(e="",t,o){const r=`${null===window||void 0===window?void 0:window.BaseUrl}/ds/v1/data-views/query/v1/${o}`;let i={};try{i=e?JSON.parse(e):{}}catch(t){i=e||{}}return Y({method:"POST",url:r,data:{headers:t,param:i},timeout:n})}const ae=(e,t)=>a(void 0,void 0,void 0,(function*(){const o=window.BaseUrl,{dateType:r="",endPeriod:i="",metricsName:a=e,startPeriod:s=""}=t;return Z({method:"GET",url:`${o}ds/v1/metrics/v1/data-alarm?dateType=${r}&endPeriod=${i}&metricsName=${a}&startPeriod=${s}`,timeout:n})})),ne=(e,t,o)=>a(void 0,void 0,void 0,(function*(){var r;const i=(null===(r=window.BaseUrl)||void 0===r?void 0:r.replace("/management",""))||"";t.newEncryption=!0;const a={staticFile:{method:"get",params:t,url:`${i}/ds/v1/file/v1/${e}/query`},datasource:{method:"post",url:`${i}/ds/v1/database/v1/${e}/query`,data:Object.assign({},t)}}[o];if(!a)throw new Error("Invalid data type provided");return Y(Object.assign({timeout:n},a))})),se=e=>new Promise(((t,o)=>{let r;r=e.originData&&Object.keys(e.originData).length?e.originData:e.data,void 0!==r?t({data:r}):o("Failed to retrieve cdata")})),le=(e,t,o)=>{try{let r;switch(t){case"api":{let t=be(e,o);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=ve(e.inputSql,o);return{dsName:e.dsName,dsType:"1",sql:M(t),filter:e.sqlFilter}}case"staticFile":return{dsName:e.dsName,dsType:e.dsType,sql:""};case"indicator":return r=we(e,o),{zbId:e.zbId,params:ve(r.params,o),headers:ve(r.headers,o)};case"dataSet":return{params:ve(e.params,o),headers:ve(e.headers,o),value:e.value};case"indicatorCQ":return{zbName:e.zbName,params:ve(e.params,o)};case"packData":return{};default:throw new Error("Invalid type")}}catch(t){console.log("准备请求数据发生错误",t,e)}},de=(e,t,o)=>a(void 0,void 0,void 0,(function*(){try{switch(t){case"api":return yield oe(e.url,e.requestType,e.params,e.headers,e.agency,o);case"static":return yield se(e.data);case"datasource":return yield ne(e.dsName,{dsType:e.dsType,sql:e.sql,filter:e.filter},"datasource");case"staticFile":return yield ne(e.dsName,{dsType:e.dsType,sql:e.sql},"staticFile");case"indicator":return yield re(e.zbId,e.params,e.headers);case"dataSet":return yield ie(e.params,e.headers,e.value);case"indicatorCQ":return yield ae(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})}))}})),ce=(e,t,o,r=[],i=!1)=>a(void 0,void 0,void 0,(function*(){const a=t||e.tmpData.source.dataType;if(!a)return console.warn(`fetdata error on fetchDataByType', dataType is ${a}`),new Promise(((e,t)=>{e({error:!0,data:null,msg:`dataType is ${a}`})}));const n=e.tmpData.source["indicatorCQ"==a?"indicator":a];if("globalData"===a){const e=r.find((e=>e.key===n.id||e.key===n.key)),t=w(n.id);if(t&&!i)return t.data;if(e){let t=yield ue(e,o),r={key:n.id,data:t};return b(n.id,r),t}return}const s=le(n,a,o),l=yield de(s,a,e.cid?e.cid:"");return(null==l?void 0:l.data)?l.data:l})),ue=(e,t)=>a(void 0,void 0,void 0,(function*(){let o=Object.assign({},{tmpData:{source:e.value}});const r=o.tmpData.source.type,i=o.tmpData.source[r],a=le(i,r,t),n=yield de(a,r);return yield he(n.data,o,!0,t)})),he=(e,o,r=!0,i)=>a(void 0,void 0,void 0,(function*(){try{const{converse:n,mapFields:s}=o.tmpData.source;return n&&n.use&&r?yield new Promise(((o,r)=>a(void 0,void 0,void 0,(function*(){const r=yield function(e,o,r,i){return a(this,void 0,void 0,(function*(){let r,a=e,{use:n,data:s}=t.cloneDeep(o);if(n)for(let e=0;e<s.length;e++)if(s[e].use){let o=s[e].dependVars,n={};i&&n&&o&&o.length&&o.map((e=>{let o=t.cloneDeep(i).filter((t=>{let o=t.mapField==e;return o&&(n[e]=t.value),o}));o&&0!=o.length||(n[e]="")})),r=yield L(s[e].code,a,n,s[e].mode?s[e].mode:"worker"),a=r.data}return a}))}(t.cloneDeep(e),n,0,i);o(r)})))):yield new Promise(((t,o)=>{t(e)}))}catch(t){return console.error("执行过滤器发生错误:"+t),yield new Promise(((t,o)=>{t(e)}))}})),pe=(e,t,o)=>{const{source:r}=e.tmpData,i=r.type;o?("static"===i&&r[i]&&(r[i].originData=o),"indicatorCQ"===i?r.indicator.data=t:r[i].data=t):"indicatorCQ"===i?r.indicator.data=t:r[i].data=t,e.source=t},me=(e,t,o=[],r,i,n)=>a(void 0,void 0,void 0,(function*(){try{let a=e.tmpData.source.type,s=yield ce(e,a,o,r,n||!1);if(null==s||!s)return i&&i({error:!0}),Promise.resolve({error:!0});let l=yield he(s,e,t,o);return yield pe(e,l),i&&i(l),(null==e?void 0:e.cid)&&E(e.cid),Promise.resolve(l)}catch(t){return i&&i(t),K.error("Error in updateComData"),console.error("Error in updateComData:",t,e),Promise.reject(t)}})),fe=e=>{const t={};if(e&&e.includes("?")){const o=e.split("?")[1].split("&");for(let e of o){const[o,r]=e.split("=").map(decodeURIComponent);t[o]=r}}return t},ge=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}},ve=(e,t)=>{if(!t)return ge(e);if("string"==typeof e){if(""===e.trim())return"";const o=e.replace(/{{(\w+)}}/g,((e,o)=>{const r=t.find((e=>e.mapField===o));if(r){const e=r.value||r.originalValue||"";return"number"==typeof e||"boolean"==typeof e?e:`${String(e)}`}return e}));return ge(o)}if(Array.isArray(e))return e.map((e=>ve(e,t)));if("object"==typeof e&&null!==e){const o={};for(const r in e)o[r]=ve(e[r],t);return ge(o)}return ge(e)},ye=(e,t)=>{if(!t)return ge(e);if("string"==typeof e){if(""===e.trim())return"";try{if("string"!=typeof JSON.parse(e))return"number"==typeof JSON.parse(e)?e:ve(JSON.parse(e),t);{let o=e.replace(/@(\w+)|{{(\w+)}}/g,((e,o,r)=>{const i=o||r,a=t.find((e=>e.mapField===i));if(a){const e=a.value||a.originalValue;return console.log(e,"123123131"),"number"==typeof e?e:String(e)}return e}));return ge(o)}}catch(o){let r=e.replace(/@(\w+)|{{(\w+)}}/g,((e,o,r)=>{const i=o||r,a=t.find((e=>e.mapField===i));if(a){const e=a.value;return console.log(e,"value"),"number"==typeof e?e:String(e)}return e}));return ge(r)}}else{if(Array.isArray(e))return e.map((e=>ve(e,t)));if("object"==typeof e&&null!==e){const o={};for(let r in e)o[r]=ve(e[r],t);return ge(o)}}return ge(e)},be=(e,t)=>{const o=e.agency,r=e,{url:i=null,headers:a,params:n,requestType:s}=r,l=i?ve(i,t):void 0,d=a&&a.use?ve(a.value,t):{};return{url:l,requestType:s,params:n?ve(n,t):{},headers:d,agency:o}},we=(e,t)=>{const{headers:o,params:r}=e,i=o&&o.use?ve(o.value,t):{};return{params:r?ve(r,t):{},headers:i}},De=(e,t,o,r,i)=>a(void 0,void 0,void 0,(function*(){if(e&&e.length)for(const a of e){C(t,a.value,o)&&(yield me({tmpData:{source:{type:"globalData",globalData:{id:a.key}}}},!0,o,e,(e=>{console.log("数据更新成功-变量改变全局数据跟新")}),!0),k(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===a.key&&me(t,!0,o,e,(e=>{i(t,e)}),!1)}})))}})),Ne=(e,t,o,r,i)=>a(void 0,void 0,void 0,(function*(){e&&(yield me({tmpData:{source:{type:"globalData",globalData:{id:e.key}}}},!0,t,o,(e=>{console.log("数据更新成功")}),!0),k(r,(r=>{var a,n,s;if("globalData"===(null===(n=null===(a=null==r?void 0:r.tmpData)||void 0===a?void 0:a.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&&me(r,!0,t,o,(e=>{i(r,e)}),!1)}})))}));class ke{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)||0==(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(){if(this.fork&&(this.originalValue=this.getForkedValue()),this.converter&&this.converterCode){let e=[];return V(this.converterCode,this.originalValue,e)}return 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 i=Object.assign({},this,e);this.des=i.des,i.field&&(this.field=i.field),this.mapping=i.mapping,this.type=i.type,this.originalValue=i.originalValue,this.converter=i.converter,this.converterCode=i.converterCode,this.fork=i.fork,this.delayUpdate=null==i?void 0:i.delayUpdate,this.model=null==i?void 0:i.model,e.id&&(this.id?"string"==typeof this.id?e.id instanceof Array?this.id=o([this.id,...e.id]):this.id=[this.id,e.id]:this.id instanceof Array&&(e.id instanceof Array?this.id=o([...this.id,...e.id]):this.id=o([...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 o;this.originalValue=e,this.fork&&(this.forkValue=null!==(o=this.forkValue)&&void 0!==o?o:this.forkValue,this.originalValue=this.getForkedValue()),t&&t(this)}renew(e){e&&e(this)}static create(e,t){return new ke(e,t)}}class Se{constructor(){this.variables=new Map,this.globalObservers=[],this.url=window.location.search,this.list=[]}clearVars(){this.list=[],this.variables.clear()}togglePropertyState(e,t,o){try{let r=this.getVariable(e);if(!r)throw new Error("没有找到相应的变量!");r.togglePropertyState(t),this.addToObjectArray(this.list,r),o&&o()}catch(e){console.error(e)}}static getInstance(){return Se.instance||(Se.instance=new Se),Se.instance}getFullUrl(){this.url=window.location.search}getAllUrlParams(){const e=new URLSearchParams(window.location.search),t={};for(const[o,r]of e.entries())t[o]=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),o=[];for(const r of t)o.push({mapField:r,originalValue:e[r],model:4});if(o.length)for(const e of o)this.addVariable(e)}addVariables(e,t){if(Array.isArray(e)?e.map(((e,t)=>{this.addVariable(e)})):this.addVariable(e),t&&"coms"==t)for(let t of this.variables.values())0==t.model&&(e.some((e=>e.mapField==t.mapField))||this.delVariable(t.mapField));this.addUrlParamsToGlobalVars()}addVariable(e,t){if(!e||!(null==e?void 0:e.mapField))return console.error("新增全局变量:"+e+"参数不合法!"),!1;if(this.isVariableNameExist(e.mapField)){let o=this.getVariable(e.mapField);return this.sameValue(o,e)?o:(this.editVariable(e,t),!1)}const o=ke.create(e,this.variables);return this.variables.set(o.mapField,o),this.addToObjectArray(this.list,o),t&&t(o),this.notifyGlobalObservers(o),o}toJSON(e){try{return!!e&&JSON.stringify(e)}catch(e){return!1}}sameValue(e,t){if(e.mapfield!==t.mapfield)return!1;for(const o in t)if(!(["mapfield","field","key","value","name","globalVariables"].includes(o)||o in e&&e[o]==t[o]))return!1;return!0}creatVarJson(e){const{des:t,field:o,id:r,key:i,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!==o&&(v.field=o),void 0!==r&&(v.id=r),void 0!==i&&(v.key=i),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 o=!1;for(let r=0;r<e.length;r++)if(e[r].mapField==t.mapField){e[r]=this.creatVarJson(t),o=!0;break}o||e.push(t)}editVariable(e,t){const o=this.getVariable(e.mapField);if(o&&this.isVariableNameExist(e.mapField)){if(this.sameValue(o,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}};o?o.updateValue(e,r):this.addVariable(e,r)}getForkList(e){let t=this.isMapFieldInForkValues(e);return t||[]}editVariableForValue(e,t,o){const r=this.getVariable(e),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),o&&o(e),e.isUpdating=!1}};r&&r.updateWidthOriginalValue(t,i)}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 o=this.getVariable(e);return t==o.id&&!o.id.includes(t)&&[{key:e}]}if(Array.isArray(e)){const o=e.filter((e=>{let o=this.getVariable(e);return this.isVariableNameExist(e)&&t!=o.id&&!(o.id&&o.id.includes(t))})).map((e=>({key:e})));return!!o.length&&o}return!1}getVariable(e){return this.variables.get(e)}getVariableForId(e){var o;let r=[];for(const[,t]of this.variables)(t.id===e||(null===(o=t.id)||void 0===o?void 0:o.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)}))}}Se.instance=null;const Ae=Se.getInstance(),xe=(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))),Ce=(e,t,o,r)=>{const i=((e,t,o,r)=>{var i;let a;if(xe(e,null==t?void 0:t.field)||xe(e,null==t?void 0:t.forkValue))a=e[null==t?void 0:t.field]||0==e[null==t?void 0:t.field]?e[null==t?void 0:t.field]:"";else if(xe(e.data,null==t?void 0:t.field)||xe(e.data,null==t?void 0:t.forkValue))a=e.data[null==t?void 0:t.field]||0==e.data[null==t?void 0:t.field]?e.data[null==t?void 0:t.field]:"";else{const e=O(o,r),n=(null===(i=null==e?void 0:e.tmpData)||void 0===i?void 0:i.actions)||[];for(const e of n){const o=e.vars.find((e=>(null==e?void 0:e.mapField)===(null==t?void 0:t.mapField)));if(o){a=o.value;break}}}return a})(e,t,o,r);return void 0!==i?i:t.value},Oe=(e,t,o,r,i,a,n,s,l)=>{var d;switch(e.type){case"link":let c=ve(e.link,a);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 o=e.params[t],r=a.find((e=>e.mapField==o.mapField));r&&(o.value=r.value)}l&&l(e);break;case"dynamic":((e,t,o,r,i)=>{const a=e.dynamic||[];for(const n of a){if(e.id!==t.cid)continue;const a=O(o,n.pid);a&&(a.activeDynamic=n.name,a.isShow=n.visible||!r||e.index===t.index-1,i({cid:a.cid,flag:n.visible}))}})(e,t,o,r,i);break;case"toggle":((e,t,o,r,i)=>{const a=e.children||[];for(const o of a){const a=o.visible&&(!r||e.index===t.index-1);i({cid:o.cid,flag:a})}})(e,t,0,r,i);break;case"update":((e,t,o,r,i)=>{const a=e.children||[];for(const e of a){const a=O(t,e.cid);a&&me(a,!0,o,r,(e=>{i({cid:a.cid,data:e})}))}})(e,o,a,n,s)}},Ie=(e,o,r,i,a,n,s,l,d,c)=>{const{cid:u,actions:h,index:p}=a,{eventName:m,mode:f}=h,g=2===f;((e,o,r,i,a,n)=>{let s=Ae.getVariableForId(o.cid);if(null==s?void 0:s.length)for(const l of s)if(l.type==e){let e=Ce(o,l,r,i);Ae.editVariableForValue(l.mapField,e,(()=>{let e=a[l.mapField]||[],o=Ae.getForkList(l.mapField);if(o)for(const r of o){let o=a[r.mapField];e=t.concat(e,o)}n&&n(l,t.uniq(e))}))}})(m,a,i,u,r,((e,t)=>{if(De(d,e.mapFile,Ae.getAllVariables(),i,((e,t)=>{s({cid:e.cid,data:t})})),null==t?void 0:t.length)for(const o of t){e.eventSourceId=o;const t=O(i,o);!(null==e?void 0:e.delayUpdate)&&t&&me(t,!0,Ae.getAllVariables(),d,(e=>{s({cid:t.cid,data:e})}))}}));const v=((e,t,o,r,i)=>e.filter((e=>e.id===t&&e.eventType===o&&(!i||parseInt(e.index||"0")+1===parseInt(r||"0")))))(e,u,m,p,g);for(const e of v)Oe(e,a,i,g,n,Ae.getAllVariables(),d,s,l)};function Te(e,t){const o={};for(const r in e)if(e.hasOwnProperty(r))if("object"!=typeof e[r]||null===e[r]||Array.isArray(e[r]))Array.isArray(e[r])?JSON.stringify(e[r])!==JSON.stringify(t[r])&&(o[r]=t[r]):e[r]!==t[r]&&(o[r]=t[r]);else{const i=Te(e[r],t[r]);null!==i&&Object.keys(i).length>0&&(o[r]=i)}return Object.keys(o).length>0?o:null}function Ve(e,t){const o=Object.assign({},e);for(const e in t)t.hasOwnProperty(e)&&("object"!=typeof t[e]||null===t[e]||Array.isArray(t[e])?o[e]=t[e]:o[e]=Ve(o[e],t[e]));return o}const Fe=(e,t={})=>{let o={},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(o,r,t),o},Ee=(e,o)=>{let{option:r,actions:i,data:a,optionDes:n,actionsDes:s,source:l,theme:d}=((e,o)=>{let{option:r,actions:i,data:a,optionDes:n,actionsDes:s,source:l,theme:d}=t.cloneDeep(o[e]);return{option:r,actions:i,data:a,optionDes:n,actionsDes:s,source:l,theme:d}})(e,o);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:i},baseData:Pe(),dynamic:null,filePath:"",origin:"anov-ui",name:"",componentType:"",viewComName:e,optionComName:"AnOptionPanel",dataComName:"AnSourcePanel",eventComName:"AnActionsPanel",assemblyDeveloper:"",devEmail:"",version:"",devDept:""}},je=(e,o,r)=>{let i=Ee(e,o);return r?t.merge(i,r):i},Pe=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 $e{constructor(e,t,o){this.theme=null,this.plant=null,this.list=[],this.titleHeqadeHeight=70,this.clearance=3,this.checkComponentIntersection=(e,t,o=10)=>{const r=e.left,i=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&&i>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<o&&p<o},this.calculateCombinedComponent=e=>{if(0===e.length)return{left:0,top:0,width:0,height:0};let t=e[0].left,o=e[0].top,r=e[0].left+e[0].width,i=e[0].top+e[0].height;for(let a=1;a<e.length;a++){const n=e[a];t=Math.min(t,n.left),o=Math.min(o,n.top),r=Math.max(r,n.left+n.width),i=Math.max(i,n.top+n.height)}return{left:t,top:o,width:r-t,height:i-o}},this.getAnTextNormaltText=e=>{var t,o;try{return null===(o=null===(t=null==e?void 0:e.tmpData)||void 0===t?void 0:t.option)||void 0===o?void 0:o.text}catch(e){return console.error("配置优化(ConfigOptimizer):",e),""}},this.initProp(e),this.upgradePlant(),this.staticComponentData=t,this.upgradeHeaderComponent(),o&&Object.assign(this,o)}isStringOrObject(e){return"string"==typeof e?"string":"object"==typeof e&&null!==e&&"object"}initProp(e){try{let t,o=this.isStringOrObject(e);if(o&&"string"===o)t=JSON.parse(e);else{if(!o||"object"!==o)throw new Error(`initProp fn error :-- 传入参数${e}不合法!`);t=e}if(t){this.originData=t;const{theme:e,plant:o,list:r}=t;this.theme=e,this.plant=o,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 o=e.baseData,r=t.baseData;const i=Math.max(0,Math.min(o.left+o.width,r.left+r.width)-Math.max(o.left,r.left)),a=Math.max(0,Math.min(o.top+o.height,r.top+r.height)-Math.max(o.top,r.top));return i>0&&a>0}filterFileGroup(){this.list=t.cloneDeep(this.list).map((e=>{var t,o;if(1===(null===(t=null==e?void 0:e.children)||void 0===t?void 0:t.length)&&!(null===(o=null==e?void 0:e.children[0])||void 0===o?void 0:o.children)){const t=e.children[0],{left:o,top:r}=e.baseData;return t.baseData.left=o,t.baseData.top=r,t}return e}))}getText(e,t,o){const r=document.createElement("canvas").getContext("2d");if(!r)throw new Error("Failed to get 2D context from canvas.");r.font=`${o}px ${t}`;return r.measureText(e).width}calculateMaxWidths(e){const t=Math.min(...e.map((e=>e.width))),o=[];let r=[],i=e[0].width;for(const a of e){const e=a.width;Math.abs(e-i)<=t?r.push(e):(r.length>0&&o.push(r),r=[e]),i=e}r.length>0&&o.push(r);const a=[];for(const e of o){const t=Math.max(...e);a.push(t)}return a}findClosestValue(e,t){let o=t[0],r=Math.abs(e-o);for(const i of t){const t=Math.abs(e-i);t<r&&(r=t,o=i)}return o}adjustHeightAndTop(e,t){const o=t-e.height;return Object.assign(Object.assign({},e),{height:t,top:e.top-o/2})}findNearestComponent(e,o,r){let i=null,a=1/0;o.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===o.cid||"AnTextNormal"===e.viewComName||r&&r.includes(e.cid)))),s=t.cloneDeep(o).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 o=t.top-s.top;o<a&&o<100&&(a=o,i=e)}}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return i}findNearestComponentForPoint(e,t,o){let r=null,i=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||o&&o.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let o=this.getDistance(n.left,n.top+n.height,t.left,t.top);o<i&&o<n.width&&(i=o,r=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return r}findNearestComponentForTitlePoint(e,t,o){let r=null,i=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||o&&o.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let o=this.getDistance(n.left,n.top+n.height,t.left,t.top);o<i&&o<n.width&&t.top-n.top>100&&(i=o,r=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return r}findNearestTitleForPoint(e,t,o){let r=null,i=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||o&&o.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let o=t.top-n.top;o<i&&o<n.width&&t.top-n.top>100&&(i=o,r=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return r}getDistance(e,t,o,r){return Math.sqrt(Math.pow(o-e,2)+Math.pow(r-t,2))}findNearestComponent2(e,o,r){let i=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===o.cid||"AnTextNormal"===e.viewComName||r&&r.includes(e.cid)))),s=t.cloneDeep(o).baseData,l=s.top+s.height;for(const t of e){const e=t.baseData,o=e.top+e.height;if(s.left<e.left+e.width&&s.left+s.width>e.left){const e=o-l;e>=0&&e<a&&(a=e,i=t)}}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return i}verticalDistance(e,t){e.left,e.width;const o=e.top+e.height,r=(t.left,t.width,t.top);return Math.abs(o-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=[],o=new Set;for(const r of e){if(o.has(r.cid))continue;let i=[];for(const t of e){if(!o.has(t.cid)&&r.cid!=t.cid){this.checkComponentIntersection(r.baseData,t.baseData)&&(o.add(t.cid),o.add(r.cid),i.push(t))}}t.push([r,...i])}let r=[];for(const e of t)for(const t of e){let o=this.getAnTextNormaltText(t);this.extractAmount(o).every((e=>e))&&r.push(e)}return r}createAnOdometer(){var e,o;let r=this.judgeAnOdometer();for(const i of r){let r,a,n,s=this.calculateCombinedComponent(i.map((e=>e.baseData)));for(const e of i){let o=this.getAnTextNormaltText(e),i=this.extractAmount(o);i.every((e=>!e))&&(r=o),i.every((e=>e))&&(a=i[0],n=i[1]),t.remove(this.list,(t=>t.cid==e.cid))}let l=je("AnIndicatorNormal",this.staticComponentData,t.cloneDeep({baseData:s}));(null===(o=null===(e=null==l?void 0:l.tmpData)||void 0===e?void 0:e.source)||void 0===o?void 0:o.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 o=this.list[e];if("AnDeckTitle3"==o.viewComName){let e=this.findClosestValue(o.baseData.width,t);o.baseData.width=e>300?e:300,o.baseData=this.adjustHeightAndTop(o.baseData,this.titleHeqadeHeight)}}this.removeErroneousComponents()}containsFractionStructure(e){return/\b\d+\/\d+\b/.test(e)}removeErroneousComponents(){let e=this.getAnDeckTitle3(),t=[];for(let o=0;o<e.length;o++){const r=e[o];let i=r.tmpData.option.textNormal.text;if(this.containsFractionStructure(i))for(let o=0;o<e.length;o++){const i=e[o];if(r.cid!=i.cid){this.areComponentsIntersecting(r,i)&&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)),o=[],r=[];for(let i=0;i<e.length;i++){const a=e[i];let n=this.findNearestComponentForPoint(t,a,o);if(n&&n.cid&&o.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,o,r=[]){const i=e;let a=this.findNearestTitleForPoint(t.cloneDeep(o),i);return a?a.baseData.top-i.baseData.top-this.titleHeqadeHeight:1080-i.baseData.top-this.titleHeqadeHeight}getData(){return this.originData.list=this.list,this.originData.plant=this.plant,this.originData}}const Re=new class{randomNum(e,t){return Math.floor(Math.random()*(t-e+1))+e}generateRandomIntArray(e,t,o,r){const i=[];for(let r=0;r<e;r++){const e=this.randomNum(t,o);i.push(e)}return r&&"asc"===r?i.sort(((e,t)=>e-t)):r&&"desc"===r?i.sort(((e,t)=>t-e)):i}randomString(e,t){const o="abcdefghijklmnopqrstuvwxyz",r=this.randomNum(e,t);let i="";for(let e=0;e<r;e++){const e=Math.floor(26*Math.random());i+=o.charAt(e)}return i}generateRandomNameArray(e,t,o){const r=[];for(let i=0;i<e;i++){const e=this.randomString(t,o);r.push(e)}return r}pick(e,t){const o=void 0!==t?e.filter((e=>e!==t)):e;return o[Math.floor(Math.random()*o.length)]}},Me=()=>{const e=[],t=Re.pick([!0,!1]);let o=Re.randomNum(3,20);const r=Re.pick([null,null,null,{}]);let i=Re.pick(["asc","desc",void 0,void 0,void 0]);for(let a=0;a<Re.randomNum(1,9);a++)e.push({data:Re.generateRandomIntArray(o,0,300,i),type:"line",smooth:t,symbolSize:Re.randomNum(1,10),lineStyle:{width:Re.randomNum(1,4)},areaStyle:r});return{xAxis:{type:"category",show:!1,boundaryGap:!1,data:Re.generateRandomNameArray(o,3,6)},grid:{left:0,top:0,bottom:0,right:0},yAxis:{show:!1,type:"value"},series:e}},Be=(e,t)=>{let o={type:e,show:!1};return"category"===e&&(o.data=Re.generateRandomNameArray(t,3,6)),o},Ue=()=>{const e=[],t=Re.pick([!0,!1]);let o=Re.randomNum(3,20);const r=Re.pick([null,null,null,{}]);let i=Re.pick(["asc","desc",void 0,void 0,void 0]),a=Re.randomNum(1,9),n=Re.pick([!0,!1]);for(let s=0;s<a;s++){let a={data:Re.generateRandomIntArray(o,0,300,i),type:"bar",smooth:t,stack:n,areaStyle:r};e.push(a)}let s=Re.pick(["value","category"]),l=Re.pick(["value","category"],s);return{xAxis:Be(s,o),grid:{left:0,top:0,bottom:0,right:0},yAxis:Be(l,o),series:e}},qe=()=>{const e=[];let t=Re.randomNum(3,20);Re.pick([null,null,null,{}]);let o=Re.pick(["asc","desc",void 0,void 0,void 0]),r=Re.pick([1,2]),i=[Re.pick(["10%","20%","30%","40%","50%","60%","70%","80%"]),Re.pick(["90%","100%"])];return e.push({data:Re.generateRandomIntArray(t,3,20,o),type:"pie",radius:1==r?"100%":i,roseType:1==r?Re.pick(["area",null,null]):null,padAngle:1==r?0:Re.randomNum(1,5),startAngle:1==r?Re.pick([0,180]):0,endAngle:360,label:{show:!1},itemStyle:{borderRadius:3}}),{grid:{left:0,top:0,bottom:0,right:0},series:e}},Le=()=>{const e=[];Re.pick([!0,!1]),Re.randomNum(3,20),Re.pick([null,null,null,{}]),Re.pick(["asc","desc",void 0,void 0,void 0]);for(let t=0;t<Re.randomNum(1,20);t++){let t=Re.randomNum(3,Re.randomNum(3,20)),o=[];for(let e=0;e<t;e++){let e=[];for(let t=0;t<2;t++)e.push(Re.randomNum(1,30));o.push(e)}e.push({type:"scatter",symbolSize:Re.randomNum(3,30),data:o})}return{xAxis:{show:!1},grid:{left:0,top:0,bottom:0,right:0},yAxis:{show:!1,type:"value"},series:e}},He=()=>{const e=[],t=Re.pick(["polygon","circle"]);let o=Re.randomNum(1e4,99999),r=Re.randomNum(3,10),i=[];for(let e=0;e<r;e++)i.push({name:Re.randomString(4,8),max:o});for(let t=0;t<Re.randomNum(2,10);t++)e.push({value:Re.generateRandomIntArray(r,1e4,o),name:Re.randomString(4,8)});return{radar:{shape:t,indicator:i,axisName:{show:!1},radius:"100%"},grid:{left:0,top:0,bottom:0,right:0},series:[{type:"radar",symbol:"none",lineStyle:{width:1},data:e}]}},ze=()=>{const e=[];for(let t=0;t<Re.randomNum(4,15);t++)e.push({value:Re.randomNum(1,100),name:Re.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:Re.pick(["descending","ascending"]),gap:2,lineStyle:{width:1},data:e}]}};let Je=Re.randomNum(5,20);const Ge={width:Je};Re.pick([!0,!1])&&(Ge.color=[[.3,"#67e0e3"],[.7,"#37a2da"],[1,"#fd666d"]]);class _e{constructor(){this.names=["line","bar","pie","scatter","radar","funnel","gauge"]}static getInstance(){return _e.instance||(_e.instance=new _e),_e.instance}createLine(){switch(Re.pick(this.names)){case"line":return{type:"line",typeNum:1,option:Me()};case"bar":return{type:"bar",typeNum:2,option:Ue()};case"pie":return{type:"pie",typeNum:3,option:qe()};case"scatter":return{type:"scatter",typeNum:4,option:Le()};case"radar":return{type:"radar",typeNum:5,option:He()};case"funnel":return{type:"funnel",typeNum:6,option:ze()};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:Re.pick([!0,!1]),width:Je},axisLine:{lineStyle:Ge},data:[{value:Re.randomNum(1,100),name:"SCORE"}]}]}}}}}_e.instance=null;const We=_e.getInstance();const Xe=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,o=(null==e?void 0:e.colNum)?null==e?void 0:e.colNum:this.splitNumbers,r=e.wrapWidth/o,i=e.wrapHeight/t;let a=B(this.directions);a&&(this.direction=a);let n=[];if("row"===this.direction){let e=B([3,4]);n=this.simulateRandomSegments(24,4,12,e)}else{let e=B([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:r,hStep:i});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:i})}let e=B([2,3]),t=this.simulateRandomSegments(24,6,12,e);for(let e=0;e<s.length;e++){const o=s[e];for(let a=0;a<t.length;a++){const n=t[a];l.push({x:o.x,y:n,w:o.w,h:n,i:10*e+a,wStep:r,hStep:i})}}}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:i});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:i})}for(let e=0;e<s.length;e++){const t=s[e];let o=B([1,2,3,4]),a=this.simulateRandomSegments(24,5,12,o),n=[];for(let o=0;o<a.length;o++){const s=a[o];if(0==o)n.push({x:0,y:t.y,w:s,h:t.h,i:10*e+o,wStep:r,hStep:i}),l.push({x:0,y:t.y,w:s,h:t.h,i:10*e+o,wStep:r,hStep:i});else{let d=n[o-1].x;n.push({x:a[o-1]+d,y:t.y,w:s,h:t.h,i:10*e+o,wStep:r,hStep:i}),l.push({x:a[o-1]+d,y:t.y,w:s,h:t.h,i:10*e+o,wStep:r,hStep:i})}}}}return{layouts:l.map((t=>{let{option:o,typeNum:r}=We.createLine(),i=t.x*t.wStep+t.w*t.wStep/2,a=t.y*t.hStep+t.h*t.hStep/2,n=t.w*t.wStep,s=t.h*t.hStep;if(3==r||5==r||7==r){let e=Math.min(n,s);n=e,s=e}let l=e.wrapWidth,d=e.wrapHeight;return t.chartsOption=o,t.typeNum=r,t.txt=r+" "+i/l+" "+a/d+" "+n/l+" "+s/d,console.log(t.txt),t})),option:{colNum:o,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,o,r){const i=[];let a=e,n=r;for(;n>0;)if(1===n)i.push(a),n--;else{const e=Math.min(o,a-t*(n-1)),r=Math.floor(Math.random()*(e-t+1))+t;i.push(r),a-=r,n--}return i}simulateRandomSegments2(e,t,o,r){const i=[];let a=e,n=r;for(;n>0;)if(1==n){const t=e-i.reduce(((e,t)=>e+t),0);i.push(t),n--}else{let e=Math.floor(Math.random()*o),r=Math.max(t,e),s=a-t*n;const l=Math.min(r,s);i.push(l),a-=l,n--}return i}},Ke=e=>{try{return JSON.parse(e)}catch(t){return e}};const Qe=new class{constructor(){this.requested=new Set,this.dbName="go-db",this.storeName="store",this.init()}init(){return a(this,void 0,void 0,(function*(){const e=indexedDB.open(this.dbName,10);e.onupgradeneeded=e=>{const t=e.target.result;t.objectStoreNames.contains(this.storeName)||t.createObjectStore(this.storeName,{keyPath:"key"})},e.onsuccess=()=>{},e.onerror=e=>{var t;console.error("数据库错误: "+(null===(t=e.target.error)||void 0===t?void 0:t.message))}}))}pushCaseIdToRequested(e){this.requested.add(e)}add(e,t){return a(this,void 0,void 0,(function*(){if(!(yield this.isExist(e))){t.caseDetailData&&(t.caseDetailData="string"==typeof t.caseDetailData?Ke(t.caseDetailData):t.caseDetailData),this.pushCaseIdToRequested(e);const o=(yield this.getDB()).transaction(this.storeName,"readwrite");o.objectStore(this.storeName).add({key:e,value:t}),o.onerror=e=>{var t;console.error("事务错误: "+(null===(t=e.target.error)||void 0===t?void 0:t.message))}}}))}bulkPut(e){return a(this,void 0,void 0,(function*(){const t=(yield this.getDB()).transaction(this.storeName,"readwrite"),o=t.objectStore(this.storeName);for(const t of e){const{caseId:e,id:r}=t,i=`${e}_${r}`;(yield this.isExist(i))||(t.caseDetailData&&(t.caseDetailData=Ke(t.caseDetailData)),this.pushCaseIdToRequested(i),o.put({key:i,value:t}))}t.onerror=e=>{var t;console.error("事务错误: "+(null===(t=e.target.error)||void 0===t?void 0:t.message))}}))}get(e){return a(this,void 0,void 0,(function*(){if(!(yield this.isExist(e)))return null;const t=(yield this.getDB()).transaction(this.storeName,"readonly").objectStore(this.storeName);return new Promise(((o,r)=>{const i=t.get(e);i.onsuccess=e=>{o(e.target.result?e.target.result.value:null)},i.onerror=e=>{var t;r("请求错误: "+(null===(t=e.target.error)||void 0===t?void 0:t.message))}}))}))}getAllData(){return a(this,void 0,void 0,(function*(){const e=(yield this.getDB()).transaction(this.storeName,"readonly").objectStore(this.storeName);return new Promise(((t,o)=>{const r=e.getAll();r.onsuccess=e=>{t(e.target.result)},r.onerror=e=>{var t;o("请求错误: "+(null===(t=e.target.error)||void 0===t?void 0:t.message))}}))}))}update(e,t){return a(this,void 0,void 0,(function*(){if(yield this.isExist(e)){const o=yield this.get(e),r=Ke(t),i=(yield this.getDB()).transaction(this.storeName,"readwrite");i.objectStore(this.storeName).put({key:e,value:Object.assign(Object.assign({},o),{caseDetailData:r})}),i.onerror=e=>{var t;console.error("事务错误: "+(null===(t=e.target.error)||void 0===t?void 0:t.message))}}else console.error("更新 IndexedDB 错误")}))}delete(e){this.requested.delete(e);indexedDB.open(this.dbName).onsuccess=t=>{const o=t.target.result.transaction(this.storeName,"readwrite");o.objectStore(this.storeName).delete(e),o.onerror=e=>{var t;console.error("事务错误: "+(null===(t=e.target.error)||void 0===t?void 0:t.message))}}}isExist(e){return a(this,void 0,void 0,(function*(){const t=(yield this.getDB()).transaction(this.storeName,"readonly").objectStore(this.storeName);return new Promise(((o,r)=>{const i=t.count(e);i.onsuccess=e=>{o(e.target.result>0)},i.onerror=e=>{var t;r("请求错误: "+(null===(t=e.target.error)||void 0===t?void 0:t.message))}}))}))}reset(){this.requested.clear();indexedDB.open(this.dbName).onsuccess=e=>{const t=e.target.result.transaction(this.storeName,"readwrite");t.objectStore(this.storeName).clear(),t.onerror=e=>{var t;console.error("事务错误: "+(null===(t=e.target.error)||void 0===t?void 0:t.message))}}}clear(){return a(this,void 0,void 0,(function*(){const e=(yield this.getDB()).transaction(this.storeName,"readwrite");e.objectStore(this.storeName).clear(),e.onerror=e=>{var t;console.error("事务错误: "+(null===(t=e.target.error)||void 0===t?void 0:t.message))}}))}isExistStore(){return a(this,void 0,void 0,(function*(){const e=indexedDB.open(this.dbName);return new Promise((t=>{e.onsuccess=()=>{t(!0)},e.onerror=()=>{t(!1)}}))}))}getDB(){return a(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{const o=indexedDB.open(this.dbName);o.onsuccess=t=>{e(t.target.result)},o.onerror=e=>{var o;t("数据库错误: "+(null===(o=e.target.error)||void 0===o?void 0:o.message))}}))}))}};function Ye(e){!function(e,t){e.depends?i(e):Ze(e,t)}(e,!1)}function Ze(e,t=!0){let{theme:o,option:r,optionDes:i}=e;r&&i&&o&&Object.keys(i).forEach((a=>{"conditionSeries"!==i[a].type&&"tabs"!==i[a].type||!r[a]?i[a].theme?r.hasOwnProperty(a)&&function({theme:e,option:t,optionDes:o},r,i){let a;if("color"!=o[r].type||!i&&t[r]){if("bgcolor"==o[r].type&&(i||!t[r]||!t[r].style)){t[r]||(t[r]={});let{key:i,points:n,degree:s,type:l,opacity:d}=o[r].theme;if(n){s||(s=90),l||(l="linear");let o=`${l}-gradient(${s}deg`,i=100/(n.length-1),c=[];n.forEach(((t,r)=>{a=et(e,t),o+=`,${tt(a,t.opacity)} ${i*r}%`;let{red:n,green:s,blue:l,alpha:u}=ot(a,d);c.push({red:n,green:s,blue:l,alpha:u,left:i*r})})),o+=")",t[r].style=o,t[r].degree=s,t[r].flag=n.length?3:2,t[r].points=c,t[r].type=l}else i&&(a=et(e,o[r].theme),t[r]=Object.assign(Object.assign({},ot(a,d)),{style:tt(a,d)}))}}else{let{opacity:i}=o[r].theme;a=et(e,o[r].theme),t[r]=tt(a,i)}}(e,a,t):i[a].hasOwnProperty("type")&&"slot"!=i[a].type&&"textStyle"!=i[a].type&&"sheet"!=i[a].type||i[a].constructor!=Object||Ze({option:r[a],optionDes:i[a],theme:o},t):function(e,t,o,r,i,a){let n=t.form,s=e;if(Array.isArray(n))for(let e=0;e<n.length;e++){let t,o=n[e];t=a?s[e].form:s[e],Ze({option:t,optionDes:o,theme:r},i)}else{let e=s.length;for(let t=0;t<e;t++){let e;e=a?s[t].form:s[t],Ze({option:e,optionDes:n,theme:r},i)}}}(r[a],i[a],0,o,t,"conditionSeries"===i[a].type)}))}function et(e,t){if(e[t.key])return e[t.key]||e.color;if(t.key.indexOf(".")>-1){return[e,...t.key.split(".")].reduce(((t,o)=>"object"==typeof t&&o in t?t[o]:(rt(`属性${o}不存在,获取主题颜色错误,将使用默认主题色`),e.color)))}return rt(`属性${t.key}不存在,获取主题颜色错误,将使用默认主题色`),e.color}function tt(e,t){let{red:o,green:r,blue:i,alpha:a}=ot(e,t);return`rgba(${o},${r},${i},${a})`}function ot(e,t){return-1!=e.indexOf("#")&&(e=e.substr(1)),null==t&&(t=1),{red:parseInt("0x"+e.slice(0,2)),green:parseInt("0x"+e.slice(2,4)),blue:parseInt("0x"+e.slice(4,6)),alpha:t}}function rt(e){console.warn(e)}class it{constructor(e){this.processedIds=new Set,this.validateAccessResolve=null,e?(e.caseId&&(this.caseId=e.caseId),e.pageId&&(this.pageId=e.pageId),e.mode&&(this.mode=e.mode),e.environment&&(this.environment=e.environment),e.xhr&&(this.xhr=e.xhr),e.staticComponentData&&(this.staticComponentData=e.staticComponentData),e.theme&&(this.theme=e.theme),e.fetchMode&&(this.fetchMode=e.fetchMode)):console.log("初始化错误!"),this.defaultTheme={name:"科技蓝",color:"#006aee",background:"#00000033",pageBackground:"#051836",text:"#F0F0F0",groups:["#006aee","#00eae9","#00a9ec","#00ec80","#edc700","#9913ee"]}}checkHardware(){return a(this,void 0,void 0,(function*(){return yield new Promise(((e,t)=>{e("Hardware is not available")}))}))}checkSecurity(e){return a(this,void 0,void 0,(function*(){return yield new Promise(((t,o)=>{"preview"==this.environment?t(0):this.getShareForRelease(e).then((e=>{2e4==e.code&&e.data?(e.data,e.data.loginLimitSwitch?t(1):e.data.hasAuth?t(2):t(3)):t(4)}))}))}))}validateAccess(e,t){return a(this,void 0,void 0,(function*(){return new Promise(((o,r)=>{this.validateAccessResolve=o,t&&t(e)}))}))}initBefore(){return new Promise(((e,t)=>{let o=g("secretFree");o?sessionStorage.setItem("secret-free",o):sessionStorage.setItem("secret-free",null),console.log("运行免登录设置完成!"),e(!0)}))}fetchCaseId(e,t){return a(this,void 0,void 0,(function*(){try{const o=yield this.getKey(e,t);return 2e4===(null==o?void 0:o.code)&&(null==o?void 0:o.data)?o.data:e}catch(t){return console.error("Error fetching caseId:",t),e}}))}getDataForrelease(){return new Promise(((e,t)=>{e("data")}))}onProjectLoaded(e){}authenticate(){return a(this,void 0,void 0,(function*(){this.environment}))}getShareForRelease(e){return this.xhr.get(`/go/v1/go-share/v1/${e}/config`)}findById(e,t="",o=0,r=""){return"release"===this.environment?this.xhr.get(`/go/v1/go-share/v1/${e}?pwd=${t}&mode=${o}&token=${r}`):this.xhr.get(`/go/v1/go-cases/v1/${e}?mode=${o}&token=${r}`)}getKey(e,t=0){return this.xhr.get(`/go/v1/go-cases/v1/key/${e}?caseMode=${t}`)}getPageData(e,t){return a(this,void 0,void 0,(function*(){if("local"==this.fetchMode){const o=yield Qe.get(e+"_"+t);if(o)return{data:o}}return"release"===this.environment?this.xhr.get(`/go/v1/go-share/v1/${e}/pages/${t}`):this.xhr.get(`/go/v1/go-cases/v1/${e}/pages/${t}`)}))}getPageId(e,t){if(null==t?void 0:t.length){if(t.find((t=>t.id==e)))return e;let o=t.find((t=>t.caseDetailPath==e||t.caseDetailName==e));return o?o.id:e}return e}fetchProjectForId(e,t="",o=0,r=""){return a(this,void 0,void 0,(function*(){return yield this.findById(e,t,o,r)}))}updataPageData(e,t){var o;return a(this,void 0,void 0,(function*(){const r=this.getPageId(t,this.projectInfo.details);let i=yield this.getPageDataForID(e,r);if(null==i?void 0:i.data){let e=yield this.pageInit(i.data);return null===(o=null==this?void 0:this.lifecycleHooks)||void 0===o||o.onPageDataReady(e),e}return console.error("请求数据发生错误!",i.msg),{type:"error",error:i.msg}}))}getPageDataForID(e,t,o){return a(this,void 0,void 0,(function*(){const r=this.getPageId(t,this.projectInfo.details);if(this.processedIds.has(r)&&"local"==this.fetchMode){console.log(`ID ${r} has already been processed.`);const t=yield Qe.get(e+"_"+r);if(t)return{data:t}}const i=this.getPageData(e,r);this.processedIds.add(r),o&&o.length&&o.map((t=>a(this,void 0,void 0,(function*(){try{if(this.processedIds.has(t))return void console.log(`ID ${r} has already been processed.`);const o=yield this.getPageData(e,t);Qe.add(e+"_"+t,o.data),this.processedIds.add(t)}catch(e){console.error(`Error processing ID ${t}: ${e}`)}}))));const n=yield i;return Qe.add(e+"_"+r,n.data),n}))}fetchPageDataForId(e,t="",o=0,r=""){return a(this,void 0,void 0,(function*(){return yield this.findById(e,t,o,r)}))}setTheme(){console.log("设置主题")}setBackground(){console.log("设置背景信息")}updateVariables(){console.log("更新变量信息")}beforeRender(e){}renderComponents(){return a(this,void 0,void 0,(function*(){}))}setGlobalThemeVars(e){document.body.style.cssText=`\n --theme-background: ${e.background};\n --theme-color: ${e.color};\n --theme-pageBackground: ${e.pageBackground};\n --theme-text: ${e.text};\n ${e.groups.map(((e,t)=>`--theme-groups-${t}: ${e};`)).join("\n")}\n `}listenForRenderCompletion(){}showAnimation(){console.log("所有组件渲染完成,显示动画。")}setComTheme(e,t){var o,r;let i=null===(o=this.staticComponentData[t.viewComName])||void 0===o?void 0:o.optionDes,a=null===(r=this.staticComponentData[t.viewComName])||void 0===r?void 0:r.theme;return Ye({theme:e,option:t.tmpData.option,optionDes:i,depends:a}),t}getComData(e,t,o,r){return a(this,void 0,void 0,(function*(){return new Promise(((r,i)=>{if(e.tmpData&&e.tmpData.source)try{me(e,!0,t,o,(t=>{e.source=t,r(1)}))}catch(e){r(e)}else r("")}))}))}processingData(e){return a(this,void 0,void 0,(function*(){try{let t=this.defaultTheme;return(null==e?void 0:e.theme)&&(t=e.theme),e}catch(t){return console.warn("页面初始化发生错误:",t),e}}))}pageInit(e){return a(this,void 0,void 0,(function*(){try{let t=null==e?void 0:e.caseDetailData,o=this.defaultTheme;(null==t?void 0:t.theme)&&(o=t.theme),this.setGlobalThemeVars(o),Ae.clearVars(),Ae.addVariables(t.globalVars);Ae.getAllVariables();return t}catch(t){return console.warn("页面初始化发生错误:",t),(null==e?void 0:e.data)?e.data:e}}))}validate(e,t,o){return a(this,void 0,void 0,(function*(){return new Promise(((r,i)=>{((e,o)=>{a(this,void 0,void 0,(function*(){let i=yield this.validateAccess(e,o),a=(null==i?void 0:i.pwd)?i.pwd:"",n=(null==i?void 0:i.mode)?i.mode:this.mode,s=(null==i?void 0:i.token)?i.token:"",l=yield this.fetchProjectForId(t,a,n,s);2e4==(null==l?void 0:l.code)&&(null==l?void 0:l.data)?(this.projectInfo=l.data,console.log("验证成功!"),this.lifecycleHooks.message("验证成功!"),r(!0)):(this.lifecycleHooks.validateError(l),this.lifecycleHooks.message(l.msg,"warning"))}))})(e,o)}))}))}init(e){var t;return a(this,void 0,void 0,(function*(){try{this.lifecycleHooks=e,yield this.checkHardware();let o=yield this.fetchCaseId(this.caseId,this.mode),r=yield this.checkSecurity(o),i=e.onValidateAccess||(()=>{}),a=yield this.validate(r,o,i);(a||0==a)&&e.onCaseReady(this.projectInfo);let n=(null===(t=this.projectInfo)||void 0===t?void 0:t.details).map((e=>e.id)),s=this.getPageId(this.pageId,this.projectInfo.details),l=yield this.getPageDataForID(o,s||n[0],n);const d=yield this.pageInit(l.data);return e.onPageDataReady(d),{currentData:this.projectInfo,currentPageData:d}}catch(e){console.error("加载页面时出错:",e)}}))}}export{$e as ConfigOptimizer,Se as GlobalVariables,Q as Http,K as Log,it as PageLoader,f as addPreloadLink,te as agentData,Ve as applyDiff,S as asyncRecursion,E as delFetchStatus,Te as diffObjects,Xe as displayGenerator,pe as editItem,Ie as emitEvent,ue as fetchDataByGlobal,ce as fetchDataByType,he as filterData,O as findItemDeep,I as findItemDeep2,ee as getData,oe as getDataForApi,ie as getDataForDataSet,ne as getDataForSource,se as getDataForStatic,re as getDataForZb,ae as getDataForZbCQ,P as getResourceForComponent,w as getSessionData,v as getStandardData,A as getStringVars,g as getUrlParams,Ce as getVarDefaultVal,Ae as globalVars,C as hasVar,y as isJSON,h as loadFont,d as loadFontResource,c as loadScript,p as loadTag,k as recursion,m as removeTag,ve as replaceVariable,ye as replaceVariable2,T as safeEval,V as safeEvalForCode,F as setFetchStatus,b as setSessionData,De as updataGlobalDataSourceForVar,me as updateComData,Ne as updateGlobalDataSource};
1
+ import e from"axios";import t,{uniq as o}from"lodash";import r from"crypto-js";import{setOptionColorByTheme as i}from"@anov/ui/lib/utils/option-theme.js";function a(e,t,o,r){return new(o||(o=Promise))((function(i,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?i(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(n,s)}l((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const n=3e4,s=3e4,l=(t="",o)=>{let r=e.create({baseURL:t,timeout:n,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,o&&o(e),e.data}),(function(e){return o&&o(null==e?void 0:e.response),Promise.reject(e.response)})),r},d=function(e){return a(this,void 0,void 0,(function*(){try{let{fontUrl:t,fontName:o}=e;const r="__custom_font__";let i=document.getElementById(r);if(!i){i=document.createElement("style"),i.id=r;const e=document.head||document.getElementsByTagName("head")[0];yield e.appendChild(i)}i.innerText+=`@font-face{font-family:'${o}';src:url(${t});}`}catch(e){console.warn(e)}}))},c=(e,t="jspaths",o)=>a(void 0,void 0,void 0,(function*(){const r="csspaths"===t?"link":"script",i=document.createElement(r);"jspaths"===t?i.defer=!0:i.rel="stylesheet",i.className=t,i.src=e;(o||document.head||document.getElementsByTagName("head")[0]).appendChild(i),yield new Promise(((e,t)=>{i.addEventListener("load",e),i.addEventListener("error",e)}))})),u=(e,t="jspaths")=>a(void 0,void 0,void 0,(function*(){const o="fonts"===t?d:c;yield Promise.all(e.map((e=>o(e))))})),h=e=>a(void 0,void 0,void 0,(function*(){e.fonts&&e.fonts.length&&(yield u(e.fonts,"fonts"))})),p=({jspaths:e=[],csspaths:o=[],fonts:r=[]})=>a(void 0,void 0,void 0,(function*(){const i=t.uniqBy(r,"fontName");yield Promise.all([u(e,"jspaths"),u(o,"csspaths"),u(i,"fonts")])})),m=()=>{var e;(null==(e=document.getElementById("__custom_font__"))?void 0:e.parentNode)&&e.parentNode.removeChild(e),Array.from(document.getElementsByTagName("script")).filter((e=>"jspaths"==e.className)).forEach((e=>{!function(e){for(var t,o=Array.from(document.getElementsByTagName("script")),r=0;r<o.length;r++)o[r]&&o[r].src&&-1!=o[r].src.indexOf(e)&&(null===(t=o[r])||void 0===t?void 0:t.parentNode)&&o[r].parentNode.removeChild(o[r])}(e.src)})),Array.from(document.getElementsByTagName("link")).filter((e=>"csspaths"==e.className)).forEach((e=>{!function(e){for(var t,o=Array.from(document.getElementsByTagName("link")),r=0;r<o.length;r++)o[r].href,o[r]&&o[r].href&&-1!=o[r].href.indexOf(e)&&(null===(t=o[r])||void 0===t?void 0:t.parentNode)&&o[r].parentNode.removeChild(o[r])}(e.href)}))};const f=(e,t,o)=>{const r=document.createElement("link");switch(r.rel="preload",r.href=e,r.crossorigin="anonymous",t){case"video":r.as="video";break;case"script":r.as="script";break;case"image":r.as="image"}r.onload=()=>{console.log(`success to preload ${e}`),o&&o()},r.onerror=()=>{console.error(`Failed to preload ${e}`)},document.head.appendChild(r)},g=(e,t)=>{try{let o=t||window.location.href;if(-1!=o.indexOf("?")){let t={};return o.slice(o.indexOf("?")+1).split("&").forEach((e=>{let o=e.split("=");t[o[0]]=o[1]})),e?t[e]?t[e]:null:t}return console.log("没有参数"),null}catch(e){console.error(e)}};function v(e,t=!1){try{return t?y(e)?e:JSON.stringify(e):y(e)?JSON.parse(e):e}catch(t){return console.log("转化JSON 发生错我!",e),e}}const y=e=>{if("string"==typeof e)try{const t=JSON.parse(e);return"object"==typeof t&&null!==t}catch(e){return!1}return!1},b=(e,t)=>{try{const o=JSON.stringify(t);sessionStorage.setItem(e,o)}catch(t){console.error(`Error setting session data for key ${e}:`,t)}},w=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},D=e=>{for(const t of e)t.code&&(t.code=t.code.replace(/&gt;/g,">").replace(/&lt;/g,"<"))},N=(e,t)=>{e instanceof Map?e.forEach((e=>{t([e])})):Array.isArray(e)&&e.forEach((e=>{t(e.children)}))},k=(e,t)=>{const o=e=>{var r,i,a;if(e)for(const n of e){const e=null===(a=null===(i=null===(r=null==n?void 0:n.tmpData)||void 0===r?void 0:r.source)||void 0===i?void 0:i.converse)||void 0===a?void 0:a.data;(null==e?void 0:e.length)&&D(e),t(n),n.children?o(n.children):n.dynamicChildren?N(n.dynamicChildren,o):n.stateChildren&&o(n.stateChildren)}};o(e)},S=(e,t)=>a(void 0,void 0,void 0,(function*(){const o=e=>a(void 0,void 0,void 0,(function*(){var r,i,a,n;for(const s of e){(null===(n=null===(a=null===(i=null===(r=null==s?void 0:s.tmpData)||void 0===r?void 0:r.source)||void 0===i?void 0:i.converse)||void 0===a?void 0:a.data)||void 0===n?void 0:n.length)&&(yield D(s.tmpData.source.converse.data)),yield t(s);const e=[s.children,s.dynamicChildren?yield N(s.dynamicChildren,o):null,s.stateChildren].filter(Boolean);for(const t of e)yield o(t)}}));yield o(e)})),A=(e,t,o,r)=>{const i=e.match(/({{[\w]*}})|((@)[\w]*)/gm);if(i){const e=i.map((e=>e.replace(/{{|}}|@/gm,"")));for(const i of e)if(i&&t&&!(t.findIndex((e=>e.mapField===i))<0))return o&&r&&x(r,i,o.cid),!0}return!1},x=(e,t,o)=>{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(!o)throw new Error("ID is required");Array.isArray(e[t])||(e[t]=[]),e[t].includes(o)||e[t].push(o)},C=(e,t,o)=>{var r;let i=!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))&&(i=A(n.inputSql||n.url||(null===(r=n.headers)||void 0===r?void 0:r.value)||n.params,o)),i},O=(e,o,r=!1)=>{let i=null;const a=e=>{for(const n of e){if(n.cid===o){i=n,r&&t.remove(e,(e=>e.cid===o));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),i},I=(e,o,r)=>{let i=!1;const a=e=>{for(let n=0;n<e.length;n++){if(e[n].cid==o){i=e[n],r&&t.remove(e,(e=>e.cid==o));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 o=t[e][1];a(o)}}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 o=t[e][1];a(o)}}}else e[n].stateChildren&&a(e[n].stateChildren)}};return a(e),i||!1};function T(e,t,o){const r={};o&&o.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 V(e,o,r){let i=t.cloneDeep(o);const a={};r&&r.forEach((e=>{(null==e?void 0:e.name)&&(a[e.name]=e.value||e.originvalue)}));try{return new Function("data","vars",e)(i,a)}catch(e){return console.error(e),i}}const F=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)},E=e=>{let t=window.goFetchList;t&&t[e]&&delete t[e]};function j(e){const t=e.match(/\.([^\/\\]+)$/);return t?t[1].toLowerCase():void 0}const P=e=>{const t=[];let o=function(e){return e.endsWith("/")?e.slice(0,-1):e}(window.baseUrl);return k(e,(e=>{var r,i,a,n,s,l,d,c,u;if("AnDeckHeader3"==e.viewComName&&(null===(a=null===(i=null===(r=null==e?void 0:e.tmpData)||void 0===r?void 0:r.option)||void 0===i?void 0:i.bgImage)||void 0===a?void 0:a.path)){let r=j(e.tmpData.option.bgImage.path);t.push({type:r,url:o+e.tmpData.option.bgImage.path})}if("AnVideoNormal"==e.viewComName&&(null===(s=null===(n=null==e?void 0:e.tmpData)||void 0===n?void 0:n.option)||void 0===s?void 0:s.dynamicUrl)){let r=j(null===(d=null===(l=null==e?void 0:e.tmpData)||void 0===l?void 0:l.option)||void 0===d?void 0:d.dynamicUrl);t.push({type:r,url:o+(null===(u=null===(c=null==e?void 0:e.tmpData)||void 0===c?void 0:c.option)||void 0===u?void 0:u.dynamicUrl)})}})),t},$="anov@2019:helloX",R="anov@2020:helloX";function M(e){let t=r.enc.Utf8.parse($),o=r.enc.Utf8.parse(R);return r.AES.encrypt(e,t,{iv:o,mode:r.mode.CBC,padding:r.pad.Pkcs7}).toString()}function B(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 o=t.reduce(((e,t)=>e+t),0),r=Math.random()*o;let i=0;for(let o=0;o<e.length;o++)if(i+=t[o],r<i)return e[o];return e[0]}const U=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"]),q=URL.createObjectURL(U);function L(e,t,o={},r="worker"){return a(this,void 0,void 0,(function*(){try{if("window"==r){if("string"==typeof t)try{t=JSON.parse(t)}catch(e){console.log("转换失败!")}let[r,i]=[["data"],[t]];"object"==typeof o&&Object.keys(o).forEach((e=>{r.push(e),i.push(o[e])}));const a=new Function(...r,e)(...i);return console.log(a,"result"),{success:!0,data:a}}{let[r,i,n]=[t,o,""];"object"==typeof r&&(r=JSON.stringify(t)),"object"==typeof o&&(i=JSON.stringify(o)),Object.keys(o).forEach((e=>n+=`${e},`));let s=`let data=eval(${r}); \n             let app=${JSON.stringify({})};`;s+=n?`let {${n}} = eval(${i}); `:"",s+=`${e}`;let l=yield function(e,t=5e3){return a(this,void 0,void 0,(function*(){let o=new Worker(q);return new Promise(((r,i)=>{const a=()=>{clearTimeout(s),o.removeEventListener("message",n),o.terminate(),o=null},n=e=>{let{code:t,result:o,err:n}=e.data;a(),1===t?r(o):i(n)};o.postMessage({code:e}),o.addEventListener("message",n);let s=setTimeout((()=>{a(),i("timeout")}),t)}))}))}(s);return{success:!0,data:l}}}catch(e){return{success:!1,error:e,data:t}}}))}var H,z,J,G;!function(e){e.StaticFile="staticFile",e.DataSource="datasource"}(H||(H={})),function(e){e.json="application/json;charset=UTF-8",e.form="application/x-www-form-urlencoded; charset=UTF-8"}(z||(z={})),function(e){e.get="GET",e.post="POST",e.put="PUT",e.patch="PATCH",e.delete="DELETE"}(J||(J={}));class _{constructor(e){this.db=null,this.dbName=e.databaseName,this.tableName=e.tableName,this.keyPath=e.keyPath}static getInstance(e){return _.instance||(_.instance=new _(e)),_.instance}init(){return a(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{const o=indexedDB.open(this.dbName,1);o.onerror=e=>{t(e.target.error)},o.onupgradeneeded=e=>{this.db=e.target.result,this.db.objectStoreNames.contains(this.tableName)||this.db.createObjectStore(this.tableName,{keyPath:this.keyPath})},o.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,o)=>{const r=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).add(e);r.onsuccess=()=>{t()},r.onerror=e=>{o(e.target.error)}}))}))}deleteRecord(e){return a(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,o)=>{const r=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).delete(e);r.onsuccess=()=>{t()},r.onerror=e=>{o(e.target.error)}}))}))}updateRecord(e){return a(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,o)=>{const r=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).put(e);r.onsuccess=()=>{t()},r.onerror=e=>{o(e.target.error)}}))}))}getRecord(e){return a(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,o)=>{const r=this.db.transaction([this.tableName],"readonly").objectStore(this.tableName).get(e);r.onsuccess=()=>{t(r.result)},r.onerror=e=>{o(e.target.error)}}))}))}getAllRecords(){return a(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((e,t)=>{const o=this.db.transaction([this.tableName],"readonly").objectStore(this.tableName).getAll();o.onsuccess=()=>{e(o.result)},o.onerror=e=>{t(e.target.error)}}))}))}}_.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"}(G||(G={}));const W={databaseName:"GODB",tableName:"go-log",keyPath:"time"};class X{constructor(){this.logLevel=G.INFO,this.indexedDBInstance=_.getInstance(W);try{this.indexedDBInstance.init(),console.log("IndexedDB 初始化成功。")}catch(e){console.error("初始化 IndexedDB 时出错:",e)}}static getInstance(){return X.instance||(X.instance=new X),X.instance}setLogLevel(e){this.logLevel=e}getColor(e){switch(e){case G.FATAL:return"";case G.ERROR:return"";case G.WARN:return"";case G.INFO:return"";case G.DEBUG:return"";case G.TRACE:return"";default:return""}}log(e,t){if(t<=this.logLevel){const o=(new Date).toISOString(),r=`[${o}] [${G[t]}]`,i=this.getColor(t);if(null===window||void 0===window?void 0:window.goDev)console.log(`${i}${r} ${e}`);else{let t=w("anov-go-userInfo"),a=w("anov-go-proid"),n=` [操作人:${null==t?void 0:t.userName} 项目ID:${a}] `;const s={time:o,value:`${e}`};try{this.indexedDBInstance.addRecord(s)}catch(e){console.error("添加记录时出错:",e)}console.log(`${i}${r} ${n} ${e}`)}}}fatal(e){this.log(e,G.FATAL)}error(e){this.log(e,G.ERROR)}warn(e){this.log(e,G.WARN)}info(e){this.log(e,G.INFO)}debug(e){this.log(e,G.DEBUG)}trace(e){this.log(e,G.TRACE)}}const K=X.getInstance(),Q=(e,t)=>"string"!=typeof e?Promise.reject(new Error("URL should be a string")):l(e,t),Y=l();let Z=l();function ee(e,o="get",r={},i={},n){return a(this,void 0,void 0,(function*(){try{const r={method:J[o],url:e,headers:i,timeout:s};let l;["post","put"].includes(o.toLowerCase())?r.data=t.cloneDeep(l):r.params=t.cloneDeep(l),n&&(r.headers.sponsor=n);return/.json$/.test(e)?function(e){return a(this,void 0,void 0,(function*(){try{return yield Y({method:"get",url:e})}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 Y(e)).data}}catch(e){throw console.error("请求数据发生错误-Error:",e),e}}))}(r)}catch(e){throw console.error("获取数据:Error:",e),e}}))}function te(e,t,o,r,i){return a(this,void 0,void 0,(function*(){try{const a=window.anUrl||"",n=a+(window.agentPath||"/ds/v1/api-proxy/v1/query"),s=v(o,!0);return yield Y({url:n,method:"post",headers:{"Content-Type":"application/json;charset=UTF-8",sponsor:i||""},data:{body:"post"===e?s:void 0,headers:y(r)?v(r,!0):r,method:e,url:t}})}catch(e){throw console.error("代理请求数据:Error12:",e),e}}))}function oe(e,t,o,r,i,n){return a(this,void 0,void 0,(function*(){return i?te(t,e,o,r,n):ee(e,t,o,r,n)}))}function re(e,t="",o){var r,i,a,s;const l=`${null!==(i=null===(r=null===window||void 0===window?void 0:window.BaseUrl)||void 0===r?void 0:r.replace("/management",""))&&void 0!==i?i:""}/ds/data-engine/v1/${e}/zb-query?${`token=${(null===(a=fe("YZH_EXCHANGE_TOKEN"))||void 0===a?void 0:a.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 Y({method:"POST",url:l,data:{headers:o,param:d},timeout:n})}function ie(e="",t,o){const r=`${null===window||void 0===window?void 0:window.BaseUrl}/ds/v1/data-views/query/v1/${o}`;let i={};try{i=e?JSON.parse(e):{}}catch(t){i=e||{}}return Y({method:"POST",url:r,data:{headers:t,param:i},timeout:n})}const ae=(e,t)=>a(void 0,void 0,void 0,(function*(){const o=window.BaseUrl,{dateType:r="",endPeriod:i="",metricsName:a=e,startPeriod:s=""}=t;return Z({method:"GET",url:`${o}ds/v1/metrics/v1/data-alarm?dateType=${r}&endPeriod=${i}&metricsName=${a}&startPeriod=${s}`,timeout:n})})),ne=(e,t,o)=>a(void 0,void 0,void 0,(function*(){var r;const i=(null===(r=window.BaseUrl)||void 0===r?void 0:r.replace("/management",""))||"";t.newEncryption=!0;const a={staticFile:{method:"get",params:t,url:`${i}/ds/v1/file/v1/${e}/query`},datasource:{method:"post",url:`${i}/ds/v1/database/v1/${e}/query`,data:Object.assign({},t)}}[o];if(!a)throw new Error("Invalid data type provided");return Y(Object.assign({timeout:n},a))})),se=e=>new Promise(((t,o)=>{let r;r=e.originData&&Object.keys(e.originData).length?e.originData:e.data,void 0!==r?t({data:r}):o("Failed to retrieve cdata")})),le=(e,t,o)=>{try{let r;switch(t){case"api":{let t=be(e,o);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=ve(e.inputSql,o);return{dsName:e.dsName,dsType:"1",sql:M(t),filter:e.sqlFilter}}case"staticFile":return{dsName:e.dsName,dsType:e.dsType,sql:""};case"indicator":return r=we(e,o),{zbId:e.zbId,params:ve(r.params,o),headers:ve(r.headers,o)};case"dataSet":return{params:ve(e.params,o),headers:ve(e.headers,o),value:e.value};case"indicatorCQ":return{zbName:e.zbName,params:ve(e.params,o)};case"packData":return{};default:throw new Error("Invalid type")}}catch(t){console.log("准备请求数据发生错误",t,e)}},de=(e,t,o)=>a(void 0,void 0,void 0,(function*(){try{switch(t){case"api":return yield oe(e.url,e.requestType,e.params,e.headers,e.agency,o);case"static":return yield se(e.data);case"datasource":return yield ne(e.dsName,{dsType:e.dsType,sql:e.sql,filter:e.filter},"datasource");case"staticFile":return yield ne(e.dsName,{dsType:e.dsType,sql:e.sql},"staticFile");case"indicator":return yield re(e.zbId,e.params,e.headers);case"dataSet":return yield ie(e.params,e.headers,e.value);case"indicatorCQ":return yield ae(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})}))}})),ce=(e,t,o,r=[],i=!1)=>a(void 0,void 0,void 0,(function*(){const a=t||e.tmpData.source.dataType;if(!a)return console.warn(`fetdata error on fetchDataByType', dataType is ${a}`),new Promise(((e,t)=>{e({error:!0,data:null,msg:`dataType is ${a}`})}));const n=e.tmpData.source["indicatorCQ"==a?"indicator":a];if("globalData"===a){const e=r.find((e=>e.key===n.id||e.key===n.key)),t=w(n.id);if(t&&!i)return t.data;if(e){let t=yield ue(e,o),r={key:n.id,data:t};return b(n.id,r),t}return}const s=le(n,a,o),l=yield de(s,a,e.cid?e.cid:"");return(null==l?void 0:l.data)?l.data:l})),ue=(e,t)=>a(void 0,void 0,void 0,(function*(){let o=Object.assign({},{tmpData:{source:e.value}});const r=o.tmpData.source.type,i=o.tmpData.source[r],a=le(i,r,t),n=yield de(a,r);return yield he(n.data,o,!0,t)})),he=(e,o,r=!0,i)=>a(void 0,void 0,void 0,(function*(){try{const{converse:n,mapFields:s}=o.tmpData.source;if(n&&n.use&&r){const o=yield function(e,o,r,i){return a(this,void 0,void 0,(function*(){let r,a=e,{use:n,data:s}=t.cloneDeep(o);if(n)for(let e=0;e<s.length;e++)if(s[e].use){let o=s[e].dependVars,n={};i&&n&&o&&o.length&&o.map((e=>{let o=t.cloneDeep(i).filter((t=>{let o=t.mapField==e;return o&&(n[e]=t.value),o}));o&&0!=o.length||(n[e]="")})),r=yield L(s[e].code,a,n,s[e].mode?s[e].mode:"worker"),a=r.data}return a}))}(t.cloneDeep(e),n,0,i);return o}return e}catch(t){return console.error("执行过滤器发生错误:",t),e}})),pe=(e,t,o)=>{const{source:r}=e.tmpData,i=r.type;o?("static"===i&&r[i]&&(r[i].originData=o),"indicatorCQ"===i?r.indicator.data=t:r[i].data=t):"indicatorCQ"===i?r.indicator.data=t:r[i].data=t,e.source=t},me=(e,t,o=[],r,i,n)=>a(void 0,void 0,void 0,(function*(){try{let a=e.tmpData.source.type,s=yield ce(e,a,o,r,n||!1);if(null==s||!s)return i&&i({error:!0}),Promise.resolve({error:!0});let l=yield he(s,e,t,o);return yield pe(e,l),i&&i(l),(null==e?void 0:e.cid)&&E(e.cid),Promise.resolve(l)}catch(t){return i&&i(t),K.error("Error in updateComData"),console.error("Error in updateComData:",t,e),Promise.reject(t)}})),fe=e=>{const t={};if(e&&e.includes("?")){const o=e.split("?")[1].split("&");for(let e of o){const[o,r]=e.split("=").map(decodeURIComponent);t[o]=r}}return t},ge=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}},ve=(e,t)=>{if(!t)return ge(e);if("string"==typeof e){if(""===e.trim())return"";const o=e.replace(/{{(\w+)}}/g,((e,o)=>{const r=t.find((e=>e.mapField===o));if(r){const e=r.value||r.originalValue||"";return"number"==typeof e||"boolean"==typeof e?e:`${String(e)}`}return e}));return ge(o)}if(Array.isArray(e))return e.map((e=>ve(e,t)));if("object"==typeof e&&null!==e){const o={};for(const r in e)o[r]=ve(e[r],t);return ge(o)}return ge(e)},ye=(e,t)=>{if(!t)return ge(e);if("string"==typeof e){if(""===e.trim())return"";try{if("string"!=typeof JSON.parse(e))return"number"==typeof JSON.parse(e)?e:ve(JSON.parse(e),t);{let o=e.replace(/@(\w+)|{{(\w+)}}/g,((e,o,r)=>{const i=o||r,a=t.find((e=>e.mapField===i));if(a){const e=a.value||a.originalValue;return console.log(e,"123123131"),"number"==typeof e?e:String(e)}return e}));return ge(o)}}catch(o){let r=e.replace(/@(\w+)|{{(\w+)}}/g,((e,o,r)=>{const i=o||r,a=t.find((e=>e.mapField===i));if(a){const e=a.value;return console.log(e,"value"),"number"==typeof e?e:String(e)}return e}));return ge(r)}}else{if(Array.isArray(e))return e.map((e=>ve(e,t)));if("object"==typeof e&&null!==e){const o={};for(let r in e)o[r]=ve(e[r],t);return ge(o)}}return ge(e)},be=(e,t)=>{const o=e.agency,r=e,{url:i=null,headers:a,params:n,requestType:s}=r,l=i?ve(i,t):void 0,d=a&&a.use?ve(a.value,t):{};return{url:l,requestType:s,params:n?ve(n,t):{},headers:d,agency:o}},we=(e,t)=>{const{headers:o,params:r}=e,i=o&&o.use?ve(o.value,t):{};return{params:r?ve(r,t):{},headers:i}},De=(e,t,o,r,i)=>a(void 0,void 0,void 0,(function*(){if(e&&e.length)for(const a of e){C(t,a.value,o)&&(yield me({tmpData:{source:{type:"globalData",globalData:{id:a.key}}}},!0,o,e,(e=>{console.log("数据更新成功-变量改变全局数据跟新")}),!0),k(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===a.key&&me(t,!0,o,e,(e=>{i(t,e)}),!1)}})))}})),Ne=(e,t,o,r,i)=>a(void 0,void 0,void 0,(function*(){e&&(yield me({tmpData:{source:{type:"globalData",globalData:{id:e.key}}}},!0,t,o,(e=>{console.log("数据更新成功")}),!0),k(r,(r=>{var a,n,s;if("globalData"===(null===(n=null===(a=null==r?void 0:r.tmpData)||void 0===a?void 0:a.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&&me(r,!0,t,o,(e=>{i(r,e)}),!1)}})))}));class ke{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)||0==(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(){if(this.fork&&(this.originalValue=this.getForkedValue()),this.converter&&this.converterCode){let e=[];return V(this.converterCode,this.originalValue,e)}return 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 i=Object.assign({},this,e);this.des=i.des,i.field&&(this.field=i.field),this.mapping=i.mapping,this.type=i.type,this.originalValue=i.originalValue,this.converter=i.converter,this.converterCode=i.converterCode,this.fork=i.fork,this.delayUpdate=null==i?void 0:i.delayUpdate,this.model=null==i?void 0:i.model,e.id&&(this.id?"string"==typeof this.id?e.id instanceof Array?this.id=o([this.id,...e.id]):this.id=[this.id,e.id]:this.id instanceof Array&&(e.id instanceof Array?this.id=o([...this.id,...e.id]):this.id=o([...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 o;this.originalValue=e,this.fork&&(this.forkValue=null!==(o=this.forkValue)&&void 0!==o?o:this.forkValue,this.originalValue=this.getForkedValue()),t&&t(this)}renew(e){e&&e(this)}static create(e,t){return new ke(e,t)}}class Se{constructor(){this.variables=new Map,this.globalObservers=[],this.url=window.location.search,this.list=[]}clearVars(){this.list=[],this.variables.clear()}togglePropertyState(e,t,o){try{let r=this.getVariable(e);if(!r)throw new Error("没有找到相应的变量!");r.togglePropertyState(t),this.addToObjectArray(this.list,r),o&&o()}catch(e){console.error(e)}}static getInstance(){return Se.instance||(Se.instance=new Se),Se.instance}getFullUrl(){this.url=window.location.search}getAllUrlParams(){const e=new URLSearchParams(window.location.search),t={};for(const[o,r]of e.entries())t[o]=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),o=[];for(const r of t)o.push({mapField:r,originalValue:e[r],model:4});if(o.length)for(const e of o)this.addVariable(e)}addVariables(e,t){if(Array.isArray(e)?e.map(((e,t)=>{this.addVariable(e)})):this.addVariable(e),t&&"coms"==t)for(let t of this.variables.values())0==t.model&&(e.some((e=>e.mapField==t.mapField))||this.delVariable(t.mapField));this.addUrlParamsToGlobalVars()}addVariable(e,t){if(!e||!(null==e?void 0:e.mapField))return console.error("新增全局变量:"+e+"参数不合法!"),!1;if(this.isVariableNameExist(e.mapField)){let o=this.getVariable(e.mapField);return this.sameValue(o,e)?o:(this.editVariable(e,t),!1)}const o=ke.create(e,this.variables);return this.variables.set(o.mapField,o),this.addToObjectArray(this.list,o),t&&t(o),this.notifyGlobalObservers(o),o}toJSON(e){try{return!!e&&JSON.stringify(e)}catch(e){return!1}}sameValue(e,t){if(e.mapfield!==t.mapfield)return!1;for(const o in t)if(!(["mapfield","field","key","value","name","globalVariables"].includes(o)||o in e&&e[o]==t[o]))return!1;return!0}creatVarJson(e){const{des:t,field:o,id:r,key:i,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!==o&&(v.field=o),void 0!==r&&(v.id=r),void 0!==i&&(v.key=i),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 o=!1;for(let r=0;r<e.length;r++)if(e[r].mapField==t.mapField){e[r]=this.creatVarJson(t),o=!0;break}o||e.push(t)}editVariable(e,t){const o=this.getVariable(e.mapField);if(o&&this.isVariableNameExist(e.mapField)){if(this.sameValue(o,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}};o?o.updateValue(e,r):this.addVariable(e,r)}getForkList(e){let t=this.isMapFieldInForkValues(e);return t||[]}editVariableForValue(e,t,o){const r=this.getVariable(e),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),o&&o(e),e.isUpdating=!1}};r&&r.updateWidthOriginalValue(t,i)}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 o=this.getVariable(e);return t==o.id&&!o.id.includes(t)&&[{key:e}]}if(Array.isArray(e)){const o=e.filter((e=>{let o=this.getVariable(e);return this.isVariableNameExist(e)&&t!=o.id&&!(o.id&&o.id.includes(t))})).map((e=>({key:e})));return!!o.length&&o}return!1}getVariable(e){return this.variables.get(e)}getVariableForId(e){var o;let r=[];for(const[,t]of this.variables)(t.id===e||(null===(o=t.id)||void 0===o?void 0:o.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)}))}}Se.instance=null;const Ae=Se.getInstance(),xe=(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))),Ce=(e,t,o,r)=>{const i=((e,t,o,r)=>{var i;let a;if(xe(e,null==t?void 0:t.field)||xe(e,null==t?void 0:t.forkValue))a=e[null==t?void 0:t.field]||0==e[null==t?void 0:t.field]?e[null==t?void 0:t.field]:"";else if(xe(e.data,null==t?void 0:t.field)||xe(e.data,null==t?void 0:t.forkValue))a=e.data[null==t?void 0:t.field]||0==e.data[null==t?void 0:t.field]?e.data[null==t?void 0:t.field]:"";else{const e=O(o,r),n=(null===(i=null==e?void 0:e.tmpData)||void 0===i?void 0:i.actions)||[];for(const e of n){const o=e.vars.find((e=>(null==e?void 0:e.mapField)===(null==t?void 0:t.mapField)));if(o){a=o.value;break}}}return a})(e,t,o,r);return void 0!==i?i:t.value},Oe=(e,t,o,r,i,a,n,s,l)=>{var d;switch(e.type){case"link":let c=ve(e.link,a);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 o=e.params[t],r=a.find((e=>e.mapField==o.mapField));r&&(o.value=r.value)}l&&l(e);break;case"dynamic":((e,t,o,r,i)=>{const a=e.dynamic||[];for(const n of a){if(e.id!==t.cid)continue;const a=O(o,n.pid);a&&(a.activeDynamic=n.name,a.isShow=n.visible||!r||e.index===t.index-1,i({cid:a.cid,flag:n.visible}))}})(e,t,o,r,i);break;case"toggle":((e,t,o,r,i)=>{const a=e.children||[];for(const o of a){const a=o.visible&&(!r||e.index===t.index-1);i({cid:o.cid,flag:a})}})(e,t,0,r,i);break;case"update":((e,t,o,r,i)=>{const a=e.children||[];for(const e of a){const a=O(t,e.cid);a&&me(a,!0,o,r,(e=>{i({cid:a.cid,data:e})}))}})(e,o,a,n,s)}},Ie=(e,o,r,i,a,n,s,l,d,c)=>{const{cid:u,actions:h,index:p}=a,{eventName:m,mode:f}=h,g=2===f;((e,o,r,i,a,n)=>{let s=Ae.getVariableForId(o.cid);if(null==s?void 0:s.length)for(const l of s)if(l.type==e){let e=Ce(o,l,r,i);Ae.editVariableForValue(l.mapField,e,(()=>{let e=a[l.mapField]||[],o=Ae.getForkList(l.mapField);if(o)for(const r of o){let o=a[r.mapField];e=t.concat(e,o)}n&&n(l,t.uniq(e))}))}})(m,a,i,u,r,((e,t)=>{if(De(d,e.mapFile,Ae.getAllVariables(),i,((e,t)=>{s({cid:e.cid,data:t})})),null==t?void 0:t.length)for(const o of t){e.eventSourceId=o;const t=O(i,o);!(null==e?void 0:e.delayUpdate)&&t&&me(t,!0,Ae.getAllVariables(),d,(e=>{s({cid:t.cid,data:e})}))}}));const v=((e,t,o,r,i)=>e.filter((e=>e.id===t&&e.eventType===o&&(!i||parseInt(e.index||"0")+1===parseInt(r||"0")))))(e,u,m,p,g);for(const e of v)Oe(e,a,i,g,n,Ae.getAllVariables(),d,s,l)};function Te(e,t){const o={};for(const r in e)if(e.hasOwnProperty(r))if("object"!=typeof e[r]||null===e[r]||Array.isArray(e[r]))Array.isArray(e[r])?JSON.stringify(e[r])!==JSON.stringify(t[r])&&(o[r]=t[r]):e[r]!==t[r]&&(o[r]=t[r]);else{const i=Te(e[r],t[r]);null!==i&&Object.keys(i).length>0&&(o[r]=i)}return Object.keys(o).length>0?o:null}function Ve(e,t){const o=Object.assign({},e);for(const e in t)t.hasOwnProperty(e)&&("object"!=typeof t[e]||null===t[e]||Array.isArray(t[e])?o[e]=t[e]:o[e]=Ve(o[e],t[e]));return o}const Fe=(e,t={})=>{let o={},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(o,r,t),o},Ee=(e,o)=>{let{option:r,actions:i,data:a,optionDes:n,actionsDes:s,source:l,theme:d}=((e,o)=>{let{option:r,actions:i,data:a,optionDes:n,actionsDes:s,source:l,theme:d}=t.cloneDeep(o[e]);return{option:r,actions:i,data:a,optionDes:n,actionsDes:s,source:l,theme:d}})(e,o);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:i},baseData:Pe(),dynamic:null,filePath:"",origin:"anov-ui",name:"",componentType:"",viewComName:e,optionComName:"AnOptionPanel",dataComName:"AnSourcePanel",eventComName:"AnActionsPanel",assemblyDeveloper:"",devEmail:"",version:"",devDept:""}},je=(e,o,r)=>{let i=Ee(e,o);return r?t.merge(i,r):i},Pe=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 $e{constructor(e,t,o){this.theme=null,this.plant=null,this.list=[],this.titleHeqadeHeight=70,this.clearance=3,this.checkComponentIntersection=(e,t,o=10)=>{const r=e.left,i=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&&i>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<o&&p<o},this.calculateCombinedComponent=e=>{if(0===e.length)return{left:0,top:0,width:0,height:0};let t=e[0].left,o=e[0].top,r=e[0].left+e[0].width,i=e[0].top+e[0].height;for(let a=1;a<e.length;a++){const n=e[a];t=Math.min(t,n.left),o=Math.min(o,n.top),r=Math.max(r,n.left+n.width),i=Math.max(i,n.top+n.height)}return{left:t,top:o,width:r-t,height:i-o}},this.getAnTextNormaltText=e=>{var t,o;try{return null===(o=null===(t=null==e?void 0:e.tmpData)||void 0===t?void 0:t.option)||void 0===o?void 0:o.text}catch(e){return console.error("配置优化(ConfigOptimizer):",e),""}},this.initProp(e),this.upgradePlant(),this.staticComponentData=t,this.upgradeHeaderComponent(),o&&Object.assign(this,o)}isStringOrObject(e){return"string"==typeof e?"string":"object"==typeof e&&null!==e&&"object"}initProp(e){try{let t,o=this.isStringOrObject(e);if(o&&"string"===o)t=JSON.parse(e);else{if(!o||"object"!==o)throw new Error(`initProp fn error :-- 传入参数${e}不合法!`);t=e}if(t){this.originData=t;const{theme:e,plant:o,list:r}=t;this.theme=e,this.plant=o,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 o=e.baseData,r=t.baseData;const i=Math.max(0,Math.min(o.left+o.width,r.left+r.width)-Math.max(o.left,r.left)),a=Math.max(0,Math.min(o.top+o.height,r.top+r.height)-Math.max(o.top,r.top));return i>0&&a>0}filterFileGroup(){this.list=t.cloneDeep(this.list).map((e=>{var t,o;if(1===(null===(t=null==e?void 0:e.children)||void 0===t?void 0:t.length)&&!(null===(o=null==e?void 0:e.children[0])||void 0===o?void 0:o.children)){const t=e.children[0],{left:o,top:r}=e.baseData;return t.baseData.left=o,t.baseData.top=r,t}return e}))}getText(e,t,o){const r=document.createElement("canvas").getContext("2d");if(!r)throw new Error("Failed to get 2D context from canvas.");r.font=`${o}px ${t}`;return r.measureText(e).width}calculateMaxWidths(e){const t=Math.min(...e.map((e=>e.width))),o=[];let r=[],i=e[0].width;for(const a of e){const e=a.width;Math.abs(e-i)<=t?r.push(e):(r.length>0&&o.push(r),r=[e]),i=e}r.length>0&&o.push(r);const a=[];for(const e of o){const t=Math.max(...e);a.push(t)}return a}findClosestValue(e,t){let o=t[0],r=Math.abs(e-o);for(const i of t){const t=Math.abs(e-i);t<r&&(r=t,o=i)}return o}adjustHeightAndTop(e,t){const o=t-e.height;return Object.assign(Object.assign({},e),{height:t,top:e.top-o/2})}findNearestComponent(e,o,r){let i=null,a=1/0;o.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===o.cid||"AnTextNormal"===e.viewComName||r&&r.includes(e.cid)))),s=t.cloneDeep(o).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 o=t.top-s.top;o<a&&o<100&&(a=o,i=e)}}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return i}findNearestComponentForPoint(e,t,o){let r=null,i=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||o&&o.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let o=this.getDistance(n.left,n.top+n.height,t.left,t.top);o<i&&o<n.width&&(i=o,r=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return r}findNearestComponentForTitlePoint(e,t,o){let r=null,i=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||o&&o.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let o=this.getDistance(n.left,n.top+n.height,t.left,t.top);o<i&&o<n.width&&t.top-n.top>100&&(i=o,r=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return r}findNearestTitleForPoint(e,t,o){let r=null,i=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||o&&o.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let o=t.top-n.top;o<i&&o<n.width&&t.top-n.top>100&&(i=o,r=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return r}getDistance(e,t,o,r){return Math.sqrt(Math.pow(o-e,2)+Math.pow(r-t,2))}findNearestComponent2(e,o,r){let i=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===o.cid||"AnTextNormal"===e.viewComName||r&&r.includes(e.cid)))),s=t.cloneDeep(o).baseData,l=s.top+s.height;for(const t of e){const e=t.baseData,o=e.top+e.height;if(s.left<e.left+e.width&&s.left+s.width>e.left){const e=o-l;e>=0&&e<a&&(a=e,i=t)}}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return i}verticalDistance(e,t){e.left,e.width;const o=e.top+e.height,r=(t.left,t.width,t.top);return Math.abs(o-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=[],o=new Set;for(const r of e){if(o.has(r.cid))continue;let i=[];for(const t of e){if(!o.has(t.cid)&&r.cid!=t.cid){this.checkComponentIntersection(r.baseData,t.baseData)&&(o.add(t.cid),o.add(r.cid),i.push(t))}}t.push([r,...i])}let r=[];for(const e of t)for(const t of e){let o=this.getAnTextNormaltText(t);this.extractAmount(o).every((e=>e))&&r.push(e)}return r}createAnOdometer(){var e,o;let r=this.judgeAnOdometer();for(const i of r){let r,a,n,s=this.calculateCombinedComponent(i.map((e=>e.baseData)));for(const e of i){let o=this.getAnTextNormaltText(e),i=this.extractAmount(o);i.every((e=>!e))&&(r=o),i.every((e=>e))&&(a=i[0],n=i[1]),t.remove(this.list,(t=>t.cid==e.cid))}let l=je("AnIndicatorNormal",this.staticComponentData,t.cloneDeep({baseData:s}));(null===(o=null===(e=null==l?void 0:l.tmpData)||void 0===e?void 0:e.source)||void 0===o?void 0:o.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 o=this.list[e];if("AnDeckTitle3"==o.viewComName){let e=this.findClosestValue(o.baseData.width,t);o.baseData.width=e>300?e:300,o.baseData=this.adjustHeightAndTop(o.baseData,this.titleHeqadeHeight)}}this.removeErroneousComponents()}containsFractionStructure(e){return/\b\d+\/\d+\b/.test(e)}removeErroneousComponents(){let e=this.getAnDeckTitle3(),t=[];for(let o=0;o<e.length;o++){const r=e[o];let i=r.tmpData.option.textNormal.text;if(this.containsFractionStructure(i))for(let o=0;o<e.length;o++){const i=e[o];if(r.cid!=i.cid){this.areComponentsIntersecting(r,i)&&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)),o=[],r=[];for(let i=0;i<e.length;i++){const a=e[i];let n=this.findNearestComponentForPoint(t,a,o);if(n&&n.cid&&o.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,o,r=[]){const i=e;let a=this.findNearestTitleForPoint(t.cloneDeep(o),i);return a?a.baseData.top-i.baseData.top-this.titleHeqadeHeight:1080-i.baseData.top-this.titleHeqadeHeight}getData(){return this.originData.list=this.list,this.originData.plant=this.plant,this.originData}}const Re=new class{randomNum(e,t){return Math.floor(Math.random()*(t-e+1))+e}generateRandomIntArray(e,t,o,r){const i=[];for(let r=0;r<e;r++){const e=this.randomNum(t,o);i.push(e)}return r&&"asc"===r?i.sort(((e,t)=>e-t)):r&&"desc"===r?i.sort(((e,t)=>t-e)):i}randomString(e,t){const o="abcdefghijklmnopqrstuvwxyz",r=this.randomNum(e,t);let i="";for(let e=0;e<r;e++){const e=Math.floor(26*Math.random());i+=o.charAt(e)}return i}generateRandomNameArray(e,t,o){const r=[];for(let i=0;i<e;i++){const e=this.randomString(t,o);r.push(e)}return r}pick(e,t){const o=void 0!==t?e.filter((e=>e!==t)):e;return o[Math.floor(Math.random()*o.length)]}},Me=()=>{const e=[],t=Re.pick([!0,!1]);let o=Re.randomNum(3,20);const r=Re.pick([null,null,null,{}]);let i=Re.pick(["asc","desc",void 0,void 0,void 0]);for(let a=0;a<Re.randomNum(1,9);a++)e.push({data:Re.generateRandomIntArray(o,0,300,i),type:"line",smooth:t,symbolSize:Re.randomNum(1,10),lineStyle:{width:Re.randomNum(1,4)},areaStyle:r});return{xAxis:{type:"category",show:!1,boundaryGap:!1,data:Re.generateRandomNameArray(o,3,6)},grid:{left:0,top:0,bottom:0,right:0},yAxis:{show:!1,type:"value"},series:e}},Be=(e,t)=>{let o={type:e,show:!1};return"category"===e&&(o.data=Re.generateRandomNameArray(t,3,6)),o},Ue=()=>{const e=[],t=Re.pick([!0,!1]);let o=Re.randomNum(3,20);const r=Re.pick([null,null,null,{}]);let i=Re.pick(["asc","desc",void 0,void 0,void 0]),a=Re.randomNum(1,9),n=Re.pick([!0,!1]);for(let s=0;s<a;s++){let a={data:Re.generateRandomIntArray(o,0,300,i),type:"bar",smooth:t,stack:n,areaStyle:r};e.push(a)}let s=Re.pick(["value","category"]),l=Re.pick(["value","category"],s);return{xAxis:Be(s,o),grid:{left:0,top:0,bottom:0,right:0},yAxis:Be(l,o),series:e}},qe=()=>{const e=[];let t=Re.randomNum(3,20);Re.pick([null,null,null,{}]);let o=Re.pick(["asc","desc",void 0,void 0,void 0]),r=Re.pick([1,2]),i=[Re.pick(["10%","20%","30%","40%","50%","60%","70%","80%"]),Re.pick(["90%","100%"])];return e.push({data:Re.generateRandomIntArray(t,3,20,o),type:"pie",radius:1==r?"100%":i,roseType:1==r?Re.pick(["area",null,null]):null,padAngle:1==r?0:Re.randomNum(1,5),startAngle:1==r?Re.pick([0,180]):0,endAngle:360,label:{show:!1},itemStyle:{borderRadius:3}}),{grid:{left:0,top:0,bottom:0,right:0},series:e}},Le=()=>{const e=[];Re.pick([!0,!1]),Re.randomNum(3,20),Re.pick([null,null,null,{}]),Re.pick(["asc","desc",void 0,void 0,void 0]);for(let t=0;t<Re.randomNum(1,20);t++){let t=Re.randomNum(3,Re.randomNum(3,20)),o=[];for(let e=0;e<t;e++){let e=[];for(let t=0;t<2;t++)e.push(Re.randomNum(1,30));o.push(e)}e.push({type:"scatter",symbolSize:Re.randomNum(3,30),data:o})}return{xAxis:{show:!1},grid:{left:0,top:0,bottom:0,right:0},yAxis:{show:!1,type:"value"},series:e}},He=()=>{const e=[],t=Re.pick(["polygon","circle"]);let o=Re.randomNum(1e4,99999),r=Re.randomNum(3,10),i=[];for(let e=0;e<r;e++)i.push({name:Re.randomString(4,8),max:o});for(let t=0;t<Re.randomNum(2,10);t++)e.push({value:Re.generateRandomIntArray(r,1e4,o),name:Re.randomString(4,8)});return{radar:{shape:t,indicator:i,axisName:{show:!1},radius:"100%"},grid:{left:0,top:0,bottom:0,right:0},series:[{type:"radar",symbol:"none",lineStyle:{width:1},data:e}]}},ze=()=>{const e=[];for(let t=0;t<Re.randomNum(4,15);t++)e.push({value:Re.randomNum(1,100),name:Re.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:Re.pick(["descending","ascending"]),gap:2,lineStyle:{width:1},data:e}]}};let Je=Re.randomNum(5,20);const Ge={width:Je};Re.pick([!0,!1])&&(Ge.color=[[.3,"#67e0e3"],[.7,"#37a2da"],[1,"#fd666d"]]);class _e{constructor(){this.names=["line","bar","pie","scatter","radar","funnel","gauge"]}static getInstance(){return _e.instance||(_e.instance=new _e),_e.instance}createLine(){switch(Re.pick(this.names)){case"line":return{type:"line",typeNum:1,option:Me()};case"bar":return{type:"bar",typeNum:2,option:Ue()};case"pie":return{type:"pie",typeNum:3,option:qe()};case"scatter":return{type:"scatter",typeNum:4,option:Le()};case"radar":return{type:"radar",typeNum:5,option:He()};case"funnel":return{type:"funnel",typeNum:6,option:ze()};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:Re.pick([!0,!1]),width:Je},axisLine:{lineStyle:Ge},data:[{value:Re.randomNum(1,100),name:"SCORE"}]}]}}}}}_e.instance=null;const We=_e.getInstance();const Xe=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,o=(null==e?void 0:e.colNum)?null==e?void 0:e.colNum:this.splitNumbers,r=e.wrapWidth/o,i=e.wrapHeight/t;let a=B(this.directions);a&&(this.direction=a);let n=[];if("row"===this.direction){let e=B([3,4]);n=this.simulateRandomSegments(24,4,12,e)}else{let e=B([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:r,hStep:i});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:i})}let e=B([2,3]),t=this.simulateRandomSegments(24,6,12,e);for(let e=0;e<s.length;e++){const o=s[e];for(let a=0;a<t.length;a++){const n=t[a];l.push({x:o.x,y:n,w:o.w,h:n,i:10*e+a,wStep:r,hStep:i})}}}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:i});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:i})}for(let e=0;e<s.length;e++){const t=s[e];let o=B([1,2,3,4]),a=this.simulateRandomSegments(24,5,12,o),n=[];for(let o=0;o<a.length;o++){const s=a[o];if(0==o)n.push({x:0,y:t.y,w:s,h:t.h,i:10*e+o,wStep:r,hStep:i}),l.push({x:0,y:t.y,w:s,h:t.h,i:10*e+o,wStep:r,hStep:i});else{let d=n[o-1].x;n.push({x:a[o-1]+d,y:t.y,w:s,h:t.h,i:10*e+o,wStep:r,hStep:i}),l.push({x:a[o-1]+d,y:t.y,w:s,h:t.h,i:10*e+o,wStep:r,hStep:i})}}}}return{layouts:l.map((t=>{let{option:o,typeNum:r}=We.createLine(),i=t.x*t.wStep+t.w*t.wStep/2,a=t.y*t.hStep+t.h*t.hStep/2,n=t.w*t.wStep,s=t.h*t.hStep;if(3==r||5==r||7==r){let e=Math.min(n,s);n=e,s=e}let l=e.wrapWidth,d=e.wrapHeight;return t.chartsOption=o,t.typeNum=r,t.txt=r+" "+i/l+" "+a/d+" "+n/l+" "+s/d,console.log(t.txt),t})),option:{colNum:o,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,o,r){const i=[];let a=e,n=r;for(;n>0;)if(1===n)i.push(a),n--;else{const e=Math.min(o,a-t*(n-1)),r=Math.floor(Math.random()*(e-t+1))+t;i.push(r),a-=r,n--}return i}simulateRandomSegments2(e,t,o,r){const i=[];let a=e,n=r;for(;n>0;)if(1==n){const t=e-i.reduce(((e,t)=>e+t),0);i.push(t),n--}else{let e=Math.floor(Math.random()*o),r=Math.max(t,e),s=a-t*n;const l=Math.min(r,s);i.push(l),a-=l,n--}return i}},Ke=e=>{try{return JSON.parse(e)}catch(t){return e}};const Qe=new class{constructor(){this.requested=new Set,this.dbName="go-db",this.storeName="store",this.init()}init(){return a(this,void 0,void 0,(function*(){const e=indexedDB.open(this.dbName,10);e.onupgradeneeded=e=>{const t=e.target.result;t.objectStoreNames.contains(this.storeName)||t.createObjectStore(this.storeName,{keyPath:"key"})},e.onsuccess=()=>{},e.onerror=e=>{var t;console.error("数据库错误: "+(null===(t=e.target.error)||void 0===t?void 0:t.message))}}))}pushCaseIdToRequested(e){this.requested.add(e)}add(e,t){return a(this,void 0,void 0,(function*(){if(!(yield this.isExist(e))){t.caseDetailData&&(t.caseDetailData="string"==typeof t.caseDetailData?Ke(t.caseDetailData):t.caseDetailData),this.pushCaseIdToRequested(e);const o=(yield this.getDB()).transaction(this.storeName,"readwrite");o.objectStore(this.storeName).add({key:e,value:t}),o.onerror=e=>{var t;console.error("事务错误: "+(null===(t=e.target.error)||void 0===t?void 0:t.message))}}}))}bulkPut(e){return a(this,void 0,void 0,(function*(){const t=(yield this.getDB()).transaction(this.storeName,"readwrite"),o=t.objectStore(this.storeName);for(const t of e){const{caseId:e,id:r}=t,i=`${e}_${r}`;(yield this.isExist(i))||(t.caseDetailData&&(t.caseDetailData=Ke(t.caseDetailData)),this.pushCaseIdToRequested(i),o.put({key:i,value:t}))}t.onerror=e=>{var t;console.error("事务错误: "+(null===(t=e.target.error)||void 0===t?void 0:t.message))}}))}get(e){return a(this,void 0,void 0,(function*(){if(!(yield this.isExist(e)))return null;const t=(yield this.getDB()).transaction(this.storeName,"readonly").objectStore(this.storeName);return new Promise(((o,r)=>{const i=t.get(e);i.onsuccess=e=>{o(e.target.result?e.target.result.value:null)},i.onerror=e=>{var t;r("请求错误: "+(null===(t=e.target.error)||void 0===t?void 0:t.message))}}))}))}getAllData(){return a(this,void 0,void 0,(function*(){const e=(yield this.getDB()).transaction(this.storeName,"readonly").objectStore(this.storeName);return new Promise(((t,o)=>{const r=e.getAll();r.onsuccess=e=>{t(e.target.result)},r.onerror=e=>{var t;o("请求错误: "+(null===(t=e.target.error)||void 0===t?void 0:t.message))}}))}))}update(e,t){return a(this,void 0,void 0,(function*(){if(yield this.isExist(e)){const o=yield this.get(e),r=Ke(t),i=(yield this.getDB()).transaction(this.storeName,"readwrite");i.objectStore(this.storeName).put({key:e,value:Object.assign(Object.assign({},o),{caseDetailData:r})}),i.onerror=e=>{var t;console.error("事务错误: "+(null===(t=e.target.error)||void 0===t?void 0:t.message))}}else console.error("更新 IndexedDB 错误")}))}delete(e){this.requested.delete(e);indexedDB.open(this.dbName).onsuccess=t=>{const o=t.target.result.transaction(this.storeName,"readwrite");o.objectStore(this.storeName).delete(e),o.onerror=e=>{var t;console.error("事务错误: "+(null===(t=e.target.error)||void 0===t?void 0:t.message))}}}isExist(e){return a(this,void 0,void 0,(function*(){const t=(yield this.getDB()).transaction(this.storeName,"readonly").objectStore(this.storeName);return new Promise(((o,r)=>{const i=t.count(e);i.onsuccess=e=>{o(e.target.result>0)},i.onerror=e=>{var t;r("请求错误: "+(null===(t=e.target.error)||void 0===t?void 0:t.message))}}))}))}reset(){this.requested.clear();indexedDB.open(this.dbName).onsuccess=e=>{const t=e.target.result.transaction(this.storeName,"readwrite");t.objectStore(this.storeName).clear(),t.onerror=e=>{var t;console.error("事务错误: "+(null===(t=e.target.error)||void 0===t?void 0:t.message))}}}clear(){return a(this,void 0,void 0,(function*(){const e=(yield this.getDB()).transaction(this.storeName,"readwrite");e.objectStore(this.storeName).clear(),e.onerror=e=>{var t;console.error("事务错误: "+(null===(t=e.target.error)||void 0===t?void 0:t.message))}}))}isExistStore(){return a(this,void 0,void 0,(function*(){const e=indexedDB.open(this.dbName);return new Promise((t=>{e.onsuccess=()=>{t(!0)},e.onerror=()=>{t(!1)}}))}))}getDB(){return a(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{const o=indexedDB.open(this.dbName);o.onsuccess=t=>{e(t.target.result)},o.onerror=e=>{var o;t("数据库错误: "+(null===(o=e.target.error)||void 0===o?void 0:o.message))}}))}))}};function Ye(e){!function(e,t){e.depends?i(e):Ze(e,t)}(e,!1)}function Ze(e,t=!0){let{theme:o,option:r,optionDes:i}=e;r&&i&&o&&Object.keys(i).forEach((a=>{"conditionSeries"!==i[a].type&&"tabs"!==i[a].type||!r[a]?i[a].theme?r.hasOwnProperty(a)&&function({theme:e,option:t,optionDes:o},r,i){let a;if("color"!=o[r].type||!i&&t[r]){if("bgcolor"==o[r].type&&(i||!t[r]||!t[r].style)){t[r]||(t[r]={});let{key:i,points:n,degree:s,type:l,opacity:d}=o[r].theme;if(n){s||(s=90),l||(l="linear");let o=`${l}-gradient(${s}deg`,i=100/(n.length-1),c=[];n.forEach(((t,r)=>{a=et(e,t),o+=`,${tt(a,t.opacity)} ${i*r}%`;let{red:n,green:s,blue:l,alpha:u}=ot(a,d);c.push({red:n,green:s,blue:l,alpha:u,left:i*r})})),o+=")",t[r].style=o,t[r].degree=s,t[r].flag=n.length?3:2,t[r].points=c,t[r].type=l}else i&&(a=et(e,o[r].theme),t[r]=Object.assign(Object.assign({},ot(a,d)),{style:tt(a,d)}))}}else{let{opacity:i}=o[r].theme;a=et(e,o[r].theme),t[r]=tt(a,i)}}(e,a,t):i[a].hasOwnProperty("type")&&"slot"!=i[a].type&&"textStyle"!=i[a].type&&"sheet"!=i[a].type||i[a].constructor!=Object||Ze({option:r[a],optionDes:i[a],theme:o},t):function(e,t,o,r,i,a){let n=t.form,s=e;if(Array.isArray(n))for(let e=0;e<n.length;e++){let t,o=n[e];t=a?s[e].form:s[e],Ze({option:t,optionDes:o,theme:r},i)}else{let e=s.length;for(let t=0;t<e;t++){let e;e=a?s[t].form:s[t],Ze({option:e,optionDes:n,theme:r},i)}}}(r[a],i[a],0,o,t,"conditionSeries"===i[a].type)}))}function et(e,t){if(e[t.key])return e[t.key]||e.color;if(t.key.indexOf(".")>-1){return[e,...t.key.split(".")].reduce(((t,o)=>"object"==typeof t&&o in t?t[o]:(rt(`属性${o}不存在,获取主题颜色错误,将使用默认主题色`),e.color)))}return rt(`属性${t.key}不存在,获取主题颜色错误,将使用默认主题色`),e.color}function tt(e,t){let{red:o,green:r,blue:i,alpha:a}=ot(e,t);return`rgba(${o},${r},${i},${a})`}function ot(e,t){return-1!=e.indexOf("#")&&(e=e.substr(1)),null==t&&(t=1),{red:parseInt("0x"+e.slice(0,2)),green:parseInt("0x"+e.slice(2,4)),blue:parseInt("0x"+e.slice(4,6)),alpha:t}}function rt(e){console.warn(e)}class it{constructor(e){this.processedIds=new Set,this.validateAccessResolve=null,e?(e.caseId&&(this.caseId=e.caseId),e.pageId&&(this.pageId=e.pageId),e.mode&&(this.mode=e.mode),e.environment&&(this.environment=e.environment),e.xhr&&(this.xhr=e.xhr),e.staticComponentData&&(this.staticComponentData=e.staticComponentData),e.theme&&(this.theme=e.theme),e.fetchMode&&(this.fetchMode=e.fetchMode)):console.log("初始化错误!"),this.defaultTheme={name:"科技蓝",color:"#006aee",background:"#00000033",pageBackground:"#051836",text:"#F0F0F0",groups:["#006aee","#00eae9","#00a9ec","#00ec80","#edc700","#9913ee"]}}checkHardware(){return a(this,void 0,void 0,(function*(){return yield new Promise(((e,t)=>{e("Hardware is not available")}))}))}checkSecurity(e){return a(this,void 0,void 0,(function*(){return yield new Promise(((t,o)=>{"preview"==this.environment?t(0):this.getShareForRelease(e).then((e=>{2e4==e.code&&e.data?(e.data,e.data.loginLimitSwitch?t(1):e.data.hasAuth?t(2):t(3)):t(4)}))}))}))}validateAccess(e,t){return a(this,void 0,void 0,(function*(){return new Promise(((o,r)=>{this.validateAccessResolve=o,t&&t(e)}))}))}initBefore(){return new Promise(((e,t)=>{let o=g("secretFree");o?sessionStorage.setItem("secret-free",o):sessionStorage.setItem("secret-free",null),console.log("运行免登录设置完成!"),e(!0)}))}fetchCaseId(e,t){return a(this,void 0,void 0,(function*(){try{const o=yield this.getKey(e,t);return 2e4===(null==o?void 0:o.code)&&(null==o?void 0:o.data)?o.data:e}catch(t){return console.error("Error fetching caseId:",t),e}}))}getDataForrelease(){return new Promise(((e,t)=>{e("data")}))}onProjectLoaded(e){}authenticate(){return a(this,void 0,void 0,(function*(){this.environment}))}getShareForRelease(e){return this.xhr.get(`/go/v1/go-share/v1/${e}/config`)}findById(e,t="",o=0,r=""){return"release"===this.environment?this.xhr.get(`/go/v1/go-share/v1/${e}?pwd=${t}&mode=${o}&token=${r}`):this.xhr.get(`/go/v1/go-cases/v1/${e}?mode=${o}&token=${r}`)}getKey(e,t=0){return this.xhr.get(`/go/v1/go-cases/v1/key/${e}?caseMode=${t}`)}getPageData(e,t){return a(this,void 0,void 0,(function*(){if("local"==this.fetchMode){const o=yield Qe.get(e+"_"+t);if(o)return{data:o}}return"release"===this.environment?this.xhr.get(`/go/v1/go-share/v1/${e}/pages/${t}`):this.xhr.get(`/go/v1/go-cases/v1/${e}/pages/${t}`)}))}getPageId(e,t){if(null==t?void 0:t.length){if(t.find((t=>t.id==e)))return e;let o=t.find((t=>t.caseDetailPath==e||t.caseDetailName==e));return o?o.id:e}return e}fetchProjectForId(e,t="",o=0,r=""){return a(this,void 0,void 0,(function*(){return yield this.findById(e,t,o,r)}))}updataPageData(e,t){var o;return a(this,void 0,void 0,(function*(){const r=this.getPageId(t,this.projectInfo.details);let i=yield this.getPageDataForID(e,r);if(null==i?void 0:i.data){let e=yield this.pageInit(i.data);return null===(o=null==this?void 0:this.lifecycleHooks)||void 0===o||o.onPageDataReady(e),e}return console.error("请求数据发生错误!",i.msg),{type:"error",error:i.msg}}))}getPageDataForID(e,t,o){return a(this,void 0,void 0,(function*(){const r=this.getPageId(t,this.projectInfo.details);if(this.processedIds.has(r)&&"local"==this.fetchMode){console.log(`ID ${r} has already been processed.`);const t=yield Qe.get(e+"_"+r);if(t||null==t)return{data:t}}const i=this.getPageData(e,r);this.processedIds.add(r),o&&o.length&&o.map((t=>a(this,void 0,void 0,(function*(){try{if(this.processedIds.has(t))return void console.log(`ID ${r} has already been processed.`);const o=yield this.getPageData(e,t);Qe.add(e+"_"+t,o.data),this.processedIds.add(t)}catch(e){console.error(`Error processing ID ${t}: ${e}`)}}))));const n=yield i;return Qe.add(e+"_"+r,n.data),n}))}fetchPageDataForId(e,t="",o=0,r=""){return a(this,void 0,void 0,(function*(){return yield this.findById(e,t,o,r)}))}setTheme(){console.log("设置主题")}setBackground(){console.log("设置背景信息")}updateVariables(){console.log("更新变量信息")}beforeRender(e){}renderComponents(){return a(this,void 0,void 0,(function*(){}))}setGlobalThemeVars(e){document.body.style.cssText=`\n --theme-background: ${e.background};\n --theme-color: ${e.color};\n --theme-pageBackground: ${e.pageBackground};\n --theme-text: ${e.text};\n ${e.groups.map(((e,t)=>`--theme-groups-${t}: ${e};`)).join("\n")}\n `}listenForRenderCompletion(){}showAnimation(){console.log("所有组件渲染完成,显示动画。")}setComTheme(e,t){var o,r;let i=null===(o=this.staticComponentData[t.viewComName])||void 0===o?void 0:o.optionDes,a=null===(r=this.staticComponentData[t.viewComName])||void 0===r?void 0:r.theme;return Ye({theme:e,option:t.tmpData.option,optionDes:i,depends:a}),t}getComData(e,t,o,r){return a(this,void 0,void 0,(function*(){return new Promise(((r,i)=>{if(e.tmpData&&e.tmpData.source)try{me(e,!0,t,o,(t=>{e.source=t,r(1)}))}catch(e){r(e)}else r("")}))}))}processingData(e){return a(this,void 0,void 0,(function*(){try{let t=this.defaultTheme;return(null==e?void 0:e.theme)&&(t=e.theme),e}catch(t){return console.warn("页面初始化发生错误:",t),e}}))}pageInit(e){return a(this,void 0,void 0,(function*(){try{let t=null==e?void 0:e.caseDetailData,o=this.defaultTheme;(null==t?void 0:t.theme)&&(o=t.theme),this.setGlobalThemeVars(o),Ae.clearVars(),Ae.addVariables(t.globalVars);Ae.getAllVariables();return t}catch(t){return console.warn("页面初始化发生错误:",t),(null==e?void 0:e.data)?e.data:e}}))}validate(e,t,o){return a(this,void 0,void 0,(function*(){return new Promise(((r,i)=>{((e,o)=>{a(this,void 0,void 0,(function*(){let i=yield this.validateAccess(e,o),a=(null==i?void 0:i.pwd)?i.pwd:"",n=(null==i?void 0:i.mode)?i.mode:this.mode,s=(null==i?void 0:i.token)?i.token:"",l=yield this.fetchProjectForId(t,a,n,s);2e4==(null==l?void 0:l.code)&&(null==l?void 0:l.data)?(this.projectInfo=l.data,console.log("验证成功!"),this.lifecycleHooks.message("验证成功!"),r(!0)):(this.lifecycleHooks.validateError(l),this.lifecycleHooks.message(l.msg,"warning"))}))})(e,o)}))}))}init(e){var t;return a(this,void 0,void 0,(function*(){try{this.lifecycleHooks=e,yield this.checkHardware();let o=yield this.fetchCaseId(this.caseId,this.mode),r=yield this.checkSecurity(o),i=e.onValidateAccess||(()=>{}),a=yield this.validate(r,o,i);(a||0==a)&&e.onCaseReady(this.projectInfo);let n=(null===(t=this.projectInfo)||void 0===t?void 0:t.details).map((e=>e.id)),s=this.getPageId(this.pageId,this.projectInfo.details),l=yield this.getPageDataForID(o,s||n[0],n),d=(null==l?void 0:l.data)?l.data:null;const c=yield this.pageInit(d);return e.onPageDataReady(c),{currentData:this.projectInfo,currentPageData:c}}catch(e){console.error("加载页面时出错:",e)}}))}}export{$e as ConfigOptimizer,Se as GlobalVariables,Q as Http,K as Log,it as PageLoader,f as addPreloadLink,te as agentData,Ve as applyDiff,S as asyncRecursion,E as delFetchStatus,Te as diffObjects,Xe as displayGenerator,pe as editItem,Ie as emitEvent,ue as fetchDataByGlobal,ce as fetchDataByType,he as filterData,O as findItemDeep,I as findItemDeep2,ee as getData,oe as getDataForApi,ie as getDataForDataSet,ne as getDataForSource,se as getDataForStatic,re as getDataForZb,ae as getDataForZbCQ,P as getResourceForComponent,w as getSessionData,v as getStandardData,A as getStringVars,g as getUrlParams,Ce as getVarDefaultVal,Ae as globalVars,C as hasVar,y as isJSON,h as loadFont,d as loadFontResource,c as loadScript,p as loadTag,k as recursion,m as removeTag,ve as replaceVariable,ye as replaceVariable2,T as safeEval,V as safeEvalForCode,F as setFetchStatus,b as setSessionData,De as updataGlobalDataSourceForVar,me as updateComData,Ne as updateGlobalDataSource};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdslib/go-utils",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "go-core utils",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/types/index.d.ts",