@solidxai/core-ui 0.1.13-beta.6 → 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,1107 @@
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, Fragment as _Fragment } from "react/jsx-runtime";
22
+ import React from "react";
23
+ import { createPortal } from "react-dom";
24
+ import YAML from "yaml";
25
+ import { ArrowLeft, CircleHelp, Filter, GitBranch, Plus, Search, Trash2, Workflow, X, Zap, } from "lucide-react";
26
+ import { getExtensionComponent } from "../../helpers/registry";
27
+ import { SolidButton, SolidCodeEditor, SolidDialog, SolidDialogBody, SolidDialogFooter, SolidInput, SolidNumberInput, SolidSelect, SolidSwitch, SolidTabGroup, SolidTag, SolidTextarea, SolidTooltip, SolidTooltipContent, SolidTooltipTrigger, SolidIcon, normalizeSolidIconName, } from "../shad-cn-ui";
28
+ import "./WorkflowNodeSchemaEditor.css";
29
+ var EMPTY_YAML_OBJECT = {};
30
+ var EMPTY_YAML_ARRAY = [];
31
+ function normalizeFieldValue(field, currentValue) {
32
+ if (currentValue !== undefined) {
33
+ return currentValue;
34
+ }
35
+ return field.defaultValue;
36
+ }
37
+ function stringifyYamlEditorValue(value, emptyValue) {
38
+ if (typeof value === "string") {
39
+ return value;
40
+ }
41
+ return YAML.stringify(value !== null && value !== void 0 ? value : emptyValue);
42
+ }
43
+ function stringifyJsonEditorValue(value, emptyValue) {
44
+ if (typeof value === "string") {
45
+ return value;
46
+ }
47
+ return JSON.stringify(value !== null && value !== void 0 ? value : emptyValue, null, 2);
48
+ }
49
+ function getYamlValueSignature(value) {
50
+ try {
51
+ return JSON.stringify(value);
52
+ }
53
+ catch (_a) {
54
+ return String(value);
55
+ }
56
+ }
57
+ function getPathValue(value, pathOrKey) {
58
+ return pathOrKey
59
+ .split(".")
60
+ .reduce(function (current, part) { return current === null || current === void 0 ? void 0 : current[part]; }, value);
61
+ }
62
+ function setPathValue(value, pathOrKey, nextValue) {
63
+ var _a;
64
+ var parts = pathOrKey.split(".");
65
+ if (parts.length === 1) {
66
+ return __assign(__assign({}, value), (_a = {}, _a[pathOrKey] = nextValue, _a));
67
+ }
68
+ var nextRoot = __assign({}, value);
69
+ var cursor = nextRoot;
70
+ parts.forEach(function (part, index) {
71
+ if (index === parts.length - 1) {
72
+ cursor[part] = nextValue;
73
+ return;
74
+ }
75
+ var existing = cursor[part];
76
+ cursor[part] =
77
+ existing && typeof existing === "object" && !Array.isArray(existing)
78
+ ? __assign({}, existing) : {};
79
+ cursor = cursor[part];
80
+ });
81
+ return nextRoot;
82
+ }
83
+ function getSlotCount(node, slot) {
84
+ var _a;
85
+ if (slot.kind === "case-collection") {
86
+ return Object.keys((_a = node.cases) !== null && _a !== void 0 ? _a : {}).length;
87
+ }
88
+ var value = node[slot.key];
89
+ return Array.isArray(value) ? value.length : 0;
90
+ }
91
+ function hasRuntimeFields(nodeType) {
92
+ var authoring = nodeType.authoring;
93
+ return Boolean((authoring === null || authoring === void 0 ? void 0 : authoring.supportsDisableToggle) ||
94
+ (authoring === null || authoring === void 0 ? void 0 : authoring.supportsTimeoutMs) ||
95
+ (authoring === null || authoring === void 0 ? void 0 : authoring.supportsOnError) ||
96
+ (authoring === null || authoring === void 0 ? void 0 : authoring.supportsRetryPolicy));
97
+ }
98
+ function getNodeTypeIconName(nodeType) {
99
+ var _a, _b;
100
+ return (_b = (_a = nodeType.ui) === null || _a === void 0 ? void 0 : _a.icon) !== null && _b !== void 0 ? _b : nodeType.icon;
101
+ }
102
+ function WorkflowNodeTypeIcon(_a) {
103
+ var nodeType = _a.nodeType, _b = _a.size, size = _b === void 0 ? 18 : _b;
104
+ var iconName = getNodeTypeIconName(nodeType);
105
+ var normalizedIconName = normalizeSolidIconName(iconName);
106
+ if (normalizedIconName) {
107
+ return _jsx(SolidIcon, { name: normalizedIconName, size: size, "aria-hidden": true });
108
+ }
109
+ if (nodeType.kind === "control") {
110
+ return _jsx(GitBranch, { size: size, strokeWidth: 1.9 });
111
+ }
112
+ if (nodeType.kind === "subflow") {
113
+ return _jsx(Workflow, { size: size, strokeWidth: 1.9 });
114
+ }
115
+ return _jsx(Zap, { size: size, strokeWidth: 1.9 });
116
+ }
117
+ function getWorkflowNodeIconStyle(nodeType) {
118
+ var _a, _b, _c;
119
+ var backgroundColor = (_a = nodeType.ui) === null || _a === void 0 ? void 0 : _a.iconBackgroundColor;
120
+ var color = (_b = nodeType.ui) === null || _b === void 0 ? void 0 : _b.iconColor;
121
+ var borderColor = (_c = nodeType.ui) === null || _c === void 0 ? void 0 : _c.iconBorderColor;
122
+ if (!backgroundColor && !color && !borderColor) {
123
+ return undefined;
124
+ }
125
+ return __assign(__assign(__assign({}, (backgroundColor ? { backgroundColor: backgroundColor } : null)), (color ? { color: color } : null)), (borderColor ? { borderColor: borderColor } : null));
126
+ }
127
+ function normalizeGroupLabel(value, fallback) {
128
+ var trimmed = value === null || value === void 0 ? void 0 : value.trim();
129
+ return trimmed || fallback;
130
+ }
131
+ function getNodeTypeSearchText(nodeType) {
132
+ var _a, _b, _c;
133
+ return __spreadArray(__spreadArray([
134
+ nodeType.type,
135
+ nodeType.kind,
136
+ nodeType.label,
137
+ nodeType.description,
138
+ nodeType.category,
139
+ nodeType.subcategory
140
+ ], ((_a = nodeType.tags) !== null && _a !== void 0 ? _a : []), true), ((_c = (_b = nodeType.authoring) === null || _b === void 0 ? void 0 : _b.searchableText) !== null && _c !== void 0 ? _c : []), true).filter(Boolean)
141
+ .join(" ")
142
+ .toLowerCase();
143
+ }
144
+ function createSelectOptions(values, allLabel) {
145
+ return __spreadArray([
146
+ { label: allLabel, value: "" }
147
+ ], values
148
+ .filter(Boolean)
149
+ .sort(function (a, b) { return a.localeCompare(b); })
150
+ .map(function (value) { return ({ label: value, value: value }); }), true);
151
+ }
152
+ function isConfigurationFieldVisible(field, draft) {
153
+ var _a, _b;
154
+ var visibleWhen = (_a = field.uiSchema) === null || _a === void 0 ? void 0 : _a.visibleWhen;
155
+ if (!visibleWhen) {
156
+ return true;
157
+ }
158
+ var dependencyPath = (_b = visibleWhen.path) !== null && _b !== void 0 ? _b : visibleWhen.field;
159
+ if (!dependencyPath) {
160
+ return true;
161
+ }
162
+ var dependencyValue = getPathValue(draft, dependencyPath);
163
+ if ("equals" in visibleWhen) {
164
+ return dependencyValue === visibleWhen.equals;
165
+ }
166
+ if ("notEquals" in visibleWhen) {
167
+ return dependencyValue !== visibleWhen.notEquals;
168
+ }
169
+ if (Array.isArray(visibleWhen.includes)) {
170
+ return visibleWhen.includes.includes(dependencyValue);
171
+ }
172
+ return true;
173
+ }
174
+ function getConfigurationFieldWidth(field) {
175
+ var _a, _b;
176
+ var width = (_b = (_a = field.uiSchema) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.width;
177
+ return width === "full" || width === "field" ? width : "half";
178
+ }
179
+ function normalizeCssLength(value) {
180
+ if (typeof value === "number" && Number.isFinite(value)) {
181
+ return "".concat(value, "px");
182
+ }
183
+ if (typeof value === "string" && value.trim()) {
184
+ return value;
185
+ }
186
+ return undefined;
187
+ }
188
+ function getConfigurationFieldEditorHeight(field, fallback) {
189
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
190
+ if (fallback === void 0) { fallback = "220px"; }
191
+ return ((_j = (_f = (_c = normalizeCssLength((_b = (_a = field.uiSchema) === null || _a === void 0 ? void 0 : _a.editor) === null || _b === void 0 ? void 0 : _b.height)) !== null && _c !== void 0 ? _c : normalizeCssLength((_e = (_d = field.uiSchema) === null || _d === void 0 ? void 0 : _d.layout) === null || _e === void 0 ? void 0 : _e.height)) !== null && _f !== void 0 ? _f : normalizeCssLength((_h = (_g = field.uiSchema) === null || _g === void 0 ? void 0 : _g.layout) === null || _h === void 0 ? void 0 : _h.minHeight)) !== null && _j !== void 0 ? _j : fallback);
192
+ }
193
+ function getWorkflowNodeEditorDialogStyle(nodeType) {
194
+ var _a, _b;
195
+ var modalSize = (_b = (_a = nodeType.ui) === null || _a === void 0 ? void 0 : _a.modalSize) !== null && _b !== void 0 ? _b : "lg";
196
+ if (modalSize === "full") {
197
+ return {
198
+ width: "96vw",
199
+ maxWidth: "96vw",
200
+ height: "92vh",
201
+ maxHeight: "92vh",
202
+ };
203
+ }
204
+ if (modalSize === "xl") {
205
+ return {
206
+ width: "min(1240px, 94vw)",
207
+ maxWidth: "94vw",
208
+ height: "min(880px, 90vh)",
209
+ maxHeight: "90vh",
210
+ };
211
+ }
212
+ return {
213
+ width: "min(780px, 92vw)",
214
+ maxWidth: "92vw",
215
+ maxHeight: "90vh",
216
+ };
217
+ }
218
+ function getFieldHintItems(field) {
219
+ return [
220
+ field.valueType ? { key: "valueType", label: field.valueType } : null,
221
+ field.required ? { key: "required", label: "required", tone: "warn" } : null,
222
+ field.expressionAllowed ? { key: "expressions", label: "expressions" } : null,
223
+ field.secretAllowed ? { key: "secret", label: "secret", tone: "success" } : null,
224
+ ].filter(Boolean);
225
+ }
226
+ function WorkflowFieldHelp(_a) {
227
+ var _b;
228
+ var field = _a.field;
229
+ var hintItems = getFieldHintItems(field);
230
+ if (!field.description && !hintItems.length) {
231
+ return null;
232
+ }
233
+ return (_jsxs(SolidTooltip, { delayDuration: 120, children: [_jsx(SolidTooltipTrigger, { asChild: true, children: _jsx("button", { type: "button", className: "workflow-node-editor-help-trigger", "aria-label": "".concat((_b = field.label) !== null && _b !== void 0 ? _b : field.key, " help"), children: _jsx(CircleHelp, { size: 13 }) }) }), _jsxs(SolidTooltipContent, { side: "top", align: "end", className: "workflow-node-editor-help-tooltip", children: [field.description ? (_jsxs("div", { className: "workflow-node-editor-help-section", children: [_jsx("div", { className: "workflow-node-editor-help-title", children: "Help" }), _jsx("div", { className: "workflow-node-editor-help-copy", children: field.description })] })) : null, hintItems.length ? (_jsxs("div", { className: "workflow-node-editor-help-section", children: [_jsx("div", { className: "workflow-node-editor-help-title", children: "Allowed" }), _jsx("div", { className: "workflow-node-editor-help-pills", children: hintItems.map(function (item) { return (_jsx(SolidTag, { tone: item.tone, children: item.label }, item.key)); }) })] })) : null] })] }));
234
+ }
235
+ function normalizeKeyValueRows(value) {
236
+ if (Array.isArray(value)) {
237
+ return value.map(function (item) {
238
+ var _a, _b, _c;
239
+ return ({
240
+ key: String((_b = (_a = item === null || item === void 0 ? void 0 : item.key) !== null && _a !== void 0 ? _a : item === null || item === void 0 ? void 0 : item.name) !== null && _b !== void 0 ? _b : ""),
241
+ value: (_c = item === null || item === void 0 ? void 0 : item.value) !== null && _c !== void 0 ? _c : "",
242
+ });
243
+ });
244
+ }
245
+ if (value && typeof value === "object") {
246
+ return Object.entries(value).map(function (_a) {
247
+ var key = _a[0], rowValue = _a[1];
248
+ return ({
249
+ key: key,
250
+ value: rowValue === undefined || rowValue === null
251
+ ? ""
252
+ : typeof rowValue === "string"
253
+ ? rowValue
254
+ : YAML.stringify(rowValue).trim(),
255
+ });
256
+ });
257
+ }
258
+ return [];
259
+ }
260
+ function rowsToKeyValueObject(rows) {
261
+ return rows.reduce(function (acc, row) {
262
+ var key = row.key.trim();
263
+ if (!key) {
264
+ return acc;
265
+ }
266
+ acc[key] = row.value;
267
+ return acc;
268
+ }, {});
269
+ }
270
+ function keyValueRowsSignature(rows) {
271
+ return JSON.stringify(rowsToKeyValueObject(rows));
272
+ }
273
+ function WorkflowKeyValueEditor(_a) {
274
+ var value = _a.value, readOnly = _a.readOnly, onChange = _a.onChange;
275
+ var normalizedRows = normalizeKeyValueRows(value);
276
+ var _b = React.useState(normalizedRows.length ? normalizedRows : [{ key: "", value: "" }]), rows = _b[0], setRows = _b[1];
277
+ var lastEmittedSignatureRef = React.useRef(keyValueRowsSignature(normalizedRows));
278
+ React.useEffect(function () {
279
+ var nextRows = normalizeKeyValueRows(value);
280
+ var nextSignature = keyValueRowsSignature(nextRows);
281
+ if (nextSignature === lastEmittedSignatureRef.current) {
282
+ return;
283
+ }
284
+ setRows(nextRows.length ? nextRows : [{ key: "", value: "" }]);
285
+ lastEmittedSignatureRef.current = nextSignature;
286
+ }, [value]);
287
+ var emitRows = function (nextRows) {
288
+ var nextValue = rowsToKeyValueObject(nextRows);
289
+ lastEmittedSignatureRef.current = JSON.stringify(nextValue);
290
+ onChange(nextValue);
291
+ };
292
+ var updateRow = function (index, patch) {
293
+ var nextRows = rows.map(function (row, rowIndex) {
294
+ return rowIndex === index ? __assign(__assign({}, row), patch) : row;
295
+ });
296
+ setRows(nextRows);
297
+ emitRows(nextRows);
298
+ };
299
+ var removeRow = function (index) {
300
+ var nextRows = rows.filter(function (_, rowIndex) { return rowIndex !== index; });
301
+ var displayRows = nextRows.length ? nextRows : [{ key: "", value: "" }];
302
+ setRows(displayRows);
303
+ emitRows(displayRows);
304
+ };
305
+ var addRow = function () {
306
+ setRows(__spreadArray(__spreadArray([], rows, true), [{ key: "", value: "" }], false));
307
+ };
308
+ return (_jsxs("div", { className: "workflow-node-key-value-editor", children: [_jsxs("div", { className: "workflow-node-key-value-header", children: [_jsx("span", { children: "Key" }), _jsx("span", { children: "Value" }), _jsx("span", {})] }), rows.map(function (row, index) {
309
+ var _a;
310
+ return (_jsxs("div", { className: "workflow-node-key-value-row", children: [_jsx(SolidInput, { value: row.key, disabled: readOnly, placeholder: "key", onChange: function (event) { return updateRow(index, { key: event.target.value }); } }), _jsx(SolidInput, { value: (_a = row.value) !== null && _a !== void 0 ? _a : "", disabled: readOnly, placeholder: "value", onChange: function (event) { return updateRow(index, { value: event.target.value }); } }), _jsx("button", { type: "button", className: "workflow-node-key-value-action", disabled: readOnly || rows.length === 1, "aria-label": "Remove row", onClick: function () { return removeRow(index); }, children: _jsx(Trash2, { size: 14 }) })] }, "".concat(row.key || "row", "-").concat(index)));
311
+ }), _jsxs("button", { type: "button", className: "workflow-node-key-value-add", disabled: readOnly, onClick: addRow, children: [_jsx(Plus, { size: 14 }), "Add row"] })] }));
312
+ }
313
+ function WorkflowYamlFieldEditor(_a) {
314
+ var value = _a.value, readOnly = _a.readOnly, onChange = _a.onChange, _b = _a.emptyValue, emptyValue = _b === void 0 ? {} : _b, _c = _a.format, format = _c === void 0 ? "yaml" : _c, _d = _a.height, height = _d === void 0 ? "220px" : _d;
315
+ var stringifyValue = React.useCallback(function (nextValue, nextEmptyValue) {
316
+ return format === "json"
317
+ ? stringifyJsonEditorValue(nextValue, nextEmptyValue)
318
+ : stringifyYamlEditorValue(nextValue, nextEmptyValue);
319
+ }, [format]);
320
+ var _e = React.useState(function () {
321
+ return stringifyValue(value, emptyValue);
322
+ }), textValue = _e[0], setTextValue = _e[1];
323
+ var _f = React.useState(null), parseError = _f[0], setParseError = _f[1];
324
+ var lastEmittedSignatureRef = React.useRef(getYamlValueSignature(value !== null && value !== void 0 ? value : emptyValue));
325
+ React.useEffect(function () {
326
+ var nextSignature = getYamlValueSignature(value !== null && value !== void 0 ? value : emptyValue);
327
+ if (nextSignature === lastEmittedSignatureRef.current) {
328
+ return;
329
+ }
330
+ setTextValue(stringifyValue(value, emptyValue));
331
+ setParseError(null);
332
+ lastEmittedSignatureRef.current = nextSignature;
333
+ }, [emptyValue, stringifyValue, value]);
334
+ var handleEditorChange = function (nextText) {
335
+ var _a;
336
+ var safeText = nextText !== null && nextText !== void 0 ? nextText : "";
337
+ setTextValue(safeText);
338
+ try {
339
+ var parsedValue = safeText.trim()
340
+ ? format === "json"
341
+ ? JSON.parse(safeText)
342
+ : YAML.parse(safeText)
343
+ : emptyValue;
344
+ setParseError(null);
345
+ lastEmittedSignatureRef.current = getYamlValueSignature(parsedValue);
346
+ onChange(parsedValue);
347
+ }
348
+ catch (error) {
349
+ setParseError((_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : "".concat(format.toUpperCase(), " is invalid."));
350
+ }
351
+ };
352
+ return (_jsxs("div", { className: "workflow-node-yaml-field-editor", children: [_jsx(SolidCodeEditor, { language: format, height: height, fontSize: 12, readOnly: readOnly, value: textValue, onChange: handleEditorChange }), parseError ? (_jsx("div", { className: "workflow-node-yaml-field-error", children: parseError })) : null] }));
353
+ }
354
+ function stringifyRecipientListValue(value) {
355
+ if (Array.isArray(value)) {
356
+ return value.join(", ");
357
+ }
358
+ if (value === undefined || value === null) {
359
+ return "";
360
+ }
361
+ return String(value);
362
+ }
363
+ function parseRecipientListValue(value) {
364
+ var trimmedValue = value.trim();
365
+ if (!trimmedValue) {
366
+ return [];
367
+ }
368
+ if (/^\{\{[\s\S]*\}\}$/.test(trimmedValue)) {
369
+ return trimmedValue;
370
+ }
371
+ var recipients = trimmedValue
372
+ .split(",")
373
+ .map(function (recipient) { return recipient.trim(); })
374
+ .filter(Boolean);
375
+ return recipients.length <= 1 ? trimmedValue : recipients;
376
+ }
377
+ function WorkflowRecipientListFieldEditor(_a) {
378
+ var value = _a.value, readOnly = _a.readOnly, placeholder = _a.placeholder, expressionSuggestions = _a.expressionSuggestions, onChange = _a.onChange;
379
+ var _b = React.useState(function () {
380
+ return stringifyRecipientListValue(value);
381
+ }), textValue = _b[0], setTextValue = _b[1];
382
+ var lastValueSignatureRef = React.useRef(getYamlValueSignature(value));
383
+ React.useEffect(function () {
384
+ var nextSignature = getYamlValueSignature(value);
385
+ if (nextSignature === lastValueSignatureRef.current) {
386
+ return;
387
+ }
388
+ setTextValue(stringifyRecipientListValue(value));
389
+ lastValueSignatureRef.current = nextSignature;
390
+ }, [value]);
391
+ var emitChange = function (nextValue) {
392
+ setTextValue(nextValue);
393
+ var parsedValue = parseRecipientListValue(nextValue);
394
+ lastValueSignatureRef.current = getYamlValueSignature(parsedValue);
395
+ onChange(parsedValue);
396
+ };
397
+ return (_jsx(WorkflowExpressionAutocompleteField, { value: textValue, readOnly: readOnly, placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : "{{ item.email }}", suggestions: expressionSuggestions, onChange: emitChange }));
398
+ }
399
+ function getExpressionSearchTerm(value, caretIndex) {
400
+ var _a;
401
+ var prefix = value.slice(0, caretIndex);
402
+ var expressionStart = prefix.lastIndexOf("{{");
403
+ if (expressionStart >= 0 && prefix.lastIndexOf("}}") < expressionStart) {
404
+ return prefix.slice(expressionStart + 2).trim();
405
+ }
406
+ var wordMatch = prefix.match(/[A-Za-z0-9_.-]*$/);
407
+ return (_a = wordMatch === null || wordMatch === void 0 ? void 0 : wordMatch[0]) !== null && _a !== void 0 ? _a : "";
408
+ }
409
+ function insertExpressionAtCaret(value, caretIndex, insertText) {
410
+ var prefix = value.slice(0, caretIndex);
411
+ var suffix = value.slice(caretIndex);
412
+ var expressionStart = prefix.lastIndexOf("{{");
413
+ var expressionEndInSuffix = suffix.indexOf("}}");
414
+ if (expressionStart >= 0 && prefix.lastIndexOf("}}") < expressionStart) {
415
+ var endIndex = expressionEndInSuffix >= 0
416
+ ? caretIndex + expressionEndInSuffix + 2
417
+ : caretIndex;
418
+ return {
419
+ value: "".concat(value.slice(0, expressionStart)).concat(insertText).concat(value.slice(endIndex)),
420
+ caretIndex: expressionStart + insertText.length,
421
+ };
422
+ }
423
+ var wordMatch = prefix.match(/[A-Za-z0-9_.-]*$/);
424
+ var replaceStart = wordMatch ? caretIndex - wordMatch[0].length : caretIndex;
425
+ var spacerBefore = replaceStart > 0 && !/\s/.test(value.charAt(replaceStart - 1)) ? " " : "";
426
+ var spacerAfter = suffix && !/^\s/.test(suffix) ? " " : "";
427
+ var replacement = "".concat(spacerBefore).concat(insertText).concat(spacerAfter);
428
+ return {
429
+ value: "".concat(value.slice(0, replaceStart)).concat(replacement).concat(suffix),
430
+ caretIndex: replaceStart + spacerBefore.length + insertText.length,
431
+ };
432
+ }
433
+ function getWorkflowAutocompletePortalPosition(anchor) {
434
+ if (!anchor || typeof window === "undefined") {
435
+ return null;
436
+ }
437
+ var rect = anchor.getBoundingClientRect();
438
+ var viewportWidth = window.innerWidth;
439
+ var viewportHeight = window.innerHeight;
440
+ var gutter = 12;
441
+ var offset = 6;
442
+ var preferredWidth = Math.max(rect.width, 420);
443
+ var width = Math.min(preferredWidth, viewportWidth - gutter * 2);
444
+ var left = Math.min(Math.max(rect.left, gutter), Math.max(viewportWidth - width - gutter, gutter));
445
+ var spaceBelow = viewportHeight - rect.bottom - gutter;
446
+ var spaceAbove = rect.top - gutter;
447
+ var renderAbove = spaceBelow < 220 && spaceAbove > spaceBelow;
448
+ var availableHeight = Math.max(160, Math.min(320, renderAbove ? spaceAbove - offset : spaceBelow - offset));
449
+ return {
450
+ left: left,
451
+ top: renderAbove
452
+ ? Math.max(gutter, rect.top - offset - availableHeight)
453
+ : Math.min(viewportHeight - gutter - availableHeight, rect.bottom + offset),
454
+ width: width,
455
+ maxHeight: availableHeight,
456
+ };
457
+ }
458
+ export function WorkflowExpressionAutocompleteField(_a) {
459
+ var value = _a.value, readOnly = _a.readOnly, multiline = _a.multiline, placeholder = _a.placeholder, _b = _a.suggestions, suggestions = _b === void 0 ? [] : _b, onChange = _a.onChange;
460
+ var inputRef = React.useRef(null);
461
+ var _c = React.useState(false), open = _c[0], setOpen = _c[1];
462
+ var _d = React.useState(""), query = _d[0], setQuery = _d[1];
463
+ var _e = React.useState(0), activeIndex = _e[0], setActiveIndex = _e[1];
464
+ var _f = React.useState(null), portalPosition = _f[0], setPortalPosition = _f[1];
465
+ var filteredSuggestions = React.useMemo(function () {
466
+ var normalizedQuery = query.trim().toLowerCase();
467
+ if (!normalizedQuery) {
468
+ return suggestions;
469
+ }
470
+ return suggestions.filter(function (suggestion) {
471
+ return [
472
+ suggestion.group,
473
+ suggestion.label,
474
+ suggestion.insertText,
475
+ suggestion.detail,
476
+ suggestion.description,
477
+ ]
478
+ .filter(Boolean)
479
+ .some(function (entry) { return String(entry).toLowerCase().includes(normalizedQuery); });
480
+ });
481
+ }, [query, suggestions]);
482
+ React.useEffect(function () {
483
+ setActiveIndex(0);
484
+ }, [query]);
485
+ var updatePortalPosition = React.useCallback(function () {
486
+ setPortalPosition(getWorkflowAutocompletePortalPosition(inputRef.current));
487
+ }, []);
488
+ React.useLayoutEffect(function () {
489
+ if (!open) {
490
+ setPortalPosition(null);
491
+ return;
492
+ }
493
+ updatePortalPosition();
494
+ }, [open, updatePortalPosition, value, filteredSuggestions.length]);
495
+ React.useEffect(function () {
496
+ if (!open || typeof window === "undefined") {
497
+ return;
498
+ }
499
+ window.addEventListener("resize", updatePortalPosition);
500
+ window.addEventListener("scroll", updatePortalPosition, true);
501
+ return function () {
502
+ window.removeEventListener("resize", updatePortalPosition);
503
+ window.removeEventListener("scroll", updatePortalPosition, true);
504
+ };
505
+ }, [open, updatePortalPosition]);
506
+ var openPicker = function () {
507
+ var _a;
508
+ var input = inputRef.current;
509
+ var caretIndex = (_a = input === null || input === void 0 ? void 0 : input.selectionStart) !== null && _a !== void 0 ? _a : value.length;
510
+ setQuery(getExpressionSearchTerm(value, caretIndex));
511
+ setPortalPosition(getWorkflowAutocompletePortalPosition(input));
512
+ setOpen(true);
513
+ };
514
+ var closePicker = function () {
515
+ setOpen(false);
516
+ setQuery("");
517
+ setActiveIndex(0);
518
+ setPortalPosition(null);
519
+ };
520
+ var selectSuggestion = function (suggestion) {
521
+ var _a;
522
+ var input = inputRef.current;
523
+ var caretIndex = (_a = input === null || input === void 0 ? void 0 : input.selectionStart) !== null && _a !== void 0 ? _a : value.length;
524
+ var next = insertExpressionAtCaret(value, caretIndex, suggestion.insertText);
525
+ onChange(next.value);
526
+ closePicker();
527
+ window.requestAnimationFrame(function () {
528
+ input === null || input === void 0 ? void 0 : input.focus();
529
+ input === null || input === void 0 ? void 0 : input.setSelectionRange(next.caretIndex, next.caretIndex);
530
+ });
531
+ };
532
+ var handleKeyDown = function (event) {
533
+ if (event.ctrlKey && event.code === "Space") {
534
+ event.preventDefault();
535
+ if (!readOnly) {
536
+ openPicker();
537
+ }
538
+ return;
539
+ }
540
+ if (!open) {
541
+ return;
542
+ }
543
+ if (event.key === "Escape") {
544
+ event.preventDefault();
545
+ closePicker();
546
+ return;
547
+ }
548
+ if (event.key === "ArrowDown") {
549
+ event.preventDefault();
550
+ setActiveIndex(function (current) {
551
+ return Math.min(current + 1, Math.max(filteredSuggestions.length - 1, 0));
552
+ });
553
+ return;
554
+ }
555
+ if (event.key === "ArrowUp") {
556
+ event.preventDefault();
557
+ setActiveIndex(function (current) { return Math.max(current - 1, 0); });
558
+ return;
559
+ }
560
+ if (event.key === "Enter" && filteredSuggestions[activeIndex]) {
561
+ event.preventDefault();
562
+ selectSuggestion(filteredSuggestions[activeIndex]);
563
+ }
564
+ };
565
+ var handleChange = function (event) {
566
+ var _a;
567
+ var nextValue = event.target.value;
568
+ onChange(nextValue);
569
+ if (open) {
570
+ setQuery(getExpressionSearchTerm(nextValue, (_a = event.target.selectionStart) !== null && _a !== void 0 ? _a : nextValue.length));
571
+ }
572
+ };
573
+ var groupedSuggestions = filteredSuggestions.reduce(function (acc, suggestion) {
574
+ var _a;
575
+ acc[suggestion.group] = (_a = acc[suggestion.group]) !== null && _a !== void 0 ? _a : [];
576
+ acc[suggestion.group].push(suggestion);
577
+ return acc;
578
+ }, {});
579
+ var inputProps = {
580
+ ref: inputRef,
581
+ value: value,
582
+ disabled: readOnly,
583
+ placeholder: placeholder,
584
+ onChange: handleChange,
585
+ onKeyDown: handleKeyDown,
586
+ onBlur: function () { return window.setTimeout(function () { return setOpen(false); }, 120); },
587
+ };
588
+ var handleMenuWheel = function (event) {
589
+ var menuElement = event.currentTarget;
590
+ var canScrollVertically = menuElement.scrollHeight > menuElement.clientHeight;
591
+ var canScrollHorizontally = menuElement.scrollWidth > menuElement.clientWidth;
592
+ if (!canScrollVertically && !canScrollHorizontally) {
593
+ return;
594
+ }
595
+ event.preventDefault();
596
+ event.stopPropagation();
597
+ if (canScrollVertically) {
598
+ menuElement.scrollTop += event.deltaY;
599
+ }
600
+ if (event.shiftKey && canScrollHorizontally) {
601
+ menuElement.scrollLeft += event.deltaY || event.deltaX;
602
+ }
603
+ else if (canScrollHorizontally && Math.abs(event.deltaX) > Math.abs(event.deltaY)) {
604
+ menuElement.scrollLeft += event.deltaX;
605
+ }
606
+ };
607
+ var menu = open && portalPosition && typeof document !== "undefined" ? (_jsxs("div", { className: "workflow-expression-autocomplete-menu", "data-solid-dialog-outside-safe": "true", style: {
608
+ left: portalPosition.left,
609
+ top: portalPosition.top,
610
+ width: portalPosition.width,
611
+ maxHeight: portalPosition.maxHeight,
612
+ }, onMouseDown: function (event) { return event.preventDefault(); }, onWheelCapture: handleMenuWheel, children: [_jsx("div", { className: "workflow-expression-autocomplete-help", children: "Start typing to choose from available variables, inputs, secrets, or outputs." }), filteredSuggestions.length ? (Object.entries(groupedSuggestions).map(function (_a) {
613
+ var group = _a[0], groupSuggestions = _a[1];
614
+ return (_jsxs("div", { className: "workflow-expression-autocomplete-group", children: [_jsx("div", { className: "workflow-expression-autocomplete-group-title", children: group }), groupSuggestions.map(function (suggestion) {
615
+ var absoluteIndex = filteredSuggestions.indexOf(suggestion);
616
+ var isActive = absoluteIndex === activeIndex;
617
+ return (_jsxs("button", { type: "button", className: "workflow-expression-autocomplete-option ".concat(isActive ? "is-active" : ""), onMouseDown: function (event) {
618
+ event.preventDefault();
619
+ selectSuggestion(suggestion);
620
+ }, children: [_jsxs("span", { className: "workflow-expression-autocomplete-option-main", children: [_jsx("span", { className: "workflow-expression-autocomplete-option-label", children: suggestion.label }), suggestion.detail ? (_jsx("span", { className: "workflow-expression-autocomplete-option-detail", children: suggestion.detail })) : null] }), suggestion.description ? (_jsx("span", { className: "workflow-expression-autocomplete-option-description", children: suggestion.description })) : null] }, "".concat(suggestion.group, "-").concat(suggestion.insertText)));
621
+ })] }, group));
622
+ })) : (_jsx("div", { className: "workflow-expression-autocomplete-empty", children: "No matching expression references." }))] })) : null;
623
+ return (_jsxs("div", { className: "workflow-expression-autocomplete", children: [multiline ? (_jsx(SolidTextarea, __assign({}, inputProps))) : (_jsx(SolidInput, __assign({}, inputProps))), menu ? createPortal(menu, document.body) : null] }));
624
+ }
625
+ function WorkflowNodeFieldEditor(_a) {
626
+ var _b, _c, _d, _e, _f, _g, _h, _j;
627
+ var nodeType = _a.nodeType, field = _a.field, value = _a.value, expressionSuggestions = _a.expressionSuggestions, readOnly = _a.readOnly, onChange = _a.onChange;
628
+ var extensionKey = (_b = field.extensionComponentKey) !== null && _b !== void 0 ? _b : (_d = (_c = nodeType.ui) === null || _c === void 0 ? void 0 : _c.fieldComponentKeys) === null || _d === void 0 ? void 0 : _d[field.key];
629
+ var ExtensionComponent = extensionKey ? getExtensionComponent(extensionKey) : null;
630
+ var normalizedValue = normalizeFieldValue(field, value);
631
+ if (ExtensionComponent) {
632
+ return (_jsx(ExtensionComponent, { nodeType: nodeType, field: field, value: normalizedValue, onChange: onChange, readOnly: readOnly }));
633
+ }
634
+ if ((_e = field.enumValues) === null || _e === void 0 ? void 0 : _e.length) {
635
+ return (_jsx(SolidSelect, { value: normalizedValue, disabled: readOnly, options: field.enumValues.map(function (item) { return ({
636
+ label: String(item),
637
+ value: item,
638
+ }); }), onChange: function (event) { return onChange(event.value); } }));
639
+ }
640
+ if (field.widgetHint === "key-value-editor") {
641
+ return (_jsx(WorkflowKeyValueEditor, { value: normalizedValue, readOnly: readOnly, onChange: onChange }));
642
+ }
643
+ if (field.valueType === "boolean") {
644
+ return (_jsx(SolidSwitch, { checked: !!normalizedValue, disabled: readOnly, onChange: function (checked) { return onChange(checked); } }));
645
+ }
646
+ if (field.valueType === "number" || field.valueType === "integer") {
647
+ return (_jsx(SolidNumberInput, { value: normalizedValue, disabled: readOnly, onChange: function (event) { return onChange(event.value); } }));
648
+ }
649
+ if (field.widgetHint === "raw-editor") {
650
+ var stringValue = typeof normalizedValue === "string"
651
+ ? normalizedValue
652
+ : normalizedValue === undefined || normalizedValue === null
653
+ ? ""
654
+ : JSON.stringify(normalizedValue, null, 2);
655
+ var editorLanguage = (_h = (_g = (_f = field.uiSchema) === null || _f === void 0 ? void 0 : _f.editor) === null || _g === void 0 ? void 0 : _g.language) !== null && _h !== void 0 ? _h : "json";
656
+ return (_jsx(SolidCodeEditor, { language: editorLanguage, height: getConfigurationFieldEditorHeight(field), fontSize: 12, readOnly: readOnly, value: stringValue, onChange: function (next) { return onChange(next !== null && next !== void 0 ? next : ""); } }));
657
+ }
658
+ if (field.widgetHint === "recipient-list") {
659
+ return (_jsx(WorkflowRecipientListFieldEditor, { value: normalizedValue, readOnly: readOnly, placeholder: (_j = field.uiSchema) === null || _j === void 0 ? void 0 : _j.placeholder, expressionSuggestions: expressionSuggestions, onChange: onChange }));
660
+ }
661
+ if (field.valueType === "object" ||
662
+ field.valueType === "array" ||
663
+ field.valueType === "json" ||
664
+ field.widgetHint === "json-editor" ||
665
+ field.widgetHint === "yaml-editor") {
666
+ return (_jsx(WorkflowYamlFieldEditor, { value: normalizedValue, readOnly: readOnly, onChange: onChange, emptyValue: field.valueType === "array" ? EMPTY_YAML_ARRAY : EMPTY_YAML_OBJECT, format: field.widgetHint === "yaml-editor" ? "yaml" : "json", height: getConfigurationFieldEditorHeight(field) }));
667
+ }
668
+ if (field.valueType === "any") {
669
+ return (_jsx(WorkflowYamlFieldEditor, { value: normalizedValue, readOnly: readOnly, onChange: onChange, emptyValue: null, format: "yaml", height: getConfigurationFieldEditorHeight(field) }));
670
+ }
671
+ if (field.widgetHint === "textarea") {
672
+ if (field.expressionAllowed) {
673
+ return (_jsx(WorkflowExpressionAutocompleteField, { value: normalizedValue !== null && normalizedValue !== void 0 ? normalizedValue : "", readOnly: readOnly, multiline: true, suggestions: expressionSuggestions, onChange: onChange }));
674
+ }
675
+ return (_jsx(SolidTextarea, { value: normalizedValue !== null && normalizedValue !== void 0 ? normalizedValue : "", disabled: readOnly, onChange: function (event) { return onChange(event.target.value); } }));
676
+ }
677
+ if (field.expressionAllowed) {
678
+ return (_jsx(WorkflowExpressionAutocompleteField, { value: normalizedValue !== null && normalizedValue !== void 0 ? normalizedValue : "", readOnly: readOnly, suggestions: expressionSuggestions, onChange: onChange }));
679
+ }
680
+ return (_jsx(SolidInput, { value: normalizedValue !== null && normalizedValue !== void 0 ? normalizedValue : "", disabled: readOnly, onChange: function (event) { return onChange(event.target.value); } }));
681
+ }
682
+ function orderGroupLabels(groupLabels, groupOrder) {
683
+ return __spreadArray([], groupLabels, true).sort(function (left, right) {
684
+ var leftIndex = groupOrder.indexOf(left);
685
+ var rightIndex = groupOrder.indexOf(right);
686
+ if (leftIndex >= 0 && rightIndex >= 0) {
687
+ return leftIndex - rightIndex;
688
+ }
689
+ if (leftIndex >= 0) {
690
+ return -1;
691
+ }
692
+ if (rightIndex >= 0) {
693
+ return 1;
694
+ }
695
+ return left.localeCompare(right);
696
+ });
697
+ }
698
+ function buildConfigurationSections(fields, groupOrder) {
699
+ var groupedFields = fields.reduce(function (acc, field) {
700
+ var _a, _b;
701
+ var group = (_a = field.group) !== null && _a !== void 0 ? _a : "General";
702
+ acc[group] = (_b = acc[group]) !== null && _b !== void 0 ? _b : [];
703
+ acc[group].push(field);
704
+ return acc;
705
+ }, {});
706
+ return orderGroupLabels(Object.keys(groupedFields), groupOrder).map(function (group) { return ({
707
+ key: group,
708
+ label: group,
709
+ fields: groupedFields[group],
710
+ }); });
711
+ }
712
+ function getFieldLayoutKeys(field) {
713
+ return [field.key, field.path].filter(Boolean);
714
+ }
715
+ function buildConfigurationTabs(fields, groupOrder, layout) {
716
+ if ((layout === null || layout === void 0 ? void 0 : layout.type) !== "tabs" || !Array.isArray(layout.tabs) || !layout.tabs.length) {
717
+ return [];
718
+ }
719
+ var assignedFieldKeys = new Set();
720
+ var tabs = layout.tabs
721
+ .map(function (tab) {
722
+ var _a, _b;
723
+ var tabFieldKeys = new Set((_a = tab.fields) !== null && _a !== void 0 ? _a : []);
724
+ var tabGroupLabels = new Set((_b = tab.groups) !== null && _b !== void 0 ? _b : []);
725
+ var tabFields = fields.filter(function (field) {
726
+ var _a;
727
+ var isFieldMatch = getFieldLayoutKeys(field).some(function (key) { return tabFieldKeys.has(key); });
728
+ var isGroupMatch = tabGroupLabels.has((_a = field.group) !== null && _a !== void 0 ? _a : "General");
729
+ if (isFieldMatch || isGroupMatch) {
730
+ getFieldLayoutKeys(field).forEach(function (key) { return assignedFieldKeys.add(key); });
731
+ return true;
732
+ }
733
+ return false;
734
+ });
735
+ return {
736
+ key: tab.key,
737
+ label: tab.label,
738
+ sections: buildConfigurationSections(tabFields, groupOrder),
739
+ };
740
+ })
741
+ .filter(function (tab) { return tab.sections.some(function (section) { return section.fields.length; }); });
742
+ var unassignedFields = fields.filter(function (field) { return !getFieldLayoutKeys(field).some(function (key) { return assignedFieldKeys.has(key); }); });
743
+ if (unassignedFields.length) {
744
+ tabs.push({
745
+ key: "other",
746
+ label: "Other",
747
+ sections: buildConfigurationSections(unassignedFields, groupOrder),
748
+ });
749
+ }
750
+ return tabs;
751
+ }
752
+ function WorkflowConfigurationSections(_a) {
753
+ var sections = _a.sections, nodeType = _a.nodeType, draft = _a.draft, expressionSuggestions = _a.expressionSuggestions, readOnly = _a.readOnly, updateField = _a.updateField;
754
+ return (_jsx(_Fragment, { children: sections.map(function (section) { return (_jsxs("section", { className: "workflow-node-editor-section", children: [sections.length > 1 || section.label !== "General" ? (_jsx("div", { className: "workflow-node-editor-section-heading", children: section.label })) : null, _jsx("div", { className: "workflow-node-editor-form-grid", children: section.fields.map(function (field) {
755
+ var _a, _b;
756
+ var fieldWidth = getConfigurationFieldWidth(field);
757
+ return (_jsxs("div", { className: "workflow-node-editor-field workflow-node-editor-field--".concat(fieldWidth), children: [_jsx("div", { className: "workflow-node-editor-field-heading", children: _jsxs("div", { className: "workflow-node-editor-label-row", children: [_jsx("label", { className: "workflow-node-editor-label", children: (_a = field.label) !== null && _a !== void 0 ? _a : field.key }), _jsx(WorkflowFieldHelp, { field: field })] }) }), _jsx(WorkflowNodeFieldEditor, { nodeType: nodeType, field: field, value: getPathValue(draft, (_b = field.path) !== null && _b !== void 0 ? _b : field.key), expressionSuggestions: expressionSuggestions, readOnly: readOnly, onChange: function (nextValue) { return updateField(field, nextValue); } })] }, field.key));
758
+ }) })] }, section.key)); }) }));
759
+ }
760
+ export function WorkflowNodeSchemaEditor(_a) {
761
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
762
+ var nodeType = _a.nodeType, value = _a.value, onChange = _a.onChange, onSubmit = _a.onSubmit, expressionSuggestions = _a.expressionSuggestions, readOnly = _a.readOnly, className = _a.className;
763
+ var _o = React.useState((_c = value !== null && value !== void 0 ? value : (_b = nodeType.authoring) === null || _b === void 0 ? void 0 : _b.defaultConfiguration) !== null && _c !== void 0 ? _c : {}), draft = _o[0], setDraft = _o[1];
764
+ var _p = React.useState(""), activeConfigurationTab = _p[0], setActiveConfigurationTab = _p[1];
765
+ React.useEffect(function () {
766
+ var _a, _b;
767
+ setDraft((_b = value !== null && value !== void 0 ? value : (_a = nodeType.authoring) === null || _a === void 0 ? void 0 : _a.defaultConfiguration) !== null && _b !== void 0 ? _b : {});
768
+ }, [nodeType, value]);
769
+ var fields = (_e = (_d = nodeType.authoring) === null || _d === void 0 ? void 0 : _d.configurationFields) !== null && _e !== void 0 ? _e : [];
770
+ var groupOrder = (_h = (_g = (_f = nodeType.ui) === null || _f === void 0 ? void 0 : _f.layoutHints) === null || _g === void 0 ? void 0 : _g.groupOrder) !== null && _h !== void 0 ? _h : [];
771
+ var visibleFields = fields.filter(function (field) {
772
+ return isConfigurationFieldVisible(field, draft);
773
+ });
774
+ var configurationSections = buildConfigurationSections(visibleFields, groupOrder);
775
+ var configurationTabs = buildConfigurationTabs(visibleFields, groupOrder, (_j = nodeType.authoring) === null || _j === void 0 ? void 0 : _j.configurationLayout);
776
+ var activeConfigurationTabValue = activeConfigurationTab || ((_k = configurationTabs[0]) === null || _k === void 0 ? void 0 : _k.key) || "";
777
+ var updateField = function (field, nextValue) {
778
+ var _a;
779
+ var nextDraft = setPathValue(draft, (_a = field.path) !== null && _a !== void 0 ? _a : field.key, nextValue);
780
+ setDraft(nextDraft);
781
+ onChange === null || onChange === void 0 ? void 0 : onChange(nextDraft);
782
+ };
783
+ React.useEffect(function () {
784
+ if (configurationTabs.length &&
785
+ !configurationTabs.some(function (tab) { return tab.key === activeConfigurationTab; })) {
786
+ setActiveConfigurationTab(configurationTabs[0].key);
787
+ }
788
+ }, [activeConfigurationTab, configurationTabs]);
789
+ if (!configurationSections.length) {
790
+ return (_jsx("div", { className: "workflow-node-editor-empty ".concat(className !== null && className !== void 0 ? className : ""), children: "This node does not expose configuration fields yet." }));
791
+ }
792
+ return (_jsxs("div", { className: "workflow-node-editor-config ".concat(className !== null && className !== void 0 ? className : ""), children: [configurationTabs.length > 1 ? (_jsx(SolidTabGroup, { tabs: configurationTabs.map(function (tab) { return ({
793
+ value: tab.key,
794
+ label: tab.label,
795
+ content: (_jsx(WorkflowConfigurationSections, { sections: tab.sections, nodeType: nodeType, draft: draft, expressionSuggestions: expressionSuggestions, readOnly: readOnly, updateField: updateField })),
796
+ }); }), value: activeConfigurationTabValue, onValueChange: setActiveConfigurationTab, className: "workflow-node-editor-config-tabs", panelClassName: "workflow-node-editor-config-tab-panel" })) : (_jsx(WorkflowConfigurationSections, { sections: (_m = (_l = configurationTabs[0]) === null || _l === void 0 ? void 0 : _l.sections) !== null && _m !== void 0 ? _m : configurationSections, nodeType: nodeType, draft: draft, expressionSuggestions: expressionSuggestions, readOnly: readOnly, updateField: updateField })), !readOnly && onSubmit ? (_jsx("div", { className: "workflow-node-editor-inline-actions", children: _jsx(SolidButton, { onClick: function () { return onSubmit(draft); }, children: "Save" }) })) : null] }));
797
+ }
798
+ function WorkflowNodeTags(_a) {
799
+ var _b;
800
+ var nodeType = _a.nodeType;
801
+ return (_jsxs("div", { className: "workflow-node-editor-tags", children: [_jsx(SolidTag, { children: nodeType.kind }), nodeType.category ? _jsx(SolidTag, { children: nodeType.category }) : null, ((_b = nodeType.ui) === null || _b === void 0 ? void 0 : _b.defaultEditorMode) ? _jsx(SolidTag, { children: nodeType.ui.defaultEditorMode }) : null] }));
802
+ }
803
+ function WorkflowNodeHeaderMeta(_a) {
804
+ var nodeType = _a.nodeType;
805
+ return (_jsxs("div", { className: "workflow-node-editor-dialog-meta", children: [_jsx("span", { className: "workflow-node-editor-dialog-icon", style: getWorkflowNodeIconStyle(nodeType), children: _jsx(WorkflowNodeTypeIcon, { nodeType: nodeType, size: 15 }) }), _jsx(SolidTag, { children: nodeType.kind }), _jsx(SolidTag, { children: nodeType.type }), nodeType.category ? _jsx(SolidTag, { children: nodeType.category }) : null, nodeType.subcategory ? _jsx(SolidTag, { children: nodeType.subcategory }) : null] }));
806
+ }
807
+ function WorkflowNodeCommonFields(_a) {
808
+ var _b, _c, _d, _e;
809
+ var nodeType = _a.nodeType, draft = _a.draft, readOnly = _a.readOnly, onChange = _a.onChange;
810
+ var authoring = nodeType.authoring;
811
+ var update = function (patch) {
812
+ onChange(__assign(__assign({}, draft), patch));
813
+ };
814
+ return (_jsx("section", { className: "workflow-node-editor-section", children: _jsxs("div", { className: "workflow-node-editor-form-grid", children: [_jsxs("div", { className: "workflow-node-editor-field", children: [_jsx("label", { className: "workflow-node-editor-label", children: "Id" }), _jsx(SolidInput, { value: (_b = draft.id) !== null && _b !== void 0 ? _b : "", disabled: readOnly, onChange: function (event) { return update({ id: event.target.value }); } })] }), _jsxs("div", { className: "workflow-node-editor-field", children: [_jsx("label", { className: "workflow-node-editor-label", children: "Type" }), _jsx(SolidInput, { value: (_c = draft.type) !== null && _c !== void 0 ? _c : nodeType.type, disabled: true })] }), (authoring === null || authoring === void 0 ? void 0 : authoring.supportsName) !== false ? (_jsxs("div", { className: "workflow-node-editor-field", children: [_jsx("label", { className: "workflow-node-editor-label", children: "Name" }), _jsx(SolidInput, { value: (_d = draft.name) !== null && _d !== void 0 ? _d : "", disabled: readOnly, onChange: function (event) { return update({ name: event.target.value }); } })] })) : null, _jsxs("div", { className: "workflow-node-editor-field", children: [_jsx("label", { className: "workflow-node-editor-label", children: "Kind" }), _jsx(WorkflowNodeTags, { nodeType: nodeType })] }), (authoring === null || authoring === void 0 ? void 0 : authoring.supportsDescription) ? (_jsxs("div", { className: "workflow-node-editor-field workflow-node-editor-field--wide", children: [_jsx("label", { className: "workflow-node-editor-label", children: "Description" }), _jsx(SolidTextarea, { className: "workflow-node-editor-description-input", value: (_e = draft.description) !== null && _e !== void 0 ? _e : "", disabled: readOnly, onChange: function (event) { return update({ description: event.target.value }); } })] })) : null] }) }));
815
+ }
816
+ function WorkflowNodeRuntimeFields(_a) {
817
+ var _b, _c, _d;
818
+ var nodeType = _a.nodeType, draft = _a.draft, readOnly = _a.readOnly, onChange = _a.onChange;
819
+ var authoring = nodeType.authoring;
820
+ if (!hasRuntimeFields(nodeType)) {
821
+ return null;
822
+ }
823
+ var update = function (patch) {
824
+ onChange(__assign(__assign({}, draft), patch));
825
+ };
826
+ return (_jsxs("section", { className: "workflow-node-editor-section", children: [(authoring === null || authoring === void 0 ? void 0 : authoring.supportsDisableToggle) ? (_jsxs("div", { className: "workflow-node-editor-toggle-row", children: [_jsxs("div", { children: [_jsx("div", { className: "workflow-node-editor-toggle-title", children: "Disabled" }), _jsx("div", { className: "workflow-node-editor-description", children: "Skip this node during execution." })] }), _jsx(SolidSwitch, { checked: !!draft.disabled, disabled: readOnly, onChange: function (checked) { return update({ disabled: checked || undefined }); } })] })) : null, _jsxs("div", { className: "workflow-node-editor-form-grid", children: [(authoring === null || authoring === void 0 ? void 0 : authoring.supportsTimeoutMs) ? (_jsxs("div", { className: "workflow-node-editor-field", children: [_jsx("label", { className: "workflow-node-editor-label", children: "Timeout (ms)" }), _jsx(SolidNumberInput, { value: draft.timeoutMs, disabled: readOnly, onChange: function (event) { var _a; return update({ timeoutMs: (_a = event.value) !== null && _a !== void 0 ? _a : undefined }); } })] })) : null, (authoring === null || authoring === void 0 ? void 0 : authoring.supportsOnError) ? (_jsxs("div", { className: "workflow-node-editor-field", children: [_jsx("label", { className: "workflow-node-editor-label", children: "On error" }), _jsx(SolidSelect, { value: (_b = draft.onError) !== null && _b !== void 0 ? _b : "fail", disabled: readOnly, options: [
827
+ { label: "Fail workflow", value: "fail" },
828
+ { label: "Continue", value: "continue" },
829
+ ], onChange: function (event) { return update({ onError: event.value }); } })] })) : null, (authoring === null || authoring === void 0 ? void 0 : authoring.supportsRetryPolicy) ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "workflow-node-editor-field", children: [_jsx("label", { className: "workflow-node-editor-label", children: "Max retries" }), _jsx(SolidNumberInput, { value: (_c = draft.retryPolicy) === null || _c === void 0 ? void 0 : _c.maxRetries, disabled: readOnly, onChange: function (event) {
830
+ var _a, _b;
831
+ return update({
832
+ retryPolicy: __assign(__assign({}, ((_a = draft.retryPolicy) !== null && _a !== void 0 ? _a : {})), { maxRetries: (_b = event.value) !== null && _b !== void 0 ? _b : undefined }),
833
+ });
834
+ } })] }), _jsxs("div", { className: "workflow-node-editor-field", children: [_jsx("label", { className: "workflow-node-editor-label", children: "Retry delay (ms)" }), _jsx(SolidNumberInput, { value: (_d = draft.retryPolicy) === null || _d === void 0 ? void 0 : _d.delayMs, disabled: readOnly, onChange: function (event) {
835
+ var _a, _b;
836
+ return update({
837
+ retryPolicy: __assign(__assign({}, ((_a = draft.retryPolicy) !== null && _a !== void 0 ? _a : {})), { delayMs: (_b = event.value) !== null && _b !== void 0 ? _b : undefined }),
838
+ });
839
+ } })] })] })) : null] })] }));
840
+ }
841
+ function WorkflowNodeChildSlotsSummary(_a) {
842
+ var _b, _c;
843
+ var nodeType = _a.nodeType, draft = _a.draft;
844
+ var childSlots = (_c = (_b = nodeType.authoring) === null || _b === void 0 ? void 0 : _b.childSlots) !== null && _c !== void 0 ? _c : [];
845
+ if (!childSlots.length) {
846
+ return null;
847
+ }
848
+ return (_jsxs("section", { className: "workflow-node-editor-section", children: [_jsx("div", { className: "workflow-node-editor-slot-list", children: childSlots.map(function (slot) {
849
+ var _a, _b;
850
+ return (_jsxs("div", { className: "workflow-node-editor-slot-row", children: [_jsxs("div", { className: "workflow-node-editor-slot-copy", children: [_jsx("div", { className: "workflow-node-editor-slot-title", children: (_a = slot.label) !== null && _a !== void 0 ? _a : slot.key }), _jsx("div", { className: "workflow-node-editor-description", children: (_b = slot.description) !== null && _b !== void 0 ? _b : "Use the topology canvas to add, reorder, or remove child nodes." })] }), _jsx(SolidTag, { children: getSlotCount(draft, slot) })] }, slot.key));
851
+ }) }), _jsx("div", { className: "workflow-node-editor-note", children: "Child node membership is edited from the topology canvas. This dialog edits the control node itself." })] }));
852
+ }
853
+ function WorkflowNodeFullEditor(_a) {
854
+ var _b, _c, _d, _e, _f;
855
+ var nodeType = _a.nodeType, value = _a.value, onChange = _a.onChange, expressionSuggestions = _a.expressionSuggestions, readOnly = _a.readOnly;
856
+ var configuration = (_b = value.configuration) !== null && _b !== void 0 ? _b : {};
857
+ var _g = React.useState("basic"), activeTab = _g[0], setActiveTab = _g[1];
858
+ var hasConfiguration = Boolean((_d = (_c = nodeType.authoring) === null || _c === void 0 ? void 0 : _c.configurationFields) === null || _d === void 0 ? void 0 : _d.length);
859
+ var childSlots = (_f = (_e = nodeType.authoring) === null || _e === void 0 ? void 0 : _e.childSlots) !== null && _f !== void 0 ? _f : [];
860
+ var tabs = [
861
+ {
862
+ value: "basic",
863
+ label: "Basic Info",
864
+ content: (_jsx(WorkflowNodeCommonFields, { nodeType: nodeType, draft: value, readOnly: readOnly, onChange: onChange })),
865
+ },
866
+ hasConfiguration
867
+ ? {
868
+ value: "configuration",
869
+ label: "Configuration",
870
+ content: (_jsx(WorkflowNodeSchemaEditor, { nodeType: nodeType, value: configuration, expressionSuggestions: expressionSuggestions, readOnly: readOnly, onChange: function (nextConfiguration) {
871
+ return onChange(__assign(__assign({}, value), { configuration: nextConfiguration }));
872
+ } })),
873
+ }
874
+ : null,
875
+ hasRuntimeFields(nodeType)
876
+ ? {
877
+ value: "runtime",
878
+ label: "Runtime",
879
+ content: (_jsx(WorkflowNodeRuntimeFields, { nodeType: nodeType, draft: value, readOnly: readOnly, onChange: onChange })),
880
+ }
881
+ : null,
882
+ childSlots.length
883
+ ? {
884
+ value: "topology",
885
+ label: "Topology",
886
+ content: _jsx(WorkflowNodeChildSlotsSummary, { nodeType: nodeType, draft: value }),
887
+ }
888
+ : null,
889
+ ].filter(Boolean);
890
+ React.useEffect(function () {
891
+ var _a, _b;
892
+ if (!tabs.some(function (tab) { return tab.value === activeTab; })) {
893
+ setActiveTab((_b = (_a = tabs[0]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : "basic");
894
+ }
895
+ }, [activeTab, tabs]);
896
+ return (_jsx(SolidTabGroup, { tabs: tabs, value: activeTab, onValueChange: setActiveTab, className: "workflow-node-editor-tabs", panelClassName: "workflow-node-editor-tab-panel" }));
897
+ }
898
+ export function WorkflowNodeEditorDialog(_a) {
899
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
900
+ var open = _a.open, onOpenChange = _a.onOpenChange, title = _a.title, nodeType = _a.nodeType, value = _a.value, onChange = _a.onChange, onSubmit = _a.onSubmit, expressionSuggestions = _a.expressionSuggestions, readOnly = _a.readOnly, nodeValue = _a.nodeValue, onNodeChange = _a.onNodeChange, onNodeSubmit = _a.onNodeSubmit;
901
+ var _m = React.useState((_d = (_b = value !== null && value !== void 0 ? value : nodeValue === null || nodeValue === void 0 ? void 0 : nodeValue.configuration) !== null && _b !== void 0 ? _b : (_c = nodeType.authoring) === null || _c === void 0 ? void 0 : _c.defaultConfiguration) !== null && _d !== void 0 ? _d : {}), draft = _m[0], setDraft = _m[1];
902
+ var _o = React.useState(nodeValue !== null && nodeValue !== void 0 ? nodeValue : {
903
+ id: "",
904
+ type: nodeType.type,
905
+ kind: nodeType.kind,
906
+ configuration: (_f = value !== null && value !== void 0 ? value : (_e = nodeType.authoring) === null || _e === void 0 ? void 0 : _e.defaultConfiguration) !== null && _f !== void 0 ? _f : {},
907
+ }), nodeDraft = _o[0], setNodeDraft = _o[1];
908
+ React.useEffect(function () {
909
+ var _a, _b, _c, _d, _e;
910
+ setDraft((_c = (_a = value !== null && value !== void 0 ? value : nodeValue === null || nodeValue === void 0 ? void 0 : nodeValue.configuration) !== null && _a !== void 0 ? _a : (_b = nodeType.authoring) === null || _b === void 0 ? void 0 : _b.defaultConfiguration) !== null && _c !== void 0 ? _c : {});
911
+ setNodeDraft(nodeValue !== null && nodeValue !== void 0 ? nodeValue : {
912
+ id: "",
913
+ type: nodeType.type,
914
+ kind: nodeType.kind,
915
+ configuration: (_e = value !== null && value !== void 0 ? value : (_d = nodeType.authoring) === null || _d === void 0 ? void 0 : _d.defaultConfiguration) !== null && _e !== void 0 ? _e : {},
916
+ });
917
+ }, [nodeType, nodeValue, value, open]);
918
+ var editorComponentKey = (_g = nodeType.ui) === null || _g === void 0 ? void 0 : _g.editorComponentKey;
919
+ var CustomEditor = editorComponentKey ? getExtensionComponent(editorComponentKey) : null;
920
+ var useCustomEditor = !!CustomEditor && ((_h = nodeType.ui) === null || _h === void 0 ? void 0 : _h.defaultEditorMode) === "custom";
921
+ var isFullNodeMode = !!nodeValue || !!onNodeSubmit || !!onNodeChange;
922
+ var dialogTitle = (_j = title !== null && title !== void 0 ? title : nodeType.label) !== null && _j !== void 0 ? _j : nodeType.type;
923
+ var dialogSubtitle = isFullNodeMode
924
+ ? "Review the node details and configuration for this workflow step."
925
+ : "Review the configuration fields for this workflow node.";
926
+ var handleNodeChange = function (nextValue) {
927
+ var _a;
928
+ setNodeDraft(nextValue);
929
+ setDraft((_a = nextValue.configuration) !== null && _a !== void 0 ? _a : {});
930
+ onNodeChange === null || onNodeChange === void 0 ? void 0 : onNodeChange(nextValue);
931
+ };
932
+ return (_jsxs(SolidDialog, { open: open, onOpenChange: onOpenChange, header: _jsxs("div", { className: "workflow-node-editor-dialog-heading", children: [_jsx("div", { className: "workflow-node-editor-dialog-title", children: dialogTitle }), _jsx("div", { className: "workflow-node-editor-dialog-subtitle", children: dialogSubtitle }), _jsx(WorkflowNodeHeaderMeta, { nodeType: nodeType })] }), className: "solid-workflow-node-editor-dialog solid-workflow-node-editor-dialog--".concat((_l = (_k = nodeType.ui) === null || _k === void 0 ? void 0 : _k.modalSize) !== null && _l !== void 0 ? _l : "lg"), style: getWorkflowNodeEditorDialogStyle(nodeType), children: [_jsx(SolidDialogBody, { className: "workflow-node-editor-dialog-body", children: useCustomEditor ? (_jsx(CustomEditor, { nodeType: nodeType, value: isFullNodeMode ? nodeDraft : draft, nodeValue: nodeDraft, configuration: draft, onChange: isFullNodeMode ? handleNodeChange : setDraft, readOnly: readOnly })) : isFullNodeMode ? (_jsx(WorkflowNodeFullEditor, { nodeType: nodeType, value: nodeDraft, onChange: handleNodeChange, expressionSuggestions: expressionSuggestions, readOnly: readOnly })) : (_jsx(WorkflowNodeSchemaEditor, { className: "workflow-node-editor-standalone-config", nodeType: nodeType, value: draft, expressionSuggestions: expressionSuggestions, onChange: function (nextValue) {
933
+ setDraft(nextValue);
934
+ onChange === null || onChange === void 0 ? void 0 : onChange(nextValue);
935
+ }, onSubmit: function (nextValue) {
936
+ setDraft(nextValue);
937
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(nextValue);
938
+ }, readOnly: readOnly })) }), !readOnly && (onSubmit || onNodeSubmit) ? (_jsxs(SolidDialogFooter, { className: "workflow-node-editor-dialog-footer", children: [_jsx(SolidButton, { variant: "secondary", onClick: function () { return onOpenChange(false); }, children: "Cancel" }), _jsx(SolidButton, { onClick: function () {
939
+ if (isFullNodeMode) {
940
+ onNodeSubmit === null || onNodeSubmit === void 0 ? void 0 : onNodeSubmit(nodeDraft);
941
+ }
942
+ else {
943
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(draft);
944
+ }
945
+ }, children: "Save" })] })) : null] }));
946
+ }
947
+ export function WorkflowAddNodeDialog(_a) {
948
+ var _b, _c;
949
+ var open = _a.open, nodeTypes = _a.nodeTypes, onOpenChange = _a.onOpenChange, createNodeValue = _a.createNodeValue, onSubmit = _a.onSubmit;
950
+ var _d = React.useState("select"), step = _d[0], setStep = _d[1];
951
+ var _e = React.useState(""), query = _e[0], setQuery = _e[1];
952
+ var _f = React.useState(""), categoryFilter = _f[0], setCategoryFilter = _f[1];
953
+ var _g = React.useState(""), subcategoryFilter = _g[0], setSubcategoryFilter = _g[1];
954
+ var _h = React.useState(""), kindFilter = _h[0], setKindFilter = _h[1];
955
+ var _j = React.useState(false), filtersOpen = _j[0], setFiltersOpen = _j[1];
956
+ var _k = React.useState(""), selectedType = _k[0], setSelectedType = _k[1];
957
+ var _l = React.useState(null), nodeDraft = _l[0], setNodeDraft = _l[1];
958
+ React.useEffect(function () {
959
+ if (!open) {
960
+ setStep("select");
961
+ setQuery("");
962
+ setCategoryFilter("");
963
+ setSubcategoryFilter("");
964
+ setKindFilter("");
965
+ setFiltersOpen(false);
966
+ setSelectedType("");
967
+ setNodeDraft(null);
968
+ }
969
+ }, [open]);
970
+ var selectedNodeType = React.useMemo(function () { return nodeTypes.find(function (nodeType) { return nodeType.type === selectedType; }); }, [nodeTypes, selectedType]);
971
+ var categoryOptions = React.useMemo(function () {
972
+ return createSelectOptions(Array.from(new Set(nodeTypes.map(function (nodeType) { var _a; return (_a = nodeType.category) !== null && _a !== void 0 ? _a : ""; }).filter(Boolean))), "All categories");
973
+ }, [nodeTypes]);
974
+ var subcategoryOptions = React.useMemo(function () {
975
+ var source = categoryFilter
976
+ ? nodeTypes.filter(function (nodeType) { return nodeType.category === categoryFilter; })
977
+ : nodeTypes;
978
+ return createSelectOptions(Array.from(new Set(source.map(function (nodeType) { var _a; return (_a = nodeType.subcategory) !== null && _a !== void 0 ? _a : ""; }).filter(Boolean))), "All subcategories");
979
+ }, [categoryFilter, nodeTypes]);
980
+ var kindOptions = React.useMemo(function () {
981
+ return createSelectOptions(Array.from(new Set(nodeTypes.map(function (nodeType) { return nodeType.kind; }).filter(Boolean))), "All kinds");
982
+ }, [nodeTypes]);
983
+ React.useEffect(function () {
984
+ if (subcategoryFilter &&
985
+ !subcategoryOptions.some(function (option) { return option.value === subcategoryFilter; })) {
986
+ setSubcategoryFilter("");
987
+ }
988
+ }, [subcategoryFilter, subcategoryOptions]);
989
+ var filteredNodeTypes = React.useMemo(function () {
990
+ var normalizedQuery = query.trim().toLowerCase();
991
+ return nodeTypes.filter(function (nodeType) {
992
+ if (categoryFilter && nodeType.category !== categoryFilter) {
993
+ return false;
994
+ }
995
+ if (subcategoryFilter && nodeType.subcategory !== subcategoryFilter) {
996
+ return false;
997
+ }
998
+ if (kindFilter && nodeType.kind !== kindFilter) {
999
+ return false;
1000
+ }
1001
+ if (!normalizedQuery) {
1002
+ return true;
1003
+ }
1004
+ return getNodeTypeSearchText(nodeType).includes(normalizedQuery);
1005
+ });
1006
+ }, [
1007
+ categoryFilter,
1008
+ kindFilter,
1009
+ nodeTypes,
1010
+ query,
1011
+ subcategoryFilter,
1012
+ ]);
1013
+ var groupedNodeTypes = React.useMemo(function () {
1014
+ var grouped = new Map();
1015
+ filteredNodeTypes.forEach(function (nodeType) {
1016
+ var _a, _b;
1017
+ var category = normalizeGroupLabel(nodeType.category, "Uncategorized");
1018
+ var subcategory = normalizeGroupLabel(nodeType.subcategory, "General");
1019
+ var categoryGroup = (_a = grouped.get(category)) !== null && _a !== void 0 ? _a : new Map();
1020
+ var subcategoryGroup = (_b = categoryGroup.get(subcategory)) !== null && _b !== void 0 ? _b : [];
1021
+ subcategoryGroup.push(nodeType);
1022
+ categoryGroup.set(subcategory, subcategoryGroup);
1023
+ grouped.set(category, categoryGroup);
1024
+ });
1025
+ return Array.from(grouped.entries())
1026
+ .sort(function (_a, _b) {
1027
+ var left = _a[0];
1028
+ var right = _b[0];
1029
+ return left.localeCompare(right);
1030
+ })
1031
+ .map(function (_a) {
1032
+ var category = _a[0], subcategories = _a[1];
1033
+ return ({
1034
+ category: category,
1035
+ subcategories: Array.from(subcategories.entries())
1036
+ .sort(function (_a, _b) {
1037
+ var left = _a[0];
1038
+ var right = _b[0];
1039
+ return left.localeCompare(right);
1040
+ })
1041
+ .map(function (_a) {
1042
+ var subcategory = _a[0], nodes = _a[1];
1043
+ return ({
1044
+ subcategory: subcategory,
1045
+ nodes: nodes.sort(function (left, right) { var _a, _b; return ((_a = left.label) !== null && _a !== void 0 ? _a : left.type).localeCompare((_b = right.label) !== null && _b !== void 0 ? _b : right.type); }),
1046
+ });
1047
+ }),
1048
+ });
1049
+ });
1050
+ }, [filteredNodeTypes]);
1051
+ var goToConfigureStep = function (nodeType) {
1052
+ if (nodeType === void 0) { nodeType = selectedNodeType; }
1053
+ if (!nodeType) {
1054
+ return;
1055
+ }
1056
+ setSelectedType(nodeType.type);
1057
+ setNodeDraft(createNodeValue(nodeType));
1058
+ setStep("configure");
1059
+ };
1060
+ var handleSubmit = function () {
1061
+ if (!nodeDraft) {
1062
+ return;
1063
+ }
1064
+ onSubmit(nodeDraft);
1065
+ onOpenChange(false);
1066
+ };
1067
+ var header = (_jsxs("div", { className: "workflow-node-editor-dialog-heading", children: [_jsx("div", { className: "workflow-node-editor-dialog-title", children: step === "select" ? "Add Node" : "Configure ".concat((_c = (_b = selectedNodeType === null || selectedNodeType === void 0 ? void 0 : selectedNodeType.label) !== null && _b !== void 0 ? _b : selectedNodeType === null || selectedNodeType === void 0 ? void 0 : selectedNodeType.type) !== null && _c !== void 0 ? _c : "Node") }), _jsx("div", { className: "workflow-node-editor-dialog-subtitle", children: step === "select"
1068
+ ? "Choose the workflow node type to insert at this point in the flow."
1069
+ : "Review the node details and configuration before adding it to the workflow." }), selectedNodeType ? _jsx(WorkflowNodeHeaderMeta, { nodeType: selectedNodeType }) : null] }));
1070
+ return (_jsxs(SolidDialog, { open: open, onOpenChange: onOpenChange, header: header, className: "solid-workflow-node-editor-dialog solid-workflow-add-node-dialog", style: { width: "min(1040px, 94vw)", maxWidth: "96vw" }, children: [_jsx(SolidDialogBody, { className: "workflow-node-editor-dialog-body workflow-add-node-dialog-body", children: step === "select" ? (_jsxs("div", { className: "workflow-add-node-picker", children: [_jsxs("div", { className: "workflow-add-node-search-row", children: [_jsxs("div", { className: "workflow-add-node-search", children: [_jsx(Search, { size: 15 }), _jsx(SolidInput, { value: query, onChange: function (event) { return setQuery(event.target.value); }, placeholder: "Search node types" }), _jsx("button", { type: "button", className: "workflow-add-node-search-action ".concat(filtersOpen ? "is-active" : ""), "aria-label": filtersOpen ? "Hide filters" : "Show filters", title: filtersOpen ? "Hide filters" : "Show filters", onClick: function () { return setFiltersOpen(function (current) { return !current; }); }, children: _jsx(Filter, { size: 14 }) }), _jsx("button", { type: "button", className: "workflow-add-node-search-action", "aria-label": "Clear search", title: "Clear search", disabled: !query, onClick: function () { return setQuery(""); }, children: _jsx(X, { size: 14 }) })] }), filtersOpen ? (_jsxs("div", { className: "workflow-add-node-filters", children: [_jsx(SolidSelect, { value: categoryFilter, options: categoryOptions, onChange: function (event) { var _a; return setCategoryFilter((_a = event.value) !== null && _a !== void 0 ? _a : ""); } }), _jsx(SolidSelect, { value: subcategoryFilter, options: subcategoryOptions, onChange: function (event) { var _a; return setSubcategoryFilter((_a = event.value) !== null && _a !== void 0 ? _a : ""); } }), _jsx(SolidSelect, { value: kindFilter, options: kindOptions, onChange: function (event) { var _a; return setKindFilter((_a = event.value) !== null && _a !== void 0 ? _a : ""); } })] })) : null] }), _jsx("div", { className: "workflow-add-node-results", children: groupedNodeTypes.length ? (groupedNodeTypes.map(function (categoryGroup) { return (_jsxs("section", { className: "workflow-add-node-category", children: [_jsx("div", { className: "workflow-add-node-category-title", children: categoryGroup.category }), _jsx("div", { className: "workflow-add-node-subcategory-list", children: categoryGroup.subcategories.map(function (subcategoryGroup) { return (_jsxs("div", { className: "workflow-add-node-subcategory", children: [_jsx("div", { className: "workflow-add-node-subcategory-title", children: subcategoryGroup.subcategory }), _jsx("div", { className: "workflow-add-node-grid", children: subcategoryGroup.nodes.map(function (nodeType) {
1071
+ var _a, _b;
1072
+ return (_jsxs("button", { type: "button", className: "workflow-add-node-card ".concat(selectedType === nodeType.type ? "is-active" : ""), onClick: function () { return goToConfigureStep(nodeType); }, children: [_jsx("span", { className: "workflow-add-node-card-icon workflow-add-node-card-icon--".concat(nodeType.kind), style: getWorkflowNodeIconStyle(nodeType), children: _jsx(WorkflowNodeTypeIcon, { nodeType: nodeType }) }), _jsxs("span", { className: "workflow-add-node-card-copy", children: [_jsx("span", { className: "workflow-add-node-card-title", children: (_a = nodeType.label) !== null && _a !== void 0 ? _a : nodeType.type }), _jsx("span", { className: "workflow-add-node-card-description", children: (_b = nodeType.description) !== null && _b !== void 0 ? _b : nodeType.type })] })] }, nodeType.type));
1073
+ }) })] }, "".concat(categoryGroup.category, "-").concat(subcategoryGroup.subcategory))); }) })] }, categoryGroup.category)); })) : (_jsx("div", { className: "workflow-node-editor-empty", children: "No node types match the current search and filters." })) })] })) : selectedNodeType && nodeDraft ? (_jsx(WorkflowNodeFullEditor, { nodeType: selectedNodeType, value: nodeDraft, onChange: setNodeDraft })) : null }), _jsx(SolidDialogFooter, { className: "workflow-node-editor-dialog-footer", children: step === "select" ? (_jsx(SolidButton, { variant: "secondary", onClick: function () { return onOpenChange(false); }, children: "Cancel" })) : (_jsxs(_Fragment, { children: [_jsx(SolidButton, { variant: "secondary", leftIcon: _jsx(ArrowLeft, { size: 14 }), onClick: function () { return setStep("select"); }, children: "Back" }), _jsx(SolidButton, { onClick: handleSubmit, children: "Add Node" })] })) })] }));
1074
+ }
1075
+ export function WorkflowNodePalette(_a) {
1076
+ var nodeTypes = _a.nodeTypes, value = _a.value, onSelect = _a.onSelect, className = _a.className;
1077
+ var _b = React.useState(""), query = _b[0], setQuery = _b[1];
1078
+ var filteredNodeTypes = nodeTypes.filter(function (nodeType) {
1079
+ var _a, _b, _c;
1080
+ var haystack = __spreadArray(__spreadArray([
1081
+ nodeType.type,
1082
+ nodeType.label,
1083
+ nodeType.description,
1084
+ nodeType.category,
1085
+ nodeType.subcategory
1086
+ ], ((_a = nodeType.tags) !== null && _a !== void 0 ? _a : []), true), ((_c = (_b = nodeType.authoring) === null || _b === void 0 ? void 0 : _b.searchableText) !== null && _c !== void 0 ? _c : []), true).filter(Boolean)
1087
+ .join(" ")
1088
+ .toLowerCase();
1089
+ return haystack.includes(query.trim().toLowerCase());
1090
+ });
1091
+ return (_jsxs("div", { className: className, style: { display: "grid", gap: "1rem" }, children: [_jsx(SolidInput, { value: query, onChange: function (event) { return setQuery(event.target.value); }, placeholder: "Search node types" }), _jsx("div", { style: { display: "grid", gap: "0.75rem" }, children: filteredNodeTypes.map(function (nodeType) {
1092
+ var _a;
1093
+ return (_jsxs("button", { type: "button", onClick: function () { return onSelect === null || onSelect === void 0 ? void 0 : onSelect(nodeType); }, style: {
1094
+ textAlign: "left",
1095
+ border: value === nodeType.type
1096
+ ? "1px solid var(--primary-color, #2563eb)"
1097
+ : "1px solid var(--surface-border, #e5e7eb)",
1098
+ borderRadius: "0.75rem",
1099
+ padding: "0.9rem 1rem",
1100
+ background: "var(--surface-card, #fff)",
1101
+ display: "grid",
1102
+ gap: "0.5rem",
1103
+ cursor: "pointer",
1104
+ }, children: [_jsxs("div", { style: { display: "flex", gap: "0.5rem", alignItems: "center", flexWrap: "wrap" }, children: [_jsx("strong", { children: (_a = nodeType.label) !== null && _a !== void 0 ? _a : nodeType.type }), nodeType.category ? _jsx(SolidTag, { children: nodeType.category }) : null, _jsx(SolidTag, { children: nodeType.kind })] }), nodeType.description ? (_jsx("div", { style: { opacity: 0.8 }, children: nodeType.description })) : null] }, nodeType.type));
1105
+ }) })] }));
1106
+ }
1107
+ //# sourceMappingURL=WorkflowNodeSchemaEditor.js.map