@openbkn/workshop 0.2.2-rc.5 → 0.2.2-rc.6
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 +79 -8
- package/component.d.ts +10 -0
- package/dist/ActionConfirm-DJ91X3ml.js +236 -0
- package/dist/ActionFailure-ZgPt_3B-.js +37 -0
- package/dist/AgentChat-CRYai8ge.js +1062 -0
- package/dist/AppFormModal-D73ucaHK.js +4282 -0
- package/dist/AppListPage-D87piiOw.js +1364 -0
- package/dist/AskDrawer-BUMYsRnt.js +38 -0
- package/dist/ComputedView-CgYrDbx1.js +3221 -0
- package/dist/ConclusionApply-sjGfoEBY.js +153 -0
- package/dist/CypherEditor-lus6FA5L.js +485 -0
- package/dist/LandingList-6JI6864C.js +230 -0
- package/dist/MenuUnfoldOutlined-Cdg24l2h.js +27 -0
- package/dist/ModelTrial-ClHFGTpQ.js +359 -0
- package/dist/PageRenderer-DBd_g6mN.js +85480 -0
- package/dist/README-DjRyTQSR.js +76 -0
- package/dist/ScenarioApply-DtW_hh47.js +590 -0
- package/dist/SimulateForm-C-i08Jjd.js +153 -0
- package/dist/Subgraph-CnrkH9AN.js +32586 -0
- package/dist/WorkshopLabPage-DiVXQL9e.js +11364 -0
- package/dist/WorkshopRunPage-6hjRUf64.js +253 -0
- package/dist/abnfDiagram-WEYOIA3C-beRNhN3c.js +87 -0
- package/dist/action-type-tool.service-B2B74fKC.js +1060 -0
- package/dist/actionButton-DA5CNEzx.js +94 -0
- package/dist/actionButton.en-US-qjeqA7hs.js +94 -0
- package/dist/agentChat-EoDznd58.js +116 -0
- package/dist/agentChat.en-US-B6-pFd9Y.js +116 -0
- package/dist/alertList-DqditwM8.js +84 -0
- package/dist/alertList.en-US-BAXAgltP.js +84 -0
- package/dist/architectureDiagram-ZHVYKT53-DY2l1qxx.js +4779 -0
- package/dist/asOfSlider-QPvHWUMV.js +83 -0
- package/dist/asOfSlider.en-US-BI4jVfSn.js +83 -0
- package/dist/bkn-agent-execution.service-DVh-SHyl.js +205 -0
- package/dist/blockDiagram-RJAE7QA3-DR0mjN2h.js +1435 -0
- package/dist/c4Diagram-XDPPPE54-DH5zsGug.js +1518 -0
- package/dist/channel-B034hcOF.js +5 -0
- package/dist/china-C6m7zXIv.js +9 -0
- package/dist/chunk-2E7WHVMD-Ba3svxgx.js +664 -0
- package/dist/chunk-2Q5K7J3B-rT4eU6_y.js +15 -0
- package/dist/chunk-4EMNKR2T-C1kQZYHK.js +262 -0
- package/dist/chunk-55XCU76K-dcpLOktb.js +68 -0
- package/dist/chunk-5VM5RSS4-BdpQuzmO.js +19 -0
- package/dist/chunk-JWPE2WC7-CDBrSjU7.js +8 -0
- package/dist/chunk-VQ5W62QI-BiVKc40w.js +19 -0
- package/dist/chunk-XXDRQBXY-CPYrcdVW.js +8 -0
- package/dist/chunk-ZCHMQSOR-BG8OLpvb.js +451 -0
- package/dist/classDiagram-v2-4MYWR3UA-DqbpQpwI.js +1564 -0
- package/dist/component.d-DFoMKuUv.js +179 -0
- package/dist/cose-bilkent-JH36ORCC-CdXk4sPf.js +2609 -0
- package/dist/customComponents-DasaZ6pq.js +4 -0
- package/dist/customComponents.en-US-CkabuCXg.js +79 -0
- package/dist/customParseFormat-C0uLEpdq.js +182 -0
- package/dist/cynefin-EF2NZ3EQ-D7MVnMHu.js +21746 -0
- package/dist/cynefinDiagram-WF24UDRP-BYT_KpDL.js +299 -0
- package/dist/cytoscape.esm-BCV9V6aO.js +18760 -0
- package/dist/d3-scale-DA8IHmf0.js +1841 -0
- package/dist/dagre-NK4GIZVX-l-ghPdM8.js +2154 -0
- package/dist/dateRange-BbkLMg8L.js +79 -0
- package/dist/dateRange.en-US-CV12Q02G.js +79 -0
- package/dist/dayjs.min-DZ-YV8Mv.js +284 -0
- package/dist/diagram-CBK3MWTC-Bt3HiwvA.js +542 -0
- package/dist/diagram-I5XIIV2D-DcbqfBjx.js +150 -0
- package/dist/diagram-ODIL2UCW-9PC1n3n5.js +346 -0
- package/dist/diagram-PFBEJUXE-DGhr2kc7.js +478 -0
- package/dist/diagram-RJA3I4VV-DwzpOjZ_.js +219 -0
- package/dist/diagram-TYUNFSNR-B3Bd3TDU.js +2583 -0
- package/dist/dropdownFilter-DOi_8-ZT.js +76 -0
- package/dist/dropdownFilter.en-US-BiXpvXtF.js +76 -0
- package/dist/ebnfDiagram-V4P3TTPT-E5NN2oKc.js +109 -0
- package/dist/elk-QONTBCTQ-dFjcujl_.js +49170 -0
- package/dist/erDiagram-KYQIGQAA-BMrasBzB.js +1061 -0
- package/dist/eventList-CnsAwfDS.js +115 -0
- package/dist/eventList.en-US-Cof3rCLq.js +115 -0
- package/dist/eventReport-XS-HegnH.js +76 -0
- package/dist/eventReport.en-US-DTx4vzWT.js +76 -0
- package/dist/flowDiagram-IUGLLWBU-BGIBH0q0.js +1769 -0
- package/dist/ganttChart-DEeSvTJA.js +77 -0
- package/dist/ganttChart.en-US-SwRKrnoD.js +77 -0
- package/dist/ganttDiagram-R7GPNTJY-C0tb1Lpp.js +1741 -0
- package/dist/generateCypher-Ch9_lQa6.js +399 -0
- package/dist/gitGraphDiagram-PDYL7XHY-DBqcOa-c.js +815 -0
- package/dist/graph-CKJmgLki.js +1541 -0
- package/dist/index-BA-GzCXt.js +441 -0
- package/dist/infoDiagram-MVDRKAX5-Bwuki4JA.js +24 -0
- package/dist/ishikawaDiagram-HPEHV2GE-Dz4d6ygx.js +622 -0
- package/dist/journeyDiagram-BOSHW7O7-C99m34Bb.js +834 -0
- package/dist/kanban-definition-FNSA4HC5-mdqjODsT.js +724 -0
- package/dist/katex-BsrBVQKd.js +11314 -0
- package/dist/manifest-BjV1PJ6u.js +41 -0
- package/dist/mermaid.core-yQghUlIz.js +17642 -0
- package/dist/metricCards-CSb-_cT2.js +104 -0
- package/dist/metricCards.en-US-BLLhRsQU.js +104 -0
- package/dist/mindmap-definition-6OY57UG3-BZhO2wX4.js +834 -0
- package/dist/modelTrial-Bvb-RhGt.js +137 -0
- package/dist/modelTrial.en-US-DYcuor-G.js +137 -0
- package/dist/models-DekiCOuZ.js +6 -0
- package/dist/object-metric-numeric-vs3BeDkH.js +42 -0
- package/dist/object-metric.service-flZgBMRX.js +233 -0
- package/dist/objectDetail-SQUbp4Py.js +117 -0
- package/dist/objectDetail.en-US-DW3mlONM.js +117 -0
- package/dist/objectList-D99wPtJH.js +97 -0
- package/dist/objectList.en-US-PBBNyVLW.js +97 -0
- package/dist/objectTable-0jsFFMN3.js +127 -0
- package/dist/objectTable.en-US-yWEs8qc_.js +127 -0
- package/dist/pegDiagram-ECIUJNBX-BDa5RfZt.js +95 -0
- package/dist/pieDiagram-GNMPY74T-DNVtzXPv.js +165 -0
- package/dist/pivotTable-CHmQw18-.js +102 -0
- package/dist/pivotTable.en-US-B4uv4P08.js +102 -0
- package/dist/prompt-DYrjlEFr.js +373 -0
- package/dist/quadrantDiagram-D57K4MC3-vK0f2OvQ.js +1023 -0
- package/dist/railroadDiagram-Y72NRBL7-j6ZrTmRp.js +77 -0
- package/dist/regionMap-Cme-JyV_.js +128 -0
- package/dist/regionMap.en-US-Bwr2_p32.js +128 -0
- package/dist/requirementDiagram-EQYSW5RA-DgfEyljA.js +886 -0
- package/dist/sankeyDiagram-SY24JHO5-CImx-IX0.js +1160 -0
- package/dist/scenarioBar-BV43p7n-.js +122 -0
- package/dist/scenarioBar.en-US-5KqMQ2Bg.js +122 -0
- package/dist/scheduleGantt-CTYO-zYP.js +180 -0
- package/dist/scheduleGantt.en-US-hE7mvVUW.js +180 -0
- package/dist/searchBox-Ca7w0f_6.js +67 -0
- package/dist/searchBox.en-US-ArS_XBvB.js +67 -0
- package/dist/segmentedFilter-MhjVcWo0.js +80 -0
- package/dist/segmentedFilter.en-US-BxNrQO5T.js +80 -0
- package/dist/sequenceDiagram-BLEHNHQU-nWmjd1ci.js +2969 -0
- package/dist/sizeCapture-INFHLROL-D3jlbt7h.js +46 -0
- package/dist/stageChain-BxBafwjD.js +74 -0
- package/dist/stageChain.en-US-CP0G27n8.js +74 -0
- package/dist/stateDiagram-v2-A6IESKWZ-DG1ZetEu.js +1514 -0
- package/dist/subgraph-7n4SwliR.js +71 -0
- package/dist/subgraph.en-US-BNvY18IW.js +71 -0
- package/dist/swimlanes-B3ENRKFQ-cCmJE8AU.js +4991 -0
- package/dist/swimlanesDiagram-AYQRV4AK-CtuhyguU.js +14 -0
- package/dist/taskInbox-DGWYeI2b.js +118 -0
- package/dist/taskInbox.en-US-B-OzDmVl.js +118 -0
- package/dist/text-BqSVQKS6.js +78 -0
- package/dist/text.en-US-BhAxy_LE.js +78 -0
- package/dist/timeline-definition-JXYKGLGB-Cc-INsOv.js +1057 -0
- package/dist/trendChart-BjEeRS5_.js +135 -0
- package/dist/trendChart.en-US-BBGqWUKM.js +135 -0
- package/dist/useLabData-Df-jEHKs.js +20470 -0
- package/dist/usecaseDiagram-WPOLBNNX-r8wVjopm.js +7920 -0
- package/dist/vennDiagram-Q3Y3IDCW-BZiOcgrj.js +1579 -0
- package/dist/wardleyDiagram-IVAIDKWA-16jd07C_.js +675 -0
- package/dist/workshop-app-DnHNjBqy.js +86038 -0
- package/dist/workshop-app.css +1 -0
- package/dist/workshop-app.js +4 -0
- package/dist/world-Djau1JyJ.js +9 -0
- package/dist/xychartDiagram-4URNHDU4-C8DwWQNh.js +1460 -0
- package/dist-cli/workshop.js +340 -217
- package/example/host.js +109 -0
- package/example/index.html +93 -0
- package/example/server.mjs +237 -0
- package/index.d.ts +48 -0
- package/lib/validate.js +47 -1
- package/package.json +17 -5
- package/runtime/frame-runtime.js +13 -1
- package/workshop-component.js +32 -12
- package/workshop.js +2 -0
package/dist-cli/workshop.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import{execFile as ru,spawn as au}from"node:child_process";import{homedir as iu}from"node:os";import{join as H,extname as Yl,posix as lu,relative as Gl,sep as cu,dirname as $t,resolve as Xe}from"node:path";import{isDeepStrictEqual as du,parseArgs as uu}from"node:util";import{readFileSync as it,readdirSync as Qt,statSync as hu,existsSync as Se,rmSync as dt,mkdirSync as qn,writeFileSync as Hl,rmdirSync as pu,watch as fu,cpSync as So,symlinkSync as mu,lstatSync as Vl,readlinkSync as gu}from"node:fs";import Sr from"process";import yu from"buffer";import{deflateRawSync as bu,inflateRawSync as wu}from"node:zlib";import{createHash as Jl}from"node:crypto";import{request as ku}from"node:http";import{request as vu}from"node:https";function Rt(e){const t=e?.trim().split(/[.@]/)[0];if(!(!t||t==="C"||t==="POSIX"))return/^zh/i.test(t)?"zh-CN":"en-US"}function $u(e,t=process.env){return Rt(e)??Rt(t.WORKSHOP_LANG)??Rt(t.LC_ALL)??Rt(t.LC_MESSAGES)??Rt(t.LANG)??"zh-CN"}function Zl(e,t={}){return e.replace(/\{(\w+)\}/g,(n,o)=>o in t?String(t[o]):n)}let Fn=null;function Su(e){Fn=e}function ju(){return Fn}function et(){if(!Fn)throw new Error("No Workshop host is installed: call installWorkshopHost first.");return Fn}const nt={get:(e,t)=>et().http.get(e,t),delete:(e,t)=>et().http.delete(e,t),post:(e,t,n)=>et().http.post(e,t,n),put:(e,t,n)=>et().http.put(e,t,n)};function Au(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=Au(e,n);if(!o)return;const s=Jr.get(n);if(s?.base===o)return s.value;const r={...o,id:n.id,label:n.label,from:n.from};return Jr.set(n,{base:o,value:r}),r}const Jr=new WeakMap,P=e=>typeof e=="string",Pt=()=>{let e,t;const n=new Promise((o,s)=>{e=o,t=s});return n.resolve=e,n.reject=t,n},Zr=e=>e==null?"":""+e,Tu=(e,t,n)=>{e.forEach(o=>{t[o]&&(n[o]=t[o])})},Ou=/###/g,Xr=e=>e&&e.indexOf("###")>-1?e.replace(Ou,"."):e,Qr=e=>!e||P(e),Kt=(e,t,n)=>{const o=P(t)?t.split("."):t;let s=0;for(;s<o.length-1;){if(Qr(e))return{};const r=Xr(o[s]);!e[r]&&n&&(e[r]=new n),Object.prototype.hasOwnProperty.call(e,r)?e=e[r]:e={},++s}return Qr(e)?{}:{obj:e,k:Xr(o[s])}},ea=(e,t,n)=>{const{obj:o,k:s}=Kt(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=Kt(e,a,Object);for(;l.obj===void 0&&a.length;)r=`${a[a.length-1]}.${r}`,a=a.slice(0,a.length-1),l=Kt(e,a,Object),l?.obj&&typeof l.obj[`${l.k}.${r}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${r}`]=n},Eu=(e,t,n,o)=>{const{obj:s,k:r}=Kt(e,t,Object);s[r]=s[r]||[],s[r].push(n)},Dn=(e,t)=>{const{obj:n,k:o}=Kt(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,o))return n[o]},Cu=(e,t,n)=>{const o=Dn(e,n);return o!==void 0?o:Dn(t,n)},Xl=(e,t,n)=>{for(const o in t)o!=="__proto__"&&o!=="constructor"&&(o in e?P(e[o])||e[o]instanceof String||P(t[o])||t[o]instanceof String?n&&(e[o]=t[o]):Xl(e[o],t[o],n):e[o]=t[o]);return e},ot=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Nu={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const xu=e=>P(e)?e.replace(/[&<>"'\/]/g,t=>Nu[t]):e;class Ru{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 Pu=[" ",",","?","!",";"],Lu=new Ru(20),_u=(e,t,n)=>{t=t||"",n=n||"";const o=Pu.filter(a=>t.indexOf(a)<0&&n.indexOf(a)<0);if(o.length===0)return!0;const s=Lu.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},Ps=(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"].indexOf(typeof a)>-1&&c<o.length-1)continue;r+=c-r+1;break}s=a}return s},en=e=>e?.replace(/_/g,"-"),Iu={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 Bn{constructor(t,n={}){this.init(t,n)}init(t,n={}){this.prefix=n.prefix||"i18next:",this.logger=t||Iu,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:(P(t[0])&&(t[0]=`${o}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new Bn(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new Bn(this.logger,t)}}var Fe=new Bn;class no{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)}}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.apply(s,[t,...n])})}}class ta extends no{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.indexOf(t)<0&&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.indexOf(".")>-1?l=t.split("."):(l=[t,n],o&&(Array.isArray(o)?l.push(...o):P(o)&&r?l.push(...o.split(r)):l.push(o)));const c=Dn(this.data,l);return!c&&!n&&!o&&t.indexOf(".")>-1&&(t=l[0],n=l[1],o=l.slice(2).join(".")),c||!a||!P(o)?c:Ps(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.indexOf(".")>-1&&(l=t.split("."),s=n,n=l[1]),this.addNamespaces(n),ea(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)(P(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.indexOf(".")>-1&&(l=t.split("."),s=o,o=n,n=l[1]),this.addNamespaces(n);let c=Dn(this.data,l)||{};a.skipCopy||(o=JSON.parse(JSON.stringify(o))),s?Xl(c,o,r):c={...c,...o},ea(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 Ql={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 ec=Symbol("i18next/PATH_KEY");function Mu(){const e=[],t=Object.create(null);let n;return t.get=(o,s)=>(n?.revoke?.(),s===ec?e:(e.push(s),n=Proxy.revocable(o,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function St(e,t){const{[ec]:n}=e(Mu()),o=t?.keySeparator??".",s=t?.nsSeparator??":";if(n.length>1&&s){const r=t?.ns,a=Array.isArray(r)?r:null;if(a&&a.length>1&&a.slice(1).includes(n[0]))return`${n[0]}${s}${n.slice(1).join(o)}`}return n.join(o)}const na={},jo=e=>!P(e)&&typeof e!="boolean"&&typeof e!="number";class Un extends no{constructor(t,n={}){super(),Tu(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Fe.create("translator")}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=jo(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.indexOf(o)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!_u(t,o,s);if(a&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:P(r)?[r]:r};const i=t.split(o);(o!==s||o===s&&this.options.ns.indexOf(i[0])>-1)&&(r=i.shift()),t=i.join(s)}return{key:t,namespaces:P(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=St(t,{...this.options,...s})),Array.isArray(t)||(t=[String(t)]),t=t.map(M=>typeof M=="function"?St(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&&!P(s.count),v=Un.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=jo(E),I=Object.prototype.toString.apply(E);if(k&&E&&x&&y.indexOf(I)<0&&!(P(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),_=M?[]:{},ne=M?g:m;for(const q in E)if(Object.prototype.hasOwnProperty.call(E,q)){const N=`${ne}${a}${q}`;v&&!f?_[q]=this.translate(N,{...s,defaultValue:jo(A)?A[q]:void 0,joinArrays:!1,ns:c}):_[q]=this.translate(N,{...s,joinArrays:!1,ns:c}),_[q]===N&&(_[q]=E[q])}f=_}}else if(k&&P(b)&&Array.isArray(f))f=f.join(b),f&&(f=this.extendTranslation(f,t,s,o));else{let M=!1,_=!1;!this.isValidLookup(f)&&v&&(M=!0,f=A),this.isValidLookup(f)||(_=!0,f=l);const q=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&_?void 0:f,N=v&&A!==f&&this.options.updateMissing;if(_||M||N){if(this.logger.log(N?"updateKey":"missingKey",h,i,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.indexOf(`${this.options.pluralSeparator}zero`)<0&&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),_&&f===l&&this.options.appendNamespaceToMissingKey&&(f=`${i}${d}${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=P(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&&!P(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=P(a)?[a]:a;return t!=null&&l?.length&&o.applyPostProcessor!==!1&&(t=Ql.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 P(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(c=>typeof c=="function"?St(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&&!P(n.count),p=u&&!n.ordinal&&n.count===0,f=n.context!==void 0&&(P(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,!na[`${m[0]}-${g}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(na[`${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.indexOf(S)===0&&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.indexOf(S)===0&&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&&!P(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)&&n===o.substring(0,n.length)&&t[o]!==void 0)return!0;return!1}}class oa{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Fe.create("languageUtils")}getScriptPartFromCode(t){if(t=en(t),!t||t.indexOf("-")<0)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=en(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(P(t)&&t.indexOf("-")>-1){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.indexOf(t)>-1}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=>{if(a===r)return a;if(!(a.indexOf("-")<0&&r.indexOf("-")<0)&&(a.indexOf("-")>0&&r.indexOf("-")<0&&a.substring(0,a.indexOf("-"))===r||a.indexOf(r)===0&&r.length>1))return a})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),P(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 P(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(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))):P(t)&&r(this.formatLanguageCode(t)),o.forEach(a=>{s.indexOf(a)<0&&r(this.formatLanguageCode(a))}),s}}const sa={zero:0,one:1,two:2,few:3,many:4,other:5},ra={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class qu{constructor(t,n={}){this.languageUtils=t,this.options=n,this.logger=Fe.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(t,n={}){const o=en(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!"),ra;if(!t.match(/-|_/))return ra;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)=>sa[s]-sa[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 aa=(e,t,n,o=".",s=!0)=>{let r=Cu(e,t,n);return!r&&s&&P(n)&&(r=Ps(e,n,o),r===void 0&&(r=Ps(t,n,o))),r},Ao=e=>e.replace(/\$/g,"$$$$");class ia{constructor(t={}){this.logger=Fe.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:xu,this.escapeValue=o!==void 0?o:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=r?ot(r):a||"{{",this.suffix=l?ot(l):c||"}}",this.formatSeparator=i||",",this.unescapePrefix=d?"":h||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=u?ot(u):p||ot("$t("),this.nestingSuffix=f?ot(f):m||ot(")"),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.indexOf(this.formatSeparator)<0){const y=aa(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(aa(n,c,m,this.options.keySeparator,this.options.ignoreJSONStructure),g,o,{...s,...n,interpolationkey:m})};this.resetRegExp();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=>Ao(p)},{regex:this.regexp,safeValue:p=>this.escapeValue?Ao(this.escape(p)):Ao(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=P(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!P(a)&&!this.useRawValueToEscape&&(a=Zr(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.indexOf(d)<0)return c;const h=c.split(new RegExp(`${ot(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.indexOf(this.prefix)>-1&&delete a.defaultValue,c};for(;s=this.nestingRegexp.exec(t);){let c=[];a={...o},a=a.replace&&!P(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&&!P(r))return r;P(r)||(r=Zr(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 Fu=e=>{let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const o=e.split("(");t=o[0].toLowerCase().trim();const s=o[1].substring(0,o[1].length-1);t==="currency"&&s.indexOf(":")<0?n.currency||(n.currency=s.trim()):t==="relativetime"&&s.indexOf(":")<0?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}},la=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(en(o),s),t[a]=l),l(n)}},Du=e=>(t,n,o)=>e(en(n),o)(t);class Bu{constructor(t={}){this.logger=Fe.create("formatter"),this.options=t,this.init(t)}init(t,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const o=n.cacheInBuiltFormats?la:Du;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()]=la(n)}format(t,n,o,s={}){const r=n.split(this.formatSeparator);if(r.length>1&&r[0].indexOf("(")>1&&r[0].indexOf(")")<0&&r.find(l=>l.indexOf(")")>-1)){const l=r.findIndex(c=>c.indexOf(")")>-1);r[0]=[r[0],...r.splice(1,l)].join(this.formatSeparator)}return r.reduce((l,c)=>{const{formatName:i,formatOptions:d}=Fu(c);if(this.formats[i]){let h=l;try{const u=s?.formatParams?.[s.interpolationkey]||{},p=u.locale||u.lng||s.locale||s.lng||o;h=this.formats[i](l,p,{...d,...s,...u})}catch(u){this.logger.warn(u)}return h}else this.logger.warn(`there was no format function for ${i}`);return l},t)}}const Uu=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class zu extends no{constructor(t,n,o,s={}){super(),this.backend=t,this.store=n,this.services=o,this.languageUtils=o.languageUtils,this.options=s,this.logger=Fe.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=>{Eu(c.loaded,[r],a),Uu(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.call(this,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();P(t)&&(t=this.languageUtils.toResolveHierarchy(t)),P(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 To=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",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]),P(e[1])&&(t.defaultValue=e[1]),P(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,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),ca=e=>(P(e.ns)&&(e.ns=[e.ns]),P(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),P(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),typeof e.initImmediate=="boolean"&&(e.initAsync=e.initImmediate),e),gn=()=>{},Wu=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})},tc="__i18next_supportNoticeShown",Ku=()=>!!(typeof globalThis<"u"&&globalThis[tc]||typeof process<"u"&&process.env&&process.env.I18NEXT_NO_SUPPORT_NOTICE||typeof process<"u"&&process.env),Yu=()=>{typeof globalThis<"u"&&(globalThis[tc]=!0)},Gu=e=>!!(e?.modules?.backend?.name?.indexOf("Locize")>0||e?.modules?.backend?.constructor?.name?.indexOf("Locize")>0||e?.options?.backend?.backends&&e.options.backend.backends.some(t=>t?.name?.indexOf("Locize")>0||t?.constructor?.name?.indexOf("Locize")>0)||e?.options?.backend?.projectId||e?.options?.backend?.backendOptions&&e.options.backend.backendOptions.some(t=>t?.projectId));class Yt extends no{constructor(t={},n){if(super(),this.options=ca(t),this.services={},this.logger=Fe,this.modules={external:[]},Wu(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&&(P(t.ns)?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));const o=To();this.options={...o,...this.options,...ca(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),this.options.showSupportNotice!==!1&&!Gu(this)&&!Ku()&&(typeof console<"u"&&typeof console.info<"u"&&console.info("🌐 i18next is made possible by our own product, Locize — consider powering your project with managed localization (AI, CDN, integrations): https://locize.com 💙"),Yu());const s=i=>i?typeof i=="function"?new i:i:null;if(!this.options.isClone){this.modules.logger?Fe.init(s(this.modules.logger),this.options):Fe.init(null,this.options);let i;this.modules.formatter?i=this.modules.formatter:i=Bu;const d=new oa(this.options);this.store=new ta(this.options.resources,this.options);const h=this.services;h.logger=Fe,h.resourceStore=this.store,h.languageUtils=d,h.pluralResolver=new qu(d,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==o.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),i&&(!this.options.interpolation.format||this.options.interpolation.format===o.interpolation.format)&&(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 ia(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("*",(p,...f)=>{this.emit(p,...f)}),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 Un(this.services,this.options),this.translator.on("*",(p,...f)=>{this.emit(p,...f)}),this.modules.external.forEach(p=>{p.init&&p.init(this)})}if(this.format=this.options.interpolation.format,n||(n=gn),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=Pt(),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.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=gn){let o=n;const s=P(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.indexOf(i)<0&&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=Pt();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=gn),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"&&Ql.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"].indexOf(t)>-1)){for(let n=0;n<this.languages.length;n++){const o=this.languages[n];if(!(["cimode","dev"].indexOf(o)>-1)&&this.store.hasLanguageSomeTranslations(o)){this.resolvedLanguage=o;break}}!this.resolvedLanguage&&this.languages.indexOf(t)<0&&this.store.hasLanguageSomeTranslations(t)&&(this.resolvedLanguage=t,this.languages.unshift(t))}}changeLanguage(t,n){this.isLanguageChangingTo=t;const o=Pt();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=P(l)?l:l&&l[0],i=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(P(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){const s=(r,a,...l)=>{let c;typeof a!="object"?c=this.options.overloadTranslationOptionHandler([r,a].concat(l)):c={...a},c.lng=c.lng||s.lng,c.lngs=c.lngs||s.lngs,c.ns=c.ns||s.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||o||s.keyPrefix);const i={...this.options,...c};typeof c.keyPrefix=="function"&&(c.keyPrefix=St(c.keyPrefix,i));const d=this.options.keySeparator||".";let h;return c.keyPrefix&&Array.isArray(r)?h=r.map(u=>(typeof u=="function"&&(u=St(u,i)),`${c.keyPrefix}${d}${u}`)):(typeof r=="function"&&(r=St(r,i)),h=c.keyPrefix?`${c.keyPrefix}${d}${r}`:r),this.t(h,c)};return P(t)?s.lng=t:s.lngs=t,s.ns=n,s.keyPrefix=o,s}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=Pt();return this.options.ns?(P(t)&&(t=[t]),t.forEach(s=>{this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}),this.loadResources(s=>{o.resolve(),n&&n(s)}),o):(n&&n(),Promise.resolve())}loadLanguages(t,n){const o=Pt();P(t)&&(t=[t]);const s=this.options.preload||[],r=t.filter(a=>s.indexOf(a)<0&&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 oa(To());return t.toLowerCase().indexOf("-latn")>1?"ltr":n.indexOf(o.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(t={},n){const o=new Yt(t,n);return o.createInstance=Yt.createInstance,o}cloneInstance(t={},n=gn){const o=t.forkResourceStore;o&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},r=new Yt(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 ta(l,s),r.services.resourceStore=r.store}if(t.interpolation){const c={...To().interpolation,...this.options.interpolation,...t.interpolation},i={...s,interpolation:c};r.services.interpolator=new ia(i)}return r.translator=new Un(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=Yt.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 nc=ge;function Hu(e){nc=e}function Vu(){const e=nc.language;return e&&!e.startsWith("zh")?"en-US":"zh-CN"}function fe(e){return e[Vu()]}const Ju={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||"未绑定的对象")},和数据源的对象类不同`},Zu={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`},jr=()=>fe({"zh-CN":Ju,"en-US":Zu}),Ls=100;function sn(e,t){return e.actionTypes?.find(n=>n.id===t)}function zn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Xu(e,t,n,o,s){const r=jr();if(e===void 0||e==="hit")return t?[]:[r.hitNeeds(s)];if(!zn(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 Qu(e,t,n,o){const s=jr();if(e!==void 0&&!zn(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(!zn(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 oc(e,t,n,o,s){const r=jr();if(!zn(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>Ls)&&l.push(r.maxObjects(`${s}.maxObjects`,Ls)),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=sn(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(...Xu(e.targets,t.hit,n.spec,c.objectType,`${s}.targets`)),l.push(...Qu(e.params,d,n.spec,`${s}.params`)),l):[...l,r.notAction(`${s}.action`,e.action)]}const _s=["workbench","dashboard","detail","free"],sc={workbench:["side","main","aside"],dashboard:["header","grid"],detail:["header","main","aside"],free:["cells"]},yn=12,Ke=["asOfSlider","dateRange","metricCards","segmentedFilter","dropdownFilter","searchBox","objectTable","objectList","pivotTable","trendChart","regionMap","ganttChart","scheduleGantt","stageChain","subgraph","agentChat","alertList","eventList","eventReport","taskInbox","actionButton","scenarioBar","modelTrial"],Ar=new Set(["taskInbox"]),eh=/^x-[a-z0-9-]+\.[A-Za-z][A-Za-z0-9]*$/,Ot=e=>typeof e=="string"&&eh.test(e),rc={asOfSlider:[4,2],dateRange:[3,2],metricCards:[4,3],segmentedFilter:[3,2],dropdownFilter:[3,2],searchBox:[3,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]},th=8,nh=5,me="objectDetail",Tr=12,Is=["none","subtle","strong"],Ms=["compact","comfortable"],Et=["neutral","info","success","warning","danger"],he="$asOf",Wn=["isSet","isEmpty","eq","ne","in","before","onOrBefore","after","onOrAfter","gt","gte","lt","lte"],Gt=["classify","days","formula","related","region","text","matched"],da=["china","world"],qs=["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"}},Fs=6,ua=4,rn="$scenarioMark",Pn={edited:{value:"edited",label:"改动",tone:"warning"},followed:{value:"followed",label:"联动",tone:"info"},related:{value:"related",label:"相关",tone:"neutral"}},Ds=["shiftDays","add","set","fromAsOf"],Bs=["scenario","user"],Kn=["asOf","value","dateRange","search","selection","set"],ha=["value","dateRange","search","set"],oh=["P1","P2","P3","P4"],Us=["text","number","date"],zs=["none","property","batch"],pa=/(^|_)(id|key|code|no)$/i,sh=/(主键|编号|编码|单号|单据号|代码|\bID\b|\bNo\.?$)/i;function fa(e,t){const n=e.filter(o=>o.type==="text"&&!t?.primaryKeys.includes(o.name));return n.find(o=>o.name!==t?.displayKey&&!pa.test(o.name)&&!sh.test(o.label))??n.find(o=>o.name!==t?.displayKey&&!pa.test(o.name))??n[0]}function Oo(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 oo(e){return e.operation==="tool"?"tool":e.operation==="relation"?"relation":e.kind==="add"?"create":"modify"}const rh=new Set(["date","datetime","timestamp"]),ah=new Set(["integer","unsigned integer","float","decimal","int","long","short","double","bigint","smallint","tinyint","number","numeric","real"]),ih=new Set(["binary","vector","shape","point"]);function lh(e){const t=e.toLowerCase().replace(/\s+/g," ").trim();return rh.has(t)?"date":ah.has(t)?"number":"text"}function ch(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 Or(e){return{name:e.name,label:e.label,type:ch(e)}}function ac(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 dh(e){return!!(e.operations?.length||e.follows?.length||e.relatedTo?.length)}const uh={name:rn,label:"方案标记",type:"text"};function pe(e,t){return[...t.objectTypes[e.objectType]?.properties??[],...ac(e.progress),...(e.computed??[]).map(Or),...dh(e)?[uh]:[]]}const ma="~";function hh(e){return e.startsWith(ma)?{id:e.slice(ma.length),reversed:!0}:{id:e,reversed:!1}}function so(e,t,n){const o=[];let s=t;for(const r of n){const{id:a,reversed:l}=hh(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 ph(e,t,n){const o=so(e,t,n);return o?[t,...o.map(s=>s.to)].map(s=>e.objectTypes[s]?.name??s).join(" → "):n.join(" → ")}const fh={unknown:(e,t)=>`第 ${e} 个字符“${t}”无法识别`,empty:"公式是空的",unfinished:"公式没写完",unclosed:e=>`第 ${e} 个字符的括号没有闭合`,missing:(e,t)=>`第 ${e} 个字符“${t}”前缺少数字或字段`,extra:(e,t)=>`第 ${e} 个字符“${t}”多余`},mh={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`},ic=()=>fe({"zh-CN":fh,"en-US":mh}),ga=/(\d+(?:\.\d+)?)|(\$?[A-Za-z_][A-Za-z0-9_]*)|`([^`]+)`|([-+*/()])/y;function gh(e){const t=ic(),n=[];let o=0;for(;o<e.length;){if(/\s/.test(e[o])){o++;continue}ga.lastIndex=o;const s=ga.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 lc(e){const t=ic(),n=gh(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 Ht(e){switch(e.type){case"number":return[];case"field":return[e.name];case"negate":return Ht(e.arg);case"binary":return[...Ht(e.left),...Ht(e.right)]}}const yh={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}`},bh={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}`},Ge=()=>fe({"zh-CN":yh,"en-US":bh}),wh=/^[A-Za-z][A-Za-z0-9_]*$/,kh=/^\d{4}-\d{2}-\d{2}$/,vh=["before","onOrBefore","after","onOrAfter"],$h=["gt","gte","lt","lte"],cc=()=>[];function ya(e,t,n,o){const s=n(e);if(s.length===0)return[];const r=Ge();return t.filter(a=>typeof a=="string"&&!s.includes(a)).map(a=>r.valueNotTaken(o,String(a),e,s.join(r.sep)))}function Sh(e,t,n,o=cc){const s=Ge();if(!$e(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(!Ct(e.op,Wn))return[s.opOneOf(n,Wn.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")?ya(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))]:vh.includes(l)?a!=="date"?[s.needDateField(n,l)]:(c?i==="date":typeof e.value=="string"&&kh.test(e.value))?[]:[s.otherDate(n,l,he)]:$h.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)]:ya(String(e.field),[e.value],o,`${n}.value`)}function Ce(e,t,n,o=cc){return Array.isArray(e)?e.flatMap((s,r)=>Sh(s,t,`${n}[${r}]`,o)):[Ge().conditionList(n)]}function dc(e,t=!1){return n=>{if(t&&n===le.status)return pc.map(s=>s.value);if(n===rn)return _h.map(s=>s.value);const o=e.find(s=>$e(s)&&s.name===n&&s.kind==="classify"&&Array.isArray(s.cases)&&$e(s.otherwise));return o?[...o.cases,o.otherwise].map(s=>$e(s)?s.value:void 0).filter(s=>typeof s=="string"):[]}}const Ws=e=>(e??[]).flatMap(t=>[t.field,t.ref].filter(n=>typeof n=="string"&&n!==he)),jh=/\{([^{}]+)\}/g;function uc(e){return[...new Set([...e.matchAll(jh)].map(t=>t[1].trim()))]}function Er(e){switch(e.kind){case"classify":return e.cases.flatMap(t=>Ws(t.when));case"days":return[e.from,e.to,...Ws(e.when)].filter(t=>t!==he);case"formula":{const t=lc(e.expr);return t.ok?Ht(t.node):[]}case"related":return[];case"matched":return[];case"region":return[e.from];case"text":return uc(e.template)}}function Ah(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=>Er(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 Th(e){const t=Ah(e),n=new Set(e.map(r=>r.name)),o=new Set,s=[];for(const r of t)Er(r).some(a=>n.has(a)&&!o.has(a))&&s.push(r.name),o.add(r.name);return s}function hc(e){return Array.isArray(e)?e.filter(t=>$e(t)&&typeof t.name=="string"&&Ct(t.kind,Gt)):[]}function Oh(e){try{return Er(e)??[]}catch{return[]}}const Eo=e=>typeof e=="string"&&e!==""?[e]:[];function Eh(e){const t=h=>e.find(u=>u.id===h)?.from?.source??h,n=h=>hc(h.computed),o=e.filter(h=>$e(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=>$e(y)):[];f=[...a(h.id,g.flatMap(y=>Eo(y?.field))),...a(m,[...g.flatMap(y=>Eo(y?.other)),...Eo(u.field),...Ws(Array.isArray(u.where)?u.where.filter(y=>$e(y)):void 0)])]}else f=a(h.id,Oh(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 Ch=new Set([...Object.values(le),rn]);function Nh(e,t,n,o){if(e===void 0)return[];const s=Ge();if(!Array.isArray(e))return[s.array(n)];const r=[],a=dc(e,o.progress),l=e.filter(d=>$e(d)&&typeof d.name=="string"&&Ct(d.kind,Gt)),c=new Set;e.forEach((d,h)=>{const u=`${n}[${h}]`;if(!$e(d))return r.push(s.object(u));if(typeof d.name!="string"||!wh.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(Ch.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`)),!Ct(d.kind,Gt))return r.push(s.kindOneOf(u,Gt.join(s.sep)));const p=l.filter(f=>f.name!==d.name).map(Or);r.push(...Rh(d,[...t,...p],u,a,o))});const i=Th(l);return i.length>0?r.push(s.cycle(n,i.join(s.sep))):o.sources&&o.source&&r.push(...xh(n,o)),r}function xh(e,t){const n=Ge(),o=t.sources??[],{stuck:s}=Eh(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 Rh(e,t,n,o,s){const r=Ge(),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(...ba(c,d)),$e(c)&&l.push(...Ce(c.when,t,`${d}.when`,o))}):l.push(r.array(`${n}.cases`)),l.push(...ba(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?[]:Ce(e.when,t,`${n}.when`,o)];case"formula":{if(typeof e.expr!="string")return[r.exprText(n)];const l=lc(e.expr);return l.ok?[...new Set(Ht(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 Ph(e,n,s);case"matched":return Lh(e,n,s,t);case"text":{if(typeof e.template!="string"||e.template.trim()==="")return[r.templateText(n)];const l=uc(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||da.includes(e.scope)?[]:[r.scopeOneOf(n,da.join(r.sep))]]}}function Ph(e,t,{kn:n,objectType:o,cypher:s}){const r=Ge();if(s)return[r.relatedCypher(t)];if(!Array.isArray(e.path)||e.path.length===0)return[r.pathNeeded(t)];const a=so(n,o,e.path);if(!a)return[r.pathUnreachable(t,o)];const l=n.objectTypes[a[a.length-1].to],c=l?.properties??[];if(!Ct(e.aggregate,qs))return[r.aggregateOneOf(t,qs.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(...Ce(e.where,c,`${t}.where`)),Array.isArray(e.where)&&e.where.some(h=>$e(h)&&(h.ref!==void 0||h.field===he))&&i.push(r.whereFixed(t))),i}function Lh(e,t,{kn:n,objectType:o,cypher:s,sources:r},a){const l=Ge();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??[],...hc(c.computed).map(Or)]: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 $e(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(...Ce(e.where,i,`${t}.where`)),d}function ba(e,t){const n=Ge();return $e(e)?[...typeof e.value=="string"&&e.value.trim()!==""?[]:[n.valueText(t)],...e.tone===void 0||Ct(e.tone,Et)?[]:[n.toneOneOf(t,Et.join(n.sep))]]:[n.object(t)]}const pc=[re.done,re.overdue,re.active],_h=[Pn.edited,Pn.followed,Pn.related];function an(e){return dc(e?.computed??[],!!e?.progress)}function Ih(e){return e?e.progress?!0:JSON.stringify(e.computed??[]).includes(`"${he}"`):!1}const Mh=`计算列(sources[].computed,可选):浏览器为数据源的每行算出的列;组件、筛选像普通属性一样用它们。计算列可以读数据源的属性、进度列和其他计算列,系统按依赖自动排顺序,不能互相引用成环。每项 { name, label, kind, ... },name 为字母开头的标识,不得与属性或进度列重名:
|
|
2
|
-
- classify(判断状态){ cases: [{ when: [条件…], value, tone? }], otherwise: { value, tone? } }:从上往下取第一条全部条件成立的 value,都不成立取 otherwise;tone 为 ${
|
|
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 为字母开头的标识,不得与属性或进度列重名:
|
|
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 时为空。
|
|
5
5
|
- related(读关联数据){ path, aggregate, field?, type?, where? }:沿关系路径(关系 id 列表,从数据源的对象类出发,可反向经过关系)读到达的对象:aggregate 为 count(计数)、sum(求和)、avg(平均)、min、max(对终点对象类的数字属性 field);one 取到达对象的属性 field 作为本行的一个值(一对一的关系,如订单的客户名称;到达多个时取第一个),须写 type 为该属性的类型(date/number/text);list 把到达的每个对象的属性 field 列出来(文本,顿号连接,最多 10 个)。where 为对终点对象属性的条件,只能和固定值比较。随数据一起读取,不随基准日期变化;Cypher 数据源不能用。要在表格里显示关联对象的名称,用 one。
|
|
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 $e(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ct(e,t){return typeof e=="string"&&t.includes(e)}const qh={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}`},Fh={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}`},ro=()=>fe({"zh-CN":qh,"en-US":Fh}),fc=/^[A-Za-z][A-Za-z0-9_]*$/,Dh=["number","date","text"],Bh=["number","date","datetime","text"],Ks=10,Yn=5,Ys=5,st=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Uh(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 mc(e,t,n=Dh){const o=ro(),s=[],r=new Map;return!Array.isArray(e)||e.length===0||e.length>Yn?{errors:[o.paramsCount(t,Yn)],types:r}:(e.forEach((a,l)=>{const c=`${t}[${l}]`;return st(a)?(typeof a.name!="string"||!fc.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 zh(e,t,n,o){const s=ro();if(!Array.isArray(e)||e.length>Ks)return[s.operationsList(o,Ks)];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(!st(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"||!fc.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(...Ce(i.when,l,`${h}.when`,an(t)));const p=mc(i.params,`${h}.params`,Bh);u.push(...p.errors);const f=p.types,m=Wh(i,n),g=Array.isArray(i.effects)?i.effects:null;if(!g||g.length===0&&!m||g.length>Ys?u.push(s.effectsCount(`${h}.effects`,m?0:1,Ys)):g.forEach((y,b)=>{const k=`${h}.effects[${b}]`;if(!st(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(!Ds.includes(y.kind))return u.push(s.kindOneOf(`${k}.kind`,Ds));const v=Uh(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=st(i.action)?i.action:null,b=y&&typeof y.id=="string"?sn(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&&oo(b)!=="create"&&u.push(s.actionOn(`${h}.action.id`,t.objectType)):u.push(s.notActionType(`${h}.action.id`)),b&&y.params!==void 0)if(!st(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)?st(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"&&!Bs.includes(w.name)?u.push(s.contextOneOf(`${v}.name`,Bs)):["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(...Kh(y,b,n,h))}}return u})}function Wh(e,t){const n=st(e.action)?e.action:null,o=n?sn(t,n.id):void 0;return o!==void 0&&oo(o)==="create"}function Kh(e,t,n,o){if(e.unique===void 0&&e.active===void 0)return[];const s=ro();if(oo(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(...Ce(e.active,r,`${o}.action.active`)),a}const wa=e=>e?.type==="date"||e?.type==="datetime";function ka(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 Yh(e,t){const n=c=>typeof c=="string"&&c!==""?c:void 0,o=n(t.startField),s=n(t.endField),r=ro();if(!o||!s)return r.adjustNeedsLayer();if(!wa(ka(e,o))||!wa(ka(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 Gh={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`},Hh={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`},va=()=>fe({"zh-CN":Gh,"en-US":Hh}),$a=/^[A-Za-z][A-Za-z0-9_]*$/,Co=["number","date","text"],Gs=["count","sum","avg","min","max","ratio"],Hs=5,Vs=20,Js=8,Zs=8,Ve=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Vh(e,t,n,o){if(!Array.isArray(e)||e.length>Hs)return[va().list(o,Hs)];const s=va(),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(!Ve(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"||!$a.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=Ve(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>Vs?u.push(s.inputsCount(`${h}.inputs`,Vs)):f.forEach((w,v)=>{(typeof w!="string"||!a.has(w))&&u.push(s.inputField(`${h}.inputs[${v}]`))});const m=mc(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>Js?u.push(s.outputsCount(`${h}.outputs`,Js)):g.forEach((w,v)=>{const S=`${h}.outputs[${v}]`;return Ve(w)?(typeof w.name!="string"||!$a.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`)),Co.includes(w.type)||u.push(s.oneOf(`${S}.type`,Co.join(s.joiner))),u):u.push(s.object(S))});const b=[...r,...(g??[]).filter(Ve).map(w=>({name:String(w.name),label:String(w.label),type:Co.includes(w.type)?w.type:"text"}))],k=Array.isArray(i.measures)?i.measures:null;if(!k||k.length===0||k.length>Zs?u.push(s.measuresCount(`${h}.measures`,Zs)):k.forEach((w,v)=>{const S=`${h}.measures[${v}]`;if(!Ve(w))return u.push(s.object(S));if((typeof w.label!="string"||!w.label.trim())&&u.push(s.required(`${S}.label`)),Gs.includes(w.aggregate)||u.push(s.oneOf(`${S}.aggregate`,Gs.join(s.joiner))),w.when!==void 0&&u.push(...Ce(w.when,b,`${S}.when`,an(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=Ve(i.action)?i.action:null,v=w&&typeof w.id=="string"?sn(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(!Ve(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)?Ve(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 Jh=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"]}]`),Zh=["北京","天津","河北","山西","内蒙古","辽宁","吉林","黑龙江","上海","江苏","浙江","安徽","福建","江西","山东","河南","湖北","湖南","广东","广西","海南","重庆","四川","贵州","云南","西藏","陕西","甘肃","青海","宁夏","新疆","台湾","香港","澳门"],Xh={河北:"石家庄 唐山 保定 邯郸 秦皇岛 廊坊 沧州 邢台 张家口 承德 衡水",山西:"太原 大同 长治 晋城 运城 临汾",内蒙古:"呼和浩特 包头 鄂尔多斯 赤峰",辽宁:"沈阳 大连 鞍山 抚顺 锦州 营口 丹东",吉林:"长春 四平 延吉",黑龙江:"哈尔滨 齐齐哈尔 大庆 牡丹江 佳木斯",江苏:"南京 苏州 无锡 常州 南通 徐州 扬州 镇江 盐城 泰州 连云港 淮安 宿迁 昆山 江阴",浙江:"杭州 宁波 温州 绍兴 嘉兴 金华 台州 湖州 义乌",安徽:"合肥 芜湖 蚌埠 马鞍山 安庆",福建:"福州 厦门 泉州 漳州 莆田",江西:"南昌 赣州 九江 景德镇",山东:"济南 青岛 烟台 潍坊 淄博 威海 临沂 济宁 泰安 日照 东营",河南:"郑州 洛阳 开封 新乡 南阳 许昌 安阳",湖北:"武汉 宜昌 襄阳 十堰 荆州 黄石",湖南:"长沙 株洲 湘潭 衡阳 岳阳 常德",广东:"广州 深圳 东莞 佛山 珠海 中山 惠州 汕头 江门 湛江 肇庆",广西:"南宁 柳州 桂林 北海",海南:"海口 三亚",四川:"成都 绵阳 德阳 宜宾 南充 泸州",贵州:"贵阳 遵义",云南:"昆明 大理 曲靖 玉溪",西藏:"拉萨",陕西:"西安 宝鸡 咸阳 榆林 延安 汉中",甘肃:"兰州 天水",青海:"西宁",宁夏:"银川",新疆:"乌鲁木齐 克拉玛依 喀什"};[...Zh.map(e=>[e,e]),...Object.entries(Xh).flatMap(([e,t])=>t.split(" ").map(n=>[n,e]))].sort((e,t)=>t[0].length-e[0].length);const Qh={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","阿联酋"]},ep=e=>e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^\p{L}\p{N}]+/gu,""),tp=["zh-Hans","en"].flatMap(e=>{try{return typeof Intl<"u"&&"DisplayNames"in Intl?[new Intl.DisplayNames([e],{type:"region"})]:[]}catch{return[]}});function np(e){return e?tp.flatMap(t=>{try{const n=t.of(e);return n&&n!==e?[n]:[]}catch{return[]}}):[]}const gc=Jh.flatMap(e=>[e.name,e.zh,e.a2,e.a3,...e.alt??[],...e.a2?Qh[e.a2]??[]:[],...np(e.a2)].filter(t=>!!t).map(t=>[ep(t),e.name])).filter(([e])=>e.length>0).sort((e,t)=>t[0].length-e[0].length);new Map(gc);gc.filter(([e])=>new RegExp("\\p{Script=Han}","u").test(e)&&e.length>=2);function yc(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 Vt(e,t){return e&&t?.length?[{field:e,op:"in",values:t}]:void 0}const op={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`},sp={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`},bc=()=>fe({"zh-CN":op,"en-US":sp}),rp={alertList:["rule","object"],metricCards:["card"],objectTable:["row"],objectList:["row"],pivotTable:["row"],trendChart:["point"],regionMap:["region"],stageChain:["stage"],[me]:["button"]},ap={alertList:["rule","object"],objectTable:["row"],objectList:["row"],pivotTable:["row"],[me]:["button"]},Sa={objectTable:"row",objectList:"row",[me]:"button"},wc={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"]},kc=["object","row","button"],Xs=["hits","filters"],Qs=["auto","prefill"],er=200,ip=/\{([^{}]+)\}/g;function lp(e){return[...e.matchAll(ip)].map(t=>t[1].trim())}function tr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function cp(e,t,n,o){const s=bc();if(!tr(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([...wc[e.on]??[],...kc.includes(e.on)?(n??[]).map(c=>c.name):[]]);for(const c of lp(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=>!Xs.includes(l)))&&a.push(s.context(`${o}.context`,Xs)),e.send!==void 0&&!Qs.includes(e.send)&&a.push(s.send(`${o}.send`,Qs)),e.maxObjects!==void 0&&(typeof e.maxObjects!="number"||!Number.isInteger(e.maxObjects)||e.maxObjects<1||e.maxObjects>er)&&a.push(s.maxObjects(`${o}.maxObjects`,er)),a}const dp=["row","object","rule","button"],up=8,Gn=5;function hp({on:e,...t}){return{on:e,do:[{kind:"ask",...t}]}}function pp({on:e,label:t,...n}){return{on:e,...t?{label:t}:{},do:[{kind:"act",...n}]}}function fp(e,t,n,o,s,r){const a=bc();return!Array.isArray(e)||e.length>t.max?[a.list(r,t.max)]:e.flatMap((l,c)=>{const i=`${r}[${c}]`;if(!tr(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>Gn?(d.push(a.steps(`${i}.do`,Gn)),d):(l.do.forEach((u,p)=>{const f=`${i}.do[${p}]`;if(!tr(u))return d.push(a.object(f));const{kind:m,...g}=u;if(m==="ask")d.push(...cp({...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(...oc({...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 mp(e,t,n,o){const s=e.filter(a=>dp.includes(a)),r=e.map(a=>`${a}:${wc[a].join("、")}`).join(";");return[`点击时还要做什么,列表,每项 { on, label?, do }:on 为 ${e.join("、")} 之一;do 为按顺序执行的 1 到 ${Gn} 个动作(点击写入的筛选总是先写入,不写在这里)`,s.length>0?`${s.join("、")} 各项是单独一个按钮,label 为按钮文字`:"",`问 Agent 的动作 { kind: "ask", question, agent?, context?, send?, maxObjects? }:question 是问题模板,可用占位 {…}(${r}${e.some(a=>kc.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 gp(e){return typeof e=="string"&&e!==""?e.slice(0,10):"—"}function yp(e,t="text"){return e==null||e===""?"—":t==="date"?gp(e):t==="number"&&typeof e=="number"?e.toLocaleString():String(e)}let Hn=ge;function bp(e){const t=Object.values(re).find(s=>s.value===e);if(!t)return e;const n=`workshopLab.progress.status.${e}`,o=Hn.isInitialized?Hn.t(n):n;return typeof o=="string"&&o!==n?o:t.label}function wp(e){const t=Object.values(Pn).find(s=>s.value===e);if(!t)return e;const n=`workshopLab.scenario.mark.${e}`,o=Hn.isInitialized?Hn.t(n):n;return typeof o=="string"&&o!==n?o:t.label}function No(e,t,n){return e===le.status&&typeof t=="string"?bp(t):e===rn&&typeof t=="string"?wp(t):yp(t,n)}const Ie=e=>typeof e=="string"?e:"";function kp(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"}),Ie(e.source)!==""&&Ie(e.titleField)===""&&o.push({key:"noResourceName"});const r=n.some(a=>a.style==="background"&&a.blocks===!0);for(const a of s){const l=Ie(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||Ie(a.earliestField)!==""||i(a.readyFrom)||i(a.predecessorPath);Ie(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||Ie(p.box)===""||Ie(p.tool)==="")continue;const f=`${Ie(p.box)}/${Ie(p.tool)}`;h.has(f)&&o.push({key:"duplicateTool",values:{layer:l,name:Ie(u.name)}}),h.add(f)}}return o}const vp=/^\d{4}-\d{2}-\d{2}$/;function ja(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 $p(e){if(e)try{return new Intl.DateTimeFormat("en-US",{timeZone:e}),e}catch{return}}const Sp=e=>{const[t,n,o]=e.split("-").map(Number);return new Date(Date.UTC(t,n-1,o+1)).toISOString().slice(0,10)};function vc(e,t){const[n,o,s]=e.split("-").map(Number),r=$p(t);if(!r)return new Date(n,o-1,s).getTime();const a=Date.UTC(n,o-1,s),l=a-ja(a,r);return a-ja(l,r)}function jp(e,t){return vc(Sp(e),t)-1}function Ap(e){return new Set([...e.dimensions,...e.timeDimensions])}function Aa(e,t){return e.kn.objectTypes[e.metric.objectType]?.properties.find(n=>n.name===t)?.type}const nr=(e,t)=>({source:"property",property_ref:{object_type_id:e.objectType,property_name:t}}),$c=e=>({source:"literal",value_type:"string",value:e}),Sc=e=>({source:"literal",value_type:Number.isInteger(e)?"int64":"decimal",value:e}),Je=e=>({source:"literal",value_type:"datetime",value:e}),Te=(e,t,n)=>({node_type:"predicate",left:e,comparison_operator:t,...n?{right:n}:{}});function Tp(e,t){if(t.length!==0)return t.length===1?t[0]:{node_type:"group",boolean_operator:e,children:t}}const jc=e=>e!==""&&e!==null&&e!==void 0&&!Number.isNaN(Number(e));function Ac(e,t,n,o){if(!vp.test(n))return null;const[s,r]=[vc(n,o.timezone),jp(n,o.timezone)];switch(t){case"eq":return Te(e,"between",[Je(s),Je(r)]);case"ne":return Te(e,"not_between",[Je(s),Je(r)]);case"before":return Te(e,"before",[Je(s)]);case"onOrBefore":return Te(e,"before_or_equal",[Je(r)]);case"after":return Te(e,"after",[Je(r)]);case"onOrAfter":return Te(e,"after_or_equal",[Je(s)]);default:return null}}function Op(e,t,n,o){if(n.length===0)return null;const s=nr(o,e);if(t==="text")return Te(s,"in",n.map($c));if(t==="number")return n.every(jc)?Te(s,"in",n.map(a=>Sc(Number(a)))):null;const r=n.map(a=>Ac(s,"eq",a.slice(0,10),o));return r.every(Boolean)?Tp("or",r)??null:null}const Ta={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 Tc(e,t){const n=Ap(t.metric),o=n.has(e.field)?Aa(t,e.field):void 0;if(!o)return null;const s=nr(t.metric,e.field);if(e.op==="isSet")return Te(s,o==="text"?"is_not_empty":"is_not_null");if(e.op==="isEmpty")return Te(s,o==="text"?"is_empty":"is_null");if(e.op==="in")return Op(e.field,o,e.values??[],t.metric);if(e.ref!==void 0&&e.ref!==he){const l=n.has(e.ref)?Aa(t,e.ref):void 0,c=Ta[e.op];return!c||l!==o||["before","onOrBefore","after","onOrAfter"].includes(e.op)||["gt","gte","lt","lte"].includes(e.op)&&o!=="number"?null:Te(s,c,[nr(t.metric,e.ref)])}const r=e.ref===he?t.asOf:e.value;if(r===void 0||r==="")return null;if(o==="date")return Ac(s,e.op,String(r).slice(0,10),t.metric);const a=Ta[e.op];return o==="number"?!a||["before","onOrBefore","after","onOrAfter"].includes(e.op)?null:jc(r)?Te(s,a,[Sc(Number(r))]):null:e.op==="eq"||e.op==="ne"?Te(s,a,[$c(String(r))]):null}const Ep={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}」`},Cp={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}")`},Cr=()=>fe({"zh-CN":Ep,"en-US":Cp}),Np=new Set(["day","week","month","quarter"]);function xp(e,t){return e==="card"?{place:"card"}:t.axis==="category"?{place:"category",...typeof t.category=="string"?{category:t.category}:{}}:{place:"time"}}function or(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 Rp(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 Pp(e,t=[]){const n=new Map;for(const o of[...e,...t]){const s=Rp(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 Lp(e,t,n){const o=Cr();return t==="card"?e.shape==="summary"?null:o.cardShape:t==="time"?e.shape!=="time_series"||e.groupBy.length>0?o.timeShape:Np.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 _p(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 Ip(e,t,n){return(e.from?.where??[]).find(o=>!Tc(o,{metric:t,kn:n,asOf:"2000-01-01"}))}function Oc(e){const t=Cr(),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 Mp(e,t,n,o,s,r,a){const l=Cr(),c=or(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=_p(n,o);if(!d)return[l.sourceKind(r)];if(d.objectType!==i.objectType)return[l.otherObjectType(r,i.name)];const h=Ip(d,i,t);if(h)return[l.subsetBlocked(r,Oc(h))];const u=c.version===i.version?Lp(i,s,a):null;return u?[l.unfit(r,u,i.name)]:[]}function Oa(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 qp(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 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 与版本,不能编造):
|
|
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
|
|
12
|
-
- steps:1 到 ${
|
|
11
|
+
`)}`}const Kp={object:e=>`${e} 必须是对象`,steps:(e,t)=>`${e}.steps 必须是 1 到 ${t} 步`,required:e=>`${e} 必填`,stepField:e=>`${e} 必填:日期属性,或给出 done 条件`,dateField:e=>`${e} 必须是数据源的日期属性`},Yp={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`},Gp=()=>fe({"zh-CN":Kp,"en-US":Yp}),cr=12;function Hp(e,t,n){if(e===void 0)return[];const o=Gp();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 Vp(e){return e?.steps[0]?.field}const Jp=`进度(sources[].progress,可选):这类对象依次经过哪几步、截止日期是哪个。{ steps: [{ label, field, done? }], due?: { field, label? } }
|
|
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 xo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Kp=e=>oh.includes(e??"")?e:"P3";function Yp(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 Ec(e,t,n){const o=n?.get(t.id),s=o?.subject||void 0,r=Yp(e,s);return{...t,label:o?.name||t.id,severity:Kp(o?.severity),...o?{source:o.source,network:o}:{},...n&&!o?{missing:!0}:{},...s?{objectType:s}:{},...r?{subject:r}:{}}}function Jt(e){if(!e)return;const t=Array.isArray(e)?e:Object.values(e);return new Map(t.map(n=>[n.code,n]))}function Ln(e,t){return(e.eventTypes??[]).map(n=>Ec(e,n,t))}const tt="fieldRoles",Cc=`${tt}.`,tn=new Map,Gp=new Set;function Nc(e,t,n="zh-CN"){const o=tn.get(t.type);o?.package===e&&o.locale===n||(tn.set(t.type,{package:e,manifest:t,schema:xc(t,n),locale:n}),Gp.forEach(s=>s()))}function Hp(e){return tn.get(e)?.schema??Vp(e)}function Vp(e){return{label:e,summary:"",category:"display",description:`自定义组件 ${e}`,descriptors:[],follows:!1,selectorKeys:[],defaults:()=>({})}}function Jp(e){if(!Ot(e))return rc[e];const t=tn.get(e)?.manifest.minSize;return t?[t.w,t.h]:[3,3]}function Zp(e,t){return e.label[t]??e.label["zh-CN"]??e.type}const Nr=e=>e==="string"?"text":e==="number"?"number":e==="date"||e==="datetime"?"date":void 0,Xp=["filter","display","chart","relation"];function Qp(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=Nr(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:Kn};break;case"objectType":a={...s,kind:"objectType"};break;case"relationPath":a={...s,kind:"relationPath",...ef(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",...t.maxLength?{max:t.maxLength}:{}})}return a}const ef=e=>e.type==="string"||e["x-workshop"]?.maxHops===1;function tf(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 nf(e,t){const n=tn.get(e)?.manifest,{[tt]:o,...s}=t,r={...s};if(o&&typeof o=="object"&&!Array.isArray(o))for(const[a,l]of Object.entries(o))r[Cc+a]=l;for(const a of n?tf(n):[])typeof r[a]=="string"&&(r[a]=[r[a]]);return r}function xc(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=[{key:"title",label:"标题",kind:"text",max:80,optional:!0,tab:"display"}];n&&r.push({key:"source",label:"数据源",kind:"source",tab:"data"});for(const l of o){const c=Nr(l.type);r.push({key:Cc+l.role,label:`字段:${l.role}`,kind:"field",...c?{of:c}:{},tab:"data"})}for(const[l,c]of Object.entries(e.configSchema.properties??{})){if(["title","source","filters","selection",tt].includes(l))continue;const i=Qp(l,c,s.has(l));i&&r.push(i)}const a=n&&e.follows;return a&&r.push({key:"filters",label:"跟随筛选",kind:"bindings",optional:!0,tab:"link"}),e.emits?.includes("selection")&&r.push({key:"selection",label:"点选对象写入",kind:"variable",accepts:["selection"],optional:!0,tab:"link"}),{label:Zp(e,t),summary:e.description,category:Xp.includes(e.category)?e.category:"display",description:e.description,descriptors:r,follows:a,selectorKeys:[],defaults:(l,c)=>of(e,l,c.kn)}}function of(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=Nr(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[tt]=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 Ea=[["neutral","中性"],["info","信息"],["success","成功"],["warning","警示"],["danger","危险"]],rr=[["count","计数"],["sum","求和"],["avg","平均"],["min","最小"],["max","最大"],["distinct","去重计数"]],sf=[...rr,["ratio","占比(满足条件的 ÷ 全部)"]];function Ca(e){return e.basis==="period"||e.basis===void 0&&e.periodField!==void 0}function Ro(e){return typeof e.compare=="string"&&e.compare!=="none"}const rf=[["local","浏览器所在时区"],["Asia/Shanghai","北京时间"],["UTC","协调世界时"],["Asia/Tokyo","东京时间"],["Asia/Singapore","新加坡时间"],["Europe/Berlin","柏林时间"],["Europe/London","伦敦时间"],["America/New_York","纽约时间"],["America/Los_Angeles","洛杉矶时间"]],af=[["high","严重"],["medium","关注"],["low","提示"]],Na=[["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}),Qe={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},Lt=[{key:"label",label:"名称",kind:"text"},{key:"when",label:"仅统计满足以下条件的",kind:"conditions",optional:!0},{key:"aggregate",label:"统计方式",kind:"enum",options:sf},Qe],Me=e=>e.metric!==void 0,xa=e=>({key:"metric",label:"数值来源",hint:"对象指标由平台按全部对象计算,口径在知识网络中定义。",kind:"metric",on:e,optional:!0}),je={key:"filters",label:"跟随的筛选",kind:"bindings",tab:"link",optional:!0},ke=(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")}:{}}]:[],lf=[["frontend","前端 Agent(在浏览器内调用平台模型,可读取页面并代为筛选)"],["bknAgent","内置 BKN Agent(平台智能问答 Agent,以当前用户身份查询知识网络)"],["mcp","外部 Agent(执行工厂中登记的 MCP 服务,由对方直接回答)"]];function Ra(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 Be={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,Ih)?.id,step:"day",writes:ve(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=>ke(e,"writes",e.field),defaults:(e,t,n)=>{const o=ee(e,n);return{title:"日期区间",source:o?.id,field:o?zp(o.progress)??Po(o,t,"date"):void 0,presets:!0,writes:ve(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)=>Ca(t)},{key:"periodUnit",label:"周期",hint:"默认按月:环比对比上个月,按期统计时一期为一个月。",kind:"enum",tab:"data",optional:!0,shows:(e,t)=>Ro(t)||Ca(t),options:[["day","日"],["week","周"],["month","月"],["quarter","季度"],["year","年"]]},{key:"showNoData",label:"对比期无数据时显示「无对比数据」",kind:"bool",tab:"data",optional:!0,shows:(e,t)=>Ro(t)},{key:"items",label:"指标",kind:"list",tab:"data",min:1,max:8,item:[Lt[0],xa("card"),Lt[1],{...Lt[2],shows:e=>!Me(e),notNeeded:Me},{...Qe,shows:e=>!Me(e)&&Qe.shows(e),neededAs:e=>Me(e)?void 0:Qe.neededAs(e)},{key:"tone",label:"色调",kind:"enum",options:Ea},{key:"compare",label:"同比环比",hint:"留空时沿用整组设置。",kind:"enum",optional:!0,shows:(e,t)=>Ro(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}"),je],follows:!0,selectorKeys:["writes"],emits:(e,t)=>Io(t,e.writes)==="set"?ke(e,"writes"):ke(e,"writes",Ia(e.items)[0]),check:(e,t,n)=>{const o=e.items??[],s=o.flatMap((a,l)=>{const c=Oa(t.kn,or(a.metric));return c?(a.when??[]).filter(i=>!Tc(i,{metric:c,kn:t.kn,asOf:"2000-01-01"})).map(i=>`${n}.items[${l}].when 的条件(${Oc(i)})不能交给平台:对象指标卡的条件只能用指标「${c.name}」开放的属性`):[]});if(Io(t.spec,e.writes)!=="value")return s;const r=o.filter(a=>a.metric===void 0);return r.some(a=>a.when?.length&&!yc(a.when))?[...s,`${n}.items 写入取值筛选时,每张卡的条件只能是“某字段为某些值”;条件更复杂时改写入对象集合筛选`]:new Set(Ia(r)).size>1?[...s,`${n}.items 写入同一个筛选的指标要按同一个字段取值`]:s},defaults:(e,t,n)=>{const o=ee(e,n,r=>!!Ze(r)),s=o&&Ze(o);return{title:"关键指标",source:o?.id,items:[{label:"全部",aggregate:"count",tone:"neutral"},...(s?Lo(s):[]).map(r=>({label:s?No(s.name,r.value):r.value,when:Vt(s?.name,[r.value]),aggregate:"count",tone:r.tone??"neutral"}))],writes:s?bn(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}),je],follows:!0,selectorKeys:["writes"],emits:e=>ke(e,"writes",e.field),defaults:(e,t,n)=>{const o=ee(e,n,r=>!!Ze(r)),s=o&&Ze(o);return{source:o?.id,field:s?.name,options:[{label:"全部"},...(s?Lo(s):[]).map(r=>({label:s?No(s.name,r.value):r.value,values:[r.value]}))],showCounts:!0,writes:s?bn(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}),je],follows:!0,selectorKeys:["writes"],emits:e=>ke(e,"writes",e.field),defaults:(e,t,n)=>{const o=ee(e,n),s=o&&(Ze(o)?.name??_o(o,t).find(r=>r!==o.key));return{source:o?.id,field:s,multiple:!1,showCounts:!0,writes:s?bn(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=>ke(e,"writes",void 0,e.fields),defaults:(e,t,n)=>{const o=ee(e,n);return{source:o?.id,fields:o?[..._o(o,t).filter(s=>s===o.key),..._o(o,t).filter(s=>s!==o.key).slice(0,2)]:[],placeholder:"搜索",writes:ve(e,"search",o?.id)}}},objectTable:{label:"对象表",summary:"明细表,支持排序、分页、勾选;点击行选中对象。",category:"display",description:"对象明细表,可排序分页;点行选中对象,表头可带按某字段取值的快捷筛选与搜索,某列可点击筛选;格式 tag 把值显示成标签,进度状态和判断状态的计算列带颜色",descriptors:[J(),ae,{key:"columns",label:"列",kind:"list",tab:"data",min:1,max:20,fill:{from:"field",item:Pa},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:Na},{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"]}]},je],follows:!0,selectorKeys:["picks"],emits:e=>[...ke(e,"picks"),...ke(e,"quickFilter",e.quickField),...ke(e,"search",void 0,hf(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(Pa),sortOrder:"desc",pageSize:10,selection:ve(e,"selection",o?.id)}}},objectList:{label:"对象列表",summary:"卡片式列表,适用于待办和收件箱;点击列表项选中对象。",category:"display",description:"卡片式列表,适合收件箱、待办;可只看满足条件的对象,点一项选中对象",descriptors:[J(),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:Na},{key:"badgeField",label:"徽标字段(状态类字段按颜色区分)",kind:"field",tab:"display",optional:!0},{key:"limit",label:"最多显示",kind:"number",tab:"display",min:3,max:30},Q("selection","点击写入",["selection"],"点击列表项时,选中该对象(写入 {var}),详情抽屉和关系子图将显示该对象"),je],follows:!0,selectorKeys:[],defaults:(e,t,n)=>{const o=ee(e,n);return{title:o?.label,source:o?.id,titleField:o&&Oo(o,t.kn),sortOrder:"desc",badgeField:o?Ze(o)?.name:void 0,limit:8,selection:ve(e,"selection",o?.id)}}},pivotTable:{label:"透视表",summary:"按一个属性分组汇总,每列一项统计;点击行可筛选页面。",category:"display",description:"按一个属性分组汇总,每列一个度量;点一行按该分组筛选全页",descriptors:[J(),ae,{key:"dimension",label:"分组属性",kind:"field",tab:"data"},{key:"measures",label:"度量",kind:"list",tab:"data",min:1,max:5,item:[...Lt]},{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}"),je],follows:!0,selectorKeys:["writes"],emits:e=>ke(e,"writes",e.dimension),defaults:(e,t,n)=>{const o=ee(e,n),s=o?fa(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(),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)=>!_a(t)||t.segmentBy!==void 0},{key:"grain",label:"统计粒度",shows:(e,t)=>t.axis!=="category"&&!_a(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"},xa("chart"),{key:"dateField",label:"日期属性",shows:(e,t)=>t.axis!=="category"&&!Me(e),kind:"field",of:"date",optional:!0},{key:"aggregate",label:"聚合",kind:"enum",options:rr,shows:e=>!Me(e),notNeeded:Me},{...Qe,shows:e=>!Me(e)&&Qe.shows(e),neededAs:e=>Me(e)?void 0:Qe.neededAs(e)},{key:"chart",label:"图形",kind:"enum",options:[["bar","柱"],["line","线"],["pie","饼(仅限单系列且横轴为类别时可用)"]]}]},Q("writes","点击写入",["dateRange","value"],"点击周期(或类别)时,将其写入 {var}"),je],follows:!0,selectorKeys:["writes"],emits:e=>ke(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=>Oa(t.kn,or(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=Io(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?Po(o,t,"date"):void 0;return{source:o?.id,months:8,series:[{label:"数量",dateField:s,aggregate:"count",chart:"bar"}],writes:ve(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:rr},{...Qe,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}"),je],follows:!0,selectorKeys:["writes"],emits:e=>ke(e,"writes",e.regionField),defaults:(e,t,n)=>{const o=ee(e,n,l=>!!La(l)),s=o&&La(o),r=s?.name??(o&&uf(o,t)),a=s?.kind==="region"?s.scope:r&&Rc.test(r)?"world":void 0;return{title:"地区分布",source:o?.id,...a==="world"?{basemap:a}:{},regionField:r,aggregate:"count",writes:r?bn(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},je],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&&Oo(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:th,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:Ea,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)=>Yh(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:Ra("需求对象类","目标日期"),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:Ra("资源对象类","就绪日"),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:nh,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:rf},Q("timeZoneVariable","按页面变量取时区",["value"],"按 {var} 选中的时区换算时间,没有选中时用上面的时区"),Q("resourceSelection","点击资源写入",["selection"],"点击资源名称时,选中该资源(写入 {var})")],follows:!1,selectorKeys:[],emits:e=>[...ke(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:kp,defaults:(e,t,n)=>{const o=ee(e,n,c=>!!(ue(e,c.id)&&Po(c,t,"date"))),s=o?pe(o,t.kn):[],r=s.filter(c=>c.type==="date"),a=o?fa(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:[Oo(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:ve(e,"selection",o.id),filters:Lc(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}]},je],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:ve(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:[...Lt]},je],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,je],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(),ae,{key:"rules",label:"规则",kind:"list",tab:"data",min:1,max:8,item:[{key:"label",label:"名称",kind:"text"},{key:"severity",label:"严重程度",kind:"enum",options:af},{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})"),je],follows:!0,selectorKeys:["writes"],emits:e=>ke(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=>!!Ze(a)),s=o&&Ze(o),r=s?Lo(s).filter(a=>a.tone==="danger"):[];return{title:"告警",source:o?.id,rules:s&&r.length>0?r.map(a=>({label:s?No(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:ve(e,"set",o?.id),selection:ve(e,"selection",o?.id)}}},eventList:{label:"事件列表",summary:"列出应用的业务事件,支持核实、驳回、关闭;点击事件选中其关联的对象。",category:"display",description:"列出应用里的业务事件(规则命中或用户登记的),未关闭的在前、按严重程度排;待核实的可以核实或驳回,已核实的可以关闭;显示规则的最近与下次检查时间,可以立即检查。事件类型在知识网络里建模,应用在 eventTypes 里按编码选择要处理的。点事件把它关联的对象写入一个选中对象筛选",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"},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 Ln(t.spec,Jt(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=Ln(e,Jt(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=Ln(e,Jt(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&&ve(e,"selection",o.id),a=o&&ve(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:lf},{key:"agent",label:"外部 Agent",hint:"选择 MCP 服务和其中回答问题的工具(通常名为 ask);使用者须有该服务的执行权限。",kind:"mcpTool",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:ve(e,"selection",o?.id),canFilter:!0}}}};function cf(e){return Ke.filter(t=>!Ar.has(t)&&(e||Be[t].category!=="scenario"))}const lt={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:ve(e,"selection",o?.id)}}};function ut(e){return e===me?lt:Ot(e)?Hp(e):Be[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 ve(e,t,n){return e.variables.find(o=>o.kind===t&&(!n||!("source"in o)||o.source===n))?.name}function Po(e,t,n){return pe(e,t.kn).find(o=>o.type===n)?.name}function df(e){return e==="date"?"date":e==="number"?"number":"text"}function Pa(e){return{field:e.name,label:e.label,format:e.name===le.status?"tag":e.type?df(e.type):"text"}}function Ze(e){if(e.progress)return{name:le.status,outcomes:pc};const t=e.computed?.find(n=>n.kind==="classify");return t&&{name:t.name,outcomes:[...t.cases,t.otherwise]}}function La(e){return e.computed?.find(t=>t.kind==="region")}const Rc=/country|nation|国家|国籍/i;function uf(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(Rc)??s(n)}function Lo(e){return e.outcomes}function _o(e,t){return pe(e,t.kn).filter(n=>n.type==="text").map(n=>n.name)}function _a(e){return Array.isArray(e.series)&&e.series.some(t=>Me(t))}function Ia(e){return(e?.filter(t=>t.metric===void 0)??[]).flatMap(t=>{const n=yc(t.when);return n?[n.field]:[]})}function Io(e,t){return e?.variables.find(n=>n.name===t)?.kind}function hf(e){return(e.columns??[]).filter(t=>t.format==="text"||t.format==="tag").map(t=>t.field).filter(t=>typeof t=="string")}function pf(e){return[...Object.values(e.regions).flatMap(t=>t??[]),...e.detail?[e.detail]:[]]}function Pc(e){const t=new Map;for(const n of pf(e)){const o=ut(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 bn(e,t){const n=Pc(e);return e.variables.find(o=>o.kind==="value"&&((n.get(o.name)??[]).some(s=>s.field===t)||o.name===t))?.name}function Lc(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=Pc(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(Be)){if(!e.follows)continue;const t=e.defaults;e.defaults=(n,o,s)=>{const r=t(n,o,s);return{...r,filters:Lc(n,o.kn,r,e)}}}for(const[e,t]of Object.entries(rp)){const n=e===me?lt:Be[e];n.descriptors=[...n.descriptors,{key:"interactions",label:"点击后的动作",kind:"interactions",on:t,actOn:ap[e]??[],hit:!0,max:up,...Sa[e]?{offers:Sa[e]}:{},tab:"link",optional:!0}]}function ff(e,t){return new Set([t,...e.sources.filter(n=>n.from?.source===t).map(n=>n.id)])}function _c(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=ff(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 mf(e){if(e.ask===void 0&&e.act===void 0)return;const t=Array.isArray(e.interactions)?e.interactions:[],n=X(e.ask)?[hp(e.ask)]:[],o=Array.isArray(e.act)?e.act.map(pp):[],s=[...t,...n,...o];s.length>0&&(e.interactions=s),delete e.ask,delete e.act}function gf(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 yf(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 bf=new Set(["status","overdueDays","dueInDays"]);function wf(e){const[t,n]=e.split("-").map(Number);return new Date(Date.UTC(t,n,0)).toISOString().slice(0,10)}function kf(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 Mo(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 ar(e){if(Array.isArray(e))return e.forEach(ar);X(e)&&("sumField"in e&&(e.valueField===void 0&&(e.valueField=e.sumField),delete e.sumField),Object.values(e).forEach(ar))}function vf(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 $f(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 Sf(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=kf(i);if(!d)continue;const h=vf(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=>!bf.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..${wf(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:{};yf(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"){gf(u,f,n);continue}if(ar(f),mf(f),p==="metricCards"&&Array.isArray(f.items)&&f.items.forEach(b=>X(b)&&Mo(b)),p==="pivotTable"&&Array.isArray(f.measures)&&f.measures.forEach(b=>X(b)&&Mo(b)),p==="objectList"&&Mo(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),!Ke.includes(p))continue;const m=ut(p);if(p==="searchBox"&&typeof f.writes=="string"&&!f.fields){const b=a.get(f.writes)?.fields??$f(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=_c(t,i,"status",d);return r.size>0&&(t=Nf(t,r)),Of(t),jf(t),t}function jf(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 Af=/^[a-z0-9][a-z0-9_.-]{0,63}$/;function Tf(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 Of(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"||Af.test(a))continue;n.delete(a);const l=Tf(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(!Ke.includes(c.type)||!X(c.config))continue;const i=c.config;for(const d of ut(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 Ef=new Map([["status",le.status],["stage",le.stage],["overdueDays",le.overdueDays],["dueInDays",le.dueInDays]]),Cf=new Map(Object.values(re).map(e=>[e.label,e.value]));function Ic(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)&&Ic(s.item,l,n)}}function Nf(e,t){let n=structuredClone(e);const o=r=>Ef.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)&&Ic(ut(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=_c(n,r.id,le.status,Cf)}return n}const ht="workshop.openbkn.ai/v1",xf=["tabs","cards","segmented","side"],Rf=["dashboard","table","chart","map","alert","task","calendar","relation","search","agent","team","setting"],Pf=["tasks","alerts"];function Zt(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 Lf(e){if(typeof e!="object"||e===null)return e;const t=Sf(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 qo={exports:{}},L={};var Ma;function _f(){if(Ma)return L;Ma=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 _($,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===""?"."+_($,0):R,v(z)?(C="",V!=null&&(C=V.replace(M,"$&/")+"/"),q(z,T,C,"",function(su){return su})):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 _e=R===""?".":R+":";if(v($))for(var we=0;we<$.length;we++)R=$[we],Y=_e+_(R,we),V+=q(R,T,C,Y,z);else if(we=p($),typeof we=="function")for($=we.call($),we=0;!(R=$.next()).done;)R=R.value,Y=_e+_(R,we++),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 L.Activity=h,L.Children=oe,L.Component=y,L.Fragment=n,L.Profiler=s,L.PureComponent=k,L.StrictMode=o,L.Suspense=c,L.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=j,L.__COMPILER_RUNTIME={__proto__:null,c:function($){return j.H.useMemoCache($)}},L.cache=function($){return function(){return $.apply(null,arguments)}},L.cacheSignal=function(){return null},L.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),_e=0;_e<Y;_e++)V[_e]=arguments[_e+2];R.children=V}return A($.type,z,R)},L.createContext=function($){return $={$$typeof:a,_currentValue:$,_currentValue2:$,_threadCount:0,Provider:null,Consumer:null},$.Provider=$,$.Consumer={$$typeof:r,_context:$},$},L.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 _e=Array(V),we=0;we<V;we++)_e[we]=arguments[we+2];z.children=_e}if($&&$.defaultProps)for(R in V=$.defaultProps,V)z[R]===void 0&&(z[R]=V[R]);return A($,Y,z)},L.createRef=function(){return{current:null}},L.forwardRef=function($){return{$$typeof:l,render:$}},L.isValidElement=x,L.lazy=function($){return{$$typeof:d,_payload:{_status:-1,_result:$},_init:Z}},L.memo=function($,T){return{$$typeof:i,type:$,compare:T===void 0?null:T}},L.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}},L.unstable_useCacheRefresh=function(){return j.H.useCacheRefresh()},L.use=function($){return j.H.use($)},L.useActionState=function($,T,C){return j.H.useActionState($,T,C)},L.useCallback=function($,T){return j.H.useCallback($,T)},L.useContext=function($){return j.H.useContext($)},L.useDebugValue=function(){},L.useDeferredValue=function($,T){return j.H.useDeferredValue($,T)},L.useEffect=function($,T){return j.H.useEffect($,T)},L.useEffectEvent=function($){return j.H.useEffectEvent($)},L.useId=function(){return j.H.useId()},L.useImperativeHandle=function($,T,C){return j.H.useImperativeHandle($,T,C)},L.useInsertionEffect=function($,T){return j.H.useInsertionEffect($,T)},L.useLayoutEffect=function($,T){return j.H.useLayoutEffect($,T)},L.useMemo=function($,T){return j.H.useMemo($,T)},L.useOptimistic=function($,T){return j.H.useOptimistic($,T)},L.useReducer=function($,T,C){return j.H.useReducer($,T,C)},L.useRef=function($){return j.H.useRef($)},L.useState=function($){return j.H.useState($)},L.useSyncExternalStore=function($,T,C){return j.H.useSyncExternalStore($,T,C)},L.useTransition=function(){return j.H.useTransition()},L.version="19.2.8",L}var qa;function If(){return qa||(qa=1,qo.exports=_f()),qo.exports}If();const Mf={skipErrorToast:!0},qf=e=>`/bkn-backend/v1/knowledge-networks/${encodeURIComponent(e)}`;async function Ff(e){const{data:t}=await nt.get(`${qf(e)}/event-types`,Mf);return t.entries??[]}Math.random().toString(36).slice(2);const Df=new Map;Math.random().toString(36).slice(2);function Bf(){for(const e of Df.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=>{Bf()&&(e.preventDefault(),e.returnValue="")});class Mc extends Error{constructor(t){super("draft changed since it was read"),this.currentRevision=t}currentRevision}class xr extends Error{constructor(){super("app not found")}}class Rr extends Error{constructor(){super("not allowed")}}class qc extends Error{constructor(){super("app too large")}}class Uf extends Error{constructor(t){super("event types missing on the network"),this.eventTypes=t}eventTypes}const Pr="/workshop/v1",ln={skipErrorToast:!0},zf=200;function Wf(e){const t=e?.response,n=t?.status,o=t?.data?.metadata;if(n===404)return new xr;if(n===403)return new Rr;if(n===413)return new qc;if(n===409){if(typeof o?.current_revision=="number")return new Mc(o.current_revision);if(Array.isArray(o?.event_types))return new Uf(o.event_types.map(String))}return e}async function cn(e){try{return(await e()).data}catch(t){throw Wf(t)}}function Kf(){return`ws-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}const Fa=e=>({id:e?.id??"",name:e?.name||e?.id||""});function Yf(e){return!e||typeof e!="object"||!Array.isArray(e.pages)?null:Lf(e)}function Fc(e){const t=e.tags??[],n=(e.references??[]).map(Fa);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:Fa(e.kn),version:e.current_version??0,revision:e.draft_revision??0,creator:e.creator??"",updatedAt:e.update_time??0,operations:e.operations??[]}}const Lr=e=>({...Fc(e),draft:Yf(e.draft)}),_r=e=>`${Pr}/apps/${encodeURIComponent(e)}`;async function Gf(){const e=[];let t="";for(const n=new Set;;n.add(t)){const o=new URLSearchParams({limit:String(zf)});t&&o.set("cursor",t);const s=await cn(()=>nt.get(`${Pr}/apps`,{...ln,params:o}));if(e.push(...(s.entries??[]).map(Fc)),t=s.next_cursor??"",!t||n.has(t))return e}}async function Hf(e){try{return Lr(await cn(()=>nt.get(_r(e),ln)))}catch(t){if(t instanceof xr)return null;throw t}}const Vf=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 Jf(e,t,n,o={}){const s=await cn(()=>nt.post(`${Pr}/apps`,{...Vf({...o,name:e}),kn:{id:t.id,name:t.name},draft:n},{...ln,headers:{"Idempotency-Key":Kf()}}));return Lr(s)}async function Zf(e,t,n){return Lr(await cn(()=>nt.put(`${_r(e)}/draft`,{draft:t,revision:n},ln)))}async function Xf(e,t,n="upload"){const o=await cn(()=>nt.post(`${_r(e)}/component-packages`,t,{...ln,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 Qf=()=>et().listNetworks(),em=e=>et().listObjectTypes(e),tm=(e,t)=>et().getObjectType(e,t),nm=e=>et().listRelationTypes(e);var W={},Fo={},Do={},de={},Da;function B(){if(Da)return de;Da=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 wn={},Ba;function ao(){if(Ba)return wn;Ba=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 wn.visit=s,wn.visitAsync=a,wn}var Ua;function Dc(){if(Ua)return Do;Ua=1;var e=B(),t=ao();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:"},
|
|
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={},Va;function zr(){if(Va)return kt;Va=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={},Ja;function Hc(){if(Ja)return Vo;Ja=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={},Za;function ft(){if(Za)return Jo;Za=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 Xa;function Wr(){if(Xa)return Ho;Xa=1;var e=Hc(),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 Qa;function uo(){if(Qa)return Go;Qa=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={},$n={},ei;function ce(){if(ei)return $n;ei=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",$n.Scalar=s,$n.isScalarValue=o,$n}var ti;function ho(){if(ti)return Zo;ti=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 ni;function Kr(){if(ni)return Ft;ni=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 Sn={},Xo={},jn={},Dt={},oi;function po(){if(oi)return Dt;oi=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
|
|
20
|
+
`+t(r,s):(o.endsWith(" ")?"":" ")+r;return Dt.indentComment=t,Dt.lineComment=n,Dt.stringifyComment=e,Dt}var Qo={},vt={},si;function gm(){if(si)return vt;si=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
|
|
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 ri;function fo(){if(ri)return Qo;ri=1;var e=ce(),t=gm();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+=`
|
|
@@ -38,15 +38,15 @@ ${f}`)+"'";return p.implicitKey?m:t.foldFlowLines(m,f,t.FOLD_FLOW,n(p,!1))}funct
|
|
|
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
40
|
`&&(A=A.slice(0,-1)),A=A.replace(c,`$&${v}`));let x=!1,I,M=-1;for(I=0;I<f.length;++I){const N=f[I];if(N===" ")x=!0;else if(N===`
|
|
41
|
-
`)M=I;else break}let
|
|
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(`${
|
|
41
|
+
`)M=I;else break}let L=f.substring(0,M<I?M+1:I);L&&(f=f.substring(L.length),L=L.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(`${L}${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}${L}${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
|
|
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 ai;function mo(){if(ai)return jn;ai=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 jn.createStringifyContext=s,jn.stringify=l,jn}var ii;function ym(){if(ii)return Xo;ii=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 I="With simple keys, collection cannot be used as a key value";throw new Error(I)}}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
51
|
`:"",j){const I=f(j);x+=`
|
|
52
52
|
${o.indentComment(I,l.indent)}`}E===""&&!l.inFlow?x===`
|
|
@@ -54,34 +54,34 @@ ${o.indentComment(I,l.indent)}`}E===""&&!l.inFlow?x===`
|
|
|
54
54
|
|
|
55
55
|
`):x+=`
|
|
56
56
|
${l.indent}`}else if(!b&&e.isCollection(a)){const I=E[0],M=E.indexOf(`
|
|
57
|
-
`),
|
|
57
|
+
`),L=M!==-1,ne=l.inFlow??a.flow??a.items.length===0;if(L||!ne){let q=!1;if(L&&(I==="&"||I==="!")){let N=E.indexOf(" ");I==="&"&&N!==-1&&N<M&&E[N+1]==="!"&&(N=E.indexOf(" ",N+1)),(N===-1||M<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
|
|
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={},An={},li;function Vc(){if(li)return An;li=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 An.debug=t,An.warn=n,An}var Bt={},ci;function Yr(){if(ci)return Bt;ci=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 di;function Jc(){if(di)return es;di=1;var e=Vc(),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 ui;function mt(){if(ui)return Sn;ui=1;var e=ho(),t=ym(),n=Jc(),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 Zc{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 Zc(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 Sn.Pair=r,Sn.createPair=s,Sn}var ts={},ns={},Tn={},os={},hi;function Xc(){if(hi)return os;hi=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
|
|
67
|
-
`:" ")}return n.stringifyString({comment:s,type:r,value:h},l,c,i)}};return
|
|
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 pi;function gt(){if(pi)return Tn;pi=1;var e=Xc(),t=Jc(),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 Tn.YAMLMap=l,Tn.findPair=a,Tn}var fi;function pn(){if(fi)return ns;fi=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={},mi;function yt(){if(mi)return rs;mi=1;var e=ho(),t=Xc(),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 gi;function fn(){if(gi)return ss;gi=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={},yi;function go(){if(yi)return as;yi=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 On={},is={},bi;function Gr(){if(bi)return is;bi=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={},wi;function Qc(){if(wi)return ls;wi=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={},ki;function mn(){if(ki)return cs;ki=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 vi;function ed(){if(vi)return Ut;vi=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),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={},$i;function td(){if($i)return zt;$i=1;var e=mn();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={},Si;function bm(){if(Si)return ds;Si=1;var e=pn(),t=Gr(),n=fn(),o=go(),s=Qc(),r=ed(),a=td();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={},ji;function wm(){if(ji)return us;ji=1;var e=ce(),t=pn(),n=fn();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={},Ai;function nd(){if(Ai)return hs;Ai=1;var e=Tu,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 En={},Wt={},Ti;function Hr(){if(Ti)return Wt;Ti=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 Dt.createPairs=r,Dt.pairs=a,Dt.resolvePairs=s,Dt}var vi;function Jc(){if(vi)return Tn;vi=1;var e=B(),t=pt(),n=mt(),o=gt(),s=Br();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 Tn.YAMLOMap=r,Tn.omap=a,Tn}var ls={},On={},$i;function im(){if($i)return On;$i=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 On.falseTag=o,On.trueTag=n,On}var Bt={},Si;function lm(){if(Si)return Bt;Si=1;var e=ce(),t=hn();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 Bt.float=s,Bt.floatExp=o,Bt.floatNaN=n,Bt}var wt={},ji;function cm(){if(ji)return wt;ji=1;var e=hn();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 wt.int=a,wt.intBin=s,wt.intHex=l,wt.intOct=r,wt}var En={},Ai;function Zc(){if(Ai)return En;Ai=1;var e=B(),t=ft(),n=mt();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 En.YAMLSet=o,En.set=s,En}var Ut={},Ti;function Xc(){if(Ti)return Ut;Ti=1;var e=hn();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 Ut.floatTime=s,Ut.intTime=o,Ut.timestamp=r,Ut}var Oi;function dm(){if(Oi)return ls;Oi=1;var e=dn(),t=Dr(),n=un(),o=po(),s=Vc(),r=im(),a=lm(),l=cm(),c=Fr(),i=Jc(),d=Br(),h=Zc(),u=Xc();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 ls.schema=p,ls}var Ei;function um(){if(Ei)return An;Ei=1;var e=dn(),t=Dr(),n=un(),o=po(),s=Yc(),r=Gc(),a=Hc(),l=rm(),c=am(),i=Vc(),d=Fr(),h=Jc(),u=Br(),p=dm(),f=Zc(),m=Xc();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(_=>JSON.stringify(_)).join(", ");throw new Error(`Unknown custom tag ${I}; use one of ${M}`)}return A.includes(x)||A.push(x),A},[])}return An.coreKnownTags=b,An.getTags=k,An}var Ci;function ed(){if(Ci)return Jo;Ci=1;var e=B(),t=dn(),n=un(),o=po(),s=um();const r=(l,c)=>l.key<c.key?-1:l.key>c.key?1:0;let a=class Qc{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(Qc.prototype,Object.getOwnPropertyDescriptors(this));return c.tags=this.tags.slice(),c}};return Jo.Schema=a,Jo}var cs={},Ni;function hm(){if(Ni)return cs;Ni=1;var e=B(),t=ho(),n=co();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 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(`
|
|
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
|
|
72
|
+
`}return fs.stringifyDocument=o,fs}var Mi;function yo(){if(Mi)return Yo;Mi=1;var e=uo(),t=Kr(),n=B(),o=mt(),s=ft(),r=id(),a=Am(),l=zr(),c=Hc(),i=ho(),d=Gc();let h=class ld{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(ld.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 M=ne=>typeof ne=="number"||ne instanceof String||ne instanceof Number,L=m.filter(M).map(String);L.length>0&&(m=m.concat(L)),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},I=i.createNode(f,j,x);return w&&n.isCollection(I)&&(I.flow=!0),A(),I}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={},qi;function bo(){if(qi)return St;qi=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
|
|
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
|
|
77
|
+
`}};return St.YAMLError=e,St.YAMLParseError=t,St.YAMLWarning=n,St.prettifyError=o,St}var ms={},xn={},gs={},ys={},bs={},Fi;function wo(){if(Fi)return bs;Fi=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={},Di;function Vr(){if(Di)return ws;Di=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={},Bi;function cd(){if(Bi)return ks;Bi=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={},Ui;function dd(){if(Ui)return vs;Ui=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 zi;function Tm(){if(zi)return ys;zi=1;var e=mt(),t=gt(),n=wo(),o=Vr(),s=cd(),r=dd();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
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 I=S?c(d,S,x,u):i(d,g,v,null,x,u);d.schema.compat&&s.flowIndentCheck(h.indent,S,u),g=I.range[2];const M=new e.Pair(E,I);d.options.keepSourceTokens&&(M.srcToken=b),m.items.push(M)}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 I=new e.Pair(E);d.options.keepSourceTokens&&(I.srcToken=b),m.items.push(I)}}return y&&y<g&&u(y,"IMPOSSIBLE","Map comment with trailing content"),m.range=[h.offset,g,y??g],m}return
|
|
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=
|
|
80
|
+
`+x.comment:E.comment=x.comment);const I=new e.Pair(E);d.options.keepSourceTokens&&(I.srcToken=b),m.items.push(I)}}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={},Wi;function Om(){if(Wi)return $s;Wi=1;var e=yt(),t=wo(),n=cd();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={},Ki;function gn(){if(Ki)return js;Ki=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 Yi;function Em(){if(Yi)return Ss;Yi=1;var e=B(),t=mt(),n=gt(),o=yt(),s=gn(),r=wo(),a=Vr(),l=dd();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 I=f.items[x],{start:M,key:L,sep:ne,value:q}=I,N=r.resolveProps(M,{flow:b,indicator:"explicit-key-ind",next:L??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(L)&&m(L,"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 M)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=L?h(p,L,N,m):u(p,Z,M,null,N,m);i(L)&&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
83
|
`+oe.comment:U.comment=oe.comment);const T=new t.Pair(U,$);if(p.options.keepSourceTokens&&(T.srcToken=I),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),I=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",I),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
|
|
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 Gi;function Cm(){if(Gi)return gs;Gi=1;var e=B(),t=ce(),n=gt(),o=yt(),s=Tm(),r=Om(),a=Em();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={},Hi;function ud(){if(Hi)return Ts;Hi=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
|
|
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={},Vi;function hd(){if(Vi)return Os;Vi=1;var e=ce(),t=gn();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
|
|
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 Ji;function Nm(){if(Ji)return As;Ji=1;var e=B(),t=ce(),n=ud(),o=hd();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={},Zi;function xm(){if(Zi)return Es;Zi=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 Xi;function Rm(){if(Xi)return xn;Xi=1;var e=uo(),t=B(),n=Cm(),o=Nm(),s=gn(),r=xm();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 xn.composeEmptyNode=c,xn.composeNode=l,xn}var Qi;function _m(){if(Qi)return ms;Qi=1;var e=yo(),t=Rm(),n=gn(),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 el;function pd(){if(el)return Wo;el=1;var e=Er,t=Gc(),n=yo(),o=bo(),s=B(),r=_m(),a=gn();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
|
|
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 ye={},Gt={},tl;function Pm(){if(tl)return Gt;tl=1;var e=ud(),t=hd(),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
|
|
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={},nl;function Lm(){if(nl)return Cs;nl=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={},ol;function Im(){if(ol)return Ns;ol=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 sl;function Jr(){if(sl)return ye;sl=1;var e=Pm(),t=Lm(),n=Im();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 ye.createScalarToken=e.createScalarToken,ye.resolveAsScalar=e.resolveAsScalar,ye.setScalarValue=e.setScalarValue,ye.stringify=t.stringify,ye.visit=n.visit,ye.BOM=o,ye.DOCUMENT=s,ye.FLOW_END=r,ye.SCALAR=a,ye.isCollection=l,ye.isScalar=c,ye.prettyToken=i,ye.tokenType=d,ye}var
|
|
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 ye.createScalarToken=e.createScalarToken,ye.resolveAsScalar=e.resolveAsScalar,ye.setScalarValue=e.setScalarValue,ye.stringify=t.stringify,ye.visit=n.visit,ye.BOM=o,ye.DOCUMENT=s,ye.FLOW_END=r,ye.SCALAR=a,ye.isCollection=l,ye.isScalar=c,ye.prettyToken=i,ye.tokenType=d,ye}var xs={},rl;function fd(){if(rl)return xs;rl=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,13 +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
|
|
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={},al;function md(){if(al)return Rs;al=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={},il;function gd(){if(il)return _s;il=1;var e=Er,t=Jr(),n=fd();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 Es.Parser=d,Es}var vt={},nl;function jm(){if(nl)return vt;nl=1;var e=ad(),t=fo(),n=mo(),o=Uc(),s=B(),r=ld(),a=cd();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 vt.parse=d,vt.parseAllDocuments=c,vt.parseDocument=i,vt.stringify=h,vt}var ol;function Am(){if(ol)return W;ol=1;var e=ad(),t=fo(),n=ed(),o=mo(),s=io(),r=B(),a=ft(),l=ce(),c=mt(),i=gt(),d=zr(),h=id(),u=ld(),p=cd(),f=jm(),m=ao();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 We=Am();const Tm=5*1024*1024,Om=new Set([".js",".mjs",".css",".json",".svg",".png",".jpg",".webp",".woff2",".md"]),sl=["component","page"],rl=["filter","display","chart","relation"],Em=["value","dateRange","selection","set"],Cm=["query","act","ask","navigate"],al=["string","number","integer","boolean","object","array"],Nm=new Set(["type","properties","required","items","enum","title","description","default","minimum","maximum","minItems","maxItems","maxLength","x-workshop"]),il=["field","fields","variable","objectType","relationPath","actionType"],xm=new Set(["widget","fieldTypes","maxHops","tab","showIf"]),ll=["data","display","link"],ir=["string","number","boolean","date","datetime","object"],cl={"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} 从外部地址加载脚本:依赖须全部打进包里",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",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 Wr(e){const t=cl[e]??cl["zh-CN"],n=(o,s)=>Zl(t[o],s);return n.list=o=>o.join(t.and),n}function fn(e){const t=[],n=o=>{for(const s of Qt(o).sort()){if(s.startsWith(".")||s==="node_modules")continue;const r=H(o,s),a=hu(r);if(a.isDirectory())n(r);else{if(Yl(s).toLowerCase()===".zip")continue;t.push({path:r,name:Gl(e,r).split(cu).join("/"),size:a.size})}}};return n(e),t}const qe=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),jt=e=>typeof e=="string"&&e.trim()!=="";function Rm(e,t,n,o){(!qe(e)||!jt(e["zh-CN"]))&&n.push(o("label",{key:t}))}function dl(e,t,n,o,s){if(e===void 0){o&&n.push(s("required",{key:t}));return}(!(qe(e)&&[e.w,e.h].every(a=>Number.isInteger(a)&&a>0))||e.w>12)&&n.push(s("size",{key:t}))}function lr(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 cr(e,t="configSchema",n="zh-CN"){const o=Wr(n),s=[];if(!qe(e))return[o("object",{at:t})];for(const a of Object.keys(e))Nm.has(a)||s.push(o("unsupported",{at:t,key:a}));if(e.type!==void 0&&!al.includes(e.type)&&s.push(o("oneOf",{at:`${t}.type`,allowed:o.list(al)})),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(!qe(e.properties))s.push(o("object",{at:`${t}.properties`}));else for(const[a,l]of Object.entries(e.properties))s.push(...cr(l,`${t}.properties.${a}`,n));if(e.required!==void 0){const a=qe(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(...cr(e.items,`${t}.items`,n));const r=e["x-workshop"];if(r!==void 0)if(!qe(r))s.push(o("object",{at:`${t}.x-workshop`}));else{for(const a of Object.keys(r))xm.has(a)||s.push(o("unsupported",{at:`${t}.x-workshop`,key:a}));r.widget!==void 0&&!il.includes(r.widget)&&s.push(o("oneOf",{at:`${t}.x-workshop.widget`,allowed:o.list(il)})),r.tab!==void 0&&!ll.includes(r.tab)&&s.push(o("oneOf",{at:`${t}.x-workshop.tab`,allowed:o.list(ll)})),r.fieldTypes!==void 0&&lr(r.fieldTypes,`${t}.x-workshop.fieldTypes`,ir,s,o),r.showIf!==void 0&&!qe(r.showIf)&&s.push(o("object",{at:`${t}.x-workshop.showIf`}))}return s}function dd(e,t="zh-CN"){const n=Wr(t),o=[];if(!qe(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")),sl.includes(s.kind)||o.push(n("oneOf",{at:"kind",allowed:n.list(sl)})),/^\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")),jt(s.entry)||o.push(n("required",{key:"entry"})),Rm(s.label,"label",o,n),jt(s.description)||o.push(n("description")),s.kind!=="page"&&!rl.includes(s.category)&&o.push(n("oneOf",{at:"category",allowed:n.list(rl)})),o.push(...cr(s.configSchema,"configSchema",t)),!qe(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=>qe(l)&&jt(l.role)&&ir.includes(l.type))||o.push(n("dataFields",{types:n.list(ir)}))}return typeof s.follows!="boolean"&&o.push(n("boolean",{key:"follows"})),lr(s.emits,"emits",Em,o,n),lr(s.capabilities,"capabilities",Cm,o,n),s.describes!==void 0&&typeof s.describes!="boolean"&&o.push(n("boolean",{key:"describes"})),dl(s.defaultSize,"defaultSize",o,s.kind==="component",n),dl(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}function Pm(e,{language:t="zh-CN"}={}){const n=Wr(t),o=[],s=[];let r;try{r=JSON.parse(it(H(e,"manifest.json"),"utf8"))}catch(d){return{ok:!1,errors:[n("unreadable",{message:d.message})],warnings:s,files:[]}}o.push(...dd(r,t));const a=fn(e),l=a.reduce((d,h)=>d+h.size,0);l>Tm&&o.push(n("tooLarge",{total:l}));for(const d of a)Om.has(Yl(d.name).toLowerCase())||o.push(n("fileType",{name:d.name}));const c=jt(r.entry)?lu.normalize(r.entry.replace(/^\.\//,"")):null,i=a.find(d=>d.name===c);if(jt(r.entry)&&!i&&o.push(n("noEntry",{entry:r.entry})),i){const d=it(i.path,"utf8");r.element&&!d.includes(r.element)&&o.push(n("noElement",{element:r.element})),i.size>300*1024&&s.push(n("bigEntry"))}for(const d of a.filter(h=>/\.(m?js)$/.test(h.name))){const h=it(d.path,"utf8");(/import\s*\(\s*["'`]https?:\/\//.test(h)||/from\s+["']https?:\/\//.test(h))&&o.push(n("remoteScript",{name:d.name})),/\beval\s*\(|new\s+Function\s*\(/.test(h)&&s.push(n("evalUsed",{name:d.name}))}return a.some(d=>d.name==="README.md")||s.push(n("noReadme")),r.data?.source&&!a.some(d=>d.name==="preview.json")&&s.push(n("noPreview")),{ok:o.length===0,errors:o,warnings:s,files:a,manifest:r}}const Lm=(()=>{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 ud(e){let t=4294967295;for(const n of e)t=Lm[(t^n)&255]^t>>>8;return(t^4294967295)>>>0}function _m(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=bu(i),u=h.length>=i.length,p=u?i:h,f=ud(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 ul={"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 Im(e,t="zh-CN"){const n=(c,i)=>Zl((ul[t]??ul["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):wu(b);if(k.length!==u||ud(k)!==d)throw new Error(n("damaged",{name:g}));l.push({name:g,data:k})}return l}const Nn='"Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif',Vn={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:Nn,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:Nn,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:Nn,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:Nn,fontSize:13,radius:4,shadow:"none",density:"compact"}},hl={free:{type:"free",columns:2,sidePosition:"left",sideWidth:300,asideWidth:0,gap:"normal"}};re.done.value;const dr=re.overdue.value,hd=[re.active.value,dr],Mm={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"}},pd=(...e)=>Object.entries(Mm).filter(([t])=>!e.includes(t)).map(([,t])=>t);pd("alert");Vt("$status",hd);Vt("$status",hd),Vt("$status",[dr]),Vt("$status",[dr]),pd();const qm=(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 Fm(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=>qm({...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 Dm={sep:"、",object:e=>`${e} 必须是对象`,noOption:(e,t)=>`${e} 没有配置项 ${t}`,required:e=>`${e} 必填`,textMax:(e,t)=>`${e} 必须是不超过 ${t} 字的文本`,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} 不一致`},Bm={sep:", ",object:e=>`${e} must be an object`,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`,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}`},He=()=>fe({"zh-CN":Dm,"en-US":Bm}),Um=80;function fd(e,t,n,o){if(!Xt(t))return[He().object(o)];const s=typeof t.source=="string"?t.source:void 0;return md(e,t,n,o,{sourceId:s,config:t})}function zm(e,t){return{...t,sourceId:typeof e.source=="string"?e.source:t.sourceId,objectType:typeof e.objectType=="string"?e.objectType:t.objectType}}function Wm(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?[He().required(a)]:[];const c=l&&e.kind==="field"?{...e,of:l}:e;return Km(c,r,n,a,s,t)}function md(e,t,n,o,s){const r=He(),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=zm(t,s);for(const i of e)a.push(...Wm(i,t,n,o,c));return a}function Km(e,t,n,o,s,r){const a=He(),l=an(ue(n.spec,s.sourceId));switch(e.kind){case"text":{const c=e.max??Um;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 pl(e,t,n,o,s);case"fields":return!Array.isArray(t)||t.length===0?[a.pickProperty(o)]:t.flatMap((c,i)=>pl(e,c,n,`${o}[${i}]`,s));case"variable":return Ym(e.accepts,t,n,o,s);case"bindings":return Gm(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=Jn("source",n,s);return c===null?[a.needSource(o)]:Ce(t,c,o,l)}case"objectType":return typeof t=="string"&&Object.hasOwn(n.kn.objectTypes,t)?[]:[a.notObjectType(o)];case"relationPath":return Hm(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)?Ln(n.spec,Jt(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 fp(t,e,n,s.sourceId,Jn("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}=xp(e.on,s.config??{});return Mp(t,n.kn,n.spec,s.sourceId,c,o,i)}case"tool":return Xt(t)&&typeof t.box=="string"&&t.box!==""&&typeof t.tool=="string"&&t.tool!==""?[]:[a.pickTool(o)];case"mcpTool":return Xt(t)&&typeof t.mcp=="string"&&t.mcp!==""&&typeof t.tool=="string"&&t.tool!==""?[]:[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)=>Xt(c)?md(e.item,c,n,`${o}[${i}]`,s):[a.object(`${o}[${i}]`)])}}const gd="$key";function pl(e,t,n,o,s){if(e.objectKey&&t===gd&&!e.of)return[];const r=He(),a=Jn(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 Ym(e,t,n,o,s){const r=He(),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 bd(a,n,s)?[]:[yd(o,a.name)]}const yd=(e,t)=>He().objectsMismatch(e,t);function bd(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 Gm(e,t,n,o){const s=He();if(!Array.isArray(e))return[s.list(n)];if(e.length===0)return[];const r=Jn("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(!Xt(c)||typeof c.variable!="string")return[s.bindingShape(d)];const h=t.spec.variables.find(u=>u.name===c.variable);if(!h||!ha.includes(h.kind)){const u=t.spec.variables.filter(p=>ha.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 bd(h,t,o)?[]:[yd(d,h.name)]}})}function Hm(e,t,n,o,s=!1){const r=He(),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=so(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 Jn(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 Vm={date:"日期",number:"数字",text:"文本"};function Zn(e,t=" "){return e.map(n=>{const o=`${t}- ${n.key}(${n.label}${n.optional?",可选":""}):`;return n.kind==="list"?`${o}列表 ${n.min} 到 ${n.max} 项,每项:
|
|
155
|
-
${Zn(n.item,`${t} `)}`:o+Jm(n)}).join(`
|
|
156
|
-
`)}function Jm(e){switch(e.kind){case"text":return e.max?`文本,不超过 ${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?`,或 ${gd} 表示对象本身`:"";return`${t}名${n}${e.of?`,须为${Vm[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 mp(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 }:执行工厂里已发布 MCP 服务的 id 和其中工具的名称;不知道有哪些服务时不写,由构建者选择";case"eventType":return`${e.multiple?"事件类型 id 列表":"事件类型 id"}(eventTypes 里的 id${e.of==="report"?",须为知识网络里来源是用户登记的":""})`}}function Xt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Zm={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 }`},Xm={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 }`},Le=()=>fe({"zh-CN":Zm,"en-US":Xm}),fl=["self","record"],Qm=["title","subtitleField","daysBefore","daysAfter","tick","timeZone","timeZoneVariable","resourceSelection"],eg=["label","popoverFields","color","tone","colorField","snap","selection","filters"],tg=["result","tasks","resource","time","rules","plan"],Xn=3,ur=3,ml=4,gl=5,se=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Re=e=>typeof e=="string"&&e!=="";function De(e,t,n){return Object.keys(e).filter(o=>!t.includes(o)).map(o=>Le().noOption(n,o))}function wd(e,t,n,o=10){const s=Le();return e===void 0?n?[s.required(t)]:[]:!Array.isArray(e)||e.length>o||!e.every(Re)?[s.namesList(t,o)]:[]}function G(e,t,n=!0){return e===void 0&&!n?[]:Re(e)?[]:[Le().name(t)]}function kd(e,t){const n=Le();return e===void 0?[]:Array.isArray(e)?e.flatMap((o,s)=>se(o)&&Re(o.field)&&Wn.includes(o.op)?[]:[n.condition(`${t}[${s}]`)]):[n.conditionList(t)]}function hr(e,t,n){const o=Le();if(e===void 0)return n?[o.required(t)]:[];if(!se(e))return[o.object(t)];const s=[...De(e,["action","params"],t),...G(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")&&Re(a.name)||a.from==="const"&&(typeof a.value=="string"||typeof a.value=="number")||a.from==="context"&&Bs.includes(a.name)))&&s.push(o.paramFrom(`${t}.params.${r}`));return s}function yl(e,t){return Array.isArray(e)&&e.length>0&&e.length<=4&&e.every(Re)?[]:[Le().pathLength(t)]}function ng(e,t,n){const o=Le();if(!se(e))return[o.object(t)];const s=[...De(e,["objectType","assignField","start","end","status","titleFields","doneWhen","groupField","target","ready","predecessors","modify","rules"],t),...G(e.objectType,`${t}.objectType`),...G(e.assignField,`${t}.assignField`,n),...G(e.start,`${t}.start`,n),...G(e.end,`${t}.end`,n),...G(e.status,`${t}.status`,!1),...G(e.groupField,`${t}.groupField`,!1),...wd(e.titleFields,`${t}.titleFields`,!1,4),...kd(e.doneWhen,`${t}.doneWhen`),...hr(e.modify,`${t}.modify`,!1)];if(e.target!==void 0&&(se(e.target)?(s.push(...G(e.target.field,`${t}.target.field`)),e.target.path!==void 0&&s.push(...yl(e.target.path,`${t}.target.path`))):s.push(o.targetShape(`${t}.target`))),e.ready!==void 0&&(se(e.ready)?s.push(...yl(e.ready.path,`${t}.ready.path`),...G(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||!Re(r[0]))&&s.push(o.onePath(`${t}.predecessors.path`))}return e.rules!==void 0&&(!Array.isArray(e.rules)||e.rules.length>gl?s.push(o.rulesCount(`${t}.rules`,gl)):e.rules.forEach((r,a)=>{const l=se(r)?r.tool:void 0;!se(r)||!Re(r.name)||!se(l)||!Re(l.box)||!Re(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 bl(e,t,n){return e===void 0?[]:Array.isArray(e)&&e.length<=n&&e.every(o=>typeof o=="string")?[]:[Le().sourcesList(t,n)]}function og(e,t){return e===void 0?[]:se(e)?[...De(e,["tasks","resource","calendars","plan"],t),...bl(e.tasks,`${t}.tasks`,Xn),...G(e.resource,`${t}.resource`,!1),...bl(e.calendars,`${t}.calendars`,ur),...G(e.plan,`${t}.plan`,!1)]:[Le().object(t)]}function sg(e,t){if(e===void 0)return[];const n=Le();if(!se(e))return[n.object(t)];const o=De(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(...De(r,[...Qm,"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(...De(a,eg,`${t}.${s}.layers[${l}]`)):o.push(n.object(`${t}.${s}.layers[${l}]`))}))}}return o}function rg(e,t="scheduleModel"){const n=Le();if(!se(e))return[n.object(t)];const o=De(e,["result","tasks","resource","calendars","record","sources","display"],t);o.push(...og(e.sources,`${t}.sources`),...sg(e.display,`${t}.display`)),fl.includes(e.result)||o.push(n.oneOf(`${t}.result`,fl.join(n.joiner)));const s=e.result==="self",r=s?Xn:1;!Array.isArray(e.tasks)||e.tasks.length===0||e.tasks.length>r?o.push(s?n.tasksSelf(`${t}.tasks`,Xn):n.tasksRecord(`${t}.tasks`)):e.tasks.forEach((c,i)=>o.push(...ng(c,`${t}.tasks[${i}]`,s)));const a=e.resource;se(a)?(o.push(...De(a,["objectType","titleField","parentField","groupField","capacityField"],`${t}.resource`),...G(a.objectType,`${t}.resource.objectType`),...G(a.titleField,`${t}.resource.titleField`),...G(a.parentField,`${t}.resource.parentField`,!1),...G(a.groupField,`${t}.resource.groupField`,!1),...G(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>ur?o.push(n.calendarsCount(`${t}.calendars`,ur)):e.calendars.forEach((c,i)=>{const d=`${t}.calendars[${i}]`;return se(c)?(o.push(...De(c,["objectType","resourceField","start","end","inherit"],d),...G(c.objectType,`${d}.objectType`),...G(c.resourceField,`${d}.resourceField`),...G(c.start,`${d}.start`),...G(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(...De(l,["objectType","match","resourceField","start","end","status","titleFields","active","create","modify","days","daysField"],c),...G(l.objectType,`${c}.objectType`),...G(l.resourceField,`${c}.resourceField`,!1),...G(l.start,`${c}.start`),...G(l.end,`${c}.end`),...G(l.status,`${c}.status`,!1),...wd(l.titleFields,`${c}.titleFields`,!1,4),...G(l.daysField,`${c}.daysField`,!1),...l.days!==void 0&&(typeof l.days!="number"||!(l.days>0)||l.days>365)?[n.days(`${c}.days`)]:[],...kd(l.active,`${c}.active`),...hr(l.create,`${c}.create`,!1),...hr(l.modify,`${c}.modify`,!1)),l.match!==void 0&&(!Array.isArray(l.match)||l.match.length>ml?o.push(n.matchCount(`${c}.match`,ml)):l.match.forEach((i,d)=>{(!se(i)||!Re(i.from)||!Re(i.to))&&o.push(n.matchShape(`${c}.match[${d}]`))}))}return o}function ag(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 ig={object:e=>`${e} 必须是对象`,noOption:(e,t)=>`${e} 没有配置项 ${t}`,notBoth:e=>`${e} 不能同时是 Cypher 数据源和事件数据源`,mustBe:(e,t)=>`${e} 必须是 ${t}`,typesList:e=>`${e} 必须是事件类型 id 列表`},lg={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":ig,"en-US":lg}),dg="events:",pr="event_id",fr=e=>`${dg}${e}`,ug=[{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 hg(e,t){return{id:fr(e),name:t,primaryKeys:[pr],displayKey:"title",properties:ug}}function pg(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!==fr(String(e.id))&&o.push(n.mustBe(`${t}.objectType`,fr(String(e.id)))),e.key!==pr&&o.push(n.mustBe(`${t}.key`,pr));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 fg={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`},mg={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`},yo=()=>fe({"zh-CN":fg,"en-US":mg}),gg="model:",mr=e=>`${gg}${e}`,wl=5,kl=5,vl=8,$l=10,Sl=10,jl=20,_n=/^[A-Za-z][A-Za-z0-9_]*$/,vd=/^\d{4}-\d{2}-\d{2}$/,at=["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:mr(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:at.includes(o.type)?o.type:"text"}))}}function yg(e,t){return e.find(o=>o.id===t)?.from?.source??t}function Al(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=>yg(e,r.source)).filter(r=>n.has(r));return[...new Set(s)]}function bg(e,t="scenarioParams"){if(e===void 0)return[];const n=yo();if(!Array.isArray(e)||e.length>$l)return[n.list(t,$l)];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"||!_n.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`)),!at.includes(s.type))return[...l,n.oneOf(`${a}.type`,at.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"||!vd.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>Sl)l.push(n.optionsCount(`${a}.options`,Sl));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 wg(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!==rn)}const Tl=128,Ol=40,kg=["result_id","row_key","scenario_id","scenario_name","run_id","as_of","computed_at","app_id","source_id"];function vg(e,t,n){const o=yo(),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>Tl&&r.push(o.saveAsNameLong(`${s}.name`,Tl)):r.push(o.saveAsName(`${s}.name`));for(const l of t)l.length>Ol&&r.push(o.outputTooLong(`${n}.model.outputs`,l,Ol)),kg.includes(l)&&r.push(o.outputFixedName(`${n}.model.outputs`,l));return r}function $g(e,t,n){const{sources:o,kn:s,variables:r,scenarioParams:a}=t,l=yo(),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!==mr(e.id)&&i.push(l.objectTypeMustBe(`${n}.objectType`,mr(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>wl)i.push(l.inputsCount(`${n}.model.inputs`,wl));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"||!_n.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(wg(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?Al(o,v).some(k):!1};return k(y)};Al(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>kl)i.push(l.paramsCount(`${n}.model.params`,kl));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"||!_n.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),!at.includes(g.type))return i.push(l.oneOf(`${b}.type`,at.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"&&!vd.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>vl+1?i.push(l.outputsCount(`${n}.model.outputs`,vl)):p.forEach((m,g)=>{const y=`${n}.model.outputs[${g}]`;return te(m)?(typeof m.name!="string"||!_n.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`)),at.includes(m.type)||i.push(l.oneOf(`${y}.type`,at.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(...Sg(c.landing,e,s,n)),c.saveAs!==void 0&&i.push(...vg(c.saveAs,f,n)),i}function Sg(e,t,n,o){const s=yo(),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(...Ce(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=sn(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>jl)a.push(s.prefix(`${r}.action.newObject.prefix`,jl));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 jg={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} 变量`},Ag={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`},Sd=()=>fe({"zh-CN":jg,"en-US":Ag}),Tg="cypher:";function gr(e){return`${Tg}${e}`}const Og=["asOf","value","search","selection"];function jd(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=hg(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=gr(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 Ad(e){return e.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`[^`]*`/g,t=>" ".repeat(t.length))}function Eg(e){const t=[...Ad(e).matchAll(/\$([A-Za-z_][A-Za-z0-9_]*)/g)].map(n=>n[1]);return[...new Set(t)]}const Cg=/\b(CREATE|MERGE|SET|DELETE|DETACH|REMOVE|DROP|CALL|LOAD|FOREACH)\b/i;function Ng(e,t){const n=Sd(),o=[],s=e.cypher;if(typeof s!="object"||s===null)return[n.object(t)];if(e.objectType!==gr(String(e.id))&&o.push(n.objectType(t,gr(String(e.id)))),typeof s.query!="string"||s.query.trim()===""?o.push(n.queryRequired(t)):Cg.test(Ad(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 xg(e,t,n){if(!e.cypher)return[];const o=Sd(),s=[],r=e.cypher.params??{};for(const a of Eg(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?Og.includes(c.kind)||s.push(o.badKind(n,a,c.kind)):s.push(o.notVariable(n,a))}return s}new TextEncoder;const Rg=/\{([^{}]+)\}/g;function Pg(e){return[...e.matchAll(Rg)].map(t=>t[1].trim())}const Lg={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 相同`},_g={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`},bo=()=>fe({"zh-CN":Lg,"en-US":_g}),yr=5,br=3,Qn=3,eo=365,to=1439,Td=/^[A-Za-z][A-Za-z0-9_]*$/,Od=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Ig=e=>!e.from&&!e.cypher&&!e.events;function Ed(e,t,n,o,s){if(!t)return[];const r=bo();if(!Array.isArray(e)||e.length===0||e.length>Qn||!e.every(c=>typeof c=="string"))return[r.pathCount(s,Qn)];const a=so(o,t.objectType,e);return a?a[a.length-1].to===n.objectType?[]:[r.pathEnd(s,ph(o,t.objectType,e),n.objectType)]:[r.notPath(s,t.objectType)]}function Cd(e,t,n){const o=bo(),s=t.find(r=>r.id===e);return s?Ig(s)?{source:s,errors:[]}:{errors:[o.fromLinkable(n)]}:{errors:[o.fromSource(n)]}}const Cs=(e,t,n)=>e.objectTypes[t]?.properties.find(o=>o.name===n&&o.type==="date");function Mg(e,t,n,o,s){const r=bo();if(!Array.isArray(e)||e.length>yr)return[r.list(s,yr)];const a=o.objectTypes[t.objectType],l=new Set;return e.flatMap((c,i)=>{const d=`${s}[${i}]`;if(!Od(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"||!Td.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),Cs(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=Cd(c.from,n,`${d}.from`);return h.push(...u.errors),h.push(...Ed(c.path,u.source,t,o,`${d}.path`)),u.source&&!Cs(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)>eo)&&h.push(r.integerRange(`${d}.gapDays`,eo)),c.gapMinutes!==void 0&&(typeof c.gapMinutes!="number"||!Number.isInteger(c.gapMinutes)||Math.abs(c.gapMinutes)>to)&&h.push(r.integerRange(`${d}.gapMinutes`,to)),c.keepDuration!==void 0&&(Cs(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 qg(e,t,n,o,s){const r=bo();if(!Array.isArray(e)||e.length>br)return[r.list(s,br)];const a=new Set;return e.flatMap((l,c)=>{const i=`${s}[${c}]`;if(!Od(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"||!Td.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=Cd(l.from,n,`${i}.from`);return d.push(...h.errors),d.push(...Ed(l.path,h.source,t,o,`${i}.path`)),d})}const Fg={notString:"default 必须是字符串",noDefault:e=>`${e} 变量不能有默认值`,asOf:"基准日期的默认值必须是 today 或 YYYY-MM-DD",dateRange:"日期区间的默认值必须是 YYYY-MM-DD..YYYY-MM-DD(可省略一端)"},Dg={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)"},Bg=()=>fe({"zh-CN":Fg,"en-US":Dg}),Ug="today",El=/^\d{4}-\d{2}-\d{2}$/,zg=["asOf","value","dateRange","search"],Wg="..";function Kg(e){const t=e.default;if(t===void 0)return null;const n=Bg();if(typeof t!="string")return n.notString;if(!zg.includes(e.kind))return n.noDefault(e.kind);switch(e.kind){case"asOf":return t===Ug||El.test(t)&&!Number.isNaN(Date.parse(t))?null:n.asOf;case"dateRange":{const o=t.split(Wg);return o.length===2&&o.every(r=>r===""||El.test(r))&&o.some(r=>r!=="")?null:n.dateRange}default:return null}}const Yg={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} 必须是角色名`},Gg={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`},Nt=()=>fe({"zh-CN":Yg,"en-US":Gg}),Hg=/^[a-z0-9][a-z0-9_.-]{0,63}$/,Vg=/^[a-z][a-z0-9_-]{0,39}$/,Cl=720,Jg=new Set(["id","owners","dueHours","report","analysis","grouping","strategies","strategyActions"]),Zg=new Set(["label","source","subject","severity","rule"]),Ye=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Xg=(e,t)=>e===void 0||typeof e=="number"&&Math.abs(e*60-Math.round(e*60))<1e-6&&e*60>=1&&e<=Cl?[]:[Nt().hours(t,Cl)],Nd=(e,t)=>e.objectType&&t.kn.objectTypes[e.objectType]?.name||e.objectType||"";function Qg(e,t,n,o){const s=Nt();if(!Ye(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(!Ye(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?oc({on:"button",...l},{on:["button"],hit:!0},n,t.subject,c):[s.noSubjectSource(c,Nd(t,n))]:[]})}function ey(e,t,n){const o=Nt();if(e!==void 0&&!Array.isArray(e))return[o.eventTypesList()];const s=Array.isArray(e)?e:[],r=Jt(t.kn.eventTypes),a=new Set,l=new Set(s.map(i=>Ye(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(!Ye(i))return[o.object(h)];const u=[];for(const f of Object.keys(i))Zg.has(f)?u.push(o.inNetwork(`${h}.${f}`)):Jg.has(f)||u.push(o.noOption(h,f));if(typeof i.id!="string"||!Hg.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=Ec(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(...Xg(i.dueHours,`${h}.dueHours`)),i.report!==void 0&&(p.source==="rule"?u.push(o.reportRule(`${h}.report`)):u.push(...oy(i.report,`${h}.report`))),i.analysis!==void 0&&u.push(...ny(i.analysis,p,t,n,`${h}.analysis`)),i.grouping!==void 0&&u.push(...ty(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(...Qg(i,p,t,`${h}.strategyActions`)),u})]}function ty(e,t,n,o){const s=Nt();if(!Ye(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(!zs.includes(e.mode))return[...r,s.groupingMode(`${o}.mode`,zs)];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,Nd(t,n))),r}function ny(e,t,n,o,s){const r=Nt();if(!Ye(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(!Ye(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=Nt();if(!Ye(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(!Ye(a))return o.push(n.object(c));typeof a.name!="string"||!Vg.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`)),Us.includes(a.type)||o.push(n.fieldType(`${c}.type`,Us)),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 sy={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} 行高`},ry={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`},be=()=>fe({"zh-CN":sy,"en-US":ry}),Nl=/^#[0-9a-fA-F]{6}$/,wo=/^[A-Za-z][A-Za-z0-9_-]{0,39}$/,ay=/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/,iy=["colorPrimary","colorAccent","colorBg","colorSurface","colorSurfaceAlt","colorBorder","colorText","colorTextMuted","colorSuccess","colorWarning","colorDanger","colorInfo"],wr=4.5,kr=3;function ly(e,t,n={}){const o=be(),s=[],r=c=>s.push(c);if(!K(e))return{ok:!1,errors:[o.pageNotObject]};const a=jd(t,e.sources);if(e.version!==2&&r(o.version),(typeof e.title!="string"||e.title.trim()==="")&&r(o.nonEmptyString("title")),hy(e.layout,r),py(e.theme,r),s.length>0)return{ok:!1,errors:s};if(fy(e.sources,a,r),s.length>0)return{ok:!1,errors:s};if(vy(e.variables,e,r),s.length>0)return{ok:!1,errors:s};if(e.sources.forEach((c,i)=>xg(c,e.variables,`sources[${i}]`).forEach(r)),s.length>0)return{ok:!1,errors:s};if(bg(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 $y(e,{kn:a,spec:l},r,n.allowEmpty??!1),s.length>0?{ok:!1,errors:s}:{ok:!0,spec:l}}const cy=()=>be().emptyApp;function xd(e,t,n={}){const o=be();if(!K(e))return{ok:!1,errors:[o.appNotObject]};const s=[],r=u=>s.push(u);e.apiVersion!==ht&&r(o.apiVersion(String(ht)));const a=e.app;K(a)?((typeof a.id!="string"||!ay.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"||!wo.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(dy(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:[cy()]};for(const u of i.pages){const p=ly(Zt(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(...ey(e.eventTypes,{kn:jd(t,i.sources),spec:Zt(i,i.pages[0].id)},i.pages.map(u=>u.id))),e.scheduleModel!==void 0&&s.push(...rg(e.scheduleModel)),s.length>0?{ok:!1,errors:s}:{ok:!0,app:i})}function dy(e,t){if(e===void 0)return;const n=be();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(!Ot(s.type))return t(n.customType(a));o.has(s.type)&&t(n.customTwice(s.type)),o.add(s.type),(typeof s.package!="string"||!uy.test(s.package))&&t(n.packageId(a)),s.source!==void 0&&!Ue(s.source,["upload","ai"])&&t(n.either(`${a}.source`,"upload","ai"))})}const uy=/^[0-9a-f]{64}$/;function hy(e,t){const n=be();if(!K(e))return t(n.object("layout"));Ue(e.type,_s)||t(n.oneOf("layout.type",n.join(_s))),Pe(e.columns,2,4,"layout.columns",t),Ue(e.sidePosition,["left","right"])||t(n.either("layout.sidePosition","left","right")),Pe(e.sideWidth,220,420,"layout.sideWidth",t),e.asideWidth!==0&&Pe(e.asideWidth,240,420,n.asideWidth,t),Ue(e.gap,["compact","normal","relaxed"])||t(n.oneOf("layout.gap",n.join(["compact","normal","relaxed"]))),e.pinRows!==void 0&&Pe(e.pinRows,0,Tr,"layout.pinRows",t)}function py(e,t){const n=be();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")),Ue(e.mode,["light","dark"])||s(n.either("theme.mode","light","dark"));for(const c of iy)(typeof e[c]!="string"||!Nl.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"&&Nl.test(c))||s(n.chartPaletteHex),(typeof e.fontFamily!="string"||e.fontFamily.trim()===""||/[;{}<>]/.test(e.fontFamily))&&s(n.fontFamily),Pe(e.fontSize,12,16,"theme.fontSize",s),Pe(e.radius,0,16,"theme.radius",s),Ue(e.shadow,Is)||s(n.oneOf("theme.shadow",n.join(Is))),Ue(e.density,Ms)||s(n.oneOf("theme.density",n.join(Ms))),o.forEach(t),o.length>0)return;const a=e.colorText;for(const c of["colorBg","colorSurface"]){const i=Rl(a,e[c]);i<wr&&t(n.contrast("colorText",c,i.toFixed(2),wr))}const l=Rl(e.colorTextMuted,e.colorSurface);l<kr&&t(n.contrast("colorTextMuted","colorSurface",l.toFixed(2),kr))}function fy(e,t,n){const o=be();if(!Array.isArray(e)||e.length===0)return n(o.sourcesMin);const s=new Set;e.forEach((r,a)=>{const l=`sources[${a}]`;if(!K(r))return n(o.object(l));if(typeof r.id!="string"||!wo.test(r.id)?n(o.identifier(`${l}.id`)):s.has(r.id)?n(o.sourceTwice(r.id)):s.add(r.id),(typeof r.label!="string"||r.label.trim()==="")&&n(o.required(`${l}.label`)),r.from!==void 0)return yy(r,e,t,l).forEach(n);if(r.model!==void 0){if(!K(r.model))return n(o.object(`${l}.model`))}else if(r.events!==void 0){const h=pg(r,l);if(h.forEach(n),h.length>0)return}else if(r.cypher!==void 0){const h=Ng(r,l);if(h.forEach(n),h.length>0)return}const c=typeof r.objectType=="string"&&Object.hasOwn(t.objectTypes,r.objectType)?t.objectTypes[r.objectType]:void 0;if(!c)return n(o.notObjectType(l));((h,u)=>c.properties.find(f=>f.name===h)&&!0)(r.key)||n(o.notProperty(l,c.id)),Up(r.progress,c.properties,`${l}.progress`).forEach(n);const d=K(r.progress)&&Array.isArray(r.progress.steps);Nh(r.computed,[...c.properties,...d?ac(r.progress):[]],`${l}.computed`,{kn:t,objectType:c.id,cypher:r.cypher!==void 0,progress:d,sources:e.filter(K),...typeof r.id=="string"?{source:r.id}:{}}).forEach(n),r.display!==void 0&&my(r.display,r,t,`${l}.display`).forEach(n),r.formats!==void 0&&gy(r.formats,r,t,`${l}.formats`).forEach(n),r.operations!==void 0&&(r.cypher!==void 0||r.events!==void 0?n(o.onlyObjectSources(`${l}.operations`)):zh(r.operations,r,t,`${l}.operations`).forEach(n)),r.models!==void 0&&(r.cypher!==void 0||r.events!==void 0||r.model!==void 0?n(o.onlyObjectSources(`${l}.models`)):Vh(r.models,r,t,`${l}.models`).forEach(n));for(const h of["follows","relatedTo"]){if(r[h]===void 0)continue;if(r.cypher!==void 0||r.events!==void 0||r.model!==void 0){n(o.onlyObjectSources(`${l}.${h}`));continue}(h==="follows"?Mg:qg)(r[h],r,e.filter(K),t,`${l}.${h}`).forEach(n)}})}function my(e,t,n,o){const s=be();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=Pg(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>ua||!e.facts.every(i=>typeof i=="string"))l.push(s.factsList(o,ua));else for(const i of e.facts)a(i)||l.push(s.factsNotField(o,i));return l}function gy(e,t,n,o){const s=be();if(!K(e))return[s.formatsShape(o)];const r=pe(t,n),a=an(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>Fs?l.push(s.decimalsInt(d,Fs)):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));Ue(u.tone,Et)||l.push(s.oneOf(`${f}.tone`,s.join(Et))),l.push(...Ce(u.when,r,`${f}.when`,a))})}}return l}function yy(e,t,n,o){const s=be(),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(...Ce(r.where,i,`${o}.from.where`,an(c)))}return l}const by=[{key:"source",label:"来源数据源",kind:"source"},{key:"filters",label:"跟随的筛选",kind:"bindings",optional:!0}];function wy(e,t,n){const o=be(),s=e.scenarioParams??[];e.sources.forEach((r,a)=>{const l=`sources[${a}]`;r.model&&($g(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};fd(by,r,{kn:t,spec:e},`sources[${s}].from`).forEach(n)})}function vy(e,t,n){const o=be();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"||!wo.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`)),!Ue(r.kind,Kn))return n(o.oneOf(`${l}.kind`,o.join(Kn)));const c=Kg(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 $y(e,t,n,o){const s=be(),{layout:r,regions:a}=t.spec;if(!K(a))return n(s.object("regions"));const l=sc[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"||!wo.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=Ot(m.type);if(b&&!i.has(m.type))return n(s.customNoPackage(y,String(m.type)));if(!b&&!Ue(m.type,Ke))return n(s.typeOneOf(y,s.join(Ke)));const k=m.type;d++,m.span!==void 0&&Pe(m.span,1,4,`${y}.span`,n),r.type==="free"&&Sy(m.frame,k,`${s.component(String(m.id))}.frame`,n),xl(k,Ot(k)&&K(m.config)?nf(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"),xl(me,u.config,t,s.component(String(u.id)),n)}}function xl(e,t,n,o,s){const r=ut(e),a=fd(r.descriptors,t,n,o);a.forEach(s),a.length===0&&r.check&&r.check(t,n,o).forEach(s)}function Sy(e,t,n,o){const s=be();if(!K(e))return o(s.frameShape(n));Pe(e.x,0,yn-1,`${n}.x`,o),Pe(e.w,1,yn,`${n}.w`,o),Pe(e.y,0,400,`${n}.y`,o),Pe(e.h,2,40,`${n}.h`,o),typeof e.x=="number"&&typeof e.w=="number"&&e.x+e.w>yn&&o(s.frameRight(n,yn));const[r,a]=Jp(t);(typeof e.w=="number"&&e.w<r||typeof e.h=="number"&&e.h<a)&&o(s.frameSmall(n,t,r,a))}function Rl(e,t){const[n,o]=[Pl(e),Pl(t)].sort((s,r)=>r-s);return(n+.05)/(o+.05)}function Pl(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 Ue(e,t){return typeof e=="string"&&t.includes(e)}function Pe(e,t,n,o,s){(typeof e!="number"||!Number.isInteger(e)||e<t||e>n)&&s(be().integer(o,t,n))}const jy="scheduleWorkbench",Ay=[{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"}]]}]}],Ty={id:"blank"};function Oy(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 Ey(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 Ll=e=>JSON.parse(JSON.stringify(e));function Cy(e){const t=JSON.stringify(e.pages);return{...e,variables:e.variables.filter(n=>n.kind==="asOf"||t.includes(`"${n.name}"`))}}const Ny=e=>Be[e]?.category==="scenario";function xy(e){return{...e,pages:e.pages.map(t=>{const n=t.regions.cells??[],o=Fm(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 Ry(e,t,n,o,{scenarios:s=!0}={}){const r=Ay.find(g=>g.id===e),a=o&&n.objectTypes[o]||Oy(n),l={apiVersion:ht,app:t,dependencies:{knowledgeNetwork:{id:n.id,name:n.name}},sources:[],variables:[{name:"asOf",label:"基准日期",kind:"asOf"}],pages:[{id:"main",title:"页面 1",layout:structuredClone(hl.free),regions:{}}],theme:structuredClone(Vn.default)};if(!a)return{spec:l,skipped:[]};const c={id:ag(Zt(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:Ey(i,c),pages:r.pages.map((g,y)=>({id:y===0?"main":`page${y+1}`,title:g.title,layout:structuredClone(hl.free),regions:{cells:[]}})),theme:structuredClone(Vn[r.theme])};const h=[],u=new Set,p=g=>{for(let y=1;;y++)if(!u.has(`${g}${y}`))return`${g}${y}`},f=g=>xd(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&&Ny(S))continue;const I=Zt(d,b),M={id:p(S),type:S,config:Ll({...ut(S).defaults(I,{kn:n,spec:I},c.id),...x}),frame:{x:j,y:O,w:A,h:E}},_=Py(d,y,M);(S!=="asOfSlider"||m)&&f(_)?(d=_,u.add(M.id)):h.push(S)}const k=Zt(d,b),w={id:y===0?"detail":`detail${y+1}`,type:me,config:Ll(ut(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:xy(Cy(d)),skipped:h}}function Py(e,t,n){return{...e,pages:e.pages.map((o,s)=>s===t?{...o,regions:{cells:[...o.regions.cells??[],n]}}:o)}}const Ly={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={},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
|
+
${Qn(n.item,`${t} `)}`:o+hg(n)}).join(`
|
|
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 <命令> [参数] [选项]
|
|
157
158
|
|
|
158
159
|
list 列出能看到的应用
|
|
159
160
|
create <网络> <名称> [目录] 在知识网络上新建一个空应用并拉取;<网络> 为网络 id 或名称,目录默认以应用名命名
|
|
@@ -165,14 +166,15 @@ ${Zn(n.item,`${t} `)}`:o+Jm(n)}).join(`
|
|
|
165
166
|
dev [目录] 边改边推:文件停改 1 秒后自动校验并推送,按 Ctrl+C 结束
|
|
166
167
|
preview [目录] 打开平台上这个应用的预览页
|
|
167
168
|
--no-open 只打印地址
|
|
168
|
-
skill add | remove 把本包带的 skill(${e})装进 Claude Code、Codex,或卸掉
|
|
169
|
+
skill add | remove 把本包带的 skill(${e})装进 Claude Code、Codex、WorkBuddy,或卸掉
|
|
169
170
|
|
|
170
171
|
-k, --insecure 平台是自签证书时使用(拉取时记进工程目录)
|
|
171
172
|
--lang <语言> zh-CN 或 en-US;默认依次看 WORKSHOP_LANG、系统语言(LANG 等),都没有时为中文
|
|
172
173
|
-h, --help 显示本说明
|
|
174
|
+
-v, --version 显示开发包版本
|
|
173
175
|
|
|
174
176
|
目录默认为当前目录。平台地址与令牌取自 openbkn 命令行(先 openbkn auth login <平台地址>),
|
|
175
|
-
也可以用环境变量 BKN_BASE_URL 与 BKN_TOKEN 给出。`,noCommand:e=>`没有命令 ${e}`,skillUsage:"用法:workshop skill add | remove",noSkillSource:"找不到本包的 skill:请用安装好的 workshop 命令运行",createUsage:"用法:workshop create <网络> <名称> [目录]",noBrowser:"没能打开浏览器,请复制上面的地址打开",note:e=>`提示:${e}`,at:(e,t)=>`${e}:${t}`,and:"、",quoted:e=>`「${e}」`,notProject:(e,t)=>`${e} 不是 Workshop 应用的工程目录:先运行 workshop pull <应用> ${t}`,noAppFile:(e,t)=>`${e} 下没有 ${t}:运行 workshop pull ${e} 重新拉取`,ambiguousApp:(e,t,n)=>`有 ${e} 个应用叫「${t}」,请写应用 id:
|
|
177
|
+
也可以用环境变量 BKN_BASE_URL 与 BKN_TOKEN 给出。`,noCommand:e=>`没有命令 ${e}`,noVersion:"不知道开发包版本:请用安装好的 workshop 命令运行",skillUsage:"用法:workshop skill add | remove",noSkillSource:"找不到本包的 skill:请用安装好的 workshop 命令运行",createUsage:"用法:workshop create <网络> <名称> [目录]",noBrowser:"没能打开浏览器,请复制上面的地址打开",note:e=>`提示:${e}`,at:(e,t)=>`${e}:${t}`,and:"、",quoted:e=>`「${e}」`,notProject:(e,t)=>`${e} 不是 Workshop 应用的工程目录:先运行 workshop pull <应用> ${t}`,noAppFile:(e,t)=>`${e} 下没有 ${t}:运行 workshop pull ${e} 重新拉取`,ambiguousApp:(e,t,n)=>`有 ${e} 个应用叫「${t}」,请写应用 id:
|
|
176
178
|
${n}`,appNotFound:e=>`没有找到应用「${e}」,或你没有权限查看它`,appIdNotFound:e=>`没有找到应用 ${e},或你没有权限查看它`,conflict:(e,t,n)=>`平台上的草稿已有别人的改动(草稿版本 ${e}),本地的 ${t} 也有还没推送的改动,所以没有覆盖。
|
|
177
179
|
平台上的版本在 ${n}:把两边要保留的改动合并进本地的 ${t},再运行 workshop push --merged`,componentKept:(e,t)=>`平台上已没有组件 ${e},${t} 有改动,保留了:推送时会把它加回应用;不要它就删掉这个目录`,componentRemoved:(e,t)=>`已删除 ${e}:平台上已没有组件 ${t}`,folderTaken:(e,t)=>`${e} 已有别的内容,没有下载组件 ${t}`,downloaded:(e,t)=>`已下载组件 ${e} 到 ${t}`,notDownloadedBehind:(e,t,n)=>`组件 ${e} 的组件包没有下载下来(${t}):${n} 不是平台上的版本,推送时不会用它;再运行 workshop pull 下载`,notDownloaded:(e,t)=>`组件 ${e} 的组件包没有下载下来(${t}):再运行 workshop pull 下载`,pulled:(e,t,n)=>`已拉取「${e}」(草稿版本 ${t})到 ${n}`,blankApp:"应用还是空白的:app.yaml 是构建器的空白模板,推送后才保存到平台上",networkAt:(e,t)=>`知识网络「${e}」的结构在 ${t}`,upToDate:e=>`已是最新(草稿版本 ${e})`,updatedTo:e=>`已更新到平台上的草稿版本 ${e}`,localOnly:e=>`${e} 有还没推送的改动,平台上没有新的改动:改好后运行 workshop push`,noApps:"没有能看到的应用:用 workshop create <网络> <名称> 新建一个",appLine:(e,t,n,o,s)=>`${e} ${t}(知识网络「${n}」,草稿版本 ${o},${s>0?`已发布第 ${s} 版`:"未发布"})`,ambiguousNetwork:(e,t,n)=>`有 ${e} 个知识网络叫「${t}」,请写网络 id:
|
|
178
180
|
${n}`,networkNotFound:(e,t,n,o)=>`没有找到知识网络「${e}」,或你没有权限查看它`+(t?`。能看到的知识网络:${t}${o?` 等 ${n} 个`:""}`:""),emptyName:"应用名称不能为空",alreadyProject:(e,t)=>`${e} 已是应用「${t}」的工程目录:换一个目录`,hasAppFile:(e,t)=>`${e} 下已有 ${t}:换一个目录`,noCreateRight:e=>`你没有在知识网络「${e}」上新建应用的权限`,created:(e,t,n)=>`已在知识网络「${e}」上新建应用「${t}」(${n})`,otherProject:(e,t,n,o)=>`${e} 是应用「${t}」(${n})的工程目录,不是「${o}」的`,firstPullNeedsApp:"第一次拉取要写应用:workshop pull <应用 id 或名称> [目录]",notPulled:(e,t)=>`${e} 下已有 ${t},但不是用 workshop pull 拉取的:换一个目录`,sameType:(e,t)=>`与 ${e} 是同一个组件类型 ${t}`,behindChanged:e=>`平台上的组件 ${e} 已更新、还没下载下来,这个目录是旧版本,改动没有推送:先运行 workshop pull 下载新版本,再把改动合进去`,apiVersion:(e,t,n)=>`${e} 的 apiVersion 是 ${t},这个开发包认得的是 ${n}:请安装与平台 Workshop 同版本的开发包`,manifestUnreadable:e=>`组件包 ${e} 的清单读不到,或类型对不上:没有按它的配置项校验`,errorCount:e=>`共 ${e} 处错误`,validated:"校验通过:可以推送",forbidden:"你没有修改这个应用的权限",appGone:e=>`应用 ${e} 已不在平台上,或你没有权限查看它`,tooLarge:"超过了平台允许的大小",nothingToMerge:"没有要合并的平台草稿:直接运行 workshop push",unchanged:"没有改动,不用推送",backToPushed:"已改回上次拉取或推送时的样子,不用推送",invalidNotPushed:"校验没通过,没有推送",uploaded:(e,t)=>`已上传 ${e}(${t})`,uploadRefused:(e,t)=>`${e} 上传没通过:${t}`,pushed:e=>`已推送:草稿版本 ${e}`,preview:e=>`预览:${e}`,syncedPushAgain:"平台上的草稿有别人的改动,已拉取到本地,没有冲突:再运行 workshop push",syncedPushing:"平台上的草稿有别人的改动,已拉取到本地,没有冲突:接着推送",devStarted:(e,t)=>`边改边推:${e} 与 ${t}/ 有改动就校验并推送;按 Ctrl+C 结束`,skillTaken:e=>`${e} 已有别的内容,不是 workshop skill add 装的,没有动它:要装本包的 skill,先把它挪走`,noSkillFiles:e=>`找不到 skill 的文件:${e}`,skillInstalled:(e,t)=>`已安装 skill ${e}:${t}`,skillLink:(e,t,n)=>` ${e}:${t}${n?"(复制)":""}`,skillNext:"新开一个 IDE 会话后生效;升级开发包后再运行一次 workshop skill add 换成新版",skillNotOurs:e=>`${e} 不是 workshop skill add 装的,没有删`,removed:e=>`已删除 ${e}`,noSkill:e=>`没有装过 skill ${e}`,noOpenbkn:"找不到 openbkn 命令行:安装 @openbkn/bkn-sdk 后运行 openbkn auth login <平台地址>,或设置环境变量 BKN_BASE_URL 与 BKN_TOKEN",openbknFailed:(e,t)=>`openbkn ${e} 失败:${t}`,otherPlatform:(e,t)=>`这个工程目录属于平台 ${e},BKN_BASE_URL 却是 ${t}`,notLoggedIn:"openbkn 还没有登录:先运行 openbkn auth login <平台地址>",otherLogin:(e,t)=>`openbkn 当前登录的平台是 ${e},不是 ${t}:先运行 openbkn auth use ${t},或设置 BKN_TOKEN`,tokenWithoutBase:"设置了 BKN_TOKEN,也要设置 BKN_BASE_URL(平台地址)",httpStatus:(e,t,n)=>`${e} 返回 ${t}${n?`:${n}`:""}`,timeout:(e,t)=>`${e} 超过 ${t} 秒没有回应`,certificate:(e,t)=>`平台 ${e} 的证书校验不通过(${t}):自签证书的平台加 -k(--insecure)`,unreachable:(e,t)=>`连不上平台 ${e}(${t})`,unsafePath:e=>`组件包里有不能写出的路径:${e}`,notInCli:"命令行不提供这项功能",rulesHeader:"# App Spec 的规则\n\n> 由 `workshop` 命令生成,与构建器 AI 读到的规则同出一处。其中说“输出 JSON、patch”的地方是写给构建器 AI 的,这里直接改 `app.yaml`。",agents:e=>`# Workshop 应用「${e}」
|
|
@@ -211,7 +213,7 @@ ${n}`,networkNotFound:(e,t,n,o)=>`没有找到知识网络「${e}」,或你没
|
|
|
211
213
|
- \`app.yaml\` 的 \`components\` 列出应用用到的组件包,其中的 \`package\` 由 \`workshop push\` 按目录的内容填写,不要手改。
|
|
212
214
|
- 删除组件:删掉它的目录,并从 \`app.yaml\` 的 \`components\` 与页面中删掉它。
|
|
213
215
|
- 这里放的是组件包本身。用 React 等模板写的组件,源码放在别处,构建后把产物放进这里。
|
|
214
|
-
`},
|
|
216
|
+
`},tb={usage:e=>`Usage: workshop <command> [arguments] [options]
|
|
215
217
|
|
|
216
218
|
list Lists the apps you can see
|
|
217
219
|
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
|
|
@@ -223,14 +225,15 @@ ${n}`,networkNotFound:(e,t,n,o)=>`没有找到知识网络「${e}」,或你没
|
|
|
223
225
|
dev [dir] Pushes as you edit: checks and pushes 1 second after files stop changing; Ctrl+C to stop
|
|
224
226
|
preview [dir] Opens the app's preview page on the platform
|
|
225
227
|
--no-open only prints the address
|
|
226
|
-
skill add | remove Installs this package's skill (${e}) into Claude Code and
|
|
228
|
+
skill add | remove Installs this package's skill (${e}) into Claude Code, Codex and WorkBuddy, or removes it
|
|
227
229
|
|
|
228
230
|
-k, --insecure For a platform with a self-signed certificate (kept in the project when pulling)
|
|
229
231
|
--lang <lang> zh-CN or en-US; else WORKSHOP_LANG, then the system's language (LANG...), else Chinese
|
|
230
232
|
-h, --help Shows this
|
|
233
|
+
-v, --version Shows the package's version
|
|
231
234
|
|
|
232
235
|
The folder is the current one unless named. The platform's address and the token come from the
|
|
233
|
-
openbkn command line (openbkn auth login <platform> first), or from BKN_BASE_URL and BKN_TOKEN.`,noCommand:e=>`No command ${e}`,skillUsage:"Usage: workshop skill add | remove",noSkillSource:"This package's skill was not found: run the installed workshop command",createUsage:"Usage: workshop create <network> <name> [dir]",noBrowser:"Could not open a browser: copy the address above and open it",note:e=>`Note: ${e}`,at:(e,t)=>`${e}: ${t}`,and:", ",quoted:e=>`"${e}"`,notProject:(e,t)=>`${e} is not a Workshop app's project folder: run workshop pull <app> ${t} first`,noAppFile:(e,t)=>`${e} has no ${t}: run workshop pull ${e} to pull it again`,ambiguousApp:(e,t,n)=>`${e} apps are called "${t}"; write the app's id:
|
|
236
|
+
openbkn command line (openbkn auth login <platform> first), or from BKN_BASE_URL and BKN_TOKEN.`,noCommand:e=>`No command ${e}`,noVersion:"The package's version is not known: run the installed workshop command",skillUsage:"Usage: workshop skill add | remove",noSkillSource:"This package's skill was not found: run the installed workshop command",createUsage:"Usage: workshop create <network> <name> [dir]",noBrowser:"Could not open a browser: copy the address above and open it",note:e=>`Note: ${e}`,at:(e,t)=>`${e}: ${t}`,and:", ",quoted:e=>`"${e}"`,notProject:(e,t)=>`${e} is not a Workshop app's project folder: run workshop pull <app> ${t} first`,noAppFile:(e,t)=>`${e} has no ${t}: run workshop pull ${e} to pull it again`,ambiguousApp:(e,t,n)=>`${e} apps are called "${t}"; write the app's id:
|
|
234
237
|
${n}`,appNotFound:e=>`No app "${e}" was found, or you may not view it`,appIdNotFound:e=>`No app ${e} was found, or you may not view it`,conflict:(e,t,n)=>`The platform's draft has someone else's changes (draft revision ${e}), and ${t} here has changes not pushed yet, so nothing was overwritten.
|
|
235
238
|
The platform's versions are in ${n}: merge what to keep from both into ${t} here, then run workshop push --merged`,componentKept:(e,t)=>`The component ${e} is no longer on the platform; ${t} has changes and was kept: a push adds it back to the app; delete the folder if it is not wanted`,componentRemoved:(e,t)=>`Deleted ${e}: the component ${t} is no longer on the platform`,folderTaken:(e,t)=>`${e} holds something else; the component ${t} was not downloaded`,downloaded:(e,t)=>`Downloaded the component ${e} to ${t}`,notDownloadedBehind:(e,t,n)=>`The package of the component ${e} was not downloaded (${t}): ${n} is not the platform's version and a push will not use it; run workshop pull again to download it`,notDownloaded:(e,t)=>`The package of the component ${e} was not downloaded (${t}): run workshop pull again to download it`,pulled:(e,t,n)=>`Pulled "${e}" (draft revision ${t}) into ${n}`,blankApp:"The app is still blank: app.yaml is the builder's blank template, saved on the platform at the first push",networkAt:(e,t)=>`The knowledge network "${e}" is described in ${t}`,upToDate:e=>`Up to date (draft revision ${e})`,updatedTo:e=>`Updated to the platform's draft revision ${e}`,localOnly:e=>`${e} has changes not pushed yet, and nothing changed on the platform: run workshop push when it is ready`,noApps:"No apps you can see: make one with workshop create <network> <name>",appLine:(e,t,n,o,s)=>`${e} ${t} (knowledge network "${n}", draft revision ${o}, ${s>0?`published v${s}`:"not published"})`,ambiguousNetwork:(e,t,n)=>`${e} knowledge networks are called "${t}"; write the network's id:
|
|
236
239
|
${n}`,networkNotFound:(e,t,n,o)=>`No knowledge network "${e}" was found, or you may not view it`+(t?`. Knowledge networks you can see: ${t}${o?` and more, ${n} in all`:""}`:""),emptyName:"The app's name cannot be empty",alreadyProject:(e,t)=>`${e} is already the project folder of the app "${t}": pick another folder`,hasAppFile:(e,t)=>`${e} already has ${t}: pick another folder`,noCreateRight:e=>`You may not make apps on the knowledge network "${e}"`,created:(e,t,n)=>`Made the app "${t}" (${n}) on the knowledge network "${e}"`,otherProject:(e,t,n,o)=>`${e} is the project folder of the app "${t}" (${n}), not of "${o}"`,firstPullNeedsApp:"The first pull names the app: workshop pull <app id or name> [dir]",notPulled:(e,t)=>`${e} already has ${t}, not pulled by workshop pull: pick another folder`,sameType:(e,t)=>`The same component type ${t} as ${e}`,behindChanged:e=>`The component ${e} was updated on the platform and not downloaded yet; this folder is the old version and its changes were not pushed: run workshop pull to download the new version first, then bring the changes into it`,apiVersion:(e,t,n)=>`The apiVersion of ${e} is ${t}; this package knows ${n}: install the package of the same version as the platform's Workshop`,manifestUnreadable:e=>`The manifest of the component package ${e} could not be read, or its type does not match: its config was not checked against it`,errorCount:e=>`${e} ${e===1?"error":"errors"}`,validated:"Checks passed: ready to push",forbidden:"You may not change this app",appGone:e=>`The app ${e} is no longer on the platform, or you may not view it`,tooLarge:"Over the size the platform allows",nothingToMerge:"No platform draft to merge: run workshop push",unchanged:"Nothing changed; nothing to push",backToPushed:"Back as it was at the last pull or push; nothing to push",invalidNotPushed:"The checks failed; nothing was pushed",uploaded:(e,t)=>`Uploaded ${e} (${t})`,uploadRefused:(e,t)=>`${e} was refused on upload: ${t}`,pushed:e=>`Pushed: draft revision ${e}`,preview:e=>`Preview: ${e}`,syncedPushAgain:"The platform's draft had someone else's changes; they were pulled in without conflict: run workshop push again",syncedPushing:"The platform's draft had someone else's changes; they were pulled in without conflict: pushing on",devStarted:(e,t)=>`Pushing as you edit: changes to ${e} and ${t}/ are checked and pushed; Ctrl+C to stop`,skillTaken:e=>`${e} holds something else, not installed by workshop skill add, and was left alone: move it away to install this package's skill`,noSkillFiles:e=>`The skill's files were not found: ${e}`,skillInstalled:(e,t)=>`Installed the skill ${e}: ${t}`,skillLink:(e,t,n)=>` ${e}: ${t}${n?" (copied)":""}`,skillNext:"It takes effect in a new IDE session; after upgrading the package, run workshop skill add again for the new version",skillNotOurs:e=>`${e} was not installed by workshop skill add and was not deleted`,removed:e=>`Deleted ${e}`,noSkill:e=>`The skill ${e} is not installed`,noOpenbkn:"The openbkn command line was not found: install @openbkn/bkn-sdk and run openbkn auth login <platform>, or set BKN_BASE_URL and BKN_TOKEN",openbknFailed:(e,t)=>`openbkn ${e} failed: ${t}`,otherPlatform:(e,t)=>`This project folder belongs to the platform ${e}, but BKN_BASE_URL is ${t}`,notLoggedIn:"openbkn is not logged in: run openbkn auth login <platform> first",otherLogin:(e,t)=>`openbkn is logged in to ${e}, not ${t}: run openbkn auth use ${t} first, or set BKN_TOKEN`,tokenWithoutBase:"With BKN_TOKEN, set BKN_BASE_URL (the platform's address) too",httpStatus:(e,t,n)=>`${e} answered ${t}${n?`: ${n}`:""}`,timeout:(e,t)=>`${e} did not answer within ${t} seconds`,certificate:(e,t)=>`The certificate of the platform ${e} did not check out (${t}): for a self-signed platform add -k (--insecure)`,unreachable:(e,t)=>`Cannot reach the platform ${e} (${t})`,unsafePath:e=>`The component package has a path that cannot be written: ${e}`,notInCli:"The command line does not offer this",rulesHeader:"# App Spec rules\n\n> Written by the `workshop` command from the same source as the rules the builder's AI reads. The rules below are in Chinese, as the builder's AI reads them; read them as they are. Where they say \"output JSON or a patch\", that is for the builder's AI: here, edit `app.yaml` directly.",agents:e=>`# Workshop app "${e}"
|
|
@@ -269,15 +272,15 @@ Each folder under \`components/\` is a component package: \`manifest.json\`, \`i
|
|
|
269
272
|
- \`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.
|
|
270
273
|
- To delete a component, delete its folder and remove it from \`components\` in \`app.yaml\` and from the pages.
|
|
271
274
|
- 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.
|
|
272
|
-
`};let
|
|
273
|
-
`)[0],line:t.linePos(l.pos[0]).line})),s=o.length===0?n.toJS():void 0,r=
|
|
275
|
+
`};let Xr="zh-CN";function Ul(e){Xr=e,Qu({language:e})}function It(){return Xr}function D(){return Xr==="en-US"?tb:eb}const ie="components",nb=e=>e.replace(/^x-/,"").replace(/[^A-Za-z0-9-]+/g,"-"),Dd=(e,t)=>Buffer.compare(Buffer.from(e),Buffer.from(t));function Bd(e){const t=sc("sha256");for(const n of[...e].sort((o,s)=>Dd(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 ob=e=>Bd(yn(e).map(t=>({name:t.name,data:ct(t.path)}))),sb=e=>!e.startsWith(".")&&e!=="node_modules";function bn(e){const t=G(e,ie);return be(t)?nn(t,{withFileTypes:!0}).filter(n=>n.isDirectory()&&sb(n.name)).map(n=>n.name).sort(Dd).map(n=>{const o=G(t,n),s=Vm(o,{language:It()}),a=(s.manifest?s.files:yn(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:Bd(a),files:a,check:s}}):[]}function rb(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(be(e)){for(const n of nn(e,{withFileTypes:!0}))n.isDirectory()&&Qr(G(e,n.name),!0);t&&nn(e).length===0&&$u(e)}}function ab(e){if(be(e)){for(const t of yn(e))ut(t.path);Qr(e,!0)}}function zl(e,t){const n=t.find(o=>rb(o.name)===null);if(n)throw new Error(D().unsafePath(n.name));if(be(e))for(const o of yn(e))ut(o.path);for(const o of t){const s=G(e,o.name);Dn(Tt(s),{recursive:!0}),nc(s,o.data)}Qr(e,!1)}const ib=new Set(["title","layout","regions","detail"]);function Wl(e){const t=[];for(const[,n,o]of e.matchAll(/([^.[\]]+)|\[(\d+)\]/g))t.push(o!==void 0?Number(o):n);return t}const lb=/^[A-Za-z][A-Za-z0-9_]*(?:\[\d+\]|\.[A-Za-z_$][A-Za-z0-9_$-]*)*/,cb=/(?:组件|\b[Cc]omponent) ([A-Za-z][A-Za-z0-9_-]*)((?:\[\d+\]|\.[A-Za-z_$][A-Za-z0-9_$-]*)*)/,Kl=/^(?:页面 (\S+?):|page (\S+?): )/;function db(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 ub(e,t){const n=Kl.exec(t),o=n?.[1]??n?.[2],s=t.replace(Kl,""),r=o?e.pages.findIndex(i=>i.id===o):e.pages.length===1?0:-1,a=[],l=cb.exec(s);if(l){const i=db(e,r,l[1]);if(i){const d=Wl(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=lb.exec(s)?.[0];if(c){const i=Wl(c);ib.has(String(i[0]))?r>=0&&a.push(["pages",r,...i]):a.push(i)}return r>=0&&o&&a.push(["pages",r]),a}function hb(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 pb(e){const t=new Ge.LineCounter,n=Ge.parseDocument(e,{lineCounter:t,prettyErrors:!1}),o=n.errors.map(l=>({message:l.message.split(`
|
|
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 ub(s,l)){const i=hb(n,c);if(i!==void 0)return{message:l,line:t.linePos(i).line}}return{message:l}}}}const fb=Object.assign({"./actionButton.en-US.md":()=>Promise.resolve().then(()=>Mw).then(e=>e.default),"./actionButton.md":()=>Promise.resolve().then(()=>Fw).then(e=>e.default),"./agentChat.en-US.md":()=>Promise.resolve().then(()=>Bw).then(e=>e.default),"./agentChat.md":()=>Promise.resolve().then(()=>zw).then(e=>e.default),"./alertList.en-US.md":()=>Promise.resolve().then(()=>Kw).then(e=>e.default),"./alertList.md":()=>Promise.resolve().then(()=>Gw).then(e=>e.default),"./asOfSlider.en-US.md":()=>Promise.resolve().then(()=>Vw).then(e=>e.default),"./asOfSlider.md":()=>Promise.resolve().then(()=>Zw).then(e=>e.default),"./customComponents.en-US.md":()=>Promise.resolve().then(()=>du).then(e=>e.default),"./customComponents.md":()=>Promise.resolve().then(()=>uu).then(e=>e.default),"./dateRange.en-US.md":()=>Promise.resolve().then(()=>tk).then(e=>e.default),"./dateRange.md":()=>Promise.resolve().then(()=>ok).then(e=>e.default),"./dropdownFilter.en-US.md":()=>Promise.resolve().then(()=>rk).then(e=>e.default),"./dropdownFilter.md":()=>Promise.resolve().then(()=>ik).then(e=>e.default),"./eventList.en-US.md":()=>Promise.resolve().then(()=>ck).then(e=>e.default),"./eventList.md":()=>Promise.resolve().then(()=>uk).then(e=>e.default),"./eventReport.en-US.md":()=>Promise.resolve().then(()=>pk).then(e=>e.default),"./eventReport.md":()=>Promise.resolve().then(()=>mk).then(e=>e.default),"./ganttChart.en-US.md":()=>Promise.resolve().then(()=>yk).then(e=>e.default),"./ganttChart.md":()=>Promise.resolve().then(()=>wk).then(e=>e.default),"./metricCards.en-US.md":()=>Promise.resolve().then(()=>vk).then(e=>e.default),"./metricCards.md":()=>Promise.resolve().then(()=>Sk).then(e=>e.default),"./modelTrial.en-US.md":()=>Promise.resolve().then(()=>Ak).then(e=>e.default),"./modelTrial.md":()=>Promise.resolve().then(()=>Ok).then(e=>e.default),"./objectDetail.en-US.md":()=>Promise.resolve().then(()=>Ck).then(e=>e.default),"./objectDetail.md":()=>Promise.resolve().then(()=>xk).then(e=>e.default),"./objectList.en-US.md":()=>Promise.resolve().then(()=>_k).then(e=>e.default),"./objectList.md":()=>Promise.resolve().then(()=>Lk).then(e=>e.default),"./objectTable.en-US.md":()=>Promise.resolve().then(()=>Mk).then(e=>e.default),"./objectTable.md":()=>Promise.resolve().then(()=>Fk).then(e=>e.default),"./pivotTable.en-US.md":()=>Promise.resolve().then(()=>Bk).then(e=>e.default),"./pivotTable.md":()=>Promise.resolve().then(()=>zk).then(e=>e.default),"./regionMap.en-US.md":()=>Promise.resolve().then(()=>Kk).then(e=>e.default),"./regionMap.md":()=>Promise.resolve().then(()=>Gk).then(e=>e.default),"./scenarioBar.en-US.md":()=>Promise.resolve().then(()=>Vk).then(e=>e.default),"./scenarioBar.md":()=>Promise.resolve().then(()=>Zk).then(e=>e.default),"./scheduleGantt.en-US.md":()=>Promise.resolve().then(()=>Qk).then(e=>e.default),"./scheduleGantt.md":()=>Promise.resolve().then(()=>tv).then(e=>e.default),"./searchBox.en-US.md":()=>Promise.resolve().then(()=>ov).then(e=>e.default),"./searchBox.md":()=>Promise.resolve().then(()=>rv).then(e=>e.default),"./segmentedFilter.en-US.md":()=>Promise.resolve().then(()=>iv).then(e=>e.default),"./segmentedFilter.md":()=>Promise.resolve().then(()=>cv).then(e=>e.default),"./stageChain.en-US.md":()=>Promise.resolve().then(()=>uv).then(e=>e.default),"./stageChain.md":()=>Promise.resolve().then(()=>pv).then(e=>e.default),"./subgraph.en-US.md":()=>Promise.resolve().then(()=>mv).then(e=>e.default),"./subgraph.md":()=>Promise.resolve().then(()=>yv).then(e=>e.default),"./taskInbox.en-US.md":()=>Promise.resolve().then(()=>wv).then(e=>e.default),"./taskInbox.md":()=>Promise.resolve().then(()=>vv).then(e=>e.default),"./text.en-US.md":()=>Promise.resolve().then(()=>Sv).then(e=>e.default),"./text.md":()=>Promise.resolve().then(()=>Av).then(e=>e.default),"./trendChart.en-US.md":()=>Promise.resolve().then(()=>Ov).then(e=>e.default),"./trendChart.md":()=>Promise.resolve().then(()=>Cv).then(e=>e.default)}),mb=new Set([...Ve,me]),Nt={};for(const[e,t]of Object.entries(fb)){const[,n,o]=/^\.\/([A-Za-z]+)(\.en-US)?\.md$/.exec(e)??[];!n||!mb.has(n)||(Nt[n]??={load:()=>Promise.reject(new Error(`no guide for ${n}`))},o?Nt[n].loadEnglish=t:Nt[n].load=t)}const gb={scheduleGantt:["排产","排程","调度","派工","检修","维修","齐套","甘特","产能","schedul","dispatch","gantt","kitting"]},yb=Object.keys(Nt).sort();Object.keys(gb).filter(e=>e in Nt);async function bb(e,t="zh-CN"){const n=Nt[e];if(!n)throw new Error(`no guide for ${e}`);return(!Ud(t)&&n.loadEnglish?n.loadEnglish:n.load)()}async function wb(e="zh-CN"){return(Ud(e)?await Promise.resolve().then(()=>uu):await Promise.resolve().then(()=>du)).default}function Ud(e){return e.startsWith("zh")}function kb(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`
|
|
274
277
|
## 调度模型(排产、派工、检修等调度场景)
|
|
275
278
|
请求要把任务排到资源上(排产、排程、派工、检修、齐套、产能等),或要改调度甘特排什么、排在哪、何时完成、查哪些规则、怎么写回时,不要自己写 scheduleGantt 的图层、数据源和情景操作,而是只输出调度模型的答案;系统据此生成页面,并在向导里请用户逐项确认:
|
|
276
279
|
{"scheduleModel": {...}, "needs": [{"step": "rules", "text": "..."}]}
|
|
277
280
|
|
|
278
281
|
scheduleModel 的结构(只填知识网络里确有依据的项;没把握的项省略,由向导按知识网络建议):
|
|
279
282
|
- result:"self"(直接改任务本身的资源与时间,由任务的修改行动写回)或 "record"(写入计划记录,任务本身不改,由计划记录的新建、修改行动写回)。
|
|
280
|
-
- 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 到 ${
|
|
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 到 ${eo} 类共用同一类资源。assignField 为取值是资源标识的字段;target 为何时要完成(任务自己的日期,或沿 path 到达的对象的日期,如工单的交期);ready 为开工前要就绪的对象及其就绪日;predecessors 为同类任务之间的前序关系(一条)。result 为 record 时只能 1 类任务,不写 assignField、start、end、modify,可写 groupField(成批的字段,如预测单号)。
|
|
281
284
|
- resource:{ objectType, titleField, parentField?, groupField?, capacityField? }:资源(产线、机台、班组),parentField 为上级资源标识(与 groupField 二选一),capacityField 为并行上限(数字)。
|
|
282
285
|
- calendars?:[{ objectType, resourceField, start, end }]:资源不可用的时段(停线、停机、请假),最多 3 个。
|
|
283
286
|
- record(result 为 record 时):{ objectType, match: [{ from: 计划记录的字段, to: 任务的字段 }], resourceField, start, end, status?, active?: [{ field, op: "ne", value }], create?: { action }, modify?: { action }, daysField? }。match 是计划认出“为哪条需求排的”的字段:只用单号、编码这类编号(如 单号 ↔ 单号、产品编码 ↔ 物料编码),合起来要能唯一确定一条需求(一张单有多个产品时,单号之外再加产品编码);不要用数量、日期、状态,它们碰巧相等不代表是同一条需求。
|
|
@@ -292,35 +295,49 @@ ${o.length>0?o.join(`
|
|
|
292
295
|
${s.length>0?s.join(`
|
|
293
296
|
`):"(知识网络没有挂载带规则函数的工具箱)"}
|
|
294
297
|
|
|
295
|
-
needs:知识网络缺对象类、属性、关系或行动,或没有合适的规则函数时,逐条写清楚要补什么,step 取 ${
|
|
298
|
+
needs:知识网络缺对象类、属性、关系或行动,或没有合适的规则函数时,逐条写清楚要补什么,step 取 ${yg.join("、")} 之一。needs 的 text 是给业务人员看的:对象类、属性、行动一律写显示名(如“预测单号”),不要写 id 或属性名(如 billno)。不要编造 id,也不要用别的对象、属性凑;规则函数没有合适的就不写进 rules,在 needs 里写“建议新建:XX 检查(读哪些对象、判断什么)”。
|
|
296
299
|
当前 App Spec 已有 scheduleModel 时,输出修改后的完整 scheduleModel:用户没提到的答案原样保留。只改调度甘特的显示时,在 scheduleModel 里写 display:{ resource?: { title?, tick?, daysBefore?, daysAfter?, layers?: [{ color?, tone?, colorField?, popoverFields? }] }, demand?: 同 },layers 按甘特现有图层的顺序。
|
|
297
|
-
请求与调度无关(例如加一张指标卡)时,照常输出 patch 或 spec,不要写 scheduleModel。`}const
|
|
298
|
-
|
|
300
|
+
请求与调度无关(例如加一张指标卡)时,照常输出 patch 或 spec,不要写 scheduleModel。`}const vb=Object.entries(hc).filter(([e])=>!Nr.has(e)).map(([e,[t,n]])=>`${e} ${t}×${n}`).join("、"),$b=Ve.filter(e=>ze[e].category==="scenario"),Sb=`## 页面写法
|
|
301
|
+
1. 一页一个任务:页面标题写谁要做什么(如“今日缺料”“待回复采购单”),不写功能名。
|
|
302
|
+
2. 首屏先说结论:页面开头放一个文字组件(text),一句话说清现在怎么样、先干什么,数字用 values 引用;下面最多 4 个关键数字,一个按紧急程度或日期排好的清单(告警、事件列表或表格),再加最多两张图。其余放到下一页或详情抽屉。
|
|
303
|
+
3. 数字带一句说明:指标卡每项写 description,说明它的含义或该干什么;表格、告警、事件列表、图表也写一句 description。
|
|
304
|
+
4. 同级数字不超过 6 个:一组指标卡最多 6 项,一页的指标卡合计不超过 8 项;多了就分组,或把次要的放进表格。
|
|
305
|
+
5. 用业务话:标题、列名、指标名用显示名,不出现英文字段名、id,也不出现“对象类、关系、实例”这类建模用语。
|
|
306
|
+
6. 数字干净:件数、单数不带小数;金额用合适的单位(如万元);比率用百分比、一位小数。
|
|
307
|
+
7. 红色只给要处理的:一页只用一种强调色,其他用中性色。
|
|
308
|
+
8. 清单先急后缓:告警、清单按紧急程度或日期排序,只显示前几条。
|
|
309
|
+
9. 组件大小跟内容走:行数少的清单不要占满一屏高;自由布局里规则不多于 3 条的告警高度不超过 7 行。
|
|
310
|
+
10. 空状态说清楚:没有数据时写明原因和下一步。
|
|
311
|
+
11. 页面不超过 7 页:按“每天看”“偶尔用”“设置”分组。
|
|
312
|
+
`;function jb(e,t,n=[],{scenarios:o=!0,ruleTools:s,scheduling:r=n.some(a=>a.type==="scheduleGantt")}={}){const a=s&&r?kb(e,s):"",l=Object.entries(uc).map(([d,h])=>`- ${d}:区域 ${h.join("、")}`).join(`
|
|
313
|
+
`),c=gf(o).map(d=>{const h=ze[d];return`### ${d}(${h.label})
|
|
299
314
|
${h.description}
|
|
300
315
|
config:
|
|
301
|
-
${
|
|
316
|
+
${Qn(h.descriptors)}`}).join(`
|
|
302
317
|
|
|
303
318
|
`),i=o?"":`
|
|
304
|
-
方案推演需要企业版,当前环境不提供:不要加方案类组件(${
|
|
305
|
-
{ apiVersion: "${
|
|
319
|
+
方案推演需要企业版,当前环境不提供:不要加方案类组件(${$b.join("、")});用户要求方案推演时,只输出不含它们的 App Spec。`;return`## App Spec 结构
|
|
320
|
+
{ apiVersion: "${pt}", app: { id, name }, dependencies: { knowledgeNetwork: { id: "${e.id}", name: "${e.name}" } }, sources, variables, eventTypes?, scheduleModel?, pages: [ { id, title, layout, regions, detail? } ], theme }
|
|
306
321
|
- 数据源、筛选和主题属于整个应用,所有页面共用,筛选的值在页面之间保留。
|
|
307
322
|
- 每个页面有自己的 id、标题、布局、组件和详情抽屉;组件 id 在页面内唯一。
|
|
308
323
|
- scheduleModel(可选)是调度模型的答案,页面上的调度甘特与它的数据源由它生成:patch 和 spec 里不要写、改或删 scheduleModel,系统会保留原值;要改调度的答案,按“调度模型”一节输出。
|
|
309
324
|
|
|
310
325
|
## 布局(layout)
|
|
311
326
|
${l}
|
|
327
|
+
- 每种布局都必须完整填写 type、columns、sidePosition、sideWidth、asideWidth、gap,即使该布局不使用某个字段也不能省略。columns 必须是 2–4 的整数,sidePosition 只能是 left/right,sideWidth 必须是 220–420 的整数,asideWidth 只能是 0 或 240–420 的整数,不能写 null、字符串或百分比。
|
|
328
|
+
- 完整示例:{"type":"dashboard","columns":3,"sidePosition":"left","sideWidth":300,"asideWidth":0,"gap":"normal"}。修改现有页面时优先只 patch 要改的字段;替换整个 layout 时必须保留全部必填字段。
|
|
312
329
|
- workbench:side 为侧栏(宽 sideWidth 220–420,位置 sidePosition left/right),main 为主区,aside 为右栏(宽 asideWidth,0 表示隐藏,否则 240–420)。
|
|
313
330
|
- dashboard:header 为顶部整行;grid 为网格,列数 columns 2–4,组件用 span 指定跨列数。
|
|
314
331
|
- detail:header 顶部整行;main 主区;aside 右栏。
|
|
315
|
-
- free:自由网格,12 列、行高 40 像素,区域只有 cells;每个组件必须带 frame { x: 0–11, y: ≥0, w: 1–12, h: 2–40 },且 x + w ≤ 12;w、h 不得小于组件的最小尺寸(列×行):${
|
|
332
|
+
- free:自由网格,12 列、行高 40 像素,区域只有 cells;每个组件必须带 frame { x: 0–11, y: ≥0, w: 1–12, h: 2–40 },且 x + w ≤ 12;w、h 不得小于组件的最小尺寸(列×行):${vb};同一行的组件 y 相同,不要重叠。pinRows(可选,0–${xr})为页面滚动时固定在顶部的行数:完全落在前 pinRows 行里的组件(如基准日期、筛选)一直显示在顶部;有组件从这几行开始、又延伸到下面时整页不固定,所以固定的组件要整个放在这几行里。
|
|
316
333
|
- gap 为 compact、normal、relaxed。
|
|
317
334
|
|
|
318
335
|
## 数据源(sources)
|
|
319
336
|
每项 { id, label, objectType, key, progress?, computed? }:objectType 为对象类 id;key 为标识对象的属性。
|
|
320
337
|
子集 { id, label, objectType, key, from: { source, where?, filters? } }:另一个数据源的子集,组件的 source 可以选它。from.source 为来源数据源 id(不能再是子集,也不能是带参数的 Cypher 数据源);where 为对象须全部满足的条件,可读来源的属性、进度列和计算列,写法同计算列的条件;filters 为它跟随的筛选,写法同组件的 filters。objectType、key 必须与来源一致;progress、computed 沿用来源,不能自己写。同一个子集(如“执行中的订单”)要给多个组件用,或要按条件统计时,定义成子集。
|
|
321
338
|
字段格式 formats(可选):{ 字段名: { unit?, decimals?, colors? } },所有组件显示这个字段时都沿用。unit 为数字的单位(如 件、万元),decimals 为小数位(0–6),colors 为着色规则列表 [{ when: 条件列表, tone }]:行满足条件时该字段显示为这个颜色(tone 同计算列的色调:neutral/info/success/warning/danger),条件可读本行任何字段,第一条成立的生效。子集沿用来源的格式。
|
|
322
|
-
${
|
|
323
|
-
${
|
|
339
|
+
${Jp}
|
|
340
|
+
${Uh}
|
|
324
341
|
|
|
325
342
|
## 筛选(variables)与联动
|
|
326
343
|
联动两头都是显式的:组件点击时把值写入一个筛选(组件 config 里的 writes 等配置项);其他组件在自己的 filters 里列出跟随哪些筛选、按自己的哪个字段比对。没列在 filters 里的筛选不影响它;filters 为空就不受任何筛选影响。筛选本身不绑数据源和字段,所以不同数据源的组件可以跟随同一个筛选(比如两类对象都有客户字段时,各按自己的客户字段跟随同一个“客户”筛选)。
|
|
@@ -338,31 +355,34 @@ ${Mh}
|
|
|
338
355
|
可选 default 为页面打开时的值,清除筛选后也回到它:asOf 为 today 或 YYYY-MM-DD;dateRange 为 YYYY-MM-DD..YYYY-MM-DD(可省略一端);value、search 为文本;selection、set 不带 default。
|
|
339
356
|
|
|
340
357
|
## 事件类型(eventTypes,可选)
|
|
341
|
-
业务事件是业务上发生的事(订单超期、需求变更),和页面点击分开:点击只写筛选,不产生事件。事件类型在知识网络里建模,名称、来源、关于的对象类、严重程度和规则都在网络上,同一网络的应用共用,应用不能新建或修改。eventTypes 只写本应用处理哪些、怎么处理;eventList(事件列表)与 eventReport(事件登记)组件引用它的 id。每项 { id, owners?, dueHours?, report?, analysis?, grouping?, strategies? },不要写 label、source、subject、severity、rule:
|
|
358
|
+
业务事件是业务上发生的事(订单超期、需求变更),和页面点击分开:点击只写筛选,不产生事件。事件类型在知识网络里建模,名称、来源、关于的对象类、严重程度和规则都在网络上,同一网络的应用共用,应用不能新建或修改。eventTypes 只写本应用处理哪些、怎么处理;eventList(事件列表)与 eventReport(事件登记)组件引用它的 id。每项 { id, owners?, dueHours?, report?, analysis?, grouping?, strategies?, canvas? },不要写 label、source、subject、severity、rule:
|
|
342
359
|
- id:知识网络里事件类型的编码,只能用知识网络一节列出的事件类型;没有列出时不要写 eventTypes,请用户先在知识网络里建事件类。
|
|
343
360
|
- owners:负责角色名列表;dueHours:发生后多少小时内要处理完(以小时计,可精确到分钟,如 0.5 为 30 分钟;最长 720)。
|
|
344
361
|
- report(只用于用户登记的事件类型,可选):{ fields: [{ name(小写字母开头), label, type: text|number|date, required? }], verifier?(核实角色)}。
|
|
345
362
|
事件数据源 { id, label, objectType: "events:<id>", key: "event_id", events: { types? } }:把应用的事件当成数据(每条事件一行),供指标卡、图表、表格统计,如按周数超期事件、按严重程度分布。列为 event_id、title、event_type(事件类型名称)、severity(P1–P4)、status(待核实/已核实/已驳回/重复/已关闭)、open(未关闭/已关闭)、overdue(已超时/未超时)、source(规则命中/用户登记)、occurred_at、ended_at、recorded_at(日期)、object(关联对象名称)、object_key、reported_by、verified_by。types 只取这些事件类型,不写为全部。它没有关系,不能沿关系取值。
|
|
346
|
-
归并方式 grouping(可选):{ mode: none | property | batch, by? },事件按它进入任务:none 一个事件一个任务;property 按属性 by 相同的进同一个任务:用户登记的事件类型 by 为关联对象的属性(如订单的客户),规则事件类型 by
|
|
363
|
+
归并方式 grouping(可选):{ mode: none | property | batch, by? },事件按它进入任务:none 一个事件一个任务;property 按属性 by 相同的进同一个任务:用户登记的事件类型 by 为关联对象的属性(如订单的客户),规则事件类型 by 为识别规则命中返回的列名;batch 同一次检查新命中的进同一个任务。不写时规则事件为 batch、登记事件为 none。处理方案 strategies(可选):处理时可选的方案名称列表,如 ["催交供应商","调整交期"],最多 12 个。
|
|
347
364
|
分析视图 analysis(可选):{ page, selection?, asOf?, window? },事件列表点“分析”时打开 page,把关联对象写入 selection(选中对象筛选,须与事件类型关于的对象类相同),asOf 为 true 时基准日期设为发生日,window { variable(日期区间筛选), days } 设为发生日前后 days 天。
|
|
365
|
+
画布分析要求 canvas(可选):{ prompt?, question? },事件列表点“到分析画布”时交给画布 AI:prompt 写怎样分析(先查什么、看哪些指标、原因怎么归类、结论写成什么样),question 写这次要回答的问题,各不超过 2000 字;可引用 {title}、{type}、{severity}、{object}、{occurredAt}、{detail.<字段>},如 question: "采购订单 {object}({title})为什么超期?"。用户要求“发到画布让 AI 分析”时才写。
|
|
348
366
|
用户只要求“提醒、告警、看哪些超期”时用 alertList 即可;要求“记录下来、要有人处理、要核实或关闭”时,才在 eventTypes 里处理知识网络的事件类型。
|
|
349
367
|
|
|
350
368
|
## 组件
|
|
351
|
-
regions 中每项 { id, type, span?, frame?, config };id 在页面内唯一,字母开头;span 只用于 dashboard,frame 只用于 free
|
|
369
|
+
regions 中每项 { id, type, span?, frame?, surface?, config };id 在页面内唯一,字母开头;span 只用于 dashboard,frame 只用于 free;surface(可选)为 card 或 plain,只给要和主题不同的组件写,如不带框的页面里给一张很密的表格加底色。${i}
|
|
352
370
|
${c}
|
|
353
371
|
|
|
354
372
|
### 详情抽屉 detail(type 固定为 ${me},不放在 regions 里)
|
|
355
|
-
${
|
|
373
|
+
${dt.description}
|
|
356
374
|
config:
|
|
357
|
-
${
|
|
358
|
-
${
|
|
375
|
+
${Qn(dt.descriptors)}
|
|
376
|
+
${Ab(n,a!=="")}${a}
|
|
377
|
+
${Sb}
|
|
359
378
|
## 主题(theme)
|
|
360
|
-
|
|
379
|
+
surface(可选)为组件外观:card 每个组件带底色和边框,plain 组件直接放在页面上、靠间距分开,不写为 card。新建应用写 plain;改已有应用时,用户没要求就保留原值。
|
|
380
|
+
颜色一律 #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。
|
|
361
381
|
用户说的“强调色、主色”指 colorPrimary(chartPalette 第一个颜色通常与它一致);点名的颜色要在所选模板基础上改进去。主题模板:
|
|
362
|
-
${Object.values(
|
|
382
|
+
${Object.values(Zn).map(d=>`- ${d.name}:${JSON.stringify(d)}`).join(`
|
|
363
383
|
`)}
|
|
364
384
|
|
|
365
|
-
${
|
|
385
|
+
${Eb(e,t)}${Tb(e)}`}function Ab(e,t=!1){return e.length===0?"":`
|
|
366
386
|
## 组件说明
|
|
367
387
|
以下组件附有说明,配置它们时以说明为准:先按“本体契约”把业务对象对应到组件的角色,再按“扩展点”接知识网络上的规则工具、逻辑属性或指标。说明中要求的对象类、属性、关系或工具在上面的知识网络里找不到时,不要用别的对象或计算列凑,也不要在配置里写业务规则,相应的可选项留空。${t?"调度甘特按“调度模型”一节输出答案:规则函数只从那里列出的选,要补的内容写进 needs。其他组件里要填 { box, tool } 的配置项一律不写,不要编造工具箱或工具的 id,由构建者在配置面板中选择。":"本提示不含执行工厂的工具清单:说明里提到的规则工具(如“齐套检查”)以及任何要填 { box, tool } 的配置项一律不写,不要编造工具箱或工具的 id,由构建者在配置面板中选择。说明里“问用户”“列出要补的内容”在这里不适用:只输出 App Spec。"}
|
|
368
388
|
|
|
@@ -371,49 +391,51 @@ ${o.text.trim()}
|
|
|
371
391
|
</guide>`).join(`
|
|
372
392
|
|
|
373
393
|
`)}
|
|
374
|
-
`}function
|
|
394
|
+
`}function Tb(e,t){const n=Wp(e);return n?`
|
|
375
395
|
|
|
376
396
|
## 对象指标
|
|
377
|
-
${n}`:""}const
|
|
378
|
-
对象类(id:名称;业务说明;属性 名称:类型(显示名))${n.length>
|
|
397
|
+
${n}`:""}const Ob=30;function Eb(e,t){const n=Object.values(e.objectTypes),o=s=>!t;return`## 知识网络 ${e.name}(${e.id})
|
|
398
|
+
对象类(id:名称;业务说明;属性 名称:类型(显示名))${n.length>Ob&&t?";网络较大,只列出与本次要求相关的对象类的属性,其余只列名称,需要时请用户点名":""}:
|
|
379
399
|
${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(`
|
|
380
400
|
`)}
|
|
381
401
|
关系(id:名称,起点 → 终点;路径可以反向经过关系):
|
|
382
402
|
${e.relations.map(s=>`- ${s.id}:${s.name},${s.source} → ${s.target}`).join(`
|
|
383
|
-
`)}${
|
|
403
|
+
`)}${Cb(e)}`}function Cb(e){if(!e.eventTypes)return"";const t=e.eventTypes.map(n=>`- ${n.code}:${n.name},${n.source==="rule"?"规则命中":"用户登记"}${n.subject?`,关于 ${n.subject}`:""}`);return`
|
|
384
404
|
事件类型(编码:名称,来源,关于的对象类):
|
|
385
405
|
${t.length>0?t.join(`
|
|
386
|
-
`):"(暂无)"}`}const Ae={type:"string",pattern:"^[A-Za-z][A-Za-z0-9_-]{0,39}$"},db={type:"string",pattern:"^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$"},ub={type:"number",minimum:1/60,maximum:720},ql={type:"string",pattern:"^#[0-9a-fA-F]{6}$"},ze={type:"object",required:["field","op"],properties:{field:{type:"string"},op:{enum:[...Wn]},ref:{type:"string"},value:{type:["string","number"]},values:{type:"array",items:{type:"string"}}}};function hb(e){const t={title:e.label};switch(e.kind){case"text":return{...t,type:"string",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:ze};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"},tool:{type:"string",description:"MCP 服务里的工具名称"}}};case"list":return{...t,type:"array",minItems:e.min,maxItems:e.max,items:vr(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:[...Xs]}},send:{type:"string",enum:[...Qs]},maxObjects:{type:"integer",minimum:1,maximum:er}},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:Ls}},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:Gn,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 vr(e){return{type:"object",additionalProperties:!1,properties:Object.fromEntries(e.map(t=>[t.key,hb(t)])),required:e.filter(t=>!t.optional&&!t.notNeeded).map(t=>t.key)}}const Fl=Object.keys(Vn.default).filter(e=>e.startsWith("color"));function pb(){const e=t=>({type:"object",additionalProperties:!1,required:["id","type","config"],properties:{id:Ae,type:{const:t},span:{type:"integer",minimum:1,maximum:4},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:ht},app:{type:"object",additionalProperties:!1,required:["id","name"],properties:{id:db,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:[...xf]}}},theme:{$ref:"#/$defs/theme"}},$defs:{source:{type:"object",additionalProperties:!1,required:["id","label","objectType","key"],properties:{id:Ae,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:ze}}}},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:Fs},colors:{type:"array",items:{type:"object",required:["when","tone"],properties:{when:{type:"array",items:ze},tone:{enum:[...Et]}}}}}}},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:ze},filters:{type:"array",items:{type:"object"}}}},computed:{type:"array",items:{type:"object",required:["name","label","kind"],properties:{name:Ae,label:{type:"string"},kind:{enum:[...Gt]},cases:{type:"array",items:{type:"object"}},otherwise:{type:"object"},from:{type:"string"},to:{type:"string"},when:{type:"array",items:ze},expr:{type:"string"},template:{type:"string"},path:{type:"array",items:{type:"string"}},aggregate:{enum:[...qs]},field:{type:"string"},type:{enum:["date","number","text"]},where:{type:"array",items:ze},source:{type:"string"},pairs:{type:"array",items:{type:"object",required:["field","other"],properties:{field:{type:"string"},other:{type:"string"}}}}}}},operations:{type:"array",maxItems:Ks,description:"推演操作:业务用户在方案中可做的假设;effects 只改知识网络属性,shiftDays/add 按当前值增减,set 设为参数值(日期属性可用 date 或 datetime 参数,datetime 精确到分钟),fromAsOf 设为基准日期起若干天;action 为采用方案时执行的行动",items:{type:"object",additionalProperties:!1,required:["id","label","params","effects"],properties:{id:Ae,label:{type:"string",maxLength:30},when:{type:"array",items:ze},params:{type:"array",minItems:1,maxItems:Yn,items:{type:"object",additionalProperties:!1,required:["name","label","type"],properties:{name:Ae,label:{type:"string"},type:{enum:["number","date","datetime","text"]},min:{type:"number"},max:{type:"number"},default:{type:["string","number"]}}}},effects:{type:"array",description:"新建对象的行动(如为需求新建计划)可以没有效果",maxItems:Ys,items:{type:"object",additionalProperties:!1,required:["field","kind","param"],properties:{field:{type:"string"},kind:{enum:[...Ds]},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:ze,description:"查重时只算满足这些条件的已有对象,如状态不是已取消"}}}}}},follows:{type:"array",maxItems:yr,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:Ae,field:{type:"string"},from:{type:"string",description:"sources[].id"},path:{type:"array",minItems:1,maxItems:Qn,items:{type:"string"}},fromField:{type:"string"},gapDays:{type:"integer",minimum:-eo,maximum:eo},gapMinutes:{type:"integer",minimum:-to,maximum:to},keepDuration:{type:"string",description:"本数据源的结束日期属性"}}}},models:{type:"array",maxItems:Hs,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:Ae,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:Vs,items:{type:"string"}},params:{type:"array",minItems:1,maxItems:Yn,items:{type:"object",additionalProperties:!1,required:["name","label","type"],properties:{name:Ae,label:{type:"string"},type:{enum:["number","date","text"]},min:{type:"number"},max:{type:"number"},default:{type:["string","number"]}}}},outputs:{type:"array",minItems:1,maxItems:Js,items:{type:"object",additionalProperties:!1,required:["name","label","type"],properties:{name:Ae,label:{type:"string"},type:{enum:["number","date","text"]}}}},measures:{type:"array",minItems:1,maxItems:Zs,items:{type:"object",additionalProperties:!1,required:["label","aggregate"],properties:{label:{type:"string"},when:{type:"array",items:ze},aggregate:{enum:[...Gs]},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:br,description:"相关对象:方案中,from 数据源里有变化(改动或联动)的对象沿 path 关联到的本数据源对象标为相关,值不变",items:{type:"object",additionalProperties:!1,required:["id","from","path"],properties:{id:Ae,from:{type:"string",description:"sources[].id"},path:{type:"array",minItems:1,maxItems:Qn,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:ub,grouping:{type:"object",additionalProperties:!1,required:["mode"],properties:{mode:{enum:[...zs]},by:{type:"string",description:"按属性归并时:用户登记的事件取关联对象的属性名;规则命中的事件取规则工具返回的列名"}}},strategies:{type:"array",maxItems:12,items:{type:"string",maxLength:40}},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:[...Us]},required:{type:"boolean"}}}},verifier:{type:"string"}}}}},variable:{type:"object",required:["name","label","kind"],properties:{name:Ae,label:{type:"string"},kind:{enum:[...Kn]},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:Ae,title:{type:"string"},icon:{enum:[...Rf]},group:{type:"string"},hidden:{type:"boolean"},badge:{enum:[...Pf]},layout:{$ref:"#/$defs/layout"},regions:{type:"object",additionalProperties:{type:"array",items:{oneOf:Ke.map(t=>e(t))}}},detail:{type:"object",additionalProperties:!1,required:["id","type","config"],properties:{id:Ae,type:{const:me},config:{$ref:`#/$defs/config_${me}`}}}}},layout:{type:"object",required:["type","columns","sidePosition","sideWidth","asideWidth","gap"],properties:{type:{enum:[..._s]},columns:{type:"integer",minimum:2,maximum:4},sidePosition:{enum:["left","right"]},sideWidth:{type:"integer",minimum:220,maximum:420},asideWidth:{type:"integer",minimum:0,maximum:420},gap:{enum:["compact","normal","relaxed"]},pinRows:{type:"integer",minimum:0,maximum:Tr}}},theme:{type:"object",required:["name","mode",...Fl,"chartPalette","fontFamily"],properties:{name:{type:"string"},mode:{enum:["light","dark"]},...Object.fromEntries(Fl.map(t=>[t,ql])),chartPalette:{type:"array",minItems:6,maxItems:8,items:ql},fontFamily:{type:"string"},fontSize:{type:"integer",minimum:12,maximum:16},radius:{type:"integer",minimum:0,maximum:16},shadow:{enum:[...Is]},density:{enum:[...Ms]}}},...Object.fromEntries(Ke.map(t=>[`config_${t}`,{title:Be[t].label,description:Be[t].description,...vr(Be[t].descriptors)}])),[`config_${me}`]:{title:lt.label,description:lt.description,...vr(lt.descriptors)}}}}const fb={string:"文本属性",number:"数字属性",date:"日期属性",datetime:"日期属性"},mb=new Set(["title","source","filters","selection",tt]);function gb(e,t){return t.length===0?"":`## 本应用的自定义组件
|
|
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?"":`## 本应用的自定义组件
|
|
387
407
|
按 ${ie}/ 下各组件的清单生成,放法与上面的标准组件相同:
|
|
388
408
|
- type 写清单里的 type;app.yaml 的 components 由 workshop push 填写,不要手写。
|
|
389
|
-
- ${
|
|
409
|
+
- ${ot}.<角色> 在 app.yaml 里写成 ${ot}: { <角色>: 属性名 },角色来自清单的 data.fields。
|
|
390
410
|
- 新建的组件要先运行一次 workshop validate,这里才会列出它。
|
|
391
411
|
|
|
392
|
-
${t.map(n=>
|
|
412
|
+
${t.map(n=>Mb(e,n)).join(`
|
|
393
413
|
|
|
394
|
-
`)}`}function
|
|
395
|
-
清单读不出来,这里列不出它的配置:运行 workshop validate 查看错误。`;if(!o)return s;let r;try{r=
|
|
396
|
-
`)}function
|
|
397
|
-
`)}const
|
|
398
|
-
${
|
|
399
|
-
`)}const
|
|
400
|
-
`),
|
|
401
|
-
`);const s=
|
|
414
|
+
`)}`}function Mb(e,t){const n=`${ie}/${t.folder}`,o=t.manifest,s=`### ${n}
|
|
415
|
+
清单读不出来,这里列不出它的配置:运行 workshop validate 查看错误。`;if(!o)return s;let r;try{r=qc(o)}catch{return s}const a=o.defaultSize??{w:6,h:6},l=o.minSize??{w:3,h:3},c=be(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=>Qn([i])+(i.hint?`;${i.hint}`:"")),"示例:",qb(o,a)].join(`
|
|
416
|
+
`)}function qb(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}: <${Pb[l.type]??"属性"}>`).join(", ")} }`);const s=e.configSchema.properties??{};for(const l of e.configSchema.required??[]){if(Lb.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(`
|
|
417
|
+
`)}const Re="app.yaml",Ee=".workshop",zd=`${Ee}/app-spec.schema.json`,So=`${Ee}/remote`,Wd=`${So}/${Re}`,Kd=`${So}/${ie}`,Fb=`# yaml-language-server: $schema=./${zd}`,it=e=>sc("sha256").update(e).digest("hex");function Hl(e){return`${Fb}
|
|
418
|
+
${Ge.stringify(e,{lineWidth:0})}`}function Ce(e,t,n){const o=G(e,t);Dn(Tt(o),{recursive:!0}),nc(o,n)}function rn(e,t){const n=G(e,t);return be(n)?ct(n,"utf8"):null}function Pe(e){const t=rn(e,`${Ee}/state.json`);return t===null?null:JSON.parse(t)}function Yd(e,t){Ce(e,`${Ee}/state.json`,`${JSON.stringify(t,null,2)}
|
|
419
|
+
`)}const jo=e=>rn(e,Re),Or=(e,t)=>Ce(e,Re,t),Db=e=>be(G(e,So)),Bb=(e,t)=>Ce(e,Wd,t);function Gd(e){ut(G(e,So),{recursive:!0,force:!0})}function Hd(e){const t=G(e,Kd);return[...be(G(e,Wd))?[Re]:[],...be(t)?nn(t).sort().map(n=>`${ie}/${n}`):[]]}const Ub=()=>yb.filter(e=>!Nr.has(e));async function Vd(e,t,n=bn(e)){const o=It();Ce(e,`${Ee}/network.json`,`${JSON.stringify(t,null,2)}
|
|
420
|
+
`),Ce(e,zd,`${JSON.stringify(_b(),null,2)}
|
|
421
|
+
`);const s=Ib(e,n);Ce(e,`${Ee}/guides/app-spec.md`,`${D().rulesHeader}
|
|
402
422
|
|
|
403
|
-
${
|
|
423
|
+
${jb(t)}
|
|
404
424
|
${s?`
|
|
405
425
|
${s}
|
|
406
|
-
`:""}`),
|
|
407
|
-
`)}function
|
|
408
|
-
`):n.split(/\r?\n/).some(o=>o.trim().replace(/\/$/,"")===
|
|
409
|
-
`)}${
|
|
410
|
-
`)}class F extends Error{}const
|
|
411
|
-
`))):new F(D().appNotFound(t))}function
|
|
412
|
-
`)));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 Nb(e,t,n,o,s){const r=o.trim(),a=D();if(!r)throw new F(a.emptyName);const l=xe(t);if(l)throw new F(a.alreadyProject(t,l.app.name));if(Se(t)&&vo(t)!==null)throw new F(a.hasAppFile(t,Ne));const c=await Cb(e,n);let i;try{i=await e.createApp(r,c)}catch(d){throw d instanceof Rr?new F(a.noCreateRight(c.name)):d}return s.out(a.created(c.name,i.name,i.id)),await Vr(e,t,i.id,null,s.out,s),0}async function xb(e,t,n,o){const s=D(),r=xe(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&&Se(t)&&vo(t)!==null)throw new F(s.notPulled(t,Ne));const a=r?.app.id??(await Ab(e,n)).id;return await Vr(e,t,a,r,o.out,o),0}const Mn=e=>typeof e=="object"&&e!==null&&"type"in e;function Rb(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=Mn(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=>Mn(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=>Mn(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 Pb(e,t){const n=We.parseDocument(e),o=n.toJS()?.components;return du(o??[],t)?e:(t.length===0?n.delete("components"):n.set("components",t),n.toString({lineWidth:0}))}async function Wd(e,t,n,o,s=mn(t)){const{spec:r,syntax:a,locate:l}=Hy(o);if(a.length>0)return{ok:!1,errors:a,warnings:[]};const c=r?.apiVersion,i=[],d=D();typeof c=="string"&&c!==ht&&i.push(d.apiVersion(Ne,c,ht));const h=await e.readNetwork(n.network);await Bd(t,h,s);const u=r?.components,p=Rb(u,s,n.components??{});i.push(...p.warnings);for(const[k,w]of p.usable)!p.behind.has(k)&&dd(w.manifest,xt()).length===0&&Nc(p.components.find(v=>v.type===k)?.package??w.hash,w.manifest);const f=p.components.filter(k=>Mn(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=xd(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 Kd(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??Ne}${o.line?`:${o.line}`:""} ${o.message}`);e.err(n.errorCount(t.errors.length))}}async function Lb(e,t,n){const{state:o,text:s}=Hr(t),r=await Wd(e,t,o,s);return Kd(n,r),r.ok&&n.out(D().validated),r.ok?0:1}function Bl(e,t){const n=D();return e instanceof Rr?new F(n.forbidden):e instanceof xr?new F(n.appGone(t)):e instanceof qc?new F(n.tooLarge):null}function _b(e,t){const n={};for(const[o,s]of Object.entries(e))n[o]={...s,package:t(s.package)};return n}function Yd(e,t,n){const o=e.components??{},s=n.every(r=>r.type&&r.hash===o[r.type]?.hash);return rt(t)!==e.appHash||!s}function Ib(e){const{state:t,text:n}=Hr(e);return Yd(t,n,mn(e))}async function Gd(e,t,{merged:n=!1},o){const s=D(),{state:r,text:a}=Hr(t);if(n&&r.remoteRevision===void 0)throw new F(s.nothingToMerge);if(!n&&kb(t))return o.err(zd(r.remoteRevision??r.revision,Dd(t))),"merge";const l=mn(t);if(!n&&!Yd(r,a,l))return o.out(s.unchanged),"unchanged";const c=await Wd(e,t,r,a,l);if(Kd(o,c),!c.ok)return o.err(s.invalidNotPushed),"invalid";const i=n?r.remoteRevision:r.revision,d=async()=>await Vr(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,_m(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 Bl(S,r.app.id)??new F(s.uploadRefused(v,In(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=Pb(a,p);let g;try{g=await e.saveDraft(r.app.id,f,i)}catch(w){if(w instanceof Mc)return await d();throw Bl(w,r.app.id)??w}m!==a&&$r(t,m);const{remoteRevision:y,blankHash:b,...k}=r;return qd(t,{...k,app:{id:g.id,name:g.name},revision:g.revision,appHash:rt(m),components:_b(c.tracked,u)}),Fd(t),o.out(s.pushed(g.revision)),o.out(s.preview(Gr(r))),"pushed"}async function Mb(e,t,n,o){const s=await Gd(e,t,n,o);return s==="synced"&&o.err(D().syncedPushAgain),s==="pushed"||s==="unchanged"?0:1}const Hd=e=>new Promise((t,n)=>{ru("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())))})}),Wt=e=>e.trim().replace(/\/+$/,"");async function xn({state:e,insecure:t,near:n},o=process.env,s=Hd){const r=D(),a=o.BKN_BASE_URL?Wt(o.BKN_BASE_URL):void 0;if(e&&a&&a!==Wt(e.baseUrl))throw new F(r.otherPlatform(e.baseUrl,a));let l=a??(e?Wt(e.baseUrl):void 0);const c=typeof n?.baseUrl=="string"?Wt(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?Wt(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 qb=(e,t)=>{const n=fu(e,{recursive:!0},(o,s)=>{s&&t(String(s))});return()=>n.close()};function Fb(e){const t=e.split(/[\\/]/);return t.length===1?t[0]===Ne:t[0]===ie&&t.slice(1).every(n=>!n.startsWith(".")&&n!=="node_modules")}const Db=e=>e instanceof Error?e.message:String(e);async function Bb(e,t,n,{signal:o,watch:s=qb,settle:r=1e3}){const a=D(),l=xe(t);if(!l)throw new F(a.notProject(t,t));n.out(a.devStarted(Ne,ie)),n.out(a.preview(Gr(l)));let c,i,d=!1,h=!1;const u=async g=>{try{if(!g&&!Ib(t)){h&&n.out(a.backToPushed),h=!1;return}for(let y=0;y<2;y+=1){const b=await Gd(await e(),t,{},n);if(h=b==="invalid",b!=="synced")break;n.err(a.syncedPushing)}}catch(y){h=!0,n.err(Db(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=>{Fb(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 Tt=100,$o=e=>`/bkn-backend/v1/knowledge-networks/${encodeURIComponent(e)}`;async function Ub(e,t){const n=[];for(let o=0;;o+=Tt){const{data:s}=await e.get(`${$o(t)}/object-types`,{params:{direction:"desc",limit:Tt,offset:o,sort:"update_time"}}),r=s.entries??[];if(n.push(...r),r.length<Tt||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 zb(e,t,n){const{data:o}=await e.get(`${$o(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 Wb(e,t){const{data:n}=await e.get(`${$o(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 Kb(e){const t=[];for(let n=0;;n+=Tt){const{data:o}=await e.get("/bkn-backend/v1/knowledge-networks",{params:{direction:"asc",limit:Tt,offset:n,sort:"name"}}),s=o.entries??[];if(t.push(...s),s.length<Tt||t.length>=(o.total_count??0))break}return t.map(({id:n,name:o})=>({id:n,name:o}))}function xs(){throw new Error(D().notInCli)}function Yb(e){return{useOffered:()=>"yes",list:async(t,n)=>(await e.get(`${$o(t)}/object-metrics`,{params:{limit:n.limit,offset:n.offset,status:n.status}})).data,get:xs,query:xs,participants:xs}}function Gb(e){return{http:e,userName:()=>{},userId:()=>{},listNetworks:()=>Kb(e),listObjectTypes:t=>Ub(e,t),getObjectType:(t,n)=>zb(e,t,n),listRelationTypes:t=>Wb(e,t),objectMetrics:Yb(e)}}function Hb(e){Su(Gb(e))}class Vd extends Error{constructor(t,n){super(D().httpStatus(n,t.status,Jb(t.data))),this.response=t}response}const Vb=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"]),Ul=6e4;function Jb(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 Zb(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 Jd(e,t){if(!(e?/json/i.test(e):/^\s*[[{]/.test(t))||t==="")return t;try{return JSON.parse(t)}catch{return t}}async function Xb(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 Zd(e,t,n,o,s={}){const r=new URL(`${e.baseUrl.replace(/\/+$/,"")}/api${n}${Zb(s.params)}`),a=await Xb(o),l={method:t,headers:{Accept:"application/json, text/plain, */*","Accept-Language":xt(),...e.token?{Authorization:`Bearer ${e.token}`}:{},...a?{"Content-Type":a.type,"Content-Length":String(a.data.length)}:{},...s.headers},timeout:s.timeout??Ul,...s.signal?{signal:s.signal}:{},...r.protocol==="https:"&&e.insecure?{rejectUnauthorized:!1}:{}},c=r.protocol==="https:"?vu:ku;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,Ul/1e3)))),h.on("error",u=>{u.code&&Vb.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 Xd=e=>e.status>=200&&e.status<300;async function Rn(e,t,n,o,s){const r=await Zd(e,t,n,o,s),a=Jd(r.type,r.bytes.toString("utf8"));if(!Xd(r))throw new Vd({status:r.status,data:a},n);return{data:a}}async function Qb(e,t){const n=await Zd(e,"GET",t,void 0,{headers:{Accept:"application/zip, application/octet-stream, */*"}});if(Xd(n))return n.bytes;const o=Jd(n.type,n.bytes.toString("utf8"));throw new Vd({status:n.status,data:o},t)}function ew(e){return{get:(t,n)=>Rn(e,"GET",t,void 0,n),delete:(t,n)=>Rn(e,"DELETE",t,void 0,n),post:(t,n,o)=>Rn(e,"POST",t,n,o),put:(t,n,o)=>Rn(e,"PUT",t,n,o)}}const tw=e=>`/workshop/v1/component-frames/${e}/`;async function nw(e){return((await nt.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=oo({operation:s,kind:r})==="create",l=i=>i.comment?.trim()?{label:i.comment.trim()}:{},c=[];for(const i of n.parameters??[])i.value_from==="input"&&i.name?c.push({name:i.name,type:i.type??"string",...l(i)}):a&&i.value_from==="property"&&typeof i.value=="string"&&i.value!==""&&!c.some(d=>d.name===i.value)&&c.push({name:i.value,type:i.type??"string",...l(i),property:!0});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")}})}async function ow(e,t){const[n,o,s,r]=await Promise.all([em(e),nm(e),nw(e).catch(()=>{}),Ff(e).catch(()=>{})]),a=await Promise.all(n.map(i=>tm(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=>!ih.has(h.type.toLowerCase())).map(h=>({name:h.name,label:h.displayName||h.name,type:lh(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 sw(){const e=ju()?.objectMetrics;if(!e)throw new Error("This page's host offers no object metrics.");return e}const Rs=100;async function zl(e,t){const n=[];for(let o=0;;o+=Rs){const s=await sw().list(e,{status:t,limit:Rs,offset:o});if(n.push(...s.entries),s.entries.length<Rs||n.length>=s.total_count)return n}}async function rw(e){const[t,n]=await Promise.all([zl(e,"published"),zl(e,"deprecated").catch(()=>[])]);return Pp(t,n)}async function aw(e){const[t,n]=await Promise.all([ow(e.id,e.name),rw(e.id).catch(()=>{})]);return{...t,name:e.name,...n?{metrics:n}:{}}}async function iw(e){const t=[];return await Promise.all((e??[]).map(async n=>{try{const{data:o}=await nt.get(`${tw(n.package)}manifest.json`);o?.type===n.type?Nc(n.package,o):t.push(n.package)}catch{t.push(n.package)}})),t}const ct="openbkn-workshop",Wl="SKILL.en-US.md",lw=/^\s*source:\s*["']?@openbkn(?:-ai)?\/workshop["']?\s*$/m;function Qd(e){const t=[{agent:"Claude Code",path:H(e,".claude","skills",ct)}];return Se(H(e,".codex"))&&t.push({agent:"Codex",path:H(e,".codex","skills",ct)}),{files:H(e,".agents","skills",ct),links:t}}const cw=e=>{try{return lw.test(it(H(e,"SKILL.md"),"utf8"))}catch{return!1}};function eu(e){try{return Vl(e),!0}catch{return!1}}function tu(e,t){if(cw(e))return!0;try{return Vl(e).isSymbolicLink()&&Xe($t(e),gu(e))===t}catch{return!1}}const on=(e,t)=>e.startsWith(`${t}/`)||e.startsWith(`${t}\\`)?`~${e.slice(t.length)}`:e,dw=(e,t)=>new F(D().skillTaken(on(e,t)));function uw(e,t,n,{platform:o=process.platform}={}){const s=D();if(!Se(H(e,"SKILL.md")))throw new F(s.noSkillFiles(e));const{files:r,links:a}=Qd(t);for(const c of[r,...a.map(i=>i.path)])if(eu(c)&&!tu(c,r))throw dw(c,t);dt(r,{recursive:!0,force:!0}),qn($t(r),{recursive:!0}),So(e,r,{recursive:!0,filter:c=>c!==H(e,Wl)});const l=H(e,Wl);xt()==="en-US"&&Se(l)&&So(l,H(r,"SKILL.md")),n.out(s.skillInstalled(ct,on(r,t)));for(const c of a){dt(c.path,{recursive:!0,force:!0}),qn($t(c.path),{recursive:!0});let i=o==="win32";if(!i)try{mu(Gl($t(c.path),r),c.path,"dir")}catch{i=!0}i&&So(r,c.path,{recursive:!0}),n.out(s.skillLink(c.agent,on(c.path,t),i))}return n.out(s.skillNext),0}function hw(e,t){const n=D(),{files:o,links:s}=Qd(e);let r=0;for(const a of[...s.map(l=>l.path),o])if(eu(a)){if(!tu(a,o)){t.err(n.skillNotOurs(on(a,e)));continue}dt(a,{recursive:!0,force:!0}),t.out(n.removed(on(a,e))),r+=1}return r===0&&t.out(n.noSkill(ct)),0}const pw={out:e=>process.stdout.write(`${e}
|
|
426
|
+
`:""}`),Ce(e,`${Ee}/guides/custom-components.md`,await wb(o)),ut(G(e,Ee,"guides","components"),{recursive:!0,force:!0});for(const r of Ub())Ce(e,`${Ee}/guides/components/${r}.md`,await bb(r,o))}function Jd(e,t){rn(e,"AGENTS.md")===null&&Ce(e,"AGENTS.md",D().agents(t.name)),rn(e,"CLAUDE.md")===null&&Ce(e,"CLAUDE.md",`@AGENTS.md
|
|
427
|
+
`)}function zb(e,t){Jd(e,t);const n=rn(e,".gitignore");n===null?Ce(e,".gitignore",`${Ee}/
|
|
428
|
+
`):n.split(/\r?\n/).some(o=>o.trim().replace(/\/$/,"")===Ee)||Ce(e,".gitignore",`${n.replace(/\n?$/,`
|
|
429
|
+
`)}${Ee}/
|
|
430
|
+
`)}class F extends Error{}const Wb="/studio";function ea(e){return`${e.baseUrl.replace(/\/+$/,"")}${Wb}/workshop/apps/${encodeURIComponent(e.app.id)}/preview`}const qn=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 Kb(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(`
|
|
431
|
+
`))):new F(D().appNotFound(t))}function Yb(e,t){return e.draft?Hl(e.draft):Hl(Xy(Fd.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}),Zd=(e,t)=>{const n=D();return n.conflict(e,t.join(n.and),t.map(o=>`${Ee}/remote/${o}`).join(n.and))};async function Gb(e,t,n,o,s,r){const a=new Map((n.draft?.components??[]).map(m=>[m.type,m.package])),l=bn(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=>Xm(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??nb(m);try{if(g===void 0){if(b&&k){s.push(u.componentKept(m,`${ie}/${w}`));continue}b&&(ab(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){zl(G(t,Kd,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);zl(v,await p(g)),d[m]={folder:w,package:g,hash:ob(v)},s.push(u.downloaded(m,`${ie}/${w}`))}catch(v){g===void 0?r.err(u.note(u.at(`${ie}/${w}`,qn(v)))):y||b?(d[m]={folder:w,package:g,hash:y?.hash??"",behind:!0},r.err(u.note(u.notDownloadedBehind(m,qn(v),`${ie}/${w}`)))):r.err(u.note(u.notDownloaded(m,qn(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=Yb(l,c),d=l.draft?it(i):"",h=jo(t);Gd(t);const u=[],p=await Gb(e,t,l,o?.components??{},u,r);await Vd(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),zb(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)]:(Bb(t,i),y=!0),Jd(t,l);const b=y||p.conflicts.length>0;Yd(t,{...f,...m?{blankHash:m}:{},components:p.tracked,...b?{remoteRevision:l.revision}:{}});for(const k of[...g,...u])s(k);return b&&s(Zd(l.revision,Hd(t))),b}async function Hb(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 Vb(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(`
|
|
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}
|
|
413
433
|
`),err:e=>process.stderr.write(`${e}
|
|
414
|
-
`)};function
|
|
434
|
+
`)};function Pw(e){return fw(kw(e)),{baseUrl:e.baseUrl,...e.insecure?{insecure:!0}:{},listApps:am,getApp:im,listNetworks:hm,createApp:(t,n)=>cm(t,n,null),saveDraft:dm,readNetwork:Tw,registerComponents:Ow,downloadPackage:(t,n)=>ww(e,`/workshop/v1/apps/${encodeURIComponent(t)}/component-packages/${encodeURIComponent(n)}/zip`),uploadPackage:async(t,n)=>{const o=await um(t,new Blob([new Uint8Array(n)]));return{id:o.id,warnings:o.warnings}}}}function Lw(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=mu(t,n,{stdio:"ignore",detached:!0});s.on("error",()=>o(!1)),s.on("spawn",()=>{s.unref(),o(!0)})})}async function Yv(e,t=_w,{env:n=process.env,openbkn:o=nu,workshopOf:s=Pw,open:r=Lw,skillSource:a,home:l=gu(),signal:c,version:i}={}){let d;try{d=ku({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 Ul(oa(y<0?void 0:e[y+1],n)),t.err(`${g instanceof Error?g.message:String(g)}
|
|
415
435
|
|
|
416
|
-
${
|
|
436
|
+
${D().usage(He)}`),1}const{positionals:h,values:u}=d;Ul(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 Rw(l,t);if(g!=="add")throw new F(p.skillUsage);if(!a)throw new F(p.noSkillSource);return xw(a,l,t)}if(f==="list"||f==="create"){let g=null;try{g=Pe(tt("."))}catch{}const y=await _n({state:null,near:g,insecure:u.insecure},n,o);if(f==="list")return await Hb(s(y),t);const[b,k,w]=m;if(!b||!k)throw new F(p.createUsage);return await Jb(s(y),tt(w??Ql(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?Ql(g):".")),v=Pe(w),S=await _n({state:v,insecure:u.insecure},n,o);return await Zb(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 _n({state:y,insecure:u.insecure},n,o));return f==="validate"?await ew(b,g,t):await ow(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 iw(async()=>s(await _n({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
|
+
|
|
438
|
+
${p.usage(He)}`)}catch(g){return t.err(g instanceof Error?g.message:String(g)),1}}function Ql(e){return e.replace(/[\\/:*?"<>|\s]+/g,"-").replace(/^-+|-+$/g,"")||"app"}const Iw=`# Button (actionButton)
|
|
417
439
|
|
|
418
440
|
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.
|
|
419
441
|
|
|
@@ -439,7 +461,7 @@ A button that only asks the Agent needs no action and no object source.
|
|
|
439
461
|
## Built-in checks
|
|
440
462
|
|
|
441
463
|
- No objects: when the action's object source is a selection or a set that is empty right now, the button cannot be clicked and a note says to select one object or to pick the objects first; with objects the note says how many objects it will run on.
|
|
442
|
-
- Confirmation: before an action runs, a confirmation opens that lists the objects, lets the user fill parameters and checks the permission to run (with a note when not allowed); after confirming, the action runs object by object as the user, and the result of each is shown.
|
|
464
|
+
- Confirmation: before an action runs, a confirmation opens that lists the objects, lets the user fill parameters and checks the permission to run (with a note when not allowed); after confirming, the action runs object by object as the user, and the result of each is shown. A parameter named \`app_id\` is filled in with the current app's ID and is not asked for.
|
|
443
465
|
- Count: at most 20 objects per run by default, raised in the step to at most 100; beyond that only the first ones run and the dialog says so.
|
|
444
466
|
- The button text is the name written in the button step, or the name of the first step when empty; at most 20 characters.
|
|
445
467
|
- The icon is a chat icon when the first step asks, a lightning bolt otherwise.
|
|
@@ -503,7 +525,7 @@ A button that only asks the Agent needs no action and no object source.
|
|
|
503
525
|
- One confirmation runs at most 100 objects, 20 by default.
|
|
504
526
|
- It does not follow or write filters.
|
|
505
527
|
- Actions run with the user's own permissions.
|
|
506
|
-
`,
|
|
528
|
+
`,Mw=Object.freeze(Object.defineProperty({__proto__:null,default:Iw},Symbol.toStringTag,{value:"Module"})),qw=`# 按钮(actionButton)
|
|
507
529
|
|
|
508
530
|
页面上的一个按钮,点一下按顺序做配置好的动作:向 Agent 提问,或对选中、勾选的对象执行知识网络里的行动。用来把“看完数据后要做的那一步”放在页面上,执行前总会先确认。
|
|
509
531
|
|
|
@@ -529,7 +551,7 @@ A button that only asks the Agent needs no action and no object source.
|
|
|
529
551
|
## 组件内置的判断
|
|
530
552
|
|
|
531
553
|
- 对象为空时:行动的对象来源是选中或对象集合,目前一个都没有,按钮不能点,旁边提示“请先选中一个对象”或“请先选出要执行的对象”;有对象时提示“将对 N 个对象执行”。
|
|
532
|
-
-
|
|
554
|
+
- 确认:行动执行前总会打开确认窗,列出对象、让用户填写参数、检查执行权限(无权时提示),确认后逐个对象以用户本人的身份执行,并显示每个对象的结果。行动有名为 \`app_id\` 的参数时,自动填入当前应用的 ID,不用填写。
|
|
533
555
|
- 数量:一次最多执行的对象数默认 20,可在动作里调到最多 100;超出时只执行前面的并说明。
|
|
534
556
|
- 按钮文字取按钮动作里写的名称,不写则取第一个动作的名称;最多 20 个字。
|
|
535
557
|
- 按钮的图标:第一个动作是提问时为对话图标,否则为闪电。
|
|
@@ -593,7 +615,7 @@ A button that only asks the Agent needs no action and no object source.
|
|
|
593
615
|
- 一次确认最多执行 100 个对象,默认 20。
|
|
594
616
|
- 不跟随筛选,不写入筛选。
|
|
595
617
|
- 行动按用户本人的权限执行。
|
|
596
|
-
`,
|
|
618
|
+
`,Fw=Object.freeze(Object.defineProperty({__proto__:null,default:qw},Symbol.toStringTag,{value:"Module"})),Dw=`# Agent chat (agentChat)
|
|
597
619
|
|
|
598
620
|
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".
|
|
599
621
|
|
|
@@ -621,7 +643,7 @@ This component has no data source of its own.
|
|
|
621
643
|
- Tools (front-end Agent): read the page state, query objects (at most 50 per query), summarize by a field, query the knowledge network along relations; when allowed, set filters and select an object; when actions are set, suggest actions; when a data source has what-if operations, suggest those. At most 12 steps per question.
|
|
622
644
|
- Step display: each query shows as one sentence of what was looked at, its conditions and the count, not the tool's internal name.
|
|
623
645
|
- Suggestion cards: an action or what-if suggestion only makes a card; the user clicks it to open the confirmation or the parameter form and decides; the Agent cannot run anything itself, and a card runs only once.
|
|
624
|
-
- External Agent: the page calls the answering tool of a registered MCP service through the execution factory, as the user, sending only the parameters the tool declares; the answer is marked as from that external Agent and not checked by the platform; it
|
|
646
|
+
- External Agent: the page calls the answering tool of a registered MCP service through the execution factory, as the user, sending only the parameters the tool declares; the answer is marked as from that external Agent and not checked by the platform; one call is waited on for up to a minute (by default the gateway cuts a call at 60 seconds); when the tool says it is still working, that is shown as such, not as an answer, and when the tool declares \`run_id\` the page asks again with it, for up to 10 minutes.
|
|
625
647
|
- Where questions come from: "Ask the Agent" set on other components goes first to the host page (when embedded), then to this chat, and with neither is answered in a drawer; a folded chat opens to receive it.
|
|
626
648
|
|
|
627
649
|
## Extension points
|
|
@@ -641,11 +663,12 @@ Do not keep a definition only here: a judgement that can be computed belongs in
|
|
|
641
663
|
|
|
642
664
|
- **Purpose**: a customer's or third party's Agent answers the chat directly, without the platform's Agents.
|
|
643
665
|
- **Where**: set "Who answers" to "External Agent", then pick, under "External Agent", an MCP service registered and published in the execution factory and its answering tool (an \`ask\` tool is picked by itself). Users need execute permission on the service.
|
|
644
|
-
- **
|
|
666
|
+
- **Filled in from the workspace**: when the app's workspace (where the builder put it) has a default outside Agent, a new chat starts with its service, tool and Agent, which you can change. They are written into the app then, and later changes to the workspace leave it alone; a service deleted, unpublished or not yours to use is not filled in, and the builder says why. The token switch is never filled in.
|
|
667
|
+
- **What it connects to**: an MCP tool. The page sends only the parameters the tool declares: \`question\`, \`context\` (page context and extra instructions), \`conversation_id\` (one per chat), \`app_id\`, \`kn_id\`, \`workspace_id\` (which of their own workspaces the asker put the app in, their default one when they put it nowhere; a grouping only, granting nothing), \`bkn_token\`, and when asking after a run, \`run_id\` (the number the tool gave for it).
|
|
645
668
|
- **Hand over the user's sign-in token**: off by default. When on, and the tool declares \`bkn_token\`, the user's own access token is sent; with it the Agent can do whatever the user can, running actions and approving included. Turn it on only for a trusted Agent.
|
|
646
|
-
- **Input / output**: standard MCP text content, shown as Markdown.
|
|
647
|
-
- **Failures and timeouts**: no execute permission, service missing or unpublished, tool gone, an error from the other side,
|
|
648
|
-
- **How the result shows**: the answer is headed with which external Agent gave it and that the platform did not check it.
|
|
669
|
+
- **Input / output**: standard MCP text content, shown as Markdown. The tool should answer within 45 seconds; when it needs longer it returns \`status\` (\`running\` or \`queued\`) and \`run_id\` in \`structuredContent\`, with a note for people in \`content\`; a \`status\` of \`failed\` is shown as an error.
|
|
670
|
+
- **Failures and timeouts**: no execute permission, service missing or unpublished, tool gone, an error from the other side, no answer within a minute (the gateway cutting the call included), a tool that cannot be asked after a run, and a run still unfinished after 10 minutes are each told apart; once the page stops waiting, the other side may still be working.
|
|
671
|
+
- **How the result shows**: the answer is headed with which external Agent gave it (the service name; when the settings have none, the name the execution factory gives) and that the platform did not check it; while the tool is still working, only its note shows, not marked as an answer.
|
|
649
672
|
|
|
650
673
|
### Actions it may suggest
|
|
651
674
|
|
|
@@ -697,10 +720,14 @@ Do not keep a definition only here: a judgement that can be computed belongs in
|
|
|
697
720
|
- Extra instructions up to 600 characters; up to 6 suggested questions; fixed height 280 to 800.
|
|
698
721
|
- The front-end Agent takes at most 12 steps per question and 50 objects per query.
|
|
699
722
|
- Setting filters, action suggestions and what-if suggestions are supported only by the front-end Agent.
|
|
700
|
-
- An external Agent is waited on for up to
|
|
723
|
+
- An external Agent is waited on for up to a minute per call, and asked after a run still going for up to 10 minutes in all.
|
|
701
724
|
- One action suggestion runs on at most 100 objects.
|
|
702
725
|
- The Agent's answers come from query results and are not saved to the knowledge network.
|
|
703
|
-
|
|
726
|
+
|
|
727
|
+
### Selecting an agent within a service
|
|
728
|
+
|
|
729
|
+
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
|
+
`,Bw=Object.freeze(Object.defineProperty({__proto__:null,default:Dw},Symbol.toStringTag,{value:"Module"})),Uw=`# Agent 对话(agentChat)
|
|
704
731
|
|
|
705
732
|
围绕页面上的数据提问和回答的对话框。Agent 能查页面上全部数据源和整个知识网络,读当前筛选和选中的对象,允许时还能替用户设置筛选、建议行动。用来让业务人员用自然语言追问“为什么”“哪些”“怎么办”。
|
|
706
733
|
|
|
@@ -728,7 +755,7 @@ Do not keep a definition only here: a judgement that can be computed belongs in
|
|
|
728
755
|
- 工具(前端 Agent):读取页面现状、查询对象(单次最多 50 条)、按字段汇总、沿关系查询知识网络;允许时设置筛选、选中对象;配了行动时提出行动建议;数据源有推演操作时提出推演建议。一次提问最多调用 12 步。
|
|
729
756
|
- 步骤显示:每次查询以一句话显示查了什么、条件与数量,不显示工具内部名称。
|
|
730
757
|
- 建议卡:行动或推演建议只生成卡片,用户点击后打开确认或参数窗,执行与否由用户决定;Agent 不能自己执行,每张卡只执行一次。
|
|
731
|
-
- 外部 Agent:页面以用户本人身份,经执行工厂调用登记的 MCP 服务里回答问题的工具,只传工具声明了的参数;回答标为外部 Agent
|
|
758
|
+
- 外部 Agent:页面以用户本人身份,经执行工厂调用登记的 MCP 服务里回答问题的工具,只传工具声明了的参数;回答标为外部 Agent、未经平台校验;单次最多等 1 分钟(默认部署下网关 60 秒即断开);工具说仍在处理时显示为处理中、不当作回答,工具声明了 \`run_id\` 时带上它续查,最多 10 分钟。
|
|
732
759
|
- 提问来源:别的组件配置的“向 Agent 提问”会先交给宿主页面(应用嵌入时),其次这个对话,都没有时在抽屉里回答;折叠的对话会自动展开接收。
|
|
733
760
|
|
|
734
761
|
## 扩展点
|
|
@@ -748,11 +775,12 @@ Do not keep a definition only here: a judgement that can be computed belongs in
|
|
|
748
775
|
|
|
749
776
|
- **用途**:由客户或第三方的 Agent 直接回答对话框里的问题,不经平台的 Agent。
|
|
750
777
|
- **在哪里配**:“由谁回答”选“外部 Agent”,再在“外部 Agent”里选执行工厂登记并发布的 MCP 服务与其中回答问题的工具(服务有 \`ask\` 工具时自动选上)。使用者须有该服务的执行权限。
|
|
751
|
-
-
|
|
778
|
+
- **按工作区预填**:应用所在的工作区(构建者自己放的)设了默认外部 Agent 时,新加的对话框预先选好服务、工具和智能体,可以改。填好后写进应用,以后改工作区设置不影响它;服务已删除、未发布或无权使用时不预填,并提示原因。登录令牌开关不预填。
|
|
779
|
+
- **接什么**:MCP 工具。页面只传工具声明了的参数:\`question\`、\`context\`(页面上下文与补充说明)、\`conversation_id\`(同一对话框共用)、\`app_id\`、\`kn_id\`、\`workspace_id\`(提问人把应用放在自己的哪个工作区,没放过的是默认工作区;只表示分组,不表示权限)、\`bkn_token\`,续查时另有 \`run_id\`(工具上次给出的运行编号)。
|
|
752
780
|
- **交出使用者的登录令牌**:默认关。打开后,工具声明了 \`bkn_token\` 时把使用者本人的访问令牌交给它;对方凭它能做使用者能做的一切,包括执行行动和办理审批。只对可信的 Agent 打开。
|
|
753
|
-
- **输入 / 输出**:返回 MCP 标准的文本内容,按 Markdown
|
|
754
|
-
- **失败与超时**:无执行权限、服务不存在或未发布、工具不在、对方报错、
|
|
755
|
-
- **结果怎样显示**:回答上方标明是哪个外部 Agent
|
|
781
|
+
- **输入 / 输出**:返回 MCP 标准的文本内容,按 Markdown 显示。工具应在 45 秒内返回;做不完时在 \`structuredContent\` 中返回 \`status\`(\`running\` 或 \`queued\`)与 \`run_id\`,\`content\` 写给人看的说明;\`status\` 为 \`failed\` 时按报错显示。
|
|
782
|
+
- **失败与超时**:无执行权限、服务不存在或未发布、工具不在、对方报错、1 分钟无回答(含网关断开)、工具不能续查、续查 10 分钟仍未完成,分别提示原因;停止等待后对方可能仍在执行。
|
|
783
|
+
- **结果怎样显示**:回答上方标明是哪个外部 Agent 的回答(服务名称;配置里没有名称时向执行工厂取)、未经平台校验;处理中只显示工具的说明,不标为回答。
|
|
756
784
|
|
|
757
785
|
### 允许建议的行动
|
|
758
786
|
|
|
@@ -804,10 +832,14 @@ Do not keep a definition only here: a judgement that can be computed belongs in
|
|
|
804
832
|
- 补充说明最多 600 字;建议问题最多 6 条;常驻高度 280 到 800。
|
|
805
833
|
- 前端 Agent 单次提问最多 12 步,单次查询最多取 50 条对象。
|
|
806
834
|
- 设置筛选、行动建议与推演建议只有前端 Agent 支持。
|
|
807
|
-
- 外部 Agent
|
|
835
|
+
- 外部 Agent 单次调用最多等 1 分钟,处理中续查累计最多 10 分钟。
|
|
808
836
|
- 一次行动建议最多对 100 个对象执行。
|
|
809
837
|
- Agent 的回答来自查询结果,不保存到知识网络。
|
|
810
|
-
|
|
838
|
+
|
|
839
|
+
### 选择服务中的智能体
|
|
840
|
+
|
|
841
|
+
外部 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
|
+
`,zw=Object.freeze(Object.defineProperty({__proto__:null,default:Uw},Symbol.toStringTag,{value:"Module"})),Ww=`# Alerts (alertList)
|
|
811
843
|
|
|
812
844
|
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.
|
|
813
845
|
|
|
@@ -887,7 +919,7 @@ None. The component only counts by the configured conditions and calls no outsid
|
|
|
887
919
|
- 1 to 8 rules; 3 to 20 rows when expanded.
|
|
888
920
|
- It computes only what hits now; it keeps no history and has no owner or handling state.
|
|
889
921
|
- Missing-link rules read relations, so the count shows a spinner while loading.
|
|
890
|
-
`,
|
|
922
|
+
`,Kw=Object.freeze(Object.defineProperty({__proto__:null,default:Ww},Symbol.toStringTag,{value:"Module"})),Yw=`# 告警(alertList)
|
|
891
923
|
|
|
892
924
|
按事先写好的规则,实时列出当前命中的对象,按严重程度排序。用来回答“现在有哪些对象需要关注”,点一条规则就把页面收窄到它命中的对象。
|
|
893
925
|
|
|
@@ -967,7 +999,7 @@ None. The component only counts by the configured conditions and calls no outsid
|
|
|
967
999
|
- 规则 1 到 8 条;展开显示 3 到 20 条。
|
|
968
1000
|
- 只计算此刻命中,不保存历史,也没有负责人、处理状态。
|
|
969
1001
|
- 缺失关联查询需要读取关系,命中数加载时显示转圈。
|
|
970
|
-
`,
|
|
1002
|
+
`,Gw=Object.freeze(Object.defineProperty({__proto__:null,default:Yw},Symbol.toStringTag,{value:"Module"})),Hw=`# Base date (asOfSlider)
|
|
971
1003
|
|
|
972
1004
|
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".
|
|
973
1005
|
|
|
@@ -1046,7 +1078,7 @@ None. The component only writes the base date and calls no tool. Industry rules
|
|
|
1046
1078
|
- Steps are day, week and month only; a month is fixed at 30 days.
|
|
1047
1079
|
- One base date variable per page.
|
|
1048
1080
|
- 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).
|
|
1049
|
-
`,
|
|
1081
|
+
`,Vw=Object.freeze(Object.defineProperty({__proto__:null,default:Hw},Symbol.toStringTag,{value:"Module"})),Jw=`# 基准日期(asOfSlider)
|
|
1050
1082
|
|
|
1051
1083
|
拖动滑块选一个日期,整页按这一天计算。用来回答“截至某天是什么样”“上个月底有多少项已超期”这类问题。
|
|
1052
1084
|
|
|
@@ -1125,7 +1157,7 @@ None. The component only writes the base date and calls no tool. Industry rules
|
|
|
1125
1157
|
- 步长只有天、周、月三种;月固定按 30 天。
|
|
1126
1158
|
- 一个页面一个基准日期变量。
|
|
1127
1159
|
- 范围依据已读入的数据,对象类数据源最多读 5000 行,Cypher 数据源最多 10000 行(查询没写 LIMIT 时 1000 行)。
|
|
1128
|
-
`,
|
|
1160
|
+
`,Zw=Object.freeze(Object.defineProperty({__proto__:null,default:Jw},Symbol.toStringTag,{value:"Module"})),Xw=`# Custom components: building and extending
|
|
1129
1161
|
|
|
1130
1162
|
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.
|
|
1131
1163
|
|
|
@@ -1156,10 +1188,19 @@ When the standard components cannot show or do what you need, you can build your
|
|
|
1156
1188
|
| Can | How |
|
|
1157
1189
|
| --- | --- |
|
|
1158
1190
|
| Show the objects of a data source | The data source and field roles in its settings; the component gets the rows in \`data\` |
|
|
1159
|
-
| Look up more data | \`workshop.query\`: read-only Cypher, or a filter over an existing data source |
|
|
1191
|
+
| Look up more data | \`workshop.query\`: read-only Cypher, or a filter over an existing data source (see "What lookups and questions do today" below) |
|
|
1160
1192
|
| Select or filter for other components | Declared in the manifest's \`emits\`, written to the shared filters |
|
|
1161
|
-
| Run an action | \`workshop.act\`: Workshop always asks for confirmation first |
|
|
1193
|
+
| Run an action | \`workshop.act\`: Workshop always asks for confirmation first. When the action has a parameter named \`app_id\`, Workshop fills in the current app's ID and ignores any value the component passes |
|
|
1162
1194
|
| Let the page's Agent understand it | \`workshop.describe\`: tells the Agent what the component shows now |
|
|
1195
|
+
| Ask the Agent | \`workshop.ask\`: hands a question to the page's Agent chat |
|
|
1196
|
+
|
|
1197
|
+
**What lookups and questions do today.** This is how they behave now; write components for it:
|
|
1198
|
+
|
|
1199
|
+
- \`query({ kind: "objects" })\` does not go to the server: it filters the page's own data source of that object type. With no such source on the page it rejects with \`unavailable\`; \`where\` takes equal values only; at most 5000 rows come back, with \`truncated\` true when there were more. With a scenario picked, the rows are the scenario's, as in the component's own \`data\`, computed columns worked out the same way. For more data or other conditions, use Cypher.
|
|
1200
|
+
- \`query({ kind: "cypher" })\` reads the network's current data as the user, without a scenario's changes, and without the computed columns of the page's data sources.
|
|
1201
|
+
- \`query({ kind: "metric" })\` is not offered yet and rejects with \`unavailable\`. To use a metric, put a metric card on the page, or its results in a data source.
|
|
1202
|
+
- \`ask\` sends only the question; the objects in \`context\` are not sent yet. The question goes into the Agent chat's input box for the user to send. A page with an Agent chat component gets it there; without one, a chat opens in a drawer beside the page, which keeps the conversation when closed and opens again on the next question.
|
|
1203
|
+
- Array and object settings with no \`x-workshop\` widget are not in the settings panel: write them in the app's \`app.yaml\`, and the component gets what is written or the manifest's default; the app's check only sees that each is an array or an object.
|
|
1163
1204
|
|
|
1164
1205
|
It cannot: use browser storage or cookies; reach addresses its manifest does not declare; run an action without the confirmation; run actions or open pages while the app is designed or previewed in the builder; get the user's token, or act as the user beyond the table above (it cannot create an analysis canvas, for one). The addresses its manifest's \`network\` declares can be reached, but the requests do not carry the user's identity.
|
|
1165
1206
|
|
|
@@ -1191,73 +1232,7 @@ Write it under these headings, with "None" under a heading that has nothing:
|
|
|
1191
1232
|
- **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.
|
|
1192
1233
|
- **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.
|
|
1193
1234
|
- **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.
|
|
1194
|
-
`,
|
|
1195
|
-
|
|
1196
|
-
标准组件满足不了的展示与交互,可以自己开发组件,打成组件包上传到这个应用。组件跑在隔离的框架里,只能通过 Workshop 给的接口读数据、执行行动,拿不到登录信息,也不能随意联网。
|
|
1197
|
-
|
|
1198
|
-
## 一 怎样开发一个组件
|
|
1199
|
-
|
|
1200
|
-
1. **装开发包。** 在自己的项目里装 \`@openbkn/workshop\`(发布在公开 npm 源上,直接安装):
|
|
1201
|
-
|
|
1202
|
-
\`\`\`bash
|
|
1203
|
-
npm install --save-dev @openbkn/workshop@rc
|
|
1204
|
-
\`\`\`
|
|
1205
|
-
|
|
1206
|
-
2. **新建组件包。** 目录名就是组件名,类型为 \`x-<前缀>.<名称>\`:
|
|
1207
|
-
|
|
1208
|
-
\`\`\`bash
|
|
1209
|
-
npx workshop-component init supplier-ranking --prefix acme --label 供应商排行
|
|
1210
|
-
\`\`\`
|
|
1211
|
-
|
|
1212
|
-
生成四个文件:\`manifest.json\`(清单:类型、名称、配置项、数据角色、联动)、\`index.js\`(入口,定义一个自定义元素)、\`preview.json\`(本地预览用的示例数据)、\`README.md\`(组件说明,见第三节)。
|
|
1213
|
-
|
|
1214
|
-
3. **本地预览。** \`npx workshop-component dev supplier-ranking\`,打开 \`http://localhost:8765/\`。组件在与 Workshop 相同的隔离框架里运行,可以切换主题、语言、宽度,模拟空结果、无权限和行动确认框。
|
|
1215
|
-
|
|
1216
|
-
4. **校验并打包。** \`npx workshop-component validate\` 按上传时的检查校验;\`npx workshop-component pack --out dist\` 打出 zip。
|
|
1217
|
-
|
|
1218
|
-
5. **上传。** 在左侧组件库「自定义组件」里点「上传组件包」。上传后组件会放到当前页面上,配置面板按清单生成;同一类型再次上传会换成新包。发布前,应用里用到的每个组件包都要能找到,否则发布会被拦下。
|
|
1219
|
-
|
|
1220
|
-
## 二 组件能做什么、不能做什么
|
|
1221
|
-
|
|
1222
|
-
| 能做 | 怎么做 |
|
|
1223
|
-
| --- | --- |
|
|
1224
|
-
| 显示数据源里的对象 | 配置项里的数据源与字段角色,组件从 \`data\` 拿到已经取好的行 |
|
|
1225
|
-
| 补查数据 | \`workshop.query\`:只读 Cypher,或在已有数据源里再筛选 |
|
|
1226
|
-
| 选中、筛选别的组件 | 清单 \`emits\` 声明后,写入共享筛选 |
|
|
1227
|
-
| 执行行动 | \`workshop.act\`:一定先弹 Workshop 的确认框,用户点确定才执行 |
|
|
1228
|
-
| 让页面的 Agent 读懂组件 | \`workshop.describe\`:告诉 Agent 组件现在显示什么 |
|
|
1229
|
-
|
|
1230
|
-
不能做:读写浏览器存储与 Cookie;访问清单没有声明的网络地址;绕过确认框执行行动;在构建器设计和预览时执行行动或打开页面;拿使用者的令牌,或以使用者的身份做上表以外的事(比如建分析画布)。清单 \`network\` 里声明的地址可以访问,但请求不带使用者的身份。
|
|
1231
|
-
|
|
1232
|
-
包的限制:总大小 5 MB、最多 500 个文件,入口建议不超过 300 KB;只收 js、css、json、svg、png、jpg、webp、woff2、md 文件。
|
|
1233
|
-
|
|
1234
|
-
## 三 每个组件都要附说明
|
|
1235
|
-
|
|
1236
|
-
组件包里放一份 \`README.md\`,上传后在组件库和配置面板上点「说明」就能看到,构建应用的人和 AI 都靠它配置组件。没有说明的包,校验时会给出提醒。
|
|
1237
|
-
|
|
1238
|
-
说明按下面的标题写,没有内容的节写“无”:
|
|
1239
|
-
|
|
1240
|
-
- **概述**:写在标题下的第一段,说明展示什么、用来做什么决策。
|
|
1241
|
-
- **适用与不适用**:不适用时改用什么。
|
|
1242
|
-
- **本体契约**:组件里有哪些角色(如“项”“资源”“任务”),每个角色要哪类对象、哪些属性、哪些关系、是否必填。
|
|
1243
|
-
- **组件内置的判断**:组件自己做的、与行业无关的检查,是硬约束还是只标出。
|
|
1244
|
-
- **扩展点**:场景判断从哪里接进来,接逻辑属性、指标还是规则工具,输入输出是什么。
|
|
1245
|
-
- **交互与联动**:写入、读取哪些筛选,能触发哪些行动。
|
|
1246
|
-
- **场景配方**:每个场景怎样对应角色、要在知识网络里补什么、扩展点挂什么。
|
|
1247
|
-
- **给 AI 的指引**:配置步骤、先问用户什么、常见错误。
|
|
1248
|
-
- **限制**:数量上限、不支持的情况。
|
|
1249
|
-
|
|
1250
|
-
## 四 二次开发建议
|
|
1251
|
-
|
|
1252
|
-
- **业务判断放在知识网络里,不写进组件。** “是否超期”“是否齐套”“风险高低”这类判断,写成知识网络的属性、逻辑属性、指标或规则工具,组件只读结果。这样同一个问题在各处答案一致,改规则不用改组件。
|
|
1253
|
-
- **组件只做通用能力。** 排行、矩阵、甘特、拖动、重叠检查这类与行业无关的展示和交互放在组件里;行业规则通过扩展点接进来。
|
|
1254
|
-
- **为新场景复用组件,先改知识网络。** 按说明里的本体契约把场景对象对应到组件角色,缺的对象、属性、关系在知识网络里补;再把场景判断挂到扩展点上。
|
|
1255
|
-
- **不要写死对象类和属性名。** 对象类、关系、字段都从配置项和数据源里取,不要在代码里写死 \`supplier\` 这样的名字,换一个网络组件照样能用。
|
|
1256
|
-
- **改数据只走行动。** 组件不直接写数据,需要改动时调用知识网络的行动,用户在确认框里确认。
|
|
1257
|
-
- **让 Agent 能读懂。** 用 \`describe\` 报告组件当前显示的内容和选中项,页面上的 Agent 才能基于它回答问题。
|
|
1258
|
-
- **说明与代码一起改。** 配置项、上限、扩展点变了,同一次改动更新 \`README.md\`,并把清单里的版本号加一。
|
|
1259
|
-
- **AI 生成或修改组件时也一样。** 缺判断时补知识网络,不补代码。
|
|
1260
|
-
`,ou=Object.freeze(Object.defineProperty({__proto__:null,default:Pw},Symbol.toStringTag,{value:"Module"})),Lw=`# Date range (dateRange)
|
|
1235
|
+
`,du=Object.freeze(Object.defineProperty({__proto__:null,default:Xw},Symbol.toStringTag,{value:"Module"})),Qw='# 自定义组件:开发与二次开发\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',uu=Object.freeze(Object.defineProperty({__proto__:null,default:Qw},Symbol.toStringTag,{value:"Module"})),ek=`# Date range (dateRange)
|
|
1261
1236
|
|
|
1262
1237
|
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".
|
|
1263
1238
|
|
|
@@ -1332,7 +1307,7 @@ None. The quick picks are fixed and cannot come from the knowledge network, so f
|
|
|
1332
1307
|
- One component writes one date range; filtering by several dates separately takes several ranges.
|
|
1333
1308
|
- There are 7 fixed quick picks; they can only be turned on or off.
|
|
1334
1309
|
- Dates are compared by day, without time of day.
|
|
1335
|
-
`,
|
|
1310
|
+
`,tk=Object.freeze(Object.defineProperty({__proto__:null,default:ek},Symbol.toStringTag,{value:"Module"})),nk=`# 日期区间(dateRange)
|
|
1336
1311
|
|
|
1337
1312
|
选起点和终点两个日期,页面上跟随它的组件只显示某个日期落在这段时间里的对象。用来回答“这个月签了多少”“近 30 天新增了哪些”。
|
|
1338
1313
|
|
|
@@ -1407,7 +1382,7 @@ None. The quick picks are fixed and cannot come from the knowledge network, so f
|
|
|
1407
1382
|
- 一个组件写一个日期区间;一个对象类里要按几个日期分别筛,需要几个区间。
|
|
1408
1383
|
- 快捷项固定为 7 个,无法增删,只能开或关。
|
|
1409
1384
|
- 日期按天比较,不含时分。
|
|
1410
|
-
`,
|
|
1385
|
+
`,ok=Object.freeze(Object.defineProperty({__proto__:null,default:nk},Symbol.toStringTag,{value:"Module"})),sk=`# Dropdown filter (dropdownFilter)
|
|
1411
1386
|
|
|
1412
1387
|
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.
|
|
1413
1388
|
|
|
@@ -1479,7 +1454,7 @@ None. Options come only from the data and cannot be supplied by the knowledge ne
|
|
|
1479
1454
|
|
|
1480
1455
|
- 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.
|
|
1481
1456
|
- It filters by equal values only, with no range or fuzzy match.
|
|
1482
|
-
`,
|
|
1457
|
+
`,rk=Object.freeze(Object.defineProperty({__proto__:null,default:sk},Symbol.toStringTag,{value:"Module"})),ak=`# 下拉筛选(dropdownFilter)
|
|
1483
1458
|
|
|
1484
1459
|
下拉选择一个或多个值,页面上跟随它的组件只显示所选值。选项从数据里自动取,带数量,可以搜索。用在取值很多的字段上,如城市、客户、球队。
|
|
1485
1460
|
|
|
@@ -1551,7 +1526,7 @@ None. Options come only from the data and cannot be supplied by the knowledge ne
|
|
|
1551
1526
|
|
|
1552
1527
|
- 选项最多等于数据中出现过的不同取值;对象类数据源最多读 5000 行,Cypher 数据源最多 10000 行(查询没写 LIMIT 时 1000 行),超过时只有读到的取值。
|
|
1553
1528
|
- 只按取值相等筛选,不支持范围或模糊匹配。
|
|
1554
|
-
`,
|
|
1529
|
+
`,ik=Object.freeze(Object.defineProperty({__proto__:null,default:ak},Symbol.toStringTag,{value:"Module"})),lk=`# Event list (eventList)
|
|
1555
1530
|
|
|
1556
1531
|
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.
|
|
1557
1532
|
|
|
@@ -1662,7 +1637,7 @@ Whether an event is created, what a check found, and which actions a status allo
|
|
|
1662
1637
|
- The reason for reject, close and reopen is at most 200 characters.
|
|
1663
1638
|
- When a chosen event type is missing from the knowledge network, the list says events of that type cannot come in.
|
|
1664
1639
|
- The app needs at least one event type. Without any, the component asks you to choose some on the "Events" tab.
|
|
1665
|
-
`,
|
|
1640
|
+
`,ck=Object.freeze(Object.defineProperty({__proto__:null,default:lk},Symbol.toStringTag,{value:"Module"})),dk=`# 事件列表(eventList)
|
|
1666
1641
|
|
|
1667
1642
|
列出应用处理的业务事件,未关闭的在前、按严重程度排,由人核实、驳回、关闭,并从事件进入分析。用来做“哪些事要先看、是不是真的、要不要处理”的决策。
|
|
1668
1643
|
|
|
@@ -1773,7 +1748,7 @@ Whether an event is created, what a check found, and which actions a status allo
|
|
|
1773
1748
|
- 驳回、关闭、重新打开的原因不超过 200 字。
|
|
1774
1749
|
- 知识网络里没有某个已选的事件类型时,列表提示该类型的事件进不来。
|
|
1775
1750
|
- 应用至少要选一个事件类型;没有时组件提示先到“事件”页签选择。
|
|
1776
|
-
`,
|
|
1751
|
+
`,uk=Object.freeze(Object.defineProperty({__proto__:null,default:dk},Symbol.toStringTag,{value:"Module"})),hk=`# Event report (eventReport)
|
|
1777
1752
|
|
|
1778
1753
|
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.
|
|
1779
1754
|
|
|
@@ -1845,7 +1820,7 @@ None. The form's fields are configuration, not business judgment. Whether a repo
|
|
|
1845
1820
|
- One component serves one event type. To report several kinds, place several components.
|
|
1846
1821
|
- The form has at most 12 fields, of type text, number or date.
|
|
1847
1822
|
- The title is at most 80 characters and a text field at most 200.
|
|
1848
|
-
`,
|
|
1823
|
+
`,pk=Object.freeze(Object.defineProperty({__proto__:null,default:hk},Symbol.toStringTag,{value:"Module"})),fk=`# 事件登记(eventReport)
|
|
1849
1824
|
|
|
1850
1825
|
一个按钮,点开表单登记一条业务事件,登记后状态为待核实。用来让现场人员把规则发现不了的异常记下来,交给有权限的人核实。
|
|
1851
1826
|
|
|
@@ -1917,7 +1892,7 @@ None. The form's fields are configuration, not business judgment. Whether a repo
|
|
|
1917
1892
|
- 一个组件对应一个事件类型;要登记多类事件,放多个组件。
|
|
1918
1893
|
- 登记表单最多 12 个字段,类型只有文本、数字、日期。
|
|
1919
1894
|
- 标题不超过 80 字,文本字段不超过 200 字。
|
|
1920
|
-
`,
|
|
1895
|
+
`,mk=Object.freeze(Object.defineProperty({__proto__:null,default:fk},Symbol.toStringTag,{value:"Module"})),gk=`# Gantt chart (ganttChart)
|
|
1921
1896
|
|
|
1922
1897
|
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.
|
|
1923
1898
|
|
|
@@ -1990,7 +1965,7 @@ None. Put judgements such as late or at risk in logical properties on the knowle
|
|
|
1990
1965
|
- Days shown 14 to 365; max rows 3 to 40; one data source.
|
|
1991
1966
|
- No click or drag, and it writes no filter.
|
|
1992
1967
|
- Only the rows with the most bars are shown; the rest are not.
|
|
1993
|
-
`,
|
|
1968
|
+
`,yk=Object.freeze(Object.defineProperty({__proto__:null,default:gk},Symbol.toStringTag,{value:"Module"})),bk=`# 甘特图(ganttChart)
|
|
1994
1969
|
|
|
1995
1970
|
按开始、结束日期把对象画成条,每行一组,围绕页面的基准日期显示一段时间。用来看计划与进度的整体分布,判断哪些项挤在一起、哪些已拖期。
|
|
1996
1971
|
|
|
@@ -2063,7 +2038,7 @@ None. Put judgements such as late or at risk in logical properties on the knowle
|
|
|
2063
2038
|
- 显示天数 14 到 365;最多行数 3 到 40;一个数据源。
|
|
2064
2039
|
- 不能点击、拖动,不写入任何筛选。
|
|
2065
2040
|
- 只显示条数最多的前若干行,其余行不显示。
|
|
2066
|
-
`,
|
|
2041
|
+
`,wk=Object.freeze(Object.defineProperty({__proto__:null,default:bk},Symbol.toStringTag,{value:"Module"})),kk=`# Metric cards (metricCards)
|
|
2067
2042
|
|
|
2068
2043
|
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".
|
|
2069
2044
|
|
|
@@ -2163,7 +2138,7 @@ Business rules in a metric's definition or conditions belong in the knowledge ne
|
|
|
2163
2138
|
- 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.
|
|
2164
2139
|
- Object metric cards write no filter.
|
|
2165
2140
|
- The trend line covers at most the last 6 periods.
|
|
2166
|
-
`,
|
|
2141
|
+
`,vk=Object.freeze(Object.defineProperty({__proto__:null,default:kk},Symbol.toStringTag,{value:"Module"})),$k=`# 指标卡组(metricCards)
|
|
2167
2142
|
|
|
2168
2143
|
一排数字卡片,每张统计一项指标,可显示同比环比与趋势;点击卡片可以筛选页面。用来回答“现在有多少、多少已超期、比上月涨了还是降了”。
|
|
2169
2144
|
|
|
@@ -2263,7 +2238,7 @@ Business rules in a metric's definition or conditions belong in the knowledge ne
|
|
|
2263
2238
|
- 页面内统计读入的对象有行数上限(对象类数据源最多 5000 行,Cypher 数据源最多 10000 行,查询没写 LIMIT 时 1000 行),超过时只统计读到的部分;对象指标由平台算,不受此限。
|
|
2264
2239
|
- 对象指标卡不写入筛选。
|
|
2265
2240
|
- 同比环比的趋势线最多画最近 6 期。
|
|
2266
|
-
`,
|
|
2241
|
+
`,Sk=Object.freeze(Object.defineProperty({__proto__:null,default:$k},Symbol.toStringTag,{value:"Module"})),jk=`# Model trial (modelTrial)
|
|
2267
2242
|
|
|
2268
2243
|
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.
|
|
2269
2244
|
|
|
@@ -2396,7 +2371,7 @@ Independent of industry, the component does these itself:
|
|
|
2396
2371
|
- 2 to 4 parameter sets, and the first is the baseline.
|
|
2397
2372
|
- A call is cut after about 30 seconds, and the set that timed out shows as failed.
|
|
2398
2373
|
- Trial results are not saved to the service, only in the current browser.
|
|
2399
|
-
`,
|
|
2374
|
+
`,Ak=Object.freeze(Object.defineProperty({__proto__:null,default:jk},Symbol.toStringTag,{value:"Module"})),Tk=`# 模型试算(modelTrial)
|
|
2400
2375
|
|
|
2401
2376
|
对一批对象,按 2 到 4 组参数各调用一次模型,并排比较各组的汇总与明细;结果只显示在页面上,不改对象。用来做“参数这样调、结果会怎样”的决策。
|
|
2402
2377
|
|
|
@@ -2529,7 +2504,7 @@ Independent of industry, the component does these itself:
|
|
|
2529
2504
|
- 参数组 2 到 4 个;第一组是基准。
|
|
2530
2505
|
- 一次调用最长约 30 秒;超时的组显示失败。
|
|
2531
2506
|
- 试算结果不保存到服务,只保存在当前浏览器。
|
|
2532
|
-
`,
|
|
2507
|
+
`,Ok=Object.freeze(Object.defineProperty({__proto__:null,default:Tk},Symbol.toStringTag,{value:"Module"})),Ek=`# Object detail (objectDetail)
|
|
2533
2508
|
|
|
2534
2509
|
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.
|
|
2535
2510
|
|
|
@@ -2642,7 +2617,7 @@ What counts as "done" or "overdue" is defined by the data source's progress, not
|
|
|
2642
2617
|
- The drawer has a fixed width, and properties are laid out in two columns.
|
|
2643
2618
|
- Actions on click: up to 8 items with up to 5 steps each.
|
|
2644
2619
|
- 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.
|
|
2645
|
-
`,
|
|
2620
|
+
`,Ck=Object.freeze(Object.defineProperty({__proto__:null,default:Ek},Symbol.toStringTag,{value:"Module"})),Nk=`# 对象详情(objectDetail)
|
|
2646
2621
|
|
|
2647
2622
|
选中一个对象后,从右侧抽屉里显示它的进度、属性,以及沿关系查到的关联记录。用来在列表或汇总里点中一项后,看这一项的全貌并就地处理。
|
|
2648
2623
|
|
|
@@ -2755,7 +2730,7 @@ What counts as "done" or "overdue" is defined by the data source's progress, not
|
|
|
2755
2730
|
- 抽屉宽度固定,属性按两列排。
|
|
2756
2731
|
- 点击后的动作最多 8 项,每项最多 5 个动作。
|
|
2757
2732
|
- 对象类数据源最多读入 5000 个对象,Cypher 数据源最多 10000 行(查询没写 LIMIT 时 1000 行);选中的对象不在已读取的部分时找不到,抽屉不打开。
|
|
2758
|
-
`,
|
|
2733
|
+
`,xk=Object.freeze(Object.defineProperty({__proto__:null,default:Nk},Symbol.toStringTag,{value:"Module"})),Rk=`# Object list (objectList)
|
|
2759
2734
|
|
|
2760
2735
|
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.
|
|
2761
2736
|
|
|
@@ -2848,7 +2823,7 @@ What a business means by "needs handling" or "urgent" is not judged in the list;
|
|
|
2848
2823
|
- "Show at most" is 3 to 30 items (default 8); the rest are only counted in a note, with no paging.
|
|
2849
2824
|
- 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.
|
|
2850
2825
|
- Actions on click: up to 8 items with up to 5 steps each; one execution confirmation covers at most 100 objects.
|
|
2851
|
-
`,
|
|
2826
|
+
`,_k=Object.freeze(Object.defineProperty({__proto__:null,default:Rk},Symbol.toStringTag,{value:"Module"})),Pk=`# 对象列表(objectList)
|
|
2852
2827
|
|
|
2853
2828
|
卡片式列表:每项一个标题,加几行说明和一个状态徽标;点一项选中对象。用来做待办、收件箱这类“先看哪几项、点开处理”的入口。
|
|
2854
2829
|
|
|
@@ -2941,7 +2916,7 @@ What a business means by "needs handling" or "urgent" is not judged in the list;
|
|
|
2941
2916
|
- “最多显示”3 到 30 项(默认 8);超出的只提示个数,不翻页。
|
|
2942
2917
|
- 对象类数据源最多读入 5000 个对象,Cypher 数据源最多 10000 行(查询没写 LIMIT 时 1000 行),超过时上方提示,列表只覆盖已读取部分。
|
|
2943
2918
|
- 点击后的动作最多 8 项,每项最多 5 个动作;一次执行确认最多 100 个对象。
|
|
2944
|
-
`,
|
|
2919
|
+
`,Lk=Object.freeze(Object.defineProperty({__proto__:null,default:Pk},Symbol.toStringTag,{value:"Module"})),Ik=`# Object table (objectTable)
|
|
2945
2920
|
|
|
2946
2921
|
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.
|
|
2947
2922
|
|
|
@@ -3064,7 +3039,7 @@ What a business means by "overdue", "high risk" or "short of material" is not ju
|
|
|
3064
3039
|
- 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.
|
|
3065
3040
|
- 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.
|
|
3066
3041
|
- Search runs only on the objects already read into the browser; it does not query the knowledge network again.
|
|
3067
|
-
`,
|
|
3042
|
+
`,Mk=Object.freeze(Object.defineProperty({__proto__:null,default:Ik},Symbol.toStringTag,{value:"Module"})),qk=`# 对象表(objectTable)
|
|
3068
3043
|
|
|
3069
3044
|
把一类对象列成明细表,可排序、分页、勾选,点一行选中对象。用来逐项核对、挑出一批对象交给别的组件或行动处理。
|
|
3070
3045
|
|
|
@@ -3187,7 +3162,7 @@ What a business means by "overdue", "high risk" or "short of material" is not ju
|
|
|
3187
3162
|
- 对象类数据源最多读入 5000 个对象,Cypher 数据源最多 10000 行(查询没写 LIMIT 时 1000 行);超过时表上方提示“仅读取前 N 条(共 M 条)”(Cypher 数据源不知道总数,只提示可能不完整),表里的数据与统计只覆盖已读取部分。
|
|
3188
3163
|
- 点击后的动作最多 8 项,每项最多 5 个动作;一次执行确认最多 100 个对象,单个行动配置默认最多 20 个。
|
|
3189
3164
|
- 搜索只在浏览器已读入的对象上做,不去知识网络再查。
|
|
3190
|
-
`,
|
|
3165
|
+
`,Fk=Object.freeze(Object.defineProperty({__proto__:null,default:qk},Symbol.toStringTag,{value:"Module"})),Dk=`# Pivot table (pivotTable)
|
|
3191
3166
|
|
|
3192
3167
|
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.
|
|
3193
3168
|
|
|
@@ -3285,7 +3260,7 @@ Sum, average, least and greatest need a number property; count and share do not.
|
|
|
3285
3260
|
- Up to 5 measures; 5 to 50 rows shown (default 10), further groups are not shown.
|
|
3286
3261
|
- 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.
|
|
3287
3262
|
- Actions on click: up to 8 items with up to 5 steps each; one execution confirmation covers at most 100 objects.
|
|
3288
|
-
`,
|
|
3263
|
+
`,Bk=Object.freeze(Object.defineProperty({__proto__:null,default:Dk},Symbol.toStringTag,{value:"Module"})),Uk=`# 透视表(pivotTable)
|
|
3289
3264
|
|
|
3290
3265
|
按一个属性把对象分组,每组一行,每列一个统计数;点一行,整页只看这一组。用来回答“各类里分别有多少、多少金额、占比多少”,并从汇总点进明细。
|
|
3291
3266
|
|
|
@@ -3383,7 +3358,7 @@ Sum, average, least and greatest need a number property; count and share do not.
|
|
|
3383
3358
|
- 度量最多 5 个;最多显示 5 到 50 行(默认 10),超出的组不显示。
|
|
3384
3359
|
- 对象类数据源最多读入 5000 个对象,Cypher 数据源最多 10000 行(查询没写 LIMIT 时 1000 行),超过时上方提示,统计只覆盖已读取部分。
|
|
3385
3360
|
- 点击后的动作最多 8 项,每项最多 5 个动作;一次执行确认最多 100 个对象。
|
|
3386
|
-
`,
|
|
3361
|
+
`,zk=Object.freeze(Object.defineProperty({__proto__:null,default:Uk},Symbol.toStringTag,{value:"Module"})),Wk=`# Map (regionMap)
|
|
3387
3362
|
|
|
3388
3363
|
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".
|
|
3389
3364
|
|
|
@@ -3507,7 +3482,7 @@ What counts as a "risk region" or a "key area" is not judged on the map; propert
|
|
|
3507
3482
|
- Up to 2 relation lines, each one direct relation only.
|
|
3508
3483
|
- 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.
|
|
3509
3484
|
- Actions on click: up to 8 items with up to 5 steps each.
|
|
3510
|
-
`,
|
|
3485
|
+
`,Kk=Object.freeze(Object.defineProperty({__proto__:null,default:Wk},Symbol.toStringTag,{value:"Module"})),Yk=`# 地图(regionMap)
|
|
3511
3486
|
|
|
3512
3487
|
按地区给地图着色:中国地图按省份,世界地图按国家,颜色深浅表示该地区对象的数量或金额;可画出关联对象到这些对象之间的连线,点一个地区,整页只看它。用来回答“这些对象分布在哪里、哪里最集中、货从哪里来到哪里去”。
|
|
3513
3488
|
|
|
@@ -3631,7 +3606,7 @@ What counts as a "risk region" or a "key area" is not judged on the map; propert
|
|
|
3631
3606
|
- 关系连线最多 2 条,每条只能是一条直接关系。
|
|
3632
3607
|
- 对象类数据源最多读入 5000 个对象,Cypher 数据源最多 10000 行(查询没写 LIMIT 时 1000 行),超过时上方提示,统计只覆盖已读取部分。
|
|
3633
3608
|
- 点击后的动作最多 8 项,每项最多 5 个动作。
|
|
3634
|
-
`,
|
|
3609
|
+
`,Gk=Object.freeze(Object.defineProperty({__proto__:null,default:Yk},Symbol.toStringTag,{value:"Module"})),Hk=`# Scenario (scenarioBar)
|
|
3635
3610
|
|
|
3636
3611
|
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.
|
|
3637
3612
|
|
|
@@ -3749,7 +3724,7 @@ Independent of industry, the component does these itself:
|
|
|
3749
3724
|
- 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.
|
|
3750
3725
|
- A scenario name is at most 40 characters.
|
|
3751
3726
|
- A model result reads at most 5000 rows per input and 25000 in total.
|
|
3752
|
-
`,
|
|
3727
|
+
`,Vk=Object.freeze(Object.defineProperty({__proto__:null,default:Hk},Symbol.toStringTag,{value:"Module"})),Jk=`# 方案(scenarioBar)
|
|
3753
3728
|
|
|
3754
3729
|
选择页面显示现状还是某个方案,新建、复制、保存、采用、作废方案,查看并调整方案里的改动,并排对比各方案与现状的指标。用来做“如果这样改,结果会怎样,要不要真的采用”的决策。
|
|
3755
3730
|
|
|
@@ -3867,7 +3842,7 @@ Independent of industry, the component does these itself:
|
|
|
3867
3842
|
- 每个数据源最多 10 个推演操作,每个操作最多 5 个参数、5 个效果;方案参数最多 10 个,每个文本参数最多 10 个可选值。
|
|
3868
3843
|
- 方案名称不超过 40 字。
|
|
3869
3844
|
- 模型结果每次最多读 5000 行、合计 25000 行。
|
|
3870
|
-
`,
|
|
3845
|
+
`,Zk=Object.freeze(Object.defineProperty({__proto__:null,default:Jk},Symbol.toStringTag,{value:"Module"})),Xk=`# Schedule Gantt (scheduleGantt)
|
|
3871
3846
|
|
|
3872
3847
|
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.
|
|
3873
3848
|
|
|
@@ -4043,7 +4018,7 @@ Tasks that meet "Done when" take no part in these checks. Hard constraints block
|
|
|
4043
4018
|
- 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.
|
|
4044
4019
|
- Predecessor relations are one hop only.
|
|
4045
4020
|
- 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.
|
|
4046
|
-
`,
|
|
4021
|
+
`,Qk=Object.freeze(Object.defineProperty({__proto__:null,default:Xk},Symbol.toStringTag,{value:"Module"})),ev=`# 调度甘特(scheduleGantt)
|
|
4047
4022
|
|
|
4048
4023
|
资源排成行、时间横向展开,在一个方案里拖动任务改资源与时间,由内置约束和知识网络上的规则判断方案能否采用。用来做排产、检修、派工这类“把任务排到资源上”的决策。
|
|
4049
4024
|
|
|
@@ -4219,7 +4194,7 @@ Tasks that meet "Done when" take no part in these checks. Hard constraints block
|
|
|
4219
4194
|
- 规则工具每次最多收 200 个任务;一次调用最长等 30 秒,失败后自动重试一次,合计不超过 90 秒。
|
|
4220
4195
|
- 前序关系只支持一跳关系。
|
|
4221
4196
|
- 规则工具在浏览器中按需调用,结果不保存;同一方案在另一页面打开时会重新判断。
|
|
4222
|
-
`,
|
|
4197
|
+
`,tv=Object.freeze(Object.defineProperty({__proto__:null,default:ev},Symbol.toStringTag,{value:"Module"})),nv=`# Search box (searchBox)
|
|
4223
4198
|
|
|
4224
4199
|
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.
|
|
4225
4200
|
|
|
@@ -4282,7 +4257,7 @@ None. The component only does text containment; it calls no tool and does no syn
|
|
|
4282
4257
|
|
|
4283
4258
|
- Text containment only; no multiple words, pinyin or fuzzy matching.
|
|
4284
4259
|
- 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).
|
|
4285
|
-
`,
|
|
4260
|
+
`,ov=Object.freeze(Object.defineProperty({__proto__:null,default:nv},Symbol.toStringTag,{value:"Module"})),sv=`# 搜索框(searchBox)
|
|
4286
4261
|
|
|
4287
4262
|
输入关键词,页面上跟随它的组件只显示在文本列里包含这个词的对象。用来按名称、编号快速找到对象。
|
|
4288
4263
|
|
|
@@ -4345,7 +4320,7 @@ None. The component only does text containment; it calls no tool and does no syn
|
|
|
4345
4320
|
|
|
4346
4321
|
- 只做文字包含匹配,不支持多个词、拼音或模糊匹配。
|
|
4347
4322
|
- 只在已读入的数据里查找;对象类数据源最多读 5000 行,Cypher 数据源最多 10000 行(查询没写 LIMIT 时 1000 行)。
|
|
4348
|
-
`,
|
|
4323
|
+
`,rv=Object.freeze(Object.defineProperty({__proto__:null,default:sv},Symbol.toStringTag,{value:"Module"})),av=`# Segmented filter (segmentedFilter)
|
|
4349
4324
|
|
|
4350
4325
|
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.
|
|
4351
4326
|
|
|
@@ -4421,7 +4396,7 @@ None. The segments come from the configured values. Industry judgments (such as
|
|
|
4421
4396
|
- 2 to 6 options.
|
|
4422
4397
|
- One button selected at a time.
|
|
4423
4398
|
- 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).
|
|
4424
|
-
`,
|
|
4399
|
+
`,iv=Object.freeze(Object.defineProperty({__proto__:null,default:av},Symbol.toStringTag,{value:"Module"})),lv=`# 分段筛选(segmentedFilter)
|
|
4425
4400
|
|
|
4426
4401
|
一排带数量的按钮,按一个字段的取值分段,点一下页面只看这一类。用来在“全部 / 进行中 / 已超期”这类少数几类之间快速切换。
|
|
4427
4402
|
|
|
@@ -4497,7 +4472,7 @@ None. The segments come from the configured values. Industry judgments (such as
|
|
|
4497
4472
|
- 选项 2 到 6 个。
|
|
4498
4473
|
- 一次只选一个按钮。
|
|
4499
4474
|
- 数量按已读入的数据统计;对象类数据源最多读 5000 行,Cypher 数据源最多 10000 行(查询没写 LIMIT 时 1000 行)。
|
|
4500
|
-
`,
|
|
4475
|
+
`,cv=Object.freeze(Object.defineProperty({__proto__:null,default:lv},Symbol.toStringTag,{value:"Module"})),dv=`# Stage chain (stageChain)
|
|
4501
4476
|
|
|
4502
4477
|
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.
|
|
4503
4478
|
|
|
@@ -4567,7 +4542,7 @@ None. Which objects count at a stage is decided by the relation path; to limit b
|
|
|
4567
4542
|
- 1 to 9 stages; up to 20 records when expanded.
|
|
4568
4543
|
- One data source; it counts reachable objects only and shows no conversion rate between stages.
|
|
4569
4544
|
- A stage without a relation path does not follow filters.
|
|
4570
|
-
`,
|
|
4545
|
+
`,uv=Object.freeze(Object.defineProperty({__proto__:null,default:dv},Symbol.toStringTag,{value:"Module"})),hv=`# 环节链路(stageChain)
|
|
4571
4546
|
|
|
4572
4547
|
把几类对象按业务顺序排成一排,每个环节显示关联的对象数量,点开可看具体记录。用来看一批对象流转到各环节的数量,判断哪个环节堆积或断档。
|
|
4573
4548
|
|
|
@@ -4637,7 +4612,7 @@ None. Which objects count at a stage is decided by the relation path; to limit b
|
|
|
4637
4612
|
- 环节 1 到 9 个;展开最多 20 条。
|
|
4638
4613
|
- 一个数据源,只数关系可达的对象,不显示环节之间的转化率。
|
|
4639
4614
|
- 没配关系路径的环节不跟随筛选。
|
|
4640
|
-
`,
|
|
4615
|
+
`,pv=Object.freeze(Object.defineProperty({__proto__:null,default:hv},Symbol.toStringTag,{value:"Module"})),fv=`# Related graph (subgraph)
|
|
4641
4616
|
|
|
4642
4617
|
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.
|
|
4643
4618
|
|
|
@@ -4704,7 +4679,7 @@ None.
|
|
|
4704
4679
|
- 1 to 6 paths; 1 to 50 nodes per path; height 240 to 640.
|
|
4705
4680
|
- One center object at a time.
|
|
4706
4681
|
- Only objects reachable along the paths are shown, not other links between them.
|
|
4707
|
-
`,
|
|
4682
|
+
`,mv=Object.freeze(Object.defineProperty({__proto__:null,default:fv},Symbol.toStringTag,{value:"Module"})),gv=`# 关系子图(subgraph)
|
|
4708
4683
|
|
|
4709
4684
|
以页面上选中的对象为中心,沿配置的关系路径展开它关联的对象,画成一张关系图。用来看一个对象和哪些对象相连,判断影响范围或追溯来源。
|
|
4710
4685
|
|
|
@@ -4771,7 +4746,7 @@ None.
|
|
|
4771
4746
|
- 展开路径 1 到 6 条;每条最多节点 1 到 50;高度 240 到 640。
|
|
4772
4747
|
- 一次只显示一个中心对象。
|
|
4773
4748
|
- 只显示关系路径可达的对象,不显示路径之外的连线。
|
|
4774
|
-
`,
|
|
4749
|
+
`,yv=Object.freeze(Object.defineProperty({__proto__:null,default:gv},Symbol.toStringTag,{value:"Module"})),bv=`# Task inbox (taskInbox)
|
|
4775
4750
|
|
|
4776
4751
|
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.
|
|
4777
4752
|
|
|
@@ -4885,7 +4860,7 @@ The same as in the event list (\`eventList\`): when the event type has an analys
|
|
|
4885
4860
|
- Each event type has at most 12 handling choices, each at most 40 characters.
|
|
4886
4861
|
- A handling cannot be reverted once its action has run or been accepted on any object.
|
|
4887
4862
|
- Without event types the component asks you to choose some on the "Events" tab.
|
|
4888
|
-
`,
|
|
4863
|
+
`,wv=Object.freeze(Object.defineProperty({__proto__:null,default:bv},Symbol.toStringTag,{value:"Module"})),kv=`# 任务收件箱(taskInbox)
|
|
4889
4864
|
|
|
4890
4865
|
列出由事件归并成的任务,打开一个任务查看事件、分析与处理,选处理方案并记录决定,必要时直接执行方案绑定的行动。用来做“这批事件怎么处理、谁处理、有没有逾期”的决策。
|
|
4891
4866
|
|
|
@@ -4999,7 +4974,155 @@ The same as in the event list (\`eventList\`): when the event type has an analys
|
|
|
4999
4974
|
- 每个事件类型最多 12 个处理方案,每个方案名不超过 40 字。
|
|
5000
4975
|
- 处理的行动已有对象成功执行或受理后,不能回退。
|
|
5001
4976
|
- 没有事件类型时,组件提示先到“事件”页签选择。
|
|
5002
|
-
`,
|
|
4977
|
+
`,vv=Object.freeze(Object.defineProperty({__proto__:null,default:kv},Symbol.toStringTag,{value:"Module"})),$v=`# Text (text)
|
|
4978
|
+
|
|
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.
|
|
4980
|
+
|
|
4981
|
+
## When to use it and when not
|
|
4982
|
+
|
|
4983
|
+
- Use it to say in one sentence at the top of a page how things stand and what to do first; to head a group of components; to write a note on how to work.
|
|
4984
|
+
- Do not use it:
|
|
4985
|
+
- For a row of numbers to click and filter by: use the metric cards (\`metricCards\`).
|
|
4986
|
+
- To list objects one by one: use the object table (\`objectTable\`) or the object list (\`objectList\`).
|
|
4987
|
+
- To let users ask questions: use the Agent chat (\`agentChat\`).
|
|
4988
|
+
|
|
4989
|
+
## Ontology contract
|
|
4990
|
+
|
|
4991
|
+
| Role | Object type requirement | Required properties | Relations | Required |
|
|
4992
|
+
| --- | --- | --- | --- | --- |
|
|
4993
|
+
| Number named | The object type of each number's own data source | A number property for a sum, average, least or greatest | None | No |
|
|
4994
|
+
|
|
4995
|
+
With text alone and no numbers, the component reads no data.
|
|
4996
|
+
|
|
4997
|
+
## Built-in checks
|
|
4998
|
+
|
|
4999
|
+
- The content is Markdown: headings, bold, lists and links.
|
|
5000
|
+
- \`{name}\` becomes the number of that name and \`{$asOf}\` the base date; a number not read yet, or not there, reads "—".
|
|
5001
|
+
- 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
|
+
- 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.
|
|
5003
|
+
- Each number follows its own filters, apart from the other numbers of the component.
|
|
5004
|
+
|
|
5005
|
+
## Extension points
|
|
5006
|
+
|
|
5007
|
+
None. The component counts objects of its sources or reads object metrics; it calls no tool.
|
|
5008
|
+
|
|
5009
|
+
## Interaction and links
|
|
5010
|
+
|
|
5011
|
+
- **Writes**: no filter.
|
|
5012
|
+
- **Reads**: each number follows the filters it picks, and is counted on the base date.
|
|
5013
|
+
- **What changes with it**: the component itself; when the filters or the base date change, so do the numbers in the text.
|
|
5014
|
+
|
|
5015
|
+
## Recipes
|
|
5016
|
+
|
|
5017
|
+
### The conclusion on an inventory home page
|
|
5018
|
+
|
|
5019
|
+
| Role | Mapped to |
|
|
5020
|
+
| --- | --- |
|
|
5021
|
+
| Number named | Purchase orders (overdue, not received), sales orders (overdue, short shipped) |
|
|
5022
|
+
|
|
5023
|
+
**The network needs:** purchase orders and sales orders, each with a progress that has planned dates.
|
|
5024
|
+
|
|
5025
|
+
\`\`\`yaml
|
|
5026
|
+
- id: lead
|
|
5027
|
+
type: text
|
|
5028
|
+
config:
|
|
5029
|
+
content: "As of {$asOf}, **{poLate}** purchase orders are overdue and **{soLate}** sales orders are short. Chase the purchases first, then plan the sales refill."
|
|
5030
|
+
values:
|
|
5031
|
+
- { name: poLate, source: purchaseOrders, aggregate: count, when: [{ field: $status, op: eq, value: overdue }] }
|
|
5032
|
+
- { name: soLate, source: salesOrders, aggregate: count, when: [{ field: $status, op: eq, value: overdue }] }
|
|
5033
|
+
\`\`\`
|
|
5034
|
+
|
|
5035
|
+
**Check:** pick another base date and both numbers change; with an empty source they read "—".
|
|
5036
|
+
|
|
5037
|
+
## Guidance for AI
|
|
5038
|
+
|
|
5039
|
+
1. Start each page with a text that says in one sentence how things stand and what to do first. Name the key numbers in \`values\` rather than writing them into the text.
|
|
5040
|
+
2. A name starts with a letter and holds only letters, digits and underscores; the text writes \`{name}\`.
|
|
5041
|
+
3. Write business words: no field names, ids or modelling words such as object type or relation.
|
|
5042
|
+
4. Common mistakes:
|
|
5043
|
+
- A \`{name}\` in the text with no entry in \`values\`: it reads "—".
|
|
5044
|
+
- Numbers to click and filter by written into text: they cannot be clicked. Use metric cards.
|
|
5045
|
+
- A long passage: keep one or two sentences on the first screen, and the details in the components below or on another page.
|
|
5046
|
+
|
|
5047
|
+
## Limits
|
|
5048
|
+
|
|
5049
|
+
- 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 alignment.
|
|
5051
|
+
`,Sv=Object.freeze(Object.defineProperty({__proto__:null,default:$v},Symbol.toStringTag,{value:"Module"})),jv=`# 文字(text)
|
|
5052
|
+
|
|
5053
|
+
一段文字,用来写页面开头的结论、分节标题和说明段落。正文里可以引用数字,数字跟着页面的筛选和基准日期变。
|
|
5054
|
+
|
|
5055
|
+
## 适用与不适用
|
|
5056
|
+
|
|
5057
|
+
- 适用:页面开头用一句话说清现在怎么样、先干什么;给一组组件写分节标题;写一段操作说明。
|
|
5058
|
+
- 不适用:
|
|
5059
|
+
- 一排要点击筛选的数字:用指标卡组(\`metricCards\`)。
|
|
5060
|
+
- 逐条列出对象:用对象表(\`objectTable\`)或对象列表(\`objectList\`)。
|
|
5061
|
+
- 让用户提问:用 Agent 对话(\`agentChat\`)。
|
|
5062
|
+
|
|
5063
|
+
## 本体契约
|
|
5064
|
+
|
|
5065
|
+
| 角色 | 对象类要求 | 必要的属性 | 关系 | 必填 |
|
|
5066
|
+
| --- | --- | --- | --- | --- |
|
|
5067
|
+
| 被引用的数字 | 每个数字各自的数据源对应的对象类 | 求和、平均、最大、最小时要一个数字属性 | 无 | 否 |
|
|
5068
|
+
|
|
5069
|
+
只有文字、不引用数字时,组件不读任何数据。
|
|
5070
|
+
|
|
5071
|
+
## 组件内置的判断
|
|
5072
|
+
|
|
5073
|
+
- 内容是 Markdown:标题、加粗、列表、链接。
|
|
5074
|
+
- \`{引用名}\` 换成对应的数字,\`{$asOf}\` 换成基准日期;数字还没读到或读不到时显示「—」。
|
|
5075
|
+
- 数字的统计写法和指标卡的一项相同:计数、求和、平均、最大最小、去重计数、占比,可只算满足条件的对象,也可以取知识网络的对象指标。
|
|
5076
|
+
- 数字没设小数位时,整数不带小数,其他最多两位;占比显示为百分比、一位小数。
|
|
5077
|
+
- 每个数字按它自己的「跟随的筛选」过滤,和组件上的其他数字互不影响。
|
|
5078
|
+
|
|
5079
|
+
## 扩展点
|
|
5080
|
+
|
|
5081
|
+
无。组件只统计数据源里的对象或读对象指标,不调用工具。
|
|
5082
|
+
|
|
5083
|
+
## 交互与联动
|
|
5084
|
+
|
|
5085
|
+
- **写入**:不写入任何筛选。
|
|
5086
|
+
- **读取**:每个数字跟随自己勾选的筛选,并按基准日期统计。
|
|
5087
|
+
- **谁会跟着变**:组件自己;筛选或基准日期变了,正文里的数字跟着变。
|
|
5088
|
+
|
|
5089
|
+
## 场景配方
|
|
5090
|
+
|
|
5091
|
+
### 进销存首页的结论
|
|
5092
|
+
|
|
5093
|
+
| 角色 | 对应 |
|
|
5094
|
+
| --- | --- |
|
|
5095
|
+
| 被引用的数字 | 采购单(逾期未入库的张数)、销售单(逾期欠货的张数) |
|
|
5096
|
+
|
|
5097
|
+
**知识网络中要有:** 采购单、销售单,各有带计划日期的进度。
|
|
5098
|
+
|
|
5099
|
+
\`\`\`yaml
|
|
5100
|
+
- id: lead
|
|
5101
|
+
type: text
|
|
5102
|
+
config:
|
|
5103
|
+
content: "截至 {$asOf},**{poLate}** 张采购单逾期未入库,**{soLate}** 张销售单逾期欠货——先催采购,再排销售补货。"
|
|
5104
|
+
values:
|
|
5105
|
+
- { name: poLate, source: purchaseOrders, aggregate: count, when: [{ field: $status, op: eq, value: overdue }] }
|
|
5106
|
+
- { name: soLate, source: salesOrders, aggregate: count, when: [{ field: $status, op: eq, value: overdue }] }
|
|
5107
|
+
\`\`\`
|
|
5108
|
+
|
|
5109
|
+
**检查项:** 换一个基准日期,两个数字跟着变;清空数据源后显示「—」。
|
|
5110
|
+
|
|
5111
|
+
## 给 AI 的指引
|
|
5112
|
+
|
|
5113
|
+
1. 每个页面开头放一个文字组件,一句话说清现在怎么样、先干什么,关键数字用 \`values\` 引用,不要写死在正文里。
|
|
5114
|
+
2. 引用名字母开头,只含字母、数字和下划线;正文里写 \`{引用名}\`。
|
|
5115
|
+
3. 正文用业务话,不出现字段名、id 和「对象类、关系」这类建模用语。
|
|
5116
|
+
4. 常见错误:
|
|
5117
|
+
- 正文里的 \`{引用名}\` 在 \`values\` 里没有:显示「—」。
|
|
5118
|
+
- 把要点击筛选的数字写进文字:点不了,改用指标卡组。
|
|
5119
|
+
- 一段写得太长:首屏只留一两句,细节放到下面的组件或下一页。
|
|
5120
|
+
|
|
5121
|
+
## 限制
|
|
5122
|
+
|
|
5123
|
+
- 只统计已读入的数据;对象类数据源最多读 5000 行,Cypher 数据源最多 10000 行(查询没写 LIMIT 时 1000 行)。对象指标由平台按全部对象计算,不受这个限制。
|
|
5124
|
+
- 只支持 Markdown 本身的排版,不支持字体颜色、对齐这类设置。
|
|
5125
|
+
`,Av=Object.freeze(Object.defineProperty({__proto__:null,default:jv},Symbol.toStringTag,{value:"Module"})),Tv=`# Chart (trendChart)
|
|
5003
5126
|
|
|
5004
5127
|
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".
|
|
5005
5128
|
|
|
@@ -5130,7 +5253,7 @@ What counts as a "defect" or as "finished" is decided by the data source and the
|
|
|
5130
5253
|
- At most 6 parts in a split (a status column uses its own values).
|
|
5131
5254
|
- 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.
|
|
5132
5255
|
- Actions on click: up to 8 items with up to 5 steps each.
|
|
5133
|
-
`,
|
|
5256
|
+
`,Ov=Object.freeze(Object.defineProperty({__proto__:null,default:Tv},Symbol.toStringTag,{value:"Module"})),Ev=`# 图表(trendChart)
|
|
5134
5257
|
|
|
5135
5258
|
柱状图、折线图或饼图:按时间看数量或金额的变化,或按类别比较大小;点一个周期或类别,整页只看它。用来回答“最近几个月走势如何”“哪几类最多”。
|
|
5136
5259
|
|
|
@@ -5261,4 +5384,4 @@ What counts as a "defect" or as "finished" is decided by the data source and the
|
|
|
5261
5384
|
- 拆分最多 6 部分(判断状态列按其自身取值)。
|
|
5262
5385
|
- 页面内统计时,对象类数据源最多读入 5000 个对象,Cypher 数据源最多 10000 行(查询没写 LIMIT 时 1000 行),超过时上方提示,统计只覆盖已读取部分。
|
|
5263
5386
|
- 点击后的动作最多 8 项,每项最多 5 个动作。
|
|
5264
|
-
`,
|
|
5387
|
+
`,Cv=Object.freeze(Object.defineProperty({__proto__:null,default:Ev},Symbol.toStringTag,{value:"Module"}));export{Pw as liveWorkshop,Yv as run};
|