@emaarco/bpmn-js-data-simulation 0.1.0 → 0.2.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 (117) hide show
  1. package/dist/domain/GatewayRouter.d.ts +11 -0
  2. package/dist/domain/GatewayRouter.d.ts.map +1 -0
  3. package/dist/domain/ScenarioError.d.ts +4 -0
  4. package/dist/domain/ScenarioError.d.ts.map +1 -0
  5. package/dist/domain/ScenarioParser.d.ts +7 -0
  6. package/dist/domain/ScenarioParser.d.ts.map +1 -0
  7. package/dist/domain/StartFieldCodec.d.ts +7 -0
  8. package/dist/domain/StartFieldCodec.d.ts.map +1 -0
  9. package/dist/domain/StartFieldDeriver.d.ts +7 -0
  10. package/dist/domain/StartFieldDeriver.d.ts.map +1 -0
  11. package/dist/domain/model.d.ts +32 -0
  12. package/dist/domain/model.d.ts.map +1 -1
  13. package/dist/engines/EngineRegistry.d.ts +6 -0
  14. package/dist/engines/EngineRegistry.d.ts.map +1 -0
  15. package/dist/engines/camunda7/Camunda7Engine.d.ts +17 -0
  16. package/dist/engines/camunda7/Camunda7Engine.d.ts.map +1 -0
  17. package/dist/engines/camunda7/juel/JuelError.d.ts +4 -0
  18. package/dist/engines/camunda7/juel/JuelError.d.ts.map +1 -0
  19. package/dist/engines/camunda7/juel/JuelEvaluator.d.ts +18 -0
  20. package/dist/engines/camunda7/juel/JuelEvaluator.d.ts.map +1 -0
  21. package/dist/engines/camunda7/juel/JuelLexer.d.ts +6 -0
  22. package/dist/engines/camunda7/juel/JuelLexer.d.ts.map +1 -0
  23. package/dist/engines/camunda7/juel/JuelParser.d.ts +19 -0
  24. package/dist/engines/camunda7/juel/JuelParser.d.ts.map +1 -0
  25. package/dist/engines/camunda7/juel/JuelTemplate.d.ts +11 -0
  26. package/dist/engines/camunda7/juel/JuelTemplate.d.ts.map +1 -0
  27. package/dist/engines/camunda7/juel/juelSyntax.d.ts +34 -0
  28. package/dist/engines/camunda7/juel/juelSyntax.d.ts.map +1 -0
  29. package/dist/engines/engines.d.ts +5 -0
  30. package/dist/engines/engines.d.ts.map +1 -0
  31. package/dist/engines/zeebe/ZeebeEngine.d.ts +21 -0
  32. package/dist/engines/zeebe/ZeebeEngine.d.ts.map +1 -0
  33. package/dist/index.cjs +1875 -1741
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.ts +10 -6
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +1870 -1737
  38. package/dist/index.js.map +1 -1
  39. package/dist/integration/DataGateways.d.ts +2 -1
  40. package/dist/integration/DataGateways.d.ts.map +1 -1
  41. package/dist/integration/DataSimulation.d.ts +2 -1
  42. package/dist/integration/DataSimulation.d.ts.map +1 -1
  43. package/dist/integration/DataSimulationOverlays.d.ts.map +1 -1
  44. package/dist/integration/DataSimulationPanel.d.ts +3 -0
  45. package/dist/integration/DataSimulationPanel.d.ts.map +1 -1
  46. package/dist/integration/DataSimulationToggle.d.ts +8 -0
  47. package/dist/integration/DataSimulationToggle.d.ts.map +1 -1
  48. package/dist/integration/DataStartForm.d.ts +5 -4
  49. package/dist/integration/DataStartForm.d.ts.map +1 -1
  50. package/dist/integration/IoMappings.d.ts +11 -0
  51. package/dist/integration/IoMappings.d.ts.map +1 -0
  52. package/dist/integration/VariableUsageCollector.d.ts +11 -0
  53. package/dist/integration/VariableUsageCollector.d.ts.map +1 -0
  54. package/dist/integration/behaviors/DataContextPads.d.ts +5 -0
  55. package/dist/integration/behaviors/DataContextPads.d.ts.map +1 -1
  56. package/dist/integration/behaviors/DataGatewayBehaviors.d.ts +2 -0
  57. package/dist/integration/behaviors/DataGatewayBehaviors.d.ts.map +1 -1
  58. package/dist/integration/behaviors/DataGatewaySettings.d.ts +2 -0
  59. package/dist/integration/behaviors/DataGatewaySettings.d.ts.map +1 -1
  60. package/dist/integration/tokenSimulation.d.ts +0 -3
  61. package/dist/integration/tokenSimulation.d.ts.map +1 -1
  62. package/dist/simulation/DataSimulationStore.d.ts +2 -2
  63. package/dist/simulation/DataSimulationStore.d.ts.map +1 -1
  64. package/dist/simulation/GatewayDecisionView.d.ts +10 -0
  65. package/dist/simulation/GatewayDecisionView.d.ts.map +1 -0
  66. package/dist/ui/DecisionCard.d.ts +8 -0
  67. package/dist/ui/DecisionCard.d.ts.map +1 -0
  68. package/dist/ui/OutcomeBadge.d.ts +6 -0
  69. package/dist/ui/OutcomeBadge.d.ts.map +1 -0
  70. package/dist/ui/SimpleStartForm.d.ts +15 -2
  71. package/dist/ui/SimpleStartForm.d.ts.map +1 -1
  72. package/dist/ui/SimpleStartFormRenderer.d.ts +6 -0
  73. package/dist/ui/SimpleStartFormRenderer.d.ts.map +1 -0
  74. package/dist/ui/StartDialog.d.ts +28 -4
  75. package/dist/ui/StartDialog.d.ts.map +1 -1
  76. package/dist/ui/VariablesPanel.d.ts +4 -0
  77. package/dist/ui/VariablesPanel.d.ts.map +1 -1
  78. package/dist/ui/startForm.d.ts +1 -2
  79. package/dist/ui/startForm.d.ts.map +1 -1
  80. package/dist/utils/badgePosition.d.ts +10 -0
  81. package/dist/utils/badgePosition.d.ts.map +1 -0
  82. package/dist/utils/diagramElements.d.ts +7 -0
  83. package/dist/utils/diagramElements.d.ts.map +1 -0
  84. package/dist/utils/dom.d.ts.map +1 -0
  85. package/dist/{engines → utils}/moddle.d.ts +1 -1
  86. package/dist/{engines → utils}/moddle.d.ts.map +1 -1
  87. package/dist/utils/objects.d.ts +3 -0
  88. package/dist/utils/objects.d.ts.map +1 -0
  89. package/dist/utils/popoverPlacement.d.ts.map +1 -0
  90. package/dist/utils/shadow.d.ts.map +1 -0
  91. package/dist/utils/variables.d.ts +5 -0
  92. package/dist/utils/variables.d.ts.map +1 -0
  93. package/package.json +9 -9
  94. package/dist/domain/routing.d.ts +0 -4
  95. package/dist/domain/routing.d.ts.map +0 -1
  96. package/dist/domain/scenario.d.ts +0 -13
  97. package/dist/domain/scenario.d.ts.map +0 -1
  98. package/dist/domain/startFields.d.ts +0 -31
  99. package/dist/domain/startFields.d.ts.map +0 -1
  100. package/dist/domain/variables.d.ts +0 -4
  101. package/dist/domain/variables.d.ts.map +0 -1
  102. package/dist/engines/camunda7/camunda7Engine.d.ts +0 -3
  103. package/dist/engines/camunda7/camunda7Engine.d.ts.map +0 -1
  104. package/dist/engines/camunda7/juel.d.ts +0 -32
  105. package/dist/engines/camunda7/juel.d.ts.map +0 -1
  106. package/dist/engines/index.d.ts +0 -7
  107. package/dist/engines/index.d.ts.map +0 -1
  108. package/dist/engines/zeebe/zeebeEngine.d.ts +0 -3
  109. package/dist/engines/zeebe/zeebeEngine.d.ts.map +0 -1
  110. package/dist/ui/dom.d.ts.map +0 -1
  111. package/dist/ui/overlayContent.d.ts +0 -5
  112. package/dist/ui/overlayContent.d.ts.map +0 -1
  113. package/dist/ui/popoverPlacement.d.ts.map +0 -1
  114. package/dist/ui/shadow.d.ts.map +0 -1
  115. /package/dist/{ui → utils}/dom.d.ts +0 -0
  116. /package/dist/{ui → utils}/popoverPlacement.d.ts +0 -0
  117. /package/dist/{ui → utils}/shadow.d.ts +0 -0
package/dist/index.js CHANGED
@@ -1,1951 +1,2084 @@
1
- import { parseExpression, evaluate } from 'feelin';
1
+ import { evaluate, parseExpression } from 'feelin';
2
2
 
3
- function routeGateway(kind, outgoing, evaluateCondition) {
4
- const conditional = outgoing.filter(flow => !flow.isDefault);
5
- const defaultFlow = outgoing.find(flow => flow.isDefault);
3
+ class GatewayRouter {
4
+ route(kind, outgoing, evaluateCondition) {
5
+ const conditional = outgoing.filter((flow) => !flow.isDefault);
6
+ const defaultFlow = outgoing.find((flow) => flow.isDefault);
6
7
  const evaluations = [];
7
8
  for (const flow of conditional) {
8
- const alreadyDecided = kind === 'exclusive' && evaluations.some(isDecisive);
9
- evaluations.push(alreadyDecided ? { flow, outcome: 'skipped' } : evaluateFlow(flow, evaluateCondition));
9
+ const alreadyDecided = kind === "exclusive" && evaluations.some((evaluation) => this.isDecisive(evaluation));
10
+ evaluations.push(alreadyDecided ? { flow, outcome: "skipped" } : this.evaluateFlow(flow, evaluateCondition));
10
11
  }
11
- const failed = evaluations.find(evaluation => evaluation.outcome === 'error');
12
+ const failed = evaluations.find((evaluation) => evaluation.outcome === "error");
12
13
  if (failed) {
13
- return stuck(evaluations, defaultFlow, `Condition of "${failed.flow.name ?? failed.flow.id}" failed: ${failed.reason}`);
14
+ return this.stuck(
15
+ evaluations,
16
+ defaultFlow,
17
+ `Condition of "${failed.flow.name ?? failed.flow.id}" failed: ${failed.reason}`
18
+ );
14
19
  }
15
- const taken = evaluations.filter(evaluation => evaluation.outcome === 'taken');
20
+ const taken = evaluations.filter((evaluation) => evaluation.outcome === "taken");
16
21
  if (taken.length) {
17
- return withDefault(evaluations, defaultFlow, 'not-taken', taken.map(evaluation => evaluation.flow.id));
22
+ return this.withDefault(
23
+ evaluations,
24
+ defaultFlow,
25
+ "not-taken",
26
+ taken.map((evaluation) => evaluation.flow.id)
27
+ );
18
28
  }
19
29
  if (defaultFlow) {
20
- return withDefault(evaluations, defaultFlow, 'taken', [defaultFlow.id]);
30
+ return this.withDefault(evaluations, defaultFlow, "taken", [defaultFlow.id]);
21
31
  }
22
- return stuck(evaluations, defaultFlow, 'No condition is true and there is no default flow');
23
- }
24
- function evaluateFlow(flow, evaluateCondition) {
25
- if (flow.expression === undefined) {
26
- return { flow, outcome: 'error', reason: 'Missing condition' };
32
+ return this.stuck(evaluations, defaultFlow, "No condition is true and there is no default flow");
33
+ }
34
+ evaluateFlow(flow, evaluateCondition) {
35
+ if (flow.expression === void 0) {
36
+ return { flow, outcome: "error", reason: "Missing condition" };
27
37
  }
28
38
  const evaluation = evaluateCondition(flow.expression);
29
39
  if (!evaluation.ok) {
30
- return { flow, outcome: 'error', reason: evaluation.reason };
31
- }
32
- if (typeof evaluation.value !== 'boolean') {
33
- return {
34
- flow,
35
- outcome: 'error',
36
- value: evaluation.value,
37
- reason: `Expected a boolean but got ${describe(evaluation.value)}`,
38
- };
39
- }
40
- return { flow, outcome: evaluation.value ? 'taken' : 'not-taken', value: evaluation.value };
41
- }
42
- function isDecisive(evaluation) {
43
- return evaluation.outcome === 'taken' || evaluation.outcome === 'error';
44
- }
45
- function withDefault(evaluations, defaultFlow, defaultOutcome, takenFlowIds) {
40
+ return { flow, outcome: "error", reason: evaluation.reason };
41
+ }
42
+ if (typeof evaluation.value !== "boolean") {
43
+ return {
44
+ flow,
45
+ outcome: "error",
46
+ value: evaluation.value,
47
+ reason: `Expected a boolean but got ${this.describe(evaluation.value)}`
48
+ };
49
+ }
50
+ return { flow, outcome: evaluation.value ? "taken" : "not-taken", value: evaluation.value };
51
+ }
52
+ isDecisive(evaluation) {
53
+ return evaluation.outcome === "taken" || evaluation.outcome === "error";
54
+ }
55
+ withDefault(evaluations, defaultFlow, defaultOutcome, takenFlowIds) {
46
56
  const flows = defaultFlow ? [...evaluations, { flow: defaultFlow, outcome: defaultOutcome }] : evaluations;
47
57
  return { flows, takenFlowIds };
48
- }
49
- function stuck(evaluations, defaultFlow, stuckReason) {
50
- return { ...withDefault(evaluations, defaultFlow, 'skipped', []), stuckReason };
51
- }
52
- function describe(value) {
53
- if (value === null || value === undefined)
54
- return 'null';
58
+ }
59
+ stuck(evaluations, defaultFlow, stuckReason) {
60
+ return { ...this.withDefault(evaluations, defaultFlow, "skipped", []), stuckReason };
61
+ }
62
+ describe(value) {
63
+ if (value === null || value === void 0) return "null";
55
64
  return `${typeof value} ${JSON.stringify(value)}`;
65
+ }
66
+ }
67
+
68
+ class ScenarioError extends Error {
69
+ constructor() {
70
+ super(...arguments);
71
+ this.name = "ScenarioError";
72
+ }
56
73
  }
57
74
 
58
75
  function setVariable(variables, path, value) {
59
- const [head, ...rest] = path.split('.');
60
- if (!rest.length) {
61
- return { ...variables, [head]: value };
62
- }
63
- const nested = variables[head];
64
- const nestedVariables = isVariables(nested) ? nested : {};
65
- return { ...variables, [head]: setVariable(nestedVariables, rest.join('.'), value) };
76
+ const [head, ...rest] = path.split(".");
77
+ if (!rest.length) {
78
+ return { ...variables, [head]: value };
79
+ }
80
+ const nested = variables[head];
81
+ const nestedVariables = isVariables(nested) ? nested : {};
82
+ return { ...variables, [head]: setVariable(nestedVariables, rest.join("."), value) };
66
83
  }
67
84
  function isVariables(value) {
68
- return typeof value === 'object' && value !== null && !Array.isArray(value);
85
+ return typeof value === "object" && value !== null && !Array.isArray(value);
69
86
  }
70
-
71
- class ScenarioError extends Error {
72
- constructor() {
73
- super(...arguments);
74
- this.name = 'ScenarioError';
75
- }
87
+ function withoutKeys(variables, keys) {
88
+ return Object.fromEntries(Object.entries(variables).filter(([key]) => !keys.includes(key)));
76
89
  }
77
- function parseScenarios(input) {
90
+
91
+ class ScenarioParser {
92
+ parse(input) {
78
93
  const list = isVariables(input) ? input.scenarios : input;
79
94
  if (!Array.isArray(list)) {
80
- throw new ScenarioError('Expected an array of scenarios or an object with a "scenarios" array');
95
+ throw new ScenarioError('Expected an array of scenarios or an object with a "scenarios" array');
81
96
  }
82
- const scenarios = list.map(parseScenario);
83
- assertUniqueIds(scenarios);
97
+ const scenarios = list.map((raw, index) => this.parseScenario(raw, index));
98
+ this.assertUniqueIds(scenarios);
84
99
  return scenarios;
85
- }
86
- function parseScenario(raw, index) {
100
+ }
101
+ parseScenario(raw, index) {
87
102
  if (!isVariables(raw)) {
88
- throw new ScenarioError(`Scenario #${index + 1} must be an object`);
103
+ throw new ScenarioError(`Scenario #${index + 1} must be an object`);
89
104
  }
90
105
  const { id, name, description, variables = {}, taskResults = {} } = raw;
91
- const label = typeof id === 'string' ? `"${id}"` : `#${index + 1}`;
92
- if (typeof id !== 'string' || !id) {
93
- throw new ScenarioError(`Scenario ${label} needs a non-empty string "id"`);
106
+ const label = typeof id === "string" ? `"${id}"` : `#${index + 1}`;
107
+ if (typeof id !== "string" || !id) {
108
+ throw new ScenarioError(`Scenario ${label} needs a non-empty string "id"`);
94
109
  }
95
- if (name !== undefined && typeof name !== 'string') {
96
- throw new ScenarioError(`Scenario ${label}: "name" must be a string`);
110
+ if (name !== void 0 && typeof name !== "string") {
111
+ throw new ScenarioError(`Scenario ${label}: "name" must be a string`);
97
112
  }
98
- if (description !== undefined && typeof description !== 'string') {
99
- throw new ScenarioError(`Scenario ${label}: "description" must be a string`);
113
+ if (description !== void 0 && typeof description !== "string") {
114
+ throw new ScenarioError(`Scenario ${label}: "description" must be a string`);
100
115
  }
101
116
  if (!isVariables(variables)) {
102
- throw new ScenarioError(`Scenario ${label}: "variables" must be an object`);
117
+ throw new ScenarioError(`Scenario ${label}: "variables" must be an object`);
103
118
  }
104
119
  if (!isVariables(taskResults) || !Object.values(taskResults).every(isVariables)) {
105
- throw new ScenarioError(`Scenario ${label}: "taskResults" must map element ids to objects`);
120
+ throw new ScenarioError(`Scenario ${label}: "taskResults" must map element ids to objects`);
106
121
  }
107
122
  return {
108
- id,
109
- name: name ?? id,
110
- ...(description === undefined ? {} : { description }),
111
- variables,
112
- taskResults: taskResults,
123
+ id,
124
+ name: name ?? id,
125
+ ...description === void 0 ? {} : { description },
126
+ variables,
127
+ taskResults
113
128
  };
114
- }
115
- function assertUniqueIds(scenarios) {
116
- const seen = new Set();
129
+ }
130
+ assertUniqueIds(scenarios) {
131
+ const seen = /* @__PURE__ */ new Set();
117
132
  for (const { id } of scenarios) {
118
- if (seen.has(id)) {
119
- throw new ScenarioError(`Duplicate scenario id "${id}"`);
120
- }
121
- seen.add(id);
133
+ if (seen.has(id)) {
134
+ throw new ScenarioError(`Duplicate scenario id "${id}"`);
135
+ }
136
+ seen.add(id);
122
137
  }
138
+ }
123
139
  }
124
140
 
125
- function deriveStartFields(usages, { examples = [], taskResultNames = [] } = {}) {
126
- const written = new Set([...usages.flatMap(usage => usage.outputTargets.map(topLevelName)), ...taskResultNames]);
127
- const usedBy = new Map();
128
- for (const usage of usages) {
129
- const localNames = new Set(usage.inputTargets.map(topLevelName));
130
- for (const name of [...usage.conditionReads, ...usage.inputReads, ...usage.outputReads]) {
131
- if (written.has(name) || localNames.has(name))
132
- continue;
133
- if (!usedBy.has(name))
134
- usedBy.set(name, new Set());
135
- usedBy.get(name).add(usage.elementName);
136
- }
137
- }
138
- return [...usedBy.entries()].map(([name, elements]) => ({
139
- name,
140
- type: inferType(examples.map(example => example[name]).find(value => value !== undefined)),
141
- usedBy: [...elements],
142
- }));
143
- }
144
- function parseFieldValue(field, raw) {
145
- if (typeof raw === 'boolean')
146
- return { ok: true, value: raw };
141
+ class StartFieldCodec {
142
+ parse(field, raw) {
143
+ if (typeof raw === "boolean") return { ok: true, value: raw };
147
144
  const text = raw.trim();
148
- if (!text)
149
- return { ok: true, value: undefined };
145
+ if (!text) return { ok: true, value: void 0 };
150
146
  switch (field.type) {
151
- case 'number': {
152
- const value = Number(text);
153
- return Number.isNaN(value) ? { ok: false, reason: `${field.name} must be a number` } : { ok: true, value };
147
+ case "number": {
148
+ const value = Number(text);
149
+ return Number.isNaN(value) ? { ok: false, reason: `${field.name} must be a number` } : { ok: true, value };
150
+ }
151
+ case "json":
152
+ try {
153
+ return { ok: true, value: JSON.parse(text) };
154
+ } catch {
155
+ return { ok: false, reason: `${field.name} must be valid JSON` };
156
+ }
157
+ case "auto":
158
+ try {
159
+ return { ok: true, value: JSON.parse(text) };
160
+ } catch {
161
+ return { ok: true, value: raw };
154
162
  }
155
- case 'json':
156
- try {
157
- return { ok: true, value: JSON.parse(text) };
158
- }
159
- catch {
160
- return { ok: false, reason: `${field.name} must be valid JSON` };
161
- }
162
- case 'auto':
163
- try {
164
- return { ok: true, value: JSON.parse(text) };
165
- }
166
- catch {
167
- return { ok: true, value: raw };
168
- }
169
- default:
170
- return { ok: true, value: raw };
163
+ default:
164
+ return { ok: true, value: raw };
171
165
  }
172
- }
173
- function formatFieldValue(field, value) {
174
- if (field.type === 'boolean')
175
- return value === true;
176
- if (value === undefined || value === null)
177
- return '';
178
- if (typeof value === 'string' && field.type !== 'json')
179
- return value;
180
- return field.type === 'number' ? String(value) : JSON.stringify(value);
181
- }
182
- function applyFieldValues(base, values) {
166
+ }
167
+ format(field, value) {
168
+ if (field.type === "boolean") return value === true;
169
+ if (value === void 0 || value === null) return "";
170
+ if (typeof value === "string" && field.type !== "json") return value;
171
+ return field.type === "number" ? String(value) : JSON.stringify(value);
172
+ }
173
+ apply(base, values) {
183
174
  const variables = { ...base };
184
175
  for (const [name, value] of Object.entries(values)) {
185
- if (value === undefined)
186
- delete variables[name];
187
- else
188
- variables[name] = value;
176
+ if (value === void 0) delete variables[name];
177
+ else variables[name] = value;
189
178
  }
190
179
  return variables;
191
- }
192
- function topLevelName(path) {
193
- return path.split('.')[0];
194
- }
195
- function inferType(example) {
196
- if (typeof example === 'number')
197
- return 'number';
198
- if (typeof example === 'boolean')
199
- return 'boolean';
200
- if (typeof example === 'string')
201
- return 'text';
202
- if (Array.isArray(example) || isVariables(example))
203
- return 'json';
204
- return 'auto';
180
+ }
205
181
  }
206
182
 
207
183
  function findExtension(element, type) {
208
- const extensionElements = element.extensionElements;
209
- return extensionElements?.values?.find(value => value.$type === type);
184
+ const extensionElements = element.extensionElements;
185
+ return extensionElements?.values?.find((value) => value.$type === type);
210
186
  }
211
187
  function listProperty(element, property) {
212
- const value = element?.[property];
213
- return Array.isArray(value) ? value : [];
188
+ const value = element?.[property];
189
+ return Array.isArray(value) ? value : [];
214
190
  }
215
191
  function readConditionExpression(sequenceFlow) {
216
- const condition = sequenceFlow.conditionExpression;
217
- if (!condition)
218
- return undefined;
219
- return {
220
- body: typeof condition.body === 'string' ? condition.body : undefined,
221
- language: typeof condition.language === 'string' ? condition.language : undefined,
222
- };
192
+ const condition = sequenceFlow.conditionExpression;
193
+ if (!condition) return void 0;
194
+ return {
195
+ body: typeof condition.body === "string" ? condition.body : void 0,
196
+ language: typeof condition.language === "string" ? condition.language : void 0
197
+ };
223
198
  }
224
199
 
225
200
  class JuelError extends Error {
226
- constructor() {
227
- super(...arguments);
228
- this.name = 'JuelError';
229
- }
230
- }
231
- const KEYWORD_OPERATORS = {
232
- and: '&&',
233
- or: '||',
234
- not: '!',
235
- eq: '==',
236
- ne: '!=',
237
- lt: '<',
238
- gt: '>',
239
- le: '<=',
240
- ge: '>=',
241
- div: '/',
242
- mod: '%',
243
- empty: 'empty',
244
- };
245
- const SYMBOL_OPERATORS = [
246
- '==',
247
- '!=',
248
- '<=',
249
- '>=',
250
- '&&',
251
- '||',
252
- '<',
253
- '>',
254
- '!',
255
- '+',
256
- '-',
257
- '*',
258
- '/',
259
- '%',
260
- '(',
261
- ')',
262
- '[',
263
- ']',
264
- '.',
265
- '?',
266
- ':',
267
- ];
268
- function parseJuelTemplate(text) {
269
- const parts = [];
270
- let cursor = 0;
271
- while (cursor < text.length) {
272
- const start = findExpressionStart(text, cursor);
273
- if (start === -1) {
274
- parts.push(text.slice(cursor));
275
- break;
276
- }
277
- if (start > cursor)
278
- parts.push(text.slice(cursor, start));
279
- const end = findExpressionEnd(text, start + 2);
280
- parts.push(parseJuelExpression(text.slice(start + 2, end)));
281
- cursor = end + 1;
282
- }
283
- return parts;
284
- }
285
- function evaluateJuelTemplate(template, variables) {
286
- if (template.length === 1 && typeof template[0] !== 'string') {
287
- return evaluateNode(template[0], variables);
288
- }
289
- return template
290
- .map(part => (typeof part === 'string' ? part : coerceToString(evaluateNode(part, variables))))
291
- .join('');
201
+ constructor() {
202
+ super(...arguments);
203
+ this.name = "JuelError";
204
+ }
292
205
  }
293
- function readJuelVariableNames(template) {
294
- const names = new Set();
295
- const visit = (node) => {
296
- if (node.type === 'identifier')
297
- names.add(node.name);
298
- if (node.type === 'member') {
299
- visit(node.object);
300
- visit(node.property);
301
- }
302
- if (node.type === 'unary')
303
- visit(node.operand);
304
- if (node.type === 'binary') {
305
- visit(node.left);
306
- visit(node.right);
307
- }
308
- if (node.type === 'conditional') {
309
- visit(node.test);
310
- visit(node.consequent);
311
- visit(node.alternate);
312
- }
313
- };
314
- template.forEach(part => typeof part !== 'string' && visit(part));
315
- return [...names];
316
- }
317
- function findExpressionStart(text, from) {
318
- const dollar = text.indexOf('${', from);
319
- const hash = text.indexOf('#{', from);
320
- if (dollar === -1)
321
- return hash;
322
- if (hash === -1)
323
- return dollar;
324
- return Math.min(dollar, hash);
325
- }
326
- function findExpressionEnd(text, from) {
327
- let quote = null;
328
- for (let index = from; index < text.length; index++) {
329
- const char = text[index];
330
- if (quote) {
331
- if (char === '\\')
332
- index++;
333
- else if (char === quote)
334
- quote = null;
335
- }
336
- else if (char === "'" || char === '"') {
337
- quote = char;
338
- }
339
- else if (char === '}') {
340
- return index;
341
- }
342
- }
343
- throw new JuelError('Unterminated expression, missing "}"');
344
- }
345
- function parseJuelExpression(source) {
346
- const parser = new Parser(tokenize(source));
347
- const node = parser.parseExpression();
348
- parser.expectEnd();
349
- return node;
350
- }
351
- function tokenize(source) {
352
- const tokens = [];
353
- let index = 0;
354
- while (index < source.length) {
355
- const char = source[index];
356
- if (/\s/.test(char)) {
357
- index++;
358
- }
359
- else if (/[0-9]/.test(char) || (char === '.' && /[0-9]/.test(source[index + 1] ?? ''))) {
360
- const match = /^[0-9]*\.?[0-9]+(?:[eE][+-]?[0-9]+)?/.exec(source.slice(index));
361
- tokens.push({ kind: 'number', text: match[0], value: Number(match[0]) });
362
- index += match[0].length;
363
- }
364
- else if (char === "'" || char === '"') {
365
- const { value, length } = readString(source, index);
366
- tokens.push({ kind: 'string', text: source.slice(index, index + length), value });
367
- index += length;
368
- }
369
- else if (/[A-Za-z_$]/.test(char)) {
370
- const match = /^[A-Za-z_$][A-Za-z0-9_$]*/.exec(source.slice(index));
371
- const word = match[0];
372
- const keywordOperator = hasOwn(KEYWORD_OPERATORS, word) ? KEYWORD_OPERATORS[word] : undefined;
373
- tokens.push(keywordOperator ? { kind: 'operator', text: keywordOperator } : { kind: 'identifier', text: word });
374
- index += word.length;
375
- }
376
- else {
377
- const operator = SYMBOL_OPERATORS.find(candidate => source.startsWith(candidate, index));
378
- if (!operator)
379
- throw new JuelError(`Unexpected character "${char}"`);
380
- tokens.push({ kind: 'operator', text: operator });
381
- index += operator.length;
382
- }
383
- }
384
- return tokens;
385
- }
386
- function readString(source, start) {
387
- const quote = source[start];
388
- let value = '';
389
- for (let index = start + 1; index < source.length; index++) {
390
- const char = source[index];
391
- if (char === '\\') {
392
- value += source[index + 1] ?? '';
393
- index++;
394
- }
395
- else if (char === quote) {
396
- return { value, length: index - start + 1 };
397
- }
398
- else {
399
- value += char;
400
- }
401
- }
402
- throw new JuelError('Unterminated string literal');
403
- }
404
- class Parser {
405
- constructor(tokens) {
406
- this.tokens = tokens;
407
- this.position = 0;
408
- }
409
- parseExpression() {
410
- const test = this.parseBinary(0);
411
- if (!this.accept('?'))
412
- return test;
413
- const consequent = this.parseExpression();
414
- this.expect(':');
415
- const alternate = this.parseExpression();
416
- return { type: 'conditional', test, consequent, alternate };
417
- }
418
- expectEnd() {
419
- const token = this.peek();
420
- if (token)
421
- throw new JuelError(`Unexpected "${token.text}"`);
422
- }
423
- parseBinary(level) {
424
- if (level === Parser.PRECEDENCE.length)
425
- return this.parseUnary();
426
- let left = this.parseBinary(level + 1);
427
- let operator = this.acceptAny(Parser.PRECEDENCE[level]);
428
- while (operator) {
429
- const right = this.parseBinary(level + 1);
430
- left = { type: 'binary', operator, left, right };
431
- operator = this.acceptAny(Parser.PRECEDENCE[level]);
432
- }
433
- return left;
434
- }
435
- parseUnary() {
436
- const operator = this.acceptAny(['!', '-', 'empty']);
437
- if (operator)
438
- return { type: 'unary', operator, operand: this.parseUnary() };
439
- return this.parseMember();
440
- }
441
- parseMember() {
442
- let node = this.parsePrimary();
443
- for (;;) {
444
- if (this.accept('.')) {
445
- const property = this.next();
446
- if (property?.kind !== 'identifier')
447
- throw new JuelError('Expected a property name after "."');
448
- node = { type: 'member', object: node, property: { type: 'literal', value: property.text } };
449
- }
450
- else if (this.accept('[')) {
451
- node = { type: 'member', object: node, property: this.parseExpression() };
452
- this.expect(']');
453
- }
454
- else if (this.peek()?.text === '(') {
455
- throw new JuelError('Method calls are not supported');
456
- }
457
- else {
458
- return node;
459
- }
460
- }
461
- }
462
- parsePrimary() {
463
- const token = this.next();
464
- if (!token)
465
- throw new JuelError('Unexpected end of expression');
466
- if (token.kind === 'number' || token.kind === 'string')
467
- return { type: 'literal', value: token.value };
468
- if (token.kind === 'identifier')
469
- return identifierOrLiteral(token.text);
470
- if (token.text === '(') {
471
- const node = this.parseExpression();
472
- this.expect(')');
473
- return node;
474
- }
475
- throw new JuelError(`Unexpected "${token.text}"`);
476
- }
477
- peek() {
478
- return this.tokens[this.position];
479
- }
480
- next() {
481
- return this.tokens[this.position++];
482
- }
483
- accept(text) {
484
- if (this.peek()?.kind !== 'operator' || this.peek()?.text !== text)
485
- return false;
486
- this.position++;
487
- return true;
488
- }
489
- acceptAny(operators) {
490
- return operators.find(operator => this.accept(operator));
491
- }
492
- expect(text) {
493
- if (!this.accept(text))
494
- throw new JuelError(`Expected "${text}"`);
495
- }
206
+
207
+ function hasOwn(object, key) {
208
+ return Object.prototype.hasOwnProperty.call(object, key);
496
209
  }
497
- Parser.PRECEDENCE = [
498
- ['||'],
499
- ['&&'],
500
- ['==', '!='],
501
- ['<', '>', '<=', '>='],
502
- ['+', '-'],
503
- ['*', '/', '%'],
504
- ];
505
- function identifierOrLiteral(name) {
506
- if (name === 'true')
507
- return { type: 'literal', value: true };
508
- if (name === 'false')
509
- return { type: 'literal', value: false };
510
- if (name === 'null')
511
- return { type: 'literal', value: null };
512
- return { type: 'identifier', name };
210
+ function deepEqual(left, right) {
211
+ if (left === right) return true;
212
+ if (typeof left !== "object" || typeof right !== "object" || left === null || right === null) return false;
213
+ if (Array.isArray(left) !== Array.isArray(right)) return false;
214
+ const leftKeys = Object.keys(left);
215
+ const rightKeys = Object.keys(right);
216
+ return leftKeys.length === rightKeys.length && leftKeys.every(
217
+ (key) => hasOwn(right, key) && deepEqual(left[key], right[key])
218
+ );
513
219
  }
514
- function evaluateNode(node, variables) {
220
+
221
+ class JuelEvaluator {
222
+ constructor(variables) {
223
+ this.variables = variables;
224
+ }
225
+ evaluate(node) {
515
226
  switch (node.type) {
516
- case 'literal':
517
- return node.value;
518
- case 'identifier':
519
- if (!hasOwn(variables, node.name))
520
- throw new JuelError(`Unknown property used in expression: ${node.name}`);
521
- return variables[node.name];
522
- case 'member':
523
- return readMember(evaluateNode(node.object, variables), evaluateNode(node.property, variables));
524
- case 'unary':
525
- return evaluateUnary(node.operator, evaluateNode(node.operand, variables));
526
- case 'conditional':
527
- return coerceToBoolean(evaluateNode(node.test, variables))
528
- ? evaluateNode(node.consequent, variables)
529
- : evaluateNode(node.alternate, variables);
530
- case 'binary':
531
- return evaluateBinary(node, variables);
532
- }
533
- }
534
- function readMember(object, property) {
535
- if (object === null || object === undefined)
536
- return null;
227
+ case "literal":
228
+ return node.value;
229
+ case "identifier":
230
+ if (!hasOwn(this.variables, node.name)) {
231
+ throw new JuelError(`Unknown property used in expression: ${node.name}`);
232
+ }
233
+ return this.variables[node.name];
234
+ case "member":
235
+ return this.readMember(this.evaluate(node.object), this.evaluate(node.property));
236
+ case "unary":
237
+ return this.evaluateUnary(node.operator, this.evaluate(node.operand));
238
+ case "conditional":
239
+ return this.coerceToBoolean(this.evaluate(node.test)) ? this.evaluate(node.consequent) : this.evaluate(node.alternate);
240
+ case "binary":
241
+ return this.evaluateBinary(node);
242
+ }
243
+ }
244
+ coerceToString(value) {
245
+ if (value === null || value === void 0) return "";
246
+ return typeof value === "object" ? JSON.stringify(value) : String(value);
247
+ }
248
+ readMember(object, property) {
249
+ if (object === null || object === void 0) return null;
537
250
  const key = Array.isArray(object) ? Number(property) : String(property);
538
- return hasOwn(object, key) ? (object[key] ?? null) : null;
539
- }
540
- function hasOwn(object, key) {
541
- return Object.prototype.hasOwnProperty.call(object, key);
542
- }
543
- function evaluateUnary(operator, operand) {
544
- if (operator === '!')
545
- return !coerceToBoolean(operand);
546
- if (operator === '-')
547
- return -coerceToNumber(operand);
548
- return isEmpty(operand);
549
- }
550
- function evaluateBinary(node, variables) {
251
+ return hasOwn(object, key) ? object[key] ?? null : null;
252
+ }
253
+ evaluateUnary(operator, operand) {
254
+ if (operator === "!") return !this.coerceToBoolean(operand);
255
+ if (operator === "-") return -this.coerceToNumber(operand);
256
+ return this.isEmpty(operand);
257
+ }
258
+ evaluateBinary(node) {
551
259
  const { operator } = node;
552
- if (operator === '&&') {
553
- return coerceToBoolean(evaluateNode(node.left, variables)) && coerceToBoolean(evaluateNode(node.right, variables));
260
+ if (operator === "&&") {
261
+ return this.coerceToBoolean(this.evaluate(node.left)) && this.coerceToBoolean(this.evaluate(node.right));
554
262
  }
555
- if (operator === '||') {
556
- return coerceToBoolean(evaluateNode(node.left, variables)) || coerceToBoolean(evaluateNode(node.right, variables));
263
+ if (operator === "||") {
264
+ return this.coerceToBoolean(this.evaluate(node.left)) || this.coerceToBoolean(this.evaluate(node.right));
557
265
  }
558
- const left = evaluateNode(node.left, variables);
559
- const right = evaluateNode(node.right, variables);
266
+ const left = this.evaluate(node.left);
267
+ const right = this.evaluate(node.right);
268
+ const eitherIsNull = this.isNull(left) || this.isNull(right);
269
+ const bothAreNull = this.isNull(left) && this.isNull(right);
560
270
  switch (operator) {
561
- case '==':
562
- return areEqual(left, right);
563
- case '!=':
564
- return !areEqual(left, right);
565
- case '<':
566
- return isNull(left) || isNull(right) ? false : compare(left, right) < 0;
567
- case '>':
568
- return isNull(left) || isNull(right) ? false : compare(left, right) > 0;
569
- case '<=':
570
- return isNull(left) || isNull(right) ? isNull(left) && isNull(right) : compare(left, right) <= 0;
571
- case '>=':
572
- return isNull(left) || isNull(right) ? isNull(left) && isNull(right) : compare(left, right) >= 0;
573
- case '+':
574
- return coerceToNumber(left) + coerceToNumber(right);
575
- case '-':
576
- return coerceToNumber(left) - coerceToNumber(right);
577
- case '*':
578
- return coerceToNumber(left) * coerceToNumber(right);
579
- case '/':
580
- return coerceToNumber(left) / coerceToNumber(right);
581
- default:
582
- return coerceToNumber(left) % coerceToNumber(right);
583
- }
584
- }
585
- function isNull(value) {
586
- return value === null || value === undefined;
587
- }
588
- function areEqual(left, right) {
589
- if (left === right)
590
- return true;
591
- if (isNull(left) || isNull(right))
592
- return isNull(left) && isNull(right);
593
- if (typeof left === 'number' || typeof right === 'number')
594
- return coerceToNumber(left) === coerceToNumber(right);
595
- if (typeof left === 'boolean' || typeof right === 'boolean')
596
- return coerceToBoolean(left) === coerceToBoolean(right);
597
- if (typeof left === 'object' || typeof right === 'object')
598
- return deepEqual(left, right);
271
+ case "==":
272
+ return this.areEqual(left, right);
273
+ case "!=":
274
+ return !this.areEqual(left, right);
275
+ case "<":
276
+ return eitherIsNull ? false : this.compare(left, right) < 0;
277
+ case ">":
278
+ return eitherIsNull ? false : this.compare(left, right) > 0;
279
+ case "<=":
280
+ return eitherIsNull ? bothAreNull : this.compare(left, right) <= 0;
281
+ case ">=":
282
+ return eitherIsNull ? bothAreNull : this.compare(left, right) >= 0;
283
+ case "+":
284
+ return this.coerceToNumber(left) + this.coerceToNumber(right);
285
+ case "-":
286
+ return this.coerceToNumber(left) - this.coerceToNumber(right);
287
+ case "*":
288
+ return this.coerceToNumber(left) * this.coerceToNumber(right);
289
+ case "/":
290
+ return this.coerceToNumber(left) / this.coerceToNumber(right);
291
+ default:
292
+ return this.coerceToNumber(left) % this.coerceToNumber(right);
293
+ }
294
+ }
295
+ isNull(value) {
296
+ return value === null || value === void 0;
297
+ }
298
+ areEqual(left, right) {
299
+ if (left === right) return true;
300
+ if (this.isNull(left) || this.isNull(right)) return this.isNull(left) && this.isNull(right);
301
+ if (typeof left === "number" || typeof right === "number") {
302
+ return this.coerceToNumber(left) === this.coerceToNumber(right);
303
+ }
304
+ if (typeof left === "boolean" || typeof right === "boolean") {
305
+ return this.coerceToBoolean(left) === this.coerceToBoolean(right);
306
+ }
307
+ if (typeof left === "object" || typeof right === "object") return deepEqual(left, right);
599
308
  return String(left) === String(right);
600
- }
601
- function deepEqual(left, right) {
602
- if (left === right)
603
- return true;
604
- if (typeof left !== 'object' || typeof right !== 'object' || left === null || right === null)
605
- return false;
606
- if (Array.isArray(left) !== Array.isArray(right))
607
- return false;
608
- const leftKeys = Object.keys(left);
609
- const rightKeys = Object.keys(right);
610
- return (leftKeys.length === rightKeys.length &&
611
- leftKeys.every(key => hasOwn(right, key) &&
612
- deepEqual(left[key], right[key])));
613
- }
614
- function compare(left, right) {
615
- if (typeof left === 'string' && typeof right === 'string')
616
- return left < right ? -1 : left > right ? 1 : 0;
617
- return coerceToNumber(left) - coerceToNumber(right);
618
- }
619
- function coerceToNumber(value) {
620
- if (value === null || value === undefined || value === '')
621
- return 0;
622
- const number = typeof value === 'number' ? value : Number(value);
623
- if (typeof value === 'boolean' || Number.isNaN(number)) {
624
- throw new JuelError(`Cannot coerce ${JSON.stringify(value)} to a number`);
309
+ }
310
+ compare(left, right) {
311
+ if (typeof left === "string" && typeof right === "string") return left < right ? -1 : left > right ? 1 : 0;
312
+ return this.coerceToNumber(left) - this.coerceToNumber(right);
313
+ }
314
+ coerceToNumber(value) {
315
+ if (value === null || value === void 0 || value === "") return 0;
316
+ const number = typeof value === "number" ? value : Number(value);
317
+ if (typeof value === "boolean" || Number.isNaN(number)) {
318
+ throw new JuelError(`Cannot coerce ${JSON.stringify(value)} to a number`);
625
319
  }
626
320
  return number;
627
- }
628
- function coerceToBoolean(value) {
629
- if (typeof value === 'boolean')
630
- return value;
631
- if (value === null || value === undefined || value === '')
632
- return false;
633
- if (typeof value === 'string')
634
- return value.toLowerCase() === 'true';
321
+ }
322
+ coerceToBoolean(value) {
323
+ if (typeof value === "boolean") return value;
324
+ if (value === null || value === void 0 || value === "") return false;
325
+ if (typeof value === "string") return value.toLowerCase() === "true";
635
326
  throw new JuelError(`Cannot coerce ${JSON.stringify(value)} to a boolean`);
636
- }
637
- function coerceToString(value) {
638
- if (value === null || value === undefined)
639
- return '';
640
- return typeof value === 'object' ? JSON.stringify(value) : String(value);
641
- }
642
- function isEmpty(value) {
643
- if (value === null || value === undefined || value === '')
644
- return true;
645
- if (Array.isArray(value))
646
- return value.length === 0;
647
- if (typeof value === 'object')
648
- return Object.keys(value).length === 0;
327
+ }
328
+ isEmpty(value) {
329
+ if (value === null || value === void 0 || value === "") return true;
330
+ if (Array.isArray(value)) return value.length === 0;
331
+ if (typeof value === "object") return Object.keys(value).length === 0;
649
332
  return false;
333
+ }
650
334
  }
651
335
 
652
- const camunda7Engine = {
653
- id: 'camunda7',
654
- label: 'Camunda 7',
655
- expressionLanguage: 'JUEL',
656
- taskResultPropagation: 'always',
657
- writeVariable: (variables, target, value) => ({ ...variables, [target]: value }),
658
- readInputMappings: element => readMappings$1(element, 'inputParameters'),
659
- readOutputMappings: element => readMappings$1(element, 'outputParameters'),
660
- readCondition,
661
- canEvaluate,
662
- evaluate: evaluateCamundaExpression,
663
- readVariableNames: readVariableNames$1,
336
+ const KEYWORD_OPERATORS = {
337
+ and: "&&",
338
+ or: "||",
339
+ not: "!",
340
+ eq: "==",
341
+ ne: "!=",
342
+ lt: "<",
343
+ gt: ">",
344
+ le: "<=",
345
+ ge: ">=",
346
+ div: "/",
347
+ mod: "%",
348
+ empty: "empty"
664
349
  };
665
- function readMappings$1(element, property) {
666
- const inputOutput = findExtension(element, 'camunda:InputOutput');
667
- return listProperty(inputOutput, property)
668
- .filter(parameter => typeof parameter.name === 'string' && parameter.name && !parameter.definition)
669
- .map(parameter => ({
670
- source: typeof parameter.value === 'string' ? parameter.value : '',
671
- target: parameter.name,
672
- }));
350
+ const SYMBOL_OPERATORS = [
351
+ "==",
352
+ "!=",
353
+ "<=",
354
+ ">=",
355
+ "&&",
356
+ "||",
357
+ "<",
358
+ ">",
359
+ "!",
360
+ "+",
361
+ "-",
362
+ "*",
363
+ "/",
364
+ "%",
365
+ "(",
366
+ ")",
367
+ "[",
368
+ "]",
369
+ ".",
370
+ "?",
371
+ ":"
372
+ ];
373
+ const BINARY_PRECEDENCE = [
374
+ ["||"],
375
+ ["&&"],
376
+ ["==", "!="],
377
+ ["<", ">", "<=", ">="],
378
+ ["+", "-"],
379
+ ["*", "/", "%"]
380
+ ];
381
+
382
+ class JuelLexer {
383
+ tokenize(source) {
384
+ const tokens = [];
385
+ let index = 0;
386
+ while (index < source.length) {
387
+ const char = source[index];
388
+ if (/\s/.test(char)) {
389
+ index++;
390
+ } else if (/[0-9]/.test(char) || char === "." && /[0-9]/.test(source[index + 1] ?? "")) {
391
+ const match = /^[0-9]*\.?[0-9]+(?:[eE][+-]?[0-9]+)?/.exec(source.slice(index));
392
+ tokens.push({ kind: "number", text: match[0], value: Number(match[0]) });
393
+ index += match[0].length;
394
+ } else if (char === "'" || char === '"') {
395
+ const { value, length } = this.readString(source, index);
396
+ tokens.push({ kind: "string", text: source.slice(index, index + length), value });
397
+ index += length;
398
+ } else if (/[A-Za-z_$]/.test(char)) {
399
+ const match = /^[A-Za-z_$][A-Za-z0-9_$]*/.exec(source.slice(index));
400
+ const word = match[0];
401
+ const keywordOperator = hasOwn(KEYWORD_OPERATORS, word) ? KEYWORD_OPERATORS[word] : void 0;
402
+ tokens.push(keywordOperator ? { kind: "operator", text: keywordOperator } : { kind: "identifier", text: word });
403
+ index += word.length;
404
+ } else {
405
+ const operator = SYMBOL_OPERATORS.find((candidate) => source.startsWith(candidate, index));
406
+ if (!operator) throw new JuelError(`Unexpected character "${char}"`);
407
+ tokens.push({ kind: "operator", text: operator });
408
+ index += operator.length;
409
+ }
410
+ }
411
+ return tokens;
412
+ }
413
+ readString(source, start) {
414
+ const quote = source[start];
415
+ let value = "";
416
+ for (let index = start + 1; index < source.length; index++) {
417
+ const char = source[index];
418
+ if (char === "\\") {
419
+ value += source[index + 1] ?? "";
420
+ index++;
421
+ } else if (char === quote) {
422
+ return { value, length: index - start + 1 };
423
+ } else {
424
+ value += char;
425
+ }
426
+ }
427
+ throw new JuelError("Unterminated string literal");
428
+ }
673
429
  }
674
- function readCondition(sequenceFlow) {
675
- const condition = readConditionExpression(sequenceFlow);
676
- const isJuel = !condition?.language || condition.language.toLowerCase() === 'juel';
677
- return isJuel ? condition?.body?.trim() || undefined : undefined;
430
+
431
+ class JuelParser {
432
+ constructor(source) {
433
+ this.position = 0;
434
+ this.tokens = new JuelLexer().tokenize(source);
435
+ }
436
+ parse() {
437
+ const node = this.parseExpression();
438
+ const token = this.peek();
439
+ if (token) throw new JuelError(`Unexpected "${token.text}"`);
440
+ return node;
441
+ }
442
+ parseExpression() {
443
+ const test = this.parseBinary(0);
444
+ if (!this.accept("?")) return test;
445
+ const consequent = this.parseExpression();
446
+ this.expect(":");
447
+ const alternate = this.parseExpression();
448
+ return { type: "conditional", test, consequent, alternate };
449
+ }
450
+ parseBinary(level) {
451
+ if (level === BINARY_PRECEDENCE.length) return this.parseUnary();
452
+ let left = this.parseBinary(level + 1);
453
+ let operator = this.acceptAny(BINARY_PRECEDENCE[level]);
454
+ while (operator) {
455
+ const right = this.parseBinary(level + 1);
456
+ left = { type: "binary", operator, left, right };
457
+ operator = this.acceptAny(BINARY_PRECEDENCE[level]);
458
+ }
459
+ return left;
460
+ }
461
+ parseUnary() {
462
+ const operator = this.acceptAny(["!", "-", "empty"]);
463
+ if (operator) return { type: "unary", operator, operand: this.parseUnary() };
464
+ return this.parseMember();
465
+ }
466
+ parseMember() {
467
+ let node = this.parsePrimary();
468
+ for (; ; ) {
469
+ if (this.accept(".")) {
470
+ const property = this.next();
471
+ if (property?.kind !== "identifier") throw new JuelError('Expected a property name after "."');
472
+ node = { type: "member", object: node, property: { type: "literal", value: property.text } };
473
+ } else if (this.accept("[")) {
474
+ node = { type: "member", object: node, property: this.parseExpression() };
475
+ this.expect("]");
476
+ } else if (this.peek()?.text === "(") {
477
+ throw new JuelError("Method calls are not supported");
478
+ } else {
479
+ return node;
480
+ }
481
+ }
482
+ }
483
+ parsePrimary() {
484
+ const token = this.next();
485
+ if (!token) throw new JuelError("Unexpected end of expression");
486
+ if (token.kind === "number" || token.kind === "string") return { type: "literal", value: token.value };
487
+ if (token.kind === "identifier") return this.identifierOrLiteral(token.text);
488
+ if (token.text === "(") {
489
+ const node = this.parseExpression();
490
+ this.expect(")");
491
+ return node;
492
+ }
493
+ throw new JuelError(`Unexpected "${token.text}"`);
494
+ }
495
+ identifierOrLiteral(name) {
496
+ if (name === "true") return { type: "literal", value: true };
497
+ if (name === "false") return { type: "literal", value: false };
498
+ if (name === "null") return { type: "literal", value: null };
499
+ return { type: "identifier", name };
500
+ }
501
+ peek() {
502
+ return this.tokens[this.position];
503
+ }
504
+ next() {
505
+ return this.tokens[this.position++];
506
+ }
507
+ accept(text) {
508
+ if (this.peek()?.kind !== "operator" || this.peek()?.text !== text) return false;
509
+ this.position++;
510
+ return true;
511
+ }
512
+ acceptAny(operators) {
513
+ return operators.find((operator) => this.accept(operator));
514
+ }
515
+ expect(text) {
516
+ if (!this.accept(text)) throw new JuelError(`Expected "${text}"`);
517
+ }
678
518
  }
679
- function canEvaluate(expression) {
680
- try {
681
- parseJuelTemplate(expression);
682
- return true;
683
- }
684
- catch {
685
- return false;
519
+
520
+ class JuelTemplate {
521
+ constructor(parts) {
522
+ this.parts = parts;
523
+ }
524
+ static parse(text) {
525
+ const parts = [];
526
+ let cursor = 0;
527
+ while (cursor < text.length) {
528
+ const start = JuelTemplate.findExpressionStart(text, cursor);
529
+ if (start === -1) {
530
+ parts.push(text.slice(cursor));
531
+ break;
532
+ }
533
+ if (start > cursor) parts.push(text.slice(cursor, start));
534
+ const end = JuelTemplate.findExpressionEnd(text, start + 2);
535
+ parts.push(new JuelParser(text.slice(start + 2, end)).parse());
536
+ cursor = end + 1;
537
+ }
538
+ return new JuelTemplate(parts);
539
+ }
540
+ evaluate(variables) {
541
+ const evaluator = new JuelEvaluator(variables);
542
+ const [onlyPart] = this.parts;
543
+ if (this.parts.length === 1 && typeof onlyPart !== "string") {
544
+ return evaluator.evaluate(onlyPart);
545
+ }
546
+ return this.parts.map((part) => typeof part === "string" ? part : evaluator.coerceToString(evaluator.evaluate(part))).join("");
547
+ }
548
+ variableNames() {
549
+ const names = /* @__PURE__ */ new Set();
550
+ const visit = (node) => {
551
+ if (node.type === "identifier") names.add(node.name);
552
+ if (node.type === "member") {
553
+ visit(node.object);
554
+ visit(node.property);
555
+ }
556
+ if (node.type === "unary") visit(node.operand);
557
+ if (node.type === "binary") {
558
+ visit(node.left);
559
+ visit(node.right);
560
+ }
561
+ if (node.type === "conditional") {
562
+ visit(node.test);
563
+ visit(node.consequent);
564
+ visit(node.alternate);
565
+ }
566
+ };
567
+ this.parts.forEach((part) => typeof part !== "string" && visit(part));
568
+ return [...names];
569
+ }
570
+ static findExpressionStart(text, from) {
571
+ const dollar = text.indexOf("${", from);
572
+ const hash = text.indexOf("#{", from);
573
+ if (dollar === -1) return hash;
574
+ if (hash === -1) return dollar;
575
+ return Math.min(dollar, hash);
576
+ }
577
+ static findExpressionEnd(text, from) {
578
+ let quote = null;
579
+ for (let index = from; index < text.length; index++) {
580
+ const char = text[index];
581
+ if (quote) {
582
+ if (char === "\\") index++;
583
+ else if (char === quote) quote = null;
584
+ } else if (char === "'" || char === '"') {
585
+ quote = char;
586
+ } else if (char === "}") {
587
+ return index;
588
+ }
686
589
  }
590
+ throw new JuelError('Unterminated expression, missing "}"');
591
+ }
687
592
  }
688
- function readVariableNames$1(expression) {
593
+
594
+ class Camunda7Engine {
595
+ constructor() {
596
+ this.id = "camunda7";
597
+ this.label = "Camunda 7";
598
+ this.expressionLanguage = "JUEL";
599
+ this.taskResultPropagation = "always";
600
+ }
601
+ writeVariable(variables, target, value) {
602
+ return { ...variables, [target]: value };
603
+ }
604
+ readInputMappings(element) {
605
+ return this.readMappings(element, "inputParameters");
606
+ }
607
+ readOutputMappings(element) {
608
+ return this.readMappings(element, "outputParameters");
609
+ }
610
+ readCondition(sequenceFlow) {
611
+ const condition = readConditionExpression(sequenceFlow);
612
+ const isJuel = !condition?.language || condition.language.toLowerCase() === "juel";
613
+ return isJuel ? condition?.body?.trim() || void 0 : void 0;
614
+ }
615
+ canEvaluate(expression) {
689
616
  try {
690
- return readJuelVariableNames(parseJuelTemplate(expression));
691
- }
692
- catch {
693
- return [];
617
+ JuelTemplate.parse(expression);
618
+ return true;
619
+ } catch {
620
+ return false;
694
621
  }
695
- }
696
- function evaluateCamundaExpression(expression, variables) {
622
+ }
623
+ evaluate(expression, variables) {
697
624
  if (!expression) {
698
- return { ok: true, value: null };
625
+ return { ok: true, value: null };
699
626
  }
700
627
  try {
701
- return { ok: true, value: evaluateJuelTemplate(parseJuelTemplate(expression), variables) };
702
- }
703
- catch (error) {
704
- return { ok: false, reason: error.message };
628
+ return { ok: true, value: JuelTemplate.parse(expression).evaluate(variables) };
629
+ } catch (error) {
630
+ return { ok: false, reason: error.message };
705
631
  }
632
+ }
633
+ readVariableNames(expression) {
634
+ try {
635
+ return JuelTemplate.parse(expression).variableNames();
636
+ } catch {
637
+ return [];
638
+ }
639
+ }
640
+ readMappings(element, property) {
641
+ const inputOutput = findExtension(element, "camunda:InputOutput");
642
+ return listProperty(inputOutput, property).filter((parameter) => typeof parameter.name === "string" && parameter.name && !parameter.definition).map((parameter) => ({
643
+ source: typeof parameter.value === "string" ? parameter.value : "",
644
+ target: parameter.name
645
+ }));
646
+ }
706
647
  }
707
648
 
708
- const EXPRESSION_PREFIX = '=';
709
- const zeebeEngine = {
710
- id: 'zeebe',
711
- label: 'Zeebe',
712
- expressionLanguage: 'FEEL',
713
- taskResultPropagation: 'without-output-mappings',
714
- writeVariable: setVariable,
715
- readInputMappings: element => readMappings(element, 'inputParameters'),
716
- readOutputMappings: element => readMappings(element, 'outputParameters'),
717
- readCondition: sequenceFlow => readConditionExpression(sequenceFlow)?.body?.trim() || undefined,
718
- canEvaluate: expression => isFeel(expression) && parsesAsFeel(expression),
719
- evaluate: evaluateZeebeExpression,
720
- readVariableNames,
721
- };
722
- function readMappings(element, property) {
723
- const ioMapping = findExtension(element, 'zeebe:IoMapping');
724
- return listProperty(ioMapping, property)
725
- .filter(parameter => typeof parameter.target === 'string' && parameter.target)
726
- .map(parameter => ({ source: String(parameter.source ?? ''), target: parameter.target }));
727
- }
728
- function evaluateZeebeExpression(expression, variables) {
729
- if (!isFeel(expression)) {
730
- return { ok: true, value: expression };
649
+ const EXPRESSION_PREFIX = "=";
650
+ class ZeebeEngine {
651
+ constructor() {
652
+ this.id = "zeebe";
653
+ this.label = "Zeebe";
654
+ this.expressionLanguage = "FEEL";
655
+ this.taskResultPropagation = "without-output-mappings";
656
+ }
657
+ writeVariable(variables, target, value) {
658
+ return setVariable(variables, target, value);
659
+ }
660
+ readInputMappings(element) {
661
+ return this.readMappings(element, "inputParameters");
662
+ }
663
+ readOutputMappings(element) {
664
+ return this.readMappings(element, "outputParameters");
665
+ }
666
+ readCondition(sequenceFlow) {
667
+ return readConditionExpression(sequenceFlow)?.body?.trim() || void 0;
668
+ }
669
+ canEvaluate(expression) {
670
+ return this.isFeel(expression) && this.parsesAsFeel(expression);
671
+ }
672
+ evaluate(expression, variables) {
673
+ if (!this.isFeel(expression)) {
674
+ return { ok: true, value: expression };
731
675
  }
732
676
  try {
733
- const { value, warnings } = evaluate(feelBody(expression), variables);
734
- const missingVariable = warnings.find(warning => warning.type === 'NO_VARIABLE_FOUND');
735
- if (value === null && missingVariable) {
736
- return { ok: false, reason: missingVariable.message };
737
- }
738
- return { ok: true, value: toVariableValue(value) };
739
- }
740
- catch (error) {
741
- return { ok: false, reason: `Invalid FEEL: ${error.message}` };
742
- }
743
- }
744
- function readVariableNames(expression) {
745
- if (!isFeel(expression))
746
- return [];
747
- const body = feelBody(expression);
748
- const read = new Set();
749
- const bound = new Set();
750
- parseExpression(body, {}, undefined).iterate({
751
- enter(node) {
752
- const text = body.slice(node.from, node.to);
753
- if (node.name === 'Name')
754
- bound.add(text);
755
- if (node.name !== 'VariableName')
756
- return;
757
- const isCallee = node.node.parent?.name === 'FunctionInvocation' && node.node.prevSibling === null;
758
- if (!isCallee)
759
- read.add(text);
760
- },
677
+ const { value, warnings } = evaluate(this.feelBody(expression), variables);
678
+ const missingVariable = warnings.find((warning) => warning.type === "NO_VARIABLE_FOUND");
679
+ if (value === null && missingVariable) {
680
+ return { ok: false, reason: missingVariable.message };
681
+ }
682
+ return { ok: true, value: this.toVariableValue(value) };
683
+ } catch (error) {
684
+ return { ok: false, reason: `Invalid FEEL: ${error.message}` };
685
+ }
686
+ }
687
+ readVariableNames(expression) {
688
+ if (!this.isFeel(expression)) return [];
689
+ const body = this.feelBody(expression);
690
+ const read = /* @__PURE__ */ new Set();
691
+ const bound = /* @__PURE__ */ new Set();
692
+ parseExpression(body, {}, void 0).iterate({
693
+ enter(node) {
694
+ const text = body.slice(node.from, node.to);
695
+ if (node.name === "Name") bound.add(text);
696
+ if (node.name !== "VariableName") return;
697
+ const isCallee = node.node.parent?.name === "FunctionInvocation" && node.node.prevSibling === null;
698
+ if (!isCallee) read.add(text);
699
+ }
761
700
  });
762
- return [...read].filter(name => !bound.has(name));
763
- }
764
- function toVariableValue(value) {
765
- if (value === undefined)
766
- return null;
767
- return typeof value === 'object' && value !== null ? JSON.parse(JSON.stringify(value)) : value;
768
- }
769
- function parsesAsFeel(expression) {
701
+ return [...read].filter((name) => !bound.has(name));
702
+ }
703
+ readMappings(element, property) {
704
+ const ioMapping = findExtension(element, "zeebe:IoMapping");
705
+ return listProperty(ioMapping, property).filter((parameter) => typeof parameter.target === "string" && parameter.target).map((parameter) => ({ source: String(parameter.source ?? ""), target: parameter.target }));
706
+ }
707
+ toVariableValue(value) {
708
+ if (value === void 0) return null;
709
+ return typeof value === "object" && value !== null ? JSON.parse(JSON.stringify(value)) : value;
710
+ }
711
+ parsesAsFeel(expression) {
770
712
  try {
771
- evaluate(feelBody(expression), {});
772
- return true;
773
- }
774
- catch {
775
- return false;
713
+ evaluate(this.feelBody(expression), {});
714
+ return true;
715
+ } catch {
716
+ return false;
776
717
  }
777
- }
778
- function isFeel(expression) {
718
+ }
719
+ isFeel(expression) {
779
720
  return expression.trimStart().startsWith(EXPRESSION_PREFIX);
780
- }
781
- function feelBody(expression) {
721
+ }
722
+ feelBody(expression) {
782
723
  return expression.trimStart().slice(EXPRESSION_PREFIX.length);
724
+ }
783
725
  }
784
726
 
785
- const ENGINES = {
786
- zeebe: zeebeEngine,
787
- camunda7: camunda7Engine,
788
- };
789
- function resolveEngine(engine) {
790
- if (typeof engine !== 'string')
791
- return engine;
792
- const adapter = ENGINES[engine];
727
+ const zeebeEngine = new ZeebeEngine();
728
+ const camunda7Engine = new Camunda7Engine();
729
+
730
+ class EngineRegistry {
731
+ constructor() {
732
+ this.engines = {
733
+ zeebe: zeebeEngine,
734
+ camunda7: camunda7Engine
735
+ };
736
+ }
737
+ resolve(engine) {
738
+ if (typeof engine !== "string") return engine;
739
+ const adapter = this.engines[engine];
793
740
  if (!adapter) {
794
- throw new Error(`Unknown engine "${engine}", expected one of: ${Object.keys(ENGINES).join(', ')}`);
741
+ throw new Error(`Unknown engine "${engine}", expected one of: ${Object.keys(this.engines).join(", ")}`);
795
742
  }
796
743
  return adapter;
744
+ }
797
745
  }
798
746
 
799
747
  class DataSimulationStore {
800
- constructor() {
801
- this.engineLabel = '';
802
- this.expressionLanguage = '';
803
- this.scenarios = [];
804
- this.selectedScenarioId = null;
805
- this.startVariables = {};
806
- this.instances = new Map();
807
- this.selectedInstanceId = null;
808
- this.log = [];
809
- this.nextLogId = 1;
810
- this.listeners = new Set();
811
- }
812
- setEngine(label, expressionLanguage) {
813
- this.engineLabel = label;
814
- this.expressionLanguage = expressionLanguage;
815
- this.emit();
816
- }
817
- setScenarios(scenarios) {
818
- this.scenarios = scenarios;
819
- this.selectScenario(scenarios[0]?.id ?? null);
820
- }
821
- selectScenario(scenarioId) {
822
- const scenario = this.scenarios.find(candidate => candidate.id === scenarioId);
823
- this.selectedScenarioId = scenario?.id ?? null;
824
- this.startVariables = scenario ? structuredClone(scenario.variables) : {};
825
- this.emit();
826
- }
827
- setStartVariables(variables) {
828
- this.startVariables = structuredClone(variables);
829
- this.emit();
830
- }
831
- startInstance(id, processName) {
832
- this.instances.set(id, {
833
- id,
834
- number: this.instances.size + 1,
835
- processName,
836
- scenarioId: this.selectedScenarioId,
837
- status: 'running',
838
- variables: structuredClone(this.startVariables),
839
- waiting: [],
840
- });
841
- this.selectedInstanceId = id;
842
- this.emit();
843
- }
844
- selectInstance(instanceId) {
845
- if (!this.instances.has(instanceId))
846
- return;
847
- this.selectedInstanceId = instanceId;
848
- this.emit();
849
- }
850
- completeInstance(id) {
851
- this.updateInstance(id, instance => ({ ...instance, status: 'completed', waiting: [] }));
852
- }
853
- hasInstance(id) {
854
- return this.instances.has(id);
855
- }
856
- getTaskResult(instanceId, elementId) {
857
- const scenarioId = this.instances.get(instanceId)?.scenarioId;
858
- return this.scenarios.find(scenario => scenario.id === scenarioId)?.taskResults[elementId];
859
- }
860
- getVariables(instanceId) {
861
- return this.instances.get(instanceId)?.variables ?? {};
862
- }
863
- setVariables(instanceId, variables) {
864
- this.updateInstance(instanceId, instance => ({ ...instance, variables: structuredClone(variables) }));
865
- }
866
- addWaiting(instanceId, waiting) {
867
- this.updateInstance(instanceId, instance => ({ ...instance, waiting: [...instance.waiting, waiting] }));
868
- }
869
- removeWaiting(scopeId) {
870
- const instance = [...this.instances.values()].find(candidate => candidate.waiting.some(waiting => waiting.scopeId === scopeId));
871
- if (!instance)
872
- return;
873
- this.updateInstance(instance.id, current => ({
874
- ...current,
875
- waiting: current.waiting.filter(waiting => waiting.scopeId !== scopeId),
876
- }));
877
- }
878
- record(entry) {
879
- this.log = [...this.log, { ...entry, id: this.nextLogId++ }];
880
- this.emit();
881
- }
882
- reset() {
883
- this.instances.clear();
884
- this.selectedInstanceId = null;
885
- this.log = [];
886
- this.emit();
887
- }
888
- getSnapshot() {
889
- return {
890
- engineLabel: this.engineLabel,
891
- expressionLanguage: this.expressionLanguage,
892
- scenarios: this.scenarios,
893
- selectedScenarioId: this.selectedScenarioId,
894
- startVariables: this.startVariables,
895
- instances: [...this.instances.values()].map(withStatus),
896
- selectedInstanceId: this.selectedInstanceId,
897
- log: this.log,
898
- };
899
- }
900
- subscribe(listener) {
901
- this.listeners.add(listener);
902
- return () => this.listeners.delete(listener);
903
- }
904
- updateInstance(id, update) {
905
- const instance = this.instances.get(id);
906
- if (!instance)
907
- return;
908
- this.instances.set(id, update(instance));
909
- this.emit();
910
- }
911
- emit() {
912
- const snapshot = this.getSnapshot();
913
- for (const listener of [...this.listeners])
914
- listener(snapshot);
915
- }
916
- }
917
- function withStatus(instance) {
918
- if (instance.status === 'completed')
919
- return instance;
920
- return { ...instance, status: instance.waiting.length ? 'waiting' : 'running' };
748
+ constructor() {
749
+ this.engineLabel = "";
750
+ this.expressionLanguage = "";
751
+ this.scenarios = [];
752
+ this.selectedScenarioId = null;
753
+ this.startVariables = {};
754
+ this.instances = /* @__PURE__ */ new Map();
755
+ this.selectedInstanceId = null;
756
+ this.log = [];
757
+ this.nextLogId = 1;
758
+ this.listeners = /* @__PURE__ */ new Set();
759
+ }
760
+ setEngine(label, expressionLanguage) {
761
+ this.engineLabel = label;
762
+ this.expressionLanguage = expressionLanguage;
763
+ this.emit();
764
+ }
765
+ setScenarios(scenarios) {
766
+ this.scenarios = scenarios;
767
+ this.selectScenario(scenarios[0]?.id ?? null);
768
+ }
769
+ selectScenario(scenarioId) {
770
+ const scenario = this.scenarios.find((candidate) => candidate.id === scenarioId);
771
+ this.selectedScenarioId = scenario?.id ?? null;
772
+ this.startVariables = scenario ? structuredClone(scenario.variables) : {};
773
+ this.emit();
774
+ }
775
+ setStartVariables(variables) {
776
+ this.startVariables = structuredClone(variables);
777
+ this.emit();
778
+ }
779
+ startInstance(id, processName) {
780
+ this.instances.set(id, {
781
+ id,
782
+ number: this.instances.size + 1,
783
+ processName,
784
+ scenarioId: this.selectedScenarioId,
785
+ status: "running",
786
+ variables: structuredClone(this.startVariables),
787
+ waiting: []
788
+ });
789
+ this.selectedInstanceId = id;
790
+ this.emit();
791
+ }
792
+ selectInstance(instanceId) {
793
+ if (!this.instances.has(instanceId)) return;
794
+ this.selectedInstanceId = instanceId;
795
+ this.emit();
796
+ }
797
+ completeInstance(id) {
798
+ this.updateInstance(id, (instance) => ({ ...instance, status: "completed", waiting: [] }));
799
+ }
800
+ hasInstance(id) {
801
+ return this.instances.has(id);
802
+ }
803
+ getTaskResult(instanceId, elementId) {
804
+ const scenarioId = this.instances.get(instanceId)?.scenarioId;
805
+ return this.scenarios.find((scenario) => scenario.id === scenarioId)?.taskResults[elementId];
806
+ }
807
+ getVariables(instanceId) {
808
+ return this.instances.get(instanceId)?.variables ?? {};
809
+ }
810
+ setVariables(instanceId, variables) {
811
+ this.updateInstance(instanceId, (instance) => ({ ...instance, variables: structuredClone(variables) }));
812
+ }
813
+ addWaiting(instanceId, waiting) {
814
+ this.updateInstance(instanceId, (instance) => ({ ...instance, waiting: [...instance.waiting, waiting] }));
815
+ }
816
+ removeWaiting(scopeId) {
817
+ const instance = [...this.instances.values()].find(
818
+ (candidate) => candidate.waiting.some((waiting) => waiting.scopeId === scopeId)
819
+ );
820
+ if (!instance) return;
821
+ this.updateInstance(instance.id, (current) => ({
822
+ ...current,
823
+ waiting: current.waiting.filter((waiting) => waiting.scopeId !== scopeId)
824
+ }));
825
+ }
826
+ record(entry) {
827
+ this.log = [...this.log, { ...entry, id: this.nextLogId++ }];
828
+ this.emit();
829
+ }
830
+ reset() {
831
+ this.instances.clear();
832
+ this.selectedInstanceId = null;
833
+ this.log = [];
834
+ this.emit();
835
+ }
836
+ getSnapshot() {
837
+ return {
838
+ engineLabel: this.engineLabel,
839
+ expressionLanguage: this.expressionLanguage,
840
+ scenarios: this.scenarios,
841
+ selectedScenarioId: this.selectedScenarioId,
842
+ startVariables: this.startVariables,
843
+ instances: [...this.instances.values()].map((instance) => this.withStatus(instance)),
844
+ selectedInstanceId: this.selectedInstanceId,
845
+ log: this.log
846
+ };
847
+ }
848
+ subscribe(listener) {
849
+ this.listeners.add(listener);
850
+ return () => this.listeners.delete(listener);
851
+ }
852
+ updateInstance(id, update) {
853
+ const instance = this.instances.get(id);
854
+ if (!instance) return;
855
+ this.instances.set(id, update(instance));
856
+ this.emit();
857
+ }
858
+ emit() {
859
+ const snapshot = this.getSnapshot();
860
+ for (const listener of [...this.listeners]) listener(snapshot);
861
+ }
862
+ withStatus(instance) {
863
+ if (instance.status === "completed") return instance;
864
+ return { ...instance, status: instance.waiting.length ? "waiting" : "running" };
865
+ }
921
866
  }
922
867
 
923
868
  function h(tag, attributes = {}, ...children) {
924
- const element = document.createElement(tag);
925
- for (const [name, value] of Object.entries(attributes)) {
926
- if (name === 'className')
927
- element.className = value;
928
- else
929
- element.setAttribute(name, value);
930
- }
931
- for (const child of children) {
932
- if (child)
933
- element.append(child);
934
- }
935
- return element;
869
+ const element = document.createElement(tag);
870
+ for (const [name, value] of Object.entries(attributes)) {
871
+ if (name === "className") element.className = value;
872
+ else element.setAttribute(name, value);
873
+ }
874
+ for (const child of children) {
875
+ if (child) element.append(child);
876
+ }
877
+ return element;
936
878
  }
937
879
  function formatValue(value) {
938
- if (value === undefined)
939
- return 'undefined';
940
- return JSON.stringify(value) ?? String(value);
880
+ if (value === void 0) return "undefined";
881
+ return JSON.stringify(value) ?? String(value);
941
882
  }
942
883
 
943
- const simpleStartFormRenderer = {
944
- render(container, fields, values) {
945
- const inputs = new Map();
946
- const form = h('div', { className: 'bds-form' });
947
- for (const field of fields) {
948
- const input = createInput(field);
949
- inputs.set(field.name, input);
950
- form.append(renderField(field, input));
951
- }
952
- for (const field of fields)
953
- writeInput(inputs.get(field.name), formatFieldValue(field, values[field.name]));
954
- container.append(form);
955
- return {
956
- readValues() {
957
- const result = {};
958
- for (const field of fields) {
959
- const input = inputs.get(field.name);
960
- const parsed = parseFieldValue(field, input.type === 'checkbox' ? input.checked : input.value);
961
- if (!parsed.ok)
962
- return parsed;
963
- result[field.name] = parsed.value;
964
- }
965
- return { ok: true, values: result };
966
- },
967
- focus() {
968
- inputs.values().next().value?.focus();
969
- },
970
- destroy() {
971
- form.remove();
972
- },
973
- };
974
- },
975
- };
976
- function renderField(field, input) {
884
+ class SimpleStartForm {
885
+ constructor(container, fields, values) {
886
+ this.fields = fields;
887
+ this.codec = new StartFieldCodec();
888
+ this.inputs = /* @__PURE__ */ new Map();
889
+ this.form = h("div", { className: "bds-form" });
890
+ for (const field of fields) {
891
+ const input = this.createInput(field);
892
+ this.inputs.set(field.name, input);
893
+ this.form.append(this.renderField(field, input));
894
+ }
895
+ for (const field of fields)
896
+ this.writeInput(this.inputs.get(field.name), this.codec.format(field, values[field.name]));
897
+ container.append(this.form);
898
+ }
899
+ readValues() {
900
+ const result = {};
901
+ for (const field of this.fields) {
902
+ const input = this.inputs.get(field.name);
903
+ const parsed = this.codec.parse(
904
+ field,
905
+ input.type === "checkbox" ? input.checked : input.value
906
+ );
907
+ if (!parsed.ok) return parsed;
908
+ result[field.name] = parsed.value;
909
+ }
910
+ return { ok: true, values: result };
911
+ }
912
+ focus() {
913
+ this.inputs.values().next().value?.focus();
914
+ }
915
+ destroy() {
916
+ this.form.remove();
917
+ }
918
+ renderField(field, input) {
977
919
  const id = `bds-field-${field.name}`;
978
920
  input.id = id;
979
- const hint = h('span', { className: 'bds-field-hint' }, `Used by ${field.usedBy.join(', ')}`);
980
- if (field.type === 'boolean') {
981
- return h('div', { className: 'bds-field bds-field--checkbox' }, h('label', { className: 'bds-checkbox', for: id }, input, h('span', { className: 'bds-field-name' }, field.name)), hint);
982
- }
983
- return h('div', { className: 'bds-field' }, h('label', { className: 'bds-field-name', for: id }, field.name), input, hint);
921
+ const hint = h("span", { className: "bds-field-hint" }, `Used by ${field.usedBy.join(", ")}`);
922
+ if (field.type === "boolean") {
923
+ return h(
924
+ "div",
925
+ { className: "bds-field bds-field--checkbox" },
926
+ h(
927
+ "label",
928
+ { className: "bds-checkbox", for: id },
929
+ input,
930
+ h("span", { className: "bds-field-name" }, field.name)
931
+ ),
932
+ hint
933
+ );
934
+ }
935
+ return h(
936
+ "div",
937
+ { className: "bds-field" },
938
+ h("label", { className: "bds-field-name", for: id }, field.name),
939
+ input,
940
+ hint
941
+ );
942
+ }
943
+ createInput(field) {
944
+ if (field.type === "boolean") return h("input", { type: "checkbox", name: field.name });
945
+ if (field.type === "json") {
946
+ return h("textarea", { className: "bds-input bds-json", name: field.name, rows: "2", spellcheck: "false" });
947
+ }
948
+ const type = field.type === "number" ? "number" : "text";
949
+ return h("input", { className: "bds-input", type, name: field.name, step: "any", autocomplete: "off" });
950
+ }
951
+ writeInput(input, value) {
952
+ if (typeof value === "boolean") input.checked = value;
953
+ else input.value = value;
954
+ }
984
955
  }
985
- function createInput(field) {
986
- if (field.type === 'boolean')
987
- return h('input', { type: 'checkbox', name: field.name });
988
- if (field.type === 'json') {
989
- return h('textarea', { className: 'bds-input bds-json', name: field.name, rows: '2', spellcheck: 'false' });
990
- }
991
- const type = field.type === 'number' ? 'number' : 'text';
992
- return h('input', { className: 'bds-input', type, name: field.name, step: 'any', autocomplete: 'off' });
993
- }
994
- function writeInput(input, value) {
995
- if (typeof value === 'boolean')
996
- input.checked = value;
997
- else
998
- input.value = value;
956
+
957
+ class SimpleStartFormRenderer {
958
+ render(container, fields, values) {
959
+ return new SimpleStartForm(container, fields, values);
960
+ }
999
961
  }
1000
962
 
1001
- const FLOW_CHOICE_TYPES = ['bpmn:ExclusiveGateway', 'bpmn:InclusiveGateway'];
1002
- const TRIGGER_TYPE = 'bpmn:Event';
963
+ const FLOW_CHOICE_TYPES = ["bpmn:ExclusiveGateway", "bpmn:InclusiveGateway"];
964
+ const TRIGGER_TYPE = "bpmn:Event";
1003
965
  class DataContextPads {
1004
- constructor(contextPads, dataGateways, startForm, dataSimulation) {
1005
- for (const { handler, type } of contextPads._handlers) {
1006
- if (FLOW_CHOICE_TYPES.includes(type))
1007
- hideOnDataDrivenGateways(handler, dataGateways);
1008
- if (type === TRIGGER_TYPE)
1009
- openStartFormOnProcessStart(handler, startForm, dataSimulation);
1010
- }
1011
- }
1012
- }
1013
- DataContextPads.$inject = ['contextPads', 'dataGateways', 'dataStartForm', 'dataSimulation'];
1014
- function hideOnDataDrivenGateways(handler, dataGateways) {
966
+ constructor(contextPads, dataGateways, startForm, dataSimulation) {
967
+ this.dataGateways = dataGateways;
968
+ this.startForm = startForm;
969
+ this.dataSimulation = dataSimulation;
970
+ for (const { handler, type } of contextPads._handlers) {
971
+ if (FLOW_CHOICE_TYPES.includes(type)) this.hideOnDataDrivenGateways(handler);
972
+ if (type === TRIGGER_TYPE) this.openStartFormOnProcessStart(handler);
973
+ }
974
+ }
975
+ hideOnDataDrivenGateways(handler) {
1015
976
  const createContextPads = handler.createContextPads.bind(handler);
1016
- handler.createContextPads = element => (dataGateways.isDataDriven(element) ? undefined : createContextPads(element));
1017
- }
1018
- function openStartFormOnProcessStart(handler, startForm, dataSimulation) {
977
+ handler.createContextPads = (element) => this.dataGateways.isDataDriven(element) ? void 0 : createContextPads(element);
978
+ }
979
+ openStartFormOnProcessStart(handler) {
1019
980
  const createContextPads = handler.createContextPads.bind(handler);
1020
- handler.createContextPads = element => {
1021
- const pads = createContextPads(element);
1022
- if (!dataSimulation.isEnabled() || !startForm.isProcessStart(element))
1023
- return pads;
1024
- return []
1025
- .concat(pads)
1026
- .map(pad => pad?.action
1027
- ? { ...pad, action: (contexts) => startForm.open(element, () => pad.action(contexts)) }
1028
- : pad);
981
+ handler.createContextPads = (element) => {
982
+ const pads = createContextPads(element);
983
+ if (!this.dataSimulation.isEnabled() || !this.startForm.isProcessStart(element)) return pads;
984
+ return [].concat(pads).map(
985
+ (pad) => pad?.action ? { ...pad, action: (contexts) => this.startForm.open(element, () => pad.action(contexts)) } : pad
986
+ );
1029
987
  };
988
+ }
1030
989
  }
990
+ DataContextPads.$inject = ["contextPads", "dataGateways", "dataStartForm", "dataSimulation"];
1031
991
 
1032
992
  class DataGatewayBehaviors {
1033
- constructor(exclusive, inclusive, dataGateways) {
1034
- routeByData(exclusive, 'exclusive', dataGateways);
1035
- routeByData(inclusive, 'inclusive', dataGateways);
1036
- }
1037
- }
1038
- DataGatewayBehaviors.$inject = ['exclusiveGatewayBehavior', 'inclusiveGatewayBehavior', 'dataGateways'];
1039
- function routeByData(behavior, kind, dataGateways) {
993
+ constructor(exclusive, inclusive, dataGateways) {
994
+ this.dataGateways = dataGateways;
995
+ this.routeByData(exclusive, "exclusive");
996
+ this.routeByData(inclusive, "inclusive");
997
+ }
998
+ routeByData(behavior, kind) {
1040
999
  const exitByClick = behavior.exit.bind(behavior);
1041
- behavior.exit = context => {
1042
- if (dataGateways.isDataDriven(context.element)) {
1043
- dataGateways.exit(context, kind);
1044
- }
1045
- else {
1046
- dataGateways.recordClickDecision(context, kind);
1047
- exitByClick(context);
1048
- }
1000
+ behavior.exit = (context) => {
1001
+ if (this.dataGateways.isDataDriven(context.element)) {
1002
+ this.dataGateways.exit(context, kind);
1003
+ } else {
1004
+ this.dataGateways.recordClickDecision(context, kind);
1005
+ exitByClick(context);
1006
+ }
1049
1007
  };
1008
+ }
1050
1009
  }
1010
+ DataGatewayBehaviors.$inject = ["exclusiveGatewayBehavior", "inclusiveGatewayBehavior", "dataGateways"];
1051
1011
 
1052
1012
  class DataGatewaySettings {
1053
- constructor(exclusive, inclusive, dataGateways) {
1054
- const onlyForClickGateways = (method) => {
1055
- return (gateway, ...rest) => {
1056
- if (!dataGateways.isDataDriven(gateway))
1057
- method(gateway, ...rest);
1058
- };
1059
- };
1060
- exclusive.setSequenceFlow = onlyForClickGateways(exclusive.setSequenceFlow.bind(exclusive));
1061
- inclusive._setGatewayDefaults = onlyForClickGateways(inclusive._setGatewayDefaults.bind(inclusive));
1062
- inclusive.toggleSequenceFlow = onlyForClickGateways(inclusive.toggleSequenceFlow.bind(inclusive));
1063
- }
1013
+ constructor(exclusive, inclusive, dataGateways) {
1014
+ this.dataGateways = dataGateways;
1015
+ exclusive.setSequenceFlow = this.onlyForClickGateways(exclusive.setSequenceFlow.bind(exclusive));
1016
+ inclusive._setGatewayDefaults = this.onlyForClickGateways(inclusive._setGatewayDefaults.bind(inclusive));
1017
+ inclusive.toggleSequenceFlow = this.onlyForClickGateways(inclusive.toggleSequenceFlow.bind(inclusive));
1018
+ }
1019
+ onlyForClickGateways(method) {
1020
+ return (gateway, ...rest) => {
1021
+ if (!this.dataGateways.isDataDriven(gateway)) method(gateway, ...rest);
1022
+ };
1023
+ }
1064
1024
  }
1065
- DataGatewaySettings.$inject = ['exclusiveGatewaySettings', 'inclusiveGatewaySettings', 'dataGateways'];
1025
+ DataGatewaySettings.$inject = ["exclusiveGatewaySettings", "inclusiveGatewaySettings", "dataGateways"];
1066
1026
 
1067
- const TOGGLE_MODE_EVENT = 'tokenSimulation.toggleMode';
1068
- const RESET_SIMULATION_EVENT = 'tokenSimulation.resetSimulation';
1069
- const SCOPE_CREATE_EVENT = 'tokenSimulation.simulator.createScope';
1070
- const SCOPE_DESTROYED_EVENT = 'tokenSimulation.simulator.destroyScope';
1071
- const TRACE_EVENT = 'tokenSimulation.simulator.trace';
1072
- const DATA_TOGGLE_EVENT = 'dataSimulation.toggle';
1073
1027
  function findProcessInstance(scope) {
1074
- let current = scope;
1075
- while (current.parent)
1076
- current = current.parent;
1077
- return current;
1028
+ let current = scope;
1029
+ while (current.parent) current = current.parent;
1030
+ return current;
1078
1031
  }
1079
1032
  function elementName(element) {
1080
- const name = element.businessObject.name;
1081
- return typeof name === 'string' && name.trim() ? name.trim() : element.id;
1033
+ const name = element.businessObject.name;
1034
+ return typeof name === "string" && name.trim() ? name.trim() : element.id;
1082
1035
  }
1083
1036
  function is(element, type) {
1084
- const businessObject = element.businessObject;
1085
- return typeof businessObject?.$instanceOf === 'function' && businessObject.$instanceOf(type);
1037
+ const businessObject = element.businessObject;
1038
+ return typeof businessObject?.$instanceOf === "function" && businessObject.$instanceOf(type);
1039
+ }
1040
+ function isGateway(element) {
1041
+ return element.type === "bpmn:ExclusiveGateway" || element.type === "bpmn:InclusiveGateway";
1042
+ }
1043
+ function gatewayOf(element) {
1044
+ if (isGateway(element)) return element.id;
1045
+ if (element.type === "bpmn:SequenceFlow" && element.source && isGateway(element.source)) return element.source.id;
1046
+ return void 0;
1086
1047
  }
1087
1048
 
1088
1049
  class DataGateways {
1089
- constructor(dataSimulation, store, simulator) {
1090
- this.dataSimulation = dataSimulation;
1091
- this.store = store;
1092
- this.simulator = simulator;
1093
- }
1094
- isDataDriven(gateway) {
1095
- const engine = this.dataSimulation.getEngine();
1096
- const outgoing = this.outgoingFlows(gateway);
1097
- return (this.dataSimulation.isEnabled() &&
1098
- outgoing.length > 1 &&
1099
- outgoing
1100
- .filter(flow => !flow.isDefault)
1101
- .every(flow => flow.expression !== undefined && engine.canEvaluate(flow.expression)));
1102
- }
1103
- exit(context, kind) {
1104
- const { element: gateway, scope } = context;
1105
- const decision = this.decide(gateway, scope, kind);
1106
- if (decision.stuckReason) {
1107
- this.waitForRetry(gateway, scope);
1108
- return;
1109
- }
1110
- for (const flowId of decision.takenFlowIds) {
1111
- const flow = this.sequenceFlows(gateway).find(candidate => candidate.id === flowId);
1112
- this.simulator.enter({ element: flow, scope: scope.parent });
1113
- }
1114
- }
1115
- recordClickDecision(context, kind) {
1116
- if (!this.dataSimulation.isEnabled())
1117
- return;
1118
- const { element: gateway, scope } = context;
1119
- const { activeOutgoing } = this.simulator.getConfig(gateway);
1120
- const chosen = [].concat(activeOutgoing ?? []);
1121
- const outgoing = this.outgoingFlows(gateway);
1122
- if (outgoing.length < 2 || !chosen.length)
1123
- return;
1124
- const flows = outgoing.map(flow => chosen.some(candidate => candidate.id === flow.id)
1125
- ? { flow, outcome: 'taken', reason: 'Chosen by click' }
1126
- : { flow, outcome: 'skipped', reason: 'Not chosen by click' });
1127
- const decision = {
1128
- flows,
1129
- takenFlowIds: flows.filter(flow => flow.outcome === 'taken').map(flow => flow.flow.id),
1130
- };
1131
- this.record(gateway, scope, kind, 'click', decision, []);
1132
- }
1133
- decide(gateway, scope, kind) {
1134
- const engine = this.dataSimulation.getEngine();
1135
- const variables = this.dataSimulation.getVariables(scope);
1136
- const outgoing = this.outgoingFlows(gateway);
1137
- const decision = routeGateway(kind, outgoing, expression => engine.evaluate(expression, variables));
1138
- const names = outgoing.flatMap(flow => (flow.expression ? engine.readVariableNames(flow.expression) : []));
1139
- const inputs = [...new Set(names)].map(name => ({ name, value: structuredClone(variables[name]) }));
1140
- this.record(gateway, scope, kind, 'data', decision, inputs);
1141
- return decision;
1142
- }
1143
- record(gateway, scope, gatewayKind, chosenBy, decision, inputs) {
1050
+ constructor(dataSimulation, store, simulator) {
1051
+ this.dataSimulation = dataSimulation;
1052
+ this.store = store;
1053
+ this.simulator = simulator;
1054
+ this.router = new GatewayRouter();
1055
+ }
1056
+ isDataDriven(gateway) {
1057
+ const engine = this.dataSimulation.getEngine();
1058
+ const outgoing = this.outgoingFlows(gateway);
1059
+ return this.dataSimulation.isEnabled() && outgoing.length > 1 && outgoing.filter((flow) => !flow.isDefault).every((flow) => flow.expression !== void 0 && engine.canEvaluate(flow.expression));
1060
+ }
1061
+ exit(context, kind) {
1062
+ const { element: gateway, scope } = context;
1063
+ const decision = this.decide(gateway, scope, kind);
1064
+ if (decision.stuckReason) {
1065
+ this.waitForRetry(gateway, scope);
1066
+ return;
1067
+ }
1068
+ for (const flowId of decision.takenFlowIds) {
1069
+ const flow = this.sequenceFlows(gateway).find((candidate) => candidate.id === flowId);
1070
+ this.simulator.enter({ element: flow, scope: scope.parent });
1071
+ }
1072
+ }
1073
+ recordClickDecision(context, kind) {
1074
+ if (!this.dataSimulation.isEnabled()) return;
1075
+ const { element: gateway, scope } = context;
1076
+ const { activeOutgoing } = this.simulator.getConfig(gateway);
1077
+ const chosen = [].concat(activeOutgoing ?? []);
1078
+ const outgoing = this.outgoingFlows(gateway);
1079
+ if (outgoing.length < 2 || !chosen.length) return;
1080
+ const flows = outgoing.map(
1081
+ (flow) => chosen.some((candidate) => candidate.id === flow.id) ? { flow, outcome: "taken", reason: "Chosen by click" } : { flow, outcome: "skipped", reason: "Not chosen by click" }
1082
+ );
1083
+ const decision = {
1084
+ flows,
1085
+ takenFlowIds: flows.filter((flow) => flow.outcome === "taken").map((flow) => flow.flow.id)
1086
+ };
1087
+ this.record(gateway, scope, kind, "click", decision, []);
1088
+ }
1089
+ decide(gateway, scope, kind) {
1090
+ const engine = this.dataSimulation.getEngine();
1091
+ const variables = this.dataSimulation.getVariables(scope);
1092
+ const outgoing = this.outgoingFlows(gateway);
1093
+ const decision = this.router.route(kind, outgoing, (expression) => engine.evaluate(expression, variables));
1094
+ const names = outgoing.flatMap((flow) => flow.expression ? engine.readVariableNames(flow.expression) : []);
1095
+ const inputs = [...new Set(names)].map((name) => ({ name, value: structuredClone(variables[name]) }));
1096
+ this.record(gateway, scope, kind, "data", decision, inputs);
1097
+ return decision;
1098
+ }
1099
+ record(gateway, scope, gatewayKind, chosenBy, decision, inputs) {
1100
+ this.store.record({
1101
+ kind: "decision",
1102
+ instanceId: findProcessInstance(scope).id,
1103
+ elementId: gateway.id,
1104
+ elementName: elementName(gateway),
1105
+ gatewayKind,
1106
+ chosenBy,
1107
+ decision,
1108
+ inputs
1109
+ });
1110
+ }
1111
+ waitForRetry(gateway, scope) {
1112
+ const waitingScope = this.simulator.createScope({ element: gateway, parent: scope.parent, initiator: scope }).start();
1113
+ this.store.addWaiting(findProcessInstance(scope).id, {
1114
+ scopeId: waitingScope.id,
1115
+ gatewayId: gateway.id,
1116
+ gatewayName: elementName(gateway)
1117
+ });
1118
+ const retry = { element: gateway, type: "continue", interrupting: false, boundary: false };
1119
+ const subscription = this.simulator.subscribe(waitingScope, retry, (initiator) => {
1120
+ subscription.remove();
1121
+ this.store.removeWaiting(waitingScope.id);
1122
+ this.simulator.exit({ element: gateway, scope: waitingScope, initiator });
1123
+ });
1124
+ }
1125
+ outgoingFlows(gateway) {
1126
+ const engine = this.dataSimulation.getEngine();
1127
+ const defaultFlow = gateway.businessObject.default;
1128
+ return this.sequenceFlows(gateway).map((flow) => {
1129
+ const name = flow.businessObject.name;
1130
+ return {
1131
+ id: flow.id,
1132
+ ...typeof name === "string" && name ? { name } : {},
1133
+ expression: engine.readCondition(flow.businessObject),
1134
+ isDefault: flow.businessObject === defaultFlow
1135
+ };
1136
+ });
1137
+ }
1138
+ sequenceFlows(gateway) {
1139
+ return (gateway.outgoing ?? []).filter((flow) => is(flow, "bpmn:SequenceFlow"));
1140
+ }
1141
+ }
1142
+ DataGateways.$inject = ["dataSimulation", "dataSimulationStore", "simulator"];
1143
+
1144
+ class IoMappings {
1145
+ constructor(engine, store) {
1146
+ this.engine = engine;
1147
+ this.store = store;
1148
+ }
1149
+ apply(element, instanceId) {
1150
+ const inputs = this.engine.readInputMappings(element.businessObject);
1151
+ const outputs = this.engine.readOutputMappings(element.businessObject);
1152
+ const taskResult = this.store.getTaskResult(instanceId, element.id);
1153
+ if (!inputs.length && !outputs.length && !taskResult) return;
1154
+ const processVariables = this.store.getVariables(instanceId);
1155
+ const localVariables = this.evaluate(element, instanceId, inputs, {}, (current) => ({
1156
+ ...processVariables,
1157
+ ...current
1158
+ }));
1159
+ const context = { ...processVariables, ...localVariables, ...taskResult };
1160
+ const propagatesTaskResult = taskResult && (this.engine.taskResultPropagation === "always" || !outputs.length);
1161
+ const withTaskResult = propagatesTaskResult ? { ...processVariables, ...withoutKeys(taskResult, Object.keys(localVariables)) } : processVariables;
1162
+ this.store.setVariables(
1163
+ instanceId,
1164
+ this.evaluate(element, instanceId, outputs, withTaskResult, () => context)
1165
+ );
1166
+ }
1167
+ evaluate(element, instanceId, mappings, target, contextOf) {
1168
+ let result = target;
1169
+ for (const mapping of mappings) {
1170
+ const evaluation = this.engine.evaluate(mapping.source, contextOf(result));
1171
+ if (evaluation.ok) {
1172
+ result = this.engine.writeVariable(result, mapping.target, evaluation.value);
1173
+ } else {
1144
1174
  this.store.record({
1145
- kind: 'decision',
1146
- instanceId: findProcessInstance(scope).id,
1147
- elementId: gateway.id,
1148
- elementName: elementName(gateway),
1149
- gatewayKind,
1150
- chosenBy,
1151
- decision,
1152
- inputs,
1153
- });
1154
- }
1155
- waitForRetry(gateway, scope) {
1156
- const waitingScope = this.simulator
1157
- .createScope({ element: gateway, parent: scope.parent, initiator: scope })
1158
- .start();
1159
- this.store.addWaiting(findProcessInstance(scope).id, {
1160
- scopeId: waitingScope.id,
1161
- gatewayId: gateway.id,
1162
- gatewayName: elementName(gateway),
1163
- });
1164
- const retry = { element: gateway, type: 'continue', interrupting: false, boundary: false };
1165
- const subscription = this.simulator.subscribe(waitingScope, retry, initiator => {
1166
- subscription.remove();
1167
- this.store.removeWaiting(waitingScope.id);
1168
- this.simulator.exit({ element: gateway, scope: waitingScope, initiator });
1169
- });
1170
- }
1171
- outgoingFlows(gateway) {
1172
- const engine = this.dataSimulation.getEngine();
1173
- const defaultFlow = gateway.businessObject.default;
1174
- return this.sequenceFlows(gateway).map(flow => {
1175
- const name = flow.businessObject.name;
1176
- return {
1177
- id: flow.id,
1178
- ...(typeof name === 'string' && name ? { name } : {}),
1179
- expression: engine.readCondition(flow.businessObject),
1180
- isDefault: flow.businessObject === defaultFlow,
1181
- };
1175
+ kind: "mapping-issue",
1176
+ instanceId,
1177
+ elementId: element.id,
1178
+ elementName: elementName(element),
1179
+ target: mapping.target,
1180
+ reason: evaluation.reason
1182
1181
  });
1182
+ }
1183
1183
  }
1184
- sequenceFlows(gateway) {
1185
- return (gateway.outgoing ?? []).filter(flow => is(flow, 'bpmn:SequenceFlow'));
1186
- }
1184
+ return result;
1185
+ }
1187
1186
  }
1188
- DataGateways.$inject = ['dataSimulation', 'dataSimulationStore', 'simulator'];
1187
+
1188
+ const TOGGLE_MODE_EVENT = "tokenSimulation.toggleMode";
1189
+ const RESET_SIMULATION_EVENT = "tokenSimulation.resetSimulation";
1190
+ const SCOPE_CREATE_EVENT = "tokenSimulation.simulator.createScope";
1191
+ const SCOPE_DESTROYED_EVENT = "tokenSimulation.simulator.destroyScope";
1192
+ const TRACE_EVENT = "tokenSimulation.simulator.trace";
1193
+ const DATA_TOGGLE_EVENT = "dataSimulation.toggle";
1189
1194
 
1190
1195
  class DataSimulation {
1191
- constructor(config, eventBus, store) {
1192
- this.eventBus = eventBus;
1193
- this.store = store;
1194
- this.engine = resolveEngine(config?.engine ?? 'zeebe');
1195
- this.enabled = config?.enabled ?? true;
1196
- this.store.setEngine(this.engine.label, this.engine.expressionLanguage);
1197
- if (config?.scenarios !== undefined)
1198
- this.setScenarios(config.scenarios);
1199
- eventBus.on(SCOPE_CREATE_EVENT, ({ scope }) => this.onScopeCreated(scope));
1200
- eventBus.on(SCOPE_DESTROYED_EVENT, ({ scope }) => {
1201
- this.store.completeInstance(scope.id);
1202
- this.store.removeWaiting(scope.id);
1203
- });
1204
- eventBus.on(TRACE_EVENT, (event) => {
1205
- if (event.action === 'exit')
1206
- this.applyMappings(event.element, event.scope);
1207
- });
1208
- eventBus.on([RESET_SIMULATION_EVENT, TOGGLE_MODE_EVENT], () => this.store.reset());
1209
- }
1210
- getEngine() {
1211
- return this.engine;
1212
- }
1213
- isEnabled() {
1214
- return this.enabled;
1215
- }
1216
- setEnabled(enabled) {
1217
- if (enabled === this.enabled)
1218
- return;
1219
- this.enabled = enabled;
1220
- this.store.reset();
1221
- this.eventBus.fire(DATA_TOGGLE_EVENT, { enabled });
1222
- }
1223
- setScenarios(input) {
1224
- this.store.setScenarios(parseScenarios(input));
1225
- }
1226
- selectScenario(scenarioId) {
1227
- this.store.selectScenario(scenarioId);
1228
- }
1229
- setStartVariables(variables) {
1230
- this.store.setStartVariables(variables);
1231
- }
1232
- selectInstance(instanceId) {
1233
- this.store.selectInstance(instanceId);
1234
- }
1235
- setInstanceVariables(instanceId, variables) {
1236
- this.store.setVariables(instanceId, variables);
1237
- }
1238
- getVariables(scope) {
1239
- return this.store.getVariables(findProcessInstance(scope).id);
1240
- }
1241
- getSnapshot() {
1242
- return this.store.getSnapshot();
1243
- }
1244
- subscribe(listener) {
1245
- return this.store.subscribe(listener);
1246
- }
1247
- onScopeCreated(scope) {
1248
- if (!this.enabled || scope.parent || (!is(scope.element, 'bpmn:Process') && !is(scope.element, 'bpmn:Participant')))
1249
- return;
1250
- this.store.startInstance(scope.id, elementName(scope.element));
1251
- }
1252
- applyMappings(element, scope) {
1253
- if (!is(element, 'bpmn:FlowNode') || scope.failed || scope.canceled)
1254
- return;
1255
- const instanceId = findProcessInstance(scope).id;
1256
- if (!this.store.hasInstance(instanceId))
1257
- return;
1258
- const inputs = this.engine.readInputMappings(element.businessObject);
1259
- const outputs = this.engine.readOutputMappings(element.businessObject);
1260
- const taskResult = this.store.getTaskResult(instanceId, element.id);
1261
- if (!inputs.length && !outputs.length && !taskResult)
1262
- return;
1263
- const processVariables = this.store.getVariables(instanceId);
1264
- const localVariables = this.evaluateMappings(element, instanceId, inputs, {}, current => ({
1265
- ...processVariables,
1266
- ...current,
1267
- }));
1268
- const context = { ...processVariables, ...localVariables, ...taskResult };
1269
- const propagatesTaskResult = taskResult && (this.engine.taskResultPropagation === 'always' || !outputs.length);
1270
- const withTaskResult = propagatesTaskResult
1271
- ? { ...processVariables, ...withoutKeys(taskResult, Object.keys(localVariables)) }
1272
- : processVariables;
1273
- this.store.setVariables(instanceId, this.evaluateMappings(element, instanceId, outputs, withTaskResult, () => context));
1196
+ constructor(config, eventBus, store) {
1197
+ this.eventBus = eventBus;
1198
+ this.store = store;
1199
+ this.scenarioParser = new ScenarioParser();
1200
+ this.engine = new EngineRegistry().resolve(config?.engine ?? "zeebe");
1201
+ this.ioMappings = new IoMappings(this.engine, store);
1202
+ this.enabled = config?.enabled ?? true;
1203
+ this.store.setEngine(this.engine.label, this.engine.expressionLanguage);
1204
+ if (config?.scenarios !== void 0) this.setScenarios(config.scenarios);
1205
+ eventBus.on(SCOPE_CREATE_EVENT, ({ scope }) => this.onScopeCreated(scope));
1206
+ eventBus.on(SCOPE_DESTROYED_EVENT, ({ scope }) => {
1207
+ this.store.completeInstance(scope.id);
1208
+ this.store.removeWaiting(scope.id);
1209
+ });
1210
+ eventBus.on(TRACE_EVENT, (event) => {
1211
+ if (event.action === "exit") this.applyMappings(event.element, event.scope);
1212
+ });
1213
+ eventBus.on([RESET_SIMULATION_EVENT, TOGGLE_MODE_EVENT], () => this.store.reset());
1214
+ }
1215
+ getEngine() {
1216
+ return this.engine;
1217
+ }
1218
+ isEnabled() {
1219
+ return this.enabled;
1220
+ }
1221
+ setEnabled(enabled) {
1222
+ if (enabled === this.enabled) return;
1223
+ this.enabled = enabled;
1224
+ this.store.reset();
1225
+ this.eventBus.fire(DATA_TOGGLE_EVENT, { enabled });
1226
+ }
1227
+ setScenarios(input) {
1228
+ this.store.setScenarios(this.scenarioParser.parse(input));
1229
+ }
1230
+ selectScenario(scenarioId) {
1231
+ this.store.selectScenario(scenarioId);
1232
+ }
1233
+ setStartVariables(variables) {
1234
+ this.store.setStartVariables(variables);
1235
+ }
1236
+ selectInstance(instanceId) {
1237
+ this.store.selectInstance(instanceId);
1238
+ }
1239
+ setInstanceVariables(instanceId, variables) {
1240
+ this.store.setVariables(instanceId, variables);
1241
+ }
1242
+ getVariables(scope) {
1243
+ return this.store.getVariables(findProcessInstance(scope).id);
1244
+ }
1245
+ getSnapshot() {
1246
+ return this.store.getSnapshot();
1247
+ }
1248
+ subscribe(listener) {
1249
+ return this.store.subscribe(listener);
1250
+ }
1251
+ onScopeCreated(scope) {
1252
+ if (!this.enabled || scope.parent || !is(scope.element, "bpmn:Process") && !is(scope.element, "bpmn:Participant"))
1253
+ return;
1254
+ this.store.startInstance(scope.id, elementName(scope.element));
1255
+ }
1256
+ applyMappings(element, scope) {
1257
+ if (!is(element, "bpmn:FlowNode") || scope.failed || scope.canceled) return;
1258
+ const instanceId = findProcessInstance(scope).id;
1259
+ if (this.store.hasInstance(instanceId)) this.ioMappings.apply(element, instanceId);
1260
+ }
1261
+ }
1262
+ DataSimulation.$inject = ["config.dataSimulation", "eventBus", "dataSimulationStore"];
1263
+
1264
+ class GatewayDecisionView {
1265
+ constructor(snapshot) {
1266
+ this.snapshot = snapshot;
1267
+ this.decisions = this.latestDecisionPerGateway();
1268
+ const shownPerGateway = new Map(this.decisions.map((entry) => [entry.elementId, entry]));
1269
+ for (const entry of this.latestStuckDecisionPerGateway()) shownPerGateway.set(entry.elementId, entry);
1270
+ this.shown = [...shownPerGateway.values()];
1271
+ }
1272
+ latestDecisionPerGateway() {
1273
+ const { log, selectedInstanceId } = this.snapshot;
1274
+ const latest = /* @__PURE__ */ new Map();
1275
+ for (const entry of log) {
1276
+ if (entry.kind === "decision" && entry.instanceId === selectedInstanceId) latest.set(entry.elementId, entry);
1274
1277
  }
1275
- evaluateMappings(element, instanceId, mappings, target, contextOf) {
1276
- let result = target;
1277
- for (const mapping of mappings) {
1278
- const evaluation = this.engine.evaluate(mapping.source, contextOf(result));
1279
- if (evaluation.ok) {
1280
- result = this.engine.writeVariable(result, mapping.target, evaluation.value);
1281
- }
1282
- else {
1283
- this.store.record({
1284
- kind: 'mapping-issue',
1285
- instanceId,
1286
- elementId: element.id,
1287
- elementName: elementName(element),
1288
- target: mapping.target,
1289
- reason: evaluation.reason,
1290
- });
1291
- }
1292
- }
1293
- return result;
1278
+ return [...latest.values()];
1279
+ }
1280
+ latestStuckDecisionPerGateway() {
1281
+ const { instances, log } = this.snapshot;
1282
+ const latest = /* @__PURE__ */ new Map();
1283
+ for (const instance of instances) {
1284
+ for (const { gatewayId } of instance.waiting) {
1285
+ const decision = [...log].reverse().find(
1286
+ (entry) => entry.kind === "decision" && entry.instanceId === instance.id && entry.elementId === gatewayId
1287
+ );
1288
+ if (decision && (latest.get(gatewayId)?.id ?? 0) < decision.id) latest.set(gatewayId, decision);
1289
+ }
1294
1290
  }
1295
- }
1296
- DataSimulation.$inject = ['config.dataSimulation', 'eventBus', 'dataSimulationStore'];
1297
- function withoutKeys(variables, keys) {
1298
- return Object.fromEntries(Object.entries(variables).filter(([key]) => !keys.includes(key)));
1291
+ return [...latest.values()];
1292
+ }
1299
1293
  }
1300
1294
 
1301
1295
  const OUTCOME_LABELS = {
1302
- taken: { symbol: '✓', title: 'Taken' },
1303
- 'not-taken': { symbol: '✗', title: 'Condition is false' },
1304
- error: { symbol: '!', title: 'Condition could not be evaluated' },
1305
- skipped: { symbol: '–', title: 'Not evaluated' },
1296
+ taken: { symbol: "\u2713", title: "Taken" },
1297
+ "not-taken": { symbol: "\u2717", title: "Condition is false" },
1298
+ error: { symbol: "!", title: "Condition could not be evaluated" },
1299
+ skipped: { symbol: "\u2013", title: "Not evaluated" }
1306
1300
  };
1307
1301
  const DEFAULT_FLOW_TITLES = {
1308
- taken: 'Default flow taken, no condition is true',
1309
- 'not-taken': 'Default flow not needed',
1302
+ taken: "Default flow taken, no condition is true",
1303
+ "not-taken": "Default flow not needed"
1310
1304
  };
1311
- function createOutcomeBadge(outcome, detail, isDefault = false) {
1312
- const { symbol } = OUTCOME_LABELS[outcome];
1313
- const title = (isDefault && DEFAULT_FLOW_TITLES[outcome]) || OUTCOME_LABELS[outcome].title;
1314
- const badge = document.createElement('span');
1315
- badge.className = `bds-outcome bds-outcome--${outcome}`;
1316
- badge.textContent = symbol;
1317
- badge.title = detail ? `${title}: ${detail}` : title;
1318
- return badge;
1305
+ class OutcomeBadge {
1306
+ constructor(outcome, detail, isDefault = false) {
1307
+ this.element = document.createElement("span");
1308
+ const title = isDefault && DEFAULT_FLOW_TITLES[outcome] || OUTCOME_LABELS[outcome].title;
1309
+ this.element.className = `bds-outcome bds-outcome--${outcome}`;
1310
+ this.element.textContent = OUTCOME_LABELS[outcome].symbol;
1311
+ this.element.title = detail ? `${title}: ${detail}` : title;
1312
+ }
1319
1313
  }
1320
- function createDecisionCard({ elementName, gatewayKind, chosenBy, decision, inputs }, onClose) {
1321
- const closeButton = onClose
1322
- ? h('button', { className: 'bds-icon-button bds-decision-close', type: 'button', 'aria-label': 'Close' }, '×')
1323
- : null;
1324
- closeButton?.addEventListener('click', onClose);
1325
- return h('div', { className: `bds-decision${decision.stuckReason ? ' bds-decision--stuck' : ''}`, role: 'note' }, h('div', { className: 'bds-decision-title' }, h('span', {}, elementName), h('span', { className: 'bds-tag' }, chosenBy === 'click' ? `${gatewayKind} · by click` : gatewayKind), closeButton), decision.stuckReason
1326
- ? h('p', { className: 'bds-error' }, `${decision.stuckReason}. Change the variables in Process Data, then press ▶ on the gateway.`)
1327
- : null, h('ul', { className: 'bds-flows' }, ...decision.flows.map(({ flow, outcome, reason }) => h('li', { className: `bds-flow bds-flow--${outcome}` }, createOutcomeBadge(outcome, reason, flow.isDefault), h('span', { className: 'bds-flow-name' }, flow.name ?? flow.id), flow.isDefault
1328
- ? h('span', { className: 'bds-tag' }, 'default')
1329
- : flow.expression && h('code', {}, flow.expression)))), inputs.length ? createInputList(inputs) : null);
1314
+
1315
+ class DecisionCard {
1316
+ constructor({ elementName, gatewayKind, chosenBy, decision, inputs }, onClose) {
1317
+ this.element = h(
1318
+ "div",
1319
+ { className: `bds-decision${decision.stuckReason ? " bds-decision--stuck" : ""}`, role: "note" },
1320
+ h(
1321
+ "div",
1322
+ { className: "bds-decision-title" },
1323
+ h("span", {}, elementName),
1324
+ h("span", { className: "bds-tag" }, chosenBy === "click" ? `${gatewayKind} \xB7 by click` : gatewayKind),
1325
+ onClose ? this.closeButton(onClose) : null
1326
+ ),
1327
+ decision.stuckReason ? h(
1328
+ "p",
1329
+ { className: "bds-error" },
1330
+ `${decision.stuckReason}. Change the variables in Process Data, then press \u25B6 on the gateway.`
1331
+ ) : null,
1332
+ h(
1333
+ "ul",
1334
+ { className: "bds-flows" },
1335
+ ...decision.flows.map(
1336
+ ({ flow, outcome, reason }) => h(
1337
+ "li",
1338
+ { className: `bds-flow bds-flow--${outcome}` },
1339
+ new OutcomeBadge(outcome, reason, flow.isDefault).element,
1340
+ h("span", { className: "bds-flow-name" }, flow.name ?? flow.id),
1341
+ flow.isDefault ? h("span", { className: "bds-tag" }, "default") : flow.expression && h("code", {}, flow.expression)
1342
+ )
1343
+ )
1344
+ ),
1345
+ inputs.length ? this.inputList(inputs) : null
1346
+ );
1347
+ }
1348
+ closeButton(onClose) {
1349
+ const button = h(
1350
+ "button",
1351
+ { className: "bds-icon-button bds-decision-close", type: "button", "aria-label": "Close" },
1352
+ "\xD7"
1353
+ );
1354
+ button.addEventListener("click", onClose);
1355
+ return button;
1356
+ }
1357
+ inputList(inputs) {
1358
+ return h(
1359
+ "dl",
1360
+ { className: "bds-decision-inputs" },
1361
+ ...inputs.flatMap(({ name, value }) => [
1362
+ h("dt", {}, name),
1363
+ h(
1364
+ "dd",
1365
+ {},
1366
+ value === void 0 ? h("span", { className: "bds-hint" }, "not set") : h("code", {}, formatValue(value))
1367
+ )
1368
+ ])
1369
+ );
1370
+ }
1330
1371
  }
1331
- function createInputList(inputs) {
1332
- return h('dl', { className: 'bds-decision-inputs' }, ...inputs.flatMap(({ name, value }) => [
1333
- h('dt', {}, name),
1334
- h('dd', {}, value === undefined ? h('span', { className: 'bds-hint' }, 'not set') : h('code', {}, formatValue(value))),
1335
- ]));
1372
+
1373
+ function badgePosition(waypoints, distanceFromStart) {
1374
+ const [start, next] = waypoints;
1375
+ const length = Math.hypot(next.x - start.x, next.y - start.y) || 1;
1376
+ const distance = Math.min(distanceFromStart, length / 2);
1377
+ const x = start.x + (next.x - start.x) / length * distance;
1378
+ const y = start.y + (next.y - start.y) / length * distance;
1379
+ const minX = Math.min(...waypoints.map((point) => point.x));
1380
+ const minY = Math.min(...waypoints.map((point) => point.y));
1381
+ return { left: x - minX, top: y - minY };
1336
1382
  }
1337
1383
 
1338
1384
  const GAP$1 = 12;
1339
1385
  const MARGIN = 8;
1340
1386
  function placePopover(anchor, popover, bounds) {
1341
- const below = anchor.y + anchor.height + GAP$1;
1342
- const above = anchor.y - GAP$1 - popover.height;
1343
- const fitsBelow = below + popover.height <= bounds.height - MARGIN;
1344
- const fitsAbove = above >= MARGIN;
1345
- const height = Math.min(popover.height, bounds.height - 2 * MARGIN);
1346
- return {
1347
- left: clamp(anchor.x + anchor.width / 2 - popover.width / 2, MARGIN, bounds.width - popover.width - MARGIN),
1348
- top: fitsBelow ? below : fitsAbove ? above : clamp(below, MARGIN, bounds.height - height - MARGIN),
1349
- maxHeight: height < popover.height ? height : undefined,
1350
- hidden: !isInView(anchor, bounds),
1351
- };
1387
+ const below = anchor.y + anchor.height + GAP$1;
1388
+ const above = anchor.y - GAP$1 - popover.height;
1389
+ const fitsBelow = below + popover.height <= bounds.height - MARGIN;
1390
+ const fitsAbove = above >= MARGIN;
1391
+ const height = Math.min(popover.height, bounds.height - 2 * MARGIN);
1392
+ return {
1393
+ left: clamp(anchor.x + anchor.width / 2 - popover.width / 2, MARGIN, bounds.width - popover.width - MARGIN),
1394
+ top: fitsBelow ? below : fitsAbove ? above : clamp(below, MARGIN, bounds.height - height - MARGIN),
1395
+ maxHeight: height < popover.height ? height : void 0,
1396
+ hidden: !isInView(anchor, bounds)
1397
+ };
1352
1398
  }
1353
1399
  function clamp(value, min, max) {
1354
- return Math.max(min, Math.min(value, max));
1400
+ return Math.max(min, Math.min(value, max));
1355
1401
  }
1356
1402
  function isInView(anchor, bounds) {
1357
- return (anchor.x + anchor.width > 0 && anchor.x < bounds.width && anchor.y + anchor.height > 0 && anchor.y < bounds.height);
1403
+ return anchor.x + anchor.width > 0 && anchor.x < bounds.width && anchor.y + anchor.height > 0 && anchor.y < bounds.height;
1358
1404
  }
1359
1405
 
1360
1406
  var componentStyles = ":host {\n all: initial;\n display: contents;\n}\n\n.bds-panel {\n position: absolute;\n top: 30%;\n right: 20px;\n bottom: 50px;\n z-index: 10000;\n display: flex;\n flex-direction: column;\n width: 300px;\n overflow: hidden;\n font-family: var(--bds-font);\n font-size: 13px;\n color: var(--bds-ink);\n background: var(--token-simulation-control-background, #f1f2f4);\n border-radius: var(--surface-border-radius, 4px);\n}\n\n.bds-panel[hidden] {\n display: none;\n}\n\n.bds-panel-header {\n display: flex;\n flex: 0 0 auto;\n align-items: center;\n gap: var(--bds-space-2);\n box-sizing: border-box;\n height: 30px;\n padding: 6px 8px;\n font-size: 16px;\n color: var(--token-simulation-control-surface, #fff);\n background: var(--token-simulation-primary, #0067cc);\n}\n\n.bds-panel-heading {\n flex: 1;\n margin: 0;\n font: inherit;\n text-align: center;\n}\n\n.bds-panel-close {\n display: inline-flex;\n align-items: center;\n padding: 0;\n color: inherit;\n background: none;\n border: none;\n cursor: pointer;\n}\n\n.bds-variables-icon svg,\n.bds-panel-close svg {\n width: 1em;\n height: 1em;\n fill: none;\n stroke: currentColor;\n stroke-width: 1.6;\n stroke-linecap: round;\n stroke-linejoin: round;\n}\n\n.bds-variables-icon {\n display: inline-flex;\n align-items: center;\n}\n\n.bds-panel-body {\n display: flex;\n flex: 1;\n flex-direction: column;\n gap: var(--bds-space-2);\n margin: 7px 3px 7px 12px;\n padding: 5px 9px 5px 0;\n overflow-y: auto;\n}\n\n.bds-panel-engine {\n margin: 0;\n}\n\n.bds-panel .bds-section {\n padding: var(--bds-space-2);\n background: var(--token-simulation-control-surface, #fff);\n border-radius: var(--surface-border-radius, 4px);\n}\n\n.bds-panel-title {\n margin: 0;\n font-size: 14px;\n font-weight: 600;\n}\n\n.bds-engine {\n padding: 2px 8px;\n font-size: 11px;\n font-weight: 600;\n color: var(--bds-accent-ink);\n background: var(--bds-accent-soft);\n border-radius: var(--bds-radius-pill);\n}\n\n.bds-icon-button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n margin-left: auto;\n width: 26px;\n height: 26px;\n padding: 0;\n color: var(--bds-muted);\n background: transparent;\n border: 1px solid transparent;\n border-radius: var(--bds-radius-sm);\n cursor: pointer;\n}\n\n.bds-icon-button svg {\n width: 16px;\n height: 16px;\n fill: none;\n stroke: currentColor;\n stroke-width: 1.5;\n stroke-linecap: round;\n stroke-linejoin: round;\n transition: transform var(--bds-motion-fast) var(--bds-ease);\n}\n\n.bds-icon-button:hover {\n color: var(--bds-accent-ink);\n background: var(--bds-accent-soft);\n}\n\n.bds-section {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-1);\n}\n\n.bds-section[hidden] {\n display: none;\n}\n\n.bds-section-title,\n.bds-label {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-1);\n margin: 0;\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0.01em;\n color: var(--bds-muted);\n}\n\n.bds-section-title {\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n}\n\n.bds-hint {\n margin: 0;\n font-size: 12px;\n color: var(--bds-muted);\n}\n\n.bds-hint[hidden],\n.bds-error[hidden] {\n display: none;\n}\n\n.bds-error {\n margin: 0;\n font-size: 12px;\n color: var(--bds-danger);\n}\n\n.bds-input {\n box-sizing: border-box;\n width: 100%;\n padding: 6px 10px;\n font-family: inherit;\n font-size: 13px;\n font-weight: 400;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-sm);\n transition:\n border-color var(--bds-motion-fast) var(--bds-ease),\n box-shadow var(--bds-motion-fast) var(--bds-ease);\n}\n\n.bds-input:focus,\n.bds-input:focus-visible {\n outline: none;\n border-color: var(--bds-accent);\n box-shadow: 0 0 0 3px var(--bds-accent-soft);\n}\n\n.bds-input--invalid,\n.bds-input--invalid:focus {\n border-color: var(--bds-danger);\n box-shadow: 0 0 0 3px var(--bds-danger-soft);\n}\n\n.bds-json {\n min-height: 72px;\n font-family: var(--bds-font-mono);\n font-size: 12px;\n line-height: 1.5;\n resize: vertical;\n}\n\n.bds-instance-select[hidden] {\n display: none;\n}\n\n.bds-instance-select {\n padding: 4px 8px;\n font-size: 12px;\n}\n\n.bds-actions {\n display: flex;\n justify-content: flex-end;\n gap: var(--bds-space-2);\n margin-top: var(--bds-space-2);\n}\n\n.bds-button {\n padding: 5px 12px;\n font-family: inherit;\n font-size: 12px;\n font-weight: 600;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-sm);\n box-shadow: var(--bds-shadow-1);\n cursor: pointer;\n transition:\n background var(--bds-motion-fast) var(--bds-ease),\n border-color var(--bds-motion-fast) var(--bds-ease),\n color var(--bds-motion-fast) var(--bds-ease);\n}\n\n.bds-button:hover {\n color: var(--bds-accent-ink);\n border-color: var(--bds-accent);\n background: var(--bds-accent-soft);\n}\n\n.bds-button--primary {\n color: var(--bds-on-accent);\n background: var(--bds-accent);\n border-color: var(--bds-accent);\n}\n\n.bds-button--primary:hover {\n color: var(--bds-on-accent);\n background: var(--bds-accent-ink);\n}\n\n.bds-button:focus-visible,\n.bds-icon-button:focus-visible {\n outline: none;\n box-shadow: 0 0 0 3px var(--bds-accent-soft);\n}\n\n.bds-status {\n margin: 0 0 var(--bds-space-1);\n font-size: 12px;\n font-weight: 600;\n}\n\n.bds-status--running {\n color: var(--bds-accent-ink);\n}\n\n.bds-status--completed {\n color: var(--bds-success);\n}\n\n.bds-status--waiting {\n color: var(--bds-danger);\n}\n\n.bds-variables {\n width: 100%;\n border-collapse: collapse;\n}\n\n.bds-variables th,\n.bds-variables td {\n padding: 4px 0;\n text-align: left;\n vertical-align: top;\n border-bottom: 1px solid var(--bds-line);\n}\n\n.bds-variables tr:last-child th,\n.bds-variables tr:last-child td {\n border-bottom: none;\n}\n\n.bds-variables th {\n width: 1%;\n padding-right: var(--bds-space-3);\n font-weight: 500;\n white-space: nowrap;\n}\n\n.bds-variables code,\n.bds-flow code {\n font-family: var(--bds-font-mono);\n font-size: 12px;\n overflow-wrap: anywhere;\n}\n\n.bds-log {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-2);\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.bds-log-entry {\n padding: var(--bds-space-2);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-sm);\n}\n\n.bds-log-entry--issue {\n border-color: var(--bds-danger-soft);\n background: linear-gradient(var(--bds-danger-soft), var(--bds-danger-soft)), var(--bds-surface);\n}\n\n.bds-log-title {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--bds-space-2);\n margin-bottom: var(--bds-space-1);\n font-weight: 600;\n}\n\n.bds-tag {\n padding: 1px 6px;\n font-size: 11px;\n font-weight: 500;\n color: var(--bds-muted);\n background: var(--bds-code-bg);\n border-radius: var(--bds-radius-pill);\n}\n\n.bds-flows {\n display: flex;\n flex-direction: column;\n gap: 2px;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.bds-flow {\n display: grid;\n grid-template-columns: 18px 1fr;\n align-items: center;\n column-gap: var(--bds-space-2);\n row-gap: 2px;\n}\n\n.bds-flow code,\n.bds-flow .bds-tag {\n grid-column: 2;\n justify-self: start;\n}\n\n.bds-flow code {\n padding: 1px 4px;\n color: var(--bds-muted);\n background: var(--bds-code-bg);\n border-radius: 4px;\n}\n\n.bds-flow--skipped,\n.bds-flow--not-taken {\n color: var(--bds-muted);\n}\n\n.bds-outcome {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n width: 18px;\n height: 18px;\n font-family: var(--bds-font);\n font-size: 11px;\n font-weight: 700;\n line-height: 1;\n border-radius: var(--bds-radius-pill);\n border: 1px solid transparent;\n cursor: default;\n}\n\n.bds-outcome--taken {\n color: var(--bds-on-accent);\n background: var(--bds-success);\n}\n\n.bds-outcome--not-taken {\n color: var(--bds-muted);\n background: var(--bds-surface);\n border-color: var(--bds-line);\n}\n\n.bds-outcome--error {\n color: var(--bds-on-accent);\n background: var(--bds-danger);\n}\n\n.bds-outcome--skipped {\n color: var(--bds-muted);\n background: var(--bds-code-bg);\n}\n\n.bds-outcome--on-flow {\n display: flex;\n box-shadow: var(--bds-shadow-1);\n transform: translate(-50%, -50%);\n}\n\n.bds-popover {\n position: absolute;\n z-index: 100;\n overflow-y: auto;\n}\n\n.bds-popover[hidden] {\n display: none;\n}\n\n.bds-decision {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-2);\n box-sizing: border-box;\n width: 300px;\n padding: 12px;\n font-family: var(--bds-font);\n font-size: 12px;\n line-height: 1.4;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-md);\n box-shadow: var(--bds-shadow-3);\n}\n\n.bds-decision--stuck {\n border-color: var(--bds-danger);\n}\n\n.bds-decision-title {\n display: flex;\n align-items: center;\n gap: var(--bds-space-2);\n font-size: 13px;\n font-weight: 600;\n}\n\n.bds-decision-title .bds-tag {\n margin-left: auto;\n}\n\n.bds-decision-close {\n margin-left: 0;\n width: 22px;\n height: 22px;\n font-size: 16px;\n line-height: 1;\n}\n\n.bds-decision-inputs {\n display: grid;\n grid-template-columns: auto 1fr;\n gap: 2px var(--bds-space-3);\n margin: 0;\n padding-top: var(--bds-space-2);\n border-top: 1px solid var(--bds-line);\n}\n\n.bds-decision-inputs dt {\n font-family: var(--bds-font-mono);\n color: var(--bds-muted);\n}\n\n.bds-decision-inputs dd {\n margin: 0;\n overflow-wrap: anywhere;\n}\n\n.bds-decision-inputs code {\n font-family: var(--bds-font-mono);\n}\n\n.bds-dialog-backdrop {\n position: fixed;\n inset: 0;\n z-index: 10010;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: var(--bds-space-3);\n background: rgba(29, 29, 29, 0.24);\n}\n\n.bds-dialog {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-3);\n box-sizing: border-box;\n width: 420px;\n max-width: 100%;\n max-height: 100%;\n margin: 0;\n padding: 20px;\n font-family: var(--bds-font);\n font-size: 13px;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-lg);\n box-shadow: var(--bds-shadow-3);\n}\n\n.bds-dialog-content {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-3);\n min-height: 0;\n overflow-y: auto;\n}\n\n.bds-dialog-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--bds-space-2);\n}\n\n.bds-dialog .bds-actions {\n margin-top: 0;\n}\n\n.bds-form {\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\n.bds-field {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-1);\n}\n\n.bds-field-name {\n font-family: var(--bds-font-mono);\n font-size: 12px;\n font-weight: 600;\n}\n\n.bds-field-hint {\n font-size: 11px;\n color: var(--bds-muted);\n}\n\n.bds-checkbox {\n display: inline-flex;\n align-items: center;\n gap: var(--bds-space-2);\n cursor: pointer;\n}\n\n.bds-checkbox input {\n width: 16px;\n height: 16px;\n margin: 0;\n accent-color: var(--bds-accent);\n}\n\n@media (prefers-reduced-motion: reduce) {\n * {\n transition-duration: 0.001ms !important;\n }\n}\n\n.bds-form .bds-json {\n min-height: 0;\n}\n";
1361
1407
 
1362
1408
  let sharedSheet;
1363
1409
  function inShadow(...children) {
1364
- const host = h('div', { className: 'bds-host' });
1365
- const root = host.attachShadow({ mode: 'open' });
1366
- adoptComponentStyles(root);
1367
- root.append(...children);
1368
- return host;
1410
+ const host = h("div", { className: "bds-host" });
1411
+ const root = host.attachShadow({ mode: "open" });
1412
+ adoptComponentStyles(root);
1413
+ root.append(...children);
1414
+ return host;
1369
1415
  }
1370
1416
  function adoptComponentStyles(root) {
1371
- if ('adoptedStyleSheets' in root && 'replaceSync' in CSSStyleSheet.prototype) {
1372
- sharedSheet ?? (sharedSheet = createSheet());
1373
- root.adoptedStyleSheets = [sharedSheet];
1374
- }
1375
- else {
1376
- root.append(h('style', {}, componentStyles));
1377
- }
1417
+ if ("adoptedStyleSheets" in root && "replaceSync" in CSSStyleSheet.prototype) {
1418
+ sharedSheet ?? (sharedSheet = createSheet());
1419
+ root.adoptedStyleSheets = [sharedSheet];
1420
+ } else {
1421
+ root.append(h("style", {}, componentStyles));
1422
+ }
1378
1423
  }
1379
1424
  function createSheet() {
1380
- const sheet = new CSSStyleSheet();
1381
- sheet.replaceSync(componentStyles);
1382
- return sheet;
1425
+ const sheet = new CSSStyleSheet();
1426
+ sheet.replaceSync(componentStyles);
1427
+ return sheet;
1383
1428
  }
1384
1429
 
1385
- const OUTCOME_OVERLAY = 'bds-flow-outcome';
1386
- const DECIDED_MARKER = 'bds-gateway--decided';
1387
- const STUCK_MARKER = 'bds-gateway--stuck';
1430
+ const OUTCOME_OVERLAY = "bds-flow-outcome";
1431
+ const DECIDED_MARKER = "bds-gateway--decided";
1432
+ const STUCK_MARKER = "bds-gateway--stuck";
1388
1433
  const BADGE_DISTANCE = 38;
1389
1434
  const BADGE_MIN_SCALE = 1;
1390
1435
  class DataSimulationOverlays {
1391
- constructor(eventBus, overlays, elementRegistry, canvas, dataSimulation) {
1392
- this.overlays = overlays;
1393
- this.elementRegistry = elementRegistry;
1394
- this.canvas = canvas;
1395
- this.pinnedGatewayIds = new Set();
1396
- this.markedGateways = [];
1397
- this.popovers = [];
1398
- this.popoverLayer = inShadow();
1399
- this.renderedState = '';
1400
- this.snapshot = dataSimulation.getSnapshot();
1401
- const unsubscribe = dataSimulation.subscribe(snapshot => {
1402
- this.snapshot = snapshot;
1403
- this.render();
1404
- });
1405
- eventBus.on('element.hover', ({ element }) => {
1406
- this.hoveredGatewayId = gatewayOf(element);
1407
- this.render();
1408
- });
1409
- eventBus.on('element.click', ({ element }) => {
1410
- if (!isGateway(element))
1411
- return;
1412
- if (!this.pinnedGatewayIds.delete(element.id))
1413
- this.pinnedGatewayIds.add(element.id);
1414
- this.render();
1415
- });
1416
- eventBus.on(['canvas.viewbox.changed', 'canvas.resized'], () => this.placePopovers());
1417
- canvas.getContainer().append(this.popoverLayer);
1418
- eventBus.on('diagram.destroy', () => {
1419
- unsubscribe();
1420
- this.popoverLayer.remove();
1421
- });
1422
- }
1423
- render() {
1424
- const decisions = latestDecisionPerGateway(this.snapshot);
1425
- const shownPerGateway = new Map(decisions.map(entry => [entry.elementId, entry]));
1426
- for (const entry of latestStuckDecisionPerGateway(this.snapshot))
1427
- shownPerGateway.set(entry.elementId, entry);
1428
- const shown = [...shownPerGateway.values()];
1429
- const cards = shown.filter(({ elementId }) => elementId === this.hoveredGatewayId || this.pinnedGatewayIds.has(elementId));
1430
- const state = JSON.stringify([
1431
- decisions.map(entry => entry.id),
1432
- shown.map(entry => entry.id),
1433
- cards.map(entry => [entry.id, this.pinnedGatewayIds.has(entry.elementId)]),
1434
- ]);
1435
- if (state === this.renderedState)
1436
- return;
1437
- this.renderedState = state;
1438
- this.overlays.remove({ type: OUTCOME_OVERLAY });
1439
- this.unmarkGateways();
1440
- for (const entry of decisions)
1441
- this.showOutcomes(entry.decision);
1442
- for (const entry of shown)
1443
- this.markGateway(entry);
1444
- this.showCards(cards);
1445
- }
1446
- markGateway({ elementId, decision }) {
1447
- const gateway = this.elementRegistry.get(elementId);
1448
- if (!gateway)
1449
- return;
1450
- this.canvas.addMarker(gateway, decision.stuckReason ? STUCK_MARKER : DECIDED_MARKER);
1451
- this.markedGateways.push(gateway);
1452
- }
1453
- unmarkGateways() {
1454
- for (const gateway of this.markedGateways) {
1455
- this.canvas.removeMarker(gateway, DECIDED_MARKER);
1456
- this.canvas.removeMarker(gateway, STUCK_MARKER);
1457
- }
1458
- this.markedGateways = [];
1459
- }
1460
- showOutcomes(decision) {
1461
- for (const { flow, outcome, reason } of decision.flows) {
1462
- const connection = this.elementRegistry.get(flow.id);
1463
- if (!connection?.waypoints)
1464
- continue;
1465
- const badge = createOutcomeBadge(outcome, reason, flow.isDefault);
1466
- badge.classList.add('bds-outcome--on-flow');
1467
- this.overlays.add(connection, OUTCOME_OVERLAY, {
1468
- position: badgePosition(connection.waypoints),
1469
- scale: { min: BADGE_MIN_SCALE },
1470
- html: inShadow(badge),
1471
- });
1472
- }
1473
- }
1474
- showCards(entries) {
1475
- this.popovers = entries.flatMap(entry => {
1476
- const gateway = this.elementRegistry.get(entry.elementId);
1477
- if (!gateway)
1478
- return [];
1479
- const close = () => {
1480
- this.pinnedGatewayIds.delete(entry.elementId);
1481
- this.render();
1482
- };
1483
- const card = createDecisionCard(entry, this.pinnedGatewayIds.has(entry.elementId) ? close : undefined);
1484
- card.classList.add('bds-popover');
1485
- card.dataset.elementId = entry.elementId;
1486
- return [{ gateway, card }];
1487
- });
1488
- this.popoverLayer.shadowRoot.replaceChildren(...this.popovers.map(({ card }) => card));
1489
- this.placePopovers();
1490
- }
1491
- placePopovers() {
1492
- const container = this.canvas.getContainer();
1493
- const bounds = { width: container.clientWidth, height: container.clientHeight };
1494
- for (const { gateway, card } of this.popovers) {
1495
- card.style.maxHeight = '';
1496
- const { left, top, maxHeight, hidden } = placePopover(this.canvas.getAbsoluteBBox(gateway), { width: card.offsetWidth, height: card.offsetHeight }, bounds);
1497
- card.hidden = hidden;
1498
- card.style.left = `${left}px`;
1499
- card.style.top = `${top}px`;
1500
- card.style.maxHeight = maxHeight === undefined ? '' : `${maxHeight}px`;
1501
- }
1502
- }
1503
- }
1504
- DataSimulationOverlays.$inject = ['eventBus', 'overlays', 'elementRegistry', 'canvas', 'dataSimulation'];
1505
- function isGateway(element) {
1506
- return element.type === 'bpmn:ExclusiveGateway' || element.type === 'bpmn:InclusiveGateway';
1507
- }
1508
- function gatewayOf(element) {
1509
- if (isGateway(element))
1510
- return element.id;
1511
- if (element.type === 'bpmn:SequenceFlow' && element.source && isGateway(element.source))
1512
- return element.source.id;
1513
- return undefined;
1514
- }
1515
- function latestDecisionPerGateway({ log, selectedInstanceId }) {
1516
- const latest = new Map();
1517
- for (const entry of log) {
1518
- if (entry.kind === 'decision' && entry.instanceId === selectedInstanceId)
1519
- latest.set(entry.elementId, entry);
1520
- }
1521
- return [...latest.values()];
1522
- }
1523
- function latestStuckDecisionPerGateway({ instances, log }) {
1524
- const latest = new Map();
1525
- for (const instance of instances) {
1526
- for (const { gatewayId } of instance.waiting) {
1527
- const decision = [...log]
1528
- .reverse()
1529
- .find((entry) => entry.kind === 'decision' && entry.instanceId === instance.id && entry.elementId === gatewayId);
1530
- if (decision && (latest.get(gatewayId)?.id ?? 0) < decision.id)
1531
- latest.set(gatewayId, decision);
1532
- }
1533
- }
1534
- return [...latest.values()];
1535
- }
1536
- function badgePosition(waypoints) {
1537
- const [start, next] = waypoints;
1538
- const length = Math.hypot(next.x - start.x, next.y - start.y) || 1;
1539
- const distance = Math.min(BADGE_DISTANCE, length / 2);
1540
- const x = start.x + ((next.x - start.x) / length) * distance;
1541
- const y = start.y + ((next.y - start.y) / length) * distance;
1542
- const minX = Math.min(...waypoints.map(point => point.x));
1543
- const minY = Math.min(...waypoints.map(point => point.y));
1544
- return { left: x - minX, top: y - minY };
1545
- }
1436
+ constructor(eventBus, overlays, elementRegistry, canvas, dataSimulation) {
1437
+ this.overlays = overlays;
1438
+ this.elementRegistry = elementRegistry;
1439
+ this.canvas = canvas;
1440
+ this.pinnedGatewayIds = /* @__PURE__ */ new Set();
1441
+ this.markedGateways = [];
1442
+ this.popovers = [];
1443
+ this.popoverLayer = inShadow();
1444
+ this.renderedState = "";
1445
+ this.snapshot = dataSimulation.getSnapshot();
1446
+ const unsubscribe = dataSimulation.subscribe((snapshot) => {
1447
+ this.snapshot = snapshot;
1448
+ this.render();
1449
+ });
1450
+ eventBus.on("element.hover", ({ element }) => {
1451
+ this.hoveredGatewayId = gatewayOf(element);
1452
+ this.render();
1453
+ });
1454
+ eventBus.on("element.click", ({ element }) => {
1455
+ if (!isGateway(element)) return;
1456
+ if (!this.pinnedGatewayIds.delete(element.id)) this.pinnedGatewayIds.add(element.id);
1457
+ this.render();
1458
+ });
1459
+ eventBus.on(["canvas.viewbox.changed", "canvas.resized"], () => this.placePopovers());
1460
+ canvas.getContainer().append(this.popoverLayer);
1461
+ eventBus.on("diagram.destroy", () => {
1462
+ unsubscribe();
1463
+ this.popoverLayer.remove();
1464
+ });
1465
+ }
1466
+ render() {
1467
+ const { decisions, shown } = new GatewayDecisionView(this.snapshot);
1468
+ const cards = shown.filter(
1469
+ ({ elementId }) => elementId === this.hoveredGatewayId || this.pinnedGatewayIds.has(elementId)
1470
+ );
1471
+ const state = JSON.stringify([
1472
+ decisions.map((entry) => entry.id),
1473
+ shown.map((entry) => entry.id),
1474
+ cards.map((entry) => [entry.id, this.pinnedGatewayIds.has(entry.elementId)])
1475
+ ]);
1476
+ if (state === this.renderedState) return;
1477
+ this.renderedState = state;
1478
+ this.overlays.remove({ type: OUTCOME_OVERLAY });
1479
+ this.unmarkGateways();
1480
+ for (const entry of decisions) this.showOutcomes(entry.decision);
1481
+ for (const entry of shown) this.markGateway(entry);
1482
+ this.showCards(cards);
1483
+ }
1484
+ markGateway({ elementId, decision }) {
1485
+ const gateway = this.elementRegistry.get(elementId);
1486
+ if (!gateway) return;
1487
+ this.canvas.addMarker(gateway, decision.stuckReason ? STUCK_MARKER : DECIDED_MARKER);
1488
+ this.markedGateways.push(gateway);
1489
+ }
1490
+ unmarkGateways() {
1491
+ for (const gateway of this.markedGateways) {
1492
+ this.canvas.removeMarker(gateway, DECIDED_MARKER);
1493
+ this.canvas.removeMarker(gateway, STUCK_MARKER);
1494
+ }
1495
+ this.markedGateways = [];
1496
+ }
1497
+ showOutcomes(decision) {
1498
+ for (const { flow, outcome, reason } of decision.flows) {
1499
+ const connection = this.elementRegistry.get(flow.id);
1500
+ if (!connection?.waypoints) continue;
1501
+ const badge = new OutcomeBadge(outcome, reason, flow.isDefault).element;
1502
+ badge.classList.add("bds-outcome--on-flow");
1503
+ this.overlays.add(connection, OUTCOME_OVERLAY, {
1504
+ position: badgePosition(connection.waypoints, BADGE_DISTANCE),
1505
+ scale: { min: BADGE_MIN_SCALE },
1506
+ html: inShadow(badge)
1507
+ });
1508
+ }
1509
+ }
1510
+ showCards(entries) {
1511
+ this.popovers = entries.flatMap((entry) => {
1512
+ const gateway = this.elementRegistry.get(entry.elementId);
1513
+ if (!gateway) return [];
1514
+ const close = () => {
1515
+ this.pinnedGatewayIds.delete(entry.elementId);
1516
+ this.render();
1517
+ };
1518
+ const card = new DecisionCard(entry, this.pinnedGatewayIds.has(entry.elementId) ? close : void 0).element;
1519
+ card.classList.add("bds-popover");
1520
+ card.dataset.elementId = entry.elementId;
1521
+ return [{ gateway, card }];
1522
+ });
1523
+ this.popoverLayer.shadowRoot.replaceChildren(...this.popovers.map(({ card }) => card));
1524
+ this.placePopovers();
1525
+ }
1526
+ placePopovers() {
1527
+ const container = this.canvas.getContainer();
1528
+ const bounds = { width: container.clientWidth, height: container.clientHeight };
1529
+ for (const { gateway, card } of this.popovers) {
1530
+ card.style.maxHeight = "";
1531
+ const { left, top, maxHeight, hidden } = placePopover(
1532
+ this.canvas.getAbsoluteBBox(gateway),
1533
+ { width: card.offsetWidth, height: card.offsetHeight },
1534
+ bounds
1535
+ );
1536
+ card.hidden = hidden;
1537
+ card.style.left = `${left}px`;
1538
+ card.style.top = `${top}px`;
1539
+ card.style.maxHeight = maxHeight === void 0 ? "" : `${maxHeight}px`;
1540
+ }
1541
+ }
1542
+ }
1543
+ DataSimulationOverlays.$inject = ["eventBus", "overlays", "elementRegistry", "canvas", "dataSimulation"];
1546
1544
 
1547
1545
  const VARIABLES_ICON = '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M5.5 2.5C4 2.5 4 3.5 4 5v1c0 1-.8 2-2 2 1.2 0 2 1 2 2v1c0 1.5 0 2.5 1.5 2.5M10.5 2.5c1.5 0 1.5 1 1.5 2.5v1c0 1 .8 2 2 2-1.2 0-2 1-2 2v1c0 1.5 0 2.5-1.5 2.5" /></svg>';
1548
1546
  const CLOSE_ICON = '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 4l8 8M12 4l-8 8" /></svg>';
1549
1547
  class VariablesPanel {
1550
- constructor(actions) {
1551
- this.actions = actions;
1552
- this.paletteEntry = h('button', {
1553
- className: 'bts-entry bds-palette-entry',
1554
- type: 'button',
1555
- title: 'Toggle Process Data',
1556
- 'aria-label': 'Toggle Process Data',
1557
- });
1558
- this.engineBadge = h('span', { className: 'bds-engine' });
1559
- this.closeButton = h('button', { className: 'bds-panel-close', type: 'button', 'aria-label': 'Close' });
1560
- this.instanceTitle = h('h3', { className: 'bds-section-title' }, 'Instance');
1561
- this.instancePicker = h('select', {
1562
- className: 'bds-input bds-instance-select',
1563
- 'aria-label': 'Process instance',
1564
- });
1565
- this.instanceBody = h('div', { className: 'bds-instance-body' });
1566
- this.issueList = h('ol', { className: 'bds-log' });
1567
- this.issueSection = h('section', { className: 'bds-section bds-issues' }, h('h3', { className: 'bds-section-title' }, 'Issues'), this.issueList);
1568
- this.shownInstances = '';
1569
- this.paletteEntry.innerHTML = `<span class="bts-icon bds-variables-icon">${VARIABLES_ICON}</span>`;
1570
- this.closeButton.innerHTML = CLOSE_ICON;
1571
- const icon = h('span', { className: 'bds-variables-icon' });
1572
- icon.innerHTML = VARIABLES_ICON;
1573
- this.element = h('aside', { className: 'bds-panel', 'aria-label': 'Process Data' }, h('header', { className: 'bds-panel-header' }, icon, h('h2', { className: 'bds-panel-heading' }, 'Process Data'), this.closeButton), h('div', { className: 'bds-panel-body' }, h('p', { className: 'bds-panel-engine' }, this.engineBadge), h('section', { className: 'bds-section bds-instance' }, this.instanceTitle, this.instanceBody), this.issueSection));
1574
- this.paletteEntry.addEventListener('click', () => this.toggle());
1575
- this.closeButton.addEventListener('click', () => this.toggle(false));
1576
- this.instancePicker.addEventListener('change', () => this.actions.selectInstance(this.instancePicker.value));
1577
- this.toggle(false);
1578
- }
1579
- toggle(shown = this.element.hidden === true) {
1580
- this.element.hidden = !shown;
1581
- this.paletteEntry.classList.toggle('active', shown);
1582
- }
1583
- render(snapshot) {
1584
- this.snapshot = snapshot;
1585
- this.engineBadge.textContent = `${snapshot.engineLabel} · ${snapshot.expressionLanguage}`;
1586
- this.renderInstance(snapshot);
1587
- this.renderIssues(snapshot);
1588
- }
1589
- renderInstance({ instances, selectedInstanceId, scenarios }) {
1590
- const editedInstance = instances.find(candidate => candidate.id === this.editingInstanceId);
1591
- if (editedInstance && editedInstance.status !== 'completed' && editedInstance.id !== selectedInstanceId) {
1592
- this.actions.selectInstance(editedInstance.id);
1593
- return;
1594
- }
1595
- const instance = instances.find(candidate => candidate.id === selectedInstanceId);
1596
- this.renderInstancePicker(instances, selectedInstanceId, scenarios);
1597
- if (this.editingInstanceId && this.editingInstanceId === instance?.id && instance.status !== 'completed')
1598
- return;
1599
- this.editingInstanceId = undefined;
1600
- this.instanceBody.replaceChildren(instance
1601
- ? this.instanceView(instance)
1602
- : h('p', { className: 'bds-hint' }, 'Press ▶ on a start event to start a process instance.'));
1603
- }
1604
- renderInstancePicker(instances, selectedInstanceId, scenarios) {
1605
- const signature = JSON.stringify(instances.map(instance => [instance.id, instance.status]));
1606
- if (signature !== this.shownInstances) {
1607
- this.shownInstances = signature;
1608
- this.instancePicker.replaceChildren(...instances.map(instance => {
1609
- const scenarioName = scenarios.find(scenario => scenario.id === instance.scenarioId)?.name ?? 'no scenario';
1610
- return h('option', { value: instance.id }, `#${instance.number} ${scenarioName} (${instance.status})`);
1611
- }));
1612
- }
1613
- this.instancePicker.value = selectedInstanceId ?? '';
1614
- this.instancePicker.hidden = instances.length < 2;
1615
- if (!this.instancePicker.isConnected)
1616
- this.instanceTitle.after(this.instancePicker);
1617
- }
1618
- instanceView(instance) {
1619
- const scenarioName = this.snapshot?.scenarios.find(scenario => scenario.id === instance.scenarioId)?.name;
1620
- const entries = Object.entries(instance.variables);
1621
- const editButton = h('button', { className: 'bds-button', type: 'button' }, 'Edit');
1622
- editButton.addEventListener('click', () => this.editInstance(instance));
1623
- return h('div', {}, h('p', { className: `bds-status bds-status--${instance.status}` }, describeStatus(instance)), scenarioName ? h('p', { className: 'bds-hint' }, `Scenario: ${scenarioName}`) : null, entries.length
1624
- ? h('table', { className: 'bds-variables' }, h('tbody', {}, ...entries.map(([name, value]) => h('tr', {}, h('th', { scope: 'row' }, name), h('td', {}, h('code', {}, formatValue(value)))))))
1625
- : h('p', { className: 'bds-hint' }, 'No variables yet.'), h('p', { className: 'bds-hint' }, 'Hover a gateway to see why it took its flow, click it to keep the card open.'), instance.status !== 'completed' ? h('div', { className: 'bds-actions' }, editButton) : null);
1626
- }
1627
- editInstance(instance) {
1628
- this.editingInstanceId = instance.id;
1629
- const editor = h('textarea', {
1630
- className: 'bds-input bds-json bds-instance-editor',
1631
- spellcheck: 'false',
1632
- rows: '8',
1633
- 'aria-label': 'Instance variables (JSON)',
1634
- });
1635
- editor.value = JSON.stringify(instance.variables, null, 2);
1636
- const error = h('p', { className: 'bds-error', role: 'alert' });
1637
- showError(error, editor, '');
1638
- const applyButton = h('button', { className: 'bds-button bds-button--primary', type: 'button' }, 'Apply');
1639
- const cancelButton = h('button', { className: 'bds-button', type: 'button' }, 'Cancel');
1640
- applyButton.addEventListener('click', () => {
1641
- const parsed = parseVariables(editor.value);
1642
- if (typeof parsed === 'string') {
1643
- showError(error, editor, parsed);
1644
- return;
1645
- }
1646
- this.editingInstanceId = undefined;
1647
- this.actions.setInstanceVariables(instance.id, parsed);
1648
- });
1649
- cancelButton.addEventListener('click', () => {
1650
- this.editingInstanceId = undefined;
1651
- if (this.snapshot)
1652
- this.renderInstance(this.snapshot);
1653
- });
1654
- this.instanceBody.replaceChildren(editor, error, h('div', { className: 'bds-actions' }, cancelButton, applyButton));
1655
- editor.focus();
1656
- }
1657
- renderIssues({ log, selectedInstanceId }) {
1658
- const issues = log.filter((entry) => entry.kind === 'mapping-issue' && entry.instanceId === selectedInstanceId);
1659
- this.issueSection.hidden = !issues.length;
1660
- this.issueList.replaceChildren(...issues.slice().reverse().map(renderMappingIssue));
1661
- }
1662
- }
1663
- function describeStatus({ processName, status, waiting }) {
1664
- if (status !== 'waiting')
1665
- return `${processName} · ${status}`;
1666
- return `${processName} · waiting at ${waiting.map(gateway => gateway.gatewayName).join(', ')}`;
1667
- }
1668
- function showError(error, input, message) {
1548
+ constructor(actions) {
1549
+ this.actions = actions;
1550
+ this.paletteEntry = h("button", {
1551
+ className: "bts-entry bds-palette-entry",
1552
+ type: "button",
1553
+ title: "Toggle Process Data",
1554
+ "aria-label": "Toggle Process Data"
1555
+ });
1556
+ this.engineBadge = h("span", { className: "bds-engine" });
1557
+ this.closeButton = h("button", { className: "bds-panel-close", type: "button", "aria-label": "Close" });
1558
+ this.instanceTitle = h("h3", { className: "bds-section-title" }, "Instance");
1559
+ this.instancePicker = h("select", {
1560
+ className: "bds-input bds-instance-select",
1561
+ "aria-label": "Process instance"
1562
+ });
1563
+ this.instanceBody = h("div", { className: "bds-instance-body" });
1564
+ this.issueList = h("ol", { className: "bds-log" });
1565
+ this.issueSection = h(
1566
+ "section",
1567
+ { className: "bds-section bds-issues" },
1568
+ h("h3", { className: "bds-section-title" }, "Issues"),
1569
+ this.issueList
1570
+ );
1571
+ this.shownInstances = "";
1572
+ this.paletteEntry.innerHTML = `<span class="bts-icon bds-variables-icon">${VARIABLES_ICON}</span>`;
1573
+ this.closeButton.innerHTML = CLOSE_ICON;
1574
+ const icon = h("span", { className: "bds-variables-icon" });
1575
+ icon.innerHTML = VARIABLES_ICON;
1576
+ this.element = h(
1577
+ "aside",
1578
+ { className: "bds-panel", "aria-label": "Process Data" },
1579
+ h(
1580
+ "header",
1581
+ { className: "bds-panel-header" },
1582
+ icon,
1583
+ h("h2", { className: "bds-panel-heading" }, "Process Data"),
1584
+ this.closeButton
1585
+ ),
1586
+ h(
1587
+ "div",
1588
+ { className: "bds-panel-body" },
1589
+ h("p", { className: "bds-panel-engine" }, this.engineBadge),
1590
+ h("section", { className: "bds-section bds-instance" }, this.instanceTitle, this.instanceBody),
1591
+ this.issueSection
1592
+ )
1593
+ );
1594
+ this.paletteEntry.addEventListener("click", () => this.toggle());
1595
+ this.closeButton.addEventListener("click", () => this.toggle(false));
1596
+ this.instancePicker.addEventListener("change", () => this.actions.selectInstance(this.instancePicker.value));
1597
+ this.toggle(false);
1598
+ }
1599
+ toggle(shown = this.element.hidden === true) {
1600
+ this.element.hidden = !shown;
1601
+ this.paletteEntry.classList.toggle("active", shown);
1602
+ }
1603
+ render(snapshot) {
1604
+ this.snapshot = snapshot;
1605
+ this.engineBadge.textContent = `${snapshot.engineLabel} \xB7 ${snapshot.expressionLanguage}`;
1606
+ this.renderInstance(snapshot);
1607
+ this.renderIssues(snapshot);
1608
+ }
1609
+ renderInstance({ instances, selectedInstanceId, scenarios }) {
1610
+ const editedInstance = instances.find((candidate) => candidate.id === this.editingInstanceId);
1611
+ if (editedInstance && editedInstance.status !== "completed" && editedInstance.id !== selectedInstanceId) {
1612
+ this.actions.selectInstance(editedInstance.id);
1613
+ return;
1614
+ }
1615
+ const instance = instances.find((candidate) => candidate.id === selectedInstanceId);
1616
+ this.renderInstancePicker(instances, selectedInstanceId, scenarios);
1617
+ if (this.editingInstanceId && this.editingInstanceId === instance?.id && instance.status !== "completed") return;
1618
+ this.editingInstanceId = void 0;
1619
+ this.instanceBody.replaceChildren(
1620
+ instance ? this.instanceView(instance) : h("p", { className: "bds-hint" }, "Press \u25B6 on a start event to start a process instance.")
1621
+ );
1622
+ }
1623
+ renderInstancePicker(instances, selectedInstanceId, scenarios) {
1624
+ const signature = JSON.stringify(instances.map((instance) => [instance.id, instance.status]));
1625
+ if (signature !== this.shownInstances) {
1626
+ this.shownInstances = signature;
1627
+ this.instancePicker.replaceChildren(
1628
+ ...instances.map((instance) => {
1629
+ const scenarioName = scenarios.find((scenario) => scenario.id === instance.scenarioId)?.name ?? "no scenario";
1630
+ return h("option", { value: instance.id }, `#${instance.number} ${scenarioName} (${instance.status})`);
1631
+ })
1632
+ );
1633
+ }
1634
+ this.instancePicker.value = selectedInstanceId ?? "";
1635
+ this.instancePicker.hidden = instances.length < 2;
1636
+ if (!this.instancePicker.isConnected) this.instanceTitle.after(this.instancePicker);
1637
+ }
1638
+ instanceView(instance) {
1639
+ const scenarioName = this.snapshot?.scenarios.find((scenario) => scenario.id === instance.scenarioId)?.name;
1640
+ const entries = Object.entries(instance.variables);
1641
+ const editButton = h("button", { className: "bds-button", type: "button" }, "Edit");
1642
+ editButton.addEventListener("click", () => this.editInstance(instance));
1643
+ return h(
1644
+ "div",
1645
+ {},
1646
+ h("p", { className: `bds-status bds-status--${instance.status}` }, this.describeStatus(instance)),
1647
+ scenarioName ? h("p", { className: "bds-hint" }, `Scenario: ${scenarioName}`) : null,
1648
+ entries.length ? h(
1649
+ "table",
1650
+ { className: "bds-variables" },
1651
+ h(
1652
+ "tbody",
1653
+ {},
1654
+ ...entries.map(
1655
+ ([name, value]) => h("tr", {}, h("th", { scope: "row" }, name), h("td", {}, h("code", {}, formatValue(value))))
1656
+ )
1657
+ )
1658
+ ) : h("p", { className: "bds-hint" }, "No variables yet."),
1659
+ h("p", { className: "bds-hint" }, "Hover a gateway to see why it took its flow, click it to keep the card open."),
1660
+ instance.status !== "completed" ? h("div", { className: "bds-actions" }, editButton) : null
1661
+ );
1662
+ }
1663
+ editInstance(instance) {
1664
+ this.editingInstanceId = instance.id;
1665
+ const editor = h("textarea", {
1666
+ className: "bds-input bds-json bds-instance-editor",
1667
+ spellcheck: "false",
1668
+ rows: "8",
1669
+ "aria-label": "Instance variables (JSON)"
1670
+ });
1671
+ editor.value = JSON.stringify(instance.variables, null, 2);
1672
+ const error = h("p", { className: "bds-error", role: "alert" });
1673
+ this.showError(error, editor, "");
1674
+ const applyButton = h("button", { className: "bds-button bds-button--primary", type: "button" }, "Apply");
1675
+ const cancelButton = h("button", { className: "bds-button", type: "button" }, "Cancel");
1676
+ applyButton.addEventListener("click", () => {
1677
+ const parsed = this.parseVariables(editor.value);
1678
+ if (typeof parsed === "string") {
1679
+ this.showError(error, editor, parsed);
1680
+ return;
1681
+ }
1682
+ this.editingInstanceId = void 0;
1683
+ this.actions.setInstanceVariables(instance.id, parsed);
1684
+ });
1685
+ cancelButton.addEventListener("click", () => {
1686
+ this.editingInstanceId = void 0;
1687
+ if (this.snapshot) this.renderInstance(this.snapshot);
1688
+ });
1689
+ this.instanceBody.replaceChildren(editor, error, h("div", { className: "bds-actions" }, cancelButton, applyButton));
1690
+ editor.focus();
1691
+ }
1692
+ renderIssues({ log, selectedInstanceId }) {
1693
+ const issues = log.filter(
1694
+ (entry) => entry.kind === "mapping-issue" && entry.instanceId === selectedInstanceId
1695
+ );
1696
+ this.issueSection.hidden = !issues.length;
1697
+ this.issueList.replaceChildren(
1698
+ ...issues.slice().reverse().map((issue) => this.renderMappingIssue(issue))
1699
+ );
1700
+ }
1701
+ describeStatus({ processName, status, waiting }) {
1702
+ if (status !== "waiting") return `${processName} \xB7 ${status}`;
1703
+ return `${processName} \xB7 waiting at ${waiting.map((gateway) => gateway.gatewayName).join(", ")}`;
1704
+ }
1705
+ showError(error, input, message) {
1669
1706
  error.textContent = message;
1670
1707
  error.hidden = !message;
1671
- input.classList.toggle('bds-input--invalid', Boolean(message));
1672
- }
1673
- function renderMappingIssue({ elementName, target, reason }) {
1674
- return h('li', { className: 'bds-log-entry bds-log-entry--issue' }, h('div', { className: 'bds-log-title' }, elementName, h('span', { className: 'bds-tag' }, 'mapping')), h('p', { className: 'bds-error' }, `${target}: ${reason}`));
1675
- }
1676
- function parseVariables(text) {
1708
+ input.classList.toggle("bds-input--invalid", Boolean(message));
1709
+ }
1710
+ renderMappingIssue({ elementName, target, reason }) {
1711
+ return h(
1712
+ "li",
1713
+ { className: "bds-log-entry bds-log-entry--issue" },
1714
+ h("div", { className: "bds-log-title" }, elementName, h("span", { className: "bds-tag" }, "mapping")),
1715
+ h("p", { className: "bds-error" }, `${target}: ${reason}`)
1716
+ );
1717
+ }
1718
+ parseVariables(text) {
1677
1719
  try {
1678
- const value = JSON.parse(text || '{}');
1679
- return isVariables(value) ? value : 'Variables must be a JSON object';
1680
- }
1681
- catch (error) {
1682
- return `Invalid JSON: ${error.message}`;
1720
+ const value = JSON.parse(text || "{}");
1721
+ return isVariables(value) ? value : "Variables must be a JSON object";
1722
+ } catch (error) {
1723
+ return `Invalid JSON: ${error.message}`;
1683
1724
  }
1725
+ }
1684
1726
  }
1685
1727
 
1686
1728
  const PALETTE_INDEX = 4;
1687
1729
  class DataSimulationPanel {
1688
- constructor(eventBus, canvas, palette, dataSimulation) {
1689
- const panel = new VariablesPanel({
1690
- selectInstance: instanceId => dataSimulation.selectInstance(instanceId),
1691
- setInstanceVariables: (instanceId, variables) => dataSimulation.setInstanceVariables(instanceId, variables),
1692
- });
1693
- panel.render(dataSimulation.getSnapshot());
1694
- const host = inShadow(panel.element);
1695
- canvas.getContainer().append(host);
1696
- palette.addEntry(panel.paletteEntry, PALETTE_INDEX);
1697
- const showPaletteEntry = () => {
1698
- panel.paletteEntry.hidden = !dataSimulation.isEnabled();
1699
- };
1700
- showPaletteEntry();
1701
- const unsubscribe = dataSimulation.subscribe(snapshot => panel.render(snapshot));
1702
- eventBus.on(TOGGLE_MODE_EVENT, () => panel.toggle(false));
1703
- eventBus.on(DATA_TOGGLE_EVENT, showPaletteEntry);
1704
- eventBus.on('diagram.destroy', () => {
1705
- unsubscribe();
1706
- host.remove();
1707
- panel.paletteEntry.remove();
1708
- });
1709
- }
1730
+ constructor(eventBus, canvas, palette, dataSimulation) {
1731
+ this.dataSimulation = dataSimulation;
1732
+ this.panel = new VariablesPanel({
1733
+ selectInstance: (instanceId) => dataSimulation.selectInstance(instanceId),
1734
+ setInstanceVariables: (instanceId, variables) => dataSimulation.setInstanceVariables(instanceId, variables)
1735
+ });
1736
+ this.panel.render(dataSimulation.getSnapshot());
1737
+ const host = inShadow(this.panel.element);
1738
+ canvas.getContainer().append(host);
1739
+ palette.addEntry(this.panel.paletteEntry, PALETTE_INDEX);
1740
+ this.showPaletteEntry();
1741
+ const unsubscribe = dataSimulation.subscribe((snapshot) => this.panel.render(snapshot));
1742
+ eventBus.on(TOGGLE_MODE_EVENT, () => this.panel.toggle(false));
1743
+ eventBus.on(DATA_TOGGLE_EVENT, () => this.showPaletteEntry());
1744
+ eventBus.on("diagram.destroy", () => {
1745
+ unsubscribe();
1746
+ host.remove();
1747
+ this.panel.paletteEntry.remove();
1748
+ });
1749
+ }
1750
+ showPaletteEntry() {
1751
+ this.panel.paletteEntry.hidden = !this.dataSimulation.isEnabled();
1752
+ }
1710
1753
  }
1711
- DataSimulationPanel.$inject = ['eventBus', 'canvas', 'tokenSimulationPalette', 'dataSimulation'];
1754
+ DataSimulationPanel.$inject = ["eventBus", "canvas", "tokenSimulationPalette", "dataSimulation"];
1712
1755
 
1713
- const LABEL = 'Data Simulation';
1756
+ const LABEL = "Data Simulation";
1714
1757
  const GAP = 8;
1715
1758
  const TOGGLE_ON = '<svg viewBox="0 0 26 14" aria-hidden="true"><rect x="1" y="1" width="24" height="12" rx="6" /><circle cx="18" cy="7" r="3.5" /></svg>';
1716
1759
  const TOGGLE_OFF = '<svg viewBox="0 0 26 14" aria-hidden="true"><rect x="1" y="1" width="24" height="12" rx="6" /><circle cx="8" cy="7" r="3.5" /></svg>';
1717
1760
  class DataSimulationToggle {
1718
- constructor(eventBus, canvas, toggleMode, dataSimulation) {
1719
- let simulating = false;
1720
- const button = h('button', { className: 'bds-data-toggle', type: 'button' });
1721
- const render = () => {
1722
- const enabled = dataSimulation.isEnabled();
1723
- button.innerHTML = `${LABEL} <span class="bds-data-toggle-icon">${enabled ? TOGGLE_ON : TOGGLE_OFF}</span>`;
1724
- button.classList.toggle('active', enabled);
1725
- button.setAttribute('aria-pressed', String(enabled));
1726
- };
1727
- let tokenToggleObserver;
1728
- const placeNextToTokenSimulationToggle = () => {
1729
- const container = canvas.getContainer();
1730
- const tokenToggle = container.querySelector('.bts-toggle-mode');
1731
- if (!tokenToggle)
1732
- return;
1733
- const containerBox = container.getBoundingClientRect();
1734
- const toggleBox = tokenToggle.getBoundingClientRect();
1735
- const scale = containerBox.width / container.offsetWidth || 1;
1736
- button.style.fontSize = getComputedStyle(tokenToggle).fontSize;
1737
- button.style.left = `${(toggleBox.right - containerBox.left) / scale + GAP}px`;
1738
- button.style.top = `${(toggleBox.top + toggleBox.height / 2 - containerBox.top) / scale - button.offsetHeight / 2}px`;
1739
- if (!tokenToggleObserver && typeof ResizeObserver === 'function') {
1740
- tokenToggleObserver = new ResizeObserver(placeNextToTokenSimulationToggle);
1741
- tokenToggleObserver.observe(tokenToggle);
1742
- }
1743
- };
1744
- render();
1745
- canvas.getContainer().append(button);
1746
- button.addEventListener('click', () => dataSimulation.setEnabled(!dataSimulation.isEnabled()));
1747
- eventBus.on(TOGGLE_MODE_EVENT, ({ active }) => {
1748
- simulating = active;
1749
- if (active)
1750
- placeNextToTokenSimulationToggle();
1751
- });
1752
- eventBus.on(DATA_TOGGLE_EVENT, () => {
1753
- render();
1754
- if (!simulating)
1755
- return;
1756
- toggleMode.toggleMode(false);
1757
- toggleMode.toggleMode(true);
1758
- });
1759
- eventBus.on('diagram.destroy', () => {
1760
- tokenToggleObserver?.disconnect();
1761
- button.remove();
1762
- });
1761
+ constructor(eventBus, canvas, toggleMode, dataSimulation) {
1762
+ this.canvas = canvas;
1763
+ this.dataSimulation = dataSimulation;
1764
+ this.button = h("button", { className: "bds-data-toggle", type: "button" });
1765
+ this.simulating = false;
1766
+ this.render();
1767
+ canvas.getContainer().append(this.button);
1768
+ this.button.addEventListener("click", () => dataSimulation.setEnabled(!dataSimulation.isEnabled()));
1769
+ eventBus.on(TOGGLE_MODE_EVENT, ({ active }) => {
1770
+ this.simulating = active;
1771
+ if (active) this.placeNextToTokenSimulationToggle();
1772
+ });
1773
+ eventBus.on(DATA_TOGGLE_EVENT, () => {
1774
+ this.render();
1775
+ if (!this.simulating) return;
1776
+ toggleMode.toggleMode(false);
1777
+ toggleMode.toggleMode(true);
1778
+ });
1779
+ eventBus.on("diagram.destroy", () => {
1780
+ this.tokenToggleObserver?.disconnect();
1781
+ this.button.remove();
1782
+ });
1783
+ }
1784
+ render() {
1785
+ const enabled = this.dataSimulation.isEnabled();
1786
+ this.button.innerHTML = `${LABEL} <span class="bds-data-toggle-icon">${enabled ? TOGGLE_ON : TOGGLE_OFF}</span>`;
1787
+ this.button.classList.toggle("active", enabled);
1788
+ this.button.setAttribute("aria-pressed", String(enabled));
1789
+ }
1790
+ placeNextToTokenSimulationToggle() {
1791
+ const container = this.canvas.getContainer();
1792
+ const tokenToggle = container.querySelector(".bts-toggle-mode");
1793
+ if (!tokenToggle) return;
1794
+ const containerBox = container.getBoundingClientRect();
1795
+ const toggleBox = tokenToggle.getBoundingClientRect();
1796
+ const scale = containerBox.width / container.offsetWidth || 1;
1797
+ this.button.style.fontSize = getComputedStyle(tokenToggle).fontSize;
1798
+ this.button.style.left = `${(toggleBox.right - containerBox.left) / scale + GAP}px`;
1799
+ this.button.style.top = `${(toggleBox.top + toggleBox.height / 2 - containerBox.top) / scale - this.button.offsetHeight / 2}px`;
1800
+ this.observeTokenToggle(tokenToggle);
1801
+ }
1802
+ observeTokenToggle(tokenToggle) {
1803
+ if (this.tokenToggleObserver || typeof ResizeObserver !== "function") return;
1804
+ this.tokenToggleObserver = new ResizeObserver(() => this.placeNextToTokenSimulationToggle());
1805
+ this.tokenToggleObserver.observe(tokenToggle);
1806
+ }
1807
+ }
1808
+ DataSimulationToggle.$inject = ["eventBus", "canvas", "toggleMode", "dataSimulation"];
1809
+
1810
+ class StartFieldDeriver {
1811
+ derive(usages, { examples = [], taskResultNames = [] } = {}) {
1812
+ const written = /* @__PURE__ */ new Set([
1813
+ ...usages.flatMap((usage) => usage.outputTargets.map((target) => this.topLevelName(target))),
1814
+ ...taskResultNames
1815
+ ]);
1816
+ const usedBy = /* @__PURE__ */ new Map();
1817
+ for (const usage of usages) {
1818
+ const localNames = new Set(usage.inputTargets.map((target) => this.topLevelName(target)));
1819
+ for (const name of [...usage.conditionReads, ...usage.inputReads, ...usage.outputReads]) {
1820
+ if (written.has(name) || localNames.has(name)) continue;
1821
+ if (!usedBy.has(name)) usedBy.set(name, /* @__PURE__ */ new Set());
1822
+ usedBy.get(name).add(usage.elementName);
1823
+ }
1763
1824
  }
1825
+ return [...usedBy.entries()].map(([name, elements]) => ({
1826
+ name,
1827
+ type: this.inferType(examples.map((example) => example[name]).find((value) => value !== void 0)),
1828
+ usedBy: [...elements]
1829
+ }));
1830
+ }
1831
+ topLevelName(path) {
1832
+ return path.split(".")[0];
1833
+ }
1834
+ inferType(example) {
1835
+ if (typeof example === "number") return "number";
1836
+ if (typeof example === "boolean") return "boolean";
1837
+ if (typeof example === "string") return "text";
1838
+ if (Array.isArray(example) || isVariables(example)) return "json";
1839
+ return "auto";
1840
+ }
1764
1841
  }
1765
- DataSimulationToggle.$inject = ['eventBus', 'canvas', 'toggleMode', 'dataSimulation'];
1766
1842
 
1767
- const NO_SCENARIO = '';
1768
- function openStartDialog(container, options) {
1769
- const { scenarios, renderer } = options;
1770
- let baseVariables = options.startVariables;
1771
- const scenarioSelect = h('select', { className: 'bds-input bds-scenario-select', 'aria-label': 'Scenario' });
1772
- scenarioSelect.append(h('option', { value: NO_SCENARIO }, 'No scenario'), ...scenarios.map(scenario => h('option', { value: scenario.id }, scenario.name)));
1773
- scenarioSelect.value = options.selectedScenarioId ?? NO_SCENARIO;
1774
- const scenarioDescription = h('p', { className: 'bds-hint' });
1775
- const formContainer = h('div', { className: 'bds-dialog-form' });
1776
- const noFieldsHint = h('p', { className: 'bds-hint' }, 'The process reads no start variables.');
1777
- const error = h('p', { className: 'bds-error', role: 'alert' });
1778
- error.hidden = true;
1779
- const cancelButton = h('button', { className: 'bds-button', type: 'button' }, 'Cancel');
1780
- const startButton = h('button', { className: 'bds-button bds-button--primary', type: 'submit' }, 'Start instance');
1781
- const titleId = `bds-start-title-${Math.random().toString(36).slice(2)}`;
1782
- const form = h('form', { className: 'bds-dialog', role: 'dialog', 'aria-modal': 'true', 'aria-labelledby': titleId }, h('header', { className: 'bds-dialog-header' }, h('h2', { className: 'bds-panel-title', id: titleId }, `Start “${options.processName}”`), h('span', { className: 'bds-engine' }, options.engineLabel)), h('div', { className: 'bds-dialog-content' }, scenarios.length
1783
- ? h('section', { className: 'bds-section' }, h('label', { className: 'bds-label' }, 'Scenario', scenarioSelect), scenarioDescription)
1784
- : null, h('section', { className: 'bds-section' }, h('h3', { className: 'bds-section-title' }, 'Start variables'), formContainer, noFieldsHint), error), h('footer', { className: 'bds-actions' }, cancelButton, startButton));
1785
- const backdrop = h('div', { className: 'bds-dialog-backdrop' }, form);
1786
- const selectedScenarioId = () => scenarioSelect.value || null;
1787
- let fields = [];
1788
- const renderForm = () => {
1789
- fields = options.fieldsFor(selectedScenarioId());
1790
- noFieldsHint.hidden = fields.length > 0;
1791
- return renderer.render(formContainer, fields, baseVariables);
1792
- };
1793
- let rendered = renderForm();
1794
- const close = () => {
1795
- rendered.destroy();
1796
- backdrop.remove();
1797
- };
1798
- const showScenarioDescription = () => {
1799
- const description = scenarios.find(scenario => scenario.id === scenarioSelect.value)?.description ?? '';
1800
- scenarioDescription.textContent = description;
1801
- scenarioDescription.hidden = !description;
1802
- };
1803
- scenarioSelect.addEventListener('change', () => {
1804
- baseVariables = scenarios.find(scenario => scenario.id === scenarioSelect.value)?.variables ?? {};
1805
- rendered.destroy();
1806
- rendered = renderForm();
1807
- showScenarioDescription();
1843
+ const NO_SCENARIO = "";
1844
+ class StartDialog {
1845
+ constructor(options) {
1846
+ this.options = options;
1847
+ this.codec = new StartFieldCodec();
1848
+ this.scenarioSelect = h("select", {
1849
+ className: "bds-input bds-scenario-select",
1850
+ "aria-label": "Scenario"
1808
1851
  });
1809
- cancelButton.addEventListener('click', close);
1810
- backdrop.addEventListener('mousedown', event => {
1811
- if (event.target === backdrop)
1812
- close();
1852
+ this.scenarioDescription = h("p", { className: "bds-hint" });
1853
+ this.formContainer = h("div", { className: "bds-dialog-form" });
1854
+ this.noFieldsHint = h("p", { className: "bds-hint" }, "The process reads no start variables.");
1855
+ this.error = h("p", { className: "bds-error", role: "alert" });
1856
+ this.cancelButton = h("button", { className: "bds-button", type: "button" }, "Cancel");
1857
+ this.startButton = h(
1858
+ "button",
1859
+ { className: "bds-button bds-button--primary", type: "submit" },
1860
+ "Start instance"
1861
+ );
1862
+ this.fields = [];
1863
+ this.baseVariables = options.startVariables;
1864
+ this.scenarioSelect.append(
1865
+ h("option", { value: NO_SCENARIO }, "No scenario"),
1866
+ ...options.scenarios.map((scenario) => h("option", { value: scenario.id }, scenario.name))
1867
+ );
1868
+ this.scenarioSelect.value = options.selectedScenarioId ?? NO_SCENARIO;
1869
+ this.error.hidden = true;
1870
+ this.form = this.createForm();
1871
+ this.backdrop = h("div", { className: "bds-dialog-backdrop" }, this.form);
1872
+ this.rendered = this.renderForm();
1873
+ this.listen();
1874
+ }
1875
+ open(container) {
1876
+ this.showScenarioDescription();
1877
+ container.append(this.backdrop);
1878
+ if (this.fields.length) this.rendered.focus();
1879
+ else this.startButton.focus();
1880
+ }
1881
+ close() {
1882
+ this.rendered.destroy();
1883
+ this.backdrop.remove();
1884
+ }
1885
+ createForm() {
1886
+ const titleId = `bds-start-title-${Math.random().toString(36).slice(2)}`;
1887
+ return h(
1888
+ "form",
1889
+ { className: "bds-dialog", role: "dialog", "aria-modal": "true", "aria-labelledby": titleId },
1890
+ h(
1891
+ "header",
1892
+ { className: "bds-dialog-header" },
1893
+ h("h2", { className: "bds-panel-title", id: titleId }, `Start \u201C${this.options.processName}\u201D`),
1894
+ h("span", { className: "bds-engine" }, this.options.engineLabel)
1895
+ ),
1896
+ h(
1897
+ "div",
1898
+ { className: "bds-dialog-content" },
1899
+ this.options.scenarios.length ? h(
1900
+ "section",
1901
+ { className: "bds-section" },
1902
+ h("label", { className: "bds-label" }, "Scenario", this.scenarioSelect),
1903
+ this.scenarioDescription
1904
+ ) : null,
1905
+ h(
1906
+ "section",
1907
+ { className: "bds-section" },
1908
+ h("h3", { className: "bds-section-title" }, "Start variables"),
1909
+ this.formContainer,
1910
+ this.noFieldsHint
1911
+ ),
1912
+ this.error
1913
+ ),
1914
+ h("footer", { className: "bds-actions" }, this.cancelButton, this.startButton)
1915
+ );
1916
+ }
1917
+ listen() {
1918
+ this.scenarioSelect.addEventListener("change", () => this.switchScenario());
1919
+ this.cancelButton.addEventListener("click", () => this.close());
1920
+ this.backdrop.addEventListener("mousedown", (event) => {
1921
+ if (event.target === this.backdrop) this.close();
1813
1922
  });
1814
- backdrop.addEventListener('keydown', event => {
1815
- event.stopPropagation();
1816
- if (event.key === 'Escape')
1817
- close();
1923
+ this.backdrop.addEventListener("keydown", (event) => {
1924
+ event.stopPropagation();
1925
+ if (event.key === "Escape") this.close();
1818
1926
  });
1819
- form.addEventListener('submit', event => {
1820
- event.preventDefault();
1821
- const values = rendered.readValues();
1822
- if (!values.ok) {
1823
- error.textContent = values.reason;
1824
- error.hidden = false;
1825
- return;
1826
- }
1827
- close();
1828
- options.onStart(selectedScenarioId(), applyFieldValues(baseVariables, values.values));
1927
+ this.form.addEventListener("submit", (event) => {
1928
+ event.preventDefault();
1929
+ this.submit();
1829
1930
  });
1830
- showScenarioDescription();
1831
- container.append(backdrop);
1832
- if (fields.length)
1833
- rendered.focus();
1834
- else
1835
- startButton.focus();
1836
- return close;
1931
+ }
1932
+ selectedScenarioId() {
1933
+ return this.scenarioSelect.value || null;
1934
+ }
1935
+ selectedScenario() {
1936
+ return this.options.scenarios.find((scenario) => scenario.id === this.scenarioSelect.value);
1937
+ }
1938
+ renderForm() {
1939
+ this.fields = this.options.fieldsFor(this.selectedScenarioId());
1940
+ this.noFieldsHint.hidden = this.fields.length > 0;
1941
+ return this.options.renderer.render(this.formContainer, this.fields, this.baseVariables);
1942
+ }
1943
+ switchScenario() {
1944
+ this.baseVariables = this.selectedScenario()?.variables ?? {};
1945
+ this.rendered.destroy();
1946
+ this.rendered = this.renderForm();
1947
+ this.showScenarioDescription();
1948
+ }
1949
+ showScenarioDescription() {
1950
+ const description = this.selectedScenario()?.description ?? "";
1951
+ this.scenarioDescription.textContent = description;
1952
+ this.scenarioDescription.hidden = !description;
1953
+ }
1954
+ submit() {
1955
+ const values = this.rendered.readValues();
1956
+ if (!values.ok) {
1957
+ this.error.textContent = values.reason;
1958
+ this.error.hidden = false;
1959
+ return;
1960
+ }
1961
+ this.close();
1962
+ this.options.onStart(this.selectedScenarioId(), this.codec.apply(this.baseVariables, values.values));
1963
+ }
1837
1964
  }
1838
1965
 
1839
- class DataStartForm {
1840
- constructor(config, eventBus, dataSimulation, store) {
1841
- this.dataSimulation = dataSimulation;
1842
- this.store = store;
1843
- this.renderer = config?.startFormRenderer ?? simpleStartFormRenderer;
1844
- eventBus.on(TOGGLE_MODE_EVENT, () => this.closeDialog?.());
1845
- eventBus.on('diagram.destroy', () => {
1846
- this.closeDialog?.();
1847
- this.dialogHost?.remove();
1848
- });
1849
- }
1850
- isProcessStart(element) {
1851
- return (is(element, 'bpmn:StartEvent') &&
1852
- Boolean(element.parent) &&
1853
- (is(element.parent, 'bpmn:Process') || is(element.parent, 'bpmn:Participant')));
1854
- }
1855
- fieldsFor(startEvent, scenarioId) {
1856
- const snapshot = this.store.getSnapshot();
1857
- const examples = [snapshot.startVariables, ...snapshot.scenarios.map(scenario => scenario.variables)];
1858
- const taskResults = snapshot.scenarios.find(scenario => scenario.id === scenarioId)?.taskResults ?? {};
1859
- const taskResultNames = Object.values(taskResults).flatMap(result => Object.keys(result));
1860
- return deriveStartFields(this.collectUsages(startEvent.parent), { examples, taskResultNames });
1861
- }
1862
- open(startEvent, start) {
1863
- this.closeDialog?.();
1864
- const snapshot = this.store.getSnapshot();
1865
- this.dialogHost ?? (this.dialogHost = document.body.appendChild(inShadow()));
1866
- const close = openStartDialog(this.dialogHost.shadowRoot, {
1867
- processName: elementName(startEvent.parent),
1868
- engineLabel: `${snapshot.engineLabel} · ${snapshot.expressionLanguage}`,
1869
- scenarios: snapshot.scenarios,
1870
- selectedScenarioId: snapshot.selectedScenarioId,
1871
- startVariables: snapshot.startVariables,
1872
- fieldsFor: scenarioId => this.fieldsFor(startEvent, scenarioId),
1873
- renderer: this.renderer,
1874
- onStart: (scenarioId, variables) => {
1875
- this.closeDialog = undefined;
1876
- this.store.selectScenario(scenarioId);
1877
- this.store.setStartVariables(variables);
1878
- start();
1879
- },
1880
- });
1881
- this.closeDialog = () => {
1882
- close();
1883
- this.closeDialog = undefined;
1884
- };
1885
- }
1886
- collectUsages(container) {
1887
- const engine = this.dataSimulation.getEngine();
1888
- const usages = [];
1889
- const visit = (element) => {
1890
- if (element.type === 'label')
1891
- return;
1892
- const businessObject = element.businessObject;
1893
- if (is(element, 'bpmn:SequenceFlow')) {
1894
- const condition = engine.readCondition(businessObject);
1895
- if (condition)
1896
- usages.push(usage(element, { conditionReads: engine.readVariableNames(condition) }));
1897
- }
1898
- else if (is(element, 'bpmn:FlowNode')) {
1899
- const inputs = engine.readInputMappings(businessObject);
1900
- const outputs = engine.readOutputMappings(businessObject);
1901
- usages.push(usage(element, {
1902
- inputReads: inputs.flatMap(mapping => engine.readVariableNames(mapping.source)),
1903
- inputTargets: inputs.map(mapping => mapping.target),
1904
- outputReads: outputs.flatMap(mapping => engine.readVariableNames(mapping.source)),
1905
- outputTargets: outputs.map(mapping => mapping.target),
1906
- }));
1907
- }
1908
- element.children?.forEach(visit);
1909
- };
1910
- container.children?.forEach(visit);
1911
- return usages;
1912
- }
1913
- }
1914
- DataStartForm.$inject = ['config.dataSimulation', 'eventBus', 'dataSimulation', 'dataSimulationStore'];
1915
- function usage(element, reads) {
1916
- const target = is(element, 'bpmn:SequenceFlow') ? (element.source ?? element) : element;
1966
+ class VariableUsageCollector {
1967
+ constructor(engine) {
1968
+ this.engine = engine;
1969
+ }
1970
+ collect(container) {
1971
+ const usages = [];
1972
+ const visit = (element) => {
1973
+ if (element.type === "label") return;
1974
+ const usage = this.usageOf(element);
1975
+ if (usage) usages.push(usage);
1976
+ element.children?.forEach(visit);
1977
+ };
1978
+ container.children?.forEach(visit);
1979
+ return usages;
1980
+ }
1981
+ usageOf(element) {
1982
+ const businessObject = element.businessObject;
1983
+ if (is(element, "bpmn:SequenceFlow")) {
1984
+ const condition = this.engine.readCondition(businessObject);
1985
+ if (!condition) return void 0;
1986
+ return this.usage(element.source ?? element, { conditionReads: this.engine.readVariableNames(condition) });
1987
+ }
1988
+ if (!is(element, "bpmn:FlowNode")) return void 0;
1989
+ const inputs = this.engine.readInputMappings(businessObject);
1990
+ const outputs = this.engine.readOutputMappings(businessObject);
1991
+ return this.usage(element, {
1992
+ inputReads: inputs.flatMap((mapping) => this.engine.readVariableNames(mapping.source)),
1993
+ inputTargets: inputs.map((mapping) => mapping.target),
1994
+ outputReads: outputs.flatMap((mapping) => this.engine.readVariableNames(mapping.source)),
1995
+ outputTargets: outputs.map((mapping) => mapping.target)
1996
+ });
1997
+ }
1998
+ usage(element, reads) {
1917
1999
  return {
1918
- elementName: elementName(target),
1919
- conditionReads: [],
1920
- inputReads: [],
1921
- inputTargets: [],
1922
- outputReads: [],
1923
- outputTargets: [],
1924
- ...reads,
2000
+ elementName: elementName(element),
2001
+ conditionReads: [],
2002
+ inputReads: [],
2003
+ inputTargets: [],
2004
+ outputReads: [],
2005
+ outputTargets: [],
2006
+ ...reads
1925
2007
  };
2008
+ }
1926
2009
  }
1927
2010
 
2011
+ class DataStartForm {
2012
+ constructor(config, eventBus, dataSimulation, store) {
2013
+ this.store = store;
2014
+ this.fieldDeriver = new StartFieldDeriver();
2015
+ this.renderer = config?.startFormRenderer ?? new SimpleStartFormRenderer();
2016
+ this.usageCollector = new VariableUsageCollector(dataSimulation.getEngine());
2017
+ eventBus.on(TOGGLE_MODE_EVENT, () => this.closeDialog());
2018
+ eventBus.on("diagram.destroy", () => {
2019
+ this.closeDialog();
2020
+ this.dialogHost?.remove();
2021
+ });
2022
+ }
2023
+ isProcessStart(element) {
2024
+ return is(element, "bpmn:StartEvent") && Boolean(element.parent) && (is(element.parent, "bpmn:Process") || is(element.parent, "bpmn:Participant"));
2025
+ }
2026
+ fieldsFor(startEvent, scenarioId) {
2027
+ const snapshot = this.store.getSnapshot();
2028
+ const examples = [snapshot.startVariables, ...snapshot.scenarios.map((scenario) => scenario.variables)];
2029
+ const taskResults = snapshot.scenarios.find((scenario) => scenario.id === scenarioId)?.taskResults ?? {};
2030
+ const taskResultNames = Object.values(taskResults).flatMap((result) => Object.keys(result));
2031
+ return this.fieldDeriver.derive(this.usageCollector.collect(startEvent.parent), { examples, taskResultNames });
2032
+ }
2033
+ open(startEvent, start) {
2034
+ this.closeDialog();
2035
+ const snapshot = this.store.getSnapshot();
2036
+ this.dialogHost ?? (this.dialogHost = document.body.appendChild(inShadow()));
2037
+ this.dialog = new StartDialog({
2038
+ processName: elementName(startEvent.parent),
2039
+ engineLabel: `${snapshot.engineLabel} \xB7 ${snapshot.expressionLanguage}`,
2040
+ scenarios: snapshot.scenarios,
2041
+ selectedScenarioId: snapshot.selectedScenarioId,
2042
+ startVariables: snapshot.startVariables,
2043
+ fieldsFor: (scenarioId) => this.fieldsFor(startEvent, scenarioId),
2044
+ renderer: this.renderer,
2045
+ onStart: (scenarioId, variables) => {
2046
+ this.dialog = void 0;
2047
+ this.store.selectScenario(scenarioId);
2048
+ this.store.setStartVariables(variables);
2049
+ start();
2050
+ }
2051
+ });
2052
+ this.dialog.open(this.dialogHost.shadowRoot);
2053
+ }
2054
+ closeDialog() {
2055
+ this.dialog?.close();
2056
+ this.dialog = void 0;
2057
+ }
2058
+ }
2059
+ DataStartForm.$inject = ["config.dataSimulation", "eventBus", "dataSimulation", "dataSimulationStore"];
2060
+
1928
2061
  const DataSimulationModule = {
1929
- __init__: [
1930
- 'dataSimulation',
1931
- 'dataSimulationOverlays',
1932
- 'dataSimulationPanel',
1933
- 'dataSimulationToggle',
1934
- 'dataGatewayBehaviors',
1935
- 'dataGatewaySettings',
1936
- 'dataContextPads',
1937
- ],
1938
- dataSimulationStore: ['type', DataSimulationStore],
1939
- dataSimulation: ['type', DataSimulation],
1940
- dataSimulationOverlays: ['type', DataSimulationOverlays],
1941
- dataSimulationPanel: ['type', DataSimulationPanel],
1942
- dataSimulationToggle: ['type', DataSimulationToggle],
1943
- dataGateways: ['type', DataGateways],
1944
- dataStartForm: ['type', DataStartForm],
1945
- dataGatewayBehaviors: ['type', DataGatewayBehaviors],
1946
- dataGatewaySettings: ['type', DataGatewaySettings],
1947
- dataContextPads: ['type', DataContextPads],
2062
+ __init__: [
2063
+ "dataSimulation",
2064
+ "dataSimulationOverlays",
2065
+ "dataSimulationPanel",
2066
+ "dataSimulationToggle",
2067
+ "dataGatewayBehaviors",
2068
+ "dataGatewaySettings",
2069
+ "dataContextPads"
2070
+ ],
2071
+ dataSimulationStore: ["type", DataSimulationStore],
2072
+ dataSimulation: ["type", DataSimulation],
2073
+ dataSimulationOverlays: ["type", DataSimulationOverlays],
2074
+ dataSimulationPanel: ["type", DataSimulationPanel],
2075
+ dataSimulationToggle: ["type", DataSimulationToggle],
2076
+ dataGateways: ["type", DataGateways],
2077
+ dataStartForm: ["type", DataStartForm],
2078
+ dataGatewayBehaviors: ["type", DataGatewayBehaviors],
2079
+ dataGatewaySettings: ["type", DataGatewaySettings],
2080
+ dataContextPads: ["type", DataContextPads]
1948
2081
  };
1949
2082
 
1950
- export { DataSimulationStore, ScenarioError, camunda7Engine, DataSimulationModule as default, formatFieldValue, parseFieldValue, parseScenarios, resolveEngine, routeGateway, simpleStartFormRenderer, zeebeEngine };
2083
+ export { Camunda7Engine, DataSimulationStore, EngineRegistry, GatewayRouter, ScenarioError, ScenarioParser, SimpleStartFormRenderer, StartFieldCodec, ZeebeEngine, camunda7Engine, DataSimulationModule as default, zeebeEngine };
1951
2084
  //# sourceMappingURL=index.js.map