@diagrammo/dgmo 0.15.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +14 -1
  2. package/dist/advanced.cjs +53069 -0
  3. package/dist/advanced.d.cts +4691 -0
  4. package/dist/advanced.d.ts +4691 -0
  5. package/dist/advanced.js +52823 -0
  6. package/dist/auto.cjs +1495 -1288
  7. package/dist/auto.js +132 -109
  8. package/dist/auto.mjs +1491 -1284
  9. package/dist/cli.cjs +173 -150
  10. package/dist/index.cjs +1486 -1276
  11. package/dist/index.d.cts +45 -1
  12. package/dist/index.d.ts +45 -1
  13. package/dist/index.js +1481 -1272
  14. package/dist/internal.cjs +1497 -1289
  15. package/dist/internal.d.cts +80 -79
  16. package/dist/internal.d.ts +80 -79
  17. package/dist/internal.js +1492 -1285
  18. package/dist/pert.cjs +325 -0
  19. package/dist/pert.d.cts +542 -0
  20. package/dist/pert.d.ts +542 -0
  21. package/dist/pert.js +294 -0
  22. package/package.json +28 -3
  23. package/src/advanced.ts +731 -0
  24. package/src/auto/index.ts +14 -13
  25. package/src/boxes-and-lines/layout.ts +481 -445
  26. package/src/c4/parser.ts +7 -7
  27. package/src/chart-types.ts +0 -5
  28. package/src/class/parser.ts +1 -9
  29. package/src/cli.ts +9 -7
  30. package/src/completion-types.ts +28 -0
  31. package/src/completion.ts +15 -18
  32. package/src/cycle/layout.ts +2 -2
  33. package/src/d3.ts +1455 -1122
  34. package/src/echarts.ts +11 -11
  35. package/src/er/parser.ts +1 -9
  36. package/src/er/renderer.ts +1 -1
  37. package/src/gantt/calculator.ts +1 -11
  38. package/src/gantt/parser.ts +16 -16
  39. package/src/gantt/renderer.ts +2 -2
  40. package/src/graph/flowchart-parser.ts +1 -1
  41. package/src/graph/flowchart-renderer.ts +1 -1
  42. package/src/graph/state-renderer.ts +1 -1
  43. package/src/index.ts +17 -1
  44. package/src/infra/parser.ts +19 -19
  45. package/src/infra/renderer.ts +2 -2
  46. package/src/internal.ts +9 -721
  47. package/src/kanban/parser.ts +2 -2
  48. package/src/mindmap/layout.ts +1 -1
  49. package/src/mindmap/parser.ts +1 -1
  50. package/src/org/parser.ts +1 -1
  51. package/src/org/renderer.ts +1 -1
  52. package/src/pert/layout.ts +1 -1
  53. package/src/pert/monte-carlo.ts +2 -2
  54. package/src/pert/parser.ts +3 -3
  55. package/src/raci/parser.ts +4 -4
  56. package/src/raci/renderer.ts +1 -1
  57. package/src/sequence/renderer.ts +1 -4
  58. package/src/sitemap/parser.ts +1 -1
  59. package/src/tech-radar/interactive.ts +1 -1
  60. package/src/tech-radar/renderer.ts +1 -1
  61. package/src/utils/tag-groups.ts +11 -12
  62. package/src/wireframe/layout.ts +11 -7
  63. package/src/wireframe/parser.ts +2 -2
  64. package/src/wireframe/renderer.ts +5 -2
package/dist/pert.d.ts ADDED
@@ -0,0 +1,542 @@
1
+ type DgmoSeverity = 'error' | 'warning';
2
+ interface DgmoError {
3
+ line: number;
4
+ column?: number;
5
+ message: string;
6
+ severity: DgmoSeverity;
7
+ /**
8
+ * Optional stable diagnostic code (e.g. 'E_ARROW_SUBSTRING_IN_LABEL').
9
+ * Additive; pre-existing diagnostics omit this field and existing
10
+ * substring-on-`.message` assertions keep working unchanged.
11
+ */
12
+ code?: string;
13
+ }
14
+
15
+ /** A single entry inside a tag group: `Value(color)` */
16
+ interface TagEntry {
17
+ value: string;
18
+ color: string;
19
+ lineNumber: number;
20
+ }
21
+ /** A tag group block: heading + entries */
22
+ interface TagGroup {
23
+ name: string;
24
+ alias?: string;
25
+ entries: TagEntry[];
26
+ /** Default value for nodes without explicit metadata. First entry unless another is marked `default`. */
27
+ defaultValue?: string;
28
+ lineNumber: number;
29
+ }
30
+
31
+ /** Calendar units: d (days), w (weeks), m (months), q (quarters), y (years), h (hours), min (minutes). bd = business days. s = sprints. */
32
+ type DurationUnit = 'd' | 'bd' | 'w' | 'm' | 'q' | 'y' | 'h' | 'min' | 's';
33
+ interface Duration {
34
+ amount: number;
35
+ unit: DurationUnit;
36
+ }
37
+
38
+ /**
39
+ * A three-point duration estimate. Each component is a parsed
40
+ * `Duration { amount, unit }` so mixed units (`1w 2w 3m`) are
41
+ * preserved; the analyzer normalizes to `options.timeUnit` for
42
+ * arithmetic.
43
+ */
44
+ interface DurationEstimate {
45
+ o: Duration;
46
+ m: Duration;
47
+ p: Duration;
48
+ /**
49
+ * When true, only an M token was given on the source line and the
50
+ * analyzer must expand O/P from confidence factors. When false, the
51
+ * user wrote an explicit O M P triple (even when all three values
52
+ * are equal — zero-variance is a valid, deterministic estimate).
53
+ */
54
+ mOnly: boolean;
55
+ }
56
+
57
+ /** Layout direction. `LR` is the default; `TB` for tall chains. */
58
+ type PertDirection = 'LR' | 'TB';
59
+ /** `node-detail` directive value. */
60
+ type NodeDetail = 'compact' | 'full';
61
+ /**
62
+ * Project schedule anchor. Mutually-exclusive at parse time:
63
+ * - `forward` — `start-date YYYY-MM-DD` anchors source-activity ES.
64
+ * - `backward` — `end-date YYYY-MM-DD` anchors sink-activity LF.
65
+ * - `null` — no anchor; ES/EF/LS/LF render as numeric offsets.
66
+ */
67
+ type Anchor = {
68
+ kind: 'forward';
69
+ date: string;
70
+ } | {
71
+ kind: 'backward';
72
+ date: string;
73
+ } | null;
74
+ /**
75
+ * One row of the project-stats caption. Replaces the previous
76
+ * `\n`-joined `summaryText` string with a structured shape so the
77
+ * renderer doesn't have to recover bullet structure by splitting on
78
+ * `\n` / `. ` and tests can assert on `isPast` directly instead of
79
+ * matching the trailing `(latest-safe start has passed)` suffix.
80
+ */
81
+ interface CaptionRow {
82
+ /** Pre-formatted caption text for this row (no leading bullet glyph). */
83
+ text: string;
84
+ /** 0 = top-level row; 1 = sub-row (indented under the previous level-0 row). */
85
+ level: 0 | 1;
86
+ /** When true, renderer paints the text italic. */
87
+ italic?: boolean;
88
+ /**
89
+ * Backward-mode flag — true when the row reports a latest-safe-start
90
+ * date that precedes `options.today`. The text already carries a
91
+ * `(latest-safe start has passed)` suffix; the flag is for downstream
92
+ * styling/test assertions.
93
+ */
94
+ isPast?: boolean;
95
+ }
96
+ /** Diagram-level options collected by the parser. */
97
+ interface PertOptions {
98
+ /** Time unit for μ/σ/ES/EF formatting and M-only heuristics. */
99
+ timeUnit: Duration['unit'];
100
+ /** `direction` directive. Defaults to `LR`. */
101
+ direction: PertDirection;
102
+ /** `node-detail` directive. Defaults to `compact`. */
103
+ nodeDetail: NodeDetail;
104
+ /**
105
+ * Global confidence used to fill O/P from M-only durations.
106
+ * Stored verbatim — analyzer applies `resolveConfidence()` to expand
107
+ * named levels (`high`/`medium`/`low`) or `O/P` factor pairs.
108
+ */
109
+ confidence: string;
110
+ /** Monte-Carlo trials for the canonical run (default 10000). */
111
+ trials: number;
112
+ /** Monte-Carlo seed; deterministic across machines via mulberry32. */
113
+ seed: number;
114
+ /** Fast-MC trials for the live duration scrubber (default 300, floor 100). */
115
+ scrubberTrials: number;
116
+ /**
117
+ * Date anchor — discriminated union enforces mutual exclusion.
118
+ * `null` when no `start-date`/`end-date` directive was authored.
119
+ */
120
+ anchor: Anchor;
121
+ /** When true, the renderer suppresses the diagram banner title. */
122
+ noTitle?: boolean;
123
+ /**
124
+ * `active-tag <name>` directive — selects which declared tag group
125
+ * drives node fill via `resolveTagColor()`. `'none'` (case-insensitive)
126
+ * suppresses tag coloring; `undefined` lets `resolveActiveTagGroup()`
127
+ * auto-activate the first declared group.
128
+ */
129
+ activeTag?: string;
130
+ /**
131
+ * Sprint mode (mirrors Gantt's surface). Activated automatically when
132
+ * `time-unit s` is set, or explicitly when any `sprint-*` directive
133
+ * appears. Schedule cells render as `S<n>` instead of numeric offsets
134
+ * or ISO dates.
135
+ */
136
+ sprintLength: Duration | null;
137
+ sprintNumber: number | null;
138
+ sprintStart: string | null;
139
+ sprintMode: 'auto' | 'explicit' | null;
140
+ /**
141
+ * "Today" baked in at parse time (ISO YYYY-MM-DD). Same source as
142
+ * `start-date now`, captured for every parse regardless of whether
143
+ * `now` was authored. Analyzer reads this to flag past latest-safe
144
+ * starts in backward mode; renderer surfaces it in the
145
+ * `(as of YYYY-MM-DD)` anchor annotation. Empty string when the
146
+ * parser was given no `now` and no `start-date now` directive (legacy
147
+ * fixtures pre-dating this field) — consumers treat empty as
148
+ * "no today known" and skip past-flagging.
149
+ */
150
+ today: string;
151
+ }
152
+ /**
153
+ * A PERT activity (node). Activities have either a three-point estimate,
154
+ * an M-only estimate (parser fills O/P from confidence factors), or no
155
+ * estimate at all (TBD — analyzer null-poisons descendants).
156
+ */
157
+ interface PertActivity {
158
+ /** Stable id — alias if `as` was given, otherwise normalized name. */
159
+ id: string;
160
+ /** Human-readable label as written in source. */
161
+ name: string;
162
+ /** Optional alias from `<name> <durs> as <id>`. */
163
+ alias?: string;
164
+ /**
165
+ * Activity duration estimate.
166
+ * - `null` → TBD (no estimate); analyzer poisons descendants with `null`.
167
+ */
168
+ duration: DurationEstimate | null;
169
+ /**
170
+ * Per-activity confidence override from pipe metadata (`| confidence: low`).
171
+ * When unset, analyzer uses `options.confidence`.
172
+ */
173
+ confidence?: string;
174
+ /** Group id this activity belongs to (post-resolve). */
175
+ groupId?: string;
176
+ /** Source line of the declaration site (1-based). */
177
+ lineNumber: number;
178
+ /** True for `milestone <name>` primitives (zero-duration, diamond shape). */
179
+ isMilestone: boolean;
180
+ /**
181
+ * Resolved tag-group metadata from pipe-metadata aliases. Keys are
182
+ * lowercased tag-group names (e.g. `priority`, `team`); values are the
183
+ * authored tag entry names. Drives node fill via `resolveTagColor()`
184
+ * when an `active-tag` group is set. Empty when no tag groups are
185
+ * declared or the activity carried no tag metadata.
186
+ */
187
+ tags?: Record<string, string>;
188
+ }
189
+ /**
190
+ * Forward-style milestone shorthand. Stored as a `PertActivity` with
191
+ * `isMilestone: true` and a zero-duration estimate, but kept here as a
192
+ * distinct exported alias for callers that want to filter by kind.
193
+ */
194
+ type PertMilestone = PertActivity & {
195
+ isMilestone: true;
196
+ };
197
+ /**
198
+ * Dependency type — defaults to FS (Finish-to-Start), the dominant case.
199
+ * - FS: `B.ES ≥ A.EF + lag` (most edges)
200
+ * - SS: `B.ES ≥ A.ES + lag` (parallel start)
201
+ * - FF: `B.EF ≥ A.EF + lag` (synchronized finish)
202
+ * - SF: `B.EF ≥ A.ES + lag` (rare; included for completeness)
203
+ */
204
+ type EdgeType = 'FS' | 'SS' | 'FF' | 'SF';
205
+ /**
206
+ * Directed dependency edge from `source` activity to `target`.
207
+ * `type` defaults to FS, `lag` to null (zero offset). Lag amount may be
208
+ * negative (a lead — predecessor and successor overlap).
209
+ */
210
+ interface PertEdge {
211
+ source: string;
212
+ target: string;
213
+ lineNumber: number;
214
+ type: EdgeType;
215
+ lag: Duration | null;
216
+ }
217
+ /** Group declared via `[group-name] | metadata`. */
218
+ interface PertGroup {
219
+ id: string;
220
+ name: string;
221
+ /** Activity ids belonging to this group, populated in Pass 2. */
222
+ activityIds: string[];
223
+ /** Whether the user authored `| collapsed: true`. */
224
+ collapsed: boolean;
225
+ /** Source line of the `[group-name]` header (1-based). */
226
+ lineNumber: number;
227
+ /**
228
+ * Resolved tag-group metadata for the cluster header — same shape as
229
+ * `PertActivity.tags`. Currently informational; default-tag injection
230
+ * skips groups (containers) so they appear "untagged" unless the user
231
+ * authors an explicit value via pipe metadata.
232
+ */
233
+ tags?: Record<string, string>;
234
+ /**
235
+ * Auto-detected group topology (Pass 2 result).
236
+ * - `hammock`: single entry + single exit — collapses to a super-edge.
237
+ * - `cluster`: multi-entry or multi-exit — collapses to a bounding rect.
238
+ */
239
+ classification?: 'hammock' | 'cluster';
240
+ }
241
+ /** Output of `parsePert(content)`. */
242
+ interface ParsedPert {
243
+ /** Optional title parsed from `pert <title>`. */
244
+ title: string | null;
245
+ options: PertOptions;
246
+ activities: PertActivity[];
247
+ edges: PertEdge[];
248
+ groups: PertGroup[];
249
+ /**
250
+ * Tag groups declared at the top of the diagram (`tag Priority as p
251
+ * High(red), Low(green)`). Drive node fill via `resolveTagColor()`.
252
+ * Empty when no `tag` blocks are declared.
253
+ */
254
+ tagGroups: TagGroup[];
255
+ /**
256
+ * Map alias-or-name → canonical activity id. Useful for the analyzer
257
+ * and for editor autocomplete; also populated in Pass 2.
258
+ */
259
+ idMap: Record<string, string>;
260
+ diagnostics: DgmoError[];
261
+ /** First fatal error message; `null` when parse succeeded. */
262
+ error: string | null;
263
+ }
264
+ /**
265
+ * Fully-resolved per-activity analysis output. ES/EF/LS/LF/slack are
266
+ * `null` for any activity downstream of a TBD (poison-propagation per
267
+ * AC2.3).
268
+ */
269
+ interface ResolvedActivity {
270
+ activity: PertActivity;
271
+ /** Earliest start (forward pass). `null` if upstream TBD. */
272
+ es: number | null;
273
+ /** Earliest finish. */
274
+ ef: number | null;
275
+ /** Latest start (backward pass). */
276
+ ls: number | null;
277
+ /** Latest finish. */
278
+ lf: number | null;
279
+ /** Slack = LS − ES (or LF − EF). 0 = on critical path. `null` if poisoned. */
280
+ slack: number | null;
281
+ /** True iff the M-world critical path passes through this activity. */
282
+ isCriticalPath: boolean;
283
+ /** Resolved μ in `options.timeUnit` (numeric mean of o/m/p). */
284
+ mu: number | null;
285
+ /** Resolved σ in `options.timeUnit` (Beta-PERT std dev). */
286
+ sigma: number | null;
287
+ /**
288
+ * Criticality index from Monte Carlo (0–1). `null` when MC is off or
289
+ * when this activity is downstream of a TBD.
290
+ */
291
+ criticality: number | null;
292
+ /**
293
+ * True iff the source declared an explicit O/M/P triple. M-only,
294
+ * TBD, and milestone activities all report `false`.
295
+ */
296
+ isAuthored: boolean;
297
+ }
298
+ /** Resolved hammock/cluster group. */
299
+ interface ResolvedGroup {
300
+ group: PertGroup;
301
+ /** Aggregate μ/σ along the group's internal critical path. */
302
+ rolledMu: number | null;
303
+ rolledSigma: number | null;
304
+ /** Group entry/exit ids derived in Pass 2. */
305
+ entries: string[];
306
+ exits: string[];
307
+ /**
308
+ * Rolled-up schedule envelope across member activities.
309
+ * ES = min member.es
310
+ * EF = max member.ef
311
+ * LS = min member.ls
312
+ * LF = max member.lf
313
+ * slack = LS − ES
314
+ * criticality = max member.criticality (when MC is on)
315
+ * Each is `null` when no member has a non-null value (e.g. all-TBD group).
316
+ */
317
+ es: number | null;
318
+ ef: number | null;
319
+ ls: number | null;
320
+ lf: number | null;
321
+ slack: number | null;
322
+ criticality: number | null;
323
+ }
324
+ /**
325
+ * Bare shape for a Monte-Carlo simulation result; Phase 2 fills it.
326
+ * Keeping the shape exported in v1 means analyzer consumers don't break
327
+ * when MC support lands.
328
+ */
329
+ interface MonteCarloResult {
330
+ /** Trials run (canonical or fast). */
331
+ trials: number;
332
+ /** Seed used for deterministic reproduction. */
333
+ seed: number;
334
+ /** Project-completion percentiles. */
335
+ p50: number;
336
+ p80: number;
337
+ p95: number;
338
+ /**
339
+ * Central ~68% band — empirical equivalent of a ±1σ window. Used by
340
+ * the S-curve to draw a "where the project most likely lands" shaded
341
+ * region without assuming the finish-time distribution is normal.
342
+ */
343
+ p16: number;
344
+ p84: number;
345
+ /**
346
+ * Empirical lower bound — minimum trial duration in canonical days.
347
+ * Used by the S-curve to anchor its x-axis at the actually-observed
348
+ * span rather than an analytical extrapolation. Backward-mode reads
349
+ * this through `end_date − max` to land the left edge of the
350
+ * candidate-start axis.
351
+ */
352
+ minDurationDays: number;
353
+ /**
354
+ * Empirical upper bound — maximum trial duration in canonical days.
355
+ * Symmetric counterpart to `minDurationDays`. Backward-mode reads
356
+ * this as the latest candidate start that still has a chance of
357
+ * hitting the deadline.
358
+ */
359
+ maxDurationDays: number;
360
+ /** Per-activity criticality index, keyed by activity id. */
361
+ criticalityByActivity: Record<string, number>;
362
+ /** Modal-longest-path tuple (activity ids). */
363
+ modalCriticalPath: string[];
364
+ /**
365
+ * Per-activity tornado swings — how much the project end-date
366
+ * moves when this activity comes in at its optimistic (O) or
367
+ * pessimistic (P) extreme while every other activity stays at
368
+ * its mean (μ). Sorted descending by total swing.
369
+ *
370
+ * `lowSwing` and `highSwing` are in canonical days (≥ 0).
371
+ * Renderer converts to display unit.
372
+ */
373
+ tornadoSwings: TornadoSwing[];
374
+ }
375
+ /**
376
+ * One row of a true two-sided tornado: the project end-date moves
377
+ * lowSwing days earlier when the activity is at its optimistic
378
+ * extreme, and highSwing days later when at its pessimistic extreme.
379
+ * All other activities held at their μ.
380
+ */
381
+ interface TornadoSwing {
382
+ id: string;
383
+ name: string;
384
+ /** Days the project finishes EARLIER when this activity ≈ O. */
385
+ lowSwing: number;
386
+ /** Days the project finishes LATER when this activity ≈ P. */
387
+ highSwing: number;
388
+ /** Per-activity MC criticality index, used by the renderer for bar color. */
389
+ criticality: number | null;
390
+ }
391
+ /**
392
+ * Per-activity (O, M, P) in canonical days — the analyzer's
393
+ * expanded-estimate cache, populated for every activity that has an
394
+ * estimate (TBDs are omitted). Workers re-running Monte Carlo on an
395
+ * already-resolved PERT can read this directly instead of re-parsing
396
+ * + re-expanding from source.
397
+ */
398
+ interface PertExpandedActivity {
399
+ id: string;
400
+ o: number;
401
+ m: number;
402
+ p: number;
403
+ }
404
+ interface ResolvedPert {
405
+ options: PertOptions;
406
+ activities: ResolvedActivity[];
407
+ edges: PertEdge[];
408
+ groups: ResolvedGroup[];
409
+ /**
410
+ * Tag groups copied from the parsed source. The renderer reads this
411
+ * + `options.activeTag` to drive node fill via `resolveTagColor()`
412
+ * and to render the legend.
413
+ */
414
+ tagGroups: TagGroup[];
415
+ /**
416
+ * Analysis mode auto-derived from data: `monte-carlo` when at least
417
+ * one non-milestone activity carries an O/M/P triple AND `trials >= 100`,
418
+ * otherwise `analytical`.
419
+ */
420
+ mode: 'monte-carlo' | 'analytical';
421
+ /**
422
+ * Project-stats caption rows. Each row is one bullet in the rendered
423
+ * caption box; level-1 rows render indented under the preceding
424
+ * level-0 row. Null only when analysis bails out before producing
425
+ * any output (e.g. cycle detection); non-null in every successful
426
+ * analyze() run.
427
+ */
428
+ summaryRows: CaptionRow[] | null;
429
+ /**
430
+ * One-line project summary rendered as a subtitle under the diagram title.
431
+ * Shape per mode (see §13A.7):
432
+ * - Forward: `Expected finish: <date> · ≈ <μ> <unit> of work (± <σ>)`
433
+ * - Backward: `Expected start: <date> · ≈ <μ> <unit> lead time (± <σ>)`
434
+ * - Unanchored: `≈ <μ> <unit> (± <σ>)`
435
+ * Null when analysis bails out before producing any output.
436
+ */
437
+ projectSubtitle: string | null;
438
+ /** μ along the M-world critical path (max EF over all activities). */
439
+ projectMu: number | null;
440
+ /** σ along the M-world critical path (sqrt of variance sum). */
441
+ projectSigma: number | null;
442
+ /** Critical-path activity ids in topological order. */
443
+ criticalPath: string[];
444
+ /**
445
+ * Anchored mode: the date all four schedule labels (ES/EF/LS/LF) are
446
+ * computed off. Forward = start-date; backward = end-date − projectMu;
447
+ * null otherwise (no anchor, or backward + TBD upstream).
448
+ */
449
+ projectStart: string | null;
450
+ /** Populated when `mode === 'monte-carlo'`. */
451
+ monteCarloResult: MonteCarloResult | null;
452
+ /**
453
+ * Per-activity (O, M, P) in canonical days. Always populated; used
454
+ * by Phase 3b Worker / scrubber so the simulator can re-run on a
455
+ * postMessage-cloned ResolvedPert without needing the original
456
+ * ParsedPert or analyzer state.
457
+ */
458
+ expandedActivities: PertExpandedActivity[];
459
+ diagnostics: DgmoError[];
460
+ error: string | null;
461
+ }
462
+ interface PertLayoutNode {
463
+ id: string;
464
+ x: number;
465
+ y: number;
466
+ width: number;
467
+ height: number;
468
+ }
469
+ interface PertLayoutEdge {
470
+ source: string;
471
+ target: string;
472
+ points: {
473
+ x: number;
474
+ y: number;
475
+ }[];
476
+ }
477
+ interface PertLayoutGroup {
478
+ id: string;
479
+ x: number;
480
+ y: number;
481
+ width: number;
482
+ height: number;
483
+ classification: 'hammock' | 'cluster';
484
+ /**
485
+ * True when the group is currently collapsed. Layout sized this rect
486
+ * as a single rolled-up node and hid the group's member activities
487
+ * from `nodes` / re-routed external edges to land on this rect.
488
+ */
489
+ collapsed?: boolean;
490
+ }
491
+ interface LayoutResult {
492
+ nodes: PertLayoutNode[];
493
+ edges: PertLayoutEdge[];
494
+ groups: PertLayoutGroup[];
495
+ width: number;
496
+ height: number;
497
+ }
498
+
499
+ /**
500
+ * mulberry32: 32-bit seedable PRNG. Portable, deterministic, ~10 lines.
501
+ * Returns a function that yields [0, 1).
502
+ */
503
+ declare function mulberry32(seed: number): () => number;
504
+ /**
505
+ * Sample one duration from a Beta-PERT distribution defined by (O, M, P).
506
+ * Zero-variance case (O = M = P) bypasses sampling deterministically.
507
+ */
508
+ declare function sampleBetaPert(o: number, m: number, p: number, rng: () => number): number;
509
+ interface ExpandedActivity {
510
+ id: string;
511
+ o: number;
512
+ m: number;
513
+ p: number;
514
+ }
515
+ interface SimulateOptions {
516
+ trials: number;
517
+ seed: number;
518
+ }
519
+ /**
520
+ * Build a runnable simulation context from a `ResolvedPert`. The
521
+ * analyzer will call this then invoke `simulateCanonical` /
522
+ * `simulateFast` on the result.
523
+ */
524
+ declare function buildSimulationContext(resolved: ResolvedPert): {
525
+ predecessors: Map<string, string[]>;
526
+ successors: Map<string, string[]>;
527
+ topo: string[];
528
+ terminals: string[];
529
+ poisoned: Set<string>;
530
+ };
531
+ /**
532
+ * Canonical simulation — N=10000 by default. Used for static export
533
+ * and the "computing…" Worker job in the app.
534
+ */
535
+ declare function simulateCanonical(resolved: ResolvedPert, expanded: ExpandedActivity[], opts: SimulateOptions): MonteCarloResult;
536
+ /**
537
+ * Fast simulation — N=300 by default. Used by the duration scrubber for
538
+ * sub-100ms re-analysis on each rAF tick.
539
+ */
540
+ declare function simulateFast(resolved: ResolvedPert, expanded: ExpandedActivity[], opts: SimulateOptions): MonteCarloResult;
541
+
542
+ export { type ExpandedActivity, type LayoutResult, type MonteCarloResult, type NodeDetail, type ParsedPert, type PertActivity, type PertDirection, type PertEdge, type PertExpandedActivity, type PertGroup, type PertLayoutEdge, type PertLayoutGroup, type PertLayoutNode, type PertMilestone, type PertOptions, type ResolvedActivity, type ResolvedGroup, type ResolvedPert, type SimulateOptions, buildSimulationContext, mulberry32, sampleBetaPert, simulateCanonical, simulateFast };