@openbkn/workshop 0.2.2-rc.5 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/README.md +83 -13
  2. package/component.d.ts +10 -0
  3. package/dist/ActionConfirm-DJ91X3ml.js +236 -0
  4. package/dist/ActionFailure-ZgPt_3B-.js +37 -0
  5. package/dist/AgentChat-CRYai8ge.js +1062 -0
  6. package/dist/AppFormModal-D73ucaHK.js +4282 -0
  7. package/dist/AppListPage-D87piiOw.js +1364 -0
  8. package/dist/AskDrawer-BUMYsRnt.js +38 -0
  9. package/dist/ComputedView-CgYrDbx1.js +3221 -0
  10. package/dist/ConclusionApply-sjGfoEBY.js +153 -0
  11. package/dist/CypherEditor-lus6FA5L.js +485 -0
  12. package/dist/LandingList-6JI6864C.js +230 -0
  13. package/dist/MenuUnfoldOutlined-Cdg24l2h.js +27 -0
  14. package/dist/ModelTrial-ClHFGTpQ.js +359 -0
  15. package/dist/PageRenderer-DBd_g6mN.js +85480 -0
  16. package/dist/README-DjRyTQSR.js +76 -0
  17. package/dist/ScenarioApply-DtW_hh47.js +590 -0
  18. package/dist/SimulateForm-C-i08Jjd.js +153 -0
  19. package/dist/Subgraph-CnrkH9AN.js +32586 -0
  20. package/dist/WorkshopLabPage-DiVXQL9e.js +11364 -0
  21. package/dist/WorkshopRunPage-6hjRUf64.js +253 -0
  22. package/dist/abnfDiagram-WEYOIA3C-beRNhN3c.js +87 -0
  23. package/dist/action-type-tool.service-B2B74fKC.js +1060 -0
  24. package/dist/actionButton-DA5CNEzx.js +94 -0
  25. package/dist/actionButton.en-US-qjeqA7hs.js +94 -0
  26. package/dist/agentChat-EoDznd58.js +116 -0
  27. package/dist/agentChat.en-US-B6-pFd9Y.js +116 -0
  28. package/dist/alertList-DqditwM8.js +84 -0
  29. package/dist/alertList.en-US-BAXAgltP.js +84 -0
  30. package/dist/architectureDiagram-ZHVYKT53-DY2l1qxx.js +4779 -0
  31. package/dist/asOfSlider-QPvHWUMV.js +83 -0
  32. package/dist/asOfSlider.en-US-BI4jVfSn.js +83 -0
  33. package/dist/bkn-agent-execution.service-DVh-SHyl.js +205 -0
  34. package/dist/blockDiagram-RJAE7QA3-DR0mjN2h.js +1435 -0
  35. package/dist/c4Diagram-XDPPPE54-DH5zsGug.js +1518 -0
  36. package/dist/channel-B034hcOF.js +5 -0
  37. package/dist/china-C6m7zXIv.js +9 -0
  38. package/dist/chunk-2E7WHVMD-Ba3svxgx.js +664 -0
  39. package/dist/chunk-2Q5K7J3B-rT4eU6_y.js +15 -0
  40. package/dist/chunk-4EMNKR2T-C1kQZYHK.js +262 -0
  41. package/dist/chunk-55XCU76K-dcpLOktb.js +68 -0
  42. package/dist/chunk-5VM5RSS4-BdpQuzmO.js +19 -0
  43. package/dist/chunk-JWPE2WC7-CDBrSjU7.js +8 -0
  44. package/dist/chunk-VQ5W62QI-BiVKc40w.js +19 -0
  45. package/dist/chunk-XXDRQBXY-CPYrcdVW.js +8 -0
  46. package/dist/chunk-ZCHMQSOR-BG8OLpvb.js +451 -0
  47. package/dist/classDiagram-v2-4MYWR3UA-DqbpQpwI.js +1564 -0
  48. package/dist/component.d-DFoMKuUv.js +179 -0
  49. package/dist/cose-bilkent-JH36ORCC-CdXk4sPf.js +2609 -0
  50. package/dist/customComponents-DasaZ6pq.js +4 -0
  51. package/dist/customComponents.en-US-CkabuCXg.js +79 -0
  52. package/dist/customParseFormat-C0uLEpdq.js +182 -0
  53. package/dist/cynefin-EF2NZ3EQ-D7MVnMHu.js +21746 -0
  54. package/dist/cynefinDiagram-WF24UDRP-BYT_KpDL.js +299 -0
  55. package/dist/cytoscape.esm-BCV9V6aO.js +18760 -0
  56. package/dist/d3-scale-DA8IHmf0.js +1841 -0
  57. package/dist/dagre-NK4GIZVX-l-ghPdM8.js +2154 -0
  58. package/dist/dateRange-BbkLMg8L.js +79 -0
  59. package/dist/dateRange.en-US-CV12Q02G.js +79 -0
  60. package/dist/dayjs.min-DZ-YV8Mv.js +284 -0
  61. package/dist/diagram-CBK3MWTC-Bt3HiwvA.js +542 -0
  62. package/dist/diagram-I5XIIV2D-DcbqfBjx.js +150 -0
  63. package/dist/diagram-ODIL2UCW-9PC1n3n5.js +346 -0
  64. package/dist/diagram-PFBEJUXE-DGhr2kc7.js +478 -0
  65. package/dist/diagram-RJA3I4VV-DwzpOjZ_.js +219 -0
  66. package/dist/diagram-TYUNFSNR-B3Bd3TDU.js +2583 -0
  67. package/dist/dropdownFilter-DOi_8-ZT.js +76 -0
  68. package/dist/dropdownFilter.en-US-BiXpvXtF.js +76 -0
  69. package/dist/ebnfDiagram-V4P3TTPT-E5NN2oKc.js +109 -0
  70. package/dist/elk-QONTBCTQ-dFjcujl_.js +49170 -0
  71. package/dist/erDiagram-KYQIGQAA-BMrasBzB.js +1061 -0
  72. package/dist/eventList-CnsAwfDS.js +115 -0
  73. package/dist/eventList.en-US-Cof3rCLq.js +115 -0
  74. package/dist/eventReport-XS-HegnH.js +76 -0
  75. package/dist/eventReport.en-US-DTx4vzWT.js +76 -0
  76. package/dist/flowDiagram-IUGLLWBU-BGIBH0q0.js +1769 -0
  77. package/dist/ganttChart-DEeSvTJA.js +77 -0
  78. package/dist/ganttChart.en-US-SwRKrnoD.js +77 -0
  79. package/dist/ganttDiagram-R7GPNTJY-C0tb1Lpp.js +1741 -0
  80. package/dist/generateCypher-Ch9_lQa6.js +399 -0
  81. package/dist/gitGraphDiagram-PDYL7XHY-DBqcOa-c.js +815 -0
  82. package/dist/graph-CKJmgLki.js +1541 -0
  83. package/dist/index-BA-GzCXt.js +441 -0
  84. package/dist/infoDiagram-MVDRKAX5-Bwuki4JA.js +24 -0
  85. package/dist/ishikawaDiagram-HPEHV2GE-Dz4d6ygx.js +622 -0
  86. package/dist/journeyDiagram-BOSHW7O7-C99m34Bb.js +834 -0
  87. package/dist/kanban-definition-FNSA4HC5-mdqjODsT.js +724 -0
  88. package/dist/katex-BsrBVQKd.js +11314 -0
  89. package/dist/manifest-BjV1PJ6u.js +41 -0
  90. package/dist/mermaid.core-yQghUlIz.js +17642 -0
  91. package/dist/metricCards-CSb-_cT2.js +104 -0
  92. package/dist/metricCards.en-US-BLLhRsQU.js +104 -0
  93. package/dist/mindmap-definition-6OY57UG3-BZhO2wX4.js +834 -0
  94. package/dist/modelTrial-Bvb-RhGt.js +137 -0
  95. package/dist/modelTrial.en-US-DYcuor-G.js +137 -0
  96. package/dist/models-DekiCOuZ.js +6 -0
  97. package/dist/object-metric-numeric-vs3BeDkH.js +42 -0
  98. package/dist/object-metric.service-flZgBMRX.js +233 -0
  99. package/dist/objectDetail-SQUbp4Py.js +117 -0
  100. package/dist/objectDetail.en-US-DW3mlONM.js +117 -0
  101. package/dist/objectList-D99wPtJH.js +97 -0
  102. package/dist/objectList.en-US-PBBNyVLW.js +97 -0
  103. package/dist/objectTable-0jsFFMN3.js +127 -0
  104. package/dist/objectTable.en-US-yWEs8qc_.js +127 -0
  105. package/dist/pegDiagram-ECIUJNBX-BDa5RfZt.js +95 -0
  106. package/dist/pieDiagram-GNMPY74T-DNVtzXPv.js +165 -0
  107. package/dist/pivotTable-CHmQw18-.js +102 -0
  108. package/dist/pivotTable.en-US-B4uv4P08.js +102 -0
  109. package/dist/prompt-DYrjlEFr.js +373 -0
  110. package/dist/quadrantDiagram-D57K4MC3-vK0f2OvQ.js +1023 -0
  111. package/dist/railroadDiagram-Y72NRBL7-j6ZrTmRp.js +77 -0
  112. package/dist/regionMap-Cme-JyV_.js +128 -0
  113. package/dist/regionMap.en-US-Bwr2_p32.js +128 -0
  114. package/dist/requirementDiagram-EQYSW5RA-DgfEyljA.js +886 -0
  115. package/dist/sankeyDiagram-SY24JHO5-CImx-IX0.js +1160 -0
  116. package/dist/scenarioBar-BV43p7n-.js +122 -0
  117. package/dist/scenarioBar.en-US-5KqMQ2Bg.js +122 -0
  118. package/dist/scheduleGantt-CTYO-zYP.js +180 -0
  119. package/dist/scheduleGantt.en-US-hE7mvVUW.js +180 -0
  120. package/dist/searchBox-Ca7w0f_6.js +67 -0
  121. package/dist/searchBox.en-US-ArS_XBvB.js +67 -0
  122. package/dist/segmentedFilter-MhjVcWo0.js +80 -0
  123. package/dist/segmentedFilter.en-US-BxNrQO5T.js +80 -0
  124. package/dist/sequenceDiagram-BLEHNHQU-nWmjd1ci.js +2969 -0
  125. package/dist/sizeCapture-INFHLROL-D3jlbt7h.js +46 -0
  126. package/dist/stageChain-BxBafwjD.js +74 -0
  127. package/dist/stageChain.en-US-CP0G27n8.js +74 -0
  128. package/dist/stateDiagram-v2-A6IESKWZ-DG1ZetEu.js +1514 -0
  129. package/dist/subgraph-7n4SwliR.js +71 -0
  130. package/dist/subgraph.en-US-BNvY18IW.js +71 -0
  131. package/dist/swimlanes-B3ENRKFQ-cCmJE8AU.js +4991 -0
  132. package/dist/swimlanesDiagram-AYQRV4AK-CtuhyguU.js +14 -0
  133. package/dist/taskInbox-DGWYeI2b.js +118 -0
  134. package/dist/taskInbox.en-US-B-OzDmVl.js +118 -0
  135. package/dist/text-BqSVQKS6.js +78 -0
  136. package/dist/text.en-US-BhAxy_LE.js +78 -0
  137. package/dist/timeline-definition-JXYKGLGB-Cc-INsOv.js +1057 -0
  138. package/dist/trendChart-BjEeRS5_.js +135 -0
  139. package/dist/trendChart.en-US-BBGqWUKM.js +135 -0
  140. package/dist/useLabData-Df-jEHKs.js +20470 -0
  141. package/dist/usecaseDiagram-WPOLBNNX-r8wVjopm.js +7920 -0
  142. package/dist/vennDiagram-Q3Y3IDCW-BZiOcgrj.js +1579 -0
  143. package/dist/wardleyDiagram-IVAIDKWA-16jd07C_.js +675 -0
  144. package/dist/workshop-app-DnHNjBqy.js +86038 -0
  145. package/dist/workshop-app.css +1 -0
  146. package/dist/workshop-app.js +4 -0
  147. package/dist/world-Djau1JyJ.js +9 -0
  148. package/dist/xychartDiagram-4URNHDU4-C8DwWQNh.js +1460 -0
  149. package/dist-cli/workshop.js +341 -218
  150. package/example/host.js +109 -0
  151. package/example/index.html +93 -0
  152. package/example/server.mjs +237 -0
  153. package/index.d.ts +48 -0
  154. package/lib/validate.js +47 -1
  155. package/package.json +17 -5
  156. package/runtime/frame-runtime.js +13 -1
  157. package/workshop-component.js +32 -12
  158. package/workshop.js +2 -0
@@ -0,0 +1,153 @@
1
+ import { u as z, r as d, l as J, j as a, a as x, p as K } from "./workshop-app-DnHNjBqy.js";
2
+ import { u as Q, b as W, B as Y, C as Z, M as ee, A as se, S as te, f as ae, E as ne, F as oe } from "./useLabData-Df-jEHKs.js";
3
+ import { s as u, d as ie } from "./PageRenderer-DBd_g6mN.js";
4
+ import { u as re, L as ce, a as le, r as de } from "./LandingList-6JI6864C.js";
5
+ const pe = /* @__PURE__ */ new Set(), S = () => (/* @__PURE__ */ new Date()).toISOString();
6
+ function fe({ source: l, onClose: g }) {
7
+ const { t: n } = z(), i = Q(), y = i.appId ?? "", h = i.models, E = W(i.spec, i.values), { records: M } = Y(y), [b] = d.useState(
8
+ () => new Set(
9
+ Object.entries(M).filter(([, e]) => J(e.applied)).map(([e]) => e)
10
+ )
11
+ ), B = d.useMemo(() => [l], [l]), T = [...Z(i.spec.sources, [l.id])], N = T.every((e) => h?.views[e]?.status === "fresh"), { plans: c, asks: U, asked: _, setAsked: P, finding: O } = re({
12
+ sources: B,
13
+ views: h?.views,
14
+ records: M,
15
+ upToDate: N,
16
+ moved: pe,
17
+ asOf: E,
18
+ again: b
19
+ }), [p, A] = d.useState(!1), [f, H] = d.useState(!1), k = d.useRef(!0);
20
+ d.useEffect(() => (k.current = !0, () => {
21
+ k.current = !1;
22
+ }), []);
23
+ const C = (e) => !b.has(e.item.id) && !e.blocked, [m, I] = d.useState(
24
+ () => new Set(c.filter(C).map((e) => e.item.id))
25
+ ), [G, X] = d.useState(!O);
26
+ !G && !O && (X(!0), !p && !f && I(
27
+ (e) => /* @__PURE__ */ new Set([
28
+ ...e,
29
+ ...c.filter((t) => t.item.landing.action?.target === "object" && C(t)).map((t) => t.item.id)
30
+ ])
31
+ ));
32
+ const $ = (e, t) => I((r) => {
33
+ const s = new Set(r);
34
+ return t ? s.add(e) : s.delete(e), s;
35
+ }), D = (e, t, r) => oe(y, (s) => ({
36
+ records: {
37
+ ...s.records,
38
+ ...Object.fromEntries(
39
+ [...e].map(([o, w]) => [o, { ...s.records[o], ...w, run: t }])
40
+ )
41
+ },
42
+ runs: r ? [...s.runs, r] : s.runs
43
+ })), q = async () => {
44
+ A(!0);
45
+ const e = {
46
+ id: `run_${Date.now().toString(36)}`,
47
+ at: S(),
48
+ asOf: E,
49
+ params: K(i.spec.scenarioParams, void 0),
50
+ results: Object.fromEntries(
51
+ T.flatMap((s) => {
52
+ const o = h?.views[s]?.result;
53
+ return o?.status === "done" ? [[s, o]] : [];
54
+ })
55
+ )
56
+ }, t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
57
+ for (const s of c) {
58
+ if (!m.has(s.item.id)) continue;
59
+ const o = await de(i.kn.id, s, S());
60
+ t.set(s.item.id, o), o.applied?.executionId && r.set(o.applied.executionId, s.item.id);
61
+ }
62
+ D(t, e.id, e), window.dispatchEvent(
63
+ new CustomEvent(te, {
64
+ detail: {
65
+ source: l.id,
66
+ results: [...t.values()].flatMap((s) => s.applied ? [s.applied] : [])
67
+ }
68
+ })
69
+ ), await ae(
70
+ i.kn.id,
71
+ [...r.keys()],
72
+ (s, o) => {
73
+ const w = r.get(s), F = t.get(w), V = {
74
+ ...F,
75
+ applied: { ...F.applied, ...o, at: S() }
76
+ };
77
+ t.set(w, V), D(/* @__PURE__ */ new Map([[w, V]]), e.id), window.dispatchEvent(new CustomEvent(ne, { detail: { executionId: s, ...o } }));
78
+ },
79
+ () => k.current
80
+ ), k.current && (A(!1), H(!0));
81
+ }, L = c.filter((e) => m.has(e.item.id)).length, R = c.filter((e) => m.has(e.item.id) && e.item.action).length, j = [
82
+ ...new Set(c.filter((e) => m.has(e.item.id)).flatMap((e) => e.waiting))
83
+ ], v = h?.views[l.id]?.result;
84
+ return /* @__PURE__ */ a.jsx(
85
+ ee,
86
+ {
87
+ open: !0,
88
+ width: 760,
89
+ title: n("workshopLab.modelSource.actTitle", { source: l.label }),
90
+ onCancel: p ? void 0 : g,
91
+ closable: !p,
92
+ maskClosable: !1,
93
+ footer: f ? /* @__PURE__ */ a.jsx(x, { type: "primary", onClick: g, children: n("workshopLab.act.close") }) : /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
94
+ /* @__PURE__ */ a.jsx(x, { disabled: p, onClick: g, children: n("workshopLab.act.cancel") }),
95
+ /* @__PURE__ */ a.jsx(
96
+ x,
97
+ {
98
+ type: "primary",
99
+ disabled: L === 0 || j.length > 0,
100
+ title: j.length > 0 ? n("workshopLab.scenario.apply.fillAsked", { names: j.join("、") }) : void 0,
101
+ loading: p,
102
+ onClick: () => {
103
+ q();
104
+ },
105
+ children: R > 0 ? n("workshopLab.scenario.apply.run", { count: L }) : n("workshopLab.scenario.apply.record", { count: L })
106
+ }
107
+ )
108
+ ] }),
109
+ children: /* @__PURE__ */ a.jsxs("div", { className: u.actConfirm, style: ie(i.spec.theme, i.spec.layout), children: [
110
+ /* @__PURE__ */ a.jsx("p", { className: u.actMuted, children: n("workshopLab.modelSource.actHint") }),
111
+ v && /* @__PURE__ */ a.jsx("span", { className: u.actMuted, children: n("workshopLab.modelSource.actBasis", {
112
+ at: new Date(v.at).toLocaleString(),
113
+ asOf: v.asOf
114
+ }) }),
115
+ !N && /* @__PURE__ */ a.jsx(se, { type: "warning", showIcon: !0, message: n("workshopLab.scenario.computeFirst") }),
116
+ /* @__PURE__ */ a.jsx("b", { children: n("workshopLab.scenario.apply.landingTitle", {
117
+ source: l.label,
118
+ count: c.length
119
+ }) }),
120
+ /* @__PURE__ */ a.jsx(
121
+ ce,
122
+ {
123
+ source: l,
124
+ asks: U,
125
+ asked: _,
126
+ onAsked: P,
127
+ disabled: p || f
128
+ }
129
+ ),
130
+ c.length === 0 ? /* @__PURE__ */ a.jsx("span", { className: u.actMuted, children: n("workshopLab.scenario.apply.noLanding") }) : /* @__PURE__ */ a.jsx("ul", { className: u.applyList, children: c.map((e) => {
131
+ const t = b.has(e.item.id) ? e.record?.applied?.at : void 0;
132
+ return /* @__PURE__ */ a.jsx(
133
+ le,
134
+ {
135
+ plan: e,
136
+ ticked: m.has(e.item.id),
137
+ disabled: p || f || !!e.blocked,
138
+ onTick: (r) => $(e.item.id, r),
139
+ note: t ? n("workshopLab.modelSource.lastRun", {
140
+ at: new Date(t).toLocaleString()
141
+ }) : void 0
142
+ },
143
+ e.item.id
144
+ );
145
+ }) }),
146
+ R > 0 && /* @__PURE__ */ a.jsx("span", { className: u.actMuted, children: n("workshopLab.act.noApproval") })
147
+ ] })
148
+ }
149
+ );
150
+ }
151
+ export {
152
+ fe as ConclusionApply
153
+ };
@@ -0,0 +1,485 @@
1
+ import { N as Ne, r as c, R as Se, u as Re, j as e, Z as k, I as v, i as ne, a as N, _ as Ee } from "./workshop-app-DnHNjBqy.js";
2
+ import { p as Ce, e as oe, g as Te } from "./generateCypher-Ch9_lQa6.js";
3
+ import { am as $e, ab as Ie, a8 as le, a9 as Me, M as Ae, an as Oe, R as _e, A as ie, ao as qe, ap as Pe, aq as ze, ar as Be } from "./useLabData-Df-jEHKs.js";
4
+ import { F as ce, X as t, a3 as Fe, a4 as De, a5 as Ke } from "./PageRenderer-DBd_g6mN.js";
5
+ import { u as Ve } from "./WorkshopLabPage-DiVXQL9e.js";
6
+ var M = {}, pe;
7
+ function He() {
8
+ if (pe) return M;
9
+ pe = 1, Object.defineProperty(M, "__esModule", { value: !0 });
10
+ var p = { icon: { tag: "svg", attrs: { viewBox: "0 0 1024 1024", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M715.8 493.5L335 165.1c-14.2-12.2-35-1.2-35 18.5v656.8c0 19.7 20.8 30.7 35 18.5l380.8-328.4c10.9-9.4 10.9-27.6 0-37z" } }] }, name: "caret-right", theme: "outlined" };
11
+ return M.default = p, M;
12
+ }
13
+ var Ge = /* @__PURE__ */ He();
14
+ const Qe = /* @__PURE__ */ Ne(Ge);
15
+ function z() {
16
+ return z = Object.assign ? Object.assign.bind() : function(p) {
17
+ for (var h = 1; h < arguments.length; h++) {
18
+ var i = arguments[h];
19
+ for (var f in i)
20
+ Object.prototype.hasOwnProperty.call(i, f) && (p[f] = i[f]);
21
+ }
22
+ return p;
23
+ }, z.apply(this, arguments);
24
+ }
25
+ const Ue = (p, h) => /* @__PURE__ */ c.createElement(Se, z({}, p, {
26
+ ref: h,
27
+ icon: Qe
28
+ })), We = /* @__PURE__ */ c.forwardRef(Ue), he = 50, Xe = 3;
29
+ function Ze(p, h) {
30
+ const i = [];
31
+ for (const f of p) {
32
+ const g = f[h];
33
+ if (g == null || g === "") continue;
34
+ const x = String(g).slice(0, 24);
35
+ if (i.includes(x) || i.push(x), i.length >= Xe) break;
36
+ }
37
+ return i.join("、") || "—";
38
+ }
39
+ function Je(p) {
40
+ const h = new Set(p.sources.map((f) => f.id));
41
+ if (!h.has("query")) return "query";
42
+ let i = 2;
43
+ for (; h.has(`query${i}`); ) i++;
44
+ return `query${i}`;
45
+ }
46
+ function ts({
47
+ spec: p,
48
+ kn: h,
49
+ source: i,
50
+ chatModel: f,
51
+ apply: g,
52
+ onClose: x
53
+ }) {
54
+ const { t: r } = Re(), me = Ve(), B = c.useMemo(() => $e(h.id), [h.id]), F = c.useRef(null), [L, de] = c.useState(i?.id ?? Je(p)), [D, ue] = c.useState(i?.label ?? ""), [d, A] = c.useState(i?.cypher?.query ?? ""), [u, O] = c.useState(i?.cypher?.columns ?? []), [S, K] = c.useState(i?.key ?? ""), [V, ye] = c.useState(i?.cypher?.params ?? {}), [y, H] = c.useState(null), [G, _] = c.useState(null), [Q, U] = c.useState(!1), [R, be] = c.useState(""), [W, X] = c.useState(!1), [Z, w] = c.useState(null), [J, fe] = c.useState([]), E = c.useRef(null), Y = c.useMemo(() => Ie(p.variables, {}), [p.variables]), C = le(d), T = c.useMemo(
55
+ () => p.variables.filter((s) => Me.includes(s.kind)),
56
+ [p.variables]
57
+ ), q = (s) => V[s] ?? (T.some((a) => a.name === s) ? s : void 0), ee = (s, a) => {
58
+ H({ ...s, ms: a }), _(null);
59
+ const l = s.columns.map(
60
+ (o) => u.find((m) => m.name === o.name) ?? {
61
+ name: o.name,
62
+ label: o.name,
63
+ type: ze(o.type)
64
+ }
65
+ );
66
+ O(l), l.some((o) => o.name === S) || K(l[0]?.name ?? "");
67
+ }, se = async (s = d) => {
68
+ U(!0);
69
+ const a = performance.now();
70
+ try {
71
+ const l = Object.fromEntries(
72
+ le(s).map((o) => [o, Y[q(o) ?? ""]])
73
+ );
74
+ ee(await B(s, Ce(s, l)), performance.now() - a);
75
+ } catch (l) {
76
+ H(null), _(oe(l));
77
+ } finally {
78
+ U(!1);
79
+ }
80
+ }, ae = c.useRef(!1);
81
+ c.useEffect(() => {
82
+ ae.current || !i?.cypher?.query || (ae.current = !0, se(i.cypher.query));
83
+ }, []);
84
+ const re = async () => {
85
+ const s = f();
86
+ if (!s) {
87
+ w(r("workshopLab.cypher.noModel"));
88
+ return;
89
+ }
90
+ const a = new AbortController();
91
+ E.current = a, X(!0), w(r("workshopLab.cypher.generating"));
92
+ const l = performance.now();
93
+ try {
94
+ const o = await Te({
95
+ model: s,
96
+ kn: h,
97
+ variables: p.variables,
98
+ values: Y,
99
+ instruction: R,
100
+ current: d,
101
+ query: B,
102
+ signal: a.signal,
103
+ onStep: (m) => w(
104
+ m.kind === "generating" ? r("workshopLab.cypher.attempt", { attempt: m.attempt }) : m.kind === "running" ? r("workshopLab.cypher.trying") : r("workshopLab.cypher.retry", { error: m.error })
105
+ )
106
+ });
107
+ o.query && A(o.query), o.ok ? (ee(o.result, performance.now() - l), w(
108
+ r("workshopLab.cypher.generated", {
109
+ seconds: ((performance.now() - l) / 1e3).toFixed(1),
110
+ explanation: o.explanation
111
+ })
112
+ )) : (_(o.error), w(r("workshopLab.cypher.gaveUp", { attempts: o.attempts })));
113
+ } catch (o) {
114
+ w(a.signal.aborted ? null : oe(o));
115
+ } finally {
116
+ X(!1);
117
+ }
118
+ }, ge = (s) => {
119
+ const a = F.current?.resizableTextArea?.textArea, l = a?.selectionStart ?? d.length, o = a?.selectionEnd ?? l;
120
+ A(d.slice(0, l) + s + d.slice(o)), requestAnimationFrame(() => {
121
+ a?.focus(), a?.setSelectionRange(l + s.length, l + s.length);
122
+ });
123
+ }, xe = () => {
124
+ const s = Object.fromEntries(
125
+ C.flatMap((m) => {
126
+ const I = q(m);
127
+ return I ? [[m, I]] : [];
128
+ })
129
+ ), a = {
130
+ id: L,
131
+ label: D.trim() || L,
132
+ objectType: Be(L),
133
+ key: S,
134
+ cypher: { query: d, columns: u, ...C.length > 0 ? { params: s } : {} },
135
+ // Progress, computed columns and formats stay; validation names any that lost a column.
136
+ ...i?.progress ? { progress: i.progress } : {},
137
+ ...i?.computed ? { computed: i.computed } : {},
138
+ ...i?.formats ? { formats: i.formats } : {}
139
+ }, l = i ? p.sources.map((m) => m.id === i.id ? a : m) : [...p.sources, a], o = g({ ...p, sources: l });
140
+ fe(o), o.length === 0 && x();
141
+ }, [$, we] = c.useState(""), je = c.useMemo(() => {
142
+ const s = $.trim().toLowerCase(), a = (...n) => !s || n.some((j) => j.toLowerCase().includes(s)), l = (n) => h.objectTypes[n]?.name ?? n, o = Object.values(h.objectTypes).flatMap((n) => {
143
+ const j = n.properties.filter(
144
+ (b) => a(n.name, n.id, b.label, b.name)
145
+ );
146
+ return !a(n.name, n.id) && j.length === 0 ? [] : [
147
+ {
148
+ key: `type:${n.id}`,
149
+ name: n.name,
150
+ detail: n.id,
151
+ insert: `(n:\`${n.id}\`)`,
152
+ children: j.map((b) => ({
153
+ key: `prop:${n.id}:${b.name}`,
154
+ name: b.label,
155
+ detail: b.name,
156
+ insert: `n.\`${b.name}\``,
157
+ isLeaf: !0
158
+ }))
159
+ }
160
+ ];
161
+ }), m = h.relations.filter(
162
+ (n) => a(n.name, n.id, l(n.source), l(n.target))
163
+ ).map((n) => ({
164
+ key: `rel:${n.id}`,
165
+ name: n.name,
166
+ detail: `${l(n.source)} → ${l(n.target)}`,
167
+ insert: `-[:\`${n.id}\`]->`,
168
+ isLeaf: !0
169
+ })), I = T.filter((n) => a(n.name, n.label)).map((n) => ({
170
+ key: `var:${n.name}`,
171
+ name: `$${n.name}`,
172
+ detail: n.label,
173
+ insert: `$${n.name}`,
174
+ isLeaf: !0
175
+ })), P = (n, j, b) => ({
176
+ key: n,
177
+ name: `${j} · ${b.length}`,
178
+ selectable: !1,
179
+ children: b
180
+ });
181
+ return [
182
+ P("variables", r("workshopLab.cypher.variables"), I),
183
+ P("types", r("workshopLab.cypher.objectTypes"), o),
184
+ P("relations", r("workshopLab.cypher.relations"), m)
185
+ ];
186
+ }, [h, T, $, r]), ke = !!(d.trim() && u.length > 0 && S && L), te = y?.entries.slice(0, he) ?? [], ve = y ? te.length > 0 ? /* @__PURE__ */ e.jsx(
187
+ ce,
188
+ {
189
+ size: "small",
190
+ rowKey: "$row",
191
+ pagination: !1,
192
+ scroll: { x: "max-content", y: 260 },
193
+ dataSource: te.map((s, a) => ({ ...s, $row: a })),
194
+ columns: y.columns.map((s) => ({
195
+ title: u.find((a) => a.name === s.name)?.label ?? s.name,
196
+ dataIndex: s.name,
197
+ ellipsis: !0,
198
+ render: (a) => a == null ? "—" : String(a)
199
+ }))
200
+ }
201
+ ) : /* @__PURE__ */ e.jsx(k, { image: k.PRESENTED_IMAGE_SIMPLE, description: r("workshopLab.cypher.noRows") }) : /* @__PURE__ */ e.jsx(k, { image: k.PRESENTED_IMAGE_SIMPLE, description: r("workshopLab.cypher.notRun") }), Le = u.length > 0 ? /* @__PURE__ */ e.jsxs("div", { className: t.cypherTabBody, children: [
202
+ /* @__PURE__ */ e.jsx("span", { className: t.muted, children: r("workshopLab.cypher.columnsHint") }),
203
+ /* @__PURE__ */ e.jsx(
204
+ ce,
205
+ {
206
+ size: "small",
207
+ rowKey: "name",
208
+ pagination: !1,
209
+ dataSource: u,
210
+ columns: [
211
+ {
212
+ title: r("workshopLab.cypher.column"),
213
+ dataIndex: "name",
214
+ render: (s) => /* @__PURE__ */ e.jsx("code", { className: t.cypherCode, children: s })
215
+ },
216
+ {
217
+ title: r("workshopLab.cypher.columnLabel"),
218
+ render: (s, a) => /* @__PURE__ */ e.jsx(
219
+ v,
220
+ {
221
+ size: "small",
222
+ value: a.label,
223
+ onChange: (l) => O(
224
+ u.map(
225
+ (o) => o.name === a.name ? { ...o, label: l.target.value } : o
226
+ )
227
+ )
228
+ }
229
+ )
230
+ },
231
+ {
232
+ title: r("workshopLab.cypher.samples"),
233
+ render: (s, a) => /* @__PURE__ */ e.jsx("span", { className: t.muted, children: y ? Ze(y.entries, a.name) : Q ? r("workshopLab.cypher.running") : "—" })
234
+ },
235
+ {
236
+ title: r("workshopLab.cypher.columnType"),
237
+ width: 120,
238
+ render: (s, a) => /* @__PURE__ */ e.jsx(
239
+ ne,
240
+ {
241
+ size: "small",
242
+ className: t.full,
243
+ value: a.type,
244
+ options: ["text", "number", "date"].map((l) => ({
245
+ value: l,
246
+ label: r(`workshopLab.cypher.types.${l}`)
247
+ })),
248
+ onChange: (l) => O(
249
+ u.map(
250
+ (o) => o.name === a.name ? { ...o, type: l } : o
251
+ )
252
+ )
253
+ }
254
+ )
255
+ },
256
+ {
257
+ title: r("workshopLab.cypher.key"),
258
+ width: 64,
259
+ align: "center",
260
+ render: (s, a) => /* @__PURE__ */ e.jsx(
261
+ Fe,
262
+ {
263
+ "aria-label": r("workshopLab.cypher.keyOf", { name: a.name }),
264
+ checked: S === a.name,
265
+ onChange: () => K(a.name)
266
+ }
267
+ )
268
+ }
269
+ ]
270
+ }
271
+ )
272
+ ] }) : /* @__PURE__ */ e.jsx(k, { image: k.PRESENTED_IMAGE_SIMPLE, description: r("workshopLab.cypher.notRun") });
273
+ return /* @__PURE__ */ e.jsx(
274
+ Ae,
275
+ {
276
+ open: !0,
277
+ width: 1180,
278
+ title: r(i ? "workshopLab.cypher.editTitle" : "workshopLab.cypher.newTitle"),
279
+ onCancel: () => {
280
+ E.current?.abort(), x();
281
+ },
282
+ footer: /* @__PURE__ */ e.jsxs("div", { className: t.cypherFooter, children: [
283
+ /* @__PURE__ */ e.jsx("span", { className: t.muted, children: r("workshopLab.cypher.limits") }),
284
+ /* @__PURE__ */ e.jsxs(Pe, { children: [
285
+ /* @__PURE__ */ e.jsx(
286
+ N,
287
+ {
288
+ onClick: () => {
289
+ E.current?.abort(), x();
290
+ },
291
+ children: r("workshopLab.cypher.cancel")
292
+ }
293
+ ),
294
+ /* @__PURE__ */ e.jsx(N, { type: "primary", disabled: !ke, onClick: xe, children: r("workshopLab.cypher.save") })
295
+ ] })
296
+ ] }),
297
+ children: /* @__PURE__ */ e.jsxs("div", { className: t.cypherEditor, style: me, children: [
298
+ /* @__PURE__ */ e.jsxs("aside", { className: t.cypherSchema, children: [
299
+ /* @__PURE__ */ e.jsx(
300
+ v,
301
+ {
302
+ allowClear: !0,
303
+ size: "small",
304
+ prefix: /* @__PURE__ */ e.jsx(Oe, {}),
305
+ placeholder: r("workshopLab.cypher.search"),
306
+ value: $,
307
+ onChange: (s) => we(s.target.value)
308
+ }
309
+ ),
310
+ /* @__PURE__ */ e.jsx("span", { className: t.muted, children: r("workshopLab.cypher.schemaHint") }),
311
+ /* @__PURE__ */ e.jsx("div", { className: t.cypherTree, children: /* @__PURE__ */ e.jsx(
312
+ De,
313
+ {
314
+ blockNode: !0,
315
+ treeData: je,
316
+ fieldNames: { title: "name" },
317
+ defaultExpandedKeys: ["variables"],
318
+ ...$.trim() ? { expandedKeys: ["variables", "types", "relations"] } : {},
319
+ titleRender: (s) => {
320
+ const a = s;
321
+ return /* @__PURE__ */ e.jsxs("span", { className: t.cypherNode, title: a.detail, children: [
322
+ /* @__PURE__ */ e.jsx("span", { className: t.cypherNodeName, children: a.name }),
323
+ a.detail && /* @__PURE__ */ e.jsx("span", { className: t.cypherNodeDetail, children: a.detail })
324
+ ] });
325
+ },
326
+ onSelect: (s, { node: a }) => {
327
+ const l = a.insert;
328
+ l && ge(l);
329
+ }
330
+ }
331
+ ) })
332
+ ] }),
333
+ /* @__PURE__ */ e.jsxs("div", { className: t.cypherMain, children: [
334
+ /* @__PURE__ */ e.jsxs("div", { className: t.cypherMeta, children: [
335
+ /* @__PURE__ */ e.jsxs("label", { className: t.field, children: [
336
+ /* @__PURE__ */ e.jsx("span", { className: t.fieldLabel, children: r("workshopLab.cypher.label") }),
337
+ /* @__PURE__ */ e.jsx(
338
+ v,
339
+ {
340
+ value: D,
341
+ placeholder: r("workshopLab.cypher.labelPlaceholder"),
342
+ onChange: (s) => ue(s.target.value)
343
+ }
344
+ )
345
+ ] }),
346
+ /* @__PURE__ */ e.jsxs("label", { className: t.field, children: [
347
+ /* @__PURE__ */ e.jsx("span", { className: t.fieldLabel, children: r("workshopLab.cypher.id") }),
348
+ /* @__PURE__ */ e.jsx(
349
+ v,
350
+ {
351
+ className: t.cypherCodeInput,
352
+ disabled: !!i,
353
+ value: L,
354
+ onChange: (s) => de(s.target.value.trim())
355
+ }
356
+ )
357
+ ] })
358
+ ] }),
359
+ /* @__PURE__ */ e.jsxs("div", { className: t.cypherAsk, children: [
360
+ /* @__PURE__ */ e.jsx(_e, { className: t.cypherAskIcon }),
361
+ /* @__PURE__ */ e.jsx(
362
+ v,
363
+ {
364
+ variant: "borderless",
365
+ placeholder: r("workshopLab.cypher.askPlaceholder"),
366
+ value: R,
367
+ onChange: (s) => be(s.target.value),
368
+ onPressEnter: (s) => !s.nativeEvent.isComposing && R.trim() && !W && void re()
369
+ }
370
+ ),
371
+ W ? /* @__PURE__ */ e.jsx(N, { size: "small", onClick: () => E.current?.abort(), children: r("workshopLab.cypher.stop") }) : /* @__PURE__ */ e.jsx(
372
+ N,
373
+ {
374
+ size: "small",
375
+ type: "primary",
376
+ disabled: !R.trim(),
377
+ onClick: () => {
378
+ re();
379
+ },
380
+ children: r(d.trim() ? "workshopLab.cypher.revise" : "workshopLab.cypher.generate")
381
+ }
382
+ )
383
+ ] }),
384
+ Z && /* @__PURE__ */ e.jsx("span", { className: t.muted, children: Z }),
385
+ /* @__PURE__ */ e.jsxs("div", { className: t.cypherBox, children: [
386
+ /* @__PURE__ */ e.jsxs("div", { className: t.cypherBoxBar, children: [
387
+ /* @__PURE__ */ e.jsx("b", { children: r("workshopLab.cypher.query") }),
388
+ /* @__PURE__ */ e.jsx("span", { className: t.spacer }),
389
+ y && /* @__PURE__ */ e.jsx("span", { className: t.muted, children: r("workshopLab.cypher.rows", {
390
+ count: y.entries.length,
391
+ seconds: (y.ms / 1e3).toFixed(1)
392
+ }) }),
393
+ /* @__PURE__ */ e.jsx(
394
+ N,
395
+ {
396
+ size: "small",
397
+ icon: /* @__PURE__ */ e.jsx(We, {}),
398
+ loading: Q,
399
+ disabled: !d.trim(),
400
+ onClick: () => {
401
+ se();
402
+ },
403
+ children: r("workshopLab.cypher.run")
404
+ }
405
+ )
406
+ ] }),
407
+ /* @__PURE__ */ e.jsx(
408
+ v.TextArea,
409
+ {
410
+ ref: F,
411
+ variant: "borderless",
412
+ className: t.cypherText,
413
+ autoSize: { minRows: 7, maxRows: 14 },
414
+ spellCheck: !1,
415
+ placeholder: "MATCH (o:`…`)-[:`…`]->(p:`…`) RETURN o.… AS id, … LIMIT 1000",
416
+ value: d,
417
+ onChange: (s) => A(s.target.value)
418
+ }
419
+ ),
420
+ C.length > 0 && /* @__PURE__ */ e.jsxs("div", { className: t.cypherParams, children: [
421
+ /* @__PURE__ */ e.jsx("span", { className: t.fieldLabel, children: r("workshopLab.cypher.params") }),
422
+ C.map((s) => /* @__PURE__ */ e.jsxs("span", { className: t.cypherParam, children: [
423
+ /* @__PURE__ */ e.jsxs("code", { className: t.cypherCode, children: [
424
+ "$",
425
+ s
426
+ ] }),
427
+ /* @__PURE__ */ e.jsx("span", { className: t.muted, children: "=" }),
428
+ /* @__PURE__ */ e.jsx(
429
+ ne,
430
+ {
431
+ size: "small",
432
+ variant: "borderless",
433
+ popupMatchSelectWidth: !1,
434
+ value: q(s),
435
+ placeholder: r("workshopLab.cypher.pickVariable"),
436
+ options: T.map((a) => ({
437
+ value: a.name,
438
+ label: a.label
439
+ })),
440
+ onChange: (a) => ye({ ...V, [s]: a })
441
+ }
442
+ )
443
+ ] }, s)),
444
+ /* @__PURE__ */ e.jsx(Ee, { title: r("workshopLab.cypher.paramsHint"), children: /* @__PURE__ */ e.jsx(Ke, { className: t.muted }) })
445
+ ] })
446
+ ] }),
447
+ G && /* @__PURE__ */ e.jsx(ie, { type: "error", showIcon: !0, message: G }),
448
+ /* @__PURE__ */ e.jsx(
449
+ qe,
450
+ {
451
+ size: "small",
452
+ className: t.cypherTabs,
453
+ items: [
454
+ {
455
+ key: "result",
456
+ label: y ? r("workshopLab.cypher.preview", {
457
+ count: Math.min(he, y.entries.length)
458
+ }) : r("workshopLab.cypher.result"),
459
+ children: ve
460
+ },
461
+ {
462
+ key: "columns",
463
+ label: u.length > 0 ? `${r("workshopLab.cypher.columns")} · ${u.length}` : r("workshopLab.cypher.columns"),
464
+ children: Le
465
+ }
466
+ ]
467
+ }
468
+ ),
469
+ J.length > 0 && /* @__PURE__ */ e.jsx(
470
+ ie,
471
+ {
472
+ type: "error",
473
+ showIcon: !0,
474
+ message: r("workshopLab.cypher.invalid"),
475
+ description: /* @__PURE__ */ e.jsx("ul", { className: t.errorList, children: J.slice(0, 6).map((s) => /* @__PURE__ */ e.jsx("li", { children: s }, s)) })
476
+ }
477
+ )
478
+ ] })
479
+ ] })
480
+ }
481
+ );
482
+ }
483
+ export {
484
+ ts as CypherEditor
485
+ };