@bpmn-nova/studio 0.3.9-preview → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +2 -2
  2. package/dist/canvas.js +97 -25
  3. package/dist/config.js +13 -0
  4. package/dist/context-menu.js +41 -32
  5. package/dist/controller.js +45 -19
  6. package/dist/flow-tree.d.ts +4 -0
  7. package/dist/flow-tree.js +14 -0
  8. package/dist/index.d.ts +47 -2
  9. package/dist/index.js +1 -0
  10. package/dist/interactions.js +6 -1
  11. package/dist/modules/bpmn-model/index.d.ts +2 -1
  12. package/dist/modules/bpmn-model/index.js +12 -10
  13. package/dist/modules/core/gateway.js +16 -13
  14. package/dist/modules/core/index.d.ts +6 -4
  15. package/dist/modules/core/model.js +12 -7
  16. package/dist/modules/designer/index.d.ts +5 -1
  17. package/dist/modules/designer/index.js +36 -15
  18. package/dist/modules/export-svg/index.d.ts +12 -5
  19. package/dist/modules/export-svg/preview.js +34 -24
  20. package/dist/modules/export-svg/render.js +102 -50
  21. package/dist/modules/flow-tree/controller.js +364 -0
  22. package/dist/modules/flow-tree/index.d.ts +248 -0
  23. package/dist/modules/flow-tree/index.js +5 -0
  24. package/dist/modules/flow-tree/operations.js +484 -0
  25. package/dist/modules/flow-tree/sample.js +445 -0
  26. package/dist/modules/flow-tree/schema.js +588 -0
  27. package/dist/modules/flow-tree/validate.js +125 -0
  28. package/dist/modules/flow-tree-bpmn/compiler.js +547 -0
  29. package/dist/modules/flow-tree-bpmn/decompiler.js +524 -0
  30. package/dist/modules/flow-tree-bpmn/expression.js +135 -0
  31. package/dist/modules/flow-tree-bpmn/index.d.ts +53 -0
  32. package/dist/modules/flow-tree-bpmn/index.js +14 -0
  33. package/dist/modules/flow-tree-renderer/canvas.js +1003 -0
  34. package/dist/modules/flow-tree-renderer/export-svg.js +325 -0
  35. package/dist/modules/flow-tree-renderer/index.d.ts +143 -0
  36. package/dist/modules/flow-tree-renderer/index.js +3 -0
  37. package/dist/modules/flow-tree-renderer/shell.js +970 -0
  38. package/dist/modules/i18n/index.d.ts +647 -0
  39. package/dist/modules/i18n/index.js +247 -0
  40. package/dist/modules/i18n/locales/en-US.js +1222 -0
  41. package/dist/modules/i18n/locales/zh-CN.js +1204 -0
  42. package/dist/modules/icons/index.js +23 -0
  43. package/dist/modules/node-presentation/index.d.ts +3 -2
  44. package/dist/modules/node-presentation/index.js +14 -11
  45. package/dist/modules/palette/index.d.ts +6 -1
  46. package/dist/modules/palette/index.js +26 -8
  47. package/dist/modules/palette/panel.js +44 -6
  48. package/dist/modules/properties/index.d.ts +2 -1
  49. package/dist/modules/properties/index.js +2 -2
  50. package/dist/modules/properties-activiti/index.js +84 -59
  51. package/dist/modules/properties-bpmn/index.js +151 -128
  52. package/dist/modules/properties-core/index.d.ts +9 -3
  53. package/dist/modules/properties-core/index.js +16 -4
  54. package/dist/modules/properties-flow-tree/index.d.ts +56 -0
  55. package/dist/modules/properties-flow-tree/index.js +2 -0
  56. package/dist/modules/properties-flow-tree/panel.js +1136 -0
  57. package/dist/modules/properties-flow-tree/widgets.js +625 -0
  58. package/dist/modules/properties-flowable/index.js +55 -34
  59. package/dist/modules/properties-renderer/index.d.ts +5 -1
  60. package/dist/modules/properties-renderer/index.js +110 -42
  61. package/dist/modules/renderer-svg/index.d.ts +6 -2
  62. package/dist/modules/renderer-svg/index.js +113 -38
  63. package/dist/modules/runtime/index.d.ts +33 -5
  64. package/dist/modules/runtime/index.js +97 -73
  65. package/dist/modules/runtime/time.js +89 -4
  66. package/dist/modules/runtime/visits.js +6 -4
  67. package/dist/modules/theme/index.d.ts +5 -2
  68. package/dist/modules/theme/index.js +8 -4
  69. package/dist/modules/viewer/index.d.ts +28 -7
  70. package/dist/modules/viewer/index.js +223 -58
  71. package/dist/modules/viewer/runtime-content.js +26 -20
  72. package/dist/modules/viewer/runtime-trace.js +43 -25
  73. package/dist/modules/viewer/timeline.js +103 -36
  74. package/dist/shell.js +258 -75
  75. package/dist/sidebars.js +3 -1
  76. package/dist/styles.css +2371 -2
  77. package/llms-full.txt +586 -47
  78. package/llms.txt +6 -5
  79. package/package.json +7 -3
@@ -0,0 +1,484 @@
1
+ import { resolveI18n } from '../i18n/index.js';
2
+ import {
3
+ FLOW_TREE_NODE_DEFINITIONS,
4
+ cloneFlowTree,
5
+ createFlowTreeBranch,
6
+ createFlowTreeNode,
7
+ createFlowTreeRoute,
8
+ flowTreeUid,
9
+ isBranchNode,
10
+ isRouteNode,
11
+ normalizeBranchPriorities,
12
+ } from './schema.js';
13
+
14
+ function walkSteps(steps, visitor, parentRef) {
15
+ if (!Array.isArray(steps)) return;
16
+ for (let index = 0; index < steps.length; index += 1) {
17
+ const step = steps[index];
18
+ visitor(step, { container: parentRef, steps, index });
19
+ if (isRouteNode(step)) {
20
+ for (let bIndex = 0; bIndex < (step.branches || []).length; bIndex += 1) {
21
+ const branch = step.branches[bIndex];
22
+ visitor(branch, { container: { kind: 'route', routeId: step.id }, route: step, branchIndex: bIndex });
23
+ walkSteps(branch.steps, visitor, { kind: 'branch', branchId: branch.id, routeId: step.id });
24
+ }
25
+ } else if (step.type === 'subFlow' && step.config?.subFlowMode === 'embedded' && Array.isArray(step.config.steps)) {
26
+ walkSteps(step.config.steps, visitor, { kind: 'embedded', subFlowId: step.id });
27
+ }
28
+ }
29
+ }
30
+
31
+ export function walkFlowTree(doc, visitor) {
32
+ if (!doc || typeof visitor !== 'function') return;
33
+ if (doc.starter) visitor(doc.starter, { container: { kind: 'root' } });
34
+ walkSteps(doc.steps, visitor, { kind: 'root' });
35
+ if (doc.end) visitor(doc.end, { container: { kind: 'root' } });
36
+ }
37
+
38
+ export function collectAllFlowTreeNodes(doc) {
39
+ const nodes = [];
40
+ walkFlowTree(doc, (node) => nodes.push(node));
41
+ return nodes;
42
+ }
43
+
44
+ export function countFlowTreeVisibleCards(doc) {
45
+ let count = 0;
46
+ walkFlowTree(doc, (node) => {
47
+ if (!isRouteNode(node)) count += 1;
48
+ });
49
+ return count;
50
+ }
51
+
52
+ export function countBranchSteps(branch) {
53
+ let count = 0;
54
+ const visit = (steps) => {
55
+ for (const step of steps || []) {
56
+ if (isRouteNode(step)) {
57
+ for (const childBranch of step.branches || []) {
58
+ count += 1;
59
+ visit(childBranch.steps);
60
+ }
61
+ } else {
62
+ count += 1;
63
+ }
64
+ }
65
+ };
66
+ visit(branch?.steps);
67
+ return count;
68
+ }
69
+
70
+ export function findFlowTreeNodeLocation(doc, nodeId) {
71
+ if (!doc || !nodeId) return null;
72
+ if (doc.starter?.id === nodeId) return { node: doc.starter, kind: 'starter', container: { kind: 'root' } };
73
+ if (doc.end?.id === nodeId) return { node: doc.end, kind: 'end', container: { kind: 'root' } };
74
+
75
+ let found = null;
76
+ walkSteps(doc.steps, (node, info) => {
77
+ if (!found && node.id === nodeId) {
78
+ found = { node, kind: isBranchNode(node) ? 'branch' : isRouteNode(node) ? 'route' : 'step', ...info };
79
+ }
80
+ }, { kind: 'root' });
81
+ return found;
82
+ }
83
+
84
+ export function findFlowTreeNode(doc, nodeId) {
85
+ return findFlowTreeNodeLocation(doc, nodeId)?.node || null;
86
+ }
87
+
88
+ export function resolveStepsContainer(doc, containerRef) {
89
+ if (!doc || !containerRef) return null;
90
+ if (containerRef.kind === 'root') return doc.steps;
91
+ if (containerRef.kind === 'branch') {
92
+ const loc = findFlowTreeNodeLocation(doc, containerRef.branchId);
93
+ return loc?.node && isBranchNode(loc.node) ? loc.node.steps : null;
94
+ }
95
+ if (containerRef.kind === 'embedded') {
96
+ const loc = findFlowTreeNodeLocation(doc, containerRef.subFlowId);
97
+ if (loc?.node?.type === 'subFlow') {
98
+ if (!Array.isArray(loc.node.config.steps)) loc.node.config.steps = [];
99
+ return loc.node.config.steps;
100
+ }
101
+ }
102
+ return null;
103
+ }
104
+
105
+ export function isFlowTreeDescendant(doc, ancestorId, targetId) {
106
+ if (!ancestorId || !targetId) return false;
107
+ if (ancestorId === targetId) return true;
108
+ const ancestor = findFlowTreeNode(doc, ancestorId);
109
+ if (!ancestor) return false;
110
+ let matched = false;
111
+ const scanSteps = (steps) => {
112
+ for (const step of steps || []) {
113
+ if (step.id === targetId) { matched = true; return; }
114
+ if (isRouteNode(step)) {
115
+ for (const branch of step.branches || []) {
116
+ if (branch.id === targetId) { matched = true; return; }
117
+ scanSteps(branch.steps);
118
+ if (matched) return;
119
+ }
120
+ } else if (step.type === 'subFlow' && Array.isArray(step.config?.steps)) {
121
+ scanSteps(step.config.steps);
122
+ if (matched) return;
123
+ }
124
+ }
125
+ };
126
+ if (isRouteNode(ancestor)) {
127
+ for (const branch of ancestor.branches || []) {
128
+ if (branch.id === targetId) return true;
129
+ scanSteps(branch.steps);
130
+ if (matched) return true;
131
+ }
132
+ } else if (isBranchNode(ancestor)) {
133
+ scanSteps(ancestor.steps);
134
+ } else if (ancestor.type === 'subFlow' && Array.isArray(ancestor.config?.steps)) {
135
+ scanSteps(ancestor.config.steps);
136
+ }
137
+ return matched;
138
+ }
139
+
140
+ export function insertStepAt(doc, containerRef, index, nodeTypeOrNode, overrides = {}, options = null) {
141
+ const steps = resolveStepsContainer(doc, containerRef);
142
+ if (!steps) return null;
143
+ const node = typeof nodeTypeOrNode === 'string'
144
+ ? createFlowTreeNode(nodeTypeOrNode, overrides, options)
145
+ : cloneFlowTree(nodeTypeOrNode);
146
+ const clamped = Math.max(0, Math.min(index, steps.length));
147
+ steps.splice(clamped, 0, node);
148
+ return node;
149
+ }
150
+
151
+ export function insertRouteAt(doc, containerRef, index, routeType, options = {}) {
152
+ const steps = resolveStepsContainer(doc, containerRef);
153
+ if (!steps) return null;
154
+ const clamped = Math.max(0, Math.min(index, steps.length));
155
+ const route = createFlowTreeRoute(routeType, {
156
+ branchCount: options.branchCount || 2,
157
+ name: options.name,
158
+ }, options);
159
+ if (options.wrapFollowingSteps && clamped < steps.length) {
160
+ const trailing = steps.splice(clamped);
161
+ route.branches[0].steps.push(...trailing);
162
+ }
163
+ steps.splice(clamped, 0, route);
164
+ normalizeBranchPriorities(route);
165
+ return route;
166
+ }
167
+
168
+ export function addBranchToRoute(doc, routeId, overrides = {}, options = null) {
169
+ const loc = findFlowTreeNodeLocation(doc, routeId);
170
+ if (!loc?.node || !isRouteNode(loc.node)) return null;
171
+ const route = loc.node;
172
+ const def = FLOW_TREE_NODE_DEFINITIONS[route.type];
173
+ const insertAt = def?.hasDefaultBranch
174
+ ? Math.max(0, route.branches.findIndex((item) => item.isDefault))
175
+ : route.branches.length;
176
+ const safeIndex = insertAt < 0 ? route.branches.length : insertAt;
177
+ const branch = createFlowTreeBranch(route.type, {
178
+ ...overrides,
179
+ priority: safeIndex + 1,
180
+ isDefault: false,
181
+ }, options);
182
+ route.branches.splice(safeIndex, 0, branch);
183
+ normalizeBranchPriorities(route);
184
+ return branch;
185
+ }
186
+
187
+ export function reorderRouteBranch(doc, routeId, fromIndex, toIndex) {
188
+ const loc = findFlowTreeNodeLocation(doc, routeId);
189
+ if (!loc?.node || !isRouteNode(loc.node)) return false;
190
+ const route = loc.node;
191
+ const def = FLOW_TREE_NODE_DEFINITIONS[route.type];
192
+ const maxMovable = def?.hasDefaultBranch ? route.branches.length - 2 : route.branches.length - 1;
193
+ if (fromIndex < 0 || fromIndex > maxMovable || toIndex < 0 || toIndex > maxMovable || fromIndex === toIndex) {
194
+ return false;
195
+ }
196
+ const [moved] = route.branches.splice(fromIndex, 1);
197
+ route.branches.splice(toIndex, 0, moved);
198
+ normalizeBranchPriorities(route);
199
+ return true;
200
+ }
201
+
202
+ function regenerateIds(node) {
203
+ const copy = cloneFlowTree(node);
204
+ const assign = (item) => {
205
+ item.id = flowTreeUid(item.type);
206
+ if (isRouteNode(item)) {
207
+ for (const branch of item.branches || []) {
208
+ branch.id = flowTreeUid(branch.type);
209
+ for (const child of branch.steps || []) assign(child);
210
+ }
211
+ } else if (item.type === 'subFlow' && Array.isArray(item.config?.steps)) {
212
+ for (const child of item.config.steps) assign(child);
213
+ }
214
+ };
215
+ assign(copy);
216
+ return copy;
217
+ }
218
+
219
+ export function duplicateFlowTreeNode(doc, nodeId) {
220
+ const loc = findFlowTreeNodeLocation(doc, nodeId);
221
+ if (!loc) return null;
222
+ if (loc.kind === 'starter' || loc.kind === 'end') return null;
223
+ if (loc.kind === 'branch' && loc.route) {
224
+ if (loc.node.isDefault) return null;
225
+ const copy = regenerateIds(loc.node);
226
+ copy.isDefault = false;
227
+ copy.name = `${loc.node.name} (2)`;
228
+ loc.route.branches.splice(loc.branchIndex + 1, 0, copy);
229
+ normalizeBranchPriorities(loc.route);
230
+ return copy;
231
+ }
232
+ if (Array.isArray(loc.steps)) {
233
+ const copy = regenerateIds(loc.node);
234
+ copy.name = `${loc.node.name} (2)`;
235
+ loc.steps.splice(loc.index + 1, 0, copy);
236
+ return copy;
237
+ }
238
+ return null;
239
+ }
240
+
241
+ export function removeFlowTreeNode(doc, nodeId) {
242
+ const loc = findFlowTreeNodeLocation(doc, nodeId);
243
+ if (!loc || loc.kind === 'starter' || loc.kind === 'end') return false;
244
+
245
+ if (loc.kind === 'branch' && loc.route) {
246
+ const route = loc.route;
247
+ const def = FLOW_TREE_NODE_DEFINITIONS[route.type];
248
+ if (def?.hasDefaultBranch && loc.node.isDefault && route.branches.length > 2) {
249
+ return false;
250
+ }
251
+ route.branches.splice(loc.branchIndex, 1);
252
+ if (route.branches.length < 2) {
253
+ // Auto-unwrap route container and promote remaining branch steps to parent container.
254
+ const routeLoc = findFlowTreeNodeLocation(doc, route.id);
255
+ if (routeLoc && Array.isArray(routeLoc.steps)) {
256
+ const remainingSteps = route.branches[0]?.steps || [];
257
+ routeLoc.steps.splice(routeLoc.index, 1, ...remainingSteps);
258
+ }
259
+ } else {
260
+ normalizeBranchPriorities(route);
261
+ }
262
+ return true;
263
+ }
264
+
265
+ if (Array.isArray(loc.steps)) {
266
+ loc.steps.splice(loc.index, 1);
267
+ return true;
268
+ }
269
+ return false;
270
+ }
271
+
272
+ export function canMoveFlowTreeNode(doc, nodeId, targetContainerRef) {
273
+ const loc = findFlowTreeNodeLocation(doc, nodeId);
274
+ if (!loc || !Array.isArray(loc.steps)) return false;
275
+ if (loc.kind === 'starter' || loc.kind === 'end' || loc.kind === 'branch') return false;
276
+ if (!targetContainerRef) return false;
277
+ if (targetContainerRef.kind === 'branch') {
278
+ if (isFlowTreeDescendant(doc, nodeId, targetContainerRef.branchId)) return false;
279
+ }
280
+ if (targetContainerRef.kind === 'embedded') {
281
+ if (isFlowTreeDescendant(doc, nodeId, targetContainerRef.subFlowId)) return false;
282
+ }
283
+ return Boolean(resolveStepsContainer(doc, targetContainerRef));
284
+ }
285
+
286
+ export function moveFlowTreeNode(doc, nodeId, targetContainerRef, targetIndex) {
287
+ if (!canMoveFlowTreeNode(doc, nodeId, targetContainerRef)) return false;
288
+ const sourceLoc = findFlowTreeNodeLocation(doc, nodeId);
289
+ const targetSteps = resolveStepsContainer(doc, targetContainerRef);
290
+ if (!sourceLoc || !targetSteps) return false;
291
+
292
+ const sameList = sourceLoc.steps === targetSteps;
293
+ let adjustedIndex = Math.max(0, Math.min(targetIndex, targetSteps.length));
294
+ if (sameList && (adjustedIndex === sourceLoc.index || adjustedIndex === sourceLoc.index + 1)) {
295
+ return false;
296
+ }
297
+ const [moved] = sourceLoc.steps.splice(sourceLoc.index, 1);
298
+ if (sameList && sourceLoc.index < adjustedIndex) adjustedIndex -= 1;
299
+ targetSteps.splice(adjustedIndex, 0, moved);
300
+ return true;
301
+ }
302
+
303
+ export function updateFlowTreeNode(doc, nodeId, patch = {}) {
304
+ const node = findFlowTreeNode(doc, nodeId);
305
+ if (!node) return false;
306
+ if (patch.config && typeof patch.config === 'object') {
307
+ node.config = { ...(node.config || {}), ...cloneFlowTree(patch.config) };
308
+ }
309
+ for (const [key, value] of Object.entries(patch)) {
310
+ if (key === 'config' || key === 'id' || key === 'type') continue;
311
+ node[key] = cloneFlowTree(value);
312
+ }
313
+ return true;
314
+ }
315
+
316
+ export function updateFlowTreeNodeConfig(doc, nodeId, configPatch = {}) {
317
+ const node = findFlowTreeNode(doc, nodeId);
318
+ if (!node) return false;
319
+ node.config = deepAssign(node.config || {}, configPatch);
320
+ return true;
321
+ }
322
+
323
+ function deepAssign(target, patch) {
324
+ const out = cloneFlowTree(target || {});
325
+ for (const [key, value] of Object.entries(patch || {})) {
326
+ if (value && typeof value === 'object' && !Array.isArray(value) && out[key] && typeof out[key] === 'object' && !Array.isArray(out[key])) {
327
+ out[key] = deepAssign(out[key], value);
328
+ } else {
329
+ out[key] = cloneFlowTree(value);
330
+ }
331
+ }
332
+ return out;
333
+ }
334
+
335
+ function listLabels(items = [], limit = 2) {
336
+ const labels = (items || []).map((item) => typeof item === 'string' ? item : (item?.name || item?.label || item?.id || '')).filter(Boolean);
337
+ if (!labels.length) return '';
338
+ if (labels.length <= limit) return labels.join('、');
339
+ return `${labels.slice(0, limit).join('、')} +${labels.length - limit}`;
340
+ }
341
+
342
+ export function formatFlowTreeNodeSummary(node, options = null) {
343
+ if (!node) return '';
344
+ const i18n = resolveI18n(options);
345
+ const t = (key, params) => i18n.t(key, params);
346
+ const customResolver = options?.nodeSummaryResolver;
347
+ const registry = options?.nodeRegistry;
348
+ const config = node.config || {};
349
+
350
+ let defaultSummary = '';
351
+
352
+ if (node.type === 'starter') {
353
+ if (config.starterScope === 'specified') {
354
+ const count = (config.targets?.users?.length || 0)
355
+ + (config.targets?.departments?.length || 0)
356
+ + (config.targets?.roles?.length || 0);
357
+ defaultSummary = count ? t('flowTree.summaries.starterSpecified', { count }) : t('flowTree.summaries.starterAll');
358
+ } else {
359
+ defaultSummary = t('flowTree.summaries.starterAll');
360
+ }
361
+ } else if (node.type === 'approver' || node.type === 'handler') {
362
+ const modeKey = node.type === 'approver' ? config.approvalMode : config.completionMode;
363
+ let assigneeText = '';
364
+ if (config.assigneeType === 'users') {
365
+ const names = listLabels(config.targets?.users);
366
+ if (names) assigneeText = t('flowTree.summaries.assigneeUsers', { names });
367
+ } else if (config.assigneeType === 'roles') {
368
+ const names = listLabels(config.targets?.roles);
369
+ if (names) assigneeText = t('flowTree.summaries.assigneeRoles', { names });
370
+ } else if (config.assigneeType === 'departments') {
371
+ const names = listLabels(config.targets?.departments);
372
+ if (names) assigneeText = t('flowTree.summaries.assigneeDepartments', { names });
373
+ } else if (config.assigneeType === 'supervisor') {
374
+ assigneeText = t('flowTree.summaries.assigneeSupervisor', { level: Number(config.supervisorLevel) || 1 });
375
+ } else if (config.assigneeType === 'multiLevelSupervisor') {
376
+ assigneeText = t('flowTree.summaries.assigneeMultiSupervisor', { endLevel: Number(config.supervisorEndLevel) || 2 });
377
+ } else if (config.assigneeType === 'selfSelect') {
378
+ assigneeText = t('flowTree.summaries.assigneeSelfSelect');
379
+ } else if (config.assigneeType === 'formUser') {
380
+ if (config.formUserField) assigneeText = t('flowTree.summaries.assigneeFormUser', { field: config.formUserField });
381
+ } else if (config.assigneeType === 'initiatorSelf') {
382
+ assigneeText = t('flowTree.summaries.assigneeInitiatorSelf');
383
+ } else if (config.assigneeType === 'expression') {
384
+ if (config.expression) assigneeText = t('flowTree.summaries.assigneeExpression', { expression: config.expression });
385
+ }
386
+
387
+ if (!assigneeText) {
388
+ defaultSummary = t('flowTree.canvas.unconfigured');
389
+ } else {
390
+ const modeLabel = modeKey === 'percentage'
391
+ ? t('flowTree.summaries.approvalMode.percentage', { percent: config.passPercentage ?? 60 })
392
+ : t(`flowTree.summaries.approvalMode.${modeKey || 'or'}`);
393
+ defaultSummary = `${assigneeText} · ${modeLabel}`;
394
+ }
395
+ } else if (node.type === 'cc') {
396
+ let text = '';
397
+ if (config.assigneeType === 'users') {
398
+ const names = listLabels(config.targets?.users);
399
+ if (names) text = t('flowTree.summaries.assigneeUsers', { names });
400
+ } else if (config.assigneeType === 'roles') {
401
+ const names = listLabels(config.targets?.roles);
402
+ if (names) text = t('flowTree.summaries.assigneeRoles', { names });
403
+ } else if (config.assigneeType === 'departments') {
404
+ const names = listLabels(config.targets?.departments);
405
+ if (names) text = t('flowTree.summaries.assigneeDepartments', { names });
406
+ } else if (config.assigneeType === 'supervisor') {
407
+ text = t('flowTree.summaries.assigneeSupervisor', { level: Number(config.supervisorLevel) || 1 });
408
+ } else if (config.assigneeType === 'formUser' && config.formUserField) {
409
+ text = t('flowTree.summaries.assigneeFormUser', { field: config.formUserField });
410
+ }
411
+ if (!text && config.allowStarterSelfSelect) text = t('flowTree.summaries.assigneeSelfSelect');
412
+ else if (text && config.allowStarterSelfSelect) text += t('flowTree.summaries.ccSelfSelectSuffix');
413
+ defaultSummary = text || t('flowTree.summaries.ccUnconfigured');
414
+ } else if (node.type === 'conditionBranch' || node.type === 'inclusiveBranch') {
415
+ if (node.isDefault) {
416
+ defaultSummary = t('flowTree.canvas.defaultBranchSummary');
417
+ } else if (config.mode === 'expression') {
418
+ defaultSummary = config.expression?.trim()
419
+ ? t('flowTree.summaries.conditionExpression', { expression: config.expression.trim() })
420
+ : t('flowTree.summaries.conditionUnconfigured');
421
+ } else {
422
+ const rules = (config.conditionGroups || []).flatMap((group) => (group.rules || []).filter((rule) => rule.field));
423
+ if (rules.length) {
424
+ if (rules.length <= 2) {
425
+ defaultSummary = rules.map((rule) => {
426
+ const opLabel = t(`flowTree.properties.condition.operators.${rule.operator}`);
427
+ const fieldLabel = rule.fieldLabel || rule.field;
428
+ if (rule.operator === 'isEmpty' || rule.operator === 'isNotEmpty') return `${fieldLabel} ${opLabel}`;
429
+ if (rule.operator === 'between') return `${fieldLabel} ${rule.value ?? ''} ~ ${rule.valueMax ?? ''}`;
430
+ return `${fieldLabel} ${opLabel} ${rule.value ?? ''}`;
431
+ }).join(';');
432
+ } else {
433
+ defaultSummary = t('flowTree.summaries.conditionRulesCount', { count: rules.length });
434
+ }
435
+ } else {
436
+ defaultSummary = t('flowTree.summaries.conditionUnconfigured');
437
+ }
438
+ }
439
+ } else if (node.type === 'parallelBranch') {
440
+ defaultSummary = t('flowTree.canvas.parallelBranchSummary');
441
+ } else if (node.type === 'delay') {
442
+ if (config.delayType === 'fixedDate') {
443
+ defaultSummary = config.fixedDate ? t('flowTree.summaries.delayFixedDate', { value: config.fixedDate }) : t('flowTree.summaries.delayUnconfigured');
444
+ } else if (config.delayType === 'cron') {
445
+ defaultSummary = config.cronExpression ? t('flowTree.summaries.delayCron', { value: config.cronExpression }) : t('flowTree.summaries.delayUnconfigured');
446
+ } else if (Number(config.duration) > 0) {
447
+ const unitKey = config.unit === 'minute' ? 'unitMinute' : config.unit === 'day' ? 'unitDay' : 'unitHour';
448
+ defaultSummary = t('flowTree.summaries.delayDuration', { value: config.duration, unit: t(`flowTree.properties.options.${unitKey}`) });
449
+ } else {
450
+ defaultSummary = t('flowTree.summaries.delayUnconfigured');
451
+ }
452
+ } else if (node.type === 'trigger') {
453
+ if (config.triggerType === 'webhook') {
454
+ defaultSummary = config.url ? t('flowTree.summaries.triggerWebhook', { method: config.method || 'POST', url: config.url }) : t('flowTree.summaries.triggerUnconfigured');
455
+ } else {
456
+ defaultSummary = config.implementation
457
+ ? t('flowTree.summaries.triggerService', { type: config.triggerType, value: config.implementation })
458
+ : t('flowTree.summaries.triggerUnconfigured');
459
+ }
460
+ } else if (node.type === 'subFlow') {
461
+ if (config.subFlowMode === 'embedded') {
462
+ defaultSummary = t('flowTree.summaries.subFlowEmbedded', { count: (config.steps || []).length });
463
+ } else {
464
+ defaultSummary = config.calledElement
465
+ ? t('flowTree.summaries.subFlowCall', { target: config.calledElement })
466
+ : t('flowTree.summaries.subFlowUnconfigured');
467
+ }
468
+ } else if (node.type === 'end') {
469
+ defaultSummary = t('flowTree.canvas.endSummary');
470
+ } else {
471
+ const customDef = registry?.resolve?.(node.type);
472
+ if (typeof customDef?.formatSummary === 'function') {
473
+ defaultSummary = customDef.formatSummary(node, { i18n }) || t('flowTree.canvas.unconfigured');
474
+ } else {
475
+ defaultSummary = t('flowTree.canvas.unconfigured');
476
+ }
477
+ }
478
+
479
+ if (typeof customResolver === 'function') {
480
+ const resolved = customResolver({ node, defaultSummary, document: options?.document || null });
481
+ if (typeof resolved === 'string') return resolved;
482
+ }
483
+ return defaultSummary;
484
+ }