@aranzatech/diagrams-bpmn 0.2.14 → 0.3.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 (81) hide show
  1. package/README.md +34 -4
  2. package/dist/{catalog-xOMF2ifW.d.cts → catalog-DAGDhO-D.d.cts} +1 -1
  3. package/dist/{catalog-CK3_4cOb.d.ts → catalog-Q1QmKLDD.d.ts} +1 -1
  4. package/dist/{chunk-YUE5EM3W.js → chunk-334WN4JZ.js} +276 -107
  5. package/dist/chunk-334WN4JZ.js.map +1 -0
  6. package/dist/chunk-77L6O76M.js +3 -0
  7. package/dist/chunk-77L6O76M.js.map +1 -0
  8. package/dist/{chunk-QSMP34CT.js → chunk-CPFUQM6H.js} +80 -44
  9. package/dist/chunk-CPFUQM6H.js.map +1 -0
  10. package/dist/chunk-FFWJA5BV.js +163 -0
  11. package/dist/chunk-FFWJA5BV.js.map +1 -0
  12. package/dist/{chunk-FBTGIYZS.js → chunk-JEGYVEJO.js} +80 -3
  13. package/dist/{chunk-FBTGIYZS.js.map → chunk-JEGYVEJO.js.map} +1 -1
  14. package/dist/chunk-TB6V4S5N.js +104 -0
  15. package/dist/chunk-TB6V4S5N.js.map +1 -0
  16. package/dist/{chunk-IMW6RG6F.js → chunk-X54NHLBA.js} +43 -190
  17. package/dist/chunk-X54NHLBA.js.map +1 -0
  18. package/dist/{chunk-UAWLUDKC.js → chunk-YAYZW45I.js} +481 -26
  19. package/dist/chunk-YAYZW45I.js.map +1 -0
  20. package/dist/edges/index.cjs +78 -42
  21. package/dist/edges/index.cjs.map +1 -1
  22. package/dist/edges/index.js +1 -1
  23. package/dist/elements/index.cjs +78 -0
  24. package/dist/elements/index.cjs.map +1 -1
  25. package/dist/elements/index.d.cts +24 -5
  26. package/dist/elements/index.d.ts +24 -5
  27. package/dist/elements/index.js +1 -1
  28. package/dist/elk-QT7H4252.js +6 -0
  29. package/dist/elk-QT7H4252.js.map +1 -0
  30. package/dist/extensions/index.cjs +108 -0
  31. package/dist/extensions/index.cjs.map +1 -0
  32. package/dist/extensions/index.d.cts +145 -0
  33. package/dist/extensions/index.d.ts +145 -0
  34. package/dist/extensions/index.js +4 -0
  35. package/dist/extensions/index.js.map +1 -0
  36. package/dist/index.cjs +1067 -358
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.d.cts +7 -5
  39. package/dist/index.d.ts +7 -5
  40. package/dist/index.js +7 -5
  41. package/dist/index.js.map +1 -1
  42. package/dist/layout/index.cjs +1396 -749
  43. package/dist/layout/index.cjs.map +1 -1
  44. package/dist/layout/index.d.cts +10 -4
  45. package/dist/layout/index.d.ts +10 -4
  46. package/dist/layout/index.js +543 -104
  47. package/dist/layout/index.js.map +1 -1
  48. package/dist/modeling/index.cjs +490 -23
  49. package/dist/modeling/index.cjs.map +1 -1
  50. package/dist/modeling/index.d.cts +81 -6
  51. package/dist/modeling/index.d.ts +81 -6
  52. package/dist/modeling/index.js +1 -1
  53. package/dist/nodes/index.cjs +42 -188
  54. package/dist/nodes/index.cjs.map +1 -1
  55. package/dist/nodes/index.d.cts +1 -1
  56. package/dist/nodes/index.d.ts +1 -1
  57. package/dist/nodes/index.js +1 -1
  58. package/dist/types-BX_o95GC.d.cts +40 -0
  59. package/dist/{types-y-ZbX-ff.d.cts → types-BYN4Zuee.d.cts} +15 -1
  60. package/dist/{types-y-ZbX-ff.d.ts → types-BYN4Zuee.d.ts} +15 -1
  61. package/dist/{types-jIDz306Y.d.cts → types-CggktCqr.d.cts} +4 -1
  62. package/dist/types-D7zel9dq.d.ts +40 -0
  63. package/dist/{types-DG5yPKld.d.ts → types-DmDODKlh.d.ts} +4 -1
  64. package/dist/validation/index.cjs +81 -125
  65. package/dist/validation/index.cjs.map +1 -1
  66. package/dist/validation/index.d.cts +22 -5
  67. package/dist/validation/index.d.ts +22 -5
  68. package/dist/validation/index.js +82 -126
  69. package/dist/validation/index.js.map +1 -1
  70. package/dist/xml/index.cjs +319 -49
  71. package/dist/xml/index.cjs.map +1 -1
  72. package/dist/xml/index.d.cts +5 -3
  73. package/dist/xml/index.d.ts +5 -3
  74. package/dist/xml/index.js +2 -1
  75. package/package.json +6 -1
  76. package/dist/chunk-IMW6RG6F.js.map +0 -1
  77. package/dist/chunk-QSMP34CT.js.map +0 -1
  78. package/dist/chunk-UAWLUDKC.js.map +0 -1
  79. package/dist/chunk-YUE5EM3W.js.map +0 -1
  80. package/dist/guards-C70uIY_O.d.cts +0 -16
  81. package/dist/guards-foB6XIfZ.d.ts +0 -16
@@ -1,626 +1,23 @@
1
1
  'use strict';
2
2
 
3
- var layout = require('@aranzatech/diagrams-core/layout');
4
3
  var diagramsCore = require('@aranzatech/diagrams-core');
5
4
  require('@aranzatech/diagrams-core/serialization');
5
+ var layout = require('@aranzatech/diagrams-core/layout');
6
6
 
7
- // src/layout/index.ts
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropNames = Object.getOwnPropertyNames;
9
+ var __esm = (fn, res) => function __init() {
10
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
11
+ };
12
+ var __export = (target, all) => {
13
+ for (var name in all)
14
+ __defProp(target, name, { get: all[name], enumerable: true });
15
+ };
8
16
 
9
17
  // src/elements/catalog.ts
10
- var BPMN_ELEMENT_CATALOG = {
11
- // ─── Events ──────────────────────────────────────────────────────────────────
12
- StartEvent: {
13
- label: "Start Event",
14
- icon: "Circle",
15
- category: "event",
16
- defaultWidth: 36,
17
- defaultHeight: 36,
18
- handlePolicy: "source",
19
- orientation: "free",
20
- isContainer: false,
21
- acceptsBoundaryEvents: false,
22
- eventSemantics: "start",
23
- canBeStart: true,
24
- canBeEnd: false,
25
- maxIncoming: 0,
26
- maxOutgoing: 1
27
- },
28
- EndEvent: {
29
- label: "End Event",
30
- icon: "CircleDot",
31
- category: "event",
32
- defaultWidth: 36,
33
- defaultHeight: 36,
34
- handlePolicy: "target",
35
- orientation: "free",
36
- isContainer: false,
37
- acceptsBoundaryEvents: false,
38
- eventSemantics: "end",
39
- canBeStart: false,
40
- canBeEnd: true,
41
- maxOutgoing: 0
42
- },
43
- IntermediateCatchEvent: {
44
- label: "Intermediate Catch Event",
45
- icon: "Clock3",
46
- category: "event",
47
- defaultWidth: 36,
48
- defaultHeight: 36,
49
- handlePolicy: "all",
50
- orientation: "free",
51
- isContainer: false,
52
- acceptsBoundaryEvents: false,
53
- eventSemantics: "intermediateCatch",
54
- canBeStart: false,
55
- canBeEnd: false
56
- },
57
- IntermediateThrowEvent: {
58
- label: "Intermediate Throw Event",
59
- icon: "Send",
60
- category: "event",
61
- defaultWidth: 36,
62
- defaultHeight: 36,
63
- handlePolicy: "all",
64
- orientation: "free",
65
- isContainer: false,
66
- acceptsBoundaryEvents: false,
67
- eventSemantics: "intermediateThrow",
68
- canBeStart: false,
69
- canBeEnd: false
70
- },
71
- BoundaryEvent: {
72
- label: "Boundary Event",
73
- icon: "AlarmClock",
74
- category: "event",
75
- defaultWidth: 36,
76
- defaultHeight: 36,
77
- handlePolicy: "source",
78
- orientation: "free",
79
- isContainer: false,
80
- acceptsBoundaryEvents: false,
81
- eventSemantics: "boundary",
82
- canBeStart: false,
83
- canBeEnd: false,
84
- maxIncoming: 0
85
- },
86
- // ─── Tasks ───────────────────────────────────────────────────────────────────
87
- Task: {
88
- label: "Task",
89
- icon: "CheckSquare",
90
- category: "task",
91
- defaultWidth: 120,
92
- defaultHeight: 60,
93
- handlePolicy: "all",
94
- orientation: "free",
95
- isContainer: false,
96
- acceptsBoundaryEvents: true,
97
- supportsMarkers: true,
98
- canBeStart: false,
99
- canBeEnd: false
100
- },
101
- UserTask: {
102
- label: "User Task",
103
- icon: "UserRound",
104
- category: "task",
105
- defaultWidth: 120,
106
- defaultHeight: 60,
107
- handlePolicy: "all",
108
- orientation: "free",
109
- isContainer: false,
110
- acceptsBoundaryEvents: true,
111
- supportsMarkers: true,
112
- canBeStart: false,
113
- canBeEnd: false
114
- },
115
- ServiceTask: {
116
- label: "Service Task",
117
- icon: "Cog",
118
- category: "task",
119
- defaultWidth: 120,
120
- defaultHeight: 60,
121
- handlePolicy: "all",
122
- orientation: "free",
123
- isContainer: false,
124
- acceptsBoundaryEvents: true,
125
- supportsMarkers: true,
126
- canBeStart: false,
127
- canBeEnd: false
128
- },
129
- ScriptTask: {
130
- label: "Script Task",
131
- icon: "FileCode",
132
- category: "task",
133
- defaultWidth: 120,
134
- defaultHeight: 60,
135
- handlePolicy: "all",
136
- orientation: "free",
137
- isContainer: false,
138
- acceptsBoundaryEvents: true,
139
- supportsMarkers: true,
140
- canBeStart: false,
141
- canBeEnd: false
142
- },
143
- ManualTask: {
144
- label: "Manual Task",
145
- icon: "Hand",
146
- category: "task",
147
- defaultWidth: 120,
148
- defaultHeight: 60,
149
- handlePolicy: "all",
150
- orientation: "free",
151
- isContainer: false,
152
- acceptsBoundaryEvents: true,
153
- supportsMarkers: true,
154
- canBeStart: false,
155
- canBeEnd: false
156
- },
157
- BusinessRuleTask: {
158
- label: "Business Rule Task",
159
- icon: "Table2",
160
- category: "task",
161
- defaultWidth: 120,
162
- defaultHeight: 60,
163
- handlePolicy: "all",
164
- orientation: "free",
165
- isContainer: false,
166
- acceptsBoundaryEvents: true,
167
- supportsMarkers: true,
168
- canBeStart: false,
169
- canBeEnd: false
170
- },
171
- ReceiveTask: {
172
- label: "Receive Task",
173
- icon: "Inbox",
174
- category: "task",
175
- defaultWidth: 120,
176
- defaultHeight: 60,
177
- handlePolicy: "all",
178
- orientation: "free",
179
- isContainer: false,
180
- acceptsBoundaryEvents: true,
181
- supportsMarkers: true,
182
- canBeStart: false,
183
- canBeEnd: false
184
- },
185
- SendTask: {
186
- label: "Send Task",
187
- icon: "Send",
188
- category: "task",
189
- defaultWidth: 120,
190
- defaultHeight: 60,
191
- handlePolicy: "all",
192
- orientation: "free",
193
- isContainer: false,
194
- acceptsBoundaryEvents: true,
195
- supportsMarkers: true,
196
- canBeStart: false,
197
- canBeEnd: false
198
- },
199
- CallActivity: {
200
- label: "Call Activity",
201
- icon: "ExternalLink",
202
- category: "task",
203
- defaultWidth: 120,
204
- defaultHeight: 60,
205
- handlePolicy: "all",
206
- orientation: "free",
207
- isContainer: false,
208
- acceptsBoundaryEvents: true,
209
- supportsMarkers: true,
210
- canBeStart: false,
211
- canBeEnd: false
212
- },
213
- // ─── Gateways ────────────────────────────────────────────────────────────────
214
- ExclusiveGateway: {
215
- label: "Exclusive Gateway",
216
- icon: "X",
217
- category: "gateway",
218
- defaultWidth: 50,
219
- defaultHeight: 50,
220
- handlePolicy: "all",
221
- orientation: "free",
222
- isContainer: false,
223
- acceptsBoundaryEvents: false,
224
- canBeStart: false,
225
- canBeEnd: false
226
- },
227
- InclusiveGateway: {
228
- label: "Inclusive Gateway",
229
- icon: "Circle",
230
- category: "gateway",
231
- defaultWidth: 50,
232
- defaultHeight: 50,
233
- handlePolicy: "all",
234
- orientation: "free",
235
- isContainer: false,
236
- acceptsBoundaryEvents: false,
237
- canBeStart: false,
238
- canBeEnd: false
239
- },
240
- ParallelGateway: {
241
- label: "Parallel Gateway",
242
- icon: "Plus",
243
- category: "gateway",
244
- defaultWidth: 50,
245
- defaultHeight: 50,
246
- handlePolicy: "all",
247
- orientation: "free",
248
- isContainer: false,
249
- acceptsBoundaryEvents: false,
250
- canBeStart: false,
251
- canBeEnd: false
252
- },
253
- EventBasedGateway: {
254
- label: "Event-Based Gateway",
255
- icon: "Radio",
256
- category: "gateway",
257
- defaultWidth: 50,
258
- defaultHeight: 50,
259
- handlePolicy: "all",
260
- orientation: "free",
261
- isContainer: false,
262
- acceptsBoundaryEvents: false,
263
- canBeStart: false,
264
- canBeEnd: false,
265
- maxIncoming: 1
266
- },
267
- ComplexGateway: {
268
- label: "Complex Gateway",
269
- icon: "Asterisk",
270
- category: "gateway",
271
- defaultWidth: 50,
272
- defaultHeight: 50,
273
- handlePolicy: "all",
274
- orientation: "free",
275
- isContainer: false,
276
- acceptsBoundaryEvents: false,
277
- canBeStart: false,
278
- canBeEnd: false
279
- },
280
- // ─── Containers ───────────────────────────────────────────────────────────────
281
- SubProcess: {
282
- label: "Sub-Process",
283
- icon: "PlusSquare",
284
- category: "container",
285
- defaultWidth: 350,
286
- defaultHeight: 200,
287
- handlePolicy: "all",
288
- orientation: "horizontal",
289
- isContainer: true,
290
- acceptsBoundaryEvents: true,
291
- supportsCollapse: true,
292
- supportsMarkers: true,
293
- canBeStart: false,
294
- canBeEnd: false
295
- },
296
- Transaction: {
297
- label: "Transaction",
298
- icon: "Receipt",
299
- category: "container",
300
- defaultWidth: 350,
301
- defaultHeight: 200,
302
- handlePolicy: "all",
303
- orientation: "horizontal",
304
- isContainer: true,
305
- acceptsBoundaryEvents: true,
306
- supportsCollapse: true,
307
- supportsMarkers: true,
308
- canBeStart: false,
309
- canBeEnd: false
310
- },
311
- EventSubProcess: {
312
- label: "Event Sub-Process",
313
- icon: "CircleDotDashed",
314
- category: "container",
315
- defaultWidth: 350,
316
- defaultHeight: 200,
317
- handlePolicy: "all",
318
- orientation: "horizontal",
319
- isContainer: true,
320
- acceptsBoundaryEvents: false,
321
- supportsCollapse: true,
322
- supportsMarkers: true,
323
- canBeStart: false,
324
- canBeEnd: false
325
- },
326
- AdHocSubProcess: {
327
- label: "Ad-Hoc Sub-Process",
328
- icon: "Waves",
329
- category: "container",
330
- defaultWidth: 350,
331
- defaultHeight: 200,
332
- handlePolicy: "all",
333
- orientation: "horizontal",
334
- isContainer: true,
335
- acceptsBoundaryEvents: true,
336
- supportsCollapse: true,
337
- supportsMarkers: true,
338
- canBeStart: false,
339
- canBeEnd: false
340
- },
341
- Pool: {
342
- label: "Pool",
343
- icon: "Rows3",
344
- category: "container",
345
- defaultWidth: 600,
346
- defaultHeight: 200,
347
- handlePolicy: "none",
348
- orientation: "horizontal",
349
- isContainer: true,
350
- acceptsBoundaryEvents: false,
351
- canBeStart: false,
352
- canBeEnd: false,
353
- maxIncoming: 0,
354
- maxOutgoing: 0
355
- },
356
- Lane: {
357
- label: "Lane",
358
- icon: "PanelTop",
359
- category: "container",
360
- defaultWidth: 600,
361
- defaultHeight: 120,
362
- handlePolicy: "none",
363
- orientation: "horizontal",
364
- isContainer: true,
365
- acceptsBoundaryEvents: false,
366
- canBeStart: false,
367
- canBeEnd: false,
368
- maxIncoming: 0,
369
- maxOutgoing: 0
370
- },
371
- // ─── Artifacts ────────────────────────────────────────────────────────────────
372
- Annotation: {
373
- label: "Text Annotation",
374
- icon: "StickyNote",
375
- category: "artifact",
376
- defaultWidth: 100,
377
- defaultHeight: 60,
378
- handlePolicy: "none",
379
- orientation: "free",
380
- isContainer: false,
381
- acceptsBoundaryEvents: false,
382
- canBeStart: false,
383
- canBeEnd: false,
384
- maxIncoming: 0,
385
- maxOutgoing: 0
386
- },
387
- Group: {
388
- label: "Group",
389
- icon: "Group",
390
- category: "artifact",
391
- defaultWidth: 300,
392
- defaultHeight: 200,
393
- handlePolicy: "none",
394
- orientation: "free",
395
- isContainer: false,
396
- acceptsBoundaryEvents: false,
397
- canBeStart: false,
398
- canBeEnd: false,
399
- maxIncoming: 0,
400
- maxOutgoing: 0
401
- },
402
- // ─── Data (BPMN 2.0 §10.3) ───────────────────────────────────────────────────
403
- DataObject: {
404
- label: "Data Object",
405
- icon: "File",
406
- category: "data",
407
- defaultWidth: 36,
408
- defaultHeight: 50,
409
- handlePolicy: "all",
410
- orientation: "free",
411
- isContainer: false,
412
- acceptsBoundaryEvents: false,
413
- canBeStart: false,
414
- canBeEnd: false,
415
- maxIncoming: 0,
416
- maxOutgoing: 0
417
- },
418
- DataObjectReference: {
419
- label: "Data Object Reference",
420
- icon: "FileSymlink",
421
- category: "data",
422
- defaultWidth: 36,
423
- defaultHeight: 50,
424
- handlePolicy: "all",
425
- orientation: "free",
426
- isContainer: false,
427
- acceptsBoundaryEvents: false,
428
- canBeStart: false,
429
- canBeEnd: false,
430
- maxIncoming: 0,
431
- maxOutgoing: 0
432
- },
433
- DataInput: {
434
- label: "Data Input",
435
- icon: "FileInput",
436
- category: "data",
437
- defaultWidth: 36,
438
- defaultHeight: 50,
439
- handlePolicy: "all",
440
- orientation: "free",
441
- isContainer: false,
442
- acceptsBoundaryEvents: false,
443
- canBeStart: false,
444
- canBeEnd: false,
445
- maxIncoming: 0
446
- },
447
- DataOutput: {
448
- label: "Data Output",
449
- icon: "FileOutput",
450
- category: "data",
451
- defaultWidth: 36,
452
- defaultHeight: 50,
453
- handlePolicy: "all",
454
- orientation: "free",
455
- isContainer: false,
456
- acceptsBoundaryEvents: false,
457
- canBeStart: false,
458
- canBeEnd: false,
459
- maxOutgoing: 0
460
- },
461
- DataStore: {
462
- label: "Data Store",
463
- icon: "Database",
464
- category: "data",
465
- defaultWidth: 50,
466
- defaultHeight: 50,
467
- handlePolicy: "all",
468
- orientation: "free",
469
- isContainer: false,
470
- acceptsBoundaryEvents: false,
471
- canBeStart: false,
472
- canBeEnd: false,
473
- maxIncoming: 0,
474
- maxOutgoing: 0
475
- },
476
- DataStoreReference: {
477
- label: "Data Store Reference",
478
- icon: "DatabaseZap",
479
- category: "data",
480
- defaultWidth: 50,
481
- defaultHeight: 50,
482
- handlePolicy: "all",
483
- orientation: "free",
484
- isContainer: false,
485
- acceptsBoundaryEvents: false,
486
- canBeStart: false,
487
- canBeEnd: false,
488
- maxIncoming: 0,
489
- maxOutgoing: 0
490
- },
491
- // ─── Conversation (BPMN 2.0 §12) ─────────────────────────────────────────────
492
- Conversation: {
493
- label: "Conversation",
494
- icon: "MessageCircle",
495
- category: "conversation",
496
- defaultWidth: 60,
497
- defaultHeight: 52,
498
- handlePolicy: "all",
499
- orientation: "free",
500
- isContainer: false,
501
- acceptsBoundaryEvents: false,
502
- canBeStart: false,
503
- canBeEnd: false
504
- },
505
- SubConversation: {
506
- label: "Sub-Conversation",
507
- icon: "MessagesSquare",
508
- category: "conversation",
509
- defaultWidth: 60,
510
- defaultHeight: 52,
511
- handlePolicy: "all",
512
- orientation: "free",
513
- isContainer: true,
514
- acceptsBoundaryEvents: false,
515
- supportsCollapse: true,
516
- canBeStart: false,
517
- canBeEnd: false
518
- },
519
- CallConversation: {
520
- label: "Call Conversation",
521
- icon: "PhoneCall",
522
- category: "conversation",
523
- defaultWidth: 60,
524
- defaultHeight: 52,
525
- handlePolicy: "all",
526
- orientation: "free",
527
- isContainer: false,
528
- acceptsBoundaryEvents: false,
529
- canBeStart: false,
530
- canBeEnd: false
531
- },
532
- // ─── Choreography (BPMN 2.0 §11) ─────────────────────────────────────────────
533
- ChoreographyTask: {
534
- label: "Choreography Task",
535
- icon: "ArrowLeftRight",
536
- category: "choreography",
537
- defaultWidth: 120,
538
- defaultHeight: 80,
539
- handlePolicy: "all",
540
- orientation: "horizontal",
541
- isContainer: false,
542
- acceptsBoundaryEvents: false,
543
- canBeStart: false,
544
- canBeEnd: false
545
- },
546
- SubChoreography: {
547
- label: "Sub-Choreography",
548
- icon: "BoxSelect",
549
- category: "choreography",
550
- defaultWidth: 120,
551
- defaultHeight: 80,
552
- handlePolicy: "all",
553
- orientation: "horizontal",
554
- isContainer: true,
555
- acceptsBoundaryEvents: false,
556
- supportsCollapse: true,
557
- canBeStart: false,
558
- canBeEnd: false
559
- },
560
- CallChoreography: {
561
- label: "Call Choreography",
562
- icon: "Phone",
563
- category: "choreography",
564
- defaultWidth: 120,
565
- defaultHeight: 80,
566
- handlePolicy: "all",
567
- orientation: "horizontal",
568
- isContainer: false,
569
- acceptsBoundaryEvents: false,
570
- canBeStart: false,
571
- canBeEnd: false
572
- }
573
- };
574
18
  function getElementMeta(type) {
575
19
  return BPMN_ELEMENT_CATALOG[type];
576
20
  }
577
- var BPMN_RESIZABLE_ELEMENT_TYPES = [
578
- "Task",
579
- "UserTask",
580
- "ServiceTask",
581
- "ScriptTask",
582
- "ManualTask",
583
- "BusinessRuleTask",
584
- "ReceiveTask",
585
- "SendTask",
586
- "CallActivity",
587
- "SubProcess",
588
- "Transaction",
589
- "EventSubProcess",
590
- "AdHocSubProcess",
591
- "Pool",
592
- "Lane",
593
- "Annotation",
594
- "Group",
595
- "SubConversation",
596
- "ChoreographyTask",
597
- "SubChoreography",
598
- "CallChoreography"
599
- ];
600
- var BPMN_MIN_SIZE_OVERRIDES = {
601
- Task: { minWidth: 80, minHeight: 48 },
602
- UserTask: { minWidth: 80, minHeight: 48 },
603
- ServiceTask: { minWidth: 80, minHeight: 48 },
604
- ScriptTask: { minWidth: 80, minHeight: 48 },
605
- ManualTask: { minWidth: 80, minHeight: 48 },
606
- BusinessRuleTask: { minWidth: 80, minHeight: 48 },
607
- ReceiveTask: { minWidth: 80, minHeight: 48 },
608
- SendTask: { minWidth: 80, minHeight: 48 },
609
- CallActivity: { minWidth: 80, minHeight: 48 },
610
- SubProcess: { minWidth: 160, minHeight: 100 },
611
- Transaction: { minWidth: 160, minHeight: 100 },
612
- EventSubProcess: { minWidth: 160, minHeight: 100 },
613
- AdHocSubProcess: { minWidth: 160, minHeight: 100 },
614
- Pool: { minWidth: 240, minHeight: 120 },
615
- Lane: { minWidth: 240, minHeight: 80 },
616
- Annotation: { minWidth: 80, minHeight: 40 },
617
- Group: { minWidth: 120, minHeight: 80 },
618
- SubConversation: { minWidth: 60, minHeight: 52 },
619
- ChoreographyTask: { minWidth: 100, minHeight: 70 },
620
- SubChoreography: { minWidth: 100, minHeight: 70 },
621
- CallChoreography: { minWidth: 100, minHeight: 70 }
622
- };
623
- var resizableTypes = new Set(BPMN_RESIZABLE_ELEMENT_TYPES);
624
21
  function isBpmnElementResizable(type) {
625
22
  return resizableTypes.has(type);
626
23
  }
@@ -635,30 +32,624 @@ function getBpmnElementSize(type) {
635
32
  resizable: meta.resizable ?? isBpmnElementResizable(type)
636
33
  };
637
34
  }
35
+ var BPMN_ELEMENT_CATALOG, BPMN_RESIZABLE_ELEMENT_TYPES, BPMN_MIN_SIZE_OVERRIDES, resizableTypes;
36
+ var init_catalog = __esm({
37
+ "src/elements/catalog.ts"() {
38
+ BPMN_ELEMENT_CATALOG = {
39
+ // ─── Events ──────────────────────────────────────────────────────────────────
40
+ StartEvent: {
41
+ label: "Start Event",
42
+ icon: "Circle",
43
+ category: "event",
44
+ defaultWidth: 36,
45
+ defaultHeight: 36,
46
+ handlePolicy: "source",
47
+ orientation: "free",
48
+ isContainer: false,
49
+ acceptsBoundaryEvents: false,
50
+ eventSemantics: "start",
51
+ canBeStart: true,
52
+ canBeEnd: false,
53
+ maxIncoming: 0,
54
+ maxOutgoing: 1
55
+ },
56
+ EndEvent: {
57
+ label: "End Event",
58
+ icon: "CircleDot",
59
+ category: "event",
60
+ defaultWidth: 36,
61
+ defaultHeight: 36,
62
+ handlePolicy: "target",
63
+ orientation: "free",
64
+ isContainer: false,
65
+ acceptsBoundaryEvents: false,
66
+ eventSemantics: "end",
67
+ canBeStart: false,
68
+ canBeEnd: true,
69
+ maxOutgoing: 0
70
+ },
71
+ IntermediateCatchEvent: {
72
+ label: "Intermediate Catch Event",
73
+ icon: "Clock3",
74
+ category: "event",
75
+ defaultWidth: 36,
76
+ defaultHeight: 36,
77
+ handlePolicy: "all",
78
+ orientation: "free",
79
+ isContainer: false,
80
+ acceptsBoundaryEvents: false,
81
+ eventSemantics: "intermediateCatch",
82
+ canBeStart: false,
83
+ canBeEnd: false
84
+ },
85
+ IntermediateThrowEvent: {
86
+ label: "Intermediate Throw Event",
87
+ icon: "Send",
88
+ category: "event",
89
+ defaultWidth: 36,
90
+ defaultHeight: 36,
91
+ handlePolicy: "all",
92
+ orientation: "free",
93
+ isContainer: false,
94
+ acceptsBoundaryEvents: false,
95
+ eventSemantics: "intermediateThrow",
96
+ canBeStart: false,
97
+ canBeEnd: false
98
+ },
99
+ BoundaryEvent: {
100
+ label: "Boundary Event",
101
+ icon: "AlarmClock",
102
+ category: "event",
103
+ defaultWidth: 36,
104
+ defaultHeight: 36,
105
+ handlePolicy: "source",
106
+ orientation: "free",
107
+ isContainer: false,
108
+ acceptsBoundaryEvents: false,
109
+ eventSemantics: "boundary",
110
+ canBeStart: false,
111
+ canBeEnd: false,
112
+ maxIncoming: 0
113
+ },
114
+ // ─── Tasks ───────────────────────────────────────────────────────────────────
115
+ Task: {
116
+ label: "Task",
117
+ icon: "CheckSquare",
118
+ category: "task",
119
+ defaultWidth: 120,
120
+ defaultHeight: 60,
121
+ handlePolicy: "all",
122
+ orientation: "free",
123
+ isContainer: false,
124
+ acceptsBoundaryEvents: true,
125
+ supportsMarkers: true,
126
+ canBeStart: false,
127
+ canBeEnd: false
128
+ },
129
+ UserTask: {
130
+ label: "User Task",
131
+ icon: "UserRound",
132
+ category: "task",
133
+ defaultWidth: 120,
134
+ defaultHeight: 60,
135
+ handlePolicy: "all",
136
+ orientation: "free",
137
+ isContainer: false,
138
+ acceptsBoundaryEvents: true,
139
+ supportsMarkers: true,
140
+ canBeStart: false,
141
+ canBeEnd: false
142
+ },
143
+ ServiceTask: {
144
+ label: "Service Task",
145
+ icon: "Cog",
146
+ category: "task",
147
+ defaultWidth: 120,
148
+ defaultHeight: 60,
149
+ handlePolicy: "all",
150
+ orientation: "free",
151
+ isContainer: false,
152
+ acceptsBoundaryEvents: true,
153
+ supportsMarkers: true,
154
+ canBeStart: false,
155
+ canBeEnd: false
156
+ },
157
+ ScriptTask: {
158
+ label: "Script Task",
159
+ icon: "FileCode",
160
+ category: "task",
161
+ defaultWidth: 120,
162
+ defaultHeight: 60,
163
+ handlePolicy: "all",
164
+ orientation: "free",
165
+ isContainer: false,
166
+ acceptsBoundaryEvents: true,
167
+ supportsMarkers: true,
168
+ canBeStart: false,
169
+ canBeEnd: false
170
+ },
171
+ ManualTask: {
172
+ label: "Manual Task",
173
+ icon: "Hand",
174
+ category: "task",
175
+ defaultWidth: 120,
176
+ defaultHeight: 60,
177
+ handlePolicy: "all",
178
+ orientation: "free",
179
+ isContainer: false,
180
+ acceptsBoundaryEvents: true,
181
+ supportsMarkers: true,
182
+ canBeStart: false,
183
+ canBeEnd: false
184
+ },
185
+ BusinessRuleTask: {
186
+ label: "Business Rule Task",
187
+ icon: "Table2",
188
+ category: "task",
189
+ defaultWidth: 120,
190
+ defaultHeight: 60,
191
+ handlePolicy: "all",
192
+ orientation: "free",
193
+ isContainer: false,
194
+ acceptsBoundaryEvents: true,
195
+ supportsMarkers: true,
196
+ canBeStart: false,
197
+ canBeEnd: false
198
+ },
199
+ ReceiveTask: {
200
+ label: "Receive Task",
201
+ icon: "Inbox",
202
+ category: "task",
203
+ defaultWidth: 120,
204
+ defaultHeight: 60,
205
+ handlePolicy: "all",
206
+ orientation: "free",
207
+ isContainer: false,
208
+ acceptsBoundaryEvents: true,
209
+ supportsMarkers: true,
210
+ canBeStart: false,
211
+ canBeEnd: false
212
+ },
213
+ SendTask: {
214
+ label: "Send Task",
215
+ icon: "Send",
216
+ category: "task",
217
+ defaultWidth: 120,
218
+ defaultHeight: 60,
219
+ handlePolicy: "all",
220
+ orientation: "free",
221
+ isContainer: false,
222
+ acceptsBoundaryEvents: true,
223
+ supportsMarkers: true,
224
+ canBeStart: false,
225
+ canBeEnd: false
226
+ },
227
+ CallActivity: {
228
+ label: "Call Activity",
229
+ icon: "ExternalLink",
230
+ category: "task",
231
+ defaultWidth: 120,
232
+ defaultHeight: 60,
233
+ handlePolicy: "all",
234
+ orientation: "free",
235
+ isContainer: false,
236
+ acceptsBoundaryEvents: true,
237
+ supportsMarkers: true,
238
+ canBeStart: false,
239
+ canBeEnd: false
240
+ },
241
+ // ─── Gateways ────────────────────────────────────────────────────────────────
242
+ ExclusiveGateway: {
243
+ label: "Exclusive Gateway",
244
+ icon: "X",
245
+ category: "gateway",
246
+ defaultWidth: 50,
247
+ defaultHeight: 50,
248
+ handlePolicy: "all",
249
+ orientation: "free",
250
+ isContainer: false,
251
+ acceptsBoundaryEvents: false,
252
+ canBeStart: false,
253
+ canBeEnd: false
254
+ },
255
+ InclusiveGateway: {
256
+ label: "Inclusive Gateway",
257
+ icon: "Circle",
258
+ category: "gateway",
259
+ defaultWidth: 50,
260
+ defaultHeight: 50,
261
+ handlePolicy: "all",
262
+ orientation: "free",
263
+ isContainer: false,
264
+ acceptsBoundaryEvents: false,
265
+ canBeStart: false,
266
+ canBeEnd: false
267
+ },
268
+ ParallelGateway: {
269
+ label: "Parallel Gateway",
270
+ icon: "Plus",
271
+ category: "gateway",
272
+ defaultWidth: 50,
273
+ defaultHeight: 50,
274
+ handlePolicy: "all",
275
+ orientation: "free",
276
+ isContainer: false,
277
+ acceptsBoundaryEvents: false,
278
+ canBeStart: false,
279
+ canBeEnd: false
280
+ },
281
+ EventBasedGateway: {
282
+ label: "Event-Based Gateway",
283
+ icon: "Radio",
284
+ category: "gateway",
285
+ defaultWidth: 50,
286
+ defaultHeight: 50,
287
+ handlePolicy: "all",
288
+ orientation: "free",
289
+ isContainer: false,
290
+ acceptsBoundaryEvents: false,
291
+ canBeStart: false,
292
+ canBeEnd: false,
293
+ maxIncoming: 1
294
+ },
295
+ ComplexGateway: {
296
+ label: "Complex Gateway",
297
+ icon: "Asterisk",
298
+ category: "gateway",
299
+ defaultWidth: 50,
300
+ defaultHeight: 50,
301
+ handlePolicy: "all",
302
+ orientation: "free",
303
+ isContainer: false,
304
+ acceptsBoundaryEvents: false,
305
+ canBeStart: false,
306
+ canBeEnd: false
307
+ },
308
+ // ─── Containers ───────────────────────────────────────────────────────────────
309
+ SubProcess: {
310
+ label: "Sub-Process",
311
+ icon: "PlusSquare",
312
+ category: "container",
313
+ defaultWidth: 350,
314
+ defaultHeight: 200,
315
+ handlePolicy: "all",
316
+ orientation: "horizontal",
317
+ isContainer: true,
318
+ acceptsBoundaryEvents: true,
319
+ supportsCollapse: true,
320
+ supportsMarkers: true,
321
+ canBeStart: false,
322
+ canBeEnd: false
323
+ },
324
+ Transaction: {
325
+ label: "Transaction",
326
+ icon: "Receipt",
327
+ category: "container",
328
+ defaultWidth: 350,
329
+ defaultHeight: 200,
330
+ handlePolicy: "all",
331
+ orientation: "horizontal",
332
+ isContainer: true,
333
+ acceptsBoundaryEvents: true,
334
+ supportsCollapse: true,
335
+ supportsMarkers: true,
336
+ canBeStart: false,
337
+ canBeEnd: false
338
+ },
339
+ EventSubProcess: {
340
+ label: "Event Sub-Process",
341
+ icon: "CircleDotDashed",
342
+ category: "container",
343
+ defaultWidth: 350,
344
+ defaultHeight: 200,
345
+ handlePolicy: "all",
346
+ orientation: "horizontal",
347
+ isContainer: true,
348
+ acceptsBoundaryEvents: false,
349
+ supportsCollapse: true,
350
+ supportsMarkers: true,
351
+ canBeStart: false,
352
+ canBeEnd: false
353
+ },
354
+ AdHocSubProcess: {
355
+ label: "Ad-Hoc Sub-Process",
356
+ icon: "Waves",
357
+ category: "container",
358
+ defaultWidth: 350,
359
+ defaultHeight: 200,
360
+ handlePolicy: "all",
361
+ orientation: "horizontal",
362
+ isContainer: true,
363
+ acceptsBoundaryEvents: true,
364
+ supportsCollapse: true,
365
+ supportsMarkers: true,
366
+ canBeStart: false,
367
+ canBeEnd: false
368
+ },
369
+ Pool: {
370
+ label: "Pool",
371
+ icon: "Rows3",
372
+ category: "container",
373
+ defaultWidth: 600,
374
+ defaultHeight: 200,
375
+ handlePolicy: "none",
376
+ orientation: "horizontal",
377
+ isContainer: true,
378
+ acceptsBoundaryEvents: false,
379
+ canBeStart: false,
380
+ canBeEnd: false,
381
+ maxIncoming: 0,
382
+ maxOutgoing: 0
383
+ },
384
+ Lane: {
385
+ label: "Lane",
386
+ icon: "PanelTop",
387
+ category: "container",
388
+ defaultWidth: 600,
389
+ defaultHeight: 120,
390
+ handlePolicy: "none",
391
+ orientation: "horizontal",
392
+ isContainer: true,
393
+ acceptsBoundaryEvents: false,
394
+ canBeStart: false,
395
+ canBeEnd: false,
396
+ maxIncoming: 0,
397
+ maxOutgoing: 0
398
+ },
399
+ // ─── Artifacts ────────────────────────────────────────────────────────────────
400
+ Annotation: {
401
+ label: "Text Annotation",
402
+ icon: "StickyNote",
403
+ category: "artifact",
404
+ defaultWidth: 100,
405
+ defaultHeight: 60,
406
+ handlePolicy: "none",
407
+ orientation: "free",
408
+ isContainer: false,
409
+ acceptsBoundaryEvents: false,
410
+ canBeStart: false,
411
+ canBeEnd: false,
412
+ maxIncoming: 0,
413
+ maxOutgoing: 0
414
+ },
415
+ Group: {
416
+ label: "Group",
417
+ icon: "Group",
418
+ category: "artifact",
419
+ defaultWidth: 300,
420
+ defaultHeight: 200,
421
+ handlePolicy: "none",
422
+ orientation: "free",
423
+ isContainer: false,
424
+ acceptsBoundaryEvents: false,
425
+ canBeStart: false,
426
+ canBeEnd: false,
427
+ maxIncoming: 0,
428
+ maxOutgoing: 0
429
+ },
430
+ // ─── Data (BPMN 2.0 §10.3) ───────────────────────────────────────────────────
431
+ DataObject: {
432
+ label: "Data Object",
433
+ icon: "File",
434
+ category: "data",
435
+ defaultWidth: 36,
436
+ defaultHeight: 50,
437
+ handlePolicy: "all",
438
+ orientation: "free",
439
+ isContainer: false,
440
+ acceptsBoundaryEvents: false,
441
+ canBeStart: false,
442
+ canBeEnd: false,
443
+ maxIncoming: 0,
444
+ maxOutgoing: 0
445
+ },
446
+ DataObjectReference: {
447
+ label: "Data Object Reference",
448
+ icon: "FileSymlink",
449
+ category: "data",
450
+ defaultWidth: 36,
451
+ defaultHeight: 50,
452
+ handlePolicy: "all",
453
+ orientation: "free",
454
+ isContainer: false,
455
+ acceptsBoundaryEvents: false,
456
+ canBeStart: false,
457
+ canBeEnd: false,
458
+ maxIncoming: 0,
459
+ maxOutgoing: 0
460
+ },
461
+ DataInput: {
462
+ label: "Data Input",
463
+ icon: "FileInput",
464
+ category: "data",
465
+ defaultWidth: 36,
466
+ defaultHeight: 50,
467
+ handlePolicy: "all",
468
+ orientation: "free",
469
+ isContainer: false,
470
+ acceptsBoundaryEvents: false,
471
+ canBeStart: false,
472
+ canBeEnd: false,
473
+ maxIncoming: 0
474
+ },
475
+ DataOutput: {
476
+ label: "Data Output",
477
+ icon: "FileOutput",
478
+ category: "data",
479
+ defaultWidth: 36,
480
+ defaultHeight: 50,
481
+ handlePolicy: "all",
482
+ orientation: "free",
483
+ isContainer: false,
484
+ acceptsBoundaryEvents: false,
485
+ canBeStart: false,
486
+ canBeEnd: false,
487
+ maxOutgoing: 0
488
+ },
489
+ DataStore: {
490
+ label: "Data Store",
491
+ icon: "Database",
492
+ category: "data",
493
+ defaultWidth: 50,
494
+ defaultHeight: 50,
495
+ handlePolicy: "all",
496
+ orientation: "free",
497
+ isContainer: false,
498
+ acceptsBoundaryEvents: false,
499
+ canBeStart: false,
500
+ canBeEnd: false,
501
+ maxIncoming: 0,
502
+ maxOutgoing: 0
503
+ },
504
+ DataStoreReference: {
505
+ label: "Data Store Reference",
506
+ icon: "DatabaseZap",
507
+ category: "data",
508
+ defaultWidth: 50,
509
+ defaultHeight: 50,
510
+ handlePolicy: "all",
511
+ orientation: "free",
512
+ isContainer: false,
513
+ acceptsBoundaryEvents: false,
514
+ canBeStart: false,
515
+ canBeEnd: false,
516
+ maxIncoming: 0,
517
+ maxOutgoing: 0
518
+ },
519
+ // ─── Conversation (BPMN 2.0 §12) ─────────────────────────────────────────────
520
+ Conversation: {
521
+ label: "Conversation",
522
+ icon: "MessageCircle",
523
+ category: "conversation",
524
+ defaultWidth: 60,
525
+ defaultHeight: 52,
526
+ handlePolicy: "all",
527
+ orientation: "free",
528
+ isContainer: false,
529
+ acceptsBoundaryEvents: false,
530
+ canBeStart: false,
531
+ canBeEnd: false
532
+ },
533
+ SubConversation: {
534
+ label: "Sub-Conversation",
535
+ icon: "MessagesSquare",
536
+ category: "conversation",
537
+ defaultWidth: 60,
538
+ defaultHeight: 52,
539
+ handlePolicy: "all",
540
+ orientation: "free",
541
+ isContainer: true,
542
+ acceptsBoundaryEvents: false,
543
+ supportsCollapse: true,
544
+ canBeStart: false,
545
+ canBeEnd: false
546
+ },
547
+ CallConversation: {
548
+ label: "Call Conversation",
549
+ icon: "PhoneCall",
550
+ category: "conversation",
551
+ defaultWidth: 60,
552
+ defaultHeight: 52,
553
+ handlePolicy: "all",
554
+ orientation: "free",
555
+ isContainer: false,
556
+ acceptsBoundaryEvents: false,
557
+ canBeStart: false,
558
+ canBeEnd: false
559
+ },
560
+ // ─── Choreography (BPMN 2.0 §11) ─────────────────────────────────────────────
561
+ ChoreographyTask: {
562
+ label: "Choreography Task",
563
+ icon: "ArrowLeftRight",
564
+ category: "choreography",
565
+ defaultWidth: 120,
566
+ defaultHeight: 80,
567
+ handlePolicy: "all",
568
+ orientation: "horizontal",
569
+ isContainer: false,
570
+ acceptsBoundaryEvents: false,
571
+ canBeStart: false,
572
+ canBeEnd: false
573
+ },
574
+ SubChoreography: {
575
+ label: "Sub-Choreography",
576
+ icon: "BoxSelect",
577
+ category: "choreography",
578
+ defaultWidth: 120,
579
+ defaultHeight: 80,
580
+ handlePolicy: "all",
581
+ orientation: "horizontal",
582
+ isContainer: true,
583
+ acceptsBoundaryEvents: false,
584
+ supportsCollapse: true,
585
+ canBeStart: false,
586
+ canBeEnd: false
587
+ },
588
+ CallChoreography: {
589
+ label: "Call Choreography",
590
+ icon: "Phone",
591
+ category: "choreography",
592
+ defaultWidth: 120,
593
+ defaultHeight: 80,
594
+ handlePolicy: "all",
595
+ orientation: "horizontal",
596
+ isContainer: false,
597
+ acceptsBoundaryEvents: false,
598
+ canBeStart: false,
599
+ canBeEnd: false
600
+ }
601
+ };
602
+ BPMN_RESIZABLE_ELEMENT_TYPES = [
603
+ "Task",
604
+ "UserTask",
605
+ "ServiceTask",
606
+ "ScriptTask",
607
+ "ManualTask",
608
+ "BusinessRuleTask",
609
+ "ReceiveTask",
610
+ "SendTask",
611
+ "CallActivity",
612
+ "SubProcess",
613
+ "Transaction",
614
+ "EventSubProcess",
615
+ "AdHocSubProcess",
616
+ "Pool",
617
+ "Lane",
618
+ "Annotation",
619
+ "Group",
620
+ "SubConversation",
621
+ "ChoreographyTask",
622
+ "SubChoreography",
623
+ "CallChoreography"
624
+ ];
625
+ BPMN_MIN_SIZE_OVERRIDES = {
626
+ Task: { minWidth: 80, minHeight: 48 },
627
+ UserTask: { minWidth: 80, minHeight: 48 },
628
+ ServiceTask: { minWidth: 80, minHeight: 48 },
629
+ ScriptTask: { minWidth: 80, minHeight: 48 },
630
+ ManualTask: { minWidth: 80, minHeight: 48 },
631
+ BusinessRuleTask: { minWidth: 80, minHeight: 48 },
632
+ ReceiveTask: { minWidth: 80, minHeight: 48 },
633
+ SendTask: { minWidth: 80, minHeight: 48 },
634
+ CallActivity: { minWidth: 80, minHeight: 48 },
635
+ SubProcess: { minWidth: 160, minHeight: 100 },
636
+ Transaction: { minWidth: 160, minHeight: 100 },
637
+ EventSubProcess: { minWidth: 160, minHeight: 100 },
638
+ AdHocSubProcess: { minWidth: 160, minHeight: 100 },
639
+ Pool: { minWidth: 240, minHeight: 120 },
640
+ Lane: { minWidth: 240, minHeight: 80 },
641
+ Annotation: { minWidth: 80, minHeight: 40 },
642
+ Group: { minWidth: 120, minHeight: 80 },
643
+ SubConversation: { minWidth: 60, minHeight: 52 },
644
+ ChoreographyTask: { minWidth: 100, minHeight: 70 },
645
+ SubChoreography: { minWidth: 100, minHeight: 70 },
646
+ CallChoreography: { minWidth: 100, minHeight: 70 }
647
+ };
648
+ resizableTypes = new Set(BPMN_RESIZABLE_ELEMENT_TYPES);
649
+ }
650
+ });
638
651
 
639
652
  // src/elements/guards.ts
640
- var GATEWAY_TYPES = /* @__PURE__ */ new Set([
641
- "ExclusiveGateway",
642
- "InclusiveGateway",
643
- "ParallelGateway",
644
- "EventBasedGateway",
645
- "ComplexGateway"
646
- ]);
647
- var EVENT_TYPES = /* @__PURE__ */ new Set([
648
- "StartEvent",
649
- "EndEvent",
650
- "IntermediateCatchEvent",
651
- "IntermediateThrowEvent",
652
- "BoundaryEvent"
653
- ]);
654
- var DATA_TYPES = /* @__PURE__ */ new Set([
655
- "DataObject",
656
- "DataObjectReference",
657
- "DataInput",
658
- "DataOutput",
659
- "DataStore",
660
- "DataStoreReference"
661
- ]);
662
653
  function isGatewayType(type) {
663
654
  return GATEWAY_TYPES.has(type);
664
655
  }
@@ -674,45 +665,34 @@ function acceptsBoundaryEvents(type) {
674
665
  function getHandlePolicy(type) {
675
666
  return BPMN_ELEMENT_CATALOG[type].handlePolicy;
676
667
  }
677
-
678
- // src/modeling/index.ts
679
- var BPMN_EDGE_CONNECTION_RULES = {
680
- sequenceFlow: {
681
- edgeType: "sequenceFlow",
682
- sourceCategories: ["flowNode"],
683
- targetCategories: ["flowNode"],
684
- allowSameParent: true,
685
- allowDifferentParent: false
686
- },
687
- messageFlow: {
688
- edgeType: "messageFlow",
689
- sourceCategories: ["flowNode"],
690
- targetCategories: ["flowNode"],
691
- allowSameParent: false,
692
- allowDifferentParent: true
693
- },
694
- association: {
695
- edgeType: "association",
696
- sourceCategories: ["flowNode", "artifact", "data"],
697
- targetCategories: ["flowNode", "artifact", "data"],
698
- allowSameParent: true,
699
- allowDifferentParent: true
700
- },
701
- dataAssociation: {
702
- edgeType: "dataAssociation",
703
- sourceCategories: ["flowNode", "data"],
704
- targetCategories: ["flowNode", "data"],
705
- allowSameParent: true,
706
- allowDifferentParent: true
707
- },
708
- conversationLink: {
709
- edgeType: "conversationLink",
710
- sourceCategories: ["conversation", "flowNode"],
711
- targetCategories: ["conversation", "flowNode"],
712
- allowSameParent: true,
713
- allowDifferentParent: true
668
+ var GATEWAY_TYPES, EVENT_TYPES, DATA_TYPES;
669
+ var init_guards = __esm({
670
+ "src/elements/guards.ts"() {
671
+ init_catalog();
672
+ GATEWAY_TYPES = /* @__PURE__ */ new Set([
673
+ "ExclusiveGateway",
674
+ "InclusiveGateway",
675
+ "ParallelGateway",
676
+ "EventBasedGateway",
677
+ "ComplexGateway"
678
+ ]);
679
+ EVENT_TYPES = /* @__PURE__ */ new Set([
680
+ "StartEvent",
681
+ "EndEvent",
682
+ "IntermediateCatchEvent",
683
+ "IntermediateThrowEvent",
684
+ "BoundaryEvent"
685
+ ]);
686
+ DATA_TYPES = /* @__PURE__ */ new Set([
687
+ "DataObject",
688
+ "DataObjectReference",
689
+ "DataInput",
690
+ "DataOutput",
691
+ "DataStore",
692
+ "DataStoreReference"
693
+ ]);
714
694
  }
715
- };
695
+ });
716
696
  function inferBpmnEdgeType(state, sourceId, targetId) {
717
697
  const source = diagramsCore.getNode(state, sourceId);
718
698
  const target = diagramsCore.getNode(state, targetId);
@@ -726,7 +706,9 @@ function inferBpmnEdgeType(state, sourceId, targetId) {
726
706
  if (source.data.elementType === "Conversation" || source.data.elementType === "SubConversation" || source.data.elementType === "CallConversation" || target.data.elementType === "Conversation" || target.data.elementType === "SubConversation" || target.data.elementType === "CallConversation") {
727
707
  return "conversationLink";
728
708
  }
729
- if (source.parentId && target.parentId && source.parentId !== target.parentId) {
709
+ const sourcePoolId = getAncestorContainerId(state, source, "Pool");
710
+ const targetPoolId = getAncestorContainerId(state, target, "Pool");
711
+ if (sourcePoolId && targetPoolId && sourcePoolId !== targetPoolId) {
730
712
  return "messageFlow";
731
713
  }
732
714
  return "sequenceFlow";
@@ -764,6 +746,14 @@ function canContainBpmnElement(parentType, childType) {
764
746
  }
765
747
  return `${parentType} cannot contain BPMN child elements.`;
766
748
  }
749
+ function getAncestorContainerId(state, node, elementType) {
750
+ let current = node;
751
+ while (current) {
752
+ if (current.data.elementType === elementType) return current.id;
753
+ current = current.parentId ? diagramsCore.getNode(state, current.parentId) : void 0;
754
+ }
755
+ return void 0;
756
+ }
767
757
  function getBpmnNodeSize(node) {
768
758
  return diagramsCore.getNodeSize(node, getBpmnElementSize(node.data.elementType));
769
759
  }
@@ -807,82 +797,109 @@ function validateEdgeCardinality(state, edgeType, source, target) {
807
797
  }
808
798
  return true;
809
799
  }
810
- var bpmnConnectionValidators = [
811
- ({ state, source, target }) => {
812
- if (source.id === target.id) return "BPMN self-connections are not allowed.";
813
- const edgeType = inferBpmnEdgeType(state, source.id, target.id);
814
- if (getHandlePolicy(source.data.elementType) === "none" || getHandlePolicy(target.data.elementType) === "none") {
815
- return "Elements without BPMN connection handles cannot be directly connected.";
816
- }
817
- if (edgeType === "sequenceFlow") {
818
- return validateBpmnConnectionForEdgeType(state, edgeType, source, target);
819
- }
820
- return validateBpmnConnectionForEdgeType(state, edgeType, source, target);
821
- }
822
- ];
823
- diagramsCore.createModelingRules({
824
- connect: [
825
- ({ state, source, target }) => {
826
- if (!source || !target) return false;
827
- for (const validator of bpmnConnectionValidators) {
828
- const result = validator({
829
- state,
830
- source,
831
- target,
832
- existingEdges: state.edges
833
- });
834
- if (result !== true) return result;
835
- }
836
- return true;
837
- }
838
- ],
839
- drop: [
840
- ({ node, parent }) => {
841
- if (!node || !parent) return true;
842
- if (node.data.elementType === "BoundaryEvent") {
843
- return acceptsBoundaryEvents(parent.data.elementType) ? true : "Boundary events can only be attached to tasks or subprocesses.";
800
+ var BPMN_EDGE_CONNECTION_RULES, bpmnConnectionValidators;
801
+ var init_modeling = __esm({
802
+ "src/modeling/index.ts"() {
803
+ init_catalog();
804
+ init_guards();
805
+ init_catalog();
806
+ BPMN_EDGE_CONNECTION_RULES = {
807
+ sequenceFlow: {
808
+ edgeType: "sequenceFlow",
809
+ sourceCategories: ["flowNode"],
810
+ targetCategories: ["flowNode"],
811
+ allowSameParent: true,
812
+ allowDifferentParent: false
813
+ },
814
+ messageFlow: {
815
+ edgeType: "messageFlow",
816
+ sourceCategories: ["flowNode"],
817
+ targetCategories: ["flowNode"],
818
+ allowSameParent: false,
819
+ allowDifferentParent: true
820
+ },
821
+ association: {
822
+ edgeType: "association",
823
+ sourceCategories: ["flowNode", "artifact", "data"],
824
+ targetCategories: ["flowNode", "artifact", "data"],
825
+ allowSameParent: true,
826
+ allowDifferentParent: true
827
+ },
828
+ dataAssociation: {
829
+ edgeType: "dataAssociation",
830
+ sourceCategories: ["flowNode", "data"],
831
+ targetCategories: ["flowNode", "data"],
832
+ allowSameParent: true,
833
+ allowDifferentParent: true
834
+ },
835
+ conversationLink: {
836
+ edgeType: "conversationLink",
837
+ sourceCategories: ["conversation", "flowNode"],
838
+ targetCategories: ["conversation", "flowNode"],
839
+ allowSameParent: true,
840
+ allowDifferentParent: true
844
841
  }
845
- return canContainBpmnElement(parent.data.elementType, node.data.elementType);
846
- }
847
- ],
848
- reparent: [
849
- ({ node, parent }) => {
850
- if (!node || !parent) return true;
851
- if (node.data.elementType === "BoundaryEvent") {
852
- return acceptsBoundaryEvents(parent.data.elementType) ? true : "Boundary events can only be reparented to tasks or subprocesses.";
842
+ };
843
+ bpmnConnectionValidators = [
844
+ ({ state, source, target }) => {
845
+ if (source.id === target.id) return "BPMN self-connections are not allowed.";
846
+ const edgeType = inferBpmnEdgeType(state, source.id, target.id);
847
+ if (getHandlePolicy(source.data.elementType) === "none" || getHandlePolicy(target.data.elementType) === "none") {
848
+ return "Elements without BPMN connection handles cannot be directly connected.";
849
+ }
850
+ if (edgeType === "sequenceFlow") {
851
+ return validateBpmnConnectionForEdgeType(state, edgeType, source, target);
852
+ }
853
+ return validateBpmnConnectionForEdgeType(state, edgeType, source, target);
853
854
  }
854
- return canContainBpmnElement(parent?.data.elementType, node.data.elementType);
855
- }
856
- ],
857
- delete: [() => true],
858
- resize: [
859
- ({ node }) => !node || isBpmnElementResizable(node.data.elementType) ? true : `${node.data.elementType} is not resizable in BPMN.`
860
- ]
855
+ ];
856
+ diagramsCore.createModelingRules({
857
+ connect: [
858
+ ({ state, source, target }) => {
859
+ if (!source || !target) return false;
860
+ for (const validator of bpmnConnectionValidators) {
861
+ const result = validator({
862
+ state,
863
+ source,
864
+ target,
865
+ existingEdges: state.edges
866
+ });
867
+ if (result !== true) return result;
868
+ }
869
+ return true;
870
+ }
871
+ ],
872
+ drop: [
873
+ ({ node, parent }) => {
874
+ if (!node || !parent) return true;
875
+ if (node.data.elementType === "BoundaryEvent") {
876
+ return acceptsBoundaryEvents(parent.data.elementType) ? true : "Boundary events can only be attached to tasks or subprocesses.";
877
+ }
878
+ return canContainBpmnElement(parent.data.elementType, node.data.elementType);
879
+ }
880
+ ],
881
+ reparent: [
882
+ ({ node, parent }) => {
883
+ if (!node || !parent) return true;
884
+ if (node.data.elementType === "BoundaryEvent") {
885
+ return acceptsBoundaryEvents(parent.data.elementType) ? true : "Boundary events can only be reparented to tasks or subprocesses.";
886
+ }
887
+ return canContainBpmnElement(parent?.data.elementType, node.data.elementType);
888
+ }
889
+ ],
890
+ delete: [() => true],
891
+ resize: [
892
+ ({ node }) => !node || isBpmnElementResizable(node.data.elementType) ? true : `${node.data.elementType} is not resizable in BPMN.`
893
+ ]
894
+ });
895
+ }
896
+ });
897
+
898
+ // src/layout/elk.ts
899
+ var elk_exports = {};
900
+ __export(elk_exports, {
901
+ bpmnElkLayout: () => bpmnElkLayout
861
902
  });
862
- var BPMN_CONTAINER_TYPES = /* @__PURE__ */ new Set([
863
- "Pool",
864
- "Lane",
865
- "SubProcess",
866
- "Transaction",
867
- "EventSubProcess",
868
- "AdHocSubProcess"
869
- ]);
870
- var CONTAINER_MIN_SIZE = {
871
- Pool: { w: 720, h: 200 },
872
- Lane: { w: 600, h: 160 },
873
- SubProcess: { w: 240, h: 140 },
874
- Transaction: { w: 240, h: 140 },
875
- EventSubProcess: { w: 240, h: 140 },
876
- AdHocSubProcess: { w: 240, h: 140 }
877
- };
878
- var CONTAINER_PADDING = {
879
- Pool: "[top=30,left=60,bottom=30,right=50]",
880
- Lane: "[top=40,left=70,bottom=40,right=50]",
881
- SubProcess: "[top=30,left=40,bottom=30,right=40]",
882
- Transaction: "[top=30,left=40,bottom=30,right=40]",
883
- EventSubProcess: "[top=30,left=40,bottom=30,right=40]",
884
- AdHocSubProcess: "[top=30,left=40,bottom=30,right=40]"
885
- };
886
903
  async function bpmnElkLayout(nodes, edges) {
887
904
  const poolsWithLanes = /* @__PURE__ */ new Set();
888
905
  for (const node of nodes) {
@@ -943,10 +960,25 @@ async function bpmnElkLayout(nodes, edges) {
943
960
  );
944
961
  const nodeMap = new Map(result.nodes.map((n) => [n.id, n]));
945
962
  const edgeMap = new Map(result.edges.map((e) => [e.id, e]));
963
+ const COMPONENT_GAP = 100;
964
+ const rootNodeOrder = nodes.filter((n) => !n.parentId).map((n) => n.id);
965
+ const rootHeights = /* @__PURE__ */ new Map();
966
+ for (const id of rootNodeOrder) {
967
+ const laid = nodeMap.get(id);
968
+ const orig = nodes.find((n) => n.id === id);
969
+ rootHeights.set(id, laid?.height ?? orig?.height ?? 200);
970
+ }
971
+ let stackY = 0;
972
+ const rootY = /* @__PURE__ */ new Map();
973
+ for (const id of rootNodeOrder) {
974
+ rootY.set(id, stackY);
975
+ stackY += (rootHeights.get(id) ?? 200) + COMPONENT_GAP;
976
+ }
946
977
  const updatedNodes = nodes.map((node) => {
947
978
  const laid = nodeMap.get(node.id);
948
979
  if (!laid) return node;
949
- return { ...node, position: laid.position, width: laid.width, height: laid.height };
980
+ const pos = node.parentId ? laid.position : { x: laid.position.x, y: rootY.get(node.id) ?? laid.position.y };
981
+ return { ...node, position: pos, width: laid.width, height: laid.height };
950
982
  });
951
983
  const lanesByPool = /* @__PURE__ */ new Map();
952
984
  for (const node of updatedNodes) {
@@ -968,11 +1000,30 @@ async function bpmnElkLayout(nodes, edges) {
968
1000
  }
969
1001
  }
970
1002
  }
1003
+ const nodeRootContainer = /* @__PURE__ */ new Map();
1004
+ for (const node of updatedNodes) {
1005
+ nodeRootContainer.set(node.id, node.parentId ?? null);
1006
+ }
1007
+ const getRootContainer = (nodeId) => {
1008
+ let current = nodeId;
1009
+ const visited = /* @__PURE__ */ new Set();
1010
+ while (current) {
1011
+ if (visited.has(current)) break;
1012
+ visited.add(current);
1013
+ const parent = nodeRootContainer.get(current);
1014
+ if (!parent) return current;
1015
+ current = parent;
1016
+ }
1017
+ return null;
1018
+ };
971
1019
  const updatedEdges = edges.map((edge) => {
972
1020
  const laid = edgeMap.get(edge.id);
973
1021
  if (!laid) return edge;
974
1022
  const nextData = { ...edge.data };
975
- if (laid.points && laid.points.length > 0) {
1023
+ const sourceRoot = getRootContainer(edge.source);
1024
+ const targetRoot = getRootContainer(edge.target);
1025
+ const isCrossPool = sourceRoot !== targetRoot;
1026
+ if (!isCrossPool && laid.points && laid.points.length > 0) {
976
1027
  nextData.routingPoints = laid.points;
977
1028
  } else {
978
1029
  delete nextData.routingPoints;
@@ -981,6 +1032,601 @@ async function bpmnElkLayout(nodes, edges) {
981
1032
  });
982
1033
  return { nodes: updatedNodes, edges: updatedEdges };
983
1034
  }
1035
+ var BPMN_CONTAINER_TYPES, CONTAINER_MIN_SIZE, CONTAINER_PADDING;
1036
+ var init_elk = __esm({
1037
+ "src/layout/elk.ts"() {
1038
+ init_modeling();
1039
+ BPMN_CONTAINER_TYPES = /* @__PURE__ */ new Set([
1040
+ "Pool",
1041
+ "Lane",
1042
+ "SubProcess",
1043
+ "Transaction",
1044
+ "EventSubProcess",
1045
+ "AdHocSubProcess"
1046
+ ]);
1047
+ CONTAINER_MIN_SIZE = {
1048
+ Pool: { w: 720, h: 200 },
1049
+ Lane: { w: 600, h: 160 },
1050
+ SubProcess: { w: 240, h: 140 },
1051
+ Transaction: { w: 240, h: 140 },
1052
+ EventSubProcess: { w: 240, h: 140 },
1053
+ AdHocSubProcess: { w: 240, h: 140 }
1054
+ };
1055
+ CONTAINER_PADDING = {
1056
+ Pool: "[top=30,left=60,bottom=30,right=50]",
1057
+ Lane: "[top=40,left=70,bottom=40,right=50]",
1058
+ SubProcess: "[top=30,left=40,bottom=30,right=40]",
1059
+ Transaction: "[top=30,left=40,bottom=30,right=40]",
1060
+ EventSubProcess: "[top=30,left=40,bottom=30,right=40]",
1061
+ AdHocSubProcess: "[top=30,left=40,bottom=30,right=40]"
1062
+ };
1063
+ }
1064
+ });
1065
+
1066
+ // src/layout/index.ts
1067
+ init_modeling();
1068
+ init_elk();
1069
+
1070
+ // src/layout/bpmn-layout-graph.ts
1071
+ var LAYOUT_CONTAINER_TYPES = /* @__PURE__ */ new Set([
1072
+ "Pool",
1073
+ "Lane",
1074
+ "SubProcess",
1075
+ "Transaction",
1076
+ "EventSubProcess",
1077
+ "AdHocSubProcess"
1078
+ ]);
1079
+ var LAYOUT_GATEWAY_TYPES = /* @__PURE__ */ new Set([
1080
+ "ExclusiveGateway",
1081
+ "InclusiveGateway",
1082
+ "ParallelGateway",
1083
+ "EventBasedGateway",
1084
+ "ComplexGateway"
1085
+ ]);
1086
+ function detectBackEdges(nodeIds, seqEdges) {
1087
+ const backEdgeIds = /* @__PURE__ */ new Set();
1088
+ const state = /* @__PURE__ */ new Map();
1089
+ for (const id of nodeIds) state.set(id, 0);
1090
+ const adj = /* @__PURE__ */ new Map();
1091
+ for (const id of nodeIds) adj.set(id, []);
1092
+ for (const e of seqEdges) {
1093
+ adj.get(e.source)?.push({ target: e.target, edgeId: e.id });
1094
+ }
1095
+ for (const startId of nodeIds) {
1096
+ if (state.get(startId) !== 0) continue;
1097
+ const stack = [{ id: startId, idx: 0 }];
1098
+ state.set(startId, 1);
1099
+ while (stack.length > 0) {
1100
+ const top = stack[stack.length - 1];
1101
+ const neighbors = adj.get(top.id) ?? [];
1102
+ if (top.idx >= neighbors.length) {
1103
+ state.set(top.id, 2);
1104
+ stack.pop();
1105
+ continue;
1106
+ }
1107
+ const { target, edgeId } = neighbors[top.idx++];
1108
+ const tState = state.get(target);
1109
+ if (tState === 1) {
1110
+ backEdgeIds.add(edgeId);
1111
+ } else if (tState === 0) {
1112
+ state.set(target, 1);
1113
+ stack.push({ id: target, idx: 0 });
1114
+ }
1115
+ }
1116
+ }
1117
+ return backEdgeIds;
1118
+ }
1119
+ function extractSeqEdges(edges, nodeIds) {
1120
+ return edges.filter((e) => {
1121
+ const t = e.data?.edgeType ?? e.type;
1122
+ return t === "sequenceFlow" && nodeIds.has(e.source) && nodeIds.has(e.target);
1123
+ }).map((e) => ({ id: e.id, source: e.source, target: e.target, sourceHandle: e.sourceHandle ?? null }));
1124
+ }
1125
+ function topologicalSort(nodeIds, forwardEdges) {
1126
+ const inDeg = new Map(nodeIds.map((id) => [id, 0]));
1127
+ const adj = new Map(nodeIds.map((id) => [id, []]));
1128
+ for (const e of forwardEdges) {
1129
+ if (!inDeg.has(e.source) || !inDeg.has(e.target)) continue;
1130
+ adj.get(e.source).push(e.target);
1131
+ inDeg.set(e.target, (inDeg.get(e.target) ?? 0) + 1);
1132
+ }
1133
+ const queue = nodeIds.filter((id) => (inDeg.get(id) ?? 0) === 0);
1134
+ const result = [];
1135
+ while (queue.length > 0) {
1136
+ const id = queue.shift();
1137
+ result.push(id);
1138
+ for (const next of adj.get(id) ?? []) {
1139
+ const d = (inDeg.get(next) ?? 1) - 1;
1140
+ inDeg.set(next, d);
1141
+ if (d === 0) queue.push(next);
1142
+ }
1143
+ }
1144
+ const seen = new Set(result);
1145
+ for (const id of nodeIds) {
1146
+ if (!seen.has(id)) result.push(id);
1147
+ }
1148
+ return result;
1149
+ }
1150
+ function assignColumns(nodeIds, forwardEdges) {
1151
+ const order = topologicalSort(nodeIds, forwardEdges);
1152
+ const col = new Map(nodeIds.map((id) => [id, 0]));
1153
+ const preds = new Map(nodeIds.map((id) => [id, []]));
1154
+ for (const e of forwardEdges) {
1155
+ preds.get(e.target)?.push(e.source);
1156
+ }
1157
+ for (const id of order) {
1158
+ const predCols = (preds.get(id) ?? []).map((p) => col.get(p) ?? 0);
1159
+ col.set(id, predCols.length > 0 ? Math.max(...predCols) + 1 : 0);
1160
+ }
1161
+ return col;
1162
+ }
1163
+ function detectGatewayPairs(nodes, forwardEdges) {
1164
+ const pairs = /* @__PURE__ */ new Map();
1165
+ const nodeIds = nodes.map((n) => n.id);
1166
+ const succs = new Map(nodes.map((n) => [n.id, []]));
1167
+ for (const e of forwardEdges) {
1168
+ succs.get(e.source)?.push(e.target);
1169
+ }
1170
+ const order = topologicalSort(nodeIds, forwardEdges);
1171
+ const topoPos = new Map(order.map((id, i) => [id, i]));
1172
+ const splits = nodes.filter(
1173
+ (n) => LAYOUT_GATEWAY_TYPES.has(n.data.elementType) && (succs.get(n.id)?.length ?? 0) > 1
1174
+ );
1175
+ for (const split of splits) {
1176
+ const branches = succs.get(split.id) ?? [];
1177
+ if (branches.length < 2) continue;
1178
+ const branchSets = branches.map((start) => {
1179
+ const visited = /* @__PURE__ */ new Set();
1180
+ const q = [start];
1181
+ while (q.length) {
1182
+ const curr = q.shift();
1183
+ if (visited.has(curr)) continue;
1184
+ visited.add(curr);
1185
+ for (const next of succs.get(curr) ?? []) q.push(next);
1186
+ }
1187
+ return visited;
1188
+ });
1189
+ const common = [...branchSets[0]].filter(
1190
+ (id) => branchSets.every((s) => s.has(id))
1191
+ );
1192
+ if (common.length === 0) continue;
1193
+ const merge = common.reduce(
1194
+ (a, b) => (topoPos.get(a) ?? Infinity) < (topoPos.get(b) ?? Infinity) ? a : b
1195
+ );
1196
+ pairs.set(split.id, merge);
1197
+ }
1198
+ return pairs;
1199
+ }
1200
+ function handleToRowBias(handle) {
1201
+ if (!handle) return null;
1202
+ if (handle.includes("top")) return -1;
1203
+ if (handle.includes("bottom")) return 1;
1204
+ if (handle.includes("right")) return 0;
1205
+ return null;
1206
+ }
1207
+ function buildHandleMap(edges) {
1208
+ const map = /* @__PURE__ */ new Map();
1209
+ for (const e of edges) {
1210
+ if (!map.has(e.source)) map.set(e.source, /* @__PURE__ */ new Map());
1211
+ map.get(e.source).set(e.target, e.sourceHandle ?? null);
1212
+ }
1213
+ return map;
1214
+ }
1215
+ function assignRows(nodes, forwardEdges, columns, gatewayPairs) {
1216
+ const rows = new Map(nodes.map((n) => [n.id, 0]));
1217
+ const succs = new Map(nodes.map((n) => [n.id, []]));
1218
+ for (const e of forwardEdges) {
1219
+ succs.get(e.source)?.push(e.target);
1220
+ }
1221
+ const handleMap = buildHandleMap(forwardEdges);
1222
+ const sortedPairs = [...gatewayPairs.entries()].sort(
1223
+ (a, b) => (columns.get(b[0]) ?? 0) - (columns.get(a[0]) ?? 0)
1224
+ );
1225
+ for (const [splitId, mergeId] of sortedPairs) {
1226
+ const branches = succs.get(splitId) ?? [];
1227
+ if (branches.length < 2) continue;
1228
+ const splitRow = rows.get(splitId) ?? 0;
1229
+ const getBranchNodes = (branchStart) => {
1230
+ const result = [];
1231
+ const visited = /* @__PURE__ */ new Set();
1232
+ const q = [branchStart];
1233
+ while (q.length) {
1234
+ const curr = q.shift();
1235
+ if (visited.has(curr) || curr === mergeId) continue;
1236
+ visited.add(curr);
1237
+ result.push(curr);
1238
+ for (const next of succs.get(curr) ?? []) q.push(next);
1239
+ }
1240
+ return result;
1241
+ };
1242
+ const splitHandles = handleMap.get(splitId);
1243
+ const branchData = branches.map((start) => ({
1244
+ start,
1245
+ nodeIds: getBranchNodes(start),
1246
+ bias: handleToRowBias(splitHandles?.get(start) ?? null)
1247
+ }));
1248
+ const withBias = branchData.filter((b) => b.bias !== null && b.bias !== 0);
1249
+ const withoutBias = branchData.filter((b) => b.bias === null || b.bias === 0).sort((a, b) => b.nodeIds.length - a.nodeIds.length);
1250
+ const assigned = /* @__PURE__ */ new Map();
1251
+ for (const b of withBias) {
1252
+ assigned.set(b.start, splitRow + b.bias);
1253
+ }
1254
+ let nextOffset = 0;
1255
+ for (const b of withoutBias) {
1256
+ while ([...assigned.values()].includes(splitRow + nextOffset)) nextOffset++;
1257
+ assigned.set(b.start, splitRow + nextOffset);
1258
+ nextOffset++;
1259
+ }
1260
+ for (const b of branchData) {
1261
+ const row = assigned.get(b.start) ?? splitRow;
1262
+ for (const id of b.nodeIds) {
1263
+ rows.set(id, row);
1264
+ }
1265
+ }
1266
+ }
1267
+ const pairedSplits = new Set(gatewayPairs.keys());
1268
+ const unpairedSplits = nodes.filter(
1269
+ (n) => LAYOUT_GATEWAY_TYPES.has(n.data.elementType) && !pairedSplits.has(n.id) && (succs.get(n.id)?.length ?? 0) > 1
1270
+ );
1271
+ for (const split of unpairedSplits) {
1272
+ const branches = succs.get(split.id) ?? [];
1273
+ if (branches.length < 2) continue;
1274
+ const splitRow = rows.get(split.id) ?? 0;
1275
+ const getAllReachable = (start) => {
1276
+ const result = [];
1277
+ const visited = /* @__PURE__ */ new Set();
1278
+ const q = [start];
1279
+ while (q.length) {
1280
+ const curr = q.shift();
1281
+ if (visited.has(curr)) continue;
1282
+ visited.add(curr);
1283
+ result.push(curr);
1284
+ for (const next of succs.get(curr) ?? []) q.push(next);
1285
+ }
1286
+ return result;
1287
+ };
1288
+ const splitHandles2 = handleMap.get(split.id);
1289
+ const branchData = branches.map((start) => ({
1290
+ start,
1291
+ nodeIds: getAllReachable(start),
1292
+ bias: handleToRowBias(splitHandles2?.get(start) ?? null)
1293
+ }));
1294
+ const withBias2 = branchData.filter((b) => b.bias !== null && b.bias !== 0);
1295
+ const withoutBias2 = branchData.filter((b) => b.bias === null || b.bias === 0).sort((a, b) => b.nodeIds.length - a.nodeIds.length);
1296
+ const assigned2 = /* @__PURE__ */ new Map();
1297
+ for (const b of withBias2) assigned2.set(b.start, splitRow + b.bias);
1298
+ let nextOff = 0;
1299
+ for (const b of withoutBias2) {
1300
+ while ([...assigned2.values()].includes(splitRow + nextOff)) nextOff++;
1301
+ assigned2.set(b.start, splitRow + nextOff);
1302
+ nextOff++;
1303
+ }
1304
+ for (const b of branchData) {
1305
+ const row = assigned2.get(b.start) ?? splitRow;
1306
+ for (const id of b.nodeIds) rows.set(id, row);
1307
+ }
1308
+ }
1309
+ return rows;
1310
+ }
1311
+
1312
+ // src/layout/bpmn-custom-layout.ts
1313
+ var LANE_LABEL_W = 28;
1314
+ var LANE_H_PAD = 20;
1315
+ var COL_GAP = 80;
1316
+ var ROW_HEIGHT = 80;
1317
+ var ROW_GAP = 60;
1318
+ var LANE_V_PAD = 50;
1319
+ var POOL_H_PAD = 60;
1320
+ var POOL_V_GAP = 50;
1321
+ var LANE_MIN_H = 160;
1322
+ var POOL_MIN_W = 720;
1323
+ var POOL_INNER_PAD = 8;
1324
+ function nW(node) {
1325
+ return node.width ?? node.measured?.width ?? 120;
1326
+ }
1327
+ function nH(node) {
1328
+ return node.height ?? node.measured?.height ?? 60;
1329
+ }
1330
+ function layoutPool(pool, lanes, content, allEdges) {
1331
+ if (content.length === 0) {
1332
+ if (lanes.length === 0) {
1333
+ return { nodes: [], width: 240, height: 120 };
1334
+ }
1335
+ const laneH = LANE_MIN_H;
1336
+ const h = POOL_INNER_PAD * 2 + lanes.length * laneH + Math.max(0, lanes.length - 1) * POOL_INNER_PAD;
1337
+ const w = POOL_MIN_W;
1338
+ return {
1339
+ nodes: lanes.map((lane, i) => ({
1340
+ ...lane,
1341
+ position: { x: POOL_INNER_PAD, y: POOL_INNER_PAD + i * (laneH + POOL_INNER_PAD) },
1342
+ width: w - POOL_INNER_PAD * 2,
1343
+ height: laneH
1344
+ })),
1345
+ width: w,
1346
+ height: h
1347
+ };
1348
+ }
1349
+ const contentIds = new Set(content.map((n) => n.id));
1350
+ const seqEdges = extractSeqEdges(allEdges, contentIds);
1351
+ const backIds = detectBackEdges([...contentIds], seqEdges);
1352
+ const fwdEdges = seqEdges.filter((e) => !backIds.has(e.id));
1353
+ const columns = assignColumns([...contentIds], fwdEdges);
1354
+ const pairs = detectGatewayPairs(content, fwdEdges);
1355
+ const rows = assignRows(content, fwdEdges, columns, pairs);
1356
+ const lanePositionsDistinct = lanes.some((l) => Math.abs(l.position.y) > 10);
1357
+ const sortedLanes = lanePositionsDistinct ? [...lanes].sort((a, b) => a.position.y - b.position.y) : [...lanes];
1358
+ const hasLanes = sortedLanes.length > 0;
1359
+ const nodeLaneId = /* @__PURE__ */ new Map();
1360
+ for (const node of content) {
1361
+ if (hasLanes && node.parentId && node.parentId !== pool.id) {
1362
+ nodeLaneId.set(node.id, node.parentId);
1363
+ } else {
1364
+ nodeLaneId.set(node.id, "_pool_");
1365
+ }
1366
+ }
1367
+ const laneIds = hasLanes ? sortedLanes.map((l) => l.id) : ["_pool_"];
1368
+ const laneStats = /* @__PURE__ */ new Map();
1369
+ for (const laneId of laneIds) {
1370
+ const laneRows = content.filter((n) => nodeLaneId.get(n.id) === laneId).map((n) => rows.get(n.id) ?? 0);
1371
+ if (laneRows.length === 0) {
1372
+ laneStats.set(laneId, { minRow: 0, maxRow: 0, rowCount: 1, height: LANE_MIN_H });
1373
+ } else {
1374
+ const minRow = Math.min(...laneRows);
1375
+ const maxRow = Math.max(...laneRows);
1376
+ const rowCount = maxRow - minRow + 1;
1377
+ const contentH = rowCount * ROW_HEIGHT + Math.max(0, rowCount - 1) * ROW_GAP;
1378
+ const height = Math.max(LANE_MIN_H, LANE_V_PAD * 2 + contentH);
1379
+ laneStats.set(laneId, { minRow, maxRow, rowCount, height });
1380
+ }
1381
+ }
1382
+ const maxCol = Math.max(0, ...[...columns.values()]);
1383
+ const colW = /* @__PURE__ */ new Map();
1384
+ for (let c = 0; c <= maxCol; c++) colW.set(c, 0);
1385
+ for (const node of content) {
1386
+ const c = columns.get(node.id) ?? 0;
1387
+ colW.set(c, Math.max(colW.get(c) ?? 0, nW(node)));
1388
+ }
1389
+ const colX = /* @__PURE__ */ new Map();
1390
+ let cumX = 0;
1391
+ for (let c = 0; c <= maxCol; c++) {
1392
+ colX.set(c, cumX);
1393
+ cumX += (colW.get(c) ?? 120) + COL_GAP;
1394
+ }
1395
+ const contentW = cumX - COL_GAP;
1396
+ const innerW = LANE_LABEL_W + LANE_H_PAD + contentW + LANE_H_PAD;
1397
+ const poolW = Math.max(POOL_MIN_W, innerW + POOL_INNER_PAD * 2);
1398
+ const laneW = poolW - POOL_INNER_PAD * 2;
1399
+ const laneY = /* @__PURE__ */ new Map();
1400
+ let cumY = POOL_INNER_PAD;
1401
+ for (let i = 0; i < laneIds.length; i++) {
1402
+ const laneId = laneIds[i];
1403
+ laneY.set(laneId, cumY);
1404
+ cumY += laneStats.get(laneId)?.height ?? LANE_MIN_H;
1405
+ if (i < laneIds.length - 1) cumY += POOL_INNER_PAD;
1406
+ }
1407
+ const poolH = cumY + POOL_INNER_PAD;
1408
+ const positionedContent = content.map((node) => {
1409
+ const c = columns.get(node.id) ?? 0;
1410
+ const r = rows.get(node.id) ?? 0;
1411
+ const laneId = nodeLaneId.get(node.id) ?? "_pool_";
1412
+ const stat = laneStats.get(laneId);
1413
+ const lYOff = laneY.get(laneId) ?? 0;
1414
+ const colOffset = (colX.get(c) ?? 0) + (colW.get(c) ?? 120) / 2 - nW(node) / 2;
1415
+ const rowOffset = (r - stat.minRow) * (ROW_HEIGHT + ROW_GAP) + ROW_HEIGHT / 2 - nH(node) / 2;
1416
+ const isLaneChild = hasLanes && !!node.parentId && node.parentId !== pool.id;
1417
+ const contentH_stat = stat.rowCount * ROW_HEIGHT + Math.max(0, stat.rowCount - 1) * ROW_GAP;
1418
+ const vertTopOffset = Math.max(LANE_V_PAD, (stat.height - contentH_stat) / 2);
1419
+ const x = isLaneChild ? LANE_LABEL_W + LANE_H_PAD + colOffset : POOL_H_PAD + colOffset;
1420
+ const y = isLaneChild ? vertTopOffset + rowOffset : lYOff + vertTopOffset + rowOffset;
1421
+ return { ...node, position: { x, y } };
1422
+ });
1423
+ const NODE_MIN_GAP = 20;
1424
+ const resolvedContent = [...positionedContent];
1425
+ for (const laneId of laneIds) {
1426
+ const laneNodeIndices = resolvedContent.map((n, i) => ({ n, i })).filter(({ n }) => (nodeLaneId.get(n.id) ?? "_pool_") === laneId).sort((a, b) => a.n.position.x - b.n.position.x);
1427
+ for (let k = 1; k < laneNodeIndices.length; k++) {
1428
+ const prev = resolvedContent[laneNodeIndices[k - 1].i];
1429
+ const curr = resolvedContent[laneNodeIndices[k].i];
1430
+ const prevBottom = prev.position.y + nH(prev);
1431
+ const currTop = curr.position.y;
1432
+ const prevTop = prev.position.y;
1433
+ const currBottom = curr.position.y + nH(curr);
1434
+ const yOverlap = prevBottom + NODE_MIN_GAP > currTop && currBottom + NODE_MIN_GAP > prevTop;
1435
+ if (!yOverlap) continue;
1436
+ const prevRight = prev.position.x + nW(prev);
1437
+ if (prevRight + NODE_MIN_GAP > curr.position.x) {
1438
+ resolvedContent[laneNodeIndices[k].i] = {
1439
+ ...curr,
1440
+ position: {
1441
+ x: prevRight + NODE_MIN_GAP,
1442
+ y: curr.position.y
1443
+ }
1444
+ };
1445
+ }
1446
+ }
1447
+ }
1448
+ const positionedLanes = hasLanes ? sortedLanes.map((lane) => ({
1449
+ ...lane,
1450
+ // x: after pool label strip + left inner padding
1451
+ // y: laneY already includes top POOL_INNER_PAD offset
1452
+ position: { x: POOL_INNER_PAD, y: laneY.get(lane.id) ?? POOL_INNER_PAD },
1453
+ width: laneW,
1454
+ height: laneStats.get(lane.id)?.height ?? LANE_MIN_H
1455
+ })) : [];
1456
+ return {
1457
+ nodes: [...resolvedContent, ...positionedLanes],
1458
+ width: poolW,
1459
+ height: poolH
1460
+ };
1461
+ }
1462
+ var BACK_EDGE_CLEARANCE = 50;
1463
+ var SAME_ROW_THRESHOLD = 15;
1464
+ function absolutePos(nodeId, byId, cache) {
1465
+ const cached = cache.get(nodeId);
1466
+ if (cached) return cached;
1467
+ const node = byId.get(nodeId);
1468
+ if (!node) return { x: 0, y: 0 };
1469
+ const own = { ...node.position };
1470
+ if (!node.parentId) {
1471
+ cache.set(nodeId, own);
1472
+ return own;
1473
+ }
1474
+ const parent = absolutePos(node.parentId, byId, cache);
1475
+ const abs = { x: parent.x + own.x, y: parent.y + own.y };
1476
+ cache.set(nodeId, abs);
1477
+ return abs;
1478
+ }
1479
+ function laneOf(node, laneIds) {
1480
+ return node.parentId && laneIds.has(node.parentId) ? node.parentId : void 0;
1481
+ }
1482
+ function routeEdges(edges, layoutNodes, backEdgeIds, laneIds, poolIds) {
1483
+ const byId = new Map(layoutNodes.map((n) => [n.id, n]));
1484
+ const cache = /* @__PURE__ */ new Map();
1485
+ const abs = (id) => absolutePos(id, byId, cache);
1486
+ return edges.map((edge) => {
1487
+ const edgeType = edge.data?.edgeType ?? edge.type;
1488
+ if (edgeType !== "sequenceFlow") {
1489
+ const d = { ...edge.data };
1490
+ delete d.routingPoints;
1491
+ return { ...edge, data: d };
1492
+ }
1493
+ const src = byId.get(edge.source);
1494
+ const tgt = byId.get(edge.target);
1495
+ if (!src || !tgt) return edge;
1496
+ const sAbs = abs(src.id);
1497
+ const tAbs = abs(tgt.id);
1498
+ const sW = nW(src), sH = nH(src);
1499
+ const tW = nW(tgt), tH = nH(tgt);
1500
+ const sCX = sAbs.x + sW / 2, sCY = sAbs.y + sH / 2;
1501
+ const tCX = tAbs.x + tW / 2, tCY = tAbs.y + tH / 2;
1502
+ const srcPool = poolIds.has(src.parentId ?? "") ? src.parentId : poolIds.has(byId.get(src.parentId ?? "")?.parentId ?? "") ? byId.get(src.parentId ?? "")?.parentId : src.parentId;
1503
+ const tgtPool = poolIds.has(tgt.parentId ?? "") ? tgt.parentId : poolIds.has(byId.get(tgt.parentId ?? "")?.parentId ?? "") ? byId.get(tgt.parentId ?? "")?.parentId : tgt.parentId;
1504
+ if (srcPool !== tgtPool) {
1505
+ const d = { ...edge.data };
1506
+ delete d.routingPoints;
1507
+ return { ...edge, data: d };
1508
+ }
1509
+ let routingPoints;
1510
+ if (backEdgeIds.has(edge.id)) {
1511
+ const topY = Math.min(sAbs.y, tAbs.y) - BACK_EDGE_CLEARANCE;
1512
+ routingPoints = [
1513
+ { x: sCX, y: sAbs.y },
1514
+ // [0] discarded
1515
+ { x: sCX, y: topY },
1516
+ // [1] go up
1517
+ { x: tCX, y: topY },
1518
+ // [2] go left/right
1519
+ { x: tCX, y: tAbs.y }
1520
+ // [3] discarded
1521
+ ];
1522
+ } else if (laneOf(src, laneIds) !== laneOf(tgt, laneIds)) {
1523
+ const goingDown = tAbs.y > sAbs.y;
1524
+ const sharedX = Math.abs(sCX - tCX) < 10 ? sCX : (sCX + tCX) / 2;
1525
+ const srcLane = byId.get(src.parentId ?? "");
1526
+ const tgtLane = byId.get(tgt.parentId ?? "");
1527
+ if (srcLane && tgtLane && laneIds.has(srcLane.id) && laneIds.has(tgtLane.id)) {
1528
+ const srcLaneAbs = abs(srcLane.id);
1529
+ const borderY = goingDown ? srcLaneAbs.y + (srcLane.height ?? 160) : srcLaneAbs.y;
1530
+ routingPoints = [
1531
+ { x: sCX, y: goingDown ? sAbs.y + sH : sAbs.y },
1532
+ // [0] discarded
1533
+ { x: sharedX, y: goingDown ? sAbs.y + sH : sAbs.y },
1534
+ // [1] bend: horizontal exit
1535
+ { x: sharedX, y: borderY },
1536
+ // [2] bend: lane border
1537
+ { x: sharedX, y: goingDown ? tAbs.y : tAbs.y + tH }
1538
+ // [3] discarded
1539
+ ];
1540
+ } else {
1541
+ routingPoints = [
1542
+ { x: sCX, y: sCY },
1543
+ { x: sharedX, y: sCY },
1544
+ { x: sharedX, y: tCY },
1545
+ { x: tCX, y: tCY }
1546
+ ];
1547
+ }
1548
+ } else if (Math.abs(sCY - tCY) <= SAME_ROW_THRESHOLD) {
1549
+ const d = { ...edge.data };
1550
+ delete d.routingPoints;
1551
+ return { ...edge, data: d };
1552
+ } else {
1553
+ const handle = edge.sourceHandle ?? "";
1554
+ const exitsTop = handle.includes("top");
1555
+ const exitsBottom = handle.includes("bottom");
1556
+ if (exitsTop || exitsBottom) {
1557
+ routingPoints = [
1558
+ { x: sCX, y: exitsTop ? sAbs.y : sAbs.y + sH },
1559
+ // [0] discarded
1560
+ { x: sCX, y: tCY },
1561
+ // [1] vertical to target row
1562
+ { x: tCX, y: tCY },
1563
+ // [2] horizontal to target
1564
+ { x: tCX, y: exitsTop ? tAbs.y + tH : tAbs.y }
1565
+ // [3] discarded
1566
+ ];
1567
+ } else {
1568
+ const goingRight = tAbs.x >= sAbs.x;
1569
+ const midX = goingRight ? sAbs.x + sW + COL_GAP / 2 : sAbs.x - COL_GAP / 2;
1570
+ routingPoints = [
1571
+ { x: sAbs.x + sW, y: sCY },
1572
+ // [0] discarded
1573
+ { x: midX, y: sCY },
1574
+ // [1] horizontal exit
1575
+ { x: midX, y: tCY },
1576
+ // [2] vertical to target row
1577
+ { x: tAbs.x, y: tCY }
1578
+ // [3] discarded
1579
+ ];
1580
+ }
1581
+ }
1582
+ return { ...edge, data: { ...edge.data, routingPoints } };
1583
+ });
1584
+ }
1585
+ async function bpmnCustomLayout(nodes, edges) {
1586
+ const pools = nodes.filter((n) => n.data.elementType === "Pool");
1587
+ const lanes = nodes.filter((n) => n.data.elementType === "Lane");
1588
+ const content = nodes.filter((n) => !LAYOUT_CONTAINER_TYPES.has(n.data.elementType));
1589
+ if (pools.length === 0) {
1590
+ const { bpmnElkLayout: bpmnElkLayout2 } = await Promise.resolve().then(() => (init_elk(), elk_exports));
1591
+ return bpmnElkLayout2(nodes, edges);
1592
+ }
1593
+ const poolIds = new Set(pools.map((p) => p.id));
1594
+ const allLaneIds = new Set(lanes.map((l) => l.id));
1595
+ const allContentIds = new Set(content.map((n) => n.id));
1596
+ const allSeqEdges = edges.filter((e) => {
1597
+ const t = e.data?.edgeType ?? e.type;
1598
+ return t === "sequenceFlow" && allContentIds.has(e.source) && allContentIds.has(e.target);
1599
+ }).map((e) => ({ id: e.id, source: e.source, target: e.target }));
1600
+ const allBackEdgeIds = detectBackEdges([...allContentIds], allSeqEdges);
1601
+ const poolPositionsDistinct = pools.some((p) => Math.abs(p.position.y) > 10);
1602
+ const sortedPools = poolPositionsDistinct ? [...pools].sort((a, b) => a.position.y - b.position.y) : [...pools];
1603
+ const resultNodes = [];
1604
+ let stackY = 0;
1605
+ for (const pool of sortedPools) {
1606
+ const poolLanes = lanes.filter((l) => l.parentId === pool.id);
1607
+ const laneIds = new Set(poolLanes.map((l) => l.id));
1608
+ const poolContent = content.filter(
1609
+ (n) => n.parentId === pool.id || n.parentId != null && laneIds.has(n.parentId)
1610
+ );
1611
+ const result = layoutPool(pool, poolLanes, poolContent, edges);
1612
+ resultNodes.push({
1613
+ ...pool,
1614
+ position: { x: 0, y: stackY },
1615
+ width: result.width,
1616
+ height: result.height
1617
+ });
1618
+ for (const node of result.nodes) {
1619
+ resultNodes.push(node);
1620
+ }
1621
+ stackY += result.height + POOL_V_GAP;
1622
+ }
1623
+ const layoutted = new Set(resultNodes.map((n) => n.id));
1624
+ for (const node of nodes) {
1625
+ if (!layoutted.has(node.id)) resultNodes.push(node);
1626
+ }
1627
+ const routedEdges = routeEdges(edges, resultNodes, allBackEdgeIds, allLaneIds, poolIds);
1628
+ return { nodes: resultNodes, edges: routedEdges };
1629
+ }
984
1630
 
985
1631
  // src/layout/index.ts
986
1632
  async function bpmnDagreLayout(nodes, edges, options = {}) {
@@ -998,6 +1644,7 @@ Object.defineProperty(exports, "applyLayoutResultToDiagram", {
998
1644
  get: function () { return layout.applyLayoutResultToDiagram; }
999
1645
  });
1000
1646
  exports.applyBpmnLayoutResult = applyBpmnLayoutResult;
1647
+ exports.bpmnCustomLayout = bpmnCustomLayout;
1001
1648
  exports.bpmnDagreLayout = bpmnDagreLayout;
1002
1649
  exports.bpmnElkLayout = bpmnElkLayout;
1003
1650
  //# sourceMappingURL=index.cjs.map