@openbkn/workshop 0.2.3 → 0.3.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{ActionConfirm-ITBip2Ic.js → ActionConfirm-BX1dlrAM.js} +5 -5
- package/dist/{ActionFailure-CWifUJ2j.js → ActionFailure-xcSfKJYC.js} +2 -2
- package/dist/{AgentChat-C1uyzwuA.js → AgentChat-DHdX_6W7.js} +407 -383
- package/dist/AppListPage-DsUvFo6B.js +1549 -0
- package/dist/{AskDrawer-Bw1NM5v_.js → AskDrawer-j-CR4yXP.js} +4 -4
- package/dist/{ComputedView-_CaPjqhY.js → ComputedView-dWFlHngu.js} +1035 -1016
- package/dist/{ConclusionApply-CG5wSeVp.js → ConclusionApply-BAoZpxl-.js} +4 -4
- package/dist/{CypherEditor-DbLHQoJJ.js → CypherEditor-CZ5Z4SGH.js} +47 -47
- package/dist/{LandingList-BMPCXj6K.js → LandingList-BUO6-at_.js} +5 -5
- package/dist/{MenuUnfoldOutlined-BoARCVho.js → MenuUnfoldOutlined-DAeIeIap.js} +3 -3
- package/dist/{ModelTrial-DZjC0E8E.js → ModelTrial-C7XvLVY7.js} +4 -4
- package/dist/{PageRenderer-Debi-U0v.js → PageRenderer-CkmvW4aO.js} +21264 -20549
- package/dist/{ScenarioApply-BNFfjIwR.js → ScenarioApply-COdlyvrC.js} +6 -6
- package/dist/{SimulateForm-CEqqMjks.js → SimulateForm-B_9laTIl.js} +4 -4
- package/dist/{Subgraph-C0VjOnZf.js → Subgraph-CDY3wvCA.js} +3 -3
- package/dist/WorkshopLabPage-BtYnBpk4.js +12020 -0
- package/dist/{WorkshopRunPage-BlyM18id.js → WorkshopRunPage-DHMJ3b8k.js} +24 -24
- package/dist/{abnfDiagram-WEYOIA3C-wqYhe75a.js → abnfDiagram-WEYOIA3C-Blje2Kbf.js} +3 -3
- package/dist/{action-type-tool.service-CtCfESYq.js → action-type-tool.service-BN-W_Az_.js} +1 -1
- package/dist/{architectureDiagram-ZHVYKT53-BYJ2H7bS.js → architectureDiagram-ZHVYKT53-B_FkRXc3.js} +3 -3
- package/dist/{bkn-agent-execution.service-ogW6NIAz.js → bkn-agent-execution.service-CJalMVIc.js} +1 -1
- package/dist/{blockDiagram-RJAE7QA3-DZfrfHRw.js → blockDiagram-RJAE7QA3-CYJLthoI.js} +3 -3
- package/dist/{c4Diagram-XDPPPE54--S7sRxgd.js → c4Diagram-XDPPPE54-CmMaN3M4.js} +2 -2
- package/dist/{channel-Ca2_7Xkz.js → channel-Dp24Bgua.js} +1 -1
- package/dist/{chunk-2E7WHVMD-BMnl6-jy.js → chunk-2E7WHVMD-DrnpfYKB.js} +1 -1
- package/dist/{chunk-2Q5K7J3B-BNVTYluA.js → chunk-2Q5K7J3B-BXqKcHlQ.js} +1 -1
- package/dist/{chunk-4EMNKR2T-CKorQf5z.js → chunk-4EMNKR2T-DYgY_0_y.js} +1 -1
- package/dist/{chunk-55XCU76K-C4xutPQ4.js → chunk-55XCU76K-Bja7bE8g.js} +1 -1
- package/dist/{chunk-5VM5RSS4-BM5F2WnL.js → chunk-5VM5RSS4-CGTnbRRi.js} +1 -1
- package/dist/{chunk-JWPE2WC7-CSU5SIs8.js → chunk-JWPE2WC7-2AyjxdJR.js} +1 -1
- package/dist/{chunk-VQ5W62QI-Dtk59D_l.js → chunk-VQ5W62QI-B3PGCKOg.js} +1 -1
- package/dist/{chunk-XXDRQBXY-DzVLFl9c.js → chunk-XXDRQBXY-RrIsI-B5.js} +1 -1
- package/dist/{chunk-ZCHMQSOR-cdQdJeDJ.js → chunk-ZCHMQSOR-COJTBW1i.js} +2 -2
- package/dist/{classDiagram-v2-4MYWR3UA-CABAzYlW.js → classDiagram-v2-4MYWR3UA-DolLxH6t.js} +5 -5
- package/dist/{cose-bilkent-JH36ORCC-Ca8GJbqv.js → cose-bilkent-JH36ORCC-DMSYgFxc.js} +2 -2
- package/dist/customComponents-DasaZ6pq.js +1 -1
- package/dist/customComponents.en-US-CkabuCXg.js +1 -1
- package/dist/{customParseFormat-H00Ur3YB.js → customParseFormat-C9WAjjqH.js} +1 -1
- package/dist/{cynefinDiagram-WF24UDRP-iIy_O6OH.js → cynefinDiagram-WF24UDRP-DrksRWCn.js} +2 -2
- package/dist/{dagre-NK4GIZVX-lW5Hra0G.js → dagre-NK4GIZVX-CFRT2dAc.js} +2 -2
- package/dist/{dayjs.min-C8_4Wqpb.js → dayjs.min-CziT8yW9.js} +1 -1
- package/dist/{diagram-CBK3MWTC-l5LVSm6X.js → diagram-CBK3MWTC-DzZ_sQCl.js} +3 -3
- package/dist/{diagram-I5XIIV2D-ChpwB8Wz.js → diagram-I5XIIV2D-RYNBUOF4.js} +2 -2
- package/dist/{diagram-ODIL2UCW-DBavGl7R.js → diagram-ODIL2UCW-DqJETE9R.js} +3 -3
- package/dist/{diagram-PFBEJUXE-B3fNIQm9.js → diagram-PFBEJUXE-BekIE7hh.js} +2 -2
- package/dist/{diagram-RJA3I4VV-Dmj0Shdh.js → diagram-RJA3I4VV-DAIwlMxl.js} +2 -2
- package/dist/{diagram-TYUNFSNR-D98rsKpY.js → diagram-TYUNFSNR-CLJ0Ou9i.js} +6 -6
- package/dist/{ebnfDiagram-V4P3TTPT-Bxr2oP9U.js → ebnfDiagram-V4P3TTPT-CRs8ppfT.js} +3 -3
- package/dist/{elk-QONTBCTQ-CvFT6Pst.js → elk-QONTBCTQ-Bqoh6AYY.js} +5 -5
- package/dist/{erDiagram-KYQIGQAA-dgeEoLzk.js → erDiagram-KYQIGQAA-BSp8Z7uQ.js} +4 -4
- package/dist/{flowDiagram-IUGLLWBU-ChsJgBPn.js → flowDiagram-IUGLLWBU-WKILTCDc.js} +7 -7
- package/dist/{ganttDiagram-R7GPNTJY-C9WcR8Tf.js → ganttDiagram-R7GPNTJY-CaTn_Mmr.js} +4 -4
- package/dist/generateCypher-BE_4YCWB.js +1032 -0
- package/dist/{gitGraphDiagram-PDYL7XHY-CeZTDs7V.js → gitGraphDiagram-PDYL7XHY-DGPs-RF6.js} +3 -3
- package/dist/{infoDiagram-MVDRKAX5-CzfcVWVf.js → infoDiagram-MVDRKAX5-HIQg7U3R.js} +1 -1
- package/dist/{ishikawaDiagram-HPEHV2GE-BK4ExPHB.js → ishikawaDiagram-HPEHV2GE-C84x8n2j.js} +2 -2
- package/dist/{journeyDiagram-BOSHW7O7-DXJ-ihrY.js → journeyDiagram-BOSHW7O7-CvYDNxSY.js} +4 -4
- package/dist/{kanban-definition-FNSA4HC5-C9rAkIZN.js → kanban-definition-FNSA4HC5-B586ryFD.js} +2 -2
- package/dist/{mermaid.core-uROF3Ult.js → mermaid.core-3J01L12Z.js} +5803 -5740
- package/dist/{mindmap-definition-6OY57UG3-DC9FfvxT.js → mindmap-definition-6OY57UG3-Donc6BMy.js} +3 -3
- package/dist/{models-D5Mffixi.js → models-Rf3LB8wS.js} +1 -1
- package/dist/{object-metric-numeric-DIgqXqB5.js → object-metric-numeric-BcgaJ6EW.js} +1 -1
- package/dist/{object-metric.service-B3PtIPEA.js → object-metric.service-CKiaFYcp.js} +2 -2
- package/dist/{pegDiagram-ECIUJNBX-CUCvcOc0.js → pegDiagram-ECIUJNBX-CYVi7x6D.js} +3 -3
- package/dist/{pieDiagram-GNMPY74T-DprBId-p.js → pieDiagram-GNMPY74T-4iWKYTTS.js} +2 -2
- package/dist/{prompt-D9VtVs5i.js → prompt-BQzBLrua.js} +110 -100
- package/dist/{quadrantDiagram-D57K4MC3-CcvW9eIV.js → quadrantDiagram-D57K4MC3-Bm6Cyi1I.js} +1 -1
- package/dist/{railroadDiagram-Y72NRBL7-DH43paGB.js → railroadDiagram-Y72NRBL7-Du6iN-Jz.js} +3 -3
- package/dist/{requirementDiagram-EQYSW5RA-CBY8WT39.js → requirementDiagram-EQYSW5RA-BGxpuSlc.js} +3 -3
- package/dist/{sankeyDiagram-SY24JHO5-DD80tYLM.js → sankeyDiagram-SY24JHO5-CsHmu__D.js} +2 -2
- package/dist/{sequenceDiagram-BLEHNHQU-Bo9dDD6b.js → sequenceDiagram-BLEHNHQU-DBNi943L.js} +3 -3
- package/dist/{sizeCapture-INFHLROL-BQTwKEEH.js → sizeCapture-INFHLROL-CcGr2ilA.js} +1 -1
- package/dist/{stateDiagram-v2-A6IESKWZ-um_LWxkE.js → stateDiagram-v2-A6IESKWZ-C78tVzaF.js} +4 -4
- package/dist/{swimlanes-B3ENRKFQ-DyYkLRSQ.js → swimlanes-B3ENRKFQ-BROc4LGM.js} +3 -3
- package/dist/{swimlanesDiagram-AYQRV4AK-DlAG_Vwl.js → swimlanesDiagram-AYQRV4AK-C0RDY4m2.js} +3 -3
- package/dist/{text-BqSVQKS6.js → text-CzC6K33E.js} +7 -3
- package/dist/{text.en-US-BhAxy_LE.js → text.en-US-D8mxBP0p.js} +6 -2
- package/dist/{timeline-definition-JXYKGLGB-DVH8Jsv4.js → timeline-definition-JXYKGLGB-C6WGe4xl.js} +1 -1
- package/dist/toolMatchLines-DrXpUwcl.js +4675 -0
- package/dist/{useLabData-fKy_tVvS.js → useLabData-B-3UW8zF.js} +8007 -7251
- package/dist/{usecaseDiagram-WPOLBNNX-DvsgvjCb.js → usecaseDiagram-WPOLBNNX-yMP7SDIg.js} +3 -3
- package/dist/{vennDiagram-Q3Y3IDCW-BQcWfjtm.js → vennDiagram-Q3Y3IDCW-bZW2LzBB.js} +2 -2
- package/dist/{wardleyDiagram-IVAIDKWA-M_Wv4tRx.js → wardleyDiagram-IVAIDKWA-DBbog93x.js} +2 -2
- package/dist/{workshop-app-wZ37Phc-.js → workshop-app-ByYXbgcn.js} +5008 -4707
- package/dist/workshop-app.css +1 -1
- package/dist/workshop-app.js +1 -1
- package/dist/{xychartDiagram-4URNHDU4-DBviJ7Ux.js → xychartDiagram-4URNHDU4-CVLJNXOt.js} +1 -1
- package/dist-cli/workshop.js +182 -140
- package/package.json +1 -1
- package/skill/SKILL.en-US.md +5 -0
- package/skill/SKILL.md +3 -0
- package/dist/AppFormModal-ByNEloW-.js +0 -4282
- package/dist/AppListPage-D2NVBJs7.js +0 -1465
- package/dist/WorkshopLabPage-C7hssyUo.js +0 -11364
- package/dist/generateCypher-kvNYDLY4.js +0 -399
package/dist-cli/workshop.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{spawnSync as pu,execFile as fu,spawn as mu}from"node:child_process";import{homedir as gu}from"node:os";import{join as G,extname as ec,posix as yu,relative as tc,sep as bu,dirname as Tt,resolve as tt}from"node:path";import{isDeepStrictEqual as wu,parseArgs as ku}from"node:util";import{readFileSync as ct,readdirSync as nn,statSync as vu,existsSync as be,rmSync as ut,mkdirSync as Dn,writeFileSync as nc,rmdirSync as $u,watch as Su,cpSync as To,symlinkSync as ju,lstatSync as oc,readlinkSync as Au}from"node:fs";import Er from"process";import Tu from"buffer";import{deflateRawSync as Ou,inflateRawSync as Eu}from"node:zlib";import{createHash as sc}from"node:crypto";import{request as Cu}from"node:http";import{request as Nu}from"node:https";function Mt(e){const t=e?.trim().split(/[.@]/)[0];if(!(!t||t==="C"||t==="POSIX"))return/^zh/i.test(t)?"zh-CN":"en-US"}function oa(e,t=process.env){return Mt(e)??Mt(t.WORKSHOP_LANG)??Mt(t.LC_ALL)??Mt(t.LC_MESSAGES)??Mt(t.LANG)??"zh-CN"}function rc(e,t={}){return e.replace(/\{(\w+)\}/g,(n,o)=>o in t?String(t[o]):n)}let Bn=null;function xu(e){Bn=e}function Ru(){return Bn}function nt(){if(!Bn)throw new Error("No Workshop host is installed: call installWorkshopHost first.");return Bn}const st={get:(e,t)=>nt().http.get(e,t),delete:(e,t)=>nt().http.delete(e,t),post:(e,t,n)=>nt().http.post(e,t,n),put:(e,t,n)=>nt().http.put(e,t,n)};function _u(e,t){if(!t.from)return t;const n=t.from.source;return e.sources.find(o=>o.id===n&&!o.from)}function ue(e,t){const n=e.sources.find(a=>a.id===t);if(!n?.from)return n;const o=_u(e,n);if(!o)return;const s=sa.get(n);if(s?.base===o)return s.value;const r={...o,id:n.id,label:n.label,from:n.from};return sa.set(n,{base:o,value:r}),r}const sa=new WeakMap,_=e=>typeof e=="string",qt=()=>{let e,t;const n=new Promise((o,s)=>{e=o,t=s});return n.resolve=e,n.reject=t,n},ra=e=>e==null?"":String(e),Pu=(e,t,n)=>{e.forEach(o=>{t[o]&&(n[o]=t[o])})},Lu=/###/g,aa=e=>e&&e.includes("###")?e.replace(Lu,"."):e,ia=e=>!e||_(e),Vt=(e,t,n)=>{const o=_(t)?t.split("."):t;let s=0;for(;s<o.length-1;){if(ia(e))return{};const r=aa(o[s]);!e[r]&&n&&(e[r]=new n),Object.prototype.hasOwnProperty.call(e,r)?e=e[r]:e={},++s}return ia(e)?{}:{obj:e,k:aa(o[s])}},la=(e,t,n)=>{const{obj:o,k:s}=Vt(e,t,Object);if(o!==void 0||t.length===1){o[s]=n;return}let r=t[t.length-1],a=t.slice(0,t.length-1),l=Vt(e,a,Object);for(;l.obj===void 0&&a.length;)r=`${a[a.length-1]}.${r}`,a=a.slice(0,a.length-1),l=Vt(e,a,Object),l?.obj&&typeof l.obj[`${l.k}.${r}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${r}`]=n},Iu=(e,t,n,o)=>{const{obj:s,k:r}=Vt(e,t,Object);s[r]=s[r]||[],s[r].push(n)},Un=(e,t)=>{const{obj:n,k:o}=Vt(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,o))return n[o]},Mu=(e,t,n)=>{const o=Un(e,n);return o!==void 0?o:Un(t,n)},ac=(e,t,n)=>{for(const o in t)o!=="__proto__"&&o!=="constructor"&&(Object.prototype.hasOwnProperty.call(e,o)?_(e[o])||e[o]instanceof String||_(t[o])||t[o]instanceof String?n&&(e[o]=t[o]):ac(e[o],t[o],n):e[o]=t[o]);return e},Ke=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),qu={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},Fu=e=>_(e)?e.replace(/[&<>"'\/]/g,t=>qu[t]):e;class Du{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(t){const n=this.regExpMap.get(t);if(n!==void 0)return n;const o=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,o),this.regExpQueue.push(t),o}}const Bu=[" ",",","?","!",";"],Uu=new Du(20),zu=(e,t,n)=>{t=t||"",n=n||"";const o=Bu.filter(a=>!t.includes(a)&&!n.includes(a));if(o.length===0)return!0;const s=Uu.getRegExp(`(${o.map(a=>a==="?"?"\\?":a).join("|")})`);let r=!s.test(e);if(!r){const a=e.indexOf(n);a>0&&!s.test(e.substring(0,a))&&(r=!0)}return r},qs=(e,t,n=".")=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;const o=t.split(n);let s=e;for(let r=0;r<o.length;){if(!s||typeof s!="object")return;let a,l="";for(let c=r;c<o.length;++c)if(c!==r&&(l+=n),l+=o[c],a=s[l],a!==void 0){if(["string","number","boolean"].includes(typeof a)&&c<o.length-1)continue;r+=c-r+1;break}s=a}return s},on=e=>e?.replace(/_/g,"-"),Wu={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console?.[e]?.apply?.(console,t)}};class zn{constructor(t,n={}){this.init(t,n)}init(t,n={}){this.prefix=n.prefix||"i18next:",this.logger=t||Wu,this.options=n,this.debug=n.debug}log(...t){return this.forward(t,"log","",!0)}warn(...t){return this.forward(t,"warn","",!0)}error(...t){return this.forward(t,"error","")}deprecate(...t){return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}forward(t,n,o,s){return s&&!this.debug?null:(t=t.map(r=>_(r)?r.replace(/[\r\n\x00-\x1F\x7F]/g," "):r),_(t[0])&&(t[0]=`${o}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new zn(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new zn(this.logger,t)}}var Be=new zn;class ro{constructor(){this.observers={}}on(t,n){return t.split(" ").forEach(o=>{this.observers[o]||(this.observers[o]=new Map);const s=this.observers[o].get(n)||0;this.observers[o].set(n,s+1)}),this}off(t,n){if(this.observers[t]){if(!n){delete this.observers[t];return}this.observers[t].delete(n)}}once(t,n){const o=(...s)=>{n(...s),this.off(t,o)};return this.on(t,o),this}emit(t,...n){this.observers[t]&&Array.from(this.observers[t].entries()).forEach(([s,r])=>{for(let a=0;a<r;a++)s(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([s,r])=>{for(let a=0;a<r;a++)s(t,...n)})}}class ca extends ro{constructor(t,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=t||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.includes(t)||this.options.ns.push(t)}removeNamespaces(t){const n=this.options.ns.indexOf(t);n>-1&&this.options.ns.splice(n,1)}getResource(t,n,o,s={}){const r=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,a=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;t.includes(".")?l=t.split("."):(l=[t,n],o&&(Array.isArray(o)?l.push(...o):_(o)&&r?l.push(...o.split(r)):l.push(o)));const c=Un(this.data,l);return!c&&!n&&!o&&t.includes(".")&&(t=l[0],n=l[1],o=l.slice(2).join(".")),c||!a||!_(o)?c:qs(this.data?.[t]?.[n],o,r)}addResource(t,n,o,s,r={silent:!1}){const a=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator;let l=[t,n];o&&(l=l.concat(a?o.split(a):o)),t.includes(".")&&(l=t.split("."),s=n,n=l[1]),this.addNamespaces(n),la(this.data,l,s),r.silent||this.emit("added",t,n,o,s)}addResources(t,n,o,s={silent:!1}){for(const r in o)(_(o[r])||Array.isArray(o[r]))&&this.addResource(t,n,r,o[r],{silent:!0});s.silent||this.emit("added",t,n,o)}addResourceBundle(t,n,o,s,r,a={silent:!1,skipCopy:!1}){let l=[t,n];t.includes(".")&&(l=t.split("."),s=o,o=n,n=l[1]),this.addNamespaces(n);let c=Un(this.data,l)||{};a.skipCopy||(o=JSON.parse(JSON.stringify(o))),s?ac(c,o,r):c={...c,...o},la(this.data,l,c),a.silent||this.emit("added",t,n,o)}removeResourceBundle(t,n){this.hasResourceBundle(t,n)&&delete this.data[t][n],this.removeNamespaces(n),this.emit("removed",t,n)}hasResourceBundle(t,n){return this.getResource(t,n)!==void 0}getResourceBundle(t,n){return n||(n=this.options.defaultNS),this.getResource(t,n)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const n=this.getDataByLanguage(t);return!!(n&&Object.keys(n)||[]).find(s=>n[s]&&Object.keys(n[s]).length>0)}toJSON(){return this.data}}var ic={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,o,s){return e.forEach(r=>{t=this.processors[r]?.process(t,n,o,s)??t}),t}};const lc=Symbol("i18next/PATH_KEY");function Ku(){const e=[],t=Object.create(null);let n;return t.get=(o,s)=>(n?.revoke?.(),s===lc?e:(e.push(s),n=Proxy.revocable(o,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function Ot(e,t){const{[lc]:n}=e(Ku()),o=t?.keySeparator??".",s=t?.nsSeparator??":",r=t?.enableSelector==="strict";if(n.length>1&&s){const a=t?.ns,l=r?Array.isArray(a)?a:a?[a]:null:Array.isArray(a)?a:null;if(l&&(r?l:l.length>1?l.slice(1):[]).includes(n[0]))return`${n[0]}${s}${n.slice(1).join(o)}`}return n.join(o)}const Oo=e=>!_(e)&&typeof e!="boolean"&&typeof e!="number";class Wn extends ro{constructor(t,n={}){super(),Pu(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Be.create("translator"),this.checkedLoadedFor={}}changeLanguage(t){t&&(this.language=t)}exists(t,n={interpolation:{}}){const o={...n};if(t==null)return!1;const s=this.resolve(t,o);if(s?.res===void 0)return!1;const r=Oo(s.res);return!(o.returnObjects===!1&&r)}extractFromKey(t,n){let o=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;o===void 0&&(o=":");const s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let r=n.ns||this.options.defaultNS||[];const a=o&&t.includes(o),l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!zu(t,o,s);if(a&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:_(r)?[r]:r};const i=t.split(o);(o!==s||o===s&&this.options.ns.includes(i[0]))&&(r=i.shift()),t=i.join(s)}return{key:t,namespaces:_(r)?[r]:r}}translate(t,n,o){let s=typeof n=="object"?{...n}:n;if(typeof s!="object"&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),typeof s=="object"&&(s={...s}),s||(s={}),t==null)return"";typeof t=="function"&&(t=Ot(t,{...this.options,...s})),Array.isArray(t)||(t=[String(t)]),t=t.map(M=>typeof M=="function"?Ot(M,{...this.options,...s}):String(M));const r=s.returnDetails!==void 0?s.returnDetails:this.options.returnDetails,a=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,{key:l,namespaces:c}=this.extractFromKey(t[t.length-1],s),i=c[c.length-1];let d=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;d===void 0&&(d=":");const h=s.lng||this.language,u=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(h?.toLowerCase()==="cimode")return u?r?{res:`${i}${d}${l}`,usedKey:l,exactUsedKey:l,usedLng:h,usedNS:i,usedParams:this.getUsedParamsDetails(s)}:`${i}${d}${l}`:r?{res:l,usedKey:l,exactUsedKey:l,usedLng:h,usedNS:i,usedParams:this.getUsedParamsDetails(s)}:l;const p=this.resolve(t,s);let f=p?.res;const m=p?.usedKey||l,g=p?.exactUsedKey||l,y=["[object Number]","[object Function]","[object RegExp]"],b=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,k=!this.i18nFormat||this.i18nFormat.handleAsObject,w=s.count!==void 0&&!_(s.count),v=Wn.hasDefaultValue(s),S=w?this.pluralResolver.getSuffix(h,s.count,s):"",j=s.ordinal&&w?this.pluralResolver.getSuffix(h,s.count,{ordinal:!1}):"",O=w&&!s.ordinal&&s.count===0,A=O&&s[`defaultValue${this.options.pluralSeparator}zero`]||s[`defaultValue${S}`]||s[`defaultValue${j}`]||s.defaultValue;let E=f;k&&!f&&v&&(E=A);const x=Oo(E),I=Object.prototype.toString.apply(E);if(k&&E&&x&&!y.includes(I)&&!(_(b)&&Array.isArray(E))){if(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const M=this.options.returnedObjectHandler?this.options.returnedObjectHandler(m,E,{...s,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return r?(p.res=M,p.usedParams=this.getUsedParamsDetails(s),p):M}if(a){const M=Array.isArray(E),L=M?[]:{},ne=M?g:m;for(const q in E)if(Object.prototype.hasOwnProperty.call(E,q)){const N=`${ne}${a}${q}`;v&&!f?L[q]=this.translate(N,{...s,defaultValue:Oo(A)?A[q]:void 0,joinArrays:!1,ns:c}):L[q]=this.translate(N,{...s,joinArrays:!1,ns:c}),L[q]===N&&(L[q]=E[q])}f=L}}else if(k&&_(b)&&Array.isArray(f))f=f.join(b),f&&(f=this.extendTranslation(f,t,s,o));else{let M=!1,L=!1;!this.isValidLookup(f)&&v&&(M=!0,f=A),this.isValidLookup(f)||(L=!0,f=l);const q=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&L?void 0:f,N=v&&A!==f&&this.options.updateMissing;if(L||M||N){if(this.logger.log(N?"updateKey":"missingKey",h,i,w&&!N?`${l}${this.pluralResolver.getSuffix(h,s.count,s)}`:l,N?A:f),a){const $=this.resolve(l,{...s,keySeparator:!1});$&&$.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let Z=[];const U=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&U&&U[0])for(let $=0;$<U.length;$++)Z.push(U[$]);else this.options.saveMissingTo==="all"?Z=this.languageUtils.toResolveHierarchy(s.lng||this.language):Z.push(s.lng||this.language);const oe=($,T,C)=>{const R=v&&C!==f?C:q;this.options.missingKeyHandler?this.options.missingKeyHandler($,i,T,R,N,s):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing($,i,T,R,N,s),this.emit("missingKey",$,i,T,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&w?Z.forEach($=>{const T=this.pluralResolver.getSuffixes($,s);O&&s[`defaultValue${this.options.pluralSeparator}zero`]&&!T.includes(`${this.options.pluralSeparator}zero`)&&T.push(`${this.options.pluralSeparator}zero`),T.forEach(C=>{oe([$],l+C,s[`defaultValue${C}`]||A)})}):oe(Z,l,A))}f=this.extendTranslation(f,t,s,p,o),L&&f===l&&this.options.appendNamespaceToMissingKey&&(f=`${i}${d}${l}`),(L||M)&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${i}${d}${l}`:l,M?f:void 0,s))}return r?(p.res=f,p.usedParams=this.getUsedParamsDetails(s),p):f}extendTranslation(t,n,o,s,r){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...o},o.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!o.skipInterpolation){o.interpolation&&this.interpolator.init({...o,interpolation:{...this.options.interpolation,...o.interpolation}});const c=_(t)&&(o?.interpolation?.skipOnVariables!==void 0?o.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let i;if(c){const h=t.match(this.interpolator.nestingRegexp);i=h&&h.length}let d=o.replace&&!_(o.replace)?o.replace:o;if(this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),t=this.interpolator.interpolate(t,d,o.lng||this.language||s.usedLng,o),c){const h=t.match(this.interpolator.nestingRegexp),u=h&&h.length;i<u&&(o.nest=!1)}!o.lng&&s&&s.res&&(o.lng=this.language||s.usedLng),o.nest!==!1&&(t=this.interpolator.nest(t,(...h)=>r?.[0]===h[0]&&!o.context?(this.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):this.translate(...h,n),o)),o.interpolation&&this.interpolator.reset()}const a=o.postProcess||this.options.postProcess,l=_(a)?[a]:a;return t!=null&&l?.length&&o.applyPostProcessor!==!1&&(t=ic.handle(l,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...s,usedParams:this.getUsedParamsDetails(o)},...o}:o,this)),t}resolve(t,n={}){let o,s,r,a,l;return _(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(c=>typeof c=="function"?Ot(c,{...this.options,...n}):c)),t.forEach(c=>{if(this.isValidLookup(o))return;const i=this.extractFromKey(c,n),d=i.key;s=d;let h=i.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));const u=n.count!==void 0&&!_(n.count),p=u&&!n.ordinal&&n.count===0,f=n.context!==void 0&&(_(n.context)||typeof n.context=="number")&&n.context!=="",m=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);h.forEach(g=>{this.isValidLookup(o)||(l=g,!this.checkedLoadedFor[`${m[0]}-${g}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(this.checkedLoadedFor[`${m[0]}-${g}`]=!0,this.logger.warn(`key "${s}" for languages "${m.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),m.forEach(y=>{if(this.isValidLookup(o))return;a=y;const b=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(b,d,y,g,n);else{let w;u&&(w=this.pluralResolver.getSuffix(y,n.count,n));const v=`${this.options.pluralSeparator}zero`,S=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(n.ordinal&&w.startsWith(S)&&b.push(d+w.replace(S,this.options.pluralSeparator)),b.push(d+w),p&&b.push(d+v)),f){const j=`${d}${this.options.contextSeparator||"_"}${n.context}`;b.push(j),u&&(n.ordinal&&w.startsWith(S)&&b.push(j+w.replace(S,this.options.pluralSeparator)),b.push(j+w),p&&b.push(j+v))}}let k;for(;k=b.pop();)this.isValidLookup(o)||(r=k,o=this.getResource(y,g,k,n))}))})}),{res:o,usedKey:s,exactUsedKey:r,usedLng:a,usedNS:l}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,n,o,s={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(t,n,o,s):this.resourceStore.getResource(t,n,o,s)}getUsedParamsDetails(t={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],o=t.replace&&!_(t.replace);let s=o?t.replace:t;if(o&&typeof t.count<"u"&&(s.count=t.count),this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),!o){s={...s};for(const r of n)delete s[r]}return s}static hasDefaultValue(t){const n="defaultValue";for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&o.startsWith(n)&&t[o]!==void 0)return!0;return!1}}class da{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Be.create("languageUtils")}getScriptPartFromCode(t){if(t=on(t),!t||!t.includes("-"))return null;const n=t.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(t){if(t=on(t),!t||!t.includes("-"))return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(_(t)&&t.includes("-")){let n;try{n=Intl.getCanonicalLocales(t)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?t.toLowerCase():t)}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(t)}getBestMatchFromCodes(t){if(!t)return null;let n;return t.forEach(o=>{if(n)return;const s=this.formatLanguageCode(o);(!this.options.supportedLngs||this.isSupportedCode(s))&&(n=s)}),!n&&this.options.supportedLngs&&t.forEach(o=>{if(n)return;const s=this.getScriptPartFromCode(o);if(this.isSupportedCode(s))return n=s;const r=this.getLanguagePartFromCode(o);if(this.isSupportedCode(r))return n=r;n=this.options.supportedLngs.find(a=>a===r?!0:!a.includes("-")&&!r.includes("-")?!1:!!(a.includes("-")&&!r.includes("-")&&a.slice(0,a.indexOf("-"))===r||a.startsWith(r)&&r.length>1))}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),_(t)&&(t=[t]),Array.isArray(t))return t;if(!n)return t.default||[];let o=t[n];return o||(o=t[this.getScriptPartFromCode(n)]),o||(o=t[this.formatLanguageCode(n)]),o||(o=t[this.getLanguagePartFromCode(n)]),o||(o=t.default),o||[]}toResolveHierarchy(t,n){const o=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],t),s=[],r=a=>{a&&(this.isSupportedCode(a)?s.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return _(t)&&(t.includes("-")||t.includes("_"))?(this.options.load!=="languageOnly"&&r(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&r(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&r(this.getLanguagePartFromCode(t))):_(t)&&r(this.formatLanguageCode(t)),o.forEach(a=>{s.includes(a)||r(this.formatLanguageCode(a))}),s}}const ua={zero:0,one:1,two:2,few:3,many:4,other:5},ha={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Yu{constructor(t,n={}){this.languageUtils=t,this.options=n,this.logger=Be.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(t,n={}){const o=on(t==="dev"?"en":t),s=n.ordinal?"ordinal":"cardinal",r=JSON.stringify({cleanedCode:o,type:s});if(r in this.pluralRulesCache)return this.pluralRulesCache[r];let a;try{a=new Intl.PluralRules(o,{type:s})}catch{if(typeof Intl>"u")return this.logger.error("No Intl support, please use an Intl polyfill!"),ha;if(!t.match(/-|_/))return ha;const c=this.languageUtils.getLanguagePartFromCode(t);a=this.getRule(c,n)}return this.pluralRulesCache[r]=a,a}needsPlural(t,n={}){let o=this.getRule(t,n);return o||(o=this.getRule("dev",n)),o?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(t,n,o={}){return this.getSuffixes(t,o).map(s=>`${n}${s}`)}getSuffixes(t,n={}){let o=this.getRule(t,n);return o||(o=this.getRule("dev",n)),o?o.resolvedOptions().pluralCategories.sort((s,r)=>ua[s]-ua[r]).map(s=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${s}`):[]}getSuffix(t,n,o={}){const s=this.getRule(t,o);return s?`${this.options.prepend}${o.ordinal?`ordinal${this.options.prepend}`:""}${s.select(n)}`:(this.logger.warn(`no plural rule found for: ${t}`),this.getSuffix("dev",n,o))}}const pa=(e,t,n,o=".",s=!0)=>{let r=Mu(e,t,n);return!r&&s&&_(n)&&(r=qs(e,n,o),r===void 0&&(r=qs(t,n,o))),r},Eo=e=>e.replace(/\$/g,"$$$$");class fa{constructor(t={}){this.logger=Be.create("interpolator"),this.options=t,this.format=t?.interpolation?.format||(n=>n),this.init(t)}init(t={}){t.interpolation||(t.interpolation={escapeValue:!0});const{escape:n,escapeValue:o,useRawValueToEscape:s,prefix:r,prefixEscaped:a,suffix:l,suffixEscaped:c,formatSeparator:i,unescapeSuffix:d,unescapePrefix:h,nestingPrefix:u,nestingPrefixEscaped:p,nestingSuffix:f,nestingSuffixEscaped:m,nestingOptionsSeparator:g,maxReplaces:y,alwaysFormat:b}=t.interpolation;this.escape=n!==void 0?n:Fu,this.escapeValue=o!==void 0?o:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=r?Ke(r):a||"{{",this.suffix=l?Ke(l):c||"}}",this.formatSeparator=i||",",this.unescapePrefix=d?"":h?Ke(h):"-",this.unescapeSuffix=this.unescapePrefix?"":d?Ke(d):"",this.nestingPrefix=u?Ke(u):p||Ke("$t("),this.nestingSuffix=f?Ke(f):m||Ke(")"),this.nestingOptionsSeparator=g||",",this.maxReplaces=y||1e3,this.alwaysFormat=b!==void 0?b:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(n,o)=>n?.source===o?(n.lastIndex=0,n):new RegExp(o,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(t,n,o,s){let r,a,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},i=p=>{if(!p.includes(this.formatSeparator)){const y=pa(n,c,p,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(y,void 0,o,{...s,...n,interpolationkey:p}):y}const f=p.split(this.formatSeparator),m=f.shift().trim(),g=f.join(this.formatSeparator).trim();return this.format(pa(n,c,m,this.options.keySeparator,this.options.ignoreJSONStructure),g,o,{...s,...n,interpolationkey:m})};this.resetRegExp(),!this.escapeValue&&typeof t=="string"&&/\$t\([^)]*\{[^}]*\{\{/.test(t)&&this.logger.warn("nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.");const d=s?.missingInterpolationHandler||this.options.missingInterpolationHandler,h=s?.interpolation?.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:p=>Eo(p)},{regex:this.regexp,safeValue:p=>this.escapeValue?Eo(this.escape(p)):Eo(p)}].forEach(p=>{for(l=0;r=p.regex.exec(t);){const f=r[1].trim();if(a=i(f),a===void 0)if(typeof d=="function"){const g=d(t,r,s);a=_(g)?g:""}else if(s&&Object.prototype.hasOwnProperty.call(s,f))a="";else if(h){a=r[0];continue}else this.logger.warn(`missed to pass in variable ${f} for interpolating ${t}`),a="";else!_(a)&&!this.useRawValueToEscape&&(a=ra(a));const m=p.safeValue(a);if(t=t.replace(r[0],m),h?(p.regex.lastIndex+=a.length,p.regex.lastIndex-=r[0].length):p.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,n,o={}){let s,r,a;const l=(c,i)=>{const d=this.nestingOptionsSeparator;if(!c.includes(d))return c;const h=c.split(new RegExp(`${Ke(d)}[ ]*{`));let u=`{${h[1]}`;c=h[0],u=this.interpolate(u,a);const p=u.match(/'/g),f=u.match(/"/g);((p?.length??0)%2===0&&!f||(f?.length??0)%2!==0)&&(u=u.replace(/'/g,'"'));try{a=JSON.parse(u),i&&(a={...i,...a})}catch(m){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,m),`${c}${d}${u}`}return a.defaultValue&&a.defaultValue.includes(this.prefix)&&delete a.defaultValue,c};for(;s=this.nestingRegexp.exec(t);){let c=[];a={...o},a=a.replace&&!_(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;const i=/{.*}/.test(s[1])?s[1].lastIndexOf("}")+1:s[1].indexOf(this.formatSeparator);if(i!==-1&&(c=s[1].slice(i).split(this.formatSeparator).map(d=>d.trim()).filter(Boolean),s[1]=s[1].slice(0,i)),r=n(l.call(this,s[1].trim(),a),a),r&&s[0]===t&&!_(r))return r;_(r)||(r=ra(r)),r||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),r=""),c.length&&(r=c.reduce((d,h)=>this.format(d,h,o.lng,{...o,interpolationkey:s[1].trim()}),r.trim())),t=t.replace(s[0],r),this.regexp.lastIndex=0}return t}}const Gu=e=>{let t=e.toLowerCase().trim();const n={};if(e.includes("(")){const o=e.split("(");t=o[0].toLowerCase().trim();const s=o[1].slice(0,-1);t==="currency"&&!s.includes(":")?n.currency||(n.currency=s.trim()):t==="relativetime"&&!s.includes(":")?n.range||(n.range=s.trim()):s.split(";").forEach(a=>{if(a){const[l,...c]=a.split(":"),i=c.join(":").trim().replace(/^'+|'+$/g,""),d=l.trim();n[d]||(n[d]=i),i==="false"&&(n[d]=!1),i==="true"&&(n[d]=!0),isNaN(i)||(n[d]=parseInt(i,10))}})}return{formatName:t,formatOptions:n}},ma=e=>{const t={};return(n,o,s)=>{let r=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(r={...r,[s.interpolationkey]:void 0});const a=o+JSON.stringify(r);let l=t[a];return l||(l=e(on(o),s),t[a]=l),l(n)}},Hu=e=>(t,n,o)=>e(on(n),o)(t);class Vu{constructor(t={}){this.logger=Be.create("formatter"),this.options=t,this.init(t)}init(t,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const o=n.cacheInBuiltFormats?ma:Hu;this.formats={number:o((s,r)=>{const a=new Intl.NumberFormat(s,{...r});return l=>a.format(l)}),currency:o((s,r)=>{const a=new Intl.NumberFormat(s,{...r,style:"currency"});return l=>a.format(l)}),datetime:o((s,r)=>{const a=new Intl.DateTimeFormat(s,{...r});return l=>a.format(l)}),relativetime:o((s,r)=>{const a=new Intl.RelativeTimeFormat(s,{...r});return l=>a.format(l,r.range||"day")}),list:o((s,r)=>{const a=new Intl.ListFormat(s,{...r});return l=>a.format(l)})}}add(t,n){this.formats[t.toLowerCase().trim()]=n}addCached(t,n){this.formats[t.toLowerCase().trim()]=ma(n)}format(t,n,o,s={}){if(!n||t==null)return t;const r=n.split(this.formatSeparator),a=[];for(let c=0;c<r.length;c++){let i=r[c];for(;i.indexOf("(")>-1&&!i.includes(")")&&c+1<r.length;)i=`${i}${this.formatSeparator}${r[++c]}`;a.push(i)}return a.reduce((c,i)=>{const{formatName:d,formatOptions:h}=Gu(i);if(this.formats[d]){let u=c;try{const p=s?.formatParams?.[s.interpolationkey]||{},f=p.locale||p.lng||s.locale||s.lng||o;u=this.formats[d](c,f,{...h,...s,...p})}catch(p){this.logger.warn(p)}return u}else this.logger.warn(`there was no format function for ${d}`);return c},t)}}const Ju=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class Zu extends ro{constructor(t,n,o,s={}){super(),this.backend=t,this.store=n,this.services=o,this.languageUtils=o.languageUtils,this.options=s,this.logger=Be.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(o,s.backend,s)}queueLoad(t,n,o,s){const r={},a={},l={},c={};return t.forEach(i=>{let d=!0;n.forEach(h=>{const u=`${i}|${h}`;!o.reload&&this.store.hasResourceBundle(i,h)?this.state[u]=2:this.state[u]<0||(this.state[u]===1?a[u]===void 0&&(a[u]=!0):(this.state[u]=1,d=!1,a[u]===void 0&&(a[u]=!0),r[u]===void 0&&(r[u]=!0),c[h]===void 0&&(c[h]=!0)))}),d||(l[i]=!0)}),(Object.keys(r).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(r),pending:Object.keys(a),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(t,n,o){const s=t.split("|"),r=s[0],a=s[1];n&&this.emit("failedLoading",r,a,n),!n&&o&&this.store.addResourceBundle(r,a,o,void 0,void 0,{skipCopy:!0}),this.state[t]=n?-1:2,n&&o&&(this.state[t]=0);const l={};this.queue.forEach(c=>{Iu(c.loaded,[r],a),Ju(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(i=>{l[i]||(l[i]={});const d=c.loaded[i];d.length&&d.forEach(h=>{l[i][h]===void 0&&(l[i][h]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(t,n,o,s=0,r=this.retryTimeout,a){if(!t.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:n,fcName:o,tried:s,wait:r,callback:a});return}this.readingCalls++;const l=(i,d)=>{if(this.readingCalls--,this.waitingReads.length>0){const h=this.waitingReads.shift();this.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.callback)}if(i&&d&&s<this.maxRetries){setTimeout(()=>{this.read(t,n,o,s+1,r*2,a)},r);return}a(i,d)},c=this.backend[o].bind(this.backend);if(c.length===2){try{const i=c(t,n);i&&typeof i.then=="function"?i.then(d=>l(null,d)).catch(l):l(null,i)}catch(i){l(i)}return}return c(t,n,l)}prepareLoading(t,n,o={},s){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();_(t)&&(t=this.languageUtils.toResolveHierarchy(t)),_(n)&&(n=[n]);const r=this.queueLoad(t,n,o,s);if(!r.toLoad.length)return r.pending.length||s(),null;r.toLoad.forEach(a=>{this.loadOne(a)})}load(t,n,o){this.prepareLoading(t,n,{},o)}reload(t,n,o){this.prepareLoading(t,n,{reload:!0},o)}loadOne(t,n=""){const o=t.split("|"),s=o[0],r=o[1];this.read(s,r,"read",void 0,void 0,(a,l)=>{a&&this.logger.warn(`${n}loading namespace ${r} for language ${s} failed`,a),!a&&l&&this.logger.log(`${n}loaded namespace ${r} for language ${s}`,l),this.loaded(t,a,l)})}saveMissing(t,n,o,s,r,a={},l=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${o}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(o==null||o==="")){if(this.backend?.create){const c={...a,isUpdate:r},i=this.backend.create.bind(this.backend);if(i.length<6)try{let d;i.length===5?d=i(t,n,o,s,c):d=i(t,n,o,s),d&&typeof d.then=="function"?d.then(h=>l(null,h)).catch(l):l(null,d)}catch(d){l(d)}else i(t,n,o,s,l,c)}!t||!t[0]||this.store.addResource(t[0],n,o,s)}}}const Co=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",enableSelector:!1,partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),_(e[1])&&(t.defaultValue=e[1]),_(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const n=e[3]||e[2];Object.keys(n).forEach(o=>{t[o]=n[o]})}return t},interpolation:{escapeValue:!0,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),ga=e=>(_(e.ns)&&(e.ns=[e.ns]),_(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),_(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&!e.supportedLngs.includes("cimode")&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),wn=()=>{},Xu=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class Jt extends ro{constructor(t={},n){if(super(),this.options=ga(t),this.services={},this.logger=Be,this.modules={external:[]},Xu(this),n&&!this.isInitialized&&!t.isClone){if(!this.options.initAsync)return this.init(t,n),this;setTimeout(()=>{this.init(t,n)},0)}}init(t={},n){this.isInitializing=!0,typeof t=="function"&&(n=t,t={}),t.defaultNS==null&&t.ns&&(_(t.ns)?t.defaultNS=t.ns:t.ns.includes("translation")||(t.defaultNS=t.ns[0]));const o=Co();this.options={...o,...this.options,...ga(t)},this.options.interpolation={...o.interpolation,...this.options.interpolation},t.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=t.keySeparator),t.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=t.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=o.overloadTranslationOptionHandler);const s=i=>i?typeof i=="function"?new i:i:null;if(!this.options.isClone){this.modules.logger?Be.init(s(this.modules.logger),this.options):Be.init(null,this.options);let i;this.modules.formatter?i=this.modules.formatter:i=Vu;const d=new da(this.options);this.store=new ca(this.options.resources,this.options);const h=this.services;h.logger=Be,h.resourceStore=this.store,h.languageUtils=d,h.pluralResolver=new Yu(d,{prepend:this.options.pluralSeparator}),i&&(h.formatter=s(i),h.formatter.init&&h.formatter.init(h,this.options),this.options.interpolation.format=h.formatter.format.bind(h.formatter)),h.interpolator=new fa(this.options),h.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},h.backendConnector=new Zu(s(this.modules.backend),h.resourceStore,h,this.options),h.backendConnector.on("*",(u,...p)=>{this.emit(u,...p)}),this.modules.languageDetector&&(h.languageDetector=s(this.modules.languageDetector),h.languageDetector.init&&h.languageDetector.init(h,this.options.detection,this.options)),this.modules.i18nFormat&&(h.i18nFormat=s(this.modules.i18nFormat),h.i18nFormat.init&&h.i18nFormat.init(this)),this.translator=new Wn(this.services,this.options),this.translator.on("*",(u,...p)=>{this.emit(u,...p)}),this.modules.external.forEach(u=>{u.init&&u.init(this)})}if(this.format=this.options.interpolation.format,n||(n=wn),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const i=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);i.length>0&&i[0]!=="dev"&&(this.options.lng=i[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(i=>{this[i]=(...d)=>this.store[i](...d)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(i=>{this[i]=(...d)=>(this.store[i](...d),this)});const l=qt(),c=()=>{const i=(d,h)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(h),n(d,h)};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return i(null,this.t.bind(this));this.changeLanguage(this.options.lng,i)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),l}loadResources(t,n=wn){let o=n;const s=_(t)?t:this.language;if(typeof t=="function"&&(o=t),!this.options.resources||this.options.partialBundledLanguages){if(s?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return o();const r=[],a=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(i=>{i!=="cimode"&&(r.includes(i)||r.push(i))})};s?a(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>a(c)),this.options.preload?.forEach?.(l=>a(l)),this.services.backendConnector.load(r,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),o(l)})}else o(null)}reloadResources(t,n,o){const s=qt();return typeof t=="function"&&(o=t,t=void 0),typeof n=="function"&&(o=n,n=void 0),t||(t=this.languages),n||(n=this.options.ns),o||(o=wn),this.services.backendConnector.reload(t,n,r=>{s.resolve(),o(r)}),s}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&ic.addPostProcessor(t),t.type==="formatter"&&(this.modules.formatter=t),t.type==="3rdParty"&&this.modules.external.push(t),this}setResolvedLanguage(t){if(!(!t||!this.languages)&&!["cimode","dev"].includes(t)){for(let n=0;n<this.languages.length;n++){const o=this.languages[n];if(!["cimode","dev"].includes(o)&&this.store.hasLanguageSomeTranslations(o)){this.resolvedLanguage=o;break}}!this.resolvedLanguage&&!this.languages.includes(t)&&this.store.hasLanguageSomeTranslations(t)&&(this.resolvedLanguage=t,this.languages.unshift(t))}}changeLanguage(t,n){this.isLanguageChangingTo=t;const o=qt();this.emit("languageChanging",t);const s=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},r=(l,c)=>{c?this.isLanguageChangingTo===t&&(s(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,o.resolve((...i)=>this.t(...i)),n&&n(l,(...i)=>this.t(...i))},a=l=>{!t&&!l&&this.services.languageDetector&&(l=[]);const c=_(l)?l:l&&l[0],i=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(_(l)?[l]:l);i&&(this.language||s(i),this.translator.language||this.translator.changeLanguage(i),this.services.languageDetector?.cacheUserLanguage?.(i)),this.loadResources(i,d=>{r(d,i)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(t),o}getFixedT(t,n,o,s){const r=s?.scopeNs,a=(l,c,...i)=>{let d;typeof c!="object"?d=this.options.overloadTranslationOptionHandler([l,c].concat(i)):d={...c},d.lng=d.lng||a.lng,d.lngs=d.lngs||a.lngs;const h=d.ns!==void 0&&d.ns!==null;d.ns=d.ns||a.ns,d.keyPrefix!==""&&(d.keyPrefix=d.keyPrefix||o||a.keyPrefix);const u={...this.options,...d};Array.isArray(r)&&!h&&(u.ns=r),typeof d.keyPrefix=="function"&&(d.keyPrefix=Ot(d.keyPrefix,u));const p=this.options.keySeparator||".";let f;return d.keyPrefix&&Array.isArray(l)?f=l.map(m=>(typeof m=="function"&&(m=Ot(m,u)),`${d.keyPrefix}${p}${m}`)):(typeof l=="function"&&(l=Ot(l,u)),f=d.keyPrefix?`${d.keyPrefix}${p}${l}`:l),this.t(f,d)};return _(t)?a.lng=t:a.lngs=t,a.ns=n,a.keyPrefix=o,a}t(...t){return this.translator?.translate(...t)}exists(...t){return this.translator?.exists(...t)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const o=n.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,r=this.languages[this.languages.length-1];if(o.toLowerCase()==="cimode")return!0;const a=(l,c)=>{const i=this.services.backendConnector.state[`${l}|${c}`];return i===-1||i===0||i===2};if(n.precheck){const l=n.precheck(this,a);if(l!==void 0)return l}return!!(this.hasResourceBundle(o,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(o,t)&&(!s||a(r,t)))}loadNamespaces(t,n){const o=qt();return this.options.ns?(_(t)&&(t=[t]),t.forEach(s=>{this.options.ns.includes(s)||this.options.ns.push(s)}),this.loadResources(s=>{o.resolve(),n&&n(s)}),o):(n&&n(),Promise.resolve())}loadLanguages(t,n){const o=qt();_(t)&&(t=[t]);const s=this.options.preload||[],r=t.filter(a=>!s.includes(a)&&this.services.languageUtils.isSupportedCode(a));return r.length?(this.options.preload=s.concat(r),this.loadResources(a=>{o.resolve(),n&&n(a)}),o):(n&&n(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!t)return"rtl";try{const s=new Intl.Locale(t);if(s&&s.getTextInfo){const r=s.getTextInfo();if(r&&r.direction)return r.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],o=this.services?.languageUtils||new da(Co());return t.toLowerCase().indexOf("-latn")>1?"ltr":n.includes(o.getLanguagePartFromCode(t))||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(t={},n){const o=new Jt(t,n);return o.createInstance=Jt.createInstance,o}cloneInstance(t={},n=wn){const o=t.forkResourceStore;o&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},r=new Jt(s);if((t.debug!==void 0||t.prefix!==void 0)&&(r.logger=r.logger.clone(t)),["store","services","language"].forEach(l=>{r[l]=this[l]}),r.services={...this.services},r.services.utils={hasLoadedNamespace:r.hasLoadedNamespace.bind(r)},o){const l=Object.keys(this.store.data).reduce((c,i)=>(c[i]={...this.store.data[i]},c[i]=Object.keys(c[i]).reduce((d,h)=>(d[h]={...c[i][h]},d),c[i]),c),{});r.store=new ca(l,s),r.services.resourceStore=r.store}if(t.interpolation){const c={...Co().interpolation,...this.options.interpolation,...t.interpolation},i={...s,interpolation:c};r.services.interpolator=new fa(i)}return r.translator=new Wn(r.services,s),r.translator.on("*",(l,...c)=>{r.emit(l,...c)}),r.init(s,n),r.translator.options=s,r.translator.backendConnector.services.utils={hasLoadedNamespace:r.hasLoadedNamespace.bind(r)},r}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const ge=Jt.createInstance();ge.createInstance;ge.dir;ge.init;ge.loadResources;ge.reloadResources;ge.use;ge.changeLanguage;ge.getFixedT;ge.t;ge.exists;ge.setDefaultNamespace;ge.hasLoadedNamespace;ge.loadNamespaces;ge.loadLanguages;let cc=ge;function Qu(e){cc=e}function eh(){const e=cc.language;return e&&!e.startsWith("zh")?"en-US":"zh-CN"}function fe(e){return e[eh()]}const th={object:e=>`${e} 必须是对象`,noOption:(e,t)=>`${e} 没有配置项 ${t}`,oneOf:(e,t)=>`${e} 必须是 ${t.join("、")} 之一`,label:e=>`${e} 必须是不超过 20 字的文本`,confirm:e=>`${e} 必须是不超过 120 字的文本`,maxObjects:(e,t)=>`${e} 必须是 1 到 ${t} 的整数`,list:(e,t)=>`${e} 必须是不超过 ${t} 项的列表`,hitNeeds:e=>`${e} 要给出 { selection: 筛选 } 或 { set: 筛选 }:按钮没有点到的对象`,targetsShape:e=>`${e} 只能是 hit、{ selection } 或 { set }`,targetsNotFilter:(e,t,n)=>`${e} 不是页面上的${t==="set"?"对象集合":"选中对象"}筛选:${n}`,targetsOtherType:e=>`${e} 里的对象和行动作用的对象不是同一类`,paramNot:(e,t)=>`${e} 不是行动「${t}」要填的参数`,paramNoSource:(e,t)=>`${e} 没有给出来源:行动「${t}」要求填写它`,fromShape:e=>`${e} 必须是 { from, ... }`,notPageFilter:(e,t)=>`${e} 不是页面筛选:${t}`,constValue:e=>`${e} 必须是文本、数字或真假`,fromOneOf:e=>`${e} 只能是 input、var 或 const`,actionRequired:e=>`${e} 必填:知识网络里的行动`,needSource:e=>`${e} 需要先选好数据源`,notObjects:e=>`${e} 查询结果和事件不是网络里的对象,不能执行行动`,notAction:(e,t)=>`${e} 不是知识网络里的行动:${t}`,actionObject:(e,t,n,o)=>`${e} 行动「${t}」作用于 ${n??(o||"未绑定的对象")},和数据源的对象类不同`},nh={object:e=>`${e} must be an object`,noOption:(e,t)=>`${e} has no option ${t}`,oneOf:(e,t)=>`${e} must be one of ${t.join(", ")}`,label:e=>`${e} must be text of at most 20 characters`,confirm:e=>`${e} must be text of at most 120 characters`,maxObjects:(e,t)=>`${e} must be an integer from 1 to ${t}`,list:(e,t)=>`${e} must be a list of at most ${t} items`,hitNeeds:e=>`${e} must give { selection: filter } or { set: filter }: a button has no clicked objects`,targetsShape:e=>`${e} must be hit, { selection } or { set }`,targetsNotFilter:(e,t,n)=>`${e} is not ${t==="set"?"an object set":"a selected object"} filter of the page: ${n}`,targetsOtherType:e=>`${e} holds objects of another type than the ones the action works on`,paramNot:(e,t)=>`${e} is not a parameter of action "${t}"`,paramNoSource:(e,t)=>`${e} has no source: action "${t}" requires it`,fromShape:e=>`${e} must be { from, ... }`,notPageFilter:(e,t)=>`${e} is not a page filter: ${t}`,constValue:e=>`${e} must be text, a number or a boolean`,fromOneOf:e=>`${e} must be input, var or const`,actionRequired:e=>`${e} is required: an action of the knowledge network`,needSource:e=>`${e} needs a source to be chosen first`,notObjects:e=>`${e} query results and events are not objects of the network, so no action can run on them`,notAction:(e,t)=>`${e} is not an action of the knowledge network: ${t}`,actionObject:(e,t,n,o)=>`${e} action "${t}" acts on ${n??(o||"an unbound object")}, which is not the object type of the source`},Cr=()=>fe({"zh-CN":th,"en-US":nh}),Fs=100;function ln(e,t){return e.actionTypes?.find(n=>n.id===t)}function Kn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function oh(e,t,n,o,s){const r=Cr();if(e===void 0||e==="hit")return t?[]:[r.hitNeeds(s)];if(!Kn(e))return[r.targetsShape(s)];const a="selection"in e?"selection":"set"in e?"set":null,l=a?e[a]:void 0;if(!a||typeof l!="string"||Object.keys(e).length!==1)return[r.targetsShape(s)];const c=n.variables.find(d=>d.name===l);return!c||c.kind!==a?[r.targetsNotFilter(`${s}.${a}`,a,l)]:("source"in c?ue(n,c.source)?.objectType:void 0)===o?[]:[r.targetsOtherType(`${s}.${a}`)]}function sh(e,t,n,o){const s=Cr();if(e!==void 0&&!Kn(e))return[s.object(o)];const r=e??{},a=new Set(t.inputs.map(c=>c.name)),l=Object.keys(r).filter(c=>!a.has(c)).map(c=>s.paramNot(`${o}.${c}`,t.name));for(const c of t.inputs){const i=r[c.name],d=`${o}.${c.name}`;if(i===void 0){c.property||l.push(s.paramNoSource(d,t.name));continue}if(!Kn(i)){l.push(s.fromShape(d));continue}i.from==="input"?i.label!==void 0&&(typeof i.label!="string"||i.label.length>20)&&l.push(s.label(`${d}.label`)):i.from==="var"?n.variables.some(h=>h.name===i.variable)||l.push(s.notPageFilter(`${d}.variable`,String(i.variable))):i.from==="const"?["string","number","boolean"].includes(typeof i.value)||l.push(s.constValue(`${d}.value`)):l.push(s.fromOneOf(`${d}.from`))}return l}function dc(e,t,n,o,s){const r=Cr();if(!Kn(e))return[r.object(s)];const a=new Set(["on","action","label","targets","params","confirm","maxObjects"]),l=Object.keys(e).filter(h=>!a.has(h)).map(h=>r.noOption(s,h));if(t.on.includes(e.on)||l.push(r.oneOf(`${s}.on`,t.on)),e.label!==void 0&&(typeof e.label!="string"||e.label.length>20)&&l.push(r.label(`${s}.label`)),e.confirm!==void 0&&(typeof e.confirm!="string"||e.confirm.length>120)&&l.push(r.confirm(`${s}.confirm`)),e.maxObjects!==void 0&&(typeof e.maxObjects!="number"||!Number.isInteger(e.maxObjects)||e.maxObjects<1||e.maxObjects>Fs)&&l.push(r.maxObjects(`${s}.maxObjects`,Fs)),typeof e.action!="string"||!e.action)return l.push(r.actionRequired(`${s}.action`)),l;const c=ue(n.spec,o);if(!c)return[...l,r.needSource(s)];const i=n.spec.sources.find(h=>h.id===(c.from?.source??c.id));if(c.cypher||i?.cypher||c.events)return[...l,r.notObjects(s)];if(!n.kn.actionTypes)return l;const d=ln(n.kn,e.action);return d?(d.objectType!==c.objectType&&l.push(r.actionObject(`${s}.action`,d.name,n.kn.objectTypes[d.objectType]?.name,d.objectType)),l.push(...oh(e.targets,t.hit,n.spec,c.objectType,`${s}.targets`)),l.push(...sh(e.params,d,n.spec,`${s}.params`)),l):[...l,r.notAction(`${s}.action`,e.action)]}const Ds=["workbench","dashboard","detail","free"],uc={workbench:["side","main","aside"],dashboard:["header","grid"],detail:["header","main","aside"],free:["cells"]},At=12,Ve=["asOfSlider","dateRange","metricCards","segmentedFilter","dropdownFilter","searchBox","text","objectTable","objectList","pivotTable","trendChart","regionMap","ganttChart","scheduleGantt","stageChain","subgraph","agentChat","alertList","eventList","eventReport","taskInbox","actionButton","scenarioBar","modelTrial"],Nr=new Set(["taskInbox"]),rh=/^x-[a-z0-9-]+\.[A-Za-z][A-Za-z0-9]*$/,Rt=e=>typeof e=="string"&&rh.test(e),hc={asOfSlider:[4,2],dateRange:[3,2],metricCards:[4,3],segmentedFilter:[3,2],dropdownFilter:[3,2],searchBox:[3,2],text:[2,2],objectTable:[4,6],objectList:[3,5],pivotTable:[3,5],trendChart:[4,5],regionMap:[3,6],ganttChart:[4,5],scheduleGantt:[6,7],stageChain:[3,3],subgraph:[3,6],agentChat:[3,7],alertList:[3,5],eventList:[4,5],eventReport:[2,2],taskInbox:[4,5],actionButton:[2,2],scenarioBar:[4,2],modelTrial:[6,7]},ah=8,ih=5,me="objectDetail",xr=12,Bs=["none","subtle","strong"],Us=["compact","comfortable"],_t=["card","plain"],Pt=["neutral","info","success","warning","danger"],he="$asOf",Yn=["isSet","isEmpty","eq","ne","in","before","onOrBefore","after","onOrAfter","gt","gte","lt","lte"],Zt=["classify","days","formula","related","region","text","matched"],ya=["china","world"],zs=["count","sum","avg","min","max","one","list"],le={status:"$status",stage:"$stage",overdueDays:"$overdueDays",dueInDays:"$dueInDays"},re={done:{value:"done",label:"已完成",tone:"success"},overdue:{value:"overdue",label:"已超期",tone:"danger"},active:{value:"active",label:"进行中",tone:"info"}},Ws=6,ba=4,cn="$scenarioMark",Ln={edited:{value:"edited",label:"改动",tone:"warning"},followed:{value:"followed",label:"联动",tone:"info"},related:{value:"related",label:"相关",tone:"neutral"}},Ks=["shiftDays","add","set","fromAsOf"],Ys=["scenario","user"],Gn=["asOf","value","dateRange","search","selection","set"],wa=["value","dateRange","search","set"],lh=["P1","P2","P3","P4"],Gs=["text","number","date"],Hs=["none","property","batch"],ka=/(^|_)(id|key|code|no)$/i,ch=/(主键|编号|编码|单号|单据号|代码|\bID\b|\bNo\.?$)/i;function va(e,t){const n=e.filter(o=>o.type==="text"&&!t?.primaryKeys.includes(o.name));return n.find(o=>o.name!==t?.displayKey&&!ka.test(o.name)&&!ch.test(o.label))??n.find(o=>o.name!==t?.displayKey&&!ka.test(o.name))??n[0]}function No(e,t){const n=t.objectTypes[e.objectType],o=n?.displayKey;return!e.cypher&&o&&n.properties.some(s=>s.name===o)?o:e.key}function ao(e){return e.operation==="tool"?"tool":e.operation==="relation"?"relation":e.kind==="add"?"create":"modify"}const dh=new Set(["date","datetime","timestamp"]),uh=new Set(["integer","unsigned integer","float","decimal","int","long","short","double","bigint","smallint","tinyint","number","numeric","real"]),hh=new Set(["binary","vector","shape","point"]);function ph(e){const t=e.toLowerCase().replace(/\s+/g," ").trim();return dh.has(t)?"date":uh.has(t)?"number":"text"}function fh(e){return e.kind==="matched"?e.field?e.type??"text":"number":e.kind==="related"?e.aggregate==="one"?e.type??"text":e.aggregate==="list"?"text":"number":e.kind==="classify"||e.kind==="region"||e.kind==="text"?"text":"number"}function Rr(e){return{name:e.name,label:e.label,type:fh(e)}}function pc(e){if(!e)return[];const t=[{name:le.status,label:"进度状态",type:"text"},{name:le.stage,label:"当前步骤",type:"text"}];return e.due&&t.push({name:le.overdueDays,label:"超期天数",type:"number"},{name:le.dueInDays,label:"距截止天数",type:"number"}),t}function mh(e){return!!(e.operations?.length||e.follows?.length||e.relatedTo?.length)}const gh={name:cn,label:"方案标记",type:"text"};function pe(e,t){return[...t.objectTypes[e.objectType]?.properties??[],...pc(e.progress),...(e.computed??[]).map(Rr),...mh(e)?[gh]:[]]}const $a="~";function yh(e){return e.startsWith($a)?{id:e.slice($a.length),reversed:!0}:{id:e,reversed:!1}}function io(e,t,n){const o=[];let s=t;for(const r of n){const{id:a,reversed:l}=yh(r),c=e.relations.find(i=>i.id===a);if(!c)return null;if(l){if(c.target!==s)return null;o.push({relation:c,forward:!1,to:c.source})}else if(c.source===s)o.push({relation:c,forward:!0,to:c.target});else if(c.target===s)o.push({relation:c,forward:!1,to:c.source});else return null;s=o[o.length-1].to}return o}function bh(e,t,n){const o=io(e,t,n);return o?[t,...o.map(s=>s.to)].map(s=>e.objectTypes[s]?.name??s).join(" → "):n.join(" → ")}const wh={unknown:(e,t)=>`第 ${e} 个字符“${t}”无法识别`,empty:"公式是空的",unfinished:"公式没写完",unclosed:e=>`第 ${e} 个字符的括号没有闭合`,missing:(e,t)=>`第 ${e} 个字符“${t}”前缺少数字或字段`,extra:(e,t)=>`第 ${e} 个字符“${t}”多余`},kh={unknown:(e,t)=>`character ${e} "${t}" is not recognized`,empty:"the formula is empty",unfinished:"the formula is unfinished",unclosed:e=>`the parenthesis at character ${e} is not closed`,missing:(e,t)=>`a number or field is missing before character ${e} "${t}"`,extra:(e,t)=>`character ${e} "${t}" is unexpected`},fc=()=>fe({"zh-CN":wh,"en-US":kh}),Sa=/(\d+(?:\.\d+)?)|(\$?[A-Za-z_][A-Za-z0-9_]*)|`([^`]+)`|([-+*/()])/y;function vh(e){const t=fc(),n=[];let o=0;for(;o<e.length;){if(/\s/.test(e[o])){o++;continue}Sa.lastIndex=o;const s=Sa.exec(e);if(!s)return t.unknown(o+1,e[o]);const[r,a,l,c]=s;n.push({kind:a!==void 0?"number":l!==void 0||c!==void 0?"name":"op",text:c??r,at:o}),o+=s[0].length}return n}function mc(e){const t=fc(),n=vh(e);if(typeof n=="string")return{ok:!1,error:n};if(n.length===0)return{ok:!1,error:t.empty};let o=0;const s=()=>n[o],r=d=>{throw new Error(d)},a=()=>{let d=l();for(;s()?.text==="+"||s()?.text==="-";)d={type:"binary",op:n[o++].text,left:d,right:l()};return d},l=()=>{let d=c();for(;s()?.text==="*"||s()?.text==="/";)d={type:"binary",op:n[o++].text,left:d,right:c()};return d},c=()=>s()?.text==="-"?(o++,{type:"negate",arg:c()}):i(),i=()=>{const d=n[o++];if(!d)return r(t.unfinished);if(d.kind==="number")return{type:"number",value:Number(d.text)};if(d.kind==="name")return{type:"field",name:d.text};if(d.text==="("){const h=a();return n[o++]?.text!==")"&&r(t.unclosed(d.at+1)),h}return r(t.missing(d.at+1,d.text))};try{const d=a();return o<n.length&&r(t.extra(n[o].at+1,n[o].text)),{ok:!0,node:d}}catch(d){return{ok:!1,error:d.message}}}function Xt(e){switch(e.type){case"number":return[];case"field":return[e.name];case"negate":return Xt(e.arg);case"binary":return[...Xt(e.left),...Xt(e.right)]}}const $h={sep:"、",object:e=>`${e} 必须是对象`,array:e=>`${e} 必须是数组`,valueNotTaken:(e,t,n,o)=>`${e} 的取值「${t}」不是 ${n} 的取值(可选:${o})`,fieldUnusable:(e,t)=>`${e}.field 不是可用的字段:${t}`,opOneOf:(e,t)=>`${e}.op 只能是 ${t}`,valuesList:e=>`${e}.values 必须是非空的文本列表`,refOrValue:(e,t)=>`${e} 要给 ref(字段或 ${t})或 value(值)其中一个`,refUnusable:(e,t)=>`${e}.ref 不是可用的字段:${t}`,needDateField:(e,t)=>`${e}.field 用 ${t} 比较时必须是日期字段`,otherDate:(e,t,n)=>`${e} 用 ${t} 比较时,另一边必须是日期字段、${n} 或 YYYY-MM-DD`,needNumberField:(e,t)=>`${e}.field 用 ${t} 比较时必须是数字字段`,otherNumber:(e,t)=>`${e} 用 ${t} 比较时,另一边必须是数字字段或数字`,textOrNumber:e=>`${e}.value 必须是文本或数字`,conditionList:e=>`${e} 必须是条件列表`,identifier:e=>`${e}.name 必须是字母开头的标识`,nameTaken:(e,t)=>`${e}.name ${t} 与已有属性或计算列重名`,nameReserved:(e,t)=>`${e}.name ${t} 是进度列的保留名`,required:e=>`${e} 必填`,kindOneOf:(e,t)=>`${e}.kind 只能是 ${t}`,cycle:(e,t)=>`${e} 计算列互相引用成环:${t}`,matchedName:(e,t)=>`「${e}」的「${t}」`,matchedCycle:(e,t)=>`${e} 这些匹配字段互相取值,形成了循环,都算不出来:${t}。请让其中一个直接取对方的原始属性,而不是对方的匹配字段。`,dateOrAsOf:(e,t)=>`${e} 必须是日期字段或 ${t}`,exprText:e=>`${e}.expr 必须是公式文本`,exprError:(e,t)=>`${e}.expr ${t}`,exprField:(e,t)=>`${e}.expr 里的 ${t} 不是可用的数字字段`,templateText:e=>`${e}.template 必须是非空文本,用 {字段名} 引用字段`,templateNoField:e=>`${e}.template 至少要用 {字段名} 引用一个字段`,templateField:(e,t)=>`${e}.template 里的 {${t}} 不是可用的字段`,fromText:e=>`${e}.from 必须是文本字段`,scopeOneOf:(e,t)=>`${e}.scope 只能是 ${t}`,relatedCypher:e=>`${e} Cypher 数据源暂不支持关联统计,可以把统计直接写进查询`,pathNeeded:e=>`${e}.path 必须是至少一条关系的路径`,pathUnreachable:(e,t)=>`${e}.path 不是从 ${t} 出发连通的关系路径`,aggregateOneOf:(e,t)=>`${e}.aggregate 只能是 ${t}`,endObjectType:"终点对象类",fieldOfProperty:(e,t)=>`${e}.field 必须是 ${t} 的属性`,typeOfTaken:(e,t)=>`${e}.type 必须是所取属性的类型:${t}`,typeListIsText:e=>`${e}.type 列出的值是文本,不用写 type`,fieldNumberProperty:(e,t)=>`${e}.field 必须是 ${t} 的数字属性`,typeOnlyOne:e=>`${e}.type 只有 one 需要写`,whereFixed:e=>`${e}.where 关联统计的条件只能和固定值比较`,matchedCypher:e=>`${e} Cypher 数据源不支持按字段匹配其他数据源`,otherSource:e=>`${e}.source 必须是另一个数据源`,otherSourceKind:e=>`${e}.source 必须是本应用中读取知识网络对象类的数据源(不能是子集)`,pairsCount:e=>`${e}.pairs 必须是 1 到 4 对字段`,otherProperty:(e,t)=>`${e}.other 必须是 ${t} 的属性`,typeOnlyWithField:e=>`${e}.type 只有取属性(field)时需要写`,valueText:e=>`${e}.value 必须是非空文本`,toneOneOf:(e,t)=>`${e}.tone 只能是 ${t}`},Sh={sep:", ",object:e=>`${e} must be an object`,array:e=>`${e} must be an array`,valueNotTaken:(e,t,n,o)=>`${e} value "${t}" is not a value of ${n} (one of: ${o})`,fieldUnusable:(e,t)=>`${e}.field is not an available field: ${t}`,opOneOf:(e,t)=>`${e}.op must be one of ${t}`,valuesList:e=>`${e}.values must be a non-empty list of text`,refOrValue:(e,t)=>`${e} needs exactly one of ref (a field or ${t}) and value`,refUnusable:(e,t)=>`${e}.ref is not an available field: ${t}`,needDateField:(e,t)=>`${e}.field must be a date field when compared with ${t}`,otherDate:(e,t,n)=>`${e}: when compared with ${t}, the other side must be a date field, ${n} or YYYY-MM-DD`,needNumberField:(e,t)=>`${e}.field must be a number field when compared with ${t}`,otherNumber:(e,t)=>`${e}: when compared with ${t}, the other side must be a number field or a number`,textOrNumber:e=>`${e}.value must be text or a number`,conditionList:e=>`${e} must be a list of conditions`,identifier:e=>`${e}.name must be an identifier starting with a letter`,nameTaken:(e,t)=>`${e}.name ${t} is already used by a property or computed column`,nameReserved:(e,t)=>`${e}.name ${t} is reserved for a progress column`,required:e=>`${e} is required`,kindOneOf:(e,t)=>`${e}.kind must be one of ${t}`,cycle:(e,t)=>`${e} computed columns read each other in a circle: ${t}`,matchedName:(e,t)=>`"${t}" of "${e}"`,matchedCycle:(e,t)=>`${e} these matched fields take values from each other in a circle, so none can be worked out: ${t}. Make one of them take the other source's own property instead of its matched field.`,dateOrAsOf:(e,t)=>`${e} must be a date field or ${t}`,exprText:e=>`${e}.expr must be formula text`,exprError:(e,t)=>`${e}.expr: ${t}`,exprField:(e,t)=>`${t} in ${e}.expr is not an available number field`,templateText:e=>`${e}.template must be non-empty text that refers to fields as {field}`,templateNoField:e=>`${e}.template must refer to at least one field as {field}`,templateField:(e,t)=>`{${t}} in ${e}.template is not an available field`,fromText:e=>`${e}.from must be a text field`,scopeOneOf:(e,t)=>`${e}.scope must be one of ${t}`,relatedCypher:e=>`${e}: a Cypher source does not support related counts yet; write the count into the query`,pathNeeded:e=>`${e}.path must be a path of at least one relation`,pathUnreachable:(e,t)=>`${e}.path is not a connected relation path starting at ${t}`,aggregateOneOf:(e,t)=>`${e}.aggregate must be one of ${t}`,endObjectType:"the end object type",fieldOfProperty:(e,t)=>`${e}.field must be a property of ${t}`,typeOfTaken:(e,t)=>`${e}.type must be the type of the property taken: ${t}`,typeListIsText:e=>`${e}.type: the listed values are text, so type is not needed`,fieldNumberProperty:(e,t)=>`${e}.field must be a number property of ${t}`,typeOnlyOne:e=>`${e}.type is only needed for one`,whereFixed:e=>`${e}.where: conditions of a related count can only compare with fixed values`,matchedCypher:e=>`${e}: a Cypher source does not support matching other sources by field`,otherSource:e=>`${e}.source must be another source`,otherSourceKind:e=>`${e}.source must be a source of this app that reads an object type of the knowledge network (not a subset)`,pairsCount:e=>`${e}.pairs must be 1 to 4 pairs of fields`,otherProperty:(e,t)=>`${e}.other must be a property of ${t}`,typeOnlyWithField:e=>`${e}.type is only needed when taking a property (field)`,valueText:e=>`${e}.value must be non-empty text`,toneOneOf:(e,t)=>`${e}.tone must be one of ${t}`},Je=()=>fe({"zh-CN":$h,"en-US":Sh}),jh=/^[A-Za-z][A-Za-z0-9_]*$/,Ah=/^\d{4}-\d{2}-\d{2}$/,Th=["before","onOrBefore","after","onOrAfter"],Oh=["gt","gte","lt","lte"],gc=()=>[];function ja(e,t,n,o){const s=n(e);if(s.length===0)return[];const r=Je();return t.filter(a=>typeof a=="string"&&!s.includes(a)).map(a=>r.valueNotTaken(o,String(a),e,s.join(r.sep)))}function Eh(e,t,n,o=gc){const s=Je();if(!Ae(e))return[s.object(n)];const r=d=>d===he?"date":t.find(h=>h.name===d)?.type,a=r(e.field);if(!a)return[s.fieldUnusable(n,String(e.field))];if(!Lt(e.op,Yn))return[s.opOneOf(n,Yn.join(s.sep))];const l=e.op;if(l==="isSet"||l==="isEmpty")return[];if(l==="in")return Array.isArray(e.values)&&e.values.length>0&&e.values.every(d=>typeof d=="string")?ja(String(e.field),e.values,o,`${n}.values`):[s.valuesList(n)];const c=e.ref!==void 0;if(c===(e.value!==void 0))return[s.refOrValue(n,he)];const i=c?r(e.ref):void 0;return c&&!i?[s.refUnusable(n,String(e.ref))]:Th.includes(l)?a!=="date"?[s.needDateField(n,l)]:(c?i==="date":typeof e.value=="string"&&Ah.test(e.value))?[]:[s.otherDate(n,l,he)]:Oh.includes(l)?a!=="number"?[s.needNumberField(n,l)]:(c?i==="number":typeof e.value=="number")?[]:[s.otherNumber(n,l)]:c?[]:typeof e.value!="string"&&typeof e.value!="number"?[s.textOrNumber(n)]:ja(String(e.field),[e.value],o,`${n}.value`)}function xe(e,t,n,o=gc){return Array.isArray(e)?e.flatMap((s,r)=>Eh(s,t,`${n}[${r}]`,o)):[Je().conditionList(n)]}function yc(e,t=!1){return n=>{if(t&&n===le.status)return kc.map(s=>s.value);if(n===cn)return Dh.map(s=>s.value);const o=e.find(s=>Ae(s)&&s.name===n&&s.kind==="classify"&&Array.isArray(s.cases)&&Ae(s.otherwise));return o?[...o.cases,o.otherwise].map(s=>Ae(s)?s.value:void 0).filter(s=>typeof s=="string"):[]}}const Vs=e=>(e??[]).flatMap(t=>[t.field,t.ref].filter(n=>typeof n=="string"&&n!==he)),Ch=/\{([^{}]+)\}/g;function bc(e){return[...new Set([...e.matchAll(Ch)].map(t=>t[1].trim()))]}function _r(e){switch(e.kind){case"classify":return e.cases.flatMap(t=>Vs(t.when));case"days":return[e.from,e.to,...Vs(e.when)].filter(t=>t!==he);case"formula":{const t=mc(e.expr);return t.ok?Xt(t.node):[]}case"related":return[];case"matched":return[];case"region":return[e.from];case"text":return bc(e.template)}}function Nh(e){const t=new Set(e.map(r=>r.name)),n=new Set,o=[];let s=[...e];for(;s.length>0;){const r=s.filter(a=>_r(a).every(l=>!t.has(l)||l===a.name||n.has(l)));if(r.length===0)return[...o,...s];for(const a of r)o.push(a),n.add(a.name);s=s.filter(a=>!r.includes(a))}return o}function xh(e){const t=Nh(e),n=new Set(e.map(r=>r.name)),o=new Set,s=[];for(const r of t)_r(r).some(a=>n.has(a)&&!o.has(a))&&s.push(r.name),o.add(r.name);return s}function wc(e){return Array.isArray(e)?e.filter(t=>Ae(t)&&typeof t.name=="string"&&Lt(t.kind,Zt)):[]}function Rh(e){try{return _r(e)??[]}catch{return[]}}const xo=e=>typeof e=="string"&&e!==""?[e]:[];function _h(e){const t=h=>e.find(u=>u.id===h)?.from?.source??h,n=h=>wc(h.computed),o=e.filter(h=>Ae(h)&&!h.from&&n(h).length>0),s=new Map(o.map(h=>[h.id,new Set(n(h).map(u=>u.name))])),r=(h,u)=>`${h}\0${u}`,a=(h,u)=>u.filter(p=>s.get(h)?.has(p)).map(p=>r(h,p)),l=[];for(const h of o)for(const u of n(h)){const p=r(h.id,u.name);let f;if(u.kind==="matched"){const m=t(String(u.source)),g=Array.isArray(u.pairs)?u.pairs.filter(y=>Ae(y)):[];f=[...a(h.id,g.flatMap(y=>xo(y?.field))),...a(m,[...g.flatMap(y=>xo(y?.other)),...xo(u.field),...Vs(Array.isArray(u.where)?u.where.filter(y=>Ae(y)):void 0)])]}else f=a(h.id,Rh(u));l.push({id:p,ref:{source:h.id,field:u},reads:f.filter(m=>m!==p)})}const c=new Set,i=[];let d=l;for(;d.length>0;){const h=d.filter(u=>u.reads.every(p=>c.has(p)));if(h.length===0)break;for(const u of h)i.push(u.ref),c.add(u.id);d=d.filter(u=>!c.has(u.id))}return{order:i,stuck:d.map(h=>h.ref)}}const Ph=new Set([...Object.values(le),cn]);function Lh(e,t,n,o){if(e===void 0)return[];const s=Je();if(!Array.isArray(e))return[s.array(n)];const r=[],a=yc(e,o.progress),l=e.filter(d=>Ae(d)&&typeof d.name=="string"&&Lt(d.kind,Zt)),c=new Set;e.forEach((d,h)=>{const u=`${n}[${h}]`;if(!Ae(d))return r.push(s.object(u));if(typeof d.name!="string"||!jh.test(d.name))return r.push(s.identifier(u));if(t.some(f=>f.name===d.name)||c.has(d.name))return r.push(s.nameTaken(u,d.name));if(Ph.has(d.name)&&o.progress)return r.push(s.nameReserved(u,d.name));if(c.add(d.name),(typeof d.label!="string"||d.label.trim()==="")&&r.push(s.required(`${u}.label`)),!Lt(d.kind,Zt))return r.push(s.kindOneOf(u,Zt.join(s.sep)));const p=l.filter(f=>f.name!==d.name).map(Rr);r.push(...Mh(d,[...t,...p],u,a,o))});const i=xh(l);return i.length>0?r.push(s.cycle(n,i.join(s.sep))):o.sources&&o.source&&r.push(...Ih(n,o)),r}function Ih(e,t){const n=Je(),o=t.sources??[],{stuck:s}=_h(o);if(!s.some(l=>l.source===t.source&&l.field.kind==="matched"))return[];const r=l=>o.find(c=>c.id===l)?.label??l,a=s.map(l=>n.matchedName(r(l.source),l.field.label||l.field.name)).join(n.sep);return[n.matchedCycle(e,a)]}function Mh(e,t,n,o,s){const r=Je(),a=l=>l===he||t.some(c=>c.name===l&&c.type==="date");switch(e.kind){case"classify":{const l=[];return Array.isArray(e.cases)?e.cases.forEach((c,i)=>{const d=`${n}.cases[${i}]`;l.push(...Aa(c,d)),Ae(c)&&l.push(...xe(c.when,t,`${d}.when`,o))}):l.push(r.array(`${n}.cases`)),l.push(...Aa(e.otherwise,`${n}.otherwise`)),l}case"days":return[...a(e.from)?[]:[r.dateOrAsOf(`${n}.from`,he)],...a(e.to)?[]:[r.dateOrAsOf(`${n}.to`,he)],...e.when===void 0?[]:xe(e.when,t,`${n}.when`,o)];case"formula":{if(typeof e.expr!="string")return[r.exprText(n)];const l=mc(e.expr);return l.ok?[...new Set(Xt(l.node))].filter(c=>!t.some(i=>i.name===c&&i.type==="number")).map(c=>r.exprField(n,c)):[r.exprError(n,l.error)]}case"related":return qh(e,n,s);case"matched":return Fh(e,n,s,t);case"text":{if(typeof e.template!="string"||e.template.trim()==="")return[r.templateText(n)];const l=bc(e.template);return l.length===0?[r.templateNoField(n)]:l.filter(c=>!t.some(i=>i.name===c)).map(c=>r.templateField(n,c))}default:return[...t.some(l=>l.name===e.from&&l.type==="text")?[]:[r.fromText(n)],...e.scope===void 0||ya.includes(e.scope)?[]:[r.scopeOneOf(n,ya.join(r.sep))]]}}function qh(e,t,{kn:n,objectType:o,cypher:s}){const r=Je();if(s)return[r.relatedCypher(t)];if(!Array.isArray(e.path)||e.path.length===0)return[r.pathNeeded(t)];const a=io(n,o,e.path);if(!a)return[r.pathUnreachable(t,o)];const l=n.objectTypes[a[a.length-1].to],c=l?.properties??[];if(!Lt(e.aggregate,zs))return[r.aggregateOneOf(t,zs.join(r.sep))];const i=[],d=c.find(h=>h.name===e.field);return e.aggregate==="one"||e.aggregate==="list"?d?e.aggregate==="one"&&e.type!==d.type?i.push(r.typeOfTaken(t,d.type)):e.aggregate==="list"&&e.type!==void 0&&e.type!=="text"&&i.push(r.typeListIsText(t)):i.push(r.fieldOfProperty(t,l?.name??r.endObjectType)):(e.aggregate!=="count"&&d?.type!=="number"&&i.push(r.fieldNumberProperty(t,l?.name??r.endObjectType)),e.type!==void 0&&i.push(r.typeOnlyOne(t))),e.where!==void 0&&(i.push(...xe(e.where,c,`${t}.where`)),Array.isArray(e.where)&&e.where.some(h=>Ae(h)&&(h.ref!==void 0||h.field===he))&&i.push(r.whereFixed(t))),i}function Fh(e,t,{kn:n,objectType:o,cypher:s,sources:r},a){const l=Je();if(s)return[l.matchedCypher(t)];if(typeof e.source!="string"||e.source==="")return[l.otherSource(t)];const c=r?.find(h=>h.id===e.source);if(r&&(!c||c.cypher||c.events||c.model||c.from))return[l.otherSourceKind(t)];const i=c?[...n.objectTypes[c.objectType]?.properties??[],...wc(c.computed).map(Rr)]:void 0,d=[];if(!Array.isArray(e.pairs)||e.pairs.length===0||e.pairs.length>4?d.push(l.pairsCount(t)):e.pairs.forEach((h,u)=>{const p=`${t}.pairs[${u}]`;return Ae(h)?(n.objectTypes[o]?.properties.some(m=>m.name===h.field)||a.some(m=>m.name===h.field)||d.push(l.fieldOfProperty(p,o)),i&&!i.some(m=>m.name===h.other)&&d.push(l.otherProperty(p,c?.objectType??"")),d):d.push(l.object(p))}),e.field!==void 0){const h=i?.find(u=>u.name===e.field);i&&!h?d.push(l.fieldOfProperty(t,c?.objectType??"")):h&&e.type!==h.type&&d.push(l.typeOfTaken(t,h.type))}else e.type!==void 0&&d.push(l.typeOnlyWithField(t));return e.where!==void 0&&i&&d.push(...xe(e.where,i,`${t}.where`)),d}function Aa(e,t){const n=Je();return Ae(e)?[...typeof e.value=="string"&&e.value.trim()!==""?[]:[n.valueText(t)],...e.tone===void 0||Lt(e.tone,Pt)?[]:[n.toneOneOf(t,Pt.join(n.sep))]]:[n.object(t)]}const kc=[re.done,re.overdue,re.active],Dh=[Ln.edited,Ln.followed,Ln.related];function dn(e){return yc(e?.computed??[],!!e?.progress)}function Bh(e){return e?e.progress?!0:JSON.stringify(e.computed??[]).includes(`"${he}"`):!1}const Uh=`计算列(sources[].computed,可选):浏览器为数据源的每行算出的列;组件、筛选像普通属性一样用它们。计算列可以读数据源的属性、进度列和其他计算列,系统按依赖自动排顺序,不能互相引用成环。每项 { name, label, kind, ... },name 为字母开头的标识,不得与属性或进度列重名:
|
|
1
|
+
import{spawnSync as yu,execFile as bu,spawn as wu}from"node:child_process";import{homedir as ku}from"node:os";import{join as G,extname as sc,posix as vu,relative as rc,sep as $u,dirname as Tt,resolve as tt}from"node:path";import{isDeepStrictEqual as Su,parseArgs as ju}from"node:util";import{readFileSync as ct,readdirSync as nn,statSync as Au,existsSync as we,rmSync as ut,mkdirSync as Bn,writeFileSync as ac,rmdirSync as Tu,watch as Ou,cpSync as To,symlinkSync as Eu,lstatSync as ic,readlinkSync as Cu}from"node:fs";import Er from"process";import Nu from"buffer";import{deflateRawSync as xu,inflateRawSync as Ru}from"node:zlib";import{createHash as lc}from"node:crypto";import{request as _u}from"node:http";import{request as Pu}from"node:https";function Mt(e){const t=e?.trim().split(/[.@]/)[0];if(!(!t||t==="C"||t==="POSIX"))return/^zh/i.test(t)?"zh-CN":"en-US"}function oa(e,t=process.env){return Mt(e)??Mt(t.WORKSHOP_LANG)??Mt(t.LC_ALL)??Mt(t.LC_MESSAGES)??Mt(t.LANG)??"zh-CN"}function cc(e,t={}){return e.replace(/\{(\w+)\}/g,(n,o)=>o in t?String(t[o]):n)}let Un=null;function Lu(e){Un=e}function Iu(){return Un}function nt(){if(!Un)throw new Error("No Workshop host is installed: call installWorkshopHost first.");return Un}const st={get:(e,t)=>nt().http.get(e,t),delete:(e,t)=>nt().http.delete(e,t),post:(e,t,n)=>nt().http.post(e,t,n),put:(e,t,n)=>nt().http.put(e,t,n)};function Mu(e,t){if(!t.from)return t;const n=t.from.source;return e.sources.find(o=>o.id===n&&!o.from)}function ue(e,t){const n=e.sources.find(a=>a.id===t);if(!n?.from)return n;const o=Mu(e,n);if(!o)return;const s=sa.get(n);if(s?.base===o)return s.value;const r={...o,id:n.id,label:n.label,from:n.from};return sa.set(n,{base:o,value:r}),r}const sa=new WeakMap,_=e=>typeof e=="string",qt=()=>{let e,t;const n=new Promise((o,s)=>{e=o,t=s});return n.resolve=e,n.reject=t,n},ra=e=>e==null?"":String(e),qu=(e,t,n)=>{e.forEach(o=>{t[o]&&(n[o]=t[o])})},Fu=/###/g,aa=e=>e&&e.includes("###")?e.replace(Fu,"."):e,ia=e=>!e||_(e),Vt=(e,t,n)=>{const o=_(t)?t.split("."):t;let s=0;for(;s<o.length-1;){if(ia(e))return{};const r=aa(o[s]);!e[r]&&n&&(e[r]=new n),Object.prototype.hasOwnProperty.call(e,r)?e=e[r]:e={},++s}return ia(e)?{}:{obj:e,k:aa(o[s])}},la=(e,t,n)=>{const{obj:o,k:s}=Vt(e,t,Object);if(o!==void 0||t.length===1){o[s]=n;return}let r=t[t.length-1],a=t.slice(0,t.length-1),l=Vt(e,a,Object);for(;l.obj===void 0&&a.length;)r=`${a[a.length-1]}.${r}`,a=a.slice(0,a.length-1),l=Vt(e,a,Object),l?.obj&&typeof l.obj[`${l.k}.${r}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${r}`]=n},Du=(e,t,n,o)=>{const{obj:s,k:r}=Vt(e,t,Object);s[r]=s[r]||[],s[r].push(n)},zn=(e,t)=>{const{obj:n,k:o}=Vt(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,o))return n[o]},Bu=(e,t,n)=>{const o=zn(e,n);return o!==void 0?o:zn(t,n)},dc=(e,t,n)=>{for(const o in t)o!=="__proto__"&&o!=="constructor"&&(Object.prototype.hasOwnProperty.call(e,o)?_(e[o])||e[o]instanceof String||_(t[o])||t[o]instanceof String?n&&(e[o]=t[o]):dc(e[o],t[o],n):e[o]=t[o]);return e},Ke=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),Uu={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},zu=e=>_(e)?e.replace(/[&<>"'\/]/g,t=>Uu[t]):e;class Wu{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(t){const n=this.regExpMap.get(t);if(n!==void 0)return n;const o=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,o),this.regExpQueue.push(t),o}}const Ku=[" ",",","?","!",";"],Yu=new Wu(20),Gu=(e,t,n)=>{t=t||"",n=n||"";const o=Ku.filter(a=>!t.includes(a)&&!n.includes(a));if(o.length===0)return!0;const s=Yu.getRegExp(`(${o.map(a=>a==="?"?"\\?":a).join("|")})`);let r=!s.test(e);if(!r){const a=e.indexOf(n);a>0&&!s.test(e.substring(0,a))&&(r=!0)}return r},qs=(e,t,n=".")=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;const o=t.split(n);let s=e;for(let r=0;r<o.length;){if(!s||typeof s!="object")return;let a,l="";for(let c=r;c<o.length;++c)if(c!==r&&(l+=n),l+=o[c],a=s[l],a!==void 0){if(["string","number","boolean"].includes(typeof a)&&c<o.length-1)continue;r+=c-r+1;break}s=a}return s},on=e=>e?.replace(/_/g,"-"),Hu={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console?.[e]?.apply?.(console,t)}};class Wn{constructor(t,n={}){this.init(t,n)}init(t,n={}){this.prefix=n.prefix||"i18next:",this.logger=t||Hu,this.options=n,this.debug=n.debug}log(...t){return this.forward(t,"log","",!0)}warn(...t){return this.forward(t,"warn","",!0)}error(...t){return this.forward(t,"error","")}deprecate(...t){return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}forward(t,n,o,s){return s&&!this.debug?null:(t=t.map(r=>_(r)?r.replace(/[\r\n\x00-\x1F\x7F]/g," "):r),_(t[0])&&(t[0]=`${o}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new Wn(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new Wn(this.logger,t)}}var Be=new Wn;class ao{constructor(){this.observers={}}on(t,n){return t.split(" ").forEach(o=>{this.observers[o]||(this.observers[o]=new Map);const s=this.observers[o].get(n)||0;this.observers[o].set(n,s+1)}),this}off(t,n){if(this.observers[t]){if(!n){delete this.observers[t];return}this.observers[t].delete(n)}}once(t,n){const o=(...s)=>{n(...s),this.off(t,o)};return this.on(t,o),this}emit(t,...n){this.observers[t]&&Array.from(this.observers[t].entries()).forEach(([s,r])=>{for(let a=0;a<r;a++)s(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([s,r])=>{for(let a=0;a<r;a++)s(t,...n)})}}class ca extends ao{constructor(t,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=t||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.includes(t)||this.options.ns.push(t)}removeNamespaces(t){const n=this.options.ns.indexOf(t);n>-1&&this.options.ns.splice(n,1)}getResource(t,n,o,s={}){const r=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,a=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;t.includes(".")?l=t.split("."):(l=[t,n],o&&(Array.isArray(o)?l.push(...o):_(o)&&r?l.push(...o.split(r)):l.push(o)));const c=zn(this.data,l);return!c&&!n&&!o&&t.includes(".")&&(t=l[0],n=l[1],o=l.slice(2).join(".")),c||!a||!_(o)?c:qs(this.data?.[t]?.[n],o,r)}addResource(t,n,o,s,r={silent:!1}){const a=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator;let l=[t,n];o&&(l=l.concat(a?o.split(a):o)),t.includes(".")&&(l=t.split("."),s=n,n=l[1]),this.addNamespaces(n),la(this.data,l,s),r.silent||this.emit("added",t,n,o,s)}addResources(t,n,o,s={silent:!1}){for(const r in o)(_(o[r])||Array.isArray(o[r]))&&this.addResource(t,n,r,o[r],{silent:!0});s.silent||this.emit("added",t,n,o)}addResourceBundle(t,n,o,s,r,a={silent:!1,skipCopy:!1}){let l=[t,n];t.includes(".")&&(l=t.split("."),s=o,o=n,n=l[1]),this.addNamespaces(n);let c=zn(this.data,l)||{};a.skipCopy||(o=JSON.parse(JSON.stringify(o))),s?dc(c,o,r):c={...c,...o},la(this.data,l,c),a.silent||this.emit("added",t,n,o)}removeResourceBundle(t,n){this.hasResourceBundle(t,n)&&delete this.data[t][n],this.removeNamespaces(n),this.emit("removed",t,n)}hasResourceBundle(t,n){return this.getResource(t,n)!==void 0}getResourceBundle(t,n){return n||(n=this.options.defaultNS),this.getResource(t,n)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const n=this.getDataByLanguage(t);return!!(n&&Object.keys(n)||[]).find(s=>n[s]&&Object.keys(n[s]).length>0)}toJSON(){return this.data}}var uc={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,o,s){return e.forEach(r=>{t=this.processors[r]?.process(t,n,o,s)??t}),t}};const hc=Symbol("i18next/PATH_KEY");function Vu(){const e=[],t=Object.create(null);let n;return t.get=(o,s)=>(n?.revoke?.(),s===hc?e:(e.push(s),n=Proxy.revocable(o,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function Ot(e,t){const{[hc]:n}=e(Vu()),o=t?.keySeparator??".",s=t?.nsSeparator??":",r=t?.enableSelector==="strict";if(n.length>1&&s){const a=t?.ns,l=r?Array.isArray(a)?a:a?[a]:null:Array.isArray(a)?a:null;if(l&&(r?l:l.length>1?l.slice(1):[]).includes(n[0]))return`${n[0]}${s}${n.slice(1).join(o)}`}return n.join(o)}const Oo=e=>!_(e)&&typeof e!="boolean"&&typeof e!="number";class Kn extends ao{constructor(t,n={}){super(),qu(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Be.create("translator"),this.checkedLoadedFor={}}changeLanguage(t){t&&(this.language=t)}exists(t,n={interpolation:{}}){const o={...n};if(t==null)return!1;const s=this.resolve(t,o);if(s?.res===void 0)return!1;const r=Oo(s.res);return!(o.returnObjects===!1&&r)}extractFromKey(t,n){let o=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;o===void 0&&(o=":");const s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let r=n.ns||this.options.defaultNS||[];const a=o&&t.includes(o),l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!Gu(t,o,s);if(a&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:_(r)?[r]:r};const i=t.split(o);(o!==s||o===s&&this.options.ns.includes(i[0]))&&(r=i.shift()),t=i.join(s)}return{key:t,namespaces:_(r)?[r]:r}}translate(t,n,o){let s=typeof n=="object"?{...n}:n;if(typeof s!="object"&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),typeof s=="object"&&(s={...s}),s||(s={}),t==null)return"";typeof t=="function"&&(t=Ot(t,{...this.options,...s})),Array.isArray(t)||(t=[String(t)]),t=t.map(I=>typeof I=="function"?Ot(I,{...this.options,...s}):String(I));const r=s.returnDetails!==void 0?s.returnDetails:this.options.returnDetails,a=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,{key:l,namespaces:c}=this.extractFromKey(t[t.length-1],s),i=c[c.length-1];let d=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;d===void 0&&(d=":");const h=s.lng||this.language,u=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(h?.toLowerCase()==="cimode")return u?r?{res:`${i}${d}${l}`,usedKey:l,exactUsedKey:l,usedLng:h,usedNS:i,usedParams:this.getUsedParamsDetails(s)}:`${i}${d}${l}`:r?{res:l,usedKey:l,exactUsedKey:l,usedLng:h,usedNS:i,usedParams:this.getUsedParamsDetails(s)}:l;const p=this.resolve(t,s);let f=p?.res;const m=p?.usedKey||l,g=p?.exactUsedKey||l,y=["[object Number]","[object Function]","[object RegExp]"],b=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,k=!this.i18nFormat||this.i18nFormat.handleAsObject,w=s.count!==void 0&&!_(s.count),v=Kn.hasDefaultValue(s),S=w?this.pluralResolver.getSuffix(h,s.count,s):"",j=s.ordinal&&w?this.pluralResolver.getSuffix(h,s.count,{ordinal:!1}):"",O=w&&!s.ordinal&&s.count===0,A=O&&s[`defaultValue${this.options.pluralSeparator}zero`]||s[`defaultValue${S}`]||s[`defaultValue${j}`]||s.defaultValue;let E=f;k&&!f&&v&&(E=A);const x=Oo(E),L=Object.prototype.toString.apply(E);if(k&&E&&x&&!y.includes(L)&&!(_(b)&&Array.isArray(E))){if(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const I=this.options.returnedObjectHandler?this.options.returnedObjectHandler(m,E,{...s,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return r?(p.res=I,p.usedParams=this.getUsedParamsDetails(s),p):I}if(a){const I=Array.isArray(E),M=I?[]:{},ne=I?g:m;for(const q in E)if(Object.prototype.hasOwnProperty.call(E,q)){const N=`${ne}${a}${q}`;v&&!f?M[q]=this.translate(N,{...s,defaultValue:Oo(A)?A[q]:void 0,joinArrays:!1,ns:c}):M[q]=this.translate(N,{...s,joinArrays:!1,ns:c}),M[q]===N&&(M[q]=E[q])}f=M}}else if(k&&_(b)&&Array.isArray(f))f=f.join(b),f&&(f=this.extendTranslation(f,t,s,o));else{let I=!1,M=!1;!this.isValidLookup(f)&&v&&(I=!0,f=A),this.isValidLookup(f)||(M=!0,f=l);const q=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&M?void 0:f,N=v&&A!==f&&this.options.updateMissing;if(M||I||N){if(this.logger.log(N?"updateKey":"missingKey",h,i,w&&!N?`${l}${this.pluralResolver.getSuffix(h,s.count,s)}`:l,N?A:f),a){const $=this.resolve(l,{...s,keySeparator:!1});$&&$.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let Z=[];const U=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&U&&U[0])for(let $=0;$<U.length;$++)Z.push(U[$]);else this.options.saveMissingTo==="all"?Z=this.languageUtils.toResolveHierarchy(s.lng||this.language):Z.push(s.lng||this.language);const oe=($,T,C)=>{const R=v&&C!==f?C:q;this.options.missingKeyHandler?this.options.missingKeyHandler($,i,T,R,N,s):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing($,i,T,R,N,s),this.emit("missingKey",$,i,T,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&w?Z.forEach($=>{const T=this.pluralResolver.getSuffixes($,s);O&&s[`defaultValue${this.options.pluralSeparator}zero`]&&!T.includes(`${this.options.pluralSeparator}zero`)&&T.push(`${this.options.pluralSeparator}zero`),T.forEach(C=>{oe([$],l+C,s[`defaultValue${C}`]||A)})}):oe(Z,l,A))}f=this.extendTranslation(f,t,s,p,o),M&&f===l&&this.options.appendNamespaceToMissingKey&&(f=`${i}${d}${l}`),(M||I)&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${i}${d}${l}`:l,I?f:void 0,s))}return r?(p.res=f,p.usedParams=this.getUsedParamsDetails(s),p):f}extendTranslation(t,n,o,s,r){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...o},o.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!o.skipInterpolation){o.interpolation&&this.interpolator.init({...o,interpolation:{...this.options.interpolation,...o.interpolation}});const c=_(t)&&(o?.interpolation?.skipOnVariables!==void 0?o.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let i;if(c){const h=t.match(this.interpolator.nestingRegexp);i=h&&h.length}let d=o.replace&&!_(o.replace)?o.replace:o;if(this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),t=this.interpolator.interpolate(t,d,o.lng||this.language||s.usedLng,o),c){const h=t.match(this.interpolator.nestingRegexp),u=h&&h.length;i<u&&(o.nest=!1)}!o.lng&&s&&s.res&&(o.lng=this.language||s.usedLng),o.nest!==!1&&(t=this.interpolator.nest(t,(...h)=>r?.[0]===h[0]&&!o.context?(this.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):this.translate(...h,n),o)),o.interpolation&&this.interpolator.reset()}const a=o.postProcess||this.options.postProcess,l=_(a)?[a]:a;return t!=null&&l?.length&&o.applyPostProcessor!==!1&&(t=uc.handle(l,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...s,usedParams:this.getUsedParamsDetails(o)},...o}:o,this)),t}resolve(t,n={}){let o,s,r,a,l;return _(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(c=>typeof c=="function"?Ot(c,{...this.options,...n}):c)),t.forEach(c=>{if(this.isValidLookup(o))return;const i=this.extractFromKey(c,n),d=i.key;s=d;let h=i.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));const u=n.count!==void 0&&!_(n.count),p=u&&!n.ordinal&&n.count===0,f=n.context!==void 0&&(_(n.context)||typeof n.context=="number")&&n.context!=="",m=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);h.forEach(g=>{this.isValidLookup(o)||(l=g,!this.checkedLoadedFor[`${m[0]}-${g}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(this.checkedLoadedFor[`${m[0]}-${g}`]=!0,this.logger.warn(`key "${s}" for languages "${m.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),m.forEach(y=>{if(this.isValidLookup(o))return;a=y;const b=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(b,d,y,g,n);else{let w;u&&(w=this.pluralResolver.getSuffix(y,n.count,n));const v=`${this.options.pluralSeparator}zero`,S=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(n.ordinal&&w.startsWith(S)&&b.push(d+w.replace(S,this.options.pluralSeparator)),b.push(d+w),p&&b.push(d+v)),f){const j=`${d}${this.options.contextSeparator||"_"}${n.context}`;b.push(j),u&&(n.ordinal&&w.startsWith(S)&&b.push(j+w.replace(S,this.options.pluralSeparator)),b.push(j+w),p&&b.push(j+v))}}let k;for(;k=b.pop();)this.isValidLookup(o)||(r=k,o=this.getResource(y,g,k,n))}))})}),{res:o,usedKey:s,exactUsedKey:r,usedLng:a,usedNS:l}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,n,o,s={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(t,n,o,s):this.resourceStore.getResource(t,n,o,s)}getUsedParamsDetails(t={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],o=t.replace&&!_(t.replace);let s=o?t.replace:t;if(o&&typeof t.count<"u"&&(s.count=t.count),this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),!o){s={...s};for(const r of n)delete s[r]}return s}static hasDefaultValue(t){const n="defaultValue";for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&o.startsWith(n)&&t[o]!==void 0)return!0;return!1}}class da{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Be.create("languageUtils")}getScriptPartFromCode(t){if(t=on(t),!t||!t.includes("-"))return null;const n=t.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(t){if(t=on(t),!t||!t.includes("-"))return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(_(t)&&t.includes("-")){let n;try{n=Intl.getCanonicalLocales(t)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?t.toLowerCase():t)}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(t)}getBestMatchFromCodes(t){if(!t)return null;let n;return t.forEach(o=>{if(n)return;const s=this.formatLanguageCode(o);(!this.options.supportedLngs||this.isSupportedCode(s))&&(n=s)}),!n&&this.options.supportedLngs&&t.forEach(o=>{if(n)return;const s=this.getScriptPartFromCode(o);if(this.isSupportedCode(s))return n=s;const r=this.getLanguagePartFromCode(o);if(this.isSupportedCode(r))return n=r;n=this.options.supportedLngs.find(a=>a===r?!0:!a.includes("-")&&!r.includes("-")?!1:!!(a.includes("-")&&!r.includes("-")&&a.slice(0,a.indexOf("-"))===r||a.startsWith(r)&&r.length>1))}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),_(t)&&(t=[t]),Array.isArray(t))return t;if(!n)return t.default||[];let o=t[n];return o||(o=t[this.getScriptPartFromCode(n)]),o||(o=t[this.formatLanguageCode(n)]),o||(o=t[this.getLanguagePartFromCode(n)]),o||(o=t.default),o||[]}toResolveHierarchy(t,n){const o=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],t),s=[],r=a=>{a&&(this.isSupportedCode(a)?s.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return _(t)&&(t.includes("-")||t.includes("_"))?(this.options.load!=="languageOnly"&&r(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&r(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&r(this.getLanguagePartFromCode(t))):_(t)&&r(this.formatLanguageCode(t)),o.forEach(a=>{s.includes(a)||r(this.formatLanguageCode(a))}),s}}const ua={zero:0,one:1,two:2,few:3,many:4,other:5},ha={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Ju{constructor(t,n={}){this.languageUtils=t,this.options=n,this.logger=Be.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(t,n={}){const o=on(t==="dev"?"en":t),s=n.ordinal?"ordinal":"cardinal",r=JSON.stringify({cleanedCode:o,type:s});if(r in this.pluralRulesCache)return this.pluralRulesCache[r];let a;try{a=new Intl.PluralRules(o,{type:s})}catch{if(typeof Intl>"u")return this.logger.error("No Intl support, please use an Intl polyfill!"),ha;if(!t.match(/-|_/))return ha;const c=this.languageUtils.getLanguagePartFromCode(t);a=this.getRule(c,n)}return this.pluralRulesCache[r]=a,a}needsPlural(t,n={}){let o=this.getRule(t,n);return o||(o=this.getRule("dev",n)),o?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(t,n,o={}){return this.getSuffixes(t,o).map(s=>`${n}${s}`)}getSuffixes(t,n={}){let o=this.getRule(t,n);return o||(o=this.getRule("dev",n)),o?o.resolvedOptions().pluralCategories.sort((s,r)=>ua[s]-ua[r]).map(s=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${s}`):[]}getSuffix(t,n,o={}){const s=this.getRule(t,o);return s?`${this.options.prepend}${o.ordinal?`ordinal${this.options.prepend}`:""}${s.select(n)}`:(this.logger.warn(`no plural rule found for: ${t}`),this.getSuffix("dev",n,o))}}const pa=(e,t,n,o=".",s=!0)=>{let r=Bu(e,t,n);return!r&&s&&_(n)&&(r=qs(e,n,o),r===void 0&&(r=qs(t,n,o))),r},Eo=e=>e.replace(/\$/g,"$$$$");class fa{constructor(t={}){this.logger=Be.create("interpolator"),this.options=t,this.format=t?.interpolation?.format||(n=>n),this.init(t)}init(t={}){t.interpolation||(t.interpolation={escapeValue:!0});const{escape:n,escapeValue:o,useRawValueToEscape:s,prefix:r,prefixEscaped:a,suffix:l,suffixEscaped:c,formatSeparator:i,unescapeSuffix:d,unescapePrefix:h,nestingPrefix:u,nestingPrefixEscaped:p,nestingSuffix:f,nestingSuffixEscaped:m,nestingOptionsSeparator:g,maxReplaces:y,alwaysFormat:b}=t.interpolation;this.escape=n!==void 0?n:zu,this.escapeValue=o!==void 0?o:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=r?Ke(r):a||"{{",this.suffix=l?Ke(l):c||"}}",this.formatSeparator=i||",",this.unescapePrefix=d?"":h?Ke(h):"-",this.unescapeSuffix=this.unescapePrefix?"":d?Ke(d):"",this.nestingPrefix=u?Ke(u):p||Ke("$t("),this.nestingSuffix=f?Ke(f):m||Ke(")"),this.nestingOptionsSeparator=g||",",this.maxReplaces=y||1e3,this.alwaysFormat=b!==void 0?b:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(n,o)=>n?.source===o?(n.lastIndex=0,n):new RegExp(o,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(t,n,o,s){let r,a,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},i=p=>{if(!p.includes(this.formatSeparator)){const y=pa(n,c,p,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(y,void 0,o,{...s,...n,interpolationkey:p}):y}const f=p.split(this.formatSeparator),m=f.shift().trim(),g=f.join(this.formatSeparator).trim();return this.format(pa(n,c,m,this.options.keySeparator,this.options.ignoreJSONStructure),g,o,{...s,...n,interpolationkey:m})};this.resetRegExp(),!this.escapeValue&&typeof t=="string"&&/\$t\([^)]*\{[^}]*\{\{/.test(t)&&this.logger.warn("nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.");const d=s?.missingInterpolationHandler||this.options.missingInterpolationHandler,h=s?.interpolation?.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:p=>Eo(p)},{regex:this.regexp,safeValue:p=>this.escapeValue?Eo(this.escape(p)):Eo(p)}].forEach(p=>{for(l=0;r=p.regex.exec(t);){const f=r[1].trim();if(a=i(f),a===void 0)if(typeof d=="function"){const g=d(t,r,s);a=_(g)?g:""}else if(s&&Object.prototype.hasOwnProperty.call(s,f))a="";else if(h){a=r[0];continue}else this.logger.warn(`missed to pass in variable ${f} for interpolating ${t}`),a="";else!_(a)&&!this.useRawValueToEscape&&(a=ra(a));const m=p.safeValue(a);if(t=t.replace(r[0],m),h?(p.regex.lastIndex+=a.length,p.regex.lastIndex-=r[0].length):p.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,n,o={}){let s,r,a;const l=(c,i)=>{const d=this.nestingOptionsSeparator;if(!c.includes(d))return c;const h=c.split(new RegExp(`${Ke(d)}[ ]*{`));let u=`{${h[1]}`;c=h[0],u=this.interpolate(u,a);const p=u.match(/'/g),f=u.match(/"/g);((p?.length??0)%2===0&&!f||(f?.length??0)%2!==0)&&(u=u.replace(/'/g,'"'));try{a=JSON.parse(u),i&&(a={...i,...a})}catch(m){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,m),`${c}${d}${u}`}return a.defaultValue&&a.defaultValue.includes(this.prefix)&&delete a.defaultValue,c};for(;s=this.nestingRegexp.exec(t);){let c=[];a={...o},a=a.replace&&!_(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;const i=/{.*}/.test(s[1])?s[1].lastIndexOf("}")+1:s[1].indexOf(this.formatSeparator);if(i!==-1&&(c=s[1].slice(i).split(this.formatSeparator).map(d=>d.trim()).filter(Boolean),s[1]=s[1].slice(0,i)),r=n(l.call(this,s[1].trim(),a),a),r&&s[0]===t&&!_(r))return r;_(r)||(r=ra(r)),r||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),r=""),c.length&&(r=c.reduce((d,h)=>this.format(d,h,o.lng,{...o,interpolationkey:s[1].trim()}),r.trim())),t=t.replace(s[0],r),this.regexp.lastIndex=0}return t}}const Zu=e=>{let t=e.toLowerCase().trim();const n={};if(e.includes("(")){const o=e.split("(");t=o[0].toLowerCase().trim();const s=o[1].slice(0,-1);t==="currency"&&!s.includes(":")?n.currency||(n.currency=s.trim()):t==="relativetime"&&!s.includes(":")?n.range||(n.range=s.trim()):s.split(";").forEach(a=>{if(a){const[l,...c]=a.split(":"),i=c.join(":").trim().replace(/^'+|'+$/g,""),d=l.trim();n[d]||(n[d]=i),i==="false"&&(n[d]=!1),i==="true"&&(n[d]=!0),isNaN(i)||(n[d]=parseInt(i,10))}})}return{formatName:t,formatOptions:n}},ma=e=>{const t={};return(n,o,s)=>{let r=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(r={...r,[s.interpolationkey]:void 0});const a=o+JSON.stringify(r);let l=t[a];return l||(l=e(on(o),s),t[a]=l),l(n)}},Xu=e=>(t,n,o)=>e(on(n),o)(t);class Qu{constructor(t={}){this.logger=Be.create("formatter"),this.options=t,this.init(t)}init(t,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const o=n.cacheInBuiltFormats?ma:Xu;this.formats={number:o((s,r)=>{const a=new Intl.NumberFormat(s,{...r});return l=>a.format(l)}),currency:o((s,r)=>{const a=new Intl.NumberFormat(s,{...r,style:"currency"});return l=>a.format(l)}),datetime:o((s,r)=>{const a=new Intl.DateTimeFormat(s,{...r});return l=>a.format(l)}),relativetime:o((s,r)=>{const a=new Intl.RelativeTimeFormat(s,{...r});return l=>a.format(l,r.range||"day")}),list:o((s,r)=>{const a=new Intl.ListFormat(s,{...r});return l=>a.format(l)})}}add(t,n){this.formats[t.toLowerCase().trim()]=n}addCached(t,n){this.formats[t.toLowerCase().trim()]=ma(n)}format(t,n,o,s={}){if(!n||t==null)return t;const r=n.split(this.formatSeparator),a=[];for(let c=0;c<r.length;c++){let i=r[c];for(;i.indexOf("(")>-1&&!i.includes(")")&&c+1<r.length;)i=`${i}${this.formatSeparator}${r[++c]}`;a.push(i)}return a.reduce((c,i)=>{const{formatName:d,formatOptions:h}=Zu(i);if(this.formats[d]){let u=c;try{const p=s?.formatParams?.[s.interpolationkey]||{},f=p.locale||p.lng||s.locale||s.lng||o;u=this.formats[d](c,f,{...h,...s,...p})}catch(p){this.logger.warn(p)}return u}else this.logger.warn(`there was no format function for ${d}`);return c},t)}}const eh=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class th extends ao{constructor(t,n,o,s={}){super(),this.backend=t,this.store=n,this.services=o,this.languageUtils=o.languageUtils,this.options=s,this.logger=Be.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(o,s.backend,s)}queueLoad(t,n,o,s){const r={},a={},l={},c={};return t.forEach(i=>{let d=!0;n.forEach(h=>{const u=`${i}|${h}`;!o.reload&&this.store.hasResourceBundle(i,h)?this.state[u]=2:this.state[u]<0||(this.state[u]===1?a[u]===void 0&&(a[u]=!0):(this.state[u]=1,d=!1,a[u]===void 0&&(a[u]=!0),r[u]===void 0&&(r[u]=!0),c[h]===void 0&&(c[h]=!0)))}),d||(l[i]=!0)}),(Object.keys(r).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(r),pending:Object.keys(a),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(t,n,o){const s=t.split("|"),r=s[0],a=s[1];n&&this.emit("failedLoading",r,a,n),!n&&o&&this.store.addResourceBundle(r,a,o,void 0,void 0,{skipCopy:!0}),this.state[t]=n?-1:2,n&&o&&(this.state[t]=0);const l={};this.queue.forEach(c=>{Du(c.loaded,[r],a),eh(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(i=>{l[i]||(l[i]={});const d=c.loaded[i];d.length&&d.forEach(h=>{l[i][h]===void 0&&(l[i][h]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(t,n,o,s=0,r=this.retryTimeout,a){if(!t.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:n,fcName:o,tried:s,wait:r,callback:a});return}this.readingCalls++;const l=(i,d)=>{if(this.readingCalls--,this.waitingReads.length>0){const h=this.waitingReads.shift();this.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.callback)}if(i&&d&&s<this.maxRetries){setTimeout(()=>{this.read(t,n,o,s+1,r*2,a)},r);return}a(i,d)},c=this.backend[o].bind(this.backend);if(c.length===2){try{const i=c(t,n);i&&typeof i.then=="function"?i.then(d=>l(null,d)).catch(l):l(null,i)}catch(i){l(i)}return}return c(t,n,l)}prepareLoading(t,n,o={},s){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();_(t)&&(t=this.languageUtils.toResolveHierarchy(t)),_(n)&&(n=[n]);const r=this.queueLoad(t,n,o,s);if(!r.toLoad.length)return r.pending.length||s(),null;r.toLoad.forEach(a=>{this.loadOne(a)})}load(t,n,o){this.prepareLoading(t,n,{},o)}reload(t,n,o){this.prepareLoading(t,n,{reload:!0},o)}loadOne(t,n=""){const o=t.split("|"),s=o[0],r=o[1];this.read(s,r,"read",void 0,void 0,(a,l)=>{a&&this.logger.warn(`${n}loading namespace ${r} for language ${s} failed`,a),!a&&l&&this.logger.log(`${n}loaded namespace ${r} for language ${s}`,l),this.loaded(t,a,l)})}saveMissing(t,n,o,s,r,a={},l=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${o}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(o==null||o==="")){if(this.backend?.create){const c={...a,isUpdate:r},i=this.backend.create.bind(this.backend);if(i.length<6)try{let d;i.length===5?d=i(t,n,o,s,c):d=i(t,n,o,s),d&&typeof d.then=="function"?d.then(h=>l(null,h)).catch(l):l(null,d)}catch(d){l(d)}else i(t,n,o,s,l,c)}!t||!t[0]||this.store.addResource(t[0],n,o,s)}}}const Co=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",enableSelector:!1,partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),_(e[1])&&(t.defaultValue=e[1]),_(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const n=e[3]||e[2];Object.keys(n).forEach(o=>{t[o]=n[o]})}return t},interpolation:{escapeValue:!0,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),ga=e=>(_(e.ns)&&(e.ns=[e.ns]),_(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),_(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&!e.supportedLngs.includes("cimode")&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),kn=()=>{},nh=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class Jt extends ao{constructor(t={},n){if(super(),this.options=ga(t),this.services={},this.logger=Be,this.modules={external:[]},nh(this),n&&!this.isInitialized&&!t.isClone){if(!this.options.initAsync)return this.init(t,n),this;setTimeout(()=>{this.init(t,n)},0)}}init(t={},n){this.isInitializing=!0,typeof t=="function"&&(n=t,t={}),t.defaultNS==null&&t.ns&&(_(t.ns)?t.defaultNS=t.ns:t.ns.includes("translation")||(t.defaultNS=t.ns[0]));const o=Co();this.options={...o,...this.options,...ga(t)},this.options.interpolation={...o.interpolation,...this.options.interpolation},t.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=t.keySeparator),t.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=t.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=o.overloadTranslationOptionHandler);const s=i=>i?typeof i=="function"?new i:i:null;if(!this.options.isClone){this.modules.logger?Be.init(s(this.modules.logger),this.options):Be.init(null,this.options);let i;this.modules.formatter?i=this.modules.formatter:i=Qu;const d=new da(this.options);this.store=new ca(this.options.resources,this.options);const h=this.services;h.logger=Be,h.resourceStore=this.store,h.languageUtils=d,h.pluralResolver=new Ju(d,{prepend:this.options.pluralSeparator}),i&&(h.formatter=s(i),h.formatter.init&&h.formatter.init(h,this.options),this.options.interpolation.format=h.formatter.format.bind(h.formatter)),h.interpolator=new fa(this.options),h.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},h.backendConnector=new th(s(this.modules.backend),h.resourceStore,h,this.options),h.backendConnector.on("*",(u,...p)=>{this.emit(u,...p)}),this.modules.languageDetector&&(h.languageDetector=s(this.modules.languageDetector),h.languageDetector.init&&h.languageDetector.init(h,this.options.detection,this.options)),this.modules.i18nFormat&&(h.i18nFormat=s(this.modules.i18nFormat),h.i18nFormat.init&&h.i18nFormat.init(this)),this.translator=new Kn(this.services,this.options),this.translator.on("*",(u,...p)=>{this.emit(u,...p)}),this.modules.external.forEach(u=>{u.init&&u.init(this)})}if(this.format=this.options.interpolation.format,n||(n=kn),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const i=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);i.length>0&&i[0]!=="dev"&&(this.options.lng=i[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(i=>{this[i]=(...d)=>this.store[i](...d)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(i=>{this[i]=(...d)=>(this.store[i](...d),this)});const l=qt(),c=()=>{const i=(d,h)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(h),n(d,h)};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return i(null,this.t.bind(this));this.changeLanguage(this.options.lng,i)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),l}loadResources(t,n=kn){let o=n;const s=_(t)?t:this.language;if(typeof t=="function"&&(o=t),!this.options.resources||this.options.partialBundledLanguages){if(s?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return o();const r=[],a=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(i=>{i!=="cimode"&&(r.includes(i)||r.push(i))})};s?a(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>a(c)),this.options.preload?.forEach?.(l=>a(l)),this.services.backendConnector.load(r,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),o(l)})}else o(null)}reloadResources(t,n,o){const s=qt();return typeof t=="function"&&(o=t,t=void 0),typeof n=="function"&&(o=n,n=void 0),t||(t=this.languages),n||(n=this.options.ns),o||(o=kn),this.services.backendConnector.reload(t,n,r=>{s.resolve(),o(r)}),s}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&uc.addPostProcessor(t),t.type==="formatter"&&(this.modules.formatter=t),t.type==="3rdParty"&&this.modules.external.push(t),this}setResolvedLanguage(t){if(!(!t||!this.languages)&&!["cimode","dev"].includes(t)){for(let n=0;n<this.languages.length;n++){const o=this.languages[n];if(!["cimode","dev"].includes(o)&&this.store.hasLanguageSomeTranslations(o)){this.resolvedLanguage=o;break}}!this.resolvedLanguage&&!this.languages.includes(t)&&this.store.hasLanguageSomeTranslations(t)&&(this.resolvedLanguage=t,this.languages.unshift(t))}}changeLanguage(t,n){this.isLanguageChangingTo=t;const o=qt();this.emit("languageChanging",t);const s=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},r=(l,c)=>{c?this.isLanguageChangingTo===t&&(s(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,o.resolve((...i)=>this.t(...i)),n&&n(l,(...i)=>this.t(...i))},a=l=>{!t&&!l&&this.services.languageDetector&&(l=[]);const c=_(l)?l:l&&l[0],i=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(_(l)?[l]:l);i&&(this.language||s(i),this.translator.language||this.translator.changeLanguage(i),this.services.languageDetector?.cacheUserLanguage?.(i)),this.loadResources(i,d=>{r(d,i)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(t),o}getFixedT(t,n,o,s){const r=s?.scopeNs,a=(l,c,...i)=>{let d;typeof c!="object"?d=this.options.overloadTranslationOptionHandler([l,c].concat(i)):d={...c},d.lng=d.lng||a.lng,d.lngs=d.lngs||a.lngs;const h=d.ns!==void 0&&d.ns!==null;d.ns=d.ns||a.ns,d.keyPrefix!==""&&(d.keyPrefix=d.keyPrefix||o||a.keyPrefix);const u={...this.options,...d};Array.isArray(r)&&!h&&(u.ns=r),typeof d.keyPrefix=="function"&&(d.keyPrefix=Ot(d.keyPrefix,u));const p=this.options.keySeparator||".";let f;return d.keyPrefix&&Array.isArray(l)?f=l.map(m=>(typeof m=="function"&&(m=Ot(m,u)),`${d.keyPrefix}${p}${m}`)):(typeof l=="function"&&(l=Ot(l,u)),f=d.keyPrefix?`${d.keyPrefix}${p}${l}`:l),this.t(f,d)};return _(t)?a.lng=t:a.lngs=t,a.ns=n,a.keyPrefix=o,a}t(...t){return this.translator?.translate(...t)}exists(...t){return this.translator?.exists(...t)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const o=n.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,r=this.languages[this.languages.length-1];if(o.toLowerCase()==="cimode")return!0;const a=(l,c)=>{const i=this.services.backendConnector.state[`${l}|${c}`];return i===-1||i===0||i===2};if(n.precheck){const l=n.precheck(this,a);if(l!==void 0)return l}return!!(this.hasResourceBundle(o,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(o,t)&&(!s||a(r,t)))}loadNamespaces(t,n){const o=qt();return this.options.ns?(_(t)&&(t=[t]),t.forEach(s=>{this.options.ns.includes(s)||this.options.ns.push(s)}),this.loadResources(s=>{o.resolve(),n&&n(s)}),o):(n&&n(),Promise.resolve())}loadLanguages(t,n){const o=qt();_(t)&&(t=[t]);const s=this.options.preload||[],r=t.filter(a=>!s.includes(a)&&this.services.languageUtils.isSupportedCode(a));return r.length?(this.options.preload=s.concat(r),this.loadResources(a=>{o.resolve(),n&&n(a)}),o):(n&&n(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!t)return"rtl";try{const s=new Intl.Locale(t);if(s&&s.getTextInfo){const r=s.getTextInfo();if(r&&r.direction)return r.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],o=this.services?.languageUtils||new da(Co());return t.toLowerCase().indexOf("-latn")>1?"ltr":n.includes(o.getLanguagePartFromCode(t))||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(t={},n){const o=new Jt(t,n);return o.createInstance=Jt.createInstance,o}cloneInstance(t={},n=kn){const o=t.forkResourceStore;o&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},r=new Jt(s);if((t.debug!==void 0||t.prefix!==void 0)&&(r.logger=r.logger.clone(t)),["store","services","language"].forEach(l=>{r[l]=this[l]}),r.services={...this.services},r.services.utils={hasLoadedNamespace:r.hasLoadedNamespace.bind(r)},o){const l=Object.keys(this.store.data).reduce((c,i)=>(c[i]={...this.store.data[i]},c[i]=Object.keys(c[i]).reduce((d,h)=>(d[h]={...c[i][h]},d),c[i]),c),{});r.store=new ca(l,s),r.services.resourceStore=r.store}if(t.interpolation){const c={...Co().interpolation,...this.options.interpolation,...t.interpolation},i={...s,interpolation:c};r.services.interpolator=new fa(i)}return r.translator=new Kn(r.services,s),r.translator.on("*",(l,...c)=>{r.emit(l,...c)}),r.init(s,n),r.translator.options=s,r.translator.backendConnector.services.utils={hasLoadedNamespace:r.hasLoadedNamespace.bind(r)},r}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const ge=Jt.createInstance();ge.createInstance;ge.dir;ge.init;ge.loadResources;ge.reloadResources;ge.use;ge.changeLanguage;ge.getFixedT;ge.t;ge.exists;ge.setDefaultNamespace;ge.hasLoadedNamespace;ge.loadNamespaces;ge.loadLanguages;let pc=ge;function oh(e){pc=e}function sh(){const e=pc.language;return e&&!e.startsWith("zh")?"en-US":"zh-CN"}function fe(e){return e[sh()]}const rh={object:e=>`${e} 必须是对象`,noOption:(e,t)=>`${e} 没有配置项 ${t}`,oneOf:(e,t)=>`${e} 必须是 ${t.join("、")} 之一`,label:e=>`${e} 必须是不超过 20 字的文本`,confirm:e=>`${e} 必须是不超过 120 字的文本`,maxObjects:(e,t)=>`${e} 必须是 1 到 ${t} 的整数`,list:(e,t)=>`${e} 必须是不超过 ${t} 项的列表`,hitNeeds:e=>`${e} 要给出 { selection: 筛选 } 或 { set: 筛选 }:按钮没有点到的对象`,targetsShape:e=>`${e} 只能是 hit、{ selection } 或 { set }`,targetsNotFilter:(e,t,n)=>`${e} 不是页面上的${t==="set"?"对象集合":"选中对象"}筛选:${n}`,targetsOtherType:e=>`${e} 里的对象和行动作用的对象不是同一类`,paramNot:(e,t)=>`${e} 不是行动「${t}」要填的参数`,paramNoSource:(e,t)=>`${e} 没有给出来源:行动「${t}」要求填写它`,fromShape:e=>`${e} 必须是 { from, ... }`,notPageFilter:(e,t)=>`${e} 不是页面筛选:${t}`,constValue:e=>`${e} 必须是文本、数字或真假`,fromOneOf:e=>`${e} 只能是 input、var 或 const`,actionRequired:e=>`${e} 必填:知识网络里的行动`,needSource:e=>`${e} 需要先选好数据源`,notObjects:e=>`${e} 查询结果和事件不是网络里的对象,不能执行行动`,notAction:(e,t)=>`${e} 不是知识网络里的行动:${t}`,actionObject:(e,t,n,o)=>`${e} 行动「${t}」作用于 ${n??(o||"未绑定的对象")},和数据源的对象类不同`},ah={object:e=>`${e} must be an object`,noOption:(e,t)=>`${e} has no option ${t}`,oneOf:(e,t)=>`${e} must be one of ${t.join(", ")}`,label:e=>`${e} must be text of at most 20 characters`,confirm:e=>`${e} must be text of at most 120 characters`,maxObjects:(e,t)=>`${e} must be an integer from 1 to ${t}`,list:(e,t)=>`${e} must be a list of at most ${t} items`,hitNeeds:e=>`${e} must give { selection: filter } or { set: filter }: a button has no clicked objects`,targetsShape:e=>`${e} must be hit, { selection } or { set }`,targetsNotFilter:(e,t,n)=>`${e} is not ${t==="set"?"an object set":"a selected object"} filter of the page: ${n}`,targetsOtherType:e=>`${e} holds objects of another type than the ones the action works on`,paramNot:(e,t)=>`${e} is not a parameter of action "${t}"`,paramNoSource:(e,t)=>`${e} has no source: action "${t}" requires it`,fromShape:e=>`${e} must be { from, ... }`,notPageFilter:(e,t)=>`${e} is not a page filter: ${t}`,constValue:e=>`${e} must be text, a number or a boolean`,fromOneOf:e=>`${e} must be input, var or const`,actionRequired:e=>`${e} is required: an action of the knowledge network`,needSource:e=>`${e} needs a source to be chosen first`,notObjects:e=>`${e} query results and events are not objects of the network, so no action can run on them`,notAction:(e,t)=>`${e} is not an action of the knowledge network: ${t}`,actionObject:(e,t,n,o)=>`${e} action "${t}" acts on ${n??(o||"an unbound object")}, which is not the object type of the source`},Cr=()=>fe({"zh-CN":rh,"en-US":ah}),Fs=100;function ln(e,t){return e.actionTypes?.find(n=>n.id===t)}function Yn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ih(e,t,n,o,s){const r=Cr();if(e===void 0||e==="hit")return t?[]:[r.hitNeeds(s)];if(!Yn(e))return[r.targetsShape(s)];const a="selection"in e?"selection":"set"in e?"set":null,l=a?e[a]:void 0;if(!a||typeof l!="string"||Object.keys(e).length!==1)return[r.targetsShape(s)];const c=n.variables.find(d=>d.name===l);return!c||c.kind!==a?[r.targetsNotFilter(`${s}.${a}`,a,l)]:("source"in c?ue(n,c.source)?.objectType:void 0)===o?[]:[r.targetsOtherType(`${s}.${a}`)]}function lh(e,t,n,o){const s=Cr();if(e!==void 0&&!Yn(e))return[s.object(o)];const r=e??{},a=new Set(t.inputs.map(c=>c.name)),l=Object.keys(r).filter(c=>!a.has(c)).map(c=>s.paramNot(`${o}.${c}`,t.name));for(const c of t.inputs){const i=r[c.name],d=`${o}.${c.name}`;if(i===void 0){c.property||l.push(s.paramNoSource(d,t.name));continue}if(!Yn(i)){l.push(s.fromShape(d));continue}i.from==="input"?i.label!==void 0&&(typeof i.label!="string"||i.label.length>20)&&l.push(s.label(`${d}.label`)):i.from==="var"?n.variables.some(h=>h.name===i.variable)||l.push(s.notPageFilter(`${d}.variable`,String(i.variable))):i.from==="const"?["string","number","boolean"].includes(typeof i.value)||l.push(s.constValue(`${d}.value`)):l.push(s.fromOneOf(`${d}.from`))}return l}function fc(e,t,n,o,s){const r=Cr();if(!Yn(e))return[r.object(s)];const a=new Set(["on","action","label","targets","params","confirm","maxObjects"]),l=Object.keys(e).filter(h=>!a.has(h)).map(h=>r.noOption(s,h));if(t.on.includes(e.on)||l.push(r.oneOf(`${s}.on`,t.on)),e.label!==void 0&&(typeof e.label!="string"||e.label.length>20)&&l.push(r.label(`${s}.label`)),e.confirm!==void 0&&(typeof e.confirm!="string"||e.confirm.length>120)&&l.push(r.confirm(`${s}.confirm`)),e.maxObjects!==void 0&&(typeof e.maxObjects!="number"||!Number.isInteger(e.maxObjects)||e.maxObjects<1||e.maxObjects>Fs)&&l.push(r.maxObjects(`${s}.maxObjects`,Fs)),typeof e.action!="string"||!e.action)return l.push(r.actionRequired(`${s}.action`)),l;const c=ue(n.spec,o);if(!c)return[...l,r.needSource(s)];const i=n.spec.sources.find(h=>h.id===(c.from?.source??c.id));if(c.cypher||i?.cypher||c.events)return[...l,r.notObjects(s)];if(!n.kn.actionTypes)return l;const d=ln(n.kn,e.action);return d?(d.objectType!==c.objectType&&l.push(r.actionObject(`${s}.action`,d.name,n.kn.objectTypes[d.objectType]?.name,d.objectType)),l.push(...ih(e.targets,t.hit,n.spec,c.objectType,`${s}.targets`)),l.push(...lh(e.params,d,n.spec,`${s}.params`)),l):[...l,r.notAction(`${s}.action`,e.action)]}const Ds=["workbench","dashboard","detail","free"],mc={workbench:["side","main","aside"],dashboard:["header","grid"],detail:["header","main","aside"],free:["cells"]},At=12,Ve=["asOfSlider","dateRange","metricCards","segmentedFilter","dropdownFilter","searchBox","text","objectTable","objectList","pivotTable","trendChart","regionMap","ganttChart","scheduleGantt","stageChain","subgraph","agentChat","alertList","eventList","eventReport","taskInbox","actionButton","scenarioBar","modelTrial"],Nr=new Set(["taskInbox"]),ch=/^x-[a-z0-9-]+\.[A-Za-z][A-Za-z0-9]*$/,Rt=e=>typeof e=="string"&&ch.test(e),gc={asOfSlider:[4,2],dateRange:[3,2],metricCards:[4,3],segmentedFilter:[3,2],dropdownFilter:[3,2],searchBox:[3,2],text:[2,2],objectTable:[4,6],objectList:[3,5],pivotTable:[3,5],trendChart:[4,5],regionMap:[3,6],ganttChart:[4,5],scheduleGantt:[6,7],stageChain:[3,3],subgraph:[3,6],agentChat:[3,7],alertList:[3,5],eventList:[4,5],eventReport:[2,2],taskInbox:[4,5],actionButton:[2,2],scenarioBar:[4,2],modelTrial:[6,7]},dh=8,uh=5,me="objectDetail",xr=12,Bs=["none","subtle","strong"],Us=["compact","comfortable"],_t=["card","plain"],Pt=["neutral","info","success","warning","danger"],he="$asOf",Gn=["isSet","isEmpty","eq","ne","in","before","onOrBefore","after","onOrAfter","gt","gte","lt","lte"],Zt=["classify","days","formula","related","region","text","matched"],ya=["china","world"],zs=["count","sum","avg","min","max","one","list"],le={status:"$status",stage:"$stage",overdueDays:"$overdueDays",dueInDays:"$dueInDays"},re={done:{value:"done",label:"已完成",tone:"success"},overdue:{value:"overdue",label:"已超期",tone:"danger"},active:{value:"active",label:"进行中",tone:"info"}},Ws=6,ba=4,cn="$scenarioMark",In={edited:{value:"edited",label:"改动",tone:"warning"},followed:{value:"followed",label:"联动",tone:"info"},related:{value:"related",label:"相关",tone:"neutral"}},Ks=["shiftDays","add","set","fromAsOf"],Ys=["scenario","user"],Hn=["asOf","value","dateRange","search","selection","set"],wa=["value","dateRange","search","set"],ka=["auto","manual"],va=["filter","select","none"],hh=["P1","P2","P3","P4"],Gs=["text","number","date"],Hs=["none","property","batch"],$a=/(^|_)(id|key|code|no)$/i,ph=/(主键|编号|编码|单号|单据号|代码|\bID\b|\bNo\.?$)/i;function Sa(e,t){const n=e.filter(o=>o.type==="text"&&!t?.primaryKeys.includes(o.name));return n.find(o=>o.name!==t?.displayKey&&!$a.test(o.name)&&!ph.test(o.label))??n.find(o=>o.name!==t?.displayKey&&!$a.test(o.name))??n[0]}function No(e,t){const n=t.objectTypes[e.objectType],o=n?.displayKey;return!e.cypher&&o&&n.properties.some(s=>s.name===o)?o:e.key}function io(e){return e.operation==="tool"?"tool":e.operation==="relation"?"relation":e.kind==="add"?"create":"modify"}const fh=new Set(["date","datetime","timestamp"]),mh=new Set(["integer","unsigned integer","float","decimal","int","long","short","double","bigint","smallint","tinyint","number","numeric","real"]),gh=new Set(["binary","vector","shape","point"]);function yh(e){const t=e.toLowerCase().replace(/\s+/g," ").trim();return fh.has(t)?"date":mh.has(t)?"number":"text"}function bh(e){return e.kind==="matched"?e.field?e.type??"text":"number":e.kind==="related"?e.aggregate==="one"?e.type??"text":e.aggregate==="list"?"text":"number":e.kind==="classify"||e.kind==="region"||e.kind==="text"?"text":"number"}function Rr(e){return{name:e.name,label:e.label,type:bh(e)}}function yc(e){if(!e)return[];const t=[{name:le.status,label:"进度状态",type:"text"},{name:le.stage,label:"当前步骤",type:"text"}];return e.due&&t.push({name:le.overdueDays,label:"超期天数",type:"number"},{name:le.dueInDays,label:"距截止天数",type:"number"}),t}function wh(e){return!!(e.operations?.length||e.follows?.length||e.relatedTo?.length)}const kh={name:cn,label:"方案标记",type:"text"};function pe(e,t){return[...t.objectTypes[e.objectType]?.properties??[],...yc(e.progress),...(e.computed??[]).map(Rr),...wh(e)?[kh]:[]]}const ja="~";function vh(e){return e.startsWith(ja)?{id:e.slice(ja.length),reversed:!0}:{id:e,reversed:!1}}function dn(e,t,n){const o=[];let s=t;for(const r of n){const{id:a,reversed:l}=vh(r),c=e.relations.find(i=>i.id===a);if(!c)return null;if(l){if(c.target!==s)return null;o.push({relation:c,forward:!1,to:c.source})}else if(c.source===s)o.push({relation:c,forward:!0,to:c.target});else if(c.target===s)o.push({relation:c,forward:!1,to:c.source});else return null;s=o[o.length-1].to}return o}function $h(e,t,n){const o=dn(e,t,n);return o?[t,...o.map(s=>s.to)].map(s=>e.objectTypes[s]?.name??s).join(" → "):n.join(" → ")}const Sh={unknown:(e,t)=>`第 ${e} 个字符“${t}”无法识别`,empty:"公式是空的",unfinished:"公式没写完",unclosed:e=>`第 ${e} 个字符的括号没有闭合`,missing:(e,t)=>`第 ${e} 个字符“${t}”前缺少数字或字段`,extra:(e,t)=>`第 ${e} 个字符“${t}”多余`},jh={unknown:(e,t)=>`character ${e} "${t}" is not recognized`,empty:"the formula is empty",unfinished:"the formula is unfinished",unclosed:e=>`the parenthesis at character ${e} is not closed`,missing:(e,t)=>`a number or field is missing before character ${e} "${t}"`,extra:(e,t)=>`character ${e} "${t}" is unexpected`},bc=()=>fe({"zh-CN":Sh,"en-US":jh}),Aa=/(\d+(?:\.\d+)?)|(\$?[A-Za-z_][A-Za-z0-9_]*)|`([^`]+)`|([-+*/()])/y;function Ah(e){const t=bc(),n=[];let o=0;for(;o<e.length;){if(/\s/.test(e[o])){o++;continue}Aa.lastIndex=o;const s=Aa.exec(e);if(!s)return t.unknown(o+1,e[o]);const[r,a,l,c]=s;n.push({kind:a!==void 0?"number":l!==void 0||c!==void 0?"name":"op",text:c??r,at:o}),o+=s[0].length}return n}function wc(e){const t=bc(),n=Ah(e);if(typeof n=="string")return{ok:!1,error:n};if(n.length===0)return{ok:!1,error:t.empty};let o=0;const s=()=>n[o],r=d=>{throw new Error(d)},a=()=>{let d=l();for(;s()?.text==="+"||s()?.text==="-";)d={type:"binary",op:n[o++].text,left:d,right:l()};return d},l=()=>{let d=c();for(;s()?.text==="*"||s()?.text==="/";)d={type:"binary",op:n[o++].text,left:d,right:c()};return d},c=()=>s()?.text==="-"?(o++,{type:"negate",arg:c()}):i(),i=()=>{const d=n[o++];if(!d)return r(t.unfinished);if(d.kind==="number")return{type:"number",value:Number(d.text)};if(d.kind==="name")return{type:"field",name:d.text};if(d.text==="("){const h=a();return n[o++]?.text!==")"&&r(t.unclosed(d.at+1)),h}return r(t.missing(d.at+1,d.text))};try{const d=a();return o<n.length&&r(t.extra(n[o].at+1,n[o].text)),{ok:!0,node:d}}catch(d){return{ok:!1,error:d.message}}}function Xt(e){switch(e.type){case"number":return[];case"field":return[e.name];case"negate":return Xt(e.arg);case"binary":return[...Xt(e.left),...Xt(e.right)]}}const Th={sep:"、",object:e=>`${e} 必须是对象`,array:e=>`${e} 必须是数组`,valueNotTaken:(e,t,n,o)=>`${e} 的取值「${t}」不是 ${n} 的取值(可选:${o})`,fieldUnusable:(e,t)=>`${e}.field 不是可用的字段:${t}`,opOneOf:(e,t)=>`${e}.op 只能是 ${t}`,valuesList:e=>`${e}.values 必须是非空的文本列表`,refOrValue:(e,t)=>`${e} 要给 ref(字段或 ${t})或 value(值)其中一个`,refUnusable:(e,t)=>`${e}.ref 不是可用的字段:${t}`,needDateField:(e,t)=>`${e}.field 用 ${t} 比较时必须是日期字段`,otherDate:(e,t,n)=>`${e} 用 ${t} 比较时,另一边必须是日期字段、${n} 或 YYYY-MM-DD`,needNumberField:(e,t)=>`${e}.field 用 ${t} 比较时必须是数字字段`,otherNumber:(e,t)=>`${e} 用 ${t} 比较时,另一边必须是数字字段或数字`,textOrNumber:e=>`${e}.value 必须是文本或数字`,conditionList:e=>`${e} 必须是条件列表`,identifier:e=>`${e}.name 必须是字母开头的标识`,nameTaken:(e,t)=>`${e}.name ${t} 与已有属性或计算列重名`,nameReserved:(e,t)=>`${e}.name ${t} 是进度列的保留名`,required:e=>`${e} 必填`,kindOneOf:(e,t)=>`${e}.kind 只能是 ${t}`,cycle:(e,t)=>`${e} 计算列互相引用成环:${t}`,matchedName:(e,t)=>`「${e}」的「${t}」`,matchedCycle:(e,t)=>`${e} 这些匹配字段互相取值,形成了循环,都算不出来:${t}。请让其中一个直接取对方的原始属性,而不是对方的匹配字段。`,dateOrAsOf:(e,t)=>`${e} 必须是日期字段或 ${t}`,exprText:e=>`${e}.expr 必须是公式文本`,exprError:(e,t)=>`${e}.expr ${t}`,exprField:(e,t)=>`${e}.expr 里的 ${t} 不是可用的数字字段`,templateText:e=>`${e}.template 必须是非空文本,用 {字段名} 引用字段`,templateNoField:e=>`${e}.template 至少要用 {字段名} 引用一个字段`,templateField:(e,t)=>`${e}.template 里的 {${t}} 不是可用的字段`,fromText:e=>`${e}.from 必须是文本字段`,scopeOneOf:(e,t)=>`${e}.scope 只能是 ${t}`,relatedCypher:e=>`${e} Cypher 数据源暂不支持关联统计,可以把统计直接写进查询`,pathNeeded:e=>`${e}.path 必须是至少一条关系的路径`,pathUnreachable:(e,t)=>`${e}.path 不是从 ${t} 出发连通的关系路径`,aggregateOneOf:(e,t)=>`${e}.aggregate 只能是 ${t}`,endObjectType:"终点对象类",fieldOfProperty:(e,t)=>`${e}.field 必须是 ${t} 的属性`,typeOfTaken:(e,t)=>`${e}.type 必须是所取属性的类型:${t}`,typeListIsText:e=>`${e}.type 列出的值是文本,不用写 type`,fieldNumberProperty:(e,t)=>`${e}.field 必须是 ${t} 的数字属性`,typeOnlyOne:e=>`${e}.type 只有 one 需要写`,whereFixed:e=>`${e}.where 关联统计的条件只能和固定值比较`,matchedCypher:e=>`${e} Cypher 数据源不支持按字段匹配其他数据源`,otherSource:e=>`${e}.source 必须是另一个数据源`,otherSourceKind:e=>`${e}.source 必须是本应用中读取知识网络对象类的数据源(不能是子集)`,pairsCount:e=>`${e}.pairs 必须是 1 到 4 对字段`,otherProperty:(e,t)=>`${e}.other 必须是 ${t} 的属性`,typeOnlyWithField:e=>`${e}.type 只有取属性(field)时需要写`,valueText:e=>`${e}.value 必须是非空文本`,toneOneOf:(e,t)=>`${e}.tone 只能是 ${t}`},Oh={sep:", ",object:e=>`${e} must be an object`,array:e=>`${e} must be an array`,valueNotTaken:(e,t,n,o)=>`${e} value "${t}" is not a value of ${n} (one of: ${o})`,fieldUnusable:(e,t)=>`${e}.field is not an available field: ${t}`,opOneOf:(e,t)=>`${e}.op must be one of ${t}`,valuesList:e=>`${e}.values must be a non-empty list of text`,refOrValue:(e,t)=>`${e} needs exactly one of ref (a field or ${t}) and value`,refUnusable:(e,t)=>`${e}.ref is not an available field: ${t}`,needDateField:(e,t)=>`${e}.field must be a date field when compared with ${t}`,otherDate:(e,t,n)=>`${e}: when compared with ${t}, the other side must be a date field, ${n} or YYYY-MM-DD`,needNumberField:(e,t)=>`${e}.field must be a number field when compared with ${t}`,otherNumber:(e,t)=>`${e}: when compared with ${t}, the other side must be a number field or a number`,textOrNumber:e=>`${e}.value must be text or a number`,conditionList:e=>`${e} must be a list of conditions`,identifier:e=>`${e}.name must be an identifier starting with a letter`,nameTaken:(e,t)=>`${e}.name ${t} is already used by a property or computed column`,nameReserved:(e,t)=>`${e}.name ${t} is reserved for a progress column`,required:e=>`${e} is required`,kindOneOf:(e,t)=>`${e}.kind must be one of ${t}`,cycle:(e,t)=>`${e} computed columns read each other in a circle: ${t}`,matchedName:(e,t)=>`"${t}" of "${e}"`,matchedCycle:(e,t)=>`${e} these matched fields take values from each other in a circle, so none can be worked out: ${t}. Make one of them take the other source's own property instead of its matched field.`,dateOrAsOf:(e,t)=>`${e} must be a date field or ${t}`,exprText:e=>`${e}.expr must be formula text`,exprError:(e,t)=>`${e}.expr: ${t}`,exprField:(e,t)=>`${t} in ${e}.expr is not an available number field`,templateText:e=>`${e}.template must be non-empty text that refers to fields as {field}`,templateNoField:e=>`${e}.template must refer to at least one field as {field}`,templateField:(e,t)=>`{${t}} in ${e}.template is not an available field`,fromText:e=>`${e}.from must be a text field`,scopeOneOf:(e,t)=>`${e}.scope must be one of ${t}`,relatedCypher:e=>`${e}: a Cypher source does not support related counts yet; write the count into the query`,pathNeeded:e=>`${e}.path must be a path of at least one relation`,pathUnreachable:(e,t)=>`${e}.path is not a connected relation path starting at ${t}`,aggregateOneOf:(e,t)=>`${e}.aggregate must be one of ${t}`,endObjectType:"the end object type",fieldOfProperty:(e,t)=>`${e}.field must be a property of ${t}`,typeOfTaken:(e,t)=>`${e}.type must be the type of the property taken: ${t}`,typeListIsText:e=>`${e}.type: the listed values are text, so type is not needed`,fieldNumberProperty:(e,t)=>`${e}.field must be a number property of ${t}`,typeOnlyOne:e=>`${e}.type is only needed for one`,whereFixed:e=>`${e}.where: conditions of a related count can only compare with fixed values`,matchedCypher:e=>`${e}: a Cypher source does not support matching other sources by field`,otherSource:e=>`${e}.source must be another source`,otherSourceKind:e=>`${e}.source must be a source of this app that reads an object type of the knowledge network (not a subset)`,pairsCount:e=>`${e}.pairs must be 1 to 4 pairs of fields`,otherProperty:(e,t)=>`${e}.other must be a property of ${t}`,typeOnlyWithField:e=>`${e}.type is only needed when taking a property (field)`,valueText:e=>`${e}.value must be non-empty text`,toneOneOf:(e,t)=>`${e}.tone must be one of ${t}`},Je=()=>fe({"zh-CN":Th,"en-US":Oh}),Eh=/^[A-Za-z][A-Za-z0-9_]*$/,Ch=/^\d{4}-\d{2}-\d{2}$/,Nh=["before","onOrBefore","after","onOrAfter"],xh=["gt","gte","lt","lte"],kc=()=>[];function Ta(e,t,n,o){const s=n(e);if(s.length===0)return[];const r=Je();return t.filter(a=>typeof a=="string"&&!s.includes(a)).map(a=>r.valueNotTaken(o,String(a),e,s.join(r.sep)))}function Rh(e,t,n,o=kc){const s=Je();if(!Oe(e))return[s.object(n)];const r=d=>d===he?"date":t.find(h=>h.name===d)?.type,a=r(e.field);if(!a)return[s.fieldUnusable(n,String(e.field))];if(!Lt(e.op,Gn))return[s.opOneOf(n,Gn.join(s.sep))];const l=e.op;if(l==="isSet"||l==="isEmpty")return[];if(l==="in")return Array.isArray(e.values)&&e.values.length>0&&e.values.every(d=>typeof d=="string")?Ta(String(e.field),e.values,o,`${n}.values`):[s.valuesList(n)];const c=e.ref!==void 0;if(c===(e.value!==void 0))return[s.refOrValue(n,he)];const i=c?r(e.ref):void 0;return c&&!i?[s.refUnusable(n,String(e.ref))]:Nh.includes(l)?a!=="date"?[s.needDateField(n,l)]:(c?i==="date":typeof e.value=="string"&&Ch.test(e.value))?[]:[s.otherDate(n,l,he)]:xh.includes(l)?a!=="number"?[s.needNumberField(n,l)]:(c?i==="number":typeof e.value=="number")?[]:[s.otherNumber(n,l)]:c?[]:typeof e.value!="string"&&typeof e.value!="number"?[s.textOrNumber(n)]:Ta(String(e.field),[e.value],o,`${n}.value`)}function xe(e,t,n,o=kc){return Array.isArray(e)?e.flatMap((s,r)=>Rh(s,t,`${n}[${r}]`,o)):[Je().conditionList(n)]}function vc(e,t=!1){return n=>{if(t&&n===le.status)return jc.map(s=>s.value);if(n===cn)return Wh.map(s=>s.value);const o=e.find(s=>Oe(s)&&s.name===n&&s.kind==="classify"&&Array.isArray(s.cases)&&Oe(s.otherwise));return o?[...o.cases,o.otherwise].map(s=>Oe(s)?s.value:void 0).filter(s=>typeof s=="string"):[]}}const Vs=e=>(e??[]).flatMap(t=>[t.field,t.ref].filter(n=>typeof n=="string"&&n!==he)),_h=/\{([^{}]+)\}/g;function $c(e){return[...new Set([...e.matchAll(_h)].map(t=>t[1].trim()))]}function _r(e){switch(e.kind){case"classify":return e.cases.flatMap(t=>Vs(t.when));case"days":return[e.from,e.to,...Vs(e.when)].filter(t=>t!==he);case"formula":{const t=wc(e.expr);return t.ok?Xt(t.node):[]}case"related":return[];case"matched":return[];case"region":return[e.from];case"text":return $c(e.template)}}function Ph(e){const t=new Set(e.map(r=>r.name)),n=new Set,o=[];let s=[...e];for(;s.length>0;){const r=s.filter(a=>_r(a).every(l=>!t.has(l)||l===a.name||n.has(l)));if(r.length===0)return[...o,...s];for(const a of r)o.push(a),n.add(a.name);s=s.filter(a=>!r.includes(a))}return o}function Lh(e){const t=Ph(e),n=new Set(e.map(r=>r.name)),o=new Set,s=[];for(const r of t)_r(r).some(a=>n.has(a)&&!o.has(a))&&s.push(r.name),o.add(r.name);return s}function Sc(e){return Array.isArray(e)?e.filter(t=>Oe(t)&&typeof t.name=="string"&&Lt(t.kind,Zt)):[]}function Ih(e){try{return _r(e)??[]}catch{return[]}}const xo=e=>typeof e=="string"&&e!==""?[e]:[];function Mh(e){const t=h=>e.find(u=>u.id===h)?.from?.source??h,n=h=>Sc(h.computed),o=e.filter(h=>Oe(h)&&!h.from&&n(h).length>0),s=new Map(o.map(h=>[h.id,new Set(n(h).map(u=>u.name))])),r=(h,u)=>`${h}\0${u}`,a=(h,u)=>u.filter(p=>s.get(h)?.has(p)).map(p=>r(h,p)),l=[];for(const h of o)for(const u of n(h)){const p=r(h.id,u.name);let f;if(u.kind==="matched"){const m=t(String(u.source)),g=Array.isArray(u.pairs)?u.pairs.filter(y=>Oe(y)):[];f=[...a(h.id,g.flatMap(y=>xo(y?.field))),...a(m,[...g.flatMap(y=>xo(y?.other)),...xo(u.field),...Vs(Array.isArray(u.where)?u.where.filter(y=>Oe(y)):void 0)])]}else f=a(h.id,Ih(u));l.push({id:p,ref:{source:h.id,field:u},reads:f.filter(m=>m!==p)})}const c=new Set,i=[];let d=l;for(;d.length>0;){const h=d.filter(u=>u.reads.every(p=>c.has(p)));if(h.length===0)break;for(const u of h)i.push(u.ref),c.add(u.id);d=d.filter(u=>!c.has(u.id))}return{order:i,stuck:d.map(h=>h.ref)}}const qh=new Set([...Object.values(le),cn]);function Fh(e,t,n,o){if(e===void 0)return[];const s=Je();if(!Array.isArray(e))return[s.array(n)];const r=[],a=vc(e,o.progress),l=e.filter(d=>Oe(d)&&typeof d.name=="string"&&Lt(d.kind,Zt)),c=new Set;e.forEach((d,h)=>{const u=`${n}[${h}]`;if(!Oe(d))return r.push(s.object(u));if(typeof d.name!="string"||!Eh.test(d.name))return r.push(s.identifier(u));if(t.some(f=>f.name===d.name)||c.has(d.name))return r.push(s.nameTaken(u,d.name));if(qh.has(d.name)&&o.progress)return r.push(s.nameReserved(u,d.name));if(c.add(d.name),(typeof d.label!="string"||d.label.trim()==="")&&r.push(s.required(`${u}.label`)),!Lt(d.kind,Zt))return r.push(s.kindOneOf(u,Zt.join(s.sep)));const p=l.filter(f=>f.name!==d.name).map(Rr);r.push(...Bh(d,[...t,...p],u,a,o))});const i=Lh(l);return i.length>0?r.push(s.cycle(n,i.join(s.sep))):o.sources&&o.source&&r.push(...Dh(n,o)),r}function Dh(e,t){const n=Je(),o=t.sources??[],{stuck:s}=Mh(o);if(!s.some(l=>l.source===t.source&&l.field.kind==="matched"))return[];const r=l=>o.find(c=>c.id===l)?.label??l,a=s.map(l=>n.matchedName(r(l.source),l.field.label||l.field.name)).join(n.sep);return[n.matchedCycle(e,a)]}function Bh(e,t,n,o,s){const r=Je(),a=l=>l===he||t.some(c=>c.name===l&&c.type==="date");switch(e.kind){case"classify":{const l=[];return Array.isArray(e.cases)?e.cases.forEach((c,i)=>{const d=`${n}.cases[${i}]`;l.push(...Oa(c,d)),Oe(c)&&l.push(...xe(c.when,t,`${d}.when`,o))}):l.push(r.array(`${n}.cases`)),l.push(...Oa(e.otherwise,`${n}.otherwise`)),l}case"days":return[...a(e.from)?[]:[r.dateOrAsOf(`${n}.from`,he)],...a(e.to)?[]:[r.dateOrAsOf(`${n}.to`,he)],...e.when===void 0?[]:xe(e.when,t,`${n}.when`,o)];case"formula":{if(typeof e.expr!="string")return[r.exprText(n)];const l=wc(e.expr);return l.ok?[...new Set(Xt(l.node))].filter(c=>!t.some(i=>i.name===c&&i.type==="number")).map(c=>r.exprField(n,c)):[r.exprError(n,l.error)]}case"related":return Uh(e,n,s);case"matched":return zh(e,n,s,t);case"text":{if(typeof e.template!="string"||e.template.trim()==="")return[r.templateText(n)];const l=$c(e.template);return l.length===0?[r.templateNoField(n)]:l.filter(c=>!t.some(i=>i.name===c)).map(c=>r.templateField(n,c))}default:return[...t.some(l=>l.name===e.from&&l.type==="text")?[]:[r.fromText(n)],...e.scope===void 0||ya.includes(e.scope)?[]:[r.scopeOneOf(n,ya.join(r.sep))]]}}function Uh(e,t,{kn:n,objectType:o,cypher:s}){const r=Je();if(s)return[r.relatedCypher(t)];if(!Array.isArray(e.path)||e.path.length===0)return[r.pathNeeded(t)];const a=dn(n,o,e.path);if(!a)return[r.pathUnreachable(t,o)];const l=n.objectTypes[a[a.length-1].to],c=l?.properties??[];if(!Lt(e.aggregate,zs))return[r.aggregateOneOf(t,zs.join(r.sep))];const i=[],d=c.find(h=>h.name===e.field);return e.aggregate==="one"||e.aggregate==="list"?d?e.aggregate==="one"&&e.type!==d.type?i.push(r.typeOfTaken(t,d.type)):e.aggregate==="list"&&e.type!==void 0&&e.type!=="text"&&i.push(r.typeListIsText(t)):i.push(r.fieldOfProperty(t,l?.name??r.endObjectType)):(e.aggregate!=="count"&&d?.type!=="number"&&i.push(r.fieldNumberProperty(t,l?.name??r.endObjectType)),e.type!==void 0&&i.push(r.typeOnlyOne(t))),e.where!==void 0&&(i.push(...xe(e.where,c,`${t}.where`)),Array.isArray(e.where)&&e.where.some(h=>Oe(h)&&(h.ref!==void 0||h.field===he))&&i.push(r.whereFixed(t))),i}function zh(e,t,{kn:n,objectType:o,cypher:s,sources:r},a){const l=Je();if(s)return[l.matchedCypher(t)];if(typeof e.source!="string"||e.source==="")return[l.otherSource(t)];const c=r?.find(h=>h.id===e.source);if(r&&(!c||c.cypher||c.events||c.model||c.from))return[l.otherSourceKind(t)];const i=c?[...n.objectTypes[c.objectType]?.properties??[],...Sc(c.computed).map(Rr)]:void 0,d=[];if(!Array.isArray(e.pairs)||e.pairs.length===0||e.pairs.length>4?d.push(l.pairsCount(t)):e.pairs.forEach((h,u)=>{const p=`${t}.pairs[${u}]`;return Oe(h)?(n.objectTypes[o]?.properties.some(m=>m.name===h.field)||a.some(m=>m.name===h.field)||d.push(l.fieldOfProperty(p,o)),i&&!i.some(m=>m.name===h.other)&&d.push(l.otherProperty(p,c?.objectType??"")),d):d.push(l.object(p))}),e.field!==void 0){const h=i?.find(u=>u.name===e.field);i&&!h?d.push(l.fieldOfProperty(t,c?.objectType??"")):h&&e.type!==h.type&&d.push(l.typeOfTaken(t,h.type))}else e.type!==void 0&&d.push(l.typeOnlyWithField(t));return e.where!==void 0&&i&&d.push(...xe(e.where,i,`${t}.where`)),d}function Oa(e,t){const n=Je();return Oe(e)?[...typeof e.value=="string"&&e.value.trim()!==""?[]:[n.valueText(t)],...e.tone===void 0||Lt(e.tone,Pt)?[]:[n.toneOneOf(t,Pt.join(n.sep))]]:[n.object(t)]}const jc=[re.done,re.overdue,re.active],Wh=[In.edited,In.followed,In.related];function un(e){return vc(e?.computed??[],!!e?.progress)}function Kh(e){return e?e.progress?!0:JSON.stringify(e.computed??[]).includes(`"${he}"`):!1}const Yh=`计算列(sources[].computed,可选):浏览器为数据源的每行算出的列;组件、筛选像普通属性一样用它们。计算列可以读数据源的属性、进度列和其他计算列,系统按依赖自动排顺序,不能互相引用成环。每项 { name, label, kind, ... },name 为字母开头的标识,不得与属性或进度列重名:
|
|
2
2
|
- classify(判断状态){ cases: [{ when: [条件…], value, tone? }], otherwise: { value, tone? } }:从上往下取第一条全部条件成立的 value,都不成立取 otherwise;tone 为 ${Pt.join("/")},决定标签颜色。
|
|
3
3
|
- days(算天数){ from, to, when? }:from 到 to 的天数(to 减 from),二者为日期字段或 ${he};when 不成立时为空。
|
|
4
4
|
- formula(算数){ expr }:数字字段的四则运算,可用 + - * / 和括号、数字和数字字段名,比如 "<数字字段A> - <数字字段B>" 或 "$overdueDays * 2";名字不是普通标识符的字段(含 -、以数字开头)用反引号括起来,比如 \`unit-price\` * 2;字段为空或除以 0 时为空。
|
|
@@ -6,24 +6,24 @@ import{spawnSync as pu,execFile as fu,spawn as mu}from"node:child_process";impor
|
|
|
6
6
|
- region(识别地区){ from, scope? }:从文本字段里识别地区。scope 为 china(默认,中国的省份,可从客户名称这类含地名的文字里推断)或 world(国家,按中英文国名、常见别称或 ISO 代码识别)。只在数据里确实有地名时才用。
|
|
7
7
|
- text(拼文本){ template }:用 {字段名} 把几个字段和文字拼成一列文本,如 "{given_name} {family_name}" 得到球员全名、"{code} - {name}";引用的字段都为空时为空。需要显示全名、组合名称时用它(后端查询不能拼字符串)。
|
|
8
8
|
条件 { field, op, ref? | value? | values? }:field 为字段或 ${he};op 为 isSet、isEmpty(无需另一边)、eq、ne(文本或数字)、in(values 文本列表)、before、onOrBefore、after、onOrAfter(日期,另一边为日期字段、${he} 或 YYYY-MM-DD)、gt、gte、lt、lte(数字);另一边是字段或 ${he} 时写 ref,是值时写 value。
|
|
9
|
-
状态、超期天数这类随进度变化的列,优先用进度(progress)自动得出,不要再用计算列重写一遍。`;function Ae(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Lt(e,t){return typeof e=="string"&&t.includes(e)}const zh={object:e=>`${e} 必须是对象`,noOption:(e,t)=>`${e} 没有配置项 ${t}`,required:e=>`${e} 必填`,identifier:e=>`${e} 必须是字母开头的标识`,duplicate:(e,t)=>`${e} 重复:${t}`,paramsCount:(e,t)=>`${e} 必须是 1 到 ${t} 个参数`,typeOneOf:(e,t)=>`${e} 只能是 ${t.join("、")}`,minOverMax:e=>`${e} 不能大于 max`,operationsList:(e,t)=>`${e} 必须是不超过 ${t} 项的列表`,label:e=>`${e} 必须是不超过 30 字的名称`,effectsCount:(e,t,n)=>`${e} 必须是 ${t} 到 ${n} 个效果`,propertyOf:(e,t)=>`${e} 必须是 ${t} 的属性`,notKey:e=>`${e} 不能是对象的主键或标识`,kindOneOf:(e,t)=>`${e} 只能是 ${t.join("、")}`,kindOnlyFor:(e,t,n)=>`${e} ${t} 只能用于${n.join("、")}类型的属性`,ownParam:e=>`${e} 必须是本操作的参数`,paramNeeds:(e,t,n,o)=>`${e} 要求 ${t.join(" 或 ")} 类型的参数,${n} 是 ${o}`,notActionType:e=>`${e} 不是知识网络中的行动类型`,actionOn:(e,t)=>`${e} 必须作用于 ${t},或是新建对象的行动`,notUserParam:e=>`${e} 不是该行动的用户填写参数`,contextOneOf:(e,t)=>`${e} 只能是 ${t.join("、")}`,fromOneOf:e=>`${e} 只能是 param、field、const 或 context`,uniqueOnlyCreate:e=>`${e} 只用于新建对象的行动`,uniqueList:(e,t)=>`${e} 必须是 ${t} 的属性列表`,adjustNeedsLayer:()=>"图层需要先选好开始和结束",adjustSetters:(e,t)=>`操作须用日期或日期时间参数设置开始(${e})和结束(${t})`,adjustOther:e=>`操作只能设置开始、结束和所属资源,不能改 ${e}`},Wh={object:e=>`${e} must be an object`,noOption:(e,t)=>`${e} has no option ${t}`,required:e=>`${e} is required`,identifier:e=>`${e} must be an identifier starting with a letter`,duplicate:(e,t)=>`${e} is used twice: ${t}`,paramsCount:(e,t)=>`${e} must be 1 to ${t} parameters`,typeOneOf:(e,t)=>`${e} must be one of ${t.join(", ")}`,minOverMax:e=>`${e} cannot be greater than max`,operationsList:(e,t)=>`${e} must be a list of at most ${t} items`,label:e=>`${e} must be a name of at most 30 characters`,effectsCount:(e,t,n)=>`${e} must be ${t} to ${n} effects`,propertyOf:(e,t)=>`${e} must be a property of ${t}`,notKey:e=>`${e} cannot be the primary key or identifier of the object`,kindOneOf:(e,t)=>`${e} must be one of ${t.join(", ")}`,kindOnlyFor:(e,t,n)=>`${e} ${t} only works on properties of type ${n.join(", ")}`,ownParam:e=>`${e} must be a parameter of this operation`,paramNeeds:(e,t,n,o)=>`${e} needs a parameter of type ${t.join(" or ")}, but ${n} is ${o}`,notActionType:e=>`${e} is not an action type of the knowledge network`,actionOn:(e,t)=>`${e} must act on ${t}, or be an action that creates an object`,notUserParam:e=>`${e} is not a parameter the user fills in for this action`,contextOneOf:(e,t)=>`${e} must be one of ${t.join(", ")}`,fromOneOf:e=>`${e} must be param, field, const or context`,uniqueOnlyCreate:e=>`${e} is only for actions that create an object`,uniqueList:(e,t)=>`${e} must be a list of properties of ${t}`,adjustNeedsLayer:()=>"the layer needs a start and an end first",adjustSetters:(e,t)=>`the operation must set the start (${e}) and the end (${t}) from date or datetime parameters`,adjustOther:e=>`the operation can only set the start, the end and the resource it belongs to, not ${e}`},lo=()=>fe({"zh-CN":zh,"en-US":Wh}),vc=/^[A-Za-z][A-Za-z0-9_]*$/,Kh=["number","date","text"],Yh=["number","date","datetime","text"],Js=10,Hn=5,Zs=5,at=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Gh(e,t){return e==="shiftDays"||e==="fromAsOf"?{param:["number"],field:["date"]}:e==="add"?{param:["number"],field:["number"]}:t==="date"?{param:["date","datetime"],field:[]}:{param:[t==="number"?"number":"text"],field:[]}}function $c(e,t,n=Kh){const o=lo(),s=[],r=new Map;return!Array.isArray(e)||e.length===0||e.length>Hn?{errors:[o.paramsCount(t,Hn)],types:r}:(e.forEach((a,l)=>{const c=`${t}[${l}]`;return at(a)?(typeof a.name!="string"||!vc.test(a.name)?s.push(o.identifier(`${c}.name`)):r.has(a.name)&&s.push(o.duplicate(`${c}.name`,a.name)),(typeof a.label!="string"||!a.label.trim())&&s.push(o.required(`${c}.label`)),n.includes(a.type)?typeof a.name=="string"&&r.set(a.name,a.type):s.push(o.typeOneOf(`${c}.type`,n)),typeof a.min=="number"&&typeof a.max=="number"&&a.min>a.max&&s.push(o.minOverMax(`${c}.min`)),s):s.push(o.object(c))}),{errors:s,types:r})}function Hh(e,t,n,o){const s=lo();if(!Array.isArray(e)||e.length>Js)return[s.operationsList(o,Js)];const r=n.objectTypes[t.objectType],a=r?.properties??[],l=pe(t,n),c=new Set;return e.flatMap((i,d)=>{const h=`${o}[${d}]`;if(!at(i))return[s.object(h)];const u=Object.keys(i).filter(y=>!["id","label","when","params","effects","action"].includes(y)).map(y=>s.noOption(h,y));typeof i.id!="string"||!vc.test(i.id)?u.push(s.identifier(`${h}.id`)):c.has(i.id)?u.push(s.duplicate(`${h}.id`,i.id)):c.add(i.id),(typeof i.label!="string"||!i.label.trim()||i.label.length>30)&&u.push(s.label(`${h}.label`)),i.when!==void 0&&u.push(...xe(i.when,l,`${h}.when`,dn(t)));const p=$c(i.params,`${h}.params`,Yh);u.push(...p.errors);const f=p.types,m=Vh(i,n),g=Array.isArray(i.effects)?i.effects:null;if(!g||g.length===0&&!m||g.length>Zs?u.push(s.effectsCount(`${h}.effects`,m?0:1,Zs)):g.forEach((y,b)=>{const k=`${h}.effects[${b}]`;if(!at(y))return u.push(s.object(k));const w=a.find(j=>j.name===y.field);if(!w)return u.push(s.propertyOf(`${k}.field`,t.objectType));if(y.field===t.key||r?.primaryKeys.includes(w.name))return u.push(s.notKey(`${k}.field`));if(!Ks.includes(y.kind))return u.push(s.kindOneOf(`${k}.kind`,Ks));const v=Gh(String(y.kind),w.type);v.field.length>0&&!v.field.includes(w.type)&&u.push(s.kindOnlyFor(k,String(y.kind),v.field));const S=f.get(String(y.param));return S?v.param.includes(S)||u.push(s.paramNeeds(`${k}.param`,v.param,String(y.param),S)):u.push(s.ownParam(`${k}.param`)),u}),i.action!==void 0){const y=at(i.action)?i.action:null,b=y&&typeof y.id=="string"?ln(n,y.id):void 0;if(!y)u.push(s.object(`${h}.action`));else if(n.actionTypes!==void 0){if(b?b.objectType!==t.objectType&&ao(b)!=="create"&&u.push(s.actionOn(`${h}.action.id`,t.objectType)):u.push(s.notActionType(`${h}.action.id`)),b&&y.params!==void 0)if(!at(y.params))u.push(s.object(`${h}.action.params`));else for(const[k,w]of Object.entries(y.params)){const v=`${h}.action.params.${k}`;b.inputs.some(S=>S.name===k)?at(w)?w.from==="param"&&!f.has(String(w.name))?u.push(s.ownParam(`${v}.name`)):w.from==="field"&&!a.some(S=>S.name===w.name)?u.push(s.propertyOf(`${v}.name`,t.objectType)):w.from==="const"&&w.value===void 0?u.push(s.required(`${v}.value`)):w.from==="context"&&!Ys.includes(w.name)?u.push(s.contextOneOf(`${v}.name`,Ys)):["param","field","const","context"].includes(String(w.from))||u.push(s.fromOneOf(`${v}.from`)):u.push(s.object(v)):u.push(s.notUserParam(v))}b&&u.push(...Jh(y,b,n,h))}}return u})}function Vh(e,t){const n=at(e.action)?e.action:null,o=n?ln(t,n.id):void 0;return o!==void 0&&ao(o)==="create"}function Jh(e,t,n,o){if(e.unique===void 0&&e.active===void 0)return[];const s=lo();if(ao(t)!=="create")return[s.uniqueOnlyCreate(`${o}.action.unique`)];const r=n.objectTypes[t.objectType]?.properties??[],a=[],l=e.unique;return(!Array.isArray(l)||l.length===0||l.some(c=>!r.some(i=>i.name===c)))&&a.push(s.uniqueList(`${o}.action.unique`,t.objectType)),e.active!==void 0&&a.push(...xe(e.active,r,`${o}.action.active`)),a}const Ta=e=>e?.type==="date"||e?.type==="datetime";function Oa(e,t){if(!t)return;const n=e.effects.find(o=>o.kind==="set"&&o.field===t);return n&&e.params.find(o=>o.name===n.param)}function Zh(e,t){const n=c=>typeof c=="string"&&c!==""?c:void 0,o=n(t.startField),s=n(t.endField),r=lo();if(!o||!s)return r.adjustNeedsLayer();if(!Ta(Oa(e,o))||!Ta(Oa(e,s)))return r.adjustSetters(o,s);const a=[o,s,n(t.resourceField)],l=e.effects.find(c=>c.kind!=="set"||!a.includes(c.field));if(l)return r.adjustOther(l.field)}const Xh={joiner:"、",list:(e,t)=>`${e} 必须是不超过 ${t} 项的列表`,object:e=>`${e} 必须是对象`,noOption:(e,t)=>`${e} 没有配置项 ${t}`,idFormat:e=>`${e} 必须是字母开头的标识`,idTwice:(e,t)=>`${e} 重复:${t}`,label:e=>`${e} 必须是不超过 30 字的名称`,text:e=>`${e} 必须是文字`,tool:e=>`${e} 必须写明执行工厂的工具箱 box 与工具 tool`,required:e=>`${e} 必填`,inputsCount:(e,t)=>`${e} 必须是 1 到 ${t} 个属性`,inputField:e=>`${e} 必须是本数据源的字段`,outputsCount:(e,t)=>`${e} 必须是 1 到 ${t} 个结果字段`,outputSameName:(e,t)=>`${e} 与本数据源的字段同名:${t}`,oneOf:(e,t)=>`${e} 只能是 ${t}`,measuresCount:(e,t)=>`${e} 必须是 1 到 ${t} 个度量`,valueField:e=>`${e} 必须是本数据源的字段或模型的结果字段`,valueFieldNumber:e=>`${e} 求和、平均、最大、最小须是数字字段`,actionType:e=>`${e} 不是知识网络中的行动类型`,actionObjectType:(e,t)=>`${e} 必须作用于 ${t}`,notUserParam:e=>`${e} 不是该行动的用户填写参数`,mustBeModelParam:e=>`${e} 必须是本模型的参数`,mustBePropertyOf:(e,t)=>`${e} 必须是 ${t} 的属性`,mustBeModelOutput:e=>`${e} 必须是本模型的结果字段`,fromOneOf:e=>`${e} 只能是 param、field、output 或 const`},Qh={joiner:", ",list:(e,t)=>`${e} must be a list of at most ${t} items`,object:e=>`${e} must be an object`,noOption:(e,t)=>`${e} has no option ${t}`,idFormat:e=>`${e} must be an identifier starting with a letter`,idTwice:(e,t)=>`${e} is used twice: ${t}`,label:e=>`${e} must be a name of at most 30 characters`,text:e=>`${e} must be text`,tool:e=>`${e} must name the execution factory toolbox (box) and tool`,required:e=>`${e} is required`,inputsCount:(e,t)=>`${e} must list 1 to ${t} properties`,inputField:e=>`${e} must be a field of this source`,outputsCount:(e,t)=>`${e} must list 1 to ${t} result fields`,outputSameName:(e,t)=>`${e} has the same name as a field of this source: ${t}`,oneOf:(e,t)=>`${e} must be one of ${t}`,measuresCount:(e,t)=>`${e} must list 1 to ${t} measures`,valueField:e=>`${e} must be a field of this source or a result field of the model`,valueFieldNumber:e=>`${e} must be a number field for sum, average, max and min`,actionType:e=>`${e} is not an action type of the knowledge network`,actionObjectType:(e,t)=>`${e} must act on ${t}`,notUserParam:e=>`${e} is not a parameter the user fills in for this action`,mustBeModelParam:e=>`${e} must be a parameter of this model`,mustBePropertyOf:(e,t)=>`${e} must be a property of ${t}`,mustBeModelOutput:e=>`${e} must be a result field of this model`,fromOneOf:e=>`${e} must be one of param, field, output or const`},Ea=()=>fe({"zh-CN":Xh,"en-US":Qh}),Ca=/^[A-Za-z][A-Za-z0-9_]*$/,Ro=["number","date","text"],Xs=["count","sum","avg","min","max","ratio"],Qs=5,er=20,tr=8,nr=8,Xe=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function ep(e,t,n,o){if(!Array.isArray(e)||e.length>Qs)return[Ea().list(o,Qs)];const s=Ea(),r=pe(t,n),a=new Set(r.map(i=>i.name)),l=n.objectTypes[t.objectType]?.properties??[],c=new Set;return e.flatMap((i,d)=>{const h=`${o}[${d}]`;if(!Xe(i))return[s.object(h)];const u=Object.keys(i).filter(w=>!["id","label","description","tool","inputs","params","outputs","measures","action"].includes(w)).map(w=>s.noOption(h,w));typeof i.id!="string"||!Ca.test(i.id)?u.push(s.idFormat(`${h}.id`)):c.has(i.id)?u.push(s.idTwice(`${h}.id`,i.id)):c.add(i.id),(typeof i.label!="string"||!i.label.trim()||i.label.length>30)&&u.push(s.label(`${h}.label`)),i.description!==void 0&&typeof i.description!="string"&&u.push(s.text(`${h}.description`));const p=Xe(i.tool)?i.tool:null;!p||typeof p.box!="string"||!p.box||typeof p.tool!="string"?u.push(s.tool(`${h}.tool`)):p.tool||u.push(s.required(`${h}.tool.tool`));const f=Array.isArray(i.inputs)?i.inputs:null;!f||f.length===0||f.length>er?u.push(s.inputsCount(`${h}.inputs`,er)):f.forEach((w,v)=>{(typeof w!="string"||!a.has(w))&&u.push(s.inputField(`${h}.inputs[${v}]`))});const m=$c(i.params,`${h}.params`);u.push(...m.errors);const g=Array.isArray(i.outputs)?i.outputs:null,y=new Set;!g||g.length===0||g.length>tr?u.push(s.outputsCount(`${h}.outputs`,tr)):g.forEach((w,v)=>{const S=`${h}.outputs[${v}]`;return Xe(w)?(typeof w.name!="string"||!Ca.test(w.name)?u.push(s.idFormat(`${S}.name`)):a.has(w.name)?u.push(s.outputSameName(`${S}.name`,w.name)):y.has(w.name)?u.push(s.idTwice(`${S}.name`,w.name)):y.add(w.name),(typeof w.label!="string"||!w.label.trim())&&u.push(s.required(`${S}.label`)),Ro.includes(w.type)||u.push(s.oneOf(`${S}.type`,Ro.join(s.joiner))),u):u.push(s.object(S))});const b=[...r,...(g??[]).filter(Xe).map(w=>({name:String(w.name),label:String(w.label),type:Ro.includes(w.type)?w.type:"text"}))],k=Array.isArray(i.measures)?i.measures:null;if(!k||k.length===0||k.length>nr?u.push(s.measuresCount(`${h}.measures`,nr)):k.forEach((w,v)=>{const S=`${h}.measures[${v}]`;if(!Xe(w))return u.push(s.object(S));if((typeof w.label!="string"||!w.label.trim())&&u.push(s.required(`${S}.label`)),Xs.includes(w.aggregate)||u.push(s.oneOf(`${S}.aggregate`,Xs.join(s.joiner))),w.when!==void 0&&u.push(...xe(w.when,b,`${S}.when`,dn(t))),["sum","avg","min","max"].includes(String(w.aggregate))){const O=b.find(A=>A.name===w.valueField);O?O.type!=="number"&&u.push(s.valueFieldNumber(`${S}.valueField`)):u.push(s.valueField(`${S}.valueField`))}return u}),i.action!==void 0){const w=Xe(i.action)?i.action:null,v=w&&typeof w.id=="string"?ln(n,w.id):void 0;if(!w)u.push(s.object(`${h}.action`));else if(n.actionTypes!==void 0){if(!v)u.push(s.actionType(`${h}.action.id`));else if(v.objectType!==t.objectType)u.push(s.actionObjectType(`${h}.action.id`,t.objectType));else if(w.params!==void 0)if(!Xe(w.params))u.push(s.object(`${h}.action.params`));else for(const[S,j]of Object.entries(w.params)){const O=`${h}.action.params.${S}`;v.inputs.some(A=>A.name===S)?Xe(j)?j.from==="param"&&!m.types.has(String(j.name))?u.push(s.mustBeModelParam(`${O}.name`)):j.from==="field"&&!l.some(A=>A.name===j.name)?u.push(s.mustBePropertyOf(`${O}.name`,t.objectType)):j.from==="output"&&!y.has(String(j.name))?u.push(s.mustBeModelOutput(`${O}.name`)):j.from==="const"&&j.value===void 0?u.push(s.required(`${O}.value`)):["param","field","output","const"].includes(String(j.from))||u.push(s.fromOneOf(`${O}.from`)):u.push(s.object(O)):u.push(s.notUserParam(O))}}}return u})}const tp=JSON.parse(`[{"name":"Fiji","zh":"斐济","a2":"FJ","a3":"FJI","alt":["Republic of Fiji"]},{"name":"Tanzania","zh":"坦桑尼亚","a2":"TZ","a3":"TZA","alt":["United Republic of Tanzania"]},{"name":"Western Sahara","zh":"西撒哈拉","a2":"EH","a3":"ESH","alt":["Sahrawi Arab Democratic Republic","W. Sahara"]},{"name":"Canada","zh":"加拿大","a2":"CA","a3":"CAN"},{"name":"United States of America","zh":"美国","a2":"US","a3":"USA","alt":["United States"]},{"name":"Kazakhstan","zh":"哈萨克斯坦","a2":"KZ","a3":"KAZ","alt":["Republic of Kazakhstan"]},{"name":"Uzbekistan","zh":"乌兹别克斯坦","a2":"UZ","a3":"UZB","alt":["Republic of Uzbekistan"]},{"name":"Papua New Guinea","zh":"巴布亚新几内亚","a2":"PG","a3":"PNG","alt":["Independent State of Papua New Guinea"]},{"name":"Indonesia","zh":"印度尼西亚","a2":"ID","a3":"IDN","alt":["Republic of Indonesia"]},{"name":"Argentina","zh":"阿根廷","a2":"AR","a3":"ARG","alt":["Argentine Republic"]},{"name":"Chile","zh":"智利","a2":"CL","a3":"CHL","alt":["Republic of Chile"]},{"name":"Democratic Republic of the Congo","zh":"刚果民主共和国","a2":"CD","a3":"COD","alt":["Congo, Dem. Rep.","Dem. Rep. Congo"]},{"name":"Somalia","zh":"索马里","a2":"SO","a3":"SOM","alt":["Federal Republic of Somalia"]},{"name":"Kenya","zh":"肯尼亚","a2":"KE","a3":"KEN","alt":["Republic of Kenya"]},{"name":"Sudan","zh":"苏丹","a2":"SD","a3":"SDN","alt":["Republic of the Sudan"]},{"name":"Chad","zh":"乍得","a2":"TD","a3":"TCD","alt":["Republic of Chad"]},{"name":"Haiti","zh":"海地","a2":"HT","a3":"HTI","alt":["Republic of Haiti"]},{"name":"Dominican Republic","zh":"多米尼加","a2":"DO","a3":"DOM","alt":["Dominican Rep."]},{"name":"Russia","zh":"俄罗斯","a2":"RU","a3":"RUS","alt":["Russian Federation"]},{"name":"The Bahamas","zh":"巴哈马","a2":"BS","a3":"BHS","alt":["Bahamas","Bahamas, The","Commonwealth of the Bahamas"]},{"name":"Falkland Islands","zh":"福克兰群岛","a2":"FK","a3":"FLK","alt":["Falkland Is.","Falkland Islands / Malvinas"]},{"name":"Norway","zh":"挪威","a2":"NO","a3":"NOR","alt":["Kingdom of Norway"]},{"name":"Greenland","zh":"格陵兰","a2":"GL","a3":"GRL"},{"name":"French Southern and Antarctic Lands","zh":"法属南部和南极领地","a2":"TF","a3":"ATF","alt":["Fr. S. Antarctic Lands","Territory of the French Southern and Antarctic Lands"]},{"name":"East Timor","zh":"东帝汶","a2":"TL","a3":"TLS","alt":["Democratic Republic of Timor-Leste","Timor-Leste"]},{"name":"South Africa","zh":"南非","a2":"ZA","a3":"ZAF","alt":["Republic of South Africa"]},{"name":"Lesotho","zh":"莱索托","a2":"LS","a3":"LSO","alt":["Kingdom of Lesotho"]},{"name":"Mexico","zh":"墨西哥","a2":"MX","a3":"MEX","alt":["United Mexican States"]},{"name":"Uruguay","zh":"乌拉圭","a2":"UY","a3":"URY","alt":["Oriental Republic of Uruguay"]},{"name":"Brazil","zh":"巴西","a2":"BR","a3":"BRA","alt":["Federative Republic of Brazil"]},{"name":"Bolivia","zh":"玻利维亚","a2":"BO","a3":"BOL","alt":["Plurinational State of Bolivia"]},{"name":"Peru","zh":"秘鲁","a2":"PE","a3":"PER","alt":["Republic of Peru"]},{"name":"Colombia","zh":"哥伦比亚","a2":"CO","a3":"COL","alt":["Republic of Colombia"]},{"name":"Panama","zh":"巴拿马","a2":"PA","a3":"PAN","alt":["Republic of Panama"]},{"name":"Costa Rica","zh":"哥斯达黎加","a2":"CR","a3":"CRI","alt":["Republic of Costa Rica"]},{"name":"Nicaragua","zh":"尼加拉瓜","a2":"NI","a3":"NIC","alt":["Republic of Nicaragua"]},{"name":"Honduras","zh":"洪都拉斯","a2":"HN","a3":"HND","alt":["Republic of Honduras"]},{"name":"El Salvador","zh":"萨尔瓦多","a2":"SV","a3":"SLV","alt":["Republic of El Salvador"]},{"name":"Guatemala","zh":"危地马拉","a2":"GT","a3":"GTM","alt":["Republic of Guatemala"]},{"name":"Belize","zh":"伯利兹","a2":"BZ","a3":"BLZ"},{"name":"Venezuela","zh":"委内瑞拉","a2":"VE","a3":"VEN","alt":["Bolivarian Republic of Venezuela","Venezuela, RB"]},{"name":"Guyana","zh":"圭亚那","a2":"GY","a3":"GUY","alt":["Co-operative Republic of Guyana"]},{"name":"Suriname","zh":"苏里南","a2":"SR","a3":"SUR","alt":["Republic of Suriname"]},{"name":"France","zh":"法国","a2":"FR","a3":"FRA","alt":["French Republic"]},{"name":"Ecuador","zh":"厄瓜多尔","a2":"EC","a3":"ECU","alt":["Republic of Ecuador"]},{"name":"Puerto Rico","zh":"波多黎各","a2":"PR","a3":"PRI","alt":["Commonwealth of Puerto Rico"]},{"name":"Jamaica","zh":"牙买加","a2":"JM","a3":"JAM"},{"name":"Cuba","zh":"古巴","a2":"CU","a3":"CUB","alt":["Republic of Cuba"]},{"name":"Zimbabwe","zh":"津巴布韦","a2":"ZW","a3":"ZWE","alt":["Republic of Zimbabwe"]},{"name":"Botswana","zh":"博茨瓦纳","a2":"BW","a3":"BWA","alt":["Republic of Botswana"]},{"name":"Namibia","zh":"纳米比亚","a2":"NA","a3":"NAM","alt":["Republic of Namibia"]},{"name":"Senegal","zh":"塞内加尔","a2":"SN","a3":"SEN","alt":["Republic of Senegal"]},{"name":"Mali","zh":"马里","a2":"ML","a3":"MLI","alt":["Republic of Mali"]},{"name":"Mauritania","zh":"毛里塔尼亚","a2":"MR","a3":"MRT","alt":["Islamic Republic of Mauritania"]},{"name":"Benin","zh":"贝宁","a2":"BJ","a3":"BEN","alt":["Republic of Benin"]},{"name":"Niger","zh":"尼日尔","a2":"NE","a3":"NER","alt":["Republic of Niger"]},{"name":"Nigeria","zh":"尼日利亚","a2":"NG","a3":"NGA","alt":["Federal Republic of Nigeria"]},{"name":"Cameroon","zh":"喀麦隆","a2":"CM","a3":"CMR","alt":["Republic of Cameroon"]},{"name":"Togo","zh":"多哥","a2":"TG","a3":"TGO","alt":["Togolese Republic"]},{"name":"Ghana","zh":"加纳","a2":"GH","a3":"GHA","alt":["Republic of Ghana"]},{"name":"Ivory Coast","zh":"科特迪瓦","a2":"CI","a3":"CIV","alt":["Côte d'Ivoire","Republic of Ivory Coast"]},{"name":"Guinea","zh":"几内亚","a2":"GN","a3":"GIN","alt":["Republic of Guinea"]},{"name":"Guinea-Bissau","zh":"几内亚比绍","a2":"GW","a3":"GNB","alt":["Republic of Guinea-Bissau"]},{"name":"Liberia","zh":"利比里亚","a2":"LR","a3":"LBR","alt":["Republic of Liberia"]},{"name":"Sierra Leone","zh":"塞拉利昂","a2":"SL","a3":"SLE","alt":["Republic of Sierra Leone"]},{"name":"Burkina Faso","zh":"布基纳法索","a2":"BF","a3":"BFA"},{"name":"Central African Republic","zh":"中非共和国","a2":"CF","a3":"CAF","alt":["Central African Rep."]},{"name":"Republic of the Congo","zh":"刚果共和国","a2":"CG","a3":"COG","alt":["Congo","Congo, Rep."]},{"name":"Gabon","zh":"加蓬","a2":"GA","a3":"GAB","alt":["Gabonese Republic"]},{"name":"Equatorial Guinea","zh":"赤道几内亚","a2":"GQ","a3":"GNQ","alt":["Eq. Guinea","Republic of Equatorial Guinea"]},{"name":"Zambia","zh":"赞比亚","a2":"ZM","a3":"ZMB","alt":["Republic of Zambia"]},{"name":"Malawi","zh":"马拉维","a2":"MW","a3":"MWI","alt":["Republic of Malawi"]},{"name":"Mozambique","zh":"莫桑比克","a2":"MZ","a3":"MOZ","alt":["Republic of Mozambique"]},{"name":"Eswatini","zh":"斯威士兰","a2":"SZ","a3":"SWZ","alt":["Kingdom of eSwatini","eSwatini"]},{"name":"Angola","zh":"安哥拉","a2":"AO","a3":"AGO","alt":["People's Republic of Angola"]},{"name":"Burundi","zh":"布隆迪","a2":"BI","a3":"BDI","alt":["Republic of Burundi"]},{"name":"Israel","zh":"以色列","a2":"IL","a3":"ISR","alt":["State of Israel"]},{"name":"Lebanon","zh":"黎巴嫩","a2":"LB","a3":"LBN","alt":["Lebanese Republic"]},{"name":"Madagascar","zh":"马达加斯加","a2":"MG","a3":"MDG","alt":["Republic of Madagascar"]},{"name":"Palestine","zh":"巴勒斯坦","a2":"PS","a3":"PSE","alt":["Palestine (West Bank and Gaza)","West Bank and Gaza"]},{"name":"The Gambia","zh":"冈比亚","a2":"GM","a3":"GMB","alt":["Gambia","Gambia, The","Republic of the Gambia"]},{"name":"Tunisia","zh":"突尼斯","a2":"TN","a3":"TUN","alt":["Republic of Tunisia"]},{"name":"Algeria","zh":"阿尔及利亚","a2":"DZ","a3":"DZA","alt":["People's Democratic Republic of Algeria"]},{"name":"Jordan","zh":"约旦","a2":"JO","a3":"JOR","alt":["Hashemite Kingdom of Jordan"]},{"name":"United Arab Emirates","zh":"阿拉伯联合酋长国","a2":"AE","a3":"ARE"},{"name":"Qatar","zh":"卡塔尔","a2":"QA","a3":"QAT","alt":["State of Qatar"]},{"name":"Kuwait","zh":"科威特","a2":"KW","a3":"KWT","alt":["State of Kuwait"]},{"name":"Iraq","zh":"伊拉克","a2":"IQ","a3":"IRQ","alt":["Republic of Iraq"]},{"name":"Oman","zh":"阿曼","a2":"OM","a3":"OMN","alt":["Sultanate of Oman"]},{"name":"Vanuatu","zh":"瓦努阿图","a2":"VU","a3":"VUT","alt":["Republic of Vanuatu"]},{"name":"Cambodia","zh":"柬埔寨","a2":"KH","a3":"KHM","alt":["Kingdom of Cambodia"]},{"name":"Thailand","zh":"泰国","a2":"TH","a3":"THA","alt":["Kingdom of Thailand"]},{"name":"Laos","zh":"老挝","a2":"LA","a3":"LAO","alt":["Lao PDR","Lao People's Democratic Republic"]},{"name":"Myanmar","zh":"缅甸","a2":"MM","a3":"MMR","alt":["Republic of the Union of Myanmar"]},{"name":"Vietnam","zh":"越南","a2":"VN","a3":"VNM","alt":["Socialist Republic of Vietnam"]},{"name":"North Korea","zh":"朝鲜民主主义人民共和国","a2":"KP","a3":"PRK","alt":["Dem. Rep. Korea","Democratic People's Republic of Korea","Korea, Dem. Rep."]},{"name":"South Korea","zh":"大韩民国","a2":"KR","a3":"KOR","alt":["Korea, Rep.","Republic of Korea"]},{"name":"Mongolia","zh":"蒙古国","a2":"MN","a3":"MNG"},{"name":"India","zh":"印度","a2":"IN","a3":"IND","alt":["Republic of India"]},{"name":"Bangladesh","zh":"孟加拉国","a2":"BD","a3":"BGD","alt":["People's Republic of Bangladesh"]},{"name":"Bhutan","zh":"不丹","a2":"BT","a3":"BTN","alt":["Kingdom of Bhutan"]},{"name":"Nepal","zh":"尼泊尔","a2":"NP","a3":"NPL"},{"name":"Pakistan","zh":"巴基斯坦","a2":"PK","a3":"PAK","alt":["Islamic Republic of Pakistan"]},{"name":"Afghanistan","zh":"阿富汗","a2":"AF","a3":"AFG","alt":["Islamic State of Afghanistan"]},{"name":"Tajikistan","zh":"塔吉克斯坦","a2":"TJ","a3":"TJK","alt":["Republic of Tajikistan"]},{"name":"Kyrgyzstan","zh":"吉尔吉斯斯坦","a2":"KG","a3":"KGZ","alt":["Kyrgyz Republic"]},{"name":"Turkmenistan","zh":"土库曼斯坦","a2":"TM","a3":"TKM"},{"name":"Iran","zh":"伊朗","a2":"IR","a3":"IRN","alt":["Iran, Islamic Rep.","Islamic Republic of Iran"]},{"name":"Syria","zh":"叙利亚","a2":"SY","a3":"SYR","alt":["Syrian Arab Republic"]},{"name":"Armenia","zh":"亚美尼亚","a2":"AM","a3":"ARM","alt":["Republic of Armenia"]},{"name":"Sweden","zh":"瑞典","a2":"SE","a3":"SWE","alt":["Kingdom of Sweden"]},{"name":"Belarus","zh":"白俄罗斯","a2":"BY","a3":"BLR","alt":["Republic of Belarus"]},{"name":"Ukraine","zh":"乌克兰","a2":"UA","a3":"UKR"},{"name":"Poland","zh":"波兰","a2":"PL","a3":"POL","alt":["Republic of Poland"]},{"name":"Austria","zh":"奥地利","a2":"AT","a3":"AUT","alt":["Republic of Austria"]},{"name":"Hungary","zh":"匈牙利","a2":"HU","a3":"HUN","alt":["Republic of Hungary"]},{"name":"Moldova","zh":"摩尔多瓦","a2":"MD","a3":"MDA","alt":["Republic of Moldova"]},{"name":"Romania","zh":"罗马尼亚","a2":"RO","a3":"ROU"},{"name":"Lithuania","zh":"立陶宛","a2":"LT","a3":"LTU","alt":["Republic of Lithuania"]},{"name":"Latvia","zh":"拉脱维亚","a2":"LV","a3":"LVA","alt":["Republic of Latvia"]},{"name":"Estonia","zh":"爱沙尼亚","a2":"EE","a3":"EST","alt":["Republic of Estonia"]},{"name":"Germany","zh":"德国","a2":"DE","a3":"DEU","alt":["Federal Republic of Germany"]},{"name":"Bulgaria","zh":"保加利亚","a2":"BG","a3":"BGR","alt":["Republic of Bulgaria"]},{"name":"Greece","zh":"希腊","a2":"GR","a3":"GRC","alt":["Hellenic Republic"]},{"name":"Turkey","zh":"土耳其","a2":"TR","a3":"TUR","alt":["Republic of Turkey"]},{"name":"Albania","zh":"阿尔巴尼亚","a2":"AL","a3":"ALB","alt":["Republic of Albania"]},{"name":"Croatia","zh":"克罗地亚","a2":"HR","a3":"HRV","alt":["Republic of Croatia"]},{"name":"Switzerland","zh":"瑞士","a2":"CH","a3":"CHE","alt":["Swiss Confederation"]},{"name":"Luxembourg","zh":"卢森堡","a2":"LU","a3":"LUX","alt":["Grand Duchy of Luxembourg"]},{"name":"Belgium","zh":"比利时","a2":"BE","a3":"BEL","alt":["Kingdom of Belgium"]},{"name":"Netherlands","zh":"荷兰","a2":"NL","a3":"NLD","alt":["Kingdom of the Netherlands"]},{"name":"Portugal","zh":"葡萄牙","a2":"PT","a3":"PRT","alt":["Portuguese Republic"]},{"name":"Spain","zh":"西班牙","a2":"ES","a3":"ESP","alt":["Kingdom of Spain"]},{"name":"Ireland","zh":"爱尔兰","a2":"IE","a3":"IRL"},{"name":"New Caledonia","zh":"新喀里多尼亚","a2":"NC","a3":"NCL"},{"name":"Solomon Islands","zh":"所罗门群岛","a2":"SB","a3":"SLB","alt":["Solomon Is."]},{"name":"New Zealand","zh":"新西兰","a2":"NZ","a3":"NZL"},{"name":"Australia","zh":"澳大利亚","a2":"AU","a3":"AUS","alt":["Commonwealth of Australia"]},{"name":"Sri Lanka","zh":"斯里兰卡","a2":"LK","a3":"LKA","alt":["Democratic Socialist Republic of Sri Lanka"]},{"name":"People's Republic of China","zh":"中华人民共和国","a2":"CN","a3":"CHN","alt":["China","Chinese Taipei","Taiwan","中国台湾","台湾"]},{"name":"Italy","zh":"意大利","a2":"IT","a3":"ITA","alt":["Italian Republic"]},{"name":"Denmark","zh":"丹麦","a2":"DK","a3":"DNK","alt":["Kingdom of Denmark"]},{"name":"United Kingdom","zh":"英国","a2":"GB","a3":"GBR","alt":["United Kingdom of Great Britain and Northern Ireland"]},{"name":"Iceland","zh":"冰岛","a2":"IS","a3":"ISL","alt":["Republic of Iceland"]},{"name":"Azerbaijan","zh":"阿塞拜疆","a2":"AZ","a3":"AZE","alt":["Republic of Azerbaijan"]},{"name":"Georgia","zh":"格鲁吉亚","a2":"GE","a3":"GEO"},{"name":"Philippines","zh":"菲律宾","a2":"PH","a3":"PHL","alt":["Republic of the Philippines"]},{"name":"Malaysia","zh":"马来西亚","a2":"MY","a3":"MYS"},{"name":"Brunei","zh":"文莱","a2":"BN","a3":"BRN","alt":["Brunei Darussalam","Negara Brunei Darussalam"]},{"name":"Slovenia","zh":"斯洛文尼亚","a2":"SI","a3":"SVN","alt":["Republic of Slovenia"]},{"name":"Finland","zh":"芬兰","a2":"FI","a3":"FIN","alt":["Republic of Finland"]},{"name":"Slovakia","zh":"斯洛伐克","a2":"SK","a3":"SVK","alt":["Slovak Republic"]},{"name":"Czech Republic","zh":"捷克","a2":"CZ","a3":"CZE","alt":["Czechia"]},{"name":"Eritrea","zh":"厄立特里亚","a2":"ER","a3":"ERI","alt":["State of Eritrea"]},{"name":"Japan","zh":"日本","a2":"JP","a3":"JPN"},{"name":"Paraguay","zh":"巴拉圭","a2":"PY","a3":"PRY","alt":["Republic of Paraguay"]},{"name":"Yemen","zh":"也门","a2":"YE","a3":"YEM","alt":["Republic of Yemen","Yemen, Rep."]},{"name":"Saudi Arabia","zh":"沙特阿拉伯","a2":"SA","a3":"SAU","alt":["Kingdom of Saudi Arabia"]},{"name":"Antarctica","zh":"南极洲","a2":"AQ","a3":"ATA"},{"name":"Turkish Republic of Northern Cyprus","zh":"北塞浦路斯土耳其共和国","a3":"CYN","alt":["Cyprus, Northern","N. Cyprus","Northern Cyprus"]},{"name":"Cyprus","zh":"塞浦路斯","a2":"CY","a3":"CYP","alt":["Republic of Cyprus"]},{"name":"Morocco","zh":"摩洛哥","a2":"MA","a3":"MAR","alt":["Kingdom of Morocco"]},{"name":"Egypt","zh":"埃及","a2":"EG","a3":"EGY","alt":["Arab Republic of Egypt","Egypt, Arab Rep."]},{"name":"Libya","zh":"利比亚","a2":"LY","a3":"LBY"},{"name":"Ethiopia","zh":"埃塞俄比亚","a2":"ET","a3":"ETH","alt":["Federal Democratic Republic of Ethiopia"]},{"name":"Djibouti","zh":"吉布提","a2":"DJ","a3":"DJI","alt":["Republic of Djibouti"]},{"name":"Somaliland","zh":"索马里兰","a3":"SOL","alt":["Republic of Somaliland"]},{"name":"Uganda","zh":"乌干达","a2":"UG","a3":"UGA","alt":["Republic of Uganda"]},{"name":"Rwanda","zh":"卢旺达","a2":"RW","a3":"RWA","alt":["Republic of Rwanda"]},{"name":"Bosnia and Herzegovina","zh":"波斯尼亚和黑塞哥维那","a2":"BA","a3":"BIH","alt":["Bosnia and Herz."]},{"name":"North Macedonia","zh":"北马其顿","a2":"MK","a3":"MKD","alt":["Republic of North Macedonia"]},{"name":"Serbia","zh":"塞尔维亚","a2":"RS","a3":"SRB","alt":["Republic of Serbia"]},{"name":"Montenegro","zh":"黑山","a2":"ME","a3":"MNE"},{"name":"Kosovo","zh":"科索沃","a2":"XK","a3":"KOS","alt":["Republic of Kosovo"]},{"name":"Trinidad and Tobago","zh":"特立尼达和多巴哥","a2":"TT","a3":"TTO","alt":["Republic of Trinidad and Tobago"]},{"name":"South Sudan","zh":"南苏丹","a2":"SS","a3":"SSD","alt":["Republic of South Sudan","S. Sudan"]}]`),np=["北京","天津","河北","山西","内蒙古","辽宁","吉林","黑龙江","上海","江苏","浙江","安徽","福建","江西","山东","河南","湖北","湖南","广东","广西","海南","重庆","四川","贵州","云南","西藏","陕西","甘肃","青海","宁夏","新疆","台湾","香港","澳门"],op={河北:"石家庄 唐山 保定 邯郸 秦皇岛 廊坊 沧州 邢台 张家口 承德 衡水",山西:"太原 大同 长治 晋城 运城 临汾",内蒙古:"呼和浩特 包头 鄂尔多斯 赤峰",辽宁:"沈阳 大连 鞍山 抚顺 锦州 营口 丹东",吉林:"长春 四平 延吉",黑龙江:"哈尔滨 齐齐哈尔 大庆 牡丹江 佳木斯",江苏:"南京 苏州 无锡 常州 南通 徐州 扬州 镇江 盐城 泰州 连云港 淮安 宿迁 昆山 江阴",浙江:"杭州 宁波 温州 绍兴 嘉兴 金华 台州 湖州 义乌",安徽:"合肥 芜湖 蚌埠 马鞍山 安庆",福建:"福州 厦门 泉州 漳州 莆田",江西:"南昌 赣州 九江 景德镇",山东:"济南 青岛 烟台 潍坊 淄博 威海 临沂 济宁 泰安 日照 东营",河南:"郑州 洛阳 开封 新乡 南阳 许昌 安阳",湖北:"武汉 宜昌 襄阳 十堰 荆州 黄石",湖南:"长沙 株洲 湘潭 衡阳 岳阳 常德",广东:"广州 深圳 东莞 佛山 珠海 中山 惠州 汕头 江门 湛江 肇庆",广西:"南宁 柳州 桂林 北海",海南:"海口 三亚",四川:"成都 绵阳 德阳 宜宾 南充 泸州",贵州:"贵阳 遵义",云南:"昆明 大理 曲靖 玉溪",西藏:"拉萨",陕西:"西安 宝鸡 咸阳 榆林 延安 汉中",甘肃:"兰州 天水",青海:"西宁",宁夏:"银川",新疆:"乌鲁木齐 克拉玛依 喀什"};[...np.map(e=>[e,e]),...Object.entries(op).flatMap(([e,t])=>t.split(" ").map(n=>[n,e]))].sort((e,t)=>t[0].length-e[0].length);const sp={GB:["England","Scotland","Wales","Northern Ireland","Great Britain","UK","英格兰","苏格兰","威尔士","北爱尔兰"],US:["USA","United States","America","美利坚"],KR:["Korea Republic","Republic of Korea","Korea","韩国"],KP:["Korea DPR","DPR Korea","North Korea","朝鲜"],IR:["IR Iran","Iran"],CI:["Côte d'Ivoire","Cote d'Ivoire","Ivory Coast","科特迪瓦"],CZ:["Czechia","Czech Republic","捷克"],TR:["Türkiye","Turkey","土耳其"],NL:["Holland","荷兰"],IE:["Republic of Ireland","Éire"],RU:["Russia","Russian Federation","俄罗斯"],CN:["China PR","中国","TWN"],AE:["UAE","阿联酋"]},rp=e=>e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^\p{L}\p{N}]+/gu,""),ap=["zh-Hans","en"].flatMap(e=>{try{return typeof Intl<"u"&&"DisplayNames"in Intl?[new Intl.DisplayNames([e],{type:"region"})]:[]}catch{return[]}});function ip(e){return e?ap.flatMap(t=>{try{const n=t.of(e);return n&&n!==e?[n]:[]}catch{return[]}}):[]}const Sc=tp.flatMap(e=>[e.name,e.zh,e.a2,e.a3,...e.alt??[],...e.a2?sp[e.a2]??[]:[],...ip(e.a2)].filter(t=>!!t).map(t=>[rp(t),e.name])).filter(([e])=>e.length>0).sort((e,t)=>t[0].length-e[0].length);new Map(Sc);Sc.filter(([e])=>new RegExp("\\p{Script=Han}","u").test(e)&&e.length>=2);function jc(e){if(e?.length!==1)return null;const[t]=e;return t.op==="in"&&t.values?.length?{field:t.field,values:t.values}:t.op==="eq"&&t.ref===void 0&&t.value!==void 0?{field:t.field,values:[String(t.value)]}:null}function Qt(e,t){return e&&t?.length?[{field:e,op:"in",values:t}]:void 0}const lp={object:e=>`${e} 必须是对象`,noOption:(e,t)=>`${e} 没有配置项 ${t}`,oneOf:(e,t)=>`${e} 必须是 ${t.join("、")} 之一`,question:e=>`${e} 必须是不超过 300 字的问题`,placeholder:(e,t)=>`${e} 里的 {${t}} 不是这次点击能填的内容`,agent:e=>`${e} 目前只能是 analyst`,context:(e,t)=>`${e} 只能取 ${t.join("、")}`,send:(e,t)=>`${e} 只能是 ${t.join(" 或 ")}`,maxObjects:(e,t)=>`${e} 必须是 1 到 ${t} 的整数`,list:(e,t)=>`${e} 必须是不超过 ${t} 项的列表`,label:e=>`${e} 必须是不超过 20 字的文本`,steps:(e,t)=>`${e} 必须是 1 到 ${t} 个动作`,noObjectSimulate:(e,t)=>`${e} 这次点击没有对象,不能推演:${t}`,operation:(e,t)=>`${e} 必须是数据源的推演操作:${t}`,noObjectAct:(e,t)=>`${e} 这次点击没有对象,不能执行行动:${t}`,kind:e=>`${e} 只能是 ask、act 或 simulate`},cp={object:e=>`${e} must be an object`,noOption:(e,t)=>`${e} has no option ${t}`,oneOf:(e,t)=>`${e} must be one of ${t.join(", ")}`,question:e=>`${e} must be a question of at most 300 characters`,placeholder:(e,t)=>`${e} has {${t}}, which this click cannot fill in`,agent:e=>`${e} can only be analyst for now`,context:(e,t)=>`${e} must be one of ${t.join(", ")}`,send:(e,t)=>`${e} must be ${t.join(" or ")}`,maxObjects:(e,t)=>`${e} must be an integer from 1 to ${t}`,list:(e,t)=>`${e} must be a list of at most ${t} items`,label:e=>`${e} must be text of at most 20 characters`,steps:(e,t)=>`${e} must be 1 to ${t} steps`,noObjectSimulate:(e,t)=>`${e} this click has no objects, so it cannot simulate: ${t}`,operation:(e,t)=>`${e} must be a scenario operation of the source: ${t}`,noObjectAct:(e,t)=>`${e} this click has no objects, so it cannot run an action: ${t}`,kind:e=>`${e} must be ask, act or simulate`},Ac=()=>fe({"zh-CN":lp,"en-US":cp}),dp={alertList:["rule","object"],metricCards:["card"],objectTable:["row"],objectList:["row"],pivotTable:["row"],trendChart:["point"],regionMap:["region"],stageChain:["stage"],[me]:["button"]},up={alertList:["rule","object"],objectTable:["row"],objectList:["row"],pivotTable:["row"],[me]:["button"]},Na={objectTable:"row",objectList:"row",[me]:"button"},Tc={rule:["count","rule.label","rule.severity"],object:["count","rule.label","rule.severity"],card:["count","card.label","value"],row:["count"],point:["count","category","period","value","series"],region:["count","region","value"],stage:["count","stage.label"],button:["count"]},Oc=["object","row","button"],or=["hits","filters"],sr=["auto","prefill"],rr=200,hp=/\{([^{}]+)\}/g;function pp(e){return[...e.matchAll(hp)].map(t=>t[1].trim())}function ar(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function fp(e,t,n,o){const s=Ac();if(!ar(e))return[s.object(o)];const r=new Set(["on","question","agent","context","send","maxObjects"]),a=Object.keys(e).filter(l=>!r.has(l)).map(l=>s.noOption(o,l));if(t.includes(e.on)||a.push(s.oneOf(`${o}.on`,t)),typeof e.question!="string"||!e.question.trim()||e.question.length>300)a.push(s.question(`${o}.question`));else{const l=new Set([...Tc[e.on]??[],...Oc.includes(e.on)?(n??[]).map(c=>c.name):[]]);for(const c of pp(e.question))l.has(c)||a.push(s.placeholder(`${o}.question`,c))}return e.agent!==void 0&&e.agent!=="analyst"&&a.push(s.agent(`${o}.agent`)),e.context!==void 0&&(!Array.isArray(e.context)||e.context.some(l=>!or.includes(l)))&&a.push(s.context(`${o}.context`,or)),e.send!==void 0&&!sr.includes(e.send)&&a.push(s.send(`${o}.send`,sr)),e.maxObjects!==void 0&&(typeof e.maxObjects!="number"||!Number.isInteger(e.maxObjects)||e.maxObjects<1||e.maxObjects>rr)&&a.push(s.maxObjects(`${o}.maxObjects`,rr)),a}const mp=["row","object","rule","button"],gp=8,Vn=5;function yp({on:e,...t}){return{on:e,do:[{kind:"ask",...t}]}}function bp({on:e,label:t,...n}){return{on:e,...t?{label:t}:{},do:[{kind:"act",...n}]}}function wp(e,t,n,o,s,r){const a=Ac();return!Array.isArray(e)||e.length>t.max?[a.list(r,t.max)]:e.flatMap((l,c)=>{const i=`${r}[${c}]`;if(!ar(l))return[a.object(i)];const d=Object.keys(l).filter(u=>!["on","label","do"].includes(u)).map(u=>a.noOption(i,u)),h=l.on;return t.on.includes(h)?(l.label!==void 0&&(typeof l.label!="string"||l.label.length>20)&&d.push(a.label(`${i}.label`)),!Array.isArray(l.do)||l.do.length===0||l.do.length>Vn?(d.push(a.steps(`${i}.do`,Vn)),d):(l.do.forEach((u,p)=>{const f=`${i}.do[${p}]`;if(!ar(u))return d.push(a.object(f));const{kind:m,...g}=u;if(m==="ask")d.push(...fp({...g,on:h},[h],s,f));else if(m==="simulate"){t.actOn.includes(h)||d.push(a.noObjectSimulate(f,h));const y=ue(n.spec,o);Object.keys(g).filter(b=>b!=="operation").forEach(b=>d.push(a.noOption(f,b))),y?.operations?.some(b=>b.id===g.operation)||d.push(a.operation(`${f}.operation`,String(g.operation)))}else m==="act"?t.actOn.includes(h)?d.push(...dc({...g,on:h},{on:[h],hit:t.hit},n,o,f)):d.push(a.noObjectAct(f,h)):d.push(a.kind(`${f}.kind`));return d}),d)):(d.push(a.oneOf(`${i}.on`,t.on)),d)})}function kp(e,t,n,o){const s=e.filter(a=>mp.includes(a)),r=e.map(a=>`${a}:${Tc[a].join("、")}`).join(";");return[`点击时还要做什么,列表,每项 { on, label?, do }:on 为 ${e.join("、")} 之一;do 为按顺序执行的 1 到 ${Vn} 个动作(点击写入的筛选总是先写入,不写在这里)`,s.length>0?`${s.join("、")} 各项是单独一个按钮,label 为按钮文字`:"",`问 Agent 的动作 { kind: "ask", question, agent?, context?, send?, maxObjects? }:question 是问题模板,可用占位 {…}(${r}${e.some(a=>Oc.includes(a))?";点到单个对象时还可用该对象的字段名":""});context 取 hits(点到的对象)、filters(当前筛选);send 为 auto(直接发送)或 prefill(放进输入框)`,t.length>0?`推演的动作 { kind: "simulate", operation }(只能用于 ${t.join("、")}):operation 为数据源的推演操作 id,点击后由用户填参数,写入当前方案,不执行行动${o?`;数据源有推演操作而这里没写推演的动作时,${o} 上已自动提供“推演”按钮(多个操作时为下拉选择),只在要限定用哪个操作时才写`:""};执行行动的动作 { kind: "act", action, targets?, params?, confirm?, maxObjects? }(只能用于 ${t.join("、")}):action 为行动类型 id,须作用于数据源的对象类;targets ${n?"默认 hit(点到的对象),也可":""}为 { selection: 选中筛选 } 或 { set: 对象集合筛选 };params 给行动的每个“用户填写”参数指定来源:{ from: "input", label? }(确认时用户填)、{ from: "var", variable }(页面筛选的值)、{ from: "const", value };confirm 为确认时的说明,可用 {count}、{action};执行前总会弹出确认`:""].filter(Boolean).join(";")}function vp(e){return typeof e=="string"&&e!==""?e.slice(0,10):"—"}function $p(e){return e.toLocaleString(void 0,{maximumFractionDigits:2})}function Sp(e,t="text"){return e==null||e===""?"—":t==="date"?vp(e):t==="number"&&typeof e=="number"?$p(e):String(e)}let Jn=ge;function jp(e){const t=Object.values(re).find(s=>s.value===e);if(!t)return e;const n=`workshopLab.progress.status.${e}`,o=Jn.isInitialized?Jn.t(n):n;return typeof o=="string"&&o!==n?o:t.label}function Ap(e){const t=Object.values(Ln).find(s=>s.value===e);if(!t)return e;const n=`workshopLab.scenario.mark.${e}`,o=Jn.isInitialized?Jn.t(n):n;return typeof o=="string"&&o!==n?o:t.label}function _o(e,t,n){return e===le.status&&typeof t=="string"?jp(t):e===cn&&typeof t=="string"?Ap(t):Sp(t,n)}const Fe=e=>typeof e=="string"?e:"";function Tp(e,t){const n=(Array.isArray(e.layers)?e.layers:[]).filter(a=>typeof a=="object"&&a!==null),o=[],s=n.filter(a=>a.style==="standard");n.length>0&&s.length===0&&o.push({key:"noTasks"}),Fe(e.source)!==""&&Fe(e.titleField)===""&&o.push({key:"noResourceName"});const r=n.some(a=>a.style==="background"&&a.blocks===!0);for(const a of s){const l=Fe(a.label),c=Array.isArray(a.ruleTools)?a.ruleTools:[],i=u=>Array.isArray(u)&&u.length>0,d=a.exclusive===!0||r||c.length>0||Fe(a.earliestField)!==""||i(a.readyFrom)||i(a.predecessorPath);Fe(a.adjust)!==""&&!d&&o.push({key:"noConstraints",values:{layer:l}});const h=new Set;for(const u of c){const p=u?.tool;if(!p||Fe(p.box)===""||Fe(p.tool)==="")continue;const f=`${Fe(p.box)}/${Fe(p.tool)}`;h.has(f)&&o.push({key:"duplicateTool",values:{layer:l,name:Fe(u.name)}}),h.add(f)}}return o}const Op=/^\d{4}-\d{2}-\d{2}$/;function xa(e,t){const n=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(new Date(e)),o=r=>Number(n.find(a=>a.type===r)?.value);return Date.UTC(o("year"),o("month")-1,o("day"),o("hour"),o("minute"),o("second"))-(e-(e%1e3+1e3)%1e3)}function Ep(e){if(e)try{return new Intl.DateTimeFormat("en-US",{timeZone:e}),e}catch{return}}const Cp=e=>{const[t,n,o]=e.split("-").map(Number);return new Date(Date.UTC(t,n-1,o+1)).toISOString().slice(0,10)};function Ec(e,t){const[n,o,s]=e.split("-").map(Number),r=Ep(t);if(!r)return new Date(n,o-1,s).getTime();const a=Date.UTC(n,o-1,s),l=a-xa(a,r);return a-xa(l,r)}function Np(e,t){return Ec(Cp(e),t)-1}function xp(e){return new Set([...e.dimensions,...e.timeDimensions])}function Ra(e,t){return e.kn.objectTypes[e.metric.objectType]?.properties.find(n=>n.name===t)?.type}const ir=(e,t)=>({source:"property",property_ref:{object_type_id:e.objectType,property_name:t}}),Cc=e=>({source:"literal",value_type:"string",value:e}),Nc=e=>({source:"literal",value_type:Number.isInteger(e)?"int64":"decimal",value:e}),Qe=e=>({source:"literal",value_type:"datetime",value:e}),Oe=(e,t,n)=>({node_type:"predicate",left:e,comparison_operator:t,...n?{right:n}:{}});function Rp(e,t){if(t.length!==0)return t.length===1?t[0]:{node_type:"group",boolean_operator:e,children:t}}const xc=e=>e!==""&&e!==null&&e!==void 0&&!Number.isNaN(Number(e));function Rc(e,t,n,o){if(!Op.test(n))return null;const[s,r]=[Ec(n,o.timezone),Np(n,o.timezone)];switch(t){case"eq":return Oe(e,"between",[Qe(s),Qe(r)]);case"ne":return Oe(e,"not_between",[Qe(s),Qe(r)]);case"before":return Oe(e,"before",[Qe(s)]);case"onOrBefore":return Oe(e,"before_or_equal",[Qe(r)]);case"after":return Oe(e,"after",[Qe(r)]);case"onOrAfter":return Oe(e,"after_or_equal",[Qe(s)]);default:return null}}function _p(e,t,n,o){if(n.length===0)return null;const s=ir(o,e);if(t==="text")return Oe(s,"in",n.map(Cc));if(t==="number")return n.every(xc)?Oe(s,"in",n.map(a=>Nc(Number(a)))):null;const r=n.map(a=>Rc(s,"eq",a.slice(0,10),o));return r.every(Boolean)?Rp("or",r)??null:null}const _a={eq:"eq",ne:"neq",before:"before",onOrBefore:"before_or_equal",after:"after",onOrAfter:"after_or_equal",gt:"gt",gte:"gte",lt:"lt",lte:"lte"};function _c(e,t){const n=xp(t.metric),o=n.has(e.field)?Ra(t,e.field):void 0;if(!o)return null;const s=ir(t.metric,e.field);if(e.op==="isSet")return Oe(s,o==="text"?"is_not_empty":"is_not_null");if(e.op==="isEmpty")return Oe(s,o==="text"?"is_empty":"is_null");if(e.op==="in")return _p(e.field,o,e.values??[],t.metric);if(e.ref!==void 0&&e.ref!==he){const l=n.has(e.ref)?Ra(t,e.ref):void 0,c=_a[e.op];return!c||l!==o||["before","onOrBefore","after","onOrAfter"].includes(e.op)||["gt","gte","lt","lte"].includes(e.op)&&o!=="number"?null:Oe(s,c,[ir(t.metric,e.ref)])}const r=e.ref===he?t.asOf:e.value;if(r===void 0||r==="")return null;if(o==="date")return Rc(s,e.op,String(r).slice(0,10),t.metric);const a=_a[e.op];return o==="number"?!a||["before","onOrBefore","after","onOrAfter"].includes(e.op)?null:xc(r)?Oe(s,a,[Nc(Number(r))]):null:e.op==="eq"||e.op==="ne"?Oe(s,a,[Cc(String(r))]):null}const Pp={cardShape:"指标卡只能显示返回单个值的指标",timeShape:"按时间的图表只能用有固定时间粒度、没有固定分组的指标",timeGrain:"时间粒度须为日、周、月或季度",weekStart:"按周的指标须从周一起算",categoryShape:"按类别的图表只能用返回单个值的指标",categoryDimension:"类别列须是指标开放的分析维度",blocked:e=>`子集的条件(${e})不能交给平台`,listJoiner:"、",ops:{isSet:"有值",isEmpty:"为空",eq:"等于",ne:"不等于",in:"属于",before:"早于",onOrBefore:"不晚于",after:"晚于",onOrAfter:"不早于",gt:"大于",gte:"不小于",lt:"小于",lte:"不大于"},refShape:e=>`${e} 必须是 { id, version },version 为不小于 1 的整数`,unknownMetric:(e,t)=>`${e} 不是知识网络中已发布的对象指标:${t}`,unpublished:(e,t,n)=>`${e} 的版本 ${t} 尚未发布(最新为 ${n})`,sourceKind:e=>`${e} 对象指标只能用在对象类数据源或它的子集上`,otherObjectType:(e,t)=>`${e} 指标「${t}」不属于数据源的对象类`,subsetBlocked:(e,t)=>`${e} 数据源是子集,它的条件(${t})不能交给平台,不能用对象指标`,unfit:(e,t,n)=>`${e} ${t}:「${n}」`},Lp={cardShape:"a metric card can only show a metric that returns a single value",timeShape:"a chart by time can only use a metric with a fixed time grain and no fixed grouping",timeGrain:"the time grain must be day, week, month or quarter",weekStart:"a weekly metric must start its weeks on Monday",categoryShape:"a chart by category can only use a metric that returns a single value",categoryDimension:"the category column must be an analysis dimension the metric opens",blocked:e=>`the subset's condition (${e}) cannot be handed to the platform`,listJoiner:", ",ops:{isSet:"has a value",isEmpty:"is empty",eq:"equals",ne:"does not equal",in:"is one of",before:"is before",onOrBefore:"is not after",after:"is after",onOrAfter:"is not before",gt:"is greater than",gte:"is at least",lt:"is less than",lte:"is at most"},refShape:e=>`${e} must be { id, version }, with version an integer of at least 1`,unknownMetric:(e,t)=>`${e} is not a published object metric of the knowledge network: ${t}`,unpublished:(e,t,n)=>`version ${t} of ${e} is not published yet (the latest is ${n})`,sourceKind:e=>`${e}: an object metric can only be used on an object type source or a subset of one`,otherObjectType:(e,t)=>`${e}: metric "${t}" does not belong to the source's object type`,subsetBlocked:(e,t)=>`${e}: the source is a subset whose condition (${t}) cannot be handed to the platform, so it cannot use an object metric`,unfit:(e,t,n)=>`${e}: ${t} ("${n}")`},Pr=()=>fe({"zh-CN":Pp,"en-US":Lp}),Ip=new Set(["day","week","month","quarter"]);function Mp(e,t){return e==="card"?{place:"card"}:t.axis==="category"?{place:"category",...typeof t.category=="string"?{category:t.category}:{}}:{place:"time"}}function lr(e){if(typeof e!="object"||e===null)return;const{id:t,version:n}=e;return typeof t=="string"&&t!==""&&Number.isInteger(n)&&(n??0)>=1?{id:t,version:n}:void 0}function qp(e){const t=e.owner_object_type_id,n=p=>p.filter(f=>f.object_type_id===t&&!f.relation_path_alias).map(f=>f.property_name),o=e.result_semantics.statistical_grain,s=e.specification,r=s.kind==="derived"?s.business_qualifiers:void 0,a=n(e.query_capabilities.time_dimensions),l=r?.event_time,c=l?l.object_type_id===t?l.property_name:void 0:e.query_capabilities.time_dimensions.length===1?a[0]:void 0,i=r?.time_window,d=e.result_semantics.value,h=d.unit?.display_symbol||d.unit?.code,u=o.time_granularity?"time_series":o.group_by_dimensions.length>0?"grouped":"summary";return{id:e.id,version:e.version,status:e.lifecycle.status==="deprecated"?"deprecated":"published",code:e.code,name:e.name,description:e.description,objectType:t,kind:e.metric_type,shape:u,...o.time_granularity?{grain:o.time_granularity}:{},...o.timezone?{timezone:o.timezone}:{},...o.week_start?{weekStart:o.week_start}:{},groupBy:n(o.group_by_dimensions),dimensions:n(e.query_capabilities.analysis_dimensions),timeDimensions:a,...c?{timeField:c}:{},...i&&i.mode!=="unbounded"?{window:{mode:i.mode,..."length"in i?{length:i.length,unit:i.unit}:{},..."period"in i?{period:i.period}:{}}}:{},noData:e.result_semantics.no_data_policy,value:{semantic:d.semantic_type,...d.scale!==void 0?{scale:d.scale}:{},...h?{unit:h}:{},...d.unit?.quantity_kind==="currency"?{unitFirst:!0}:{}}}}function Fp(e,t=[]){const n=new Map;for(const o of[...e,...t]){const s=qp(o.definition),r=n.get(s.id);(!r||r.status===s.status&&s.version>r.version)&&n.set(s.id,s)}return[...n.values()]}function Dp(e,t,n){const o=Pr();return t==="card"?e.shape==="summary"?null:o.cardShape:t==="time"?e.shape!=="time_series"||e.groupBy.length>0?o.timeShape:Ip.has(e.grain??"")?e.grain==="week"&&e.weekStart==="sunday"?o.weekStart:null:o.timeGrain:e.shape!=="summary"?o.categoryShape:n&&!e.dimensions.includes(n)?o.categoryDimension:null}function Bp(e,t){const n=ue(e,t);if(!n||n.cypher||n.events||n.model)return;const o=n.from?e.sources.find(s=>s.id===n.from?.source):n;return o&&!o.cypher&&!o.events&&!o.model?n:void 0}function Up(e,t,n){return(e.from?.where??[]).find(o=>!_c(o,{metric:t,kn:n,asOf:"2000-01-01"}))}function Pc(e){const t=Pr(),n=t.ops,o=e.ref??e.values?.join(t.listJoiner)??(e.value!==void 0?String(e.value):"");return[e.field,n[e.op],o].filter(Boolean).join(" ")}function zp(e,t,n,o,s,r,a){const l=Pr(),c=lr(e);if(!c)return[l.refShape(r)];if(!t.metrics)return[];const i=t.metrics.find(p=>p.id===c.id);if(!i)return[l.unknownMetric(r,c.id)];if(c.version>i.version)return[l.unpublished(r,c.version,i.version)];const d=Bp(n,o);if(!d)return[l.sourceKind(r)];if(d.objectType!==i.objectType)return[l.otherObjectType(r,i.name)];const h=Up(d,i,t);if(h)return[l.subsetBlocked(r,Pc(h))];const u=c.version===i.version?Dp(i,s,a):null;return u?[l.unfit(r,u,i.name)]:[]}function Pa(e,t){const n=t?e.metrics?.find(o=>o.id===t.id):void 0;return n&&n.version===t?.version?n:void 0}function Wp(e,t){const n=(e.metrics??[]).filter(s=>!0);if(n.length===0)return"";const o=s=>s.shape==="time_series"?`时间序列(按${s.grain})`:s.shape==="grouped"?`固定分组(${s.groupBy.join("、")})`:"单个值";return`对象指标(网络中已发布,平台按全部对象计算;卡片或系列写 metric: { id, version },只能用下列 id 与版本,不能编造):
|
|
9
|
+
状态、超期天数这类随进度变化的列,优先用进度(progress)自动得出,不要再用计算列重写一遍。`;function Oe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Lt(e,t){return typeof e=="string"&&t.includes(e)}const Gh={object:e=>`${e} 必须是对象`,noOption:(e,t)=>`${e} 没有配置项 ${t}`,required:e=>`${e} 必填`,identifier:e=>`${e} 必须是字母开头的标识`,duplicate:(e,t)=>`${e} 重复:${t}`,paramsCount:(e,t)=>`${e} 必须是 1 到 ${t} 个参数`,typeOneOf:(e,t)=>`${e} 只能是 ${t.join("、")}`,minOverMax:e=>`${e} 不能大于 max`,operationsList:(e,t)=>`${e} 必须是不超过 ${t} 项的列表`,label:e=>`${e} 必须是不超过 30 字的名称`,effectsCount:(e,t,n)=>`${e} 必须是 ${t} 到 ${n} 个效果`,propertyOf:(e,t)=>`${e} 必须是 ${t} 的属性`,notKey:e=>`${e} 不能是对象的主键或标识`,kindOneOf:(e,t)=>`${e} 只能是 ${t.join("、")}`,kindOnlyFor:(e,t,n)=>`${e} ${t} 只能用于${n.join("、")}类型的属性`,ownParam:e=>`${e} 必须是本操作的参数`,paramNeeds:(e,t,n,o)=>`${e} 要求 ${t.join(" 或 ")} 类型的参数,${n} 是 ${o}`,notActionType:e=>`${e} 不是知识网络中的行动类型`,actionOn:(e,t)=>`${e} 必须作用于 ${t},或是新建对象的行动`,notUserParam:e=>`${e} 不是该行动的用户填写参数`,contextOneOf:(e,t)=>`${e} 只能是 ${t.join("、")}`,fromOneOf:e=>`${e} 只能是 param、field、const 或 context`,uniqueOnlyCreate:e=>`${e} 只用于新建对象的行动`,uniqueList:(e,t)=>`${e} 必须是 ${t} 的属性列表`,adjustNeedsLayer:()=>"图层需要先选好开始和结束",adjustSetters:(e,t)=>`操作须用日期或日期时间参数设置开始(${e})和结束(${t})`,adjustOther:e=>`操作只能设置开始、结束和所属资源,不能改 ${e}`},Hh={object:e=>`${e} must be an object`,noOption:(e,t)=>`${e} has no option ${t}`,required:e=>`${e} is required`,identifier:e=>`${e} must be an identifier starting with a letter`,duplicate:(e,t)=>`${e} is used twice: ${t}`,paramsCount:(e,t)=>`${e} must be 1 to ${t} parameters`,typeOneOf:(e,t)=>`${e} must be one of ${t.join(", ")}`,minOverMax:e=>`${e} cannot be greater than max`,operationsList:(e,t)=>`${e} must be a list of at most ${t} items`,label:e=>`${e} must be a name of at most 30 characters`,effectsCount:(e,t,n)=>`${e} must be ${t} to ${n} effects`,propertyOf:(e,t)=>`${e} must be a property of ${t}`,notKey:e=>`${e} cannot be the primary key or identifier of the object`,kindOneOf:(e,t)=>`${e} must be one of ${t.join(", ")}`,kindOnlyFor:(e,t,n)=>`${e} ${t} only works on properties of type ${n.join(", ")}`,ownParam:e=>`${e} must be a parameter of this operation`,paramNeeds:(e,t,n,o)=>`${e} needs a parameter of type ${t.join(" or ")}, but ${n} is ${o}`,notActionType:e=>`${e} is not an action type of the knowledge network`,actionOn:(e,t)=>`${e} must act on ${t}, or be an action that creates an object`,notUserParam:e=>`${e} is not a parameter the user fills in for this action`,contextOneOf:(e,t)=>`${e} must be one of ${t.join(", ")}`,fromOneOf:e=>`${e} must be param, field, const or context`,uniqueOnlyCreate:e=>`${e} is only for actions that create an object`,uniqueList:(e,t)=>`${e} must be a list of properties of ${t}`,adjustNeedsLayer:()=>"the layer needs a start and an end first",adjustSetters:(e,t)=>`the operation must set the start (${e}) and the end (${t}) from date or datetime parameters`,adjustOther:e=>`the operation can only set the start, the end and the resource it belongs to, not ${e}`},lo=()=>fe({"zh-CN":Gh,"en-US":Hh}),Ac=/^[A-Za-z][A-Za-z0-9_]*$/,Vh=["number","date","text"],Jh=["number","date","datetime","text"],Js=10,Vn=5,Zs=5,at=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Zh(e,t){return e==="shiftDays"||e==="fromAsOf"?{param:["number"],field:["date"]}:e==="add"?{param:["number"],field:["number"]}:t==="date"?{param:["date","datetime"],field:[]}:{param:[t==="number"?"number":"text"],field:[]}}function Tc(e,t,n=Vh){const o=lo(),s=[],r=new Map;return!Array.isArray(e)||e.length===0||e.length>Vn?{errors:[o.paramsCount(t,Vn)],types:r}:(e.forEach((a,l)=>{const c=`${t}[${l}]`;return at(a)?(typeof a.name!="string"||!Ac.test(a.name)?s.push(o.identifier(`${c}.name`)):r.has(a.name)&&s.push(o.duplicate(`${c}.name`,a.name)),(typeof a.label!="string"||!a.label.trim())&&s.push(o.required(`${c}.label`)),n.includes(a.type)?typeof a.name=="string"&&r.set(a.name,a.type):s.push(o.typeOneOf(`${c}.type`,n)),typeof a.min=="number"&&typeof a.max=="number"&&a.min>a.max&&s.push(o.minOverMax(`${c}.min`)),s):s.push(o.object(c))}),{errors:s,types:r})}function Xh(e,t,n,o){const s=lo();if(!Array.isArray(e)||e.length>Js)return[s.operationsList(o,Js)];const r=n.objectTypes[t.objectType],a=r?.properties??[],l=pe(t,n),c=new Set;return e.flatMap((i,d)=>{const h=`${o}[${d}]`;if(!at(i))return[s.object(h)];const u=Object.keys(i).filter(y=>!["id","label","when","params","effects","action"].includes(y)).map(y=>s.noOption(h,y));typeof i.id!="string"||!Ac.test(i.id)?u.push(s.identifier(`${h}.id`)):c.has(i.id)?u.push(s.duplicate(`${h}.id`,i.id)):c.add(i.id),(typeof i.label!="string"||!i.label.trim()||i.label.length>30)&&u.push(s.label(`${h}.label`)),i.when!==void 0&&u.push(...xe(i.when,l,`${h}.when`,un(t)));const p=Tc(i.params,`${h}.params`,Jh);u.push(...p.errors);const f=p.types,m=Qh(i,n),g=Array.isArray(i.effects)?i.effects:null;if(!g||g.length===0&&!m||g.length>Zs?u.push(s.effectsCount(`${h}.effects`,m?0:1,Zs)):g.forEach((y,b)=>{const k=`${h}.effects[${b}]`;if(!at(y))return u.push(s.object(k));const w=a.find(j=>j.name===y.field);if(!w)return u.push(s.propertyOf(`${k}.field`,t.objectType));if(y.field===t.key||r?.primaryKeys.includes(w.name))return u.push(s.notKey(`${k}.field`));if(!Ks.includes(y.kind))return u.push(s.kindOneOf(`${k}.kind`,Ks));const v=Zh(String(y.kind),w.type);v.field.length>0&&!v.field.includes(w.type)&&u.push(s.kindOnlyFor(k,String(y.kind),v.field));const S=f.get(String(y.param));return S?v.param.includes(S)||u.push(s.paramNeeds(`${k}.param`,v.param,String(y.param),S)):u.push(s.ownParam(`${k}.param`)),u}),i.action!==void 0){const y=at(i.action)?i.action:null,b=y&&typeof y.id=="string"?ln(n,y.id):void 0;if(!y)u.push(s.object(`${h}.action`));else if(n.actionTypes!==void 0){if(b?b.objectType!==t.objectType&&io(b)!=="create"&&u.push(s.actionOn(`${h}.action.id`,t.objectType)):u.push(s.notActionType(`${h}.action.id`)),b&&y.params!==void 0)if(!at(y.params))u.push(s.object(`${h}.action.params`));else for(const[k,w]of Object.entries(y.params)){const v=`${h}.action.params.${k}`;b.inputs.some(S=>S.name===k)?at(w)?w.from==="param"&&!f.has(String(w.name))?u.push(s.ownParam(`${v}.name`)):w.from==="field"&&!a.some(S=>S.name===w.name)?u.push(s.propertyOf(`${v}.name`,t.objectType)):w.from==="const"&&w.value===void 0?u.push(s.required(`${v}.value`)):w.from==="context"&&!Ys.includes(w.name)?u.push(s.contextOneOf(`${v}.name`,Ys)):["param","field","const","context"].includes(String(w.from))||u.push(s.fromOneOf(`${v}.from`)):u.push(s.object(v)):u.push(s.notUserParam(v))}b&&u.push(...ep(y,b,n,h))}}return u})}function Qh(e,t){const n=at(e.action)?e.action:null,o=n?ln(t,n.id):void 0;return o!==void 0&&io(o)==="create"}function ep(e,t,n,o){if(e.unique===void 0&&e.active===void 0)return[];const s=lo();if(io(t)!=="create")return[s.uniqueOnlyCreate(`${o}.action.unique`)];const r=n.objectTypes[t.objectType]?.properties??[],a=[],l=e.unique;return(!Array.isArray(l)||l.length===0||l.some(c=>!r.some(i=>i.name===c)))&&a.push(s.uniqueList(`${o}.action.unique`,t.objectType)),e.active!==void 0&&a.push(...xe(e.active,r,`${o}.action.active`)),a}const Ea=e=>e?.type==="date"||e?.type==="datetime";function Ca(e,t){if(!t)return;const n=e.effects.find(o=>o.kind==="set"&&o.field===t);return n&&e.params.find(o=>o.name===n.param)}function tp(e,t){const n=c=>typeof c=="string"&&c!==""?c:void 0,o=n(t.startField),s=n(t.endField),r=lo();if(!o||!s)return r.adjustNeedsLayer();if(!Ea(Ca(e,o))||!Ea(Ca(e,s)))return r.adjustSetters(o,s);const a=[o,s,n(t.resourceField)],l=e.effects.find(c=>c.kind!=="set"||!a.includes(c.field));if(l)return r.adjustOther(l.field)}const np={joiner:"、",list:(e,t)=>`${e} 必须是不超过 ${t} 项的列表`,object:e=>`${e} 必须是对象`,noOption:(e,t)=>`${e} 没有配置项 ${t}`,idFormat:e=>`${e} 必须是字母开头的标识`,idTwice:(e,t)=>`${e} 重复:${t}`,label:e=>`${e} 必须是不超过 30 字的名称`,text:e=>`${e} 必须是文字`,tool:e=>`${e} 必须写明执行工厂的工具箱 box 与工具 tool`,required:e=>`${e} 必填`,inputsCount:(e,t)=>`${e} 必须是 1 到 ${t} 个属性`,inputField:e=>`${e} 必须是本数据源的字段`,outputsCount:(e,t)=>`${e} 必须是 1 到 ${t} 个结果字段`,outputSameName:(e,t)=>`${e} 与本数据源的字段同名:${t}`,oneOf:(e,t)=>`${e} 只能是 ${t}`,measuresCount:(e,t)=>`${e} 必须是 1 到 ${t} 个度量`,valueField:e=>`${e} 必须是本数据源的字段或模型的结果字段`,valueFieldNumber:e=>`${e} 求和、平均、最大、最小须是数字字段`,actionType:e=>`${e} 不是知识网络中的行动类型`,actionObjectType:(e,t)=>`${e} 必须作用于 ${t}`,notUserParam:e=>`${e} 不是该行动的用户填写参数`,mustBeModelParam:e=>`${e} 必须是本模型的参数`,mustBePropertyOf:(e,t)=>`${e} 必须是 ${t} 的属性`,mustBeModelOutput:e=>`${e} 必须是本模型的结果字段`,fromOneOf:e=>`${e} 只能是 param、field、output 或 const`},op={joiner:", ",list:(e,t)=>`${e} must be a list of at most ${t} items`,object:e=>`${e} must be an object`,noOption:(e,t)=>`${e} has no option ${t}`,idFormat:e=>`${e} must be an identifier starting with a letter`,idTwice:(e,t)=>`${e} is used twice: ${t}`,label:e=>`${e} must be a name of at most 30 characters`,text:e=>`${e} must be text`,tool:e=>`${e} must name the execution factory toolbox (box) and tool`,required:e=>`${e} is required`,inputsCount:(e,t)=>`${e} must list 1 to ${t} properties`,inputField:e=>`${e} must be a field of this source`,outputsCount:(e,t)=>`${e} must list 1 to ${t} result fields`,outputSameName:(e,t)=>`${e} has the same name as a field of this source: ${t}`,oneOf:(e,t)=>`${e} must be one of ${t}`,measuresCount:(e,t)=>`${e} must list 1 to ${t} measures`,valueField:e=>`${e} must be a field of this source or a result field of the model`,valueFieldNumber:e=>`${e} must be a number field for sum, average, max and min`,actionType:e=>`${e} is not an action type of the knowledge network`,actionObjectType:(e,t)=>`${e} must act on ${t}`,notUserParam:e=>`${e} is not a parameter the user fills in for this action`,mustBeModelParam:e=>`${e} must be a parameter of this model`,mustBePropertyOf:(e,t)=>`${e} must be a property of ${t}`,mustBeModelOutput:e=>`${e} must be a result field of this model`,fromOneOf:e=>`${e} must be one of param, field, output or const`},Na=()=>fe({"zh-CN":np,"en-US":op}),xa=/^[A-Za-z][A-Za-z0-9_]*$/,Ro=["number","date","text"],Xs=["count","sum","avg","min","max","ratio"],Qs=5,er=20,tr=8,nr=8,Xe=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function sp(e,t,n,o){if(!Array.isArray(e)||e.length>Qs)return[Na().list(o,Qs)];const s=Na(),r=pe(t,n),a=new Set(r.map(i=>i.name)),l=n.objectTypes[t.objectType]?.properties??[],c=new Set;return e.flatMap((i,d)=>{const h=`${o}[${d}]`;if(!Xe(i))return[s.object(h)];const u=Object.keys(i).filter(w=>!["id","label","description","tool","inputs","params","outputs","measures","action"].includes(w)).map(w=>s.noOption(h,w));typeof i.id!="string"||!xa.test(i.id)?u.push(s.idFormat(`${h}.id`)):c.has(i.id)?u.push(s.idTwice(`${h}.id`,i.id)):c.add(i.id),(typeof i.label!="string"||!i.label.trim()||i.label.length>30)&&u.push(s.label(`${h}.label`)),i.description!==void 0&&typeof i.description!="string"&&u.push(s.text(`${h}.description`));const p=Xe(i.tool)?i.tool:null;!p||typeof p.box!="string"||!p.box||typeof p.tool!="string"?u.push(s.tool(`${h}.tool`)):p.tool||u.push(s.required(`${h}.tool.tool`));const f=Array.isArray(i.inputs)?i.inputs:null;!f||f.length===0||f.length>er?u.push(s.inputsCount(`${h}.inputs`,er)):f.forEach((w,v)=>{(typeof w!="string"||!a.has(w))&&u.push(s.inputField(`${h}.inputs[${v}]`))});const m=Tc(i.params,`${h}.params`);u.push(...m.errors);const g=Array.isArray(i.outputs)?i.outputs:null,y=new Set;!g||g.length===0||g.length>tr?u.push(s.outputsCount(`${h}.outputs`,tr)):g.forEach((w,v)=>{const S=`${h}.outputs[${v}]`;return Xe(w)?(typeof w.name!="string"||!xa.test(w.name)?u.push(s.idFormat(`${S}.name`)):a.has(w.name)?u.push(s.outputSameName(`${S}.name`,w.name)):y.has(w.name)?u.push(s.idTwice(`${S}.name`,w.name)):y.add(w.name),(typeof w.label!="string"||!w.label.trim())&&u.push(s.required(`${S}.label`)),Ro.includes(w.type)||u.push(s.oneOf(`${S}.type`,Ro.join(s.joiner))),u):u.push(s.object(S))});const b=[...r,...(g??[]).filter(Xe).map(w=>({name:String(w.name),label:String(w.label),type:Ro.includes(w.type)?w.type:"text"}))],k=Array.isArray(i.measures)?i.measures:null;if(!k||k.length===0||k.length>nr?u.push(s.measuresCount(`${h}.measures`,nr)):k.forEach((w,v)=>{const S=`${h}.measures[${v}]`;if(!Xe(w))return u.push(s.object(S));if((typeof w.label!="string"||!w.label.trim())&&u.push(s.required(`${S}.label`)),Xs.includes(w.aggregate)||u.push(s.oneOf(`${S}.aggregate`,Xs.join(s.joiner))),w.when!==void 0&&u.push(...xe(w.when,b,`${S}.when`,un(t))),["sum","avg","min","max"].includes(String(w.aggregate))){const O=b.find(A=>A.name===w.valueField);O?O.type!=="number"&&u.push(s.valueFieldNumber(`${S}.valueField`)):u.push(s.valueField(`${S}.valueField`))}return u}),i.action!==void 0){const w=Xe(i.action)?i.action:null,v=w&&typeof w.id=="string"?ln(n,w.id):void 0;if(!w)u.push(s.object(`${h}.action`));else if(n.actionTypes!==void 0){if(!v)u.push(s.actionType(`${h}.action.id`));else if(v.objectType!==t.objectType)u.push(s.actionObjectType(`${h}.action.id`,t.objectType));else if(w.params!==void 0)if(!Xe(w.params))u.push(s.object(`${h}.action.params`));else for(const[S,j]of Object.entries(w.params)){const O=`${h}.action.params.${S}`;v.inputs.some(A=>A.name===S)?Xe(j)?j.from==="param"&&!m.types.has(String(j.name))?u.push(s.mustBeModelParam(`${O}.name`)):j.from==="field"&&!l.some(A=>A.name===j.name)?u.push(s.mustBePropertyOf(`${O}.name`,t.objectType)):j.from==="output"&&!y.has(String(j.name))?u.push(s.mustBeModelOutput(`${O}.name`)):j.from==="const"&&j.value===void 0?u.push(s.required(`${O}.value`)):["param","field","output","const"].includes(String(j.from))||u.push(s.fromOneOf(`${O}.from`)):u.push(s.object(O)):u.push(s.notUserParam(O))}}}return u})}const rp=JSON.parse(`[{"name":"Fiji","zh":"斐济","a2":"FJ","a3":"FJI","alt":["Republic of Fiji"]},{"name":"Tanzania","zh":"坦桑尼亚","a2":"TZ","a3":"TZA","alt":["United Republic of Tanzania"]},{"name":"Western Sahara","zh":"西撒哈拉","a2":"EH","a3":"ESH","alt":["Sahrawi Arab Democratic Republic","W. Sahara"]},{"name":"Canada","zh":"加拿大","a2":"CA","a3":"CAN"},{"name":"United States of America","zh":"美国","a2":"US","a3":"USA","alt":["United States"]},{"name":"Kazakhstan","zh":"哈萨克斯坦","a2":"KZ","a3":"KAZ","alt":["Republic of Kazakhstan"]},{"name":"Uzbekistan","zh":"乌兹别克斯坦","a2":"UZ","a3":"UZB","alt":["Republic of Uzbekistan"]},{"name":"Papua New Guinea","zh":"巴布亚新几内亚","a2":"PG","a3":"PNG","alt":["Independent State of Papua New Guinea"]},{"name":"Indonesia","zh":"印度尼西亚","a2":"ID","a3":"IDN","alt":["Republic of Indonesia"]},{"name":"Argentina","zh":"阿根廷","a2":"AR","a3":"ARG","alt":["Argentine Republic"]},{"name":"Chile","zh":"智利","a2":"CL","a3":"CHL","alt":["Republic of Chile"]},{"name":"Democratic Republic of the Congo","zh":"刚果民主共和国","a2":"CD","a3":"COD","alt":["Congo, Dem. Rep.","Dem. Rep. Congo"]},{"name":"Somalia","zh":"索马里","a2":"SO","a3":"SOM","alt":["Federal Republic of Somalia"]},{"name":"Kenya","zh":"肯尼亚","a2":"KE","a3":"KEN","alt":["Republic of Kenya"]},{"name":"Sudan","zh":"苏丹","a2":"SD","a3":"SDN","alt":["Republic of the Sudan"]},{"name":"Chad","zh":"乍得","a2":"TD","a3":"TCD","alt":["Republic of Chad"]},{"name":"Haiti","zh":"海地","a2":"HT","a3":"HTI","alt":["Republic of Haiti"]},{"name":"Dominican Republic","zh":"多米尼加","a2":"DO","a3":"DOM","alt":["Dominican Rep."]},{"name":"Russia","zh":"俄罗斯","a2":"RU","a3":"RUS","alt":["Russian Federation"]},{"name":"The Bahamas","zh":"巴哈马","a2":"BS","a3":"BHS","alt":["Bahamas","Bahamas, The","Commonwealth of the Bahamas"]},{"name":"Falkland Islands","zh":"福克兰群岛","a2":"FK","a3":"FLK","alt":["Falkland Is.","Falkland Islands / Malvinas"]},{"name":"Norway","zh":"挪威","a2":"NO","a3":"NOR","alt":["Kingdom of Norway"]},{"name":"Greenland","zh":"格陵兰","a2":"GL","a3":"GRL"},{"name":"French Southern and Antarctic Lands","zh":"法属南部和南极领地","a2":"TF","a3":"ATF","alt":["Fr. S. Antarctic Lands","Territory of the French Southern and Antarctic Lands"]},{"name":"East Timor","zh":"东帝汶","a2":"TL","a3":"TLS","alt":["Democratic Republic of Timor-Leste","Timor-Leste"]},{"name":"South Africa","zh":"南非","a2":"ZA","a3":"ZAF","alt":["Republic of South Africa"]},{"name":"Lesotho","zh":"莱索托","a2":"LS","a3":"LSO","alt":["Kingdom of Lesotho"]},{"name":"Mexico","zh":"墨西哥","a2":"MX","a3":"MEX","alt":["United Mexican States"]},{"name":"Uruguay","zh":"乌拉圭","a2":"UY","a3":"URY","alt":["Oriental Republic of Uruguay"]},{"name":"Brazil","zh":"巴西","a2":"BR","a3":"BRA","alt":["Federative Republic of Brazil"]},{"name":"Bolivia","zh":"玻利维亚","a2":"BO","a3":"BOL","alt":["Plurinational State of Bolivia"]},{"name":"Peru","zh":"秘鲁","a2":"PE","a3":"PER","alt":["Republic of Peru"]},{"name":"Colombia","zh":"哥伦比亚","a2":"CO","a3":"COL","alt":["Republic of Colombia"]},{"name":"Panama","zh":"巴拿马","a2":"PA","a3":"PAN","alt":["Republic of Panama"]},{"name":"Costa Rica","zh":"哥斯达黎加","a2":"CR","a3":"CRI","alt":["Republic of Costa Rica"]},{"name":"Nicaragua","zh":"尼加拉瓜","a2":"NI","a3":"NIC","alt":["Republic of Nicaragua"]},{"name":"Honduras","zh":"洪都拉斯","a2":"HN","a3":"HND","alt":["Republic of Honduras"]},{"name":"El Salvador","zh":"萨尔瓦多","a2":"SV","a3":"SLV","alt":["Republic of El Salvador"]},{"name":"Guatemala","zh":"危地马拉","a2":"GT","a3":"GTM","alt":["Republic of Guatemala"]},{"name":"Belize","zh":"伯利兹","a2":"BZ","a3":"BLZ"},{"name":"Venezuela","zh":"委内瑞拉","a2":"VE","a3":"VEN","alt":["Bolivarian Republic of Venezuela","Venezuela, RB"]},{"name":"Guyana","zh":"圭亚那","a2":"GY","a3":"GUY","alt":["Co-operative Republic of Guyana"]},{"name":"Suriname","zh":"苏里南","a2":"SR","a3":"SUR","alt":["Republic of Suriname"]},{"name":"France","zh":"法国","a2":"FR","a3":"FRA","alt":["French Republic"]},{"name":"Ecuador","zh":"厄瓜多尔","a2":"EC","a3":"ECU","alt":["Republic of Ecuador"]},{"name":"Puerto Rico","zh":"波多黎各","a2":"PR","a3":"PRI","alt":["Commonwealth of Puerto Rico"]},{"name":"Jamaica","zh":"牙买加","a2":"JM","a3":"JAM"},{"name":"Cuba","zh":"古巴","a2":"CU","a3":"CUB","alt":["Republic of Cuba"]},{"name":"Zimbabwe","zh":"津巴布韦","a2":"ZW","a3":"ZWE","alt":["Republic of Zimbabwe"]},{"name":"Botswana","zh":"博茨瓦纳","a2":"BW","a3":"BWA","alt":["Republic of Botswana"]},{"name":"Namibia","zh":"纳米比亚","a2":"NA","a3":"NAM","alt":["Republic of Namibia"]},{"name":"Senegal","zh":"塞内加尔","a2":"SN","a3":"SEN","alt":["Republic of Senegal"]},{"name":"Mali","zh":"马里","a2":"ML","a3":"MLI","alt":["Republic of Mali"]},{"name":"Mauritania","zh":"毛里塔尼亚","a2":"MR","a3":"MRT","alt":["Islamic Republic of Mauritania"]},{"name":"Benin","zh":"贝宁","a2":"BJ","a3":"BEN","alt":["Republic of Benin"]},{"name":"Niger","zh":"尼日尔","a2":"NE","a3":"NER","alt":["Republic of Niger"]},{"name":"Nigeria","zh":"尼日利亚","a2":"NG","a3":"NGA","alt":["Federal Republic of Nigeria"]},{"name":"Cameroon","zh":"喀麦隆","a2":"CM","a3":"CMR","alt":["Republic of Cameroon"]},{"name":"Togo","zh":"多哥","a2":"TG","a3":"TGO","alt":["Togolese Republic"]},{"name":"Ghana","zh":"加纳","a2":"GH","a3":"GHA","alt":["Republic of Ghana"]},{"name":"Ivory Coast","zh":"科特迪瓦","a2":"CI","a3":"CIV","alt":["Côte d'Ivoire","Republic of Ivory Coast"]},{"name":"Guinea","zh":"几内亚","a2":"GN","a3":"GIN","alt":["Republic of Guinea"]},{"name":"Guinea-Bissau","zh":"几内亚比绍","a2":"GW","a3":"GNB","alt":["Republic of Guinea-Bissau"]},{"name":"Liberia","zh":"利比里亚","a2":"LR","a3":"LBR","alt":["Republic of Liberia"]},{"name":"Sierra Leone","zh":"塞拉利昂","a2":"SL","a3":"SLE","alt":["Republic of Sierra Leone"]},{"name":"Burkina Faso","zh":"布基纳法索","a2":"BF","a3":"BFA"},{"name":"Central African Republic","zh":"中非共和国","a2":"CF","a3":"CAF","alt":["Central African Rep."]},{"name":"Republic of the Congo","zh":"刚果共和国","a2":"CG","a3":"COG","alt":["Congo","Congo, Rep."]},{"name":"Gabon","zh":"加蓬","a2":"GA","a3":"GAB","alt":["Gabonese Republic"]},{"name":"Equatorial Guinea","zh":"赤道几内亚","a2":"GQ","a3":"GNQ","alt":["Eq. Guinea","Republic of Equatorial Guinea"]},{"name":"Zambia","zh":"赞比亚","a2":"ZM","a3":"ZMB","alt":["Republic of Zambia"]},{"name":"Malawi","zh":"马拉维","a2":"MW","a3":"MWI","alt":["Republic of Malawi"]},{"name":"Mozambique","zh":"莫桑比克","a2":"MZ","a3":"MOZ","alt":["Republic of Mozambique"]},{"name":"Eswatini","zh":"斯威士兰","a2":"SZ","a3":"SWZ","alt":["Kingdom of eSwatini","eSwatini"]},{"name":"Angola","zh":"安哥拉","a2":"AO","a3":"AGO","alt":["People's Republic of Angola"]},{"name":"Burundi","zh":"布隆迪","a2":"BI","a3":"BDI","alt":["Republic of Burundi"]},{"name":"Israel","zh":"以色列","a2":"IL","a3":"ISR","alt":["State of Israel"]},{"name":"Lebanon","zh":"黎巴嫩","a2":"LB","a3":"LBN","alt":["Lebanese Republic"]},{"name":"Madagascar","zh":"马达加斯加","a2":"MG","a3":"MDG","alt":["Republic of Madagascar"]},{"name":"Palestine","zh":"巴勒斯坦","a2":"PS","a3":"PSE","alt":["Palestine (West Bank and Gaza)","West Bank and Gaza"]},{"name":"The Gambia","zh":"冈比亚","a2":"GM","a3":"GMB","alt":["Gambia","Gambia, The","Republic of the Gambia"]},{"name":"Tunisia","zh":"突尼斯","a2":"TN","a3":"TUN","alt":["Republic of Tunisia"]},{"name":"Algeria","zh":"阿尔及利亚","a2":"DZ","a3":"DZA","alt":["People's Democratic Republic of Algeria"]},{"name":"Jordan","zh":"约旦","a2":"JO","a3":"JOR","alt":["Hashemite Kingdom of Jordan"]},{"name":"United Arab Emirates","zh":"阿拉伯联合酋长国","a2":"AE","a3":"ARE"},{"name":"Qatar","zh":"卡塔尔","a2":"QA","a3":"QAT","alt":["State of Qatar"]},{"name":"Kuwait","zh":"科威特","a2":"KW","a3":"KWT","alt":["State of Kuwait"]},{"name":"Iraq","zh":"伊拉克","a2":"IQ","a3":"IRQ","alt":["Republic of Iraq"]},{"name":"Oman","zh":"阿曼","a2":"OM","a3":"OMN","alt":["Sultanate of Oman"]},{"name":"Vanuatu","zh":"瓦努阿图","a2":"VU","a3":"VUT","alt":["Republic of Vanuatu"]},{"name":"Cambodia","zh":"柬埔寨","a2":"KH","a3":"KHM","alt":["Kingdom of Cambodia"]},{"name":"Thailand","zh":"泰国","a2":"TH","a3":"THA","alt":["Kingdom of Thailand"]},{"name":"Laos","zh":"老挝","a2":"LA","a3":"LAO","alt":["Lao PDR","Lao People's Democratic Republic"]},{"name":"Myanmar","zh":"缅甸","a2":"MM","a3":"MMR","alt":["Republic of the Union of Myanmar"]},{"name":"Vietnam","zh":"越南","a2":"VN","a3":"VNM","alt":["Socialist Republic of Vietnam"]},{"name":"North Korea","zh":"朝鲜民主主义人民共和国","a2":"KP","a3":"PRK","alt":["Dem. Rep. Korea","Democratic People's Republic of Korea","Korea, Dem. Rep."]},{"name":"South Korea","zh":"大韩民国","a2":"KR","a3":"KOR","alt":["Korea, Rep.","Republic of Korea"]},{"name":"Mongolia","zh":"蒙古国","a2":"MN","a3":"MNG"},{"name":"India","zh":"印度","a2":"IN","a3":"IND","alt":["Republic of India"]},{"name":"Bangladesh","zh":"孟加拉国","a2":"BD","a3":"BGD","alt":["People's Republic of Bangladesh"]},{"name":"Bhutan","zh":"不丹","a2":"BT","a3":"BTN","alt":["Kingdom of Bhutan"]},{"name":"Nepal","zh":"尼泊尔","a2":"NP","a3":"NPL"},{"name":"Pakistan","zh":"巴基斯坦","a2":"PK","a3":"PAK","alt":["Islamic Republic of Pakistan"]},{"name":"Afghanistan","zh":"阿富汗","a2":"AF","a3":"AFG","alt":["Islamic State of Afghanistan"]},{"name":"Tajikistan","zh":"塔吉克斯坦","a2":"TJ","a3":"TJK","alt":["Republic of Tajikistan"]},{"name":"Kyrgyzstan","zh":"吉尔吉斯斯坦","a2":"KG","a3":"KGZ","alt":["Kyrgyz Republic"]},{"name":"Turkmenistan","zh":"土库曼斯坦","a2":"TM","a3":"TKM"},{"name":"Iran","zh":"伊朗","a2":"IR","a3":"IRN","alt":["Iran, Islamic Rep.","Islamic Republic of Iran"]},{"name":"Syria","zh":"叙利亚","a2":"SY","a3":"SYR","alt":["Syrian Arab Republic"]},{"name":"Armenia","zh":"亚美尼亚","a2":"AM","a3":"ARM","alt":["Republic of Armenia"]},{"name":"Sweden","zh":"瑞典","a2":"SE","a3":"SWE","alt":["Kingdom of Sweden"]},{"name":"Belarus","zh":"白俄罗斯","a2":"BY","a3":"BLR","alt":["Republic of Belarus"]},{"name":"Ukraine","zh":"乌克兰","a2":"UA","a3":"UKR"},{"name":"Poland","zh":"波兰","a2":"PL","a3":"POL","alt":["Republic of Poland"]},{"name":"Austria","zh":"奥地利","a2":"AT","a3":"AUT","alt":["Republic of Austria"]},{"name":"Hungary","zh":"匈牙利","a2":"HU","a3":"HUN","alt":["Republic of Hungary"]},{"name":"Moldova","zh":"摩尔多瓦","a2":"MD","a3":"MDA","alt":["Republic of Moldova"]},{"name":"Romania","zh":"罗马尼亚","a2":"RO","a3":"ROU"},{"name":"Lithuania","zh":"立陶宛","a2":"LT","a3":"LTU","alt":["Republic of Lithuania"]},{"name":"Latvia","zh":"拉脱维亚","a2":"LV","a3":"LVA","alt":["Republic of Latvia"]},{"name":"Estonia","zh":"爱沙尼亚","a2":"EE","a3":"EST","alt":["Republic of Estonia"]},{"name":"Germany","zh":"德国","a2":"DE","a3":"DEU","alt":["Federal Republic of Germany"]},{"name":"Bulgaria","zh":"保加利亚","a2":"BG","a3":"BGR","alt":["Republic of Bulgaria"]},{"name":"Greece","zh":"希腊","a2":"GR","a3":"GRC","alt":["Hellenic Republic"]},{"name":"Turkey","zh":"土耳其","a2":"TR","a3":"TUR","alt":["Republic of Turkey"]},{"name":"Albania","zh":"阿尔巴尼亚","a2":"AL","a3":"ALB","alt":["Republic of Albania"]},{"name":"Croatia","zh":"克罗地亚","a2":"HR","a3":"HRV","alt":["Republic of Croatia"]},{"name":"Switzerland","zh":"瑞士","a2":"CH","a3":"CHE","alt":["Swiss Confederation"]},{"name":"Luxembourg","zh":"卢森堡","a2":"LU","a3":"LUX","alt":["Grand Duchy of Luxembourg"]},{"name":"Belgium","zh":"比利时","a2":"BE","a3":"BEL","alt":["Kingdom of Belgium"]},{"name":"Netherlands","zh":"荷兰","a2":"NL","a3":"NLD","alt":["Kingdom of the Netherlands"]},{"name":"Portugal","zh":"葡萄牙","a2":"PT","a3":"PRT","alt":["Portuguese Republic"]},{"name":"Spain","zh":"西班牙","a2":"ES","a3":"ESP","alt":["Kingdom of Spain"]},{"name":"Ireland","zh":"爱尔兰","a2":"IE","a3":"IRL"},{"name":"New Caledonia","zh":"新喀里多尼亚","a2":"NC","a3":"NCL"},{"name":"Solomon Islands","zh":"所罗门群岛","a2":"SB","a3":"SLB","alt":["Solomon Is."]},{"name":"New Zealand","zh":"新西兰","a2":"NZ","a3":"NZL"},{"name":"Australia","zh":"澳大利亚","a2":"AU","a3":"AUS","alt":["Commonwealth of Australia"]},{"name":"Sri Lanka","zh":"斯里兰卡","a2":"LK","a3":"LKA","alt":["Democratic Socialist Republic of Sri Lanka"]},{"name":"People's Republic of China","zh":"中华人民共和国","a2":"CN","a3":"CHN","alt":["China","Chinese Taipei","Taiwan","中国台湾","台湾"]},{"name":"Italy","zh":"意大利","a2":"IT","a3":"ITA","alt":["Italian Republic"]},{"name":"Denmark","zh":"丹麦","a2":"DK","a3":"DNK","alt":["Kingdom of Denmark"]},{"name":"United Kingdom","zh":"英国","a2":"GB","a3":"GBR","alt":["United Kingdom of Great Britain and Northern Ireland"]},{"name":"Iceland","zh":"冰岛","a2":"IS","a3":"ISL","alt":["Republic of Iceland"]},{"name":"Azerbaijan","zh":"阿塞拜疆","a2":"AZ","a3":"AZE","alt":["Republic of Azerbaijan"]},{"name":"Georgia","zh":"格鲁吉亚","a2":"GE","a3":"GEO"},{"name":"Philippines","zh":"菲律宾","a2":"PH","a3":"PHL","alt":["Republic of the Philippines"]},{"name":"Malaysia","zh":"马来西亚","a2":"MY","a3":"MYS"},{"name":"Brunei","zh":"文莱","a2":"BN","a3":"BRN","alt":["Brunei Darussalam","Negara Brunei Darussalam"]},{"name":"Slovenia","zh":"斯洛文尼亚","a2":"SI","a3":"SVN","alt":["Republic of Slovenia"]},{"name":"Finland","zh":"芬兰","a2":"FI","a3":"FIN","alt":["Republic of Finland"]},{"name":"Slovakia","zh":"斯洛伐克","a2":"SK","a3":"SVK","alt":["Slovak Republic"]},{"name":"Czech Republic","zh":"捷克","a2":"CZ","a3":"CZE","alt":["Czechia"]},{"name":"Eritrea","zh":"厄立特里亚","a2":"ER","a3":"ERI","alt":["State of Eritrea"]},{"name":"Japan","zh":"日本","a2":"JP","a3":"JPN"},{"name":"Paraguay","zh":"巴拉圭","a2":"PY","a3":"PRY","alt":["Republic of Paraguay"]},{"name":"Yemen","zh":"也门","a2":"YE","a3":"YEM","alt":["Republic of Yemen","Yemen, Rep."]},{"name":"Saudi Arabia","zh":"沙特阿拉伯","a2":"SA","a3":"SAU","alt":["Kingdom of Saudi Arabia"]},{"name":"Antarctica","zh":"南极洲","a2":"AQ","a3":"ATA"},{"name":"Turkish Republic of Northern Cyprus","zh":"北塞浦路斯土耳其共和国","a3":"CYN","alt":["Cyprus, Northern","N. Cyprus","Northern Cyprus"]},{"name":"Cyprus","zh":"塞浦路斯","a2":"CY","a3":"CYP","alt":["Republic of Cyprus"]},{"name":"Morocco","zh":"摩洛哥","a2":"MA","a3":"MAR","alt":["Kingdom of Morocco"]},{"name":"Egypt","zh":"埃及","a2":"EG","a3":"EGY","alt":["Arab Republic of Egypt","Egypt, Arab Rep."]},{"name":"Libya","zh":"利比亚","a2":"LY","a3":"LBY"},{"name":"Ethiopia","zh":"埃塞俄比亚","a2":"ET","a3":"ETH","alt":["Federal Democratic Republic of Ethiopia"]},{"name":"Djibouti","zh":"吉布提","a2":"DJ","a3":"DJI","alt":["Republic of Djibouti"]},{"name":"Somaliland","zh":"索马里兰","a3":"SOL","alt":["Republic of Somaliland"]},{"name":"Uganda","zh":"乌干达","a2":"UG","a3":"UGA","alt":["Republic of Uganda"]},{"name":"Rwanda","zh":"卢旺达","a2":"RW","a3":"RWA","alt":["Republic of Rwanda"]},{"name":"Bosnia and Herzegovina","zh":"波斯尼亚和黑塞哥维那","a2":"BA","a3":"BIH","alt":["Bosnia and Herz."]},{"name":"North Macedonia","zh":"北马其顿","a2":"MK","a3":"MKD","alt":["Republic of North Macedonia"]},{"name":"Serbia","zh":"塞尔维亚","a2":"RS","a3":"SRB","alt":["Republic of Serbia"]},{"name":"Montenegro","zh":"黑山","a2":"ME","a3":"MNE"},{"name":"Kosovo","zh":"科索沃","a2":"XK","a3":"KOS","alt":["Republic of Kosovo"]},{"name":"Trinidad and Tobago","zh":"特立尼达和多巴哥","a2":"TT","a3":"TTO","alt":["Republic of Trinidad and Tobago"]},{"name":"South Sudan","zh":"南苏丹","a2":"SS","a3":"SSD","alt":["Republic of South Sudan","S. Sudan"]}]`),ap=["北京","天津","河北","山西","内蒙古","辽宁","吉林","黑龙江","上海","江苏","浙江","安徽","福建","江西","山东","河南","湖北","湖南","广东","广西","海南","重庆","四川","贵州","云南","西藏","陕西","甘肃","青海","宁夏","新疆","台湾","香港","澳门"],ip={河北:"石家庄 唐山 保定 邯郸 秦皇岛 廊坊 沧州 邢台 张家口 承德 衡水",山西:"太原 大同 长治 晋城 运城 临汾",内蒙古:"呼和浩特 包头 鄂尔多斯 赤峰",辽宁:"沈阳 大连 鞍山 抚顺 锦州 营口 丹东",吉林:"长春 四平 延吉",黑龙江:"哈尔滨 齐齐哈尔 大庆 牡丹江 佳木斯",江苏:"南京 苏州 无锡 常州 南通 徐州 扬州 镇江 盐城 泰州 连云港 淮安 宿迁 昆山 江阴",浙江:"杭州 宁波 温州 绍兴 嘉兴 金华 台州 湖州 义乌",安徽:"合肥 芜湖 蚌埠 马鞍山 安庆",福建:"福州 厦门 泉州 漳州 莆田",江西:"南昌 赣州 九江 景德镇",山东:"济南 青岛 烟台 潍坊 淄博 威海 临沂 济宁 泰安 日照 东营",河南:"郑州 洛阳 开封 新乡 南阳 许昌 安阳",湖北:"武汉 宜昌 襄阳 十堰 荆州 黄石",湖南:"长沙 株洲 湘潭 衡阳 岳阳 常德",广东:"广州 深圳 东莞 佛山 珠海 中山 惠州 汕头 江门 湛江 肇庆",广西:"南宁 柳州 桂林 北海",海南:"海口 三亚",四川:"成都 绵阳 德阳 宜宾 南充 泸州",贵州:"贵阳 遵义",云南:"昆明 大理 曲靖 玉溪",西藏:"拉萨",陕西:"西安 宝鸡 咸阳 榆林 延安 汉中",甘肃:"兰州 天水",青海:"西宁",宁夏:"银川",新疆:"乌鲁木齐 克拉玛依 喀什"};[...ap.map(e=>[e,e]),...Object.entries(ip).flatMap(([e,t])=>t.split(" ").map(n=>[n,e]))].sort((e,t)=>t[0].length-e[0].length);const lp={GB:["England","Scotland","Wales","Northern Ireland","Great Britain","UK","英格兰","苏格兰","威尔士","北爱尔兰"],US:["USA","United States","America","美利坚"],KR:["Korea Republic","Republic of Korea","Korea","韩国"],KP:["Korea DPR","DPR Korea","North Korea","朝鲜"],IR:["IR Iran","Iran"],CI:["Côte d'Ivoire","Cote d'Ivoire","Ivory Coast","科特迪瓦"],CZ:["Czechia","Czech Republic","捷克"],TR:["Türkiye","Turkey","土耳其"],NL:["Holland","荷兰"],IE:["Republic of Ireland","Éire"],RU:["Russia","Russian Federation","俄罗斯"],CN:["China PR","中国","TWN"],AE:["UAE","阿联酋"]},cp=e=>e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^\p{L}\p{N}]+/gu,""),dp=["zh-Hans","en"].flatMap(e=>{try{return typeof Intl<"u"&&"DisplayNames"in Intl?[new Intl.DisplayNames([e],{type:"region"})]:[]}catch{return[]}});function up(e){return e?dp.flatMap(t=>{try{const n=t.of(e);return n&&n!==e?[n]:[]}catch{return[]}}):[]}const Oc=rp.flatMap(e=>[e.name,e.zh,e.a2,e.a3,...e.alt??[],...e.a2?lp[e.a2]??[]:[],...up(e.a2)].filter(t=>!!t).map(t=>[cp(t),e.name])).filter(([e])=>e.length>0).sort((e,t)=>t[0].length-e[0].length);new Map(Oc);Oc.filter(([e])=>new RegExp("\\p{Script=Han}","u").test(e)&&e.length>=2);function Ec(e){if(e?.length!==1)return null;const[t]=e;return t.op==="in"&&t.values?.length?{field:t.field,values:t.values}:t.op==="eq"&&t.ref===void 0&&t.value!==void 0?{field:t.field,values:[String(t.value)]}:null}function Qt(e,t){return e&&t?.length?[{field:e,op:"in",values:t}]:void 0}const hp=()=>nt().listNetworks(),pp=e=>nt().listObjectTypes(e),fp=(e,t)=>nt().getObjectType(e,t),mp=e=>nt().listRelationTypes(e),gp={object:e=>`${e} 必须是对象`,noOption:(e,t)=>`${e} 没有配置项 ${t}`,oneOf:(e,t)=>`${e} 必须是 ${t.join("、")} 之一`,question:e=>`${e} 必须是不超过 300 字的问题`,placeholder:(e,t)=>`${e} 里的 {${t}} 不是这次点击能填的内容`,agent:e=>`${e} 目前只能是 analyst`,context:(e,t)=>`${e} 只能取 ${t.join("、")}`,send:(e,t)=>`${e} 只能是 ${t.join(" 或 ")}`,maxObjects:(e,t)=>`${e} 必须是 1 到 ${t} 的整数`,list:(e,t)=>`${e} 必须是不超过 ${t} 项的列表`,label:e=>`${e} 必须是不超过 20 字的文本`,steps:(e,t)=>`${e} 必须是 1 到 ${t} 个动作`,noObjectSimulate:(e,t)=>`${e} 这次点击没有对象,不能推演:${t}`,operation:(e,t)=>`${e} 必须是数据源的推演操作:${t}`,noObjectAct:(e,t)=>`${e} 这次点击没有对象,不能执行行动:${t}`,kind:e=>`${e} 只能是 ask、act 或 simulate`},yp={object:e=>`${e} must be an object`,noOption:(e,t)=>`${e} has no option ${t}`,oneOf:(e,t)=>`${e} must be one of ${t.join(", ")}`,question:e=>`${e} must be a question of at most 300 characters`,placeholder:(e,t)=>`${e} has {${t}}, which this click cannot fill in`,agent:e=>`${e} can only be analyst for now`,context:(e,t)=>`${e} must be one of ${t.join(", ")}`,send:(e,t)=>`${e} must be ${t.join(" or ")}`,maxObjects:(e,t)=>`${e} must be an integer from 1 to ${t}`,list:(e,t)=>`${e} must be a list of at most ${t} items`,label:e=>`${e} must be text of at most 20 characters`,steps:(e,t)=>`${e} must be 1 to ${t} steps`,noObjectSimulate:(e,t)=>`${e} this click has no objects, so it cannot simulate: ${t}`,operation:(e,t)=>`${e} must be a scenario operation of the source: ${t}`,noObjectAct:(e,t)=>`${e} this click has no objects, so it cannot run an action: ${t}`,kind:e=>`${e} must be ask, act or simulate`},Cc=()=>fe({"zh-CN":gp,"en-US":yp}),bp={alertList:["rule","object"],metricCards:["card"],objectTable:["row"],objectList:["row"],pivotTable:["row"],trendChart:["point"],regionMap:["region"],stageChain:["stage"],[me]:["button"]},wp={alertList:["rule","object"],objectTable:["row"],objectList:["row"],pivotTable:["row"],[me]:["button"]},Ra={objectTable:"row",objectList:"row",[me]:"button"},Nc={rule:["count","rule.label","rule.severity"],object:["count","rule.label","rule.severity"],card:["count","card.label","value"],row:["count"],point:["count","category","period","value","series"],region:["count","region","value"],stage:["count","stage.label"],button:["count"]},xc=["object","row","button"],or=["hits","filters"],sr=["auto","prefill"],rr=200,kp=/\{([^{}]+)\}/g;function vp(e){return[...e.matchAll(kp)].map(t=>t[1].trim())}function ar(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $p(e,t,n,o){const s=Cc();if(!ar(e))return[s.object(o)];const r=new Set(["on","question","agent","context","send","maxObjects"]),a=Object.keys(e).filter(l=>!r.has(l)).map(l=>s.noOption(o,l));if(t.includes(e.on)||a.push(s.oneOf(`${o}.on`,t)),typeof e.question!="string"||!e.question.trim()||e.question.length>300)a.push(s.question(`${o}.question`));else{const l=new Set([...Nc[e.on]??[],...xc.includes(e.on)?(n??[]).map(c=>c.name):[]]);for(const c of vp(e.question))l.has(c)||a.push(s.placeholder(`${o}.question`,c))}return e.agent!==void 0&&e.agent!=="analyst"&&a.push(s.agent(`${o}.agent`)),e.context!==void 0&&(!Array.isArray(e.context)||e.context.some(l=>!or.includes(l)))&&a.push(s.context(`${o}.context`,or)),e.send!==void 0&&!sr.includes(e.send)&&a.push(s.send(`${o}.send`,sr)),e.maxObjects!==void 0&&(typeof e.maxObjects!="number"||!Number.isInteger(e.maxObjects)||e.maxObjects<1||e.maxObjects>rr)&&a.push(s.maxObjects(`${o}.maxObjects`,rr)),a}const Sp=["row","object","rule","button"],jp=8,Jn=5;function Ap({on:e,...t}){return{on:e,do:[{kind:"ask",...t}]}}function Tp({on:e,label:t,...n}){return{on:e,...t?{label:t}:{},do:[{kind:"act",...n}]}}function Op(e,t,n,o,s,r){const a=Cc();return!Array.isArray(e)||e.length>t.max?[a.list(r,t.max)]:e.flatMap((l,c)=>{const i=`${r}[${c}]`;if(!ar(l))return[a.object(i)];const d=Object.keys(l).filter(u=>!["on","label","do"].includes(u)).map(u=>a.noOption(i,u)),h=l.on;return t.on.includes(h)?(l.label!==void 0&&(typeof l.label!="string"||l.label.length>20)&&d.push(a.label(`${i}.label`)),!Array.isArray(l.do)||l.do.length===0||l.do.length>Jn?(d.push(a.steps(`${i}.do`,Jn)),d):(l.do.forEach((u,p)=>{const f=`${i}.do[${p}]`;if(!ar(u))return d.push(a.object(f));const{kind:m,...g}=u;if(m==="ask")d.push(...$p({...g,on:h},[h],s,f));else if(m==="simulate"){t.actOn.includes(h)||d.push(a.noObjectSimulate(f,h));const y=ue(n.spec,o);Object.keys(g).filter(b=>b!=="operation").forEach(b=>d.push(a.noOption(f,b))),y?.operations?.some(b=>b.id===g.operation)||d.push(a.operation(`${f}.operation`,String(g.operation)))}else m==="act"?t.actOn.includes(h)?d.push(...fc({...g,on:h},{on:[h],hit:t.hit},n,o,f)):d.push(a.noObjectAct(f,h)):d.push(a.kind(`${f}.kind`));return d}),d)):(d.push(a.oneOf(`${i}.on`,t.on)),d)})}function Ep(e,t,n,o){const s=e.filter(a=>Sp.includes(a)),r=e.map(a=>`${a}:${Nc[a].join("、")}`).join(";");return[`点击时还要做什么,列表,每项 { on, label?, do }:on 为 ${e.join("、")} 之一;do 为按顺序执行的 1 到 ${Jn} 个动作(点击写入的筛选总是先写入,不写在这里)`,s.length>0?`${s.join("、")} 各项是单独一个按钮,label 为按钮文字`:"",`问 Agent 的动作 { kind: "ask", question, agent?, context?, send?, maxObjects? }:question 是问题模板,可用占位 {…}(${r}${e.some(a=>xc.includes(a))?";点到单个对象时还可用该对象的字段名":""});context 取 hits(点到的对象)、filters(当前筛选);send 为 auto(直接发送)或 prefill(放进输入框)`,t.length>0?`推演的动作 { kind: "simulate", operation }(只能用于 ${t.join("、")}):operation 为数据源的推演操作 id,点击后由用户填参数,写入当前方案,不执行行动${o?`;数据源有推演操作而这里没写推演的动作时,${o} 上已自动提供“推演”按钮(多个操作时为下拉选择),只在要限定用哪个操作时才写`:""};执行行动的动作 { kind: "act", action, targets?, params?, confirm?, maxObjects? }(只能用于 ${t.join("、")}):action 为行动类型 id,须作用于数据源的对象类;targets ${n?"默认 hit(点到的对象),也可":""}为 { selection: 选中筛选 } 或 { set: 对象集合筛选 };params 给行动的每个“用户填写”参数指定来源:{ from: "input", label? }(确认时用户填)、{ from: "var", variable }(页面筛选的值)、{ from: "const", value };confirm 为确认时的说明,可用 {count}、{action};执行前总会弹出确认`:""].filter(Boolean).join(";")}function Cp(e){return typeof e=="string"&&e!==""?e.slice(0,10):"—"}function Np(e){return e.toLocaleString(void 0,{maximumFractionDigits:2})}function xp(e,t="text"){return e==null||e===""?"—":t==="date"?Cp(e):t==="number"&&typeof e=="number"?Np(e):String(e)}let Zn=ge;function Rp(e){const t=Object.values(re).find(s=>s.value===e);if(!t)return e;const n=`workshopLab.progress.status.${e}`,o=Zn.isInitialized?Zn.t(n):n;return typeof o=="string"&&o!==n?o:t.label}function _p(e){const t=Object.values(In).find(s=>s.value===e);if(!t)return e;const n=`workshopLab.scenario.mark.${e}`,o=Zn.isInitialized?Zn.t(n):n;return typeof o=="string"&&o!==n?o:t.label}function _o(e,t,n){return e===le.status&&typeof t=="string"?Rp(t):e===cn&&typeof t=="string"?_p(t):xp(t,n)}const Fe=e=>typeof e=="string"?e:"";function Pp(e,t){const n=(Array.isArray(e.layers)?e.layers:[]).filter(a=>typeof a=="object"&&a!==null),o=[],s=n.filter(a=>a.style==="standard");n.length>0&&s.length===0&&o.push({key:"noTasks"}),Fe(e.source)!==""&&Fe(e.titleField)===""&&o.push({key:"noResourceName"});const r=n.some(a=>a.style==="background"&&a.blocks===!0);for(const a of s){const l=Fe(a.label),c=Array.isArray(a.ruleTools)?a.ruleTools:[],i=u=>Array.isArray(u)&&u.length>0,d=a.exclusive===!0||r||c.length>0||Fe(a.earliestField)!==""||i(a.readyFrom)||i(a.predecessorPath);Fe(a.adjust)!==""&&!d&&o.push({key:"noConstraints",values:{layer:l}});const h=new Set;for(const u of c){const p=u?.tool;if(!p||Fe(p.box)===""||Fe(p.tool)==="")continue;const f=`${Fe(p.box)}/${Fe(p.tool)}`;h.has(f)&&o.push({key:"duplicateTool",values:{layer:l,name:Fe(u.name)}}),h.add(f)}}return o}const Lp=/^\d{4}-\d{2}-\d{2}$/;function _a(e,t){const n=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(new Date(e)),o=r=>Number(n.find(a=>a.type===r)?.value);return Date.UTC(o("year"),o("month")-1,o("day"),o("hour"),o("minute"),o("second"))-(e-(e%1e3+1e3)%1e3)}function Ip(e){if(e)try{return new Intl.DateTimeFormat("en-US",{timeZone:e}),e}catch{return}}const Mp=e=>{const[t,n,o]=e.split("-").map(Number);return new Date(Date.UTC(t,n-1,o+1)).toISOString().slice(0,10)};function Rc(e,t){const[n,o,s]=e.split("-").map(Number),r=Ip(t);if(!r)return new Date(n,o-1,s).getTime();const a=Date.UTC(n,o-1,s),l=a-_a(a,r);return a-_a(l,r)}function qp(e,t){return Rc(Mp(e),t)-1}function Fp(e){return new Set([...e.dimensions,...e.timeDimensions])}function Pa(e,t){return e.kn.objectTypes[e.metric.objectType]?.properties.find(n=>n.name===t)?.type}const ir=(e,t)=>({source:"property",property_ref:{object_type_id:e.objectType,property_name:t}}),_c=e=>({source:"literal",value_type:"string",value:e}),Pc=e=>({source:"literal",value_type:Number.isInteger(e)?"int64":"decimal",value:e}),Qe=e=>({source:"literal",value_type:"datetime",value:e}),Ce=(e,t,n)=>({node_type:"predicate",left:e,comparison_operator:t,...n?{right:n}:{}});function Dp(e,t){if(t.length!==0)return t.length===1?t[0]:{node_type:"group",boolean_operator:e,children:t}}const Lc=e=>e!==""&&e!==null&&e!==void 0&&!Number.isNaN(Number(e));function Ic(e,t,n,o){if(!Lp.test(n))return null;const[s,r]=[Rc(n,o.timezone),qp(n,o.timezone)];switch(t){case"eq":return Ce(e,"between",[Qe(s),Qe(r)]);case"ne":return Ce(e,"not_between",[Qe(s),Qe(r)]);case"before":return Ce(e,"before",[Qe(s)]);case"onOrBefore":return Ce(e,"before_or_equal",[Qe(r)]);case"after":return Ce(e,"after",[Qe(r)]);case"onOrAfter":return Ce(e,"after_or_equal",[Qe(s)]);default:return null}}function Bp(e,t,n,o){if(n.length===0)return null;const s=ir(o,e);if(t==="text")return Ce(s,"in",n.map(_c));if(t==="number")return n.every(Lc)?Ce(s,"in",n.map(a=>Pc(Number(a)))):null;const r=n.map(a=>Ic(s,"eq",a.slice(0,10),o));return r.every(Boolean)?Dp("or",r)??null:null}const La={eq:"eq",ne:"neq",before:"before",onOrBefore:"before_or_equal",after:"after",onOrAfter:"after_or_equal",gt:"gt",gte:"gte",lt:"lt",lte:"lte"};function Mc(e,t){const n=Fp(t.metric),o=n.has(e.field)?Pa(t,e.field):void 0;if(!o)return null;const s=ir(t.metric,e.field);if(e.op==="isSet")return Ce(s,o==="text"?"is_not_empty":"is_not_null");if(e.op==="isEmpty")return Ce(s,o==="text"?"is_empty":"is_null");if(e.op==="in")return Bp(e.field,o,e.values??[],t.metric);if(e.ref!==void 0&&e.ref!==he){const l=n.has(e.ref)?Pa(t,e.ref):void 0,c=La[e.op];return!c||l!==o||["before","onOrBefore","after","onOrAfter"].includes(e.op)||["gt","gte","lt","lte"].includes(e.op)&&o!=="number"?null:Ce(s,c,[ir(t.metric,e.ref)])}const r=e.ref===he?t.asOf:e.value;if(r===void 0||r==="")return null;if(o==="date")return Ic(s,e.op,String(r).slice(0,10),t.metric);const a=La[e.op];return o==="number"?!a||["before","onOrBefore","after","onOrAfter"].includes(e.op)?null:Lc(r)?Ce(s,a,[Pc(Number(r))]):null:e.op==="eq"||e.op==="ne"?Ce(s,a,[_c(String(r))]):null}const Up={cardShape:"指标卡只能显示返回单个值的指标",timeShape:"按时间的图表只能用有固定时间粒度、没有固定分组的指标",timeGrain:"时间粒度须为日、周、月或季度",weekStart:"按周的指标须从周一起算",categoryShape:"按类别的图表只能用返回单个值的指标",categoryDimension:"类别列须是指标开放的分析维度",blocked:e=>`子集的条件(${e})不能交给平台`,listJoiner:"、",ops:{isSet:"有值",isEmpty:"为空",eq:"等于",ne:"不等于",in:"属于",before:"早于",onOrBefore:"不晚于",after:"晚于",onOrAfter:"不早于",gt:"大于",gte:"不小于",lt:"小于",lte:"不大于"},refShape:e=>`${e} 必须是 { id, version },version 为不小于 1 的整数`,unknownMetric:(e,t)=>`${e} 不是知识网络中已发布的对象指标:${t}`,unpublished:(e,t,n)=>`${e} 的版本 ${t} 尚未发布(最新为 ${n})`,sourceKind:e=>`${e} 对象指标只能用在对象类数据源或它的子集上`,otherObjectType:(e,t)=>`${e} 指标「${t}」不属于数据源的对象类`,subsetBlocked:(e,t)=>`${e} 数据源是子集,它的条件(${t})不能交给平台,不能用对象指标`,unfit:(e,t,n)=>`${e} ${t}:「${n}」`},zp={cardShape:"a metric card can only show a metric that returns a single value",timeShape:"a chart by time can only use a metric with a fixed time grain and no fixed grouping",timeGrain:"the time grain must be day, week, month or quarter",weekStart:"a weekly metric must start its weeks on Monday",categoryShape:"a chart by category can only use a metric that returns a single value",categoryDimension:"the category column must be an analysis dimension the metric opens",blocked:e=>`the subset's condition (${e}) cannot be handed to the platform`,listJoiner:", ",ops:{isSet:"has a value",isEmpty:"is empty",eq:"equals",ne:"does not equal",in:"is one of",before:"is before",onOrBefore:"is not after",after:"is after",onOrAfter:"is not before",gt:"is greater than",gte:"is at least",lt:"is less than",lte:"is at most"},refShape:e=>`${e} must be { id, version }, with version an integer of at least 1`,unknownMetric:(e,t)=>`${e} is not a published object metric of the knowledge network: ${t}`,unpublished:(e,t,n)=>`version ${t} of ${e} is not published yet (the latest is ${n})`,sourceKind:e=>`${e}: an object metric can only be used on an object type source or a subset of one`,otherObjectType:(e,t)=>`${e}: metric "${t}" does not belong to the source's object type`,subsetBlocked:(e,t)=>`${e}: the source is a subset whose condition (${t}) cannot be handed to the platform, so it cannot use an object metric`,unfit:(e,t,n)=>`${e}: ${t} ("${n}")`},Pr=()=>fe({"zh-CN":Up,"en-US":zp}),Wp=new Set(["day","week","month","quarter"]);function Kp(e,t){return e==="card"?{place:"card"}:t.axis==="category"?{place:"category",...typeof t.category=="string"?{category:t.category}:{}}:{place:"time"}}function lr(e){if(typeof e!="object"||e===null)return;const{id:t,version:n}=e;return typeof t=="string"&&t!==""&&Number.isInteger(n)&&(n??0)>=1?{id:t,version:n}:void 0}function Yp(e){const t=e.owner_object_type_id,n=p=>p.filter(f=>f.object_type_id===t&&!f.relation_path_alias).map(f=>f.property_name),o=e.result_semantics.statistical_grain,s=e.specification,r=s.kind==="derived"?s.business_qualifiers:void 0,a=n(e.query_capabilities.time_dimensions),l=r?.event_time,c=l?l.object_type_id===t?l.property_name:void 0:e.query_capabilities.time_dimensions.length===1?a[0]:void 0,i=r?.time_window,d=e.result_semantics.value,h=d.unit?.display_symbol||d.unit?.code,u=o.time_granularity?"time_series":o.group_by_dimensions.length>0?"grouped":"summary";return{id:e.id,version:e.version,status:e.lifecycle.status==="deprecated"?"deprecated":"published",code:e.code,name:e.name,description:e.description,objectType:t,kind:e.metric_type,shape:u,...o.time_granularity?{grain:o.time_granularity}:{},...o.timezone?{timezone:o.timezone}:{},...o.week_start?{weekStart:o.week_start}:{},groupBy:n(o.group_by_dimensions),dimensions:n(e.query_capabilities.analysis_dimensions),timeDimensions:a,...c?{timeField:c}:{},...i&&i.mode!=="unbounded"?{window:{mode:i.mode,..."length"in i?{length:i.length,unit:i.unit}:{},..."period"in i?{period:i.period}:{}}}:{},noData:e.result_semantics.no_data_policy,value:{semantic:d.semantic_type,...d.scale!==void 0?{scale:d.scale}:{},...h?{unit:h}:{},...d.unit?.quantity_kind==="currency"?{unitFirst:!0}:{}}}}function Gp(e,t=[]){const n=new Map;for(const o of[...e,...t]){const s=Yp(o.definition),r=n.get(s.id);(!r||r.status===s.status&&s.version>r.version)&&n.set(s.id,s)}return[...n.values()]}function Hp(e,t,n){const o=Pr();return t==="card"?e.shape==="summary"?null:o.cardShape:t==="time"?e.shape!=="time_series"||e.groupBy.length>0?o.timeShape:Wp.has(e.grain??"")?e.grain==="week"&&e.weekStart==="sunday"?o.weekStart:null:o.timeGrain:e.shape!=="summary"?o.categoryShape:n&&!e.dimensions.includes(n)?o.categoryDimension:null}function Vp(e,t){const n=ue(e,t);if(!n||n.cypher||n.events||n.model)return;const o=n.from?e.sources.find(s=>s.id===n.from?.source):n;return o&&!o.cypher&&!o.events&&!o.model?n:void 0}function Jp(e,t,n){return(e.from?.where??[]).find(o=>!Mc(o,{metric:t,kn:n,asOf:"2000-01-01"}))}function qc(e){const t=Pr(),n=t.ops,o=e.ref??e.values?.join(t.listJoiner)??(e.value!==void 0?String(e.value):"");return[e.field,n[e.op],o].filter(Boolean).join(" ")}function Zp(e,t,n,o,s,r,a){const l=Pr(),c=lr(e);if(!c)return[l.refShape(r)];if(!t.metrics)return[];const i=t.metrics.find(p=>p.id===c.id);if(!i)return[l.unknownMetric(r,c.id)];if(c.version>i.version)return[l.unpublished(r,c.version,i.version)];const d=Vp(n,o);if(!d)return[l.sourceKind(r)];if(d.objectType!==i.objectType)return[l.otherObjectType(r,i.name)];const h=Jp(d,i,t);if(h)return[l.subsetBlocked(r,qc(h))];const u=c.version===i.version?Hp(i,s,a):null;return u?[l.unfit(r,u,i.name)]:[]}function Ia(e,t){const n=t?e.metrics?.find(o=>o.id===t.id):void 0;return n&&n.version===t?.version?n:void 0}function Xp(e,t){const n=(e.metrics??[]).filter(s=>!0);if(n.length===0)return"";const o=s=>s.shape==="time_series"?`时间序列(按${s.grain})`:s.shape==="grouped"?`固定分组(${s.groupBy.join("、")})`:"单个值";return`对象指标(网络中已发布,平台按全部对象计算;卡片或系列写 metric: { id, version },只能用下列 id 与版本,不能编造):
|
|
10
10
|
${n.map(s=>`- ${s.id} v${s.version}:${s.name}(${s.code});${s.description};对象类 ${s.objectType};${s.kind==="atomic"?"原子":s.kind==="derived"?"衍生":"复合"};返回${o(s)};时间维度 ${s.timeField??"无(不随基准日期)"};开放的维度 ${s.dimensions.join("、")||"无"}${s.value.unit?`;单位 ${s.value.unit}`:""}`).join(`
|
|
11
|
-
`)}`}const
|
|
11
|
+
`)}`}const Qp={object:e=>`${e} 必须是对象`,steps:(e,t)=>`${e}.steps 必须是 1 到 ${t} 步`,required:e=>`${e} 必填`,stepField:e=>`${e} 必填:日期属性,或给出 done 条件`,dateField:e=>`${e} 必须是数据源的日期属性`},ef={object:e=>`${e} must be an object`,steps:(e,t)=>`${e}.steps must have 1 to ${t} steps`,required:e=>`${e} is required`,stepField:e=>`${e} is required: a date property, unless done is given`,dateField:e=>`${e} must be a date property of the source`},tf=()=>fe({"zh-CN":Qp,"en-US":ef}),cr=12;function nf(e,t,n){if(e===void 0)return[];const o=tf();if(!Po(e))return[o.object(n)];const s=a=>t.some(l=>l.name===a&&l.type==="date"),r=[];return!Array.isArray(e.steps)||e.steps.length===0||e.steps.length>cr?[o.steps(n,cr)]:(e.steps.forEach((a,l)=>{const c=`${n}.steps[${l}]`;if(!Po(a))return r.push(o.object(c));(typeof a.label!="string"||a.label.trim()==="")&&r.push(o.required(`${c}.label`));const i=Array.isArray(a.done)&&a.done.length>0;a.field===void 0||a.field===""?i||r.push(o.stepField(`${c}.field`)):s(a.field)||r.push(o.dateField(`${c}.field`)),a.done!==void 0&&r.push(...xe(a.done,t,`${c}.done`))}),e.due!==void 0&&(!Po(e.due)||!s(e.due.field))&&r.push(o.dateField(`${n}.due.field`)),r)}function of(e){return e?.steps[0]?.field}const sf=`进度(sources[].progress,可选):这类对象依次经过哪几步、截止日期是哪个。{ steps: [{ label, field, done? }], due?: { field, label? } }
|
|
12
12
|
- steps:1 到 ${cr} 步,按先后顺序;field 为这一步的日期属性。默认日期不晚于基准日期就算这一步完成;给了 done(条件列表,写法同计算列的条件,只能读数据源自己的属性)则按条件判断,比如某个状态属性 eq 某个表示完成的值,这时 field 可以省略。计划日期(如计划完工日)不能说明这一步真的完成了,这种步骤要用 done 按实际状态判断。
|
|
13
13
|
- due:截止日期属性。
|
|
14
14
|
- 第一步有日期时,对象从这个日期起才算存在:基准日期早于这个日期的对象不出现;没有这个日期的对象不显示,页面上会提示有几条。
|
|
15
15
|
- 有进度的数据源自动多出这些列,组件、筛选、计算列都能直接用:${le.status}(进度状态,取值是代码:最后一步完成为 "${re.done.value}"(${re.done.label});否则过了截止日期为 "${re.overdue.value}"(${re.overdue.label});其余为 "${re.active.value}"(${re.active.label})。条件、取值列表、筛选默认值里都写代码,页面上按语言显示名称)、${le.stage}(当前步骤:已完成的最后一步的 label);有 due 时还有 ${le.overdueDays}(超期天数,只有已超期时有值)、${le.dueInDays}(距截止天数,只有进行中时有值)。这些列名以 $ 开头,不会和属性重名;对象类自己的 status 等属性照常可用。
|
|
16
|
-
- 详情抽屉的进度条直接按进度画。`;function Po(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Zp=e=>lh.includes(e??"")?e:"P3";function Xp(e,t){if(!t)return;const n=e.sources.filter(o=>{const s=ue(e,o.id);return s&&!s.events&&!s.cypher&&s.objectType===t});return(n.find(o=>!o.from)??n[0])?.id}function Lc(e,t,n){const o=n?.get(t.id),s=o?.subject||void 0,r=Xp(e,s);return{...t,label:o?.name||t.id,severity:Zp(o?.severity),...o?{source:o.source,network:o}:{},...n&&!o?{missing:!0}:{},...s?{objectType:s}:{},...r?{subject:r}:{}}}function en(e){if(!e)return;const t=Array.isArray(e)?e:Object.values(e);return new Map(t.map(n=>[n.code,n]))}function In(e,t){return(e.eventTypes??[]).map(n=>Lc(e,n,t))}const ot="fieldRoles",Ic=`${ot}.`,sn=new Map,Qp=new Set;function Mc(e,t,n="zh-CN"){const o=sn.get(t.type);o?.package===e&&o.locale===n||(sn.set(t.type,{package:e,manifest:t,schema:qc(t,n),locale:n}),Qp.forEach(s=>s()))}function ef(e){return sn.get(e)?.schema??tf(e)}function tf(e){return{label:e,summary:"",category:"display",description:`自定义组件 ${e}`,descriptors:[],follows:!1,selectorKeys:[],defaults:()=>({})}}function nf(e){if(!Rt(e))return hc[e];const t=sn.get(e)?.manifest.minSize;return t?[t.w,t.h]:[3,3]}function of(e,t){return e.label[t]??e.label["zh-CN"]??e.type}const Lr=e=>e==="string"?"text":e==="number"?"number":e==="date"||e==="datetime"?"date":void 0,sf=["filter","display","chart","relation"];function rf(e,t,n){const o=t["x-workshop"],s={key:e,label:t.title??e,...t.description?{hint:t.description}:{},...n?{}:{optional:!0},tab:o?.tab??"display",...o?.showIf?{shows:l=>Object.entries(o.showIf??{}).every(([c,i])=>l[c]===i)}:{}},r=Lr(o?.fieldTypes?.[0]);let a=null;switch(o?.widget){case"field":a={...s,kind:"field",...r?{of:r}:{}};break;case"fields":a={...s,kind:"fields",...r?{of:r}:{}};break;case"variable":a={...s,kind:"variable",accepts:Gn};break;case"objectType":a={...s,kind:"objectType"};break;case"relationPath":a={...s,kind:"relationPath",...af(t)?{single:!0}:{}};break;case"actionType":a={...s,kind:"actionTypes"};break;default:Array.isArray(t.enum)&&t.enum.every(l=>typeof l=="string")?a={...s,kind:"enum",options:t.enum.map(l=>[l,l])}:t.type==="boolean"?a={...s,kind:"bool"}:t.type==="number"||t.type==="integer"?a={...s,kind:"number",min:t.minimum??-1e12,max:t.maximum??1e12,...t.type==="number"?{decimal:!0}:{}}:t.type==="string"&&(a={...s,kind:"text",max:t.maxLength??null})}return a}const af=e=>e.type==="string"||e["x-workshop"]?.maxHops===1;function lf(e){return Object.entries(e.configSchema.properties??{}).filter(([,t])=>{const n=t["x-workshop"]?.widget;return n==="actionType"||n==="relationPath"&&t.type==="string"}).map(([t])=>t)}function cf(e,t){const n=sn.get(e)?.manifest,{[ot]:o,...s}=t,r={...s};if(o&&typeof o=="object"&&!Array.isArray(o))for(const[a,l]of Object.entries(o))r[Ic+a]=l;for(const a of n?lf(n):[])typeof r[a]=="string"&&(r[a]=[r[a]]);return r}function qc(e,t="zh-CN"){const n=e.data.source,o=Array.isArray(e.data.fields)?e.data.fields:[],s=new Set(e.configSchema.required??[]),r={},a=[{key:"title",label:"标题",kind:"text",max:80,optional:!0,tab:"display"}];n&&a.push({key:"source",label:"数据源",kind:"source",tab:"data"});for(const c of o){const i=Lr(c.type);a.push({key:Ic+c.role,label:`字段:${c.role}`,kind:"field",...i?{of:i}:{},tab:"data"})}for(const[c,i]of Object.entries(e.configSchema.properties??{})){if(["title","source","filters","selection",ot].includes(c))continue;const d=rf(c,i,s.has(c));d?a.push(d):(i.type==="array"||i.type==="object")&&(r[c]=i.type)}const l=n&&e.follows;return l&&a.push({key:"filters",label:"跟随筛选",kind:"bindings",optional:!0,tab:"link"}),e.emits?.includes("selection")&&a.push({key:"selection",label:"点选对象写入",kind:"variable",accepts:["selection"],optional:!0,tab:"link"}),{label:of(e,t),summary:e.description,category:sf.includes(e.category)?e.category:"display",description:e.description,descriptors:a,...Object.keys(r).length>0?{free:r}:{},follows:l,selectorKeys:[],defaults:(c,i)=>df(e,c,i.kn)}}function df(e,t,n){const o={};for(const[i,d]of Object.entries(e.configSchema.properties??{}))d.default!==void 0&&(o[i]=d.default);if(!e.data.source)return o;const s=t.sources[0];if(!s)return o;if(o.source=s.id,e.emits?.includes("selection")){const i=t.variables.find(d=>d.kind==="selection"&&(!("source"in d)||d.source===s.id))?.name;i&&(o.selection=i)}if(Array.isArray(e.data.fields)){const i=pe(s,n),d={},h=new Set;for(const u of e.data.fields){const p=Lr(u.type),f=i.find(m=>!h.has(m.name)&&(!p||m.type===p));f&&(d[u.role]=f.name,h.add(f.name))}Object.keys(d).length>0&&(o[ot]=d)}const r=new Set(e.configSchema.required??[]),a=i=>Object.entries(e.configSchema.properties??{}).filter(([d,h])=>r.has(d)&&o[d]===void 0&&h["x-workshop"]?.widget===i);let l;const c=n.relations.find(i=>i.source===s.objectType||i.target===s.objectType);if(c){l=c.source===s.objectType?c.target:c.source;for(const[i,d]of a("relationPath"))o[i]=d.type==="string"?c.id:[c.id]}for(const[i]of a("objectType"))o[i]=l??s.objectType;return o}const La=[["neutral","中性"],["info","信息"],["success","成功"],["warning","警示"],["danger","危险"]],dr=[["count","计数"],["sum","求和"],["avg","平均"],["min","最小"],["max","最大"],["distinct","去重计数"]],uf=[...dr,["ratio","占比(满足条件的 ÷ 全部)"]];function Ia(e){return e.basis==="period"||e.basis===void 0&&e.periodField!==void 0}function Lo(e){return typeof e.compare=="string"&&e.compare!=="none"}const hf=[["local","浏览器所在时区"],["Asia/Shanghai","北京时间"],["UTC","协调世界时"],["Asia/Tokyo","东京时间"],["Asia/Singapore","新加坡时间"],["Europe/Berlin","柏林时间"],["Europe/London","伦敦时间"],["America/New_York","纽约时间"],["America/Los_Angeles","洛杉矶时间"]],pf=[["high","严重"],["medium","关注"],["low","提示"]],Ma=[["asc","升序"],["desc","降序"]],J=(e="标题")=>({key:"title",label:e,kind:"text",tab:"display",optional:!0}),ae={key:"source",label:"数据源",kind:"source",tab:"data"},Q=(e,t,n,o,s={})=>({key:e,label:t,kind:"variable",accepts:n,tab:"link",sentence:o,optional:s.optional??!0,reads:s.reads}),_e={key:"valueField",label:"统计字段",hint:"求和、平均、最大、最小须选择数字列。",kind:"field",optional:!0,shows:e=>e.aggregate!==void 0&&!["count","ratio"].includes(String(e.aggregate)),neededAs:e=>["sum","avg","min","max"].includes(String(e.aggregate))?"number":void 0},rt=[{key:"label",label:"名称",kind:"text"},{key:"when",label:"仅统计满足以下条件的",kind:"conditions",optional:!0},{key:"aggregate",label:"统计方式",kind:"enum",options:uf},_e],Se=e=>e.metric!==void 0,Io=e=>({key:"metric",label:"数值来源",hint:"对象指标由平台按全部对象计算,口径在知识网络中定义。",kind:"metric",on:e,optional:!0}),wt={key:"description",label:"说明",hint:"显示在标题下面的一行小字,写这里看什么、该做什么。",kind:"text",max:120,tab:"display",optional:!0},ff=/^[A-Za-z][A-Za-z0-9_]*$/,ve={key:"filters",label:"跟随的筛选",kind:"bindings",tab:"link",optional:!0},$e=(e,t,n,o)=>typeof e[t]=="string"&&e[t]!==""?[{key:t,variable:e[t],...typeof n=="string"?{field:n}:{},...Array.isArray(o)?{fields:o.filter(s=>typeof s=="string")}:{}}]:[],mf=[["frontend","前端 Agent(在浏览器内调用平台模型,可读取页面并代为筛选)"],["bknAgent","内置 BKN Agent(平台智能问答 Agent,以当前用户身份查询知识网络)"],["mcp","外部 Agent(执行工厂中登记的 MCP 服务,由对方直接回答)"]];function qa(e,t){return[{key:"objectType",label:e,kind:"objectType"},{key:"path",label:"关系路径",kind:"relationPath"},{key:"field",label:t,kind:"field",owner:"objectType",of:"date"}]}const ze={asOfSlider:{label:"基准日期",summary:"拖动滑块选择日期,整页按该日期计算。",category:"filter",description:"滑块选一个日期,全页按这一天计算:有进度的数据源按第一步的日期决定对象在这天是否存在,状态、超期天数等读基准日期的列跟着重算;滑块范围从范围日期属性的最早值到今天",descriptors:[J(),{...ae,label:"滑块范围取自"},{key:"rangeField",label:"范围日期属性(默认取进度第一步的日期)",kind:"field",tab:"data",of:"date",optional:!0},{key:"step",label:"步长",kind:"enum",tab:"display",options:[["day","天"],["week","周"],["month","月"]]},Q("writes","写入",["asOf"],"拖动滑块时,按 {var} 重新计算全页",{optional:!1})],follows:!1,selectorKeys:[],defaults:(e,t,n)=>({title:"基准日期",source:ee(e,n,Bh)?.id,step:"day",writes:je(e,"asOf")})},dateRange:{label:"日期区间",summary:"选择日期区间,跟随它的组件仅查看该时间段。",category:"filter",description:"选起点和终点两个日期(附本月、上月、近 30 天、今年等快捷项),写入一个日期区间筛选;跟随它的组件只看某个日期列落在区间里的对象",descriptors:[J(),ae,{key:"field",label:"依据的日期(新组件默认依此跟随)",kind:"field",tab:"data",of:"date"},{key:"presets",label:"显示快捷项",kind:"bool",tab:"display"},Q("writes","写入",["dateRange"],"选定日期后,按 {var} 筛选",{optional:!1})],follows:!1,selectorKeys:[],emits:e=>$e(e,"writes",e.field),defaults:(e,t,n)=>{const o=ee(e,n);return{title:"日期区间",source:o?.id,field:o?Vp(o.progress)??Mo(o,t,"date"):void 0,presets:!0,writes:je(e,"dateRange")}}},metricCards:{label:"指标卡组",summary:"一排数字卡片,每张统计一项指标;点击卡片可筛选页面。",category:"filter",description:"一行指标卡,每张是一个统计(计数、求和、平均、最大最小、去重计数、占比),可只算满足条件的对象(如进度状态为 overdue 且金额大于 100 万);整组 compare(none 不显示、mom 环比、yoy 同比、both 都显示)对每张卡生效;basis 为 asOf(默认:统计基准日期(没有则今天)当天处于各状态的对象,与告警一致,同环比对比上一期、去年的同一天)或 period(只统计日期落在基准日期所在期的对象,如本月签约数;periodField 为日期属性,不填取进度第一步的日期;同环比按相同天数对比);periodUnit 为 day/week/month/quarter/year(默认 month);单张卡的 compare 可覆盖整组(none 为这张不显示),better(up 越高越好、down 越低越好)决定涨跌颜色,不填时按色调推断(danger、warning 越低越好,success 越高越好);点卡片写入筛选:取值筛选写这张卡的取值(卡片条件只能是一个字段取某些值),对象集合筛选写它算到的对象。一张卡写了 metric 就改为显示知识网络的对象指标:由平台按全部对象计算,不受数据源读取行数限制;when 只能用该指标开放的属性;它不写入筛选,点击时列出参与对象",descriptors:[J(),ae,{key:"compare",label:"同比环比",hint:"对整组卡片生效;单张卡片可在下方「指标」中另设。",kind:"enum",tab:"data",optional:!0,options:[["none","不显示"],["mom","环比(与上一期比较)"],["yoy","同比(与去年同期比较)"],["both","同比与环比"]]},{key:"basis",label:"统计口径",hint:"截至基准日期:统计基准日期当天处于各状态的对象,与告警、表格一致,适合已超期、进行中等状态;同比、环比与去年、上一期的同一天对比。基准日期所在期:只统计日期落在本期的对象,适合本月签约数等新增量;同比、环比按相同天数对比。",kind:"enum",tab:"data",optional:!0,options:[["asOf","截至基准日期"],["period","基准日期所在期"]]},{key:"periodField",label:"分期日期",hint:"对象按该日期归入某一期。留空时使用进度第一步的日期(如签约时间)。",kind:"field",of:"date",tab:"data",optional:!0,shows:(e,t)=>Ia(t)},{key:"periodUnit",label:"周期",hint:"默认按月:环比对比上个月,按期统计时一期为一个月。",kind:"enum",tab:"data",optional:!0,shows:(e,t)=>Lo(t)||Ia(t),options:[["day","日"],["week","周"],["month","月"],["quarter","季度"],["year","年"]]},{key:"showNoData",label:"对比期无数据时显示「无对比数据」",kind:"bool",tab:"data",optional:!0,shows:(e,t)=>Lo(t)},{key:"items",label:"指标",kind:"list",tab:"data",min:1,max:8,item:[rt[0],{key:"description",label:"说明",hint:"显示在数字下面的一行小字,写它的含义或该做什么。",kind:"text",max:60,optional:!0},Io("card"),rt[1],{...rt[2],shows:e=>!Se(e),notNeeded:Se},{..._e,shows:e=>!Se(e)&&_e.shows(e),neededAs:e=>Se(e)?void 0:_e.neededAs(e)},{key:"tone",label:"色调",kind:"enum",options:La},{key:"compare",label:"同比环比",hint:"留空时沿用整组设置。",kind:"enum",optional:!0,shows:(e,t)=>Lo(t)||e.compare!==void 0,options:[["none","不显示"],["mom","环比(与上一期比较)"],["yoy","同比(与去年同期比较)"],["both","同比与环比"]]},{key:"better",label:"变化方向",hint:"决定涨跌显示为绿色还是红色。留空时按色调判定:危险、警示越低越好,成功越高越好。",kind:"enum",optional:!0,shows:(e,t)=>(e.compare??t.compare??"none")!=="none"||e.better!==void 0,options:[["up","越高越好(上涨为绿色)"],["down","越低越好(上涨为红色)"]]}]},Q("writes","点击写入",["value","set"],"点击指标卡时,将该卡统计的对象写入 {var}"),ve],follows:!0,selectorKeys:["writes"],emits:(e,t)=>Do(t,e.writes)==="set"?$e(e,"writes"):$e(e,"writes",Ua(e.items)[0]),check:(e,t,n)=>{const o=e.items??[],s=o.flatMap((a,l)=>{const c=Pa(t.kn,lr(a.metric));return c?(a.when??[]).filter(i=>!_c(i,{metric:c,kn:t.kn,asOf:"2000-01-01"})).map(i=>`${n}.items[${l}].when 的条件(${Pc(i)})不能交给平台:对象指标卡的条件只能用指标「${c.name}」开放的属性`):[]});if(Do(t.spec,e.writes)!=="value")return s;const r=o.filter(a=>a.metric===void 0);return r.some(a=>a.when?.length&&!jc(a.when))?[...s,`${n}.items 写入取值筛选时,每张卡的条件只能是“某字段为某些值”;条件更复杂时改写入对象集合筛选`]:new Set(Ua(r)).size>1?[...s,`${n}.items 写入同一个筛选的指标要按同一个字段取值`]:s},defaults:(e,t,n)=>{const o=ee(e,n,r=>!!et(r)),s=o&&et(o);return{title:"关键指标",source:o?.id,items:[{label:"全部",aggregate:"count",tone:"neutral"},...(s?qo(s):[]).map(r=>({label:s?_o(s.name,r.value):r.value,when:Qt(s?.name,[r.value]),aggregate:"count",tone:r.tone??"neutral"}))],writes:s?kn(e,s.name):void 0}}},segmentedFilter:{label:"分段筛选",summary:"一排带数量的按钮,点击后仅显示该类。",category:"filter",description:"一组带数量的筛选按钮,按一个字段的取值分段;一个按钮可以包含几个取值",descriptors:[J(),ae,{key:"field",label:"字段",kind:"field",tab:"data"},{key:"options",label:"选项",kind:"list",tab:"data",min:2,max:6,item:[{key:"label",label:"名称",kind:"text"},{key:"values",label:"取值(留空为全部)",kind:"values",fieldKey:"field",optional:!0}]},{key:"showCounts",label:"显示数量",kind:"bool",tab:"display"},Q("writes","写入",["value"],"点击选项时,将其取值写入 {var}",{optional:!1}),ve],follows:!0,selectorKeys:["writes"],emits:e=>$e(e,"writes",e.field),defaults:(e,t,n)=>{const o=ee(e,n,r=>!!et(r)),s=o&&et(o);return{source:o?.id,field:s?.name,options:[{label:"全部"},...(s?qo(s):[]).map(r=>({label:s?_o(s.name,r.value):r.value,values:[r.value]}))],showCounts:!0,writes:s?kn(e,s.name):void 0}}},dropdownFilter:{label:"下拉筛选",summary:"下拉选择一个或多个值,跟随它的组件仅显示所选值;选项与数量取自数据。",category:"filter",description:"按一个字段的取值筛选,选项从数据里自动取并带数量,可搜索、可多选;适合取值很多的字段(城市、球队、客户)",descriptors:[J(),ae,{key:"field",label:"字段",kind:"field",tab:"data"},{key:"multiple",label:"允许多选",kind:"bool",tab:"display"},{key:"showCounts",label:"显示数量",kind:"bool",tab:"display"},{key:"placeholder",label:"提示文字",kind:"text",tab:"display",optional:!0},Q("writes","写入",["value"],"选中值时,将其写入 {var}",{optional:!1}),ve],follows:!0,selectorKeys:["writes"],emits:e=>$e(e,"writes",e.field),defaults:(e,t,n)=>{const o=ee(e,n),s=o&&(et(o)?.name??Fo(o,t).find(r=>r!==o.key));return{source:o?.id,field:s,multiple:!1,showCounts:!0,writes:s?kn(e,s):void 0}}},searchBox:{label:"搜索框",summary:"输入关键词,跟随它的组件仅显示包含该关键词的对象。",category:"filter",description:"输入文字,写入一个搜索筛选;跟随它的组件在各自的文本列里查找",descriptors:[J(),ae,{key:"fields",label:"搜索的列(新组件默认依此跟随)",kind:"fields",tab:"data",of:"text",optional:!0},{key:"placeholder",label:"提示文字",kind:"text",tab:"display",optional:!0},Q("writes","写入",["search"],"输入内容时,写入 {var}",{optional:!1})],follows:!1,selectorKeys:[],emits:e=>$e(e,"writes",void 0,e.fields),defaults:(e,t,n)=>{const o=ee(e,n);return{source:o?.id,fields:o?[...Fo(o,t).filter(s=>s===o.key),...Fo(o,t).filter(s=>s!==o.key).slice(0,2)]:[],placeholder:"搜索",writes:je(e,"search",o?.id)}}},text:{label:"文字",summary:"一段文字:页面开头的结论、分节标题或说明,可以引用随筛选变化的数字。",category:"display",description:"一段 Markdown 文字(标题、加粗、列表、链接),用来写页面开头的结论、分节标题和说明段落。values 列出正文引用的数字,每项 { name, source, aggregate, when?, valueField?, metric?, filters? }:name 字母开头;统计写法同指标卡的一项(写 metric 就取知识网络的对象指标);filters 为这个数字跟随的筛选,写法同组件的 filters,按它自己数据源的字段比对。content 里用 {name} 填入数字,用 {$asOf} 填入基准日期;读不到时显示 —",descriptors:[J(),{key:"content",label:"内容",hint:"Markdown;用 {引用名} 填入下面的数字,用 {$asOf} 填入基准日期。",kind:"text",multiline:!0,max:4e3,tab:"display"},{key:"values",label:"引用的数字",kind:"list",tab:"data",optional:!0,min:1,max:12,item:[{key:"name",label:"引用名",hint:"正文里写 {引用名} 填入这个数字;字母开头,可含数字和下划线。",kind:"text"},{key:"source",label:"数据源",kind:"source"},Io("card"),rt[1],{...rt[2],shows:e=>!Se(e),notNeeded:Se},{..._e,shows:e=>!Se(e)&&_e.shows(e),neededAs:e=>Se(e)?void 0:_e.neededAs(e)},{...ve,optional:!0}]}],follows:!1,selectorKeys:[],check:(e,t,n)=>{const s=(e.values??[]).map(l=>l.name),r=s.flatMap((l,c)=>typeof l=="string"&&!ff.test(l)?[`${n}.values[${c}].name 须字母开头,只含字母、数字和下划线`]:[]),a=s.filter((l,c)=>s.indexOf(l)!==c);return a.length>0&&r.push(`${n}.values 的引用名重复:${[...new Set(a)].join("、")}`),r},defaults:()=>({content:"**这里写一句结论**:现在怎么样,先做什么。"})},objectTable:{label:"对象表",summary:"明细表,支持排序、分页、勾选;点击行选中对象。",category:"display",description:"对象明细表,可排序分页;点行选中对象,表头可带按某字段取值的快捷筛选与搜索,某列可点击筛选;格式 tag 把值显示成标签,进度状态和判断状态的计算列带颜色",descriptors:[J(),wt,ae,{key:"columns",label:"列",kind:"list",tab:"data",min:1,max:20,fill:{from:"field",item:Fa},item:[{key:"field",label:"属性",kind:"field"},{key:"label",label:"列名",kind:"text"},{key:"format",label:"格式",kind:"enum",options:[["text","文本"],["date","日期"],["number","数字"],["tag","标签"]]}]},{key:"sortField",label:"排序属性",kind:"field",tab:"data",optional:!0},{key:"sortOrder",label:"排序方向",kind:"enum",tab:"data",options:Ma},{key:"pageSize",label:"每页行数",kind:"number",tab:"display",min:5,max:50},Q("selection","点击行写入",["selection"],"点击行时,选中该对象(写入 {var}),详情抽屉和关系子图将显示该对象"),Q("picks","勾选写入",["set"],"每行前显示勾选框,勾选的对象作为一组写入 {var},其他组件可仅查看该组"),{key:"quickField",label:"表头快捷筛选字段",kind:"field",tab:"link",optional:!0},Q("quickFilter","表头快捷筛选",["value"],"表头按上述字段的取值显示按钮,点击后写入 {var}"),Q("search","表头搜索",["search"],"表头显示搜索框,输入内容时写入 {var}"),{key:"cellFilters",label:"点击单元格筛选",sentence:"点击某列的值时,写入对应的筛选:",kind:"list",tab:"link",min:0,max:4,optional:!0,item:[{key:"field",label:"列的属性",kind:"field"},{key:"variable",label:"写入筛选",kind:"variable",accepts:["value"]}]},ve],follows:!0,selectorKeys:["picks"],emits:e=>[...$e(e,"picks"),...$e(e,"quickFilter",e.quickField),...$e(e,"search",void 0,wf(e)),...(e.cellFilters??[]).flatMap(t=>t.variable?[{key:"cellFilters",variable:t.variable,field:t.field}]:[])],check:(e,t,n)=>e.quickFilter&&!e.quickField?[`${n}.quickField 表头快捷筛选要指定按哪个字段`]:[],defaults:(e,t,n)=>{const o=ee(e,n),s=o?pe(o,t.kn).slice(0,5):[];return{title:o?.label,source:o?.id,columns:s.map(Fa),sortOrder:"desc",pageSize:10,selection:je(e,"selection",o?.id)}}},objectList:{label:"对象列表",summary:"卡片式列表,适用于待办和收件箱;点击列表项选中对象。",category:"display",description:"卡片式列表,适合收件箱、待办;可只看满足条件的对象,点一项选中对象",descriptors:[J(),wt,ae,{key:"when",label:"仅显示满足以下条件的对象",kind:"conditions",tab:"data",optional:!0},{key:"titleField",label:"标题属性",kind:"field",tab:"data"},{key:"subtitleFields",label:"副标题属性",kind:"fields",tab:"data",optional:!0},{key:"sortField",label:"排序属性",kind:"field",tab:"data",optional:!0},{key:"sortOrder",label:"排序方向",kind:"enum",tab:"data",options:Ma},{key:"badgeField",label:"徽标字段(状态类字段按颜色区分)",kind:"field",tab:"display",optional:!0},{key:"limit",label:"最多显示",kind:"number",tab:"display",min:3,max:30},Q("selection","点击写入",["selection"],"点击列表项时,选中该对象(写入 {var}),详情抽屉和关系子图将显示该对象"),ve],follows:!0,selectorKeys:[],defaults:(e,t,n)=>{const o=ee(e,n);return{title:o?.label,source:o?.id,titleField:o&&No(o,t.kn),sortOrder:"desc",badgeField:o?et(o)?.name:void 0,limit:8,selection:je(e,"selection",o?.id)}}},pivotTable:{label:"透视表",summary:"按一个属性分组汇总,每列一项统计;点击行可筛选页面。",category:"display",description:"按一个属性分组汇总,每列一个度量;点一行按该分组筛选全页",descriptors:[J(),wt,ae,{key:"dimension",label:"分组属性",kind:"field",tab:"data"},{key:"measures",label:"度量",kind:"list",tab:"data",min:1,max:5,item:[...rt]},{key:"limit",label:"最多行数",kind:"number",tab:"display",min:5,max:50},{key:"bars",label:"数值显示条形",kind:"bool",tab:"display",optional:!0,hint:"在每列数值下方显示按该列最大值比例的条形,便于比较各组。"},Q("writes","点击行写入",["value"],"点击行时,将该组的取值写入 {var}"),ve],follows:!0,selectorKeys:["writes"],emits:e=>$e(e,"writes",e.dimension),defaults:(e,t,n)=>{const o=ee(e,n),s=o?va(pe(o,t.kn),t.kn.objectTypes[o.objectType]):void 0;return{source:o?.id,dimension:s?.name,measures:[{label:"数量",aggregate:"count"}],limit:10,bars:!0}}},trendChart:{label:"图表",summary:"柱状图、折线图或饼图:按时间或类别统计;点击图形可筛选页面。",category:"chart",description:"柱线饼图。横轴 axis 为 time(默认)时按日、周、月或季度统计(grain,默认按月),每个系列用自己的日期属性 dateField,点某个周期把它写入一个日期区间筛选;为 category 时按属性 category 的取值统计(最多 limit 个,取第一个系列最大的几个;sort 为 category 时按类别本身排序,如年份,默认按数值从大到小),点一个取值把它写入取值筛选。segmentBy 把每个系列再按另一个属性拆开(柱堆叠、线分色)。只有一个系列且横轴为 category 时图形可选 pie(饼图)。横轴为 category 且各系列都是柱时,orientation 决定柱子方向:auto(默认)在有类别名长于约四个汉字时改为横向条形(类别列在左侧,过长截断、悬停看全名),vertical 始终竖向,horizontal 始终横向。系列写了 metric 就改为显示知识网络的对象指标,由平台按全部对象计算:一张图的系列要么都写 metric、要么都不写;横轴为时间时粒度跟随指标(各指标须相同,不写 grain);不能用 segmentBy;按类别时由平台取前 limit 个",descriptors:[J(),wt,ae,{key:"axis",label:"横轴",kind:"enum",tab:"data",optional:!0,options:[["time","时间(按周期)"],["category","类别(按属性取值)"]]},{key:"category",label:"类别属性",kind:"field",tab:"data",optional:!0,shows:(e,t)=>t.axis==="category"},{key:"sort",label:"类别排序",kind:"enum",tab:"display",optional:!0,shows:(e,t)=>t.axis==="category",options:[["value","按数值从大到小"],["category","按类别自身(例如年份)"]]},{key:"orientation",label:"柱子方向",kind:"enum",tab:"display",optional:!0,shows:(e,t)=>t.axis==="category"&&!t.series?.some(n=>n.chart!=="bar"),options:[["auto","自动:类别名较长时横向"],["vertical","竖向柱"],["horizontal","横向条形"]]},{key:"limit",label:"最多显示类别数",kind:"number",tab:"display",optional:!0,shows:(e,t)=>t.axis==="category",min:2,max:50},{key:"segmentBy",label:"按属性拆分系列",kind:"field",tab:"data",optional:!0,shows:(e,t)=>!Ba(t)||t.segmentBy!==void 0},{key:"grain",label:"统计粒度",shows:(e,t)=>t.axis!=="category"&&!Ba(t),kind:"enum",tab:"display",optional:!0,options:[["day","日"],["week","周"],["month","月"],["quarter","季度"]]},{key:"months",label:"显示周期数(横轴为时间时必填)",shows:(e,t)=>t.axis!=="category",kind:"number",tab:"display",optional:!0,min:3,max:36},{key:"series",label:"系列",kind:"list",tab:"data",min:1,max:4,item:[{key:"label",label:"名称",kind:"text"},Io("chart"),{key:"dateField",label:"日期属性",shows:(e,t)=>t.axis!=="category"&&!Se(e),kind:"field",of:"date",optional:!0},{key:"aggregate",label:"聚合",kind:"enum",options:dr,shows:e=>!Se(e),notNeeded:Se},{..._e,shows:e=>!Se(e)&&_e.shows(e),neededAs:e=>Se(e)?void 0:_e.neededAs(e)},{key:"chart",label:"图形",kind:"enum",options:[["bar","柱"],["line","线"],["pie","饼(仅限单系列且横轴为类别时可用)"]]}]},Q("writes","点击写入",["dateRange","value"],"点击周期(或类别)时,将其写入 {var}"),ve],follows:!0,selectorKeys:["writes"],emits:e=>$e(e,"writes",e.axis==="category"?e.category:e.series?.[0]?.dateField),check:(e,t,n)=>{const o=[],s=e.axis==="category",r=e.series??[];s&&!e.category&&o.push(`${n}.category 横轴为类别时必填`),!s&&e.months===void 0&&o.push(`${n}.months 横轴为时间时必填`),!s&&r.some(c=>!c.dateField&&c.metric===void 0)&&o.push(`${n}.series 横轴为时间时每个系列要有 dateField`);const a=r.filter(c=>c.metric!==void 0);a.length>0&&a.length<r.length&&o.push(`${n}.series 一张图的系列要么都用页面内统计,要么都用对象指标`),a.length>0&&e.segmentBy!==void 0&&o.push(`${n}.segmentBy 用对象指标的图表不能按另一个属性拆分系列`),s||new Set(a.flatMap(i=>Pa(t.kn,lr(i.metric))?.grain??[])).size>1&&o.push(`${n}.series 各对象指标的时间粒度须相同`),r.some(c=>c.chart==="pie")&&(!s||r.length!==1)&&o.push(`${n}.series 饼图只能用于横轴为类别、只有一个系列的图表`),e.orientation==="horizontal"&&!s&&o.push(`${n}.orientation 只有横轴为类别时才能横向`),e.orientation==="horizontal"&&r.some(c=>c.chart!=="bar")&&o.push(`${n}.orientation 只有全部系列都是柱时才能横向`);const l=Do(t.spec,e.writes);return l==="value"&&!s&&o.push(`${n}.writes 横轴为时间时只能写入日期区间筛选`),l==="dateRange"&&s&&o.push(`${n}.writes 横轴为类别时只能写入取值筛选`),o},defaults:(e,t,n)=>{const o=ee(e,n),s=o?Mo(o,t,"date"):void 0;return{source:o?.id,months:8,series:[{label:"数量",dateField:s,aggregate:"count",chart:"bar"}],writes:je(e,"dateRange")}}},regionMap:{label:"地图",summary:"按地区着色的地图,可绘制关联对象之间的连线;点击地区可筛选页面。",category:"chart",description:"按地区着色的地图:底图为中国(按省份,省份可从客户名称这类含地名的文字里推断)或世界(按国家,认中英文国名、常见别称和 ISO 代码),地区从一个文本字段里识别;只在数据里确实有地名时才用;可标出满足条件的对象所在地区;可加关系连线:选知识网络里与数据源对象类直接相连的一条关系,连到另一类对象,从它的位置属性识别地区,画出它到对象所在地区的连线(网络里没有直接关系的两类对象不能连线,不能沿多条关系拼出连线);点地区时,把该地区对应的字段值写入一个取值筛选",descriptors:[J(),ae,{key:"basemap",label:"底图",kind:"enum",tab:"data",optional:!0,options:[["china","中国(按省份)"],["world","世界(按国家)"]]},{key:"regionField",label:"地区字段(地名,或含地名的文本)",kind:"field",tab:"data",of:"text"},{key:"aggregate",label:"度量",kind:"enum",tab:"data",options:dr},{..._e,tab:"data"},{key:"highlight",label:"标注(存在满足条件对象的省份以红色描边)",kind:"conditions",tab:"display",optional:!0},{key:"links",label:"关系连线",kind:"list",tab:"data",min:0,max:2,optional:!0,item:[{key:"label",label:"名称",kind:"text"},{key:"objectType",label:"连到的对象类",kind:"objectType"},{key:"path",label:"关系(直接相连的一条)",kind:"relationPath",single:!0},{key:"locationField",label:"位置属性(用于识别省份)",kind:"field",owner:"objectType",of:"text"}]},Q("writes","点击省份写入",["value"],"点击省份时,将该省对应的取值写入 {var}"),ve],follows:!0,selectorKeys:["writes"],emits:e=>$e(e,"writes",e.regionField),defaults:(e,t,n)=>{const o=ee(e,n,l=>!!Da(l)),s=o&&Da(o),r=s?.name??(o&&bf(o,t)),a=s?.kind==="region"?s.scope:r&&Fc.test(r)?"world":void 0;return{title:"地区分布",source:o?.id,...a==="world"?{basemap:a}:{},regionField:r,aggregate:"count",writes:r?kn(e,r):void 0}}},ganttChart:{label:"甘特图",summary:"按开始和结束日期绘制条形,查看计划与进度。",category:"chart",description:"按分组属性排成行、按开始和结束日期画条,显示基准日期前后的一段时间(默认多看之前,lookAhead 调大可多看之后,适合排计划);状态字段有色调时按色调着色",descriptors:[J(),ae,{key:"groupField",label:"行(分组属性)",kind:"field",tab:"data"},{key:"labelField",label:"条形名称",kind:"field",tab:"data"},{key:"startField",label:"开始日期",kind:"field",tab:"data",of:"date"},{key:"endField",label:"结束日期",kind:"field",tab:"data",of:"date"},{key:"statusField",label:"状态属性",kind:"field",tab:"data",optional:!0},{key:"windowDays",label:"显示天数",kind:"number",tab:"display",min:14,max:365},{key:"lookAhead",label:"基准日期之后的占比(%,规划计划时调大)",kind:"number",tab:"display",min:0,max:100,optional:!0},{key:"maxRows",label:"最多行数",kind:"number",tab:"display",min:3,max:40},ve],follows:!0,selectorKeys:[],defaults:(e,t,n)=>{const o=ee(e,n),s=o?pe(o,t.kn).filter(r=>r.type==="date"):[];return{source:o?.id,groupField:o?.key,labelField:o&&No(o,t.kn),startField:s[0]?.name,endField:s[1]?.name??s[0]?.name,windowDays:60,maxRows:12}}},scheduleGantt:{label:"调度甘特",summary:"资源排成行、时间横向展开,查看各资源上的任务、停机窗口和关键时点。",category:"chart",description:"按资源排成行(可按上级资源折叠、按属性分组),时间轴以基准日期为中心;每个图层是一类对象:标准图层画任务条(同一资源上重叠的任务分轨显示),背景图层画停机等时段,事件图层画到货等时点(可全局显示)。悬停看起止和属性,在情景中被改动或联动的任务显示原值、原因和改动前位置;点击任务或资源写入选中变量,供对象详情和关联表显示;不满足页面筛选的任务淡化显示;缺资源或缺时间的任务列在底部待排区。标准图层配了调整操作时,可拖动任务改资源和时间、拖动右边缘改结束,改动记入当前方案(没有打开的方案时新建一个),在方案栏的改动清单里查看和移除。数据本身只在采用方案时改。标准图层可配目标完成、最早开始(或所需资源的就绪日)、前序关系和已完成条件:未就绪、前序未完是硬约束,晚于目标只标出不阻止采用;配了目标与前序时算出余量,余量不大于 0 的任务属于关键链并描边,悬停任务显示整条依赖链。工具栏的状态摘要按约束计数,点击筛选。资源可设并行上限(默认 1),任务占用资源的图层按上限判断超限,每行底部显示负荷、超出上限标红;上级资源不可排程的时段对下级同样生效;折叠的上级显示下级任务的汇总条和有问题的任务数。标准图层可配规则工具(ruleTools,执行工厂的工具)判断行业规则:工具收到 { tasks: [{ key, start, end, resource, values }], scenario: { edits } },返回 { results: [{ key, pass, severity?, text, related? }] };不通过的任务与内置约束一起标出、计数、筛选,硬约束阻止采用方案,软约束只标出;工具失败或超时,任务显示未能校验,按硬约束处理。timeZoneVariable 是取值筛选,取值须为 IANA 时区名(如 Asia/Shanghai),没有取值时用 timeZone",descriptors:[J(),{key:"source",label:"资源来源(每个对象一行)",hint:"不选时,按任务的所属资源取值自动成行。",kind:"source",tab:"data",optional:!0},{key:"titleField",label:"资源名称",kind:"field",tab:"data",optional:!0,shows:(e,t)=>!!t.source},{key:"subtitleField",label:"资源副标题",kind:"field",tab:"data",optional:!0,shows:(e,t)=>!!t.source},{key:"parentField",label:"上级资源(取值为上级资源的标识)",hint:"有上级时,资源按上级折叠展开,如工厂下的产线。",kind:"field",tab:"data",optional:!0,shows:(e,t)=>!!t.source},{key:"capacityField",label:"并行上限(同一时间最多承接的任务数)",hint:"不选或没有取值时为 1。图层打开“任务占用资源”后,同一时间的任务数超过上限会标为硬约束,并按上限算负荷。上级资源不可排程的时段,对其下级同样生效。",kind:"field",tab:"data",optional:!0,shows:(e,t)=>!!t.source,of:"number"},{key:"groupField",label:"按属性分组",kind:"field",tab:"data",optional:!0,shows:(e,t)=>!!t.source},{key:"layers",label:"图层",kind:"list",tab:"data",min:0,max:ah,item:[{key:"label",label:"名称",kind:"text"},{key:"style",label:"样式",kind:"enum",options:[["standard","任务条"],["background","背景时段(如停机窗口)"],["event","事件时点(如到货)"]]},{key:"source",label:"对象来源",kind:"source"},{key:"global",label:"在所有资源上显示",kind:"bool",optional:!0,shows:e=>e.style==="event"},{key:"resourceField",label:"所属资源",hint:"任务排在哪个资源行上:选任务里记着资源的那一项。资源来源与图层是同一类对象时,选「对象本身」,每个对象一行。",kind:"field",objectKey:!0,optional:!0,shows:e=>!(e.style==="event"&&e.global===!0)},{key:"startField",label:"开始",kind:"field",of:"date"},{key:"endField",label:"结束",kind:"field",of:"date",optional:!0,shows:e=>e.style!=="event"},{key:"barFields",label:"条上显示的属性(第一个作为名称)",kind:"fields",optional:!0},{key:"popoverFields",label:"悬浮卡显示的属性",kind:"fields",optional:!0,shows:e=>e.style!=="background"},{key:"color",label:"颜色",kind:"enum",optional:!0,options:[["static","固定颜色"],["field","按属性取值分色"],["format","按属性的条件颜色"]]},{key:"tone",label:"固定颜色",kind:"enum",options:La,optional:!0,shows:e=>e.color===void 0||e.color==="static"},{key:"colorField",label:"着色属性",hint:"按条件颜色时,读数据源里为该属性设置的条件颜色。",kind:"field",optional:!0,shows:e=>e.color==="field"||e.color==="format"},{key:"exclusive",label:"任务占用资源",hint:"打开后,同一资源同一时间的任务数超过它的并行上限(默认 1)会标为硬约束,方案超限时不能采用;每行底部显示负荷。适合设备、产线、人员这类按时间占用的资源;以物料等为行时保持关闭。",kind:"bool",optional:!0,shows:e=>e.style==="standard"},{key:"blocks",label:"该时段不可排程",kind:"bool",optional:!0,shows:e=>e.style==="background"},{key:"selection",label:"点击写入",kind:"variable",accepts:["selection"],sentence:"点击该图层的对象时,选中它(写入 {var}),对象详情和关联表将显示它",optional:!0,shows:e=>e.style!=="background"},{key:"adjust",label:"拖动时记入的调整操作",hint:"拖动任务或它的右边缘时,用这个情景操作在方案里记一条改动;不选则只能查看。操作须用时间参数设置开始和结束,也可设置所属资源以便换行。",kind:"operation",optional:!0,fits:(e,t)=>Zh(e,t),shows:e=>e.style==="standard"},{key:"create",label:"从待排区新建",hint:"计划这类为其他对象新建的记录:还没有有效记录的对象(如需求)列在待排区,拖到资源行上时用这个操作在方案里新建一条,采用时执行它的新建行动。操作须设置开始、结束和所属资源;按行动的查重属性判断对象是否已有记录。",kind:"list",min:0,max:1,optional:!0,shows:e=>e.style==="standard",item:[{key:"source",label:"待排对象",kind:"source"},{key:"operation",label:"新建操作",kind:"operation"},{key:"days",label:"默认时长(天)",kind:"number",min:0,max:365,optional:!0},{key:"daysField",label:"时长取自(天)",kind:"field",of:"number",optional:!0},{key:"fields",label:"待排卡片显示的属性",hint:"如预测单号、交货日期,帮助认出是哪条需求。",kind:"fields",optional:!0}]},{key:"snap",label:"拖动吸附到",hint:"不选时按小时取整;操作的时间参数是日期时按天取整。",kind:"enum",optional:!0,options:[["minute","分钟"],["hour","小时"],["day","天"]],shows:e=>e.style==="standard"&&!!e.adjust},{key:"targetField",label:"目标完成",hint:"任务应在这天之前完成,如工单的交期。完成晚于目标的任务标出晚了多久、计入状态摘要,但不阻止采用方案。",kind:"field",of:"date",optional:!0,shows:e=>e.style==="standard"},{key:"targetFrom",label:"或:目标完成取自关联对象",hint:"如生产计划 → 需求预测单的交货日期;关联到多个时取最早的。",kind:"list",min:0,max:1,optional:!0,item:qa("需求对象类","目标日期"),shows:e=>e.style==="standard"},{key:"earliestField",label:"最早开始",hint:"早于这天开始的任务标为未就绪,属于硬约束。",kind:"field",of:"date",optional:!0,shows:e=>e.style==="standard"},{key:"readyFrom",label:"或:所需资源及其就绪日",hint:"如工单 → 所需备件的就绪日。任务要等所需资源都就绪才能开始:取最晚的就绪日,并点名这个关键资源。",kind:"list",min:0,max:1,optional:!0,item:qa("资源对象类","就绪日"),shows:e=>e.style==="standard"},{key:"predecessorPath",label:"前序关系",hint:"同一图层任务之间的关系。开始早于前序完成的任务标为前序未完,属于硬约束;配了目标完成时,沿前后序算出每项任务的余量,余量不大于 0 的任务属于关键链。",kind:"relationPath",single:!0,optional:!0,shows:e=>e.style==="standard"},{key:"predecessorReaches",label:"沿前序关系到达的是",kind:"enum",optional:!0,options:[["predecessors","前序任务"],["successors","后序任务"]],shows:e=>e.style==="standard"&&Array.isArray(e.predecessorPath)&&e.predecessorPath.length>0},{key:"doneWhen",label:"已完成条件(须全部满足)",hint:"满足的任务不参与约束和余量,如状态为已完工。",kind:"conditions",optional:!0,shows:e=>e.style==="standard"},{key:"ruleTools",label:"规则工具",hint:"行业规则(资质、温控、法规时段、换型时间等)由执行工厂的工具判断,结果与内置约束一起标出、计数和筛选。",kind:"list",min:0,max:ih,optional:!0,shows:e=>e.style==="standard",item:[{key:"name",label:"名称",kind:"text"},{key:"tool",label:"工具",kind:"tool",contract:"scheduleRule"},{key:"severity",label:"不通过时默认",hint:"工具的回答里写了严重程度时,以回答为准。",kind:"enum",optional:!0,options:[["hard","硬约束:方案不能采用"],["soft","软约束:只标出"]]}]},{key:"filters",label:"跟随的筛选",kind:"bindings",optional:!0}]},{key:"daysBefore",label:"基准日期之前显示的天数",kind:"number",tab:"display",min:0,max:365},{key:"daysAfter",label:"基准日期之后显示的天数",kind:"number",tab:"display",min:0,max:365},{key:"tray",label:"待排区",hint:"只看不排的页面可只显示未排数量,不列出可拖动的任务。",kind:"enum",tab:"display",optional:!0,options:[["list","列出待排任务,可点开、可拖到资源上"],["count","只显示未排数量"]]},{key:"tick",label:"时间刻度",kind:"enum",tab:"display",options:[["auto","随缩放自动"],["hour","每小时"],["fourHours","每 4 小时"],["day","每天"],["week","每周"]]},{key:"timeZone",label:"时区",kind:"enum",tab:"display",options:hf},Q("timeZoneVariable","按页面变量取时区",["value"],"按 {var} 选中的时区换算时间,没有选中时用上面的时区"),Q("resourceSelection","点击资源写入",["selection"],"点击资源名称时,选中该资源(写入 {var})")],follows:!1,selectorKeys:[],emits:e=>[...$e(e,"resourceSelection"),...(e.layers??[]).flatMap(t=>typeof t?.selection=="string"&&t.selection!==""?[{key:"layers",variable:t.selection}]:[])],check:(e,t,n)=>(e.layers??[]).flatMap((o,s)=>{if(!o||typeof o!="object")return[];const r=`${n}.layers[${s}]`;return[...o.style!=="event"&&!o.endField?[`${r}.endField 任务条和背景时段要指定结束`]:[],...!o.resourceField&&!(o.style==="event"&&o.global===!0)?[`${r}.resourceField 要指定所属资源,事件时点也可改为在所有资源上显示`]:[],...(o.color==="field"||o.color==="format")&&!o.colorField?[`${r}.colorField 按属性着色要指定着色属性`]:[]]}),review:Tp,defaults:(e,t,n)=>{const o=ee(e,n,c=>!!(ue(e,c.id)&&Mo(c,t,"date"))),s=o?pe(o,t.kn):[],r=s.filter(c=>c.type==="date"),a=o?va(s,t.kn.objectTypes[o.objectType]):void 0,l=o&&{label:o.label,style:"standard",source:o.id,resourceField:a?.name,startField:r[0]?.name,endField:r[1]?.name??r[0]?.name,barFields:[No(o,t.kn)],popoverFields:s.filter(c=>c.type!=="date"&&c.name!==a?.name).slice(0,3).map(c=>c.name),color:"static",tone:"info",selection:je(e,"selection",o.id),filters:Bc(e,t.kn,{source:o.id},{follows:!0,selectorKeys:[]})};return{title:"调度甘特",layers:l?[l]:[],daysBefore:7,daysAfter:21,tick:"auto",timeZone:"local"}}},stageChain:{label:"环节链路",summary:"环节链路,查看各环节关联的对象数量。",category:"relation",description:"依次排列的环节,每个环节是一个对象类;有关系路径的环节按跟随的筛选显示关联数量,点环节展开记录",descriptors:[J(),ae,{key:"stages",label:"环节",kind:"list",tab:"data",min:1,max:9,fill:{from:"objectType",item:e=>({objectType:e.name,label:e.label})},item:[{key:"objectType",label:"对象类",kind:"objectType"},{key:"label",label:"名称",kind:"text"},{key:"path",label:"关系路径",kind:"relationPath",optional:!0},{key:"fields",label:"展开显示的属性",kind:"fields",owner:"objectType",optional:!0}]},ve],follows:!0,selectorKeys:[],defaults:(e,t,n)=>{const o=ee(e,n);return{source:o?.id,stages:o?[{label:o.label,objectType:o.objectType,path:[]}]:[]}}},subgraph:{label:"关系子图",summary:"以选中对象为中心,绘制其关联对象。",category:"relation",description:"以选中对象为中心,沿配置的关系路径展开关联对象,画成关系图;layout 为 force 时画成关系网,layered 时从左到右分层(选中对象在最左,每一步关系一列),auto(默认)在各路径首尾相连成一条链(如销售订单 → 产品 → 物料 → 采购订单)时分层,否则画成关系网",descriptors:[J(),ae,{key:"layout",label:"布局",kind:"enum",tab:"display",optional:!0,options:[["auto","自动:路径成一条链时分层"],["force","关系网"],["layered","从左到右分层"]]},{key:"paths",label:"展开路径",kind:"list",tab:"data",min:1,max:6,item:[{key:"label",label:"名称",kind:"text"},{key:"objectType",label:"对象类",kind:"objectType"},{key:"path",label:"关系路径",kind:"relationPath"},{key:"limit",label:"最多节点",kind:"number",min:1,max:50}]},{key:"height",label:"高度(自由网格中随单元格调整)",kind:"number",tab:"display",min:240,max:640},Q("selection","读取",["selection"],"显示 {var} 中选中的对象",{optional:!1,reads:!0})],follows:!1,selectorKeys:[],review:(e,t)=>{const n=typeof e.source=="string"?ue(t.spec,e.source):void 0;return!n?.objectType||t.kn.relations.some(o=>o.source===n.objectType||o.target===n.objectType)?[]:[{key:"noRelations",values:{name:t.kn.objectTypes[n.objectType]?.name??n.objectType}}]},defaults:(e,t,n)=>{const o=ee(e,n),s=t.kn.relations.find(a=>a.source===o?.objectType||a.target===o?.objectType),r=s&&(s.source===o?.objectType?s.target:s.source);return{title:"关系子图",source:o?.id,paths:r?[{label:t.kn.objectTypes[r]?.name??r,objectType:r,path:[s.id],limit:8}]:[],height:320,selection:je(e,"selection",o?.id)}}},scenarioBar:{label:"方案",summary:"切换、新建、保存与采用方案,并排对比各方案与现状的指标;紧凑样式只留一行切换,假设样式在侧栏改方案参数和改动。",category:"scenario",description:"方案推演的入口:选择页面显示哪个方案(或现状),新建、复制、命名保存、作废方案,查看方案的改动清单(可移除),采用方案时逐条执行推演操作关联的行动和模型结果的落地条目;改动由组件点击的“推演”动作或 Agent 建议写入,推演操作在数据源上配置;方案只存在于 Workshop,不写回知识网络。页面有模型结果数据源时显示计算状态和「计算」(算当前方案中待重算的结果);新建菜单可按方案参数的可选值一次建出多个方案。style 为 table(对比表,默认)时,每行一个度量,每列现状或一个方案(最多 4 列),附与现状的差值,点列头切换方案,下方可展开方案之间不同的改动;度量可读模型结果数据源,没算过的列写「待重算」,表上的「计算」依次算各列;跟随页面筛选;需要 source 与 measures。style 为 compact(紧凑)时只有一行:方案下拉、新建与当前方案的操作,适合放在页头。style 为 assumptions(假设)时适合放在侧栏:当前方案的方案参数输入、改动清单和「添加假设」,常与页头的紧凑样式配合",descriptors:[J(),{key:"style",label:"样式",kind:"enum",tab:"display",optional:!0,options:[["table","对比表"],["compact","紧凑(只切换)"],["assumptions","假设(参数与改动)"]]},{...ae,optional:!0},{key:"measures",label:"对比的指标",kind:"list",tab:"data",optional:!0,min:1,max:8,item:[...rt]},ve],follows:!0,selectorKeys:[],defaults:(e,t,n)=>{const o=ee(e,n,s=>!!s.operations?.length);return{title:"方案",style:"table",source:o?.id,measures:[{label:"数量",aggregate:"count"},...o?.progress?.due?[{label:"已超期",aggregate:"count",when:[{field:le.status,op:"eq",value:re.overdue.value}]}]:[]]}}},modelTrial:{label:"模型试算",summary:"对一批对象按几组参数调用模型,比较各组结果的差异;结果不改对象。",category:"scenario",description:"对组件跟随的筛选留下的对象(最多 200 个,例如点指标卡或在表格勾选的一批)调用数据源上登记的模型(sources[].models),每组参数调用一次,2 到 4 组并排比较:汇总度量附与第一组(基准)的差值,明细列出各组结果;选中方案时模型读到的是方案中的值;结果只显示在页面上,不写回知识网络;可按选定一组的结果执行模型配置的行动",descriptors:[J(),ae,ve],follows:!0,selectorKeys:[],defaults:(e,t,n)=>({title:"模型试算",source:ee(e,n,s=>!!s.models?.length)?.id})},alertList:{label:"告警",summary:"按规则列出需关注的对象;点击规则仅查看其命中的对象。",category:"filter",description:"按规则实时列出命中的对象:每条规则是一组条件(如进度状态为 overdue、$overdueDays 大于 90),还可要求沿关系路径查不到记录(如没有任何关联的某类对象);按严重程度排序,点规则把命中的对象写入一个对象集合筛选,展开看具体对象",descriptors:[J(),wt,ae,{key:"rules",label:"规则",kind:"list",tab:"data",min:1,max:8,item:[{key:"label",label:"名称",kind:"text"},{key:"severity",label:"严重程度",kind:"enum",options:pf},{key:"when",label:"条件(须全部满足)",kind:"conditions",optional:!0},{key:"objectType",label:"且无关联记录:关联对象类",kind:"objectType",optional:!0},{key:"path",label:"且无关联记录:关系路径",kind:"relationPath",optional:!0}]},{key:"tagField",label:"命中对象的附加显示字段",kind:"field",tab:"display",optional:!0},{key:"limit",label:"展开显示条数",kind:"number",tab:"display",min:3,max:20},Q("writes","点击规则写入",["set"],"点击规则时,将其命中的对象写入 {var}"),Q("selection","点击对象写入",["selection"],"点击展开列表中的对象时,选中该对象(写入 {var})"),ve],follows:!0,selectorKeys:["writes"],emits:e=>$e(e,"writes"),check:(e,t,n)=>(e.rules??[]).flatMap((o,s)=>{const r=`${n}.rules[${s}]`,a=!!o.objectType||!!o.path?.length;return a&&(!o.objectType||!o.path?.length)?[`${r} 查不到关联记录的条件需要同时给关联对象类 objectType 和关系路径 path`]:!a&&!o.when?.length?[`${r} 至少要有一个条件`]:[]}),defaults:(e,t,n)=>{const o=ee(e,n,a=>!!et(a)),s=o&&et(o),r=s?qo(s).filter(a=>a.tone==="danger"):[];return{title:"告警",source:o?.id,rules:s&&r.length>0?r.map(a=>({label:s?_o(s.name,a.value):a.value,severity:"medium",when:[{field:s.name,op:"eq",value:a.value}]})):[{label:"缺少标识",severity:"low",when:[{field:o?.key??"",op:"isEmpty"}]}],tagField:s?.name,limit:8,writes:je(e,"set",o?.id),selection:je(e,"selection",o?.id)}}},eventList:{label:"事件列表",summary:"列出应用的业务事件,支持核实、驳回、关闭;点击事件选中其关联的对象。",category:"display",description:"列出应用里的业务事件(规则命中或用户登记的),未关闭的在前、按严重程度排;待核实的可以核实或驳回,已核实的可以关闭;显示规则的最近与下次检查时间,可以立即检查。事件类型在知识网络里建模,应用在 eventTypes 里按编码选择要处理的。点事件把它关联的对象写入一个选中对象筛选",descriptors:[J(),wt,{key:"types",label:"显示的事件类型(不选则为全部)",kind:"eventType",multiple:!0,tab:"data",optional:!0},{key:"show",label:"默认显示",kind:"enum",options:[["open","未关闭"],["all","全部"]],tab:"display"},{key:"limit",label:"最多显示条数",kind:"number",min:5,max:100,tab:"display"},Q("selection","点击事件选中",["selection"],"点击事件时,选中其关联的对象(写入 {var})")],follows:!1,selectorKeys:[],check:(e,t,n)=>{const o=e.selection,s=t.spec.variables.find(l=>l.name===o);if(!s||!("source"in s))return[];const r=ue(t.spec,s.source)?.objectType,a=e.types;return In(t.spec,en(t.kn.eventTypes)).filter(l=>(!a?.length||a.includes(l.id))&&l.objectType).filter(l=>l.objectType!==r).map(l=>`${n}.selection 选中的是另一类对象,事件类型 ${l.id} 关联的对象对不上;换一个筛选,或只显示关联对象相同的事件类型`)},defaults:(e,t)=>{const n=In(e,en(t.kn.eventTypes)).find(s=>s.objectType)?.objectType,o=e.variables.find(s=>s.kind==="selection"&&ue(e,s.source)?.objectType===n)?.name;return{title:"事件",show:"open",limit:20,...n&&o?{selection:o}:{}}}},eventReport:{label:"事件登记",summary:"按钮,打开表单登记业务事件;登记后状态为待核实。",category:"display",description:"一个按钮,打开一类用户登记事件(应用处理的、知识网络里来源为用户登记的事件类型)的表单:标题、发生时间、关联对象与表单字段。登记的事件默认待核实,登记人可以勾选一并核实;合并窗口内同一对象再次登记记为重复",descriptors:[{key:"type",label:"事件类型",kind:"eventType",of:"report",tab:"data"},J("按钮文字")],follows:!1,selectorKeys:[],defaults:(e,t)=>{const n=In(e,en(t.kn.eventTypes)).find(o=>o.source==="report");return n?{type:n.id}:{}}},taskInbox:{label:"任务收件箱",summary:"由事件归并生成的任务:认领后查看事件、撰写分析、进行处理,事件均有结果时任务关闭。",category:"display",description:"列出事件归并成的任务(按事件类型的归并方式:一个事件一个任务、按关联对象的属性、或按检查批次),未关闭的在前,显示事件数、未处理数、认领人与剩余时限;打开一个任务看事件、分析与处理三栏:认领、添加分析(可多条)、勾选事件新建处理(可多条,处理之间不共用事件)、判定无需处理或移出、手工结束",descriptors:[J(),{key:"types",label:"任务所属事件类型(不选则为全部)",kind:"eventType",multiple:!0,tab:"data",optional:!0},{key:"show",label:"默认显示",kind:"enum",options:[["open","未关闭"],["all","全部"]],tab:"display"},{key:"limit",label:"最多显示条数",kind:"number",min:5,max:100,tab:"display"}],follows:!1,selectorKeys:[],defaults:()=>({title:"任务",show:"open",limit:20})},actionButton:{label:"按钮",summary:"按钮:向 Agent 提问,或对选中、勾选的对象执行行动,执行前需确认。",category:"ai",description:"一个按钮,点了按顺序做 interactions 里的动作:问 Agent(可带上当前筛选),或对选中的对象(selection 筛选)、一组对象(set 筛选,例如表格勾选的行)执行知识网络里的行动;行动执行前总会打开执行确认,列出对象、填写参数、检查执行权限,确认后逐个对象以用户身份执行;行动的对象为空时按钮不可点",descriptors:[J(),ae,{key:"interactions",label:"按钮动作",kind:"interactions",on:["button"],actOn:["button"],hit:!1,max:1,tab:"data"}],follows:!1,selectorKeys:[],defaults:(e,t,n)=>{const o=ee(e,n,c=>!c.cypher&&!c.events),s=o&&t.kn.actionTypes?.find(c=>c.objectType===o.objectType),r=o&&je(e,"selection",o.id),a=o&&je(e,"set",o.id),l=r?{selection:r}:a?{set:a}:void 0;return{title:s?.name??"按钮",source:o?.id,interactions:[{on:"button",...s?{label:s.name}:{},do:s&&l?[{kind:"act",action:s.id,targets:l,params:Object.fromEntries(s.inputs.map(c=>[c.name,{from:"input"}]))}]:[{kind:"ask",question:"总结一下当前页面上需要关注的情况,并给出依据。",context:["filters"],send:"auto"}]}]}}},agentChat:{label:"Agent 对话",summary:"围绕页面数据提问,也可由 Agent 代为筛选页面。",category:"ai",description:"围绕页面数据回答问题:能查页面上的全部数据源和整个知识网络,读当前筛选和选中对象,允许时还能替用户调整全页筛选",descriptors:[J(),{key:"provider",label:"由谁回答",kind:"enum",tab:"data",options:mf},{key:"agent",label:"外部 Agent",hint:"选择 MCP 服务和其中回答问题的工具(通常名为 ask);使用者须有该服务的执行权限。",kind:"mcpTool",tab:"data",optional:!0,shows:e=>e.provider==="mcp"},{key:"allowAgentSwitch",label:"允许使用者切换智能体",hint:"MCP 服务需提供 list_agents 和接受 agent_id 的 ask 工具。切换时开始新对话。列出哪些智能体由服务决定,list_agents 声明了 app_id、bkn_token 时照样传给它。",kind:"bool",tab:"data",optional:!0,shows:e=>e.provider==="mcp"},{key:"passToken",label:"交出使用者的登录令牌",hint:"打开后,工具声明了 bkn_token 时,把使用者本人的访问令牌交给这个 Agent。Agent 凭它能做使用者能做的一切,包括执行行动和办理审批;只对可信的 Agent 打开。默认不交。",kind:"bool",tab:"data",optional:!0,shows:e=>e.provider==="mcp"},{key:"instructions",label:"补充说明",kind:"text",tab:"data",optional:!0,multiline:!0,max:600},{key:"mode",label:"显示方式",kind:"enum",tab:"display",optional:!0,options:[["float","右下角按钮,点开对话"],["side","右侧栏"],["inline","放在页面里"]]},{key:"height",shows:e=>(e.mode??"inline")==="inline",label:"高度(自由网格中随单元格调整)",kind:"number",tab:"display",min:280,max:800},{key:"suggestions",label:"建议问题",kind:"list",tab:"display",min:0,max:6,optional:!0,item:[{key:"text",label:"问题",kind:"text"}]},Q("selection","当前对象",["selection"],"回答时以 {var} 中选中的对象作为当前对象",{reads:!0}),{key:"canFilter",label:"允许 Agent 设置筛选和选中对象(例如“仅看超期”)",kind:"bool",tab:"link"},{key:"actions",label:"允许 Agent 建议的行动",hint:"Agent 只生成建议卡,由用户确认后执行;目前仅前端 Agent 支持。",kind:"actionTypes",tab:"data",optional:!0}],follows:!1,selectorKeys:[],defaults:(e,t,n)=>{const o=ee(e,n);return{title:"Agent 对话",provider:"frontend",mode:"float",height:420,suggestions:o?[{text:`${o.label}里现在最需要关注的是哪些?`},{text:`这一页的${o.label}有什么异常或趋势?`}]:[],selection:je(e,"selection",o?.id),canFilter:!0}}}};function gf(e){return Ve.filter(t=>!Nr.has(t)&&(e||ze[t].category!=="scenario"))}const dt={label:"对象详情",summary:"选中对象后打开,显示其属性、进度和关联记录。",category:"relation",description:"抽屉里显示选中对象的进度、属性,以及沿关系路径关联的记录。进度条按数据源的进度(progress)画:每一步是否完成,截止日期按期还是超期",descriptors:[J(),ae,{key:"showProgress",label:"显示进度条(需先在数据源中设置进度)",kind:"bool",tab:"data",optional:!0},{key:"fields",label:"属性",kind:"fields",tab:"data"},{key:"related",label:"关联区块",kind:"list",tab:"data",min:0,max:4,optional:!0,item:[{key:"label",label:"名称",kind:"text"},{key:"objectType",label:"对象类",kind:"objectType"},{key:"path",label:"关系路径",kind:"relationPath"},{key:"fields",label:"属性",kind:"fields",owner:"objectType"},{key:"limit",label:"最多行数",kind:"number",min:1,max:20}]},Q("selection","读取",["selection"],"显示 {var} 中选中的对象",{optional:!1,reads:!0})],follows:!1,selectorKeys:[],defaults:(e,t,n)=>{const o=ee(e,n);return{source:o?.id,...o?.progress?{showProgress:!0}:{},fields:o?pe(o,t.kn).slice(0,8).map(s=>s.name):[],selection:je(e,"selection",o?.id)}}};function ht(e){return e===me?dt:Rt(e)?ef(e):ze[e]}function ee(e,t,n=()=>!0){const o=e.sources.find(s=>s.id===t)??e.sources.find(n)??e.sources[0];return o&&(ue(e,o.id)??o)}function je(e,t,n){return e.variables.find(o=>o.kind===t&&(!n||!("source"in o)||o.source===n))?.name}function Mo(e,t,n){return pe(e,t.kn).find(o=>o.type===n)?.name}function yf(e){return e==="date"?"date":e==="number"?"number":"text"}function Fa(e){return{field:e.name,label:e.label,format:e.name===le.status?"tag":e.type?yf(e.type):"text"}}function et(e){if(e.progress)return{name:le.status,outcomes:kc};const t=e.computed?.find(n=>n.kind==="classify");return t&&{name:t.name,outcomes:[...t.cases,t.otherwise]}}function Da(e){return e.computed?.find(t=>t.kind==="region")}const Fc=/country|nation|国家|国籍/i;function bf(e,t){const n=/country|nation|region|province|state|city|site|location|address|国家|国籍|地区|省|城市|地址|所在地|产地|区域/i,o=pe(e,t.kn).filter(r=>r.type==="text"),s=r=>o.find(a=>r.test(a.name)||r.test(a.label))?.name;return s(Fc)??s(n)}function qo(e){return e.outcomes}function Fo(e,t){return pe(e,t.kn).filter(n=>n.type==="text").map(n=>n.name)}function Ba(e){return Array.isArray(e.series)&&e.series.some(t=>Se(t))}function Ua(e){return(e?.filter(t=>t.metric===void 0)??[]).flatMap(t=>{const n=jc(t.when);return n?[n.field]:[]})}function Do(e,t){return e?.variables.find(n=>n.name===t)?.kind}function wf(e){return(e.columns??[]).filter(t=>t.format==="text"||t.format==="tag").map(t=>t.field).filter(t=>typeof t=="string")}function kf(e){return[...Object.values(e.regions).flatMap(t=>t??[]),...e.detail?[e.detail]:[]]}function Dc(e){const t=new Map;for(const n of kf(e)){const o=ht(n.type).emits?.(n.config,e)??[];for(const s of o){const r=t.get(s.variable)??[];r.push({...s,placement:n.id,source:typeof n.config.source=="string"?n.config.source:void 0}),t.set(s.variable,r)}}return t}function kn(e,t){const n=Dc(e);return e.variables.find(o=>o.kind==="value"&&((n.get(o.name)??[]).some(s=>s.field===t)||o.name===t))?.name}function Bc(e,t,n,o){const s=ue(e,n.source);if(!o.follows||!s)return[];const r=new Set(o.selectorKeys.map(h=>n[h])),a=pe(s,t),l=(h,u)=>a.some(p=>p.name===h&&(!u||p.type===u)),c=Dc(e),i=h=>e.sources.find(u=>u.id===h)?.objectType,d=[];for(const h of e.variables){if(r.has(h.name))continue;const u=c.get(h.name)??[],p=u.filter(f=>i(f.source)===s.objectType);switch(h.kind){case"value":{const f=p.map(m=>m.field).find(m=>l(m))??(u.length===0&&l(h.name)?h.name:void 0);f&&d.push({variable:h.name,field:f});break}case"dateRange":{const f=p.map(m=>m.field).find(m=>l(m,"date"));f&&d.push({variable:h.name,field:f});break}case"search":{const f=[...new Set(p.flatMap(m=>m.fields??[]))].filter(m=>l(m,"text"));f.length>0&&d.push({variable:h.name,fields:f});break}case"set":i(h.source)===s.objectType&&d.push({variable:h.name});break}}return d}for(const e of Object.values(ze)){if(!e.follows)continue;const t=e.defaults;e.defaults=(n,o,s)=>{const r=t(n,o,s);return{...r,filters:Bc(n,o.kn,r,e)}}}for(const[e,t]of Object.entries(dp)){const n=e===me?dt:ze[e];n.descriptors=[...n.descriptors,{key:"interactions",label:"点击后的动作",kind:"interactions",on:t,actOn:up[e]??[],hit:!0,max:gp,...Na[e]?{offers:Na[e]}:{},tab:"link",optional:!0}]}function vf(e,t){return new Set([t,...e.sources.filter(n=>n.from?.source===t).map(n=>n.id)])}function Uc(e,t,n,o){if(o.size===0)return e;const s=structuredClone(e),r=d=>typeof d=="string"?o.get(d)??d:d,a=(d,h)=>{if(Array.isArray(d))return d.forEach(f=>a(f,h));if(typeof d!="object"||d===null)return;const u=d,p=typeof u.field=="string"?u.field:h;p===n&&(Array.isArray(u.values)&&(u.values=u.values.map(r)),"op"in u&&u.ref===void 0&&(u.value=r(u.value)));for(const[f,m]of Object.entries(u))f!=="values"&&a(m,p)},l=new Set,c=vf(s,t);for(const d of s.pages)for(const h of[...Object.values(d.regions).flatMap(u=>u??[]),...d.detail?[d.detail]:[]])if(c.has(h.config.source)){a(h.config);for(const u of h.config.filters??[])u?.field===n&&l.add(u.variable)}for(const d of s.sources)d.from?.source===t&&a(d.from.where);s.variables=s.variables.map(d=>d.kind==="value"&&l.has(d.name)&&d.default!==void 0?{...d,default:r(d.default)}:d);const i=s.sources.find(d=>d.id===t);for(const d of i?.operations??[])a(d.when);for(const d of i?.computed??[])d.name!==n&&(d.kind==="classify"&&d.cases.forEach(h=>a(h.when)),d.kind==="days"&&a(d.when));i?.progress?.steps.forEach(d=>a(d.done));for(const d of Object.values(i?.formats??{}))d.colors?.forEach(h=>a(h.when));for(const d of i?.models??[])d.measures.forEach(h=>a(h.when));return s}const X=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function $f(e){if(e.ask===void 0&&e.act===void 0)return;const t=Array.isArray(e.interactions)?e.interactions:[],n=X(e.ask)?[yp(e.ask)]:[],o=Array.isArray(e.act)?e.act.map(bp):[],s=[...t,...n,...o];s.length>0&&(e.interactions=s),delete e.ask,delete e.act}function Sf(e,t,n){const o=n.find(l=>l.id===t.source),s=X(o?.from)?o.from:void 0,r=s?n.find(l=>l.id===s.source):o,a=Array.isArray(t.adjustments)?t.adjustments:[];if(r){const l=Array.isArray(r.operations)?r.operations:[],c=new Set(l.map(i=>String(i.id)));for(const i of a){if(typeof i.field!="string")continue;let d=`shift_${i.field}`.replace(/[^A-Za-z0-9_]/g,"_");for(let h=2;c.has(d);h++)d=`shift_${i.field}_${h}`.replace(/[^A-Za-z0-9_]/g,"_");c.add(d),l.push({id:d,label:String(i.label??i.field).slice(0,30),...Array.isArray(i.when)&&i.when.length>0?{when:i.when}:{},params:[{name:"days",label:"天数",type:"number",...typeof i.min=="number"?{min:i.min}:{},...typeof i.max=="number"?{max:i.max}:{}}],effects:[{field:i.field,kind:"shiftDays",param:"days"}]})}l.length>0&&(r.operations=l)}e.type="scenarioBar",e.config={title:typeof t.title=="string"?t.title:"方案",style:"compact"}}function jf(e){const n=Object.values(e).filter(r=>Array.isArray(r)).flat(),o=r=>{const a=X(r.config)?r.config:{};return r.type==="scenarioBar"&&a.style===void 0&&(a.layout!==void 0||a.source===void 0)},s=n.some(r=>r.type==="scenarioCompare");for(const r of n){const a=X(r.config)?r.config:{};r.type==="scenarioCompare"?(r.type="scenarioBar",r.config={...a,style:"table"}):o(r)&&!s&&(delete a.layout,r.config={...a,style:"compact"})}if(s)for(const[r,a]of Object.entries(e))Array.isArray(a)&&(e[r]=a.filter(l=>!o(l)))}const Af=new Set(["status","overdueDays","dueInDays"]);function Tf(e){const[t,n]=e.split("-").map(Number);return new Date(Date.UTC(t,n,0)).toISOString().slice(0,10)}function Of(e){if(typeof e.appearsOn!="string")return null;const n=(Array.isArray(e.computed)?e.computed:[]).find(c=>c.name==="status"&&c.kind==="classify"),o=Array.isArray(n?.cases)?n.cases:[],s=Array.isArray(o[0]?.when)?o[0].when[0]:void 0,r=Array.isArray(o[1]?.when)?o[1].when[0]:void 0,a=r&&r.op==="before"&&r.ref===he?String(r.field):void 0,l=[{label:"开始",field:e.appearsOn}];return s&&s.op==="onOrBefore"&&s.ref===he?l.push({label:"完成",field:String(s.field)}):s&&s.op==="eq"&&a&&l.push({label:"完成",field:a,done:[{field:String(s.field),op:"eq",value:s.value}]}),{steps:l,...a?{due:{field:a}}:{}}}function Bo(e){if(typeof e.field!="string"||e.when!==void 0)return;const t=Array.isArray(e.values)?e.values:[];t.length>0&&(e.when=[{field:e.field,op:"in",values:t}]),delete e.field,delete e.values}function ur(e){if(Array.isArray(e))return e.forEach(ur);X(e)&&("sumField"in e&&(e.valueField===void 0&&(e.valueField=e.sumField),delete e.sumField),Object.values(e).forEach(ur))}function Ef(e){const t=new Map,o=(Array.isArray(e.computed)?e.computed:[]).find(a=>a.name==="status"&&a.kind==="classify");if(!o)return t;const s=Array.isArray(o.cases)?o.cases:[],r=[[s[0]?.value,re.done.value],[s[1]?.value,re.overdue.value],[X(o.otherwise)?o.otherwise.value:void 0,re.active.value]];for(const[a,l]of r)typeof a=="string"&&a!==l&&t.set(a,l);return t}function Cf(e,t){for(const n of e){const o=X(n.regions)?n.regions:{};for(const s of Object.values(o))if(Array.isArray(s))for(const r of s){const a=X(r.config)?r.config:{},l=(Array.isArray(a.filters)?a.filters:[]).find(c=>c?.variable===t&&Array.isArray(c.fields));if(l?.fields)return l.fields}}}function Nf(e){if(!X(e))return e;let t=e;const n=Array.isArray(e.sources)?e.sources:[],o=Array.isArray(e.variables)?e.variables:[],s=new Map,r=new Set;for(const i of n){if(i.progress!==void 0)continue;const d=Of(i);if(!d)continue;const h=Ef(i);if(h.size>0&&s.set(String(i.id),h),i.progress=d,r.add(String(i.id)),delete i.appearsOn,Array.isArray(i.computed)){const u=i.computed.filter(p=>!Af.has(String(p.name)));u.length>0?i.computed=u:delete i.computed}}const a=new Map;for(const i of o)("field"in i||"fields"in i||i.kind==="month")&&(i.kind==="selection"||i.kind==="set"||(a.set(String(i.name),{...i}),i.kind==="month"&&(i.kind="dateRange",typeof i.default=="string"&&/^\d{4}-\d{2}$/.test(i.default)&&(i.default=`${i.default}-01..${Tf(i.default)}`)),delete i.source,delete i.field,delete i.fields));const l=o.filter(i=>i.kind==="set"),c=Array.isArray(e.pages)?e.pages:[];for(const i of c){const d=X(i.regions)?i.regions:{};jf(d);const h=[...Object.values(d).flatMap(u=>Array.isArray(u)?u:[]),...X(i.detail)?[i.detail]:[]];for(const u of h){const p=u.type,f=X(u.config)?u.config:null;if(!f)continue;if(p==="whatIf"){Sf(u,f,n);continue}if(ur(f),$f(f),p==="metricCards"&&Array.isArray(f.items)&&f.items.forEach(b=>X(b)&&Bo(b)),p==="pivotTable"&&Array.isArray(f.measures)&&f.measures.forEach(b=>X(b)&&Bo(b)),p==="objectList"&&Bo(f),p==="regionMap"&&Array.isArray(f.links)){const b=f.links.filter(k=>Array.isArray(k?.path)&&k.path.length===1);b.length>0?f.links=b:delete f.links}if(p===me&&Array.isArray(f.progress)&&(f.progress.length>0&&(f.showProgress=!0),delete f.progress),!Ve.includes(p))continue;const m=ht(p);if(p==="searchBox"&&typeof f.writes=="string"&&!f.fields){const b=a.get(f.writes)?.fields??Cf(c,f.writes);Array.isArray(b)&&b.length>0&&(f.fields=b)}if(p==="objectTable"&&typeof f.quickFilter=="string"&&!f.quickField){const b=a.get(f.quickFilter);typeof b?.field=="string"&&(f.quickField=b.field)}if(!m.follows||f.filters!==void 0||typeof f.source!="string")continue;const g=new Set(m.selectorKeys.map(b=>f[b])),y=[];for(const[b,k]of a)g.has(b)||k.source!==f.source||(Array.isArray(k.fields)?y.push({variable:b,fields:k.fields}):typeof k.field=="string"&&y.push({variable:b,field:k.field}));for(const b of l)!g.has(b.name)&&b.source===f.source&&y.push({variable:String(b.name)});f.filters=y}}for(const[i,d]of s)t=Uc(t,i,"status",d);return r.size>0&&(t=Mf(t,r)),Pf(t),xf(t),t}function xf(e){const t=Array.isArray(e.eventTypes)?e.eventTypes:[];for(const n of t)if(X(n)){for(const o of["label","source","subject","severity","rule"])delete n[o];X(n.report)&&delete n.report.mergeHours}}const Rf=/^[a-z0-9][a-z0-9_.-]{0,63}$/;function _f(e,t){const n=e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase().replace(/[^a-z0-9_.-]/g,"_").replace(/^[^a-z0-9]+/,"").slice(0,64)||"event";let o=n;for(let s=2;t.has(o);s+=1)o=`${n.slice(0,64-String(s).length)}${s}`;return o}function Pf(e){const t=Array.isArray(e.eventTypes)?e.eventTypes:[],n=new Set(t.map(r=>String(r.id))),o=new Map;for(const r of t){const a=r.id;if(typeof a!="string"||Rf.test(a))continue;n.delete(a);const l=_f(a,n);n.add(l),o.set(a,l),r.id=l}if(o.size===0)return;const s=r=>typeof r=="string"?o.get(r)??r:r;for(const r of Array.isArray(e.sources)?e.sources:[]){const a=X(r.events)?r.events:void 0;Array.isArray(a?.types)&&(a.types=a.types.map(s))}for(const r of Array.isArray(e.pages)?e.pages:[]){const l=[...(X(r.regions)?Object.values(r.regions):[]).flatMap(c=>Array.isArray(c)?c:[]),...X(r.detail)?[r.detail]:[]];for(const c of l){if(!Ve.includes(c.type)||!X(c.config))continue;const i=c.config;for(const d of ht(c.type).descriptors){if(d.kind!=="eventType"||i[d.key]===void 0)continue;const h=i[d.key];i[d.key]=Array.isArray(h)?h.map(s):s(h)}}}}const Lf=new Map([["status",le.status],["stage",le.stage],["overdueDays",le.overdueDays],["dueInDays",le.dueInDays]]),If=new Map(Object.values(re).map(e=>[e.label,e.value]));function zc(e,t,n){const o=s=>typeof s=="string"?n(s):s;for(const s of e){const r=t[s.key],a=!("owner"in s)||s.owner!=="objectType";if(s.kind==="field"&&a)t[s.key]=o(r);else if(s.kind==="fields"&&a&&Array.isArray(r))t[s.key]=r.map(o);else if(s.kind==="conditions"&&Array.isArray(r))for(const l of r)X(l)&&(l.field=o(l.field),l.ref!==void 0&&(l.ref=o(l.ref)));else if(s.kind==="bindings"&&Array.isArray(r))for(const l of r)X(l)&&(l.field!==void 0&&(l.field=o(l.field)),Array.isArray(l.fields)&&(l.fields=l.fields.map(o)));else if(s.kind==="list"&&Array.isArray(r))for(const l of r)X(l)&&zc(s.item,l,n)}}function Mf(e,t){let n=structuredClone(e);const o=r=>Lf.get(r)??r,s=r=>r.replace(/(?<![$\w`])(status|stage|overdueDays|dueInDays)\b/g,a=>o(a));for(const r of n.sources){if(!r.progress||t&&!t.has(r.id))continue;const a=new Set(n.sources.filter(c=>c.id===r.id||c.from?.source===r.id).map(c=>c.id));for(const c of n.pages)for(const i of[...Object.values(c.regions).flatMap(d=>d??[]),...c.detail?[c.detail]:[]])a.has(i.config.source)&&zc(ht(i.type).descriptors,i.config,o);const l=c=>c?.forEach(i=>{i.field=o(i.field),i.ref!==void 0&&(i.ref=o(i.ref))});r.formats&&(r.formats=Object.fromEntries(Object.entries(r.formats).map(([c,i])=>(i.colors?.forEach(d=>l(d.when)),[o(c),i]))));for(const c of n.sources)if(c.from?.source===r.id){l(c.from.where);for(const i of c.from.filters??[])i.field!==void 0&&(i.field=o(i.field)),i.fields&&(i.fields=i.fields.map(o))}for(const c of r.operations??[])l(c.when);for(const c of r.computed??[])c.kind==="classify"&&c.cases.forEach(i=>l(i.when)),c.kind==="days"&&(c.from=o(c.from),c.to=o(c.to),l(c.when)),c.kind==="formula"&&(c.expr=s(c.expr));n=Uc(n,r.id,le.status,If)}return n}const pt="workshop.openbkn.ai/v1",qf=["tabs","cards","segmented","side"],Ff=["dashboard","table","chart","map","alert","task","calendar","relation","search","agent","team","setting"],Df=["tasks","alerts"];function tn(e,t){const n=e.pages.find(o=>o.id===t)??e.pages[0];return{version:2,title:n.title,layout:n.layout,sources:e.sources,variables:e.variables,...e.eventTypes?{eventTypes:e.eventTypes}:{},...e.scenarioParams?{scenarioParams:e.scenarioParams}:{},...e.components?{components:e.components}:{},regions:n.regions,detail:n.detail,theme:e.theme}}function Bf(e){if(typeof e!="object"||e===null)return e;const t=Nf(structuredClone(e)),n=t.pages;if(!Array.isArray(n))return t;for(const o of n)for(const s of Object.values(o?.regions??{}))if(Array.isArray(s))for(const r of s)r?.type==="agentChat"&&r.config&&delete r.config.source;return t}var Uo={exports:{}},P={};var za;function Uf(){if(za)return P;za=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),r=Symbol.for("react.consumer"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),i=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),u=Symbol.iterator;function p($){return $===null||typeof $!="object"?null:($=u&&$[u]||$["@@iterator"],typeof $=="function"?$:null)}var f={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m=Object.assign,g={};function y($,T,C){this.props=$,this.context=T,this.refs=g,this.updater=C||f}y.prototype.isReactComponent={},y.prototype.setState=function($,T){if(typeof $!="object"&&typeof $!="function"&&$!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,$,T,"setState")},y.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function b(){}b.prototype=y.prototype;function k($,T,C){this.props=$,this.context=T,this.refs=g,this.updater=C||f}var w=k.prototype=new b;w.constructor=k,m(w,y.prototype),w.isPureReactComponent=!0;var v=Array.isArray;function S(){}var j={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function A($,T,C){var R=C.ref;return{$$typeof:e,type:$,key:T,ref:R!==void 0?R:null,props:C}}function E($,T){return A($.type,T,$.props)}function x($){return typeof $=="object"&&$!==null&&$.$$typeof===e}function I($){var T={"=":"=0",":":"=2"};return"$"+$.replace(/[=:]/g,function(C){return T[C]})}var M=/\/+/g;function L($,T){return typeof $=="object"&&$!==null&&$.key!=null?I(""+$.key):T.toString(36)}function ne($){switch($.status){case"fulfilled":return $.value;case"rejected":throw $.reason;default:switch(typeof $.status=="string"?$.then(S,S):($.status="pending",$.then(function(T){$.status==="pending"&&($.status="fulfilled",$.value=T)},function(T){$.status==="pending"&&($.status="rejected",$.reason=T)})),$.status){case"fulfilled":return $.value;case"rejected":throw $.reason}}throw $}function q($,T,C,R,z){var Y=typeof $;(Y==="undefined"||Y==="boolean")&&($=null);var V=!1;if($===null)V=!0;else switch(Y){case"bigint":case"string":case"number":V=!0;break;case"object":switch($.$$typeof){case e:case t:V=!0;break;case d:return V=$._init,q(V($._payload),T,C,R,z)}}if(V)return z=z($),V=R===""?"."+L($,0):R,v(z)?(C="",V!=null&&(C=V.replace(M,"$&/")+"/"),q(z,T,C,"",function(hu){return hu})):z!=null&&(x(z)&&(z=E(z,C+(z.key==null||$&&$.key===z.key?"":(""+z.key).replace(M,"$&/")+"/")+V)),T.push(z)),1;V=0;var qe=R===""?".":R+":";if(v($))for(var ke=0;ke<$.length;ke++)R=$[ke],Y=qe+L(R,ke),V+=q(R,T,C,Y,z);else if(ke=p($),typeof ke=="function")for($=ke.call($),ke=0;!(R=$.next()).done;)R=R.value,Y=qe+L(R,ke++),V+=q(R,T,C,Y,z);else if(Y==="object"){if(typeof $.then=="function")return q(ne($),T,C,R,z);throw T=String($),Error("Objects are not valid as a React child (found: "+(T==="[object Object]"?"object with keys {"+Object.keys($).join(", ")+"}":T)+"). If you meant to render a collection of children, use an array instead.")}return V}function N($,T,C){if($==null)return $;var R=[],z=0;return q($,R,"","",function(Y){return T.call(C,Y,z++)}),R}function Z($){if($._status===-1){var T=$._result;T=T(),T.then(function(C){($._status===0||$._status===-1)&&($._status=1,$._result=C)},function(C){($._status===0||$._status===-1)&&($._status=2,$._result=C)}),$._status===-1&&($._status=0,$._result=T)}if($._status===1)return $._result.default;throw $._result}var U=typeof reportError=="function"?reportError:function($){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var T=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof $=="object"&&$!==null&&typeof $.message=="string"?String($.message):String($),error:$});if(!window.dispatchEvent(T))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",$);return}console.error($)},oe={map:N,forEach:function($,T,C){N($,function(){T.apply(this,arguments)},C)},count:function($){var T=0;return N($,function(){T++}),T},toArray:function($){return N($,function(T){return T})||[]},only:function($){if(!x($))throw Error("React.Children.only expected to receive a single React element child.");return $}};return P.Activity=h,P.Children=oe,P.Component=y,P.Fragment=n,P.Profiler=s,P.PureComponent=k,P.StrictMode=o,P.Suspense=c,P.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=j,P.__COMPILER_RUNTIME={__proto__:null,c:function($){return j.H.useMemoCache($)}},P.cache=function($){return function(){return $.apply(null,arguments)}},P.cacheSignal=function(){return null},P.cloneElement=function($,T,C){if($==null)throw Error("The argument must be a React element, but you passed "+$+".");var R=m({},$.props),z=$.key;if(T!=null)for(Y in T.key!==void 0&&(z=""+T.key),T)!O.call(T,Y)||Y==="key"||Y==="__self"||Y==="__source"||Y==="ref"&&T.ref===void 0||(R[Y]=T[Y]);var Y=arguments.length-2;if(Y===1)R.children=C;else if(1<Y){for(var V=Array(Y),qe=0;qe<Y;qe++)V[qe]=arguments[qe+2];R.children=V}return A($.type,z,R)},P.createContext=function($){return $={$$typeof:a,_currentValue:$,_currentValue2:$,_threadCount:0,Provider:null,Consumer:null},$.Provider=$,$.Consumer={$$typeof:r,_context:$},$},P.createElement=function($,T,C){var R,z={},Y=null;if(T!=null)for(R in T.key!==void 0&&(Y=""+T.key),T)O.call(T,R)&&R!=="key"&&R!=="__self"&&R!=="__source"&&(z[R]=T[R]);var V=arguments.length-2;if(V===1)z.children=C;else if(1<V){for(var qe=Array(V),ke=0;ke<V;ke++)qe[ke]=arguments[ke+2];z.children=qe}if($&&$.defaultProps)for(R in V=$.defaultProps,V)z[R]===void 0&&(z[R]=V[R]);return A($,Y,z)},P.createRef=function(){return{current:null}},P.forwardRef=function($){return{$$typeof:l,render:$}},P.isValidElement=x,P.lazy=function($){return{$$typeof:d,_payload:{_status:-1,_result:$},_init:Z}},P.memo=function($,T){return{$$typeof:i,type:$,compare:T===void 0?null:T}},P.startTransition=function($){var T=j.T,C={};j.T=C;try{var R=$(),z=j.S;z!==null&&z(C,R),typeof R=="object"&&R!==null&&typeof R.then=="function"&&R.then(S,U)}catch(Y){U(Y)}finally{T!==null&&C.types!==null&&(T.types=C.types),j.T=T}},P.unstable_useCacheRefresh=function(){return j.H.useCacheRefresh()},P.use=function($){return j.H.use($)},P.useActionState=function($,T,C){return j.H.useActionState($,T,C)},P.useCallback=function($,T){return j.H.useCallback($,T)},P.useContext=function($){return j.H.useContext($)},P.useDebugValue=function(){},P.useDeferredValue=function($,T){return j.H.useDeferredValue($,T)},P.useEffect=function($,T){return j.H.useEffect($,T)},P.useEffectEvent=function($){return j.H.useEffectEvent($)},P.useId=function(){return j.H.useId()},P.useImperativeHandle=function($,T,C){return j.H.useImperativeHandle($,T,C)},P.useInsertionEffect=function($,T){return j.H.useInsertionEffect($,T)},P.useLayoutEffect=function($,T){return j.H.useLayoutEffect($,T)},P.useMemo=function($,T){return j.H.useMemo($,T)},P.useOptimistic=function($,T){return j.H.useOptimistic($,T)},P.useReducer=function($,T,C){return j.H.useReducer($,T,C)},P.useRef=function($){return j.H.useRef($)},P.useState=function($){return j.H.useState($)},P.useSyncExternalStore=function($,T,C){return j.H.useSyncExternalStore($,T,C)},P.useTransition=function(){return j.H.useTransition()},P.version="19.2.8",P}var Wa;function zf(){return Wa||(Wa=1,Uo.exports=Uf()),Uo.exports}zf();const Wf={skipErrorToast:!0},Ir=e=>`/bkn-backend/v1/knowledge-networks/${encodeURIComponent(e)}`,zo=100,Kf=50;async function Mr(e,t={}){const n=[];for(let o=0;o<Kf;o+=1){const{data:s}=await st.get(e,{...Wf,params:{...t,limit:zo,offset:o*zo}}),r=s.entries??[];if(n.push(...r),r.length<zo||n.length>=(s.total_count??1/0))break}return n}async function Yf(e,t){return(await Mr(`${Ir(e)}/action-types`,{operation_kind:"event"})).filter(o=>o.id&&o.operation_config?.type==="event"&&!0)}function Gf(e){const t=e.schedule;return t?.expression?{...t.type?{type:t.type}:{},expression:t.expression,...t.timezone?{timezone:t.timezone}:{}}:null}async function Hf(e,t){return(await Mr(`${Ir(e)}/action-schedules`,{})).filter(o=>o.id&&o.source==="action_type"&&!0)}function Vf(e,t,n){const o=e.id??"",s=e.event??{},r=s.source==="rule"?"rule":"report",a=t?.find(i=>i.operation_config?.event_class===o),l=a&&n?.find(i=>i.action_type_id===a.id),c=l?.next_run_time;return{code:o,name:e.name||o,source:r,...s.subject?{subject:s.subject}:{},...s.severity?{severity:s.severity}:{},...s.merge_hours?{merge_hours:s.merge_hours}:{},...r==="rule"&&t?{recognition_action_id:a?.id??null,check_schedule:a?Gf(a):null,...a&&n?{platform_schedule_id:l?.id??null}:{}}:{},...c?{next_check_at:c}:{}}}async function Jf(e){const[t,n,o]=await Promise.all([Mr(`${Ir(e)}/object-types`),Yf(e).catch(()=>{}),Hf(e).catch(()=>{})]);return t.filter(s=>s.id&&Array.isArray(s.kinds)&&s.kinds.includes("event")).map(s=>Vf(s,n,o))}Math.random().toString(36).slice(2);const Zf=new Map;Math.random().toString(36).slice(2);function Xf(){for(const e of Zf.values())if(e.dirty.size>0||e.writing.size>0||e.failed.size>0)return!0;return!1}typeof window<"u"&&window.addEventListener("beforeunload",e=>{Xf()&&(e.preventDefault(),e.returnValue="")});const Qf=new Map;function em(e,t){Qf.set(e,Promise.resolve(t))}class Wc extends Error{constructor(t){super("draft changed since it was read"),this.currentRevision=t}currentRevision}class qr extends Error{constructor(){super("app not found")}}class Fr extends Error{constructor(){super("not allowed")}}class Kc extends Error{constructor(){super("app too large")}}class tm extends Error{constructor(t){super("event types missing on the network"),this.eventTypes=t}eventTypes}const Dr="/workshop/v1",un={skipErrorToast:!0},nm=200;function om(e){const t=e?.response,n=t?.status,o=t?.data?.metadata;if(n===404)return new qr;if(n===403)return new Fr;if(n===413)return new Kc;if(n===409){if(typeof o?.current_revision=="number")return new Wc(o.current_revision);if(Array.isArray(o?.event_types))return new tm(o.event_types.map(String))}return e}async function hn(e){try{return(await e()).data}catch(t){throw om(t)}}function sm(){return`ws-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}const Ka=e=>({id:e?.id??"",name:e?.name||e?.id||""});function rm(e){return!e||typeof e!="object"||!Array.isArray(e.pages)?null:Bf(e)}function Yc(e){const t=e.tags??[],n=(e.references??[]).map(Ka);return{id:e.id,name:e.name,...e.description?{description:e.description}:{},...e.icon?{icon:e.icon}:{},...e.color?{color:e.color}:{},...t.length>0?{tags:t}:{},...n.length>0?{references:n}:{},network:Ka(e.kn),version:e.current_version??0,revision:e.draft_revision??0,creator:e.creator??"",updatedAt:e.update_time??0,operations:e.operations??[],...e.managed_by?{managedBy:e.managed_by}:{},...e.workspace_id?{workspaceId:e.workspace_id}:{}}}const Br=e=>({...Yc(e),draft:rm(e.draft)}),Ur=e=>`${Dr}/apps/${encodeURIComponent(e)}`;async function am(){const e=[];let t="";for(const n=new Set;;n.add(t)){const o=new URLSearchParams({limit:String(nm)});t&&o.set("cursor",t);const s=await hn(()=>st.get(`${Dr}/apps`,{...un,params:o}));if(e.push(...(s.entries??[]).map(Yc)),t=s.next_cursor??"",!t||n.has(t))return e}}async function im(e){try{const t=Br(await hn(()=>st.get(Ur(e),un)));return em(e,t.workspaceId),t}catch(t){if(t instanceof qr)return null;throw t}}const lm=e=>({name:e.name,description:e.description?.trim()??"",...e.icon?{icon:e.icon}:{},...e.color?{color:e.color}:{},tags:e.tags??[],references:(e.references??[]).map(({id:t,name:n})=>({id:t,name:n}))});async function cm(e,t,n,o={},s){const r=await hn(()=>st.post(`${Dr}/apps`,{...lm({...o,name:e}),kn:{id:t.id,name:t.name},draft:n,...s?{workspace_id:s}:{}},{...un,headers:{"Idempotency-Key":sm()}}));return Br(r)}async function dm(e,t,n){return Br(await hn(()=>st.put(`${Ur(e)}/draft`,{draft:t,revision:n},un)))}async function um(e,t,n="upload"){const o=await hn(()=>st.post(`${Ur(e)}/component-packages`,t,{...un,params:{source:n},headers:{"Content-Type":"application/zip"}}));return{id:o.package.id,type:o.package.type,version:o.package.version,manifest:o.package.manifest,warnings:o.warnings??[]}}const hm=()=>nt().listNetworks(),pm=e=>nt().listObjectTypes(e),fm=(e,t)=>nt().getObjectType(e,t),mm=e=>nt().listRelationTypes(e);var W={},Wo={},Ko={},de={},Ya;function B(){if(Ya)return de;Ya=1;const e=Symbol.for("yaml.alias"),t=Symbol.for("yaml.document"),n=Symbol.for("yaml.map"),o=Symbol.for("yaml.pair"),s=Symbol.for("yaml.scalar"),r=Symbol.for("yaml.seq"),a=Symbol.for("yaml.node.type"),l=g=>!!g&&typeof g=="object"&&g[a]===e,c=g=>!!g&&typeof g=="object"&&g[a]===t,i=g=>!!g&&typeof g=="object"&&g[a]===n,d=g=>!!g&&typeof g=="object"&&g[a]===o,h=g=>!!g&&typeof g=="object"&&g[a]===s,u=g=>!!g&&typeof g=="object"&&g[a]===r;function p(g){if(g&&typeof g=="object")switch(g[a]){case n:case r:return!0}return!1}function f(g){if(g&&typeof g=="object")switch(g[a]){case e:case n:case s:case r:return!0}return!1}const m=g=>(h(g)||p(g))&&!!g.anchor;return de.ALIAS=e,de.DOC=t,de.MAP=n,de.NODE_TYPE=a,de.PAIR=o,de.SCALAR=s,de.SEQ=r,de.hasAnchor=m,de.isAlias=l,de.isCollection=p,de.isDocument=c,de.isMap=i,de.isNode=f,de.isPair=d,de.isScalar=h,de.isSeq=u,de}var vn={},Ga;function co(){if(Ga)return vn;Ga=1;var e=B();const t=Symbol("break visit"),n=Symbol("skip children"),o=Symbol("remove node");function s(h,u){const p=c(u);e.isDocument(h)?r(null,h.contents,p,Object.freeze([h]))===o&&(h.contents=null):r(null,h,p,Object.freeze([]))}s.BREAK=t,s.SKIP=n,s.REMOVE=o;function r(h,u,p,f){const m=i(h,u,p,f);if(e.isNode(m)||e.isPair(m))return d(h,f,m),r(h,m,p,f);if(typeof m!="symbol"){if(e.isCollection(u)){f=Object.freeze(f.concat(u));for(let g=0;g<u.items.length;++g){const y=r(g,u.items[g],p,f);if(typeof y=="number")g=y-1;else{if(y===t)return t;y===o&&(u.items.splice(g,1),g-=1)}}}else if(e.isPair(u)){f=Object.freeze(f.concat(u));const g=r("key",u.key,p,f);if(g===t)return t;g===o&&(u.key=null);const y=r("value",u.value,p,f);if(y===t)return t;y===o&&(u.value=null)}}return m}async function a(h,u){const p=c(u);e.isDocument(h)?await l(null,h.contents,p,Object.freeze([h]))===o&&(h.contents=null):await l(null,h,p,Object.freeze([]))}a.BREAK=t,a.SKIP=n,a.REMOVE=o;async function l(h,u,p,f){const m=await i(h,u,p,f);if(e.isNode(m)||e.isPair(m))return d(h,f,m),l(h,m,p,f);if(typeof m!="symbol"){if(e.isCollection(u)){f=Object.freeze(f.concat(u));for(let g=0;g<u.items.length;++g){const y=await l(g,u.items[g],p,f);if(typeof y=="number")g=y-1;else{if(y===t)return t;y===o&&(u.items.splice(g,1),g-=1)}}}else if(e.isPair(u)){f=Object.freeze(f.concat(u));const g=await l("key",u.key,p,f);if(g===t)return t;g===o&&(u.key=null);const y=await l("value",u.value,p,f);if(y===t)return t;y===o&&(u.value=null)}}return m}function c(h){return typeof h=="object"&&(h.Collection||h.Node||h.Value)?Object.assign({Alias:h.Node,Map:h.Node,Scalar:h.Node,Seq:h.Node},h.Value&&{Map:h.Value,Scalar:h.Value,Seq:h.Value},h.Collection&&{Map:h.Collection,Seq:h.Collection},h):h}function i(h,u,p,f){if(typeof p=="function")return p(h,u,f);if(e.isMap(u))return p.Map?.(h,u,f);if(e.isSeq(u))return p.Seq?.(h,u,f);if(e.isPair(u))return p.Pair?.(h,u,f);if(e.isScalar(u))return p.Scalar?.(h,u,f);if(e.isAlias(u))return p.Alias?.(h,u,f)}function d(h,u,p){const f=u[u.length-1];if(e.isCollection(f))f.items[h]=p;else if(e.isPair(f))h==="key"?f.key=p:f.value=p;else if(e.isDocument(f))f.contents=p;else{const m=e.isAlias(f)?"alias":"scalar";throw new Error(`Cannot replace node with ${m} parent`)}}return vn.visit=s,vn.visitAsync=a,vn}var Ha;function Gc(){if(Ha)return Ko;Ha=1;var e=B(),t=co();const n={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},o=r=>r.replace(/[!,[\]{}]/g,a=>n[a]);class s{constructor(a,l){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},s.defaultYaml,a),this.tags=Object.assign({},s.defaultTags,l)}clone(){const a=new s(this.yaml,this.tags);return a.docStart=this.docStart,a}atDocument(){const a=new s(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:s.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},s.defaultTags);break}return a}add(a,l){this.atNextDocument&&(this.yaml={explicit:s.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},s.defaultTags),this.atNextDocument=!1);const c=a.trim().split(/[ \t]+/),i=c.shift();switch(i){case"%TAG":{if(c.length!==2&&(l(0,"%TAG directive should contain exactly two parts"),c.length<2))return!1;const[d,h]=c;return this.tags[d]=h,!0}case"%YAML":{if(this.yaml.explicit=!0,c.length!==1)return l(0,"%YAML directive should contain exactly one part"),!1;const[d]=c;if(d==="1.1"||d==="1.2")return this.yaml.version=d,!0;{const h=/^\d+\.\d+$/.test(d);return l(6,`Unsupported YAML version ${d}`,h),!1}}default:return l(0,`Unknown directive ${i}`,!0),!1}}tagName(a,l){if(a==="!")return"!";if(a[0]!=="!")return l(`Not a valid tag: ${a}`),null;if(a[1]==="<"){const h=a.slice(2,-1);return h==="!"||h==="!!"?(l(`Verbatim tags aren't resolved, so ${a} is invalid.`),null):(a[a.length-1]!==">"&&l("Verbatim tags must end with a >"),h)}const[,c,i]=a.match(/^(.*!)([^!]*)$/s);i||l(`The ${a} tag has no suffix`);const d=this.tags[c];if(d)try{return d+decodeURIComponent(i)}catch(h){return l(String(h)),null}return c==="!"?a:(l(`Could not resolve tag: ${a}`),null)}tagString(a){for(const[l,c]of Object.entries(this.tags))if(a.startsWith(c))return l+o(a.substring(c.length));return a[0]==="!"?a:`!<${a}>`}toString(a){const l=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],c=Object.entries(this.tags);let i;if(a&&c.length>0&&e.isNode(a.contents)){const d={};t.visit(a.contents,(h,u)=>{e.isNode(u)&&u.tag&&(d[u.tag]=!0)}),i=Object.keys(d)}else i=[];for(const[d,h]of c)d==="!!"&&h==="tag:yaml.org,2002:"||(!a||i.some(u=>u.startsWith(h)))&&l.push(`%TAG ${d} ${h}`);return l.join(`
|
|
17
|
-
`)}}return s.defaultYaml={explicit:!1,version:"1.2"},s.defaultTags={"!!":"tag:yaml.org,2002:"},Ko.Directives=s,Ko}var Yo={},Go={},kt={},
|
|
16
|
+
- 详情抽屉的进度条直接按进度画。`;function Po(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const rf=e=>hh.includes(e??"")?e:"P3";function af(e,t){if(!t)return;const n=e.sources.filter(o=>{const s=ue(e,o.id);return s&&!s.events&&!s.cypher&&s.objectType===t});return(n.find(o=>!o.from)??n[0])?.id}function Fc(e,t,n){const o=n?.get(t.id),s=o?.subject||void 0,r=af(e,s);return{...t,label:o?.name||t.id,severity:rf(o?.severity),...o?{source:o.source,network:o}:{},...n&&!o?{missing:!0}:{},...s?{objectType:s}:{},...r?{subject:r}:{}}}function en(e){if(!e)return;const t=Array.isArray(e)?e:Object.values(e);return new Map(t.map(n=>[n.code,n]))}function Mn(e,t){return(e.eventTypes??[]).map(n=>Fc(e,n,t))}const ot="fieldRoles",Dc=`${ot}.`,sn=new Map,lf=new Set;function Bc(e,t,n="zh-CN"){const o=sn.get(t.type);o?.package===e&&o.locale===n||(sn.set(t.type,{package:e,manifest:t,schema:Uc(t,n),locale:n}),lf.forEach(s=>s()))}function cf(e){return sn.get(e)?.schema??df(e)}function df(e){return{label:e,summary:"",category:"display",description:`自定义组件 ${e}`,descriptors:[],follows:!1,selectorKeys:[],defaults:()=>({})}}function uf(e){if(!Rt(e))return gc[e];const t=sn.get(e)?.manifest.minSize;return t?[t.w,t.h]:[3,3]}function hf(e,t){return e.label[t]??e.label["zh-CN"]??e.type}const Lr=e=>e==="string"?"text":e==="number"?"number":e==="date"||e==="datetime"?"date":void 0,pf=["filter","display","chart","relation"];function ff(e,t,n){const o=t["x-workshop"],s={key:e,label:t.title??e,...t.description?{hint:t.description}:{},...n?{}:{optional:!0},tab:o?.tab??"display",...o?.showIf?{shows:l=>Object.entries(o.showIf??{}).every(([c,i])=>l[c]===i)}:{}},r=Lr(o?.fieldTypes?.[0]);let a=null;switch(o?.widget){case"field":a={...s,kind:"field",...r?{of:r}:{}};break;case"fields":a={...s,kind:"fields",...r?{of:r}:{}};break;case"variable":a={...s,kind:"variable",accepts:Hn};break;case"objectType":a={...s,kind:"objectType"};break;case"relationPath":a={...s,kind:"relationPath",...mf(t)?{single:!0}:{}};break;case"actionType":a={...s,kind:"actionTypes"};break;default:Array.isArray(t.enum)&&t.enum.every(l=>typeof l=="string")?a={...s,kind:"enum",options:t.enum.map(l=>[l,l])}:t.type==="boolean"?a={...s,kind:"bool"}:t.type==="number"||t.type==="integer"?a={...s,kind:"number",min:t.minimum??-1e12,max:t.maximum??1e12,...t.type==="number"?{decimal:!0}:{}}:t.type==="string"&&(a={...s,kind:"text",max:t.maxLength??null})}return a}const mf=e=>e.type==="string"||e["x-workshop"]?.maxHops===1;function gf(e){return Object.entries(e.configSchema.properties??{}).filter(([,t])=>{const n=t["x-workshop"]?.widget;return n==="actionType"||n==="relationPath"&&t.type==="string"}).map(([t])=>t)}function yf(e,t){const n=sn.get(e)?.manifest,{[ot]:o,...s}=t,r={...s};if(o&&typeof o=="object"&&!Array.isArray(o))for(const[a,l]of Object.entries(o))r[Dc+a]=l;for(const a of n?gf(n):[])typeof r[a]=="string"&&(r[a]=[r[a]]);return r}function Uc(e,t="zh-CN"){const n=e.data.source,o=Array.isArray(e.data.fields)?e.data.fields:[],s=new Set(e.configSchema.required??[]),r={},a=[{key:"title",label:"标题",kind:"text",max:80,optional:!0,tab:"display"}];n&&a.push({key:"source",label:"数据源",kind:"source",tab:"data"});for(const c of o){const i=Lr(c.type);a.push({key:Dc+c.role,label:`字段:${c.role}`,kind:"field",...i?{of:i}:{},tab:"data"})}for(const[c,i]of Object.entries(e.configSchema.properties??{})){if(["title","source","filters","selection",ot].includes(c))continue;const d=ff(c,i,s.has(c));d?a.push(d):(i.type==="array"||i.type==="object")&&(r[c]=i.type)}const l=n&&e.follows;return l&&a.push({key:"filters",label:"跟随筛选",kind:"bindings",optional:!0,tab:"link"}),e.emits?.includes("selection")&&a.push({key:"selection",label:"点选对象写入",kind:"variable",accepts:["selection"],optional:!0,tab:"link"}),{label:hf(e,t),summary:e.description,category:pf.includes(e.category)?e.category:"display",description:e.description,descriptors:a,...Object.keys(r).length>0?{free:r}:{},follows:l,selectorKeys:[],defaults:(c,i)=>bf(e,c,i.kn)}}function bf(e,t,n){const o={};for(const[i,d]of Object.entries(e.configSchema.properties??{}))d.default!==void 0&&(o[i]=d.default);if(!e.data.source)return o;const s=t.sources[0];if(!s)return o;if(o.source=s.id,e.emits?.includes("selection")){const i=t.variables.find(d=>d.kind==="selection"&&(!("source"in d)||d.source===s.id))?.name;i&&(o.selection=i)}if(Array.isArray(e.data.fields)){const i=pe(s,n),d={},h=new Set;for(const u of e.data.fields){const p=Lr(u.type),f=i.find(m=>!h.has(m.name)&&(!p||m.type===p));f&&(d[u.role]=f.name,h.add(f.name))}Object.keys(d).length>0&&(o[ot]=d)}const r=new Set(e.configSchema.required??[]),a=i=>Object.entries(e.configSchema.properties??{}).filter(([d,h])=>r.has(d)&&o[d]===void 0&&h["x-workshop"]?.widget===i);let l;const c=n.relations.find(i=>i.source===s.objectType||i.target===s.objectType);if(c){l=c.source===s.objectType?c.target:c.source;for(const[i,d]of a("relationPath"))o[i]=d.type==="string"?c.id:[c.id]}for(const[i]of a("objectType"))o[i]=l??s.objectType;return o}const Ma=[["neutral","中性"],["info","信息"],["success","成功"],["warning","警示"],["danger","危险"]],dr=[["count","计数"],["sum","求和"],["avg","平均"],["min","最小"],["max","最大"],["distinct","去重计数"]],wf=[...dr,["ratio","占比(满足条件的 ÷ 全部)"]];function qa(e){return e.basis==="period"||e.basis===void 0&&e.periodField!==void 0}function Lo(e){return typeof e.compare=="string"&&e.compare!=="none"}const kf=[["local","浏览器所在时区"],["Asia/Shanghai","北京时间"],["UTC","协调世界时"],["Asia/Tokyo","东京时间"],["Asia/Singapore","新加坡时间"],["Europe/Berlin","柏林时间"],["Europe/London","伦敦时间"],["America/New_York","纽约时间"],["America/Los_Angeles","洛杉矶时间"]],vf=[["high","严重"],["medium","关注"],["low","提示"]],Fa=[["asc","升序"],["desc","降序"]],J=(e="标题")=>({key:"title",label:e,kind:"text",tab:"display",optional:!0}),ae={key:"source",label:"数据源",kind:"source",tab:"data"},Q=(e,t,n,o,s={})=>({key:e,label:t,kind:"variable",accepts:n,tab:"link",sentence:o,optional:s.optional??!0,reads:s.reads}),_e={key:"valueField",label:"统计字段",hint:"求和、平均、最大、最小须选择数字列。",kind:"field",optional:!0,shows:e=>e.aggregate!==void 0&&!["count","ratio"].includes(String(e.aggregate)),neededAs:e=>["sum","avg","min","max"].includes(String(e.aggregate))?"number":void 0},rt=[{key:"label",label:"名称",kind:"text"},{key:"when",label:"仅统计满足以下条件的",kind:"conditions",optional:!0},{key:"aggregate",label:"统计方式",kind:"enum",options:wf},_e],Se=e=>e.metric!==void 0,Io=e=>({key:"metric",label:"数值来源",hint:"对象指标由平台按全部对象计算,口径在知识网络中定义。",kind:"metric",on:e,optional:!0}),wt={key:"description",label:"说明",hint:"显示在标题下面的一行小字,写这里看什么、该做什么。",kind:"text",max:120,tab:"display",optional:!0},$f=/^[A-Za-z][A-Za-z0-9_]*$/,ve={key:"filters",label:"跟随的筛选",kind:"bindings",tab:"link",optional:!0},$e=(e,t,n,o)=>typeof e[t]=="string"&&e[t]!==""?[{key:t,variable:e[t],...typeof n=="string"?{field:n}:{},...Array.isArray(o)?{fields:o.filter(s=>typeof s=="string")}:{}}]:[],Sf=[["frontend","前端 Agent(在浏览器内调用平台模型,可读取页面并代为筛选)"],["bknAgent","内置 BKN Agent(平台智能问答 Agent,以当前用户身份查询知识网络)"],["mcp","外部 Agent(执行工厂中登记的 MCP 服务,由对方直接回答)"]];function Da(e,t){return[{key:"objectType",label:e,kind:"objectType"},{key:"path",label:"关系路径",kind:"relationPath"},{key:"field",label:t,kind:"field",owner:"objectType",of:"date"}]}const ze={asOfSlider:{label:"基准日期",summary:"拖动滑块选择日期,整页按该日期计算。",category:"filter",description:"滑块选一个日期,全页按这一天计算:有进度的数据源按第一步的日期决定对象在这天是否存在,状态、超期天数等读基准日期的列跟着重算;滑块范围从范围日期属性的最早值到今天",descriptors:[J(),{...ae,label:"滑块范围取自"},{key:"rangeField",label:"范围日期属性(默认取进度第一步的日期)",kind:"field",tab:"data",of:"date",optional:!0},{key:"step",label:"步长",kind:"enum",tab:"display",options:[["day","天"],["week","周"],["month","月"]]},Q("writes","写入",["asOf"],"拖动滑块时,按 {var} 重新计算全页",{optional:!1})],follows:!1,selectorKeys:[],defaults:(e,t,n)=>({title:"基准日期",source:ee(e,n,Kh)?.id,step:"day",writes:je(e,"asOf")})},dateRange:{label:"日期区间",summary:"选择日期区间,跟随它的组件仅查看该时间段。",category:"filter",description:"选起点和终点两个日期(附本月、上月、近 30 天、今年等快捷项),写入一个日期区间筛选;跟随它的组件只看某个日期列落在区间里的对象",descriptors:[J(),ae,{key:"field",label:"依据的日期(新组件默认依此跟随)",kind:"field",tab:"data",of:"date"},{key:"presets",label:"显示快捷项",kind:"bool",tab:"display"},Q("writes","写入",["dateRange"],"选定日期后,按 {var} 筛选",{optional:!1})],follows:!1,selectorKeys:[],emits:e=>$e(e,"writes",e.field),defaults:(e,t,n)=>{const o=ee(e,n);return{title:"日期区间",source:o?.id,field:o?of(o.progress)??Mo(o,t,"date"):void 0,presets:!0,writes:je(e,"dateRange")}}},metricCards:{label:"指标卡组",summary:"一排数字卡片,每张统计一项指标;点击卡片可筛选页面。",category:"filter",description:"一行指标卡,每张是一个统计(计数、求和、平均、最大最小、去重计数、占比),可只算满足条件的对象(如进度状态为 overdue 且金额大于 100 万);整组 compare(none 不显示、mom 环比、yoy 同比、both 都显示)对每张卡生效;basis 为 asOf(默认:统计基准日期(没有则今天)当天处于各状态的对象,与告警一致,同环比对比上一期、去年的同一天)或 period(只统计日期落在基准日期所在期的对象,如本月签约数;periodField 为日期属性,不填取进度第一步的日期;同环比按相同天数对比);periodUnit 为 day/week/month/quarter/year(默认 month);单张卡的 compare 可覆盖整组(none 为这张不显示),better(up 越高越好、down 越低越好)决定涨跌颜色,不填时按色调推断(danger、warning 越低越好,success 越高越好);点卡片写入筛选:取值筛选写这张卡的取值(卡片条件只能是一个字段取某些值),对象集合筛选写它算到的对象。一张卡写了 metric 就改为显示知识网络的对象指标:由平台按全部对象计算,不受数据源读取行数限制;when 只能用该指标开放的属性;它不写入筛选,点击时列出参与对象",descriptors:[J(),ae,{key:"compare",label:"同比环比",hint:"对整组卡片生效;单张卡片可在下方「指标」中另设。",kind:"enum",tab:"data",optional:!0,options:[["none","不显示"],["mom","环比(与上一期比较)"],["yoy","同比(与去年同期比较)"],["both","同比与环比"]]},{key:"basis",label:"统计口径",hint:"截至基准日期:统计基准日期当天处于各状态的对象,与告警、表格一致,适合已超期、进行中等状态;同比、环比与去年、上一期的同一天对比。基准日期所在期:只统计日期落在本期的对象,适合本月签约数等新增量;同比、环比按相同天数对比。",kind:"enum",tab:"data",optional:!0,options:[["asOf","截至基准日期"],["period","基准日期所在期"]]},{key:"periodField",label:"分期日期",hint:"对象按该日期归入某一期。留空时使用进度第一步的日期(如签约时间)。",kind:"field",of:"date",tab:"data",optional:!0,shows:(e,t)=>qa(t)},{key:"periodUnit",label:"周期",hint:"默认按月:环比对比上个月,按期统计时一期为一个月。",kind:"enum",tab:"data",optional:!0,shows:(e,t)=>Lo(t)||qa(t),options:[["day","日"],["week","周"],["month","月"],["quarter","季度"],["year","年"]]},{key:"showNoData",label:"对比期无数据时显示「无对比数据」",kind:"bool",tab:"data",optional:!0,shows:(e,t)=>Lo(t)},{key:"items",label:"指标",kind:"list",tab:"data",min:1,max:8,item:[rt[0],{key:"description",label:"说明",hint:"显示在数字下面的一行小字,写它的含义或该做什么。",kind:"text",max:60,optional:!0},Io("card"),rt[1],{...rt[2],shows:e=>!Se(e),notNeeded:Se},{..._e,shows:e=>!Se(e)&&_e.shows(e),neededAs:e=>Se(e)?void 0:_e.neededAs(e)},{key:"tone",label:"色调",kind:"enum",options:Ma},{key:"compare",label:"同比环比",hint:"留空时沿用整组设置。",kind:"enum",optional:!0,shows:(e,t)=>Lo(t)||e.compare!==void 0,options:[["none","不显示"],["mom","环比(与上一期比较)"],["yoy","同比(与去年同期比较)"],["both","同比与环比"]]},{key:"better",label:"变化方向",hint:"决定涨跌显示为绿色还是红色。留空时按色调判定:危险、警示越低越好,成功越高越好。",kind:"enum",optional:!0,shows:(e,t)=>(e.compare??t.compare??"none")!=="none"||e.better!==void 0,options:[["up","越高越好(上涨为绿色)"],["down","越低越好(上涨为红色)"]]}]},Q("writes","点击写入",["value","set"],"点击指标卡时,将该卡统计的对象写入 {var}"),ve],follows:!0,selectorKeys:["writes"],emits:(e,t)=>Do(t,e.writes)==="set"?$e(e,"writes"):$e(e,"writes",Wa(e.items)[0]),check:(e,t,n)=>{const o=e.items??[],s=o.flatMap((a,l)=>{const c=Ia(t.kn,lr(a.metric));return c?(a.when??[]).filter(i=>!Mc(i,{metric:c,kn:t.kn,asOf:"2000-01-01"})).map(i=>`${n}.items[${l}].when 的条件(${qc(i)})不能交给平台:对象指标卡的条件只能用指标「${c.name}」开放的属性`):[]});if(Do(t.spec,e.writes)!=="value")return s;const r=o.filter(a=>a.metric===void 0);return r.some(a=>a.when?.length&&!Ec(a.when))?[...s,`${n}.items 写入取值筛选时,每张卡的条件只能是“某字段为某些值”;条件更复杂时改写入对象集合筛选`]:new Set(Wa(r)).size>1?[...s,`${n}.items 写入同一个筛选的指标要按同一个字段取值`]:s},defaults:(e,t,n)=>{const o=ee(e,n,r=>!!et(r)),s=o&&et(o);return{title:"关键指标",source:o?.id,items:[{label:"全部",aggregate:"count",tone:"neutral"},...(s?qo(s):[]).map(r=>({label:s?_o(s.name,r.value):r.value,when:Qt(s?.name,[r.value]),aggregate:"count",tone:r.tone??"neutral"}))],writes:s?vn(e,s.name):void 0}}},segmentedFilter:{label:"分段筛选",summary:"一排带数量的按钮,点击后仅显示该类。",category:"filter",description:"一组带数量的筛选按钮,按一个字段的取值分段;一个按钮可以包含几个取值",descriptors:[J(),ae,{key:"field",label:"字段",kind:"field",tab:"data"},{key:"options",label:"选项",kind:"list",tab:"data",min:2,max:6,item:[{key:"label",label:"名称",kind:"text"},{key:"values",label:"取值(留空为全部)",kind:"values",fieldKey:"field",optional:!0}]},{key:"showCounts",label:"显示数量",kind:"bool",tab:"display"},Q("writes","写入",["value"],"点击选项时,将其取值写入 {var}",{optional:!1}),ve],follows:!0,selectorKeys:["writes"],emits:e=>$e(e,"writes",e.field),defaults:(e,t,n)=>{const o=ee(e,n,r=>!!et(r)),s=o&&et(o);return{source:o?.id,field:s?.name,options:[{label:"全部"},...(s?qo(s):[]).map(r=>({label:s?_o(s.name,r.value):r.value,values:[r.value]}))],showCounts:!0,writes:s?vn(e,s.name):void 0}}},dropdownFilter:{label:"下拉筛选",summary:"下拉选择一个或多个值,跟随它的组件仅显示所选值;选项与数量取自数据。",category:"filter",description:"按一个字段的取值筛选,选项从数据里自动取并带数量,可搜索、可多选;适合取值很多的字段(城市、球队、客户)",descriptors:[J(),ae,{key:"field",label:"字段",kind:"field",tab:"data"},{key:"multiple",label:"允许多选",kind:"bool",tab:"display"},{key:"showCounts",label:"显示数量",kind:"bool",tab:"display"},{key:"placeholder",label:"提示文字",kind:"text",tab:"display",optional:!0},Q("writes","写入",["value"],"选中值时,将其写入 {var}",{optional:!1}),ve],follows:!0,selectorKeys:["writes"],emits:e=>$e(e,"writes",e.field),defaults:(e,t,n)=>{const o=ee(e,n),s=o&&(et(o)?.name??Fo(o,t).find(r=>r!==o.key));return{source:o?.id,field:s,multiple:!1,showCounts:!0,writes:s?vn(e,s):void 0}}},searchBox:{label:"搜索框",summary:"输入关键词,跟随它的组件仅显示包含该关键词的对象。",category:"filter",description:"输入文字,写入一个搜索筛选;跟随它的组件在各自的文本列里查找",descriptors:[J(),ae,{key:"fields",label:"搜索的列(新组件默认依此跟随)",kind:"fields",tab:"data",of:"text",optional:!0},{key:"placeholder",label:"提示文字",kind:"text",tab:"display",optional:!0},Q("writes","写入",["search"],"输入内容时,写入 {var}",{optional:!1})],follows:!1,selectorKeys:[],emits:e=>$e(e,"writes",void 0,e.fields),defaults:(e,t,n)=>{const o=ee(e,n);return{source:o?.id,fields:o?[...Fo(o,t).filter(s=>s===o.key),...Fo(o,t).filter(s=>s!==o.key).slice(0,2)]:[],placeholder:"搜索",writes:je(e,"search",o?.id)}}},text:{label:"文本",summary:"一段文字:标题、结论或说明,在页面上直接编辑,可以引用随筛选变化的数字。",category:"basic",description:"一段 Markdown 文字(标题、加粗、列表、链接),用来写页面开头的结论、分节标题和说明段落;搭建时选中后可在页面上直接编辑。align 为对齐方式(left 左对齐、center 居中、right 右对齐,默认左对齐)。values 列出正文引用的数字,每项 { name, source, aggregate, when?, valueField?, metric?, filters? }:name 字母开头;统计写法同指标卡的一项(写 metric 就取知识网络的对象指标);filters 为这个数字跟随的筛选,写法同组件的 filters,按它自己数据源的字段比对。content 里用 {name} 填入数字,用 {$asOf} 填入基准日期;读不到时显示 —",descriptors:[J(),{key:"content",label:"内容",hint:"可在页面上选中后直接编辑;这里是 Markdown 写法。用 {引用名} 填入下面的数字,用 {$asOf} 填入基准日期。",kind:"text",multiline:!0,max:4e3,tab:"display"},{key:"align",label:"对齐",kind:"enum",tab:"display",optional:!0,options:[["left","左对齐"],["center","居中"],["right","右对齐"]]},{key:"values",label:"引用的数字",kind:"list",tab:"data",optional:!0,min:1,max:12,item:[{key:"name",label:"引用名",hint:"正文里写 {引用名} 填入这个数字;字母开头,可含数字和下划线。",kind:"text"},{key:"source",label:"数据源",kind:"source"},Io("card"),rt[1],{...rt[2],shows:e=>!Se(e),notNeeded:Se},{..._e,shows:e=>!Se(e)&&_e.shows(e),neededAs:e=>Se(e)?void 0:_e.neededAs(e)},{...ve,optional:!0}]}],follows:!1,selectorKeys:[],check:(e,t,n)=>{const s=(e.values??[]).map(l=>l.name),r=s.flatMap((l,c)=>typeof l=="string"&&!$f.test(l)?[`${n}.values[${c}].name 须字母开头,只含字母、数字和下划线`]:[]),a=s.filter((l,c)=>s.indexOf(l)!==c);return a.length>0&&r.push(`${n}.values 的引用名重复:${[...new Set(a)].join("、")}`),r},defaults:()=>({content:"在这里输入文字"})},objectTable:{label:"对象表",summary:"明细表,支持排序、分页、勾选;点击行选中对象。",category:"display",description:"对象明细表,可排序分页;点行选中对象,表头可带按某字段取值的快捷筛选与搜索,某列可点击筛选;格式 tag 把值显示成标签,进度状态和判断状态的计算列带颜色",descriptors:[J(),wt,ae,{key:"columns",label:"列",kind:"list",tab:"data",min:1,max:20,fill:{from:"field",item:Ba},item:[{key:"field",label:"属性",kind:"field"},{key:"label",label:"列名",kind:"text"},{key:"format",label:"格式",kind:"enum",options:[["text","文本"],["date","日期"],["number","数字"],["tag","标签"]]}]},{key:"sortField",label:"排序属性",kind:"field",tab:"data",optional:!0},{key:"sortOrder",label:"排序方向",kind:"enum",tab:"data",options:Fa},{key:"pageSize",label:"每页行数",kind:"number",tab:"display",min:5,max:50},Q("selection","点击行写入",["selection"],"点击行时,选中该对象(写入 {var}),详情抽屉和关系子图将显示该对象"),Q("picks","勾选写入",["set"],"每行前显示勾选框,勾选的对象作为一组写入 {var},其他组件可仅查看该组"),{key:"quickField",label:"表头快捷筛选字段",kind:"field",tab:"link",optional:!0},Q("quickFilter","表头快捷筛选",["value"],"表头按上述字段的取值显示按钮,点击后写入 {var}"),Q("search","表头搜索",["search"],"表头显示搜索框,输入内容时写入 {var}"),{key:"cellFilters",label:"点击单元格筛选",sentence:"点击某列的值时,写入对应的筛选:",kind:"list",tab:"link",min:0,max:4,optional:!0,item:[{key:"field",label:"列的属性",kind:"field"},{key:"variable",label:"写入筛选",kind:"variable",accepts:["value"]}]},ve],follows:!0,selectorKeys:["picks"],emits:e=>[...$e(e,"picks"),...$e(e,"quickFilter",e.quickField),...$e(e,"search",void 0,Of(e)),...(e.cellFilters??[]).flatMap(t=>t.variable?[{key:"cellFilters",variable:t.variable,field:t.field}]:[])],check:(e,t,n)=>e.quickFilter&&!e.quickField?[`${n}.quickField 表头快捷筛选要指定按哪个字段`]:[],defaults:(e,t,n)=>{const o=ee(e,n),s=o?pe(o,t.kn).slice(0,5):[];return{title:o?.label,source:o?.id,columns:s.map(Ba),sortOrder:"desc",pageSize:10,selection:je(e,"selection",o?.id)}}},objectList:{label:"对象列表",summary:"卡片式列表,适用于待办和收件箱;点击列表项选中对象。",category:"display",description:"卡片式列表,适合收件箱、待办;可只看满足条件的对象,点一项选中对象",descriptors:[J(),wt,ae,{key:"when",label:"仅显示满足以下条件的对象",kind:"conditions",tab:"data",optional:!0},{key:"titleField",label:"标题属性",kind:"field",tab:"data"},{key:"subtitleFields",label:"副标题属性",kind:"fields",tab:"data",optional:!0},{key:"sortField",label:"排序属性",kind:"field",tab:"data",optional:!0},{key:"sortOrder",label:"排序方向",kind:"enum",tab:"data",options:Fa},{key:"badgeField",label:"徽标字段(状态类字段按颜色区分)",kind:"field",tab:"display",optional:!0},{key:"limit",label:"最多显示",kind:"number",tab:"display",min:3,max:30},Q("selection","点击写入",["selection"],"点击列表项时,选中该对象(写入 {var}),详情抽屉和关系子图将显示该对象"),ve],follows:!0,selectorKeys:[],defaults:(e,t,n)=>{const o=ee(e,n);return{title:o?.label,source:o?.id,titleField:o&&No(o,t.kn),sortOrder:"desc",badgeField:o?et(o)?.name:void 0,limit:8,selection:je(e,"selection",o?.id)}}},pivotTable:{label:"透视表",summary:"按一个属性分组汇总,每列一项统计;点击行可筛选页面。",category:"display",description:"按一个属性分组汇总,每列一个度量;点一行按该分组筛选全页",descriptors:[J(),wt,ae,{key:"dimension",label:"分组属性",kind:"field",tab:"data"},{key:"measures",label:"度量",kind:"list",tab:"data",min:1,max:5,item:[...rt]},{key:"limit",label:"最多行数",kind:"number",tab:"display",min:5,max:50},{key:"bars",label:"数值显示条形",kind:"bool",tab:"display",optional:!0,hint:"在每列数值下方显示按该列最大值比例的条形,便于比较各组。"},Q("writes","点击行写入",["value"],"点击行时,将该组的取值写入 {var}"),ve],follows:!0,selectorKeys:["writes"],emits:e=>$e(e,"writes",e.dimension),defaults:(e,t,n)=>{const o=ee(e,n),s=o?Sa(pe(o,t.kn),t.kn.objectTypes[o.objectType]):void 0;return{source:o?.id,dimension:s?.name,measures:[{label:"数量",aggregate:"count"}],limit:10,bars:!0}}},trendChart:{label:"图表",summary:"柱状图、折线图或饼图:按时间或类别统计;点击图形可筛选页面。",category:"chart",description:"柱线饼图。横轴 axis 为 time(默认)时按日、周、月或季度统计(grain,默认按月),每个系列用自己的日期属性 dateField,点某个周期把它写入一个日期区间筛选;为 category 时按属性 category 的取值统计(最多 limit 个,取第一个系列最大的几个;sort 为 category 时按类别本身排序,如年份,默认按数值从大到小),点一个取值把它写入取值筛选。segmentBy 把每个系列再按另一个属性拆开(柱堆叠、线分色)。只有一个系列且横轴为 category 时图形可选 pie(饼图)。横轴为 category 且各系列都是柱时,orientation 决定柱子方向:auto(默认)在有类别名长于约四个汉字时改为横向条形(类别列在左侧,过长截断、悬停看全名),vertical 始终竖向,horizontal 始终横向。系列写了 metric 就改为显示知识网络的对象指标,由平台按全部对象计算:一张图的系列要么都写 metric、要么都不写;横轴为时间时粒度跟随指标(各指标须相同,不写 grain);不能用 segmentBy;按类别时由平台取前 limit 个",descriptors:[J(),wt,ae,{key:"axis",label:"横轴",kind:"enum",tab:"data",optional:!0,options:[["time","时间(按周期)"],["category","类别(按属性取值)"]]},{key:"category",label:"类别属性",kind:"field",tab:"data",optional:!0,shows:(e,t)=>t.axis==="category"},{key:"sort",label:"类别排序",kind:"enum",tab:"display",optional:!0,shows:(e,t)=>t.axis==="category",options:[["value","按数值从大到小"],["category","按类别自身(例如年份)"]]},{key:"orientation",label:"柱子方向",kind:"enum",tab:"display",optional:!0,shows:(e,t)=>t.axis==="category"&&!t.series?.some(n=>n.chart!=="bar"),options:[["auto","自动:类别名较长时横向"],["vertical","竖向柱"],["horizontal","横向条形"]]},{key:"limit",label:"最多显示类别数",kind:"number",tab:"display",optional:!0,shows:(e,t)=>t.axis==="category",min:2,max:50},{key:"segmentBy",label:"按属性拆分系列",kind:"field",tab:"data",optional:!0,shows:(e,t)=>!za(t)||t.segmentBy!==void 0},{key:"grain",label:"统计粒度",shows:(e,t)=>t.axis!=="category"&&!za(t),kind:"enum",tab:"display",optional:!0,options:[["day","日"],["week","周"],["month","月"],["quarter","季度"]]},{key:"months",label:"显示周期数(横轴为时间时必填)",shows:(e,t)=>t.axis!=="category",kind:"number",tab:"display",optional:!0,min:3,max:36},{key:"series",label:"系列",kind:"list",tab:"data",min:1,max:4,item:[{key:"label",label:"名称",kind:"text"},Io("chart"),{key:"dateField",label:"日期属性",shows:(e,t)=>t.axis!=="category"&&!Se(e),kind:"field",of:"date",optional:!0},{key:"aggregate",label:"聚合",kind:"enum",options:dr,shows:e=>!Se(e),notNeeded:Se},{..._e,shows:e=>!Se(e)&&_e.shows(e),neededAs:e=>Se(e)?void 0:_e.neededAs(e)},{key:"chart",label:"图形",kind:"enum",options:[["bar","柱"],["line","线"],["pie","饼(仅限单系列且横轴为类别时可用)"]]}]},Q("writes","点击写入",["dateRange","value"],"点击周期(或类别)时,将其写入 {var}"),ve],follows:!0,selectorKeys:["writes"],emits:e=>$e(e,"writes",e.axis==="category"?e.category:e.series?.[0]?.dateField),check:(e,t,n)=>{const o=[],s=e.axis==="category",r=e.series??[];s&&!e.category&&o.push(`${n}.category 横轴为类别时必填`),!s&&e.months===void 0&&o.push(`${n}.months 横轴为时间时必填`),!s&&r.some(c=>!c.dateField&&c.metric===void 0)&&o.push(`${n}.series 横轴为时间时每个系列要有 dateField`);const a=r.filter(c=>c.metric!==void 0);a.length>0&&a.length<r.length&&o.push(`${n}.series 一张图的系列要么都用页面内统计,要么都用对象指标`),a.length>0&&e.segmentBy!==void 0&&o.push(`${n}.segmentBy 用对象指标的图表不能按另一个属性拆分系列`),s||new Set(a.flatMap(i=>Ia(t.kn,lr(i.metric))?.grain??[])).size>1&&o.push(`${n}.series 各对象指标的时间粒度须相同`),r.some(c=>c.chart==="pie")&&(!s||r.length!==1)&&o.push(`${n}.series 饼图只能用于横轴为类别、只有一个系列的图表`),e.orientation==="horizontal"&&!s&&o.push(`${n}.orientation 只有横轴为类别时才能横向`),e.orientation==="horizontal"&&r.some(c=>c.chart!=="bar")&&o.push(`${n}.orientation 只有全部系列都是柱时才能横向`);const l=Do(t.spec,e.writes);return l==="value"&&!s&&o.push(`${n}.writes 横轴为时间时只能写入日期区间筛选`),l==="dateRange"&&s&&o.push(`${n}.writes 横轴为类别时只能写入取值筛选`),o},defaults:(e,t,n)=>{const o=ee(e,n),s=o?Mo(o,t,"date"):void 0;return{source:o?.id,months:8,series:[{label:"数量",dateField:s,aggregate:"count",chart:"bar"}],writes:je(e,"dateRange")}}},regionMap:{label:"地图",summary:"按地区着色的地图,可绘制关联对象之间的连线;点击地区可筛选页面。",category:"chart",description:"按地区着色的地图:底图为中国(按省份,省份可从客户名称这类含地名的文字里推断)或世界(按国家,认中英文国名、常见别称和 ISO 代码),地区从一个文本字段里识别;只在数据里确实有地名时才用;可标出满足条件的对象所在地区;可加关系连线:选知识网络里与数据源对象类直接相连的一条关系,连到另一类对象,从它的位置属性识别地区,画出它到对象所在地区的连线(网络里没有直接关系的两类对象不能连线,不能沿多条关系拼出连线);点地区时,把该地区对应的字段值写入一个取值筛选",descriptors:[J(),ae,{key:"basemap",label:"底图",kind:"enum",tab:"data",optional:!0,options:[["china","中国(按省份)"],["world","世界(按国家)"]]},{key:"regionField",label:"地区字段(地名,或含地名的文本)",kind:"field",tab:"data",of:"text"},{key:"aggregate",label:"度量",kind:"enum",tab:"data",options:dr},{..._e,tab:"data"},{key:"highlight",label:"标注(存在满足条件对象的省份以红色描边)",kind:"conditions",tab:"display",optional:!0},{key:"links",label:"关系连线",kind:"list",tab:"data",min:0,max:2,optional:!0,item:[{key:"label",label:"名称",kind:"text"},{key:"objectType",label:"连到的对象类",kind:"objectType"},{key:"path",label:"关系(直接相连的一条)",kind:"relationPath",single:!0},{key:"locationField",label:"位置属性(用于识别省份)",kind:"field",owner:"objectType",of:"text"}]},Q("writes","点击省份写入",["value"],"点击省份时,将该省对应的取值写入 {var}"),ve],follows:!0,selectorKeys:["writes"],emits:e=>$e(e,"writes",e.regionField),defaults:(e,t,n)=>{const o=ee(e,n,l=>!!Ua(l)),s=o&&Ua(o),r=s?.name??(o&&Tf(o,t)),a=s?.kind==="region"?s.scope:r&&zc.test(r)?"world":void 0;return{title:"地区分布",source:o?.id,...a==="world"?{basemap:a}:{},regionField:r,aggregate:"count",writes:r?vn(e,r):void 0}}},ganttChart:{label:"甘特图",summary:"按开始和结束日期绘制条形,查看计划与进度。",category:"chart",description:"按分组属性排成行、按开始和结束日期画条,显示基准日期前后的一段时间(默认多看之前,lookAhead 调大可多看之后,适合排计划);状态字段有色调时按色调着色",descriptors:[J(),ae,{key:"groupField",label:"行(分组属性)",kind:"field",tab:"data"},{key:"labelField",label:"条形名称",kind:"field",tab:"data"},{key:"startField",label:"开始日期",kind:"field",tab:"data",of:"date"},{key:"endField",label:"结束日期",kind:"field",tab:"data",of:"date"},{key:"statusField",label:"状态属性",kind:"field",tab:"data",optional:!0},{key:"windowDays",label:"显示天数",kind:"number",tab:"display",min:14,max:365},{key:"lookAhead",label:"基准日期之后的占比(%,规划计划时调大)",kind:"number",tab:"display",min:0,max:100,optional:!0},{key:"maxRows",label:"最多行数",kind:"number",tab:"display",min:3,max:40},ve],follows:!0,selectorKeys:[],defaults:(e,t,n)=>{const o=ee(e,n),s=o?pe(o,t.kn).filter(r=>r.type==="date"):[];return{source:o?.id,groupField:o?.key,labelField:o&&No(o,t.kn),startField:s[0]?.name,endField:s[1]?.name??s[0]?.name,windowDays:60,maxRows:12}}},scheduleGantt:{label:"调度甘特",summary:"资源排成行、时间横向展开,查看各资源上的任务、停机窗口和关键时点。",category:"chart",description:"按资源排成行(可按上级资源折叠、按属性分组),时间轴以基准日期为中心;每个图层是一类对象:标准图层画任务条(同一资源上重叠的任务分轨显示),背景图层画停机等时段,事件图层画到货等时点(可全局显示)。悬停看起止和属性,在情景中被改动或联动的任务显示原值、原因和改动前位置;点击任务或资源写入选中变量,供对象详情和关联表显示;不满足页面筛选的任务淡化显示;缺资源或缺时间的任务列在底部待排区。标准图层配了调整操作时,可拖动任务改资源和时间、拖动右边缘改结束,改动记入当前方案(没有打开的方案时新建一个),在方案栏的改动清单里查看和移除。数据本身只在采用方案时改。标准图层可配目标完成、最早开始(或所需资源的就绪日)、前序关系和已完成条件:未就绪、前序未完是硬约束,晚于目标只标出不阻止采用;配了目标与前序时算出余量,余量不大于 0 的任务属于关键链并描边,悬停任务显示整条依赖链。工具栏的状态摘要按约束计数,点击筛选。资源可设并行上限(默认 1),任务占用资源的图层按上限判断超限,每行底部显示负荷、超出上限标红;上级资源不可排程的时段对下级同样生效;折叠的上级显示下级任务的汇总条和有问题的任务数。标准图层可配规则工具(ruleTools,执行工厂的工具)判断行业规则:工具收到 { tasks: [{ key, start, end, resource, values }], scenario: { edits } },返回 { results: [{ key, pass, severity?, text, related? }] };不通过的任务与内置约束一起标出、计数、筛选,硬约束阻止采用方案,软约束只标出;工具失败或超时,任务显示未能校验,按硬约束处理。timeZoneVariable 是取值筛选,取值须为 IANA 时区名(如 Asia/Shanghai),没有取值时用 timeZone",descriptors:[J(),{key:"source",label:"资源来源(每个对象一行)",hint:"不选时,按任务的所属资源取值自动成行。",kind:"source",tab:"data",optional:!0},{key:"titleField",label:"资源名称",kind:"field",tab:"data",optional:!0,shows:(e,t)=>!!t.source},{key:"subtitleField",label:"资源副标题",kind:"field",tab:"data",optional:!0,shows:(e,t)=>!!t.source},{key:"parentField",label:"上级资源(取值为上级资源的标识)",hint:"有上级时,资源按上级折叠展开,如工厂下的产线。",kind:"field",tab:"data",optional:!0,shows:(e,t)=>!!t.source},{key:"capacityField",label:"并行上限(同一时间最多承接的任务数)",hint:"不选或没有取值时为 1。图层打开“任务占用资源”后,同一时间的任务数超过上限会标为硬约束,并按上限算负荷。上级资源不可排程的时段,对其下级同样生效。",kind:"field",tab:"data",optional:!0,shows:(e,t)=>!!t.source,of:"number"},{key:"groupField",label:"按属性分组",kind:"field",tab:"data",optional:!0,shows:(e,t)=>!!t.source},{key:"layers",label:"图层",kind:"list",tab:"data",min:0,max:dh,item:[{key:"label",label:"名称",kind:"text"},{key:"style",label:"样式",kind:"enum",options:[["standard","任务条"],["background","背景时段(如停机窗口)"],["event","事件时点(如到货)"]]},{key:"source",label:"对象来源",kind:"source"},{key:"global",label:"在所有资源上显示",kind:"bool",optional:!0,shows:e=>e.style==="event"},{key:"resourceField",label:"所属资源",hint:"任务排在哪个资源行上:选任务里记着资源的那一项。资源来源与图层是同一类对象时,选「对象本身」,每个对象一行。",kind:"field",objectKey:!0,optional:!0,shows:e=>!(e.style==="event"&&e.global===!0)},{key:"startField",label:"开始",kind:"field",of:"date"},{key:"endField",label:"结束",kind:"field",of:"date",optional:!0,shows:e=>e.style!=="event"},{key:"barFields",label:"条上显示的属性(第一个作为名称)",kind:"fields",optional:!0},{key:"popoverFields",label:"悬浮卡显示的属性",kind:"fields",optional:!0,shows:e=>e.style!=="background"},{key:"color",label:"颜色",kind:"enum",optional:!0,options:[["static","固定颜色"],["field","按属性取值分色"],["format","按属性的条件颜色"]]},{key:"tone",label:"固定颜色",kind:"enum",options:Ma,optional:!0,shows:e=>e.color===void 0||e.color==="static"},{key:"colorField",label:"着色属性",hint:"按条件颜色时,读数据源里为该属性设置的条件颜色。",kind:"field",optional:!0,shows:e=>e.color==="field"||e.color==="format"},{key:"exclusive",label:"任务占用资源",hint:"打开后,同一资源同一时间的任务数超过它的并行上限(默认 1)会标为硬约束,方案超限时不能采用;每行底部显示负荷。适合设备、产线、人员这类按时间占用的资源;以物料等为行时保持关闭。",kind:"bool",optional:!0,shows:e=>e.style==="standard"},{key:"blocks",label:"该时段不可排程",kind:"bool",optional:!0,shows:e=>e.style==="background"},{key:"selection",label:"点击写入",kind:"variable",accepts:["selection"],sentence:"点击该图层的对象时,选中它(写入 {var}),对象详情和关联表将显示它",optional:!0,shows:e=>e.style!=="background"},{key:"adjust",label:"拖动时记入的调整操作",hint:"拖动任务或它的右边缘时,用这个情景操作在方案里记一条改动;不选则只能查看。操作须用时间参数设置开始和结束,也可设置所属资源以便换行。",kind:"operation",optional:!0,fits:(e,t)=>tp(e,t),shows:e=>e.style==="standard"},{key:"create",label:"从待排区新建",hint:"计划这类为其他对象新建的记录:还没有有效记录的对象(如需求)列在待排区,拖到资源行上时用这个操作在方案里新建一条,采用时执行它的新建行动。操作须设置开始、结束和所属资源;按行动的查重属性判断对象是否已有记录。",kind:"list",min:0,max:1,optional:!0,shows:e=>e.style==="standard",item:[{key:"source",label:"待排对象",kind:"source"},{key:"operation",label:"新建操作",kind:"operation"},{key:"days",label:"默认时长(天)",kind:"number",min:0,max:365,optional:!0},{key:"daysField",label:"时长取自(天)",kind:"field",of:"number",optional:!0},{key:"fields",label:"待排卡片显示的属性",hint:"如预测单号、交货日期,帮助认出是哪条需求。",kind:"fields",optional:!0}]},{key:"snap",label:"拖动吸附到",hint:"不选时按小时取整;操作的时间参数是日期时按天取整。",kind:"enum",optional:!0,options:[["minute","分钟"],["hour","小时"],["day","天"]],shows:e=>e.style==="standard"&&!!e.adjust},{key:"targetField",label:"目标完成",hint:"任务应在这天之前完成,如工单的交期。完成晚于目标的任务标出晚了多久、计入状态摘要,但不阻止采用方案。",kind:"field",of:"date",optional:!0,shows:e=>e.style==="standard"},{key:"targetFrom",label:"或:目标完成取自关联对象",hint:"如生产计划 → 需求预测单的交货日期;关联到多个时取最早的。",kind:"list",min:0,max:1,optional:!0,item:Da("需求对象类","目标日期"),shows:e=>e.style==="standard"},{key:"earliestField",label:"最早开始",hint:"早于这天开始的任务标为未就绪,属于硬约束。",kind:"field",of:"date",optional:!0,shows:e=>e.style==="standard"},{key:"readyFrom",label:"或:所需资源及其就绪日",hint:"如工单 → 所需备件的就绪日。任务要等所需资源都就绪才能开始:取最晚的就绪日,并点名这个关键资源。",kind:"list",min:0,max:1,optional:!0,item:Da("资源对象类","就绪日"),shows:e=>e.style==="standard"},{key:"predecessorPath",label:"前序关系",hint:"同一图层任务之间的关系。开始早于前序完成的任务标为前序未完,属于硬约束;配了目标完成时,沿前后序算出每项任务的余量,余量不大于 0 的任务属于关键链。",kind:"relationPath",single:!0,optional:!0,shows:e=>e.style==="standard"},{key:"predecessorReaches",label:"沿前序关系到达的是",kind:"enum",optional:!0,options:[["predecessors","前序任务"],["successors","后序任务"]],shows:e=>e.style==="standard"&&Array.isArray(e.predecessorPath)&&e.predecessorPath.length>0},{key:"doneWhen",label:"已完成条件(须全部满足)",hint:"满足的任务不参与约束和余量,如状态为已完工。",kind:"conditions",optional:!0,shows:e=>e.style==="standard"},{key:"ruleTools",label:"规则工具",hint:"行业规则(资质、温控、法规时段、换型时间等)由执行工厂的工具判断,结果与内置约束一起标出、计数和筛选。",kind:"list",min:0,max:uh,optional:!0,shows:e=>e.style==="standard",item:[{key:"name",label:"名称",kind:"text"},{key:"tool",label:"工具",kind:"tool",contract:"scheduleRule"},{key:"severity",label:"不通过时默认",hint:"工具的回答里写了严重程度时,以回答为准。",kind:"enum",optional:!0,options:[["hard","硬约束:方案不能采用"],["soft","软约束:只标出"]]}]},{key:"filters",label:"跟随的筛选",kind:"bindings",optional:!0}]},{key:"daysBefore",label:"基准日期之前显示的天数",kind:"number",tab:"display",min:0,max:365},{key:"daysAfter",label:"基准日期之后显示的天数",kind:"number",tab:"display",min:0,max:365},{key:"tray",label:"待排区",hint:"只看不排的页面可只显示未排数量,不列出可拖动的任务。",kind:"enum",tab:"display",optional:!0,options:[["list","列出待排任务,可点开、可拖到资源上"],["count","只显示未排数量"]]},{key:"tick",label:"时间刻度",kind:"enum",tab:"display",options:[["auto","随缩放自动"],["hour","每小时"],["fourHours","每 4 小时"],["day","每天"],["week","每周"]]},{key:"timeZone",label:"时区",kind:"enum",tab:"display",options:kf},Q("timeZoneVariable","按页面变量取时区",["value"],"按 {var} 选中的时区换算时间,没有选中时用上面的时区"),Q("resourceSelection","点击资源写入",["selection"],"点击资源名称时,选中该资源(写入 {var})")],follows:!1,selectorKeys:[],emits:e=>[...$e(e,"resourceSelection"),...(e.layers??[]).flatMap(t=>typeof t?.selection=="string"&&t.selection!==""?[{key:"layers",variable:t.selection}]:[])],check:(e,t,n)=>(e.layers??[]).flatMap((o,s)=>{if(!o||typeof o!="object")return[];const r=`${n}.layers[${s}]`;return[...o.style!=="event"&&!o.endField?[`${r}.endField 任务条和背景时段要指定结束`]:[],...!o.resourceField&&!(o.style==="event"&&o.global===!0)?[`${r}.resourceField 要指定所属资源,事件时点也可改为在所有资源上显示`]:[],...(o.color==="field"||o.color==="format")&&!o.colorField?[`${r}.colorField 按属性着色要指定着色属性`]:[]]}),review:Pp,defaults:(e,t,n)=>{const o=ee(e,n,c=>!!(ue(e,c.id)&&Mo(c,t,"date"))),s=o?pe(o,t.kn):[],r=s.filter(c=>c.type==="date"),a=o?Sa(s,t.kn.objectTypes[o.objectType]):void 0,l=o&&{label:o.label,style:"standard",source:o.id,resourceField:a?.name,startField:r[0]?.name,endField:r[1]?.name??r[0]?.name,barFields:[No(o,t.kn)],popoverFields:s.filter(c=>c.type!=="date"&&c.name!==a?.name).slice(0,3).map(c=>c.name),color:"static",tone:"info",selection:je(e,"selection",o.id),filters:Kc(e,t.kn,{source:o.id},{follows:!0,selectorKeys:[]})};return{title:"调度甘特",layers:l?[l]:[],daysBefore:7,daysAfter:21,tick:"auto",timeZone:"local"}}},stageChain:{label:"环节链路",summary:"环节链路,查看各环节关联的对象数量。",category:"relation",description:"依次排列的环节,每个环节是一个对象类;有关系路径的环节按跟随的筛选显示关联数量,点环节展开记录",descriptors:[J(),ae,{key:"stages",label:"环节",kind:"list",tab:"data",min:1,max:9,fill:{from:"objectType",item:e=>({objectType:e.name,label:e.label})},item:[{key:"objectType",label:"对象类",kind:"objectType"},{key:"label",label:"名称",kind:"text"},{key:"path",label:"关系路径",kind:"relationPath",optional:!0},{key:"fields",label:"展开显示的属性",kind:"fields",owner:"objectType",optional:!0}]},ve],follows:!0,selectorKeys:[],defaults:(e,t,n)=>{const o=ee(e,n);return{source:o?.id,stages:o?[{label:o.label,objectType:o.objectType,path:[]}]:[]}}},subgraph:{label:"关系子图",summary:"以选中对象为中心,绘制其关联对象。",category:"relation",description:"以选中对象为中心,沿配置的关系路径展开关联对象,画成关系图;layout 为 force 时画成关系网,layered 时从左到右分层(选中对象在最左,每一步关系一列),auto(默认)在各路径首尾相连成一条链(如销售订单 → 产品 → 物料 → 采购订单)时分层,否则画成关系网",descriptors:[J(),ae,{key:"layout",label:"布局",kind:"enum",tab:"display",optional:!0,options:[["auto","自动:路径成一条链时分层"],["force","关系网"],["layered","从左到右分层"]]},{key:"paths",label:"展开路径",kind:"list",tab:"data",min:1,max:6,item:[{key:"label",label:"名称",kind:"text"},{key:"objectType",label:"对象类",kind:"objectType"},{key:"path",label:"关系路径",kind:"relationPath"},{key:"limit",label:"最多节点",kind:"number",min:1,max:50}]},{key:"height",label:"高度(自由网格中随单元格调整)",kind:"number",tab:"display",min:240,max:640},Q("selection","读取",["selection"],"显示 {var} 中选中的对象",{optional:!1,reads:!0})],follows:!1,selectorKeys:[],review:(e,t)=>{const n=typeof e.source=="string"?ue(t.spec,e.source):void 0;return!n?.objectType||t.kn.relations.some(o=>o.source===n.objectType||o.target===n.objectType)?[]:[{key:"noRelations",values:{name:t.kn.objectTypes[n.objectType]?.name??n.objectType}}]},defaults:(e,t,n)=>{const o=ee(e,n),s=t.kn.relations.find(a=>a.source===o?.objectType||a.target===o?.objectType),r=s&&(s.source===o?.objectType?s.target:s.source);return{title:"关系子图",source:o?.id,paths:r?[{label:t.kn.objectTypes[r]?.name??r,objectType:r,path:[s.id],limit:8}]:[],height:320,selection:je(e,"selection",o?.id)}}},scenarioBar:{label:"方案",summary:"切换、新建、保存与采用方案,并排对比各方案与现状的指标;紧凑样式只留一行切换,假设样式在侧栏改方案参数和改动。",category:"scenario",description:"方案推演的入口:选择页面显示哪个方案(或现状),新建、复制、命名保存、作废方案,查看方案的改动清单(可移除),采用方案时逐条执行推演操作关联的行动和模型结果的落地条目;改动由组件点击的“推演”动作或 Agent 建议写入,推演操作在数据源上配置;方案只存在于 Workshop,不写回知识网络。页面有模型结果数据源时显示计算状态和「计算」(算当前方案中待重算的结果);新建菜单可按方案参数的可选值一次建出多个方案。style 为 table(对比表,默认)时,每行一个度量,每列现状或一个方案(最多 4 列),附与现状的差值,点列头切换方案,下方可展开方案之间不同的改动;度量可读模型结果数据源,没算过的列写「待重算」,表上的「计算」依次算各列;跟随页面筛选;需要 source 与 measures。style 为 compact(紧凑)时只有一行:方案下拉、新建与当前方案的操作,适合放在页头。style 为 assumptions(假设)时适合放在侧栏:当前方案的方案参数输入、改动清单和「添加假设」,常与页头的紧凑样式配合",descriptors:[J(),{key:"style",label:"样式",kind:"enum",tab:"display",optional:!0,options:[["table","对比表"],["compact","紧凑(只切换)"],["assumptions","假设(参数与改动)"]]},{...ae,optional:!0},{key:"measures",label:"对比的指标",kind:"list",tab:"data",optional:!0,min:1,max:8,item:[...rt]},ve],follows:!0,selectorKeys:[],defaults:(e,t,n)=>{const o=ee(e,n,s=>!!s.operations?.length);return{title:"方案",style:"table",source:o?.id,measures:[{label:"数量",aggregate:"count"},...o?.progress?.due?[{label:"已超期",aggregate:"count",when:[{field:le.status,op:"eq",value:re.overdue.value}]}]:[]]}}},modelTrial:{label:"模型试算",summary:"对一批对象按几组参数调用模型,比较各组结果的差异;结果不改对象。",category:"scenario",description:"对组件跟随的筛选留下的对象(最多 200 个,例如点指标卡或在表格勾选的一批)调用数据源上登记的模型(sources[].models),每组参数调用一次,2 到 4 组并排比较:汇总度量附与第一组(基准)的差值,明细列出各组结果;选中方案时模型读到的是方案中的值;结果只显示在页面上,不写回知识网络;可按选定一组的结果执行模型配置的行动",descriptors:[J(),ae,ve],follows:!0,selectorKeys:[],defaults:(e,t,n)=>({title:"模型试算",source:ee(e,n,s=>!!s.models?.length)?.id})},alertList:{label:"告警",summary:"按规则列出需关注的对象;点击规则仅查看其命中的对象。",category:"filter",description:"按规则实时列出命中的对象:每条规则是一组条件(如进度状态为 overdue、$overdueDays 大于 90),还可要求沿关系路径查不到记录(如没有任何关联的某类对象);按严重程度排序,点规则把命中的对象写入一个对象集合筛选,展开看具体对象",descriptors:[J(),wt,ae,{key:"rules",label:"规则",kind:"list",tab:"data",min:1,max:8,item:[{key:"label",label:"名称",kind:"text"},{key:"severity",label:"严重程度",kind:"enum",options:vf},{key:"when",label:"条件(须全部满足)",kind:"conditions",optional:!0},{key:"objectType",label:"且无关联记录:关联对象类",kind:"objectType",optional:!0},{key:"path",label:"且无关联记录:关系路径",kind:"relationPath",optional:!0}]},{key:"tagField",label:"命中对象的附加显示字段",kind:"field",tab:"display",optional:!0},{key:"limit",label:"展开显示条数",kind:"number",tab:"display",min:3,max:20},Q("writes","点击规则写入",["set"],"点击规则时,将其命中的对象写入 {var}"),Q("selection","点击对象写入",["selection"],"点击展开列表中的对象时,选中该对象(写入 {var})"),ve],follows:!0,selectorKeys:["writes"],emits:e=>$e(e,"writes"),check:(e,t,n)=>(e.rules??[]).flatMap((o,s)=>{const r=`${n}.rules[${s}]`,a=!!o.objectType||!!o.path?.length;return a&&(!o.objectType||!o.path?.length)?[`${r} 查不到关联记录的条件需要同时给关联对象类 objectType 和关系路径 path`]:!a&&!o.when?.length?[`${r} 至少要有一个条件`]:[]}),defaults:(e,t,n)=>{const o=ee(e,n,a=>!!et(a)),s=o&&et(o),r=s?qo(s).filter(a=>a.tone==="danger"):[];return{title:"告警",source:o?.id,rules:s&&r.length>0?r.map(a=>({label:s?_o(s.name,a.value):a.value,severity:"medium",when:[{field:s.name,op:"eq",value:a.value}]})):[{label:"缺少标识",severity:"low",when:[{field:o?.key??"",op:"isEmpty"}]}],tagField:s?.name,limit:8,writes:je(e,"set",o?.id),selection:je(e,"selection",o?.id)}}},eventList:{label:"事件列表",summary:"列出应用的业务事件,支持核实、驳回、关闭;点击事件选中其关联的对象。",category:"display",description:"列出应用里的业务事件(规则命中或用户登记的),未关闭的在前、按严重程度排;待核实的可以核实或驳回,已核实的可以关闭;显示规则的最近与下次检查时间,可以立即检查。事件类型在知识网络里建模,应用在 eventTypes 里按编码选择要处理的。点事件把它关联的对象写入一个选中对象筛选",descriptors:[J(),wt,{key:"types",label:"显示的事件类型(不选则为全部)",kind:"eventType",multiple:!0,tab:"data",optional:!0},{key:"show",label:"默认显示",kind:"enum",options:[["open","未关闭"],["all","全部"]],tab:"display"},{key:"limit",label:"最多显示条数",kind:"number",min:5,max:100,tab:"display"},Q("selection","点击事件选中",["selection"],"点击事件时,选中其关联的对象(写入 {var})")],follows:!1,selectorKeys:[],check:(e,t,n)=>{const o=e.selection,s=t.spec.variables.find(l=>l.name===o);if(!s||!("source"in s))return[];const r=ue(t.spec,s.source)?.objectType,a=e.types;return Mn(t.spec,en(t.kn.eventTypes)).filter(l=>(!a?.length||a.includes(l.id))&&l.objectType).filter(l=>l.objectType!==r).map(l=>`${n}.selection 选中的是另一类对象,事件类型 ${l.id} 关联的对象对不上;换一个筛选,或只显示关联对象相同的事件类型`)},defaults:(e,t)=>{const n=Mn(e,en(t.kn.eventTypes)).find(s=>s.objectType)?.objectType,o=e.variables.find(s=>s.kind==="selection"&&ue(e,s.source)?.objectType===n)?.name;return{title:"事件",show:"open",limit:20,...n&&o?{selection:o}:{}}}},eventReport:{label:"事件登记",summary:"按钮,打开表单登记业务事件;登记后状态为待核实。",category:"display",description:"一个按钮,打开一类用户登记事件(应用处理的、知识网络里来源为用户登记的事件类型)的表单:标题、发生时间、关联对象与表单字段。登记的事件默认待核实,登记人可以勾选一并核实;合并窗口内同一对象再次登记记为重复",descriptors:[{key:"type",label:"事件类型",kind:"eventType",of:"report",tab:"data"},J("按钮文字")],follows:!1,selectorKeys:[],defaults:(e,t)=>{const n=Mn(e,en(t.kn.eventTypes)).find(o=>o.source==="report");return n?{type:n.id}:{}}},taskInbox:{label:"任务收件箱",summary:"由事件归并生成的任务:认领后查看事件、撰写分析、进行处理,事件均有结果时任务关闭。",category:"display",description:"列出事件归并成的任务(按事件类型的归并方式:一个事件一个任务、按关联对象的属性、或按检查批次),未关闭的在前,显示事件数、未处理数、认领人与剩余时限;打开一个任务看事件、分析与处理三栏:认领、添加分析(可多条)、勾选事件新建处理(可多条,处理之间不共用事件)、判定无需处理或移出、手工结束",descriptors:[J(),{key:"types",label:"任务所属事件类型(不选则为全部)",kind:"eventType",multiple:!0,tab:"data",optional:!0},{key:"show",label:"默认显示",kind:"enum",options:[["open","未关闭"],["all","全部"]],tab:"display"},{key:"limit",label:"最多显示条数",kind:"number",min:5,max:100,tab:"display"}],follows:!1,selectorKeys:[],defaults:()=>({title:"任务",show:"open",limit:20})},actionButton:{label:"按钮",summary:"按钮:向 Agent 提问,或对选中、勾选的对象执行行动,执行前需确认。",category:"ai",description:"一个按钮,点了按顺序做 interactions 里的动作:问 Agent(可带上当前筛选),或对选中的对象(selection 筛选)、一组对象(set 筛选,例如表格勾选的行)执行知识网络里的行动;行动执行前总会打开执行确认,列出对象、填写参数、检查执行权限,确认后逐个对象以用户身份执行;行动的对象为空时按钮不可点",descriptors:[J(),ae,{key:"interactions",label:"按钮动作",kind:"interactions",on:["button"],actOn:["button"],hit:!1,max:1,tab:"data"}],follows:!1,selectorKeys:[],defaults:(e,t,n)=>{const o=ee(e,n,c=>!c.cypher&&!c.events),s=o&&t.kn.actionTypes?.find(c=>c.objectType===o.objectType),r=o&&je(e,"selection",o.id),a=o&&je(e,"set",o.id),l=r?{selection:r}:a?{set:a}:void 0;return{title:s?.name??"按钮",source:o?.id,interactions:[{on:"button",...s?{label:s.name}:{},do:s&&l?[{kind:"act",action:s.id,targets:l,params:Object.fromEntries(s.inputs.map(c=>[c.name,{from:"input"}]))}]:[{kind:"ask",question:"总结一下当前页面上需要关注的情况,并给出依据。",context:["filters"],send:"auto"}]}]}}},agentChat:{label:"Agent 对话",summary:"围绕页面数据提问,也可由 Agent 代为筛选页面。",category:"ai",description:"围绕页面数据回答问题:能查页面上的全部数据源和整个知识网络,读当前筛选和选中对象,允许时还能替用户调整全页筛选",descriptors:[J(),{key:"provider",label:"由谁回答",kind:"enum",tab:"data",options:Sf},{key:"agent",label:"外部 Agent",hint:"选择 MCP 服务和其中回答问题的工具(通常名为 ask);使用者须有该服务的执行权限。",kind:"mcpTool",tab:"data",optional:!0,shows:e=>e.provider==="mcp"},{key:"allowAgentSwitch",label:"允许使用者切换智能体",hint:"MCP 服务需提供 list_agents 和接受 agent_id 的 ask 工具。切换时开始新对话。列出哪些智能体由服务决定,list_agents 声明了 app_id、bkn_token 时照样传给它。",kind:"bool",tab:"data",optional:!0,shows:e=>e.provider==="mcp"},{key:"passToken",label:"交出使用者的登录令牌",hint:"打开后,工具声明了 bkn_token 时,把使用者本人的访问令牌交给这个 Agent。Agent 凭它能做使用者能做的一切,包括执行行动和办理审批;只对可信的 Agent 打开。默认不交。",kind:"bool",tab:"data",optional:!0,shows:e=>e.provider==="mcp"},{key:"instructions",label:"补充说明",kind:"text",tab:"data",optional:!0,multiline:!0,max:600},{key:"mode",label:"显示方式",kind:"enum",tab:"display",optional:!0,options:[["float","右下角按钮,点开对话"],["side","右侧栏"],["inline","放在页面里"]]},{key:"height",shows:e=>(e.mode??"inline")==="inline",label:"高度(自由网格中随单元格调整)",kind:"number",tab:"display",min:280,max:800},{key:"suggestions",label:"建议问题",kind:"list",tab:"display",min:0,max:6,optional:!0,item:[{key:"text",label:"问题",kind:"text"}]},Q("selection","当前对象",["selection"],"回答时以 {var} 中选中的对象作为当前对象",{reads:!0}),{key:"canFilter",label:"允许 Agent 设置筛选和选中对象(例如“仅看超期”)",kind:"bool",tab:"link"},{key:"actions",label:"允许 Agent 建议的行动",hint:"Agent 只生成建议卡,由用户确认后执行;目前仅前端 Agent 支持。",kind:"actionTypes",tab:"data",optional:!0}],follows:!1,selectorKeys:[],defaults:(e,t,n)=>{const o=ee(e,n);return{title:"Agent 对话",provider:"frontend",mode:"float",height:420,suggestions:o?[{text:`${o.label}里现在最需要关注的是哪些?`},{text:`这一页的${o.label}有什么异常或趋势?`}]:[],selection:je(e,"selection",o?.id),canFilter:!0}}}};function jf(e){return Ve.filter(t=>!Nr.has(t)&&(e||ze[t].category!=="scenario"))}const dt={label:"对象详情",summary:"选中对象后打开,显示其属性、进度和关联记录。",category:"relation",description:"抽屉里显示选中对象的进度、属性,以及沿关系路径关联的记录。进度条按数据源的进度(progress)画:每一步是否完成,截止日期按期还是超期",descriptors:[J(),ae,{key:"showProgress",label:"显示进度条(需先在数据源中设置进度)",kind:"bool",tab:"data",optional:!0},{key:"fields",label:"属性",kind:"fields",tab:"data"},{key:"related",label:"关联区块",kind:"list",tab:"data",min:0,max:4,optional:!0,item:[{key:"label",label:"名称",kind:"text"},{key:"objectType",label:"对象类",kind:"objectType"},{key:"path",label:"关系路径",kind:"relationPath"},{key:"fields",label:"属性",kind:"fields",owner:"objectType"},{key:"limit",label:"最多行数",kind:"number",min:1,max:20}]},Q("selection","读取",["selection"],"显示 {var} 中选中的对象",{optional:!1,reads:!0})],follows:!1,selectorKeys:[],defaults:(e,t,n)=>{const o=ee(e,n);return{source:o?.id,...o?.progress?{showProgress:!0}:{},fields:o?pe(o,t.kn).slice(0,8).map(s=>s.name):[],selection:je(e,"selection",o?.id)}}};function ht(e){return e===me?dt:Rt(e)?cf(e):ze[e]}function ee(e,t,n=()=>!0){const o=e.sources.find(s=>s.id===t)??e.sources.find(n)??e.sources[0];return o&&(ue(e,o.id)??o)}function je(e,t,n){return e.variables.find(o=>o.kind===t&&(!n||!("source"in o)||o.source===n))?.name}function Mo(e,t,n){return pe(e,t.kn).find(o=>o.type===n)?.name}function Af(e){return e==="date"?"date":e==="number"?"number":"text"}function Ba(e){return{field:e.name,label:e.label,format:e.name===le.status?"tag":e.type?Af(e.type):"text"}}function et(e){if(e.progress)return{name:le.status,outcomes:jc};const t=e.computed?.find(n=>n.kind==="classify");return t&&{name:t.name,outcomes:[...t.cases,t.otherwise]}}function Ua(e){return e.computed?.find(t=>t.kind==="region")}const zc=/country|nation|国家|国籍/i;function Tf(e,t){const n=/country|nation|region|province|state|city|site|location|address|国家|国籍|地区|省|城市|地址|所在地|产地|区域/i,o=pe(e,t.kn).filter(r=>r.type==="text"),s=r=>o.find(a=>r.test(a.name)||r.test(a.label))?.name;return s(zc)??s(n)}function qo(e){return e.outcomes}function Fo(e,t){return pe(e,t.kn).filter(n=>n.type==="text").map(n=>n.name)}function za(e){return Array.isArray(e.series)&&e.series.some(t=>Se(t))}function Wa(e){return(e?.filter(t=>t.metric===void 0)??[]).flatMap(t=>{const n=Ec(t.when);return n?[n.field]:[]})}function Do(e,t){return e?.variables.find(n=>n.name===t)?.kind}function Of(e){return(e.columns??[]).filter(t=>t.format==="text"||t.format==="tag").map(t=>t.field).filter(t=>typeof t=="string")}function Ef(e){return[...Object.values(e.regions).flatMap(t=>t??[]),...e.detail?[e.detail]:[]]}function Wc(e){const t=new Map;for(const n of Ef(e)){const o=ht(n.type).emits?.(n.config,e)??[];for(const s of o){const r=t.get(s.variable)??[];r.push({...s,placement:n.id,source:typeof n.config.source=="string"?n.config.source:void 0}),t.set(s.variable,r)}}return t}function vn(e,t){const n=Wc(e);return e.variables.find(o=>o.kind==="value"&&((n.get(o.name)??[]).some(s=>s.field===t)||o.name===t))?.name}function Kc(e,t,n,o){const s=ue(e,n.source);if(!o.follows||!s)return[];const r=new Set(o.selectorKeys.map(h=>n[h])),a=pe(s,t),l=(h,u)=>a.some(p=>p.name===h&&(!u||p.type===u)),c=Wc(e),i=h=>e.sources.find(u=>u.id===h)?.objectType,d=[];for(const h of e.variables){if(r.has(h.name))continue;const u=c.get(h.name)??[],p=u.filter(f=>i(f.source)===s.objectType);switch(h.kind){case"value":{const f=p.map(m=>m.field).find(m=>l(m))??(u.length===0&&l(h.name)?h.name:void 0);f&&d.push({variable:h.name,field:f});break}case"dateRange":{const f=p.map(m=>m.field).find(m=>l(m,"date"));f&&d.push({variable:h.name,field:f});break}case"search":{const f=[...new Set(p.flatMap(m=>m.fields??[]))].filter(m=>l(m,"text"));f.length>0&&d.push({variable:h.name,fields:f});break}case"set":i(h.source)===s.objectType&&d.push({variable:h.name});break}}return d}for(const e of Object.values(ze)){if(!e.follows)continue;const t=e.defaults;e.defaults=(n,o,s)=>{const r=t(n,o,s);return{...r,filters:Kc(n,o.kn,r,e)}}}for(const[e,t]of Object.entries(bp)){const n=e===me?dt:ze[e];n.descriptors=[...n.descriptors,{key:"interactions",label:"点击后的动作",kind:"interactions",on:t,actOn:wp[e]??[],hit:!0,max:jp,...Ra[e]?{offers:Ra[e]}:{},tab:"link",optional:!0}]}function Cf(e,t){return new Set([t,...e.sources.filter(n=>n.from?.source===t).map(n=>n.id)])}function Yc(e,t,n,o){if(o.size===0)return e;const s=structuredClone(e),r=d=>typeof d=="string"?o.get(d)??d:d,a=(d,h)=>{if(Array.isArray(d))return d.forEach(f=>a(f,h));if(typeof d!="object"||d===null)return;const u=d,p=typeof u.field=="string"?u.field:h;p===n&&(Array.isArray(u.values)&&(u.values=u.values.map(r)),"op"in u&&u.ref===void 0&&(u.value=r(u.value)));for(const[f,m]of Object.entries(u))f!=="values"&&a(m,p)},l=new Set,c=Cf(s,t);for(const d of s.pages)for(const h of[...Object.values(d.regions).flatMap(u=>u??[]),...d.detail?[d.detail]:[]])if(c.has(h.config.source)){a(h.config);for(const u of h.config.filters??[])u?.field===n&&l.add(u.variable)}for(const d of s.sources)d.from?.source===t&&a(d.from.where);s.variables=s.variables.map(d=>d.kind==="value"&&l.has(d.name)&&d.default!==void 0?{...d,default:r(d.default)}:d);const i=s.sources.find(d=>d.id===t);for(const d of i?.operations??[])a(d.when);for(const d of i?.computed??[])d.name!==n&&(d.kind==="classify"&&d.cases.forEach(h=>a(h.when)),d.kind==="days"&&a(d.when));i?.progress?.steps.forEach(d=>a(d.done));for(const d of Object.values(i?.formats??{}))d.colors?.forEach(h=>a(h.when));for(const d of i?.models??[])d.measures.forEach(h=>a(h.when));return s}const X=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Nf(e){if(e.ask===void 0&&e.act===void 0)return;const t=Array.isArray(e.interactions)?e.interactions:[],n=X(e.ask)?[Ap(e.ask)]:[],o=Array.isArray(e.act)?e.act.map(Tp):[],s=[...t,...n,...o];s.length>0&&(e.interactions=s),delete e.ask,delete e.act}function xf(e,t,n){const o=n.find(l=>l.id===t.source),s=X(o?.from)?o.from:void 0,r=s?n.find(l=>l.id===s.source):o,a=Array.isArray(t.adjustments)?t.adjustments:[];if(r){const l=Array.isArray(r.operations)?r.operations:[],c=new Set(l.map(i=>String(i.id)));for(const i of a){if(typeof i.field!="string")continue;let d=`shift_${i.field}`.replace(/[^A-Za-z0-9_]/g,"_");for(let h=2;c.has(d);h++)d=`shift_${i.field}_${h}`.replace(/[^A-Za-z0-9_]/g,"_");c.add(d),l.push({id:d,label:String(i.label??i.field).slice(0,30),...Array.isArray(i.when)&&i.when.length>0?{when:i.when}:{},params:[{name:"days",label:"天数",type:"number",...typeof i.min=="number"?{min:i.min}:{},...typeof i.max=="number"?{max:i.max}:{}}],effects:[{field:i.field,kind:"shiftDays",param:"days"}]})}l.length>0&&(r.operations=l)}e.type="scenarioBar",e.config={title:typeof t.title=="string"?t.title:"方案",style:"compact"}}function Rf(e){const n=Object.values(e).filter(r=>Array.isArray(r)).flat(),o=r=>{const a=X(r.config)?r.config:{};return r.type==="scenarioBar"&&a.style===void 0&&(a.layout!==void 0||a.source===void 0)},s=n.some(r=>r.type==="scenarioCompare");for(const r of n){const a=X(r.config)?r.config:{};r.type==="scenarioCompare"?(r.type="scenarioBar",r.config={...a,style:"table"}):o(r)&&!s&&(delete a.layout,r.config={...a,style:"compact"})}if(s)for(const[r,a]of Object.entries(e))Array.isArray(a)&&(e[r]=a.filter(l=>!o(l)))}const _f=new Set(["status","overdueDays","dueInDays"]);function Pf(e){const[t,n]=e.split("-").map(Number);return new Date(Date.UTC(t,n,0)).toISOString().slice(0,10)}function Lf(e){if(typeof e.appearsOn!="string")return null;const n=(Array.isArray(e.computed)?e.computed:[]).find(c=>c.name==="status"&&c.kind==="classify"),o=Array.isArray(n?.cases)?n.cases:[],s=Array.isArray(o[0]?.when)?o[0].when[0]:void 0,r=Array.isArray(o[1]?.when)?o[1].when[0]:void 0,a=r&&r.op==="before"&&r.ref===he?String(r.field):void 0,l=[{label:"开始",field:e.appearsOn}];return s&&s.op==="onOrBefore"&&s.ref===he?l.push({label:"完成",field:String(s.field)}):s&&s.op==="eq"&&a&&l.push({label:"完成",field:a,done:[{field:String(s.field),op:"eq",value:s.value}]}),{steps:l,...a?{due:{field:a}}:{}}}function Bo(e){if(typeof e.field!="string"||e.when!==void 0)return;const t=Array.isArray(e.values)?e.values:[];t.length>0&&(e.when=[{field:e.field,op:"in",values:t}]),delete e.field,delete e.values}function ur(e){if(Array.isArray(e))return e.forEach(ur);X(e)&&("sumField"in e&&(e.valueField===void 0&&(e.valueField=e.sumField),delete e.sumField),Object.values(e).forEach(ur))}function If(e){const t=new Map,o=(Array.isArray(e.computed)?e.computed:[]).find(a=>a.name==="status"&&a.kind==="classify");if(!o)return t;const s=Array.isArray(o.cases)?o.cases:[],r=[[s[0]?.value,re.done.value],[s[1]?.value,re.overdue.value],[X(o.otherwise)?o.otherwise.value:void 0,re.active.value]];for(const[a,l]of r)typeof a=="string"&&a!==l&&t.set(a,l);return t}function Mf(e,t){for(const n of e){const o=X(n.regions)?n.regions:{};for(const s of Object.values(o))if(Array.isArray(s))for(const r of s){const a=X(r.config)?r.config:{},l=(Array.isArray(a.filters)?a.filters:[]).find(c=>c?.variable===t&&Array.isArray(c.fields));if(l?.fields)return l.fields}}}function qf(e){if(!X(e))return e;let t=e;const n=Array.isArray(e.sources)?e.sources:[],o=Array.isArray(e.variables)?e.variables:[],s=new Map,r=new Set;for(const i of n){if(i.progress!==void 0)continue;const d=Lf(i);if(!d)continue;const h=If(i);if(h.size>0&&s.set(String(i.id),h),i.progress=d,r.add(String(i.id)),delete i.appearsOn,Array.isArray(i.computed)){const u=i.computed.filter(p=>!_f.has(String(p.name)));u.length>0?i.computed=u:delete i.computed}}const a=new Map;for(const i of o)("field"in i||"fields"in i||i.kind==="month")&&(i.kind==="selection"||i.kind==="set"||(a.set(String(i.name),{...i}),i.kind==="month"&&(i.kind="dateRange",typeof i.default=="string"&&/^\d{4}-\d{2}$/.test(i.default)&&(i.default=`${i.default}-01..${Pf(i.default)}`)),delete i.source,delete i.field,delete i.fields));const l=o.filter(i=>i.kind==="set"),c=Array.isArray(e.pages)?e.pages:[];for(const i of c){const d=X(i.regions)?i.regions:{};Rf(d);const h=[...Object.values(d).flatMap(u=>Array.isArray(u)?u:[]),...X(i.detail)?[i.detail]:[]];for(const u of h){const p=u.type,f=X(u.config)?u.config:null;if(!f)continue;if(p==="whatIf"){xf(u,f,n);continue}if(ur(f),Nf(f),p==="metricCards"&&Array.isArray(f.items)&&f.items.forEach(b=>X(b)&&Bo(b)),p==="pivotTable"&&Array.isArray(f.measures)&&f.measures.forEach(b=>X(b)&&Bo(b)),p==="objectList"&&Bo(f),p==="regionMap"&&Array.isArray(f.links)){const b=f.links.filter(k=>Array.isArray(k?.path)&&k.path.length===1);b.length>0?f.links=b:delete f.links}if(p===me&&Array.isArray(f.progress)&&(f.progress.length>0&&(f.showProgress=!0),delete f.progress),!Ve.includes(p))continue;const m=ht(p);if(p==="searchBox"&&typeof f.writes=="string"&&!f.fields){const b=a.get(f.writes)?.fields??Mf(c,f.writes);Array.isArray(b)&&b.length>0&&(f.fields=b)}if(p==="objectTable"&&typeof f.quickFilter=="string"&&!f.quickField){const b=a.get(f.quickFilter);typeof b?.field=="string"&&(f.quickField=b.field)}if(!m.follows||f.filters!==void 0||typeof f.source!="string")continue;const g=new Set(m.selectorKeys.map(b=>f[b])),y=[];for(const[b,k]of a)g.has(b)||k.source!==f.source||(Array.isArray(k.fields)?y.push({variable:b,fields:k.fields}):typeof k.field=="string"&&y.push({variable:b,field:k.field}));for(const b of l)!g.has(b.name)&&b.source===f.source&&y.push({variable:String(b.name)});f.filters=y}}for(const[i,d]of s)t=Yc(t,i,"status",d);return r.size>0&&(t=Kf(t,r)),Uf(t),Ff(t),t}function Ff(e){const t=Array.isArray(e.eventTypes)?e.eventTypes:[];for(const n of t)if(X(n)){for(const o of["label","source","subject","severity","rule"])delete n[o];X(n.report)&&delete n.report.mergeHours}}const Df=/^[a-z0-9][a-z0-9_.-]{0,63}$/;function Bf(e,t){const n=e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase().replace(/[^a-z0-9_.-]/g,"_").replace(/^[^a-z0-9]+/,"").slice(0,64)||"event";let o=n;for(let s=2;t.has(o);s+=1)o=`${n.slice(0,64-String(s).length)}${s}`;return o}function Uf(e){const t=Array.isArray(e.eventTypes)?e.eventTypes:[],n=new Set(t.map(r=>String(r.id))),o=new Map;for(const r of t){const a=r.id;if(typeof a!="string"||Df.test(a))continue;n.delete(a);const l=Bf(a,n);n.add(l),o.set(a,l),r.id=l}if(o.size===0)return;const s=r=>typeof r=="string"?o.get(r)??r:r;for(const r of Array.isArray(e.sources)?e.sources:[]){const a=X(r.events)?r.events:void 0;Array.isArray(a?.types)&&(a.types=a.types.map(s))}for(const r of Array.isArray(e.pages)?e.pages:[]){const l=[...(X(r.regions)?Object.values(r.regions):[]).flatMap(c=>Array.isArray(c)?c:[]),...X(r.detail)?[r.detail]:[]];for(const c of l){if(!Ve.includes(c.type)||!X(c.config))continue;const i=c.config;for(const d of ht(c.type).descriptors){if(d.kind!=="eventType"||i[d.key]===void 0)continue;const h=i[d.key];i[d.key]=Array.isArray(h)?h.map(s):s(h)}}}}const zf=new Map([["status",le.status],["stage",le.stage],["overdueDays",le.overdueDays],["dueInDays",le.dueInDays]]),Wf=new Map(Object.values(re).map(e=>[e.label,e.value]));function Gc(e,t,n){const o=s=>typeof s=="string"?n(s):s;for(const s of e){const r=t[s.key],a=!("owner"in s)||s.owner!=="objectType";if(s.kind==="field"&&a)t[s.key]=o(r);else if(s.kind==="fields"&&a&&Array.isArray(r))t[s.key]=r.map(o);else if(s.kind==="conditions"&&Array.isArray(r))for(const l of r)X(l)&&(l.field=o(l.field),l.ref!==void 0&&(l.ref=o(l.ref)));else if(s.kind==="bindings"&&Array.isArray(r))for(const l of r)X(l)&&(l.field!==void 0&&(l.field=o(l.field)),Array.isArray(l.fields)&&(l.fields=l.fields.map(o)));else if(s.kind==="list"&&Array.isArray(r))for(const l of r)X(l)&&Gc(s.item,l,n)}}function Kf(e,t){let n=structuredClone(e);const o=r=>zf.get(r)??r,s=r=>r.replace(/(?<![$\w`])(status|stage|overdueDays|dueInDays)\b/g,a=>o(a));for(const r of n.sources){if(!r.progress||t&&!t.has(r.id))continue;const a=new Set(n.sources.filter(c=>c.id===r.id||c.from?.source===r.id).map(c=>c.id));for(const c of n.pages)for(const i of[...Object.values(c.regions).flatMap(d=>d??[]),...c.detail?[c.detail]:[]])a.has(i.config.source)&&Gc(ht(i.type).descriptors,i.config,o);const l=c=>c?.forEach(i=>{i.field=o(i.field),i.ref!==void 0&&(i.ref=o(i.ref))});r.formats&&(r.formats=Object.fromEntries(Object.entries(r.formats).map(([c,i])=>(i.colors?.forEach(d=>l(d.when)),[o(c),i]))));for(const c of n.sources)if(c.from?.source===r.id){l(c.from.where);for(const i of c.from.filters??[])i.field!==void 0&&(i.field=o(i.field)),i.fields&&(i.fields=i.fields.map(o))}for(const c of r.operations??[])l(c.when);for(const c of r.computed??[])c.kind==="classify"&&c.cases.forEach(i=>l(i.when)),c.kind==="days"&&(c.from=o(c.from),c.to=o(c.to),l(c.when)),c.kind==="formula"&&(c.expr=s(c.expr));n=Yc(n,r.id,le.status,Wf)}return n}const pt="workshop.openbkn.ai/v1",Yf=["tabs","cards","segmented","side"],Gf=["dashboard","table","chart","map","alert","task","calendar","relation","search","agent","team","setting"],Hf=["tasks","alerts"];function tn(e,t){const n=e.pages.find(o=>o.id===t)??e.pages[0];return{version:2,title:n.title,layout:n.layout,sources:e.sources,variables:e.variables,...e.eventTypes?{eventTypes:e.eventTypes}:{},...e.scenarioParams?{scenarioParams:e.scenarioParams}:{},...e.components?{components:e.components}:{},regions:n.regions,detail:n.detail,theme:e.theme,...n.linking?{linking:n.linking}:{},...e.linkPaths?{linkPaths:e.linkPaths}:{}}}function Vf(e){if(typeof e!="object"||e===null)return e;const t=qf(structuredClone(e)),n=t.pages;if(!Array.isArray(n))return t;for(const o of n)for(const s of Object.values(o?.regions??{}))if(Array.isArray(s))for(const r of s)r?.type==="agentChat"&&r.config&&delete r.config.source;return t}var Uo={exports:{}},P={};var Ka;function Jf(){if(Ka)return P;Ka=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),r=Symbol.for("react.consumer"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),i=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),u=Symbol.iterator;function p($){return $===null||typeof $!="object"?null:($=u&&$[u]||$["@@iterator"],typeof $=="function"?$:null)}var f={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m=Object.assign,g={};function y($,T,C){this.props=$,this.context=T,this.refs=g,this.updater=C||f}y.prototype.isReactComponent={},y.prototype.setState=function($,T){if(typeof $!="object"&&typeof $!="function"&&$!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,$,T,"setState")},y.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function b(){}b.prototype=y.prototype;function k($,T,C){this.props=$,this.context=T,this.refs=g,this.updater=C||f}var w=k.prototype=new b;w.constructor=k,m(w,y.prototype),w.isPureReactComponent=!0;var v=Array.isArray;function S(){}var j={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function A($,T,C){var R=C.ref;return{$$typeof:e,type:$,key:T,ref:R!==void 0?R:null,props:C}}function E($,T){return A($.type,T,$.props)}function x($){return typeof $=="object"&&$!==null&&$.$$typeof===e}function L($){var T={"=":"=0",":":"=2"};return"$"+$.replace(/[=:]/g,function(C){return T[C]})}var I=/\/+/g;function M($,T){return typeof $=="object"&&$!==null&&$.key!=null?L(""+$.key):T.toString(36)}function ne($){switch($.status){case"fulfilled":return $.value;case"rejected":throw $.reason;default:switch(typeof $.status=="string"?$.then(S,S):($.status="pending",$.then(function(T){$.status==="pending"&&($.status="fulfilled",$.value=T)},function(T){$.status==="pending"&&($.status="rejected",$.reason=T)})),$.status){case"fulfilled":return $.value;case"rejected":throw $.reason}}throw $}function q($,T,C,R,z){var Y=typeof $;(Y==="undefined"||Y==="boolean")&&($=null);var V=!1;if($===null)V=!0;else switch(Y){case"bigint":case"string":case"number":V=!0;break;case"object":switch($.$$typeof){case e:case t:V=!0;break;case d:return V=$._init,q(V($._payload),T,C,R,z)}}if(V)return z=z($),V=R===""?"."+M($,0):R,v(z)?(C="",V!=null&&(C=V.replace(I,"$&/")+"/"),q(z,T,C,"",function(gu){return gu})):z!=null&&(x(z)&&(z=E(z,C+(z.key==null||$&&$.key===z.key?"":(""+z.key).replace(I,"$&/")+"/")+V)),T.push(z)),1;V=0;var qe=R===""?".":R+":";if(v($))for(var ke=0;ke<$.length;ke++)R=$[ke],Y=qe+M(R,ke),V+=q(R,T,C,Y,z);else if(ke=p($),typeof ke=="function")for($=ke.call($),ke=0;!(R=$.next()).done;)R=R.value,Y=qe+M(R,ke++),V+=q(R,T,C,Y,z);else if(Y==="object"){if(typeof $.then=="function")return q(ne($),T,C,R,z);throw T=String($),Error("Objects are not valid as a React child (found: "+(T==="[object Object]"?"object with keys {"+Object.keys($).join(", ")+"}":T)+"). If you meant to render a collection of children, use an array instead.")}return V}function N($,T,C){if($==null)return $;var R=[],z=0;return q($,R,"","",function(Y){return T.call(C,Y,z++)}),R}function Z($){if($._status===-1){var T=$._result;T=T(),T.then(function(C){($._status===0||$._status===-1)&&($._status=1,$._result=C)},function(C){($._status===0||$._status===-1)&&($._status=2,$._result=C)}),$._status===-1&&($._status=0,$._result=T)}if($._status===1)return $._result.default;throw $._result}var U=typeof reportError=="function"?reportError:function($){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var T=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof $=="object"&&$!==null&&typeof $.message=="string"?String($.message):String($),error:$});if(!window.dispatchEvent(T))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",$);return}console.error($)},oe={map:N,forEach:function($,T,C){N($,function(){T.apply(this,arguments)},C)},count:function($){var T=0;return N($,function(){T++}),T},toArray:function($){return N($,function(T){return T})||[]},only:function($){if(!x($))throw Error("React.Children.only expected to receive a single React element child.");return $}};return P.Activity=h,P.Children=oe,P.Component=y,P.Fragment=n,P.Profiler=s,P.PureComponent=k,P.StrictMode=o,P.Suspense=c,P.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=j,P.__COMPILER_RUNTIME={__proto__:null,c:function($){return j.H.useMemoCache($)}},P.cache=function($){return function(){return $.apply(null,arguments)}},P.cacheSignal=function(){return null},P.cloneElement=function($,T,C){if($==null)throw Error("The argument must be a React element, but you passed "+$+".");var R=m({},$.props),z=$.key;if(T!=null)for(Y in T.key!==void 0&&(z=""+T.key),T)!O.call(T,Y)||Y==="key"||Y==="__self"||Y==="__source"||Y==="ref"&&T.ref===void 0||(R[Y]=T[Y]);var Y=arguments.length-2;if(Y===1)R.children=C;else if(1<Y){for(var V=Array(Y),qe=0;qe<Y;qe++)V[qe]=arguments[qe+2];R.children=V}return A($.type,z,R)},P.createContext=function($){return $={$$typeof:a,_currentValue:$,_currentValue2:$,_threadCount:0,Provider:null,Consumer:null},$.Provider=$,$.Consumer={$$typeof:r,_context:$},$},P.createElement=function($,T,C){var R,z={},Y=null;if(T!=null)for(R in T.key!==void 0&&(Y=""+T.key),T)O.call(T,R)&&R!=="key"&&R!=="__self"&&R!=="__source"&&(z[R]=T[R]);var V=arguments.length-2;if(V===1)z.children=C;else if(1<V){for(var qe=Array(V),ke=0;ke<V;ke++)qe[ke]=arguments[ke+2];z.children=qe}if($&&$.defaultProps)for(R in V=$.defaultProps,V)z[R]===void 0&&(z[R]=V[R]);return A($,Y,z)},P.createRef=function(){return{current:null}},P.forwardRef=function($){return{$$typeof:l,render:$}},P.isValidElement=x,P.lazy=function($){return{$$typeof:d,_payload:{_status:-1,_result:$},_init:Z}},P.memo=function($,T){return{$$typeof:i,type:$,compare:T===void 0?null:T}},P.startTransition=function($){var T=j.T,C={};j.T=C;try{var R=$(),z=j.S;z!==null&&z(C,R),typeof R=="object"&&R!==null&&typeof R.then=="function"&&R.then(S,U)}catch(Y){U(Y)}finally{T!==null&&C.types!==null&&(T.types=C.types),j.T=T}},P.unstable_useCacheRefresh=function(){return j.H.useCacheRefresh()},P.use=function($){return j.H.use($)},P.useActionState=function($,T,C){return j.H.useActionState($,T,C)},P.useCallback=function($,T){return j.H.useCallback($,T)},P.useContext=function($){return j.H.useContext($)},P.useDebugValue=function(){},P.useDeferredValue=function($,T){return j.H.useDeferredValue($,T)},P.useEffect=function($,T){return j.H.useEffect($,T)},P.useEffectEvent=function($){return j.H.useEffectEvent($)},P.useId=function(){return j.H.useId()},P.useImperativeHandle=function($,T,C){return j.H.useImperativeHandle($,T,C)},P.useInsertionEffect=function($,T){return j.H.useInsertionEffect($,T)},P.useLayoutEffect=function($,T){return j.H.useLayoutEffect($,T)},P.useMemo=function($,T){return j.H.useMemo($,T)},P.useOptimistic=function($,T){return j.H.useOptimistic($,T)},P.useReducer=function($,T,C){return j.H.useReducer($,T,C)},P.useRef=function($){return j.H.useRef($)},P.useState=function($){return j.H.useState($)},P.useSyncExternalStore=function($,T,C){return j.H.useSyncExternalStore($,T,C)},P.useTransition=function(){return j.H.useTransition()},P.version="19.2.8",P}var Ya;function Zf(){return Ya||(Ya=1,Uo.exports=Jf()),Uo.exports}Zf();const Xf={skipErrorToast:!0},Ir=e=>`/bkn-backend/v1/knowledge-networks/${encodeURIComponent(e)}`,zo=100,Qf=50;async function Mr(e,t={}){const n=[];for(let o=0;o<Qf;o+=1){const{data:s}=await st.get(e,{...Xf,params:{...t,limit:zo,offset:o*zo}}),r=s.entries??[];if(n.push(...r),r.length<zo||n.length>=(s.total_count??1/0))break}return n}async function em(e,t){return(await Mr(`${Ir(e)}/action-types`,{operation_kind:"event"})).filter(o=>o.id&&o.operation_config?.type==="event"&&!0)}function tm(e){const t=e.schedule;return t?.expression?{...t.type?{type:t.type}:{},expression:t.expression,...t.timezone?{timezone:t.timezone}:{}}:null}async function nm(e,t){return(await Mr(`${Ir(e)}/action-schedules`,{})).filter(o=>o.id&&o.source==="action_type"&&!0)}function om(e,t,n){const o=e.id??"",s=e.event??{},r=s.source==="rule"?"rule":"report",a=t?.find(i=>i.operation_config?.event_class===o),l=a&&n?.find(i=>i.action_type_id===a.id),c=l?.next_run_time;return{code:o,name:e.name||o,source:r,...s.subject?{subject:s.subject}:{},...s.severity?{severity:s.severity}:{},...s.merge_hours?{merge_hours:s.merge_hours}:{},...r==="rule"&&t?{recognition_action_id:a?.id??null,check_schedule:a?tm(a):null,...a&&n?{platform_schedule_id:l?.id??null}:{}}:{},...c?{next_check_at:c}:{}}}async function sm(e){const[t,n,o]=await Promise.all([Mr(`${Ir(e)}/object-types`),em(e).catch(()=>{}),nm(e).catch(()=>{})]);return t.filter(s=>s.id&&Array.isArray(s.kinds)&&s.kinds.includes("event")).map(s=>om(s,n,o))}Math.random().toString(36).slice(2);const rm=new Map;Math.random().toString(36).slice(2);function am(){for(const e of rm.values())if(e.dirty.size>0||e.writing.size>0||e.failed.size>0)return!0;return!1}typeof window<"u"&&window.addEventListener("beforeunload",e=>{am()&&(e.preventDefault(),e.returnValue="")});const im=new Map;function lm(e,t){im.set(e,Promise.resolve(t))}class Hc extends Error{constructor(t){super("draft changed since it was read"),this.currentRevision=t}currentRevision}class qr extends Error{constructor(){super("app not found")}}class Fr extends Error{constructor(){super("not allowed")}}class Vc extends Error{constructor(){super("app too large")}}class cm extends Error{constructor(t){super("event types missing on the network"),this.eventTypes=t}eventTypes}const Dr="/workshop/v1",hn={skipErrorToast:!0},dm=200;function um(e){const t=e?.response,n=t?.status,o=t?.data?.metadata;if(n===404)return new qr;if(n===403)return new Fr;if(n===413)return new Vc;if(n===409){if(typeof o?.current_revision=="number")return new Hc(o.current_revision);if(Array.isArray(o?.event_types))return new cm(o.event_types.map(String))}return e}async function pn(e){try{return(await e()).data}catch(t){throw um(t)}}function hm(){return`ws-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}const Ga=e=>({id:e?.id??"",name:e?.name||e?.id||""});function pm(e){return!e||typeof e!="object"||!Array.isArray(e.pages)?null:Vf(e)}function Jc(e){const t=e.tags??[],n=(e.references??[]).map(Ga);return{id:e.id,name:e.name,...e.description?{description:e.description}:{},...e.icon?{icon:e.icon}:{},...e.color?{color:e.color}:{},...t.length>0?{tags:t}:{},...n.length>0?{references:n}:{},network:Ga(e.kn),version:e.current_version??0,revision:e.draft_revision??0,creator:e.creator??"",updatedAt:e.update_time??0,operations:e.operations??[],...e.managed_by?{managedBy:e.managed_by}:{},...e.workspace_id?{workspaceId:e.workspace_id}:{}}}const Br=e=>({...Jc(e),draft:pm(e.draft)}),Ur=e=>`${Dr}/apps/${encodeURIComponent(e)}`;async function fm(){const e=[];let t="";for(const n=new Set;;n.add(t)){const o=new URLSearchParams({limit:String(dm)});t&&o.set("cursor",t);const s=await pn(()=>st.get(`${Dr}/apps`,{...hn,params:o}));if(e.push(...(s.entries??[]).map(Jc)),t=s.next_cursor??"",!t||n.has(t))return e}}async function mm(e){try{const t=Br(await pn(()=>st.get(Ur(e),hn)));return lm(e,t.workspaceId),t}catch(t){if(t instanceof qr)return null;throw t}}const gm=e=>({name:e.name,description:e.description?.trim()??"",...e.icon?{icon:e.icon}:{},...e.color?{color:e.color}:{},tags:e.tags??[],references:(e.references??[]).map(({id:t,name:n})=>({id:t,name:n}))});async function ym(e,t,n,o={},s){const r=await pn(()=>st.post(`${Dr}/apps`,{...gm({...o,name:e}),kn:{id:t.id,name:t.name},draft:n,...s?{workspace_id:s}:{}},{...hn,headers:{"Idempotency-Key":hm()}}));return Br(r)}async function bm(e,t,n){return Br(await pn(()=>st.put(`${Ur(e)}/draft`,{draft:t,revision:n},hn)))}async function wm(e,t,n="upload"){const o=await pn(()=>st.post(`${Ur(e)}/component-packages`,t,{...hn,params:{source:n},headers:{"Content-Type":"application/zip"}}));return{id:o.package.id,type:o.package.type,version:o.package.version,manifest:o.package.manifest,warnings:o.warnings??[]}}var W={},Wo={},Ko={},de={},Ha;function B(){if(Ha)return de;Ha=1;const e=Symbol.for("yaml.alias"),t=Symbol.for("yaml.document"),n=Symbol.for("yaml.map"),o=Symbol.for("yaml.pair"),s=Symbol.for("yaml.scalar"),r=Symbol.for("yaml.seq"),a=Symbol.for("yaml.node.type"),l=g=>!!g&&typeof g=="object"&&g[a]===e,c=g=>!!g&&typeof g=="object"&&g[a]===t,i=g=>!!g&&typeof g=="object"&&g[a]===n,d=g=>!!g&&typeof g=="object"&&g[a]===o,h=g=>!!g&&typeof g=="object"&&g[a]===s,u=g=>!!g&&typeof g=="object"&&g[a]===r;function p(g){if(g&&typeof g=="object")switch(g[a]){case n:case r:return!0}return!1}function f(g){if(g&&typeof g=="object")switch(g[a]){case e:case n:case s:case r:return!0}return!1}const m=g=>(h(g)||p(g))&&!!g.anchor;return de.ALIAS=e,de.DOC=t,de.MAP=n,de.NODE_TYPE=a,de.PAIR=o,de.SCALAR=s,de.SEQ=r,de.hasAnchor=m,de.isAlias=l,de.isCollection=p,de.isDocument=c,de.isMap=i,de.isNode=f,de.isPair=d,de.isScalar=h,de.isSeq=u,de}var $n={},Va;function co(){if(Va)return $n;Va=1;var e=B();const t=Symbol("break visit"),n=Symbol("skip children"),o=Symbol("remove node");function s(h,u){const p=c(u);e.isDocument(h)?r(null,h.contents,p,Object.freeze([h]))===o&&(h.contents=null):r(null,h,p,Object.freeze([]))}s.BREAK=t,s.SKIP=n,s.REMOVE=o;function r(h,u,p,f){const m=i(h,u,p,f);if(e.isNode(m)||e.isPair(m))return d(h,f,m),r(h,m,p,f);if(typeof m!="symbol"){if(e.isCollection(u)){f=Object.freeze(f.concat(u));for(let g=0;g<u.items.length;++g){const y=r(g,u.items[g],p,f);if(typeof y=="number")g=y-1;else{if(y===t)return t;y===o&&(u.items.splice(g,1),g-=1)}}}else if(e.isPair(u)){f=Object.freeze(f.concat(u));const g=r("key",u.key,p,f);if(g===t)return t;g===o&&(u.key=null);const y=r("value",u.value,p,f);if(y===t)return t;y===o&&(u.value=null)}}return m}async function a(h,u){const p=c(u);e.isDocument(h)?await l(null,h.contents,p,Object.freeze([h]))===o&&(h.contents=null):await l(null,h,p,Object.freeze([]))}a.BREAK=t,a.SKIP=n,a.REMOVE=o;async function l(h,u,p,f){const m=await i(h,u,p,f);if(e.isNode(m)||e.isPair(m))return d(h,f,m),l(h,m,p,f);if(typeof m!="symbol"){if(e.isCollection(u)){f=Object.freeze(f.concat(u));for(let g=0;g<u.items.length;++g){const y=await l(g,u.items[g],p,f);if(typeof y=="number")g=y-1;else{if(y===t)return t;y===o&&(u.items.splice(g,1),g-=1)}}}else if(e.isPair(u)){f=Object.freeze(f.concat(u));const g=await l("key",u.key,p,f);if(g===t)return t;g===o&&(u.key=null);const y=await l("value",u.value,p,f);if(y===t)return t;y===o&&(u.value=null)}}return m}function c(h){return typeof h=="object"&&(h.Collection||h.Node||h.Value)?Object.assign({Alias:h.Node,Map:h.Node,Scalar:h.Node,Seq:h.Node},h.Value&&{Map:h.Value,Scalar:h.Value,Seq:h.Value},h.Collection&&{Map:h.Collection,Seq:h.Collection},h):h}function i(h,u,p,f){if(typeof p=="function")return p(h,u,f);if(e.isMap(u))return p.Map?.(h,u,f);if(e.isSeq(u))return p.Seq?.(h,u,f);if(e.isPair(u))return p.Pair?.(h,u,f);if(e.isScalar(u))return p.Scalar?.(h,u,f);if(e.isAlias(u))return p.Alias?.(h,u,f)}function d(h,u,p){const f=u[u.length-1];if(e.isCollection(f))f.items[h]=p;else if(e.isPair(f))h==="key"?f.key=p:f.value=p;else if(e.isDocument(f))f.contents=p;else{const m=e.isAlias(f)?"alias":"scalar";throw new Error(`Cannot replace node with ${m} parent`)}}return $n.visit=s,$n.visitAsync=a,$n}var Ja;function Zc(){if(Ja)return Ko;Ja=1;var e=B(),t=co();const n={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},o=r=>r.replace(/[!,[\]{}]/g,a=>n[a]);class s{constructor(a,l){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},s.defaultYaml,a),this.tags=Object.assign({},s.defaultTags,l)}clone(){const a=new s(this.yaml,this.tags);return a.docStart=this.docStart,a}atDocument(){const a=new s(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:s.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},s.defaultTags);break}return a}add(a,l){this.atNextDocument&&(this.yaml={explicit:s.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},s.defaultTags),this.atNextDocument=!1);const c=a.trim().split(/[ \t]+/),i=c.shift();switch(i){case"%TAG":{if(c.length!==2&&(l(0,"%TAG directive should contain exactly two parts"),c.length<2))return!1;const[d,h]=c;return this.tags[d]=h,!0}case"%YAML":{if(this.yaml.explicit=!0,c.length!==1)return l(0,"%YAML directive should contain exactly one part"),!1;const[d]=c;if(d==="1.1"||d==="1.2")return this.yaml.version=d,!0;{const h=/^\d+\.\d+$/.test(d);return l(6,`Unsupported YAML version ${d}`,h),!1}}default:return l(0,`Unknown directive ${i}`,!0),!1}}tagName(a,l){if(a==="!")return"!";if(a[0]!=="!")return l(`Not a valid tag: ${a}`),null;if(a[1]==="<"){const h=a.slice(2,-1);return h==="!"||h==="!!"?(l(`Verbatim tags aren't resolved, so ${a} is invalid.`),null):(a[a.length-1]!==">"&&l("Verbatim tags must end with a >"),h)}const[,c,i]=a.match(/^(.*!)([^!]*)$/s);i||l(`The ${a} tag has no suffix`);const d=this.tags[c];if(d)try{return d+decodeURIComponent(i)}catch(h){return l(String(h)),null}return c==="!"?a:(l(`Could not resolve tag: ${a}`),null)}tagString(a){for(const[l,c]of Object.entries(this.tags))if(a.startsWith(c))return l+o(a.substring(c.length));return a[0]==="!"?a:`!<${a}>`}toString(a){const l=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],c=Object.entries(this.tags);let i;if(a&&c.length>0&&e.isNode(a.contents)){const d={};t.visit(a.contents,(h,u)=>{e.isNode(u)&&u.tag&&(d[u.tag]=!0)}),i=Object.keys(d)}else i=[];for(const[d,h]of c)d==="!!"&&h==="tag:yaml.org,2002:"||(!a||i.some(u=>u.startsWith(h)))&&l.push(`%TAG ${d} ${h}`);return l.join(`
|
|
17
|
+
`)}}return s.defaultYaml={explicit:!1,version:"1.2"},s.defaultTags={"!!":"tag:yaml.org,2002:"},Ko.Directives=s,Ko}var Yo={},Go={},kt={},Za;function zr(){if(Za)return kt;Za=1;var e=B(),t=co();function n(a){if(/[\x00-\x19\s,[\]{}]/.test(a)){const c=`Anchor must not contain whitespace or control characters: ${JSON.stringify(a)}`;throw new Error(c)}return!0}function o(a){const l=new Set;return t.visit(a,{Value(c,i){i.anchor&&l.add(i.anchor)}}),l}function s(a,l){for(let c=1;;++c){const i=`${a}${c}`;if(!l.has(i))return i}}function r(a,l){const c=[],i=new Map;let d=null;return{onAnchor:h=>{c.push(h),d??(d=o(a));const u=s(l,d);return d.add(u),u},setAnchors:()=>{for(const h of c){const u=i.get(h);if(typeof u=="object"&&u.anchor&&(e.isScalar(u.node)||e.isCollection(u.node)))u.node.anchor=u.anchor;else{const p=new Error("Failed to resolve repeated object (this should not happen)");throw p.source=h,p}}},sourceObjects:i}}return kt.anchorIsValid=n,kt.anchorNames=o,kt.createNodeAnchors=r,kt.findNewAnchor=s,kt}var Ho={},Vo={},Xa;function Xc(){if(Xa)return Vo;Xa=1;function e(t,n,o,s){if(s&&typeof s=="object")if(Array.isArray(s))for(let r=0,a=s.length;r<a;++r){const l=s[r],c=e(t,s,String(r),l);c===void 0?delete s[r]:c!==l&&(s[r]=c)}else if(s instanceof Map)for(const r of Array.from(s.keys())){const a=s.get(r),l=e(t,s,r,a);l===void 0?s.delete(r):l!==a&&s.set(r,l)}else if(s instanceof Set)for(const r of Array.from(s)){const a=e(t,s,r,r);a===void 0?s.delete(r):a!==r&&(s.delete(r),s.add(a))}else for(const[r,a]of Object.entries(s)){const l=e(t,s,r,a);l===void 0?delete s[r]:l!==a&&(s[r]=l)}return t.call(n,o,s)}return Vo.applyReviver=e,Vo}var Jo={},Qa;function ft(){if(Qa)return Jo;Qa=1;var e=B();function t(n,o,s){if(Array.isArray(n))return n.map((r,a)=>t(r,String(a),s));if(n&&typeof n.toJSON=="function"){if(!s||!e.hasAnchor(n))return n.toJSON(o,s);const r={aliasCount:0,count:1,res:void 0};s.anchors.set(n,r),s.onCreate=l=>{r.res=l,delete s.onCreate};const a=n.toJSON(o,s);return s.onCreate&&s.onCreate(a),a}return typeof n=="bigint"&&!s?.keep?Number(n):n}return Jo.toJS=t,Jo}var ei;function Wr(){if(ei)return Ho;ei=1;var e=Xc(),t=B(),n=ft();class o{constructor(r){Object.defineProperty(this,t.NODE_TYPE,{value:r})}clone(){const r=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(r.range=this.range.slice()),r}toJS(r,{mapAsMap:a,maxAliasCount:l,onAnchor:c,reviver:i}={}){if(!t.isDocument(r))throw new TypeError("A document argument is required");const d={anchors:new Map,doc:r,keep:!0,mapAsMap:a===!0,mapKeyWarned:!1,maxAliasCount:typeof l=="number"?l:100},h=n.toJS(this,"",d);if(typeof c=="function")for(const{count:u,res:p}of d.anchors.values())c(p,u);return typeof i=="function"?e.applyReviver(i,{"":h},"",h):h}}return Ho.NodeBase=o,Ho}var ti;function uo(){if(ti)return Go;ti=1;var e=zr(),t=co(),n=B(),o=Wr(),s=ft();let r=class extends o.NodeBase{constructor(c){super(n.ALIAS),this.source=c,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(c,i){if(i?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let d;i?.aliasResolveCache?d=i.aliasResolveCache:(d=[],t.visit(c,{Node:(u,p)=>{(n.isAlias(p)||n.hasAnchor(p))&&d.push(p)}}),i&&(i.aliasResolveCache=d));let h;for(const u of d){if(u===this)break;u.anchor===this.source&&(h=u)}return h}toJSON(c,i){if(!i)return{source:this.source};const{anchors:d,doc:h,maxAliasCount:u}=i,p=this.resolve(h,i);if(!p){const m=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(m)}let f=d.get(p);if(f||(s.toJS(p,null,i),f=d.get(p)),f?.res===void 0){const m="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(m)}if(u>=0&&(f.count+=1,f.aliasCount===0&&(f.aliasCount=a(h,p,d)),f.count*f.aliasCount>u)){const m="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(m)}return f.res}toString(c,i,d){const h=`*${this.source}`;if(c){if(e.anchorIsValid(this.source),c.options.verifyAliasOrder&&!c.anchors.has(this.source)){const u=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(u)}if(c.implicitKey)return`${h} `}return h}};function a(l,c,i){if(n.isAlias(c)){const d=c.resolve(l),h=i&&d&&i.get(d);return h?h.count*h.aliasCount:0}else if(n.isCollection(c)){let d=0;for(const h of c.items){const u=a(l,h,i);u>d&&(d=u)}return d}else if(n.isPair(c)){const d=a(l,c.key,i),h=a(l,c.value,i);return Math.max(d,h)}return 1}return Go.Alias=r,Go}var Ft={},Zo={},Sn={},ni;function ce(){if(ni)return Sn;ni=1;var e=B(),t=Wr(),n=ft();const o=r=>!r||typeof r!="function"&&typeof r!="object";let s=class extends t.NodeBase{constructor(a){super(e.SCALAR),this.value=a}toJSON(a,l){return l?.keep?this.value:n.toJS(this.value,a,l)}toString(){return String(this.value)}};return s.BLOCK_FOLDED="BLOCK_FOLDED",s.BLOCK_LITERAL="BLOCK_LITERAL",s.PLAIN="PLAIN",s.QUOTE_DOUBLE="QUOTE_DOUBLE",s.QUOTE_SINGLE="QUOTE_SINGLE",Sn.Scalar=s,Sn.isScalarValue=o,Sn}var oi;function ho(){if(oi)return Zo;oi=1;var e=uo(),t=B(),n=ce();const o="tag:yaml.org,2002:";function s(a,l,c){if(l){const i=c.filter(h=>h.tag===l),d=i.find(h=>!h.format)??i[0];if(!d)throw new Error(`Tag ${l} not found`);return d}return c.find(i=>i.identify?.(a)&&!i.format)}function r(a,l,c){if(t.isDocument(a)&&(a=a.contents),t.isNode(a))return a;if(t.isPair(a)){const y=c.schema[t.MAP].createNode?.(c.schema,null,c);return y.items.push(a),y}(a instanceof String||a instanceof Number||a instanceof Boolean||typeof BigInt<"u"&&a instanceof BigInt)&&(a=a.valueOf());const{aliasDuplicateObjects:i,onAnchor:d,onTagObj:h,schema:u,sourceObjects:p}=c;let f;if(i&&a&&typeof a=="object"){if(f=p.get(a),f)return f.anchor??(f.anchor=d(a)),new e.Alias(f.anchor);f={anchor:null,node:null},p.set(a,f)}l?.startsWith("!!")&&(l=o+l.slice(2));let m=s(a,l,u.tags);if(!m){if(a&&typeof a.toJSON=="function"&&(a=a.toJSON()),!a||typeof a!="object"){const y=new n.Scalar(a);return f&&(f.node=y),y}m=a instanceof Map?u[t.MAP]:Symbol.iterator in Object(a)?u[t.SEQ]:u[t.MAP]}h&&(h(m),delete c.onTagObj);const g=m?.createNode?m.createNode(c.schema,a,c):typeof m?.nodeClass?.from=="function"?m.nodeClass.from(c.schema,a,c):new n.Scalar(a);return l?g.tag=l:m.default||(g.tag=m.tag),f&&(f.node=g),g}return Zo.createNode=r,Zo}var si;function Kr(){if(si)return Ft;si=1;var e=ho(),t=B(),n=Wr();function o(a,l,c){let i=c;for(let d=l.length-1;d>=0;--d){const h=l[d];if(typeof h=="number"&&Number.isInteger(h)&&h>=0){const u=[];u[h]=i,i=u}else i=new Map([[h,i]])}return e.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:a,sourceObjects:new Map})}const s=a=>a==null||typeof a=="object"&&!!a[Symbol.iterator]().next().done;let r=class extends n.NodeBase{constructor(l,c){super(l),Object.defineProperty(this,"schema",{value:c,configurable:!0,enumerable:!1,writable:!0})}clone(l){const c=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return l&&(c.schema=l),c.items=c.items.map(i=>t.isNode(i)||t.isPair(i)?i.clone(l):i),this.range&&(c.range=this.range.slice()),c}addIn(l,c){if(s(l))this.add(c);else{const[i,...d]=l,h=this.get(i,!0);if(t.isCollection(h))h.addIn(d,c);else if(h===void 0&&this.schema)this.set(i,o(this.schema,d,c));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${d}`)}}deleteIn(l){const[c,...i]=l;if(i.length===0)return this.delete(c);const d=this.get(c,!0);if(t.isCollection(d))return d.deleteIn(i);throw new Error(`Expected YAML collection at ${c}. Remaining path: ${i}`)}getIn(l,c){const[i,...d]=l,h=this.get(i,!0);return d.length===0?!c&&t.isScalar(h)?h.value:h:t.isCollection(h)?h.getIn(d,c):void 0}hasAllNullValues(l){return this.items.every(c=>{if(!t.isPair(c))return!1;const i=c.value;return i==null||l&&t.isScalar(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(l){const[c,...i]=l;if(i.length===0)return this.has(c);const d=this.get(c,!0);return t.isCollection(d)?d.hasIn(i):!1}setIn(l,c){const[i,...d]=l;if(d.length===0)this.set(i,c);else{const h=this.get(i,!0);if(t.isCollection(h))h.setIn(d,c);else if(h===void 0&&this.schema)this.set(i,o(this.schema,d,c));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${d}`)}}};return Ft.Collection=r,Ft.collectionFromPath=o,Ft.isEmptyPath=s,Ft}var jn={},Xo={},An={},Dt={},ri;function po(){if(ri)return Dt;ri=1;const e=o=>o.replace(/^(?!$)(?: $)?/gm,"#");function t(o,s){return/^\n+$/.test(o)?o.substring(1):s?o.replace(/^(?! *$)/gm,s):o}const n=(o,s,r)=>o.endsWith(`
|
|
18
18
|
`)?t(r,s):r.includes(`
|
|
19
19
|
`)?`
|
|
20
|
-
`+t(r,s):(o.endsWith(" ")?"":" ")+r;return Dt.indentComment=t,Dt.lineComment=n,Dt.stringifyComment=e,Dt}var Qo={},vt={},
|
|
20
|
+
`+t(r,s):(o.endsWith(" ")?"":" ")+r;return Dt.indentComment=t,Dt.lineComment=n,Dt.stringifyComment=e,Dt}var Qo={},vt={},ai;function km(){if(ai)return vt;ai=1;const e="flow",t="block",n="quoted";function o(r,a,l="flow",{indentAtStart:c,lineWidth:i=80,minContentWidth:d=20,onFold:h,onOverflow:u}={}){if(!i||i<0)return r;i<d&&(d=0);const p=Math.max(1+d,1+i-a.length);if(r.length<=p)return r;const f=[],m={};let g=i-a.length;typeof c=="number"&&(c>i-Math.max(2,d)?f.push(0):g=i-c);let y,b,k=!1,w=-1,v=-1,S=-1;l===t&&(w=s(r,w,a.length),w!==-1&&(g=w+p));for(let O;O=r[w+=1];){if(l===n&&O==="\\"){switch(v=w,r[w+1]){case"x":w+=3;break;case"u":w+=5;break;case"U":w+=9;break;default:w+=1}S=w}if(O===`
|
|
21
21
|
`)l===t&&(w=s(r,w,a.length)),g=w+a.length+p,y=void 0;else{if(O===" "&&b&&b!==" "&&b!==`
|
|
22
22
|
`&&b!==" "){const A=r[w+1];A&&A!==" "&&A!==`
|
|
23
23
|
`&&A!==" "&&(y=w)}if(w>=g)if(y)f.push(y),g=y+p,y=void 0;else if(l===n){for(;b===" "||b===" ";)b=O,O=r[w+=1],k=!0;const A=w>S+1?w-2:v-1;if(m[A])return r;f.push(A),m[A]=!0,g=A+p,y=void 0}else k=!0}b=O}if(k&&u&&u(),f.length===0)return r;h&&h();let j=r.slice(0,f[0]);for(let O=0;O<f.length;++O){const A=f[O],E=f[O+1]||r.length;A===0?j=`
|
|
24
24
|
${a}${r.slice(0,E)}`:(l===n&&m[A]&&(j+=`${r[A]}\\`),j+=`
|
|
25
25
|
${a}${r.slice(A+1,E)}`)}return j}function s(r,a,l){let c=a,i=a+1,d=r[i];for(;d===" "||d===" ";)if(a<i+l)d=r[++a];else{do d=r[++a];while(d&&d!==`
|
|
26
|
-
`);c=a,i=a+1,d=r[i]}return c}return vt.FOLD_BLOCK=t,vt.FOLD_FLOW=e,vt.FOLD_QUOTED=n,vt.foldFlowLines=o,vt}var
|
|
26
|
+
`);c=a,i=a+1,d=r[i]}return c}return vt.FOLD_BLOCK=t,vt.FOLD_FLOW=e,vt.FOLD_QUOTED=n,vt.foldFlowLines=o,vt}var ii;function fo(){if(ii)return Qo;ii=1;var e=ce(),t=km();const n=(u,p)=>({indentAtStart:p?u.indent.length:u.indentAtStart,lineWidth:u.options.lineWidth,minContentWidth:u.options.minContentWidth}),o=u=>/^(%|---|\.\.\.)/m.test(u);function s(u,p,f){if(!p||p<0)return!1;const m=p-f,g=u.length;if(g<=m)return!1;for(let y=0,b=0;y<g;++y)if(u[y]===`
|
|
27
27
|
`){if(y-b>m)return!0;if(b=y+1,g-b<=m)return!1}return!0}function r(u,p){const f=JSON.stringify(u);if(p.options.doubleQuotedAsJSON)return f;const{implicitKey:m}=p,g=p.options.doubleQuotedMinMultiLineLength,y=p.indent||(o(u)?" ":"");let b="",k=0;for(let w=0,v=f[w];v;v=f[++w])if(v===" "&&f[w+1]==="\\"&&f[w+2]==="n"&&(b+=f.slice(k,w)+"\\ ",w+=1,k=w,v="\\"),v==="\\")switch(f[w+1]){case"u":{b+=f.slice(k,w);const S=f.substr(w+2,4);switch(S){case"0000":b+="\\0";break;case"0007":b+="\\a";break;case"000b":b+="\\v";break;case"001b":b+="\\e";break;case"0085":b+="\\N";break;case"00a0":b+="\\_";break;case"2028":b+="\\L";break;case"2029":b+="\\P";break;default:S.substr(0,2)==="00"?b+="\\x"+S.substr(2):b+=f.substr(w,6)}w+=5,k=w+1}break;case"n":if(m||f[w+2]==='"'||f.length<g)w+=1;else{for(b+=f.slice(k,w)+`
|
|
28
28
|
|
|
29
29
|
`;f[w+2]==="\\"&&f[w+3]==="n"&&f[w+4]!=='"';)b+=`
|
|
@@ -37,51 +37,51 @@ ${f}`)+"'";return p.implicitKey?m:t.foldFlowLines(m,f,t.FOLD_FLOW,n(p,!1))}funct
|
|
|
37
37
|
`;let j,O;for(O=f.length;O>0;--O){const N=f[O-1];if(N!==`
|
|
38
38
|
`&&N!==" "&&N!==" ")break}let A=f.substring(O);const E=A.indexOf(`
|
|
39
39
|
`);E===-1?j="-":f===A||E!==A.length-1?(j="+",y&&y()):j="",A&&(f=f.slice(0,-A.length),A[A.length-1]===`
|
|
40
|
-
`&&(A=A.slice(0,-1)),A=A.replace(c,`$&${v}`));let x=!1,I
|
|
41
|
-
`)
|
|
42
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${v}`);let Z=!1;const U=n(m,!0);b!=="folded"&&p!==e.Scalar.BLOCK_FOLDED&&(U.onOverflow=()=>{Z=!0});const oe=t.foldFlowLines(`${
|
|
40
|
+
`&&(A=A.slice(0,-1)),A=A.replace(c,`$&${v}`));let x=!1,L,I=-1;for(L=0;L<f.length;++L){const N=f[L];if(N===" ")x=!0;else if(N===`
|
|
41
|
+
`)I=L;else break}let M=f.substring(0,I<L?I+1:L);M&&(f=f.substring(M.length),M=M.replace(/\n+/g,`$&${v}`));let q=(x?v?"2":"1":"")+j;if(u&&(q+=" "+k(u.replace(/ ?[\r\n]+/g," ")),g&&g()),!S){const N=f.replace(/\n+/g,`
|
|
42
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${v}`);let Z=!1;const U=n(m,!0);b!=="folded"&&p!==e.Scalar.BLOCK_FOLDED&&(U.onOverflow=()=>{Z=!0});const oe=t.foldFlowLines(`${M}${N}${A}`,v,t.FOLD_BLOCK,U);if(!Z)return`>${q}
|
|
43
43
|
${v}${oe}`}return f=f.replace(/\n+/g,`$&${v}`),`|${q}
|
|
44
|
-
${v}${
|
|
44
|
+
${v}${M}${f}${A}`}function d(u,p,f,m){const{type:g,value:y}=u,{actualString:b,implicitKey:k,indent:w,indentStep:v,inFlow:S}=p;if(k&&y.includes(`
|
|
45
45
|
`)||S&&/[[\]{},]/.test(y))return l(y,p);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(y))return k||S||!y.includes(`
|
|
46
46
|
`)?l(y,p):i(u,p,f,m);if(!k&&!S&&g!==e.Scalar.PLAIN&&y.includes(`
|
|
47
47
|
`))return i(u,p,f,m);if(o(y)){if(w==="")return p.forceBlockIndent=!0,i(u,p,f,m);if(k&&w===v)return l(y,p)}const j=y.replace(/\n+/g,`$&
|
|
48
|
-
${w}`);if(b){const O=x=>x.default&&x.tag!=="tag:yaml.org,2002:str"&&x.test?.test(j),{compat:A,tags:E}=p.doc.schema;if(E.some(O)||A?.some(O))return l(y,p)}return k?j:t.foldFlowLines(j,w,t.FOLD_FLOW,n(p,!1))}function h(u,p,f,m){const{implicitKey:g,inFlow:y}=p,b=typeof u.value=="string"?u:Object.assign({},u,{value:String(u.value)});let{type:k}=u;k!==e.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(b.value)&&(k=e.Scalar.QUOTE_DOUBLE);const w=S=>{switch(S){case e.Scalar.BLOCK_FOLDED:case e.Scalar.BLOCK_LITERAL:return g||y?l(b.value,p):i(b,p,f,m);case e.Scalar.QUOTE_DOUBLE:return r(b.value,p);case e.Scalar.QUOTE_SINGLE:return a(b.value,p);case e.Scalar.PLAIN:return d(b,p,f,m);default:return null}};let v=w(k);if(v===null){const{defaultKeyType:S,defaultStringType:j}=p.options,O=g&&S||j;if(v=w(O),v===null)throw new Error(`Unsupported default string type ${O}`)}return v}return Qo.stringifyString=h,Qo}var
|
|
49
|
-
${i.indent}${m}`:m}return
|
|
48
|
+
${w}`);if(b){const O=x=>x.default&&x.tag!=="tag:yaml.org,2002:str"&&x.test?.test(j),{compat:A,tags:E}=p.doc.schema;if(E.some(O)||A?.some(O))return l(y,p)}return k?j:t.foldFlowLines(j,w,t.FOLD_FLOW,n(p,!1))}function h(u,p,f,m){const{implicitKey:g,inFlow:y}=p,b=typeof u.value=="string"?u:Object.assign({},u,{value:String(u.value)});let{type:k}=u;k!==e.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(b.value)&&(k=e.Scalar.QUOTE_DOUBLE);const w=S=>{switch(S){case e.Scalar.BLOCK_FOLDED:case e.Scalar.BLOCK_LITERAL:return g||y?l(b.value,p):i(b,p,f,m);case e.Scalar.QUOTE_DOUBLE:return r(b.value,p);case e.Scalar.QUOTE_SINGLE:return a(b.value,p);case e.Scalar.PLAIN:return d(b,p,f,m);default:return null}};let v=w(k);if(v===null){const{defaultKeyType:S,defaultStringType:j}=p.options,O=g&&S||j;if(v=w(O),v===null)throw new Error(`Unsupported default string type ${O}`)}return v}return Qo.stringifyString=h,Qo}var li;function mo(){if(li)return An;li=1;var e=zr(),t=B(),n=po(),o=fo();function s(c,i){const d=Object.assign({blockQuote:!0,commentString:n.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},c.schema.toStringOptions,i);let h;switch(d.collectionStyle){case"block":h=!1;break;case"flow":h=!0;break;default:h=null}return{anchors:new Set,doc:c,flowCollectionPadding:d.flowCollectionPadding?" ":"",indent:"",indentStep:typeof d.indent=="number"?" ".repeat(d.indent):" ",inFlow:h,options:d}}function r(c,i){if(i.tag){const u=c.filter(p=>p.tag===i.tag);if(u.length>0)return u.find(p=>p.format===i.format)??u[0]}let d,h;if(t.isScalar(i)){h=i.value;let u=c.filter(p=>p.identify?.(h));if(u.length>1){const p=u.filter(f=>f.test);p.length>0&&(u=p)}d=u.find(p=>p.format===i.format)??u.find(p=>!p.format)}else h=i,d=c.find(u=>u.nodeClass&&h instanceof u.nodeClass);if(!d){const u=h?.constructor?.name??(h===null?"null":typeof h);throw new Error(`Tag not resolved for ${u} value`)}return d}function a(c,i,{anchors:d,doc:h}){if(!h.directives)return"";const u=[],p=(t.isScalar(c)||t.isCollection(c))&&c.anchor;p&&e.anchorIsValid(p)&&(d.add(p),u.push(`&${p}`));const f=c.tag??(i.default?null:i.tag);return f&&u.push(h.directives.tagString(f)),u.join(" ")}function l(c,i,d,h){if(t.isPair(c))return c.toString(i,d,h);if(t.isAlias(c)){if(i.doc.directives)return c.toString(i);if(i.resolvedAliases?.has(c))throw new TypeError("Cannot stringify circular structure without alias nodes");i.resolvedAliases?i.resolvedAliases.add(c):i.resolvedAliases=new Set([c]),c=c.resolve(i.doc)}let u;const p=t.isNode(c)?c:i.doc.createNode(c,{onTagObj:g=>u=g});u??(u=r(i.doc.schema.tags,p));const f=a(p,u,i);f.length>0&&(i.indentAtStart=(i.indentAtStart??0)+f.length+1);const m=typeof u.stringify=="function"?u.stringify(p,i,d,h):t.isScalar(p)?o.stringifyString(p,i,d,h):p.toString(i,d,h);return f?t.isScalar(p)||m[0]==="{"||m[0]==="["?`${f} ${m}`:`${f}
|
|
49
|
+
${i.indent}${m}`:m}return An.createStringifyContext=s,An.stringify=l,An}var ci;function vm(){if(ci)return Xo;ci=1;var e=B(),t=ce(),n=mo(),o=po();function s({key:r,value:a},l,c,i){const{allNullValues:d,doc:h,indent:u,indentStep:p,options:{commentString:f,indentSeq:m,simpleKeys:g}}=l;let y=e.isNode(r)&&r.comment||null;if(g){if(y)throw new Error("With simple keys, key nodes cannot have comments");if(e.isCollection(r)||!e.isNode(r)&&typeof r=="object"){const L="With simple keys, collection cannot be used as a key value";throw new Error(L)}}let b=!g&&(!r||y&&a==null&&!l.inFlow||e.isCollection(r)||(e.isScalar(r)?r.type===t.Scalar.BLOCK_FOLDED||r.type===t.Scalar.BLOCK_LITERAL:typeof r=="object"));l=Object.assign({},l,{allNullValues:!1,implicitKey:!b&&(g||!d),indent:u+p});let k=!1,w=!1,v=n.stringify(r,l,()=>k=!0,()=>w=!0);if(!b&&!l.inFlow&&v.length>1024){if(g)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");b=!0}if(l.inFlow){if(d||a==null)return k&&c&&c(),v===""?"?":b?`? ${v}`:v}else if(d&&!g||a==null&&b)return v=`? ${v}`,y&&!k?v+=o.lineComment(v,l.indent,f(y)):w&&i&&i(),v;k&&(y=null),b?(y&&(v+=o.lineComment(v,l.indent,f(y))),v=`? ${v}
|
|
50
50
|
${u}:`):(v=`${v}:`,y&&(v+=o.lineComment(v,l.indent,f(y))));let S,j,O;e.isNode(a)?(S=!!a.spaceBefore,j=a.commentBefore,O=a.comment):(S=!1,j=null,O=null,a&&typeof a=="object"&&(a=h.createNode(a))),l.implicitKey=!1,!b&&!y&&e.isScalar(a)&&(l.indentAtStart=v.length+1),w=!1,!m&&p.length>=2&&!l.inFlow&&!b&&e.isSeq(a)&&!a.flow&&!a.tag&&!a.anchor&&(l.indent=l.indent.substring(2));let A=!1;const E=n.stringify(a,l,()=>A=!0,()=>w=!0);let x=" ";if(y||S||j){if(x=S?`
|
|
51
|
-
`:"",j){const
|
|
52
|
-
${o.indentComment(
|
|
51
|
+
`:"",j){const L=f(j);x+=`
|
|
52
|
+
${o.indentComment(L,l.indent)}`}E===""&&!l.inFlow?x===`
|
|
53
53
|
`&&O&&(x=`
|
|
54
54
|
|
|
55
55
|
`):x+=`
|
|
56
|
-
${l.indent}`}else if(!b&&e.isCollection(a)){const
|
|
57
|
-
`),
|
|
56
|
+
${l.indent}`}else if(!b&&e.isCollection(a)){const L=E[0],I=E.indexOf(`
|
|
57
|
+
`),M=I!==-1,ne=l.inFlow??a.flow??a.items.length===0;if(M||!ne){let q=!1;if(M&&(L==="&"||L==="!")){let N=E.indexOf(" ");L==="&"&&N!==-1&&N<I&&E[N+1]==="!"&&(N=E.indexOf(" ",N+1)),(N===-1||I<N)&&(q=!0)}q||(x=`
|
|
58
58
|
${l.indent}`)}}else(E===""||E[0]===`
|
|
59
|
-
`)&&(x="");return v+=x+E,l.inFlow?A&&c&&c():O&&!A?v+=o.lineComment(v,l.indent,f(O)):w&&i&&i(),v}return Xo.stringifyPair=s,Xo}var es={},
|
|
59
|
+
`)&&(x="");return v+=x+E,l.inFlow?A&&c&&c():O&&!A?v+=o.lineComment(v,l.indent,f(O)):w&&i&&i(),v}return Xo.stringifyPair=s,Xo}var es={},Tn={},di;function Qc(){if(di)return Tn;di=1;var e=Er;function t(o,...s){o==="debug"&&console.log(...s)}function n(o,s){(o==="debug"||o==="warn")&&(typeof e.emitWarning=="function"?e.emitWarning(s):console.warn(s))}return Tn.debug=t,Tn.warn=n,Tn}var Bt={},ui;function Yr(){if(ui)return Bt;ui=1;var e=B(),t=ce();const n="<<",o={identify:c=>c===n||typeof c=="symbol"&&c.description===n,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new t.Scalar(Symbol(n)),{addToJSMap:r}),stringify:()=>n},s=(c,i)=>(o.identify(i)||e.isScalar(i)&&(!i.type||i.type===t.Scalar.PLAIN)&&o.identify(i.value))&&c?.doc.schema.tags.some(d=>d.tag===o.tag&&d.default);function r(c,i,d){const h=l(c,d);if(e.isSeq(h))for(const u of h.items)a(c,i,u);else if(Array.isArray(h))for(const u of h)a(c,i,u);else a(c,i,h)}function a(c,i,d){const h=l(c,d);if(!e.isMap(h))throw new Error("Merge sources must be maps or map aliases");const u=h.toJSON(null,c,Map);for(const[p,f]of u)i instanceof Map?i.has(p)||i.set(p,f):i instanceof Set?i.add(p):Object.prototype.hasOwnProperty.call(i,p)||Object.defineProperty(i,p,{value:f,writable:!0,enumerable:!0,configurable:!0});return i}function l(c,i){return c&&e.isAlias(i)?i.resolve(c.doc,c):i}return Bt.addMergeToJSMap=r,Bt.isMergeKey=s,Bt.merge=o,Bt}var hi;function ed(){if(hi)return es;hi=1;var e=Qc(),t=Yr(),n=mo(),o=B(),s=ft();function r(l,c,{key:i,value:d}){if(o.isNode(i)&&i.addToJSMap)i.addToJSMap(l,c,d);else if(t.isMergeKey(l,i))t.addMergeToJSMap(l,c,d);else{const h=s.toJS(i,"",l);if(c instanceof Map)c.set(h,s.toJS(d,h,l));else if(c instanceof Set)c.add(h);else{const u=a(i,h,l),p=s.toJS(d,u,l);u in c?Object.defineProperty(c,u,{value:p,writable:!0,enumerable:!0,configurable:!0}):c[u]=p}}return c}function a(l,c,i){if(c===null)return"";if(typeof c!="object")return String(c);if(o.isNode(l)&&i?.doc){const d=n.createStringifyContext(i.doc,{});d.anchors=new Set;for(const u of i.anchors.keys())d.anchors.add(u.anchor);d.inFlow=!0,d.inStringifyKey=!0;const h=l.toString(d);if(!i.mapKeyWarned){let u=JSON.stringify(h);u.length>40&&(u=u.substring(0,36)+'..."'),e.warn(i.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${u}. Set mapAsMap: true to use object keys.`),i.mapKeyWarned=!0}return h}return JSON.stringify(c)}return es.addPairToJSMap=r,es}var pi;function mt(){if(pi)return jn;pi=1;var e=ho(),t=vm(),n=ed(),o=B();function s(a,l,c){const i=e.createNode(a,void 0,c),d=e.createNode(l,void 0,c);return new r(i,d)}let r=class td{constructor(l,c=null){Object.defineProperty(this,o.NODE_TYPE,{value:o.PAIR}),this.key=l,this.value=c}clone(l){let{key:c,value:i}=this;return o.isNode(c)&&(c=c.clone(l)),o.isNode(i)&&(i=i.clone(l)),new td(c,i)}toJSON(l,c){const i=c?.mapAsMap?new Map:{};return n.addPairToJSMap(c,i,this)}toString(l,c,i){return l?.doc?t.stringifyPair(this,l,c,i):JSON.stringify(this)}};return jn.Pair=r,jn.createPair=s,jn}var ts={},ns={},On={},os={},fi;function nd(){if(fi)return os;fi=1;var e=B(),t=mo(),n=po();function o(l,c,i){return(c.inFlow??l.flow?r:s)(l,c,i)}function s({comment:l,items:c},i,{blockItemPrefix:d,flowChars:h,itemIndent:u,onChompKeep:p,onComment:f}){const{indent:m,options:{commentString:g}}=i,y=Object.assign({},i,{indent:u,type:null});let b=!1;const k=[];for(let v=0;v<c.length;++v){const S=c[v];let j=null;if(e.isNode(S))!b&&S.spaceBefore&&k.push(""),a(i,k,S.commentBefore,b),S.comment&&(j=S.comment);else if(e.isPair(S)){const A=e.isNode(S.key)?S.key:null;A&&(!b&&A.spaceBefore&&k.push(""),a(i,k,A.commentBefore,b))}b=!1;let O=t.stringify(S,y,()=>j=null,()=>b=!0);j&&(O+=n.lineComment(O,u,g(j))),b&&j&&(b=!1),k.push(d+O)}let w;if(k.length===0)w=h.start+h.end;else{w=k[0];for(let v=1;v<k.length;++v){const S=k[v];w+=S?`
|
|
60
60
|
${m}${S}`:`
|
|
61
61
|
`}}return l?(w+=`
|
|
62
62
|
`+n.indentComment(g(l),m),f&&f()):b&&p&&p(),w}function r({items:l},c,{flowChars:i,itemIndent:d}){const{indent:h,indentStep:u,flowCollectionPadding:p,options:{commentString:f}}=c;d+=u;const m=Object.assign({},c,{indent:d,inFlow:!0,type:null});let g=!1,y=0;const b=[];for(let v=0;v<l.length;++v){const S=l[v];let j=null;if(e.isNode(S))S.spaceBefore&&b.push(""),a(c,b,S.commentBefore,!1),S.comment&&(j=S.comment);else if(e.isPair(S)){const A=e.isNode(S.key)?S.key:null;A&&(A.spaceBefore&&b.push(""),a(c,b,A.commentBefore,!1),A.comment&&(g=!0));const E=e.isNode(S.value)?S.value:null;E?(E.comment&&(j=E.comment),E.commentBefore&&(g=!0)):S.value==null&&A?.comment&&(j=A.comment)}j&&(g=!0);let O=t.stringify(S,m,()=>j=null);g||(g=b.length>y||O.includes(`
|
|
63
63
|
`)),v<l.length-1?O+=",":c.options.trailingComma&&(c.options.lineWidth>0&&(g||(g=b.reduce((A,E)=>A+E.length+2,2)+(O.length+2)>c.options.lineWidth)),g&&(O+=",")),j&&(O+=n.lineComment(O,d,f(j))),b.push(O),y=b.length}const{start:k,end:w}=i;if(b.length===0)return k+w;if(!g){const v=b.reduce((S,j)=>S+j.length+2,2);g=c.options.lineWidth>0&&v>c.options.lineWidth}if(g){let v=k;for(const S of b)v+=S?`
|
|
64
64
|
${u}${h}${S}`:`
|
|
65
65
|
`;return`${v}
|
|
66
|
-
${h}${w}`}else return`${k}${p}${b.join(" ")}${p}${w}`}function a({indent:l,options:{commentString:c}},i,d,h){if(d&&h&&(d=d.replace(/^\n+/,"")),d){const u=n.indentComment(c(d),l);i.push(u.trimStart())}}return os.stringifyCollection=o,os}var
|
|
67
|
-
`:" ")}return n.stringifyString({comment:s,type:r,value:h},l,c,i)}};return hs.binary=o,hs}var
|
|
66
|
+
${h}${w}`}else return`${k}${p}${b.join(" ")}${p}${w}`}function a({indent:l,options:{commentString:c}},i,d,h){if(d&&h&&(d=d.replace(/^\n+/,"")),d){const u=n.indentComment(c(d),l);i.push(u.trimStart())}}return os.stringifyCollection=o,os}var mi;function gt(){if(mi)return On;mi=1;var e=nd(),t=ed(),n=Kr(),o=B(),s=mt(),r=ce();function a(c,i){const d=o.isScalar(i)?i.value:i;for(const h of c)if(o.isPair(h)&&(h.key===i||h.key===d||o.isScalar(h.key)&&h.key.value===d))return h}let l=class extends n.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(i){super(o.MAP,i),this.items=[]}static from(i,d,h){const{keepUndefined:u,replacer:p}=h,f=new this(i),m=(g,y)=>{if(typeof p=="function")y=p.call(d,g,y);else if(Array.isArray(p)&&!p.includes(g))return;(y!==void 0||u)&&f.items.push(s.createPair(g,y,h))};if(d instanceof Map)for(const[g,y]of d)m(g,y);else if(d&&typeof d=="object")for(const g of Object.keys(d))m(g,d[g]);return typeof i.sortMapEntries=="function"&&f.items.sort(i.sortMapEntries),f}add(i,d){let h;o.isPair(i)?h=i:!i||typeof i!="object"||!("key"in i)?h=new s.Pair(i,i?.value):h=new s.Pair(i.key,i.value);const u=a(this.items,h.key),p=this.schema?.sortMapEntries;if(u){if(!d)throw new Error(`Key ${h.key} already set`);o.isScalar(u.value)&&r.isScalarValue(h.value)?u.value.value=h.value:u.value=h.value}else if(p){const f=this.items.findIndex(m=>p(h,m)<0);f===-1?this.items.push(h):this.items.splice(f,0,h)}else this.items.push(h)}delete(i){const d=a(this.items,i);return d?this.items.splice(this.items.indexOf(d),1).length>0:!1}get(i,d){const u=a(this.items,i)?.value;return(!d&&o.isScalar(u)?u.value:u)??void 0}has(i){return!!a(this.items,i)}set(i,d){this.add(new s.Pair(i,d),!0)}toJSON(i,d,h){const u=h?new h:d?.mapAsMap?new Map:{};d?.onCreate&&d.onCreate(u);for(const p of this.items)t.addPairToJSMap(d,u,p);return u}toString(i,d,h){if(!i)return JSON.stringify(this);for(const u of this.items)if(!o.isPair(u))throw new Error(`Map items must all be pairs; found ${JSON.stringify(u)} instead`);return!i.allNullValues&&this.hasAllNullValues(!1)&&(i=Object.assign({},i,{allNullValues:!0})),e.stringifyCollection(this,i,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:i.indent||"",onChompKeep:h,onComment:d})}};return On.YAMLMap=l,On.findPair=a,On}var gi;function fn(){if(gi)return ns;gi=1;var e=B(),t=gt();const n={collection:"map",default:!0,nodeClass:t.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(o,s){return e.isMap(o)||s("Expected a mapping for this tag"),o},createNode:(o,s,r)=>t.YAMLMap.from(o,s,r)};return ns.map=n,ns}var ss={},rs={},yi;function yt(){if(yi)return rs;yi=1;var e=ho(),t=nd(),n=Kr(),o=B(),s=ce(),r=ft();let a=class extends n.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(i){super(o.SEQ,i),this.items=[]}add(i){this.items.push(i)}delete(i){const d=l(i);return typeof d!="number"?!1:this.items.splice(d,1).length>0}get(i,d){const h=l(i);if(typeof h!="number")return;const u=this.items[h];return!d&&o.isScalar(u)?u.value:u}has(i){const d=l(i);return typeof d=="number"&&d<this.items.length}set(i,d){const h=l(i);if(typeof h!="number")throw new Error(`Expected a valid index, not ${i}.`);const u=this.items[h];o.isScalar(u)&&s.isScalarValue(d)?u.value=d:this.items[h]=d}toJSON(i,d){const h=[];d?.onCreate&&d.onCreate(h);let u=0;for(const p of this.items)h.push(r.toJS(p,String(u++),d));return h}toString(i,d,h){return i?t.stringifyCollection(this,i,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(i.indent||"")+" ",onChompKeep:h,onComment:d}):JSON.stringify(this)}static from(i,d,h){const{replacer:u}=h,p=new this(i);if(d&&Symbol.iterator in Object(d)){let f=0;for(let m of d){if(typeof u=="function"){const g=d instanceof Set?m:String(f++);m=u.call(d,g,m)}p.items.push(e.createNode(m,void 0,h))}}return p}};function l(c){let i=o.isScalar(c)?c.value:c;return i&&typeof i=="string"&&(i=Number(i)),typeof i=="number"&&Number.isInteger(i)&&i>=0?i:null}return rs.YAMLSeq=a,rs}var bi;function mn(){if(bi)return ss;bi=1;var e=B(),t=yt();const n={collection:"seq",default:!0,nodeClass:t.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(o,s){return e.isSeq(o)||s("Expected a sequence for this tag"),o},createNode:(o,s,r)=>t.YAMLSeq.from(o,s,r)};return ss.seq=n,ss}var as={},wi;function go(){if(wi)return as;wi=1;var e=fo();const t={identify:n=>typeof n=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:n=>n,stringify(n,o,s,r){return o=Object.assign({actualString:!0},o),e.stringifyString(n,o,s,r)}};return as.string=t,as}var En={},is={},ki;function Gr(){if(ki)return is;ki=1;var e=ce();const t={identify:n=>n==null,createNode:()=>new e.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new e.Scalar(null),stringify:({source:n},o)=>typeof n=="string"&&t.test.test(n)?n:o.options.nullStr};return is.nullTag=t,is}var ls={},vi;function od(){if(vi)return ls;vi=1;var e=ce();const t={identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:n=>new e.Scalar(n[0]==="t"||n[0]==="T"),stringify({source:n,value:o},s){if(n&&t.test.test(n)){const r=n[0]==="t"||n[0]==="T";if(o===r)return n}return o?s.options.trueStr:s.options.falseStr}};return ls.boolTag=t,ls}var Ut={},cs={},$i;function gn(){if($i)return cs;$i=1;function e({format:t,minFractionDigits:n,tag:o,value:s}){if(typeof s=="bigint")return String(s);const r=typeof s=="number"?s:Number(s);if(!isFinite(r))return isNaN(r)?".nan":r<0?"-.inf":".inf";let a=Object.is(s,-0)?"-0":JSON.stringify(s);if(!t&&n&&(!o||o==="tag:yaml.org,2002:float")&&/^-?\d/.test(a)&&!a.includes("e")){let l=a.indexOf(".");l<0&&(l=a.length,a+=".");let c=n-(a.length-l-1);for(;c-- >0;)a+="0"}return a}return cs.stringifyNumber=e,cs}var Si;function sd(){if(Si)return Ut;Si=1;var e=ce(),t=gn();const n={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:r=>r.slice(-3).toLowerCase()==="nan"?NaN:r[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:t.stringifyNumber},o={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:r=>parseFloat(r),stringify(r){const a=Number(r.value);return isFinite(a)?a.toExponential():t.stringifyNumber(r)}},s={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(r){const a=new e.Scalar(parseFloat(r)),l=r.indexOf(".");return l!==-1&&r[r.length-1]==="0"&&(a.minFractionDigits=r.length-l-1),a},stringify:t.stringifyNumber};return Ut.float=s,Ut.floatExp=o,Ut.floatNaN=n,Ut}var zt={},ji;function rd(){if(ji)return zt;ji=1;var e=gn();const t=l=>typeof l=="bigint"||Number.isInteger(l),n=(l,c,i,{intAsBigInt:d})=>d?BigInt(l):parseInt(l.substring(c),i);function o(l,c,i){const{value:d}=l;return t(d)&&d>=0?i+d.toString(c):e.stringifyNumber(l)}const s={identify:l=>t(l)&&l>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(l,c,i)=>n(l,2,8,i),stringify:l=>o(l,8,"0o")},r={identify:t,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(l,c,i)=>n(l,0,10,i),stringify:e.stringifyNumber},a={identify:l=>t(l)&&l>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(l,c,i)=>n(l,2,16,i),stringify:l=>o(l,16,"0x")};return zt.int=r,zt.intHex=a,zt.intOct=s,zt}var ds={},Ai;function $m(){if(Ai)return ds;Ai=1;var e=fn(),t=Gr(),n=mn(),o=go(),s=od(),r=sd(),a=rd();const l=[e.map,n.seq,o.string,t.nullTag,s.boolTag,a.intOct,a.int,a.intHex,r.floatNaN,r.floatExp,r.float];return ds.schema=l,ds}var us={},Ti;function Sm(){if(Ti)return us;Ti=1;var e=ce(),t=fn(),n=mn();function o(c){return typeof c=="bigint"||Number.isInteger(c)}const s=({value:c})=>JSON.stringify(c),r=[{identify:c=>typeof c=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:c=>c,stringify:s},{identify:c=>c==null,createNode:()=>new e.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:s},{identify:c=>typeof c=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:c=>c==="true",stringify:s},{identify:o,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(c,i,{intAsBigInt:d})=>d?BigInt(c):parseInt(c,10),stringify:({value:c})=>o(c)?c.toString():JSON.stringify(c)},{identify:c=>typeof c=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:c=>parseFloat(c),stringify:s}],a={default:!0,tag:"",test:/^/,resolve(c,i){return i(`Unresolved plain scalar ${JSON.stringify(c)}`),c}},l=[t.map,n.seq].concat(r,a);return us.schema=l,us}var hs={},Oi;function ad(){if(Oi)return hs;Oi=1;var e=Nu,t=ce(),n=fo();const o={identify:s=>s instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(s,r){if(typeof e.Buffer=="function")return e.Buffer.from(s,"base64");if(typeof atob=="function"){const a=atob(s.replace(/[\n\r]/g,"")),l=new Uint8Array(a.length);for(let c=0;c<a.length;++c)l[c]=a.charCodeAt(c);return l}else return r("This environment does not support reading binary tags; either Buffer or atob is required"),s},stringify({comment:s,type:r,value:a},l,c,i){if(!a)return"";const d=a;let h;if(typeof e.Buffer=="function")h=d instanceof e.Buffer?d.toString("base64"):e.Buffer.from(d.buffer).toString("base64");else if(typeof btoa=="function"){let u="";for(let p=0;p<d.length;++p)u+=String.fromCharCode(d[p]);h=btoa(u)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(r??(r=t.Scalar.BLOCK_LITERAL),r!==t.Scalar.QUOTE_DOUBLE){const u=Math.max(l.options.lineWidth-l.indent.length,l.options.minContentWidth),p=Math.ceil(h.length/u),f=new Array(p);for(let m=0,g=0;m<p;++m,g+=u)f[m]=h.substr(g,u);h=f.join(r===t.Scalar.BLOCK_LITERAL?`
|
|
67
|
+
`:" ")}return n.stringifyString({comment:s,type:r,value:h},l,c,i)}};return hs.binary=o,hs}var Cn={},Wt={},Ei;function Hr(){if(Ei)return Wt;Ei=1;var e=B(),t=mt(),n=ce(),o=yt();function s(l,c){if(e.isSeq(l))for(let i=0;i<l.items.length;++i){let d=l.items[i];if(!e.isPair(d)){if(e.isMap(d)){d.items.length>1&&c("Each pair must have its own sequence indicator");const h=d.items[0]||new t.Pair(new n.Scalar(null));if(d.commentBefore&&(h.key.commentBefore=h.key.commentBefore?`${d.commentBefore}
|
|
68
68
|
${h.key.commentBefore}`:d.commentBefore),d.comment){const u=h.value??h.key;u.comment=u.comment?`${d.comment}
|
|
69
|
-
${u.comment}`:d.comment}d=h}l.items[i]=e.isPair(d)?d:new t.Pair(d)}}else c("Expected a sequence for this tag");return l}function r(l,c,i){const{replacer:d}=i,h=new o.YAMLSeq(l);h.tag="tag:yaml.org,2002:pairs";let u=0;if(c&&Symbol.iterator in Object(c))for(let p of c){typeof d=="function"&&(p=d.call(c,String(u++),p));let f,m;if(Array.isArray(p))if(p.length===2)f=p[0],m=p[1];else throw new TypeError(`Expected [key, value] tuple: ${p}`);else if(p&&p instanceof Object){const g=Object.keys(p);if(g.length===1)f=g[0],m=p[f];else throw new TypeError(`Expected tuple with one key, not ${g.length} keys`)}else f=p;h.items.push(t.createPair(f,m,i))}return h}const a={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:s,createNode:r};return Wt.createPairs=r,Wt.pairs=a,Wt.resolvePairs=s,Wt}var Oi;function od(){if(Oi)return En;Oi=1;var e=B(),t=ft(),n=gt(),o=yt(),s=Hr();class r extends o.YAMLSeq{constructor(){super(),this.add=n.YAMLMap.prototype.add.bind(this),this.delete=n.YAMLMap.prototype.delete.bind(this),this.get=n.YAMLMap.prototype.get.bind(this),this.has=n.YAMLMap.prototype.has.bind(this),this.set=n.YAMLMap.prototype.set.bind(this),this.tag=r.tag}toJSON(c,i){if(!i)return super.toJSON(c);const d=new Map;i?.onCreate&&i.onCreate(d);for(const h of this.items){let u,p;if(e.isPair(h)?(u=t.toJS(h.key,"",i),p=t.toJS(h.value,u,i)):u=t.toJS(h,"",i),d.has(u))throw new Error("Ordered maps must not include duplicate keys");d.set(u,p)}return d}static from(c,i,d){const h=s.createPairs(c,i,d),u=new this;return u.items=h.items,u}}r.tag="tag:yaml.org,2002:omap";const a={collection:"seq",identify:l=>l instanceof Map,nodeClass:r,default:!1,tag:"tag:yaml.org,2002:omap",resolve(l,c){const i=s.resolvePairs(l,c),d=[];for(const{key:h}of i.items)e.isScalar(h)&&(d.includes(h.value)?c(`Ordered maps must not include duplicate keys: ${h.value}`):d.push(h.value));return Object.assign(new r,i)},createNode:(l,c,i)=>r.from(l,c,i)};return En.YAMLOMap=r,En.omap=a,En}var ps={},Cn={},Ei;function km(){if(Ei)return Cn;Ei=1;var e=ce();function t({value:s,source:r},a){return r&&(s?n:o).test.test(r)?r:s?a.options.trueStr:a.options.falseStr}const n={identify:s=>s===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new e.Scalar(!0),stringify:t},o={identify:s=>s===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new e.Scalar(!1),stringify:t};return Cn.falseTag=o,Cn.trueTag=n,Cn}var Kt={},Ci;function vm(){if(Ci)return Kt;Ci=1;var e=ce(),t=mn();const n={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:r=>r.slice(-3).toLowerCase()==="nan"?NaN:r[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:t.stringifyNumber},o={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:r=>parseFloat(r.replace(/_/g,"")),stringify(r){const a=Number(r.value);return isFinite(a)?a.toExponential():t.stringifyNumber(r)}},s={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(r){const a=new e.Scalar(parseFloat(r.replace(/_/g,""))),l=r.indexOf(".");if(l!==-1){const c=r.substring(l+1).replace(/_/g,"");c[c.length-1]==="0"&&(a.minFractionDigits=c.length)}return a},stringify:t.stringifyNumber};return Kt.float=s,Kt.floatExp=o,Kt.floatNaN=n,Kt}var $t={},Ni;function $m(){if(Ni)return $t;Ni=1;var e=mn();const t=c=>typeof c=="bigint"||Number.isInteger(c);function n(c,i,d,{intAsBigInt:h}){const u=c[0];if((u==="-"||u==="+")&&(i+=1),c=c.substring(i).replace(/_/g,""),h){switch(d){case 2:c=`0b${c}`;break;case 8:c=`0o${c}`;break;case 16:c=`0x${c}`;break}const f=BigInt(c);return u==="-"?BigInt(-1)*f:f}const p=parseInt(c,d);return u==="-"?-1*p:p}function o(c,i,d){const{value:h}=c;if(t(h)){const u=h.toString(i);return h<0?"-"+d+u.substr(1):d+u}return e.stringifyNumber(c)}const s={identify:t,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(c,i,d)=>n(c,2,2,d),stringify:c=>o(c,2,"0b")},r={identify:t,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(c,i,d)=>n(c,1,8,d),stringify:c=>o(c,8,"0")},a={identify:t,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(c,i,d)=>n(c,0,10,d),stringify:e.stringifyNumber},l={identify:t,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(c,i,d)=>n(c,2,16,d),stringify:c=>o(c,16,"0x")};return $t.int=a,$t.intBin=s,$t.intHex=l,$t.intOct=r,$t}var Nn={},xi;function sd(){if(xi)return Nn;xi=1;var e=B(),t=mt(),n=gt();class o extends n.YAMLMap{constructor(a){super(a),this.tag=o.tag}add(a){let l;e.isPair(a)?l=a:a&&typeof a=="object"&&"key"in a&&"value"in a&&a.value===null?l=new t.Pair(a.key,null):l=new t.Pair(a,null),n.findPair(this.items,l.key)||this.items.push(l)}get(a,l){const c=n.findPair(this.items,a);return!l&&e.isPair(c)?e.isScalar(c.key)?c.key.value:c.key:c}set(a,l){if(typeof l!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof l}`);const c=n.findPair(this.items,a);c&&!l?this.items.splice(this.items.indexOf(c),1):!c&&l&&this.items.push(new t.Pair(a))}toJSON(a,l){return super.toJSON(a,l,Set)}toString(a,l,c){if(!a)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},a,{allNullValues:!0}),l,c);throw new Error("Set items must all have null values")}static from(a,l,c){const{replacer:i}=c,d=new this(a);if(l&&Symbol.iterator in Object(l))for(let h of l)typeof i=="function"&&(h=i.call(l,h,h)),d.items.push(t.createPair(h,null,c));return d}}o.tag="tag:yaml.org,2002:set";const s={collection:"map",identify:r=>r instanceof Set,nodeClass:o,default:!1,tag:"tag:yaml.org,2002:set",createNode:(r,a,l)=>o.from(r,a,l),resolve(r,a){if(e.isMap(r)){if(r.hasAllNullValues(!0))return Object.assign(new o,r);a("Set items must all have null values")}else a("Expected a mapping for this tag");return r}};return Nn.YAMLSet=o,Nn.set=s,Nn}var Yt={},Ri;function rd(){if(Ri)return Yt;Ri=1;var e=mn();function t(a,l){const c=a[0],i=c==="-"||c==="+"?a.substring(1):a,d=u=>l?BigInt(u):Number(u),h=i.replace(/_/g,"").split(":").reduce((u,p)=>u*d(60)+d(p),d(0));return c==="-"?d(-1)*h:h}function n(a){let{value:l}=a,c=u=>u;if(typeof l=="bigint")c=u=>BigInt(u);else if(isNaN(l)||!isFinite(l))return e.stringifyNumber(a);let i="";l<0&&(i="-",l*=c(-1));const d=c(60),h=[l%d];return l<60?h.unshift(0):(l=(l-h[0])/d,h.unshift(l%d),l>=60&&(l=(l-h[0])/d,h.unshift(l))),i+h.map(u=>String(u).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}const o={identify:a=>typeof a=="bigint"||Number.isInteger(a),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(a,l,{intAsBigInt:c})=>t(a,c),stringify:n},s={identify:a=>typeof a=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:a=>t(a,!1),stringify:n},r={identify:a=>a instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(a){const l=a.match(r.test);if(!l)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");const[,c,i,d,h,u,p]=l.map(Number),f=l[7]?Number((l[7]+"00").substr(1,3)):0;let m=Date.UTC(c,i-1,d,h||0,u||0,p||0,f);const g=l[8];if(g&&g!=="Z"){let y=t(g,!1);Math.abs(y)<30&&(y*=60),m-=6e4*y}return new Date(m)},stringify:({value:a})=>a?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};return Yt.floatTime=s,Yt.intTime=o,Yt.timestamp=r,Yt}var _i;function Sm(){if(_i)return ps;_i=1;var e=pn(),t=Gr(),n=fn(),o=go(),s=nd(),r=km(),a=vm(),l=$m(),c=Yr(),i=od(),d=Hr(),h=sd(),u=rd();const p=[e.map,n.seq,o.string,t.nullTag,r.trueTag,r.falseTag,l.intBin,l.intOct,l.int,l.intHex,a.floatNaN,a.floatExp,a.float,s.binary,c.merge,i.omap,d.pairs,h.set,u.intTime,u.floatTime,u.timestamp];return ps.schema=p,ps}var Pi;function jm(){if(Pi)return On;Pi=1;var e=pn(),t=Gr(),n=fn(),o=go(),s=Qc(),r=ed(),a=td(),l=bm(),c=wm(),i=nd(),d=Yr(),h=od(),u=Hr(),p=Sm(),f=sd(),m=rd();const g=new Map([["core",l.schema],["failsafe",[e.map,n.seq,o.string]],["json",c.schema],["yaml11",p.schema],["yaml-1.1",p.schema]]),y={binary:i.binary,bool:s.boolTag,float:r.float,floatExp:r.floatExp,floatNaN:r.floatNaN,floatTime:m.floatTime,int:a.int,intHex:a.intHex,intOct:a.intOct,intTime:m.intTime,map:e.map,merge:d.merge,null:t.nullTag,omap:h.omap,pairs:u.pairs,seq:n.seq,set:f.set,timestamp:m.timestamp},b={"tag:yaml.org,2002:binary":i.binary,"tag:yaml.org,2002:merge":d.merge,"tag:yaml.org,2002:omap":h.omap,"tag:yaml.org,2002:pairs":u.pairs,"tag:yaml.org,2002:set":f.set,"tag:yaml.org,2002:timestamp":m.timestamp};function k(w,v,S){const j=g.get(v);if(j&&!w)return S&&!j.includes(d.merge)?j.concat(d.merge):j.slice();let O=j;if(!O)if(Array.isArray(w))O=[];else{const A=Array.from(g.keys()).filter(E=>E!=="yaml11").map(E=>JSON.stringify(E)).join(", ");throw new Error(`Unknown schema "${v}"; use one of ${A} or define customTags array`)}if(Array.isArray(w))for(const A of w)O=O.concat(A);else typeof w=="function"&&(O=w(O.slice()));return S&&(O=O.concat(d.merge)),O.reduce((A,E)=>{const x=typeof E=="string"?y[E]:E;if(!x){const I=JSON.stringify(E),M=Object.keys(y).map(L=>JSON.stringify(L)).join(", ");throw new Error(`Unknown custom tag ${I}; use one of ${M}`)}return A.includes(x)||A.push(x),A},[])}return On.coreKnownTags=b,On.getTags=k,On}var Li;function id(){if(Li)return ts;Li=1;var e=B(),t=pn(),n=fn(),o=go(),s=jm();const r=(l,c)=>l.key<c.key?-1:l.key>c.key?1:0;let a=class ad{constructor({compat:c,customTags:i,merge:d,resolveKnownTags:h,schema:u,sortMapEntries:p,toStringDefaults:f}){this.compat=Array.isArray(c)?s.getTags(c,"compat"):c?s.getTags(null,c):null,this.name=typeof u=="string"&&u||"core",this.knownTags=h?s.coreKnownTags:{},this.tags=s.getTags(i,this.name,d),this.toStringOptions=f??null,Object.defineProperty(this,e.MAP,{value:t.map}),Object.defineProperty(this,e.SCALAR,{value:o.string}),Object.defineProperty(this,e.SEQ,{value:n.seq}),this.sortMapEntries=typeof p=="function"?p:p===!0?r:null}clone(){const c=Object.create(ad.prototype,Object.getOwnPropertyDescriptors(this));return c.tags=this.tags.slice(),c}};return ts.Schema=a,ts}var fs={},Ii;function Am(){if(Ii)return fs;Ii=1;var e=B(),t=mo(),n=po();function o(s,r){const a=[];let l=r.directives===!0;if(r.directives!==!1&&s.directives){const u=s.directives.toString(s);u?(a.push(u),l=!0):s.directives.docStart&&(l=!0)}l&&a.push("---");const c=t.createStringifyContext(s,r),{commentString:i}=c.options;if(s.commentBefore){a.length!==1&&a.unshift("");const u=i(s.commentBefore);a.unshift(n.indentComment(u,""))}let d=!1,h=null;if(s.contents){if(e.isNode(s.contents)){if(s.contents.spaceBefore&&l&&a.push(""),s.contents.commentBefore){const f=i(s.contents.commentBefore);a.push(n.indentComment(f,""))}c.forceBlockIndent=!!s.comment,h=s.contents.comment}const u=h?void 0:()=>d=!0;let p=t.stringify(s.contents,c,()=>h=null,u);h&&(p+=n.lineComment(p,"",i(h))),(p[0]==="|"||p[0]===">")&&a[a.length-1]==="---"?a[a.length-1]=`--- ${p}`:a.push(p)}else a.push(t.stringify(s.contents,c));if(s.directives?.docEnd)if(s.comment){const u=i(s.comment);u.includes(`
|
|
69
|
+
${u.comment}`:d.comment}d=h}l.items[i]=e.isPair(d)?d:new t.Pair(d)}}else c("Expected a sequence for this tag");return l}function r(l,c,i){const{replacer:d}=i,h=new o.YAMLSeq(l);h.tag="tag:yaml.org,2002:pairs";let u=0;if(c&&Symbol.iterator in Object(c))for(let p of c){typeof d=="function"&&(p=d.call(c,String(u++),p));let f,m;if(Array.isArray(p))if(p.length===2)f=p[0],m=p[1];else throw new TypeError(`Expected [key, value] tuple: ${p}`);else if(p&&p instanceof Object){const g=Object.keys(p);if(g.length===1)f=g[0],m=p[f];else throw new TypeError(`Expected tuple with one key, not ${g.length} keys`)}else f=p;h.items.push(t.createPair(f,m,i))}return h}const a={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:s,createNode:r};return Wt.createPairs=r,Wt.pairs=a,Wt.resolvePairs=s,Wt}var Ci;function id(){if(Ci)return Cn;Ci=1;var e=B(),t=ft(),n=gt(),o=yt(),s=Hr();class r extends o.YAMLSeq{constructor(){super(),this.add=n.YAMLMap.prototype.add.bind(this),this.delete=n.YAMLMap.prototype.delete.bind(this),this.get=n.YAMLMap.prototype.get.bind(this),this.has=n.YAMLMap.prototype.has.bind(this),this.set=n.YAMLMap.prototype.set.bind(this),this.tag=r.tag}toJSON(c,i){if(!i)return super.toJSON(c);const d=new Map;i?.onCreate&&i.onCreate(d);for(const h of this.items){let u,p;if(e.isPair(h)?(u=t.toJS(h.key,"",i),p=t.toJS(h.value,u,i)):u=t.toJS(h,"",i),d.has(u))throw new Error("Ordered maps must not include duplicate keys");d.set(u,p)}return d}static from(c,i,d){const h=s.createPairs(c,i,d),u=new this;return u.items=h.items,u}}r.tag="tag:yaml.org,2002:omap";const a={collection:"seq",identify:l=>l instanceof Map,nodeClass:r,default:!1,tag:"tag:yaml.org,2002:omap",resolve(l,c){const i=s.resolvePairs(l,c),d=[];for(const{key:h}of i.items)e.isScalar(h)&&(d.includes(h.value)?c(`Ordered maps must not include duplicate keys: ${h.value}`):d.push(h.value));return Object.assign(new r,i)},createNode:(l,c,i)=>r.from(l,c,i)};return Cn.YAMLOMap=r,Cn.omap=a,Cn}var ps={},Nn={},Ni;function jm(){if(Ni)return Nn;Ni=1;var e=ce();function t({value:s,source:r},a){return r&&(s?n:o).test.test(r)?r:s?a.options.trueStr:a.options.falseStr}const n={identify:s=>s===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new e.Scalar(!0),stringify:t},o={identify:s=>s===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new e.Scalar(!1),stringify:t};return Nn.falseTag=o,Nn.trueTag=n,Nn}var Kt={},xi;function Am(){if(xi)return Kt;xi=1;var e=ce(),t=gn();const n={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:r=>r.slice(-3).toLowerCase()==="nan"?NaN:r[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:t.stringifyNumber},o={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:r=>parseFloat(r.replace(/_/g,"")),stringify(r){const a=Number(r.value);return isFinite(a)?a.toExponential():t.stringifyNumber(r)}},s={identify:r=>typeof r=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(r){const a=new e.Scalar(parseFloat(r.replace(/_/g,""))),l=r.indexOf(".");if(l!==-1){const c=r.substring(l+1).replace(/_/g,"");c[c.length-1]==="0"&&(a.minFractionDigits=c.length)}return a},stringify:t.stringifyNumber};return Kt.float=s,Kt.floatExp=o,Kt.floatNaN=n,Kt}var $t={},Ri;function Tm(){if(Ri)return $t;Ri=1;var e=gn();const t=c=>typeof c=="bigint"||Number.isInteger(c);function n(c,i,d,{intAsBigInt:h}){const u=c[0];if((u==="-"||u==="+")&&(i+=1),c=c.substring(i).replace(/_/g,""),h){switch(d){case 2:c=`0b${c}`;break;case 8:c=`0o${c}`;break;case 16:c=`0x${c}`;break}const f=BigInt(c);return u==="-"?BigInt(-1)*f:f}const p=parseInt(c,d);return u==="-"?-1*p:p}function o(c,i,d){const{value:h}=c;if(t(h)){const u=h.toString(i);return h<0?"-"+d+u.substr(1):d+u}return e.stringifyNumber(c)}const s={identify:t,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(c,i,d)=>n(c,2,2,d),stringify:c=>o(c,2,"0b")},r={identify:t,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(c,i,d)=>n(c,1,8,d),stringify:c=>o(c,8,"0")},a={identify:t,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(c,i,d)=>n(c,0,10,d),stringify:e.stringifyNumber},l={identify:t,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(c,i,d)=>n(c,2,16,d),stringify:c=>o(c,16,"0x")};return $t.int=a,$t.intBin=s,$t.intHex=l,$t.intOct=r,$t}var xn={},_i;function ld(){if(_i)return xn;_i=1;var e=B(),t=mt(),n=gt();class o extends n.YAMLMap{constructor(a){super(a),this.tag=o.tag}add(a){let l;e.isPair(a)?l=a:a&&typeof a=="object"&&"key"in a&&"value"in a&&a.value===null?l=new t.Pair(a.key,null):l=new t.Pair(a,null),n.findPair(this.items,l.key)||this.items.push(l)}get(a,l){const c=n.findPair(this.items,a);return!l&&e.isPair(c)?e.isScalar(c.key)?c.key.value:c.key:c}set(a,l){if(typeof l!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof l}`);const c=n.findPair(this.items,a);c&&!l?this.items.splice(this.items.indexOf(c),1):!c&&l&&this.items.push(new t.Pair(a))}toJSON(a,l){return super.toJSON(a,l,Set)}toString(a,l,c){if(!a)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},a,{allNullValues:!0}),l,c);throw new Error("Set items must all have null values")}static from(a,l,c){const{replacer:i}=c,d=new this(a);if(l&&Symbol.iterator in Object(l))for(let h of l)typeof i=="function"&&(h=i.call(l,h,h)),d.items.push(t.createPair(h,null,c));return d}}o.tag="tag:yaml.org,2002:set";const s={collection:"map",identify:r=>r instanceof Set,nodeClass:o,default:!1,tag:"tag:yaml.org,2002:set",createNode:(r,a,l)=>o.from(r,a,l),resolve(r,a){if(e.isMap(r)){if(r.hasAllNullValues(!0))return Object.assign(new o,r);a("Set items must all have null values")}else a("Expected a mapping for this tag");return r}};return xn.YAMLSet=o,xn.set=s,xn}var Yt={},Pi;function cd(){if(Pi)return Yt;Pi=1;var e=gn();function t(a,l){const c=a[0],i=c==="-"||c==="+"?a.substring(1):a,d=u=>l?BigInt(u):Number(u),h=i.replace(/_/g,"").split(":").reduce((u,p)=>u*d(60)+d(p),d(0));return c==="-"?d(-1)*h:h}function n(a){let{value:l}=a,c=u=>u;if(typeof l=="bigint")c=u=>BigInt(u);else if(isNaN(l)||!isFinite(l))return e.stringifyNumber(a);let i="";l<0&&(i="-",l*=c(-1));const d=c(60),h=[l%d];return l<60?h.unshift(0):(l=(l-h[0])/d,h.unshift(l%d),l>=60&&(l=(l-h[0])/d,h.unshift(l))),i+h.map(u=>String(u).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}const o={identify:a=>typeof a=="bigint"||Number.isInteger(a),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(a,l,{intAsBigInt:c})=>t(a,c),stringify:n},s={identify:a=>typeof a=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:a=>t(a,!1),stringify:n},r={identify:a=>a instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(a){const l=a.match(r.test);if(!l)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");const[,c,i,d,h,u,p]=l.map(Number),f=l[7]?Number((l[7]+"00").substr(1,3)):0;let m=Date.UTC(c,i-1,d,h||0,u||0,p||0,f);const g=l[8];if(g&&g!=="Z"){let y=t(g,!1);Math.abs(y)<30&&(y*=60),m-=6e4*y}return new Date(m)},stringify:({value:a})=>a?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};return Yt.floatTime=s,Yt.intTime=o,Yt.timestamp=r,Yt}var Li;function Om(){if(Li)return ps;Li=1;var e=fn(),t=Gr(),n=mn(),o=go(),s=ad(),r=jm(),a=Am(),l=Tm(),c=Yr(),i=id(),d=Hr(),h=ld(),u=cd();const p=[e.map,n.seq,o.string,t.nullTag,r.trueTag,r.falseTag,l.intBin,l.intOct,l.int,l.intHex,a.floatNaN,a.floatExp,a.float,s.binary,c.merge,i.omap,d.pairs,h.set,u.intTime,u.floatTime,u.timestamp];return ps.schema=p,ps}var Ii;function Em(){if(Ii)return En;Ii=1;var e=fn(),t=Gr(),n=mn(),o=go(),s=od(),r=sd(),a=rd(),l=$m(),c=Sm(),i=ad(),d=Yr(),h=id(),u=Hr(),p=Om(),f=ld(),m=cd();const g=new Map([["core",l.schema],["failsafe",[e.map,n.seq,o.string]],["json",c.schema],["yaml11",p.schema],["yaml-1.1",p.schema]]),y={binary:i.binary,bool:s.boolTag,float:r.float,floatExp:r.floatExp,floatNaN:r.floatNaN,floatTime:m.floatTime,int:a.int,intHex:a.intHex,intOct:a.intOct,intTime:m.intTime,map:e.map,merge:d.merge,null:t.nullTag,omap:h.omap,pairs:u.pairs,seq:n.seq,set:f.set,timestamp:m.timestamp},b={"tag:yaml.org,2002:binary":i.binary,"tag:yaml.org,2002:merge":d.merge,"tag:yaml.org,2002:omap":h.omap,"tag:yaml.org,2002:pairs":u.pairs,"tag:yaml.org,2002:set":f.set,"tag:yaml.org,2002:timestamp":m.timestamp};function k(w,v,S){const j=g.get(v);if(j&&!w)return S&&!j.includes(d.merge)?j.concat(d.merge):j.slice();let O=j;if(!O)if(Array.isArray(w))O=[];else{const A=Array.from(g.keys()).filter(E=>E!=="yaml11").map(E=>JSON.stringify(E)).join(", ");throw new Error(`Unknown schema "${v}"; use one of ${A} or define customTags array`)}if(Array.isArray(w))for(const A of w)O=O.concat(A);else typeof w=="function"&&(O=w(O.slice()));return S&&(O=O.concat(d.merge)),O.reduce((A,E)=>{const x=typeof E=="string"?y[E]:E;if(!x){const L=JSON.stringify(E),I=Object.keys(y).map(M=>JSON.stringify(M)).join(", ");throw new Error(`Unknown custom tag ${L}; use one of ${I}`)}return A.includes(x)||A.push(x),A},[])}return En.coreKnownTags=b,En.getTags=k,En}var Mi;function ud(){if(Mi)return ts;Mi=1;var e=B(),t=fn(),n=mn(),o=go(),s=Em();const r=(l,c)=>l.key<c.key?-1:l.key>c.key?1:0;let a=class dd{constructor({compat:c,customTags:i,merge:d,resolveKnownTags:h,schema:u,sortMapEntries:p,toStringDefaults:f}){this.compat=Array.isArray(c)?s.getTags(c,"compat"):c?s.getTags(null,c):null,this.name=typeof u=="string"&&u||"core",this.knownTags=h?s.coreKnownTags:{},this.tags=s.getTags(i,this.name,d),this.toStringOptions=f??null,Object.defineProperty(this,e.MAP,{value:t.map}),Object.defineProperty(this,e.SCALAR,{value:o.string}),Object.defineProperty(this,e.SEQ,{value:n.seq}),this.sortMapEntries=typeof p=="function"?p:p===!0?r:null}clone(){const c=Object.create(dd.prototype,Object.getOwnPropertyDescriptors(this));return c.tags=this.tags.slice(),c}};return ts.Schema=a,ts}var fs={},qi;function Cm(){if(qi)return fs;qi=1;var e=B(),t=mo(),n=po();function o(s,r){const a=[];let l=r.directives===!0;if(r.directives!==!1&&s.directives){const u=s.directives.toString(s);u?(a.push(u),l=!0):s.directives.docStart&&(l=!0)}l&&a.push("---");const c=t.createStringifyContext(s,r),{commentString:i}=c.options;if(s.commentBefore){a.length!==1&&a.unshift("");const u=i(s.commentBefore);a.unshift(n.indentComment(u,""))}let d=!1,h=null;if(s.contents){if(e.isNode(s.contents)){if(s.contents.spaceBefore&&l&&a.push(""),s.contents.commentBefore){const f=i(s.contents.commentBefore);a.push(n.indentComment(f,""))}c.forceBlockIndent=!!s.comment,h=s.contents.comment}const u=h?void 0:()=>d=!0;let p=t.stringify(s.contents,c,()=>h=null,u);h&&(p+=n.lineComment(p,"",i(h))),(p[0]==="|"||p[0]===">")&&a[a.length-1]==="---"?a[a.length-1]=`--- ${p}`:a.push(p)}else a.push(t.stringify(s.contents,c));if(s.directives?.docEnd)if(s.comment){const u=i(s.comment);u.includes(`
|
|
70
70
|
`)?(a.push("..."),a.push(n.indentComment(u,""))):a.push(`... ${u}`)}else a.push("...");else{let u=s.comment;u&&d&&(u=u.replace(/^\n+/,"")),u&&((!d||h)&&a[a.length-1]!==""&&a.push(""),a.push(n.indentComment(i(u),"")))}return a.join(`
|
|
71
71
|
`)+`
|
|
72
|
-
`}return fs.stringifyDocument=o,fs}var
|
|
72
|
+
`}return fs.stringifyDocument=o,fs}var Fi;function yo(){if(Fi)return Yo;Fi=1;var e=uo(),t=Kr(),n=B(),o=mt(),s=ft(),r=ud(),a=Cm(),l=zr(),c=Xc(),i=ho(),d=Zc();let h=class hd{constructor(f,m,g){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,n.NODE_TYPE,{value:n.DOC});let y=null;typeof m=="function"||Array.isArray(m)?y=m:g===void 0&&m&&(g=m,m=void 0);const b=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},g);this.options=b;let{version:k}=b;g?._directives?(this.directives=g._directives.atDocument(),this.directives.yaml.explicit&&(k=this.directives.yaml.version)):this.directives=new d.Directives({version:k}),this.setSchema(k,g),this.contents=f===void 0?null:this.createNode(f,y,g)}clone(){const f=Object.create(hd.prototype,{[n.NODE_TYPE]:{value:n.DOC}});return f.commentBefore=this.commentBefore,f.comment=this.comment,f.errors=this.errors.slice(),f.warnings=this.warnings.slice(),f.options=Object.assign({},this.options),this.directives&&(f.directives=this.directives.clone()),f.schema=this.schema.clone(),f.contents=n.isNode(this.contents)?this.contents.clone(f.schema):this.contents,this.range&&(f.range=this.range.slice()),f}add(f){u(this.contents)&&this.contents.add(f)}addIn(f,m){u(this.contents)&&this.contents.addIn(f,m)}createAlias(f,m){if(!f.anchor){const g=l.anchorNames(this);f.anchor=!m||g.has(m)?l.findNewAnchor(m||"a",g):m}return new e.Alias(f.anchor)}createNode(f,m,g){let y;if(typeof m=="function")f=m.call({"":f},"",f),y=m;else if(Array.isArray(m)){const I=ne=>typeof ne=="number"||ne instanceof String||ne instanceof Number,M=m.filter(I).map(String);M.length>0&&(m=m.concat(M)),y=m}else g===void 0&&m&&(g=m,m=void 0);const{aliasDuplicateObjects:b,anchorPrefix:k,flow:w,keepUndefined:v,onTagObj:S,tag:j}=g??{},{onAnchor:O,setAnchors:A,sourceObjects:E}=l.createNodeAnchors(this,k||"a"),x={aliasDuplicateObjects:b??!0,keepUndefined:v??!1,onAnchor:O,onTagObj:S,replacer:y,schema:this.schema,sourceObjects:E},L=i.createNode(f,j,x);return w&&n.isCollection(L)&&(L.flow=!0),A(),L}createPair(f,m,g={}){const y=this.createNode(f,null,g),b=this.createNode(m,null,g);return new o.Pair(y,b)}delete(f){return u(this.contents)?this.contents.delete(f):!1}deleteIn(f){return t.isEmptyPath(f)?this.contents==null?!1:(this.contents=null,!0):u(this.contents)?this.contents.deleteIn(f):!1}get(f,m){return n.isCollection(this.contents)?this.contents.get(f,m):void 0}getIn(f,m){return t.isEmptyPath(f)?!m&&n.isScalar(this.contents)?this.contents.value:this.contents:n.isCollection(this.contents)?this.contents.getIn(f,m):void 0}has(f){return n.isCollection(this.contents)?this.contents.has(f):!1}hasIn(f){return t.isEmptyPath(f)?this.contents!==void 0:n.isCollection(this.contents)?this.contents.hasIn(f):!1}set(f,m){this.contents==null?this.contents=t.collectionFromPath(this.schema,[f],m):u(this.contents)&&this.contents.set(f,m)}setIn(f,m){t.isEmptyPath(f)?this.contents=m:this.contents==null?this.contents=t.collectionFromPath(this.schema,Array.from(f),m):u(this.contents)&&this.contents.setIn(f,m)}setSchema(f,m={}){typeof f=="number"&&(f=String(f));let g;switch(f){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new d.Directives({version:"1.1"}),g={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=f:this.directives=new d.Directives({version:f}),g={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,g=null;break;default:{const y=JSON.stringify(f);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${y}`)}}if(m.schema instanceof Object)this.schema=m.schema;else if(g)this.schema=new r.Schema(Object.assign(g,m));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:f,jsonArg:m,mapAsMap:g,maxAliasCount:y,onAnchor:b,reviver:k}={}){const w={anchors:new Map,doc:this,keep:!f,mapAsMap:g===!0,mapKeyWarned:!1,maxAliasCount:typeof y=="number"?y:100},v=s.toJS(this.contents,m??"",w);if(typeof b=="function")for(const{count:S,res:j}of w.anchors.values())b(j,S);return typeof k=="function"?c.applyReviver(k,{"":v},"",v):v}toJSON(f,m){return this.toJS({json:!0,jsonArg:f,mapAsMap:!1,onAnchor:m})}toString(f={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in f&&(!Number.isInteger(f.indent)||Number(f.indent)<=0)){const m=JSON.stringify(f.indent);throw new Error(`"indent" option must be a positive integer, not ${m}`)}return a.stringifyDocument(this,f)}};function u(p){if(n.isCollection(p))return!0;throw new Error("Expected a YAML collection as document contents")}return Yo.Document=h,Yo}var St={},Di;function bo(){if(Di)return St;Di=1;class e extends Error{constructor(r,a,l,c){super(),this.name=r,this.code=l,this.message=c,this.pos=a}}class t extends e{constructor(r,a,l){super("YAMLParseError",r,a,l)}}class n extends e{constructor(r,a,l){super("YAMLWarning",r,a,l)}}const o=(s,r)=>a=>{if(a.pos[0]===-1)return;a.linePos=a.pos.map(h=>r.linePos(h));const{line:l,col:c}=a.linePos[0];a.message+=` at line ${l}, column ${c}`;let i=c-1,d=s.substring(r.lineStarts[l-1],r.lineStarts[l]).replace(/[\n\r]+$/,"");if(i>=60&&d.length>80){const h=Math.min(i-39,d.length-79);d="…"+d.substring(h),i-=h-1}if(d.length>80&&(d=d.substring(0,79)+"…"),l>1&&/^ *$/.test(d.substring(0,i))){let h=s.substring(r.lineStarts[l-2],r.lineStarts[l-1]);h.length>80&&(h=h.substring(0,79)+`…
|
|
73
73
|
`),d=h+d}if(/[^ ]/.test(d)){let h=1;const u=a.linePos[1];u?.line===l&&u.col>c&&(h=Math.max(1,Math.min(u.col-c,80-i)));const p=" ".repeat(i)+"^".repeat(h);a.message+=`:
|
|
74
74
|
|
|
75
75
|
${d}
|
|
76
76
|
${p}
|
|
77
|
-
`}};return St.YAMLError=e,St.YAMLParseError=t,St.YAMLWarning=n,St.prettifyError=o,St}var ms={},
|
|
78
|
-
`))return!0;if(t.end){for(const n of t.end)if(n.type==="newline")return!0}return!1;case"flow-collection":for(const n of t.items){for(const o of n.start)if(o.type==="newline")return!0;if(n.sep){for(const o of n.sep)if(o.type==="newline")return!0}if(e(n.key)||e(n.value))return!0}return!1;default:return!0}}return ws.containsNewline=e,ws}var ks={},
|
|
79
|
-
`+j.comment:m.comment=j.comment);continue}(j.newlineAfterProp||o.containsNewline(w))&&u(w??k[k.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else j.found?.indent!==h.indent&&u(g,"BAD_INDENT",a);d.atKey=!0;const A=j.end,E=w?c(d,w,j,u):i(d,A,k,null,j,u);d.schema.compat&&s.flowIndentCheck(h.indent,w,u),d.atKey=!1,r.mapIncludes(d,m.items,E)&&u(A,"DUPLICATE_KEY","Map keys must be unique");const x=n.resolveProps(v??[],{indicator:"map-value-ind",next:S,offset:E.range[2],onError:u,parentIndent:h.indent,startOnNewline:!w||w.type==="block-scalar"});if(g=x.end,x.found){O&&(S?.type==="block-map"&&!x.hasNewline&&u(g,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),d.options.strict&&j.start<x.found.offset-1024&&u(E.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));const
|
|
80
|
-
`+x.comment:E.comment=x.comment);const
|
|
81
|
-
`+N.comment:w.comment=N.comment),S=N.end;continue}!y&&p.options.strict&&a.containsNewline(
|
|
82
|
-
`+Z:U.comment=Z,N.comment=N.comment.substring(Z.length+1)}}if(!y&&!ne&&!N.found){const Z=q?h(p,q,N,m):u(p,N.end,ne,null,N,m);w.items.push(Z),S=Z.range[2],i(q)&&m(Z.range,"BLOCK_IN_FLOW",c)}else{p.atKey=!0;const Z=N.end,U=
|
|
83
|
-
`+oe.comment:U.comment=oe.comment);const T=new t.Pair(U,$);if(p.options.keepSourceTokens&&(T.srcToken=
|
|
84
|
-
`+x.comment:w.comment=x.comment),w.range=[f.offset,E,x.offset]}else w.range=[f.offset,E,E];return w}return Ss.resolveFlowCollection=d,Ss}var
|
|
77
|
+
`}};return St.YAMLError=e,St.YAMLParseError=t,St.YAMLWarning=n,St.prettifyError=o,St}var ms={},Rn={},gs={},ys={},bs={},Bi;function wo(){if(Bi)return bs;Bi=1;function e(t,{flow:n,indicator:o,next:s,offset:r,onError:a,parentIndent:l,startOnNewline:c}){let i=!1,d=c,h=c,u="",p="",f=!1,m=!1,g=null,y=null,b=null,k=null,w=null,v=null,S=null;for(const A of t)switch(m&&(A.type!=="space"&&A.type!=="newline"&&A.type!=="comma"&&a(A.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m=!1),g&&(d&&A.type!=="comment"&&A.type!=="newline"&&a(g,"TAB_AS_INDENT","Tabs are not allowed as indentation"),g=null),A.type){case"space":!n&&(o!=="doc-start"||s?.type!=="flow-collection")&&A.source.includes(" ")&&(g=A),h=!0;break;case"comment":{h||a(A,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const E=A.source.substring(1)||" ";u?u+=p+E:u=E,p="",d=!1;break}case"newline":d?u?u+=A.source:(!v||o!=="seq-item-ind")&&(i=!0):p+=A.source,d=!0,f=!0,(y||b)&&(k=A),h=!0;break;case"anchor":y&&a(A,"MULTIPLE_ANCHORS","A node can have at most one anchor"),A.source.endsWith(":")&&a(A.offset+A.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),y=A,S??(S=A.offset),d=!1,h=!1,m=!0;break;case"tag":{b&&a(A,"MULTIPLE_TAGS","A node can have at most one tag"),b=A,S??(S=A.offset),d=!1,h=!1,m=!0;break}case o:(y||b)&&a(A,"BAD_PROP_ORDER",`Anchors and tags must be after the ${A.source} indicator`),v&&a(A,"UNEXPECTED_TOKEN",`Unexpected ${A.source} in ${n??"collection"}`),v=A,d=o==="seq-item-ind"||o==="explicit-key-ind",h=!1;break;case"comma":if(n){w&&a(A,"UNEXPECTED_TOKEN",`Unexpected , in ${n}`),w=A,d=!1,h=!1;break}default:a(A,"UNEXPECTED_TOKEN",`Unexpected ${A.type} token`),d=!1,h=!1}const j=t[t.length-1],O=j?j.offset+j.source.length:r;return m&&s&&s.type!=="space"&&s.type!=="newline"&&s.type!=="comma"&&(s.type!=="scalar"||s.source!=="")&&a(s.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),g&&(d&&g.indent<=l||s?.type==="block-map"||s?.type==="block-seq")&&a(g,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:w,found:v,spaceBefore:i,comment:u,hasNewline:f,anchor:y,tag:b,newlineAfterProp:k,end:O,start:S??O}}return bs.resolveProps=e,bs}var ws={},Ui;function Vr(){if(Ui)return ws;Ui=1;function e(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
|
|
78
|
+
`))return!0;if(t.end){for(const n of t.end)if(n.type==="newline")return!0}return!1;case"flow-collection":for(const n of t.items){for(const o of n.start)if(o.type==="newline")return!0;if(n.sep){for(const o of n.sep)if(o.type==="newline")return!0}if(e(n.key)||e(n.value))return!0}return!1;default:return!0}}return ws.containsNewline=e,ws}var ks={},zi;function pd(){if(zi)return ks;zi=1;var e=Vr();function t(n,o,s){if(o?.type==="flow-collection"){const r=o.end[0];r.indent===n&&(r.source==="]"||r.source==="}")&&e.containsNewline(o)&&s(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}return ks.flowIndentCheck=t,ks}var vs={},Wi;function fd(){if(Wi)return vs;Wi=1;var e=B();function t(n,o,s){const{uniqueKeys:r}=n.options;if(r===!1)return!1;const a=typeof r=="function"?r:(l,c)=>l===c||e.isScalar(l)&&e.isScalar(c)&&l.value===c.value;return o.some(l=>a(l.key,s))}return vs.mapIncludes=t,vs}var Ki;function Nm(){if(Ki)return ys;Ki=1;var e=mt(),t=gt(),n=wo(),o=Vr(),s=pd(),r=fd();const a="All mapping items must start at the same column";function l({composeNode:c,composeEmptyNode:i},d,h,u,p){const f=p?.nodeClass??t.YAMLMap,m=new f(d.schema);d.atRoot&&(d.atRoot=!1);let g=h.offset,y=null;for(const b of h.items){const{start:k,key:w,sep:v,value:S}=b,j=n.resolveProps(k,{indicator:"explicit-key-ind",next:w??v?.[0],offset:g,onError:u,parentIndent:h.indent,startOnNewline:!0}),O=!j.found;if(O){if(w&&(w.type==="block-seq"?u(g,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in w&&w.indent!==h.indent&&u(g,"BAD_INDENT",a)),!j.anchor&&!j.tag&&!v){y=j.end,j.comment&&(m.comment?m.comment+=`
|
|
79
|
+
`+j.comment:m.comment=j.comment);continue}(j.newlineAfterProp||o.containsNewline(w))&&u(w??k[k.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else j.found?.indent!==h.indent&&u(g,"BAD_INDENT",a);d.atKey=!0;const A=j.end,E=w?c(d,w,j,u):i(d,A,k,null,j,u);d.schema.compat&&s.flowIndentCheck(h.indent,w,u),d.atKey=!1,r.mapIncludes(d,m.items,E)&&u(A,"DUPLICATE_KEY","Map keys must be unique");const x=n.resolveProps(v??[],{indicator:"map-value-ind",next:S,offset:E.range[2],onError:u,parentIndent:h.indent,startOnNewline:!w||w.type==="block-scalar"});if(g=x.end,x.found){O&&(S?.type==="block-map"&&!x.hasNewline&&u(g,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),d.options.strict&&j.start<x.found.offset-1024&&u(E.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));const L=S?c(d,S,x,u):i(d,g,v,null,x,u);d.schema.compat&&s.flowIndentCheck(h.indent,S,u),g=L.range[2];const I=new e.Pair(E,L);d.options.keepSourceTokens&&(I.srcToken=b),m.items.push(I)}else{O&&u(E.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),x.comment&&(E.comment?E.comment+=`
|
|
80
|
+
`+x.comment:E.comment=x.comment);const L=new e.Pair(E);d.options.keepSourceTokens&&(L.srcToken=b),m.items.push(L)}}return y&&y<g&&u(y,"IMPOSSIBLE","Map comment with trailing content"),m.range=[h.offset,g,y??g],m}return ys.resolveBlockMap=l,ys}var $s={},Yi;function xm(){if(Yi)return $s;Yi=1;var e=yt(),t=wo(),n=pd();function o({composeNode:s,composeEmptyNode:r},a,l,c,i){const d=i?.nodeClass??e.YAMLSeq,h=new d(a.schema);a.atRoot&&(a.atRoot=!1),a.atKey&&(a.atKey=!1);let u=l.offset,p=null;for(const{start:f,value:m}of l.items){const g=t.resolveProps(f,{indicator:"seq-item-ind",next:m,offset:u,onError:c,parentIndent:l.indent,startOnNewline:!0});if(!g.found)if(g.anchor||g.tag||m)m?.type==="block-seq"?c(g.end,"BAD_INDENT","All sequence items must start at the same column"):c(u,"MISSING_CHAR","Sequence item without - indicator");else{p=g.end,g.comment&&(h.comment=g.comment);continue}const y=m?s(a,m,g,c):r(a,g.end,f,null,g,c);a.schema.compat&&n.flowIndentCheck(l.indent,m,c),u=y.range[2],h.items.push(y)}return h.range=[l.offset,u,p??u],h}return $s.resolveBlockSeq=o,$s}var Ss={},js={},Gi;function yn(){if(Gi)return js;Gi=1;function e(t,n,o,s){let r="";if(t){let a=!1,l="";for(const c of t){const{source:i,type:d}=c;switch(d){case"space":a=!0;break;case"comment":{o&&!a&&s(c,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const h=i.substring(1)||" ";r?r+=l+h:r=h,l="";break}case"newline":r&&(l+=i),a=!0;break;default:s(c,"UNEXPECTED_TOKEN",`Unexpected ${d} at node end`)}n+=i.length}}return{comment:r,offset:n}}return js.resolveEnd=e,js}var Hi;function Rm(){if(Hi)return Ss;Hi=1;var e=B(),t=mt(),n=gt(),o=yt(),s=yn(),r=wo(),a=Vr(),l=fd();const c="Block collections are not allowed within flow collections",i=h=>h&&(h.type==="block-map"||h.type==="block-seq");function d({composeNode:h,composeEmptyNode:u},p,f,m,g){const y=f.start.source==="{",b=y?"flow map":"flow sequence",k=g?.nodeClass??(y?n.YAMLMap:o.YAMLSeq),w=new k(p.schema);w.flow=!0;const v=p.atRoot;v&&(p.atRoot=!1),p.atKey&&(p.atKey=!1);let S=f.offset+f.start.source.length;for(let x=0;x<f.items.length;++x){const L=f.items[x],{start:I,key:M,sep:ne,value:q}=L,N=r.resolveProps(I,{flow:b,indicator:"explicit-key-ind",next:M??ne?.[0],offset:S,onError:m,parentIndent:f.indent,startOnNewline:!1});if(!N.found){if(!N.anchor&&!N.tag&&!ne&&!q){x===0&&N.comma?m(N.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${b}`):x<f.items.length-1&&m(N.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${b}`),N.comment&&(w.comment?w.comment+=`
|
|
81
|
+
`+N.comment:w.comment=N.comment),S=N.end;continue}!y&&p.options.strict&&a.containsNewline(M)&&m(M,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(x===0)N.comma&&m(N.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${b}`);else if(N.comma||m(N.start,"MISSING_CHAR",`Missing , between ${b} items`),N.comment){let Z="";e:for(const U of I)switch(U.type){case"comma":case"space":break;case"comment":Z=U.source.substring(1);break e;default:break e}if(Z){let U=w.items[w.items.length-1];e.isPair(U)&&(U=U.value??U.key),U.comment?U.comment+=`
|
|
82
|
+
`+Z:U.comment=Z,N.comment=N.comment.substring(Z.length+1)}}if(!y&&!ne&&!N.found){const Z=q?h(p,q,N,m):u(p,N.end,ne,null,N,m);w.items.push(Z),S=Z.range[2],i(q)&&m(Z.range,"BLOCK_IN_FLOW",c)}else{p.atKey=!0;const Z=N.end,U=M?h(p,M,N,m):u(p,Z,I,null,N,m);i(M)&&m(U.range,"BLOCK_IN_FLOW",c),p.atKey=!1;const oe=r.resolveProps(ne??[],{flow:b,indicator:"map-value-ind",next:q,offset:U.range[2],onError:m,parentIndent:f.indent,startOnNewline:!1});if(oe.found){if(!y&&!N.found&&p.options.strict){if(ne)for(const C of ne){if(C===oe.found)break;if(C.type==="newline"){m(C,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}N.start<oe.found.offset-1024&&m(oe.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else q&&("source"in q&&q.source?.[0]===":"?m(q,"MISSING_CHAR",`Missing space after : in ${b}`):m(oe.start,"MISSING_CHAR",`Missing , or : between ${b} items`));const $=q?h(p,q,oe,m):oe.found?u(p,oe.end,ne,null,oe,m):null;$?i(q)&&m($.range,"BLOCK_IN_FLOW",c):oe.comment&&(U.comment?U.comment+=`
|
|
83
|
+
`+oe.comment:U.comment=oe.comment);const T=new t.Pair(U,$);if(p.options.keepSourceTokens&&(T.srcToken=L),y){const C=w;l.mapIncludes(p,C.items,U)&&m(Z,"DUPLICATE_KEY","Map keys must be unique"),C.items.push(T)}else{const C=new n.YAMLMap(p.schema);C.flow=!0,C.items.push(T);const R=($??U).range;C.range=[U.range[0],R[1],R[2]],w.items.push(C)}S=$?$.range[2]:oe.end}}const j=y?"}":"]",[O,...A]=f.end;let E=S;if(O?.source===j)E=O.offset+O.source.length;else{const x=b[0].toUpperCase()+b.substring(1),L=v?`${x} must end with a ${j}`:`${x} in block collection must be sufficiently indented and end with a ${j}`;m(S,v?"MISSING_CHAR":"BAD_INDENT",L),O&&O.source.length!==1&&A.unshift(O)}if(A.length>0){const x=s.resolveEnd(A,E,p.options.strict,m);x.comment&&(w.comment?w.comment+=`
|
|
84
|
+
`+x.comment:w.comment=x.comment),w.range=[f.offset,E,x.offset]}else w.range=[f.offset,E,E];return w}return Ss.resolveFlowCollection=d,Ss}var Vi;function _m(){if(Vi)return gs;Vi=1;var e=B(),t=ce(),n=gt(),o=yt(),s=Nm(),r=xm(),a=Rm();function l(i,d,h,u,p,f){const m=h.type==="block-map"?s.resolveBlockMap(i,d,h,u,f):h.type==="block-seq"?r.resolveBlockSeq(i,d,h,u,f):a.resolveFlowCollection(i,d,h,u,f),g=m.constructor;return p==="!"||p===g.tagName?(m.tag=g.tagName,m):(p&&(m.tag=p),m)}function c(i,d,h,u,p){const f=u.tag,m=f?d.directives.tagName(f.source,v=>p(f,"TAG_RESOLVE_FAILED",v)):null;if(h.type==="block-seq"){const{anchor:v,newlineAfterProp:S}=u,j=v&&f?v.offset>f.offset?v:f:v??f;j&&(!S||S.offset<j.offset)&&p(j,"MISSING_CHAR","Missing newline after block sequence props")}const g=h.type==="block-map"?"map":h.type==="block-seq"?"seq":h.start.source==="{"?"map":"seq";if(!f||!m||m==="!"||m===n.YAMLMap.tagName&&g==="map"||m===o.YAMLSeq.tagName&&g==="seq")return l(i,d,h,p,m);let y=d.schema.tags.find(v=>v.tag===m&&v.collection===g);if(!y){const v=d.schema.knownTags[m];if(v?.collection===g)d.schema.tags.push(Object.assign({},v,{default:!1})),y=v;else return v?p(f,"BAD_COLLECTION_TYPE",`${v.tag} used for ${g} collection, but expects ${v.collection??"scalar"}`,!0):p(f,"TAG_RESOLVE_FAILED",`Unresolved tag: ${m}`,!0),l(i,d,h,p,m)}const b=l(i,d,h,p,m,y),k=y.resolve?.(b,v=>p(f,"TAG_RESOLVE_FAILED",v),d.options)??b,w=e.isNode(k)?k:new t.Scalar(k);return w.range=b.range,w.tag=m,y?.format&&(w.format=y.format),w}return gs.composeCollection=c,gs}var As={},Ts={},Ji;function md(){if(Ji)return Ts;Ji=1;var e=ce();function t(s,r,a){const l=r.offset,c=n(r,s.options.strict,a);if(!c)return{value:"",type:null,comment:"",range:[l,l,l]};const i=c.mode===">"?e.Scalar.BLOCK_FOLDED:e.Scalar.BLOCK_LITERAL,d=r.source?o(r.source):[];let h=d.length;for(let k=d.length-1;k>=0;--k){const w=d[k][1];if(w===""||w==="\r")h=k;else break}if(h===0){const k=c.chomp==="+"&&d.length>0?`
|
|
85
85
|
`.repeat(Math.max(1,d.length-1)):"";let w=l+c.length;return r.source&&(w+=r.source.length),{value:k,type:i,comment:c.comment,range:[l,w,w]}}let u=r.indent+c.indent,p=r.offset+c.length,f=0;for(let k=0;k<h;++k){const[w,v]=d[k];if(v===""||v==="\r")c.indent===0&&w.length>u&&(u=w.length);else{w.length<u&&a(p+w.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),c.indent===0&&(u=w.length),f=k,u===0&&!s.atRoot&&a(p,"BAD_INDENT","Block scalar values in collections must be indented");break}p+=w.length+v.length+1}for(let k=d.length-1;k>=h;--k)d[k][0].length>u&&(h=k+1);let m="",g="",y=!1;for(let k=0;k<f;++k)m+=d[k][0].slice(u)+`
|
|
86
86
|
`;for(let k=f;k<h;++k){let[w,v]=d[k];p+=w.length+v.length+1;const S=v[v.length-1]==="\r";if(S&&(v=v.slice(0,-1)),v&&w.length<u){const O=`Block scalar lines must not be less indented than their ${c.indent?"explicit indentation indicator":"first line"}`;a(p-v.length-(S?2:1),"BAD_INDENT",O),w=""}i===e.Scalar.BLOCK_LITERAL?(m+=g+w.slice(u)+v,g=`
|
|
87
87
|
`):w.length>u||v[0]===" "?(g===" "?g=`
|
|
@@ -96,7 +96,7 @@ ${p}
|
|
|
96
96
|
`+d[k][0].slice(u);m[m.length-1]!==`
|
|
97
97
|
`&&(m+=`
|
|
98
98
|
`);break;default:m+=`
|
|
99
|
-
`}const b=l+c.length+r.source.length;return{value:m,type:i,comment:c.comment,range:[l,b,b]}}function n({offset:s,props:r},a,l){if(r[0].type!=="block-scalar-header")return l(r[0],"IMPOSSIBLE","Block scalar header not found"),null;const{source:c}=r[0],i=c[0];let d=0,h="",u=-1;for(let g=1;g<c.length;++g){const y=c[g];if(!h&&(y==="-"||y==="+"))h=y;else{const b=Number(y);!d&&b?d=b:u===-1&&(u=s+g)}}u!==-1&&l(u,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${c}`);let p=!1,f="",m=c.length;for(let g=1;g<r.length;++g){const y=r[g];switch(y.type){case"space":p=!0;case"newline":m+=y.source.length;break;case"comment":a&&!p&&l(y,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),m+=y.source.length,f=y.source.substring(1);break;case"error":l(y,"UNEXPECTED_TOKEN",y.message),m+=y.source.length;break;default:{const b=`Unexpected token in block scalar header: ${y.type}`;l(y,"UNEXPECTED_TOKEN",b);const k=y.source;k&&typeof k=="string"&&(m+=k.length)}}}return{mode:i,indent:d,chomp:h,comment:f,length:m}}function o(s){const r=s.split(/\n( *)/),a=r[0],l=a.match(/^( *)/),i=[l?.[1]?[l[1],a.slice(l[1].length)]:["",a]];for(let d=1;d<r.length;d+=2)i.push([r[d],r[d+1]]);return i}return Ts.resolveBlockScalar=t,Ts}var Os={},
|
|
99
|
+
`}const b=l+c.length+r.source.length;return{value:m,type:i,comment:c.comment,range:[l,b,b]}}function n({offset:s,props:r},a,l){if(r[0].type!=="block-scalar-header")return l(r[0],"IMPOSSIBLE","Block scalar header not found"),null;const{source:c}=r[0],i=c[0];let d=0,h="",u=-1;for(let g=1;g<c.length;++g){const y=c[g];if(!h&&(y==="-"||y==="+"))h=y;else{const b=Number(y);!d&&b?d=b:u===-1&&(u=s+g)}}u!==-1&&l(u,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${c}`);let p=!1,f="",m=c.length;for(let g=1;g<r.length;++g){const y=r[g];switch(y.type){case"space":p=!0;case"newline":m+=y.source.length;break;case"comment":a&&!p&&l(y,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),m+=y.source.length,f=y.source.substring(1);break;case"error":l(y,"UNEXPECTED_TOKEN",y.message),m+=y.source.length;break;default:{const b=`Unexpected token in block scalar header: ${y.type}`;l(y,"UNEXPECTED_TOKEN",b);const k=y.source;k&&typeof k=="string"&&(m+=k.length)}}}return{mode:i,indent:d,chomp:h,comment:f,length:m}}function o(s){const r=s.split(/\n( *)/),a=r[0],l=a.match(/^( *)/),i=[l?.[1]?[l[1],a.slice(l[1].length)]:["",a]];for(let d=1;d<r.length;d+=2)i.push([r[d],r[d+1]]);return i}return Ts.resolveBlockScalar=t,Ts}var Os={},Zi;function gd(){if(Zi)return Os;Zi=1;var e=ce(),t=yn();function n(d,h,u){const{offset:p,type:f,source:m,end:g}=d;let y,b;const k=(S,j,O)=>u(p+S,j,O);switch(f){case"scalar":y=e.Scalar.PLAIN,b=o(m,k);break;case"single-quoted-scalar":y=e.Scalar.QUOTE_SINGLE,b=s(m,k);break;case"double-quoted-scalar":y=e.Scalar.QUOTE_DOUBLE,b=a(m,k);break;default:return u(d,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${f}`),{value:"",type:null,comment:"",range:[p,p+m.length,p+m.length]}}const w=p+m.length,v=t.resolveEnd(g,w,h,u);return{value:b,type:y,comment:v.comment,range:[p,w,v.offset]}}function o(d,h){let u="";switch(d[0]){case" ":u="a tab character";break;case",":u="flow indicator character ,";break;case"%":u="directive indicator character %";break;case"|":case">":{u=`block scalar indicator ${d[0]}`;break}case"@":case"`":{u=`reserved character ${d[0]}`;break}}return u&&h(0,"BAD_SCALAR_START",`Plain value cannot start with ${u}`),r(d)}function s(d,h){return(d[d.length-1]!=="'"||d.length===1)&&h(d.length,"MISSING_CHAR","Missing closing 'quote"),r(d.slice(1,-1)).replace(/''/g,"'")}function r(d){let h,u;try{h=new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
100
100
|
`,"sy"),u=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
101
101
|
`,"sy")}catch{h=/(.*?)[ \t]*\r?\n/sy,u=/[ \t]*(.*?)[ \t]*\r?\n/sy}let p=h.exec(d);if(!p)return d;let f=p[1],m=" ",g=h.lastIndex;for(u.lastIndex=g;p=u.exec(d);)p[1]===""?m===`
|
|
102
102
|
`?f+=m:m=`
|
|
@@ -111,14 +111,14 @@ ${p}
|
|
|
111
111
|
`);)p===`
|
|
112
112
|
`&&(u+=`
|
|
113
113
|
`),h+=1,p=d[h+1];return u||(u=" "),{fold:u,offset:h}}const c={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
114
|
-
`,r:"\r",t:" ",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function i(d,h,u,p){const f=d.substr(h,u),g=f.length===u&&/^[0-9a-fA-F]+$/.test(f)?parseInt(f,16):NaN;try{return String.fromCodePoint(g)}catch{const y=d.substr(h-2,u+2);return p(h-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${y}`),y}}return Os.resolveFlowScalar=n,Os}var
|
|
114
|
+
`,r:"\r",t:" ",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function i(d,h,u,p){const f=d.substr(h,u),g=f.length===u&&/^[0-9a-fA-F]+$/.test(f)?parseInt(f,16):NaN;try{return String.fromCodePoint(g)}catch{const y=d.substr(h-2,u+2);return p(h-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${y}`),y}}return Os.resolveFlowScalar=n,Os}var Xi;function Pm(){if(Xi)return As;Xi=1;var e=B(),t=ce(),n=md(),o=gd();function s(l,c,i,d){const{value:h,type:u,comment:p,range:f}=c.type==="block-scalar"?n.resolveBlockScalar(l,c,d):o.resolveFlowScalar(c,l.options.strict,d),m=i?l.directives.tagName(i.source,b=>d(i,"TAG_RESOLVE_FAILED",b)):null;let g;l.options.stringKeys&&l.atKey?g=l.schema[e.SCALAR]:m?g=r(l.schema,h,m,i,d):c.type==="scalar"?g=a(l,h,c,d):g=l.schema[e.SCALAR];let y;try{const b=g.resolve(h,k=>d(i??c,"TAG_RESOLVE_FAILED",k),l.options);y=e.isScalar(b)?b:new t.Scalar(b)}catch(b){const k=b instanceof Error?b.message:String(b);d(i??c,"TAG_RESOLVE_FAILED",k),y=new t.Scalar(h)}return y.range=f,y.source=h,u&&(y.type=u),m&&(y.tag=m),g.format&&(y.format=g.format),p&&(y.comment=p),y}function r(l,c,i,d,h){if(i==="!")return l[e.SCALAR];const u=[];for(const f of l.tags)if(!f.collection&&f.tag===i)if(f.default&&f.test)u.push(f);else return f;for(const f of u)if(f.test?.test(c))return f;const p=l.knownTags[i];return p&&!p.collection?(l.tags.push(Object.assign({},p,{default:!1,test:void 0})),p):(h(d,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,i!=="tag:yaml.org,2002:str"),l[e.SCALAR])}function a({atKey:l,directives:c,schema:i},d,h,u){const p=i.tags.find(f=>(f.default===!0||l&&f.default==="key")&&f.test?.test(d))||i[e.SCALAR];if(i.compat){const f=i.compat.find(m=>m.default&&m.test?.test(d))??i[e.SCALAR];if(p.tag!==f.tag){const m=c.tagString(p.tag),g=c.tagString(f.tag),y=`Value may be parsed as either ${m} or ${g}`;u(h,"TAG_RESOLVE_FAILED",y,!0)}}return p}return As.composeScalar=s,As}var Es={},Qi;function Lm(){if(Qi)return Es;Qi=1;function e(t,n,o){if(n){o??(o=n.length);for(let s=o-1;s>=0;--s){let r=n[s];switch(r.type){case"space":case"comment":case"newline":t-=r.source.length;continue}for(r=n[++s];r?.type==="space";)t+=r.source.length,r=n[++s];break}}return t}return Es.emptyScalarPosition=e,Es}var el;function Im(){if(el)return Rn;el=1;var e=uo(),t=B(),n=_m(),o=Pm(),s=yn(),r=Lm();const a={composeNode:l,composeEmptyNode:c};function l(d,h,u,p){const f=d.atKey,{spaceBefore:m,comment:g,anchor:y,tag:b}=u;let k,w=!0;switch(h.type){case"alias":k=i(d,h,p),(y||b)&&p(h,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":k=o.composeScalar(d,h,b,p),y&&(k.anchor=y.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{k=n.composeCollection(a,d,h,u,p),y&&(k.anchor=y.source.substring(1))}catch(v){const S=v instanceof Error?v.message:String(v);p(h,"RESOURCE_EXHAUSTION",S)}break;default:{const v=h.type==="error"?h.message:`Unsupported token (type: ${h.type})`;p(h,"UNEXPECTED_TOKEN",v),w=!1}}return k??(k=c(d,h.offset,void 0,null,u,p)),y&&k.anchor===""&&p(y,"BAD_ALIAS","Anchor cannot be an empty string"),f&&d.options.stringKeys&&(!t.isScalar(k)||typeof k.value!="string"||k.tag&&k.tag!=="tag:yaml.org,2002:str")&&p(b??h,"NON_STRING_KEY","With stringKeys, all keys must be strings"),m&&(k.spaceBefore=!0),g&&(h.type==="scalar"&&h.source===""?k.comment=g:k.commentBefore=g),d.options.keepSourceTokens&&w&&(k.srcToken=h),k}function c(d,h,u,p,{spaceBefore:f,comment:m,anchor:g,tag:y,end:b},k){const w={type:"scalar",offset:r.emptyScalarPosition(h,u,p),indent:-1,source:""},v=o.composeScalar(d,w,y,k);return g&&(v.anchor=g.source.substring(1),v.anchor===""&&k(g,"BAD_ALIAS","Anchor cannot be an empty string")),f&&(v.spaceBefore=!0),m&&(v.comment=m,v.range[2]=b),v}function i({options:d},{offset:h,source:u,end:p},f){const m=new e.Alias(u.substring(1));m.source===""&&f(h,"BAD_ALIAS","Alias cannot be an empty string"),m.source.endsWith(":")&&f(h+u.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);const g=h+u.length,y=s.resolveEnd(p,g,d.strict,f);return m.range=[h,g,y.offset],y.comment&&(m.comment=y.comment),m}return Rn.composeEmptyNode=c,Rn.composeNode=l,Rn}var tl;function Mm(){if(tl)return ms;tl=1;var e=yo(),t=Im(),n=yn(),o=wo();function s(r,a,{offset:l,start:c,value:i,end:d},h){const u=Object.assign({_directives:a},r),p=new e.Document(void 0,u),f={atKey:!1,atRoot:!0,directives:p.directives,options:p.options,schema:p.schema},m=o.resolveProps(c,{indicator:"doc-start",next:i??d?.[0],offset:l,onError:h,parentIndent:0,startOnNewline:!0});m.found&&(p.directives.docStart=!0,i&&(i.type==="block-map"||i.type==="block-seq")&&!m.hasNewline&&h(m.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),p.contents=i?t.composeNode(f,i,m,h):t.composeEmptyNode(f,m.end,c,null,m,h);const g=p.contents.range[2],y=n.resolveEnd(d,g,!1,h);return y.comment&&(p.comment=y.comment),p.range=[l,g,y.offset],p}return ms.composeDoc=s,ms}var nl;function yd(){if(nl)return Wo;nl=1;var e=Er,t=Zc(),n=yo(),o=bo(),s=B(),r=Mm(),a=yn();function l(d){if(typeof d=="number")return[d,d+1];if(Array.isArray(d))return d.length===2?d:[d[0],d[1]];const{offset:h,source:u}=d;return[h,h+(typeof u=="string"?u.length:1)]}function c(d){let h="",u=!1,p=!1;for(let f=0;f<d.length;++f){const m=d[f];switch(m[0]){case"#":h+=(h===""?"":p?`
|
|
115
115
|
|
|
116
116
|
`:`
|
|
117
117
|
`)+(m.substring(1)||" "),u=!0,p=!1;break;case"%":d[f+1]?.[0]!=="#"&&(f+=1),u=!1;break;default:u||(p=!0),u=!1}}return{comment:h,afterEmptyLine:p}}class i{constructor(h={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(u,p,f,m)=>{const g=l(u);m?this.warnings.push(new o.YAMLWarning(g,p,f)):this.errors.push(new o.YAMLParseError(g,p,f))},this.directives=new t.Directives({version:h.version||"1.2"}),this.options=h}decorate(h,u){const{comment:p,afterEmptyLine:f}=c(this.prelude);if(p){const m=h.contents;if(u)h.comment=h.comment?`${h.comment}
|
|
118
118
|
${p}`:p;else if(f||h.directives.docStart||!m)h.commentBefore=p;else if(s.isCollection(m)&&!m.flow&&m.items.length>0){let g=m.items[0];s.isPair(g)&&(g=g.key);const y=g.commentBefore;g.commentBefore=y?`${p}
|
|
119
119
|
${y}`:p}else{const g=m.commentBefore;m.commentBefore=g?`${p}
|
|
120
120
|
${g}`:p}}if(u){for(let m=0;m<this.errors.length;++m)h.errors.push(this.errors[m]);for(let m=0;m<this.warnings.length;++m)h.warnings.push(this.warnings[m])}else h.errors=this.errors,h.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:c(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(h,u=!1,p=-1){for(const f of h)yield*this.next(f);yield*this.end(u,p)}*next(h){switch(e.env.LOG_STREAM&&console.dir(h,{depth:null}),h.type){case"directive":this.directives.add(h.source,(u,p,f)=>{const m=l(h);m[0]+=u,this.onError(m,"BAD_DIRECTIVE",p,f)}),this.prelude.push(h.source),this.atDirectives=!0;break;case"document":{const u=r.composeDoc(this.options,this.directives,h,this.onError);this.atDirectives&&!u.directives.docStart&&this.onError(h,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(u,!1),this.doc&&(yield this.doc),this.doc=u,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(h.source);break;case"error":{const u=h.source?`${h.message}: ${JSON.stringify(h.source)}`:h.message,p=new o.YAMLParseError(l(h),"UNEXPECTED_TOKEN",u);this.atDirectives||!this.doc?this.errors.push(p):this.doc.errors.push(p);break}case"doc-end":{if(!this.doc){const p="Unexpected doc-end without preceding document";this.errors.push(new o.YAMLParseError(l(h),"UNEXPECTED_TOKEN",p));break}this.doc.directives.docEnd=!0;const u=a.resolveEnd(h.end,h.offset+h.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),u.comment){const p=this.doc.comment;this.doc.comment=p?`${p}
|
|
121
|
-
${u.comment}`:u.comment}this.doc.range[2]=u.offset;break}default:this.errors.push(new o.YAMLParseError(l(h),"UNEXPECTED_TOKEN",`Unsupported token ${h.type}`))}}*end(h=!1,u=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(h){const p=Object.assign({_directives:this.directives},this.options),f=new n.Document(void 0,p);this.atDirectives&&this.onError(u,"MISSING_CHAR","Missing directives-end indicator line"),f.range=[0,u,u],this.decorate(f,!1),yield f}}}return Wo.Composer=i,Wo}var
|
|
121
|
+
${u.comment}`:u.comment}this.doc.range[2]=u.offset;break}default:this.errors.push(new o.YAMLParseError(l(h),"UNEXPECTED_TOKEN",`Unsupported token ${h.type}`))}}*end(h=!1,u=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(h){const p=Object.assign({_directives:this.directives},this.options),f=new n.Document(void 0,p);this.atDirectives&&this.onError(u,"MISSING_CHAR","Missing directives-end indicator line"),f.range=[0,u,u],this.decorate(f,!1),yield f}}}return Wo.Composer=i,Wo}var be={},Gt={},ol;function qm(){if(ol)return Gt;ol=1;var e=md(),t=gd(),n=bo(),o=fo();function s(d,h=!0,u){if(d){const p=(f,m,g)=>{const y=typeof f=="number"?f:Array.isArray(f)?f[0]:f.offset;if(u)u(y,m,g);else throw new n.YAMLParseError([y,y+1],m,g)};switch(d.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return t.resolveFlowScalar(d,h,p);case"block-scalar":return e.resolveBlockScalar({options:{strict:h}},d,p)}}return null}function r(d,h){const{implicitKey:u=!1,indent:p,inFlow:f=!1,offset:m=-1,type:g="PLAIN"}=h,y=o.stringifyString({type:g,value:d},{implicitKey:u,indent:p>0?" ".repeat(p):"",inFlow:f,options:{blockQuote:!0,lineWidth:-1}}),b=h.end??[{type:"newline",offset:-1,indent:p,source:`
|
|
122
122
|
`}];switch(y[0]){case"|":case">":{const k=y.indexOf(`
|
|
123
123
|
`),w=y.substring(0,k),v=y.substring(k+1)+`
|
|
124
124
|
`,S=[{type:"block-scalar-header",offset:m,indent:p,source:w}];return c(S,b)||S.push({type:"newline",offset:-1,indent:p,source:`
|
|
@@ -126,9 +126,9 @@ ${u.comment}`:u.comment}this.doc.range[2]=u.offset;break}default:this.errors.pus
|
|
|
126
126
|
`),p=h.substring(0,u),f=h.substring(u+1)+`
|
|
127
127
|
`;if(d.type==="block-scalar"){const m=d.props[0];if(m.type!=="block-scalar-header")throw new Error("Invalid block scalar header");m.source=p,d.source=f}else{const{offset:m}=d,g="indent"in d?d.indent:-1,y=[{type:"block-scalar-header",offset:m,indent:g,source:p}];c(y,"end"in d?d.end:void 0)||y.push({type:"newline",offset:-1,indent:g,source:`
|
|
128
128
|
`});for(const b of Object.keys(d))b!=="type"&&b!=="offset"&&delete d[b];Object.assign(d,{type:"block-scalar",indent:g,props:y,source:f})}}function c(d,h){if(h)for(const u of h)switch(u.type){case"space":case"comment":d.push(u);break;case"newline":return d.push(u),!0}return!1}function i(d,h,u){switch(d.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":d.type=u,d.source=h;break;case"block-scalar":{const p=d.props.slice(1);let f=h.length;d.props[0].type==="block-scalar-header"&&(f-=d.props[0].source.length);for(const m of p)m.offset+=f;delete d.props,Object.assign(d,{type:u,source:h,end:p});break}case"block-map":case"block-seq":{const f={type:"newline",offset:d.offset+h.length,indent:d.indent,source:`
|
|
129
|
-
`};delete d.items,Object.assign(d,{type:u,source:h,end:[f]});break}default:{const p="indent"in d?d.indent:-1,f="end"in d&&Array.isArray(d.end)?d.end.filter(m=>m.type==="space"||m.type==="comment"||m.type==="newline"):[];for(const m of Object.keys(d))m!=="type"&&m!=="offset"&&delete d[m];Object.assign(d,{type:u,indent:p,source:h,end:f})}}}return Gt.createScalarToken=r,Gt.resolveAsScalar=s,Gt.setScalarValue=a,Gt}var Cs={},
|
|
129
|
+
`};delete d.items,Object.assign(d,{type:u,source:h,end:[f]});break}default:{const p="indent"in d?d.indent:-1,f="end"in d&&Array.isArray(d.end)?d.end.filter(m=>m.type==="space"||m.type==="comment"||m.type==="newline"):[];for(const m of Object.keys(d))m!=="type"&&m!=="offset"&&delete d[m];Object.assign(d,{type:u,indent:p,source:h,end:f})}}}return Gt.createScalarToken=r,Gt.resolveAsScalar=s,Gt.setScalarValue=a,Gt}var Cs={},sl;function Fm(){if(sl)return Cs;sl=1;const e=o=>"type"in o?t(o):n(o);function t(o){switch(o.type){case"block-scalar":{let s="";for(const r of o.props)s+=t(r);return s+o.source}case"block-map":case"block-seq":{let s="";for(const r of o.items)s+=n(r);return s}case"flow-collection":{let s=o.start.source;for(const r of o.items)s+=n(r);for(const r of o.end)s+=r.source;return s}case"document":{let s=n(o);if(o.end)for(const r of o.end)s+=r.source;return s}default:{let s=o.source;if("end"in o&&o.end)for(const r of o.end)s+=r.source;return s}}}function n({start:o,key:s,sep:r,value:a}){let l="";for(const c of o)l+=c.source;if(s&&(l+=t(s)),r)for(const c of r)l+=c.source;return a&&(l+=t(a)),l}return Cs.stringify=e,Cs}var Ns={},rl;function Dm(){if(rl)return Ns;rl=1;const e=Symbol("break visit"),t=Symbol("skip children"),n=Symbol("remove item");function o(r,a){"type"in r&&r.type==="document"&&(r={start:r.start,value:r.value}),s(Object.freeze([]),r,a)}o.BREAK=e,o.SKIP=t,o.REMOVE=n,o.itemAtPath=(r,a)=>{let l=r;for(const[c,i]of a){const d=l?.[c];if(d&&"items"in d)l=d.items[i];else return}return l},o.parentCollection=(r,a)=>{const l=o.itemAtPath(r,a.slice(0,-1)),c=a[a.length-1][0],i=l?.[c];if(i&&"items"in i)return i;throw new Error("Parent collection not found")};function s(r,a,l){let c=l(a,r);if(typeof c=="symbol")return c;for(const i of["key","value"]){const d=a[i];if(d&&"items"in d){for(let h=0;h<d.items.length;++h){const u=s(Object.freeze(r.concat([[i,h]])),d.items[h],l);if(typeof u=="number")h=u-1;else{if(u===e)return e;u===n&&(d.items.splice(h,1),h-=1)}}typeof c=="function"&&i==="key"&&(c=c(a,r))}}return typeof c=="function"?c(a,r):c}return Ns.visit=o,Ns}var al;function Jr(){if(al)return be;al=1;var e=qm(),t=Fm(),n=Dm();const o="\uFEFF",s="",r="",a="",l=h=>!!h&&"items"in h,c=h=>!!h&&(h.type==="scalar"||h.type==="single-quoted-scalar"||h.type==="double-quoted-scalar"||h.type==="block-scalar");function i(h){switch(h){case o:return"<BOM>";case s:return"<DOC>";case r:return"<FLOW_END>";case a:return"<SCALAR>";default:return JSON.stringify(h)}}function d(h){switch(h){case o:return"byte-order-mark";case s:return"doc-mode";case r:return"flow-error-end";case a:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
130
130
|
`:case`\r
|
|
131
|
-
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(h[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}return
|
|
131
|
+
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(h[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}return be.createScalarToken=e.createScalarToken,be.resolveAsScalar=e.resolveAsScalar,be.setScalarValue=e.setScalarValue,be.stringify=t.stringify,be.visit=n.visit,be.BOM=o,be.DOCUMENT=s,be.FLOW_END=r,be.SCALAR=a,be.isCollection=l,be.isScalar=c,be.prettyToken=i,be.tokenType=d,be}var xs={},il;function bd(){if(il)return xs;il=1;var e=Jr();function t(c){switch(c){case void 0:case" ":case`
|
|
132
132
|
`:case"\r":case" ":return!0;default:return!1}}const n=new Set("0123456789ABCDEFabcdef"),o=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),s=new Set(",[]{}"),r=new Set(` ,[]{}
|
|
133
133
|
\r `),a=c=>!c||r.has(c);class l{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(i,d=!1){if(i){if(typeof i!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+i:i,this.lineEndPos=null}this.atEnd=!d;let h=this.next??"stream";for(;h&&(d||this.hasChars(1));)h=yield*this.parseNext(h)}atLineEnd(){let i=this.pos,d=this.buffer[i];for(;d===" "||d===" ";)d=this.buffer[++i];return!d||d==="#"||d===`
|
|
134
134
|
`?!0:d==="\r"?this.buffer[i+1]===`
|
|
@@ -147,14 +147,14 @@ ${u.comment}`:u.comment}this.doc.range[2]=u.offset;break}default:this.errors.pus
|
|
|
147
147
|
`,p=this.buffer[h+1]):d=h),p==="#"||i&&s.has(p))break;if(u===`
|
|
148
148
|
`){const f=this.continueScalar(h+1);if(f===-1)break;h=Math.max(h,f-2)}}else{if(i&&s.has(u))break;d=h}return!u&&!this.atEnd?this.setNext("plain-scalar"):(yield e.SCALAR,yield*this.pushToIndex(d+1,!0),i?"flow":"doc")}*pushCount(i){return i>0?(yield this.buffer.substr(this.pos,i),this.pos+=i,i):0}*pushToIndex(i,d){const h=this.buffer.slice(this.pos,i);return h?(yield h,this.pos+=h.length,h.length):(d&&(yield""),0)}*pushIndicators(){let i=0;e:for(;;){switch(this.charAt(0)){case"!":i+=yield*this.pushTag(),i+=yield*this.pushSpaces(!0);continue e;case"&":i+=yield*this.pushUntil(a),i+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{const d=this.flowLevel>0,h=this.charAt(1);if(t(h)||d&&s.has(h)){d?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0);continue e}}}break e}return i}*pushTag(){if(this.charAt(1)==="<"){let i=this.pos+2,d=this.buffer[i];for(;!t(d)&&d!==">";)d=this.buffer[++i];return yield*this.pushToIndex(d===">"?i+1:i,!1)}else{let i=this.pos+1,d=this.buffer[i];for(;d;)if(o.has(d))d=this.buffer[++i];else if(d==="%"&&n.has(this.buffer[i+1])&&n.has(this.buffer[i+2]))d=this.buffer[i+=3];else break;return yield*this.pushToIndex(i,!1)}}*pushNewline(){const i=this.buffer[this.pos];return i===`
|
|
149
149
|
`?yield*this.pushCount(1):i==="\r"&&this.charAt(1)===`
|
|
150
|
-
`?yield*this.pushCount(2):0}*pushSpaces(i){let d=this.pos-1,h;do h=this.buffer[++d];while(h===" "||i&&h===" ");const u=d-this.pos;return u>0&&(yield this.buffer.substr(this.pos,u),this.pos=d),u}*pushUntil(i){let d=this.pos,h=this.buffer[d];for(;!i(h);)h=this.buffer[++d];return yield*this.pushToIndex(d,!1)}}return xs.Lexer=l,xs}var Rs={},
|
|
150
|
+
`?yield*this.pushCount(2):0}*pushSpaces(i){let d=this.pos-1,h;do h=this.buffer[++d];while(h===" "||i&&h===" ");const u=d-this.pos;return u>0&&(yield this.buffer.substr(this.pos,u),this.pos=d),u}*pushUntil(i){let d=this.pos,h=this.buffer[d];for(;!i(h);)h=this.buffer[++d];return yield*this.pushToIndex(d,!1)}}return xs.Lexer=l,xs}var Rs={},ll;function wd(){if(ll)return Rs;ll=1;class e{constructor(){this.lineStarts=[],this.addNewLine=n=>this.lineStarts.push(n),this.linePos=n=>{let o=0,s=this.lineStarts.length;for(;o<s;){const a=o+s>>1;this.lineStarts[a]<n?o=a+1:s=a}if(this.lineStarts[o]===n)return{line:o+1,col:1};if(o===0)return{line:0,col:n};const r=this.lineStarts[o-1];return{line:o,col:n-r+1}}}}return Rs.LineCounter=e,Rs}var _s={},cl;function kd(){if(cl)return _s;cl=1;var e=Er,t=Jr(),n=bd();function o(h,u){for(let p=0;p<h.length;++p)if(h[p].type===u)return!0;return!1}function s(h){for(let u=0;u<h.length;++u)switch(h[u].type){case"space":case"comment":case"newline":break;default:return u}return-1}function r(h){switch(h?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function a(h){switch(h.type){case"document":return h.start;case"block-map":{const u=h.items[h.items.length-1];return u.sep??u.start}case"block-seq":return h.items[h.items.length-1].start;default:return[]}}function l(h){if(h.length===0)return[];let u=h.length;e:for(;--u>=0;)switch(h[u].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;h[++u]?.type==="space";);return h.splice(u,h.length)}function c(h,u){if(u.length<1e5)Array.prototype.push.apply(h,u);else for(let p=0;p<u.length;++p)h.push(u[p])}function i(h){if(h.start.type==="flow-seq-start")for(const u of h.items)u.sep&&!u.value&&!o(u.start,"explicit-key-ind")&&!o(u.sep,"map-value-ind")&&(u.key&&(u.value=u.key),delete u.key,r(u.value)?u.value.end?c(u.value.end,u.sep):u.value.end=u.sep:c(u.start,u.sep),delete u.sep)}class d{constructor(u){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new n.Lexer,this.onNewLine=u}*parse(u,p=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(const f of this.lexer.lex(u,p))yield*this.next(f);p||(yield*this.end())}*next(u){if(this.source=u,e.env.LOG_TOKENS&&console.log("|",t.prettyToken(u)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=u.length;return}const p=t.tokenType(u);if(p)if(p==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=p,yield*this.step(),p){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+u.length);break;case"space":this.atNewLine&&u[0]===" "&&(this.indent+=u.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=u.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=u.length}else{const f=`Not a YAML token: ${u}`;yield*this.pop({type:"error",offset:this.offset,message:f,source:u}),this.offset+=u.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){const u=this.peek(1);if(this.type==="doc-end"&&u?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!u)return yield*this.stream();switch(u.type){case"document":return yield*this.document(u);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(u);case"block-scalar":return yield*this.blockScalar(u);case"block-map":return yield*this.blockMap(u);case"block-seq":return yield*this.blockSequence(u);case"flow-collection":return yield*this.flowCollection(u);case"doc-end":return yield*this.documentEnd(u)}yield*this.pop()}peek(u){return this.stack[this.stack.length-u]}*pop(u){const p=u??this.stack.pop();if(!p)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield p;else{const f=this.peek(1);switch(p.type==="block-scalar"?p.indent="indent"in f?f.indent:0:p.type==="flow-collection"&&f.type==="document"&&(p.indent=0),p.type==="flow-collection"&&i(p),f.type){case"document":f.value=p;break;case"block-scalar":f.props.push(p);break;case"block-map":{const m=f.items[f.items.length-1];if(m.value){f.items.push({start:[],key:p,sep:[]}),this.onKeyLine=!0;return}else if(m.sep)m.value=p;else{Object.assign(m,{key:p,sep:[]}),this.onKeyLine=!m.explicitKey;return}break}case"block-seq":{const m=f.items[f.items.length-1];m.value?f.items.push({start:[],value:p}):m.value=p;break}case"flow-collection":{const m=f.items[f.items.length-1];!m||m.value?f.items.push({start:[],key:p,sep:[]}):m.sep?m.value=p:Object.assign(m,{key:p,sep:[]});return}default:yield*this.pop(),yield*this.pop(p)}if((f.type==="document"||f.type==="block-map"||f.type==="block-seq")&&(p.type==="block-map"||p.type==="block-seq")){const m=p.items[p.items.length-1];m&&!m.sep&&!m.value&&m.start.length>0&&s(m.start)===-1&&(p.indent===0||m.start.every(g=>g.type!=="comment"||g.indent<p.indent))&&(f.type==="document"?f.end=m.start:f.items.push({start:m.start}),p.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{const u={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&u.start.push(this.sourceToken),this.stack.push(u);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(u){if(u.value)return yield*this.lineEnd(u);switch(this.type){case"doc-start":{s(u.start)!==-1?(yield*this.pop(),yield*this.step()):u.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":u.start.push(this.sourceToken);return}const p=this.startBlockValue(u);p?this.stack.push(p):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(u){if(this.type==="map-value-ind"){const p=a(this.peek(2)),f=l(p);let m;u.end?(m=u.end,m.push(this.sourceToken),delete u.end):m=[this.sourceToken];const g={type:"block-map",offset:u.offset,indent:u.indent,items:[{start:f,key:u,sep:m}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=g}else yield*this.lineEnd(u)}*blockScalar(u){switch(this.type){case"space":case"comment":case"newline":u.props.push(this.sourceToken);return;case"scalar":if(u.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let p=this.source.indexOf(`
|
|
151
151
|
`)+1;for(;p!==0;)this.onNewLine(this.offset+p),p=this.source.indexOf(`
|
|
152
152
|
`,p)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(u){const p=u.items[u.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,p.value){const f="end"in p.value?p.value.end:void 0;(Array.isArray(f)?f[f.length-1]:void 0)?.type==="comment"?f?.push(this.sourceToken):u.items.push({start:[this.sourceToken]})}else p.sep?p.sep.push(this.sourceToken):p.start.push(this.sourceToken);return;case"space":case"comment":if(p.value)u.items.push({start:[this.sourceToken]});else if(p.sep)p.sep.push(this.sourceToken);else{if(this.atIndentedComment(p.start,u.indent)){const m=u.items[u.items.length-2]?.value?.end;if(Array.isArray(m)){c(m,p.start),m.push(this.sourceToken),u.items.pop();return}}p.start.push(this.sourceToken)}return}if(this.indent>=u.indent){const f=!this.onKeyLine&&this.indent===u.indent,m=f&&(p.sep||p.explicitKey)&&this.type!=="seq-item-ind";let g=[];if(m&&p.sep&&!p.value){const y=[];for(let b=0;b<p.sep.length;++b){const k=p.sep[b];switch(k.type){case"newline":y.push(b);break;case"space":break;case"comment":k.indent>u.indent&&(y.length=0);break;default:y.length=0}}y.length>=2&&(g=p.sep.splice(y[1]))}switch(this.type){case"anchor":case"tag":m||p.value?(g.push(this.sourceToken),u.items.push({start:g}),this.onKeyLine=!0):p.sep?p.sep.push(this.sourceToken):p.start.push(this.sourceToken);return;case"explicit-key-ind":!p.sep&&!p.explicitKey?(p.start.push(this.sourceToken),p.explicitKey=!0):m||p.value?(g.push(this.sourceToken),u.items.push({start:g,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(p.explicitKey)if(p.sep)if(p.value)u.items.push({start:[],key:null,sep:[this.sourceToken]});else if(o(p.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:g,key:null,sep:[this.sourceToken]}]});else if(r(p.key)&&!o(p.sep,"newline")){const y=l(p.start),b=p.key,k=p.sep;k.push(this.sourceToken),delete p.key,delete p.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:y,key:b,sep:k}]})}else g.length>0?p.sep=p.sep.concat(g,this.sourceToken):p.sep.push(this.sourceToken);else if(o(p.start,"newline"))Object.assign(p,{key:null,sep:[this.sourceToken]});else{const y=l(p.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:y,key:null,sep:[this.sourceToken]}]})}else p.sep?p.value||m?u.items.push({start:g,key:null,sep:[this.sourceToken]}):o(p.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):p.sep.push(this.sourceToken):Object.assign(p,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const y=this.flowScalar(this.type);m||p.value?(u.items.push({start:g,key:y,sep:[]}),this.onKeyLine=!0):p.sep?this.stack.push(y):(Object.assign(p,{key:y,sep:[]}),this.onKeyLine=!0);return}default:{const y=this.startBlockValue(u);if(y){if(y.type==="block-seq"){if(!p.explicitKey&&p.sep&&!o(p.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else f&&u.items.push({start:g});this.stack.push(y);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(u){const p=u.items[u.items.length-1];switch(this.type){case"newline":if(p.value){const f="end"in p.value?p.value.end:void 0;(Array.isArray(f)?f[f.length-1]:void 0)?.type==="comment"?f?.push(this.sourceToken):u.items.push({start:[this.sourceToken]})}else p.start.push(this.sourceToken);return;case"space":case"comment":if(p.value)u.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(p.start,u.indent)){const m=u.items[u.items.length-2]?.value?.end;if(Array.isArray(m)){c(m,p.start),m.push(this.sourceToken),u.items.pop();return}}p.start.push(this.sourceToken)}return;case"anchor":case"tag":if(p.value||this.indent<=u.indent)break;p.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==u.indent)break;p.value||o(p.start,"seq-item-ind")?u.items.push({start:[this.sourceToken]}):p.start.push(this.sourceToken);return}if(this.indent>u.indent){const f=this.startBlockValue(u);if(f){this.stack.push(f);return}}yield*this.pop(),yield*this.step()}*flowCollection(u){const p=u.items[u.items.length-1];if(this.type==="flow-error-end"){let f;do yield*this.pop(),f=this.peek(1);while(f?.type==="flow-collection")}else if(u.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!p||p.sep?u.items.push({start:[this.sourceToken]}):p.start.push(this.sourceToken);return;case"map-value-ind":!p||p.value?u.items.push({start:[],key:null,sep:[this.sourceToken]}):p.sep?p.sep.push(this.sourceToken):Object.assign(p,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!p||p.value?u.items.push({start:[this.sourceToken]}):p.sep?p.sep.push(this.sourceToken):p.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const m=this.flowScalar(this.type);!p||p.value?u.items.push({start:[],key:m,sep:[]}):p.sep?this.stack.push(m):Object.assign(p,{key:m,sep:[]});return}case"flow-map-end":case"flow-seq-end":u.end.push(this.sourceToken);return}const f=this.startBlockValue(u);f?this.stack.push(f):(yield*this.pop(),yield*this.step())}else{const f=this.peek(2);if(f.type==="block-map"&&(this.type==="map-value-ind"&&f.indent===u.indent||this.type==="newline"&&!f.items[f.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&f.type!=="flow-collection"){const m=a(f),g=l(m);i(u);const y=u.end.splice(1,u.end.length);y.push(this.sourceToken);const b={type:"block-map",offset:u.offset,indent:u.indent,items:[{start:g,key:u,sep:y}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=b}else yield*this.lineEnd(u)}}flowScalar(u){if(this.onNewLine){let p=this.source.indexOf(`
|
|
153
153
|
`)+1;for(;p!==0;)this.onNewLine(this.offset+p),p=this.source.indexOf(`
|
|
154
|
-
`,p)+1}return{type:u,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(u){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;const p=a(u),f=l(p);return f.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:f,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;const p=a(u),f=l(p);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:f,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(u,p){return this.type!=="comment"||this.indent<=p?!1:u.every(f=>f.type==="newline"||f.type==="space")}*documentEnd(u){this.type!=="doc-mode"&&(u.end?u.end.push(this.sourceToken):u.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(u){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:u.end?u.end.push(this.sourceToken):u.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}}return _s.Parser=d,_s}var jt={},ll;function Mm(){if(ll)return jt;ll=1;var e=pd(),t=yo(),n=bo(),o=Vc(),s=B(),r=md(),a=gd();function l(u){const p=u.prettyErrors!==!1;return{lineCounter:u.lineCounter||p&&new r.LineCounter||null,prettyErrors:p}}function c(u,p={}){const{lineCounter:f,prettyErrors:m}=l(p),g=new a.Parser(f?.addNewLine),y=new e.Composer(p),b=Array.from(y.compose(g.parse(u)));if(m&&f)for(const k of b)k.errors.forEach(n.prettifyError(u,f)),k.warnings.forEach(n.prettifyError(u,f));return b.length>0?b:Object.assign([],{empty:!0},y.streamInfo())}function i(u,p={}){const{lineCounter:f,prettyErrors:m}=l(p),g=new a.Parser(f?.addNewLine),y=new e.Composer(p);let b=null;for(const k of y.compose(g.parse(u),!0,u.length))if(!b)b=k;else if(b.options.logLevel!=="silent"){b.errors.push(new n.YAMLParseError(k.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return m&&f&&(b.errors.forEach(n.prettifyError(u,f)),b.warnings.forEach(n.prettifyError(u,f))),b}function d(u,p,f){let m;typeof p=="function"?m=p:f===void 0&&p&&typeof p=="object"&&(f=p);const g=i(u,f);if(!g)return null;if(g.warnings.forEach(y=>o.warn(g.options.logLevel,y)),g.errors.length>0){if(g.options.logLevel!=="silent")throw g.errors[0];g.errors=[]}return g.toJS(Object.assign({reviver:m},f))}function h(u,p,f){let m=null;if(typeof p=="function"||Array.isArray(p)?m=p:f===void 0&&p&&(f=p),typeof f=="string"&&(f=f.length),typeof f=="number"){const g=Math.round(f);f=g<1?void 0:g>8?{indent:8}:{indent:g}}if(u===void 0){const{keepUndefined:g}=f??p??{};if(!g)return}return s.isDocument(u)&&!m?u.toString(f):new t.Document(u,m,f).toString(f)}return jt.parse=d,jt.parseAllDocuments=c,jt.parseDocument=i,jt.stringify=h,jt}var cl;function qm(){if(cl)return W;cl=1;var e=pd(),t=yo(),n=id(),o=bo(),s=uo(),r=B(),a=mt(),l=ce(),c=gt(),i=yt(),d=Jr(),h=fd(),u=md(),p=gd(),f=Mm(),m=co();return W.Composer=e.Composer,W.Document=t.Document,W.Schema=n.Schema,W.YAMLError=o.YAMLError,W.YAMLParseError=o.YAMLParseError,W.YAMLWarning=o.YAMLWarning,W.Alias=s.Alias,W.isAlias=r.isAlias,W.isCollection=r.isCollection,W.isDocument=r.isDocument,W.isMap=r.isMap,W.isNode=r.isNode,W.isPair=r.isPair,W.isScalar=r.isScalar,W.isSeq=r.isSeq,W.Pair=a.Pair,W.Scalar=l.Scalar,W.YAMLMap=c.YAMLMap,W.YAMLSeq=i.YAMLSeq,W.CST=d,W.Lexer=h.Lexer,W.LineCounter=u.LineCounter,W.Parser=p.Parser,W.parse=f.parse,W.parseAllDocuments=f.parseAllDocuments,W.parseDocument=f.parseDocument,W.stringify=f.stringify,W.visit=m.visit,W.visitAsync=m.visitAsync,W}var Ge=qm();const Fm=5*1024*1024,Dm=new Set([".js",".mjs",".css",".json",".svg",".png",".jpg",".webp",".woff2",".md"]),dl=["component","page"],ul=["filter","display","chart","relation"],Bm=["value","dateRange","selection","set"],Um=["query","act","ask","navigate"],hl=["string","number","integer","boolean","object","array"],zm=new Set(["type","properties","required","items","enum","title","description","default","minimum","maximum","minItems","maxItems","maxLength","x-workshop"]),pl=["field","fields","variable","objectType","relationPath","actionType"],Wm=new Set(["widget","fieldTypes","maxHops","tab","showIf"]),fl=["data","display","link"],hr=["string","number","boolean","date","datetime","object"],ml={"zh-CN":{label:"{key} 须是对象,至少提供 zh-CN",required:"{key} 必填",size:"{key} 须是 { w: 1–12, h: ≥1 } 的整数",list:"{key} 只能是 {allowed} 的列表",object:"{at} 须是对象",unsupported:"{at} 不支持 {key}",oneOf:"{at} 只能是 {allowed}",typeOrEnum:"{at} 须有 type 或 enum",nonEmptyList:"{at} 须是非空列表",requiredNames:"{at} 只能列出 properties 中的配置项",manifestObject:"manifest.json 须是 JSON 对象",type:"type 须是 x-<前缀>.<名称>:前缀为小写字母、数字与连字符,名称为字母与数字",version:"version 须是 主.次.修订",workshopApi:"workshopApi 目前只能是 1",element:"element 须是含连字符的小写自定义元素名",description:"description 必填:写清展示什么、点了会怎样",data:"data 须是 { source: true|false, fields }",dataFields:"data.fields 须是 any,或 { role, type } 列表(type 为 {types})",boolean:"{key} 须是 true 或 false",network:"network 须是来源列表,如 https://risk.example.com(不带路径)",unreadable:"读不到 manifest.json:{message}",tooLarge:"包内文件共 {total} 字节,超过 5 MB",fileType:"不允许的文件类型:{name}",noEntry:"入口 {entry} 不存在",noElement:"入口中没有定义自定义元素 {element}",bigEntry:"入口超过 300 KB:首屏不需要的部分建议拆成分块",remoteScript:"{name} 从外部地址加载脚本:依赖须全部打进包里",syntax:"{name} 第 {line} 行有语法错误,浏览器加载不了:{message}",syntaxOldNode:"{name} 第 {line} 行在本机 Node {node} 下解析不了:{message}。Node 24 以前的版本不认识部分新语法,上传时以 Workshop 的检查为准;用 Node 24 及以上校验才能确定",evalUsed:"{name} 用了 eval 或 new Function:内容安全策略下会被拒绝",noReadme:"没有 README.md:每个组件都应附说明(本体契约、扩展点、场景配方)",noPreview:"没有 preview.json:组件库预览与本地开发都需要示例数据",and:"、"},"en-US":{label:"{key} must be an object with at least zh-CN",required:"{key} is required",size:"{key} must be whole numbers { w: 1–12, h: ≥1 }",list:"{key} must be a list of {allowed}",object:"{at} must be an object",unsupported:"{at} does not support {key}",oneOf:"{at} must be one of {allowed}",typeOrEnum:"{at} needs type or enum",nonEmptyList:"{at} must be a non-empty list",requiredNames:"{at} may only list items of properties",manifestObject:"manifest.json must be a JSON object",type:"type must be x-<prefix>.<name>: the prefix lowercase letters, digits and hyphens, the name letters and digits",version:"version must be major.minor.patch",workshopApi:"workshopApi can only be 1 for now",element:"element must be a lowercase custom element name with a hyphen",description:"description is required: say what it shows and what a click does",data:"data must be { source: true|false, fields }",dataFields:"data.fields must be any, or a list of { role, type } (type one of {types})",boolean:"{key} must be true or false",network:"network must be a list of origins, such as https://risk.example.com (no path)",unreadable:"Cannot read manifest.json: {message}",tooLarge:"The package's files take {total} bytes, over 5 MB",fileType:"File type not allowed: {name}",noEntry:"The entry {entry} does not exist",noElement:"The entry does not define the custom element {element}",bigEntry:"The entry is over 300 KB: split what the first screen does not need into chunks",remoteScript:"{name} loads a script from an outside address: bundle every dependency into the package",syntax:"{name} has a syntax error at line {line}, so the browser cannot load it: {message}",syntaxOldNode:"{name} does not parse at line {line} under this Node {node}: {message}. Node before 24 does not know some newer syntax, and the upload check decides; validate with Node 24 or later to be sure",evalUsed:"{name} uses eval or new Function, which the content security policy refuses",noReadme:"No README.md: every component should come with a guide (ontology contract, extension points, recipes)",noPreview:"No preview.json: the component library's preview and local development both need sample data",and:", "}};function Zr(e){const t=ml[e]??ml["zh-CN"],n=(o,s)=>rc(t[o],s);return n.list=o=>o.join(t.and),n}function yn(e){const t=[],n=o=>{for(const s of nn(o).sort()){if(s.startsWith(".")||s==="node_modules")continue;const r=G(o,s),a=vu(r);if(a.isDirectory())n(r);else{if(ec(s).toLowerCase()===".zip")continue;t.push({path:r,name:tc(e,r).split(bu).join("/"),size:a.size})}}};return n(e),t}const De=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Et=e=>typeof e=="string"&&e.trim()!=="";function Km(e,t,n,o){(!De(e)||!Et(e["zh-CN"]))&&n.push(o("label",{key:t}))}function gl(e,t,n,o,s){if(e===void 0){o&&n.push(s("required",{key:t}));return}(!(De(e)&&[e.w,e.h].every(a=>Number.isInteger(a)&&a>0))||e.w>12)&&n.push(s("size",{key:t}))}function pr(e,t,n,o,s){e!==void 0&&(!Array.isArray(e)||!e.every(r=>n.includes(r)))&&o.push(s("list",{key:t,allowed:s.list(n)}))}function fr(e,t="configSchema",n="zh-CN"){const o=Zr(n),s=[];if(!De(e))return[o("object",{at:t})];for(const a of Object.keys(e))zm.has(a)||s.push(o("unsupported",{at:t,key:a}));if(e.type!==void 0&&!hl.includes(e.type)&&s.push(o("oneOf",{at:`${t}.type`,allowed:o.list(hl)})),e.type===void 0&&e.enum===void 0&&t!=="configSchema"&&s.push(o("typeOrEnum",{at:t})),e.enum!==void 0&&(!Array.isArray(e.enum)||e.enum.length===0)&&s.push(o("nonEmptyList",{at:`${t}.enum`})),e.properties!==void 0)if(!De(e.properties))s.push(o("object",{at:`${t}.properties`}));else for(const[a,l]of Object.entries(e.properties))s.push(...fr(l,`${t}.properties.${a}`,n));if(e.required!==void 0){const a=De(e.properties)?Object.keys(e.properties):[];(!Array.isArray(e.required)||!e.required.every(l=>a.includes(l)))&&s.push(o("requiredNames",{at:`${t}.required`}))}e.items!==void 0&&s.push(...fr(e.items,`${t}.items`,n));const r=e["x-workshop"];if(r!==void 0)if(!De(r))s.push(o("object",{at:`${t}.x-workshop`}));else{for(const a of Object.keys(r))Wm.has(a)||s.push(o("unsupported",{at:`${t}.x-workshop`,key:a}));r.widget!==void 0&&!pl.includes(r.widget)&&s.push(o("oneOf",{at:`${t}.x-workshop.widget`,allowed:o.list(pl)})),r.tab!==void 0&&!fl.includes(r.tab)&&s.push(o("oneOf",{at:`${t}.x-workshop.tab`,allowed:o.list(fl)})),r.fieldTypes!==void 0&&pr(r.fieldTypes,`${t}.x-workshop.fieldTypes`,hr,s,o),r.showIf!==void 0&&!De(r.showIf)&&s.push(o("object",{at:`${t}.x-workshop.showIf`}))}return s}function yd(e,t="zh-CN"){const n=Zr(t),o=[];if(!De(e))return[n("manifestObject")];const s=e;if(/^x-[a-z0-9-]+\.[A-Za-z][A-Za-z0-9]*$/.test(s.type??"")||o.push(n("type")),dl.includes(s.kind)||o.push(n("oneOf",{at:"kind",allowed:n.list(dl)})),/^\d+\.\d+\.\d+$/.test(s.version??"")||o.push(n("version")),s.workshopApi!==1&&o.push(n("workshopApi")),/^[a-z][a-z0-9]*(-[a-z0-9]+)+$/.test(s.element??"")||o.push(n("element")),Et(s.entry)||o.push(n("required",{key:"entry"})),Km(s.label,"label",o,n),Et(s.description)||o.push(n("description")),s.kind!=="page"&&!ul.includes(s.category)&&o.push(n("oneOf",{at:"category",allowed:n.list(ul)})),o.push(...fr(s.configSchema,"configSchema",t)),!De(s.data)||typeof s.data.source!="boolean")o.push(n("data"));else if(s.data.fields!=="any"){const r=s.data.fields;Array.isArray(r)&&r.every(l=>De(l)&&Et(l.role)&&hr.includes(l.type))||o.push(n("dataFields",{types:n.list(hr)}))}return typeof s.follows!="boolean"&&o.push(n("boolean",{key:"follows"})),pr(s.emits,"emits",Bm,o,n),pr(s.capabilities,"capabilities",Um,o,n),s.describes!==void 0&&typeof s.describes!="boolean"&&o.push(n("boolean",{key:"describes"})),gl(s.defaultSize,"defaultSize",o,s.kind==="component",n),gl(s.minSize,"minSize",o,!1,n),s.network!==void 0&&(Array.isArray(s.network)&&s.network.every(a=>{try{const l=new URL(a);return["https:","http:","wss:"].includes(l.protocol)&&l.origin===a}catch{return!1}})||o.push(n("network"))),o}const Ym=24,Gm=[/^Private field '#[^']+' must be declared in an enclosing class$/,/^Identifier '[^']+' has already been declared$/,/^Unexpected end of input$/,/^Strict mode code may not include a with statement$/,/^Octal literals are not allowed in strict mode\.$/];function Hm(e){const t=pu(process.execPath,["--input-type=module","--check"],{input:e,encoding:"utf8"});if(t.status===0)return null;const n=`${t.stderr??""}${t.error?.message??""}`,o=Number(/^\[stdin\]:(\d+)/m.exec(n)?.[1]??0),s=/^\w*Error: (.+)$/m.exec(n)?.[1]??n.trim().split(`
|
|
155
|
-
`).at(-1);return{line:o,message:s}}function Vm(e,{language:t="zh-CN",nodeMajor:n=Number(process.versions.node.split(".")[0])}={}){const o=Zr(t),s=[],r=[];let a;try{a=JSON.parse(ct(G(e,"manifest.json"),"utf8"))}catch(h){return{ok:!1,errors:[o("unreadable",{message:h.message})],warnings:r,files:[]}}s.push(...yd(a,t));const l=yn(e),c=l.reduce((h,u)=>h+u.size,0);c>Fm&&s.push(o("tooLarge",{total:c}));for(const h of l)Dm.has(ec(h.name).toLowerCase())||s.push(o("fileType",{name:h.name}));const i=Et(a.entry)?yu.normalize(a.entry.replace(/^\.\//,"")):null,d=l.find(h=>h.name===i);if(Et(a.entry)&&!d&&s.push(o("noEntry",{entry:a.entry})),d){const h=ct(d.path,"utf8");a.element&&!h.includes(a.element)&&s.push(o("noElement",{element:a.element})),d.size>300*1024&&r.push(o("bigEntry"))}for(const h of l.filter(u=>/\.(m?js)$/.test(u.name))){const u=ct(h.path,"utf8"),p=Hm(u),f=p&&Gm.some(m=>m.test(p.message));p&&(n>=Ym||f)?s.push(o("syntax",{name:h.name,...p})):p&&r.push(o("syntaxOldNode",{name:h.name,node:process.versions.node,...p})),(/import\s*\(\s*["'`]https?:\/\//.test(u)||/from\s+["']https?:\/\//.test(u))&&s.push(o("remoteScript",{name:h.name})),/\beval\s*\(|new\s+Function\s*\(/.test(u)&&r.push(o("evalUsed",{name:h.name}))}return l.some(h=>h.name==="README.md")||r.push(o("noReadme")),a.data?.source&&!l.some(h=>h.name==="preview.json")&&r.push(o("noPreview")),{ok:s.length===0,errors:s,warnings:r,files:l,manifest:a}}const Jm=(()=>{const e=new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let o=0;o<8;o++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function bd(e){let t=4294967295;for(const n of e)t=Jm[(t^n)&255]^t>>>8;return(t^4294967295)>>>0}function Zm(e){const t=[],n=[];let o=0;const s=0,r=33;for(const{name:c,data:i}of e){const d=Buffer.from(c,"utf8"),h=Ou(i),u=h.length>=i.length,p=u?i:h,f=bd(i),m=Buffer.alloc(30);m.writeUInt32LE(67324752,0),m.writeUInt16LE(20,4),m.writeUInt16LE(2048,6),m.writeUInt16LE(u?0:8,8),m.writeUInt16LE(s,10),m.writeUInt16LE(r,12),m.writeUInt32LE(f,14),m.writeUInt32LE(p.length,18),m.writeUInt32LE(i.length,22),m.writeUInt16LE(d.length,26),m.writeUInt16LE(0,28),t.push(m,d,p);const g=Buffer.alloc(46);g.writeUInt32LE(33639248,0),g.writeUInt16LE(20,4),g.writeUInt16LE(20,6),g.writeUInt16LE(2048,8),g.writeUInt16LE(u?0:8,10),g.writeUInt16LE(s,12),g.writeUInt16LE(r,14),g.writeUInt32LE(f,16),g.writeUInt32LE(p.length,20),g.writeUInt32LE(i.length,24),g.writeUInt16LE(d.length,28),g.writeUInt32LE(o,42),n.push(g,d),o+=m.length+d.length+p.length}const a=n.reduce((c,i)=>c+i.length,0),l=Buffer.alloc(22);return l.writeUInt32LE(101010256,0),l.writeUInt16LE(e.length,8),l.writeUInt16LE(e.length,10),l.writeUInt32LE(a,12),l.writeUInt32LE(o,16),Buffer.concat([...t,...n,l])}const yl={"zh-CN":{notZip:"不是 zip 文件",directory:"zip 的目录损坏",damaged:"zip 中 {name} 损坏",method:"zip 中 {name} 的压缩方式不支持"},"en-US":{notZip:"Not a zip file",directory:"The zip's directory is damaged",damaged:"{name} in the zip is damaged",method:"{name} in the zip is compressed in a way not supported"}};function Xm(e,t="zh-CN"){const n=(c,i)=>rc((yl[t]??yl["zh-CN"])[c],i),o=Buffer.from(e.buffer,e.byteOffset,e.byteLength);let s=-1;for(let c=o.length-22;c>=Math.max(0,o.length-22-65535);c--)if(o.readUInt32LE(c)===101010256){s=c;break}if(s<0)throw new Error(n("notZip"));const r=o.readUInt16LE(s+10);let a=o.readUInt32LE(s+16);const l=[];for(let c=0;c<r;c++){if(a+46>o.length||o.readUInt32LE(a)!==33639248)throw new Error(n("directory"));const i=o.readUInt16LE(a+10),d=o.readUInt32LE(a+16),h=o.readUInt32LE(a+20),u=o.readUInt32LE(a+24),p=o.readUInt16LE(a+28),f=p+o.readUInt16LE(a+30)+o.readUInt16LE(a+32),m=o.readUInt32LE(a+42),g=o.toString("utf8",a+46,a+46+p);if(a+=46+f,g.endsWith("/"))continue;if(m+30>o.length||o.readUInt32LE(m)!==67324752)throw new Error(n("damaged",{name:g}));const y=m+30+o.readUInt16LE(m+26)+o.readUInt16LE(m+28),b=o.subarray(y,y+h);if(i!==0&&i!==8)throw new Error(n("method",{name:g}));const k=i===0?Buffer.from(b):Eu(b);if(k.length!==u||bd(k)!==d)throw new Error(n("damaged",{name:g}));l.push({name:g,data:k})}return l}const Rn='"Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif',Zn={default:{name:"default",mode:"light",colorPrimary:"#255db0",colorAccent:"#6d4fc2",colorBg:"#f3f5f8",colorSurface:"#ffffff",colorSurfaceAlt:"#f8fafc",colorBorder:"#dfe5ec",colorText:"#203043",colorTextMuted:"#607086",colorSuccess:"#267257",colorWarning:"#9b4e12",colorDanger:"#b42318",colorInfo:"#1f6f9f",chartPalette:["#255db0","#e0883a","#2f9e77","#d0453a","#6d4fc2","#3a9fc0","#8a97a8"],fontFamily:Rn,fontSize:13,radius:8,shadow:"subtle",density:"comfortable"},fresh:{name:"fresh",mode:"light",colorPrimary:"#0f7b6c",colorAccent:"#3b6fb6",colorBg:"#f3f6f5",colorSurface:"#ffffff",colorSurfaceAlt:"#f7faf9",colorBorder:"#dbe4e1",colorText:"#1f2d2b",colorTextMuted:"#5d6f6b",colorSuccess:"#237a4b",colorWarning:"#9a5b07",colorDanger:"#b42318",colorInfo:"#2a6f97",chartPalette:["#0f7b6c","#3b6fb6","#e0a33a","#7fb3a6","#c8553d","#6c63a8","#93a3a0"],fontFamily:Rn,fontSize:13,radius:6,shadow:"none",density:"comfortable"},dark:{name:"dark",mode:"dark",colorPrimary:"#9bc1ff",colorAccent:"#c4b5fd",colorBg:"#141b24",colorSurface:"#202936",colorSurfaceAlt:"#1a222d",colorBorder:"#394659",colorText:"#ecf1f7",colorTextMuted:"#adbbce",colorSuccess:"#93d8bd",colorWarning:"#ffc38e",colorDanger:"#ff9e9e",colorInfo:"#8fd3f4",chartPalette:["#9bc1ff","#ffc38e","#93d8bd","#ff9e9e","#c4b5fd","#8fd3f4"],fontFamily:Rn,fontSize:13,radius:8,shadow:"none",density:"comfortable"},tech:{name:"tech",mode:"dark",colorPrimary:"#3fd5ff",colorAccent:"#a493ff",colorBg:"#04080e",colorSurface:"#0a131f",colorSurfaceAlt:"#0d1828",colorBorder:"#1e3550",colorText:"#dce7f5",colorTextMuted:"#8193ab",colorSuccess:"#2ee6b6",colorWarning:"#ffb648",colorDanger:"#ff5470",colorInfo:"#5b8cff",chartPalette:["#3fd5ff","#ffb648","#2ee6b6","#ff5470","#a493ff","#5b8cff"],fontFamily:Rn,fontSize:13,radius:4,shadow:"none",density:"compact"}},bl={free:{type:"free",columns:2,sidePosition:"left",sideWidth:300,asideWidth:0,gap:"normal"}};re.done.value;const mr=re.overdue.value,wd=[re.active.value,mr],Qm={status:{variable:"status",field:"$status"},signed:{variable:"signed",field:"signing_date"},customer:{variable:"customer",field:"customer_name"},region:{variable:"region",field:"region"},search:{variable:"search",fields:["sales_order_id","customer_name","product_name"]},alert:{variable:"alert"}},kd=(...e)=>Object.entries(Qm).filter(([t])=>!e.includes(t)).map(([,t])=>t);kd("alert");Qt("$status",wd);Qt("$status",wd),Qt("$status",[mr]),Qt("$status",[mr]),kd();const eg=(e,t)=>e.x<t.x+t.w&&t.x<e.x+e.w&&e.y<t.y+t.h&&t.y<e.y+e.h;function tg(e,t,n){const o=[],s={},r=Object.entries(e).filter(([a])=>a!==t).sort(([,a],[,l])=>a.y-l.y||a.x-l.x);for(const[a,l]of r){const c=h=>!o.some(u=>eg({...l,y:h},u));let i=l.y;for(;i>0&&c(i-1);)i-=1;for(;!c(i);)i+=1;const d={...l,y:i};o.push(d),s[a]=d}return s}const ng={sep:"、",object:e=>`${e} 必须是对象`,array:e=>`${e} 必须是数组`,noOption:(e,t)=>`${e} 没有配置项 ${t}`,required:e=>`${e} 必填`,textMax:(e,t)=>`${e} 必须是不超过 ${t} 字的文本`,text:e=>`${e} 必须是文本`,numberRange:(e,t,n,o)=>`${e} 必须是 ${t} 到 ${n} 的${o?"数":"整数"}`,oneOf:(e,t)=>`${e} 只能是 ${t}`,bool:e=>`${e} 必须是 true 或 false`,sourceOneOf:(e,t)=>`${e} 必须是页面数据源之一:${t}`,pickProperty:e=>`${e} 至少选一个属性`,textList:e=>`${e} 必须是文本列表`,valueNotTaken:(e,t,n,o)=>`${e} 的取值「${t}」不是 ${n} 的取值(可选:${o})`,needSource:e=>`${e} 需要先选好数据源`,notObjectType:e=>`${e} 不是知识网络中的对象类`,operationOneOf:(e,t)=>`${e} 必须是数据源里定义的情景操作:${t}`,noOperations:"(数据源还没有情景操作)",operationProblem:(e,t)=>`${e} ${t}`,eventTypeOneOf:(e,t,n,o)=>`${e} 必须是应用的${t?"用户登记":""}事件类型${n?"列表":""}:${o}`,noEventTypes:"(还没有,先到「事件」页签新建)",actionIdList:e=>`${e} 必须是行动类型 id 的列表`,notAction:(e,t)=>`${e} 里的 ${t} 不是知识网络里的行动`,pickTool:e=>`${e} 要选工具箱和其中的一个工具`,pickMcpTool:e=>`${e} 要选 MCP 服务和其中的一个工具`,listSize:(e,t,n)=>`${e} 必须是 ${t} 到 ${n} 项的列表`,needSourceOrObjectType:e=>`${e} 需要先选好数据源或对象类`,propertyUnusable:(e,t)=>`${e} 不是可用的属性:${t}`,propertyOfType:(e,t)=>`${e} 必须是${t}属性`,typeNames:{date:"日期",number:"数字",text:"文本"},variableOneOf:(e,t)=>`${e} 必须是页面变量之一:${t}`,noVariables:"(没有可用变量)",objectsMismatch:(e,t)=>`${e} 筛选 ${t} 里是另一类对象,组件的数据源对不上`,list:e=>`${e} 必须是列表`,bindingShape:e=>`${e} 必须是 { variable, field? , fields? }`,filterOneOf:(e,t)=>`${e}.variable 必须是页面上的筛选之一:${t}`,noFilters:"(还没有筛选)",filterTwice:(e,t)=>`${e} 重复跟随筛选 ${t}`,bindingField:(e,t)=>`${e}.field 不是数据源的字段:${t}`,bindingDateField:e=>`${e}.field 必须是数据源的日期字段`,bindingTextFields:e=>`${e}.fields 必须是数据源的文本字段列表`,relationIds:e=>`${e} 必须是关系 ID 列表`,singleRelation:e=>`${e} 只能是一条关系:连线必须是知识网络里直接相连的关系,不能沿多条关系拼出来`,pathUnreachable:(e,t)=>`${e} 不是从 ${t} 出发连通的关系路径`,pathEnd:(e,t,n)=>`${e} 终点是 ${t},与 objectType ${n} 不一致`},og={sep:", ",object:e=>`${e} must be an object`,array:e=>`${e} must be an array`,noOption:(e,t)=>`${e} has no option ${t}`,required:e=>`${e} is required`,textMax:(e,t)=>`${e} must be text of at most ${t} characters`,text:e=>`${e} must be text`,numberRange:(e,t,n,o)=>`${e} must be ${o?"a number":"an integer"} from ${t} to ${n}`,oneOf:(e,t)=>`${e} must be one of ${t}`,bool:e=>`${e} must be true or false`,sourceOneOf:(e,t)=>`${e} must be one of the page's sources: ${t}`,pickProperty:e=>`${e} needs at least one property`,textList:e=>`${e} must be a list of text`,valueNotTaken:(e,t,n,o)=>`${e} value "${t}" is not a value of ${n} (one of: ${o})`,needSource:e=>`${e} needs a source to be chosen first`,notObjectType:e=>`${e} is not an object type of the knowledge network`,operationOneOf:(e,t)=>`${e} must be a scenario operation defined on the source: ${t}`,noOperations:"(the source has no scenario operations yet)",operationProblem:(e,t)=>`${e} ${t}`,eventTypeOneOf:(e,t,n,o)=>`${e} must be ${n?"a list of ":"an "}${t?"user-reported ":""}event type${n?"s":""} of the app: ${o}`,noEventTypes:'(none yet; create one in the "Events" tab first)',actionIdList:e=>`${e} must be a list of action type ids`,notAction:(e,t)=>`${t} in ${e} is not an action of the knowledge network`,pickTool:e=>`${e} needs a toolbox and one of its tools`,pickMcpTool:e=>`${e} needs an MCP server and one of its tools`,listSize:(e,t,n)=>`${e} must be a list of ${t} to ${n} items`,needSourceOrObjectType:e=>`${e} needs a source or an object type to be chosen first`,propertyUnusable:(e,t)=>`${e} is not an available property: ${t}`,propertyOfType:(e,t)=>`${e} must be a ${t} property`,typeNames:{date:"date",number:"number",text:"text"},variableOneOf:(e,t)=>`${e} must be one of the page variables: ${t}`,noVariables:"(no variable available)",objectsMismatch:(e,t)=>`${e} filter ${t} holds another kind of object than the component's source`,list:e=>`${e} must be a list`,bindingShape:e=>`${e} must be { variable, field? , fields? }`,filterOneOf:(e,t)=>`${e}.variable must be one of the filters of the page: ${t}`,noFilters:"(no filter yet)",filterTwice:(e,t)=>`${e} follows filter ${t} twice`,bindingField:(e,t)=>`${e}.field is not a field of the source: ${t}`,bindingDateField:e=>`${e}.field must be a date field of the source`,bindingTextFields:e=>`${e}.fields must be a list of text fields of the source`,relationIds:e=>`${e} must be a list of relation ids`,singleRelation:e=>`${e} must be a single relation: a link must be a relation directly connecting objects in the knowledge network, not several relations chained`,pathUnreachable:(e,t)=>`${e} is not a connected relation path starting at ${t}`,pathEnd:(e,t,n)=>`${e} ends at ${t}, which differs from objectType ${n}`},Ze=()=>fe({"zh-CN":ng,"en-US":og}),sg=80;function vd(e,t,n,o,s={}){const r=Ze();if(!Ct(t))return[r.object(o)];const a=typeof t.source=="string"?t.source:void 0,l=[],c={...t};for(const[i,d]of Object.entries(s)){if(!(i in c))continue;const h=c[i];delete c[i],h!=null&&(d==="array"?!Array.isArray(h):!Ct(h))&&l.push(r[d](`${o}.${i}`))}return[...l,...$d(e,c,n,o,{sourceId:a,config:t})]}function rg(e,t){return{...t,sourceId:typeof e.source=="string"?e.source:t.sourceId,objectType:typeof e.objectType=="string"?e.objectType:t.objectType}}function ag(e,t,n,o,s){const r=t[e.key],a=`${o}.${e.key}`,l=e.neededAs?.(t);if(r==null||r==="")return!e.optional&&!e.notNeeded?.(t)||l?[Ze().required(a)]:[];const c=l&&e.kind==="field"?{...e,of:l}:e;return ig(c,r,n,a,s,t)}function $d(e,t,n,o,s){const r=Ze(),a=[],l=new Set(e.map(i=>i.key));for(const i of Object.keys(t))l.has(i)||a.push(r.noOption(o,i));const c=rg(t,s);for(const i of e)a.push(...ag(i,t,n,o,c));return a}function ig(e,t,n,o,s,r){const a=Ze(),l=dn(ue(n.spec,s.sourceId));switch(e.kind){case"text":{if(e.max===null)return typeof t=="string"?[]:[a.text(o)];const c=e.max??sg;return typeof t=="string"&&t.length<=c?[]:[a.textMax(o,c)]}case"number":return typeof t=="number"&&Number.isFinite(t)&&(e.decimal===!0||Number.isInteger(t))&&t>=e.min&&t<=e.max?[]:[a.numberRange(o,e.min,e.max,e.decimal===!0)];case"enum":return e.options.some(([c])=>c===t)?[]:[a.oneOf(o,e.options.map(([c])=>c).join(a.sep))];case"bool":return typeof t=="boolean"?[]:[a.bool(o)];case"source":return n.spec.sources.some(c=>c.id===t)?[]:[a.sourceOneOf(o,n.spec.sources.map(c=>c.id).join(a.sep))];case"field":return wl(e,t,n,o,s);case"fields":return!Array.isArray(t)||t.length===0?[a.pickProperty(o)]:t.flatMap((c,i)=>wl(e,c,n,`${o}[${i}]`,s));case"variable":return lg(e.accepts,t,n,o,s);case"bindings":return cg(t,n,o,s);case"values":{if(!Array.isArray(t)||!t.every(d=>typeof d=="string"&&d!==""))return[a.textList(o)];const c=r[e.fieldKey]??s.config?.[e.fieldKey],i=typeof c=="string"?l(c):[];return i.length===0?[]:t.filter(d=>!i.includes(d)).map(d=>a.valueNotTaken(o,d,String(c),i.join(a.sep)))}case"conditions":{const c=Xn("source",n,s);return c===null?[a.needSource(o)]:xe(t,c,o,l)}case"objectType":return typeof t=="string"&&Object.hasOwn(n.kn.objectTypes,t)?[]:[a.notObjectType(o)];case"relationPath":return dg(t,n,o,s,e.single);case"operation":{const c=ue(n.spec,s.sourceId)?.operations??[],i=c.find(h=>h.id===t);if(!i)return[a.operationOneOf(o,c.map(h=>h.id).join(a.sep)||a.noOperations)];const d=e.fits?.(i,r);return d?[a.operationProblem(o,d)]:[]}case"eventType":{const i=(Array.isArray(n.spec.eventTypes)?In(n.spec,en(n.kn.eventTypes)):[]).filter(p=>!e.of||!p.source||p.source===e.of),d=p=>i.some(f=>f.id===p);if(e.multiple?Array.isArray(t)&&t.length>0&&t.every(d):d(t))return[];const u=i.map(p=>p.id).join(a.sep);return[a.eventTypeOneOf(o,e.of==="report",e.multiple===!0,u||a.noEventTypes)]}case"interactions":return wp(t,e,n,s.sourceId,Xn("source",n,s),o);case"actionTypes":{if(!Array.isArray(t)||t.some(i=>typeof i!="string"))return[a.actionIdList(o)];const c=n.kn.actionTypes;return c?t.filter(i=>!c.some(d=>d.id===i)).map(i=>a.notAction(o,String(i))):[]}case"metric":{const{place:c,category:i}=Mp(e.on,s.config??{});return zp(t,n.kn,n.spec,s.sourceId,c,o,i)}case"tool":return Ct(t)&&typeof t.box=="string"&&t.box!==""&&typeof t.tool=="string"&&t.tool!==""?[]:[a.pickTool(o)];case"mcpTool":return Ct(t)&&typeof t.mcp=="string"&&t.mcp!==""&&typeof t.tool=="string"&&t.tool!==""&&[t.agentId,t.agentName].every(c=>c===void 0||typeof c=="string")?[]:[a.pickMcpTool(o)];case"list":return!Array.isArray(t)||t.length<e.min||t.length>e.max?[a.listSize(o,e.min,e.max)]:t.flatMap((c,i)=>Ct(c)?$d(e.item,c,n,`${o}[${i}]`,s):[a.object(`${o}[${i}]`)])}}const Sd="$key";function wl(e,t,n,o,s){if(e.objectKey&&t===Sd&&!e.of)return[];const r=Ze(),a=Xn(e.owner??"source",n,s);if(a===null)return[r.needSourceOrObjectType(o)];const l=a.find(c=>c.name===t);return l?e.of&&l.type!==e.of?[r.propertyOfType(o,r.typeNames[e.of])]:[]:[r.propertyUnusable(o,String(t))]}function lg(e,t,n,o,s){const r=Ze(),a=n.spec.variables.find(l=>l.name===t);if(!a||!e.includes(a.kind)){const l=n.spec.variables.filter(c=>e.includes(c.kind)).map(c=>c.name);return[r.variableOneOf(o,l.join(r.sep)||r.noVariables)]}return Ad(a,n,s)?[]:[jd(o,a.name)]}const jd=(e,t)=>Ze().objectsMismatch(e,t);function Ad(e,t,n){if(!("source"in e)||!n.sourceId)return!0;const o=s=>t.spec.sources.find(r=>r.id===s)?.objectType;return o(e.source)===o(n.sourceId)}function cg(e,t,n,o){const s=Ze();if(!Array.isArray(e))return[s.list(n)];if(e.length===0)return[];const r=Xn("source",t,o);if(r===null)return[s.needSource(n)];const a=c=>r.find(i=>i.name===c)?.type,l=new Set;return e.flatMap((c,i)=>{const d=`${n}[${i}]`;if(!Ct(c)||typeof c.variable!="string")return[s.bindingShape(d)];const h=t.spec.variables.find(u=>u.name===c.variable);if(!h||!wa.includes(h.kind)){const u=t.spec.variables.filter(p=>wa.includes(p.kind)).map(p=>p.name);return[s.filterOneOf(d,u.join(s.sep)||s.noFilters)]}if(l.has(h.name))return[s.filterTwice(d,h.name)];switch(l.add(h.name),h.kind){case"value":return a(c.field)?[]:[s.bindingField(d,String(c.field))];case"dateRange":return a(c.field)==="date"?[]:[s.bindingDateField(d)];case"search":return Array.isArray(c.fields)&&c.fields.length>0&&c.fields.every(u=>a(u)==="text")?[]:[s.bindingTextFields(d)];case"set":return Ad(h,t,o)?[]:[jd(d,h.name)]}})}function dg(e,t,n,o,s=!1){const r=Ze(),a=ue(t.spec,o.sourceId);if(!a)return[r.needSource(n)];if(!Array.isArray(e)||!e.every(i=>typeof i=="string"))return[r.relationIds(n)];if(s&&e.length!==1)return[r.singleRelation(n)];const l=io(t.kn,a.objectType,e);if(!l)return[r.pathUnreachable(n,a.objectType)];const c=l.length>0?l[l.length-1].to:a.objectType;return o.objectType&&c!==o.objectType?[r.pathEnd(n,c,o.objectType)]:[]}function Xn(e,t,n){if(e==="objectType")return n.objectType?t.kn.objectTypes[n.objectType]?.properties??null:null;const o=ue(t.spec,n.sourceId);return o?pe(o,t.kn):null}const ug={date:"日期",number:"数字",text:"文本"};function Qn(e,t=" "){return e.map(n=>{const o=`${t}- ${n.key}(${n.label}${n.optional?",可选":""}):`;return n.kind==="list"?`${o}列表 ${n.min} 到 ${n.max} 项,每项:
|
|
156
|
-
${
|
|
157
|
-
`)}function hg(e){switch(e.kind){case"text":return e.max!=null?`文本,不超过 ${e.max} 字`:"文本";case"number":return`${e.decimal?"数":"整数"} ${e.min} 到 ${e.max}`;case"enum":return`取值 ${e.options.map(([t,n])=>`${t}(${n})`).join("、")}`;case"bool":return"true 或 false";case"source":return"页面数据源 id";case"field":case"fields":{const t=e.owner==="objectType"?"同一项 objectType 的属性":"数据源的属性",n=e.kind==="fields"?"列表":"",o=e.kind==="field"&&e.objectKey?`,或 ${Sd} 表示对象本身`:"";return`${t}名${n}${e.of?`,须为${ug[e.of]}`:""}${o}`}case"variable":return`筛选名(variables 里的 name),类型须为 ${e.accepts.join(" 或 ")}`;case"bindings":return"跟随的筛选列表,每项 { variable, field? , fields? }:value 筛选给 field(按组件数据源的哪个字段比对);dateRange 筛选给日期 field;search 筛选给文本 fields;set 筛选不用给字段(须为同一类对象)。不写或空列表表示不受任何筛选影响";case"values":return`文本列表,为 ${e.fieldKey} 字段的取值(只取其中这些值;空列表表示不限)`;case"conditions":return"条件列表,全部成立才算命中;每项 { field, op, ref? | value? | values? },写法同计算列的条件";case"objectType":return"对象类 id";case"operation":return"数据源 operations 里的情景操作 id";case"relationPath":return e.single?"只含一个关系 id 的列表:知识网络里直接连接数据源对象类与 objectType 的那条关系;网络里没有直接关系的两类对象不能连线":"关系 id 列表,从数据源的对象类依次走到 objectType";case"list":return`列表 ${e.min} 到 ${e.max} 项,每项:${e.item.map(t=>t.label).join("、")}`;case"interactions":return kp(e.on,e.actOn,e.hit,e.offers);case"actionTypes":return"行动类型 id 列表(知识网络里的行动)";case"metric":return e.on==="card"?"{ id, version }:知识网络中已发布的对象指标(见「对象指标」,没有这一节就不能用),须返回单个值、属于数据源的对象类;写了它,这张卡由平台按全部对象计算,不写 aggregate、valueField":"{ id, version }:知识网络中已发布的对象指标(见「对象指标」,没有这一节就不能用),须属于数据源的对象类;横轴为时间时须是有固定时间粒度的指标,横轴为类别时须返回单个值且类别属性是它开放的维度;写了它,这个系列由平台计算,不写 dateField、aggregate、valueField";case"tool":return"{ box, tool }:执行工厂里已发布工具箱的 id 和其中已启用工具的 id";case"mcpTool":return"{ mcp, tool, mcpName?, agentId?, agentName? }:执行工厂里已发布 MCP 服务的 id、其中工具的名称,以及服务名称(可选,只用于显示,不写时对话框向执行工厂取);支持智能体目录的服务可指定默认智能体 id 和名称;不知道有哪些服务时不写,由构建者选择";case"eventType":return`${e.multiple?"事件类型 id 列表":"事件类型 id"}(eventTypes 里的 id${e.of==="report"?",须为知识网络里来源是用户登记的":""})`}}function Ct(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const pg={joiner:"、",noOption:(e,t)=>`${e} 没有配置项 ${t}`,required:e=>`${e} 必填`,namesList:(e,t)=>`${e} 必须是不超过 ${t} 个名称的列表`,name:e=>`${e} 必须是非空名称`,conditionList:e=>`${e} 必须是条件列表`,condition:e=>`${e} 必须是 { field, op, value? } 条件`,object:e=>`${e} 必须是对象`,paramFrom:e=>`${e} 必须是 param、field、const 或 context 取值`,pathLength:e=>`${e} 必须是 1 到 4 条关系`,targetShape:e=>`${e} 必须是 { path?, field }`,readyShape:e=>`${e} 必须是 { path, field }`,onePath:e=>`${e} 必须是一条关系`,rulesCount:(e,t)=>`${e} 必须是不超过 ${t} 个规则工具`,ruleShape:e=>`${e} 必须是 { name, tool: { box, tool }, severity? }`,severity:e=>`${e} 只能是 hard 或 soft`,sourcesList:(e,t)=>`${e} 必须是不超过 ${t} 个数据源的列表`,layerList:e=>`${e} 必须是图层列表`,oneOf:(e,t)=>`${e} 只能是 ${t}`,tasksSelf:(e,t)=>`${e} 必须是 1 到 ${t} 种任务`,tasksRecord:e=>`${e} 写入计划记录时只能有一种任务`,parentOrGroup:e=>`${e} 上级字段与分组字段只能选一个`,calendarsCount:(e,t)=>`${e} 必须是不超过 ${t} 个日历`,boolean:e=>`${e} 必须是布尔值`,recordOnlyRecord:e=>`${e} 只在写入计划记录时填写`,recordRequired:e=>`${e} 写入计划记录时必填`,days:e=>`${e} 必须是 1 到 365 天`,matchCount:(e,t)=>`${e} 必须是不超过 ${t} 对字段`,matchShape:e=>`${e} 必须是 { from, to }`},fg={joiner:", ",noOption:(e,t)=>`${e} has no option ${t}`,required:e=>`${e} is required`,namesList:(e,t)=>`${e} must be a list of at most ${t} names`,name:e=>`${e} must be a non-empty name`,conditionList:e=>`${e} must be a list of conditions`,condition:e=>`${e} must be a { field, op, value? } condition`,object:e=>`${e} must be an object`,paramFrom:e=>`${e} must take its value from param, field, const or context`,pathLength:e=>`${e} must be 1 to 4 relations`,targetShape:e=>`${e} must be { path?, field }`,readyShape:e=>`${e} must be { path, field }`,onePath:e=>`${e} must be one relation`,rulesCount:(e,t)=>`${e} must be at most ${t} rule tools`,ruleShape:e=>`${e} must be { name, tool: { box, tool }, severity? }`,severity:e=>`${e} must be hard or soft`,sourcesList:(e,t)=>`${e} must be a list of at most ${t} sources`,layerList:e=>`${e} must be a list of layers`,oneOf:(e,t)=>`${e} must be one of ${t}`,tasksSelf:(e,t)=>`${e} must be 1 to ${t} kinds of task`,tasksRecord:e=>`${e} can have only one kind of task when results go into plan records`,parentOrGroup:e=>`${e} can take a parent field or a group field, not both`,calendarsCount:(e,t)=>`${e} must be at most ${t} calendars`,boolean:e=>`${e} must be true or false`,recordOnlyRecord:e=>`${e} is only for results written into plan records`,recordRequired:e=>`${e} is required when results go into plan records`,days:e=>`${e} must be 1 to 365 days`,matchCount:(e,t)=>`${e} must be at most ${t} pairs of fields`,matchShape:e=>`${e} must be { from, to }`},Me=()=>fe({"zh-CN":pg,"en-US":fg}),kl=["self","record"],mg=["title","subtitleField","daysBefore","daysAfter","tick","timeZone","timeZoneVariable","resourceSelection"],gg=["label","popoverFields","color","tone","colorField","snap","selection","filters"],yg=["result","tasks","resource","time","rules","plan"],eo=3,gr=3,vl=4,$l=5,se=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Le=e=>typeof e=="string"&&e!=="";function Ue(e,t,n){return Object.keys(e).filter(o=>!t.includes(o)).map(o=>Me().noOption(n,o))}function Td(e,t,n,o=10){const s=Me();return e===void 0?n?[s.required(t)]:[]:!Array.isArray(e)||e.length>o||!e.every(Le)?[s.namesList(t,o)]:[]}function H(e,t,n=!0){return e===void 0&&!n?[]:Le(e)?[]:[Me().name(t)]}function Od(e,t){const n=Me();return e===void 0?[]:Array.isArray(e)?e.flatMap((o,s)=>se(o)&&Le(o.field)&&Yn.includes(o.op)?[]:[n.condition(`${t}[${s}]`)]):[n.conditionList(t)]}function yr(e,t,n){const o=Me();if(e===void 0)return n?[o.required(t)]:[];if(!se(e))return[o.object(t)];const s=[...Ue(e,["action","params"],t),...H(e.action,`${t}.action`)];if(e.params!==void 0)if(!se(e.params))s.push(o.object(`${t}.params`));else for(const[r,a]of Object.entries(e.params))(!se(a)||!((a.from==="param"||a.from==="field")&&Le(a.name)||a.from==="const"&&(typeof a.value=="string"||typeof a.value=="number")||a.from==="context"&&Ys.includes(a.name)))&&s.push(o.paramFrom(`${t}.params.${r}`));return s}function Sl(e,t){return Array.isArray(e)&&e.length>0&&e.length<=4&&e.every(Le)?[]:[Me().pathLength(t)]}function bg(e,t,n){const o=Me();if(!se(e))return[o.object(t)];const s=[...Ue(e,["objectType","assignField","start","end","status","titleFields","doneWhen","groupField","target","ready","predecessors","modify","rules"],t),...H(e.objectType,`${t}.objectType`),...H(e.assignField,`${t}.assignField`,n),...H(e.start,`${t}.start`,n),...H(e.end,`${t}.end`,n),...H(e.status,`${t}.status`,!1),...H(e.groupField,`${t}.groupField`,!1),...Td(e.titleFields,`${t}.titleFields`,!1,4),...Od(e.doneWhen,`${t}.doneWhen`),...yr(e.modify,`${t}.modify`,!1)];if(e.target!==void 0&&(se(e.target)?(s.push(...H(e.target.field,`${t}.target.field`)),e.target.path!==void 0&&s.push(...Sl(e.target.path,`${t}.target.path`))):s.push(o.targetShape(`${t}.target`))),e.ready!==void 0&&(se(e.ready)?s.push(...Sl(e.ready.path,`${t}.ready.path`),...H(e.ready.field,`${t}.ready.field`)):s.push(o.readyShape(`${t}.ready`))),e.predecessors!==void 0){const r=se(e.predecessors)?e.predecessors.path:void 0;(!Array.isArray(r)||r.length!==1||!Le(r[0]))&&s.push(o.onePath(`${t}.predecessors.path`))}return e.rules!==void 0&&(!Array.isArray(e.rules)||e.rules.length>$l?s.push(o.rulesCount(`${t}.rules`,$l)):e.rules.forEach((r,a)=>{const l=se(r)?r.tool:void 0;!se(r)||!Le(r.name)||!se(l)||!Le(l.box)||!Le(l.tool)?s.push(o.ruleShape(`${t}.rules[${a}]`)):r.severity!==void 0&&r.severity!=="hard"&&r.severity!=="soft"&&s.push(o.severity(`${t}.rules[${a}].severity`))})),s}function jl(e,t,n){return e===void 0?[]:Array.isArray(e)&&e.length<=n&&e.every(o=>typeof o=="string")?[]:[Me().sourcesList(t,n)]}function wg(e,t){return e===void 0?[]:se(e)?[...Ue(e,["tasks","resource","calendars","plan"],t),...jl(e.tasks,`${t}.tasks`,eo),...H(e.resource,`${t}.resource`,!1),...jl(e.calendars,`${t}.calendars`,gr),...H(e.plan,`${t}.plan`,!1)]:[Me().object(t)]}function kg(e,t){if(e===void 0)return[];const n=Me();if(!se(e))return[n.object(t)];const o=Ue(e,["resource","demand"],t);for(const s of["resource","demand"]){const r=e[s];if(r!==void 0){if(!se(r)){o.push(n.object(`${t}.${s}`));continue}o.push(...Ue(r,[...mg,"layers"],`${t}.${s}`)),r.layers!==void 0&&(!Array.isArray(r.layers)||r.layers.length>12?o.push(n.layerList(`${t}.${s}.layers`)):r.layers.forEach((a,l)=>{se(a)?o.push(...Ue(a,gg,`${t}.${s}.layers[${l}]`)):o.push(n.object(`${t}.${s}.layers[${l}]`))}))}}return o}function vg(e,t="scheduleModel"){const n=Me();if(!se(e))return[n.object(t)];const o=Ue(e,["result","tasks","resource","calendars","record","sources","display"],t);o.push(...wg(e.sources,`${t}.sources`),...kg(e.display,`${t}.display`)),kl.includes(e.result)||o.push(n.oneOf(`${t}.result`,kl.join(n.joiner)));const s=e.result==="self",r=s?eo:1;!Array.isArray(e.tasks)||e.tasks.length===0||e.tasks.length>r?o.push(s?n.tasksSelf(`${t}.tasks`,eo):n.tasksRecord(`${t}.tasks`)):e.tasks.forEach((c,i)=>o.push(...bg(c,`${t}.tasks[${i}]`,s)));const a=e.resource;se(a)?(o.push(...Ue(a,["objectType","titleField","parentField","groupField","capacityField"],`${t}.resource`),...H(a.objectType,`${t}.resource.objectType`),...H(a.titleField,`${t}.resource.titleField`),...H(a.parentField,`${t}.resource.parentField`,!1),...H(a.groupField,`${t}.resource.groupField`,!1),...H(a.capacityField,`${t}.resource.capacityField`,!1)),a.parentField!==void 0&&a.groupField!==void 0&&o.push(n.parentOrGroup(`${t}.resource`))):o.push(n.object(`${t}.resource`)),e.calendars!==void 0&&(!Array.isArray(e.calendars)||e.calendars.length>gr?o.push(n.calendarsCount(`${t}.calendars`,gr)):e.calendars.forEach((c,i)=>{const d=`${t}.calendars[${i}]`;return se(c)?(o.push(...Ue(c,["objectType","resourceField","start","end","inherit"],d),...H(c.objectType,`${d}.objectType`),...H(c.resourceField,`${d}.resourceField`),...H(c.start,`${d}.start`),...H(c.end,`${d}.end`)),c.inherit!==void 0&&typeof c.inherit!="boolean"&&o.push(n.boolean(`${d}.inherit`)),o):o.push(n.object(d))}));const l=e.record;if(s)l!==void 0&&o.push(n.recordOnlyRecord(`${t}.record`));else if(!se(l))o.push(n.recordRequired(`${t}.record`));else{const c=`${t}.record`;o.push(...Ue(l,["objectType","match","resourceField","start","end","status","titleFields","active","create","modify","days","daysField"],c),...H(l.objectType,`${c}.objectType`),...H(l.resourceField,`${c}.resourceField`,!1),...H(l.start,`${c}.start`),...H(l.end,`${c}.end`),...H(l.status,`${c}.status`,!1),...Td(l.titleFields,`${c}.titleFields`,!1,4),...H(l.daysField,`${c}.daysField`,!1),...l.days!==void 0&&(typeof l.days!="number"||!(l.days>0)||l.days>365)?[n.days(`${c}.days`)]:[],...Od(l.active,`${c}.active`),...yr(l.create,`${c}.create`,!1),...yr(l.modify,`${c}.modify`,!1)),l.match!==void 0&&(!Array.isArray(l.match)||l.match.length>vl?o.push(n.matchCount(`${c}.match`,vl)):l.match.forEach((i,d)=>{(!se(i)||!Le(i.from)||!Le(i.to))&&o.push(n.matchShape(`${c}.match[${d}]`))}))}return o}function $g(e,t,n){const r=(n.startsWith(`${t.id}_`)?n.slice(t.id.length+1):n).replace(/[^A-Za-z0-9]+(.)?/g,(l,c)=>(c??"").toUpperCase()).replace(/^[^A-Za-z]+/,"")||`source${Object.keys(t.objectTypes).indexOf(n)+1||""}`,a=new Set(e.sources.map(l=>l.id));if(!a.has(r))return r;for(let l=2;;l++)if(!a.has(`${r}${l}`))return`${r}${l}`}const Sg={object:e=>`${e} 必须是对象`,noOption:(e,t)=>`${e} 没有配置项 ${t}`,notBoth:e=>`${e} 不能同时是 Cypher 数据源和事件数据源`,mustBe:(e,t)=>`${e} 必须是 ${t}`,typesList:e=>`${e} 必须是事件类型 id 列表`},jg={object:e=>`${e} must be an object`,noOption:(e,t)=>`${e} has no option ${t}`,notBoth:e=>`${e} cannot be both a Cypher source and an event source`,mustBe:(e,t)=>`${e} must be ${t}`,typesList:e=>`${e} must be a list of event type ids`},Ag=()=>fe({"zh-CN":Sg,"en-US":jg}),Tg="events:",br="event_id",wr=e=>`${Tg}${e}`,Og=[{name:"event_id",label:"事件 ID",type:"text"},{name:"title",label:"标题",type:"text"},{name:"event_type",label:"事件类型",type:"text"},{name:"severity",label:"严重程度",type:"text"},{name:"status",label:"状态",type:"text"},{name:"open",label:"是否未关闭",type:"text"},{name:"overdue",label:"是否超时",type:"text"},{name:"source",label:"来源",type:"text"},{name:"occurred_at",label:"发生时间",type:"date"},{name:"ended_at",label:"结束时间",type:"date"},{name:"recorded_at",label:"记录时间",type:"date"},{name:"object",label:"关联对象",type:"text"},{name:"object_key",label:"关联对象标识",type:"text"},{name:"reported_by",label:"报告人",type:"text"},{name:"verified_by",label:"核实人",type:"text"}];function Eg(e,t){return{id:wr(e),name:t,primaryKeys:[br],displayKey:"title",properties:Og}}function Cg(e,t){const n=Ag(),o=[],s=e.events;if(typeof s!="object"||s===null||Array.isArray(s))return[n.object(`${t}.events`)];e.cypher!==void 0&&o.push(n.notBoth(t)),e.objectType!==wr(String(e.id))&&o.push(n.mustBe(`${t}.objectType`,wr(String(e.id)))),e.key!==br&&o.push(n.mustBe(`${t}.key`,br));const r=s.types;r!==void 0&&!(Array.isArray(r)&&r.every(a=>typeof a=="string"))&&o.push(n.typesList(`${t}.events.types`));for(const a of Object.keys(s))a!=="types"&&o.push(n.noOption(`${t}.events`,a));return o}const Ng={joiner:"、",list:(e,t)=>`${e} 必须是不超过 ${t} 项的列表`,object:e=>`${e} 必须是对象`,noOption:(e,t)=>`${e} 没有配置项 ${t}`,idFormat:e=>`${e} 必须是字母开头的标识`,idTwice:(e,t)=>`${e} 重复:${t}`,label:e=>`${e} 必须是不超过 30 字的名称`,oneOf:(e,t)=>`${e} 只能是 ${t}`,unit:e=>`${e} 必须是不超过 10 字的文字`,text:e=>`${e} 必须是文字`,number:e=>`${e} 必须是数值`,minAboveMax:e=>`${e} 不能大于 max`,outOfRange:e=>`${e} 超出范围`,rangeOnlyNumber:e=>`${e} 只有数值参数能设范围`,dayDate:e=>`${e} 必须是 YYYY-MM-DD 日期`,optionsOnlyText:e=>`${e} 只有文本参数能列可选值`,optionsCount:(e,t)=>`${e} 必须是 2 到 ${t} 个可选值`,required:e=>`${e} 必填`,scenarioName:e=>`${e} 必须是不超过 40 字的方案名`,defaultInOptions:e=>`${e} 必须是可选值之一`,saveAsName:e=>`${e} 必填:保存为知识网络对象时的对象类名称`,saveAsNameLong:(e,t)=>`${e} 不能超过 ${t} 个字`,outputTooLong:(e,t,n)=>`${e} 的字段 ${t} 超过 ${n} 个字符,不能保存为对象属性`,outputFixedName:(e,t)=>`${e} 的字段 ${t} 与结果行的固定字段同名,请改名`,objectTypeMustBe:(e,t)=>`${e} 必须是 ${t}`,notForModelSource:e=>`${e} 不能用于模型结果数据源`,tool:e=>`${e} 必须写明执行工厂的工具箱 box 与工具 tool`,inputsCount:(e,t)=>`${e} 必须是 1 到 ${t} 个输入`,inputSource:e=>`${e} 必须是页面的其他数据源`,inputBaseMissing:e=>`${e} 的来源数据源不存在`,inputEvents:e=>`${e} 不能是事件数据源`,inputFollows:e=>`${e} 是跟随筛选的子集,模型的输入不能跟随筛选`,inputQueryParam:(e,t)=>`${e} 的查询参数 $${t} 只能绑定基准日期`,inputFieldsEmpty:e=>`${e} 至少传一个字段`,inputField:e=>`${e} 必须是该数据源的字段`,inputsLoop:e=>`${e} 形成了循环:模型结果数据源不能读到自己`,paramsCount:(e,t)=>`${e} 必须是不超过 ${t} 个参数`,notScenarioParam:e=>`${e} 不是方案参数`,paramTypeDiffers:(e,t)=>`${e} 的类型是 ${t},与参数类型不同`,paramNoValue:e=>`${e} 取方案参数时不写固定值 value`,paramValue:e=>`${e} 必须是与类型相符的固定值,或改取方案参数 param`,outputsCount:(e,t)=>`${e} 必须是行标识加 1 到 ${t} 个字段`,keyMustBeOutput:e=>`${e} 必须是模型的一个输出字段(行标识)`,knObjectType:e=>`${e} 必须是知识网络中的对象类`,mustBeModelOutput:e=>`${e} 必须是模型的输出字段`,actionTarget:e=>`${e} 只能是 object(对这个对象执行)或 new(按新对象执行)`,actionType:e=>`${e} 不是知识网络中的行动类型`,actionObjectType:(e,t)=>`${e} 必须作用于对应对象的对象类 ${t}`,actionNewIsAdd:e=>`${e} 按新对象执行须是新增类行动`,prefix:(e,t)=>`${e} 必须是不超过 ${t} 字的编号前缀`,keyField:(e,t)=>`${e} 必须是 ${t} 的主键`,notPropertyOf:(e,t)=>`${e} 不是 ${t} 的属性`,numberField:e=>`${e} 是编号字段,取新编号`,mustTakeOutput:e=>`${e} 必须取模型的输出字段`,mustGive:e=>`${e} 必须给出:新建对象时这个属性必须有值,取模型的输出字段,或在 action.params 里给出来源`,notUserParam:e=>`${e} 不是该行动的用户填写参数`,fieldsAtLeastOne:e=>`${e} 至少要有一个字段`,fieldNameEmpty:e=>`${e} 的字段名不能为空`,textOrNumber:e=>`${e} 必须是文字或数值`,fromFieldOrConst:e=>`${e} 只能是 field 或 const`},xg={joiner:", ",list:(e,t)=>`${e} must be a list of at most ${t} items`,object:e=>`${e} must be an object`,noOption:(e,t)=>`${e} has no option ${t}`,idFormat:e=>`${e} must be an identifier starting with a letter`,idTwice:(e,t)=>`${e} is used twice: ${t}`,label:e=>`${e} must be a name of at most 30 characters`,oneOf:(e,t)=>`${e} must be one of ${t}`,unit:e=>`${e} must be text of at most 10 characters`,text:e=>`${e} must be text`,number:e=>`${e} must be a number`,minAboveMax:e=>`${e} cannot be greater than max`,outOfRange:e=>`${e} is out of range`,rangeOnlyNumber:e=>`${e}: only a number parameter can have a range`,dayDate:e=>`${e} must be a date in YYYY-MM-DD`,optionsOnlyText:e=>`${e}: only a text parameter can list options`,optionsCount:(e,t)=>`${e} must list 2 to ${t} options`,required:e=>`${e} is required`,scenarioName:e=>`${e} must be a scenario name of at most 40 characters`,defaultInOptions:e=>`${e} must be one of the options`,saveAsName:e=>`${e} is required: the object type name when saved as a knowledge network object`,saveAsNameLong:(e,t)=>`${e} cannot be longer than ${t} characters`,outputTooLong:(e,t,n)=>`field ${t} of ${e} is longer than ${n} characters and cannot be saved as an object property`,outputFixedName:(e,t)=>`field ${t} of ${e} has the same name as a fixed field of the result row, please rename it`,objectTypeMustBe:(e,t)=>`${e} must be ${t}`,notForModelSource:e=>`${e} cannot be used on a model result source`,tool:e=>`${e} must name the execution factory toolbox (box) and tool`,inputsCount:(e,t)=>`${e} must list 1 to ${t} inputs`,inputSource:e=>`${e} must be another source of the page`,inputBaseMissing:e=>`the source that ${e} comes from does not exist`,inputEvents:e=>`${e} cannot be an event source`,inputFollows:e=>`${e} is a subset that follows filters, and the inputs of a model cannot follow filters`,inputQueryParam:(e,t)=>`query parameter $${t} of ${e} can only be bound to the base date`,inputFieldsEmpty:e=>`${e} must send at least one field`,inputField:e=>`${e} must be a field of that source`,inputsLoop:e=>`${e} form a loop: a model result source cannot read itself`,paramsCount:(e,t)=>`${e} must be at most ${t} parameters`,notScenarioParam:e=>`${e} is not a scenario parameter`,paramTypeDiffers:(e,t)=>`${e} has type ${t}, which differs from the parameter type`,paramNoValue:e=>`${e} takes a scenario parameter, so it must not have a fixed value`,paramValue:e=>`${e} must be a fixed value of the matching type, or take a scenario parameter with param`,outputsCount:(e,t)=>`${e} must be a row id plus 1 to ${t} fields`,keyMustBeOutput:e=>`${e} must be an output field of the model (the row id)`,knObjectType:e=>`${e} must be an object type of the knowledge network`,mustBeModelOutput:e=>`${e} must be an output field of the model`,actionTarget:e=>`${e} must be object (act on this object) or new (act on a new object)`,actionType:e=>`${e} is not an action type of the knowledge network`,actionObjectType:(e,t)=>`${e} must act on the object type ${t} of the object`,actionNewIsAdd:e=>`${e} must be an add action to act on a new object`,prefix:(e,t)=>`${e} must be a number prefix of at most ${t} characters`,keyField:(e,t)=>`${e} must be the primary key of ${t}`,notPropertyOf:(e,t)=>`${e} is not a property of ${t}`,numberField:e=>`${e} is the number field and takes the new number`,mustTakeOutput:e=>`${e} must take an output field of the model`,mustGive:e=>`${e} is required: this property must have a value when the object is created, so take an output field of the model or give its source in action.params`,notUserParam:e=>`${e} is not a parameter the user fills in for this action`,fieldsAtLeastOne:e=>`${e} must have at least one field`,fieldNameEmpty:e=>`a field name of ${e} cannot be empty`,textOrNumber:e=>`${e} must be text or a number`,fromFieldOrConst:e=>`${e} must be field or const`},ko=()=>fe({"zh-CN":Ng,"en-US":xg}),Rg="model:",kr=e=>`${Rg}${e}`,Al=5,Tl=5,Ol=8,El=10,Cl=10,Nl=20,Mn=/^[A-Za-z][A-Za-z0-9_]*$/,Ed=/^\d{4}-\d{2}-\d{2}$/,lt=["number","date","text"],te=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Cd(e){const t=Array.isArray(e.model?.outputs)?e.model.outputs:[],n=typeof e.key=="string"?e.key:"";return{id:kr(e.id),name:typeof e.label=="string"?e.label:e.id,primaryKeys:n?[n]:[],displayKey:n,properties:t.filter(o=>o&&typeof o.name=="string").map(o=>({name:o.name,label:typeof o.label=="string"&&o.label?o.label:o.name,type:lt.includes(o.type)?o.type:"text"}))}}function _g(e,t){return e.find(o=>o.id===t)?.from?.source??t}function xl(e,t){const n=new Set(e.filter(r=>r.model).map(r=>r.id)),s=(Array.isArray(t.model?.inputs)?t.model.inputs:[]).filter(r=>te(r)&&typeof r.source=="string").map(r=>_g(e,r.source)).filter(r=>n.has(r));return[...new Set(s)]}function Pg(e,t="scenarioParams"){if(e===void 0)return[];const n=ko();if(!Array.isArray(e)||e.length>El)return[n.list(t,El)];const o=new Set;return e.flatMap((s,r)=>{const a=`${t}[${r}]`;if(!te(s))return[n.object(a)];const l=Object.keys(s).filter(c=>!["name","label","type","unit","default","description","min","max","options"].includes(c)).map(c=>n.noOption(a,c));if(typeof s.name!="string"||!Mn.test(s.name)?l.push(n.idFormat(`${a}.name`)):o.has(s.name)?l.push(n.idTwice(`${a}.name`,s.name)):o.add(s.name),(typeof s.label!="string"||!s.label.trim()||s.label.length>30)&&l.push(n.label(`${a}.label`)),!lt.includes(s.type))return[...l,n.oneOf(`${a}.type`,lt.join(n.joiner))];if(s.unit!==void 0&&(typeof s.unit!="string"||s.unit.length>10)&&l.push(n.unit(`${a}.unit`)),s.description!==void 0&&typeof s.description!="string"&&l.push(n.text(`${a}.description`)),s.type==="number"){(typeof s.default!="number"||!Number.isFinite(s.default))&&l.push(n.number(`${a}.default`));for(const c of["min","max"])s[c]!==void 0&&typeof s[c]!="number"&&l.push(n.number(`${a}.${c}`));typeof s.min=="number"&&typeof s.max=="number"&&s.min>s.max?l.push(n.minAboveMax(`${a}.min`)):typeof s.default=="number"&&(typeof s.min=="number"&&s.default<s.min||typeof s.max=="number"&&s.default>s.max)&&l.push(n.outOfRange(`${a}.default`))}else(s.min!==void 0||s.max!==void 0)&&l.push(n.rangeOnlyNumber(a)),s.type==="date"&&(typeof s.default!="string"||!Ed.test(s.default))&&l.push(n.dayDate(`${a}.default`)),s.type==="text"&&typeof s.default!="string"&&l.push(n.text(`${a}.default`));if(s.options!==void 0){const c=Array.isArray(s.options)?s.options:null;if(s.type!=="text")l.push(n.optionsOnlyText(`${a}.options`));else if(!c||c.length<2||c.length>Cl)l.push(n.optionsCount(`${a}.options`,Cl));else{const i=new Set;c.forEach((d,h)=>{const u=`${a}.options[${h}]`;return!te(d)||typeof d.value!="string"||!d.value.trim()?l.push(n.required(`${u}.value`)):(i.has(d.value)&&l.push(n.idTwice(`${u}.value`,d.value)),i.add(d.value),d.scenario!==void 0&&(typeof d.scenario!="string"||d.scenario.length>40)&&l.push(n.scenarioName(`${u}.scenario`)),l)}),typeof s.default=="string"&&!i.has(s.default)&&l.push(n.defaultInOptions(`${a}.default`))}}return l})}function Lg(e,t,n){const o=e.find(a=>a.id===t),s=o?.from?e.find(a=>a.id===o.from?.source):o;if(!o||!s)return[];const r=o.from?{...s,id:o.id,from:o.from}:o;return pe(r,n).filter(a=>a.name!==cn)}const Rl=128,_l=40,Ig=["result_id","row_key","scenario_id","scenario_name","run_id","as_of","computed_at","app_id","source_id"];function Mg(e,t,n){const o=ko(),s=`${n}.model.saveAs`;if(!te(e))return[o.object(s)];const r=Object.keys(e).filter(l=>l!=="name").map(l=>o.noOption(s,l)),a=typeof e.name=="string"?e.name.trim():"";a?[...a].length>Rl&&r.push(o.saveAsNameLong(`${s}.name`,Rl)):r.push(o.saveAsName(`${s}.name`));for(const l of t)l.length>_l&&r.push(o.outputTooLong(`${n}.model.outputs`,l,_l)),Ig.includes(l)&&r.push(o.outputFixedName(`${n}.model.outputs`,l));return r}function qg(e,t,n){const{sources:o,kn:s,variables:r,scenarioParams:a}=t,l=ko(),c=e.model;if(!te(c))return[l.object(`${n}.model`)];const i=Object.keys(c).filter(m=>!["tool","inputs","params","outputs","landing","saveAs"].includes(m)).map(m=>l.noOption(`${n}.model`,m));e.objectType!==kr(e.id)&&i.push(l.objectTypeMustBe(`${n}.objectType`,kr(e.id)));for(const m of["cypher","events","from","models","follows","relatedTo","computed","progress"])e[m]!==void 0&&i.push(l.notForModelSource(`${n}.${m}`));const d=te(c.tool)?c.tool:null;!d||typeof d.box!="string"||!d.box||typeof d.tool!="string"?i.push(l.tool(`${n}.model.tool`)):d.tool||i.push(l.required(`${n}.model.tool.tool`));const h=Array.isArray(c.inputs)?c.inputs:null;if(!h||h.length===0||h.length>Al)i.push(l.inputsCount(`${n}.model.inputs`,Al));else{const m=new Set;h.forEach((y,b)=>{const k=`${n}.model.inputs[${b}]`;if(!te(y))return i.push(l.object(k));typeof y.name!="string"||!Mn.test(y.name)?i.push(l.idFormat(`${k}.name`)):m.has(y.name)?i.push(l.idTwice(`${k}.name`,y.name)):m.add(y.name);const w=o.find(j=>j.id===y.source);if(!w||w.id===e.id)return i.push(l.inputSource(`${k}.source`));const v=w.from?o.find(j=>j.id===w.from?.source):w;if(!v)return i.push(l.inputBaseMissing(`${k}.source`));if(v.events)return i.push(l.inputEvents(`${k}.source`));if(w.from?.filters?.length&&i.push(l.inputFollows(`${k}.source`)),v.cypher)for(const[j,O]of Object.entries(v.cypher.params??{}))r.find(E=>E.name===O)?.kind!=="asOf"&&i.push(l.inputQueryParam(`${k}.source`,j));const S=new Set(Lg(o,w.id,s).map(j=>j.name));return!Array.isArray(y.fields)||y.fields.length===0?i.push(l.inputFieldsEmpty(`${k}.fields`)):y.fields.forEach((j,O)=>{(typeof j!="string"||!S.has(j))&&i.push(l.inputField(`${k}.fields[${O}]`))}),i});const g=y=>{const b=new Set,k=w=>{if(w===e.id)return!0;if(b.has(w))return!1;b.add(w);const v=o.find(S=>S.id===w);return v?.model?xl(o,v).some(k):!1};return k(y)};xl(o,e).some(g)&&i.push(l.inputsLoop(`${n}.model.inputs`))}const u=c.params===void 0?[]:Array.isArray(c.params)?c.params:null;if(!u||u.length>Tl)i.push(l.paramsCount(`${n}.model.params`,Tl));else{const m=new Set;u.forEach((g,y)=>{const b=`${n}.model.params[${y}]`;if(!te(g))return i.push(l.object(b));if(typeof g.name!="string"||!Mn.test(g.name)?i.push(l.idFormat(`${b}.name`)):m.has(g.name)?i.push(l.idTwice(`${b}.name`,g.name)):m.add(g.name),!lt.includes(g.type))return i.push(l.oneOf(`${b}.type`,lt.join(l.joiner)));if(g.param!==void 0){const k=a.find(w=>w.name===g.param);k?k.type!==g.type&&i.push(l.paramTypeDiffers(`${b}.param`,k.type)):i.push(l.notScenarioParam(`${b}.param`)),g.value!==void 0&&i.push(l.paramNoValue(b))}else(g.type==="number"?typeof g.value!="number":typeof g.value!="string"||g.type==="date"&&!Ed.test(g.value))&&i.push(l.paramValue(`${b}.value`));return i})}const p=Array.isArray(c.outputs)?c.outputs:null,f=new Set;return!p||p.length<2||p.length>Ol+1?i.push(l.outputsCount(`${n}.model.outputs`,Ol)):p.forEach((m,g)=>{const y=`${n}.model.outputs[${g}]`;return te(m)?(typeof m.name!="string"||!Mn.test(m.name)?i.push(l.idFormat(`${y}.name`)):f.has(m.name)?i.push(l.idTwice(`${y}.name`,m.name)):f.add(m.name),(typeof m.label!="string"||!m.label.trim())&&i.push(l.required(`${y}.label`)),lt.includes(m.type)||i.push(l.oneOf(`${y}.type`,lt.join(l.joiner))),i):i.push(l.object(y))}),p&&!f.has(String(e.key))&&i.push(l.keyMustBeOutput(`${n}.key`)),c.landing!==void 0&&i.push(...Fg(c.landing,e,s,n)),c.saveAs!==void 0&&i.push(...Mg(c.saveAs,f,n)),i}function Fg(e,t,n,o){const s=ko(),r=`${o}.model.landing`;if(!te(e))return[s.object(r)];const a=[],l=Cd(t).properties,c=new Set(l.map(f=>f.name));e.when!==void 0&&a.push(...xe(e.when,l,`${r}.when`));const i=te(e.object)?e.object:null,d=typeof i?.type=="string"?i.type:"",h=d&&!d.includes(":")&&Object.hasOwn(n.objectTypes,d)?n.objectTypes[d]:void 0;if(h||a.push(s.knObjectType(`${r}.object.type`)),(!i||typeof i.field!="string"||!c.has(i.field))&&a.push(s.mustBeModelOutput(`${r}.object.field`)),e.action===void 0)return a;const u=te(e.action)?e.action:null;if(!u||typeof u.id!="string")return[...a,s.required(`${r}.action.id`)];if(["object","new"].includes(String(u.target))||a.push(s.actionTarget(`${r}.action.target`)),n.actionTypes===void 0)return a;const p=ln(n,u.id);if(!p)return[...a,s.actionType(`${r}.action.id`)];if(u.target==="object"&&h&&p.objectType!==h.id&&a.push(s.actionObjectType(`${r}.action.id`,h.id)),u.target==="new"){p.kind!=="add"&&a.push(s.actionNewIsAdd(`${r}.action.id`));const f=n.objectTypes[p.objectType],m=te(u.newObject)?u.newObject:null;if(!m||typeof m.prefix!="string"||!m.prefix.trim()||m.prefix.length>Nl)a.push(s.prefix(`${r}.action.newObject.prefix`,Nl));else if(f){const g=m.keyField??f.primaryKeys[0];if((typeof g!="string"||!f.primaryKeys.includes(g))&&a.push(s.keyField(`${r}.action.newObject.keyField`,f.id)),m.fields!==void 0)if(!te(m.fields))a.push(s.object(`${r}.action.newObject.fields`));else for(const[k,w]of Object.entries(m.fields))f.properties.some(v=>v.name===k)?k===g&&a.push(s.numberField(`${r}.action.newObject.fields.${k}`)):a.push(s.notPropertyOf(`${r}.action.newObject.fields.${k}`,f.id)),(typeof w!="string"||!c.has(w))&&a.push(s.mustTakeOutput(`${r}.action.newObject.fields.${k}`));const y=te(m.fields)?m.fields:{},b=te(u.params)?u.params:{};for(const k of p.inputs)k.property&&k.name!==g&&!Object.hasOwn(y,k.name)&&!Object.hasOwn(b,k.name)&&a.push(s.mustGive(`${r}.action.newObject.fields.${k.name}`))}}if(u.params!==void 0){if(!te(u.params))return[...a,s.object(`${r}.action.params`)];const f=(m,g)=>te(m)?m.from==="field"?c.has(String(m.name))?[]:[s.mustBeModelOutput(`${g}.name`)]:m.from==="const"?typeof m.value=="string"||typeof m.value=="number"?[]:[s.textOrNumber(`${g}.value`)]:[s.fromFieldOrConst(`${g}.from`)]:[s.object(g)];for(const[m,g]of Object.entries(u.params)){const y=`${r}.action.params.${m}`;if(!p.inputs.some(b=>b.name===m)){a.push(s.notUserParam(y));continue}if(!(te(g)&&g.from==="ask")){if(te(g)&&g.from==="item"){if(!te(g.fields)||Object.keys(g.fields).length===0)a.push(s.fieldsAtLeastOne(`${y}.fields`));else for(const[b,k]of Object.entries(g.fields))b.trim()||a.push(s.fieldNameEmpty(`${y}.fields`)),a.push(...f(k,`${y}.fields.${b}`));continue}a.push(...f(g,y))}}}return a}const Dg={object:e=>`${e}.cypher 必须是对象`,objectType:(e,t)=>`${e}.objectType 必须是 ${t}`,queryRequired:e=>`${e}.cypher.query 必填`,readOnly:e=>`${e}.cypher.query 只能是只读查询,不能写数据`,columnsMin:e=>`${e}.cypher.columns 至少要有一列`,nameRequired:e=>`${e}.name 必填`,nameTwice:(e,t)=>`${e}.name ${t} 重复`,columnType:e=>`${e}.type 只能是 date、number、text`,unbound:(e,t)=>`${e} 查询里的 $${t} 没有绑定页面变量`,notVariable:(e,t)=>`${e}.cypher.params.${t} 不是页面变量`,badKind:(e,t,n)=>`${e}.cypher.params.${t} 不能绑定 ${n} 变量`},Bg={object:e=>`${e}.cypher must be an object`,objectType:(e,t)=>`${e}.objectType must be ${t}`,queryRequired:e=>`${e}.cypher.query is required`,readOnly:e=>`${e}.cypher.query must be a read-only query, it cannot write data`,columnsMin:e=>`${e}.cypher.columns needs at least one column`,nameRequired:e=>`${e}.name is required`,nameTwice:(e,t)=>`${e}.name ${t} is used twice`,columnType:e=>`${e}.type must be one of date, number, text`,unbound:(e,t)=>`${e}: $${t} in the query is not bound to a page variable`,notVariable:(e,t)=>`${e}.cypher.params.${t} is not a page variable`,badKind:(e,t,n)=>`${e}.cypher.params.${t} cannot be bound to a ${n} variable`},Nd=()=>fe({"zh-CN":Dg,"en-US":Bg}),Ug="cypher:";function vr(e){return`${Ug}${e}`}const zg=["asOf","value","search","selection"];function xd(e,t){if(!Array.isArray(t))return e;const n={};for(const o of t){if(o&&typeof o.id=="string"&&o.events&&!o.cypher){const a=Eg(o.id,typeof o.label=="string"?o.label:o.id);n[a.id]=a;continue}if(o&&typeof o.id=="string"&&o.model&&!o.cypher){const a=Cd(o);n[a.id]=a;continue}if(!o||typeof o.id!="string"||!o.cypher)continue;const s=Array.isArray(o.cypher.columns)?o.cypher.columns:[],r=vr(o.id);n[r]={id:r,name:typeof o.label=="string"?o.label:o.id,primaryKeys:typeof o.key=="string"?[o.key]:[],displayKey:typeof o.key=="string"?o.key:"",properties:s.filter(a=>a&&typeof a.name=="string").map(a=>({name:a.name,label:typeof a.label=="string"&&a.label?a.label:a.name,type:["date","number","text"].includes(a.type)?a.type:"text"}))}}return Object.keys(n).length===0?e:{...e,objectTypes:{...e.objectTypes,...n}}}function Rd(e){return e.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`[^`]*`/g,t=>" ".repeat(t.length))}function Wg(e){const t=[...Rd(e).matchAll(/\$([A-Za-z_][A-Za-z0-9_]*)/g)].map(n=>n[1]);return[...new Set(t)]}const Kg=/\b(CREATE|MERGE|SET|DELETE|DETACH|REMOVE|DROP|CALL|LOAD|FOREACH)\b/i;function Yg(e,t){const n=Nd(),o=[],s=e.cypher;if(typeof s!="object"||s===null)return[n.object(t)];if(e.objectType!==vr(String(e.id))&&o.push(n.objectType(t,vr(String(e.id)))),typeof s.query!="string"||s.query.trim()===""?o.push(n.queryRequired(t)):Kg.test(Rd(s.query))&&o.push(n.readOnly(t)),!Array.isArray(s.columns)||s.columns.length===0)o.push(n.columnsMin(t));else{const r=new Set;s.columns.forEach((a,l)=>{const c=`${t}.cypher.columns[${l}]`;if(typeof a?.name!="string"||a.name==="")return o.push(n.nameRequired(c));r.has(a.name)&&o.push(n.nameTwice(c,a.name)),r.add(a.name),["date","number","text"].includes(a.type)||o.push(n.columnType(c))})}return o}function Gg(e,t,n){if(!e.cypher)return[];const o=Nd(),s=[],r=e.cypher.params??{};for(const a of Wg(e.cypher.query))r[a]||s.push(o.unbound(n,a));for(const[a,l]of Object.entries(r)){const c=t.find(i=>i.name===l);c?zg.includes(c.kind)||s.push(o.badKind(n,a,c.kind)):s.push(o.notVariable(n,a))}return s}new TextEncoder;const Hg=/\{([^{}]+)\}/g;function Vg(e){return[...e.matchAll(Hg)].map(t=>t[1].trim())}const Jg={object:e=>`${e} 必须是对象`,noOption:(e,t)=>`${e} 没有配置项 ${t}`,identifier:e=>`${e} 必须是字母开头的标识`,duplicate:(e,t)=>`${e} 重复:${t}`,pathCount:(e,t)=>`${e} 必须是 1 到 ${t} 个关系类 id`,notPath:(e,t)=>`${e} 不是从 ${t} 出发、沿知识网络关系的路径`,pathEnd:(e,t,n)=>`${e} 终点是 ${t},应到 ${n}`,fromSource:e=>`${e} 必须是页面中的数据源`,fromLinkable:e=>`${e} 必须是知识网络对象类的数据源,不能是子集或查询`,list:(e,t)=>`${e} 必须是不超过 ${t} 项的列表`,dateProperty:(e,t)=>`${e} 必须是 ${t} 的日期属性`,notKey:e=>`${e} 不能是对象的主键或标识`,integerRange:(e,t)=>`${e} 必须是 -${t} 到 ${t} 的整数`,sameAsField:e=>`${e} 不能与 field 相同`},Zg={object:e=>`${e} must be an object`,noOption:(e,t)=>`${e} has no option ${t}`,identifier:e=>`${e} must be an identifier starting with a letter`,duplicate:(e,t)=>`${e} is used twice: ${t}`,pathCount:(e,t)=>`${e} must be 1 to ${t} relation type ids`,notPath:(e,t)=>`${e} is not a path from ${t} along relations of the knowledge network`,pathEnd:(e,t,n)=>`${e} ends at ${t}, but should end at ${n}`,fromSource:e=>`${e} must be a source of the page`,fromLinkable:e=>`${e} must be a source of an object type of the knowledge network, not a subset or a query`,list:(e,t)=>`${e} must be a list of at most ${t} items`,dateProperty:(e,t)=>`${e} must be a date property of ${t}`,notKey:e=>`${e} cannot be the primary key or identifier of the object`,integerRange:(e,t)=>`${e} must be an integer from -${t} to ${t}`,sameAsField:e=>`${e} cannot be the same as field`},vo=()=>fe({"zh-CN":Jg,"en-US":Zg}),$r=5,Sr=3,to=3,no=365,oo=1439,_d=/^[A-Za-z][A-Za-z0-9_]*$/,Pd=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Xg=e=>!e.from&&!e.cypher&&!e.events;function Ld(e,t,n,o,s){if(!t)return[];const r=vo();if(!Array.isArray(e)||e.length===0||e.length>to||!e.every(c=>typeof c=="string"))return[r.pathCount(s,to)];const a=io(o,t.objectType,e);return a?a[a.length-1].to===n.objectType?[]:[r.pathEnd(s,bh(o,t.objectType,e),n.objectType)]:[r.notPath(s,t.objectType)]}function Id(e,t,n){const o=vo(),s=t.find(r=>r.id===e);return s?Xg(s)?{source:s,errors:[]}:{errors:[o.fromLinkable(n)]}:{errors:[o.fromSource(n)]}}const Ps=(e,t,n)=>e.objectTypes[t]?.properties.find(o=>o.name===n&&o.type==="date");function Qg(e,t,n,o,s){const r=vo();if(!Array.isArray(e)||e.length>$r)return[r.list(s,$r)];const a=o.objectTypes[t.objectType],l=new Set;return e.flatMap((c,i)=>{const d=`${s}[${i}]`;if(!Pd(c))return[r.object(d)];const h=Object.keys(c).filter(p=>!["id","field","from","path","fromField","gapDays","gapMinutes","keepDuration"].includes(p)).map(p=>r.noOption(d,p));typeof c.id!="string"||!_d.test(c.id)?h.push(r.identifier(`${d}.id`)):l.has(c.id)?h.push(r.duplicate(`${d}.id`,c.id)):l.add(c.id),Ps(o,t.objectType,c.field)?(c.field===t.key||a?.primaryKeys.includes(String(c.field)))&&h.push(r.notKey(`${d}.field`)):h.push(r.dateProperty(`${d}.field`,t.objectType));const u=Id(c.from,n,`${d}.from`);return h.push(...u.errors),h.push(...Ld(c.path,u.source,t,o,`${d}.path`)),u.source&&!Ps(o,u.source.objectType,c.fromField)&&h.push(r.dateProperty(`${d}.fromField`,u.source.objectType)),(typeof c.gapDays!="number"||!Number.isInteger(c.gapDays)||Math.abs(c.gapDays)>no)&&h.push(r.integerRange(`${d}.gapDays`,no)),c.gapMinutes!==void 0&&(typeof c.gapMinutes!="number"||!Number.isInteger(c.gapMinutes)||Math.abs(c.gapMinutes)>oo)&&h.push(r.integerRange(`${d}.gapMinutes`,oo)),c.keepDuration!==void 0&&(Ps(o,t.objectType,c.keepDuration)?c.keepDuration===c.field?h.push(r.sameAsField(`${d}.keepDuration`)):a?.primaryKeys.includes(c.keepDuration)&&h.push(r.notKey(`${d}.keepDuration`)):h.push(r.dateProperty(`${d}.keepDuration`,t.objectType))),h})}function ey(e,t,n,o,s){const r=vo();if(!Array.isArray(e)||e.length>Sr)return[r.list(s,Sr)];const a=new Set;return e.flatMap((l,c)=>{const i=`${s}[${c}]`;if(!Pd(l))return[r.object(i)];const d=Object.keys(l).filter(u=>!["id","from","path"].includes(u)).map(u=>r.noOption(i,u));typeof l.id!="string"||!_d.test(l.id)?d.push(r.identifier(`${i}.id`)):a.has(l.id)?d.push(r.duplicate(`${i}.id`,l.id)):a.add(l.id);const h=Id(l.from,n,`${i}.from`);return d.push(...h.errors),d.push(...Ld(l.path,h.source,t,o,`${i}.path`)),d})}const ty={notString:"default 必须是字符串",noDefault:e=>`${e} 变量不能有默认值`,asOf:"基准日期的默认值必须是 today 或 YYYY-MM-DD",dateRange:"日期区间的默认值必须是 YYYY-MM-DD..YYYY-MM-DD(可省略一端)"},ny={notString:"default must be a string",noDefault:e=>`a ${e} variable cannot have a default`,asOf:"the default of a base date must be today or YYYY-MM-DD",dateRange:"the default of a date range must be YYYY-MM-DD..YYYY-MM-DD (either end may be left out)"},oy=()=>fe({"zh-CN":ty,"en-US":ny}),sy="today",Pl=/^\d{4}-\d{2}-\d{2}$/,ry=["asOf","value","dateRange","search"],ay="..";function iy(e){const t=e.default;if(t===void 0)return null;const n=oy();if(typeof t!="string")return n.notString;if(!ry.includes(e.kind))return n.noDefault(e.kind);switch(e.kind){case"asOf":return t===sy||Pl.test(t)&&!Number.isNaN(Date.parse(t))?null:n.asOf;case"dateRange":{const o=t.split(ay);return o.length===2&&o.every(r=>r===""||Pl.test(r))&&o.some(r=>r!=="")?null:n.dateRange}default:return null}}const so=2e3,ly=["title","type","severity","object","occurredAt"],Ll="detail.",cy=/\{([A-Za-z_][A-Za-z0-9_]*(?:\.[^{}\s]*)?)\}/g,dy=e=>ly.includes(e)||e.startsWith(Ll)&&e.length>Ll.length;function uy(e){const t=[...e.matchAll(cy)].map(n=>n[1]);return[...new Set(t.filter(n=>!dy(n)))]}const hy={object:e=>`${e} 必须是对象`,noOption:(e,t)=>`${e} 没有配置项 ${t}`,required:e=>`${e} 必填`,boolean:e=>`${e} 必须是 true 或 false`,hours:(e,t)=>`${e} 必须是 1 分钟到 ${t} 小时之间的时长,以小时计,可精确到分钟(如 0.5 为 30 分钟)`,strategyActionsObject:e=>`${e} 必须是对象:处理方案 → { action, params? }`,notStrategy:e=>`${e} 不是这个事件类型的处理方案`,boundShape:e=>`${e} 必须是 { action, params? }`,noSubjectSource:(e,t)=>`${e} 要对事件的关联对象执行行动,应用里还没有「${t}」的数据源`,eventTypesList:()=>"eventTypes 必须是列表",unknownEventType:(e,t)=>`${e} 里的 ${t} 不是应用处理的事件类型`,inNetwork:e=>`${e} 在知识网络里设置:应用只配置怎样处理这类事件`,typeCode:e=>`${e} 必须是知识网络的事件类型编码:小写字母或数字开头,只含小写字母、数字、_、. 和 -,最长 64 个字符`,duplicate:e=>`事件类型 ${e} 重复`,owners:e=>`${e} 必须是最多 8 个角色名`,reportRule:e=>`${e} 只用于用户登记的事件`,strategies:e=>`${e} 必须是最多 12 个、每个不超过 40 字的处理方案名称`,groupingShape:e=>`${e} 必须是 { mode, by? }`,groupingMode:(e,t)=>`${e} 只能是 ${t.join("、")}`,groupingByOnly:e=>`${e} 只用于按属性归并`,groupingByName:e=>`${e} 必须是属性名`,groupingNoSource:(e,t)=>`${e} 按属性归并要从关联对象取值,应用里还没有「${t}」的数据源`,groupingByProperty:e=>`${e} 必须是关联对象的属性`,analysisPage:(e,t)=>`${e} 必须是应用的页面之一${t?`:${t.join("、")}`:""}`,analysisSelection:e=>`${e} 必须是选中对象筛选`,analysisSelectionOther:e=>`${e} 选中的是另一类对象,和事件关联的对象对不上`,analysisAsOfNone:e=>`${e} 页面没有基准日期`,analysisWindowShape:e=>`${e} 必须是 { variable, days }`,analysisWindowVariable:e=>`${e} 必须是日期区间筛选`,analysisWindowDays:e=>`${e} 必须是 1 到 365 的整数(天)`,mergeHours:e=>`${e} 是事件类型的合并窗口,在知识网络里设置`,fieldsList:e=>`${e} 必须是最多 12 项的列表`,fieldName:e=>`${e} 必须是小写字母开头的字段名`,fieldDuplicate:(e,t)=>`${e} ${t} 重复`,fieldType:(e,t)=>`${e} 只能是 ${t.join("、")}`,verifier:e=>`${e} 必须是角色名`,canvasText:(e,t)=>`${e} 必须是不超过 ${t} 字的文字`,canvasPlaceholder:(e,t)=>`${e} 里的 {${t}} 不是事件的值:可用 {title}、{type}、{severity}、{object}、{occurredAt} 与 {detail.<字段>}`},py={object:e=>`${e} must be an object`,noOption:(e,t)=>`${e} has no option ${t}`,required:e=>`${e} is required`,boolean:e=>`${e} must be true or false`,hours:(e,t)=>`${e} must be a length of time from 1 minute to ${t} hours, in hours, to the minute (0.5 is 30 minutes)`,strategyActionsObject:e=>`${e} must be an object: strategy -> { action, params? }`,notStrategy:e=>`${e} is not a strategy of this event type`,boundShape:e=>`${e} must be { action, params? }`,noSubjectSource:(e,t)=>`${e} runs an action on the event's object, but the app has no source for "${t}"`,eventTypesList:()=>"eventTypes must be a list",unknownEventType:(e,t)=>`${e} has ${t}, which is not an event type the app handles`,inNetwork:e=>`${e} is set in the knowledge network: the app only configures how events of this type are handled`,typeCode:e=>`${e} must be the event type code of the knowledge network: starts with a lowercase letter or digit, only lowercase letters, digits, _, . and -, at most 64 characters`,duplicate:e=>`event type ${e} is used twice`,owners:e=>`${e} must be at most 8 role names`,reportRule:e=>`${e} is only for events reported by users`,strategies:e=>`${e} must be at most 12 strategy names, each at most 40 characters`,groupingShape:e=>`${e} must be { mode, by? }`,groupingMode:(e,t)=>`${e} must be one of ${t.join(", ")}`,groupingByOnly:e=>`${e} is only for grouping by property`,groupingByName:e=>`${e} must be a property name`,groupingNoSource:(e,t)=>`${e} groups by a property of the event's object, but the app has no source for "${t}"`,groupingByProperty:e=>`${e} must be a property of the event's object`,analysisPage:(e,t)=>`${e} must be one of the app's pages${t?`: ${t.join(", ")}`:""}`,analysisSelection:e=>`${e} must be a selected-object filter`,analysisSelectionOther:e=>`${e} selects another kind of object than the one the event is about`,analysisAsOfNone:e=>`${e} the page has no as-of date`,analysisWindowShape:e=>`${e} must be { variable, days }`,analysisWindowVariable:e=>`${e} must be a date range filter`,analysisWindowDays:e=>`${e} must be an integer from 1 to 365 (days)`,mergeHours:e=>`${e} is the merge window of the event type: set it in the knowledge network`,fieldsList:e=>`${e} must be a list of at most 12 items`,fieldName:e=>`${e} must be a field name starting with a lowercase letter`,fieldDuplicate:(e,t)=>`${e} ${t} is used twice`,fieldType:(e,t)=>`${e} must be one of ${t.join(", ")}`,verifier:e=>`${e} must be a role name`,canvasText:(e,t)=>`${e} must be text of at most ${t} characters`,canvasPlaceholder:(e,t)=>`${e}: {${t}} is not a value of the event; use {title}, {type}, {severity}, {object}, {occurredAt} or {detail.<field>}`},bt=()=>fe({"zh-CN":hy,"en-US":py}),fy=/^[a-z0-9][a-z0-9_.-]{0,63}$/,my=/^[a-z][a-z0-9_-]{0,39}$/,Il=720,gy=new Set(["id","owners","dueHours","report","analysis","grouping","strategies","strategyActions","canvas"]),yy=new Set(["label","source","subject","severity","rule"]),We=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),by=(e,t)=>e===void 0||typeof e=="number"&&Math.abs(e*60-Math.round(e*60))<1e-6&&e*60>=1&&e<=Il?[]:[bt().hours(t,Il)],Md=(e,t)=>e.objectType&&t.kn.objectTypes[e.objectType]?.name||e.objectType||"";function wy(e,t,n,o){const s=bt();if(!We(e.strategyActions))return[s.strategyActionsObject(o)];const r=Array.isArray(e.strategies)?e.strategies:[];return Object.entries(e.strategyActions).flatMap(([a,l])=>{const c=`${o}.${a}`;if(!r.includes(a))return[s.notStrategy(c)];if(!We(l))return[s.boundShape(c)];const i=Object.keys(l).filter(d=>d!=="action"&&d!=="params");return i.length>0?i.map(d=>s.noOption(c,d)):t.network?t.subject?dc({on:"button",...l},{on:["button"],hit:!0},n,t.subject,c):[s.noSubjectSource(c,Md(t,n))]:[]})}function ky(e,t,n){const o=bt();if(e!==void 0&&!Array.isArray(e))return[o.eventTypesList()];const s=Array.isArray(e)?e:[],r=en(t.kn.eventTypes),a=new Set,l=new Set(s.map(i=>We(i)?i.id:void 0));return[...t.spec.sources.flatMap((i,d)=>(i.events?.types??[]).filter(h=>!l.has(h)).map(h=>o.unknownEventType(`sources[${d}].events.types`,h))),...s.flatMap((i,d)=>{const h=`eventTypes[${d}]`;if(!We(i))return[o.object(h)];const u=[];for(const f of Object.keys(i))yy.has(f)?u.push(o.inNetwork(`${h}.${f}`)):gy.has(f)||u.push(o.noOption(h,f));if(typeof i.id!="string"||!fy.test(i.id))return u.push(o.typeCode(`${h}.id`)),u;a.has(i.id)?u.push(o.duplicate(i.id)):a.add(i.id);const p=Lc(t.spec,i,r);return i.owners!==void 0&&!(Array.isArray(i.owners)&&i.owners.length<=8&&i.owners.every(f=>typeof f=="string"&&f.trim()!==""))&&u.push(o.owners(`${h}.owners`)),u.push(...by(i.dueHours,`${h}.dueHours`)),i.report!==void 0&&(p.source==="rule"?u.push(o.reportRule(`${h}.report`)):u.push(...jy(i.report,`${h}.report`))),i.analysis!==void 0&&u.push(...$y(i.analysis,p,t,n,`${h}.analysis`)),i.grouping!==void 0&&u.push(...vy(i.grouping,p,t,`${h}.grouping`)),i.strategies!==void 0&&!(Array.isArray(i.strategies)&&i.strategies.length<=12&&i.strategies.every(f=>typeof f=="string"&&f.trim()!==""&&f.length<=40))&&u.push(o.strategies(`${h}.strategies`)),i.strategyActions!==void 0&&u.push(...wy(i,p,t,`${h}.strategyActions`)),i.canvas!==void 0&&u.push(...Sy(i.canvas,`${h}.canvas`)),u})]}function vy(e,t,n,o){const s=bt();if(!We(e))return[s.groupingShape(o)];const r=[];for(const l of Object.keys(e))l!=="mode"&&l!=="by"&&r.push(s.noOption(o,l));if(!Hs.includes(e.mode))return[...r,s.groupingMode(`${o}.mode`,Hs)];if(e.mode!=="property")return e.by!==void 0&&r.push(s.groupingByOnly(`${o}.by`)),r;if(typeof e.by!="string"||e.by.trim()==="")return[...r,s.groupingByName(`${o}.by`)];if(t.source!=="report")return r;const a=ue(n.spec,t.subject);return a?pe(a,n.kn).some(l=>l.name===e.by)||r.push(s.groupingByProperty(`${o}.by`)):r.push(s.groupingNoSource(o,Md(t,n))),r}function $y(e,t,n,o,s){const r=bt();if(!We(e))return[r.object(s)];const a=[];for(const c of Object.keys(e))["page","selection","asOf","window"].includes(c)||a.push(r.noOption(s,c));(typeof e.page!="string"||o&&!o.includes(e.page))&&a.push(r.analysisPage(`${s}.page`,o));const l=c=>n.spec.variables.find(i=>i.name===c);if(e.selection!==void 0){const c=l(e.selection);!c||c.kind!=="selection"?a.push(r.analysisSelection(`${s}.selection`)):t.network&&ue(n.spec,c.source)?.objectType!==t.objectType&&a.push(r.analysisSelectionOther(`${s}.selection`))}if(e.asOf!==void 0&&(typeof e.asOf!="boolean"?a.push(r.boolean(`${s}.asOf`)):e.asOf&&!n.spec.variables.some(c=>c.kind==="asOf")&&a.push(r.analysisAsOfNone(`${s}.asOf`))),e.window!==void 0){const c=e.window;if(!We(c))a.push(r.analysisWindowShape(`${s}.window`));else{l(c.variable)?.kind!=="dateRange"&&a.push(r.analysisWindowVariable(`${s}.window.variable`));const i=c.days;(typeof i!="number"||!Number.isInteger(i)||i<1||i>365)&&a.push(r.analysisWindowDays(`${s}.window.days`))}}return a}function Sy(e,t){const n=bt();if(!We(e))return[n.object(t)];const o=[];for(const[s,r]of Object.entries(e)){const a=`${t}.${s}`;if(s!=="prompt"&&s!=="question")o.push(n.noOption(t,s));else if(typeof r!="string"||r.length>so)o.push(n.canvasText(a,so));else for(const l of uy(r))o.push(n.canvasPlaceholder(a,l))}return o}function jy(e,t){const n=bt();if(!We(e))return[n.object(t)];const o=[];for(const r of Object.keys(e))r==="mergeHours"?o.push(n.mergeHours(`${t}.mergeHours`)):r!=="fields"&&r!=="verifier"&&o.push(n.noOption(t,r));const s=e.fields;if(!Array.isArray(s)||s.length>12)o.push(n.fieldsList(`${t}.fields`));else{const r=new Set;s.forEach((a,l)=>{const c=`${t}.fields[${l}]`;if(!We(a))return o.push(n.object(c));typeof a.name!="string"||!my.test(a.name)?o.push(n.fieldName(`${c}.name`)):r.has(a.name)?o.push(n.fieldDuplicate(`${c}.name`,a.name)):r.add(a.name),(typeof a.label!="string"||a.label.trim()==="")&&o.push(n.required(`${c}.label`)),Gs.includes(a.type)||o.push(n.fieldType(`${c}.type`,Gs)),a.required!==void 0&&typeof a.required!="boolean"&&o.push(n.boolean(`${c}.required`))})}return e.verifier!==void 0&&(typeof e.verifier!="string"||e.verifier.trim()==="")&&o.push(n.verifier(`${t}.verifier`)),o}const Ay={join:e=>e.join("、"),pageNotObject:"页面定义必须是对象",appNotObject:"App Spec 必须是对象",emptyApp:"应用至少要放一个组件",pagePrefix:(e,t)=>`页面 ${e}:${t}`,component:e=>`组件 ${e}`,object:e=>`${e} 必须是对象`,array:e=>`${e} 必须是数组`,required:e=>`${e} 必填`,identifier:e=>`${e} 必须是字母开头的标识`,nonEmptyString:e=>`${e} 必须是非空字符串`,oneOf:(e,t)=>`${e} 只能是 ${t}`,either:(e,t,n)=>`${e} 只能是 ${t} 或 ${n}`,integer:(e,t,n)=>`${e} 必须是 ${t} 到 ${n} 的整数`,noOption:(e,t)=>`${e} 没有配置项 ${t}`,notField:e=>`${e} 不是数据源的字段`,version:"version 必须为 2",apiVersion:e=>`apiVersion 必须为 ${e}`,appId:"app.id 必须是字母或数字开头的标识",knDependency:(e,t)=>`dependencies.knowledgeNetwork 必须引用知识网络 ${e}(${t})`,pagesMin:"pages 至少要有一个页面",pageTwice:e=>`页面 id ${e} 重复`,navShown:"至少要有一个页面在导航中显示",customType:e=>`${e}.type 必须是 x-<发布者>.<名称> 形式的自定义组件类型`,customTwice:e=>`自定义组件 ${e} 登记了两次`,packageId:e=>`${e}.package 必须是上传后得到的组件包 id`,asideWidth:"layout.asideWidth(或 0)",chartPaletteSize:"theme.chartPalette 必须有 6 到 8 个颜色",chartPaletteHex:"theme.chartPalette 中的颜色必须是 #rrggbb",fontFamily:"theme.fontFamily 必须是字体名称列表",hexColor:e=>`${e} 必须是 #rrggbb 颜色`,contrast:(e,t,n,o)=>`${e} 与 ${t} 对比度 ${n},需不低于 ${o}`,sourcesMin:"sources 至少要有一个数据源",sourceTwice:e=>`数据源 ${e} 重复`,notObjectType:e=>`${e}.objectType 不是知识网络中的对象类`,notProperty:(e,t)=>`${e}.key 不是 ${t} 的属性`,onlyObjectSources:e=>`${e} 只能用于知识网络对象类的数据源`,modelOperationAction:e=>`${e}.action 模型结果数据源上的推演操作不能关联行动,请用落地`,notScenarioParam:e=>`${e} 不是方案参数`,scenarioParamType:e=>`${e} 的类型与方案参数不同`,displayShape:e=>`${e} 必须是 { template, facts? }`,templateNeedsField:e=>`${e}.template 至少要用 {字段名} 引用一个字段`,templateNotField:(e,t)=>`${e}.template 中的 {${t}} 不是数据源的字段`,factsList:(e,t)=>`${e}.facts 必须是不超过 ${t} 个字段名的列表`,factsNotField:(e,t)=>`${e}.facts 中的 ${t} 不是数据源的字段`,formatsShape:e=>`${e} 必须是 { 字段名: 格式 } 的对象`,formatShape:e=>`${e} 必须是 { unit?, decimals?, colors? }`,unitText:e=>`${e}.unit 必须是不超过 8 字的文本`,unitNumber:e=>`${e}.unit 只有数字字段有单位`,decimalsInt:(e,t)=>`${e}.decimals 必须是 0 到 ${t} 的整数`,decimalsNumber:e=>`${e}.decimals 只有数字字段有小数位`,colorsList:e=>`${e}.colors 必须是 [{ when, tone }] 的列表`,ruleShape:e=>`${e} 必须是 { when, tone }`,fromShape:e=>`${e}.from 必须是 { source, where?, filters? }`,fromNotSource:(e,t)=>`${e}.from.source 不是页面数据源:${t}`,fromSubset:e=>`${e}.from.source 不能是另一个子集`,fromCypherParams:e=>`${e}.from.source 不能是带参数的 Cypher 数据源`,sameAsBase:(e,t,n)=>`${e}.${t} 必须与来源数据源一致:${n}`,derivedOwn:(e,t)=>`${e}.${t} 子集沿用来源数据源的,不能自己定义`,variableTwice:e=>`变量 ${e} 重复`,variableDefault:(e,t)=>`${e}.default:${t}`,variableSource:e=>`${e}.source 不是页面数据源`,variableNoLonger:e=>`${e} 不再需要:筛选不绑数据源,由跟随它的组件各自指定字段`,componentTwice:e=>`组件 id ${e} 重复`,noRegion:(e,t,n)=>`${e} 布局没有区域 ${t},可用区域:${n}`,customNoPackage:(e,t)=>`${e}.type ${t} 是自定义组件,但应用的 components 里没有它的组件包:先上传组件包`,typeOneOf:(e,t)=>`${e}.type 只能是 ${t},或 components 里登记的自定义组件`,pageEmpty:"页面至少要放一个组件",detailType:e=>`detail 必须是 type 为 ${e} 的组件`,frameShape:e=>`${e} 必须给出 x、y、w、h`,frameRight:(e,t)=>`${e} 超出右边界:x + w 不能大于 ${t}`,frameSmall:(e,t,n,o)=>`${e} 太小:${t} 至少 ${n} 列宽、${o} 行高`},Ty={join:e=>e.join(", "),pageNotObject:"page definition must be an object",appNotObject:"App Spec must be an object",emptyApp:"the app needs at least one component",pagePrefix:(e,t)=>`page ${e}: ${t}`,component:e=>`component ${e}`,object:e=>`${e} must be an object`,array:e=>`${e} must be an array`,required:e=>`${e} is required`,identifier:e=>`${e} must be an identifier starting with a letter`,nonEmptyString:e=>`${e} must be a non-empty string`,oneOf:(e,t)=>`${e} must be one of ${t}`,either:(e,t,n)=>`${e} must be ${t} or ${n}`,integer:(e,t,n)=>`${e} must be an integer from ${t} to ${n}`,noOption:(e,t)=>`${e} has no option ${t}`,notField:e=>`${e} is not a field of the source`,version:"version must be 2",apiVersion:e=>`apiVersion must be ${e}`,appId:"app.id must be an identifier starting with a letter or digit",knDependency:(e,t)=>`dependencies.knowledgeNetwork must refer to knowledge network ${e} (${t})`,pagesMin:"pages needs at least one page",pageTwice:e=>`page id ${e} is used twice`,navShown:"at least one page must be shown in the navigation",customType:e=>`${e}.type must be a custom component type of the form x-<publisher>.<name>`,customTwice:e=>`custom component ${e} is registered twice`,packageId:e=>`${e}.package must be the id of an uploaded component package`,asideWidth:"layout.asideWidth (or 0)",chartPaletteSize:"theme.chartPalette must have 6 to 8 colors",chartPaletteHex:"theme.chartPalette colors must be #rrggbb",fontFamily:"theme.fontFamily must be a list of font names",hexColor:e=>`${e} must be a #rrggbb color`,contrast:(e,t,n,o)=>`${e} and ${t} have a contrast of ${n}, at least ${o} is needed`,sourcesMin:"sources needs at least one source",sourceTwice:e=>`source ${e} is used twice`,notObjectType:e=>`${e}.objectType is not an object type of the knowledge network`,notProperty:(e,t)=>`${e}.key is not a property of ${t}`,onlyObjectSources:e=>`${e} only applies to sources of knowledge network object types`,modelOperationAction:e=>`${e}.action: a scenario operation on a model result source cannot link an action, use landing`,notScenarioParam:e=>`${e} is not a scenario parameter`,scenarioParamType:e=>`${e} has a different type than the scenario parameter`,displayShape:e=>`${e} must be { template, facts? }`,templateNeedsField:e=>`${e}.template must refer to at least one field as {field name}`,templateNotField:(e,t)=>`{${t}} in ${e}.template is not a field of the source`,factsList:(e,t)=>`${e}.facts must be a list of at most ${t} field names`,factsNotField:(e,t)=>`${t} in ${e}.facts is not a field of the source`,formatsShape:e=>`${e} must be an object of { field name: format }`,formatShape:e=>`${e} must be { unit?, decimals?, colors? }`,unitText:e=>`${e}.unit must be text of at most 8 characters`,unitNumber:e=>`${e}.unit applies to number fields only`,decimalsInt:(e,t)=>`${e}.decimals must be an integer from 0 to ${t}`,decimalsNumber:e=>`${e}.decimals applies to number fields only`,colorsList:e=>`${e}.colors must be a list of [{ when, tone }]`,ruleShape:e=>`${e} must be { when, tone }`,fromShape:e=>`${e}.from must be { source, where?, filters? }`,fromNotSource:(e,t)=>`${e}.from.source is not a source of the page: ${t}`,fromSubset:e=>`${e}.from.source cannot be another subset`,fromCypherParams:e=>`${e}.from.source cannot be a Cypher source with parameters`,sameAsBase:(e,t,n)=>`${e}.${t} must match the source it comes from: ${n}`,derivedOwn:(e,t)=>`${e}.${t} is taken from the source the subset comes from and cannot be set here`,variableTwice:e=>`variable ${e} is used twice`,variableDefault:(e,t)=>`${e}.default: ${t}`,variableSource:e=>`${e}.source is not a source of the page`,variableNoLonger:e=>`${e} is no longer needed: a filter is not bound to a source, each component that follows it names its own field`,componentTwice:e=>`component id ${e} is used twice`,noRegion:(e,t,n)=>`${e} layout has no region ${t}, available regions: ${n}`,customNoPackage:(e,t)=>`${e}.type ${t} is a custom component, but components of the app has no component package for it: upload the component package first`,typeOneOf:(e,t)=>`${e}.type must be one of ${t}, or a custom component registered in components`,pageEmpty:"a page needs at least one component",detailType:e=>`detail must be a component of type ${e}`,frameShape:e=>`${e} must give x, y, w, h`,frameRight:(e,t)=>`${e} goes past the right edge: x + w must not exceed ${t}`,frameSmall:(e,t,n,o)=>`${e} is too small: ${t} needs at least ${n} columns wide and ${o} rows high`},we=()=>fe({"zh-CN":Ay,"en-US":Ty}),Ml=/^#[0-9a-fA-F]{6}$/,$o=/^[A-Za-z][A-Za-z0-9_-]{0,39}$/,Oy=/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/,Ey=["colorPrimary","colorAccent","colorBg","colorSurface","colorSurfaceAlt","colorBorder","colorText","colorTextMuted","colorSuccess","colorWarning","colorDanger","colorInfo"],jr=4.5,Ar=3;function Cy(e,t,n={}){const o=we(),s=[],r=c=>s.push(c);if(!K(e))return{ok:!1,errors:[o.pageNotObject]};const a=xd(t,e.sources);if(e.version!==2&&r(o.version),(typeof e.title!="string"||e.title.trim()==="")&&r(o.nonEmptyString("title")),_y(e.layout,r),Py(e.theme,r),s.length>0)return{ok:!1,errors:s};if(Ly(e.sources,a,r,n.allowEmpty??!1),s.length>0)return{ok:!1,errors:s};if(Uy(e.variables,e,r),s.length>0)return{ok:!1,errors:s};if(e.sources.forEach((c,i)=>Gg(c,e.variables,`sources[${i}]`).forEach(r)),s.length>0)return{ok:!1,errors:s};if(Pg(e.scenarioParams).forEach(r),s.length>0)return{ok:!1,errors:s};if(Dy(e,a,r),s.length>0)return{ok:!1,errors:s};if(By(e,a,r),s.length>0)return{ok:!1,errors:s};const l=e;return zy(e,{kn:a,spec:l},r,n.allowEmpty??!1),s.length>0?{ok:!1,errors:s}:{ok:!0,spec:l}}const Ny=()=>we().emptyApp;function qd(e,t,n={}){const o=we();if(!K(e))return{ok:!1,errors:[o.appNotObject]};const s=[],r=u=>s.push(u);e.apiVersion!==pt&&r(o.apiVersion(String(pt)));const a=e.app;K(a)?((typeof a.id!="string"||!Oy.test(a.id))&&r(o.appId),(typeof a.name!="string"||a.name.trim()==="")&&r(o.nonEmptyString("app.name"))):r(o.object("app"));const l=K(e.dependencies)?e.dependencies.knowledgeNetwork:void 0;(!K(l)||l.id!==t.id)&&r(o.knDependency(t.id,t.name));const c=e.pages;if(!Array.isArray(c)||c.length===0)r(o.pagesMin);else{const u=new Set;c.forEach((p,f)=>{if(!K(p))return r(o.object(`pages[${f}]`));if(typeof p.id!="string"||!$o.test(p.id))return r(o.identifier(`pages[${f}].id`));u.has(p.id)&&r(o.pageTwice(p.id)),u.add(p.id)}),c.every(p=>K(p)&&p.hidden===!0)&&r(o.navShown)}if(xy(e.components,r),s.length>0)return{ok:!1,errors:s};const i=e,d=new Set;if(i.pages.reduce((u,p)=>u+Object.values(p.regions??{}).reduce((f,m)=>f+(m?.length??0),0),0)===0&&!n.allowEmpty)return{ok:!1,errors:[Ny()]};if(!n.allowEmpty&&Array.isArray(i.sources)&&i.sources.length===0)return{ok:!1,errors:[o.sourcesMin]};for(const u of i.pages){const p=Cy(tn(i,u.id),t,{allowEmpty:!0});if(!p.ok)for(const f of p.errors)d.has(f)||(d.add(f),s.push(i.pages.length>1?o.pagePrefix(u.id,f):f))}return s.length>0?{ok:!1,errors:s}:(s.push(...ky(e.eventTypes,{kn:xd(t,i.sources),spec:tn(i,i.pages[0].id)},i.pages.map(u=>u.id))),e.scheduleModel!==void 0&&s.push(...vg(e.scheduleModel)),s.length>0?{ok:!1,errors:s}:{ok:!0,app:i})}function xy(e,t){if(e===void 0)return;const n=we();if(!Array.isArray(e))return t(n.array("components"));const o=new Set;e.forEach((s,r)=>{const a=`components[${r}]`;if(!K(s))return t(n.object(a));if(!Rt(s.type))return t(n.customType(a));o.has(s.type)&&t(n.customTwice(s.type)),o.add(s.type),(typeof s.package!="string"||!Ry.test(s.package))&&t(n.packageId(a)),s.source!==void 0&&!Ne(s.source,["upload","ai"])&&t(n.either(`${a}.source`,"upload","ai"))})}const Ry=/^[0-9a-f]{64}$/;function _y(e,t){const n=we();if(!K(e))return t(n.object("layout"));Ne(e.type,Ds)||t(n.oneOf("layout.type",n.join(Ds))),Ie(e.columns,2,4,"layout.columns",t),Ne(e.sidePosition,["left","right"])||t(n.either("layout.sidePosition","left","right")),Ie(e.sideWidth,220,420,"layout.sideWidth",t),e.asideWidth!==0&&Ie(e.asideWidth,240,420,n.asideWidth,t),Ne(e.gap,["compact","normal","relaxed"])||t(n.oneOf("layout.gap",n.join(["compact","normal","relaxed"]))),e.pinRows!==void 0&&Ie(e.pinRows,0,xr,"layout.pinRows",t)}function Py(e,t){const n=we();if(!K(e))return t(n.object("theme"));const o=[],s=c=>o.push(c);(typeof e.name!="string"||e.name.trim()==="")&&s(n.nonEmptyString("theme.name")),Ne(e.mode,["light","dark"])||s(n.either("theme.mode","light","dark"));for(const c of Ey)(typeof e[c]!="string"||!Ml.test(e[c]))&&s(n.hexColor(`theme.${c}`));const r=e.chartPalette;if(!Array.isArray(r)||r.length<6||r.length>8?s(n.chartPaletteSize):r.every(c=>typeof c=="string"&&Ml.test(c))||s(n.chartPaletteHex),(typeof e.fontFamily!="string"||e.fontFamily.trim()===""||/[;{}<>]/.test(e.fontFamily))&&s(n.fontFamily),Ie(e.fontSize,12,16,"theme.fontSize",s),Ie(e.radius,0,16,"theme.radius",s),Ne(e.shadow,Bs)||s(n.oneOf("theme.shadow",n.join(Bs))),Ne(e.density,Us)||s(n.oneOf("theme.density",n.join(Us))),e.surface!==void 0&&!Ne(e.surface,_t)&&s(n.oneOf("theme.surface",n.join(_t))),o.forEach(t),o.length>0)return;const a=e.colorText;for(const c of["colorBg","colorSurface"]){const i=Fl(a,e[c]);i<jr&&t(n.contrast("colorText",c,i.toFixed(2),jr))}const l=Fl(e.colorTextMuted,e.colorSurface);l<Ar&&t(n.contrast("colorTextMuted","colorSurface",l.toFixed(2),Ar))}function Ly(e,t,n,o){const s=we();if(!Array.isArray(e))return n(s.sourcesMin);if(e.length===0)return o?void 0:n(s.sourcesMin);const r=new Set;e.forEach((a,l)=>{const c=`sources[${l}]`;if(!K(a))return n(s.object(c));if(typeof a.id!="string"||!$o.test(a.id)?n(s.identifier(`${c}.id`)):r.has(a.id)?n(s.sourceTwice(a.id)):r.add(a.id),(typeof a.label!="string"||a.label.trim()==="")&&n(s.required(`${c}.label`)),a.from!==void 0)return qy(a,e,t,c).forEach(n);if(a.model!==void 0){if(!K(a.model))return n(s.object(`${c}.model`))}else if(a.events!==void 0){const u=Cg(a,c);if(u.forEach(n),u.length>0)return}else if(a.cypher!==void 0){const u=Yg(a,c);if(u.forEach(n),u.length>0)return}const i=typeof a.objectType=="string"&&Object.hasOwn(t.objectTypes,a.objectType)?t.objectTypes[a.objectType]:void 0;if(!i)return n(s.notObjectType(c));((u,p)=>i.properties.find(m=>m.name===u)&&!0)(a.key)||n(s.notProperty(c,i.id)),Hp(a.progress,i.properties,`${c}.progress`).forEach(n);const h=K(a.progress)&&Array.isArray(a.progress.steps);Lh(a.computed,[...i.properties,...h?pc(a.progress):[]],`${c}.computed`,{kn:t,objectType:i.id,cypher:a.cypher!==void 0,progress:h,sources:e.filter(K),...typeof a.id=="string"?{source:a.id}:{}}).forEach(n),a.display!==void 0&&Iy(a.display,a,t,`${c}.display`).forEach(n),a.formats!==void 0&&My(a.formats,a,t,`${c}.formats`).forEach(n),a.operations!==void 0&&(a.cypher!==void 0||a.events!==void 0?n(s.onlyObjectSources(`${c}.operations`)):Hh(a.operations,a,t,`${c}.operations`).forEach(n)),a.models!==void 0&&(a.cypher!==void 0||a.events!==void 0||a.model!==void 0?n(s.onlyObjectSources(`${c}.models`)):ep(a.models,a,t,`${c}.models`).forEach(n));for(const u of["follows","relatedTo"]){if(a[u]===void 0)continue;if(a.cypher!==void 0||a.events!==void 0||a.model!==void 0){n(s.onlyObjectSources(`${c}.${u}`));continue}(u==="follows"?Qg:ey)(a[u],a,e.filter(K),t,`${c}.${u}`).forEach(n)}})}function Iy(e,t,n,o){const s=we();if(!K(e)||typeof e.template!="string")return[s.displayShape(o)];const r=[...t.cypher?.columns??[],...pe(t,n)],a=i=>r.some(d=>d.name===i),l=Object.keys(e).filter(i=>!["template","facts"].includes(i)).map(i=>s.noOption(o,i)),c=Vg(e.template);c.length===0&&l.push(s.templateNeedsField(o));for(const i of c)a(i)||l.push(s.templateNotField(o,i));if(e.facts!==void 0)if(!Array.isArray(e.facts)||e.facts.length>ba||!e.facts.every(i=>typeof i=="string"))l.push(s.factsList(o,ba));else for(const i of e.facts)a(i)||l.push(s.factsNotField(o,i));return l}function My(e,t,n,o){const s=we();if(!K(e))return[s.formatsShape(o)];const r=pe(t,n),a=dn(t),l=[];for(const[c,i]of Object.entries(e)){const d=`${o}.${c}`,h=r.find(u=>u.name===c);if(!h){l.push(s.notField(d));continue}if(!K(i)){l.push(s.formatShape(d));continue}for(const u of Object.keys(i))["unit","decimals","colors"].includes(u)||l.push(s.noOption(d,u));if(i.unit!==void 0&&(typeof i.unit!="string"||i.unit.length>8?l.push(s.unitText(d)):h.type!=="number"&&l.push(s.unitNumber(d))),i.decimals!==void 0){const u=i.decimals;typeof u!="number"||!Number.isInteger(u)||u<0||u>Ws?l.push(s.decimalsInt(d,Ws)):h.type!=="number"&&l.push(s.decimalsNumber(d))}if(i.colors!==void 0){if(!Array.isArray(i.colors)){l.push(s.colorsList(d));continue}i.colors.forEach((u,p)=>{const f=`${d}.colors[${p}]`;if(!K(u))return l.push(s.ruleShape(f));Ne(u.tone,Pt)||l.push(s.oneOf(`${f}.tone`,s.join(Pt))),l.push(...xe(u.when,r,`${f}.when`,a))})}}return l}function qy(e,t,n,o){const s=we(),r=e.from;if(!K(r)||typeof r.source!="string")return[s.fromShape(o)];const a=t.find(c=>K(c)&&c.id===r.source);if(!K(a))return[s.fromNotSource(o,r.source)];if(a.from!==void 0)return[s.fromSubset(o)];const l=[];K(a.cypher)&&K(a.cypher.params)&&Object.keys(a.cypher.params).length&&l.push(s.fromCypherParams(o)),e.objectType!==a.objectType&&l.push(s.sameAsBase(o,"objectType",String(a.objectType))),e.key!==a.key&&l.push(s.sameAsBase(o,"key",String(a.key)));for(const c of["progress","computed","cypher","formats","display","operations","follows","relatedTo","models"])c in e&&l.push(s.derivedOwn(o,c));for(const c of Object.keys(r))["source","where","filters"].includes(c)||l.push(s.noOption(`${o}.from`,c));if(r.where!==void 0){const c=ue({sources:t},e.id),i=c?pe(c,n):[];l.push(...xe(r.where,i,`${o}.from.where`,dn(c)))}return l}const Fy=[{key:"source",label:"来源数据源",kind:"source"},{key:"filters",label:"跟随的筛选",kind:"bindings",optional:!0}];function Dy(e,t,n){const o=we(),s=e.scenarioParams??[];e.sources.forEach((r,a)=>{const l=`sources[${a}]`;r.model&&(qg(r,{sources:e.sources,kn:t,variables:e.variables,scenarioParams:s},l).forEach(n),(r.operations??[]).forEach((c,i)=>{c?.action!==void 0&&n(o.modelOperationAction(`${l}.operations[${i}]`))})),(r.models??[]).forEach((c,i)=>(Array.isArray(c?.params)?c.params:[]).forEach((d,h)=>{if(d?.scenarioParam===void 0)return;const u=s.find(f=>f.name===d.scenarioParam),p=`${l}.models[${i}].params[${h}].scenarioParam`;u?u.type!==d.type&&n(o.scenarioParamType(p)):n(o.notScenarioParam(p))}))})}function By(e,t,n){e.sources.forEach((o,s)=>{if(!o.from?.filters)return;const r={source:o.from.source,filters:o.from.filters};vd(Fy,r,{kn:t,spec:e},`sources[${s}].from`).forEach(n)})}function Uy(e,t,n){const o=we();if(!Array.isArray(e))return n(o.array("variables"));const s=new Set;e.forEach((r,a)=>{const l=`variables[${a}]`;if(!K(r))return n(o.object(l));if(typeof r.name!="string"||!$o.test(r.name))return n(o.identifier(`${l}.name`));if(s.has(r.name)&&n(o.variableTwice(r.name)),s.add(r.name),(typeof r.label!="string"||r.label.trim()==="")&&n(o.required(`${l}.label`)),!Ne(r.kind,Gn))return n(o.oneOf(`${l}.kind`,o.join(Gn)));const c=iy(r);if(c&&n(o.variableDefault(l,c)),r.kind==="selection"||r.kind==="set")t.sources.some(i=>i.id===r.source)||n(o.variableSource(l));else for(const i of["source","field","fields"])i in r&&n(o.variableNoLonger(`${l}.${i}`))})}function zy(e,t,n,o){const s=we(),{layout:r,regions:a}=t.spec;if(!K(a))return n(s.object("regions"));const l=uc[r.type],c=new Set,i=new Set((t.spec.components??[]).map(p=>p.type));let d=0;const h=(p,f)=>{if(typeof p!="string"||!$o.test(p))return n(s.identifier(`${f}.id`));c.has(p)&&n(s.componentTwice(p)),c.add(p)};for(const[p,f]of Object.entries(a)){if(!l.includes(p)){n(s.noRegion(r.type,p,s.join(l)));continue}if(!Array.isArray(f)){n(s.array(`regions.${p}`));continue}f.forEach((m,g)=>{const y=`regions.${p}[${g}]`;if(!K(m))return n(s.object(y));h(m.id,y);const b=Rt(m.type);if(b&&!i.has(m.type))return n(s.customNoPackage(y,String(m.type)));if(!b&&!Ne(m.type,Ve))return n(s.typeOneOf(y,s.join(Ve)));const k=m.type;d++,m.span!==void 0&&Ie(m.span,1,4,`${y}.span`,n),m.surface!==void 0&&!Ne(m.surface,_t)&&n(s.oneOf(`${y}.surface`,s.join(_t))),r.type==="free"&&Wy(m.frame,k,`${s.component(String(m.id))}.frame`,n),ql(k,Rt(k)&&K(m.config)?cf(k,m.config):m.config,t,s.component(String(m.id)),n)})}d===0&&!o&&n(s.pageEmpty);const u=e.detail;if(u!==void 0){if(!K(u)||u.type!==me)return n(s.detailType(me));h(u.id,"detail"),ql(me,u.config,t,s.component(String(u.id)),n)}}function ql(e,t,n,o,s){const r=ht(e),a=vd(r.descriptors,t,n,o,r.free);a.forEach(s),a.length===0&&r.check&&r.check(t,n,o).forEach(s)}function Wy(e,t,n,o){const s=we();if(!K(e))return o(s.frameShape(n));Ie(e.x,0,At-1,`${n}.x`,o),Ie(e.w,1,At,`${n}.w`,o),Ie(e.y,0,400,`${n}.y`,o),Ie(e.h,2,40,`${n}.h`,o),typeof e.x=="number"&&typeof e.w=="number"&&e.x+e.w>At&&o(s.frameRight(n,At));const[r,a]=nf(t);(typeof e.w=="number"&&e.w<r||typeof e.h=="number"&&e.h<a)&&o(s.frameSmall(n,t,r,a))}function Fl(e,t){const[n,o]=[Dl(e),Dl(t)].sort((s,r)=>r-s);return(n+.05)/(o+.05)}function Dl(e){const t=n=>{const o=parseInt(e.slice(n,n+2),16)/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4};return .2126*t(1)+.7152*t(3)+.0722*t(5)}function K(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ne(e,t){return typeof e=="string"&&t.includes(e)}function Ie(e,t,n,o,s){(typeof e!="number"||!Number.isInteger(e)||e<t||e>n)&&s(we().integer(o,t,n))}const Ky="scheduleWorkbench",Yy=[{id:"topBottom",name:"上下布局 · 总览",description:"顶部是基准日期和关键指标,中间是趋势与地区分布,底部是整宽的明细表。",theme:"default",pages:[{title:"总览",cells:[["asOfSlider",0,0,12,3],["metricCards",0,3,12,4],["trendChart",0,7,8,8],["regionMap",8,7,4,8],["objectTable",0,15,12,11]]}]},{id:"leftRight",name:"左右布局 · 列表 + 详情",description:"左侧是待处理对象的长列表,右侧是指标、明细表和选中对象的关系子图。",theme:"default",pages:[{title:"列表与详情",cells:[["objectList",0,0,4,26],["metricCards",4,0,8,4],["objectTable",4,4,8,12],["subgraph",4,16,8,10]]}]},{id:"workbench",name:"三栏工作台",description:"左边收件箱、中间指标与明细、右边 Agent 对话,适合每天处理事务的岗位。",theme:"default",pages:[{title:"工作台",cells:[["objectList",0,0,3,24],["asOfSlider",3,0,6,3],["metricCards",3,3,6,4],["objectTable",3,7,6,17],["agentChat",9,0,3,24]]}]},{id:"cockpit",name:"驾驶舱",description:"深色大屏:大地图居中,配趋势、告警、关系链路与甘特图。",theme:"tech",pages:[{title:"驾驶舱",cells:[["metricCards",0,0,12,4],["regionMap",0,4,6,12],["trendChart",6,4,6,6],["alertList",6,10,6,6],["stageChain",0,16,12,4],["ganttChart",0,20,12,8]]}]},{id:"alertDesk",name:"告警处置台",description:"按规则列出告警,点一条只看它命中的对象,旁边看明细、关系子图并问 Agent。",theme:"default",pages:[{title:"告警处置",cells:[["alertList",0,0,4,12],["objectTable",4,0,8,12],["subgraph",0,12,6,10],["agentChat",6,12,6,10]]}]},{id:"analysis",name:"分析看板",description:"分组汇总、月度趋势、关系链路与地区分布并排,适合周会和复盘。",theme:"dark",pages:[{title:"分析",cells:[["asOfSlider",0,0,12,3],["pivotTable",0,3,6,8],["trendChart",6,3,6,8],["stageChain",0,11,12,4],["regionMap",0,15,5,9],["objectTable",5,15,7,9]]}]},{id:"production",name:"排程台",description:"按基准日期看甘特图,下方是明细与告警,盯住临近和超期的对象。",theme:"default",pages:[{title:"排程",cells:[["asOfSlider",0,0,5,4],["metricCards",5,0,7,4],["ganttChart",0,4,12,9],["objectTable",0,13,8,11],["alertList",8,13,4,11]]}]},{id:Ky,name:"资源排程工作台",description:"按向导回答排什么、排在哪、何时完成、结果写到哪里,生成按资源排行的调度甘特与方案改动;结果写入计划记录时另有只读的需求视角,可选再加一页所需资源与就绪。拖动改排程,采用前检查约束。",theme:"default",wizard:!0,pages:[{title:"排程",cells:[["scenarioBar",0,0,12,2,{title:"方案",style:"compact"}],["scheduleGantt",0,2,8,14,{title:"排程(按资源)"}],["scheduleGantt",0,16,8,9,{title:"所需资源与就绪(可选)"}],["scenarioBar",8,2,4,23,{title:"方案改动",style:"assumptions"}]]}]}],Fd={id:"blank"};function Gy(e){const t=Object.values(e.objectTypes).filter(o=>o.properties.length>0),n=o=>o.properties.some(s=>s.type==="date")?1:0;return[...t].sort((o,s)=>n(s)-n(o)||s.properties.length-o.properties.length)[0]}function Hy(e,t){const n=[{name:"asOf",label:"基准日期",kind:"asOf"},{name:"selected",label:`选中的${t.label}`,kind:"selection",source:t.id}];return(e.has("trendChart")||e.has("dateRange"))&&n.push({name:"period",label:"日期区间",kind:"dateRange"}),e.has("alertList")&&n.push({name:"flagged",label:"告警命中",kind:"set",source:t.id}),e.has("searchBox")&&n.push({name:"search",label:"搜索",kind:"search"}),n}const Bl=e=>JSON.parse(JSON.stringify(e));function Vy(e){const t=JSON.stringify(e.pages);return{...e,variables:e.variables.filter(n=>n.kind==="asOf"||t.includes(`"${n.name}"`))}}const Jy=e=>ze[e]?.category==="scenario";function Zy(e){return{...e,pages:e.pages.map(t=>{const n=t.regions.cells??[],o=tg(Object.fromEntries(n.flatMap(s=>s.frame?[[s.id,s.frame]]:[])));return{...t,regions:{cells:n.map(s=>o[s.id]?{...s,frame:o[s.id]}:s)}}})}}function Xy(e,t,n,o,{scenarios:s=!0}={}){const r=Yy.find(g=>g.id===e),a=o&&n.objectTypes[o]||(e===Fd.id?void 0:Gy(n)),l={apiVersion:pt,app:t,dependencies:{knowledgeNetwork:{id:n.id,name:n.name}},sources:[],variables:[{name:"asOf",label:"基准日期",kind:"asOf"}],pages:[{id:"main",title:"页面 1",layout:structuredClone(bl.free),regions:{}}],theme:{...structuredClone(Zn.default),surface:"plain"}};if(!a)return{spec:l,skipped:[]};const c={id:$g(tn(l,"main"),n,a.id),label:a.name,objectType:a.id,key:a.primaryKeys[0]??a.properties[0].name};if(!r)return{spec:{...l,sources:[c]},skipped:[]};const i=new Set(r.pages.flatMap(g=>g.cells.map(([y])=>y)));let d={...l,sources:[c],variables:Hy(i,c),pages:r.pages.map((g,y)=>({id:y===0?"main":`page${y+1}`,title:g.title,layout:structuredClone(bl.free),regions:{cells:[]}})),theme:{...structuredClone(Zn[r.theme]),surface:"plain"}};const h=[],u=new Set,p=g=>{for(let y=1;;y++)if(!u.has(`${g}${y}`))return`${g}${y}`},f=g=>qd(g,n,{allowEmpty:!0}).ok,m=a.properties.some(g=>g.type==="date");return r.pages.forEach((g,y)=>{const b=d.pages[y].id;for(const[S,j,O,A,E,x]of g.cells){if(!s&&Jy(S))continue;const I=tn(d,b),M={id:p(S),type:S,config:Bl({...ht(S).defaults(I,{kn:n,spec:I},c.id),...x}),frame:{x:j,y:O,w:A,h:E}},L=Qy(d,y,M);(S!=="asOfSlider"||m)&&f(L)?(d=L,u.add(M.id)):h.push(S)}const k=tn(d,b),w={id:y===0?"detail":`detail${y+1}`,type:me,config:Bl(ht(me).defaults(k,{kn:n,spec:k},c.id))},v={...d,pages:d.pages.map((S,j)=>j===y?{...S,detail:w}:S)};f(v)&&(d=v)}),{spec:Zy(Vy(d)),skipped:h}}function Qy(e,t,n){return{...e,pages:e.pages.map((o,s)=>s===t?{...o,regions:{cells:[...o.regions.cells??[],n]}}:o)}}const eb={usage:e=>`用法:workshop <命令> [参数] [选项]
|
|
154
|
+
`,p)+1}return{type:u,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(u){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;const p=a(u),f=l(p);return f.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:f,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;const p=a(u),f=l(p);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:f,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(u,p){return this.type!=="comment"||this.indent<=p?!1:u.every(f=>f.type==="newline"||f.type==="space")}*documentEnd(u){this.type!=="doc-mode"&&(u.end?u.end.push(this.sourceToken):u.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(u){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:u.end?u.end.push(this.sourceToken):u.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}}return _s.Parser=d,_s}var jt={},dl;function Bm(){if(dl)return jt;dl=1;var e=yd(),t=yo(),n=bo(),o=Qc(),s=B(),r=wd(),a=kd();function l(u){const p=u.prettyErrors!==!1;return{lineCounter:u.lineCounter||p&&new r.LineCounter||null,prettyErrors:p}}function c(u,p={}){const{lineCounter:f,prettyErrors:m}=l(p),g=new a.Parser(f?.addNewLine),y=new e.Composer(p),b=Array.from(y.compose(g.parse(u)));if(m&&f)for(const k of b)k.errors.forEach(n.prettifyError(u,f)),k.warnings.forEach(n.prettifyError(u,f));return b.length>0?b:Object.assign([],{empty:!0},y.streamInfo())}function i(u,p={}){const{lineCounter:f,prettyErrors:m}=l(p),g=new a.Parser(f?.addNewLine),y=new e.Composer(p);let b=null;for(const k of y.compose(g.parse(u),!0,u.length))if(!b)b=k;else if(b.options.logLevel!=="silent"){b.errors.push(new n.YAMLParseError(k.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return m&&f&&(b.errors.forEach(n.prettifyError(u,f)),b.warnings.forEach(n.prettifyError(u,f))),b}function d(u,p,f){let m;typeof p=="function"?m=p:f===void 0&&p&&typeof p=="object"&&(f=p);const g=i(u,f);if(!g)return null;if(g.warnings.forEach(y=>o.warn(g.options.logLevel,y)),g.errors.length>0){if(g.options.logLevel!=="silent")throw g.errors[0];g.errors=[]}return g.toJS(Object.assign({reviver:m},f))}function h(u,p,f){let m=null;if(typeof p=="function"||Array.isArray(p)?m=p:f===void 0&&p&&(f=p),typeof f=="string"&&(f=f.length),typeof f=="number"){const g=Math.round(f);f=g<1?void 0:g>8?{indent:8}:{indent:g}}if(u===void 0){const{keepUndefined:g}=f??p??{};if(!g)return}return s.isDocument(u)&&!m?u.toString(f):new t.Document(u,m,f).toString(f)}return jt.parse=d,jt.parseAllDocuments=c,jt.parseDocument=i,jt.stringify=h,jt}var ul;function Um(){if(ul)return W;ul=1;var e=yd(),t=yo(),n=ud(),o=bo(),s=uo(),r=B(),a=mt(),l=ce(),c=gt(),i=yt(),d=Jr(),h=bd(),u=wd(),p=kd(),f=Bm(),m=co();return W.Composer=e.Composer,W.Document=t.Document,W.Schema=n.Schema,W.YAMLError=o.YAMLError,W.YAMLParseError=o.YAMLParseError,W.YAMLWarning=o.YAMLWarning,W.Alias=s.Alias,W.isAlias=r.isAlias,W.isCollection=r.isCollection,W.isDocument=r.isDocument,W.isMap=r.isMap,W.isNode=r.isNode,W.isPair=r.isPair,W.isScalar=r.isScalar,W.isSeq=r.isSeq,W.Pair=a.Pair,W.Scalar=l.Scalar,W.YAMLMap=c.YAMLMap,W.YAMLSeq=i.YAMLSeq,W.CST=d,W.Lexer=h.Lexer,W.LineCounter=u.LineCounter,W.Parser=p.Parser,W.parse=f.parse,W.parseAllDocuments=f.parseAllDocuments,W.parseDocument=f.parseDocument,W.stringify=f.stringify,W.visit=m.visit,W.visitAsync=m.visitAsync,W}var Ge=Um();const zm=5*1024*1024,Wm=new Set([".js",".mjs",".css",".json",".svg",".png",".jpg",".webp",".woff2",".md"]),hl=["component","page"],pl=["filter","display","chart","relation"],Km=["value","dateRange","selection","set"],Ym=["query","act","ask","navigate"],fl=["string","number","integer","boolean","object","array"],Gm=new Set(["type","properties","required","items","enum","title","description","default","minimum","maximum","minItems","maxItems","maxLength","x-workshop"]),ml=["field","fields","variable","objectType","relationPath","actionType"],Hm=new Set(["widget","fieldTypes","maxHops","tab","showIf"]),gl=["data","display","link"],hr=["string","number","boolean","date","datetime","object"],yl={"zh-CN":{label:"{key} 须是对象,至少提供 zh-CN",required:"{key} 必填",size:"{key} 须是 { w: 1–12, h: ≥1 } 的整数",list:"{key} 只能是 {allowed} 的列表",object:"{at} 须是对象",unsupported:"{at} 不支持 {key}",oneOf:"{at} 只能是 {allowed}",typeOrEnum:"{at} 须有 type 或 enum",nonEmptyList:"{at} 须是非空列表",requiredNames:"{at} 只能列出 properties 中的配置项",manifestObject:"manifest.json 须是 JSON 对象",type:"type 须是 x-<前缀>.<名称>:前缀为小写字母、数字与连字符,名称为字母与数字",version:"version 须是 主.次.修订",workshopApi:"workshopApi 目前只能是 1",element:"element 须是含连字符的小写自定义元素名",description:"description 必填:写清展示什么、点了会怎样",data:"data 须是 { source: true|false, fields }",dataFields:"data.fields 须是 any,或 { role, type } 列表(type 为 {types})",boolean:"{key} 须是 true 或 false",network:"network 须是来源列表,如 https://risk.example.com(不带路径)",unreadable:"读不到 manifest.json:{message}",tooLarge:"包内文件共 {total} 字节,超过 5 MB",fileType:"不允许的文件类型:{name}",noEntry:"入口 {entry} 不存在",noElement:"入口中没有定义自定义元素 {element}",bigEntry:"入口超过 300 KB:首屏不需要的部分建议拆成分块",remoteScript:"{name} 从外部地址加载脚本:依赖须全部打进包里",syntax:"{name} 第 {line} 行有语法错误,浏览器加载不了:{message}",syntaxOldNode:"{name} 第 {line} 行在本机 Node {node} 下解析不了:{message}。Node 24 以前的版本不认识部分新语法,上传时以 Workshop 的检查为准;用 Node 24 及以上校验才能确定",evalUsed:"{name} 用了 eval 或 new Function:内容安全策略下会被拒绝",noReadme:"没有 README.md:每个组件都应附说明(本体契约、扩展点、场景配方)",noPreview:"没有 preview.json:组件库预览与本地开发都需要示例数据",and:"、"},"en-US":{label:"{key} must be an object with at least zh-CN",required:"{key} is required",size:"{key} must be whole numbers { w: 1–12, h: ≥1 }",list:"{key} must be a list of {allowed}",object:"{at} must be an object",unsupported:"{at} does not support {key}",oneOf:"{at} must be one of {allowed}",typeOrEnum:"{at} needs type or enum",nonEmptyList:"{at} must be a non-empty list",requiredNames:"{at} may only list items of properties",manifestObject:"manifest.json must be a JSON object",type:"type must be x-<prefix>.<name>: the prefix lowercase letters, digits and hyphens, the name letters and digits",version:"version must be major.minor.patch",workshopApi:"workshopApi can only be 1 for now",element:"element must be a lowercase custom element name with a hyphen",description:"description is required: say what it shows and what a click does",data:"data must be { source: true|false, fields }",dataFields:"data.fields must be any, or a list of { role, type } (type one of {types})",boolean:"{key} must be true or false",network:"network must be a list of origins, such as https://risk.example.com (no path)",unreadable:"Cannot read manifest.json: {message}",tooLarge:"The package's files take {total} bytes, over 5 MB",fileType:"File type not allowed: {name}",noEntry:"The entry {entry} does not exist",noElement:"The entry does not define the custom element {element}",bigEntry:"The entry is over 300 KB: split what the first screen does not need into chunks",remoteScript:"{name} loads a script from an outside address: bundle every dependency into the package",syntax:"{name} has a syntax error at line {line}, so the browser cannot load it: {message}",syntaxOldNode:"{name} does not parse at line {line} under this Node {node}: {message}. Node before 24 does not know some newer syntax, and the upload check decides; validate with Node 24 or later to be sure",evalUsed:"{name} uses eval or new Function, which the content security policy refuses",noReadme:"No README.md: every component should come with a guide (ontology contract, extension points, recipes)",noPreview:"No preview.json: the component library's preview and local development both need sample data",and:", "}};function Zr(e){const t=yl[e]??yl["zh-CN"],n=(o,s)=>cc(t[o],s);return n.list=o=>o.join(t.and),n}function bn(e){const t=[],n=o=>{for(const s of nn(o).sort()){if(s.startsWith(".")||s==="node_modules")continue;const r=G(o,s),a=Au(r);if(a.isDirectory())n(r);else{if(sc(s).toLowerCase()===".zip")continue;t.push({path:r,name:rc(e,r).split($u).join("/"),size:a.size})}}};return n(e),t}const De=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Et=e=>typeof e=="string"&&e.trim()!=="";function Vm(e,t,n,o){(!De(e)||!Et(e["zh-CN"]))&&n.push(o("label",{key:t}))}function bl(e,t,n,o,s){if(e===void 0){o&&n.push(s("required",{key:t}));return}(!(De(e)&&[e.w,e.h].every(a=>Number.isInteger(a)&&a>0))||e.w>12)&&n.push(s("size",{key:t}))}function pr(e,t,n,o,s){e!==void 0&&(!Array.isArray(e)||!e.every(r=>n.includes(r)))&&o.push(s("list",{key:t,allowed:s.list(n)}))}function fr(e,t="configSchema",n="zh-CN"){const o=Zr(n),s=[];if(!De(e))return[o("object",{at:t})];for(const a of Object.keys(e))Gm.has(a)||s.push(o("unsupported",{at:t,key:a}));if(e.type!==void 0&&!fl.includes(e.type)&&s.push(o("oneOf",{at:`${t}.type`,allowed:o.list(fl)})),e.type===void 0&&e.enum===void 0&&t!=="configSchema"&&s.push(o("typeOrEnum",{at:t})),e.enum!==void 0&&(!Array.isArray(e.enum)||e.enum.length===0)&&s.push(o("nonEmptyList",{at:`${t}.enum`})),e.properties!==void 0)if(!De(e.properties))s.push(o("object",{at:`${t}.properties`}));else for(const[a,l]of Object.entries(e.properties))s.push(...fr(l,`${t}.properties.${a}`,n));if(e.required!==void 0){const a=De(e.properties)?Object.keys(e.properties):[];(!Array.isArray(e.required)||!e.required.every(l=>a.includes(l)))&&s.push(o("requiredNames",{at:`${t}.required`}))}e.items!==void 0&&s.push(...fr(e.items,`${t}.items`,n));const r=e["x-workshop"];if(r!==void 0)if(!De(r))s.push(o("object",{at:`${t}.x-workshop`}));else{for(const a of Object.keys(r))Hm.has(a)||s.push(o("unsupported",{at:`${t}.x-workshop`,key:a}));r.widget!==void 0&&!ml.includes(r.widget)&&s.push(o("oneOf",{at:`${t}.x-workshop.widget`,allowed:o.list(ml)})),r.tab!==void 0&&!gl.includes(r.tab)&&s.push(o("oneOf",{at:`${t}.x-workshop.tab`,allowed:o.list(gl)})),r.fieldTypes!==void 0&&pr(r.fieldTypes,`${t}.x-workshop.fieldTypes`,hr,s,o),r.showIf!==void 0&&!De(r.showIf)&&s.push(o("object",{at:`${t}.x-workshop.showIf`}))}return s}function vd(e,t="zh-CN"){const n=Zr(t),o=[];if(!De(e))return[n("manifestObject")];const s=e;if(/^x-[a-z0-9-]+\.[A-Za-z][A-Za-z0-9]*$/.test(s.type??"")||o.push(n("type")),hl.includes(s.kind)||o.push(n("oneOf",{at:"kind",allowed:n.list(hl)})),/^\d+\.\d+\.\d+$/.test(s.version??"")||o.push(n("version")),s.workshopApi!==1&&o.push(n("workshopApi")),/^[a-z][a-z0-9]*(-[a-z0-9]+)+$/.test(s.element??"")||o.push(n("element")),Et(s.entry)||o.push(n("required",{key:"entry"})),Vm(s.label,"label",o,n),Et(s.description)||o.push(n("description")),s.kind!=="page"&&!pl.includes(s.category)&&o.push(n("oneOf",{at:"category",allowed:n.list(pl)})),o.push(...fr(s.configSchema,"configSchema",t)),!De(s.data)||typeof s.data.source!="boolean")o.push(n("data"));else if(s.data.fields!=="any"){const r=s.data.fields;Array.isArray(r)&&r.every(l=>De(l)&&Et(l.role)&&hr.includes(l.type))||o.push(n("dataFields",{types:n.list(hr)}))}return typeof s.follows!="boolean"&&o.push(n("boolean",{key:"follows"})),pr(s.emits,"emits",Km,o,n),pr(s.capabilities,"capabilities",Ym,o,n),s.describes!==void 0&&typeof s.describes!="boolean"&&o.push(n("boolean",{key:"describes"})),bl(s.defaultSize,"defaultSize",o,s.kind==="component",n),bl(s.minSize,"minSize",o,!1,n),s.network!==void 0&&(Array.isArray(s.network)&&s.network.every(a=>{try{const l=new URL(a);return["https:","http:","wss:"].includes(l.protocol)&&l.origin===a}catch{return!1}})||o.push(n("network"))),o}const Jm=24,Zm=[/^Private field '#[^']+' must be declared in an enclosing class$/,/^Identifier '[^']+' has already been declared$/,/^Unexpected end of input$/,/^Strict mode code may not include a with statement$/,/^Octal literals are not allowed in strict mode\.$/];function Xm(e){const t=yu(process.execPath,["--input-type=module","--check"],{input:e,encoding:"utf8"});if(t.status===0)return null;const n=`${t.stderr??""}${t.error?.message??""}`,o=Number(/^\[stdin\]:(\d+)/m.exec(n)?.[1]??0),s=/^\w*Error: (.+)$/m.exec(n)?.[1]??n.trim().split(`
|
|
155
|
+
`).at(-1);return{line:o,message:s}}function Qm(e,{language:t="zh-CN",nodeMajor:n=Number(process.versions.node.split(".")[0])}={}){const o=Zr(t),s=[],r=[];let a;try{a=JSON.parse(ct(G(e,"manifest.json"),"utf8"))}catch(h){return{ok:!1,errors:[o("unreadable",{message:h.message})],warnings:r,files:[]}}s.push(...vd(a,t));const l=bn(e),c=l.reduce((h,u)=>h+u.size,0);c>zm&&s.push(o("tooLarge",{total:c}));for(const h of l)Wm.has(sc(h.name).toLowerCase())||s.push(o("fileType",{name:h.name}));const i=Et(a.entry)?vu.normalize(a.entry.replace(/^\.\//,"")):null,d=l.find(h=>h.name===i);if(Et(a.entry)&&!d&&s.push(o("noEntry",{entry:a.entry})),d){const h=ct(d.path,"utf8");a.element&&!h.includes(a.element)&&s.push(o("noElement",{element:a.element})),d.size>300*1024&&r.push(o("bigEntry"))}for(const h of l.filter(u=>/\.(m?js)$/.test(u.name))){const u=ct(h.path,"utf8"),p=Xm(u),f=p&&Zm.some(m=>m.test(p.message));p&&(n>=Jm||f)?s.push(o("syntax",{name:h.name,...p})):p&&r.push(o("syntaxOldNode",{name:h.name,node:process.versions.node,...p})),(/import\s*\(\s*["'`]https?:\/\//.test(u)||/from\s+["']https?:\/\//.test(u))&&s.push(o("remoteScript",{name:h.name})),/\beval\s*\(|new\s+Function\s*\(/.test(u)&&r.push(o("evalUsed",{name:h.name}))}return l.some(h=>h.name==="README.md")||r.push(o("noReadme")),a.data?.source&&!l.some(h=>h.name==="preview.json")&&r.push(o("noPreview")),{ok:s.length===0,errors:s,warnings:r,files:l,manifest:a}}const eg=(()=>{const e=new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let o=0;o<8;o++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function $d(e){let t=4294967295;for(const n of e)t=eg[(t^n)&255]^t>>>8;return(t^4294967295)>>>0}function tg(e){const t=[],n=[];let o=0;const s=0,r=33;for(const{name:c,data:i}of e){const d=Buffer.from(c,"utf8"),h=xu(i),u=h.length>=i.length,p=u?i:h,f=$d(i),m=Buffer.alloc(30);m.writeUInt32LE(67324752,0),m.writeUInt16LE(20,4),m.writeUInt16LE(2048,6),m.writeUInt16LE(u?0:8,8),m.writeUInt16LE(s,10),m.writeUInt16LE(r,12),m.writeUInt32LE(f,14),m.writeUInt32LE(p.length,18),m.writeUInt32LE(i.length,22),m.writeUInt16LE(d.length,26),m.writeUInt16LE(0,28),t.push(m,d,p);const g=Buffer.alloc(46);g.writeUInt32LE(33639248,0),g.writeUInt16LE(20,4),g.writeUInt16LE(20,6),g.writeUInt16LE(2048,8),g.writeUInt16LE(u?0:8,10),g.writeUInt16LE(s,12),g.writeUInt16LE(r,14),g.writeUInt32LE(f,16),g.writeUInt32LE(p.length,20),g.writeUInt32LE(i.length,24),g.writeUInt16LE(d.length,28),g.writeUInt32LE(o,42),n.push(g,d),o+=m.length+d.length+p.length}const a=n.reduce((c,i)=>c+i.length,0),l=Buffer.alloc(22);return l.writeUInt32LE(101010256,0),l.writeUInt16LE(e.length,8),l.writeUInt16LE(e.length,10),l.writeUInt32LE(a,12),l.writeUInt32LE(o,16),Buffer.concat([...t,...n,l])}const wl={"zh-CN":{notZip:"不是 zip 文件",directory:"zip 的目录损坏",damaged:"zip 中 {name} 损坏",method:"zip 中 {name} 的压缩方式不支持"},"en-US":{notZip:"Not a zip file",directory:"The zip's directory is damaged",damaged:"{name} in the zip is damaged",method:"{name} in the zip is compressed in a way not supported"}};function ng(e,t="zh-CN"){const n=(c,i)=>cc((wl[t]??wl["zh-CN"])[c],i),o=Buffer.from(e.buffer,e.byteOffset,e.byteLength);let s=-1;for(let c=o.length-22;c>=Math.max(0,o.length-22-65535);c--)if(o.readUInt32LE(c)===101010256){s=c;break}if(s<0)throw new Error(n("notZip"));const r=o.readUInt16LE(s+10);let a=o.readUInt32LE(s+16);const l=[];for(let c=0;c<r;c++){if(a+46>o.length||o.readUInt32LE(a)!==33639248)throw new Error(n("directory"));const i=o.readUInt16LE(a+10),d=o.readUInt32LE(a+16),h=o.readUInt32LE(a+20),u=o.readUInt32LE(a+24),p=o.readUInt16LE(a+28),f=p+o.readUInt16LE(a+30)+o.readUInt16LE(a+32),m=o.readUInt32LE(a+42),g=o.toString("utf8",a+46,a+46+p);if(a+=46+f,g.endsWith("/"))continue;if(m+30>o.length||o.readUInt32LE(m)!==67324752)throw new Error(n("damaged",{name:g}));const y=m+30+o.readUInt16LE(m+26)+o.readUInt16LE(m+28),b=o.subarray(y,y+h);if(i!==0&&i!==8)throw new Error(n("method",{name:g}));const k=i===0?Buffer.from(b):Ru(b);if(k.length!==u||$d(k)!==d)throw new Error(n("damaged",{name:g}));l.push({name:g,data:k})}return l}const _n='"Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif',Xn={default:{name:"default",mode:"light",colorPrimary:"#255db0",colorAccent:"#6d4fc2",colorBg:"#f3f5f8",colorSurface:"#ffffff",colorSurfaceAlt:"#f8fafc",colorBorder:"#dfe5ec",colorText:"#203043",colorTextMuted:"#607086",colorSuccess:"#267257",colorWarning:"#9b4e12",colorDanger:"#b42318",colorInfo:"#1f6f9f",chartPalette:["#255db0","#e0883a","#2f9e77","#d0453a","#6d4fc2","#3a9fc0","#8a97a8"],fontFamily:_n,fontSize:13,radius:8,shadow:"subtle",density:"comfortable"},fresh:{name:"fresh",mode:"light",colorPrimary:"#0f7b6c",colorAccent:"#3b6fb6",colorBg:"#f3f6f5",colorSurface:"#ffffff",colorSurfaceAlt:"#f7faf9",colorBorder:"#dbe4e1",colorText:"#1f2d2b",colorTextMuted:"#5d6f6b",colorSuccess:"#237a4b",colorWarning:"#9a5b07",colorDanger:"#b42318",colorInfo:"#2a6f97",chartPalette:["#0f7b6c","#3b6fb6","#e0a33a","#7fb3a6","#c8553d","#6c63a8","#93a3a0"],fontFamily:_n,fontSize:13,radius:6,shadow:"none",density:"comfortable"},dark:{name:"dark",mode:"dark",colorPrimary:"#9bc1ff",colorAccent:"#c4b5fd",colorBg:"#141b24",colorSurface:"#202936",colorSurfaceAlt:"#1a222d",colorBorder:"#394659",colorText:"#ecf1f7",colorTextMuted:"#adbbce",colorSuccess:"#93d8bd",colorWarning:"#ffc38e",colorDanger:"#ff9e9e",colorInfo:"#8fd3f4",chartPalette:["#9bc1ff","#ffc38e","#93d8bd","#ff9e9e","#c4b5fd","#8fd3f4"],fontFamily:_n,fontSize:13,radius:8,shadow:"none",density:"comfortable"},tech:{name:"tech",mode:"dark",colorPrimary:"#3fd5ff",colorAccent:"#a493ff",colorBg:"#04080e",colorSurface:"#0a131f",colorSurfaceAlt:"#0d1828",colorBorder:"#1e3550",colorText:"#dce7f5",colorTextMuted:"#8193ab",colorSuccess:"#2ee6b6",colorWarning:"#ffb648",colorDanger:"#ff5470",colorInfo:"#5b8cff",chartPalette:["#3fd5ff","#ffb648","#2ee6b6","#ff5470","#a493ff","#5b8cff"],fontFamily:_n,fontSize:13,radius:4,shadow:"none",density:"compact"}},kl={free:{type:"free",columns:2,sidePosition:"left",sideWidth:300,asideWidth:0,gap:"normal"}};re.done.value;const mr=re.overdue.value,Sd=[re.active.value,mr],og={status:{variable:"status",field:"$status"},signed:{variable:"signed",field:"signing_date"},customer:{variable:"customer",field:"customer_name"},region:{variable:"region",field:"region"},search:{variable:"search",fields:["sales_order_id","customer_name","product_name"]},alert:{variable:"alert"}},jd=(...e)=>Object.entries(og).filter(([t])=>!e.includes(t)).map(([,t])=>t);jd("alert");Qt("$status",Sd);Qt("$status",Sd),Qt("$status",[mr]),Qt("$status",[mr]),jd();const sg=(e,t)=>e.x<t.x+t.w&&t.x<e.x+e.w&&e.y<t.y+t.h&&t.y<e.y+e.h;function rg(e,t,n){const o=[],s={},r=Object.entries(e).filter(([a])=>a!==t).sort(([,a],[,l])=>a.y-l.y||a.x-l.x);for(const[a,l]of r){const c=h=>!o.some(u=>sg({...l,y:h},u));let i=l.y;for(;i>0&&c(i-1);)i-=1;for(;!c(i);)i+=1;const d={...l,y:i};o.push(d),s[a]=d}return s}const ag={sep:"、",object:e=>`${e} 必须是对象`,array:e=>`${e} 必须是数组`,noOption:(e,t)=>`${e} 没有配置项 ${t}`,required:e=>`${e} 必填`,textMax:(e,t)=>`${e} 必须是不超过 ${t} 字的文本`,text:e=>`${e} 必须是文本`,numberRange:(e,t,n,o)=>`${e} 必须是 ${t} 到 ${n} 的${o?"数":"整数"}`,oneOf:(e,t)=>`${e} 只能是 ${t}`,bool:e=>`${e} 必须是 true 或 false`,sourceOneOf:(e,t)=>`${e} 必须是页面数据源之一:${t}`,pickProperty:e=>`${e} 至少选一个属性`,textList:e=>`${e} 必须是文本列表`,valueNotTaken:(e,t,n,o)=>`${e} 的取值「${t}」不是 ${n} 的取值(可选:${o})`,needSource:e=>`${e} 需要先选好数据源`,notObjectType:e=>`${e} 不是知识网络中的对象类`,operationOneOf:(e,t)=>`${e} 必须是数据源里定义的情景操作:${t}`,noOperations:"(数据源还没有情景操作)",operationProblem:(e,t)=>`${e} ${t}`,eventTypeOneOf:(e,t,n,o)=>`${e} 必须是应用的${t?"用户登记":""}事件类型${n?"列表":""}:${o}`,noEventTypes:"(还没有,先到「事件」页签新建)",actionIdList:e=>`${e} 必须是行动类型 id 的列表`,notAction:(e,t)=>`${e} 里的 ${t} 不是知识网络里的行动`,pickTool:e=>`${e} 要选工具箱和其中的一个工具`,pickMcpTool:e=>`${e} 要选 MCP 服务和其中的一个工具`,listSize:(e,t,n)=>`${e} 必须是 ${t} 到 ${n} 项的列表`,needSourceOrObjectType:e=>`${e} 需要先选好数据源或对象类`,propertyUnusable:(e,t)=>`${e} 不是可用的属性:${t}`,propertyOfType:(e,t)=>`${e} 必须是${t}属性`,typeNames:{date:"日期",number:"数字",text:"文本"},variableOneOf:(e,t)=>`${e} 必须是页面变量之一:${t}`,noVariables:"(没有可用变量)",objectsMismatch:(e,t)=>`${e} 筛选 ${t} 里是另一类对象,组件的数据源对不上`,list:e=>`${e} 必须是列表`,bindingShape:e=>`${e} 必须是 { variable, field? , fields? }`,filterOneOf:(e,t)=>`${e}.variable 必须是页面上的筛选之一:${t}`,noFilters:"(还没有筛选)",filterTwice:(e,t)=>`${e} 重复跟随筛选 ${t}`,bindingField:(e,t)=>`${e}.field 不是数据源的字段:${t}`,bindingDateField:e=>`${e}.field 必须是数据源的日期字段`,bindingTextFields:e=>`${e}.fields 必须是数据源的文本字段列表`,relationIds:e=>`${e} 必须是关系 ID 列表`,singleRelation:e=>`${e} 只能是一条关系:连线必须是知识网络里直接相连的关系,不能沿多条关系拼出来`,pathUnreachable:(e,t)=>`${e} 不是从 ${t} 出发连通的关系路径`,pathEnd:(e,t,n)=>`${e} 终点是 ${t},与 objectType ${n} 不一致`},ig={sep:", ",object:e=>`${e} must be an object`,array:e=>`${e} must be an array`,noOption:(e,t)=>`${e} has no option ${t}`,required:e=>`${e} is required`,textMax:(e,t)=>`${e} must be text of at most ${t} characters`,text:e=>`${e} must be text`,numberRange:(e,t,n,o)=>`${e} must be ${o?"a number":"an integer"} from ${t} to ${n}`,oneOf:(e,t)=>`${e} must be one of ${t}`,bool:e=>`${e} must be true or false`,sourceOneOf:(e,t)=>`${e} must be one of the page's sources: ${t}`,pickProperty:e=>`${e} needs at least one property`,textList:e=>`${e} must be a list of text`,valueNotTaken:(e,t,n,o)=>`${e} value "${t}" is not a value of ${n} (one of: ${o})`,needSource:e=>`${e} needs a source to be chosen first`,notObjectType:e=>`${e} is not an object type of the knowledge network`,operationOneOf:(e,t)=>`${e} must be a scenario operation defined on the source: ${t}`,noOperations:"(the source has no scenario operations yet)",operationProblem:(e,t)=>`${e} ${t}`,eventTypeOneOf:(e,t,n,o)=>`${e} must be ${n?"a list of ":"an "}${t?"user-reported ":""}event type${n?"s":""} of the app: ${o}`,noEventTypes:'(none yet; create one in the "Events" tab first)',actionIdList:e=>`${e} must be a list of action type ids`,notAction:(e,t)=>`${t} in ${e} is not an action of the knowledge network`,pickTool:e=>`${e} needs a toolbox and one of its tools`,pickMcpTool:e=>`${e} needs an MCP server and one of its tools`,listSize:(e,t,n)=>`${e} must be a list of ${t} to ${n} items`,needSourceOrObjectType:e=>`${e} needs a source or an object type to be chosen first`,propertyUnusable:(e,t)=>`${e} is not an available property: ${t}`,propertyOfType:(e,t)=>`${e} must be a ${t} property`,typeNames:{date:"date",number:"number",text:"text"},variableOneOf:(e,t)=>`${e} must be one of the page variables: ${t}`,noVariables:"(no variable available)",objectsMismatch:(e,t)=>`${e} filter ${t} holds another kind of object than the component's source`,list:e=>`${e} must be a list`,bindingShape:e=>`${e} must be { variable, field? , fields? }`,filterOneOf:(e,t)=>`${e}.variable must be one of the filters of the page: ${t}`,noFilters:"(no filter yet)",filterTwice:(e,t)=>`${e} follows filter ${t} twice`,bindingField:(e,t)=>`${e}.field is not a field of the source: ${t}`,bindingDateField:e=>`${e}.field must be a date field of the source`,bindingTextFields:e=>`${e}.fields must be a list of text fields of the source`,relationIds:e=>`${e} must be a list of relation ids`,singleRelation:e=>`${e} must be a single relation: a link must be a relation directly connecting objects in the knowledge network, not several relations chained`,pathUnreachable:(e,t)=>`${e} is not a connected relation path starting at ${t}`,pathEnd:(e,t,n)=>`${e} ends at ${t}, which differs from objectType ${n}`},Ze=()=>fe({"zh-CN":ag,"en-US":ig}),lg=80;function Ad(e,t,n,o,s={}){const r=Ze();if(!Ct(t))return[r.object(o)];const a=typeof t.source=="string"?t.source:void 0,l=[],c={...t};for(const[i,d]of Object.entries(s)){if(!(i in c))continue;const h=c[i];delete c[i],h!=null&&(d==="array"?!Array.isArray(h):!Ct(h))&&l.push(r[d](`${o}.${i}`))}return[...l,...Td(e,c,n,o,{sourceId:a,config:t})]}function cg(e,t){return{...t,sourceId:typeof e.source=="string"?e.source:t.sourceId,objectType:typeof e.objectType=="string"?e.objectType:t.objectType}}function dg(e,t,n,o,s){const r=t[e.key],a=`${o}.${e.key}`,l=e.neededAs?.(t);if(n.spec.linking==="auto"&&e.kind==="variable"&&!e.accepts.every(i=>i==="asOf")&&(r==null||r===""||r===!0&&!e.reads))return[];if(r==null||r==="")return!e.optional&&!e.notNeeded?.(t)||l?[Ze().required(a)]:[];const c=l&&e.kind==="field"?{...e,of:l}:e;return ug(c,r,n,a,s,t)}function Td(e,t,n,o,s){const r=Ze(),a=[],l=new Set(e.map(i=>i.key));for(const i of Object.keys(t))l.has(i)||a.push(r.noOption(o,i));const c=cg(t,s);for(const i of e)a.push(...dg(i,t,n,o,c));return a}function ug(e,t,n,o,s,r){const a=Ze(),l=un(ue(n.spec,s.sourceId));switch(e.kind){case"text":{if(e.max===null)return typeof t=="string"?[]:[a.text(o)];const c=e.max??lg;return typeof t=="string"&&t.length<=c?[]:[a.textMax(o,c)]}case"number":return typeof t=="number"&&Number.isFinite(t)&&(e.decimal===!0||Number.isInteger(t))&&t>=e.min&&t<=e.max?[]:[a.numberRange(o,e.min,e.max,e.decimal===!0)];case"enum":return e.options.some(([c])=>c===t)?[]:[a.oneOf(o,e.options.map(([c])=>c).join(a.sep))];case"bool":return typeof t=="boolean"?[]:[a.bool(o)];case"source":return n.spec.sources.some(c=>c.id===t)?[]:[a.sourceOneOf(o,n.spec.sources.map(c=>c.id).join(a.sep))];case"field":return vl(e,t,n,o,s);case"fields":return!Array.isArray(t)||t.length===0?[a.pickProperty(o)]:t.flatMap((c,i)=>vl(e,c,n,`${o}[${i}]`,s));case"variable":return hg(e.accepts,t,n,o,s);case"bindings":return pg(t,n,o,s);case"values":{if(!Array.isArray(t)||!t.every(d=>typeof d=="string"&&d!==""))return[a.textList(o)];const c=r[e.fieldKey]??s.config?.[e.fieldKey],i=typeof c=="string"?l(c):[];return i.length===0?[]:t.filter(d=>!i.includes(d)).map(d=>a.valueNotTaken(o,d,String(c),i.join(a.sep)))}case"conditions":{const c=Qn("source",n,s);return c===null?[a.needSource(o)]:xe(t,c,o,l)}case"objectType":return typeof t=="string"&&Object.hasOwn(n.kn.objectTypes,t)?[]:[a.notObjectType(o)];case"relationPath":return fg(t,n,o,s,e.single);case"operation":{const c=ue(n.spec,s.sourceId)?.operations??[],i=c.find(h=>h.id===t);if(!i)return[a.operationOneOf(o,c.map(h=>h.id).join(a.sep)||a.noOperations)];const d=e.fits?.(i,r);return d?[a.operationProblem(o,d)]:[]}case"eventType":{const i=(Array.isArray(n.spec.eventTypes)?Mn(n.spec,en(n.kn.eventTypes)):[]).filter(p=>!e.of||!p.source||p.source===e.of),d=p=>i.some(f=>f.id===p);if(e.multiple?Array.isArray(t)&&t.length>0&&t.every(d):d(t))return[];const u=i.map(p=>p.id).join(a.sep);return[a.eventTypeOneOf(o,e.of==="report",e.multiple===!0,u||a.noEventTypes)]}case"interactions":return Op(t,e,n,s.sourceId,Qn("source",n,s),o);case"actionTypes":{if(!Array.isArray(t)||t.some(i=>typeof i!="string"))return[a.actionIdList(o)];const c=n.kn.actionTypes;return c?t.filter(i=>!c.some(d=>d.id===i)).map(i=>a.notAction(o,String(i))):[]}case"metric":{const{place:c,category:i}=Kp(e.on,s.config??{});return Zp(t,n.kn,n.spec,s.sourceId,c,o,i)}case"tool":return Ct(t)&&typeof t.box=="string"&&t.box!==""&&typeof t.tool=="string"&&t.tool!==""?[]:[a.pickTool(o)];case"mcpTool":return Ct(t)&&typeof t.mcp=="string"&&t.mcp!==""&&typeof t.tool=="string"&&t.tool!==""&&[t.agentId,t.agentName].every(c=>c===void 0||typeof c=="string")?[]:[a.pickMcpTool(o)];case"list":return!Array.isArray(t)||t.length<e.min||t.length>e.max?[a.listSize(o,e.min,e.max)]:t.flatMap((c,i)=>Ct(c)?Td(e.item,c,n,`${o}[${i}]`,s):[a.object(`${o}[${i}]`)])}}const Od="$key";function vl(e,t,n,o,s){if(e.objectKey&&t===Od&&!e.of)return[];const r=Ze(),a=Qn(e.owner??"source",n,s);if(a===null)return[r.needSourceOrObjectType(o)];const l=a.find(c=>c.name===t);return l?e.of&&l.type!==e.of?[r.propertyOfType(o,r.typeNames[e.of])]:[]:[r.propertyUnusable(o,String(t))]}function hg(e,t,n,o,s){const r=Ze(),a=n.spec.variables.find(l=>l.name===t);if(!a||!e.includes(a.kind)){const l=n.spec.variables.filter(c=>e.includes(c.kind)).map(c=>c.name);return[r.variableOneOf(o,l.join(r.sep)||r.noVariables)]}return Cd(a,n,s)?[]:[Ed(o,a.name)]}const Ed=(e,t)=>Ze().objectsMismatch(e,t);function Cd(e,t,n){if(!("source"in e)||!n.sourceId)return!0;const o=s=>t.spec.sources.find(r=>r.id===s)?.objectType;return o(e.source)===o(n.sourceId)}function pg(e,t,n,o){const s=Ze();if(!Array.isArray(e))return[s.list(n)];if(e.length===0)return[];const r=Qn("source",t,o);if(r===null)return[s.needSource(n)];const a=c=>r.find(i=>i.name===c)?.type,l=new Set;return e.flatMap((c,i)=>{const d=`${n}[${i}]`;if(!Ct(c)||typeof c.variable!="string")return[s.bindingShape(d)];const h=t.spec.variables.find(u=>u.name===c.variable);if(!h||!wa.includes(h.kind)){const u=t.spec.variables.filter(p=>wa.includes(p.kind)).map(p=>p.name);return[s.filterOneOf(d,u.join(s.sep)||s.noFilters)]}if(l.has(h.name))return[s.filterTwice(d,h.name)];switch(l.add(h.name),h.kind){case"value":return a(c.field)?[]:[s.bindingField(d,String(c.field))];case"dateRange":return a(c.field)==="date"?[]:[s.bindingDateField(d)];case"search":return Array.isArray(c.fields)&&c.fields.length>0&&c.fields.every(u=>a(u)==="text")?[]:[s.bindingTextFields(d)];case"set":return Cd(h,t,o)?[]:[Ed(d,h.name)]}})}function fg(e,t,n,o,s=!1){const r=Ze(),a=ue(t.spec,o.sourceId);if(!a)return[r.needSource(n)];if(!Array.isArray(e)||!e.every(i=>typeof i=="string"))return[r.relationIds(n)];if(s&&e.length!==1)return[r.singleRelation(n)];const l=dn(t.kn,a.objectType,e);if(!l)return[r.pathUnreachable(n,a.objectType)];const c=l.length>0?l[l.length-1].to:a.objectType;return o.objectType&&c!==o.objectType?[r.pathEnd(n,c,o.objectType)]:[]}function Qn(e,t,n){if(e==="objectType")return n.objectType?t.kn.objectTypes[n.objectType]?.properties??null:null;const o=ue(t.spec,n.sourceId);return o?pe(o,t.kn):null}const mg={date:"日期",number:"数字",text:"文本"};function eo(e,t=" "){return e.map(n=>{const o=`${t}- ${n.key}(${n.label}${n.optional?",可选":""}):`;return n.kind==="list"?`${o}列表 ${n.min} 到 ${n.max} 项,每项:
|
|
156
|
+
${eo(n.item,`${t} `)}`:o+gg(n)}).join(`
|
|
157
|
+
`)}function gg(e){switch(e.kind){case"text":return e.max!=null?`文本,不超过 ${e.max} 字`:"文本";case"number":return`${e.decimal?"数":"整数"} ${e.min} 到 ${e.max}`;case"enum":return`取值 ${e.options.map(([t,n])=>`${t}(${n})`).join("、")}`;case"bool":return"true 或 false";case"source":return"页面数据源 id";case"field":case"fields":{const t=e.owner==="objectType"?"同一项 objectType 的属性":"数据源的属性",n=e.kind==="fields"?"列表":"",o=e.kind==="field"&&e.objectKey?`,或 ${Od} 表示对象本身`:"";return`${t}名${n}${e.of?`,须为${mg[e.of]}`:""}${o}`}case"variable":return`筛选名(variables 里的 name),类型须为 ${e.accepts.join(" 或 ")}`;case"bindings":return"跟随的筛选列表,每项 { variable, field? , fields? }:value 筛选给 field(按组件数据源的哪个字段比对);dateRange 筛选给日期 field;search 筛选给文本 fields;set 筛选不用给字段(须为同一类对象)。不写或空列表表示不受任何筛选影响";case"values":return`文本列表,为 ${e.fieldKey} 字段的取值(只取其中这些值;空列表表示不限)`;case"conditions":return"条件列表,全部成立才算命中;每项 { field, op, ref? | value? | values? },写法同计算列的条件";case"objectType":return"对象类 id";case"operation":return"数据源 operations 里的情景操作 id";case"relationPath":return e.single?"只含一个关系 id 的列表:知识网络里直接连接数据源对象类与 objectType 的那条关系;网络里没有直接关系的两类对象不能连线":"关系 id 列表,从数据源的对象类依次走到 objectType";case"list":return`列表 ${e.min} 到 ${e.max} 项,每项:${e.item.map(t=>t.label).join("、")}`;case"interactions":return Ep(e.on,e.actOn,e.hit,e.offers);case"actionTypes":return"行动类型 id 列表(知识网络里的行动)";case"metric":return e.on==="card"?"{ id, version }:知识网络中已发布的对象指标(见「对象指标」,没有这一节就不能用),须返回单个值、属于数据源的对象类;写了它,这张卡由平台按全部对象计算,不写 aggregate、valueField":"{ id, version }:知识网络中已发布的对象指标(见「对象指标」,没有这一节就不能用),须属于数据源的对象类;横轴为时间时须是有固定时间粒度的指标,横轴为类别时须返回单个值且类别属性是它开放的维度;写了它,这个系列由平台计算,不写 dateField、aggregate、valueField";case"tool":return"{ box, tool }:执行工厂里已发布工具箱的 id 和其中已启用工具的 id";case"mcpTool":return"{ mcp, tool, mcpName?, agentId?, agentName? }:执行工厂里已发布 MCP 服务的 id、其中工具的名称,以及服务名称(可选,只用于显示,不写时对话框向执行工厂取);支持智能体目录的服务可指定默认智能体 id 和名称;不知道有哪些服务时不写,由构建者选择";case"eventType":return`${e.multiple?"事件类型 id 列表":"事件类型 id"}(eventTypes 里的 id${e.of==="report"?",须为知识网络里来源是用户登记的":""})`}}function Ct(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const yg={joiner:"、",noOption:(e,t)=>`${e} 没有配置项 ${t}`,required:e=>`${e} 必填`,namesList:(e,t)=>`${e} 必须是不超过 ${t} 个名称的列表`,name:e=>`${e} 必须是非空名称`,conditionList:e=>`${e} 必须是条件列表`,condition:e=>`${e} 必须是 { field, op, value? } 条件`,object:e=>`${e} 必须是对象`,paramFrom:e=>`${e} 必须是 param、field、const 或 context 取值`,pathLength:e=>`${e} 必须是 1 到 4 条关系`,targetShape:e=>`${e} 必须是 { path?, field }`,readyShape:e=>`${e} 必须是 { path, field }`,onePath:e=>`${e} 必须是一条关系`,rulesCount:(e,t)=>`${e} 必须是不超过 ${t} 个规则工具`,ruleShape:e=>`${e} 必须是 { name, tool: { box, tool }, severity? }`,severity:e=>`${e} 只能是 hard 或 soft`,sourcesList:(e,t)=>`${e} 必须是不超过 ${t} 个数据源的列表`,layerList:e=>`${e} 必须是图层列表`,oneOf:(e,t)=>`${e} 只能是 ${t}`,tasksSelf:(e,t)=>`${e} 必须是 1 到 ${t} 种任务`,tasksRecord:e=>`${e} 写入计划记录时只能有一种任务`,parentOrGroup:e=>`${e} 上级字段与分组字段只能选一个`,calendarsCount:(e,t)=>`${e} 必须是不超过 ${t} 个日历`,boolean:e=>`${e} 必须是布尔值`,recordOnlyRecord:e=>`${e} 只在写入计划记录时填写`,recordRequired:e=>`${e} 写入计划记录时必填`,days:e=>`${e} 必须是 1 到 365 天`,matchCount:(e,t)=>`${e} 必须是不超过 ${t} 对字段`,matchShape:e=>`${e} 必须是 { from, to }`},bg={joiner:", ",noOption:(e,t)=>`${e} has no option ${t}`,required:e=>`${e} is required`,namesList:(e,t)=>`${e} must be a list of at most ${t} names`,name:e=>`${e} must be a non-empty name`,conditionList:e=>`${e} must be a list of conditions`,condition:e=>`${e} must be a { field, op, value? } condition`,object:e=>`${e} must be an object`,paramFrom:e=>`${e} must take its value from param, field, const or context`,pathLength:e=>`${e} must be 1 to 4 relations`,targetShape:e=>`${e} must be { path?, field }`,readyShape:e=>`${e} must be { path, field }`,onePath:e=>`${e} must be one relation`,rulesCount:(e,t)=>`${e} must be at most ${t} rule tools`,ruleShape:e=>`${e} must be { name, tool: { box, tool }, severity? }`,severity:e=>`${e} must be hard or soft`,sourcesList:(e,t)=>`${e} must be a list of at most ${t} sources`,layerList:e=>`${e} must be a list of layers`,oneOf:(e,t)=>`${e} must be one of ${t}`,tasksSelf:(e,t)=>`${e} must be 1 to ${t} kinds of task`,tasksRecord:e=>`${e} can have only one kind of task when results go into plan records`,parentOrGroup:e=>`${e} can take a parent field or a group field, not both`,calendarsCount:(e,t)=>`${e} must be at most ${t} calendars`,boolean:e=>`${e} must be true or false`,recordOnlyRecord:e=>`${e} is only for results written into plan records`,recordRequired:e=>`${e} is required when results go into plan records`,days:e=>`${e} must be 1 to 365 days`,matchCount:(e,t)=>`${e} must be at most ${t} pairs of fields`,matchShape:e=>`${e} must be { from, to }`},Me=()=>fe({"zh-CN":yg,"en-US":bg}),$l=["self","record"],wg=["title","subtitleField","daysBefore","daysAfter","tick","timeZone","timeZoneVariable","resourceSelection"],kg=["label","popoverFields","color","tone","colorField","snap","selection","filters"],vg=["result","tasks","resource","time","rules","plan"],to=3,gr=3,Sl=4,jl=5,se=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Le=e=>typeof e=="string"&&e!=="";function Ue(e,t,n){return Object.keys(e).filter(o=>!t.includes(o)).map(o=>Me().noOption(n,o))}function Nd(e,t,n,o=10){const s=Me();return e===void 0?n?[s.required(t)]:[]:!Array.isArray(e)||e.length>o||!e.every(Le)?[s.namesList(t,o)]:[]}function H(e,t,n=!0){return e===void 0&&!n?[]:Le(e)?[]:[Me().name(t)]}function xd(e,t){const n=Me();return e===void 0?[]:Array.isArray(e)?e.flatMap((o,s)=>se(o)&&Le(o.field)&&Gn.includes(o.op)?[]:[n.condition(`${t}[${s}]`)]):[n.conditionList(t)]}function yr(e,t,n){const o=Me();if(e===void 0)return n?[o.required(t)]:[];if(!se(e))return[o.object(t)];const s=[...Ue(e,["action","params"],t),...H(e.action,`${t}.action`)];if(e.params!==void 0)if(!se(e.params))s.push(o.object(`${t}.params`));else for(const[r,a]of Object.entries(e.params))(!se(a)||!((a.from==="param"||a.from==="field")&&Le(a.name)||a.from==="const"&&(typeof a.value=="string"||typeof a.value=="number")||a.from==="context"&&Ys.includes(a.name)))&&s.push(o.paramFrom(`${t}.params.${r}`));return s}function Al(e,t){return Array.isArray(e)&&e.length>0&&e.length<=4&&e.every(Le)?[]:[Me().pathLength(t)]}function $g(e,t,n){const o=Me();if(!se(e))return[o.object(t)];const s=[...Ue(e,["objectType","assignField","start","end","status","titleFields","doneWhen","groupField","target","ready","predecessors","modify","rules"],t),...H(e.objectType,`${t}.objectType`),...H(e.assignField,`${t}.assignField`,n),...H(e.start,`${t}.start`,n),...H(e.end,`${t}.end`,n),...H(e.status,`${t}.status`,!1),...H(e.groupField,`${t}.groupField`,!1),...Nd(e.titleFields,`${t}.titleFields`,!1,4),...xd(e.doneWhen,`${t}.doneWhen`),...yr(e.modify,`${t}.modify`,!1)];if(e.target!==void 0&&(se(e.target)?(s.push(...H(e.target.field,`${t}.target.field`)),e.target.path!==void 0&&s.push(...Al(e.target.path,`${t}.target.path`))):s.push(o.targetShape(`${t}.target`))),e.ready!==void 0&&(se(e.ready)?s.push(...Al(e.ready.path,`${t}.ready.path`),...H(e.ready.field,`${t}.ready.field`)):s.push(o.readyShape(`${t}.ready`))),e.predecessors!==void 0){const r=se(e.predecessors)?e.predecessors.path:void 0;(!Array.isArray(r)||r.length!==1||!Le(r[0]))&&s.push(o.onePath(`${t}.predecessors.path`))}return e.rules!==void 0&&(!Array.isArray(e.rules)||e.rules.length>jl?s.push(o.rulesCount(`${t}.rules`,jl)):e.rules.forEach((r,a)=>{const l=se(r)?r.tool:void 0;!se(r)||!Le(r.name)||!se(l)||!Le(l.box)||!Le(l.tool)?s.push(o.ruleShape(`${t}.rules[${a}]`)):r.severity!==void 0&&r.severity!=="hard"&&r.severity!=="soft"&&s.push(o.severity(`${t}.rules[${a}].severity`))})),s}function Tl(e,t,n){return e===void 0?[]:Array.isArray(e)&&e.length<=n&&e.every(o=>typeof o=="string")?[]:[Me().sourcesList(t,n)]}function Sg(e,t){return e===void 0?[]:se(e)?[...Ue(e,["tasks","resource","calendars","plan"],t),...Tl(e.tasks,`${t}.tasks`,to),...H(e.resource,`${t}.resource`,!1),...Tl(e.calendars,`${t}.calendars`,gr),...H(e.plan,`${t}.plan`,!1)]:[Me().object(t)]}function jg(e,t){if(e===void 0)return[];const n=Me();if(!se(e))return[n.object(t)];const o=Ue(e,["resource","demand"],t);for(const s of["resource","demand"]){const r=e[s];if(r!==void 0){if(!se(r)){o.push(n.object(`${t}.${s}`));continue}o.push(...Ue(r,[...wg,"layers"],`${t}.${s}`)),r.layers!==void 0&&(!Array.isArray(r.layers)||r.layers.length>12?o.push(n.layerList(`${t}.${s}.layers`)):r.layers.forEach((a,l)=>{se(a)?o.push(...Ue(a,kg,`${t}.${s}.layers[${l}]`)):o.push(n.object(`${t}.${s}.layers[${l}]`))}))}}return o}function Ag(e,t="scheduleModel"){const n=Me();if(!se(e))return[n.object(t)];const o=Ue(e,["result","tasks","resource","calendars","record","sources","display"],t);o.push(...Sg(e.sources,`${t}.sources`),...jg(e.display,`${t}.display`)),$l.includes(e.result)||o.push(n.oneOf(`${t}.result`,$l.join(n.joiner)));const s=e.result==="self",r=s?to:1;!Array.isArray(e.tasks)||e.tasks.length===0||e.tasks.length>r?o.push(s?n.tasksSelf(`${t}.tasks`,to):n.tasksRecord(`${t}.tasks`)):e.tasks.forEach((c,i)=>o.push(...$g(c,`${t}.tasks[${i}]`,s)));const a=e.resource;se(a)?(o.push(...Ue(a,["objectType","titleField","parentField","groupField","capacityField"],`${t}.resource`),...H(a.objectType,`${t}.resource.objectType`),...H(a.titleField,`${t}.resource.titleField`),...H(a.parentField,`${t}.resource.parentField`,!1),...H(a.groupField,`${t}.resource.groupField`,!1),...H(a.capacityField,`${t}.resource.capacityField`,!1)),a.parentField!==void 0&&a.groupField!==void 0&&o.push(n.parentOrGroup(`${t}.resource`))):o.push(n.object(`${t}.resource`)),e.calendars!==void 0&&(!Array.isArray(e.calendars)||e.calendars.length>gr?o.push(n.calendarsCount(`${t}.calendars`,gr)):e.calendars.forEach((c,i)=>{const d=`${t}.calendars[${i}]`;return se(c)?(o.push(...Ue(c,["objectType","resourceField","start","end","inherit"],d),...H(c.objectType,`${d}.objectType`),...H(c.resourceField,`${d}.resourceField`),...H(c.start,`${d}.start`),...H(c.end,`${d}.end`)),c.inherit!==void 0&&typeof c.inherit!="boolean"&&o.push(n.boolean(`${d}.inherit`)),o):o.push(n.object(d))}));const l=e.record;if(s)l!==void 0&&o.push(n.recordOnlyRecord(`${t}.record`));else if(!se(l))o.push(n.recordRequired(`${t}.record`));else{const c=`${t}.record`;o.push(...Ue(l,["objectType","match","resourceField","start","end","status","titleFields","active","create","modify","days","daysField"],c),...H(l.objectType,`${c}.objectType`),...H(l.resourceField,`${c}.resourceField`,!1),...H(l.start,`${c}.start`),...H(l.end,`${c}.end`),...H(l.status,`${c}.status`,!1),...Nd(l.titleFields,`${c}.titleFields`,!1,4),...H(l.daysField,`${c}.daysField`,!1),...l.days!==void 0&&(typeof l.days!="number"||!(l.days>0)||l.days>365)?[n.days(`${c}.days`)]:[],...xd(l.active,`${c}.active`),...yr(l.create,`${c}.create`,!1),...yr(l.modify,`${c}.modify`,!1)),l.match!==void 0&&(!Array.isArray(l.match)||l.match.length>Sl?o.push(n.matchCount(`${c}.match`,Sl)):l.match.forEach((i,d)=>{(!se(i)||!Le(i.from)||!Le(i.to))&&o.push(n.matchShape(`${c}.match[${d}]`))}))}return o}function Tg(e,t,n){const r=(n.startsWith(`${t.id}_`)?n.slice(t.id.length+1):n).replace(/[^A-Za-z0-9]+(.)?/g,(l,c)=>(c??"").toUpperCase()).replace(/^[^A-Za-z]+/,"")||`source${Object.keys(t.objectTypes).indexOf(n)+1||""}`,a=new Set(e.sources.map(l=>l.id));if(!a.has(r))return r;for(let l=2;;l++)if(!a.has(`${r}${l}`))return`${r}${l}`}const Og={object:e=>`${e} 必须是对象`,noOption:(e,t)=>`${e} 没有配置项 ${t}`,notBoth:e=>`${e} 不能同时是 Cypher 数据源和事件数据源`,mustBe:(e,t)=>`${e} 必须是 ${t}`,typesList:e=>`${e} 必须是事件类型 id 列表`},Eg={object:e=>`${e} must be an object`,noOption:(e,t)=>`${e} has no option ${t}`,notBoth:e=>`${e} cannot be both a Cypher source and an event source`,mustBe:(e,t)=>`${e} must be ${t}`,typesList:e=>`${e} must be a list of event type ids`},Cg=()=>fe({"zh-CN":Og,"en-US":Eg}),Ng="events:",br="event_id",wr=e=>`${Ng}${e}`,xg=[{name:"event_id",label:"事件 ID",type:"text"},{name:"title",label:"标题",type:"text"},{name:"event_type",label:"事件类型",type:"text"},{name:"severity",label:"严重程度",type:"text"},{name:"status",label:"状态",type:"text"},{name:"open",label:"是否未关闭",type:"text"},{name:"overdue",label:"是否超时",type:"text"},{name:"source",label:"来源",type:"text"},{name:"occurred_at",label:"发生时间",type:"date"},{name:"ended_at",label:"结束时间",type:"date"},{name:"recorded_at",label:"记录时间",type:"date"},{name:"object",label:"关联对象",type:"text"},{name:"object_key",label:"关联对象标识",type:"text"},{name:"reported_by",label:"报告人",type:"text"},{name:"verified_by",label:"核实人",type:"text"}];function Rg(e,t){return{id:wr(e),name:t,primaryKeys:[br],displayKey:"title",properties:xg}}function _g(e,t){const n=Cg(),o=[],s=e.events;if(typeof s!="object"||s===null||Array.isArray(s))return[n.object(`${t}.events`)];e.cypher!==void 0&&o.push(n.notBoth(t)),e.objectType!==wr(String(e.id))&&o.push(n.mustBe(`${t}.objectType`,wr(String(e.id)))),e.key!==br&&o.push(n.mustBe(`${t}.key`,br));const r=s.types;r!==void 0&&!(Array.isArray(r)&&r.every(a=>typeof a=="string"))&&o.push(n.typesList(`${t}.events.types`));for(const a of Object.keys(s))a!=="types"&&o.push(n.noOption(`${t}.events`,a));return o}const Pg={joiner:"、",list:(e,t)=>`${e} 必须是不超过 ${t} 项的列表`,object:e=>`${e} 必须是对象`,noOption:(e,t)=>`${e} 没有配置项 ${t}`,idFormat:e=>`${e} 必须是字母开头的标识`,idTwice:(e,t)=>`${e} 重复:${t}`,label:e=>`${e} 必须是不超过 30 字的名称`,oneOf:(e,t)=>`${e} 只能是 ${t}`,unit:e=>`${e} 必须是不超过 10 字的文字`,text:e=>`${e} 必须是文字`,number:e=>`${e} 必须是数值`,minAboveMax:e=>`${e} 不能大于 max`,outOfRange:e=>`${e} 超出范围`,rangeOnlyNumber:e=>`${e} 只有数值参数能设范围`,dayDate:e=>`${e} 必须是 YYYY-MM-DD 日期`,optionsOnlyText:e=>`${e} 只有文本参数能列可选值`,optionsCount:(e,t)=>`${e} 必须是 2 到 ${t} 个可选值`,required:e=>`${e} 必填`,scenarioName:e=>`${e} 必须是不超过 40 字的方案名`,defaultInOptions:e=>`${e} 必须是可选值之一`,saveAsName:e=>`${e} 必填:保存为知识网络对象时的对象类名称`,saveAsNameLong:(e,t)=>`${e} 不能超过 ${t} 个字`,outputTooLong:(e,t,n)=>`${e} 的字段 ${t} 超过 ${n} 个字符,不能保存为对象属性`,outputFixedName:(e,t)=>`${e} 的字段 ${t} 与结果行的固定字段同名,请改名`,objectTypeMustBe:(e,t)=>`${e} 必须是 ${t}`,notForModelSource:e=>`${e} 不能用于模型结果数据源`,tool:e=>`${e} 必须写明执行工厂的工具箱 box 与工具 tool`,inputsCount:(e,t)=>`${e} 必须是 1 到 ${t} 个输入`,inputSource:e=>`${e} 必须是页面的其他数据源`,inputBaseMissing:e=>`${e} 的来源数据源不存在`,inputEvents:e=>`${e} 不能是事件数据源`,inputFollows:e=>`${e} 是跟随筛选的子集,模型的输入不能跟随筛选`,inputQueryParam:(e,t)=>`${e} 的查询参数 $${t} 只能绑定基准日期`,inputFieldsEmpty:e=>`${e} 至少传一个字段`,inputField:e=>`${e} 必须是该数据源的字段`,inputsLoop:e=>`${e} 形成了循环:模型结果数据源不能读到自己`,paramsCount:(e,t)=>`${e} 必须是不超过 ${t} 个参数`,notScenarioParam:e=>`${e} 不是方案参数`,paramTypeDiffers:(e,t)=>`${e} 的类型是 ${t},与参数类型不同`,paramNoValue:e=>`${e} 取方案参数时不写固定值 value`,paramValue:e=>`${e} 必须是与类型相符的固定值,或改取方案参数 param`,outputsCount:(e,t)=>`${e} 必须是行标识加 1 到 ${t} 个字段`,keyMustBeOutput:e=>`${e} 必须是模型的一个输出字段(行标识)`,knObjectType:e=>`${e} 必须是知识网络中的对象类`,mustBeModelOutput:e=>`${e} 必须是模型的输出字段`,actionTarget:e=>`${e} 只能是 object(对这个对象执行)或 new(按新对象执行)`,actionType:e=>`${e} 不是知识网络中的行动类型`,actionObjectType:(e,t)=>`${e} 必须作用于对应对象的对象类 ${t}`,actionNewIsAdd:e=>`${e} 按新对象执行须是新增类行动`,prefix:(e,t)=>`${e} 必须是不超过 ${t} 字的编号前缀`,keyField:(e,t)=>`${e} 必须是 ${t} 的主键`,notPropertyOf:(e,t)=>`${e} 不是 ${t} 的属性`,numberField:e=>`${e} 是编号字段,取新编号`,mustTakeOutput:e=>`${e} 必须取模型的输出字段`,mustGive:e=>`${e} 必须给出:新建对象时这个属性必须有值,取模型的输出字段,或在 action.params 里给出来源`,notUserParam:e=>`${e} 不是该行动的用户填写参数`,fieldsAtLeastOne:e=>`${e} 至少要有一个字段`,fieldNameEmpty:e=>`${e} 的字段名不能为空`,textOrNumber:e=>`${e} 必须是文字或数值`,fromFieldOrConst:e=>`${e} 只能是 field 或 const`},Lg={joiner:", ",list:(e,t)=>`${e} must be a list of at most ${t} items`,object:e=>`${e} must be an object`,noOption:(e,t)=>`${e} has no option ${t}`,idFormat:e=>`${e} must be an identifier starting with a letter`,idTwice:(e,t)=>`${e} is used twice: ${t}`,label:e=>`${e} must be a name of at most 30 characters`,oneOf:(e,t)=>`${e} must be one of ${t}`,unit:e=>`${e} must be text of at most 10 characters`,text:e=>`${e} must be text`,number:e=>`${e} must be a number`,minAboveMax:e=>`${e} cannot be greater than max`,outOfRange:e=>`${e} is out of range`,rangeOnlyNumber:e=>`${e}: only a number parameter can have a range`,dayDate:e=>`${e} must be a date in YYYY-MM-DD`,optionsOnlyText:e=>`${e}: only a text parameter can list options`,optionsCount:(e,t)=>`${e} must list 2 to ${t} options`,required:e=>`${e} is required`,scenarioName:e=>`${e} must be a scenario name of at most 40 characters`,defaultInOptions:e=>`${e} must be one of the options`,saveAsName:e=>`${e} is required: the object type name when saved as a knowledge network object`,saveAsNameLong:(e,t)=>`${e} cannot be longer than ${t} characters`,outputTooLong:(e,t,n)=>`field ${t} of ${e} is longer than ${n} characters and cannot be saved as an object property`,outputFixedName:(e,t)=>`field ${t} of ${e} has the same name as a fixed field of the result row, please rename it`,objectTypeMustBe:(e,t)=>`${e} must be ${t}`,notForModelSource:e=>`${e} cannot be used on a model result source`,tool:e=>`${e} must name the execution factory toolbox (box) and tool`,inputsCount:(e,t)=>`${e} must list 1 to ${t} inputs`,inputSource:e=>`${e} must be another source of the page`,inputBaseMissing:e=>`the source that ${e} comes from does not exist`,inputEvents:e=>`${e} cannot be an event source`,inputFollows:e=>`${e} is a subset that follows filters, and the inputs of a model cannot follow filters`,inputQueryParam:(e,t)=>`query parameter $${t} of ${e} can only be bound to the base date`,inputFieldsEmpty:e=>`${e} must send at least one field`,inputField:e=>`${e} must be a field of that source`,inputsLoop:e=>`${e} form a loop: a model result source cannot read itself`,paramsCount:(e,t)=>`${e} must be at most ${t} parameters`,notScenarioParam:e=>`${e} is not a scenario parameter`,paramTypeDiffers:(e,t)=>`${e} has type ${t}, which differs from the parameter type`,paramNoValue:e=>`${e} takes a scenario parameter, so it must not have a fixed value`,paramValue:e=>`${e} must be a fixed value of the matching type, or take a scenario parameter with param`,outputsCount:(e,t)=>`${e} must be a row id plus 1 to ${t} fields`,keyMustBeOutput:e=>`${e} must be an output field of the model (the row id)`,knObjectType:e=>`${e} must be an object type of the knowledge network`,mustBeModelOutput:e=>`${e} must be an output field of the model`,actionTarget:e=>`${e} must be object (act on this object) or new (act on a new object)`,actionType:e=>`${e} is not an action type of the knowledge network`,actionObjectType:(e,t)=>`${e} must act on the object type ${t} of the object`,actionNewIsAdd:e=>`${e} must be an add action to act on a new object`,prefix:(e,t)=>`${e} must be a number prefix of at most ${t} characters`,keyField:(e,t)=>`${e} must be the primary key of ${t}`,notPropertyOf:(e,t)=>`${e} is not a property of ${t}`,numberField:e=>`${e} is the number field and takes the new number`,mustTakeOutput:e=>`${e} must take an output field of the model`,mustGive:e=>`${e} is required: this property must have a value when the object is created, so take an output field of the model or give its source in action.params`,notUserParam:e=>`${e} is not a parameter the user fills in for this action`,fieldsAtLeastOne:e=>`${e} must have at least one field`,fieldNameEmpty:e=>`a field name of ${e} cannot be empty`,textOrNumber:e=>`${e} must be text or a number`,fromFieldOrConst:e=>`${e} must be field or const`},ko=()=>fe({"zh-CN":Pg,"en-US":Lg}),Ig="model:",kr=e=>`${Ig}${e}`,Ol=5,El=5,Cl=8,Nl=10,xl=10,Rl=20,qn=/^[A-Za-z][A-Za-z0-9_]*$/,Rd=/^\d{4}-\d{2}-\d{2}$/,lt=["number","date","text"],te=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function _d(e){const t=Array.isArray(e.model?.outputs)?e.model.outputs:[],n=typeof e.key=="string"?e.key:"";return{id:kr(e.id),name:typeof e.label=="string"?e.label:e.id,primaryKeys:n?[n]:[],displayKey:n,properties:t.filter(o=>o&&typeof o.name=="string").map(o=>({name:o.name,label:typeof o.label=="string"&&o.label?o.label:o.name,type:lt.includes(o.type)?o.type:"text"}))}}function Mg(e,t){return e.find(o=>o.id===t)?.from?.source??t}function _l(e,t){const n=new Set(e.filter(r=>r.model).map(r=>r.id)),s=(Array.isArray(t.model?.inputs)?t.model.inputs:[]).filter(r=>te(r)&&typeof r.source=="string").map(r=>Mg(e,r.source)).filter(r=>n.has(r));return[...new Set(s)]}function qg(e,t="scenarioParams"){if(e===void 0)return[];const n=ko();if(!Array.isArray(e)||e.length>Nl)return[n.list(t,Nl)];const o=new Set;return e.flatMap((s,r)=>{const a=`${t}[${r}]`;if(!te(s))return[n.object(a)];const l=Object.keys(s).filter(c=>!["name","label","type","unit","default","description","min","max","options"].includes(c)).map(c=>n.noOption(a,c));if(typeof s.name!="string"||!qn.test(s.name)?l.push(n.idFormat(`${a}.name`)):o.has(s.name)?l.push(n.idTwice(`${a}.name`,s.name)):o.add(s.name),(typeof s.label!="string"||!s.label.trim()||s.label.length>30)&&l.push(n.label(`${a}.label`)),!lt.includes(s.type))return[...l,n.oneOf(`${a}.type`,lt.join(n.joiner))];if(s.unit!==void 0&&(typeof s.unit!="string"||s.unit.length>10)&&l.push(n.unit(`${a}.unit`)),s.description!==void 0&&typeof s.description!="string"&&l.push(n.text(`${a}.description`)),s.type==="number"){(typeof s.default!="number"||!Number.isFinite(s.default))&&l.push(n.number(`${a}.default`));for(const c of["min","max"])s[c]!==void 0&&typeof s[c]!="number"&&l.push(n.number(`${a}.${c}`));typeof s.min=="number"&&typeof s.max=="number"&&s.min>s.max?l.push(n.minAboveMax(`${a}.min`)):typeof s.default=="number"&&(typeof s.min=="number"&&s.default<s.min||typeof s.max=="number"&&s.default>s.max)&&l.push(n.outOfRange(`${a}.default`))}else(s.min!==void 0||s.max!==void 0)&&l.push(n.rangeOnlyNumber(a)),s.type==="date"&&(typeof s.default!="string"||!Rd.test(s.default))&&l.push(n.dayDate(`${a}.default`)),s.type==="text"&&typeof s.default!="string"&&l.push(n.text(`${a}.default`));if(s.options!==void 0){const c=Array.isArray(s.options)?s.options:null;if(s.type!=="text")l.push(n.optionsOnlyText(`${a}.options`));else if(!c||c.length<2||c.length>xl)l.push(n.optionsCount(`${a}.options`,xl));else{const i=new Set;c.forEach((d,h)=>{const u=`${a}.options[${h}]`;return!te(d)||typeof d.value!="string"||!d.value.trim()?l.push(n.required(`${u}.value`)):(i.has(d.value)&&l.push(n.idTwice(`${u}.value`,d.value)),i.add(d.value),d.scenario!==void 0&&(typeof d.scenario!="string"||d.scenario.length>40)&&l.push(n.scenarioName(`${u}.scenario`)),l)}),typeof s.default=="string"&&!i.has(s.default)&&l.push(n.defaultInOptions(`${a}.default`))}}return l})}function Fg(e,t,n){const o=e.find(a=>a.id===t),s=o?.from?e.find(a=>a.id===o.from?.source):o;if(!o||!s)return[];const r=o.from?{...s,id:o.id,from:o.from}:o;return pe(r,n).filter(a=>a.name!==cn)}const Pl=128,Ll=40,Dg=["result_id","row_key","scenario_id","scenario_name","run_id","as_of","computed_at","app_id","source_id"];function Bg(e,t,n){const o=ko(),s=`${n}.model.saveAs`;if(!te(e))return[o.object(s)];const r=Object.keys(e).filter(l=>l!=="name").map(l=>o.noOption(s,l)),a=typeof e.name=="string"?e.name.trim():"";a?[...a].length>Pl&&r.push(o.saveAsNameLong(`${s}.name`,Pl)):r.push(o.saveAsName(`${s}.name`));for(const l of t)l.length>Ll&&r.push(o.outputTooLong(`${n}.model.outputs`,l,Ll)),Dg.includes(l)&&r.push(o.outputFixedName(`${n}.model.outputs`,l));return r}function Ug(e,t,n){const{sources:o,kn:s,variables:r,scenarioParams:a}=t,l=ko(),c=e.model;if(!te(c))return[l.object(`${n}.model`)];const i=Object.keys(c).filter(m=>!["tool","inputs","params","outputs","landing","saveAs"].includes(m)).map(m=>l.noOption(`${n}.model`,m));e.objectType!==kr(e.id)&&i.push(l.objectTypeMustBe(`${n}.objectType`,kr(e.id)));for(const m of["cypher","events","from","models","follows","relatedTo","computed","progress"])e[m]!==void 0&&i.push(l.notForModelSource(`${n}.${m}`));const d=te(c.tool)?c.tool:null;!d||typeof d.box!="string"||!d.box||typeof d.tool!="string"?i.push(l.tool(`${n}.model.tool`)):d.tool||i.push(l.required(`${n}.model.tool.tool`));const h=Array.isArray(c.inputs)?c.inputs:null;if(!h||h.length===0||h.length>Ol)i.push(l.inputsCount(`${n}.model.inputs`,Ol));else{const m=new Set;h.forEach((y,b)=>{const k=`${n}.model.inputs[${b}]`;if(!te(y))return i.push(l.object(k));typeof y.name!="string"||!qn.test(y.name)?i.push(l.idFormat(`${k}.name`)):m.has(y.name)?i.push(l.idTwice(`${k}.name`,y.name)):m.add(y.name);const w=o.find(j=>j.id===y.source);if(!w||w.id===e.id)return i.push(l.inputSource(`${k}.source`));const v=w.from?o.find(j=>j.id===w.from?.source):w;if(!v)return i.push(l.inputBaseMissing(`${k}.source`));if(v.events)return i.push(l.inputEvents(`${k}.source`));if(w.from?.filters?.length&&i.push(l.inputFollows(`${k}.source`)),v.cypher)for(const[j,O]of Object.entries(v.cypher.params??{}))r.find(E=>E.name===O)?.kind!=="asOf"&&i.push(l.inputQueryParam(`${k}.source`,j));const S=new Set(Fg(o,w.id,s).map(j=>j.name));return!Array.isArray(y.fields)||y.fields.length===0?i.push(l.inputFieldsEmpty(`${k}.fields`)):y.fields.forEach((j,O)=>{(typeof j!="string"||!S.has(j))&&i.push(l.inputField(`${k}.fields[${O}]`))}),i});const g=y=>{const b=new Set,k=w=>{if(w===e.id)return!0;if(b.has(w))return!1;b.add(w);const v=o.find(S=>S.id===w);return v?.model?_l(o,v).some(k):!1};return k(y)};_l(o,e).some(g)&&i.push(l.inputsLoop(`${n}.model.inputs`))}const u=c.params===void 0?[]:Array.isArray(c.params)?c.params:null;if(!u||u.length>El)i.push(l.paramsCount(`${n}.model.params`,El));else{const m=new Set;u.forEach((g,y)=>{const b=`${n}.model.params[${y}]`;if(!te(g))return i.push(l.object(b));if(typeof g.name!="string"||!qn.test(g.name)?i.push(l.idFormat(`${b}.name`)):m.has(g.name)?i.push(l.idTwice(`${b}.name`,g.name)):m.add(g.name),!lt.includes(g.type))return i.push(l.oneOf(`${b}.type`,lt.join(l.joiner)));if(g.param!==void 0){const k=a.find(w=>w.name===g.param);k?k.type!==g.type&&i.push(l.paramTypeDiffers(`${b}.param`,k.type)):i.push(l.notScenarioParam(`${b}.param`)),g.value!==void 0&&i.push(l.paramNoValue(b))}else(g.type==="number"?typeof g.value!="number":typeof g.value!="string"||g.type==="date"&&!Rd.test(g.value))&&i.push(l.paramValue(`${b}.value`));return i})}const p=Array.isArray(c.outputs)?c.outputs:null,f=new Set;return!p||p.length<2||p.length>Cl+1?i.push(l.outputsCount(`${n}.model.outputs`,Cl)):p.forEach((m,g)=>{const y=`${n}.model.outputs[${g}]`;return te(m)?(typeof m.name!="string"||!qn.test(m.name)?i.push(l.idFormat(`${y}.name`)):f.has(m.name)?i.push(l.idTwice(`${y}.name`,m.name)):f.add(m.name),(typeof m.label!="string"||!m.label.trim())&&i.push(l.required(`${y}.label`)),lt.includes(m.type)||i.push(l.oneOf(`${y}.type`,lt.join(l.joiner))),i):i.push(l.object(y))}),p&&!f.has(String(e.key))&&i.push(l.keyMustBeOutput(`${n}.key`)),c.landing!==void 0&&i.push(...zg(c.landing,e,s,n)),c.saveAs!==void 0&&i.push(...Bg(c.saveAs,f,n)),i}function zg(e,t,n,o){const s=ko(),r=`${o}.model.landing`;if(!te(e))return[s.object(r)];const a=[],l=_d(t).properties,c=new Set(l.map(f=>f.name));e.when!==void 0&&a.push(...xe(e.when,l,`${r}.when`));const i=te(e.object)?e.object:null,d=typeof i?.type=="string"?i.type:"",h=d&&!d.includes(":")&&Object.hasOwn(n.objectTypes,d)?n.objectTypes[d]:void 0;if(h||a.push(s.knObjectType(`${r}.object.type`)),(!i||typeof i.field!="string"||!c.has(i.field))&&a.push(s.mustBeModelOutput(`${r}.object.field`)),e.action===void 0)return a;const u=te(e.action)?e.action:null;if(!u||typeof u.id!="string")return[...a,s.required(`${r}.action.id`)];if(["object","new"].includes(String(u.target))||a.push(s.actionTarget(`${r}.action.target`)),n.actionTypes===void 0)return a;const p=ln(n,u.id);if(!p)return[...a,s.actionType(`${r}.action.id`)];if(u.target==="object"&&h&&p.objectType!==h.id&&a.push(s.actionObjectType(`${r}.action.id`,h.id)),u.target==="new"){p.kind!=="add"&&a.push(s.actionNewIsAdd(`${r}.action.id`));const f=n.objectTypes[p.objectType],m=te(u.newObject)?u.newObject:null;if(!m||typeof m.prefix!="string"||!m.prefix.trim()||m.prefix.length>Rl)a.push(s.prefix(`${r}.action.newObject.prefix`,Rl));else if(f){const g=m.keyField??f.primaryKeys[0];if((typeof g!="string"||!f.primaryKeys.includes(g))&&a.push(s.keyField(`${r}.action.newObject.keyField`,f.id)),m.fields!==void 0)if(!te(m.fields))a.push(s.object(`${r}.action.newObject.fields`));else for(const[k,w]of Object.entries(m.fields))f.properties.some(v=>v.name===k)?k===g&&a.push(s.numberField(`${r}.action.newObject.fields.${k}`)):a.push(s.notPropertyOf(`${r}.action.newObject.fields.${k}`,f.id)),(typeof w!="string"||!c.has(w))&&a.push(s.mustTakeOutput(`${r}.action.newObject.fields.${k}`));const y=te(m.fields)?m.fields:{},b=te(u.params)?u.params:{};for(const k of p.inputs)k.property&&k.name!==g&&!Object.hasOwn(y,k.name)&&!Object.hasOwn(b,k.name)&&a.push(s.mustGive(`${r}.action.newObject.fields.${k.name}`))}}if(u.params!==void 0){if(!te(u.params))return[...a,s.object(`${r}.action.params`)];const f=(m,g)=>te(m)?m.from==="field"?c.has(String(m.name))?[]:[s.mustBeModelOutput(`${g}.name`)]:m.from==="const"?typeof m.value=="string"||typeof m.value=="number"?[]:[s.textOrNumber(`${g}.value`)]:[s.fromFieldOrConst(`${g}.from`)]:[s.object(g)];for(const[m,g]of Object.entries(u.params)){const y=`${r}.action.params.${m}`;if(!p.inputs.some(b=>b.name===m)){a.push(s.notUserParam(y));continue}if(!(te(g)&&g.from==="ask")){if(te(g)&&g.from==="item"){if(!te(g.fields)||Object.keys(g.fields).length===0)a.push(s.fieldsAtLeastOne(`${y}.fields`));else for(const[b,k]of Object.entries(g.fields))b.trim()||a.push(s.fieldNameEmpty(`${y}.fields`)),a.push(...f(k,`${y}.fields.${b}`));continue}a.push(...f(g,y))}}}return a}const Wg={object:e=>`${e}.cypher 必须是对象`,objectType:(e,t)=>`${e}.objectType 必须是 ${t}`,queryRequired:e=>`${e}.cypher.query 必填`,readOnly:e=>`${e}.cypher.query 只能是只读查询,不能写数据`,columnsMin:e=>`${e}.cypher.columns 至少要有一列`,nameRequired:e=>`${e}.name 必填`,nameTwice:(e,t)=>`${e}.name ${t} 重复`,columnType:e=>`${e}.type 只能是 date、number、text`,unbound:(e,t)=>`${e} 查询里的 $${t} 没有绑定页面变量`,notVariable:(e,t)=>`${e}.cypher.params.${t} 不是页面变量`,badKind:(e,t,n)=>`${e}.cypher.params.${t} 不能绑定 ${n} 变量`},Kg={object:e=>`${e}.cypher must be an object`,objectType:(e,t)=>`${e}.objectType must be ${t}`,queryRequired:e=>`${e}.cypher.query is required`,readOnly:e=>`${e}.cypher.query must be a read-only query, it cannot write data`,columnsMin:e=>`${e}.cypher.columns needs at least one column`,nameRequired:e=>`${e}.name is required`,nameTwice:(e,t)=>`${e}.name ${t} is used twice`,columnType:e=>`${e}.type must be one of date, number, text`,unbound:(e,t)=>`${e}: $${t} in the query is not bound to a page variable`,notVariable:(e,t)=>`${e}.cypher.params.${t} is not a page variable`,badKind:(e,t,n)=>`${e}.cypher.params.${t} cannot be bound to a ${n} variable`},Pd=()=>fe({"zh-CN":Wg,"en-US":Kg}),Yg="cypher:";function vr(e){return`${Yg}${e}`}const Gg=["asOf","value","search","selection"];function Ld(e,t){if(!Array.isArray(t))return e;const n={};for(const o of t){if(o&&typeof o.id=="string"&&o.events&&!o.cypher){const a=Rg(o.id,typeof o.label=="string"?o.label:o.id);n[a.id]=a;continue}if(o&&typeof o.id=="string"&&o.model&&!o.cypher){const a=_d(o);n[a.id]=a;continue}if(!o||typeof o.id!="string"||!o.cypher)continue;const s=Array.isArray(o.cypher.columns)?o.cypher.columns:[],r=vr(o.id);n[r]={id:r,name:typeof o.label=="string"?o.label:o.id,primaryKeys:typeof o.key=="string"?[o.key]:[],displayKey:typeof o.key=="string"?o.key:"",properties:s.filter(a=>a&&typeof a.name=="string").map(a=>({name:a.name,label:typeof a.label=="string"&&a.label?a.label:a.name,type:["date","number","text"].includes(a.type)?a.type:"text"}))}}return Object.keys(n).length===0?e:{...e,objectTypes:{...e.objectTypes,...n}}}function Id(e){return e.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`[^`]*`/g,t=>" ".repeat(t.length))}function Hg(e){const t=[...Id(e).matchAll(/\$([A-Za-z_][A-Za-z0-9_]*)/g)].map(n=>n[1]);return[...new Set(t)]}const Vg=/\b(CREATE|MERGE|SET|DELETE|DETACH|REMOVE|DROP|CALL|LOAD|FOREACH)\b/i;function Jg(e,t){const n=Pd(),o=[],s=e.cypher;if(typeof s!="object"||s===null)return[n.object(t)];if(e.objectType!==vr(String(e.id))&&o.push(n.objectType(t,vr(String(e.id)))),typeof s.query!="string"||s.query.trim()===""?o.push(n.queryRequired(t)):Vg.test(Id(s.query))&&o.push(n.readOnly(t)),!Array.isArray(s.columns)||s.columns.length===0)o.push(n.columnsMin(t));else{const r=new Set;s.columns.forEach((a,l)=>{const c=`${t}.cypher.columns[${l}]`;if(typeof a?.name!="string"||a.name==="")return o.push(n.nameRequired(c));r.has(a.name)&&o.push(n.nameTwice(c,a.name)),r.add(a.name),["date","number","text"].includes(a.type)||o.push(n.columnType(c))})}return o}function Zg(e,t,n){if(!e.cypher)return[];const o=Pd(),s=[],r=e.cypher.params??{};for(const a of Hg(e.cypher.query))r[a]||s.push(o.unbound(n,a));for(const[a,l]of Object.entries(r)){const c=t.find(i=>i.name===l);c?Gg.includes(c.kind)||s.push(o.badKind(n,a,c.kind)):s.push(o.notVariable(n,a))}return s}new TextEncoder;const Xg=/\{([^{}]+)\}/g;function Qg(e){return[...e.matchAll(Xg)].map(t=>t[1].trim())}const ey={object:e=>`${e} 必须是对象`,noOption:(e,t)=>`${e} 没有配置项 ${t}`,identifier:e=>`${e} 必须是字母开头的标识`,duplicate:(e,t)=>`${e} 重复:${t}`,pathCount:(e,t)=>`${e} 必须是 1 到 ${t} 个关系类 id`,notPath:(e,t)=>`${e} 不是从 ${t} 出发、沿知识网络关系的路径`,pathEnd:(e,t,n)=>`${e} 终点是 ${t},应到 ${n}`,fromSource:e=>`${e} 必须是页面中的数据源`,fromLinkable:e=>`${e} 必须是知识网络对象类的数据源,不能是子集或查询`,list:(e,t)=>`${e} 必须是不超过 ${t} 项的列表`,dateProperty:(e,t)=>`${e} 必须是 ${t} 的日期属性`,notKey:e=>`${e} 不能是对象的主键或标识`,integerRange:(e,t)=>`${e} 必须是 -${t} 到 ${t} 的整数`,sameAsField:e=>`${e} 不能与 field 相同`},ty={object:e=>`${e} must be an object`,noOption:(e,t)=>`${e} has no option ${t}`,identifier:e=>`${e} must be an identifier starting with a letter`,duplicate:(e,t)=>`${e} is used twice: ${t}`,pathCount:(e,t)=>`${e} must be 1 to ${t} relation type ids`,notPath:(e,t)=>`${e} is not a path from ${t} along relations of the knowledge network`,pathEnd:(e,t,n)=>`${e} ends at ${t}, but should end at ${n}`,fromSource:e=>`${e} must be a source of the page`,fromLinkable:e=>`${e} must be a source of an object type of the knowledge network, not a subset or a query`,list:(e,t)=>`${e} must be a list of at most ${t} items`,dateProperty:(e,t)=>`${e} must be a date property of ${t}`,notKey:e=>`${e} cannot be the primary key or identifier of the object`,integerRange:(e,t)=>`${e} must be an integer from -${t} to ${t}`,sameAsField:e=>`${e} cannot be the same as field`},vo=()=>fe({"zh-CN":ey,"en-US":ty}),$r=5,Sr=3,no=3,oo=365,so=1439,Md=/^[A-Za-z][A-Za-z0-9_]*$/,qd=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),ny=e=>!e.from&&!e.cypher&&!e.events;function Fd(e,t,n,o,s){if(!t)return[];const r=vo();if(!Array.isArray(e)||e.length===0||e.length>no||!e.every(c=>typeof c=="string"))return[r.pathCount(s,no)];const a=dn(o,t.objectType,e);return a?a[a.length-1].to===n.objectType?[]:[r.pathEnd(s,$h(o,t.objectType,e),n.objectType)]:[r.notPath(s,t.objectType)]}function Dd(e,t,n){const o=vo(),s=t.find(r=>r.id===e);return s?ny(s)?{source:s,errors:[]}:{errors:[o.fromLinkable(n)]}:{errors:[o.fromSource(n)]}}const Ps=(e,t,n)=>e.objectTypes[t]?.properties.find(o=>o.name===n&&o.type==="date");function oy(e,t,n,o,s){const r=vo();if(!Array.isArray(e)||e.length>$r)return[r.list(s,$r)];const a=o.objectTypes[t.objectType],l=new Set;return e.flatMap((c,i)=>{const d=`${s}[${i}]`;if(!qd(c))return[r.object(d)];const h=Object.keys(c).filter(p=>!["id","field","from","path","fromField","gapDays","gapMinutes","keepDuration"].includes(p)).map(p=>r.noOption(d,p));typeof c.id!="string"||!Md.test(c.id)?h.push(r.identifier(`${d}.id`)):l.has(c.id)?h.push(r.duplicate(`${d}.id`,c.id)):l.add(c.id),Ps(o,t.objectType,c.field)?(c.field===t.key||a?.primaryKeys.includes(String(c.field)))&&h.push(r.notKey(`${d}.field`)):h.push(r.dateProperty(`${d}.field`,t.objectType));const u=Dd(c.from,n,`${d}.from`);return h.push(...u.errors),h.push(...Fd(c.path,u.source,t,o,`${d}.path`)),u.source&&!Ps(o,u.source.objectType,c.fromField)&&h.push(r.dateProperty(`${d}.fromField`,u.source.objectType)),(typeof c.gapDays!="number"||!Number.isInteger(c.gapDays)||Math.abs(c.gapDays)>oo)&&h.push(r.integerRange(`${d}.gapDays`,oo)),c.gapMinutes!==void 0&&(typeof c.gapMinutes!="number"||!Number.isInteger(c.gapMinutes)||Math.abs(c.gapMinutes)>so)&&h.push(r.integerRange(`${d}.gapMinutes`,so)),c.keepDuration!==void 0&&(Ps(o,t.objectType,c.keepDuration)?c.keepDuration===c.field?h.push(r.sameAsField(`${d}.keepDuration`)):a?.primaryKeys.includes(c.keepDuration)&&h.push(r.notKey(`${d}.keepDuration`)):h.push(r.dateProperty(`${d}.keepDuration`,t.objectType))),h})}function sy(e,t,n,o,s){const r=vo();if(!Array.isArray(e)||e.length>Sr)return[r.list(s,Sr)];const a=new Set;return e.flatMap((l,c)=>{const i=`${s}[${c}]`;if(!qd(l))return[r.object(i)];const d=Object.keys(l).filter(u=>!["id","from","path"].includes(u)).map(u=>r.noOption(i,u));typeof l.id!="string"||!Md.test(l.id)?d.push(r.identifier(`${i}.id`)):a.has(l.id)?d.push(r.duplicate(`${i}.id`,l.id)):a.add(l.id);const h=Dd(l.from,n,`${i}.from`);return d.push(...h.errors),d.push(...Fd(l.path,h.source,t,o,`${i}.path`)),d})}const ry={notString:"default 必须是字符串",noDefault:e=>`${e} 变量不能有默认值`,asOf:"基准日期的默认值必须是 today 或 YYYY-MM-DD",dateRange:"日期区间的默认值必须是 YYYY-MM-DD..YYYY-MM-DD(可省略一端)"},ay={notString:"default must be a string",noDefault:e=>`a ${e} variable cannot have a default`,asOf:"the default of a base date must be today or YYYY-MM-DD",dateRange:"the default of a date range must be YYYY-MM-DD..YYYY-MM-DD (either end may be left out)"},iy=()=>fe({"zh-CN":ry,"en-US":ay}),ly="today",Il=/^\d{4}-\d{2}-\d{2}$/,cy=["asOf","value","dateRange","search"],dy="..";function uy(e){const t=e.default;if(t===void 0)return null;const n=iy();if(typeof t!="string")return n.notString;if(!cy.includes(e.kind))return n.noDefault(e.kind);switch(e.kind){case"asOf":return t===ly||Il.test(t)&&!Number.isNaN(Date.parse(t))?null:n.asOf;case"dateRange":{const o=t.split(dy);return o.length===2&&o.every(r=>r===""||Il.test(r))&&o.some(r=>r!=="")?null:n.dateRange}default:return null}}const ro=2e3,hy=["title","type","severity","object","occurredAt"],Ml="detail.",py=/\{([A-Za-z_][A-Za-z0-9_]*(?:\.[^{}\s]*)?)\}/g,fy=e=>hy.includes(e)||e.startsWith(Ml)&&e.length>Ml.length;function my(e){const t=[...e.matchAll(py)].map(n=>n[1]);return[...new Set(t.filter(n=>!fy(n)))]}const gy={object:e=>`${e} 必须是对象`,noOption:(e,t)=>`${e} 没有配置项 ${t}`,required:e=>`${e} 必填`,boolean:e=>`${e} 必须是 true 或 false`,hours:(e,t)=>`${e} 必须是 1 分钟到 ${t} 小时之间的时长,以小时计,可精确到分钟(如 0.5 为 30 分钟)`,strategyActionsObject:e=>`${e} 必须是对象:处理方案 → { action, params? }`,notStrategy:e=>`${e} 不是这个事件类型的处理方案`,boundShape:e=>`${e} 必须是 { action, params? }`,noSubjectSource:(e,t)=>`${e} 要对事件的关联对象执行行动,应用里还没有「${t}」的数据源`,eventTypesList:()=>"eventTypes 必须是列表",unknownEventType:(e,t)=>`${e} 里的 ${t} 不是应用处理的事件类型`,inNetwork:e=>`${e} 在知识网络里设置:应用只配置怎样处理这类事件`,typeCode:e=>`${e} 必须是知识网络的事件类型编码:小写字母或数字开头,只含小写字母、数字、_、. 和 -,最长 64 个字符`,duplicate:e=>`事件类型 ${e} 重复`,owners:e=>`${e} 必须是最多 8 个角色名`,reportRule:e=>`${e} 只用于用户登记的事件`,strategies:e=>`${e} 必须是最多 12 个、每个不超过 40 字的处理方案名称`,groupingShape:e=>`${e} 必须是 { mode, by? }`,groupingMode:(e,t)=>`${e} 只能是 ${t.join("、")}`,groupingByOnly:e=>`${e} 只用于按属性归并`,groupingByName:e=>`${e} 必须是属性名`,groupingNoSource:(e,t)=>`${e} 按属性归并要从关联对象取值,应用里还没有「${t}」的数据源`,groupingByProperty:e=>`${e} 必须是关联对象的属性`,analysisPage:(e,t)=>`${e} 必须是应用的页面之一${t?`:${t.join("、")}`:""}`,analysisSelection:e=>`${e} 必须是选中对象筛选`,analysisSelectionOther:e=>`${e} 选中的是另一类对象,和事件关联的对象对不上`,analysisAsOfNone:e=>`${e} 页面没有基准日期`,analysisWindowShape:e=>`${e} 必须是 { variable, days }`,analysisWindowVariable:e=>`${e} 必须是日期区间筛选`,analysisWindowDays:e=>`${e} 必须是 1 到 365 的整数(天)`,mergeHours:e=>`${e} 是事件类型的合并窗口,在知识网络里设置`,fieldsList:e=>`${e} 必须是最多 12 项的列表`,fieldName:e=>`${e} 必须是小写字母开头的字段名`,fieldDuplicate:(e,t)=>`${e} ${t} 重复`,fieldType:(e,t)=>`${e} 只能是 ${t.join("、")}`,verifier:e=>`${e} 必须是角色名`,canvasText:(e,t)=>`${e} 必须是不超过 ${t} 字的文字`,canvasPlaceholder:(e,t)=>`${e} 里的 {${t}} 不是事件的值:可用 {title}、{type}、{severity}、{object}、{occurredAt} 与 {detail.<字段>}`},yy={object:e=>`${e} must be an object`,noOption:(e,t)=>`${e} has no option ${t}`,required:e=>`${e} is required`,boolean:e=>`${e} must be true or false`,hours:(e,t)=>`${e} must be a length of time from 1 minute to ${t} hours, in hours, to the minute (0.5 is 30 minutes)`,strategyActionsObject:e=>`${e} must be an object: strategy -> { action, params? }`,notStrategy:e=>`${e} is not a strategy of this event type`,boundShape:e=>`${e} must be { action, params? }`,noSubjectSource:(e,t)=>`${e} runs an action on the event's object, but the app has no source for "${t}"`,eventTypesList:()=>"eventTypes must be a list",unknownEventType:(e,t)=>`${e} has ${t}, which is not an event type the app handles`,inNetwork:e=>`${e} is set in the knowledge network: the app only configures how events of this type are handled`,typeCode:e=>`${e} must be the event type code of the knowledge network: starts with a lowercase letter or digit, only lowercase letters, digits, _, . and -, at most 64 characters`,duplicate:e=>`event type ${e} is used twice`,owners:e=>`${e} must be at most 8 role names`,reportRule:e=>`${e} is only for events reported by users`,strategies:e=>`${e} must be at most 12 strategy names, each at most 40 characters`,groupingShape:e=>`${e} must be { mode, by? }`,groupingMode:(e,t)=>`${e} must be one of ${t.join(", ")}`,groupingByOnly:e=>`${e} is only for grouping by property`,groupingByName:e=>`${e} must be a property name`,groupingNoSource:(e,t)=>`${e} groups by a property of the event's object, but the app has no source for "${t}"`,groupingByProperty:e=>`${e} must be a property of the event's object`,analysisPage:(e,t)=>`${e} must be one of the app's pages${t?`: ${t.join(", ")}`:""}`,analysisSelection:e=>`${e} must be a selected-object filter`,analysisSelectionOther:e=>`${e} selects another kind of object than the one the event is about`,analysisAsOfNone:e=>`${e} the page has no as-of date`,analysisWindowShape:e=>`${e} must be { variable, days }`,analysisWindowVariable:e=>`${e} must be a date range filter`,analysisWindowDays:e=>`${e} must be an integer from 1 to 365 (days)`,mergeHours:e=>`${e} is the merge window of the event type: set it in the knowledge network`,fieldsList:e=>`${e} must be a list of at most 12 items`,fieldName:e=>`${e} must be a field name starting with a lowercase letter`,fieldDuplicate:(e,t)=>`${e} ${t} is used twice`,fieldType:(e,t)=>`${e} must be one of ${t.join(", ")}`,verifier:e=>`${e} must be a role name`,canvasText:(e,t)=>`${e} must be text of at most ${t} characters`,canvasPlaceholder:(e,t)=>`${e}: {${t}} is not a value of the event; use {title}, {type}, {severity}, {object}, {occurredAt} or {detail.<field>}`},bt=()=>fe({"zh-CN":gy,"en-US":yy}),by=/^[a-z0-9][a-z0-9_.-]{0,63}$/,wy=/^[a-z][a-z0-9_-]{0,39}$/,ql=720,ky=new Set(["id","owners","dueHours","report","analysis","grouping","strategies","strategyActions","canvas"]),vy=new Set(["label","source","subject","severity","rule"]),We=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),$y=(e,t)=>e===void 0||typeof e=="number"&&Math.abs(e*60-Math.round(e*60))<1e-6&&e*60>=1&&e<=ql?[]:[bt().hours(t,ql)],Bd=(e,t)=>e.objectType&&t.kn.objectTypes[e.objectType]?.name||e.objectType||"";function Sy(e,t,n,o){const s=bt();if(!We(e.strategyActions))return[s.strategyActionsObject(o)];const r=Array.isArray(e.strategies)?e.strategies:[];return Object.entries(e.strategyActions).flatMap(([a,l])=>{const c=`${o}.${a}`;if(!r.includes(a))return[s.notStrategy(c)];if(!We(l))return[s.boundShape(c)];const i=Object.keys(l).filter(d=>d!=="action"&&d!=="params");return i.length>0?i.map(d=>s.noOption(c,d)):t.network?t.subject?fc({on:"button",...l},{on:["button"],hit:!0},n,t.subject,c):[s.noSubjectSource(c,Bd(t,n))]:[]})}function jy(e,t,n){const o=bt();if(e!==void 0&&!Array.isArray(e))return[o.eventTypesList()];const s=Array.isArray(e)?e:[],r=en(t.kn.eventTypes),a=new Set,l=new Set(s.map(i=>We(i)?i.id:void 0));return[...t.spec.sources.flatMap((i,d)=>(i.events?.types??[]).filter(h=>!l.has(h)).map(h=>o.unknownEventType(`sources[${d}].events.types`,h))),...s.flatMap((i,d)=>{const h=`eventTypes[${d}]`;if(!We(i))return[o.object(h)];const u=[];for(const f of Object.keys(i))vy.has(f)?u.push(o.inNetwork(`${h}.${f}`)):ky.has(f)||u.push(o.noOption(h,f));if(typeof i.id!="string"||!by.test(i.id))return u.push(o.typeCode(`${h}.id`)),u;a.has(i.id)?u.push(o.duplicate(i.id)):a.add(i.id);const p=Fc(t.spec,i,r);return i.owners!==void 0&&!(Array.isArray(i.owners)&&i.owners.length<=8&&i.owners.every(f=>typeof f=="string"&&f.trim()!==""))&&u.push(o.owners(`${h}.owners`)),u.push(...$y(i.dueHours,`${h}.dueHours`)),i.report!==void 0&&(p.source==="rule"?u.push(o.reportRule(`${h}.report`)):u.push(...Ey(i.report,`${h}.report`))),i.analysis!==void 0&&u.push(...Ty(i.analysis,p,t,n,`${h}.analysis`)),i.grouping!==void 0&&u.push(...Ay(i.grouping,p,t,`${h}.grouping`)),i.strategies!==void 0&&!(Array.isArray(i.strategies)&&i.strategies.length<=12&&i.strategies.every(f=>typeof f=="string"&&f.trim()!==""&&f.length<=40))&&u.push(o.strategies(`${h}.strategies`)),i.strategyActions!==void 0&&u.push(...Sy(i,p,t,`${h}.strategyActions`)),i.canvas!==void 0&&u.push(...Oy(i.canvas,`${h}.canvas`)),u})]}function Ay(e,t,n,o){const s=bt();if(!We(e))return[s.groupingShape(o)];const r=[];for(const l of Object.keys(e))l!=="mode"&&l!=="by"&&r.push(s.noOption(o,l));if(!Hs.includes(e.mode))return[...r,s.groupingMode(`${o}.mode`,Hs)];if(e.mode!=="property")return e.by!==void 0&&r.push(s.groupingByOnly(`${o}.by`)),r;if(typeof e.by!="string"||e.by.trim()==="")return[...r,s.groupingByName(`${o}.by`)];if(t.source!=="report")return r;const a=ue(n.spec,t.subject);return a?pe(a,n.kn).some(l=>l.name===e.by)||r.push(s.groupingByProperty(`${o}.by`)):r.push(s.groupingNoSource(o,Bd(t,n))),r}function Ty(e,t,n,o,s){const r=bt();if(!We(e))return[r.object(s)];const a=[];for(const c of Object.keys(e))["page","selection","asOf","window"].includes(c)||a.push(r.noOption(s,c));(typeof e.page!="string"||o&&!o.includes(e.page))&&a.push(r.analysisPage(`${s}.page`,o));const l=c=>n.spec.variables.find(i=>i.name===c);if(e.selection!==void 0){const c=l(e.selection);!c||c.kind!=="selection"?a.push(r.analysisSelection(`${s}.selection`)):t.network&&ue(n.spec,c.source)?.objectType!==t.objectType&&a.push(r.analysisSelectionOther(`${s}.selection`))}if(e.asOf!==void 0&&(typeof e.asOf!="boolean"?a.push(r.boolean(`${s}.asOf`)):e.asOf&&!n.spec.variables.some(c=>c.kind==="asOf")&&a.push(r.analysisAsOfNone(`${s}.asOf`))),e.window!==void 0){const c=e.window;if(!We(c))a.push(r.analysisWindowShape(`${s}.window`));else{l(c.variable)?.kind!=="dateRange"&&a.push(r.analysisWindowVariable(`${s}.window.variable`));const i=c.days;(typeof i!="number"||!Number.isInteger(i)||i<1||i>365)&&a.push(r.analysisWindowDays(`${s}.window.days`))}}return a}function Oy(e,t){const n=bt();if(!We(e))return[n.object(t)];const o=[];for(const[s,r]of Object.entries(e)){const a=`${t}.${s}`;if(s!=="prompt"&&s!=="question")o.push(n.noOption(t,s));else if(typeof r!="string"||r.length>ro)o.push(n.canvasText(a,ro));else for(const l of my(r))o.push(n.canvasPlaceholder(a,l))}return o}function Ey(e,t){const n=bt();if(!We(e))return[n.object(t)];const o=[];for(const r of Object.keys(e))r==="mergeHours"?o.push(n.mergeHours(`${t}.mergeHours`)):r!=="fields"&&r!=="verifier"&&o.push(n.noOption(t,r));const s=e.fields;if(!Array.isArray(s)||s.length>12)o.push(n.fieldsList(`${t}.fields`));else{const r=new Set;s.forEach((a,l)=>{const c=`${t}.fields[${l}]`;if(!We(a))return o.push(n.object(c));typeof a.name!="string"||!wy.test(a.name)?o.push(n.fieldName(`${c}.name`)):r.has(a.name)?o.push(n.fieldDuplicate(`${c}.name`,a.name)):r.add(a.name),(typeof a.label!="string"||a.label.trim()==="")&&o.push(n.required(`${c}.label`)),Gs.includes(a.type)||o.push(n.fieldType(`${c}.type`,Gs)),a.required!==void 0&&typeof a.required!="boolean"&&o.push(n.boolean(`${c}.required`))})}return e.verifier!==void 0&&(typeof e.verifier!="string"||e.verifier.trim()==="")&&o.push(n.verifier(`${t}.verifier`)),o}const Cy={join:e=>e.join("、"),pageNotObject:"页面定义必须是对象",appNotObject:"App Spec 必须是对象",emptyApp:"应用至少要放一个组件",pagePrefix:(e,t)=>`页面 ${e}:${t}`,component:e=>`组件 ${e}`,object:e=>`${e} 必须是对象`,array:e=>`${e} 必须是数组`,required:e=>`${e} 必填`,identifier:e=>`${e} 必须是字母开头的标识`,nonEmptyString:e=>`${e} 必须是非空字符串`,oneOf:(e,t)=>`${e} 只能是 ${t}`,either:(e,t,n)=>`${e} 只能是 ${t} 或 ${n}`,integer:(e,t,n)=>`${e} 必须是 ${t} 到 ${n} 的整数`,noOption:(e,t)=>`${e} 没有配置项 ${t}`,notField:e=>`${e} 不是数据源的字段`,version:"version 必须为 2",apiVersion:e=>`apiVersion 必须为 ${e}`,appId:"app.id 必须是字母或数字开头的标识",knDependency:(e,t)=>`dependencies.knowledgeNetwork 必须引用知识网络 ${e}(${t})`,pagesMin:"pages 至少要有一个页面",pageTwice:e=>`页面 id ${e} 重复`,navShown:"至少要有一个页面在导航中显示",variableReserved:(e,t)=>`${e} 不能以 ${t} 开头,这是自动联动保留的名称`,linkPathShape:e=>`${e} 必须是 { between: [对象类, 对象类], path: [关系…] }`,linkPathType:(e,t)=>`${e} 中的对象类 ${t} 不在知识网络中`,linkPathBroken:e=>`${e}.path 不是从 between[0] 到 between[1] 的关系路径`,linkPathLong:(e,t)=>`${e}.path 最多 ${t} 个关系`,customType:e=>`${e}.type 必须是 x-<发布者>.<名称> 形式的自定义组件类型`,customTwice:e=>`自定义组件 ${e} 登记了两次`,packageId:e=>`${e}.package 必须是上传后得到的组件包 id`,asideWidth:"layout.asideWidth(或 0)",chartPaletteSize:"theme.chartPalette 必须有 6 到 8 个颜色",chartPaletteHex:"theme.chartPalette 中的颜色必须是 #rrggbb",fontFamily:"theme.fontFamily 必须是字体名称列表",hexColor:e=>`${e} 必须是 #rrggbb 颜色`,contrast:(e,t,n,o)=>`${e} 与 ${t} 对比度 ${n},需不低于 ${o}`,sourcesMin:"sources 至少要有一个数据源",sourceTwice:e=>`数据源 ${e} 重复`,notObjectType:e=>`${e}.objectType 不是知识网络中的对象类`,notProperty:(e,t)=>`${e}.key 不是 ${t} 的属性`,onlyObjectSources:e=>`${e} 只能用于知识网络对象类的数据源`,modelOperationAction:e=>`${e}.action 模型结果数据源上的推演操作不能关联行动,请用落地`,notScenarioParam:e=>`${e} 不是方案参数`,scenarioParamType:e=>`${e} 的类型与方案参数不同`,displayShape:e=>`${e} 必须是 { template, facts? }`,templateNeedsField:e=>`${e}.template 至少要用 {字段名} 引用一个字段`,templateNotField:(e,t)=>`${e}.template 中的 {${t}} 不是数据源的字段`,factsList:(e,t)=>`${e}.facts 必须是不超过 ${t} 个字段名的列表`,factsNotField:(e,t)=>`${e}.facts 中的 ${t} 不是数据源的字段`,formatsShape:e=>`${e} 必须是 { 字段名: 格式 } 的对象`,formatShape:e=>`${e} 必须是 { unit?, decimals?, colors? }`,unitText:e=>`${e}.unit 必须是不超过 8 字的文本`,unitNumber:e=>`${e}.unit 只有数字字段有单位`,decimalsInt:(e,t)=>`${e}.decimals 必须是 0 到 ${t} 的整数`,decimalsNumber:e=>`${e}.decimals 只有数字字段有小数位`,colorsList:e=>`${e}.colors 必须是 [{ when, tone }] 的列表`,ruleShape:e=>`${e} 必须是 { when, tone }`,fromShape:e=>`${e}.from 必须是 { source, where?, filters? }`,fromNotSource:(e,t)=>`${e}.from.source 不是页面数据源:${t}`,fromSubset:e=>`${e}.from.source 不能是另一个子集`,fromCypherParams:e=>`${e}.from.source 不能是带参数的 Cypher 数据源`,sameAsBase:(e,t,n)=>`${e}.${t} 必须与来源数据源一致:${n}`,derivedOwn:(e,t)=>`${e}.${t} 子集沿用来源数据源的,不能自己定义`,variableTwice:e=>`变量 ${e} 重复`,variableDefault:(e,t)=>`${e}.default:${t}`,variableSource:e=>`${e}.source 不是页面数据源`,variableNoLonger:e=>`${e} 不再需要:筛选不绑数据源,由跟随它的组件各自指定字段`,componentTwice:e=>`组件 id ${e} 重复`,noRegion:(e,t,n)=>`${e} 布局没有区域 ${t},可用区域:${n}`,customNoPackage:(e,t)=>`${e}.type ${t} 是自定义组件,但应用的 components 里没有它的组件包:先上传组件包`,typeOneOf:(e,t)=>`${e}.type 只能是 ${t},或 components 里登记的自定义组件`,pageEmpty:"页面至少要放一个组件",detailType:e=>`detail 必须是 type 为 ${e} 的组件`,frameShape:e=>`${e} 必须给出 x、y、w、h`,frameRight:(e,t)=>`${e} 超出右边界:x + w 不能大于 ${t}`,frameSmall:(e,t,n,o)=>`${e} 太小:${t} 至少 ${n} 列宽、${o} 行高`},Ny={join:e=>e.join(", "),pageNotObject:"page definition must be an object",appNotObject:"App Spec must be an object",emptyApp:"the app needs at least one component",pagePrefix:(e,t)=>`page ${e}: ${t}`,component:e=>`component ${e}`,object:e=>`${e} must be an object`,array:e=>`${e} must be an array`,required:e=>`${e} is required`,identifier:e=>`${e} must be an identifier starting with a letter`,nonEmptyString:e=>`${e} must be a non-empty string`,oneOf:(e,t)=>`${e} must be one of ${t}`,either:(e,t,n)=>`${e} must be ${t} or ${n}`,integer:(e,t,n)=>`${e} must be an integer from ${t} to ${n}`,noOption:(e,t)=>`${e} has no option ${t}`,notField:e=>`${e} is not a field of the source`,version:"version must be 2",apiVersion:e=>`apiVersion must be ${e}`,appId:"app.id must be an identifier starting with a letter or digit",knDependency:(e,t)=>`dependencies.knowledgeNetwork must refer to knowledge network ${e} (${t})`,pagesMin:"pages needs at least one page",pageTwice:e=>`page id ${e} is used twice`,navShown:"at least one page must be shown in the navigation",variableReserved:(e,t)=>`${e} cannot start with ${t}, which default linkage uses`,linkPathShape:e=>`${e} must be { between: [object type, object type], path: [relations…] }`,linkPathType:(e,t)=>`${e} names object type ${t}, which is not in the network`,linkPathBroken:e=>`${e}.path is not a relation path from between[0] to between[1]`,linkPathLong:(e,t)=>`${e}.path may have at most ${t} relations`,customType:e=>`${e}.type must be a custom component type of the form x-<publisher>.<name>`,customTwice:e=>`custom component ${e} is registered twice`,packageId:e=>`${e}.package must be the id of an uploaded component package`,asideWidth:"layout.asideWidth (or 0)",chartPaletteSize:"theme.chartPalette must have 6 to 8 colors",chartPaletteHex:"theme.chartPalette colors must be #rrggbb",fontFamily:"theme.fontFamily must be a list of font names",hexColor:e=>`${e} must be a #rrggbb color`,contrast:(e,t,n,o)=>`${e} and ${t} have a contrast of ${n}, at least ${o} is needed`,sourcesMin:"sources needs at least one source",sourceTwice:e=>`source ${e} is used twice`,notObjectType:e=>`${e}.objectType is not an object type of the knowledge network`,notProperty:(e,t)=>`${e}.key is not a property of ${t}`,onlyObjectSources:e=>`${e} only applies to sources of knowledge network object types`,modelOperationAction:e=>`${e}.action: a scenario operation on a model result source cannot link an action, use landing`,notScenarioParam:e=>`${e} is not a scenario parameter`,scenarioParamType:e=>`${e} has a different type than the scenario parameter`,displayShape:e=>`${e} must be { template, facts? }`,templateNeedsField:e=>`${e}.template must refer to at least one field as {field name}`,templateNotField:(e,t)=>`{${t}} in ${e}.template is not a field of the source`,factsList:(e,t)=>`${e}.facts must be a list of at most ${t} field names`,factsNotField:(e,t)=>`${t} in ${e}.facts is not a field of the source`,formatsShape:e=>`${e} must be an object of { field name: format }`,formatShape:e=>`${e} must be { unit?, decimals?, colors? }`,unitText:e=>`${e}.unit must be text of at most 8 characters`,unitNumber:e=>`${e}.unit applies to number fields only`,decimalsInt:(e,t)=>`${e}.decimals must be an integer from 0 to ${t}`,decimalsNumber:e=>`${e}.decimals applies to number fields only`,colorsList:e=>`${e}.colors must be a list of [{ when, tone }]`,ruleShape:e=>`${e} must be { when, tone }`,fromShape:e=>`${e}.from must be { source, where?, filters? }`,fromNotSource:(e,t)=>`${e}.from.source is not a source of the page: ${t}`,fromSubset:e=>`${e}.from.source cannot be another subset`,fromCypherParams:e=>`${e}.from.source cannot be a Cypher source with parameters`,sameAsBase:(e,t,n)=>`${e}.${t} must match the source it comes from: ${n}`,derivedOwn:(e,t)=>`${e}.${t} is taken from the source the subset comes from and cannot be set here`,variableTwice:e=>`variable ${e} is used twice`,variableDefault:(e,t)=>`${e}.default: ${t}`,variableSource:e=>`${e}.source is not a source of the page`,variableNoLonger:e=>`${e} is no longer needed: a filter is not bound to a source, each component that follows it names its own field`,componentTwice:e=>`component id ${e} is used twice`,noRegion:(e,t,n)=>`${e} layout has no region ${t}, available regions: ${n}`,customNoPackage:(e,t)=>`${e}.type ${t} is a custom component, but components of the app has no component package for it: upload the component package first`,typeOneOf:(e,t)=>`${e}.type must be one of ${t}, or a custom component registered in components`,pageEmpty:"a page needs at least one component",detailType:e=>`detail must be a component of type ${e}`,frameShape:e=>`${e} must give x, y, w, h`,frameRight:(e,t)=>`${e} goes past the right edge: x + w must not exceed ${t}`,frameSmall:(e,t,n,o)=>`${e} is too small: ${t} needs at least ${n} columns wide and ${o} rows high`},ye=()=>fe({"zh-CN":Cy,"en-US":Ny}),Fl="lk_",Dl=4,Bl=/^#[0-9a-fA-F]{6}$/,$o=/^[A-Za-z][A-Za-z0-9_-]{0,39}$/,xy=/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/,Ry=["colorPrimary","colorAccent","colorBg","colorSurface","colorSurfaceAlt","colorBorder","colorText","colorTextMuted","colorSuccess","colorWarning","colorDanger","colorInfo"],jr=4.5,Ar=3;function _y(e,t,n={}){const o=ye(),s=[],r=c=>s.push(c);if(!K(e))return{ok:!1,errors:[o.pageNotObject]};const a=Ld(t,e.sources);if(e.version!==2&&r(o.version),(typeof e.title!="string"||e.title.trim()==="")&&r(o.nonEmptyString("title")),My(e.layout,r),qy(e.theme,r),e.linking!==void 0&&!Te(e.linking,ka)&&r(o.oneOf("linking",o.join(ka))),Hy(e.linkPaths,a,r),s.length>0)return{ok:!1,errors:s};if(Fy(e.sources,a,r,n.allowEmpty??!1),s.length>0)return{ok:!1,errors:s};if(Yy(e.variables,e,r),s.length>0)return{ok:!1,errors:s};if(e.sources.forEach((c,i)=>Zg(c,e.variables,`sources[${i}]`).forEach(r)),s.length>0)return{ok:!1,errors:s};if(qg(e.scenarioParams).forEach(r),s.length>0)return{ok:!1,errors:s};if(Wy(e,a,r),s.length>0)return{ok:!1,errors:s};if(Ky(e,a,r),s.length>0)return{ok:!1,errors:s};const l=e;return Gy(e,{kn:a,spec:l},r,n.allowEmpty??!1),s.length>0?{ok:!1,errors:s}:{ok:!0,spec:l}}const Py=()=>ye().emptyApp;function Ud(e,t,n={}){const o=ye();if(!K(e))return{ok:!1,errors:[o.appNotObject]};const s=[],r=u=>s.push(u);e.apiVersion!==pt&&r(o.apiVersion(String(pt)));const a=e.app;K(a)?((typeof a.id!="string"||!xy.test(a.id))&&r(o.appId),(typeof a.name!="string"||a.name.trim()==="")&&r(o.nonEmptyString("app.name"))):r(o.object("app"));const l=K(e.dependencies)?e.dependencies.knowledgeNetwork:void 0;(!K(l)||l.id!==t.id)&&r(o.knDependency(t.id,t.name));const c=e.pages;if(!Array.isArray(c)||c.length===0)r(o.pagesMin);else{const u=new Set;c.forEach((p,f)=>{if(!K(p))return r(o.object(`pages[${f}]`));if(typeof p.id!="string"||!$o.test(p.id))return r(o.identifier(`pages[${f}].id`));u.has(p.id)&&r(o.pageTwice(p.id)),u.add(p.id)}),c.every(p=>K(p)&&p.hidden===!0)&&r(o.navShown)}if(Ly(e.components,r),s.length>0)return{ok:!1,errors:s};const i=e,d=new Set;if(i.pages.reduce((u,p)=>u+Object.values(p.regions??{}).reduce((f,m)=>f+(m?.length??0),0),0)===0&&!n.allowEmpty)return{ok:!1,errors:[Py()]};if(!n.allowEmpty&&Array.isArray(i.sources)&&i.sources.length===0)return{ok:!1,errors:[o.sourcesMin]};for(const u of i.pages){const p=_y(tn(i,u.id),t,{allowEmpty:!0});if(!p.ok)for(const f of p.errors)d.has(f)||(d.add(f),s.push(i.pages.length>1?o.pagePrefix(u.id,f):f))}return s.length>0?{ok:!1,errors:s}:(s.push(...jy(e.eventTypes,{kn:Ld(t,i.sources),spec:tn(i,i.pages[0].id)},i.pages.map(u=>u.id))),e.scheduleModel!==void 0&&s.push(...Ag(e.scheduleModel)),s.length>0?{ok:!1,errors:s}:{ok:!0,app:i})}function Ly(e,t){if(e===void 0)return;const n=ye();if(!Array.isArray(e))return t(n.array("components"));const o=new Set;e.forEach((s,r)=>{const a=`components[${r}]`;if(!K(s))return t(n.object(a));if(!Rt(s.type))return t(n.customType(a));o.has(s.type)&&t(n.customTwice(s.type)),o.add(s.type),(typeof s.package!="string"||!Iy.test(s.package))&&t(n.packageId(a)),s.source!==void 0&&!Te(s.source,["upload","ai"])&&t(n.either(`${a}.source`,"upload","ai"))})}const Iy=/^[0-9a-f]{64}$/;function My(e,t){const n=ye();if(!K(e))return t(n.object("layout"));Te(e.type,Ds)||t(n.oneOf("layout.type",n.join(Ds))),Ie(e.columns,2,4,"layout.columns",t),Te(e.sidePosition,["left","right"])||t(n.either("layout.sidePosition","left","right")),Ie(e.sideWidth,220,420,"layout.sideWidth",t),e.asideWidth!==0&&Ie(e.asideWidth,240,420,n.asideWidth,t),Te(e.gap,["compact","normal","relaxed"])||t(n.oneOf("layout.gap",n.join(["compact","normal","relaxed"]))),e.pinRows!==void 0&&Ie(e.pinRows,0,xr,"layout.pinRows",t)}function qy(e,t){const n=ye();if(!K(e))return t(n.object("theme"));const o=[],s=c=>o.push(c);(typeof e.name!="string"||e.name.trim()==="")&&s(n.nonEmptyString("theme.name")),Te(e.mode,["light","dark"])||s(n.either("theme.mode","light","dark"));for(const c of Ry)(typeof e[c]!="string"||!Bl.test(e[c]))&&s(n.hexColor(`theme.${c}`));const r=e.chartPalette;if(!Array.isArray(r)||r.length<6||r.length>8?s(n.chartPaletteSize):r.every(c=>typeof c=="string"&&Bl.test(c))||s(n.chartPaletteHex),(typeof e.fontFamily!="string"||e.fontFamily.trim()===""||/[;{}<>]/.test(e.fontFamily))&&s(n.fontFamily),Ie(e.fontSize,12,16,"theme.fontSize",s),Ie(e.radius,0,16,"theme.radius",s),Te(e.shadow,Bs)||s(n.oneOf("theme.shadow",n.join(Bs))),Te(e.density,Us)||s(n.oneOf("theme.density",n.join(Us))),e.surface!==void 0&&!Te(e.surface,_t)&&s(n.oneOf("theme.surface",n.join(_t))),o.forEach(t),o.length>0)return;const a=e.colorText;for(const c of["colorBg","colorSurface"]){const i=zl(a,e[c]);i<jr&&t(n.contrast("colorText",c,i.toFixed(2),jr))}const l=zl(e.colorTextMuted,e.colorSurface);l<Ar&&t(n.contrast("colorTextMuted","colorSurface",l.toFixed(2),Ar))}function Fy(e,t,n,o){const s=ye();if(!Array.isArray(e))return n(s.sourcesMin);if(e.length===0)return o?void 0:n(s.sourcesMin);const r=new Set;e.forEach((a,l)=>{const c=`sources[${l}]`;if(!K(a))return n(s.object(c));if(typeof a.id!="string"||!$o.test(a.id)?n(s.identifier(`${c}.id`)):r.has(a.id)?n(s.sourceTwice(a.id)):r.add(a.id),(typeof a.label!="string"||a.label.trim()==="")&&n(s.required(`${c}.label`)),a.from!==void 0)return Uy(a,e,t,c).forEach(n);if(a.model!==void 0){if(!K(a.model))return n(s.object(`${c}.model`))}else if(a.events!==void 0){const u=_g(a,c);if(u.forEach(n),u.length>0)return}else if(a.cypher!==void 0){const u=Jg(a,c);if(u.forEach(n),u.length>0)return}const i=typeof a.objectType=="string"&&Object.hasOwn(t.objectTypes,a.objectType)?t.objectTypes[a.objectType]:void 0;if(!i)return n(s.notObjectType(c));((u,p)=>i.properties.find(m=>m.name===u)&&!0)(a.key)||n(s.notProperty(c,i.id)),nf(a.progress,i.properties,`${c}.progress`).forEach(n);const h=K(a.progress)&&Array.isArray(a.progress.steps);Fh(a.computed,[...i.properties,...h?yc(a.progress):[]],`${c}.computed`,{kn:t,objectType:i.id,cypher:a.cypher!==void 0,progress:h,sources:e.filter(K),...typeof a.id=="string"?{source:a.id}:{}}).forEach(n),a.display!==void 0&&Dy(a.display,a,t,`${c}.display`).forEach(n),a.formats!==void 0&&By(a.formats,a,t,`${c}.formats`).forEach(n),a.operations!==void 0&&(a.cypher!==void 0||a.events!==void 0?n(s.onlyObjectSources(`${c}.operations`)):Xh(a.operations,a,t,`${c}.operations`).forEach(n)),a.models!==void 0&&(a.cypher!==void 0||a.events!==void 0||a.model!==void 0?n(s.onlyObjectSources(`${c}.models`)):sp(a.models,a,t,`${c}.models`).forEach(n));for(const u of["follows","relatedTo"]){if(a[u]===void 0)continue;if(a.cypher!==void 0||a.events!==void 0||a.model!==void 0){n(s.onlyObjectSources(`${c}.${u}`));continue}(u==="follows"?oy:sy)(a[u],a,e.filter(K),t,`${c}.${u}`).forEach(n)}})}function Dy(e,t,n,o){const s=ye();if(!K(e)||typeof e.template!="string")return[s.displayShape(o)];const r=[...t.cypher?.columns??[],...pe(t,n)],a=i=>r.some(d=>d.name===i),l=Object.keys(e).filter(i=>!["template","facts"].includes(i)).map(i=>s.noOption(o,i)),c=Qg(e.template);c.length===0&&l.push(s.templateNeedsField(o));for(const i of c)a(i)||l.push(s.templateNotField(o,i));if(e.facts!==void 0)if(!Array.isArray(e.facts)||e.facts.length>ba||!e.facts.every(i=>typeof i=="string"))l.push(s.factsList(o,ba));else for(const i of e.facts)a(i)||l.push(s.factsNotField(o,i));return l}function By(e,t,n,o){const s=ye();if(!K(e))return[s.formatsShape(o)];const r=pe(t,n),a=un(t),l=[];for(const[c,i]of Object.entries(e)){const d=`${o}.${c}`,h=r.find(u=>u.name===c);if(!h){l.push(s.notField(d));continue}if(!K(i)){l.push(s.formatShape(d));continue}for(const u of Object.keys(i))["unit","decimals","colors"].includes(u)||l.push(s.noOption(d,u));if(i.unit!==void 0&&(typeof i.unit!="string"||i.unit.length>8?l.push(s.unitText(d)):h.type!=="number"&&l.push(s.unitNumber(d))),i.decimals!==void 0){const u=i.decimals;typeof u!="number"||!Number.isInteger(u)||u<0||u>Ws?l.push(s.decimalsInt(d,Ws)):h.type!=="number"&&l.push(s.decimalsNumber(d))}if(i.colors!==void 0){if(!Array.isArray(i.colors)){l.push(s.colorsList(d));continue}i.colors.forEach((u,p)=>{const f=`${d}.colors[${p}]`;if(!K(u))return l.push(s.ruleShape(f));Te(u.tone,Pt)||l.push(s.oneOf(`${f}.tone`,s.join(Pt))),l.push(...xe(u.when,r,`${f}.when`,a))})}}return l}function Uy(e,t,n,o){const s=ye(),r=e.from;if(!K(r)||typeof r.source!="string")return[s.fromShape(o)];const a=t.find(c=>K(c)&&c.id===r.source);if(!K(a))return[s.fromNotSource(o,r.source)];if(a.from!==void 0)return[s.fromSubset(o)];const l=[];K(a.cypher)&&K(a.cypher.params)&&Object.keys(a.cypher.params).length&&l.push(s.fromCypherParams(o)),e.objectType!==a.objectType&&l.push(s.sameAsBase(o,"objectType",String(a.objectType))),e.key!==a.key&&l.push(s.sameAsBase(o,"key",String(a.key)));for(const c of["progress","computed","cypher","formats","display","operations","follows","relatedTo","models"])c in e&&l.push(s.derivedOwn(o,c));for(const c of Object.keys(r))["source","where","filters"].includes(c)||l.push(s.noOption(`${o}.from`,c));if(r.where!==void 0){const c=ue({sources:t},e.id),i=c?pe(c,n):[];l.push(...xe(r.where,i,`${o}.from.where`,un(c)))}return l}const zy=[{key:"source",label:"来源数据源",kind:"source"},{key:"filters",label:"跟随的筛选",kind:"bindings",optional:!0}];function Wy(e,t,n){const o=ye(),s=e.scenarioParams??[];e.sources.forEach((r,a)=>{const l=`sources[${a}]`;r.model&&(Ug(r,{sources:e.sources,kn:t,variables:e.variables,scenarioParams:s},l).forEach(n),(r.operations??[]).forEach((c,i)=>{c?.action!==void 0&&n(o.modelOperationAction(`${l}.operations[${i}]`))})),(r.models??[]).forEach((c,i)=>(Array.isArray(c?.params)?c.params:[]).forEach((d,h)=>{if(d?.scenarioParam===void 0)return;const u=s.find(f=>f.name===d.scenarioParam),p=`${l}.models[${i}].params[${h}].scenarioParam`;u?u.type!==d.type&&n(o.scenarioParamType(p)):n(o.notScenarioParam(p))}))})}function Ky(e,t,n){e.sources.forEach((o,s)=>{if(!o.from?.filters)return;const r={source:o.from.source,filters:o.from.filters};Ad(zy,r,{kn:t,spec:e},`sources[${s}].from`).forEach(n)})}function Yy(e,t,n){const o=ye();if(!Array.isArray(e))return n(o.array("variables"));const s=new Set;e.forEach((r,a)=>{const l=`variables[${a}]`;if(!K(r))return n(o.object(l));if(typeof r.name!="string"||!$o.test(r.name))return n(o.identifier(`${l}.name`));if(s.has(r.name)&&n(o.variableTwice(r.name)),s.add(r.name),t.linking==="auto"&&r.name.startsWith(Fl)&&n(o.variableReserved(`${l}.name`,Fl)),(typeof r.label!="string"||r.label.trim()==="")&&n(o.required(`${l}.label`)),!Te(r.kind,Hn))return n(o.oneOf(`${l}.kind`,o.join(Hn)));const c=uy(r);if(c&&n(o.variableDefault(l,c)),r.kind==="selection"||r.kind==="set")t.sources.some(i=>i.id===r.source)||n(o.variableSource(l));else for(const i of["source","field","fields"])i in r&&n(o.variableNoLonger(`${l}.${i}`))})}function Gy(e,t,n,o){const s=ye(),{layout:r,regions:a}=t.spec;if(!K(a))return n(s.object("regions"));const l=mc[r.type],c=new Set,i=new Set((t.spec.components??[]).map(p=>p.type));let d=0;const h=(p,f)=>{if(typeof p!="string"||!$o.test(p))return n(s.identifier(`${f}.id`));c.has(p)&&n(s.componentTwice(p)),c.add(p)};for(const[p,f]of Object.entries(a)){if(!l.includes(p)){n(s.noRegion(r.type,p,s.join(l)));continue}if(!Array.isArray(f)){n(s.array(`regions.${p}`));continue}f.forEach((m,g)=>{const y=`regions.${p}[${g}]`;if(!K(m))return n(s.object(y));h(m.id,y);const b=Rt(m.type);if(b&&!i.has(m.type))return n(s.customNoPackage(y,String(m.type)));if(!b&&!Te(m.type,Ve))return n(s.typeOneOf(y,s.join(Ve)));const k=m.type;d++,m.span!==void 0&&Ie(m.span,1,4,`${y}.span`,n),m.surface!==void 0&&!Te(m.surface,_t)&&n(s.oneOf(`${y}.surface`,s.join(_t))),m.follow!==void 0&&typeof m.follow!="boolean"&&n(s.oneOf(`${y}.follow`,"true、false")),m.click!==void 0&&!Te(m.click,va)&&n(s.oneOf(`${y}.click`,s.join(va))),r.type==="free"&&Vy(m.frame,k,`${s.component(String(m.id))}.frame`,n),Ul(k,Rt(k)&&K(m.config)?yf(k,m.config):m.config,t,s.component(String(m.id)),n)})}d===0&&!o&&n(s.pageEmpty);const u=e.detail;if(u!==void 0){if(!K(u)||u.type!==me)return n(s.detailType(me));h(u.id,"detail"),Ul(me,u.config,t,s.component(String(u.id)),n)}}function Ul(e,t,n,o,s){const r=ht(e),a=Ad(r.descriptors,t,n,o,r.free);a.forEach(s),a.length===0&&r.check&&r.check(t,n,o).forEach(s)}function Hy(e,t,n){if(e===void 0)return;const o=ye();if(!Array.isArray(e))return n(o.array("linkPaths"));e.forEach((s,r)=>{const a=`linkPaths[${r}]`;if(!K(s)||!Array.isArray(s.between)||s.between.length!==2||!s.between.every(u=>typeof u=="string")||!Array.isArray(s.path)||!s.path.every(u=>typeof u=="string"))return n(o.linkPathShape(a));const[l,c]=s.between,i=[l,c].find(u=>!t.objectTypes[u]);if(i)return n(o.linkPathType(a,i));const d=s.path;if(d.length===0)return;if(d.length>Dl)return n(o.linkPathLong(a,Dl));const h=dn(t,l,d);(!h||h[h.length-1].to!==c)&&n(o.linkPathBroken(a))})}function Vy(e,t,n,o){const s=ye();if(!K(e))return o(s.frameShape(n));Ie(e.x,0,At-1,`${n}.x`,o),Ie(e.w,1,At,`${n}.w`,o),Ie(e.y,0,400,`${n}.y`,o),Ie(e.h,2,40,`${n}.h`,o),typeof e.x=="number"&&typeof e.w=="number"&&e.x+e.w>At&&o(s.frameRight(n,At));const[r,a]=uf(t);(typeof e.w=="number"&&e.w<r||typeof e.h=="number"&&e.h<a)&&o(s.frameSmall(n,t,r,a))}function zl(e,t){const[n,o]=[Wl(e),Wl(t)].sort((s,r)=>r-s);return(n+.05)/(o+.05)}function Wl(e){const t=n=>{const o=parseInt(e.slice(n,n+2),16)/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4};return .2126*t(1)+.7152*t(3)+.0722*t(5)}function K(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Te(e,t){return typeof e=="string"&&t.includes(e)}function Ie(e,t,n,o,s){(typeof e!="number"||!Number.isInteger(e)||e<t||e>n)&&s(ye().integer(o,t,n))}const Jy="scheduleWorkbench",Zy=[{id:"topBottom",name:"上下布局 · 总览",description:"顶部是基准日期和关键指标,中间是趋势与地区分布,底部是整宽的明细表。",theme:"default",pages:[{title:"总览",cells:[["asOfSlider",0,0,12,3],["metricCards",0,3,12,4],["trendChart",0,7,8,8],["regionMap",8,7,4,8],["objectTable",0,15,12,11]]}]},{id:"leftRight",name:"左右布局 · 列表 + 详情",description:"左侧是待处理对象的长列表,右侧是指标、明细表和选中对象的关系子图。",theme:"default",pages:[{title:"列表与详情",cells:[["objectList",0,0,4,26],["metricCards",4,0,8,4],["objectTable",4,4,8,12],["subgraph",4,16,8,10]]}]},{id:"workbench",name:"三栏工作台",description:"左边收件箱、中间指标与明细、右边 Agent 对话,适合每天处理事务的岗位。",theme:"default",pages:[{title:"工作台",cells:[["objectList",0,0,3,24],["asOfSlider",3,0,6,3],["metricCards",3,3,6,4],["objectTable",3,7,6,17],["agentChat",9,0,3,24]]}]},{id:"cockpit",name:"驾驶舱",description:"深色大屏:大地图居中,配趋势、告警、关系链路与甘特图。",theme:"tech",pages:[{title:"驾驶舱",cells:[["metricCards",0,0,12,4],["regionMap",0,4,6,12],["trendChart",6,4,6,6],["alertList",6,10,6,6],["stageChain",0,16,12,4],["ganttChart",0,20,12,8]]}]},{id:"alertDesk",name:"告警处置台",description:"按规则列出告警,点一条只看它命中的对象,旁边看明细、关系子图并问 Agent。",theme:"default",pages:[{title:"告警处置",cells:[["alertList",0,0,4,12],["objectTable",4,0,8,12],["subgraph",0,12,6,10],["agentChat",6,12,6,10]]}]},{id:"analysis",name:"分析看板",description:"分组汇总、月度趋势、关系链路与地区分布并排,适合周会和复盘。",theme:"dark",pages:[{title:"分析",cells:[["asOfSlider",0,0,12,3],["pivotTable",0,3,6,8],["trendChart",6,3,6,8],["stageChain",0,11,12,4],["regionMap",0,15,5,9],["objectTable",5,15,7,9]]}]},{id:"production",name:"排程台",description:"按基准日期看甘特图,下方是明细与告警,盯住临近和超期的对象。",theme:"default",pages:[{title:"排程",cells:[["asOfSlider",0,0,5,4],["metricCards",5,0,7,4],["ganttChart",0,4,12,9],["objectTable",0,13,8,11],["alertList",8,13,4,11]]}]},{id:Jy,name:"资源排程工作台",description:"按向导回答排什么、排在哪、何时完成、结果写到哪里,生成按资源排行的调度甘特与方案改动;结果写入计划记录时另有只读的需求视角,可选再加一页所需资源与就绪。拖动改排程,采用前检查约束。",theme:"default",wizard:!0,pages:[{title:"排程",cells:[["scenarioBar",0,0,12,2,{title:"方案",style:"compact"}],["scheduleGantt",0,2,8,14,{title:"排程(按资源)"}],["scheduleGantt",0,16,8,9,{title:"所需资源与就绪(可选)"}],["scenarioBar",8,2,4,23,{title:"方案改动",style:"assumptions"}]]}]}],zd={id:"blank"};function Xy(e){const t=Object.values(e.objectTypes).filter(o=>o.properties.length>0),n=o=>o.properties.some(s=>s.type==="date")?1:0;return[...t].sort((o,s)=>n(s)-n(o)||s.properties.length-o.properties.length)[0]}const Kl=e=>JSON.parse(JSON.stringify(e));function Qy(e){const t=JSON.stringify(e.pages);return{...e,variables:e.variables.filter(n=>n.kind==="asOf"||t.includes(`"${n.name}"`))}}const eb=e=>ze[e]?.category==="scenario";function tb(e){return{...e,pages:e.pages.map(t=>{const n=t.regions.cells??[],o=rg(Object.fromEntries(n.flatMap(s=>s.frame?[[s.id,s.frame]]:[])));return{...t,regions:{cells:n.map(s=>o[s.id]?{...s,frame:o[s.id]}:s)}}})}}function nb(e,t,n,o,{scenarios:s=!0}={}){const r=Zy.find(m=>m.id===e),a=o&&n.objectTypes[o]||(e===zd.id?void 0:Xy(n)),l={apiVersion:pt,app:t,dependencies:{knowledgeNetwork:{id:n.id,name:n.name}},sources:[],variables:[{name:"asOf",label:"基准日期",kind:"asOf"}],pages:[{id:"main",title:"页面 1",layout:structuredClone(kl.free),regions:{},linking:"auto"}],theme:{...structuredClone(Xn.default),surface:"plain"}};if(!a)return{spec:l,skipped:[]};const c={id:Tg(tn(l,"main"),n,a.id),label:a.name,objectType:a.id,key:a.primaryKeys[0]??a.properties[0].name};if(!r)return{spec:{...l,sources:[c]},skipped:[]};let i={...l,sources:[c],pages:r.pages.map((m,g)=>({id:g===0?"main":`page${g+1}`,title:m.title,layout:structuredClone(kl.free),regions:{cells:[]},linking:"auto"})),theme:{...structuredClone(Xn[r.theme]),surface:"plain"}};const d=[],h=new Set,u=m=>{for(let g=1;;g++)if(!h.has(`${m}${g}`))return`${m}${g}`},p=m=>Ud(m,n,{allowEmpty:!0}).ok,f=a.properties.some(m=>m.type==="date");return r.pages.forEach((m,g)=>{const y=i.pages[g].id;for(const[v,S,j,O,A,E]of m.cells){if(!s&&eb(v))continue;const x=tn(i,y),L={id:u(v),type:v,config:Kl({...ht(v).defaults(x,{kn:n,spec:x},c.id),...E}),frame:{x:S,y:j,w:O,h:A}},I=ob(i,g,L);(v!=="asOfSlider"||f)&&p(I)?(i=I,h.add(L.id)):d.push(v)}const b=tn(i,y),k={id:g===0?"detail":`detail${g+1}`,type:me,config:Kl(ht(me).defaults(b,{kn:n,spec:b},c.id))},w={...i,pages:i.pages.map((v,S)=>S===g?{...v,detail:k}:v)};p(w)&&(i=w)}),{spec:tb(Qy(i)),skipped:d}}function ob(e,t,n){return{...e,pages:e.pages.map((o,s)=>s===t?{...o,regions:{cells:[...o.regions.cells??[],n]}}:o)}}const sb={usage:e=>`用法:workshop <命令> [参数] [选项]
|
|
158
158
|
|
|
159
159
|
list 列出能看到的应用
|
|
160
160
|
create <网络> <名称> [目录] 在知识网络上新建一个空应用并拉取;<网络> 为网络 id 或名称,目录默认以应用名命名
|
|
@@ -187,6 +187,7 @@ ${n}`,networkNotFound:(e,t,n,o)=>`没有找到知识网络「${e}」,或你没
|
|
|
187
187
|
- \`components/<目录>/\`:应用的自定义组件,每个目录是一个组件包(见下文“自定义组件”)。
|
|
188
188
|
- \`.workshop/guides/app-spec.md\`:App Spec 的规则;\`.workshop/app-spec.schema.json\`:它的结构。
|
|
189
189
|
- \`.workshop/guides/components/<组件类型>.md\`:各组件的说明,配置某个组件前先读它的说明。
|
|
190
|
+
- \`.workshop/guides/prototype.md\`:照 HTML 原型做应用时的做法。
|
|
190
191
|
- \`.workshop/network.json\`:知识网络的结构。对象类、属性、关系、行动、事件类型与指标的 id 一律以它为准,不要编造。
|
|
191
192
|
- \`.workshop/\` 下的其他文件由命令写出,不要改。
|
|
192
193
|
|
|
@@ -213,7 +214,7 @@ ${n}`,networkNotFound:(e,t,n,o)=>`没有找到知识网络「${e}」,或你没
|
|
|
213
214
|
- \`app.yaml\` 的 \`components\` 列出应用用到的组件包,其中的 \`package\` 由 \`workshop push\` 按目录的内容填写,不要手改。
|
|
214
215
|
- 删除组件:删掉它的目录,并从 \`app.yaml\` 的 \`components\` 与页面中删掉它。
|
|
215
216
|
- 这里放的是组件包本身。用 React 等模板写的组件,源码放在别处,构建后把产物放进这里。
|
|
216
|
-
`},
|
|
217
|
+
`},rb={usage:e=>`Usage: workshop <command> [arguments] [options]
|
|
217
218
|
|
|
218
219
|
list Lists the apps you can see
|
|
219
220
|
create <network> <name> [dir] Makes an empty app on a knowledge network and pulls it; <network> is its id or name; the folder is named after the app unless named
|
|
@@ -246,6 +247,7 @@ This folder is the project of a Workshop app, pulled with \`workshop pull\`. Cha
|
|
|
246
247
|
- \`components/<folder>/\`: the app's custom components; each folder is a component package (see "Custom components" below).
|
|
247
248
|
- \`.workshop/guides/app-spec.md\`: the App Spec's rules; \`.workshop/app-spec.schema.json\`: its structure.
|
|
248
249
|
- \`.workshop/guides/components/<component type>.md\`: each component's guide; read it before configuring that component.
|
|
250
|
+
- \`.workshop/guides/prototype.md\`: how to make the app from an HTML prototype.
|
|
249
251
|
- \`.workshop/network.json\`: the knowledge network's structure. The ids of object types, properties, relations, actions, event types and metrics are always taken from it; never make them up.
|
|
250
252
|
- The other files under \`.workshop/\` are written by the command; do not change them.
|
|
251
253
|
|
|
@@ -272,15 +274,15 @@ Each folder under \`components/\` is a component package: \`manifest.json\`, \`i
|
|
|
272
274
|
- \`components\` in \`app.yaml\` lists the packages the app uses; their \`package\` is filled in by \`workshop push\` from the folders' content. Do not edit it by hand.
|
|
273
275
|
- To delete a component, delete its folder and remove it from \`components\` in \`app.yaml\` and from the pages.
|
|
274
276
|
- What goes here is the package itself. For a component written with React or another framework, keep the source elsewhere and put the built output here.
|
|
275
|
-
`};let Xr="zh-CN";function
|
|
276
|
-
`)[0],line:t.linePos(l.pos[0]).line})),s=o.length===0?n.toJS():void 0,r=Ge.isMap(n.contents)&&Ge.isSeq(n.get("pages",!0));return{spec:s,syntax:o,locate:l=>{if(!r)return{message:l};for(const c of
|
|
277
|
+
`};let Xr="zh-CN";function Yl(e){Xr=e,oh({language:e})}function It(){return Xr}function D(){return Xr==="en-US"?rb:sb}(()=>{const e=new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let o=0;o<8;o++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();const ab=e=>e.replace(/^x-/,"").replace(/[^A-Za-z0-9-]+/g,"-"),ie="components",Wd=(e,t)=>Buffer.compare(Buffer.from(e),Buffer.from(t));function Kd(e){const t=lc("sha256");for(const n of[...e].sort((o,s)=>Wd(o.name,s.name)))t.update(n.name),t.update("\0"),t.update(String(n.data.length)),t.update("\0"),t.update(n.data);return t.digest("hex")}const ib=e=>Kd(bn(e).map(t=>({name:t.name,data:ct(t.path)}))),lb=e=>!e.startsWith(".")&&e!=="node_modules";function wn(e){const t=G(e,ie);return we(t)?nn(t,{withFileTypes:!0}).filter(n=>n.isDirectory()&&lb(n.name)).map(n=>n.name).sort(Wd).map(n=>{const o=G(t,n),s=Qm(o,{language:It()}),a=(s.manifest?s.files:bn(o)).map(c=>({name:c.name,data:ct(c.path)})),l=s.manifest?.type;return{folder:n,...Rt(l)?{type:l,manifest:s.manifest}:{},hash:Kd(a),files:a,check:s}}):[]}function cb(e){return!e||e.startsWith("/")||e.includes("\\")||e.includes("\0")?null:e.split("/").every(n=>n!==""&&!n.startsWith("."))?e:null}function Qr(e,t){if(we(e)){for(const n of nn(e,{withFileTypes:!0}))n.isDirectory()&&Qr(G(e,n.name),!0);t&&nn(e).length===0&&Tu(e)}}function db(e){if(we(e)){for(const t of bn(e))ut(t.path);Qr(e,!0)}}function Gl(e,t){const n=t.find(o=>cb(o.name)===null);if(n)throw new Error(D().unsafePath(n.name));if(we(e))for(const o of bn(e))ut(o.path);for(const o of t){const s=G(e,o.name);Bn(Tt(s),{recursive:!0}),ac(s,o.data)}Qr(e,!1)}const ub=new Set(["title","layout","regions","detail"]);function Hl(e){const t=[];for(const[,n,o]of e.matchAll(/([^.[\]]+)|\[(\d+)\]/g))t.push(o!==void 0?Number(o):n);return t}const hb=/^[A-Za-z][A-Za-z0-9_]*(?:\[\d+\]|\.[A-Za-z_$][A-Za-z0-9_$-]*)*/,pb=/(?:组件|\b[Cc]omponent) ([A-Za-z][A-Za-z0-9_-]*)((?:\[\d+\]|\.[A-Za-z_$][A-Za-z0-9_$-]*)*)/,Vl=/^(?:页面 (\S+?):|page (\S+?): )/;function fb(e,t,n){const o=t>=0?[t]:e.pages.map((s,r)=>r);for(const s of o){const r=e.pages[s];if(r?.detail?.id===n)return["pages",s,"detail"];const a=r?.regions&&typeof r.regions=="object"?r.regions:{};for(const[l,c]of Object.entries(a)){const i=Array.isArray(c)?c.findIndex(d=>d?.id===n):-1;if(i>=0)return["pages",s,"regions",l,i]}}}function mb(e,t){const n=Vl.exec(t),o=n?.[1]??n?.[2],s=t.replace(Vl,""),r=o?e.pages.findIndex(i=>i.id===o):e.pages.length===1?0:-1,a=[],l=pb.exec(s);if(l){const i=fb(e,r,l[1]);if(i){const d=Hl(l[2]);d[0]==="frame"||d[0]==="span"?a.push([...i,...d]):d.length>0&&a.push([...i,"config",...d]),a.push(i)}}const c=hb.exec(s)?.[0];if(c){const i=Hl(c);ub.has(String(i[0]))?r>=0&&a.push(["pages",r,...i]):a.push(i)}return r>=0&&o&&a.push(["pages",r]),a}function gb(e,t){let n=e.contents,o;for(const s of t)if(Ge.isMap(n)){const r=n.items.find(a=>Ge.isScalar(a.key)&&String(a.key.value)===String(s));if(!r)break;o=r.key.range?.[0]??o,n=r.value}else if(Ge.isSeq(n)&&typeof s=="number"&&s<n.items.length)n=n.items[s],o=n.range?.[0]??o;else break;return o}function yb(e){const t=new Ge.LineCounter,n=Ge.parseDocument(e,{lineCounter:t,prettyErrors:!1}),o=n.errors.map(l=>({message:l.message.split(`
|
|
278
|
+
`)[0],line:t.linePos(l.pos[0]).line})),s=o.length===0?n.toJS():void 0,r=Ge.isMap(n.contents)&&Ge.isSeq(n.get("pages",!0));return{spec:s,syntax:o,locate:l=>{if(!r)return{message:l};for(const c of mb(s,l)){const i=gb(n,c);if(i!==void 0)return{message:l,line:t.linePos(i).line}}return{message:l}}}}const bb=Object.assign({"./actionButton.en-US.md":()=>Promise.resolve().then(()=>zw).then(e=>e.default),"./actionButton.md":()=>Promise.resolve().then(()=>Kw).then(e=>e.default),"./agentChat.en-US.md":()=>Promise.resolve().then(()=>Gw).then(e=>e.default),"./agentChat.md":()=>Promise.resolve().then(()=>Vw).then(e=>e.default),"./alertList.en-US.md":()=>Promise.resolve().then(()=>Zw).then(e=>e.default),"./alertList.md":()=>Promise.resolve().then(()=>Qw).then(e=>e.default),"./asOfSlider.en-US.md":()=>Promise.resolve().then(()=>tk).then(e=>e.default),"./asOfSlider.md":()=>Promise.resolve().then(()=>ok).then(e=>e.default),"./customComponents.en-US.md":()=>Promise.resolve().then(()=>fu).then(e=>e.default),"./customComponents.md":()=>Promise.resolve().then(()=>mu).then(e=>e.default),"./dateRange.en-US.md":()=>Promise.resolve().then(()=>ik).then(e=>e.default),"./dateRange.md":()=>Promise.resolve().then(()=>ck).then(e=>e.default),"./dropdownFilter.en-US.md":()=>Promise.resolve().then(()=>uk).then(e=>e.default),"./dropdownFilter.md":()=>Promise.resolve().then(()=>pk).then(e=>e.default),"./eventList.en-US.md":()=>Promise.resolve().then(()=>mk).then(e=>e.default),"./eventList.md":()=>Promise.resolve().then(()=>yk).then(e=>e.default),"./eventReport.en-US.md":()=>Promise.resolve().then(()=>wk).then(e=>e.default),"./eventReport.md":()=>Promise.resolve().then(()=>vk).then(e=>e.default),"./ganttChart.en-US.md":()=>Promise.resolve().then(()=>Sk).then(e=>e.default),"./ganttChart.md":()=>Promise.resolve().then(()=>Ak).then(e=>e.default),"./metricCards.en-US.md":()=>Promise.resolve().then(()=>Ok).then(e=>e.default),"./metricCards.md":()=>Promise.resolve().then(()=>Ck).then(e=>e.default),"./modelTrial.en-US.md":()=>Promise.resolve().then(()=>xk).then(e=>e.default),"./modelTrial.md":()=>Promise.resolve().then(()=>_k).then(e=>e.default),"./objectDetail.en-US.md":()=>Promise.resolve().then(()=>Lk).then(e=>e.default),"./objectDetail.md":()=>Promise.resolve().then(()=>Mk).then(e=>e.default),"./objectList.en-US.md":()=>Promise.resolve().then(()=>Fk).then(e=>e.default),"./objectList.md":()=>Promise.resolve().then(()=>Bk).then(e=>e.default),"./objectTable.en-US.md":()=>Promise.resolve().then(()=>zk).then(e=>e.default),"./objectTable.md":()=>Promise.resolve().then(()=>Kk).then(e=>e.default),"./pivotTable.en-US.md":()=>Promise.resolve().then(()=>Gk).then(e=>e.default),"./pivotTable.md":()=>Promise.resolve().then(()=>Vk).then(e=>e.default),"./regionMap.en-US.md":()=>Promise.resolve().then(()=>Zk).then(e=>e.default),"./regionMap.md":()=>Promise.resolve().then(()=>Qk).then(e=>e.default),"./scenarioBar.en-US.md":()=>Promise.resolve().then(()=>tv).then(e=>e.default),"./scenarioBar.md":()=>Promise.resolve().then(()=>ov).then(e=>e.default),"./scheduleGantt.en-US.md":()=>Promise.resolve().then(()=>rv).then(e=>e.default),"./scheduleGantt.md":()=>Promise.resolve().then(()=>iv).then(e=>e.default),"./searchBox.en-US.md":()=>Promise.resolve().then(()=>cv).then(e=>e.default),"./searchBox.md":()=>Promise.resolve().then(()=>uv).then(e=>e.default),"./segmentedFilter.en-US.md":()=>Promise.resolve().then(()=>pv).then(e=>e.default),"./segmentedFilter.md":()=>Promise.resolve().then(()=>mv).then(e=>e.default),"./stageChain.en-US.md":()=>Promise.resolve().then(()=>yv).then(e=>e.default),"./stageChain.md":()=>Promise.resolve().then(()=>wv).then(e=>e.default),"./subgraph.en-US.md":()=>Promise.resolve().then(()=>vv).then(e=>e.default),"./subgraph.md":()=>Promise.resolve().then(()=>Sv).then(e=>e.default),"./taskInbox.en-US.md":()=>Promise.resolve().then(()=>Av).then(e=>e.default),"./taskInbox.md":()=>Promise.resolve().then(()=>Ov).then(e=>e.default),"./text.en-US.md":()=>Promise.resolve().then(()=>Cv).then(e=>e.default),"./text.md":()=>Promise.resolve().then(()=>xv).then(e=>e.default),"./trendChart.en-US.md":()=>Promise.resolve().then(()=>_v).then(e=>e.default),"./trendChart.md":()=>Promise.resolve().then(()=>Lv).then(e=>e.default)}),wb=new Set([...Ve,me]),Nt={};for(const[e,t]of Object.entries(bb)){const[,n,o]=/^\.\/([A-Za-z]+)(\.en-US)?\.md$/.exec(e)??[];!n||!wb.has(n)||(Nt[n]??={load:()=>Promise.reject(new Error(`no guide for ${n}`))},o?Nt[n].loadEnglish=t:Nt[n].load=t)}const kb={scheduleGantt:["排产","排程","调度","派工","检修","维修","齐套","甘特","产能","schedul","dispatch","gantt","kitting"]},vb=Object.keys(Nt).sort();Object.keys(kb).filter(e=>e in Nt);async function $b(e,t="zh-CN"){const n=Nt[e];if(!n)throw new Error(`no guide for ${e}`);return(!Yd(t)&&n.loadEnglish?n.loadEnglish:n.load)()}async function Sb(e="zh-CN"){return(Yd(e)?await Promise.resolve().then(()=>mu):await Promise.resolve().then(()=>fu)).default}function Yd(e){return e.startsWith("zh")}function jb(e,t,n){const o=(e.actionTypes??[]).filter(r=>!0).map(r=>{const a=(r.inputs??[]).map(l=>l.label&&l.label!==l.name?`${l.name}(${l.label})`:l.name);return`- ${r.id}:${r.name},对象类 ${r.objectType},${r.kind}${a.length>0?`;输入:${a.join("、")}`:""}`}),s=t.map(r=>`- box "${r.box}"(${r.boxName}),tool "${r.tool}":${r.toolName}${r.description?`;${r.description}`:""}`);return`
|
|
277
279
|
## 调度模型(排产、派工、检修等调度场景)
|
|
278
280
|
请求要把任务排到资源上(排产、排程、派工、检修、齐套、产能等),或要改调度甘特排什么、排在哪、何时完成、查哪些规则、怎么写回时,不要自己写 scheduleGantt 的图层、数据源和情景操作,而是只输出调度模型的答案;系统据此生成页面,并在向导里请用户逐项确认:
|
|
279
281
|
{"scheduleModel": {...}, "needs": [{"step": "rules", "text": "..."}]}
|
|
280
282
|
|
|
281
283
|
scheduleModel 的结构(只填知识网络里确有依据的项;没把握的项省略,由向导按知识网络建议):
|
|
282
284
|
- result:"self"(直接改任务本身的资源与时间,由任务的修改行动写回)或 "record"(写入计划记录,任务本身不改,由计划记录的新建、修改行动写回)。
|
|
283
|
-
- tasks:[{ objectType, assignField?, start?, end?, status?, doneWhen?: [{ field, op: "eq", value }], groupField?, target?: { path?, field }, ready?: { path, field }, predecessors?: { path: [关系] }, modify?: { action }, rules?: [{ name, tool: { box, tool }, severity?: "hard" | "soft" }] }]:被排的东西,1 到 ${
|
|
285
|
+
- tasks:[{ objectType, assignField?, start?, end?, status?, doneWhen?: [{ field, op: "eq", value }], groupField?, target?: { path?, field }, ready?: { path, field }, predecessors?: { path: [关系] }, modify?: { action }, rules?: [{ name, tool: { box, tool }, severity?: "hard" | "soft" }] }]:被排的东西,1 到 ${to} 类共用同一类资源。assignField 为取值是资源标识的字段;target 为何时要完成(任务自己的日期,或沿 path 到达的对象的日期,如工单的交期);ready 为开工前要就绪的对象及其就绪日;predecessors 为同类任务之间的前序关系(一条)。result 为 record 时只能 1 类任务,不写 assignField、start、end、modify,可写 groupField(成批的字段,如预测单号)。
|
|
284
286
|
- resource:{ objectType, titleField, parentField?, groupField?, capacityField? }:资源(产线、机台、班组),parentField 为上级资源标识(与 groupField 二选一),capacityField 为并行上限(数字)。
|
|
285
287
|
- calendars?:[{ objectType, resourceField, start, end }]:资源不可用的时段(停线、停机、请假),最多 3 个。
|
|
286
288
|
- record(result 为 record 时):{ objectType, match: [{ from: 计划记录的字段, to: 任务的字段 }], resourceField, start, end, status?, active?: [{ field, op: "ne", value }], create?: { action }, modify?: { action }, daysField? }。match 是计划认出“为哪条需求排的”的字段:只用单号、编码这类编号(如 单号 ↔ 单号、产品编码 ↔ 物料编码),合起来要能唯一确定一条需求(一张单有多个产品时,单号之外再加产品编码);不要用数量、日期、状态,它们碰巧相等不代表是同一条需求。
|
|
@@ -295,9 +297,9 @@ ${o.length>0?o.join(`
|
|
|
295
297
|
${s.length>0?s.join(`
|
|
296
298
|
`):"(知识网络没有挂载带规则函数的工具箱)"}
|
|
297
299
|
|
|
298
|
-
needs:知识网络缺对象类、属性、关系或行动,或没有合适的规则函数时,逐条写清楚要补什么,step 取 ${
|
|
300
|
+
needs:知识网络缺对象类、属性、关系或行动,或没有合适的规则函数时,逐条写清楚要补什么,step 取 ${vg.join("、")} 之一。needs 的 text 是给业务人员看的:对象类、属性、行动一律写显示名(如“预测单号”),不要写 id 或属性名(如 billno)。不要编造 id,也不要用别的对象、属性凑;规则函数没有合适的就不写进 rules,在 needs 里写“建议新建:XX 检查(读哪些对象、判断什么)”。
|
|
299
301
|
当前 App Spec 已有 scheduleModel 时,输出修改后的完整 scheduleModel:用户没提到的答案原样保留。只改调度甘特的显示时,在 scheduleModel 里写 display:{ resource?: { title?, tick?, daysBefore?, daysAfter?, layers?: [{ color?, tone?, colorField?, popoverFields? }] }, demand?: 同 },layers 按甘特现有图层的顺序。
|
|
300
|
-
请求与调度无关(例如加一张指标卡)时,照常输出 patch 或 spec,不要写 scheduleModel。`}const
|
|
302
|
+
请求与调度无关(例如加一张指标卡)时,照常输出 patch 或 spec,不要写 scheduleModel。`}const Ab=Object.entries(gc).filter(([e])=>!Nr.has(e)).map(([e,[t,n]])=>`${e} ${t}×${n}`).join("、"),Tb=Ve.filter(e=>ze[e].category==="scenario"),Ob=`## 页面写法
|
|
301
303
|
1. 一页一个任务:页面标题写谁要做什么(如“今日缺料”“待回复采购单”),不写功能名。
|
|
302
304
|
2. 首屏先说结论:页面开头放一个文字组件(text),一句话说清现在怎么样、先干什么,数字用 values 引用;下面最多 4 个关键数字,一个按紧急程度或日期排好的清单(告警、事件列表或表格),再加最多两张图。其余放到下一页或详情抽屉。
|
|
303
305
|
3. 数字带一句说明:指标卡每项写 description,说明它的含义或该干什么;表格、告警、事件列表、图表也写一句 description。
|
|
@@ -309,14 +311,14 @@ needs:知识网络缺对象类、属性、关系或行动,或没有合适的
|
|
|
309
311
|
9. 组件大小跟内容走:行数少的清单不要占满一屏高;自由布局里规则不多于 3 条的告警高度不超过 7 行。
|
|
310
312
|
10. 空状态说清楚:没有数据时写明原因和下一步。
|
|
311
313
|
11. 页面不超过 7 页:按“每天看”“偶尔用”“设置”分组。
|
|
312
|
-
`;function
|
|
313
|
-
`),c=
|
|
314
|
+
`;function Eb(e,t,n=[],{scenarios:o=!0,ruleTools:s,scheduling:r=n.some(a=>a.type==="scheduleGantt")}={}){const a=s&&r?jb(e,s):"",l=Object.entries(mc).map(([d,h])=>`- ${d}:区域 ${h.join("、")}`).join(`
|
|
315
|
+
`),c=jf(o).map(d=>{const h=ze[d];return`### ${d}(${h.label})
|
|
314
316
|
${h.description}
|
|
315
317
|
config:
|
|
316
|
-
${
|
|
318
|
+
${eo(h.descriptors)}`}).join(`
|
|
317
319
|
|
|
318
320
|
`),i=o?"":`
|
|
319
|
-
方案推演需要企业版,当前环境不提供:不要加方案类组件(${
|
|
321
|
+
方案推演需要企业版,当前环境不提供:不要加方案类组件(${Tb.join("、")});用户要求方案推演时,只输出不含它们的 App Spec。`;return`## App Spec 结构
|
|
320
322
|
{ apiVersion: "${pt}", app: { id, name }, dependencies: { knowledgeNetwork: { id: "${e.id}", name: "${e.name}" } }, sources, variables, eventTypes?, scheduleModel?, pages: [ { id, title, layout, regions, detail? } ], theme }
|
|
321
323
|
- 数据源、筛选和主题属于整个应用,所有页面共用,筛选的值在页面之间保留。
|
|
322
324
|
- 每个页面有自己的 id、标题、布局、组件和详情抽屉;组件 id 在页面内唯一。
|
|
@@ -329,18 +331,28 @@ ${l}
|
|
|
329
331
|
- workbench:side 为侧栏(宽 sideWidth 220–420,位置 sidePosition left/right),main 为主区,aside 为右栏(宽 asideWidth,0 表示隐藏,否则 240–420)。
|
|
330
332
|
- dashboard:header 为顶部整行;grid 为网格,列数 columns 2–4,组件用 span 指定跨列数。
|
|
331
333
|
- detail:header 顶部整行;main 主区;aside 右栏。
|
|
332
|
-
- free:自由网格,12 列、行高 40 像素,区域只有 cells;每个组件必须带 frame { x: 0–11, y: ≥0, w: 1–12, h: 2–40 },且 x + w ≤ 12;w、h 不得小于组件的最小尺寸(列×行):${
|
|
334
|
+
- free:自由网格,12 列、行高 40 像素,区域只有 cells;每个组件必须带 frame { x: 0–11, y: ≥0, w: 1–12, h: 2–40 },且 x + w ≤ 12;w、h 不得小于组件的最小尺寸(列×行):${Ab};同一行的组件 y 相同,不要重叠。pinRows(可选,0–${xr})为页面滚动时固定在顶部的行数:完全落在前 pinRows 行里的组件(如基准日期、筛选)一直显示在顶部;有组件从这几行开始、又延伸到下面时整页不固定,所以固定的组件要整个放在这几行里。
|
|
333
335
|
- gap 为 compact、normal、relaxed。
|
|
334
336
|
|
|
335
337
|
## 数据源(sources)
|
|
336
338
|
每项 { id, label, objectType, key, progress?, computed? }:objectType 为对象类 id;key 为标识对象的属性。
|
|
337
339
|
子集 { id, label, objectType, key, from: { source, where?, filters? } }:另一个数据源的子集,组件的 source 可以选它。from.source 为来源数据源 id(不能再是子集,也不能是带参数的 Cypher 数据源);where 为对象须全部满足的条件,可读来源的属性、进度列和计算列,写法同计算列的条件;filters 为它跟随的筛选,写法同组件的 filters。objectType、key 必须与来源一致;progress、computed 沿用来源,不能自己写。同一个子集(如“执行中的订单”)要给多个组件用,或要按条件统计时,定义成子集。
|
|
338
340
|
字段格式 formats(可选):{ 字段名: { unit?, decimals?, colors? } },所有组件显示这个字段时都沿用。unit 为数字的单位(如 件、万元),decimals 为小数位(0–6),colors 为着色规则列表 [{ when: 条件列表, tone }]:行满足条件时该字段显示为这个颜色(tone 同计算列的色调:neutral/info/success/warning/danger),条件可读本行任何字段,第一条成立的生效。子集沿用来源的格式。
|
|
339
|
-
${
|
|
340
|
-
${
|
|
341
|
+
${sf}
|
|
342
|
+
${Yh}
|
|
343
|
+
|
|
344
|
+
## 自动联动(页面的 linking)
|
|
345
|
+
页面 linking 为 auto 时自动联动(新建的页面都是):点击任一组件(表格的行、指标卡、分段与下拉筛选、透视表的行、趋势图、地图、告警、搜索框、日期区间)就是整页共享的一个条件,其他组件自动跟随——同类对象按同一字段或同一批对象筛,另一类对象沿知识网络里两类对象之间最短的关系连接筛(3 跳以内;一样短的有几条时沿任一条关联到即保留);详情抽屉、关系子图、Agent 自动读取最近点中的对象。所以这样的页面不要写 variables 里的取值、日期区间、搜索、选中对象、对象集合筛选,也不要写组件的 writes、selection、filters;基准日期 asOf 照旧是 variables 里的一项。
|
|
346
|
+
只在需要判断时写这几项:
|
|
347
|
+
- 组件的 follow: false(写在组件这一层,与 id、type 并列):总量参照、目标值、对比基准这类不该随点击变的组件。
|
|
348
|
+
- 组件的 click(同一层):select 只选中对象、不筛选页面,用于只看详情的明细表;none 点击不产生条件。不写为筛选页面。
|
|
349
|
+
- 表格的表头搜索 search、勾选 picks、快捷筛选 quickFilter 默认不开,要开时写 true。
|
|
350
|
+
- 应用的 linkPaths:[{ between: [对象类, 对象类], path: [关系 id…] }],只在自动选的最短连接含义不对时写(按关系的名称与说明判断,例如只想按“供应商可供的物料”联动):指定一条路径(最多 4 跳,两个方向都生效),path 为空表示不联动。没有把握时不写。
|
|
351
|
+
- 自动规则覆盖不了的联动(两组互不影响的联动、同时选中两个对象对比、带参数的 Cypher 数据源)仍按下一节写显式筛选;组件写入显式筛选时点击只写它,不再产生页面条件。
|
|
352
|
+
linking 不写或为 manual 时按下一节手动联动。修改已有页面时不要擅自改它的 linking。
|
|
341
353
|
|
|
342
354
|
## 筛选(variables)与联动
|
|
343
|
-
|
|
355
|
+
手动联动的页面两头都是显式的:组件点击时把值写入一个筛选(组件 config 里的 writes 等配置项);其他组件在自己的 filters 里列出跟随哪些筛选、按自己的哪个字段比对。没列在 filters 里的筛选不影响它;filters 为空就不受任何筛选影响。筛选本身不绑数据源和字段,所以不同数据源的组件可以跟随同一个筛选(比如两类对象都有客户字段时,各按自己的客户字段跟随同一个“客户”筛选)。
|
|
344
356
|
每项 { name, label, kind, default? }:
|
|
345
357
|
- asOf:基准日期,全页一个。不是筛选,不用写进 filters:有进度或计算列读了基准日期的数据源自动按它计算。
|
|
346
358
|
- value:一个或几个取值,比如某个分类字段的值;组件写入时可以是几个值的列表,比如一张“未完成”指标卡写入 ["${re.active.value}","${re.overdue.value}"](进度状态的代码)。跟随写 { variable, field }。
|
|
@@ -372,17 +384,17 @@ ${c}
|
|
|
372
384
|
### 详情抽屉 detail(type 固定为 ${me},不放在 regions 里)
|
|
373
385
|
${dt.description}
|
|
374
386
|
config:
|
|
375
|
-
${
|
|
376
|
-
${
|
|
377
|
-
${
|
|
387
|
+
${eo(dt.descriptors)}
|
|
388
|
+
${Cb(n,a!=="")}${a}
|
|
389
|
+
${Ob}
|
|
378
390
|
## 主题(theme)
|
|
379
391
|
surface(可选)为组件外观:card 每个组件带底色和边框,plain 组件直接放在页面上、靠间距分开,不写为 card。新建应用写 plain;改已有应用时,用户没要求就保留原值。
|
|
380
392
|
颜色一律 #rrggbb;chartPalette 6–8 个颜色;colorText 与 colorBg、colorSurface 对比度不低于 ${jr},colorTextMuted 与 colorSurface 不低于 ${Ar};mode 为 light 或 dark;fontSize 12–16;radius 0–16;shadow 为 none、subtle、strong;density 为 compact、comfortable。
|
|
381
393
|
用户说的“强调色、主色”指 colorPrimary(chartPalette 第一个颜色通常与它一致);点名的颜色要在所选模板基础上改进去。主题模板:
|
|
382
|
-
${Object.values(
|
|
394
|
+
${Object.values(Xn).map(d=>`- ${d.name}:${JSON.stringify(d)}`).join(`
|
|
383
395
|
`)}
|
|
384
396
|
|
|
385
|
-
${
|
|
397
|
+
${Rb(e,t)}${Nb(e)}`}function Cb(e,t=!1){return e.length===0?"":`
|
|
386
398
|
## 组件说明
|
|
387
399
|
以下组件附有说明,配置它们时以说明为准:先按“本体契约”把业务对象对应到组件的角色,再按“扩展点”接知识网络上的规则工具、逻辑属性或指标。说明中要求的对象类、属性、关系或工具在上面的知识网络里找不到时,不要用别的对象或计算列凑,也不要在配置里写业务规则,相应的可选项留空。${t?"调度甘特按“调度模型”一节输出答案:规则函数只从那里列出的选,要补的内容写进 needs。其他组件里要填 { box, tool } 的配置项一律不写,不要编造工具箱或工具的 id,由构建者在配置面板中选择。":"本提示不含执行工厂的工具清单:说明里提到的规则工具(如“齐套检查”)以及任何要填 { box, tool } 的配置项一律不写,不要编造工具箱或工具的 id,由构建者在配置面板中选择。说明里“问用户”“列出要补的内容”在这里不适用:只输出 App Spec。"}
|
|
388
400
|
|
|
@@ -391,51 +403,73 @@ ${o.text.trim()}
|
|
|
391
403
|
</guide>`).join(`
|
|
392
404
|
|
|
393
405
|
`)}
|
|
394
|
-
`}function
|
|
406
|
+
`}function Nb(e,t){const n=Xp(e);return n?`
|
|
395
407
|
|
|
396
408
|
## 对象指标
|
|
397
|
-
${n}`:""}const
|
|
398
|
-
对象类(id:名称;业务说明;属性 名称:类型(显示名))${n.length>
|
|
409
|
+
${n}`:""}const xb=30;function Rb(e,t){const n=Object.values(e.objectTypes),o=s=>!t;return`## 知识网络 ${e.name}(${e.id})
|
|
410
|
+
对象类(id:名称;业务说明;属性 名称:类型(显示名))${n.length>xb&&t?";网络较大,只列出与本次要求相关的对象类的属性,其余只列名称,需要时请用户点名":""}:
|
|
399
411
|
${n.map(s=>`- ${s.id}:${s.name}${s.comment?`;${s.comment}`:""}${o(s.id)?`;${s.properties.map(r=>`${r.name}:${r.type}(${r.label})`).join(",")}`:""}`).join(`
|
|
400
412
|
`)}
|
|
401
413
|
关系(id:名称,起点 → 终点;路径可以反向经过关系):
|
|
402
414
|
${e.relations.map(s=>`- ${s.id}:${s.name},${s.source} → ${s.target}`).join(`
|
|
403
|
-
`)}${
|
|
415
|
+
`)}${_b(e)}`}function _b(e){if(!e.eventTypes)return"";const t=e.eventTypes.map(n=>`- ${n.code}:${n.name},${n.source==="rule"?"规则命中":"用户登记"}${n.subject?`,关于 ${n.subject}`:""}`);return`
|
|
404
416
|
事件类型(编码:名称,来源,关于的对象类):
|
|
405
417
|
${t.length>0?t.join(`
|
|
406
|
-
`):"(暂无)"}`}const Te={type:"string",pattern:"^[A-Za-z][A-Za-z0-9_-]{0,39}$"},Nb={type:"string",pattern:"^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$"},xb={type:"number",minimum:1/60,maximum:720},Yl={type:"string",pattern:"^#[0-9a-fA-F]{6}$"},Ye={type:"object",required:["field","op"],properties:{field:{type:"string"},op:{enum:[...Yn]},ref:{type:"string"},value:{type:["string","number"]},values:{type:"array",items:{type:"string"}}}};function Rb(e){const t={title:e.label};switch(e.kind){case"text":return{...t,type:"string",...e.max===null?{}:{maxLength:e.max??80}};case"number":return{...t,type:e.decimal?"number":"integer",minimum:e.min,maximum:e.max};case"enum":return{...t,enum:e.options.map(([n])=>n)};case"bool":return{...t,type:"boolean"};case"source":return{...t,type:"string",description:"sources[].id"};case"field":return{...t,type:"string",description:"数据源或对象类的属性名"};case"fields":return{...t,type:"array",items:{type:"string"},minItems:1};case"variable":return{...t,type:"string",description:`variables[].name,类型为 ${e.accepts.join(" 或 ")}`};case"bindings":return{...t,type:"array",items:{type:"object",additionalProperties:!1,required:["variable"],properties:{variable:{type:"string",description:"variables[].name"},field:{type:"string",description:"value、dateRange 筛选:按数据源的哪个字段比对"},fields:{type:"array",items:{type:"string"},description:"search 筛选:在数据源的哪些文本字段里查找"}}}};case"values":return{...t,type:"array",items:{type:"string"}};case"conditions":return{...t,type:"array",items:Ye};case"objectType":return{...t,type:"string",description:"知识网络中的对象类 id"};case"operation":return{...t,type:"string",description:"数据源里定义的情景操作 id"};case"relationPath":return e.single?{...t,type:"array",items:{type:"string"},minItems:1,maxItems:1,description:"一条直接相连的关系 id"}:{...t,type:"array",items:{type:"string"},description:"关系 id 列表"};case"eventType":return e.multiple?{...t,type:"array",items:{type:"string"},description:"eventTypes[].id"}:{...t,type:"string",description:"eventTypes[].id"};case"tool":return{...t,type:"object",additionalProperties:!1,required:["box","tool"],properties:{box:{type:"string",description:"执行工厂工具箱 id"},tool:{type:"string",description:"工具箱里的工具 id"}}};case"mcpTool":return{...t,type:"object",additionalProperties:!1,required:["mcp","tool"],properties:{mcp:{type:"string",description:"执行工厂 MCP 服务 id"},agentId:{type:"string",description:"服务中默认智能体的 id"},agentName:{type:"string",description:"默认智能体名称"},tool:{type:"string",description:"MCP 服务里的工具名称"},mcpName:{type:"string",description:"MCP 服务名称,只用于显示;不写时对话框向执行工厂取"}}};case"list":return{...t,type:"array",minItems:e.min,maxItems:e.max,items:Tr(e.item)};case"interactions":{const n={type:"object",properties:{from:{type:"string",enum:["input","var","const"]},label:{type:"string",maxLength:20},variable:{type:"string"},value:{type:["string","number","boolean"]}},required:["from"]},o={type:"object",additionalProperties:!1,properties:{kind:{const:"ask"},question:{type:"string",maxLength:300},agent:{type:"string",enum:["analyst"]},context:{type:"array",items:{type:"string",enum:[...or]}},send:{type:"string",enum:[...sr]},maxObjects:{type:"integer",minimum:1,maximum:rr}},required:["kind","question"]},s={type:"object",additionalProperties:!1,properties:{kind:{const:"act"},action:{type:"string",description:"行动类型 id"},targets:{oneOf:[...e.hit?[{const:"hit"}]:[],{type:"object",properties:{selection:{type:"string"}},required:["selection"]},{type:"object",properties:{set:{type:"string"}},required:["set"]}]},params:{type:"object",additionalProperties:n},confirm:{type:"string",maxLength:120},maxObjects:{type:"integer",minimum:1,maximum:Fs}},required:["kind","action"]},r={type:"object",additionalProperties:!1,properties:{kind:{const:"simulate"},operation:{type:"string",description:"数据源的推演操作 id"}},required:["kind","operation"]};return{...t,type:"array",maxItems:e.max,items:{type:"object",additionalProperties:!1,properties:{on:{type:"string",enum:[...e.on]},label:{type:"string",maxLength:20},do:{type:"array",minItems:1,maxItems:Vn,items:e.actOn.length>0?{oneOf:[o,s,r]}:o}},required:["on","do"]}}}case"actionTypes":return{...t,type:"array",items:{type:"string"},description:"行动类型 id"};case"metric":return{...t,type:"object",additionalProperties:!1,required:["id","version"],properties:{id:{type:"string",description:"知识网络中已发布的对象指标 id"},version:{type:"integer",minimum:1}}}}}function Tr(e){return{type:"object",additionalProperties:!1,properties:Object.fromEntries(e.map(t=>[t.key,Rb(t)])),required:e.filter(t=>!t.optional&&!t.notNeeded).map(t=>t.key)}}const Gl=Object.keys(Zn.default).filter(e=>e.startsWith("color"));function _b(){const e=t=>({type:"object",additionalProperties:!1,required:["id","type","config"],properties:{id:Te,type:{const:t},span:{type:"integer",minimum:1,maximum:4},frame:{type:"object",additionalProperties:!1,required:["x","y","w","h"],properties:{x:{type:"integer",minimum:0,maximum:At-1},y:{type:"integer",minimum:0},w:{type:"integer",minimum:1,maximum:At},h:{type:"integer",minimum:1}}},surface:{enum:[..._t]},config:{$ref:`#/$defs/config_${t}`}}});return{$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://openbkn.ai/schemas/workshop/app-spec/v1.json",title:"Workshop App Spec",type:"object",additionalProperties:!1,required:["apiVersion","app","dependencies","sources","variables","pages","theme"],properties:{scheduleModel:{type:"object",description:"调度向导的答案(结果落点、任务、资源、日历、计划记录),由向导维护;页面上的调度配置由它生成"},apiVersion:{const:pt},app:{type:"object",additionalProperties:!1,required:["id","name"],properties:{id:Nb,name:{type:"string"},description:{type:"string"}}},dependencies:{type:"object",additionalProperties:!1,required:["knowledgeNetwork"],properties:{knowledgeNetwork:{type:"object",required:["id","name"],properties:{id:{type:"string"},name:{type:"string"}}}}},sources:{type:"array",minItems:1,items:{$ref:"#/$defs/source"}},variables:{type:"array",items:{$ref:"#/$defs/variable"}},eventTypes:{type:"array",items:{$ref:"#/$defs/eventType"}},pages:{type:"array",minItems:1,items:{$ref:"#/$defs/page"}},navigation:{type:"object",additionalProperties:!1,required:["style"],properties:{style:{enum:[...qf]}}},theme:{$ref:"#/$defs/theme"}},$defs:{source:{type:"object",additionalProperties:!1,required:["id","label","objectType","key"],properties:{id:Te,label:{type:"string"},objectType:{type:"string"},key:{type:"string"},progress:{type:"object",additionalProperties:!1,required:["steps"],properties:{steps:{type:"array",minItems:1,maxItems:8,items:{type:"object",additionalProperties:!1,required:["label","field"],properties:{label:{type:"string"},field:{type:"string"},done:{type:"array",items:Ye}}}},due:{type:"object",additionalProperties:!1,required:["field"],properties:{field:{type:"string"},label:{type:"string"}}}}},formats:{type:"object",description:"字段显示格式,键为字段名:{ unit?, decimals?, colors?: [{ when, tone }] }",additionalProperties:{type:"object",additionalProperties:!1,properties:{unit:{type:"string"},decimals:{type:"integer",minimum:0,maximum:Ws},colors:{type:"array",items:{type:"object",required:["when","tone"],properties:{when:{type:"array",items:Ye},tone:{enum:[...Pt]}}}}}}},events:{type:"object",additionalProperties:!1,description:"事件数据源:objectType 为 events:<id>,key 为 event_id",properties:{types:{type:"array",items:{type:"string"}}}},from:{type:"object",additionalProperties:!1,required:["source"],description:"子集:来源数据源 id、对象须满足的条件、跟随的筛选",properties:{source:{type:"string"},where:{type:"array",items:Ye},filters:{type:"array",items:{type:"object"}}}},computed:{type:"array",items:{type:"object",required:["name","label","kind"],properties:{name:Te,label:{type:"string"},kind:{enum:[...Zt]},cases:{type:"array",items:{type:"object"}},otherwise:{type:"object"},from:{type:"string"},to:{type:"string"},when:{type:"array",items:Ye},expr:{type:"string"},template:{type:"string"},path:{type:"array",items:{type:"string"}},aggregate:{enum:[...zs]},field:{type:"string"},type:{enum:["date","number","text"]},where:{type:"array",items:Ye},source:{type:"string"},pairs:{type:"array",items:{type:"object",required:["field","other"],properties:{field:{type:"string"},other:{type:"string"}}}}}}},operations:{type:"array",maxItems:Js,description:"推演操作:业务用户在方案中可做的假设;effects 只改知识网络属性,shiftDays/add 按当前值增减,set 设为参数值(日期属性可用 date 或 datetime 参数,datetime 精确到分钟),fromAsOf 设为基准日期起若干天;action 为采用方案时执行的行动",items:{type:"object",additionalProperties:!1,required:["id","label","params","effects"],properties:{id:Te,label:{type:"string",maxLength:30},when:{type:"array",items:Ye},params:{type:"array",minItems:1,maxItems:Hn,items:{type:"object",additionalProperties:!1,required:["name","label","type"],properties:{name:Te,label:{type:"string"},type:{enum:["number","date","datetime","text"]},min:{type:"number"},max:{type:"number"},default:{type:["string","number"]}}}},effects:{type:"array",description:"新建对象的行动(如为需求新建计划)可以没有效果",maxItems:Zs,items:{type:"object",additionalProperties:!1,required:["field","kind","param"],properties:{field:{type:"string"},kind:{enum:[...Ks]},param:{type:"string"}}}},action:{type:"object",additionalProperties:!1,required:["id"],properties:{id:{type:"string",description:"行动类型 id"},params:{type:"object",additionalProperties:{type:"object",properties:{from:{enum:["param","field","const"]},name:{type:"string"},value:{type:["string","number"]}},required:["from"]}},unique:{type:"array",items:{type:"string"},description:"新建行动的查重属性:已有对象这些属性相同(为空表示不限)时阻止新建,如计划的预测单号与产品编码"},active:{type:"array",items:Ye,description:"查重时只算满足这些条件的已有对象,如状态不是已取消"}}}}}},follows:{type:"array",maxItems:$r,description:"联动规则:方案中,本数据源的日期 field 不早于 from 数据源(页面中知识网络对象类的数据源)沿 path(从 from 的对象类到本对象类的关系类 id)关联到的对象的 fromField 加 gapDays 天。只有被直接改动、日期推迟的对象才往下推,推迟量减去余量;联动的值不再触发别的规则。取值带时刻(非零点)或设了 gapMinutes 时按分钟计算,否则按天。keepDuration 为本数据源的结束日期属性,随 field 移动同样的时长",items:{type:"object",additionalProperties:!1,required:["id","field","from","path","fromField","gapDays"],properties:{id:Te,field:{type:"string"},from:{type:"string",description:"sources[].id"},path:{type:"array",minItems:1,maxItems:to,items:{type:"string"}},fromField:{type:"string"},gapDays:{type:"integer",minimum:-no,maximum:no},gapMinutes:{type:"integer",minimum:-oo,maximum:oo},keepDuration:{type:"string",description:"本数据源的结束日期属性"}}}},models:{type:"array",maxItems:Qs,description:"模型试算:业务用户选一批本数据源的对象,按几组参数各调用一次执行工厂的工具(tool.box 工具箱、tool.tool 工具),比较结果。页面把每个对象的 key 与 inputs 中的字段、params、asOf 发给工具,工具为每个对象返回 outputs 中的字段;measures 汇总结果,可读本数据源字段与 outputs;结果不写回知识网络。action 为按结果执行的行动",items:{type:"object",additionalProperties:!1,required:["id","label","tool","inputs","params","outputs","measures"],properties:{id:Te,label:{type:"string",maxLength:30},description:{type:"string"},tool:{type:"object",additionalProperties:!1,required:["box","tool"],properties:{box:{type:"string",description:"执行工厂工具箱 id"},tool:{type:"string",description:"工具 id"},name:{type:"string",description:"工具名,供人阅读"}}},inputs:{type:"array",minItems:1,maxItems:er,items:{type:"string"}},params:{type:"array",minItems:1,maxItems:Hn,items:{type:"object",additionalProperties:!1,required:["name","label","type"],properties:{name:Te,label:{type:"string"},type:{enum:["number","date","text"]},min:{type:"number"},max:{type:"number"},default:{type:["string","number"]}}}},outputs:{type:"array",minItems:1,maxItems:tr,items:{type:"object",additionalProperties:!1,required:["name","label","type"],properties:{name:Te,label:{type:"string"},type:{enum:["number","date","text"]}}}},measures:{type:"array",minItems:1,maxItems:nr,items:{type:"object",additionalProperties:!1,required:["label","aggregate"],properties:{label:{type:"string"},when:{type:"array",items:Ye},aggregate:{enum:[...Xs]},valueField:{type:"string"}}}},action:{type:"object",additionalProperties:!1,required:["id"],properties:{id:{type:"string",description:"行动类型 id"},params:{type:"object",additionalProperties:{type:"object",properties:{from:{enum:["param","field","output","const"]},name:{type:"string"},value:{type:["string","number"]}},required:["from"]}}}}}}},relatedTo:{type:"array",maxItems:Sr,description:"相关对象:方案中,from 数据源里有变化(改动或联动)的对象沿 path 关联到的本数据源对象标为相关,值不变",items:{type:"object",additionalProperties:!1,required:["id","from","path"],properties:{id:Te,from:{type:"string",description:"sources[].id"},path:{type:"array",minItems:1,maxItems:to,items:{type:"string"}}}}}}},eventType:{type:"object",additionalProperties:!1,description:"应用怎样处理知识网络里的一类事件。事件类型(名称、来源、关联对象类、严重程度、规则)在知识网络里建模,这里只按编码引用并配置处理方式",required:["id"],properties:{id:{type:"string",pattern:"^[a-z0-9][a-z0-9_.-]{0,63}$",description:"知识网络里事件类型的编码"},owners:{type:"array",maxItems:8,items:{type:"string"}},dueHours:xb,grouping:{type:"object",additionalProperties:!1,required:["mode"],properties:{mode:{enum:[...Hs]},by:{type:"string",description:"按属性归并时:用户登记的事件取关联对象的属性名;规则命中的事件取识别规则命中返回的列名"}}},strategies:{type:"array",maxItems:12,items:{type:"string",maxLength:40}},canvas:{type:"object",additionalProperties:!1,description:"把一条事件发到分析画布时交给画布 AI 的要求;可引用 {title}、{type}、{severity}、{object}、{occurredAt}、{detail.<字段>}",properties:{prompt:{type:"string",maxLength:so,description:"提示词:告诉 AI 怎样分析,放在问题之前发送,不显示为提问"},question:{type:"string",maxLength:so,description:"问题:这一次要回答的事,在 AI 栏里显示为用户的提问"}}},strategyActions:{type:"object",description:"处理方案名 → 提交这种处理时对事件关联对象执行的行动",additionalProperties:{type:"object",additionalProperties:!1,required:["action"],properties:{action:{type:"string",description:"关联对象类上的行动类型 id"},params:{type:"object",description:"行动参数名 → 取值;{ from: 'input' } 表示确认时由人填写"}}}},analysis:{type:"object",additionalProperties:!1,required:["page"],properties:{page:{type:"string",description:"分析从哪个页面开始:pages[].id"},selection:{type:"string",description:"选中事件关联对象的选中对象筛选"},asOf:{type:"boolean",description:"基准日期设为事件发生那天"},window:{type:"object",additionalProperties:!1,required:["variable","days"],properties:{variable:{type:"string",description:"日期区间筛选"},days:{type:"integer",minimum:1,maximum:365}}}}},report:{type:"object",additionalProperties:!1,description:"只用于用户登记的事件类型:登记表单与核实角色",required:["fields"],properties:{fields:{type:"array",maxItems:12,items:{type:"object",additionalProperties:!1,required:["name","label","type"],properties:{name:{type:"string",pattern:"^[a-z][a-z0-9_-]{0,39}$"},label:{type:"string"},type:{enum:[...Gs]},required:{type:"boolean"}}}},verifier:{type:"string"}}}}},variable:{type:"object",required:["name","label","kind"],properties:{name:Te,label:{type:"string"},kind:{enum:[...Gn]},source:{type:"string",description:"只有 selection、set:对象来自哪个数据源"},default:{type:"string",description:"asOf:today 或 YYYY-MM-DD;dateRange:YYYY-MM-DD..YYYY-MM-DD(可省略一端);value、search:文本;selection、set 没有默认值"}}},page:{type:"object",additionalProperties:!1,required:["id","title","layout","regions"],properties:{id:Te,title:{type:"string"},icon:{enum:[...Ff]},group:{type:"string"},hidden:{type:"boolean"},badge:{enum:[...Df]},layout:{$ref:"#/$defs/layout"},regions:{type:"object",additionalProperties:{type:"array",items:{oneOf:Ve.map(t=>e(t))}}},detail:{type:"object",additionalProperties:!1,required:["id","type","config"],properties:{id:Te,type:{const:me},config:{$ref:`#/$defs/config_${me}`}}}}},layout:{type:"object",required:["type","columns","sidePosition","sideWidth","asideWidth","gap"],properties:{type:{enum:[...Ds]},columns:{type:"integer",minimum:2,maximum:4},sidePosition:{enum:["left","right"]},sideWidth:{type:"integer",minimum:220,maximum:420},asideWidth:{anyOf:[{const:0},{type:"integer",minimum:240,maximum:420}]},gap:{enum:["compact","normal","relaxed"]},pinRows:{type:"integer",minimum:0,maximum:xr}}},theme:{type:"object",required:["name","mode",...Gl,"chartPalette","fontFamily"],properties:{name:{type:"string"},mode:{enum:["light","dark"]},...Object.fromEntries(Gl.map(t=>[t,Yl])),chartPalette:{type:"array",minItems:6,maxItems:8,items:Yl},fontFamily:{type:"string"},fontSize:{type:"integer",minimum:12,maximum:16},radius:{type:"integer",minimum:0,maximum:16},shadow:{enum:[...Bs]},density:{enum:[...Us]},surface:{enum:[..._t]}}},...Object.fromEntries(Ve.map(t=>[`config_${t}`,{title:ze[t].label,description:ze[t].description,...Tr(ze[t].descriptors)}])),[`config_${me}`]:{title:dt.label,description:dt.description,...Tr(dt.descriptors)}}}}const Pb={string:"文本属性",number:"数字属性",date:"日期属性",datetime:"日期属性"},Lb=new Set(["title","source","filters","selection",ot]);function Ib(e,t){return t.length===0?"":`## 本应用的自定义组件
|
|
418
|
+
`):"(暂无)"}`}const Pb=["对应:一组数字卡合成一个 metricCards;表格、列表做成 objectTable 或 objectList;图表做成 trendChart,类型照原型(柱、线、饼);下拉、分段按钮、搜索框、日期框做成 dropdownFilter、segmentedFilter、searchBox、dateRange;结论和说明文字做成 text;导航、页眉、装饰不做。","原型里的数字、表格行和图上的值都是示例:按列名、指标名、图例对应到知识网络中含义相同的对象类和属性,统计方式照原型(计数、合计、按月等),一律从知识网络取数,不要把示例数字写进配置。","对应不上知识网络的项去掉;整个区块都对应不上时不做这个区块。不要编造对象类、属性或关系。","主题参照原型的底色、文字色、强调色和深浅,仍须满足对比度要求;原型的区块有底色、边框或阴影时 theme.surface 用 card,否则用 plain。","原型里对对象的操作按钮(如“催交”“新建采购单”),网络里有对应行动时配成组件的行动,没有就不做。","这次以原型的排布为准,不用遵守“页面写法”里首屏先放结论、数字个数的要求。"];function Lb(){return`# 照 HTML 原型做应用
|
|
419
|
+
|
|
420
|
+
> 由 \`workshop\` 命令生成,与构建器里“照原型做应用”交给 AI 的规则同出一处。
|
|
421
|
+
|
|
422
|
+
用户给出一个 HTML 原型(手写或 AI 生成的单文件页面),要照它在当前知识网络上做这个应用时,按下面做。
|
|
423
|
+
|
|
424
|
+
## 读原型
|
|
425
|
+
|
|
426
|
+
- 直接读 HTML 文件:页面结构、样式里的颜色、脚本里的图表配置(如 ECharts 的 option、Chart.js 的 config)都在里面。
|
|
427
|
+
- 原型里靠导航、侧栏或页签切换的每个视图做成一页,页面标题用视图名称。应用已有的页面保留不动,原型的页面加在后面;用户另有要求时按要求做。不改 \`app.name\`。
|
|
428
|
+
- 不把原型原样放进自定义组件。标准组件做不到的展示(如桑基图)列进最后的清单,用户要时再写自定义组件。
|
|
429
|
+
|
|
430
|
+
## 照着做
|
|
431
|
+
|
|
432
|
+
- 页面用 free 布局:按原型里各块的位置和大小估 frame。12 列铺满内容区(不含侧栏和页边距),每行 40 像素;为满足组件最小尺寸可以适当调整,组件之间不要重叠。
|
|
433
|
+
${Pb.map(e=>`- ${e}`).join(`
|
|
434
|
+
`)}
|
|
435
|
+
|
|
436
|
+
## 做完
|
|
437
|
+
|
|
438
|
+
- 照常 \`workshop validate\`、\`workshop push\`,再给出预览地址。
|
|
439
|
+
- 告诉用户哪些没有照做、或做法与原型明显不同,以及原因,每项一句,如“表格列‘承运商’在网络中没有对应属性,已去掉”。
|
|
440
|
+
`}const Ee={type:"string",pattern:"^[A-Za-z][A-Za-z0-9_-]{0,39}$"},Ib={type:"string",pattern:"^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$"},Mb={type:"number",minimum:1/60,maximum:720},Jl={type:"string",pattern:"^#[0-9a-fA-F]{6}$"},Ye={type:"object",required:["field","op"],properties:{field:{type:"string"},op:{enum:[...Gn]},ref:{type:"string"},value:{type:["string","number"]},values:{type:"array",items:{type:"string"}}}};function qb(e){const t={title:e.label};switch(e.kind){case"text":return{...t,type:"string",...e.max===null?{}:{maxLength:e.max??80}};case"number":return{...t,type:e.decimal?"number":"integer",minimum:e.min,maximum:e.max};case"enum":return{...t,enum:e.options.map(([n])=>n)};case"bool":return{...t,type:"boolean"};case"source":return{...t,type:"string",description:"sources[].id"};case"field":return{...t,type:"string",description:"数据源或对象类的属性名"};case"fields":return{...t,type:"array",items:{type:"string"},minItems:1};case"variable":return{...t,type:"string",description:`variables[].name,类型为 ${e.accepts.join(" 或 ")}`};case"bindings":return{...t,type:"array",items:{type:"object",additionalProperties:!1,required:["variable"],properties:{variable:{type:"string",description:"variables[].name"},field:{type:"string",description:"value、dateRange 筛选:按数据源的哪个字段比对"},fields:{type:"array",items:{type:"string"},description:"search 筛选:在数据源的哪些文本字段里查找"}}}};case"values":return{...t,type:"array",items:{type:"string"}};case"conditions":return{...t,type:"array",items:Ye};case"objectType":return{...t,type:"string",description:"知识网络中的对象类 id"};case"operation":return{...t,type:"string",description:"数据源里定义的情景操作 id"};case"relationPath":return e.single?{...t,type:"array",items:{type:"string"},minItems:1,maxItems:1,description:"一条直接相连的关系 id"}:{...t,type:"array",items:{type:"string"},description:"关系 id 列表"};case"eventType":return e.multiple?{...t,type:"array",items:{type:"string"},description:"eventTypes[].id"}:{...t,type:"string",description:"eventTypes[].id"};case"tool":return{...t,type:"object",additionalProperties:!1,required:["box","tool"],properties:{box:{type:"string",description:"执行工厂工具箱 id"},tool:{type:"string",description:"工具箱里的工具 id"},boxName:{type:"string",description:"工具箱名称,编号在别的环境不同时按它找回"},toolName:{type:"string",description:"工具名称,编号在别的环境不同时按它找回"}}};case"mcpTool":return{...t,type:"object",additionalProperties:!1,required:["mcp","tool"],properties:{mcp:{type:"string",description:"执行工厂 MCP 服务 id"},agentId:{type:"string",description:"服务中默认智能体的 id"},agentName:{type:"string",description:"默认智能体名称"},tool:{type:"string",description:"MCP 服务里的工具名称"},mcpName:{type:"string",description:"MCP 服务名称,只用于显示;不写时对话框向执行工厂取"}}};case"list":return{...t,type:"array",minItems:e.min,maxItems:e.max,items:Tr(e.item)};case"interactions":{const n={type:"object",properties:{from:{type:"string",enum:["input","var","const"]},label:{type:"string",maxLength:20},variable:{type:"string"},value:{type:["string","number","boolean"]}},required:["from"]},o={type:"object",additionalProperties:!1,properties:{kind:{const:"ask"},question:{type:"string",maxLength:300},agent:{type:"string",enum:["analyst"]},context:{type:"array",items:{type:"string",enum:[...or]}},send:{type:"string",enum:[...sr]},maxObjects:{type:"integer",minimum:1,maximum:rr}},required:["kind","question"]},s={type:"object",additionalProperties:!1,properties:{kind:{const:"act"},action:{type:"string",description:"行动类型 id"},targets:{oneOf:[...e.hit?[{const:"hit"}]:[],{type:"object",properties:{selection:{type:"string"}},required:["selection"]},{type:"object",properties:{set:{type:"string"}},required:["set"]}]},params:{type:"object",additionalProperties:n},confirm:{type:"string",maxLength:120},maxObjects:{type:"integer",minimum:1,maximum:Fs}},required:["kind","action"]},r={type:"object",additionalProperties:!1,properties:{kind:{const:"simulate"},operation:{type:"string",description:"数据源的推演操作 id"}},required:["kind","operation"]};return{...t,type:"array",maxItems:e.max,items:{type:"object",additionalProperties:!1,properties:{on:{type:"string",enum:[...e.on]},label:{type:"string",maxLength:20},do:{type:"array",minItems:1,maxItems:Jn,items:e.actOn.length>0?{oneOf:[o,s,r]}:o}},required:["on","do"]}}}case"actionTypes":return{...t,type:"array",items:{type:"string"},description:"行动类型 id"};case"metric":return{...t,type:"object",additionalProperties:!1,required:["id","version"],properties:{id:{type:"string",description:"知识网络中已发布的对象指标 id"},version:{type:"integer",minimum:1}}}}}function Tr(e){return{type:"object",additionalProperties:!1,properties:Object.fromEntries(e.map(t=>[t.key,qb(t)])),required:e.filter(t=>!t.optional&&!t.notNeeded).map(t=>t.key)}}const Zl=Object.keys(Xn.default).filter(e=>e.startsWith("color"));function Fb(){const e=t=>({type:"object",additionalProperties:!1,required:["id","type","config"],properties:{id:Ee,type:{const:t},span:{type:"integer",minimum:1,maximum:4},frame:{type:"object",additionalProperties:!1,required:["x","y","w","h"],properties:{x:{type:"integer",minimum:0,maximum:At-1},y:{type:"integer",minimum:0},w:{type:"integer",minimum:1,maximum:At},h:{type:"integer",minimum:1}}},surface:{enum:[..._t]},config:{$ref:`#/$defs/config_${t}`}}});return{$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://openbkn.ai/schemas/workshop/app-spec/v1.json",title:"Workshop App Spec",type:"object",additionalProperties:!1,required:["apiVersion","app","dependencies","sources","variables","pages","theme"],properties:{scheduleModel:{type:"object",description:"调度向导的答案(结果落点、任务、资源、日历、计划记录),由向导维护;页面上的调度配置由它生成"},apiVersion:{const:pt},app:{type:"object",additionalProperties:!1,required:["id","name"],properties:{id:Ib,name:{type:"string"},description:{type:"string"}}},dependencies:{type:"object",additionalProperties:!1,required:["knowledgeNetwork"],properties:{knowledgeNetwork:{type:"object",required:["id","name"],properties:{id:{type:"string"},name:{type:"string"}}}}},sources:{type:"array",minItems:1,items:{$ref:"#/$defs/source"}},variables:{type:"array",items:{$ref:"#/$defs/variable"}},eventTypes:{type:"array",items:{$ref:"#/$defs/eventType"}},pages:{type:"array",minItems:1,items:{$ref:"#/$defs/page"}},navigation:{type:"object",additionalProperties:!1,required:["style"],properties:{style:{enum:[...Yf]}}},theme:{$ref:"#/$defs/theme"}},$defs:{source:{type:"object",additionalProperties:!1,required:["id","label","objectType","key"],properties:{id:Ee,label:{type:"string"},objectType:{type:"string"},key:{type:"string"},progress:{type:"object",additionalProperties:!1,required:["steps"],properties:{steps:{type:"array",minItems:1,maxItems:8,items:{type:"object",additionalProperties:!1,required:["label","field"],properties:{label:{type:"string"},field:{type:"string"},done:{type:"array",items:Ye}}}},due:{type:"object",additionalProperties:!1,required:["field"],properties:{field:{type:"string"},label:{type:"string"}}}}},formats:{type:"object",description:"字段显示格式,键为字段名:{ unit?, decimals?, colors?: [{ when, tone }] }",additionalProperties:{type:"object",additionalProperties:!1,properties:{unit:{type:"string"},decimals:{type:"integer",minimum:0,maximum:Ws},colors:{type:"array",items:{type:"object",required:["when","tone"],properties:{when:{type:"array",items:Ye},tone:{enum:[...Pt]}}}}}}},events:{type:"object",additionalProperties:!1,description:"事件数据源:objectType 为 events:<id>,key 为 event_id",properties:{types:{type:"array",items:{type:"string"}}}},from:{type:"object",additionalProperties:!1,required:["source"],description:"子集:来源数据源 id、对象须满足的条件、跟随的筛选",properties:{source:{type:"string"},where:{type:"array",items:Ye},filters:{type:"array",items:{type:"object"}}}},computed:{type:"array",items:{type:"object",required:["name","label","kind"],properties:{name:Ee,label:{type:"string"},kind:{enum:[...Zt]},cases:{type:"array",items:{type:"object"}},otherwise:{type:"object"},from:{type:"string"},to:{type:"string"},when:{type:"array",items:Ye},expr:{type:"string"},template:{type:"string"},path:{type:"array",items:{type:"string"}},aggregate:{enum:[...zs]},field:{type:"string"},type:{enum:["date","number","text"]},where:{type:"array",items:Ye},source:{type:"string"},pairs:{type:"array",items:{type:"object",required:["field","other"],properties:{field:{type:"string"},other:{type:"string"}}}}}}},operations:{type:"array",maxItems:Js,description:"推演操作:业务用户在方案中可做的假设;effects 只改知识网络属性,shiftDays/add 按当前值增减,set 设为参数值(日期属性可用 date 或 datetime 参数,datetime 精确到分钟),fromAsOf 设为基准日期起若干天;action 为采用方案时执行的行动",items:{type:"object",additionalProperties:!1,required:["id","label","params","effects"],properties:{id:Ee,label:{type:"string",maxLength:30},when:{type:"array",items:Ye},params:{type:"array",minItems:1,maxItems:Vn,items:{type:"object",additionalProperties:!1,required:["name","label","type"],properties:{name:Ee,label:{type:"string"},type:{enum:["number","date","datetime","text"]},min:{type:"number"},max:{type:"number"},default:{type:["string","number"]}}}},effects:{type:"array",description:"新建对象的行动(如为需求新建计划)可以没有效果",maxItems:Zs,items:{type:"object",additionalProperties:!1,required:["field","kind","param"],properties:{field:{type:"string"},kind:{enum:[...Ks]},param:{type:"string"}}}},action:{type:"object",additionalProperties:!1,required:["id"],properties:{id:{type:"string",description:"行动类型 id"},params:{type:"object",additionalProperties:{type:"object",properties:{from:{enum:["param","field","const"]},name:{type:"string"},value:{type:["string","number"]}},required:["from"]}},unique:{type:"array",items:{type:"string"},description:"新建行动的查重属性:已有对象这些属性相同(为空表示不限)时阻止新建,如计划的预测单号与产品编码"},active:{type:"array",items:Ye,description:"查重时只算满足这些条件的已有对象,如状态不是已取消"}}}}}},follows:{type:"array",maxItems:$r,description:"联动规则:方案中,本数据源的日期 field 不早于 from 数据源(页面中知识网络对象类的数据源)沿 path(从 from 的对象类到本对象类的关系类 id)关联到的对象的 fromField 加 gapDays 天。只有被直接改动、日期推迟的对象才往下推,推迟量减去余量;联动的值不再触发别的规则。取值带时刻(非零点)或设了 gapMinutes 时按分钟计算,否则按天。keepDuration 为本数据源的结束日期属性,随 field 移动同样的时长",items:{type:"object",additionalProperties:!1,required:["id","field","from","path","fromField","gapDays"],properties:{id:Ee,field:{type:"string"},from:{type:"string",description:"sources[].id"},path:{type:"array",minItems:1,maxItems:no,items:{type:"string"}},fromField:{type:"string"},gapDays:{type:"integer",minimum:-oo,maximum:oo},gapMinutes:{type:"integer",minimum:-so,maximum:so},keepDuration:{type:"string",description:"本数据源的结束日期属性"}}}},models:{type:"array",maxItems:Qs,description:"模型试算:业务用户选一批本数据源的对象,按几组参数各调用一次执行工厂的工具(tool.box 工具箱、tool.tool 工具),比较结果。页面把每个对象的 key 与 inputs 中的字段、params、asOf 发给工具,工具为每个对象返回 outputs 中的字段;measures 汇总结果,可读本数据源字段与 outputs;结果不写回知识网络。action 为按结果执行的行动",items:{type:"object",additionalProperties:!1,required:["id","label","tool","inputs","params","outputs","measures"],properties:{id:Ee,label:{type:"string",maxLength:30},description:{type:"string"},tool:{type:"object",additionalProperties:!1,required:["box","tool"],properties:{box:{type:"string",description:"执行工厂工具箱 id"},tool:{type:"string",description:"工具 id"},name:{type:"string",description:"工具名,供人阅读;编号在别的环境不同时按它找回"},boxName:{type:"string",description:"工具箱名称,编号在别的环境不同时按它找回"}}},inputs:{type:"array",minItems:1,maxItems:er,items:{type:"string"}},params:{type:"array",minItems:1,maxItems:Vn,items:{type:"object",additionalProperties:!1,required:["name","label","type"],properties:{name:Ee,label:{type:"string"},type:{enum:["number","date","text"]},min:{type:"number"},max:{type:"number"},default:{type:["string","number"]}}}},outputs:{type:"array",minItems:1,maxItems:tr,items:{type:"object",additionalProperties:!1,required:["name","label","type"],properties:{name:Ee,label:{type:"string"},type:{enum:["number","date","text"]}}}},measures:{type:"array",minItems:1,maxItems:nr,items:{type:"object",additionalProperties:!1,required:["label","aggregate"],properties:{label:{type:"string"},when:{type:"array",items:Ye},aggregate:{enum:[...Xs]},valueField:{type:"string"}}}},action:{type:"object",additionalProperties:!1,required:["id"],properties:{id:{type:"string",description:"行动类型 id"},params:{type:"object",additionalProperties:{type:"object",properties:{from:{enum:["param","field","output","const"]},name:{type:"string"},value:{type:["string","number"]}},required:["from"]}}}}}}},relatedTo:{type:"array",maxItems:Sr,description:"相关对象:方案中,from 数据源里有变化(改动或联动)的对象沿 path 关联到的本数据源对象标为相关,值不变",items:{type:"object",additionalProperties:!1,required:["id","from","path"],properties:{id:Ee,from:{type:"string",description:"sources[].id"},path:{type:"array",minItems:1,maxItems:no,items:{type:"string"}}}}}}},eventType:{type:"object",additionalProperties:!1,description:"应用怎样处理知识网络里的一类事件。事件类型(名称、来源、关联对象类、严重程度、规则)在知识网络里建模,这里只按编码引用并配置处理方式",required:["id"],properties:{id:{type:"string",pattern:"^[a-z0-9][a-z0-9_.-]{0,63}$",description:"知识网络里事件类型的编码"},owners:{type:"array",maxItems:8,items:{type:"string"}},dueHours:Mb,grouping:{type:"object",additionalProperties:!1,required:["mode"],properties:{mode:{enum:[...Hs]},by:{type:"string",description:"按属性归并时:用户登记的事件取关联对象的属性名;规则命中的事件取识别规则命中返回的列名"}}},strategies:{type:"array",maxItems:12,items:{type:"string",maxLength:40}},canvas:{type:"object",additionalProperties:!1,description:"把一条事件发到分析画布时交给画布 AI 的要求;可引用 {title}、{type}、{severity}、{object}、{occurredAt}、{detail.<字段>}",properties:{prompt:{type:"string",maxLength:ro,description:"提示词:告诉 AI 怎样分析,放在问题之前发送,不显示为提问"},question:{type:"string",maxLength:ro,description:"问题:这一次要回答的事,在 AI 栏里显示为用户的提问"}}},strategyActions:{type:"object",description:"处理方案名 → 提交这种处理时对事件关联对象执行的行动",additionalProperties:{type:"object",additionalProperties:!1,required:["action"],properties:{action:{type:"string",description:"关联对象类上的行动类型 id"},params:{type:"object",description:"行动参数名 → 取值;{ from: 'input' } 表示确认时由人填写"}}}},analysis:{type:"object",additionalProperties:!1,required:["page"],properties:{page:{type:"string",description:"分析从哪个页面开始:pages[].id"},selection:{type:"string",description:"选中事件关联对象的选中对象筛选"},asOf:{type:"boolean",description:"基准日期设为事件发生那天"},window:{type:"object",additionalProperties:!1,required:["variable","days"],properties:{variable:{type:"string",description:"日期区间筛选"},days:{type:"integer",minimum:1,maximum:365}}}}},report:{type:"object",additionalProperties:!1,description:"只用于用户登记的事件类型:登记表单与核实角色",required:["fields"],properties:{fields:{type:"array",maxItems:12,items:{type:"object",additionalProperties:!1,required:["name","label","type"],properties:{name:{type:"string",pattern:"^[a-z][a-z0-9_-]{0,39}$"},label:{type:"string"},type:{enum:[...Gs]},required:{type:"boolean"}}}},verifier:{type:"string"}}}}},variable:{type:"object",required:["name","label","kind"],properties:{name:Ee,label:{type:"string"},kind:{enum:[...Hn]},source:{type:"string",description:"只有 selection、set:对象来自哪个数据源"},default:{type:"string",description:"asOf:today 或 YYYY-MM-DD;dateRange:YYYY-MM-DD..YYYY-MM-DD(可省略一端);value、search:文本;selection、set 没有默认值"}}},page:{type:"object",additionalProperties:!1,required:["id","title","layout","regions"],properties:{id:Ee,title:{type:"string"},icon:{enum:[...Gf]},group:{type:"string"},hidden:{type:"boolean"},badge:{enum:[...Hf]},layout:{$ref:"#/$defs/layout"},regions:{type:"object",additionalProperties:{type:"array",items:{oneOf:Ve.map(t=>e(t))}}},detail:{type:"object",additionalProperties:!1,required:["id","type","config"],properties:{id:Ee,type:{const:me},config:{$ref:`#/$defs/config_${me}`}}}}},layout:{type:"object",required:["type","columns","sidePosition","sideWidth","asideWidth","gap"],properties:{type:{enum:[...Ds]},columns:{type:"integer",minimum:2,maximum:4},sidePosition:{enum:["left","right"]},sideWidth:{type:"integer",minimum:220,maximum:420},asideWidth:{anyOf:[{const:0},{type:"integer",minimum:240,maximum:420}]},gap:{enum:["compact","normal","relaxed"]},pinRows:{type:"integer",minimum:0,maximum:xr}}},theme:{type:"object",required:["name","mode",...Zl,"chartPalette","fontFamily"],properties:{name:{type:"string"},mode:{enum:["light","dark"]},...Object.fromEntries(Zl.map(t=>[t,Jl])),chartPalette:{type:"array",minItems:6,maxItems:8,items:Jl},fontFamily:{type:"string"},fontSize:{type:"integer",minimum:12,maximum:16},radius:{type:"integer",minimum:0,maximum:16},shadow:{enum:[...Bs]},density:{enum:[...Us]},surface:{enum:[..._t]}}},...Object.fromEntries(Ve.map(t=>[`config_${t}`,{title:ze[t].label,description:ze[t].description,...Tr(ze[t].descriptors)}])),[`config_${me}`]:{title:dt.label,description:dt.description,...Tr(dt.descriptors)}}}}const Db={string:"文本属性",number:"数字属性",date:"日期属性",datetime:"日期属性"},Bb=new Set(["title","source","filters","selection",ot]);function Ub(e,t){return t.length===0?"":`## 本应用的自定义组件
|
|
407
441
|
按 ${ie}/ 下各组件的清单生成,放法与上面的标准组件相同:
|
|
408
442
|
- type 写清单里的 type;app.yaml 的 components 由 workshop push 填写,不要手写。
|
|
409
443
|
- ${ot}.<角色> 在 app.yaml 里写成 ${ot}: { <角色>: 属性名 },角色来自清单的 data.fields。
|
|
410
444
|
- 新建的组件要先运行一次 workshop validate,这里才会列出它。
|
|
411
445
|
|
|
412
|
-
${t.map(n=>
|
|
446
|
+
${t.map(n=>zb(e,n)).join(`
|
|
413
447
|
|
|
414
|
-
`)}`}function
|
|
415
|
-
清单读不出来,这里列不出它的配置:运行 workshop validate 查看错误。`;if(!o)return s;let r;try{r=
|
|
416
|
-
`)}function
|
|
417
|
-
`)}const Re="app.yaml",
|
|
418
|
-
${Ge.stringify(e,{lineWidth:0})}`}function
|
|
419
|
-
`)}const jo=e=>rn(e,Re),Or=(e,t)=>
|
|
420
|
-
`),
|
|
421
|
-
`);const s=
|
|
448
|
+
`)}`}function zb(e,t){const n=`${ie}/${t.folder}`,o=t.manifest,s=`### ${n}
|
|
449
|
+
清单读不出来,这里列不出它的配置:运行 workshop validate 查看错误。`;if(!o)return s;let r;try{r=Uc(o)}catch{return s}const a=o.defaultSize??{w:6,h:6},l=o.minSize??{w:3,h:3},c=we(G(e,n,"README.md"))?`,组件说明 ${n}/README.md`:"";return[`### ${o.type}(${r.label})`,...o.description?[o.description]:[],`目录:${n}${c}`,`大小(free 布局的 frame,列×行):默认 ${a.w}×${a.h},最小 ${l.w}×${l.h}`,"config:",...r.descriptors.map(i=>eo([i])+(i.hint?`;${i.hint}`:"")),"示例:",Wb(o,a)].join(`
|
|
450
|
+
`)}function Wb(e,t){const n=[];e.data.source&&n.push("source: <数据源 id>");const o=Array.isArray(e.data.fields)?e.data.fields:[];o.length>0&&n.push(`${ot}: { ${o.map(l=>`${l.role}: <${Db[l.type]??"属性"}>`).join(", ")} }`);const s=e.configSchema.properties??{};for(const l of e.configSchema.required??[]){if(Bb.has(l))continue;const c=s[l],i=c?.default!==void 0?JSON.stringify(c.default):`<${c?.title??l}>`;n.push(`${l}: ${i}`)}const r=e.type.slice(e.type.indexOf(".")+1).replace(/[^A-Za-z0-9]/g,"");return[` - id: ${/^[A-Za-z]/.test(r)?r:`custom${r}`}`,` type: ${e.type}`,` frame: { x: 0, y: 0, w: ${t.w}, h: ${t.h} }`,...n.length>0?[" config:",...n.map(l=>` ${l}`)]:[" config: {}"]].join(`
|
|
451
|
+
`)}const Re="app.yaml",Ae=".workshop",Gd=`${Ae}/app-spec.schema.json`,So=`${Ae}/remote`,Hd=`${So}/${Re}`,Vd=`${So}/${ie}`,Kb=`# yaml-language-server: $schema=./${Gd}`,it=e=>lc("sha256").update(e).digest("hex");function Xl(e){return`${Kb}
|
|
452
|
+
${Ge.stringify(e,{lineWidth:0})}`}function Ne(e,t,n){const o=G(e,t);Bn(Tt(o),{recursive:!0}),ac(o,n)}function rn(e,t){const n=G(e,t);return we(n)?ct(n,"utf8"):null}function Pe(e){const t=rn(e,`${Ae}/state.json`);return t===null?null:JSON.parse(t)}function Jd(e,t){Ne(e,`${Ae}/state.json`,`${JSON.stringify(t,null,2)}
|
|
453
|
+
`)}const jo=e=>rn(e,Re),Or=(e,t)=>Ne(e,Re,t),Yb=e=>we(G(e,So)),Gb=(e,t)=>Ne(e,Hd,t);function Zd(e){ut(G(e,So),{recursive:!0,force:!0})}function Xd(e){const t=G(e,Vd);return[...we(G(e,Hd))?[Re]:[],...we(t)?nn(t).sort().map(n=>`${ie}/${n}`):[]]}const Hb=()=>vb.filter(e=>!Nr.has(e));async function Qd(e,t,n=wn(e)){const o=It();Ne(e,`${Ae}/network.json`,`${JSON.stringify(t,null,2)}
|
|
454
|
+
`),Ne(e,Gd,`${JSON.stringify(Fb(),null,2)}
|
|
455
|
+
`);const s=Ub(e,n);Ne(e,`${Ae}/guides/app-spec.md`,`${D().rulesHeader}
|
|
422
456
|
|
|
423
|
-
${
|
|
457
|
+
${Eb(t)}
|
|
424
458
|
${s?`
|
|
425
459
|
${s}
|
|
426
|
-
`:""}`),
|
|
427
|
-
`)}function
|
|
428
|
-
`):n.split(/\r?\n/).some(o=>o.trim().replace(/\/$/,"")===
|
|
429
|
-
`)}${
|
|
430
|
-
`)}class F extends Error{}const
|
|
431
|
-
`))):new F(D().appNotFound(t))}function
|
|
432
|
-
`)));const r=D(),a=n.slice(0,30).map(l=>r.quoted(l.name));throw new F(r.networkNotFound(t,a.join(r.and),n.length,n.length>a.length))}async function Jb(e,t,n,o,s){const r=o.trim(),a=D();if(!r)throw new F(a.emptyName);const l=Pe(t);if(l)throw new F(a.alreadyProject(t,l.app.name));if(be(t)&&jo(t)!==null)throw new F(a.hasAppFile(t,Re));const c=await Vb(e,n);let i;try{i=await e.createApp(r,c)}catch(d){throw d instanceof Fr?new F(a.noCreateRight(c.name)):d}return s.out(a.created(c.name,i.name,i.id)),await na(e,t,i.id,null,s.out,s),0}async function Zb(e,t,n,o){const s=D(),r=Pe(t);if(r&&n&&n!==r.app.id&&n!==r.app.name)throw new F(s.otherProject(t,r.app.name,r.app.id,n));if(!r&&!n)throw new F(s.firstPullNeedsApp);if(!r&&be(t)&&jo(t)!==null)throw new F(s.notPulled(t,Re));const a=r?.app.id??(await Kb(e,n)).id;return await na(e,t,a,r,o.out,o),0}const Fn=e=>typeof e=="object"&&e!==null&&"type"in e;function Xb(e,t,n){const o=D(),s=[],r=[],a=[],l=new Map;for(const p of t){const f=`${ie}/${p.folder}`;if(s.push(...p.check.errors.map(y=>({file:f,message:y}))),!p.type)continue;const m=l.get(p.type);if(m){s.push({file:f,message:o.sameType(`${ie}/${m.folder}`,p.type)});continue}l.set(p.type,p);const g=n[p.type];if(!(p.hash===g?.hash||g?.behind&&p.hash===g.package)){if(g?.behind){s.push({file:f,message:o.behindChanged(p.type)});continue}a.push(p),r.push(...p.check.warnings.map(y=>o.at(f,y)))}}const c=p=>a.includes(p)?p.hash:n[p.type]?.package,i=Array.isArray(e)?e:[],d=i.map(p=>{const f=Fn(p)?l.get(p.type):void 0;return f?{...p,package:c(f),...a.includes(f)?{source:"upload"}:{}}:p});for(const[p,f]of l)i.some(m=>Fn(m)&&m.type===p)||d.push({type:p,package:c(f),source:"upload"});const h={};for(const[p,f]of l){const m=n[p];h[p]=m?.behind&&f.hash===m.hash?m:{folder:f.folder,package:c(f),hash:f.hash}}for(const[p,f]of Object.entries(n))!h[p]&&d.some(m=>Fn(m)&&m.type===p)&&(h[p]=f);const u=new Set([...l.keys()].filter(p=>h[p]?.behind));return{components:d,uploads:a,tracked:h,problems:s,warnings:r,usable:l,behind:u}}function Qb(e,t){const n=Ge.parseDocument(e),o=n.toJS()?.components;return wu(o??[],t)?e:(t.length===0?n.delete("components"):n.set("components",t),n.toString({lineWidth:0}))}async function Xd(e,t,n,o,s=bn(t)){const{spec:r,syntax:a,locate:l}=pb(o);if(a.length>0)return{ok:!1,errors:a,warnings:[]};const c=r?.apiVersion,i=[],d=D();typeof c=="string"&&c!==pt&&i.push(d.apiVersion(Re,c,pt));const h=await e.readNetwork(n.network);await Vd(t,h,s);const u=r?.components,p=Xb(u,s,n.components??{});i.push(...p.warnings);for(const[k,w]of p.usable)!p.behind.has(k)&&yd(w.manifest,It()).length===0&&Mc(p.components.find(v=>v.type===k)?.package??w.hash,w.manifest);const f=p.components.filter(k=>Fn(k)&&(!p.usable.has(k.type)||p.behind.has(k.type)));for(const k of await e.registerComponents(f))i.push(d.manifestUnreadable(k));const g=(Array.isArray(u)||u===void 0&&p.components.length>0)&&r&&typeof r=="object"?{...r,components:p.components}:r,y=qd(g,h,{allowEmpty:!0}),b=[...p.problems,...y.ok?[]:y.errors.map(l)];return!y.ok||b.length>0?{ok:!1,errors:b,warnings:i}:{ok:!0,spec:y.app,components:p.components,uploads:p.uploads,tracked:p.tracked,warnings:i}}function Qd(e,t){const n=D();for(const o of t.warnings)e.err(n.note(o));if(!t.ok){for(const o of t.errors)e.err(`${o.file??Re}${o.line?`:${o.line}`:""} ${o.message}`);e.err(n.errorCount(t.errors.length))}}async function ew(e,t,n){const{state:o,text:s}=ta(t),r=await Xd(e,t,o,s);return Qd(n,r),r.ok&&n.out(D().validated),r.ok?0:1}function Vl(e,t){const n=D();return e instanceof Fr?new F(n.forbidden):e instanceof qr?new F(n.appGone(t)):e instanceof Kc?new F(n.tooLarge):null}function tw(e,t){const n={};for(const[o,s]of Object.entries(e))n[o]={...s,package:t(s.package)};return n}function eu(e,t,n){const o=e.components??{},s=n.every(r=>r.type&&r.hash===o[r.type]?.hash);return it(t)!==e.appHash||!s}function nw(e){const{state:t,text:n}=ta(e);return eu(t,n,bn(e))}async function tu(e,t,{merged:n=!1},o){const s=D(),{state:r,text:a}=ta(t);if(n&&r.remoteRevision===void 0)throw new F(s.nothingToMerge);if(!n&&Db(t))return o.err(Zd(r.remoteRevision??r.revision,Hd(t))),"merge";const l=bn(t);if(!n&&!eu(r,a,l))return o.out(s.unchanged),"unchanged";const c=await Xd(e,t,r,a,l);if(Qd(o,c),!c.ok)return o.err(s.invalidNotPushed),"invalid";const i=n?r.remoteRevision:r.revision,d=async()=>await na(e,t,r.app.id,r,o.err,o)?"merge":"synced";if(c.uploads.length>0){const w=await e.getApp(r.app.id);if(!w)throw new F(s.appGone(r.app.id));if(w.revision!==i)return await d()}const h=new Map;for(const w of c.uploads){const v=`${ie}/${w.folder}`;try{const S=await e.uploadPackage(r.app.id,Zm(w.files));for(const j of S.warnings)o.err(s.note(s.at(v,j)));S.id!==w.hash&&h.set(w.hash,S.id),o.out(s.uploaded(v,w.type))}catch(S){throw Vl(S,r.app.id)??new F(s.uploadRefused(v,qn(S)))}}const u=w=>h.get(w)??w,p=c.components.map(w=>({...w,package:u(w.package)})),f=c.spec.components?{...c.spec,components:c.spec.components.map(w=>({...w,package:u(w.package)}))}:c.spec,m=Qb(a,p);let g;try{g=await e.saveDraft(r.app.id,f,i)}catch(w){if(w instanceof Wc)return await d();throw Vl(w,r.app.id)??w}m!==a&&Or(t,m);const{remoteRevision:y,blankHash:b,...k}=r;return Yd(t,{...k,app:{id:g.id,name:g.name},revision:g.revision,appHash:it(m),components:tw(c.tracked,u)}),Gd(t),o.out(s.pushed(g.revision)),o.out(s.preview(ea(r))),"pushed"}async function ow(e,t,n,o){const s=await tu(e,t,n,o);return s==="synced"&&o.err(D().syncedPushAgain),s==="pushed"||s==="unchanged"?0:1}const nu=e=>new Promise((t,n)=>{fu("openbkn",e,{shell:process.platform==="win32",timeout:6e4},(o,s,r)=>{if(!o)return t(s.trim());if(o.code==="ENOENT")return n(new F(D().noOpenbkn));n(new F(D().openbknFailed(e.join(" "),(r||o.message).trim())))})}),Ht=e=>e.trim().replace(/\/+$/,"");async function _n({state:e,insecure:t,near:n},o=process.env,s=nu){const r=D(),a=o.BKN_BASE_URL?Ht(o.BKN_BASE_URL):void 0;if(e&&a&&a!==Ht(e.baseUrl))throw new F(r.otherPlatform(e.baseUrl,a));let l=a??(e?Ht(e.baseUrl):void 0);const c=typeof n?.baseUrl=="string"?Ht(n.baseUrl):void 0,i=h=>t||e?.insecure||n?.insecure&&c===h||void 0,d=o.BKN_TOKEN?.trim();if(!d){const h=JSON.parse(await s(["auth","status"])),u=h.baseUrl?Ht(h.baseUrl):void 0;if(!u)throw new F(r.notLoggedIn);if(l&&l!==u)throw new F(r.otherLogin(u,l));return l=u,{baseUrl:l,token:await s(["auth","token"]),insecure:i(l)}}if(!l)throw new F(r.tokenWithoutBase);return{baseUrl:l,token:d,insecure:i(l)}}const sw=(e,t)=>{const n=Su(e,{recursive:!0},(o,s)=>{s&&t(String(s))});return()=>n.close()};function rw(e){const t=e.split(/[\\/]/);return t.length===1?t[0]===Re:t[0]===ie&&t.slice(1).every(n=>!n.startsWith(".")&&n!=="node_modules")}const aw=e=>e instanceof Error?e.message:String(e);async function iw(e,t,n,{signal:o,watch:s=sw,settle:r=1e3}){const a=D(),l=Pe(t);if(!l)throw new F(a.notProject(t,t));n.out(a.devStarted(Re,ie)),n.out(a.preview(ea(l)));let c,i,d=!1,h=!1;const u=async g=>{try{if(!g&&!nw(t)){h&&n.out(a.backToPushed),h=!1;return}for(let y=0;y<2;y+=1){const b=await tu(await e(),t,{},n);if(h=b==="invalid",b!=="synced")break;n.err(a.syncedPushing)}}catch(y){h=!0,n.err(aw(y))}},p=(g=!1)=>{i=u(g).finally(()=>{i=void 0,d&&!o.aborted&&(d=!1,p())})},f=()=>{clearTimeout(c),c=setTimeout(()=>{i?d=!0:p()},r)},m=s(t,g=>{rw(g)&&f()});for(p(!0),await new Promise(g=>{o.aborted?g():o.addEventListener("abort",()=>g(),{once:!0})}),m(),clearTimeout(c);i;)await i;return 0}const xt=100,Ao=e=>`/bkn-backend/v1/knowledge-networks/${encodeURIComponent(e)}`;async function lw(e,t){const n=[];for(let o=0;;o+=xt){const{data:s}=await e.get(`${Ao(t)}/object-types`,{params:{direction:"desc",limit:xt,offset:o,sort:"update_time"}}),r=s.entries??[];if(n.push(...r),r.length<xt||n.length>=(s.total_count??0))break}return n.map(o=>({id:o.id,...o.color?.trim()?{color:o.color.trim()}:{},...o.icon?{icon:o.icon}:{}}))}async function cw(e,t,n){const{data:o}=await e.get(`${Ao(t)}/object-types/${encodeURIComponent(n)}`),s=o&&"entries"in o?o.entries?.[0]??null:o;return s?{id:s.id,name:s.name,description:s.comment??"",primaryKeys:s.primary_keys??[],displayKey:s.display_key??"",dataProperties:(s.data_properties??[]).map(r=>{const a=r.name??r.original_name??r.display_name??"";return{name:a,displayName:r.display_name??a,type:r.type??"string"}})}:null}async function dw(e,t){const{data:n}=await e.get(`${Ao(t)}/relation-types`,{params:{direction:"desc",limit:-1,offset:0,sort:"update_time"}});return(n.entries??[]).map(o=>({id:o.id,name:o.name,sourceObjectTypeId:o.source_object_type_id??o.source_object_type?.id??"",targetObjectTypeId:o.target_object_type_id??o.target_object_type?.id??""}))}async function uw(e){const t=[];for(let n=0;;n+=xt){const{data:o}=await e.get("/bkn-backend/v1/knowledge-networks",{params:{direction:"asc",limit:xt,offset:n,sort:"name"}}),s=o.entries??[];if(t.push(...s),s.length<xt||t.length>=(o.total_count??0))break}return t.map(({id:n,name:o})=>({id:n,name:o}))}function Is(){throw new Error(D().notInCli)}function hw(e){return{useOffered:()=>"yes",list:async(t,n)=>(await e.get(`${Ao(t)}/object-metrics`,{params:{limit:n.limit,offset:n.offset,status:n.status}})).data,get:Is,query:Is,participants:Is}}function pw(e){return{http:e,userName:()=>{},userId:()=>{},listNetworks:()=>uw(e),listObjectTypes:t=>lw(e,t),getObjectType:(t,n)=>cw(e,t,n),listRelationTypes:t=>dw(e,t),objectMetrics:hw(e)}}function fw(e){xu(pw(e))}class ou extends Error{constructor(t,n){super(D().httpStatus(n,t.status,gw(t.data))),this.response=t}response}const mw=new Set(["DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_VERIFY_LEAF_SIGNATURE","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","ERR_TLS_CERT_ALTNAME_INVALID","CERT_HAS_EXPIRED"]),Jl=6e4;function gw(e){if(!e||typeof e!="object")return"";const t=e,n=[t.description,t.message,t.error_code].find(o=>typeof o=="string"&&o.trim()!=="");return n?String(n):""}function yw(e){if(!e)return"";const n=(e instanceof URLSearchParams?new URLSearchParams(e):new URLSearchParams(Object.entries(e).filter(([,o])=>o!=null).map(([o,s])=>[o,String(s)]))).toString();return n?`?${n}`:""}function su(e,t){if(!(e?/json/i.test(e):/^\s*[[{]/.test(t))||t==="")return t;try{return JSON.parse(t)}catch{return t}}async function bw(e){if(e===void 0)return;if(e instanceof Uint8Array)return{data:Buffer.from(e),type:"application/octet-stream"};const t=e;return typeof t?.arrayBuffer=="function"?{data:Buffer.from(await t.arrayBuffer()),type:t.type||"application/octet-stream"}:{data:Buffer.from(JSON.stringify(e)),type:"application/json"}}async function ru(e,t,n,o,s={}){const r=new URL(`${e.baseUrl.replace(/\/+$/,"")}/api${n}${yw(s.params)}`),a=await bw(o),l={method:t,headers:{Accept:"application/json, text/plain, */*","Accept-Language":It(),...e.token?{Authorization:`Bearer ${e.token}`}:{},...a?{"Content-Type":a.type,"Content-Length":String(a.data.length)}:{},...s.headers},timeout:s.timeout??Jl,...s.signal?{signal:s.signal}:{},...r.protocol==="https:"&&e.insecure?{rejectUnauthorized:!1}:{}},c=r.protocol==="https:"?Nu:Cu;return new Promise((i,d)=>{const h=c(r,l,u=>{const p=[];u.on("data",f=>p.push(f)),u.on("error",d),u.on("end",()=>i({status:u.statusCode??0,type:u.headers["content-type"],bytes:Buffer.concat(p)}))});h.on("timeout",()=>h.destroy(new Error(D().timeout(n,Jl/1e3)))),h.on("error",u=>{u.code&&mw.has(u.code)?d(new Error(D().certificate(e.baseUrl,u.code))):u.code==="ECONNREFUSED"||u.code==="ENOTFOUND"?d(new Error(D().unreachable(e.baseUrl,u.code))):d(u)}),a&&h.write(a.data),h.end()})}const au=e=>e.status>=200&&e.status<300;async function Pn(e,t,n,o,s){const r=await ru(e,t,n,o,s),a=su(r.type,r.bytes.toString("utf8"));if(!au(r))throw new ou({status:r.status,data:a},n);return{data:a}}async function ww(e,t){const n=await ru(e,"GET",t,void 0,{headers:{Accept:"application/zip, application/octet-stream, */*"}});if(au(n))return n.bytes;const o=su(n.type,n.bytes.toString("utf8"));throw new ou({status:n.status,data:o},t)}function kw(e){return{get:(t,n)=>Pn(e,"GET",t,void 0,n),delete:(t,n)=>Pn(e,"DELETE",t,void 0,n),post:(t,n,o)=>Pn(e,"POST",t,n,o),put:(t,n,o)=>Pn(e,"PUT",t,n,o)}}const vw=e=>`/workshop/v1/component-frames/${e}/`;async function $w(e){return((await st.get(`/bkn-backend/v1/knowledge-networks/${encodeURIComponent(e)}/action-types`,{params:{limit:-1,offset:0,sort:"update_time",direction:"desc"},skipErrorToast:!0})).data.entries??[]).filter(n=>n.lifecycle?.status!=="deprecated"&&n.operation_config?.type!=="relation").map(n=>{const o=n.operations??[],s=n.operation_config?.type,r=n.action_type??"",a=ao({operation:s,kind:r})==="create",l=d=>d.comment?.trim()?{label:d.comment.trim()}:{},c=[];for(const d of n.parameters??[])d.value_from==="input"&&d.name?c.push({name:d.name,type:d.type??"string",...l(d)}):a&&d.value_from==="property"&&typeof d.value=="string"&&d.value!==""&&!c.some(h=>h.name===d.value)&&c.push({name:d.value,type:d.type??"string",...l(d),property:!0});const i=n.action_source;return{id:n.id,name:n.name,...n.comment?{comment:n.comment}:{},objectType:n.object_type_id??"",kind:r,...s?{operation:s}:{},inputs:c,canExecute:o.includes("*")||o.includes("execute"),...i?.type==="tool"&&i.box_id&&i.tool_id?{tool:{box:i.box_id,tool:i.tool_id}}:{}}})}async function Sw(e,t){const[n,o,s,r]=await Promise.all([pm(e),mm(e),$w(e).catch(()=>{}),Jf(e).catch(()=>{})]),a=await Promise.all(n.map(i=>fm(e,i.id))),l=new Map(n.map(i=>[i.id,i])),c={};for(const i of a){if(!i)continue;const d=i.dataProperties.filter(h=>!hh.has(h.type.toLowerCase())).map(h=>({name:h.name,label:h.displayName||h.name,type:ph(h.type),...h.type.toLowerCase().trim()==="date"?{day:!0}:{}}));c[i.id]={id:i.id,name:i.name,primaryKeys:i.primaryKeys.length>0?i.primaryKeys:[d[0]?.name??""],displayKey:i.displayKey||i.primaryKeys[0]||"",...i.description?{comment:i.description}:{},...l.get(i.id)?.color?{color:l.get(i.id)?.color}:{},...l.get(i.id)?.icon?{icon:l.get(i.id)?.icon}:{},properties:d}}return{id:e,name:t,objectTypes:c,relations:o.map(i=>({id:i.id,name:i.name,source:i.sourceObjectTypeId,target:i.targetObjectTypeId})),...s?{actionTypes:s}:{},...r?{eventTypes:r}:{}}}function jw(){const e=Ru()?.objectMetrics;if(!e)throw new Error("This page's host offers no object metrics.");return e}const Ms=100;async function Zl(e,t){const n=[];for(let o=0;;o+=Ms){const s=await jw().list(e,{status:t,limit:Ms,offset:o});if(n.push(...s.entries),s.entries.length<Ms||n.length>=s.total_count)return n}}async function Aw(e){const[t,n]=await Promise.all([Zl(e,"published"),Zl(e,"deprecated").catch(()=>[])]);return Fp(t,n)}async function Tw(e){const[t,n]=await Promise.all([Sw(e.id,e.name),Aw(e.id).catch(()=>{})]);return{...t,name:e.name,...n?{metrics:n}:{}}}async function Ow(e){const t=[];return await Promise.all((e??[]).map(async n=>{try{const{data:o}=await st.get(`${vw(n.package)}manifest.json`);o?.type===n.type?Mc(n.package,o):t.push(n.package)}catch{t.push(n.package)}})),t}const He="openbkn-workshop",Xl="SKILL.en-US.md",Ew=/^\s*source:\s*["']?@openbkn(?:-ai)?\/workshop["']?\s*$/m;function iu(e){const t=[{agent:"Claude Code",path:G(e,".claude","skills",He)}];return be(G(e,".codex"))&&t.push({agent:"Codex",path:G(e,".codex","skills",He)}),be(G(e,".workbuddy"))&&t.push({agent:"WorkBuddy",path:G(e,".workbuddy","skills",He)}),{files:G(e,".agents","skills",He),links:t}}const Cw=e=>{try{return Ew.test(ct(G(e,"SKILL.md"),"utf8"))}catch{return!1}};function lu(e){try{return oc(e),!0}catch{return!1}}function cu(e,t){if(Cw(e))return!0;try{return oc(e).isSymbolicLink()&&tt(Tt(e),Au(e))===t}catch{return!1}}const an=(e,t)=>e.startsWith(`${t}/`)||e.startsWith(`${t}\\`)?`~${e.slice(t.length)}`:e,Nw=(e,t)=>new F(D().skillTaken(an(e,t)));function xw(e,t,n,{platform:o=process.platform}={}){const s=D();if(!be(G(e,"SKILL.md")))throw new F(s.noSkillFiles(e));const{files:r,links:a}=iu(t);for(const c of[r,...a.map(i=>i.path)])if(lu(c)&&!cu(c,r))throw Nw(c,t);ut(r,{recursive:!0,force:!0}),Dn(Tt(r),{recursive:!0}),To(e,r,{recursive:!0,filter:c=>c!==G(e,Xl)});const l=G(e,Xl);It()==="en-US"&&be(l)&&To(l,G(r,"SKILL.md")),n.out(s.skillInstalled(He,an(r,t)));for(const c of a){ut(c.path,{recursive:!0,force:!0}),Dn(Tt(c.path),{recursive:!0});let i=o==="win32";if(!i)try{ju(tc(Tt(c.path),r),c.path,"dir")}catch{i=!0}i&&To(r,c.path,{recursive:!0}),n.out(s.skillLink(c.agent,an(c.path,t),i))}return n.out(s.skillNext),0}function Rw(e,t){const n=D(),{files:o,links:s}=iu(e);let r=0;for(const a of[...s.map(l=>l.path),o])if(lu(a)){if(!cu(a,o)){t.err(n.skillNotOurs(an(a,e)));continue}ut(a,{recursive:!0,force:!0}),t.out(n.removed(an(a,e))),r+=1}return r===0&&t.out(n.noSkill(He)),0}const _w={out:e=>process.stdout.write(`${e}
|
|
460
|
+
`:""}`),Ne(e,`${Ae}/guides/custom-components.md`,await Sb(o)),Ne(e,`${Ae}/guides/prototype.md`,Lb()),ut(G(e,Ae,"guides","components"),{recursive:!0,force:!0});for(const r of Hb())Ne(e,`${Ae}/guides/components/${r}.md`,await $b(r,o))}function eu(e,t){rn(e,"AGENTS.md")===null&&Ne(e,"AGENTS.md",D().agents(t.name)),rn(e,"CLAUDE.md")===null&&Ne(e,"CLAUDE.md",`@AGENTS.md
|
|
461
|
+
`)}function Vb(e,t){eu(e,t);const n=rn(e,".gitignore");n===null?Ne(e,".gitignore",`${Ae}/
|
|
462
|
+
`):n.split(/\r?\n/).some(o=>o.trim().replace(/\/$/,"")===Ae)||Ne(e,".gitignore",`${n.replace(/\n?$/,`
|
|
463
|
+
`)}${Ae}/
|
|
464
|
+
`)}class F extends Error{}const Jb="/studio";function ea(e){return`${e.baseUrl.replace(/\/+$/,"")}${Jb}/workshop/apps/${encodeURIComponent(e.app.id)}/preview`}const Fn=e=>e instanceof Error?e.message:String(e);function ta(e){const t=Pe(e);if(!t)throw new F(D().notProject(e,e));const n=jo(e);if(n===null)throw new F(D().noAppFile(e,Re));return{state:t,text:n}}async function Zb(e,t){const n=await e.listApps(),o=n.find(r=>r.id===t);if(o)return o;const s=n.filter(r=>r.name===t);if(s.length===1)return s[0];throw s.length>1?new F(D().ambiguousApp(s.length,t,s.map(r=>` ${r.id}`).join(`
|
|
465
|
+
`))):new F(D().appNotFound(t))}function Xb(e,t){return e.draft?Xl(e.draft):Xl(nb(zd.id,{id:e.id,name:e.name},t).spec)}const Ls=(e,t,n,o)=>({baseUrl:e.baseUrl,...e.insecure?{insecure:!0}:{},app:{id:t.id,name:t.name},network:t.network,revision:n,appHash:o}),tu=(e,t)=>{const n=D();return n.conflict(e,t.join(n.and),t.map(o=>`${Ae}/remote/${o}`).join(n.and))};async function Qb(e,t,n,o,s,r){const a=new Map((n.draft?.components??[]).map(m=>[m.type,m.package])),l=wn(t),c=new Map(l.flatMap(m=>m.type?[[m.type,m]]:[])),i=new Set(l.map(m=>m.folder)),d={...o},h=[],u=D(),p=async m=>ng(await e.downloadPackage(n.id,m),It()),f=[...new Set([...a.keys(),...Object.keys(o)])];for(const m of f.sort()){const g=a.get(m),y=o[m],b=c.get(m),k=b?b.hash!==y?.hash:y!==void 0,w=b?.folder??y?.folder??ab(m);try{if(g===void 0){if(b&&k){s.push(u.componentKept(m,`${ie}/${w}`));continue}b&&(db(G(t,ie,w)),s.push(u.componentRemoved(`${ie}/${w}`,m))),delete d[m];continue}if(y&&g===y.package&&!y.behind)continue;if(b&&b.hash===g){d[m]={folder:w,package:g,hash:b.hash};continue}if(k){Gl(G(t,Vd,w),await p(g)),h.push(`${ie}/${w}`);continue}if(!b&&i.has(w)){r.err(u.note(u.folderTaken(`${ie}/${w}`,m)));continue}const v=G(t,ie,w);Gl(v,await p(g)),d[m]={folder:w,package:g,hash:ib(v)},s.push(u.downloaded(m,`${ie}/${w}`))}catch(v){g===void 0?r.err(u.note(u.at(`${ie}/${w}`,Fn(v)))):y||b?(d[m]={folder:w,package:g,hash:y?.hash??"",behind:!0},r.err(u.note(u.notDownloadedBehind(m,Fn(v),`${ie}/${w}`)))):r.err(u.note(u.notDownloaded(m,Fn(v))))}}return{tracked:d,conflicts:h}}async function na(e,t,n,o,s,r){const a=D(),l=await e.getApp(n);if(!l)throw new F(a.appIdNotFound(n));const c=await e.readNetwork(l.network),i=Xb(l,c),d=l.draft?it(i):"",h=jo(t);Zd(t);const u=[],p=await Qb(e,t,l,o?.components??{},u,r);await Qd(t,c);let f=Ls(e,l,o?.revision??l.revision,o?.appHash??d),m=l.draft?void 0:o?.blankHash,g=[],y=!1;!o||h===null?(Or(t,i),Vb(t,l),f=Ls(e,l,l.revision,d),l.draft||(m=it(i)),g=[a.pulled(l.name,l.revision,t),...l.draft?[]:[a.blankApp],a.networkAt(l.network.name,`${t}/.workshop/network.json`)]):it(h)===o.appHash||it(h)===o.blankHash?l.revision===o.revision?g=[a.upToDate(l.revision)]:(Or(t,i),f=Ls(e,l,l.revision,d),l.draft||(m=it(i)),g=[a.updatedTo(l.revision)]):l.revision===o.revision?g=[a.localOnly(Re)]:(Gb(t,i),y=!0),eu(t,l);const b=y||p.conflicts.length>0;Jd(t,{...f,...m?{blankHash:m}:{},components:p.tracked,...b?{remoteRevision:l.revision}:{}});for(const k of[...g,...u])s(k);return b&&s(tu(l.revision,Xd(t))),b}async function ew(e,t){const n=[...await e.listApps()].sort((s,r)=>r.updatedAt-s.updatedAt),o=D();n.length===0&&t.out(o.noApps);for(const s of n)t.out(o.appLine(s.id,s.name,s.network.name,s.revision,s.version));return 0}async function tw(e,t){const n=await e.listNetworks(),o=n.find(l=>l.id===t);if(o)return o;const s=n.filter(l=>l.name===t);if(s.length===1)return s[0];if(s.length>1)throw new F(D().ambiguousNetwork(s.length,t,s.map(l=>` ${l.id}`).join(`
|
|
466
|
+
`)));const r=D(),a=n.slice(0,30).map(l=>r.quoted(l.name));throw new F(r.networkNotFound(t,a.join(r.and),n.length,n.length>a.length))}async function nw(e,t,n,o,s){const r=o.trim(),a=D();if(!r)throw new F(a.emptyName);const l=Pe(t);if(l)throw new F(a.alreadyProject(t,l.app.name));if(we(t)&&jo(t)!==null)throw new F(a.hasAppFile(t,Re));const c=await tw(e,n);let i;try{i=await e.createApp(r,c)}catch(d){throw d instanceof Fr?new F(a.noCreateRight(c.name)):d}return s.out(a.created(c.name,i.name,i.id)),await na(e,t,i.id,null,s.out,s),0}async function ow(e,t,n,o){const s=D(),r=Pe(t);if(r&&n&&n!==r.app.id&&n!==r.app.name)throw new F(s.otherProject(t,r.app.name,r.app.id,n));if(!r&&!n)throw new F(s.firstPullNeedsApp);if(!r&&we(t)&&jo(t)!==null)throw new F(s.notPulled(t,Re));const a=r?.app.id??(await Zb(e,n)).id;return await na(e,t,a,r,o.out,o),0}const Dn=e=>typeof e=="object"&&e!==null&&"type"in e;function sw(e,t,n){const o=D(),s=[],r=[],a=[],l=new Map;for(const p of t){const f=`${ie}/${p.folder}`;if(s.push(...p.check.errors.map(y=>({file:f,message:y}))),!p.type)continue;const m=l.get(p.type);if(m){s.push({file:f,message:o.sameType(`${ie}/${m.folder}`,p.type)});continue}l.set(p.type,p);const g=n[p.type];if(!(p.hash===g?.hash||g?.behind&&p.hash===g.package)){if(g?.behind){s.push({file:f,message:o.behindChanged(p.type)});continue}a.push(p),r.push(...p.check.warnings.map(y=>o.at(f,y)))}}const c=p=>a.includes(p)?p.hash:n[p.type]?.package,i=Array.isArray(e)?e:[],d=i.map(p=>{const f=Dn(p)?l.get(p.type):void 0;return f?{...p,package:c(f),...a.includes(f)?{source:"upload"}:{}}:p});for(const[p,f]of l)i.some(m=>Dn(m)&&m.type===p)||d.push({type:p,package:c(f),source:"upload"});const h={};for(const[p,f]of l){const m=n[p];h[p]=m?.behind&&f.hash===m.hash?m:{folder:f.folder,package:c(f),hash:f.hash}}for(const[p,f]of Object.entries(n))!h[p]&&d.some(m=>Dn(m)&&m.type===p)&&(h[p]=f);const u=new Set([...l.keys()].filter(p=>h[p]?.behind));return{components:d,uploads:a,tracked:h,problems:s,warnings:r,usable:l,behind:u}}function rw(e,t){const n=Ge.parseDocument(e),o=n.toJS()?.components;return Su(o??[],t)?e:(t.length===0?n.delete("components"):n.set("components",t),n.toString({lineWidth:0}))}async function nu(e,t,n,o,s=wn(t)){const{spec:r,syntax:a,locate:l}=yb(o);if(a.length>0)return{ok:!1,errors:a,warnings:[]};const c=r?.apiVersion,i=[],d=D();typeof c=="string"&&c!==pt&&i.push(d.apiVersion(Re,c,pt));const h=await e.readNetwork(n.network);await Qd(t,h,s);const u=r?.components,p=sw(u,s,n.components??{});i.push(...p.warnings);for(const[k,w]of p.usable)!p.behind.has(k)&&vd(w.manifest,It()).length===0&&Bc(p.components.find(v=>v.type===k)?.package??w.hash,w.manifest);const f=p.components.filter(k=>Dn(k)&&(!p.usable.has(k.type)||p.behind.has(k.type)));for(const k of await e.registerComponents(f))i.push(d.manifestUnreadable(k));const g=(Array.isArray(u)||u===void 0&&p.components.length>0)&&r&&typeof r=="object"?{...r,components:p.components}:r,y=Ud(g,h,{allowEmpty:!0}),b=[...p.problems,...y.ok?[]:y.errors.map(l)];return!y.ok||b.length>0?{ok:!1,errors:b,warnings:i}:{ok:!0,spec:y.app,components:p.components,uploads:p.uploads,tracked:p.tracked,warnings:i}}function ou(e,t){const n=D();for(const o of t.warnings)e.err(n.note(o));if(!t.ok){for(const o of t.errors)e.err(`${o.file??Re}${o.line?`:${o.line}`:""} ${o.message}`);e.err(n.errorCount(t.errors.length))}}async function aw(e,t,n){const{state:o,text:s}=ta(t),r=await nu(e,t,o,s);return ou(n,r),r.ok&&n.out(D().validated),r.ok?0:1}function Ql(e,t){const n=D();return e instanceof Fr?new F(n.forbidden):e instanceof qr?new F(n.appGone(t)):e instanceof Vc?new F(n.tooLarge):null}function iw(e,t){const n={};for(const[o,s]of Object.entries(e))n[o]={...s,package:t(s.package)};return n}function su(e,t,n){const o=e.components??{},s=n.every(r=>r.type&&r.hash===o[r.type]?.hash);return it(t)!==e.appHash||!s}function lw(e){const{state:t,text:n}=ta(e);return su(t,n,wn(e))}async function ru(e,t,{merged:n=!1},o){const s=D(),{state:r,text:a}=ta(t);if(n&&r.remoteRevision===void 0)throw new F(s.nothingToMerge);if(!n&&Yb(t))return o.err(tu(r.remoteRevision??r.revision,Xd(t))),"merge";const l=wn(t);if(!n&&!su(r,a,l))return o.out(s.unchanged),"unchanged";const c=await nu(e,t,r,a,l);if(ou(o,c),!c.ok)return o.err(s.invalidNotPushed),"invalid";const i=n?r.remoteRevision:r.revision,d=async()=>await na(e,t,r.app.id,r,o.err,o)?"merge":"synced";if(c.uploads.length>0){const w=await e.getApp(r.app.id);if(!w)throw new F(s.appGone(r.app.id));if(w.revision!==i)return await d()}const h=new Map;for(const w of c.uploads){const v=`${ie}/${w.folder}`;try{const S=await e.uploadPackage(r.app.id,tg(w.files));for(const j of S.warnings)o.err(s.note(s.at(v,j)));S.id!==w.hash&&h.set(w.hash,S.id),o.out(s.uploaded(v,w.type))}catch(S){throw Ql(S,r.app.id)??new F(s.uploadRefused(v,Fn(S)))}}const u=w=>h.get(w)??w,p=c.components.map(w=>({...w,package:u(w.package)})),f=c.spec.components?{...c.spec,components:c.spec.components.map(w=>({...w,package:u(w.package)}))}:c.spec,m=rw(a,p);let g;try{g=await e.saveDraft(r.app.id,f,i)}catch(w){if(w instanceof Hc)return await d();throw Ql(w,r.app.id)??w}m!==a&&Or(t,m);const{remoteRevision:y,blankHash:b,...k}=r;return Jd(t,{...k,app:{id:g.id,name:g.name},revision:g.revision,appHash:it(m),components:iw(c.tracked,u)}),Zd(t),o.out(s.pushed(g.revision)),o.out(s.preview(ea(r))),"pushed"}async function cw(e,t,n,o){const s=await ru(e,t,n,o);return s==="synced"&&o.err(D().syncedPushAgain),s==="pushed"||s==="unchanged"?0:1}const au=e=>new Promise((t,n)=>{bu("openbkn",e,{shell:process.platform==="win32",timeout:6e4},(o,s,r)=>{if(!o)return t(s.trim());if(o.code==="ENOENT")return n(new F(D().noOpenbkn));n(new F(D().openbknFailed(e.join(" "),(r||o.message).trim())))})}),Ht=e=>e.trim().replace(/\/+$/,"");async function Pn({state:e,insecure:t,near:n},o=process.env,s=au){const r=D(),a=o.BKN_BASE_URL?Ht(o.BKN_BASE_URL):void 0;if(e&&a&&a!==Ht(e.baseUrl))throw new F(r.otherPlatform(e.baseUrl,a));let l=a??(e?Ht(e.baseUrl):void 0);const c=typeof n?.baseUrl=="string"?Ht(n.baseUrl):void 0,i=h=>t||e?.insecure||n?.insecure&&c===h||void 0,d=o.BKN_TOKEN?.trim();if(!d){const h=JSON.parse(await s(["auth","status"])),u=h.baseUrl?Ht(h.baseUrl):void 0;if(!u)throw new F(r.notLoggedIn);if(l&&l!==u)throw new F(r.otherLogin(u,l));return l=u,{baseUrl:l,token:await s(["auth","token"]),insecure:i(l)}}if(!l)throw new F(r.tokenWithoutBase);return{baseUrl:l,token:d,insecure:i(l)}}const dw=(e,t)=>{const n=Ou(e,{recursive:!0},(o,s)=>{s&&t(String(s))});return()=>n.close()};function uw(e){const t=e.split(/[\\/]/);return t.length===1?t[0]===Re:t[0]===ie&&t.slice(1).every(n=>!n.startsWith(".")&&n!=="node_modules")}const hw=e=>e instanceof Error?e.message:String(e);async function pw(e,t,n,{signal:o,watch:s=dw,settle:r=1e3}){const a=D(),l=Pe(t);if(!l)throw new F(a.notProject(t,t));n.out(a.devStarted(Re,ie)),n.out(a.preview(ea(l)));let c,i,d=!1,h=!1;const u=async g=>{try{if(!g&&!lw(t)){h&&n.out(a.backToPushed),h=!1;return}for(let y=0;y<2;y+=1){const b=await ru(await e(),t,{},n);if(h=b==="invalid",b!=="synced")break;n.err(a.syncedPushing)}}catch(y){h=!0,n.err(hw(y))}},p=(g=!1)=>{i=u(g).finally(()=>{i=void 0,d&&!o.aborted&&(d=!1,p())})},f=()=>{clearTimeout(c),c=setTimeout(()=>{i?d=!0:p()},r)},m=s(t,g=>{uw(g)&&f()});for(p(!0),await new Promise(g=>{o.aborted?g():o.addEventListener("abort",()=>g(),{once:!0})}),m(),clearTimeout(c);i;)await i;return 0}const xt=100,Ao=e=>`/bkn-backend/v1/knowledge-networks/${encodeURIComponent(e)}`;async function fw(e,t){const n=[];for(let o=0;;o+=xt){const{data:s}=await e.get(`${Ao(t)}/object-types`,{params:{direction:"desc",limit:xt,offset:o,sort:"update_time"}}),r=s.entries??[];if(n.push(...r),r.length<xt||n.length>=(s.total_count??0))break}return n.map(o=>({id:o.id,...o.color?.trim()?{color:o.color.trim()}:{},...o.icon?{icon:o.icon}:{}}))}async function mw(e,t,n){const{data:o}=await e.get(`${Ao(t)}/object-types/${encodeURIComponent(n)}`),s=o&&"entries"in o?o.entries?.[0]??null:o;return s?{id:s.id,name:s.name,description:s.comment??"",primaryKeys:s.primary_keys??[],displayKey:s.display_key??"",dataProperties:(s.data_properties??[]).map(r=>{const a=r.name??r.original_name??r.display_name??"";return{name:a,displayName:r.display_name??a,type:r.type??"string"}})}:null}async function gw(e,t){const{data:n}=await e.get(`${Ao(t)}/relation-types`,{params:{direction:"desc",limit:-1,offset:0,sort:"update_time"}});return(n.entries??[]).map(o=>({id:o.id,name:o.name,sourceObjectTypeId:o.source_object_type_id??o.source_object_type?.id??"",targetObjectTypeId:o.target_object_type_id??o.target_object_type?.id??""}))}async function yw(e){const t=[];for(let n=0;;n+=xt){const{data:o}=await e.get("/bkn-backend/v1/knowledge-networks",{params:{direction:"asc",limit:xt,offset:n,sort:"name"}}),s=o.entries??[];if(t.push(...s),s.length<xt||t.length>=(o.total_count??0))break}return t.map(({id:n,name:o})=>({id:n,name:o}))}function Is(){throw new Error(D().notInCli)}function bw(e){return{useOffered:()=>"yes",list:async(t,n)=>(await e.get(`${Ao(t)}/object-metrics`,{params:{limit:n.limit,offset:n.offset,status:n.status}})).data,get:Is,query:Is,participants:Is}}function ww(e){return{http:e,userName:()=>{},userId:()=>{},listNetworks:()=>yw(e),listObjectTypes:t=>fw(e,t),getObjectType:(t,n)=>mw(e,t,n),listRelationTypes:t=>gw(e,t),objectMetrics:bw(e)}}function kw(e){Lu(ww(e))}class iu extends Error{constructor(t,n){super(D().httpStatus(n,t.status,$w(t.data))),this.response=t}response}const vw=new Set(["DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_VERIFY_LEAF_SIGNATURE","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","ERR_TLS_CERT_ALTNAME_INVALID","CERT_HAS_EXPIRED"]),ec=6e4;function $w(e){if(!e||typeof e!="object")return"";const t=e,n=[t.description,t.message,t.error_code].find(o=>typeof o=="string"&&o.trim()!=="");return n?String(n):""}function Sw(e){if(!e)return"";const n=(e instanceof URLSearchParams?new URLSearchParams(e):new URLSearchParams(Object.entries(e).filter(([,o])=>o!=null).map(([o,s])=>[o,String(s)]))).toString();return n?`?${n}`:""}function lu(e,t){if(!(e?/json/i.test(e):/^\s*[[{]/.test(t))||t==="")return t;try{return JSON.parse(t)}catch{return t}}async function jw(e){if(e===void 0)return;if(e instanceof Uint8Array)return{data:Buffer.from(e),type:"application/octet-stream"};const t=e;return typeof t?.arrayBuffer=="function"?{data:Buffer.from(await t.arrayBuffer()),type:t.type||"application/octet-stream"}:{data:Buffer.from(JSON.stringify(e)),type:"application/json"}}async function cu(e,t,n,o,s={}){const r=new URL(`${e.baseUrl.replace(/\/+$/,"")}/api${n}${Sw(s.params)}`),a=await jw(o),l={method:t,headers:{Accept:"application/json, text/plain, */*","Accept-Language":It(),...e.token?{Authorization:`Bearer ${e.token}`}:{},...a?{"Content-Type":a.type,"Content-Length":String(a.data.length)}:{},...s.headers},timeout:s.timeout??ec,...s.signal?{signal:s.signal}:{},...r.protocol==="https:"&&e.insecure?{rejectUnauthorized:!1}:{}},c=r.protocol==="https:"?Pu:_u;return new Promise((i,d)=>{const h=c(r,l,u=>{const p=[];u.on("data",f=>p.push(f)),u.on("error",d),u.on("end",()=>i({status:u.statusCode??0,type:u.headers["content-type"],bytes:Buffer.concat(p)}))});h.on("timeout",()=>h.destroy(new Error(D().timeout(n,ec/1e3)))),h.on("error",u=>{u.code&&vw.has(u.code)?d(new Error(D().certificate(e.baseUrl,u.code))):u.code==="ECONNREFUSED"||u.code==="ENOTFOUND"?d(new Error(D().unreachable(e.baseUrl,u.code))):d(u)}),a&&h.write(a.data),h.end()})}const du=e=>e.status>=200&&e.status<300;async function Ln(e,t,n,o,s){const r=await cu(e,t,n,o,s),a=lu(r.type,r.bytes.toString("utf8"));if(!du(r))throw new iu({status:r.status,data:a},n);return{data:a}}async function Aw(e,t){const n=await cu(e,"GET",t,void 0,{headers:{Accept:"application/zip, application/octet-stream, */*"}});if(du(n))return n.bytes;const o=lu(n.type,n.bytes.toString("utf8"));throw new iu({status:n.status,data:o},t)}function Tw(e){return{get:(t,n)=>Ln(e,"GET",t,void 0,n),delete:(t,n)=>Ln(e,"DELETE",t,void 0,n),post:(t,n,o)=>Ln(e,"POST",t,n,o),put:(t,n,o)=>Ln(e,"PUT",t,n,o)}}const Ow=e=>`/workshop/v1/component-frames/${e}/`;async function Ew(e){return((await st.get(`/bkn-backend/v1/knowledge-networks/${encodeURIComponent(e)}/action-types`,{params:{limit:-1,offset:0,sort:"update_time",direction:"desc"},skipErrorToast:!0})).data.entries??[]).filter(n=>n.lifecycle?.status!=="deprecated"&&n.operation_config?.type!=="relation").map(n=>{const o=n.operations??[],s=n.operation_config?.type,r=n.action_type??"",a=io({operation:s,kind:r})==="create",l=d=>d.comment?.trim()?{label:d.comment.trim()}:{},c=[];for(const d of n.parameters??[])d.value_from==="input"&&d.name?c.push({name:d.name,type:d.type??"string",...l(d)}):a&&d.value_from==="property"&&typeof d.value=="string"&&d.value!==""&&!c.some(h=>h.name===d.value)&&c.push({name:d.value,type:d.type??"string",...l(d),property:!0});const i=n.action_source;return{id:n.id,name:n.name,...n.comment?{comment:n.comment}:{},objectType:n.object_type_id??"",kind:r,...s?{operation:s}:{},inputs:c,canExecute:o.includes("*")||o.includes("execute"),...i?.type==="tool"&&i.box_id&&i.tool_id?{tool:{box:i.box_id,tool:i.tool_id}}:{}}})}async function Cw(e,t){const[n,o,s,r]=await Promise.all([pp(e),mp(e),Ew(e).catch(()=>{}),sm(e).catch(()=>{})]),a=await Promise.all(n.map(i=>fp(e,i.id))),l=new Map(n.map(i=>[i.id,i])),c={};for(const i of a){if(!i)continue;const d=i.dataProperties.filter(h=>!gh.has(h.type.toLowerCase())).map(h=>({name:h.name,label:h.displayName||h.name,type:yh(h.type),...h.type.toLowerCase().trim()==="date"?{day:!0}:{}}));c[i.id]={id:i.id,name:i.name,primaryKeys:i.primaryKeys.length>0?i.primaryKeys:[d[0]?.name??""],displayKey:i.displayKey||i.primaryKeys[0]||"",...i.description?{comment:i.description}:{},...l.get(i.id)?.color?{color:l.get(i.id)?.color}:{},...l.get(i.id)?.icon?{icon:l.get(i.id)?.icon}:{},properties:d}}return{id:e,name:t,objectTypes:c,relations:o.map(i=>({id:i.id,name:i.name,source:i.sourceObjectTypeId,target:i.targetObjectTypeId})),...s?{actionTypes:s}:{},...r?{eventTypes:r}:{}}}function Nw(){const e=Iu()?.objectMetrics;if(!e)throw new Error("This page's host offers no object metrics.");return e}const Ms=100;async function tc(e,t){const n=[];for(let o=0;;o+=Ms){const s=await Nw().list(e,{status:t,limit:Ms,offset:o});if(n.push(...s.entries),s.entries.length<Ms||n.length>=s.total_count)return n}}async function xw(e){const[t,n]=await Promise.all([tc(e,"published"),tc(e,"deprecated").catch(()=>[])]);return Gp(t,n)}async function Rw(e){const[t,n]=await Promise.all([Cw(e.id,e.name),xw(e.id).catch(()=>{})]);return{...t,name:e.name,...n?{metrics:n}:{}}}async function _w(e){const t=[];return await Promise.all((e??[]).map(async n=>{try{const{data:o}=await st.get(`${Ow(n.package)}manifest.json`);o?.type===n.type?Bc(n.package,o):t.push(n.package)}catch{t.push(n.package)}})),t}const He="openbkn-workshop",nc="SKILL.en-US.md",Pw=/^\s*source:\s*["']?@openbkn(?:-ai)?\/workshop["']?\s*$/m;function uu(e){const t=[{agent:"Claude Code",path:G(e,".claude","skills",He)}];return we(G(e,".codex"))&&t.push({agent:"Codex",path:G(e,".codex","skills",He)}),we(G(e,".workbuddy"))&&t.push({agent:"WorkBuddy",path:G(e,".workbuddy","skills",He)}),{files:G(e,".agents","skills",He),links:t}}const Lw=e=>{try{return Pw.test(ct(G(e,"SKILL.md"),"utf8"))}catch{return!1}};function hu(e){try{return ic(e),!0}catch{return!1}}function pu(e,t){if(Lw(e))return!0;try{return ic(e).isSymbolicLink()&&tt(Tt(e),Cu(e))===t}catch{return!1}}const an=(e,t)=>e.startsWith(`${t}/`)||e.startsWith(`${t}\\`)?`~${e.slice(t.length)}`:e,Iw=(e,t)=>new F(D().skillTaken(an(e,t)));function Mw(e,t,n,{platform:o=process.platform}={}){const s=D();if(!we(G(e,"SKILL.md")))throw new F(s.noSkillFiles(e));const{files:r,links:a}=uu(t);for(const c of[r,...a.map(i=>i.path)])if(hu(c)&&!pu(c,r))throw Iw(c,t);ut(r,{recursive:!0,force:!0}),Bn(Tt(r),{recursive:!0}),To(e,r,{recursive:!0,filter:c=>c!==G(e,nc)});const l=G(e,nc);It()==="en-US"&&we(l)&&To(l,G(r,"SKILL.md")),n.out(s.skillInstalled(He,an(r,t)));for(const c of a){ut(c.path,{recursive:!0,force:!0}),Bn(Tt(c.path),{recursive:!0});let i=o==="win32";if(!i)try{Eu(rc(Tt(c.path),r),c.path,"dir")}catch{i=!0}i&&To(r,c.path,{recursive:!0}),n.out(s.skillLink(c.agent,an(c.path,t),i))}return n.out(s.skillNext),0}function qw(e,t){const n=D(),{files:o,links:s}=uu(e);let r=0;for(const a of[...s.map(l=>l.path),o])if(hu(a)){if(!pu(a,o)){t.err(n.skillNotOurs(an(a,e)));continue}ut(a,{recursive:!0,force:!0}),t.out(n.removed(an(a,e))),r+=1}return r===0&&t.out(n.noSkill(He)),0}const Fw={out:e=>process.stdout.write(`${e}
|
|
433
467
|
`),err:e=>process.stderr.write(`${e}
|
|
434
|
-
`)};function
|
|
468
|
+
`)};function Dw(e){return kw(Tw(e)),{baseUrl:e.baseUrl,...e.insecure?{insecure:!0}:{},listApps:fm,getApp:mm,listNetworks:hp,createApp:(t,n)=>ym(t,n,null),saveDraft:bm,readNetwork:Rw,registerComponents:_w,downloadPackage:(t,n)=>Aw(e,`/workshop/v1/apps/${encodeURIComponent(t)}/component-packages/${encodeURIComponent(n)}/zip`),uploadPackage:async(t,n)=>{const o=await wm(t,new Blob([new Uint8Array(n)]));return{id:o.id,warnings:o.warnings}}}}function Bw(e){const[t,n]=process.platform==="darwin"?["open",[e]]:process.platform==="win32"?["cmd",["/c","start","",e]]:["xdg-open",[e]];return new Promise(o=>{const s=wu(t,n,{stdio:"ignore",detached:!0});s.on("error",()=>o(!1)),s.on("spawn",()=>{s.unref(),o(!0)})})}async function Xv(e,t=Fw,{env:n=process.env,openbkn:o=au,workshopOf:s=Dw,open:r=Bw,skillSource:a,home:l=ku(),signal:c,version:i}={}){let d;try{d=ju({args:e,allowPositionals:!0,options:{insecure:{type:"boolean",short:"k"},merged:{type:"boolean"},"no-open":{type:"boolean"},lang:{type:"string"},help:{type:"boolean",short:"h"},version:{type:"boolean",short:"v"}}})}catch(g){const y=e.indexOf("--lang");return Yl(oa(y<0?void 0:e[y+1],n)),t.err(`${g instanceof Error?g.message:String(g)}
|
|
435
469
|
|
|
436
|
-
${D().usage(He)}`),1}const{positionals:h,values:u}=d;
|
|
470
|
+
${D().usage(He)}`),1}const{positionals:h,values:u}=d;Yl(oa(u.lang,n));const p=D(),[f,...m]=h;if(u.version)return t.out(i??p.noVersion),0;if(u.help||!f)return t.out(p.usage(He)),f||u.help?0:1;try{if(f==="skill"){const[g]=m;if(g==="remove")return qw(l,t);if(g!=="add")throw new F(p.skillUsage);if(!a)throw new F(p.noSkillSource);return Mw(a,l,t)}if(f==="list"||f==="create"){let g=null;try{g=Pe(tt("."))}catch{}const y=await Pn({state:null,near:g,insecure:u.insecure},n,o);if(f==="list")return await ew(s(y),t);const[b,k,w]=m;if(!b||!k)throw new F(p.createUsage);return await nw(s(y),tt(w??oc(k)),b,k,t)}if(f==="pull"){const[g,y]=m,b=g!==void 0&&y===void 0&&Pe(tt(g)),k=b?void 0:g,w=tt(b?g:y??(g?oc(g):".")),v=Pe(w),S=await Pn({state:v,insecure:u.insecure},n,o);return await ow(s(S),w,k,t)}if(f==="validate"||f==="push"){const g=tt(m[0]??"."),y=Pe(g);if(!y)throw new F(p.notProject(g,m[0]??"."));const b=s(await Pn({state:y,insecure:u.insecure},n,o));return f==="validate"?await aw(b,g,t):await cw(b,g,{merged:u.merged},t)}if(f==="dev"){const g=tt(m[0]??".");if(!Pe(g))throw new F(p.notProject(g,m[0]??"."));const y=c?void 0:new AbortController;return y&&process.once("SIGINT",()=>y.abort()),await pw(async()=>s(await Pn({state:Pe(g),insecure:u.insecure},n,o)),g,t,{signal:c??y.signal})}if(f==="preview"){const g=tt(m[0]??"."),y=Pe(g);if(!y)throw new F(p.notProject(g,m[0]??"."));const b=ea(y);return t.out(b),!u["no-open"]&&!await r(b)&&t.err(p.noBrowser),0}throw new F(`${p.noCommand(f)}
|
|
437
471
|
|
|
438
|
-
${p.usage(He)}`)}catch(g){return t.err(g instanceof Error?g.message:String(g)),1}}function
|
|
472
|
+
${p.usage(He)}`)}catch(g){return t.err(g instanceof Error?g.message:String(g)),1}}function oc(e){return e.replace(/[\\/:*?"<>|\s]+/g,"-").replace(/^-+|-+$/g,"")||"app"}const Uw=`# Button (actionButton)
|
|
439
473
|
|
|
440
474
|
A button on the page: one click takes the configured steps in order, asking the Agent or running an action of the knowledge network on the selected or ticked objects. Use it to put "the step to take after reading the data" on the page; it always asks for confirmation before running.
|
|
441
475
|
|
|
@@ -525,7 +559,7 @@ A button that only asks the Agent needs no action and no object source.
|
|
|
525
559
|
- One confirmation runs at most 100 objects, 20 by default.
|
|
526
560
|
- It does not follow or write filters.
|
|
527
561
|
- Actions run with the user's own permissions.
|
|
528
|
-
`,
|
|
562
|
+
`,zw=Object.freeze(Object.defineProperty({__proto__:null,default:Uw},Symbol.toStringTag,{value:"Module"})),Ww=`# 按钮(actionButton)
|
|
529
563
|
|
|
530
564
|
页面上的一个按钮,点一下按顺序做配置好的动作:向 Agent 提问,或对选中、勾选的对象执行知识网络里的行动。用来把“看完数据后要做的那一步”放在页面上,执行前总会先确认。
|
|
531
565
|
|
|
@@ -615,7 +649,7 @@ A button that only asks the Agent needs no action and no object source.
|
|
|
615
649
|
- 一次确认最多执行 100 个对象,默认 20。
|
|
616
650
|
- 不跟随筛选,不写入筛选。
|
|
617
651
|
- 行动按用户本人的权限执行。
|
|
618
|
-
`,
|
|
652
|
+
`,Kw=Object.freeze(Object.defineProperty({__proto__:null,default:Ww},Symbol.toStringTag,{value:"Module"})),Yw=`# Agent chat (agentChat)
|
|
619
653
|
|
|
620
654
|
A chat box that asks and answers about the data on the page. The Agent can query all the page's data sources and the whole knowledge network, read the current filters and the selected object, and when allowed set filters for the user and suggest actions. Use it so business users can follow up in plain language with "why", "which" and "what now".
|
|
621
655
|
|
|
@@ -727,7 +761,7 @@ Do not keep a definition only here: a judgement that can be computed belongs in
|
|
|
727
761
|
### Selecting an agent within a service
|
|
728
762
|
|
|
729
763
|
When an MCP exposes list_agents returning structuredContent.agents: [{id, name}] and an ask tool accepting agent_id, builders can choose a default agent. Enable runtime agent switching to show the selector. Switching clears the conversation and creates a new conversation ID; switching is disabled while a reply is pending. Like ask, list_agents is sent only the parameters it declares: \`app_id\`, \`kn_id\`, \`workspace_id\`, and \`bkn_token\` when "Hand over the user's sign-in token" is on (the builder's own token in the builder). The server decides which agents to list and whether a call may run: one that declares these parameters can filter by app and user; one that does not can only go by the integration account. When a default agent is chosen, the chat also calls list_agents on opening, even with switching off, and asks nothing until it answers (a question from a click is sent once it does): if the chosen agent is not in the result, it shows "Agent unavailable", takes no questions, and does not show the agent's name; if the list cannot be read, questions go ahead and the server decides. Servers without list_agents keep their behavior.
|
|
730
|
-
`,
|
|
764
|
+
`,Gw=Object.freeze(Object.defineProperty({__proto__:null,default:Yw},Symbol.toStringTag,{value:"Module"})),Hw=`# Agent 对话(agentChat)
|
|
731
765
|
|
|
732
766
|
围绕页面上的数据提问和回答的对话框。Agent 能查页面上全部数据源和整个知识网络,读当前筛选和选中的对象,允许时还能替用户设置筛选、建议行动。用来让业务人员用自然语言追问“为什么”“哪些”“怎么办”。
|
|
733
767
|
|
|
@@ -839,7 +873,7 @@ When an MCP exposes list_agents returning structuredContent.agents: [{id, name}]
|
|
|
839
873
|
### 选择服务中的智能体
|
|
840
874
|
|
|
841
875
|
外部 MCP 提供 list_agents(返回 structuredContent.agents: [{id, name}])和接受 agent_id 的 ask 时,组件配置可选择默认智能体。打开“允许使用者切换智能体”后,对话框显示智能体选择框。切换会清空当前对话并生成新的会话标识;回答期间不可切换。list_agents 与 ask 一样只收它声明了的参数:\`app_id\`、\`kn_id\`、\`workspace_id\`,以及打开“交出使用者的登录令牌”时的 \`bkn_token\`(在构建器里是构建者自己的)。列出哪些智能体、能否调用由服务端决定:声明了这些参数的服务可以按应用和使用者筛选,没有声明的只能按集成账号。选了默认智能体时,即使没有打开切换,对话框打开时也会调用 list_agents,返回之前不提问(点击带来的问题等列表返回再发):所选智能体不在返回结果里,就显示“智能体暂不可用”,不能提问,也不显示原名称;读不到列表时照常提问,由服务端核对。服务不提供 list_agents 时保持原有行为。
|
|
842
|
-
`,
|
|
876
|
+
`,Vw=Object.freeze(Object.defineProperty({__proto__:null,default:Hw},Symbol.toStringTag,{value:"Module"})),Jw=`# Alerts (alertList)
|
|
843
877
|
|
|
844
878
|
Lists, in real time, the objects that hit rules written beforehand, most severe first. Use it to answer "which objects need attention now"; click a rule and the page narrows to the objects it hits.
|
|
845
879
|
|
|
@@ -919,7 +953,7 @@ None. The component only counts by the configured conditions and calls no outsid
|
|
|
919
953
|
- 1 to 8 rules; 3 to 20 rows when expanded.
|
|
920
954
|
- It computes only what hits now; it keeps no history and has no owner or handling state.
|
|
921
955
|
- Missing-link rules read relations, so the count shows a spinner while loading.
|
|
922
|
-
`,
|
|
956
|
+
`,Zw=Object.freeze(Object.defineProperty({__proto__:null,default:Jw},Symbol.toStringTag,{value:"Module"})),Xw=`# 告警(alertList)
|
|
923
957
|
|
|
924
958
|
按事先写好的规则,实时列出当前命中的对象,按严重程度排序。用来回答“现在有哪些对象需要关注”,点一条规则就把页面收窄到它命中的对象。
|
|
925
959
|
|
|
@@ -999,7 +1033,7 @@ None. The component only counts by the configured conditions and calls no outsid
|
|
|
999
1033
|
- 规则 1 到 8 条;展开显示 3 到 20 条。
|
|
1000
1034
|
- 只计算此刻命中,不保存历史,也没有负责人、处理状态。
|
|
1001
1035
|
- 缺失关联查询需要读取关系,命中数加载时显示转圈。
|
|
1002
|
-
`,
|
|
1036
|
+
`,Qw=Object.freeze(Object.defineProperty({__proto__:null,default:Xw},Symbol.toStringTag,{value:"Module"})),ek=`# Base date (asOfSlider)
|
|
1003
1037
|
|
|
1004
1038
|
Drag a slider to pick a date, and the whole page is computed as of that day. Use it to answer "what did it look like on a given day" or "how many items were overdue at the end of last month".
|
|
1005
1039
|
|
|
@@ -1078,7 +1112,7 @@ None. The component only writes the base date and calls no tool. Industry rules
|
|
|
1078
1112
|
- Steps are day, week and month only; a month is fixed at 30 days.
|
|
1079
1113
|
- One base date variable per page.
|
|
1080
1114
|
- The range depends on the rows already read; an object type data source reads at most 5000 rows and a Cypher data source 10,000 (1,000 when its query sets no LIMIT).
|
|
1081
|
-
`,
|
|
1115
|
+
`,tk=Object.freeze(Object.defineProperty({__proto__:null,default:ek},Symbol.toStringTag,{value:"Module"})),nk=`# 基准日期(asOfSlider)
|
|
1082
1116
|
|
|
1083
1117
|
拖动滑块选一个日期,整页按这一天计算。用来回答“截至某天是什么样”“上个月底有多少项已超期”这类问题。
|
|
1084
1118
|
|
|
@@ -1157,7 +1191,7 @@ None. The component only writes the base date and calls no tool. Industry rules
|
|
|
1157
1191
|
- 步长只有天、周、月三种;月固定按 30 天。
|
|
1158
1192
|
- 一个页面一个基准日期变量。
|
|
1159
1193
|
- 范围依据已读入的数据,对象类数据源最多读 5000 行,Cypher 数据源最多 10000 行(查询没写 LIMIT 时 1000 行)。
|
|
1160
|
-
`,
|
|
1194
|
+
`,ok=Object.freeze(Object.defineProperty({__proto__:null,default:nk},Symbol.toStringTag,{value:"Module"})),sk=`# Custom components: building and extending
|
|
1161
1195
|
|
|
1162
1196
|
When the standard components cannot show or do what you need, you can build your own component, pack it and upload it to this app. It runs in an isolated frame: it reads data and runs actions only through what Workshop gives it, never sees the sign-in, and cannot reach the network freely.
|
|
1163
1197
|
|
|
@@ -1166,7 +1200,7 @@ When the standard components cannot show or do what you need, you can build your
|
|
|
1166
1200
|
1. **Install the package.** In your own project, install \`@openbkn/workshop\` (published on the public npm registry):
|
|
1167
1201
|
|
|
1168
1202
|
\`\`\`bash
|
|
1169
|
-
npm install --save-dev @openbkn/workshop
|
|
1203
|
+
npm install --save-dev @openbkn/workshop@rc
|
|
1170
1204
|
\`\`\`
|
|
1171
1205
|
|
|
1172
1206
|
2. **Create a package.** The folder name is the component's name; its type is \`x-<prefix>.<name>\`:
|
|
@@ -1232,7 +1266,7 @@ Write it under these headings, with "None" under a heading that has nothing:
|
|
|
1232
1266
|
- **Let the Agent read it.** Report what the component shows and what is selected with \`describe\`, so the page's Agent can answer from it.
|
|
1233
1267
|
- **Change the guide with the code.** When settings, limits or extension points change, update \`README.md\` in the same change and raise the manifest's version.
|
|
1234
1268
|
- **The same holds when the AI builds or changes a component.** When a rule is missing, add it to the network, not to the code.
|
|
1235
|
-
`,
|
|
1269
|
+
`,fu=Object.freeze(Object.defineProperty({__proto__:null,default:sk},Symbol.toStringTag,{value:"Module"})),rk='# 自定义组件:开发与二次开发\n\n标准组件满足不了的展示与交互,可以自己开发组件,打成组件包上传到这个应用。组件跑在隔离的框架里,只能通过 Workshop 给的接口读数据、执行行动,拿不到登录信息,也不能随意联网。\n\n## 一 怎样开发一个组件\n\n1. **装开发包。** 在自己的项目里装 `@openbkn/workshop`(发布在公开 npm 源上,直接安装):\n\n ```bash\n npm install --save-dev @openbkn/workshop@rc\n ```\n\n2. **新建组件包。** 目录名就是组件名,类型为 `x-<前缀>.<名称>`:\n\n ```bash\n npx workshop-component init supplier-ranking --prefix acme --label 供应商排行\n ```\n\n 生成四个文件:`manifest.json`(清单:类型、名称、配置项、数据角色、联动)、`index.js`(入口,定义一个自定义元素)、`preview.json`(本地预览用的示例数据)、`README.md`(组件说明,见第三节)。\n\n3. **本地预览。** `npx workshop-component dev supplier-ranking`,打开 `http://localhost:8765/`。组件在与 Workshop 相同的隔离框架里运行,可以切换主题、语言、宽度,模拟空结果、无权限和行动确认框。\n\n4. **校验并打包。** `npx workshop-component validate` 按上传时的检查校验;`npx workshop-component pack --out dist` 打出 zip。\n\n5. **上传。** 在左侧组件库「自定义组件」里点「上传组件包」。上传后组件会放到当前页面上,配置面板按清单生成;同一类型再次上传会换成新包。发布前,应用里用到的每个组件包都要能找到,否则发布会被拦下。\n\n## 二 组件能做什么、不能做什么\n\n| 能做 | 怎么做 |\n| --- | --- |\n| 显示数据源里的对象 | 配置项里的数据源与字段角色,组件从 `data` 拿到已经取好的行 |\n| 补查数据 | `workshop.query`:只读 Cypher,或在已有数据源里再筛选(见下文“取数与提问的现状”) |\n| 选中、筛选别的组件 | 清单 `emits` 声明后,写入共享筛选 |\n| 执行行动 | `workshop.act`:一定先弹 Workshop 的确认框,用户点确定才执行。行动有名为 `app_id` 的参数时,由 Workshop 填入当前应用的 ID,组件传的值不生效 |\n| 让页面的 Agent 读懂组件 | `workshop.describe`:告诉 Agent 组件现在显示什么 |\n| 向 Agent 提问 | `workshop.ask`:把问题交给页面上的 Agent 对话 |\n\n**取数与提问的现状。** 下面这些是现在的实际行为,写组件时按它来:\n\n- `query({ kind: "objects" })` 不查服务端,只在页面上已有的、这个对象类的数据源里筛选:页面没有这样的数据源时返回 `unavailable`;`where` 只支持等值条件;最多返回 5000 行,超出时 `truncated` 为 true。选中方案时,返回的是方案里的数据,与组件自己的 `data` 一致,计算列也一样算好。要查更多数据或更复杂的条件,用 Cypher。\n- `query({ kind: "cypher" })` 以使用者的身份查知识网络当前的数据,不带方案里的改动;拿不到页面数据源上的计算列。\n- `query({ kind: "metric" })` 还没有提供,调用会以 `unavailable` 拒绝。要用指标,先在页面上放指标卡,或把指标的结果放进数据源。\n- `ask` 只带问题,`context` 里的对象暂不发送;问题填进 Agent 对话的输入框,由使用者确认发送。页面上有 Agent 对话组件时交给它;没有时在页面旁边的抽屉里打开一个对话,关掉抽屉对话还在,下次提问再打开。\n- 配置项里没有 `x-workshop` 控件的数组、对象,配置面板不显示,可以在应用的 `app.yaml` 里直接写,组件拿到写的值或清单里的默认值;应用校验只检查它是数组还是对象。\n\n不能做:读写浏览器存储与 Cookie;访问清单没有声明的网络地址;绕过确认框执行行动;在构建器设计和预览时执行行动或打开页面;拿使用者的令牌,或以使用者的身份做上表以外的事(比如建分析画布)。清单 `network` 里声明的地址可以访问,但请求不带使用者的身份。\n\n包的限制:总大小 5 MB、最多 500 个文件,入口建议不超过 300 KB;只收 js、css、json、svg、png、jpg、webp、woff2、md 文件。\n\n## 三 每个组件都要附说明\n\n组件包里放一份 `README.md`,上传后在组件库和配置面板上点「说明」就能看到,构建应用的人和 AI 都靠它配置组件。没有说明的包,校验时会给出提醒。\n\n说明按下面的标题写,没有内容的节写“无”:\n\n- **概述**:写在标题下的第一段,说明展示什么、用来做什么决策。\n- **适用与不适用**:不适用时改用什么。\n- **本体契约**:组件里有哪些角色(如“项”“资源”“任务”),每个角色要哪类对象、哪些属性、哪些关系、是否必填。\n- **组件内置的判断**:组件自己做的、与行业无关的检查,是硬约束还是只标出。\n- **扩展点**:场景判断从哪里接进来,接逻辑属性、指标还是规则工具,输入输出是什么。\n- **交互与联动**:写入、读取哪些筛选,能触发哪些行动。\n- **场景配方**:每个场景怎样对应角色、要在知识网络里补什么、扩展点挂什么。\n- **给 AI 的指引**:配置步骤、先问用户什么、常见错误。\n- **限制**:数量上限、不支持的情况。\n\n## 四 二次开发建议\n\n- **业务判断放在知识网络里,不写进组件。** “是否超期”“是否齐套”“风险高低”这类判断,写成知识网络的属性、逻辑属性、指标或规则工具,组件只读结果。这样同一个问题在各处答案一致,改规则不用改组件。\n- **组件只做通用能力。** 排行、矩阵、甘特、拖动、重叠检查这类与行业无关的展示和交互放在组件里;行业规则通过扩展点接进来。\n- **为新场景复用组件,先改知识网络。** 按说明里的本体契约把场景对象对应到组件角色,缺的对象、属性、关系在知识网络里补;再把场景判断挂到扩展点上。\n- **不要写死对象类和属性名。** 对象类、关系、字段都从配置项和数据源里取,不要在代码里写死 `supplier` 这样的名字,换一个网络组件照样能用。\n- **改数据只走行动。** 组件不直接写数据,需要改动时调用知识网络的行动,用户在确认框里确认。\n- **让 Agent 能读懂。** 用 `describe` 报告组件当前显示的内容和选中项,页面上的 Agent 才能基于它回答问题。\n- **说明与代码一起改。** 配置项、上限、扩展点变了,同一次改动更新 `README.md`,并把清单里的版本号加一。\n- **AI 生成或修改组件时也一样。** 缺判断时补知识网络,不补代码。\n',mu=Object.freeze(Object.defineProperty({__proto__:null,default:rk},Symbol.toStringTag,{value:"Module"})),ak=`# Date range (dateRange)
|
|
1236
1270
|
|
|
1237
1271
|
Pick a start and an end date, and the components that follow it show only the objects whose date falls in that span. Use it for "how many were signed this month" or "what was added in the last 30 days".
|
|
1238
1272
|
|
|
@@ -1307,7 +1341,7 @@ None. The quick picks are fixed and cannot come from the knowledge network, so f
|
|
|
1307
1341
|
- One component writes one date range; filtering by several dates separately takes several ranges.
|
|
1308
1342
|
- There are 7 fixed quick picks; they can only be turned on or off.
|
|
1309
1343
|
- Dates are compared by day, without time of day.
|
|
1310
|
-
`,
|
|
1344
|
+
`,ik=Object.freeze(Object.defineProperty({__proto__:null,default:ak},Symbol.toStringTag,{value:"Module"})),lk=`# 日期区间(dateRange)
|
|
1311
1345
|
|
|
1312
1346
|
选起点和终点两个日期,页面上跟随它的组件只显示某个日期落在这段时间里的对象。用来回答“这个月签了多少”“近 30 天新增了哪些”。
|
|
1313
1347
|
|
|
@@ -1382,7 +1416,7 @@ None. The quick picks are fixed and cannot come from the knowledge network, so f
|
|
|
1382
1416
|
- 一个组件写一个日期区间;一个对象类里要按几个日期分别筛,需要几个区间。
|
|
1383
1417
|
- 快捷项固定为 7 个,无法增删,只能开或关。
|
|
1384
1418
|
- 日期按天比较,不含时分。
|
|
1385
|
-
`,
|
|
1419
|
+
`,ck=Object.freeze(Object.defineProperty({__proto__:null,default:lk},Symbol.toStringTag,{value:"Module"})),dk=`# Dropdown filter (dropdownFilter)
|
|
1386
1420
|
|
|
1387
1421
|
Pick one or several values from a dropdown, and the components that follow it show only the chosen values. Options come from the data automatically, with counts, and can be searched. Use it for fields with many values, such as city, customer or team.
|
|
1388
1422
|
|
|
@@ -1454,7 +1488,7 @@ None. Options come only from the data and cannot be supplied by the knowledge ne
|
|
|
1454
1488
|
|
|
1455
1489
|
- The options are at most the distinct values that appear in the data; an object type data source reads at most 5000 rows and a Cypher data source 10,000 (1,000 when its query sets no LIMIT); beyond that only the values read appear.
|
|
1456
1490
|
- It filters by equal values only, with no range or fuzzy match.
|
|
1457
|
-
`,
|
|
1491
|
+
`,uk=Object.freeze(Object.defineProperty({__proto__:null,default:dk},Symbol.toStringTag,{value:"Module"})),hk=`# 下拉筛选(dropdownFilter)
|
|
1458
1492
|
|
|
1459
1493
|
下拉选择一个或多个值,页面上跟随它的组件只显示所选值。选项从数据里自动取,带数量,可以搜索。用在取值很多的字段上,如城市、客户、球队。
|
|
1460
1494
|
|
|
@@ -1526,7 +1560,7 @@ None. Options come only from the data and cannot be supplied by the knowledge ne
|
|
|
1526
1560
|
|
|
1527
1561
|
- 选项最多等于数据中出现过的不同取值;对象类数据源最多读 5000 行,Cypher 数据源最多 10000 行(查询没写 LIMIT 时 1000 行),超过时只有读到的取值。
|
|
1528
1562
|
- 只按取值相等筛选,不支持范围或模糊匹配。
|
|
1529
|
-
`,
|
|
1563
|
+
`,pk=Object.freeze(Object.defineProperty({__proto__:null,default:hk},Symbol.toStringTag,{value:"Module"})),fk=`# Event list (eventList)
|
|
1530
1564
|
|
|
1531
1565
|
Lists the business events the app handles, open ones first and by severity, so people can verify, reject or close them and move on to analysis. Use it to decide which events to look at first, whether they are real, and whether they need handling.
|
|
1532
1566
|
|
|
@@ -1637,7 +1671,7 @@ Whether an event is created, what a check found, and which actions a status allo
|
|
|
1637
1671
|
- The reason for reject, close and reopen is at most 200 characters.
|
|
1638
1672
|
- When a chosen event type is missing from the knowledge network, the list says events of that type cannot come in.
|
|
1639
1673
|
- The app needs at least one event type. Without any, the component asks you to choose some on the "Events" tab.
|
|
1640
|
-
`,
|
|
1674
|
+
`,mk=Object.freeze(Object.defineProperty({__proto__:null,default:fk},Symbol.toStringTag,{value:"Module"})),gk=`# 事件列表(eventList)
|
|
1641
1675
|
|
|
1642
1676
|
列出应用处理的业务事件,未关闭的在前、按严重程度排,由人核实、驳回、关闭,并从事件进入分析。用来做“哪些事要先看、是不是真的、要不要处理”的决策。
|
|
1643
1677
|
|
|
@@ -1748,7 +1782,7 @@ Whether an event is created, what a check found, and which actions a status allo
|
|
|
1748
1782
|
- 驳回、关闭、重新打开的原因不超过 200 字。
|
|
1749
1783
|
- 知识网络里没有某个已选的事件类型时,列表提示该类型的事件进不来。
|
|
1750
1784
|
- 应用至少要选一个事件类型;没有时组件提示先到“事件”页签选择。
|
|
1751
|
-
`,
|
|
1785
|
+
`,yk=Object.freeze(Object.defineProperty({__proto__:null,default:gk},Symbol.toStringTag,{value:"Module"})),bk=`# Event report (eventReport)
|
|
1752
1786
|
|
|
1753
1787
|
A button that opens a form to report a business event, which then starts as unverified. Use it to let people on the floor record anomalies rules cannot find and pass them to someone with the right to verify.
|
|
1754
1788
|
|
|
@@ -1820,7 +1854,7 @@ None. The form's fields are configuration, not business judgment. Whether a repo
|
|
|
1820
1854
|
- One component serves one event type. To report several kinds, place several components.
|
|
1821
1855
|
- The form has at most 12 fields, of type text, number or date.
|
|
1822
1856
|
- The title is at most 80 characters and a text field at most 200.
|
|
1823
|
-
`,
|
|
1857
|
+
`,wk=Object.freeze(Object.defineProperty({__proto__:null,default:bk},Symbol.toStringTag,{value:"Module"})),kk=`# 事件登记(eventReport)
|
|
1824
1858
|
|
|
1825
1859
|
一个按钮,点开表单登记一条业务事件,登记后状态为待核实。用来让现场人员把规则发现不了的异常记下来,交给有权限的人核实。
|
|
1826
1860
|
|
|
@@ -1892,7 +1926,7 @@ None. The form's fields are configuration, not business judgment. Whether a repo
|
|
|
1892
1926
|
- 一个组件对应一个事件类型;要登记多类事件,放多个组件。
|
|
1893
1927
|
- 登记表单最多 12 个字段,类型只有文本、数字、日期。
|
|
1894
1928
|
- 标题不超过 80 字,文本字段不超过 200 字。
|
|
1895
|
-
`,
|
|
1929
|
+
`,vk=Object.freeze(Object.defineProperty({__proto__:null,default:kk},Symbol.toStringTag,{value:"Module"})),$k=`# Gantt chart (ganttChart)
|
|
1896
1930
|
|
|
1897
1931
|
Draws objects as bars from start to end date, one row per group, around the page's base date. Use it to see how plans and progress are spread out: which items crowd together and which have run late.
|
|
1898
1932
|
|
|
@@ -1965,7 +1999,7 @@ None. Put judgements such as late or at risk in logical properties on the knowle
|
|
|
1965
1999
|
- Days shown 14 to 365; max rows 3 to 40; one data source.
|
|
1966
2000
|
- No click or drag, and it writes no filter.
|
|
1967
2001
|
- Only the rows with the most bars are shown; the rest are not.
|
|
1968
|
-
`,
|
|
2002
|
+
`,Sk=Object.freeze(Object.defineProperty({__proto__:null,default:$k},Symbol.toStringTag,{value:"Module"})),jk=`# 甘特图(ganttChart)
|
|
1969
2003
|
|
|
1970
2004
|
按开始、结束日期把对象画成条,每行一组,围绕页面的基准日期显示一段时间。用来看计划与进度的整体分布,判断哪些项挤在一起、哪些已拖期。
|
|
1971
2005
|
|
|
@@ -2038,7 +2072,7 @@ None. Put judgements such as late or at risk in logical properties on the knowle
|
|
|
2038
2072
|
- 显示天数 14 到 365;最多行数 3 到 40;一个数据源。
|
|
2039
2073
|
- 不能点击、拖动,不写入任何筛选。
|
|
2040
2074
|
- 只显示条数最多的前若干行,其余行不显示。
|
|
2041
|
-
`,
|
|
2075
|
+
`,Ak=Object.freeze(Object.defineProperty({__proto__:null,default:jk},Symbol.toStringTag,{value:"Module"})),Tk=`# Metric cards (metricCards)
|
|
2042
2076
|
|
|
2043
2077
|
A row of number cards, each counting one metric, with optional year-over-year and period-over-period change and a trend; clicking a card can filter the page. Use it to answer "how many are there now, how many are overdue, and is that up or down on last month".
|
|
2044
2078
|
|
|
@@ -2138,7 +2172,7 @@ Business rules in a metric's definition or conditions belong in the knowledge ne
|
|
|
2138
2172
|
- Page-counted cards use the rows read; an object type data source reads at most 5000 rows and a Cypher data source 10,000 (1,000 when its query sets no LIMIT); beyond that only what was read is counted. Object metrics are computed by the platform and are not limited this way.
|
|
2139
2173
|
- Object metric cards write no filter.
|
|
2140
2174
|
- The trend line covers at most the last 6 periods.
|
|
2141
|
-
`,
|
|
2175
|
+
`,Ok=Object.freeze(Object.defineProperty({__proto__:null,default:Tk},Symbol.toStringTag,{value:"Module"})),Ek=`# 指标卡组(metricCards)
|
|
2142
2176
|
|
|
2143
2177
|
一排数字卡片,每张统计一项指标,可显示同比环比与趋势;点击卡片可以筛选页面。用来回答“现在有多少、多少已超期、比上月涨了还是降了”。
|
|
2144
2178
|
|
|
@@ -2238,7 +2272,7 @@ Business rules in a metric's definition or conditions belong in the knowledge ne
|
|
|
2238
2272
|
- 页面内统计读入的对象有行数上限(对象类数据源最多 5000 行,Cypher 数据源最多 10000 行,查询没写 LIMIT 时 1000 行),超过时只统计读到的部分;对象指标由平台算,不受此限。
|
|
2239
2273
|
- 对象指标卡不写入筛选。
|
|
2240
2274
|
- 同比环比的趋势线最多画最近 6 期。
|
|
2241
|
-
`,
|
|
2275
|
+
`,Ck=Object.freeze(Object.defineProperty({__proto__:null,default:Ek},Symbol.toStringTag,{value:"Module"})),Nk=`# Model trial (modelTrial)
|
|
2242
2276
|
|
|
2243
2277
|
Runs a model on a batch of objects once for each of 2 to 4 parameter sets, and compares the totals and details of the sets side by side. Results show only on the page and do not change the objects. Use it to decide what happens if the parameters are set this way.
|
|
2244
2278
|
|
|
@@ -2371,7 +2405,7 @@ Independent of industry, the component does these itself:
|
|
|
2371
2405
|
- 2 to 4 parameter sets, and the first is the baseline.
|
|
2372
2406
|
- A call is cut after about 30 seconds, and the set that timed out shows as failed.
|
|
2373
2407
|
- Trial results are not saved to the service, only in the current browser.
|
|
2374
|
-
`,
|
|
2408
|
+
`,xk=Object.freeze(Object.defineProperty({__proto__:null,default:Nk},Symbol.toStringTag,{value:"Module"})),Rk=`# 模型试算(modelTrial)
|
|
2375
2409
|
|
|
2376
2410
|
对一批对象,按 2 到 4 组参数各调用一次模型,并排比较各组的汇总与明细;结果只显示在页面上,不改对象。用来做“参数这样调、结果会怎样”的决策。
|
|
2377
2411
|
|
|
@@ -2504,7 +2538,7 @@ Independent of industry, the component does these itself:
|
|
|
2504
2538
|
- 参数组 2 到 4 个;第一组是基准。
|
|
2505
2539
|
- 一次调用最长约 30 秒;超时的组显示失败。
|
|
2506
2540
|
- 试算结果不保存到服务,只保存在当前浏览器。
|
|
2507
|
-
`,
|
|
2541
|
+
`,_k=Object.freeze(Object.defineProperty({__proto__:null,default:Rk},Symbol.toStringTag,{value:"Module"})),Pk=`# Object detail (objectDetail)
|
|
2508
2542
|
|
|
2509
2543
|
When an object is selected, a drawer on the right shows its progress, its properties and the related records found along relations. Use it after a click in a list or a summary, to see the whole picture of that item and handle it on the spot.
|
|
2510
2544
|
|
|
@@ -2617,7 +2651,7 @@ What counts as "done" or "overdue" is defined by the data source's progress, not
|
|
|
2617
2651
|
- The drawer has a fixed width, and properties are laid out in two columns.
|
|
2618
2652
|
- Actions on click: up to 8 items with up to 5 steps each.
|
|
2619
2653
|
- At most 5000 objects are read per object type data source, and at most 10,000 rows per Cypher data source (1,000 when its query sets no LIMIT); a selected object outside what was read is not found and the drawer does not open.
|
|
2620
|
-
`,
|
|
2654
|
+
`,Lk=Object.freeze(Object.defineProperty({__proto__:null,default:Pk},Symbol.toStringTag,{value:"Module"})),Ik=`# 对象详情(objectDetail)
|
|
2621
2655
|
|
|
2622
2656
|
选中一个对象后,从右侧抽屉里显示它的进度、属性,以及沿关系查到的关联记录。用来在列表或汇总里点中一项后,看这一项的全貌并就地处理。
|
|
2623
2657
|
|
|
@@ -2730,7 +2764,7 @@ What counts as "done" or "overdue" is defined by the data source's progress, not
|
|
|
2730
2764
|
- 抽屉宽度固定,属性按两列排。
|
|
2731
2765
|
- 点击后的动作最多 8 项,每项最多 5 个动作。
|
|
2732
2766
|
- 对象类数据源最多读入 5000 个对象,Cypher 数据源最多 10000 行(查询没写 LIMIT 时 1000 行);选中的对象不在已读取的部分时找不到,抽屉不打开。
|
|
2733
|
-
`,
|
|
2767
|
+
`,Mk=Object.freeze(Object.defineProperty({__proto__:null,default:Ik},Symbol.toStringTag,{value:"Module"})),qk=`# Object list (objectList)
|
|
2734
2768
|
|
|
2735
2769
|
A list of cards: each item has a title, a few lines of description and a status badge; clicking an item selects the object. Use it as the entry point of a to-do or inbox: see which few come first and open them to deal with.
|
|
2736
2770
|
|
|
@@ -2823,7 +2857,7 @@ What a business means by "needs handling" or "urgent" is not judged in the list;
|
|
|
2823
2857
|
- "Show at most" is 3 to 30 items (default 8); the rest are only counted in a note, with no paging.
|
|
2824
2858
|
- At most 5000 objects are read per object type data source, and at most 10,000 rows per Cypher data source (1,000 when its query sets no LIMIT); beyond that a note shows above and the list covers only what was read.
|
|
2825
2859
|
- Actions on click: up to 8 items with up to 5 steps each; one execution confirmation covers at most 100 objects.
|
|
2826
|
-
`,
|
|
2860
|
+
`,Fk=Object.freeze(Object.defineProperty({__proto__:null,default:qk},Symbol.toStringTag,{value:"Module"})),Dk=`# 对象列表(objectList)
|
|
2827
2861
|
|
|
2828
2862
|
卡片式列表:每项一个标题,加几行说明和一个状态徽标;点一项选中对象。用来做待办、收件箱这类“先看哪几项、点开处理”的入口。
|
|
2829
2863
|
|
|
@@ -2916,7 +2950,7 @@ What a business means by "needs handling" or "urgent" is not judged in the list;
|
|
|
2916
2950
|
- “最多显示”3 到 30 项(默认 8);超出的只提示个数,不翻页。
|
|
2917
2951
|
- 对象类数据源最多读入 5000 个对象,Cypher 数据源最多 10000 行(查询没写 LIMIT 时 1000 行),超过时上方提示,列表只覆盖已读取部分。
|
|
2918
2952
|
- 点击后的动作最多 8 项,每项最多 5 个动作;一次执行确认最多 100 个对象。
|
|
2919
|
-
`,
|
|
2953
|
+
`,Bk=Object.freeze(Object.defineProperty({__proto__:null,default:Dk},Symbol.toStringTag,{value:"Module"})),Uk=`# Object table (objectTable)
|
|
2920
2954
|
|
|
2921
2955
|
Lists one type of object as a detail table that can be sorted, paged and ticked; clicking a row selects the object. Use it to check items one by one and to pick a batch for other components or actions.
|
|
2922
2956
|
|
|
@@ -3039,7 +3073,7 @@ What a business means by "overdue", "high risk" or "short of material" is not ju
|
|
|
3039
3073
|
- At most 5000 objects are read per object type data source, and at most 10,000 rows per Cypher data source (1,000 when its query sets no LIMIT); beyond that a note above the table says only the first N of M were read (a Cypher data source does not know M, so the note only says there may be more), and the table and its figures cover only what was read.
|
|
3040
3074
|
- Actions on click: up to 8 items with up to 5 steps each; one execution confirmation covers at most 100 objects, and a single action config defaults to 20.
|
|
3041
3075
|
- Search runs only on the objects already read into the browser; it does not query the knowledge network again.
|
|
3042
|
-
`,
|
|
3076
|
+
`,zk=Object.freeze(Object.defineProperty({__proto__:null,default:Uk},Symbol.toStringTag,{value:"Module"})),Wk=`# 对象表(objectTable)
|
|
3043
3077
|
|
|
3044
3078
|
把一类对象列成明细表,可排序、分页、勾选,点一行选中对象。用来逐项核对、挑出一批对象交给别的组件或行动处理。
|
|
3045
3079
|
|
|
@@ -3162,7 +3196,7 @@ What a business means by "overdue", "high risk" or "short of material" is not ju
|
|
|
3162
3196
|
- 对象类数据源最多读入 5000 个对象,Cypher 数据源最多 10000 行(查询没写 LIMIT 时 1000 行);超过时表上方提示“仅读取前 N 条(共 M 条)”(Cypher 数据源不知道总数,只提示可能不完整),表里的数据与统计只覆盖已读取部分。
|
|
3163
3197
|
- 点击后的动作最多 8 项,每项最多 5 个动作;一次执行确认最多 100 个对象,单个行动配置默认最多 20 个。
|
|
3164
3198
|
- 搜索只在浏览器已读入的对象上做,不去知识网络再查。
|
|
3165
|
-
`,
|
|
3199
|
+
`,Kk=Object.freeze(Object.defineProperty({__proto__:null,default:Wk},Symbol.toStringTag,{value:"Module"})),Yk=`# Pivot table (pivotTable)
|
|
3166
3200
|
|
|
3167
3201
|
Groups objects by one property, one row per group and one statistic per column; clicking a row makes the whole page look at that group only. Use it to answer "how many, how much and what share in each class", and to move from a total to its details.
|
|
3168
3202
|
|
|
@@ -3260,7 +3294,7 @@ Sum, average, least and greatest need a number property; count and share do not.
|
|
|
3260
3294
|
- Up to 5 measures; 5 to 50 rows shown (default 10), further groups are not shown.
|
|
3261
3295
|
- At most 5000 objects are read per object type data source, and at most 10,000 rows per Cypher data source (1,000 when its query sets no LIMIT); beyond that a note shows above and the figures cover only what was read.
|
|
3262
3296
|
- Actions on click: up to 8 items with up to 5 steps each; one execution confirmation covers at most 100 objects.
|
|
3263
|
-
`,
|
|
3297
|
+
`,Gk=Object.freeze(Object.defineProperty({__proto__:null,default:Yk},Symbol.toStringTag,{value:"Module"})),Hk=`# 透视表(pivotTable)
|
|
3264
3298
|
|
|
3265
3299
|
按一个属性把对象分组,每组一行,每列一个统计数;点一行,整页只看这一组。用来回答“各类里分别有多少、多少金额、占比多少”,并从汇总点进明细。
|
|
3266
3300
|
|
|
@@ -3358,7 +3392,7 @@ Sum, average, least and greatest need a number property; count and share do not.
|
|
|
3358
3392
|
- 度量最多 5 个;最多显示 5 到 50 行(默认 10),超出的组不显示。
|
|
3359
3393
|
- 对象类数据源最多读入 5000 个对象,Cypher 数据源最多 10000 行(查询没写 LIMIT 时 1000 行),超过时上方提示,统计只覆盖已读取部分。
|
|
3360
3394
|
- 点击后的动作最多 8 项,每项最多 5 个动作;一次执行确认最多 100 个对象。
|
|
3361
|
-
`,
|
|
3395
|
+
`,Vk=Object.freeze(Object.defineProperty({__proto__:null,default:Hk},Symbol.toStringTag,{value:"Module"})),Jk=`# Map (regionMap)
|
|
3362
3396
|
|
|
3363
3397
|
Colors a map by region: the China map by province, the world map by country, with deeper color for a greater count or amount of objects; it can draw lines between related objects and these objects, and clicking a region makes the whole page look at it only. Use it to answer "where are these objects, where are they most concentrated, where do goods come from and go to".
|
|
3364
3398
|
|
|
@@ -3482,7 +3516,7 @@ What counts as a "risk region" or a "key area" is not judged on the map; propert
|
|
|
3482
3516
|
- Up to 2 relation lines, each one direct relation only.
|
|
3483
3517
|
- At most 5000 objects are read per object type data source, and at most 10,000 rows per Cypher data source (1,000 when its query sets no LIMIT); beyond that a note shows above and the figures cover only what was read.
|
|
3484
3518
|
- Actions on click: up to 8 items with up to 5 steps each.
|
|
3485
|
-
`,
|
|
3519
|
+
`,Zk=Object.freeze(Object.defineProperty({__proto__:null,default:Jk},Symbol.toStringTag,{value:"Module"})),Xk=`# 地图(regionMap)
|
|
3486
3520
|
|
|
3487
3521
|
按地区给地图着色:中国地图按省份,世界地图按国家,颜色深浅表示该地区对象的数量或金额;可画出关联对象到这些对象之间的连线,点一个地区,整页只看它。用来回答“这些对象分布在哪里、哪里最集中、货从哪里来到哪里去”。
|
|
3488
3522
|
|
|
@@ -3606,7 +3640,7 @@ What counts as a "risk region" or a "key area" is not judged on the map; propert
|
|
|
3606
3640
|
- 关系连线最多 2 条,每条只能是一条直接关系。
|
|
3607
3641
|
- 对象类数据源最多读入 5000 个对象,Cypher 数据源最多 10000 行(查询没写 LIMIT 时 1000 行),超过时上方提示,统计只覆盖已读取部分。
|
|
3608
3642
|
- 点击后的动作最多 8 项,每项最多 5 个动作。
|
|
3609
|
-
`,
|
|
3643
|
+
`,Qk=Object.freeze(Object.defineProperty({__proto__:null,default:Xk},Symbol.toStringTag,{value:"Module"})),ev=`# Scenario (scenarioBar)
|
|
3610
3644
|
|
|
3611
3645
|
Chooses whether the page shows the data as it is or a scenario, creates, copies, saves, applies and voids scenarios, lists and adjusts the assumptions in a scenario, and compares the indicators of scenarios side by side with the data as it is. Use it to decide: if we change this, what happens, and should we really apply it.
|
|
3612
3646
|
|
|
@@ -3724,7 +3758,7 @@ Independent of industry, the component does these itself:
|
|
|
3724
3758
|
- Each source has at most 10 operations, each with at most 5 inputs and 5 effects. There are at most 10 scenario parameters, each text parameter with at most 10 values.
|
|
3725
3759
|
- A scenario name is at most 40 characters.
|
|
3726
3760
|
- A model result reads at most 5000 rows per input and 25000 in total.
|
|
3727
|
-
`,
|
|
3761
|
+
`,tv=Object.freeze(Object.defineProperty({__proto__:null,default:ev},Symbol.toStringTag,{value:"Module"})),nv=`# 方案(scenarioBar)
|
|
3728
3762
|
|
|
3729
3763
|
选择页面显示现状还是某个方案,新建、复制、保存、采用、作废方案,查看并调整方案里的改动,并排对比各方案与现状的指标。用来做“如果这样改,结果会怎样,要不要真的采用”的决策。
|
|
3730
3764
|
|
|
@@ -3842,7 +3876,7 @@ Independent of industry, the component does these itself:
|
|
|
3842
3876
|
- 每个数据源最多 10 个推演操作,每个操作最多 5 个参数、5 个效果;方案参数最多 10 个,每个文本参数最多 10 个可选值。
|
|
3843
3877
|
- 方案名称不超过 40 字。
|
|
3844
3878
|
- 模型结果每次最多读 5000 行、合计 25000 行。
|
|
3845
|
-
`,
|
|
3879
|
+
`,ov=Object.freeze(Object.defineProperty({__proto__:null,default:nv},Symbol.toStringTag,{value:"Module"})),sv=`# Schedule Gantt (scheduleGantt)
|
|
3846
3880
|
|
|
3847
3881
|
Resources as rows and time running across: in a scenario you drag tasks to change their resource and time, and built-in constraints plus rules on the knowledge network decide whether the scenario can be applied. Use it for decisions that put tasks on resources, such as production scheduling, maintenance and dispatching.
|
|
3848
3882
|
|
|
@@ -4018,7 +4052,7 @@ Tasks that meet "Done when" take no part in these checks. Hard constraints block
|
|
|
4018
4052
|
- A rule tool gets at most 200 tasks per call; a call waits up to 30 seconds and is tried once more after a failure, 90 seconds in all.
|
|
4019
4053
|
- Predecessor relations are one hop only.
|
|
4020
4054
|
- Rule tools are called in the browser as needed and their results are not saved; the same scenario opened in another page is judged again.
|
|
4021
|
-
`,
|
|
4055
|
+
`,rv=Object.freeze(Object.defineProperty({__proto__:null,default:sv},Symbol.toStringTag,{value:"Module"})),av=`# 调度甘特(scheduleGantt)
|
|
4022
4056
|
|
|
4023
4057
|
资源排成行、时间横向展开,在一个方案里拖动任务改资源与时间,由内置约束和知识网络上的规则判断方案能否采用。用来做排产、检修、派工这类“把任务排到资源上”的决策。
|
|
4024
4058
|
|
|
@@ -4194,7 +4228,7 @@ Tasks that meet "Done when" take no part in these checks. Hard constraints block
|
|
|
4194
4228
|
- 规则工具每次最多收 200 个任务;一次调用最长等 30 秒,失败后自动重试一次,合计不超过 90 秒。
|
|
4195
4229
|
- 前序关系只支持一跳关系。
|
|
4196
4230
|
- 规则工具在浏览器中按需调用,结果不保存;同一方案在另一页面打开时会重新判断。
|
|
4197
|
-
`,
|
|
4231
|
+
`,iv=Object.freeze(Object.defineProperty({__proto__:null,default:av},Symbol.toStringTag,{value:"Module"})),lv=`# Search box (searchBox)
|
|
4198
4232
|
|
|
4199
4233
|
Type a keyword, and the components that follow it show only the objects whose text columns contain it. Use it to find objects quickly by name or number.
|
|
4200
4234
|
|
|
@@ -4257,7 +4291,7 @@ None. The component only does text containment; it calls no tool and does no syn
|
|
|
4257
4291
|
|
|
4258
4292
|
- Text containment only; no multiple words, pinyin or fuzzy matching.
|
|
4259
4293
|
- It searches only the rows already read; an object type data source reads at most 5000 rows and a Cypher data source 10,000 (1,000 when its query sets no LIMIT).
|
|
4260
|
-
`,
|
|
4294
|
+
`,cv=Object.freeze(Object.defineProperty({__proto__:null,default:lv},Symbol.toStringTag,{value:"Module"})),dv=`# 搜索框(searchBox)
|
|
4261
4295
|
|
|
4262
4296
|
输入关键词,页面上跟随它的组件只显示在文本列里包含这个词的对象。用来按名称、编号快速找到对象。
|
|
4263
4297
|
|
|
@@ -4320,7 +4354,7 @@ None. The component only does text containment; it calls no tool and does no syn
|
|
|
4320
4354
|
|
|
4321
4355
|
- 只做文字包含匹配,不支持多个词、拼音或模糊匹配。
|
|
4322
4356
|
- 只在已读入的数据里查找;对象类数据源最多读 5000 行,Cypher 数据源最多 10000 行(查询没写 LIMIT 时 1000 行)。
|
|
4323
|
-
`,
|
|
4357
|
+
`,uv=Object.freeze(Object.defineProperty({__proto__:null,default:dv},Symbol.toStringTag,{value:"Module"})),hv=`# Segmented filter (segmentedFilter)
|
|
4324
4358
|
|
|
4325
4359
|
A row of buttons with counts, splitting by the value of one field; one click and the page shows only that group. Use it to switch quickly between a few groups such as all, in progress and overdue.
|
|
4326
4360
|
|
|
@@ -4396,7 +4430,7 @@ None. The segments come from the configured values. Industry judgments (such as
|
|
|
4396
4430
|
- 2 to 6 options.
|
|
4397
4431
|
- One button selected at a time.
|
|
4398
4432
|
- Counts come from the rows already read; an object type data source reads at most 5000 rows and a Cypher data source 10,000 (1,000 when its query sets no LIMIT).
|
|
4399
|
-
`,
|
|
4433
|
+
`,pv=Object.freeze(Object.defineProperty({__proto__:null,default:hv},Symbol.toStringTag,{value:"Module"})),fv=`# 分段筛选(segmentedFilter)
|
|
4400
4434
|
|
|
4401
4435
|
一排带数量的按钮,按一个字段的取值分段,点一下页面只看这一类。用来在“全部 / 进行中 / 已超期”这类少数几类之间快速切换。
|
|
4402
4436
|
|
|
@@ -4472,7 +4506,7 @@ None. The segments come from the configured values. Industry judgments (such as
|
|
|
4472
4506
|
- 选项 2 到 6 个。
|
|
4473
4507
|
- 一次只选一个按钮。
|
|
4474
4508
|
- 数量按已读入的数据统计;对象类数据源最多读 5000 行,Cypher 数据源最多 10000 行(查询没写 LIMIT 时 1000 行)。
|
|
4475
|
-
`,
|
|
4509
|
+
`,mv=Object.freeze(Object.defineProperty({__proto__:null,default:fv},Symbol.toStringTag,{value:"Module"})),gv=`# Stage chain (stageChain)
|
|
4476
4510
|
|
|
4477
4511
|
Lines up several object types in business order and shows how many related objects each stage has; click a stage to see the records. Use it to see how many objects have reached each stage and to spot where they pile up or drop off.
|
|
4478
4512
|
|
|
@@ -4542,7 +4576,7 @@ None. Which objects count at a stage is decided by the relation path; to limit b
|
|
|
4542
4576
|
- 1 to 9 stages; up to 20 records when expanded.
|
|
4543
4577
|
- One data source; it counts reachable objects only and shows no conversion rate between stages.
|
|
4544
4578
|
- A stage without a relation path does not follow filters.
|
|
4545
|
-
`,
|
|
4579
|
+
`,yv=Object.freeze(Object.defineProperty({__proto__:null,default:gv},Symbol.toStringTag,{value:"Module"})),bv=`# 环节链路(stageChain)
|
|
4546
4580
|
|
|
4547
4581
|
把几类对象按业务顺序排成一排,每个环节显示关联的对象数量,点开可看具体记录。用来看一批对象流转到各环节的数量,判断哪个环节堆积或断档。
|
|
4548
4582
|
|
|
@@ -4612,7 +4646,7 @@ None. Which objects count at a stage is decided by the relation path; to limit b
|
|
|
4612
4646
|
- 环节 1 到 9 个;展开最多 20 条。
|
|
4613
4647
|
- 一个数据源,只数关系可达的对象,不显示环节之间的转化率。
|
|
4614
4648
|
- 没配关系路径的环节不跟随筛选。
|
|
4615
|
-
`,
|
|
4649
|
+
`,wv=Object.freeze(Object.defineProperty({__proto__:null,default:bv},Symbol.toStringTag,{value:"Module"})),kv=`# Related graph (subgraph)
|
|
4616
4650
|
|
|
4617
4651
|
Takes the object selected on the page as the center, follows the configured relation paths to the objects around it, and draws them as a graph. Use it to see what an object connects to, to judge its reach or trace its source.
|
|
4618
4652
|
|
|
@@ -4679,7 +4713,7 @@ None.
|
|
|
4679
4713
|
- 1 to 6 paths; 1 to 50 nodes per path; height 240 to 640.
|
|
4680
4714
|
- One center object at a time.
|
|
4681
4715
|
- Only objects reachable along the paths are shown, not other links between them.
|
|
4682
|
-
`,
|
|
4716
|
+
`,vv=Object.freeze(Object.defineProperty({__proto__:null,default:kv},Symbol.toStringTag,{value:"Module"})),$v=`# 关系子图(subgraph)
|
|
4683
4717
|
|
|
4684
4718
|
以页面上选中的对象为中心,沿配置的关系路径展开它关联的对象,画成一张关系图。用来看一个对象和哪些对象相连,判断影响范围或追溯来源。
|
|
4685
4719
|
|
|
@@ -4746,7 +4780,7 @@ None.
|
|
|
4746
4780
|
- 展开路径 1 到 6 条;每条最多节点 1 到 50;高度 240 到 640。
|
|
4747
4781
|
- 一次只显示一个中心对象。
|
|
4748
4782
|
- 只显示关系路径可达的对象,不显示路径之外的连线。
|
|
4749
|
-
`,
|
|
4783
|
+
`,Sv=Object.freeze(Object.defineProperty({__proto__:null,default:$v},Symbol.toStringTag,{value:"Module"})),jv=`# Task inbox (taskInbox)
|
|
4750
4784
|
|
|
4751
4785
|
Lists the tasks that events were gathered into. Open one to see its events, analyses and handlings, pick a handling choice and record the decision, and run the action bound to that choice when there is one. Use it to decide how a batch of events is handled, by whom, and whether anything is overdue.
|
|
4752
4786
|
|
|
@@ -4860,7 +4894,7 @@ The same as in the event list (\`eventList\`): when the event type has an analys
|
|
|
4860
4894
|
- Each event type has at most 12 handling choices, each at most 40 characters.
|
|
4861
4895
|
- A handling cannot be reverted once its action has run or been accepted on any object.
|
|
4862
4896
|
- Without event types the component asks you to choose some on the "Events" tab.
|
|
4863
|
-
`,
|
|
4897
|
+
`,Av=Object.freeze(Object.defineProperty({__proto__:null,default:jv},Symbol.toStringTag,{value:"Module"})),Tv=`# 任务收件箱(taskInbox)
|
|
4864
4898
|
|
|
4865
4899
|
列出由事件归并成的任务,打开一个任务查看事件、分析与处理,选处理方案并记录决定,必要时直接执行方案绑定的行动。用来做“这批事件怎么处理、谁处理、有没有逾期”的决策。
|
|
4866
4900
|
|
|
@@ -4974,9 +5008,9 @@ The same as in the event list (\`eventList\`): when the event type has an analys
|
|
|
4974
5008
|
- 每个事件类型最多 12 个处理方案,每个方案名不超过 40 字。
|
|
4975
5009
|
- 处理的行动已有对象成功执行或受理后,不能回退。
|
|
4976
5010
|
- 没有事件类型时,组件提示先到“事件”页签选择。
|
|
4977
|
-
`,
|
|
5011
|
+
`,Ov=Object.freeze(Object.defineProperty({__proto__:null,default:Tv},Symbol.toStringTag,{value:"Module"})),Ev=`# Text (text)
|
|
4978
5012
|
|
|
4979
|
-
A passage of text for a page's opening conclusion, section headings and notes. It can name numbers, which follow the page's filters and base date.
|
|
5013
|
+
A passage of text for a page's opening conclusion, section headings and notes, in the Basic group. Picked while building, it is edited right on the page. It can name numbers, which follow the page's filters and base date.
|
|
4980
5014
|
|
|
4981
5015
|
## When to use it and when not
|
|
4982
5016
|
|
|
@@ -4997,6 +5031,9 @@ With text alone and no numbers, the component reads no data.
|
|
|
4997
5031
|
## Built-in checks
|
|
4998
5032
|
|
|
4999
5033
|
- The content is Markdown: headings, bold, lists and links.
|
|
5034
|
+
- Picked while building, the text is typed right on the page; its pick bar has buttons for heading, bold, italic, bulleted and numbered lists, and alignment. It is kept as Markdown when you leave it. Pasting keeps the words only.
|
|
5035
|
+
- A text with a table, image, task list, code or HTML is not edited on the page: change its Markdown in the config.
|
|
5036
|
+
- Alignment (\`align\`): left (the default), center or right, for the whole passage.
|
|
5000
5037
|
- \`{name}\` becomes the number of that name and \`{$asOf}\` the base date; a number not read yet, or not there, reads "—".
|
|
5001
5038
|
- A number is counted as one metric card is: count, sum, average, least, greatest, distinct count or share, over the objects that meet its conditions, or an object metric of the network.
|
|
5002
5039
|
- A number with no decimals set shows a whole number as it is and others to two decimals at most; a share shows as a percentage to one decimal.
|
|
@@ -5047,10 +5084,11 @@ None. The component counts objects of its sources or reads object metrics; it ca
|
|
|
5047
5084
|
## Limits
|
|
5048
5085
|
|
|
5049
5086
|
- Counts only the data read: up to 5000 rows for an object type source, up to 10000 for a Cypher source (1000 when the query has no LIMIT). Object metrics are counted by the platform over every object and are not limited.
|
|
5050
|
-
- Only the layout Markdown itself gives: no font colors or
|
|
5051
|
-
|
|
5087
|
+
- Only the layout Markdown itself gives, and the alignment of the whole passage: no font colors or sizes.
|
|
5088
|
+
- While it is edited on the page, the text shows \`{name}\` itself rather than the number; leave it to see the numbers.
|
|
5089
|
+
`,Cv=Object.freeze(Object.defineProperty({__proto__:null,default:Ev},Symbol.toStringTag,{value:"Module"})),Nv=`# 文本(text)
|
|
5052
5090
|
|
|
5053
|
-
|
|
5091
|
+
一段文字,用来写页面开头的结论、分节标题和说明段落,在「基础」分类里。搭建时选中它就能在页面上直接编辑。正文里可以引用数字,数字跟着页面的筛选和基准日期变。
|
|
5054
5092
|
|
|
5055
5093
|
## 适用与不适用
|
|
5056
5094
|
|
|
@@ -5071,6 +5109,9 @@ None. The component counts objects of its sources or reads object metrics; it ca
|
|
|
5071
5109
|
## 组件内置的判断
|
|
5072
5110
|
|
|
5073
5111
|
- 内容是 Markdown:标题、加粗、列表、链接。
|
|
5112
|
+
- 搭建时选中文本即可在页面上直接输入;选中条上有标题、加粗、斜体、项目符号列表、编号列表和对齐按钮。离开文本时按 Markdown 保存。粘贴只保留文字。
|
|
5113
|
+
- 含表格、图片、任务列表、代码或 HTML 的文本不能在页面上直接编辑,要在配置里改 Markdown。
|
|
5114
|
+
- 对齐(\`align\`):左对齐(默认)、居中、右对齐,对整段文字生效。
|
|
5074
5115
|
- \`{引用名}\` 换成对应的数字,\`{$asOf}\` 换成基准日期;数字还没读到或读不到时显示「—」。
|
|
5075
5116
|
- 数字的统计写法和指标卡的一项相同:计数、求和、平均、最大最小、去重计数、占比,可只算满足条件的对象,也可以取知识网络的对象指标。
|
|
5076
5117
|
- 数字没设小数位时,整数不带小数,其他最多两位;占比显示为百分比、一位小数。
|
|
@@ -5121,8 +5162,9 @@ None. The component counts objects of its sources or reads object metrics; it ca
|
|
|
5121
5162
|
## 限制
|
|
5122
5163
|
|
|
5123
5164
|
- 只统计已读入的数据;对象类数据源最多读 5000 行,Cypher 数据源最多 10000 行(查询没写 LIMIT 时 1000 行)。对象指标由平台按全部对象计算,不受这个限制。
|
|
5124
|
-
- 只支持 Markdown
|
|
5125
|
-
|
|
5165
|
+
- 只支持 Markdown 本身的排版和整段对齐,不支持字体颜色、字号这类设置。
|
|
5166
|
+
- 在页面上直接编辑时,正文里显示 \`{引用名}\` 本身,不显示数字;离开文本后显示数字。
|
|
5167
|
+
`,xv=Object.freeze(Object.defineProperty({__proto__:null,default:Nv},Symbol.toStringTag,{value:"Module"})),Rv=`# Chart (trendChart)
|
|
5126
5168
|
|
|
5127
5169
|
A bar, line or pie chart: see how counts or amounts change over time, or compare sizes across categories; clicking a period or a category makes the whole page look at it only. Use it to answer "how has it gone over the last months" and "which few classes are biggest".
|
|
5128
5170
|
|
|
@@ -5253,7 +5295,7 @@ What counts as a "defect" or as "finished" is decided by the data source and the
|
|
|
5253
5295
|
- At most 6 parts in a split (a status column uses its own values).
|
|
5254
5296
|
- With counting on the page, at most 5000 objects are read per object type data source, and at most 10,000 rows per Cypher data source (1,000 when its query sets no LIMIT); beyond that a note shows above and the figures cover only what was read.
|
|
5255
5297
|
- Actions on click: up to 8 items with up to 5 steps each.
|
|
5256
|
-
`,
|
|
5298
|
+
`,_v=Object.freeze(Object.defineProperty({__proto__:null,default:Rv},Symbol.toStringTag,{value:"Module"})),Pv=`# 图表(trendChart)
|
|
5257
5299
|
|
|
5258
5300
|
柱状图、折线图或饼图:按时间看数量或金额的变化,或按类别比较大小;点一个周期或类别,整页只看它。用来回答“最近几个月走势如何”“哪几类最多”。
|
|
5259
5301
|
|
|
@@ -5384,4 +5426,4 @@ What counts as a "defect" or as "finished" is decided by the data source and the
|
|
|
5384
5426
|
- 拆分最多 6 部分(判断状态列按其自身取值)。
|
|
5385
5427
|
- 页面内统计时,对象类数据源最多读入 5000 个对象,Cypher 数据源最多 10000 行(查询没写 LIMIT 时 1000 行),超过时上方提示,统计只覆盖已读取部分。
|
|
5386
5428
|
- 点击后的动作最多 8 项,每项最多 5 个动作。
|
|
5387
|
-
`,
|
|
5429
|
+
`,Lv=Object.freeze(Object.defineProperty({__proto__:null,default:Pv},Symbol.toStringTag,{value:"Module"}));export{Dw as liveWorkshop,Xv as run};
|