@solidxai/core-ui 0.1.13 → 0.1.14-beta.0

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 (147) hide show
  1. package/dist/components/common/SolidPopupContainer.d.ts.map +1 -1
  2. package/dist/components/common/SolidPopupContainer.js +68 -5
  3. package/dist/components/common/SolidPopupContainer.js.map +1 -1
  4. package/dist/components/common/SolidPopupContainer.tsx +50 -4
  5. package/dist/components/core/card/SolidCardViewConfigure.d.ts.map +1 -1
  6. package/dist/components/core/card/SolidCardViewConfigure.js +1 -1
  7. package/dist/components/core/card/SolidCardViewConfigure.js.map +1 -1
  8. package/dist/components/core/card/SolidCardViewConfigure.tsx +3 -1
  9. package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorHeaderAction.d.ts +2 -0
  10. package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorHeaderAction.d.ts.map +1 -0
  11. package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorHeaderAction.js +4 -0
  12. package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorHeaderAction.js.map +1 -0
  13. package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorHeaderAction.ts +3 -0
  14. package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorRowAction.d.ts +8 -0
  15. package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorRowAction.d.ts.map +1 -0
  16. package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorRowAction.js +9 -0
  17. package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorRowAction.js.map +1 -0
  18. package/dist/components/core/extension/solid-core/workflowDefinition/list/openWorkflowDefinitionEditorRowAction.ts +17 -0
  19. package/dist/components/core/form/SolidFormView.d.ts.map +1 -1
  20. package/dist/components/core/form/SolidFormView.js +52 -22
  21. package/dist/components/core/form/SolidFormView.js.map +1 -1
  22. package/dist/components/core/form/SolidFormView.tsx +49 -9
  23. package/dist/components/core/kanban/SolidKanbanViewConfigure.d.ts.map +1 -1
  24. package/dist/components/core/kanban/SolidKanbanViewConfigure.js +1 -1
  25. package/dist/components/core/kanban/SolidKanbanViewConfigure.js.map +1 -1
  26. package/dist/components/core/kanban/SolidKanbanViewConfigure.tsx +3 -1
  27. package/dist/components/core/list/SolidCustomListViewColumn.d.ts +2 -1
  28. package/dist/components/core/list/SolidCustomListViewColumn.d.ts.map +1 -1
  29. package/dist/components/core/list/SolidCustomListViewColumn.js +3 -2
  30. package/dist/components/core/list/SolidCustomListViewColumn.js.map +1 -1
  31. package/dist/components/core/list/SolidCustomListViewColumn.tsx +4 -1
  32. package/dist/components/core/list/SolidListView.d.ts.map +1 -1
  33. package/dist/components/core/list/SolidListView.js +75 -71
  34. package/dist/components/core/list/SolidListView.js.map +1 -1
  35. package/dist/components/core/list/SolidListView.tsx +25 -10
  36. package/dist/components/core/list/SolidListViewColumn.d.ts +3 -1
  37. package/dist/components/core/list/SolidListViewColumn.d.ts.map +1 -1
  38. package/dist/components/core/list/SolidListViewColumn.js +81 -42
  39. package/dist/components/core/list/SolidListViewColumn.js.map +1 -1
  40. package/dist/components/core/list/SolidListViewColumn.tsx +93 -44
  41. package/dist/components/core/list/SolidListViewConfigure.d.ts.map +1 -1
  42. package/dist/components/core/list/SolidListViewConfigure.js +2 -2
  43. package/dist/components/core/list/SolidListViewConfigure.js.map +1 -1
  44. package/dist/components/core/list/SolidListViewConfigure.tsx +4 -2
  45. package/dist/components/core/list/widgets/PillWidget.d.ts +3 -0
  46. package/dist/components/core/list/widgets/PillWidget.d.ts.map +1 -0
  47. package/dist/components/core/list/widgets/PillWidget.js +95 -0
  48. package/dist/components/core/list/widgets/PillWidget.js.map +1 -0
  49. package/dist/components/core/list/widgets/PillWidget.tsx +127 -0
  50. package/dist/components/shad-cn-ui/SolidDialog.js +1 -1
  51. package/dist/components/shad-cn-ui/SolidDialog.js.map +1 -1
  52. package/dist/components/shad-cn-ui/SolidDialog.tsx +1 -1
  53. package/dist/components/shad-cn-ui/SolidDropdownMenu.d.ts +3 -1
  54. package/dist/components/shad-cn-ui/SolidDropdownMenu.d.ts.map +1 -1
  55. package/dist/components/shad-cn-ui/SolidDropdownMenu.js +2 -2
  56. package/dist/components/shad-cn-ui/SolidDropdownMenu.js.map +1 -1
  57. package/dist/components/shad-cn-ui/SolidDropdownMenu.tsx +11 -5
  58. package/dist/components/shad-cn-ui/SolidIcon.d.ts +2 -1
  59. package/dist/components/shad-cn-ui/SolidIcon.d.ts.map +1 -1
  60. package/dist/components/shad-cn-ui/SolidIcon.js +2 -1
  61. package/dist/components/shad-cn-ui/SolidIcon.js.map +1 -1
  62. package/dist/components/shad-cn-ui/SolidIcon.tsx +2 -0
  63. package/dist/components/workflow/WorkflowFlowCanvas.css +454 -0
  64. package/dist/components/workflow/WorkflowFlowCanvas.d.ts +40 -0
  65. package/dist/components/workflow/WorkflowFlowCanvas.d.ts.map +1 -0
  66. package/dist/components/workflow/WorkflowFlowCanvas.js +861 -0
  67. package/dist/components/workflow/WorkflowFlowCanvas.js.map +1 -0
  68. package/dist/components/workflow/WorkflowFlowCanvas.tsx +1522 -0
  69. package/dist/components/workflow/WorkflowNodeDocsPanel.css +247 -0
  70. package/dist/components/workflow/WorkflowNodeDocsPanel.d.ts +22 -0
  71. package/dist/components/workflow/WorkflowNodeDocsPanel.d.ts.map +1 -0
  72. package/dist/components/workflow/WorkflowNodeDocsPanel.js +97 -0
  73. package/dist/components/workflow/WorkflowNodeDocsPanel.js.map +1 -0
  74. package/dist/components/workflow/WorkflowNodeDocsPanel.tsx +363 -0
  75. package/dist/components/workflow/WorkflowNodeSchemaEditor.css +802 -0
  76. package/dist/components/workflow/WorkflowNodeSchemaEditor.d.ts +72 -0
  77. package/dist/components/workflow/WorkflowNodeSchemaEditor.d.ts.map +1 -0
  78. package/dist/components/workflow/WorkflowNodeSchemaEditor.js +1107 -0
  79. package/dist/components/workflow/WorkflowNodeSchemaEditor.js.map +1 -0
  80. package/dist/components/workflow/WorkflowNodeSchemaEditor.tsx +2347 -0
  81. package/dist/helpers/registry.d.ts.map +1 -1
  82. package/dist/helpers/registry.js +7 -0
  83. package/dist/helpers/registry.js.map +1 -1
  84. package/dist/helpers/registry.ts +8 -0
  85. package/dist/index.d.ts +6 -0
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +5 -0
  88. package/dist/index.js.map +1 -1
  89. package/dist/index.ts +37 -0
  90. package/dist/redux/api/workflowDefinitionEditorApi.d.ts +17 -0
  91. package/dist/redux/api/workflowDefinitionEditorApi.d.ts.map +1 -0
  92. package/dist/redux/api/workflowDefinitionEditorApi.js +38 -0
  93. package/dist/redux/api/workflowDefinitionEditorApi.js.map +1 -0
  94. package/dist/redux/api/workflowDefinitionEditorApi.ts +40 -0
  95. package/dist/redux/api/workflowNodeApi.d.ts +6 -0
  96. package/dist/redux/api/workflowNodeApi.d.ts.map +1 -0
  97. package/dist/redux/api/workflowNodeApi.js +14 -0
  98. package/dist/redux/api/workflowNodeApi.js.map +1 -0
  99. package/dist/redux/api/workflowNodeApi.ts +18 -0
  100. package/dist/redux/features/popupSlice.d.ts +17 -2
  101. package/dist/redux/features/popupSlice.d.ts.map +1 -1
  102. package/dist/redux/features/popupSlice.js.map +1 -1
  103. package/dist/redux/features/popupSlice.ts +19 -3
  104. package/dist/redux/store/defaultStoreConfig.d.ts +13 -0
  105. package/dist/redux/store/defaultStoreConfig.d.ts.map +1 -1
  106. package/dist/redux/store/defaultStoreConfig.js +4 -0
  107. package/dist/redux/store/defaultStoreConfig.js.map +1 -1
  108. package/dist/redux/store/defaultStoreConfig.ts +4 -0
  109. package/dist/redux/store/solidEntityApiPool.d.ts.map +1 -1
  110. package/dist/redux/store/solidEntityApiPool.js +1 -0
  111. package/dist/redux/store/solidEntityApiPool.js.map +1 -1
  112. package/dist/redux/store/solidEntityApiPool.ts +1 -0
  113. package/dist/resources/solid-custom.css +16 -0
  114. package/dist/resources/solid-tailwind-generated.css +1 -1
  115. package/dist/routes/pages/admin/core/WorkflowDefinitionEditorPage.css +3194 -0
  116. package/dist/routes/pages/admin/core/WorkflowDefinitionEditorPage.d.ts +3 -0
  117. package/dist/routes/pages/admin/core/WorkflowDefinitionEditorPage.d.ts.map +1 -0
  118. package/dist/routes/pages/admin/core/WorkflowDefinitionEditorPage.js +3371 -0
  119. package/dist/routes/pages/admin/core/WorkflowDefinitionEditorPage.js.map +1 -0
  120. package/dist/routes/pages/admin/core/WorkflowDefinitionEditorPage.tsx +6215 -0
  121. package/dist/routes/pages/admin/core/WorkflowDefinitionListPage.css +217 -0
  122. package/dist/routes/pages/admin/core/WorkflowDefinitionListPage.d.ts +3 -0
  123. package/dist/routes/pages/admin/core/WorkflowDefinitionListPage.d.ts.map +1 -0
  124. package/dist/routes/pages/admin/core/WorkflowDefinitionListPage.js +268 -0
  125. package/dist/routes/pages/admin/core/WorkflowDefinitionListPage.js.map +1 -0
  126. package/dist/routes/pages/admin/core/WorkflowDefinitionListPage.tsx +510 -0
  127. package/dist/routes/pages/admin/core/WorkflowExecutionDetailPage.d.ts +3 -0
  128. package/dist/routes/pages/admin/core/WorkflowExecutionDetailPage.d.ts.map +1 -0
  129. package/dist/routes/pages/admin/core/WorkflowExecutionDetailPage.js +618 -0
  130. package/dist/routes/pages/admin/core/WorkflowExecutionDetailPage.js.map +1 -0
  131. package/dist/routes/pages/admin/core/WorkflowExecutionDetailPage.tsx +1322 -0
  132. package/dist/routes/solidRoutes.d.ts.map +1 -1
  133. package/dist/routes/solidRoutes.js +6 -0
  134. package/dist/routes/solidRoutes.js.map +1 -1
  135. package/dist/routes/solidRoutes.tsx +6 -0
  136. package/dist/types/extension-registry.d.ts +4 -0
  137. package/dist/types/extension-registry.d.ts.map +1 -1
  138. package/dist/types/extension-registry.js +5 -1
  139. package/dist/types/extension-registry.js.map +1 -1
  140. package/dist/types/extension-registry.ts +5 -1
  141. package/dist/types/solid-core.d.ts +32 -0
  142. package/dist/types/workflow-node.d.ts +142 -0
  143. package/dist/types/workflow-node.d.ts.map +1 -0
  144. package/dist/types/workflow-node.js +2 -0
  145. package/dist/types/workflow-node.js.map +1 -0
  146. package/dist/types/workflow-node.ts +179 -0
  147. package/package.json +3 -1
@@ -0,0 +1,861 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
+ if (ar || !(i in from)) {
15
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
16
+ ar[i] = from[i];
17
+ }
18
+ }
19
+ return to.concat(ar || Array.prototype.slice.call(from));
20
+ };
21
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
+ import React from "react";
23
+ import { Background, BackgroundVariant, BaseEdge, Controls, Handle, MarkerType, Position, ReactFlow, ReactFlowProvider, } from "@xyflow/react";
24
+ import { CircleHelp, Pencil, Plus, Trash2 } from "lucide-react";
25
+ import { normalizeSolidIconName, SolidIcon } from "../shad-cn-ui";
26
+ import "@xyflow/react/dist/style.css";
27
+ import "./WorkflowFlowCanvas.css";
28
+ var DIMENSIONS = {
29
+ workflowWidth: 300,
30
+ workflowHeight: 136,
31
+ triggerWidth: 280,
32
+ triggerHeight: 108,
33
+ triggerGap: 34,
34
+ insertWidth: 40,
35
+ insertHeight: 40,
36
+ junctionWidth: 8,
37
+ junctionHeight: 8,
38
+ sectionLabelWidth: 104,
39
+ sectionLabelHeight: 28,
40
+ groupPaddingX: 36,
41
+ groupPaddingTop: 58,
42
+ groupPaddingBottom: 36,
43
+ loopGroupPaddingX: 70,
44
+ loopGroupPaddingTop: 62,
45
+ loopGroupPaddingBottom: 44,
46
+ sequenceInsertToNodeGap: 88,
47
+ sequenceNodeToInsertGap: 48,
48
+ controlNodeToChildGap: 78,
49
+ controlBranchLabelGap: 42,
50
+ controlBranchGap: 120,
51
+ controlJoinGap: 92,
52
+ groupExteriorEdgeGap: 44,
53
+ };
54
+ var DEFAULT_WORKFLOW_VIEWPORT = {
55
+ x: 360,
56
+ y: 56,
57
+ zoom: 0.82,
58
+ };
59
+ function normalizeChildSlots(node, nodeType) {
60
+ var _a, _b;
61
+ if ((_b = (_a = nodeType === null || nodeType === void 0 ? void 0 : nodeType.authoring) === null || _a === void 0 ? void 0 : _a.childSlots) === null || _b === void 0 ? void 0 : _b.length) {
62
+ return nodeType.authoring.childSlots;
63
+ }
64
+ var slots = [];
65
+ if (node.cases && typeof node.cases === "object" && !Array.isArray(node.cases)) {
66
+ slots.push({ key: "cases", label: "Cases", kind: "case-collection" });
67
+ if (Array.isArray(node.defaults)) {
68
+ slots.push({ key: "defaults", label: "Default", kind: "sequence" });
69
+ }
70
+ }
71
+ else if (Array.isArray(node.then) || Array.isArray(node.else)) {
72
+ slots.push({ key: "then", label: "Then", kind: "sequence" });
73
+ slots.push({ key: "else", label: "Else", kind: "sequence" });
74
+ }
75
+ else if (Array.isArray(node.tasks)) {
76
+ slots.push({ key: "tasks", label: "Tasks", kind: "sequence" });
77
+ }
78
+ return slots;
79
+ }
80
+ function isLoopNode(workflowNode, nodeType) {
81
+ var _a, _b, _c;
82
+ var nodeTypeId = String((_b = (_a = workflowNode.type) !== null && _a !== void 0 ? _a : nodeType === null || nodeType === void 0 ? void 0 : nodeType.type) !== null && _b !== void 0 ? _b : "").toLowerCase();
83
+ var category = String((_c = nodeType === null || nodeType === void 0 ? void 0 : nodeType.category) !== null && _c !== void 0 ? _c : "").toLowerCase();
84
+ var nodeTypeTags = nodeType === null || nodeType === void 0 ? void 0 : nodeType.tags;
85
+ var tags = Array.isArray(nodeTypeTags)
86
+ ? nodeTypeTags.map(function (tag) { return String(tag).toLowerCase(); })
87
+ : [];
88
+ return (nodeTypeId === "foreach" ||
89
+ nodeTypeId === "for.each" ||
90
+ nodeTypeId === "loopuntil" ||
91
+ nodeTypeId === "loop.until" ||
92
+ category.includes("loop") ||
93
+ tags.includes("loop") ||
94
+ tags.includes("iteration"));
95
+ }
96
+ function getSequenceSlotNodes(workflowNode, slotKey) {
97
+ if (Array.isArray(workflowNode[slotKey])) {
98
+ return workflowNode[slotKey];
99
+ }
100
+ if (slotKey === "tasks") {
101
+ return [];
102
+ }
103
+ return [];
104
+ }
105
+ function getSwitchCaseEntries(workflowNode) {
106
+ var cases = workflowNode.cases &&
107
+ typeof workflowNode.cases === "object" &&
108
+ !Array.isArray(workflowNode.cases)
109
+ ? workflowNode.cases
110
+ : {};
111
+ var entries = Object.entries(cases).map(function (_a) {
112
+ var caseKey = _a[0], nodes = _a[1];
113
+ return ({
114
+ key: "case-".concat(caseKey),
115
+ label: caseKey,
116
+ nodes: Array.isArray(nodes) ? nodes : [],
117
+ scope: {
118
+ scope: "case",
119
+ parentNodeId: String(workflowNode.id),
120
+ caseKey: caseKey,
121
+ },
122
+ });
123
+ });
124
+ if (Array.isArray(workflowNode.defaults)) {
125
+ entries.push({
126
+ key: "default",
127
+ label: "Default",
128
+ nodes: workflowNode.defaults,
129
+ scope: {
130
+ scope: "slot",
131
+ parentNodeId: String(workflowNode.id),
132
+ slotKey: "defaults",
133
+ },
134
+ });
135
+ }
136
+ return entries;
137
+ }
138
+ function getNodeRect(node) {
139
+ var _a, _b, _c, _d;
140
+ var width = Number((_b = (_a = node.style) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : 0);
141
+ var height = Number((_d = (_c = node.style) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : 0);
142
+ if (node.type === "workflow") {
143
+ width = DIMENSIONS.workflowWidth;
144
+ height = DIMENSIONS.workflowHeight;
145
+ }
146
+ else if (node.type === "trigger") {
147
+ width = DIMENSIONS.triggerWidth;
148
+ height = DIMENSIONS.triggerHeight;
149
+ }
150
+ else if (node.type === "insert") {
151
+ width = DIMENSIONS.insertWidth;
152
+ height = DIMENSIONS.insertHeight;
153
+ }
154
+ else if (node.type === "junction") {
155
+ width = DIMENSIONS.junctionWidth;
156
+ height = DIMENSIONS.junctionHeight;
157
+ }
158
+ else if (node.type === "sectionLabel") {
159
+ width = DIMENSIONS.sectionLabelWidth;
160
+ height = DIMENSIONS.sectionLabelHeight;
161
+ }
162
+ return {
163
+ left: node.position.x,
164
+ top: node.position.y,
165
+ right: node.position.x + width,
166
+ bottom: node.position.y + height,
167
+ };
168
+ }
169
+ function createEdge(source, target, options) {
170
+ var _a;
171
+ if (options === void 0) { options = {}; }
172
+ var edgeKind = (_a = options.kind) !== null && _a !== void 0 ? _a : (options.marker === false ? "merge" : "default");
173
+ var data = options.busY == null && options.splitMode == null
174
+ ? undefined
175
+ : {
176
+ busY: options.busY,
177
+ splitMode: options.splitMode,
178
+ };
179
+ return {
180
+ id: "".concat(source, "->").concat(target),
181
+ source: source,
182
+ target: target,
183
+ type: edgeKind === "merge"
184
+ ? "workflowMerge"
185
+ : edgeKind === "split"
186
+ ? "workflowSplit"
187
+ : "smoothstep",
188
+ data: data,
189
+ markerEnd: options.marker === false
190
+ ? undefined
191
+ : {
192
+ type: MarkerType.ArrowClosed,
193
+ width: 12,
194
+ height: 12,
195
+ color: "rgba(203, 213, 225, 0.94)",
196
+ },
197
+ style: {
198
+ stroke: "rgba(203, 213, 225, 0.94)",
199
+ strokeWidth: 2,
200
+ strokeDasharray: "6 7",
201
+ },
202
+ animated: true,
203
+ zIndex: 1,
204
+ };
205
+ }
206
+ function WorkflowMergeEdge(_a) {
207
+ var id = _a.id, sourceX = _a.sourceX, sourceY = _a.sourceY, targetX = _a.targetX, targetY = _a.targetY, style = _a.style;
208
+ var mergeY = targetY;
209
+ var path = "M ".concat(sourceX, " ").concat(sourceY, " V ").concat(mergeY, " H ").concat(targetX);
210
+ return (_jsx(BaseEdge, { id: id, path: path, style: style, interactionWidth: 18 }));
211
+ }
212
+ function WorkflowSplitEdge(_a) {
213
+ var id = _a.id, sourceX = _a.sourceX, sourceY = _a.sourceY, targetX = _a.targetX, targetY = _a.targetY, markerEnd = _a.markerEnd, style = _a.style, data = _a.data;
214
+ if ((data === null || data === void 0 ? void 0 : data.splitMode) === "fromJunction") {
215
+ var path_1 = "M ".concat(sourceX, " ").concat(sourceY, " H ").concat(targetX, " V ").concat(targetY);
216
+ return (_jsx(BaseEdge, { id: id, path: path_1, markerEnd: markerEnd, style: style, interactionWidth: 18 }));
217
+ }
218
+ var requestedBusY = typeof (data === null || data === void 0 ? void 0 : data.busY) === "number"
219
+ ? data.busY
220
+ : sourceY + Math.max(24, (targetY - sourceY) * 0.42);
221
+ var minBusY = Math.min(sourceY, targetY) + 12;
222
+ var maxBusY = Math.max(sourceY, targetY) - 12;
223
+ var busY = maxBusY > minBusY
224
+ ? Math.min(maxBusY, Math.max(minBusY, requestedBusY))
225
+ : (sourceY + targetY) / 2;
226
+ var path = "M ".concat(sourceX, " ").concat(sourceY, " V ").concat(busY, " H ").concat(targetX, " V ").concat(targetY);
227
+ return (_jsx(BaseEdge, { id: id, path: path, markerEnd: markerEnd, style: style, interactionWidth: 18 }));
228
+ }
229
+ function resolveWorkflowNodeIcon(nodeType) {
230
+ var _a, _b, _c;
231
+ return (_c = normalizeSolidIconName((_b = (_a = nodeType === null || nodeType === void 0 ? void 0 : nodeType.ui) === null || _a === void 0 ? void 0 : _a.icon) !== null && _b !== void 0 ? _b : nodeType === null || nodeType === void 0 ? void 0 : nodeType.icon)) !== null && _c !== void 0 ? _c : "si-th-large";
232
+ }
233
+ function getWorkflowNodeIconStyle(nodeType) {
234
+ var _a, _b, _c;
235
+ var backgroundColor = (_a = nodeType === null || nodeType === void 0 ? void 0 : nodeType.ui) === null || _a === void 0 ? void 0 : _a.iconBackgroundColor;
236
+ var color = (_b = nodeType === null || nodeType === void 0 ? void 0 : nodeType.ui) === null || _b === void 0 ? void 0 : _b.iconColor;
237
+ var borderColor = (_c = nodeType === null || nodeType === void 0 ? void 0 : nodeType.ui) === null || _c === void 0 ? void 0 : _c.iconBorderColor;
238
+ if (!backgroundColor && !color && !borderColor) {
239
+ return undefined;
240
+ }
241
+ return __assign(__assign(__assign({}, (backgroundColor ? { backgroundColor: backgroundColor } : null)), (color ? { color: color } : null)), (borderColor ? { borderColor: borderColor } : null));
242
+ }
243
+ function estimateSequenceWidth(sequence, nodeTypeMap) {
244
+ if (!sequence.length) {
245
+ return DIMENSIONS.insertWidth;
246
+ }
247
+ return sequence.reduce(function (maxWidth, workflowNode) {
248
+ var nodeType = nodeTypeMap.get(String(workflowNode.type));
249
+ var nodeWidth = estimateWorkflowNodeWidth(workflowNode, nodeTypeMap, nodeType);
250
+ return Math.max(maxWidth, nodeWidth);
251
+ }, DIMENSIONS.workflowWidth);
252
+ }
253
+ function estimateWorkflowNodeWidth(workflowNode, nodeTypeMap, nodeType) {
254
+ var slotDefinitions = normalizeChildSlots(workflowNode, nodeType);
255
+ var branchSlots = slotDefinitions.filter(function (slot) { return slot.key === "then" || slot.key === "else"; });
256
+ if (branchSlots.length >= 2) {
257
+ var branchGap = DIMENSIONS.controlBranchGap;
258
+ var branchWidths = branchSlots.map(function (slot) {
259
+ return estimateSequenceWidth(Array.isArray(workflowNode[slot.key]) ? workflowNode[slot.key] : [], nodeTypeMap);
260
+ });
261
+ var totalBranchWidth = branchWidths.reduce(function (sum, width) { return sum + width; }, 0) +
262
+ branchGap * Math.max(branchWidths.length - 1, 0);
263
+ return Math.max(DIMENSIONS.workflowWidth, totalBranchWidth);
264
+ }
265
+ if (slotDefinitions.some(function (slot) { return slot.kind === "case-collection"; })) {
266
+ var caseEntries = getSwitchCaseEntries(workflowNode);
267
+ var branchGap = DIMENSIONS.controlBranchGap;
268
+ var branchWidths = caseEntries.map(function (entry) {
269
+ return estimateSequenceWidth(entry.nodes, nodeTypeMap);
270
+ });
271
+ var totalBranchWidth = branchWidths.reduce(function (sum, width) { return sum + width; }, 0) +
272
+ branchGap * Math.max(branchWidths.length - 1, 0);
273
+ return Math.max(DIMENSIONS.workflowWidth, totalBranchWidth);
274
+ }
275
+ if (slotDefinitions.length === 1 && slotDefinitions[0].kind === "sequence") {
276
+ var slot = slotDefinitions[0];
277
+ var slotKey = slot.key;
278
+ var childNodes = getSequenceSlotNodes(workflowNode, slotKey);
279
+ if (slot.layout === "parallel") {
280
+ var childWidths = childNodes.map(function (childNode) {
281
+ return estimateWorkflowNodeWidth(childNode, nodeTypeMap, nodeTypeMap.get(String(childNode.type)));
282
+ });
283
+ var totalChildWidth = childWidths.reduce(function (sum, width) { return sum + width; }, 0) +
284
+ DIMENSIONS.controlBranchGap * Math.max(childWidths.length - 1, 0);
285
+ return Math.max(DIMENSIONS.workflowWidth, totalChildWidth);
286
+ }
287
+ return Math.max(DIMENSIONS.workflowWidth, estimateSequenceWidth(childNodes, nodeTypeMap));
288
+ }
289
+ return DIMENSIONS.workflowWidth;
290
+ }
291
+ function WorkflowCanvasNodeRenderer(_a) {
292
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
293
+ var data = _a.data;
294
+ if (data.kind === "group") {
295
+ return (_jsx("div", { className: "workflow-flow-group-node workflow-flow-group-node--".concat((_b = data.tone) !== null && _b !== void 0 ? _b : "control"), children: _jsxs("div", { className: "workflow-flow-group-node__header", children: [_jsx("span", { children: data.label }), data.workflowNode ? (_jsx("button", { type: "button", className: "workflow-flow-help-button nodrag nopan nowheel", "aria-label": "Open ".concat((_d = (_c = data.nodeType) === null || _c === void 0 ? void 0 : _c.label) !== null && _d !== void 0 ? _d : data.label, " documentation"), title: "Documentation", onPointerDown: function (event) {
296
+ event.stopPropagation();
297
+ }, onClick: function (event) {
298
+ var _a, _b;
299
+ event.stopPropagation();
300
+ (_a = data.onViewDocs) === null || _a === void 0 ? void 0 : _a.call(data, String((_b = data.workflowNode) === null || _b === void 0 ? void 0 : _b.id));
301
+ }, children: _jsx(CircleHelp, { size: 12 }) })) : null] }) }));
302
+ }
303
+ if (data.kind === "insert") {
304
+ return (_jsxs("div", { className: "workflow-flow-insert-node", children: [_jsx("button", { type: "button", onPointerDown: function (event) {
305
+ event.stopPropagation();
306
+ }, onClick: function (event) {
307
+ event.stopPropagation();
308
+ data.onInsert();
309
+ }, className: "workflow-flow-insert-node__button nodrag nopan nowheel", "aria-label": data.enabled
310
+ ? "Add ".concat((_e = data.selectedTypeLabel) !== null && _e !== void 0 ? _e : "node")
311
+ : "Add node", title: data.enabled
312
+ ? "Add ".concat((_f = data.selectedTypeLabel) !== null && _f !== void 0 ? _f : "node")
313
+ : "Add node", children: _jsx(Plus, { size: 16 }) }), _jsx(Handle, { type: "target", position: Position.Top, className: "workflow-flow-insert-node__handle workflow-flow-insert-node__handle--top", isConnectable: false }), _jsx(Handle, { type: "source", position: Position.Bottom, className: "workflow-flow-insert-node__handle workflow-flow-insert-node__handle--bottom", isConnectable: false })] }));
314
+ }
315
+ if (data.kind === "junction") {
316
+ return (_jsxs("div", { className: "workflow-flow-junction-node", children: [_jsx(Handle, { type: "target", position: Position.Top, className: "workflow-flow-junction-node__handle workflow-flow-junction-node__handle--top", isConnectable: false }), _jsx(Handle, { type: "source", position: Position.Bottom, className: "workflow-flow-junction-node__handle workflow-flow-junction-node__handle--bottom", isConnectable: false })] }));
317
+ }
318
+ if (data.kind === "section-label") {
319
+ return _jsx("div", { className: "workflow-flow-section-label", children: data.label });
320
+ }
321
+ if (data.kind === "workflow-trigger") {
322
+ var triggerTitle = (_h = (_g = data.trigger.name) !== null && _g !== void 0 ? _g : data.trigger.label) !== null && _h !== void 0 ? _h : data.trigger.id;
323
+ return (_jsxs("div", { className: "workflow-flow-node-card workflow-flow-node-card--trigger ".concat(data.selected ? "is-selected" : ""), onClick: function () { return data.onSelectTrigger(String(data.trigger.id)); }, role: "button", tabIndex: 0, onKeyDown: function (event) {
324
+ if (event.key === "Enter" || event.key === " ") {
325
+ event.preventDefault();
326
+ data.onSelectTrigger(String(data.trigger.id));
327
+ }
328
+ }, children: [_jsxs("div", { className: "workflow-flow-node-card__typebar", children: [_jsx("span", { children: data.trigger.disabled ? "disabled trigger" : "trigger" }), _jsx("span", { className: "workflow-flow-node-card__quick-actions", children: _jsx("button", { type: "button", className: "workflow-flow-icon-button nodrag nopan nowheel", "aria-label": "Open ".concat(triggerTitle, " documentation"), title: "Documentation", onPointerDown: function (event) {
329
+ event.stopPropagation();
330
+ }, onClick: function (event) {
331
+ event.stopPropagation();
332
+ data.onViewDocs(String(data.trigger.id));
333
+ }, children: _jsx(CircleHelp, { size: 12 }) }) })] }), _jsx("div", { className: "workflow-flow-node-card__body", children: _jsxs("div", { className: "workflow-flow-node-card__header-main", children: [_jsx("div", { className: "workflow-flow-node-card__icon-shell", children: _jsx(SolidIcon, { name: "si-calendar", size: 16, "aria-hidden": true }) }), _jsxs("div", { children: [_jsx("div", { className: "workflow-flow-node-card__title", title: String(triggerTitle), children: triggerTitle }), _jsx("div", { className: "workflow-flow-node-card__subtitle", children: (_j = data.trigger.type) !== null && _j !== void 0 ? _j : "Trigger" })] })] }) }), data.trigger.description ? (_jsx("div", { className: "workflow-flow-node-card__description", children: data.trigger.description })) : null, _jsx(Handle, { type: "target", position: Position.Top, className: "workflow-flow-node-card__handle workflow-flow-node-card__handle--top", isConnectable: false }), _jsx(Handle, { type: "source", position: Position.Bottom, className: "workflow-flow-node-card__handle workflow-flow-node-card__handle--bottom", isConnectable: false })] }));
334
+ }
335
+ var workflowNode = data.workflowNode, nodeType = data.nodeType, selected = data.selected;
336
+ var iconName = resolveWorkflowNodeIcon(nodeType);
337
+ var nodeTitle = (_k = workflowNode.name) !== null && _k !== void 0 ? _k : workflowNode.id;
338
+ var nodeTypeLabel = (_o = (_m = (_l = nodeType === null || nodeType === void 0 ? void 0 : nodeType.label) !== null && _l !== void 0 ? _l : workflowNode.type) !== null && _m !== void 0 ? _m : workflowNode.kind) !== null && _o !== void 0 ? _o : "node";
339
+ return (_jsxs("div", { className: "workflow-flow-node-card ".concat(selected ? "is-selected" : ""), onClick: function () { return data.onSelectNode(String(workflowNode.id)); }, role: "button", tabIndex: 0, onKeyDown: function (event) {
340
+ if (event.key === "Enter" || event.key === " ") {
341
+ event.preventDefault();
342
+ data.onSelectNode(String(workflowNode.id));
343
+ }
344
+ }, children: [_jsxs("div", { className: "workflow-flow-node-card__typebar", children: [_jsx("span", { children: nodeTypeLabel }), _jsxs("span", { className: "workflow-flow-node-card__quick-actions", children: [_jsx("button", { type: "button", className: "workflow-flow-icon-button nodrag nopan nowheel", "aria-label": "Edit ".concat(nodeTitle), title: "Edit", onPointerDown: function (event) {
345
+ event.stopPropagation();
346
+ }, onClick: function (event) {
347
+ event.stopPropagation();
348
+ data.onEditNode(String(workflowNode.id));
349
+ }, children: _jsx(Pencil, { size: 12 }) }), _jsx("button", { type: "button", className: "workflow-flow-icon-button workflow-flow-icon-button--danger nodrag nopan nowheel", "aria-label": "Delete ".concat(nodeTitle), title: "Delete", onPointerDown: function (event) {
350
+ event.stopPropagation();
351
+ }, onClick: function (event) {
352
+ event.stopPropagation();
353
+ data.onDeleteNode(String(workflowNode.id));
354
+ }, children: _jsx(Trash2, { size: 12 }) }), _jsx("button", { type: "button", className: "workflow-flow-icon-button nodrag nopan nowheel", "aria-label": "Open ".concat(nodeTypeLabel, " documentation"), title: "Documentation", onPointerDown: function (event) {
355
+ event.stopPropagation();
356
+ }, onClick: function (event) {
357
+ event.stopPropagation();
358
+ data.onViewDocs(String(workflowNode.id));
359
+ }, children: _jsx(CircleHelp, { size: 12 }) })] })] }), _jsx("div", { className: "workflow-flow-node-card__body", children: _jsxs("div", { className: "workflow-flow-node-card__header-main", children: [_jsx("div", { className: "workflow-flow-node-card__icon-shell", style: getWorkflowNodeIconStyle(nodeType), children: _jsx(SolidIcon, { name: iconName, size: 16, "aria-hidden": true }) }), _jsx("div", { children: _jsx("div", { className: "workflow-flow-node-card__title", title: String(nodeTitle), children: nodeTitle }) })] }) }), workflowNode.description ? (_jsx("div", { className: "workflow-flow-node-card__description", children: workflowNode.description })) : null, _jsx(Handle, { type: "target", position: Position.Top, className: "workflow-flow-node-card__handle workflow-flow-node-card__handle--top", isConnectable: false }), _jsx(Handle, { type: "source", position: Position.Bottom, className: "workflow-flow-node-card__handle workflow-flow-node-card__handle--bottom", isConnectable: false })] }));
360
+ }
361
+ var canvasNodeTypes = {
362
+ group: WorkflowCanvasNodeRenderer,
363
+ workflow: WorkflowCanvasNodeRenderer,
364
+ trigger: WorkflowCanvasNodeRenderer,
365
+ insert: WorkflowCanvasNodeRenderer,
366
+ junction: WorkflowCanvasNodeRenderer,
367
+ sectionLabel: WorkflowCanvasNodeRenderer,
368
+ };
369
+ var canvasEdgeTypes = {
370
+ workflowMerge: WorkflowMergeEdge,
371
+ workflowSplit: WorkflowSplitEdge,
372
+ };
373
+ function pushGroupNode(ctx, id, label, tone, subset, workflowNode, nodeType) {
374
+ if (!subset.length) {
375
+ return undefined;
376
+ }
377
+ var bounds = subset.reduce(function (acc, node) {
378
+ var rect = getNodeRect(node);
379
+ return {
380
+ left: Math.min(acc.left, rect.left),
381
+ top: Math.min(acc.top, rect.top),
382
+ right: Math.max(acc.right, rect.right),
383
+ bottom: Math.max(acc.bottom, rect.bottom),
384
+ };
385
+ }, {
386
+ left: Number.POSITIVE_INFINITY,
387
+ top: Number.POSITIVE_INFINITY,
388
+ right: Number.NEGATIVE_INFINITY,
389
+ bottom: Number.NEGATIVE_INFINITY,
390
+ });
391
+ var paddingX = tone === "loop" ? DIMENSIONS.loopGroupPaddingX : DIMENSIONS.groupPaddingX;
392
+ var paddingTop = tone === "loop" ? DIMENSIONS.loopGroupPaddingTop : DIMENSIONS.groupPaddingTop;
393
+ var paddingBottom = tone === "loop" ? DIMENSIONS.loopGroupPaddingBottom : DIMENSIONS.groupPaddingBottom;
394
+ var groupTop = bounds.top - paddingTop;
395
+ var groupBottom = bounds.bottom + paddingBottom;
396
+ ctx.backgroundNodes.push({
397
+ id: id,
398
+ type: "group",
399
+ position: {
400
+ x: bounds.left - paddingX,
401
+ y: groupTop,
402
+ },
403
+ draggable: false,
404
+ selectable: false,
405
+ style: {
406
+ width: bounds.right - bounds.left + paddingX * 2,
407
+ height: bounds.bottom - bounds.top + paddingTop + paddingBottom,
408
+ zIndex: 0,
409
+ },
410
+ data: {
411
+ kind: "group",
412
+ label: label,
413
+ tone: tone,
414
+ workflowNode: workflowNode,
415
+ nodeType: nodeType,
416
+ onViewDocs: ctx.onViewDocs,
417
+ },
418
+ });
419
+ return {
420
+ top: groupTop,
421
+ bottom: groupBottom,
422
+ };
423
+ }
424
+ function pushInsertNode(ctx, id, x, y, target) {
425
+ var _a;
426
+ ctx.nodes.push({
427
+ id: id,
428
+ type: "insert",
429
+ position: {
430
+ x: x - DIMENSIONS.insertWidth / 2,
431
+ y: y,
432
+ },
433
+ draggable: false,
434
+ selectable: false,
435
+ style: {
436
+ zIndex: 5,
437
+ },
438
+ data: {
439
+ kind: "insert",
440
+ enabled: true,
441
+ selectedTypeLabel: (_a = ctx.activePaletteNodeType) === null || _a === void 0 ? void 0 : _a.label,
442
+ onInsert: function () { return ctx.onInsertNode(target); },
443
+ },
444
+ sourcePosition: Position.Bottom,
445
+ targetPosition: Position.Top,
446
+ });
447
+ }
448
+ function pushJunctionNode(ctx, id, x, y) {
449
+ ctx.nodes.push({
450
+ id: id,
451
+ type: "junction",
452
+ position: {
453
+ x: x - DIMENSIONS.junctionWidth / 2,
454
+ y: y - DIMENSIONS.junctionHeight / 2,
455
+ },
456
+ draggable: false,
457
+ selectable: false,
458
+ style: {
459
+ zIndex: 2,
460
+ },
461
+ data: {
462
+ kind: "junction",
463
+ },
464
+ sourcePosition: Position.Bottom,
465
+ targetPosition: Position.Top,
466
+ });
467
+ }
468
+ function pushWorkflowNode(ctx, workflowNode, x, y) {
469
+ var nodeType = ctx.nodeTypeMap.get(String(workflowNode.type));
470
+ ctx.nodes.push({
471
+ id: String(workflowNode.id),
472
+ type: "workflow",
473
+ position: { x: x, y: y },
474
+ draggable: false,
475
+ style: {
476
+ zIndex: 4,
477
+ },
478
+ data: {
479
+ kind: "workflow-node",
480
+ workflowNode: workflowNode,
481
+ nodeType: nodeType,
482
+ selected: ctx.selectedNodeId === String(workflowNode.id),
483
+ onSelectNode: ctx.onSelectNode,
484
+ onEditNode: ctx.onEditNode,
485
+ onDeleteNode: ctx.onDeleteNode,
486
+ onViewDocs: ctx.onViewDocs,
487
+ },
488
+ sourcePosition: Position.Bottom,
489
+ targetPosition: Position.Top,
490
+ });
491
+ }
492
+ function pushTriggerNode(ctx, trigger, x, y) {
493
+ ctx.nodes.push({
494
+ id: "trigger-".concat(String(trigger.id)),
495
+ type: "trigger",
496
+ position: { x: x, y: y },
497
+ draggable: false,
498
+ selectable: false,
499
+ style: {
500
+ zIndex: 4,
501
+ },
502
+ sourcePosition: Position.Bottom,
503
+ targetPosition: Position.Top,
504
+ data: {
505
+ kind: "workflow-trigger",
506
+ trigger: trigger,
507
+ selected: ctx.selectedTriggerId === String(trigger.id),
508
+ onSelectTrigger: ctx.onSelectTrigger,
509
+ onViewDocs: ctx.onViewTriggerDocs,
510
+ },
511
+ });
512
+ }
513
+ function pushSectionLabelNode(ctx, id, x, y, label) {
514
+ ctx.nodes.push({
515
+ id: id,
516
+ type: "sectionLabel",
517
+ position: { x: x, y: y },
518
+ draggable: false,
519
+ selectable: false,
520
+ style: {
521
+ zIndex: 5,
522
+ },
523
+ data: {
524
+ kind: "section-label",
525
+ label: label,
526
+ },
527
+ });
528
+ }
529
+ function buildSequenceGraph(sequence, ctx, laneX, startY, scope, options) {
530
+ var _a, _b, _c;
531
+ if (options === void 0) { options = {}; }
532
+ var cursorY = startY;
533
+ var maxWidth = DIMENSIONS.workflowWidth;
534
+ var indexOffset = (_a = options.indexOffset) !== null && _a !== void 0 ? _a : 0;
535
+ var idSuffix = options.idSuffix ? "-".concat(options.idSuffix) : "";
536
+ var boundaryInserts = (_b = options.boundaryInserts) !== null && _b !== void 0 ? _b : true;
537
+ var entryIds = [];
538
+ var previousExitIds = [];
539
+ if (boundaryInserts) {
540
+ var initialInsertId = "insert-".concat(JSON.stringify(scope), "-").concat(indexOffset).concat(idSuffix);
541
+ pushInsertNode(ctx, initialInsertId, laneX, cursorY, __assign(__assign({}, scope), { index: indexOffset }));
542
+ entryIds.push(initialInsertId);
543
+ previousExitIds = [initialInsertId];
544
+ }
545
+ var _loop_1 = function (index) {
546
+ var workflowNode = sequence[index];
547
+ var nodeType = ctx.nodeTypeMap.get(String(workflowNode.type));
548
+ var slotDefinitions = normalizeChildSlots(workflowNode, nodeType);
549
+ var isControlNode = (nodeType === null || nodeType === void 0 ? void 0 : nodeType.kind) === "control" || slotDefinitions.length > 0;
550
+ var estimatedNodeWidth = estimateWorkflowNodeWidth(workflowNode, ctx.nodeTypeMap, nodeType);
551
+ maxWidth = Math.max(maxWidth, estimatedNodeWidth);
552
+ var subtreeStartIndex = ctx.nodes.length;
553
+ var groupTone = isLoopNode(workflowNode, nodeType) ? "loop" : "control";
554
+ var controlTopPadding = groupTone === "loop" ? DIMENSIONS.loopGroupPaddingTop : DIMENSIONS.groupPaddingTop;
555
+ var nodeGap = isControlNode
556
+ ? controlTopPadding + DIMENSIONS.insertHeight + DIMENSIONS.groupExteriorEdgeGap
557
+ : DIMENSIONS.sequenceInsertToNodeGap;
558
+ cursorY += nodeGap;
559
+ pushWorkflowNode(ctx, workflowNode, laneX - DIMENSIONS.workflowWidth / 2, cursorY);
560
+ if (!entryIds.length) {
561
+ entryIds.push(String(workflowNode.id));
562
+ }
563
+ previousExitIds.forEach(function (sourceId) {
564
+ ctx.edges.push(createEdge(sourceId, String(workflowNode.id)));
565
+ });
566
+ var deepestY = cursorY;
567
+ var childStartY = cursorY + DIMENSIONS.workflowHeight + DIMENSIONS.controlNodeToChildGap;
568
+ var exitIds = [String(workflowNode.id)];
569
+ var usesMergeJunction = false;
570
+ var branchSlots = slotDefinitions.filter(function (slot) { return slot.key === "then" || slot.key === "else"; });
571
+ var caseEntries = slotDefinitions.some(function (slot) { return slot.kind === "case-collection"; })
572
+ ? getSwitchCaseEntries(workflowNode)
573
+ : [];
574
+ if (caseEntries.length > 0) {
575
+ var branchGap_1 = DIMENSIONS.controlBranchGap;
576
+ var branchWidths_1 = caseEntries.map(function (entry) {
577
+ return estimateSequenceWidth(entry.nodes, ctx.nodeTypeMap);
578
+ });
579
+ var totalBranchWidth = branchWidths_1.reduce(function (sum, width) { return sum + width; }, 0) +
580
+ branchGap_1 * Math.max(branchWidths_1.length - 1, 0);
581
+ var branchStartX_1 = laneX - totalBranchWidth / 2;
582
+ var branchLayouts = caseEntries.map(function (entry, branchIndex) {
583
+ var beforeWidth = branchWidths_1
584
+ .slice(0, branchIndex)
585
+ .reduce(function (sum, width) { return sum + width; }, 0);
586
+ var branchLaneX = branchStartX_1 +
587
+ beforeWidth +
588
+ branchGap_1 * branchIndex +
589
+ branchWidths_1[branchIndex] / 2;
590
+ var labelX = branchLaneX - DIMENSIONS.sectionLabelWidth / 2;
591
+ var labelY = childStartY - DIMENSIONS.controlBranchLabelGap;
592
+ pushSectionLabelNode(ctx, "".concat(workflowNode.id, "-").concat(entry.key, "-label"), labelX, labelY, entry.label);
593
+ var childLayout = buildSequenceGraph(entry.nodes, ctx, branchLaneX, childStartY, entry.scope);
594
+ childLayout.entryIds.forEach(function (entryId) {
595
+ ctx.edges.push(createEdge(String(workflowNode.id), entryId));
596
+ });
597
+ deepestY = Math.max(deepestY, childLayout.endY);
598
+ maxWidth = Math.max(maxWidth, childLayout.width);
599
+ return childLayout;
600
+ });
601
+ var branchExitIds = branchLayouts.flatMap(function (layout) { return layout.exitIds; });
602
+ exitIds = branchExitIds.length ? branchExitIds : [String(workflowNode.id)];
603
+ }
604
+ else if (branchSlots.length >= 2) {
605
+ var branchGap_2 = DIMENSIONS.controlBranchGap;
606
+ var branchWidths_2 = branchSlots.map(function (slot) {
607
+ return estimateSequenceWidth(Array.isArray(workflowNode[slot.key]) ? workflowNode[slot.key] : [], ctx.nodeTypeMap);
608
+ });
609
+ var totalBranchWidth = branchWidths_2.reduce(function (sum, width) { return sum + width; }, 0) +
610
+ branchGap_2 * Math.max(branchWidths_2.length - 1, 0);
611
+ var branchStartX_2 = laneX - totalBranchWidth / 2;
612
+ var branchLayouts = branchSlots.map(function (slot, branchIndex) {
613
+ var _a;
614
+ var slotKey = slot.key;
615
+ var childNodes = Array.isArray(workflowNode[slotKey]) ? workflowNode[slotKey] : [];
616
+ var beforeWidth = branchWidths_2
617
+ .slice(0, branchIndex)
618
+ .reduce(function (sum, width) { return sum + width; }, 0);
619
+ var branchLaneX = branchStartX_2 +
620
+ beforeWidth +
621
+ branchGap_2 * branchIndex +
622
+ branchWidths_2[branchIndex] / 2;
623
+ var labelX = branchLaneX - DIMENSIONS.sectionLabelWidth / 2;
624
+ var labelY = childStartY - DIMENSIONS.controlBranchLabelGap;
625
+ pushSectionLabelNode(ctx, "".concat(workflowNode.id, "-").concat(slotKey, "-label"), labelX, labelY, (_a = slot.label) !== null && _a !== void 0 ? _a : slotKey);
626
+ var childLayout = buildSequenceGraph(childNodes, ctx, branchLaneX, childStartY, {
627
+ scope: "slot",
628
+ parentNodeId: String(workflowNode.id),
629
+ slotKey: slotKey,
630
+ });
631
+ childLayout.entryIds.forEach(function (entryId) {
632
+ ctx.edges.push(createEdge(String(workflowNode.id), entryId));
633
+ });
634
+ deepestY = Math.max(deepestY, childLayout.endY);
635
+ maxWidth = Math.max(maxWidth, childLayout.width);
636
+ return childLayout;
637
+ });
638
+ var branchExitIds = branchLayouts.flatMap(function (layout) { return layout.exitIds; });
639
+ exitIds = branchExitIds.length ? branchExitIds : [String(workflowNode.id)];
640
+ }
641
+ else if (slotDefinitions.length === 1 && slotDefinitions[0].kind === "sequence") {
642
+ var slot = slotDefinitions[0];
643
+ var slotKey_1 = slot.key;
644
+ var childNodes_1 = getSequenceSlotNodes(workflowNode, slotKey_1);
645
+ if (slot.label && slotKey_1 !== "tasks") {
646
+ pushSectionLabelNode(ctx, "".concat(workflowNode.id, "-").concat(slotKey_1, "-label"), laneX - DIMENSIONS.sectionLabelWidth / 2, childStartY - DIMENSIONS.controlBranchLabelGap, slot.label);
647
+ }
648
+ if (slot.layout === "parallel") {
649
+ var childWidths_1 = childNodes_1.map(function (childNode) {
650
+ return estimateWorkflowNodeWidth(childNode, ctx.nodeTypeMap, ctx.nodeTypeMap.get(String(childNode.type)));
651
+ });
652
+ var totalChildWidth = childWidths_1.reduce(function (sum, width) { return sum + width; }, 0) +
653
+ DIMENSIONS.controlBranchGap * Math.max(childWidths_1.length - 1, 0);
654
+ var childStartX_1 = laneX - totalChildWidth / 2;
655
+ var collectionInsertId_1 = "insert-".concat(JSON.stringify({
656
+ scope: "slot",
657
+ parentNodeId: String(workflowNode.id),
658
+ slotKey: slotKey_1,
659
+ }), "-").concat(childNodes_1.length, "-").concat(workflowNode.id, "-").concat(slotKey_1, "-collection");
660
+ var collectionInsertY = cursorY +
661
+ DIMENSIONS.workflowHeight +
662
+ Math.round(DIMENSIONS.controlNodeToChildGap * 0.22);
663
+ pushInsertNode(ctx, collectionInsertId_1, laneX, collectionInsertY, {
664
+ scope: "slot",
665
+ parentNodeId: String(workflowNode.id),
666
+ slotKey: slotKey_1,
667
+ index: childNodes_1.length,
668
+ });
669
+ maxWidth = Math.max(maxWidth, totalChildWidth);
670
+ var splitJunctionY = cursorY +
671
+ DIMENSIONS.workflowHeight +
672
+ Math.round(DIMENSIONS.controlNodeToChildGap * 0.78);
673
+ var splitJunctionId_1 = "".concat(workflowNode.id, "-").concat(slotKey_1, "-split");
674
+ if (childNodes_1.length > 1) {
675
+ pushJunctionNode(ctx, splitJunctionId_1, laneX, splitJunctionY);
676
+ ctx.edges.push(createEdge(String(workflowNode.id), collectionInsertId_1));
677
+ ctx.edges.push(createEdge(collectionInsertId_1, splitJunctionId_1, { marker: false }));
678
+ deepestY = Math.max(deepestY, splitJunctionY);
679
+ }
680
+ else if (childNodes_1.length === 0) {
681
+ ctx.edges.push(createEdge(String(workflowNode.id), collectionInsertId_1));
682
+ exitIds = [collectionInsertId_1];
683
+ deepestY = Math.max(deepestY, collectionInsertY + DIMENSIONS.insertHeight);
684
+ }
685
+ var childLayouts = childNodes_1.map(function (childNode, childIndex) {
686
+ var beforeWidth = childWidths_1
687
+ .slice(0, childIndex)
688
+ .reduce(function (sum, width) { return sum + width; }, 0);
689
+ var childLaneX = childStartX_1 +
690
+ beforeWidth +
691
+ DIMENSIONS.controlBranchGap * childIndex +
692
+ childWidths_1[childIndex] / 2;
693
+ var childLayout = buildSequenceGraph([childNode], ctx, childLaneX, childStartY, {
694
+ scope: "slot",
695
+ parentNodeId: String(workflowNode.id),
696
+ slotKey: slotKey_1,
697
+ }, {
698
+ idSuffix: "".concat(workflowNode.id, "-").concat(slotKey_1, "-").concat(childIndex),
699
+ indexOffset: childIndex,
700
+ boundaryInserts: false,
701
+ });
702
+ childLayout.entryIds.forEach(function (entryId) {
703
+ if (childNodes_1.length > 1) {
704
+ ctx.edges.push(createEdge(splitJunctionId_1, entryId, {
705
+ kind: "split",
706
+ splitMode: "fromJunction",
707
+ }));
708
+ return;
709
+ }
710
+ ctx.edges.push(createEdge(String(workflowNode.id), collectionInsertId_1));
711
+ ctx.edges.push(createEdge(collectionInsertId_1, entryId));
712
+ });
713
+ deepestY = Math.max(deepestY, childLayout.endY);
714
+ maxWidth = Math.max(maxWidth, childLayout.width);
715
+ return childLayout;
716
+ });
717
+ var childExitIds = childLayouts.flatMap(function (layout) { return layout.exitIds; });
718
+ exitIds = childExitIds.length ? childExitIds : exitIds;
719
+ }
720
+ else {
721
+ var childLayout = buildSequenceGraph(childNodes_1, ctx, laneX, childStartY, {
722
+ scope: "slot",
723
+ parentNodeId: String(workflowNode.id),
724
+ slotKey: slotKey_1,
725
+ });
726
+ childLayout.entryIds.forEach(function (entryId) {
727
+ ctx.edges.push(createEdge(String(workflowNode.id), entryId));
728
+ });
729
+ deepestY = Math.max(deepestY, childLayout.endY);
730
+ maxWidth = Math.max(maxWidth, childLayout.width);
731
+ exitIds = childLayout.exitIds.length ? childLayout.exitIds : [String(workflowNode.id)];
732
+ }
733
+ }
734
+ if (isControlNode && exitIds.length > 1) {
735
+ var junctionY = Math.max(cursorY + DIMENSIONS.workflowHeight + DIMENSIONS.sequenceNodeToInsertGap, deepestY + DIMENSIONS.controlJoinGap);
736
+ var junctionId_1 = "junction-".concat(String(workflowNode.id));
737
+ pushJunctionNode(ctx, junctionId_1, laneX, junctionY);
738
+ exitIds.forEach(function (sourceId) {
739
+ ctx.edges.push(createEdge(sourceId, junctionId_1, { marker: false }));
740
+ });
741
+ exitIds = [junctionId_1];
742
+ deepestY = Math.max(deepestY, junctionY);
743
+ usesMergeJunction = true;
744
+ }
745
+ var groupBounds = isControlNode
746
+ ? pushGroupNode(ctx, "group-".concat(String(workflowNode.id)), (_c = workflowNode.name) !== null && _c !== void 0 ? _c : workflowNode.id, groupTone, ctx.nodes.slice(subtreeStartIndex), workflowNode, nodeType)
747
+ : undefined;
748
+ var nextInsertY = usesMergeJunction
749
+ ? deepestY + DIMENSIONS.sequenceNodeToInsertGap
750
+ : deepestY + (isControlNode ? DIMENSIONS.sequenceNodeToInsertGap : 0);
751
+ var afterGroupInsertY = groupBounds == null
752
+ ? nextInsertY
753
+ : groupBounds.bottom + DIMENSIONS.groupExteriorEdgeGap;
754
+ cursorY = Math.max(cursorY + DIMENSIONS.workflowHeight + DIMENSIONS.sequenceNodeToInsertGap, afterGroupInsertY);
755
+ if (boundaryInserts) {
756
+ var afterInsertIndex = indexOffset + index + 1;
757
+ var afterInsertId_1 = "insert-".concat(JSON.stringify(scope), "-").concat(afterInsertIndex, "-").concat(workflowNode.id).concat(idSuffix);
758
+ pushInsertNode(ctx, afterInsertId_1, laneX, cursorY, __assign(__assign({}, scope), { index: afterInsertIndex }));
759
+ exitIds.forEach(function (sourceId) {
760
+ ctx.edges.push(createEdge(sourceId, afterInsertId_1));
761
+ });
762
+ previousExitIds = [afterInsertId_1];
763
+ }
764
+ else {
765
+ previousExitIds = exitIds;
766
+ }
767
+ };
768
+ for (var index = 0; index < sequence.length; index += 1) {
769
+ _loop_1(index);
770
+ }
771
+ return {
772
+ entryIds: entryIds.length ? entryIds : previousExitIds,
773
+ exitIds: previousExitIds,
774
+ endY: cursorY,
775
+ width: maxWidth,
776
+ };
777
+ }
778
+ function buildGraph(definition, nodeTypes, props) {
779
+ var _a, _b;
780
+ var ctx = {
781
+ backgroundNodes: [],
782
+ nodes: [],
783
+ edges: [],
784
+ nodeTypeMap: new Map(nodeTypes.map(function (item) { return [item.type, item]; })),
785
+ activePaletteNodeType: props.activePaletteNodeType,
786
+ selectedNodeId: props.selectedNodeId,
787
+ selectedTriggerId: props.selectedTriggerId,
788
+ onSelectNode: props.onSelectNode,
789
+ onSelectTrigger: props.onSelectTrigger,
790
+ onEditNode: props.onEditNode,
791
+ onDeleteNode: props.onDeleteNode,
792
+ onViewDocs: props.onViewDocs,
793
+ onViewTriggerDocs: props.onViewTriggerDocs,
794
+ onInsertNode: props.onInsertNode,
795
+ };
796
+ var triggers = Array.isArray(definition.triggers) ? definition.triggers : [];
797
+ var rootLaneX = 80;
798
+ var startY = 0;
799
+ var previousTriggerId = null;
800
+ if (triggers.length) {
801
+ var triggerStartIndex = ctx.nodes.length;
802
+ var triggerY_1 = 60;
803
+ triggers.forEach(function (trigger) {
804
+ var triggerNodeId = "trigger-".concat(String(trigger.id));
805
+ pushTriggerNode(ctx, trigger, rootLaneX - DIMENSIONS.triggerWidth / 2, triggerY_1);
806
+ if (previousTriggerId) {
807
+ ctx.edges.push(createEdge(previousTriggerId, triggerNodeId));
808
+ }
809
+ previousTriggerId = triggerNodeId;
810
+ triggerY_1 += DIMENSIONS.triggerHeight + DIMENSIONS.triggerGap;
811
+ });
812
+ var triggerGroupBounds = pushGroupNode(ctx, "group-triggers", "Triggers", "trigger", ctx.nodes.slice(triggerStartIndex));
813
+ startY =
814
+ ((_a = triggerGroupBounds === null || triggerGroupBounds === void 0 ? void 0 : triggerGroupBounds.bottom) !== null && _a !== void 0 ? _a : triggerY_1) + DIMENSIONS.groupExteriorEdgeGap;
815
+ }
816
+ var layout = buildSequenceGraph((_b = definition.nodes) !== null && _b !== void 0 ? _b : [], ctx, rootLaneX, startY, { scope: "root" });
817
+ if (previousTriggerId) {
818
+ var triggerSourceId_1 = previousTriggerId;
819
+ layout.entryIds.forEach(function (entryId) {
820
+ ctx.edges.push(createEdge(triggerSourceId_1, entryId));
821
+ });
822
+ }
823
+ return {
824
+ nodes: __spreadArray(__spreadArray([], ctx.backgroundNodes, true), ctx.nodes, true),
825
+ edges: ctx.edges,
826
+ };
827
+ }
828
+ function WorkflowFlowCanvasInner(props) {
829
+ var graph = React.useMemo(function () {
830
+ return buildGraph(props.definition, props.nodeTypes, {
831
+ selectedNodeId: props.selectedNodeId,
832
+ selectedTriggerId: props.selectedTriggerId,
833
+ activePaletteNodeType: props.activePaletteNodeType,
834
+ onSelectNode: props.onSelectNode,
835
+ onSelectTrigger: props.onSelectTrigger,
836
+ onEditNode: props.onEditNode,
837
+ onDeleteNode: props.onDeleteNode,
838
+ onViewDocs: props.onViewDocs,
839
+ onViewTriggerDocs: props.onViewTriggerDocs,
840
+ onInsertNode: props.onInsertNode,
841
+ });
842
+ }, [
843
+ props.activePaletteNodeType,
844
+ props.definition,
845
+ props.nodeTypes,
846
+ props.onDeleteNode,
847
+ props.onEditNode,
848
+ props.onInsertNode,
849
+ props.onSelectNode,
850
+ props.onSelectTrigger,
851
+ props.onViewDocs,
852
+ props.onViewTriggerDocs,
853
+ props.selectedNodeId,
854
+ props.selectedTriggerId,
855
+ ]);
856
+ return (_jsx("div", { className: "workflow-flow-canvas", children: _jsxs(ReactFlow, { nodes: graph.nodes, edges: graph.edges, nodeTypes: canvasNodeTypes, edgeTypes: canvasEdgeTypes, defaultViewport: DEFAULT_WORKFLOW_VIEWPORT, minZoom: 0.25, maxZoom: 1.6, proOptions: { hideAttribution: true }, defaultEdgeOptions: { zIndex: 1 }, nodesDraggable: false, nodesConnectable: false, elementsSelectable: true, panOnDrag: true, zoomOnDoubleClick: false, children: [_jsx(Controls, { showInteractive: false }), _jsx(Background, { variant: BackgroundVariant.Dots, gap: 18, size: 1.45, color: "rgba(148, 163, 184, 0.34)" })] }) }));
857
+ }
858
+ export function WorkflowFlowCanvas(props) {
859
+ return (_jsx(ReactFlowProvider, { children: _jsx(WorkflowFlowCanvasInner, __assign({}, props)) }));
860
+ }
861
+ //# sourceMappingURL=WorkflowFlowCanvas.js.map