@cristianormazabal/triton-core 0.1.18 → 0.1.19

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 (30) hide show
  1. package/dist/diagrams/mermaid/architecture/gridPlacer.d.ts +36 -0
  2. package/dist/diagrams/mermaid/architecture/gridPlacer.d.ts.map +1 -0
  3. package/dist/diagrams/mermaid/architecture/gridPlacer.js +153 -0
  4. package/dist/diagrams/mermaid/architecture/gridPlacer.js.map +1 -0
  5. package/dist/diagrams/{triton → mermaid}/architecture/index.d.ts +1 -1
  6. package/dist/diagrams/mermaid/architecture/index.d.ts.map +1 -0
  7. package/dist/diagrams/{triton → mermaid}/architecture/index.js +2 -2
  8. package/dist/diagrams/mermaid/architecture/index.js.map +1 -0
  9. package/dist/diagrams/mermaid/architecture/ir.d.ts +55 -0
  10. package/dist/diagrams/mermaid/architecture/ir.d.ts.map +1 -0
  11. package/dist/diagrams/mermaid/architecture/ir.js.map +1 -0
  12. package/dist/diagrams/mermaid/architecture/layout.d.ts +27 -0
  13. package/dist/diagrams/mermaid/architecture/layout.d.ts.map +1 -0
  14. package/dist/diagrams/mermaid/architecture/layout.js +352 -0
  15. package/dist/diagrams/mermaid/architecture/layout.js.map +1 -0
  16. package/dist/frontend/index.js +1 -1
  17. package/dist/frontend/index.js.map +1 -1
  18. package/dist/index.js +805 -130
  19. package/dist/index.js.map +4 -4
  20. package/package.json +1 -1
  21. package/dist/diagrams/triton/architecture/index.d.ts.map +0 -1
  22. package/dist/diagrams/triton/architecture/index.js.map +0 -1
  23. package/dist/diagrams/triton/architecture/ir.d.ts +0 -29
  24. package/dist/diagrams/triton/architecture/ir.d.ts.map +0 -1
  25. package/dist/diagrams/triton/architecture/ir.js.map +0 -1
  26. package/dist/diagrams/triton/architecture/layout.d.ts +0 -11
  27. package/dist/diagrams/triton/architecture/layout.d.ts.map +0 -1
  28. package/dist/diagrams/triton/architecture/layout.js +0 -124
  29. package/dist/diagrams/triton/architecture/layout.js.map +0 -1
  30. /package/dist/diagrams/{triton → mermaid}/architecture/ir.js +0 -0
package/dist/index.js CHANGED
@@ -38320,8 +38320,99 @@ var c4 = {
38320
38320
  }
38321
38321
  };
38322
38322
 
38323
- // src/diagrams/triton/architecture/layout.ts
38324
- var ARROW_ID8 = "arch-arrow";
38323
+ // src/diagrams/mermaid/architecture/gridPlacer.ts
38324
+ var DELTA = {
38325
+ LR: [-1, 0],
38326
+ RL: [1, 0],
38327
+ TB: [0, -1],
38328
+ BT: [0, 1],
38329
+ LT: [-1, -1],
38330
+ LB: [-1, 1],
38331
+ RT: [1, -1],
38332
+ RB: [1, 1],
38333
+ TL: [-1, -1],
38334
+ TR: [1, -1],
38335
+ BL: [-1, 1],
38336
+ BR: [1, 1]
38337
+ };
38338
+ function directionalGridPlacer(nodes, edges2) {
38339
+ if (nodes.length === 0) return /* @__PURE__ */ new Map();
38340
+ const adjList = /* @__PURE__ */ new Map();
38341
+ for (const n of nodes) adjList.set(n.id, /* @__PURE__ */ new Map());
38342
+ for (const e of edges2) {
38343
+ const fs = e.fromSide.toUpperCase();
38344
+ const ts = e.toSide.toUpperCase();
38345
+ const fwd = fs + ts;
38346
+ const rev = ts + fs;
38347
+ const fromAdj = adjList.get(e.from);
38348
+ const toAdj = adjList.get(e.to);
38349
+ if (!fromAdj || !toAdj) continue;
38350
+ if (fromAdj.has(fwd) && fromAdj.get(fwd) !== e.to) {
38351
+ console.warn(`[gridPlacer] Contradictory constraint on "${e.from}" direction ${fwd} \u2014 first-wins`);
38352
+ } else {
38353
+ fromAdj.set(fwd, e.to);
38354
+ }
38355
+ if (toAdj.has(rev) && toAdj.get(rev) !== e.from) {
38356
+ console.warn(`[gridPlacer] Contradictory constraint on "${e.to}" direction ${rev} \u2014 first-wins`);
38357
+ } else {
38358
+ toAdj.set(rev, e.from);
38359
+ }
38360
+ }
38361
+ const position = /* @__PURE__ */ new Map();
38362
+ const occupied = /* @__PURE__ */ new Map();
38363
+ function bfs(seed2, seedCol, seedRow) {
38364
+ position.set(seed2, { col: seedCol, row: seedRow });
38365
+ occupied.set(`${seedCol},${seedRow}`, seed2);
38366
+ const queue2 = [seed2];
38367
+ while (queue2.length > 0) {
38368
+ const curr = queue2.shift();
38369
+ const currPos = position.get(curr);
38370
+ const adj = adjList.get(curr);
38371
+ if (!adj) continue;
38372
+ for (const [pair, neighbor] of adj) {
38373
+ if (position.has(neighbor)) continue;
38374
+ const d = DELTA[pair];
38375
+ if (!d) continue;
38376
+ let col = currPos.col + d[0];
38377
+ let row = currPos.row + d[1];
38378
+ const key = `${col},${row}`;
38379
+ if (occupied.has(key) && occupied.get(key) !== neighbor) {
38380
+ console.warn(`[gridPlacer] Cell collision at (${col},${row}), bumping "${neighbor}"`);
38381
+ let bump = row + 1;
38382
+ while (occupied.has(`${col},${bump}`)) bump++;
38383
+ row = bump;
38384
+ }
38385
+ position.set(neighbor, { col, row });
38386
+ occupied.set(`${col},${row}`, neighbor);
38387
+ queue2.push(neighbor);
38388
+ }
38389
+ }
38390
+ }
38391
+ const connected = /* @__PURE__ */ new Set([...edges2.map((e) => e.from), ...edges2.map((e) => e.to)]);
38392
+ const seed = nodes.find((n) => connected.has(n.id)) ?? nodes[0];
38393
+ bfs(seed.id, 0, 0);
38394
+ for (const n of nodes) {
38395
+ if (!position.has(n.id)) {
38396
+ const maxCol = position.size > 0 ? Math.max(...[...position.values()].map((p) => p.col)) + 2 : 0;
38397
+ bfs(n.id, maxCol, 0);
38398
+ }
38399
+ }
38400
+ if (position.size === 0) {
38401
+ nodes.forEach((n, i) => position.set(n.id, { col: i, row: 0 }));
38402
+ }
38403
+ const vals = [...position.values()];
38404
+ const minCol = Math.min(...vals.map((p) => p.col));
38405
+ const minRow = Math.min(...vals.map((p) => p.row));
38406
+ const result = /* @__PURE__ */ new Map();
38407
+ for (const [id, pos] of position) {
38408
+ result.set(id, { col: pos.col - minCol, row: pos.row - minRow });
38409
+ }
38410
+ return result;
38411
+ }
38412
+
38413
+ // src/diagrams/mermaid/architecture/layout.ts
38414
+ var ARROW_END_ID = "arch-arrow-end";
38415
+ var ARROW_START_ID = "arch-arrow-start";
38325
38416
  function port(r, side) {
38326
38417
  switch (side.toUpperCase()) {
38327
38418
  case "L":
@@ -38334,42 +38425,162 @@ function port(r, side) {
38334
38425
  return { x: r.x + r.width / 2, y: r.y + r.height };
38335
38426
  }
38336
38427
  }
38337
- function layoutArchitecture(ir, theme) {
38428
+ function sideToDir(side) {
38429
+ switch (side.toUpperCase()) {
38430
+ case "L":
38431
+ return "W";
38432
+ case "R":
38433
+ return "E";
38434
+ case "T":
38435
+ return "N";
38436
+ default:
38437
+ return "S";
38438
+ }
38439
+ }
38440
+ function groupsByDepth(groups) {
38441
+ const result = [];
38442
+ const added = /* @__PURE__ */ new Set();
38443
+ function add(g) {
38444
+ if (added.has(g.id)) return;
38445
+ if (g.parent) {
38446
+ const par = groups.find((pg) => pg.id === g.parent);
38447
+ if (par) add(par);
38448
+ }
38449
+ result.push(g);
38450
+ added.add(g.id);
38451
+ }
38452
+ for (const g of groups) add(g);
38453
+ return result;
38454
+ }
38455
+ function layoutArchitecture(ir, theme, options) {
38338
38456
  const { palette, typography, spacing } = theme;
38339
38457
  const p = pen(theme);
38340
38458
  const margin = spacing.diagramMargin;
38341
38459
  const font = typography.baseFontSize;
38460
+ const iconPacks = options?.icons;
38342
38461
  const svcW = 130, svcH = 56;
38343
- const nodes = ir.services.map((s) => ({ id: s.id, width: svcW, height: svcH }));
38344
- const edges2 = ir.edges.map((e) => ({ from: e.from, to: e.to }));
38345
- const laid = layeredLayout(nodes, edges2, { direction: "LR", layerGap: 90, nodeGap: 44, margin: margin + 26 });
38462
+ const jctW = 16, jctH = 16;
38463
+ const nodeSizes = /* @__PURE__ */ new Map();
38464
+ for (const s of ir.services) nodeSizes.set(s.id, { width: svcW, height: svcH });
38465
+ for (const j of ir.junctions) nodeSizes.set(j.id, { width: jctW, height: jctH });
38466
+ const colGap = 90, rowGap = 44;
38467
+ const gridCells = directionalGridPlacer(
38468
+ [...ir.services, ...ir.junctions],
38469
+ ir.edges
38470
+ );
38471
+ const positions = /* @__PURE__ */ new Map();
38472
+ for (const [id, cell] of gridCells) {
38473
+ positions.set(id, {
38474
+ x: cell.col * (svcW + colGap) + margin,
38475
+ y: cell.row * (svcH + rowGap) + margin
38476
+ });
38477
+ }
38478
+ for (const align of ir.aligns) {
38479
+ const coords = align.members.map((id) => positions.get(id)).filter((pos) => !!pos);
38480
+ if (coords.length < 2) continue;
38481
+ if (align.axis === "row") {
38482
+ const ys = coords.map((c) => c.y).sort((a, b) => a - b);
38483
+ const medY = ys[Math.floor(ys.length / 2)];
38484
+ for (const id of align.members) {
38485
+ const pos = positions.get(id);
38486
+ if (pos) pos.y = medY;
38487
+ }
38488
+ } else {
38489
+ const xs = coords.map((c) => c.x).sort((a, b) => a - b);
38490
+ const medX = xs[Math.floor(xs.length / 2)];
38491
+ for (const id of align.members) {
38492
+ const pos = positions.get(id);
38493
+ if (pos) pos.x = medX;
38494
+ }
38495
+ }
38496
+ }
38346
38497
  const titleH = ir.metadata.title ? typography.titleFontSize + 14 : 0;
38347
38498
  const yOff = titleH;
38348
38499
  const rectOf = (id) => {
38349
- const b = laid.boxes.get(id);
38350
- return b ? { x: b.x, y: b.y + yOff, width: b.width, height: b.height } : void 0;
38500
+ const pos = positions.get(id);
38501
+ const sz = nodeSizes.get(id);
38502
+ if (!pos || !sz) return void 0;
38503
+ return { x: pos.x, y: pos.y + yOff, width: sz.width, height: sz.height };
38504
+ };
38505
+ const groupRectCache = /* @__PURE__ */ new Map();
38506
+ const computeGroupRect = (gId) => {
38507
+ if (groupRectCache.has(gId)) return groupRectCache.get(gId);
38508
+ const pad = 20;
38509
+ const memberRects = [
38510
+ ...ir.services.filter((s) => s.group === gId).map((s) => rectOf(s.id)).filter((r) => !!r),
38511
+ ...ir.junctions.filter((j) => j.group === gId).map((j) => rectOf(j.id)).filter((r) => !!r),
38512
+ ...ir.groups.filter((g) => g.parent === gId).map((g) => computeGroupRect(g.id)).filter((r) => !!r)
38513
+ ];
38514
+ if (memberRects.length === 0) return void 0;
38515
+ const minX = Math.min(...memberRects.map((r) => r.x)) - pad;
38516
+ const minY = Math.min(...memberRects.map((r) => r.y)) - pad - 14;
38517
+ const maxX = Math.max(...memberRects.map((r) => r.x + r.width)) + pad;
38518
+ const maxY = Math.max(...memberRects.map((r) => r.y + r.height)) + pad;
38519
+ const rect = { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
38520
+ groupRectCache.set(gId, rect);
38521
+ return rect;
38351
38522
  };
38523
+ for (const g of ir.groups) computeGroupRect(g.id);
38352
38524
  const elements = [];
38353
- if (ir.metadata.title) elements.push(p.text(ir.metadata.title, margin, margin + typography.titleFontSize, typography.titleFontSize, palette.text, { weight: "bold" }));
38354
- ir.groups.forEach((g, gi) => {
38355
- const members = ir.services.filter((s) => s.group === g.id).map((s) => rectOf(s.id)).filter((r) => !!r);
38356
- if (members.length === 0) return;
38357
- const pad = 20;
38358
- const minX = Math.min(...members.map((r) => r.x)) - pad;
38359
- const minY = Math.min(...members.map((r) => r.y)) - pad - 14;
38360
- const maxX = Math.max(...members.map((r) => r.x + r.width)) + pad;
38361
- const maxY = Math.max(...members.map((r) => r.y + r.height)) + pad;
38525
+ if (ir.metadata.title) {
38526
+ elements.push(p.text(
38527
+ String(ir.metadata.title),
38528
+ margin,
38529
+ margin + typography.titleFontSize,
38530
+ typography.titleFontSize,
38531
+ palette.text,
38532
+ { weight: "bold" }
38533
+ ));
38534
+ }
38535
+ const orderedGroups = groupsByDepth(ir.groups);
38536
+ orderedGroups.forEach((g, gi) => {
38537
+ const r = computeGroupRect(g.id);
38538
+ if (!r) return;
38362
38539
  const hue = categoricalHue(gi);
38363
- elements.push(p.rect({ x: rhu(minX), y: rhu(minY), width: rhu(maxX - minX), height: rhu(maxY - minY) }, hue + "14", hue, 1.4, { rx: 10 }));
38364
- elements.push(p.text(g.label, rhu(minX + 12), rhu(minY + 16), typography.smallFontSize, hue, { weight: "bold" }));
38540
+ elements.push(p.rect(
38541
+ { x: rhu(r.x), y: rhu(r.y), width: rhu(r.width), height: rhu(r.height) },
38542
+ hue + "14",
38543
+ hue,
38544
+ 1.4,
38545
+ { rx: 10 }
38546
+ ));
38547
+ elements.push(p.text(
38548
+ g.label,
38549
+ rhu(r.x + 12),
38550
+ rhu(r.y + 16),
38551
+ typography.smallFontSize,
38552
+ hue,
38553
+ { weight: "bold" }
38554
+ ));
38365
38555
  });
38366
- const allBoxes = [...laid.boxes.values()];
38556
+ const allBoxes = [];
38557
+ for (const [id, pos] of positions) {
38558
+ const sz = nodeSizes.get(id);
38559
+ if (sz) allBoxes.push({ id, x: pos.x, y: pos.y, width: sz.width, height: sz.height });
38560
+ }
38367
38561
  for (const e of ir.edges) {
38368
- const a = rectOf(e.from), b = rectOf(e.to);
38369
- if (!a || !b) continue;
38370
- const pa = port(a, e.fromSide), pb = port(b, e.toSide);
38371
- const fromDir = e.fromSide.toUpperCase() === "L" ? "W" : e.fromSide.toUpperCase() === "R" ? "E" : e.fromSide.toUpperCase() === "T" ? "N" : "S";
38372
- const toDir = e.toSide.toUpperCase() === "L" ? "W" : e.toSide.toUpperCase() === "R" ? "E" : e.toSide.toUpperCase() === "T" ? "N" : "S";
38562
+ let fromRect = rectOf(e.from);
38563
+ if (!fromRect) continue;
38564
+ if (e.fromGroup) {
38565
+ const svc = ir.services.find((s) => s.id === e.from);
38566
+ if (svc?.group) {
38567
+ const gr = computeGroupRect(svc.group);
38568
+ if (gr) fromRect = gr;
38569
+ }
38570
+ }
38571
+ let toRect2 = rectOf(e.to);
38572
+ if (!toRect2) continue;
38573
+ if (e.toGroup) {
38574
+ const svc = ir.services.find((s) => s.id === e.to);
38575
+ if (svc?.group) {
38576
+ const gr = computeGroupRect(svc.group);
38577
+ if (gr) toRect2 = gr;
38578
+ }
38579
+ }
38580
+ const pa = port(fromRect, e.fromSide);
38581
+ const pb = port(toRect2, e.toSide);
38582
+ const fromDir = sideToDir(e.fromSide);
38583
+ const toDir = sideToDir(e.toSide);
38373
38584
  const obstacles = allBoxes.filter((bx) => bx.id !== e.from && bx.id !== e.to).map((bx) => ({ x: bx.x, y: bx.y + yOff, width: bx.width, height: bx.height }));
38374
38585
  const route = orthogonalRouter.route({
38375
38586
  from: pa,
@@ -38380,28 +38591,106 @@ function layoutArchitecture(ir, theme) {
38380
38591
  fromDir,
38381
38592
  toDir
38382
38593
  });
38383
- elements.push(p.path(route.path, palette.primary, 1.6, { markerEnd: ARROW_ID8 }));
38594
+ const pathOpts = {};
38595
+ if (e.arrowRight) pathOpts.markerEnd = ARROW_END_ID;
38596
+ if (e.arrowLeft) pathOpts.markerStart = ARROW_START_ID;
38597
+ elements.push(p.path(route.path, palette.primary, 1.6, pathOpts));
38384
38598
  }
38599
+ const warnedIcons = /* @__PURE__ */ new Set();
38385
38600
  ir.services.forEach((s, i) => {
38386
38601
  const r = rectOf(s.id);
38602
+ if (!r) return;
38387
38603
  const hue = categoricalHue(i);
38388
- elements.push(p.rect({ x: rhu(r.x), y: rhu(r.y), width: rhu(r.width), height: rhu(r.height) }, palette.surface, palette.border, 1.4, { rx: 8 }));
38389
- elements.push(p.rect({ x: rhu(r.x), y: rhu(r.y), width: rhu(r.width), height: 8 }, hue, hue, 0, { rx: 4 }));
38390
- elements.push(...iconGlyph(p, s.icon, r.x + r.width / 2, r.y + 24, hue, palette));
38391
- elements.push(p.text(s.label, rhuInt(r.x + r.width / 2), rhu(r.y + r.height - 9), font, palette.text, { weight: "bold", anchor: "middle" }));
38604
+ elements.push(p.rect(
38605
+ { x: rhu(r.x), y: rhu(r.y), width: rhu(r.width), height: rhu(r.height) },
38606
+ palette.surface,
38607
+ palette.border,
38608
+ 1.4,
38609
+ { rx: 8 }
38610
+ ));
38611
+ elements.push(p.rect(
38612
+ { x: rhu(r.x), y: rhu(r.y), width: rhu(r.width), height: 8 },
38613
+ hue,
38614
+ hue,
38615
+ 0,
38616
+ { rx: 4 }
38617
+ ));
38618
+ const iconElems = resolveIconElems(p, s.icon, r.x + r.width / 2, r.y + 24, hue, palette, iconPacks, warnedIcons);
38619
+ elements.push(...iconElems);
38620
+ elements.push(p.text(
38621
+ s.label,
38622
+ rhuInt(r.x + r.width / 2),
38623
+ rhu(r.y + r.height - 9),
38624
+ font,
38625
+ palette.text,
38626
+ { weight: "bold", anchor: "middle" }
38627
+ ));
38392
38628
  });
38393
- const allR = ir.services.map((s) => rectOf(s.id));
38394
- const totalW = rhuInt(Math.max(...allR.map((r) => r.x + r.width)) + margin + 26);
38395
- const totalH = rhuInt(Math.max(...allR.map((r) => r.y + r.height)) + margin + 26);
38396
- const defs = [`<marker id="${ARROW_ID8}" markerWidth="10" markerHeight="8" refX="9" refY="4" orient="auto"><polygon points="0 0, 10 4, 0 8" fill="${palette.primary}" /></marker>`];
38629
+ ir.junctions.forEach((j) => {
38630
+ const r = rectOf(j.id);
38631
+ if (!r) return;
38632
+ const cx = rhu(r.x + r.width / 2);
38633
+ const cy = rhu(r.y + r.height / 2);
38634
+ const R = 4;
38635
+ elements.push(p.circle({ x: cx, y: cy }, R, palette.primary, palette.primary, 0));
38636
+ elements.push(p.path(
38637
+ `M ${rhu(cx - R)} ${cy} L ${rhu(cx + R)} ${cy} M ${cx} ${rhu(cy - R)} L ${cx} ${rhu(cy + R)}`,
38638
+ palette.primary,
38639
+ 1.6
38640
+ ));
38641
+ });
38642
+ const allNodeRects = [
38643
+ ...ir.services.map((s) => rectOf(s.id)).filter((r) => !!r),
38644
+ ...ir.junctions.map((j) => rectOf(j.id)).filter((r) => !!r)
38645
+ ];
38646
+ const allGroupRects = [...groupRectCache.values()];
38647
+ const allRects = [...allNodeRects, ...allGroupRects];
38648
+ if (allRects.length === 0) {
38649
+ const scene2 = applyOverlays(
38650
+ { viewBox: { x: 0, y: 0, width: 200, height: 100 }, background: palette.background, elements, defs: [] },
38651
+ ir.overlays,
38652
+ theme
38653
+ );
38654
+ return { scene: scene2, anchors: {} };
38655
+ }
38656
+ const totalW = rhuInt(Math.max(...allRects.map((r) => r.x + r.width)) + margin + 26);
38657
+ const totalH = rhuInt(Math.max(...allRects.map((r) => r.y + r.height)) + margin + 26);
38658
+ const vbX = rhuInt(Math.min(0, ...allRects.map((r) => r.x)) - margin);
38659
+ const vbY = rhuInt(Math.min(0, ...allRects.map((r) => r.y)) - margin);
38660
+ const defs = [
38661
+ `<marker id="${ARROW_END_ID}" markerWidth="10" markerHeight="8" refX="9" refY="4" orient="auto"><polygon points="0 0, 10 4, 0 8" fill="${palette.primary}" /></marker>`,
38662
+ `<marker id="${ARROW_START_ID}" markerWidth="10" markerHeight="8" refX="1" refY="4" orient="auto-start-reverse"><polygon points="0 0, 10 4, 0 8" fill="${palette.primary}" /></marker>`
38663
+ ];
38397
38664
  const scene = applyOverlays({
38398
- viewBox: { x: 0, y: 0, width: totalW, height: totalH },
38665
+ viewBox: { x: vbX, y: vbY, width: totalW - vbX, height: totalH - vbY },
38399
38666
  background: palette.background,
38400
38667
  elements,
38401
38668
  defs
38402
38669
  }, ir.overlays, theme);
38403
38670
  return { scene, anchors: {} };
38404
38671
  }
38672
+ function resolveIconElems(p, icon, cx, cy, hue, palette, iconPacks, warnedIcons) {
38673
+ if (icon.includes(":") && iconPacks) {
38674
+ const ref = parseIconRef(icon);
38675
+ if (ref.ok) {
38676
+ const resolved = resolveIcon(ref.value, iconPacks);
38677
+ if (resolved.ok) {
38678
+ const size = 24;
38679
+ return [p.icon(resolved.value, rhu(cx - size / 2), rhu(cy - size / 2), size, { color: hue })];
38680
+ }
38681
+ }
38682
+ if (!warnedIcons.has(icon)) {
38683
+ warnedIcons.add(icon);
38684
+ console.warn(`[architecture] icon "${icon}" could not be resolved \u2014 falling back to glyph.`);
38685
+ }
38686
+ } else if (icon.includes(":") && !iconPacks) {
38687
+ if (!warnedIcons.has(icon)) {
38688
+ warnedIcons.add(icon);
38689
+ console.warn(`[architecture] icon "${icon}" is an iconify token but no icon packs were loaded.`);
38690
+ }
38691
+ }
38692
+ return iconGlyph(p, icon, cx, cy, hue, palette);
38693
+ }
38405
38694
  function iconGlyph(p, icon, cx, cy, hue, palette) {
38406
38695
  const name = icon.toLowerCase();
38407
38696
  const out = [];
@@ -38426,7 +38715,7 @@ function iconGlyph(p, icon, cx, cy, hue, palette) {
38426
38715
  return out;
38427
38716
  }
38428
38717
 
38429
- // src/diagrams/triton/architecture/parser.js
38718
+ // src/diagrams/mermaid/architecture/parser.js
38430
38719
  function peg$subclass21(child, parent) {
38431
38720
  function C() {
38432
38721
  this.constructor = child;
@@ -38562,14 +38851,20 @@ function peg$parse21(input, options) {
38562
38851
  var peg$c3 = ")";
38563
38852
  var peg$c4 = "[";
38564
38853
  var peg$c5 = "]";
38565
- var peg$c6 = "service";
38566
- var peg$c7 = "in";
38567
- var peg$c8 = ":";
38568
- var peg$c9 = "-->";
38569
- var peg$c10 = "--";
38854
+ var peg$c6 = "in";
38855
+ var peg$c7 = "service";
38856
+ var peg$c8 = "junction";
38857
+ var peg$c9 = ":";
38858
+ var peg$c10 = "{group}";
38570
38859
  var peg$c11 = "<-->";
38571
- var peg$c12 = "\r";
38572
- var peg$c13 = "\n";
38860
+ var peg$c12 = "-->";
38861
+ var peg$c13 = "<--";
38862
+ var peg$c14 = "--";
38863
+ var peg$c15 = "align";
38864
+ var peg$c16 = "row";
38865
+ var peg$c17 = "column";
38866
+ var peg$c18 = "\r";
38867
+ var peg$c19 = "\n";
38573
38868
  var peg$r0 = /^[ \t]/;
38574
38869
  var peg$r1 = /^[^)\n]/;
38575
38870
  var peg$r2 = /^[^\]\n]/;
@@ -38585,48 +38880,96 @@ function peg$parse21(input, options) {
38585
38880
  var peg$e6 = peg$literalExpectation("[", false);
38586
38881
  var peg$e7 = peg$classExpectation(["]", "\n"], true, false);
38587
38882
  var peg$e8 = peg$literalExpectation("]", false);
38588
- var peg$e9 = peg$literalExpectation("service", true);
38589
- var peg$e10 = peg$literalExpectation("in", true);
38590
- var peg$e11 = peg$literalExpectation(":", false);
38591
- var peg$e12 = peg$literalExpectation("-->", false);
38592
- var peg$e13 = peg$literalExpectation("--", false);
38883
+ var peg$e9 = peg$literalExpectation("in", true);
38884
+ var peg$e10 = peg$literalExpectation("service", true);
38885
+ var peg$e11 = peg$literalExpectation("junction", true);
38886
+ var peg$e12 = peg$literalExpectation(":", false);
38887
+ var peg$e13 = peg$literalExpectation("{group}", false);
38593
38888
  var peg$e14 = peg$literalExpectation("<-->", false);
38594
- var peg$e15 = peg$classExpectation(["L", "R", "T", "B", "l", "r", "t", "b"], false, false);
38595
- var peg$e16 = peg$classExpectation(["\n"], true, false);
38596
- var peg$e17 = peg$classExpectation([["A", "Z"], ["a", "z"], ["0", "9"], "_"], false, false);
38597
- var peg$e18 = peg$literalExpectation("\r", false);
38598
- var peg$e19 = peg$literalExpectation("\n", false);
38599
- var peg$e20 = peg$anyExpectation();
38889
+ var peg$e15 = peg$literalExpectation("-->", false);
38890
+ var peg$e16 = peg$literalExpectation("<--", false);
38891
+ var peg$e17 = peg$literalExpectation("--", false);
38892
+ var peg$e18 = peg$literalExpectation("align", true);
38893
+ var peg$e19 = peg$literalExpectation("row", true);
38894
+ var peg$e20 = peg$literalExpectation("column", true);
38895
+ var peg$e21 = peg$classExpectation(["L", "R", "T", "B", "l", "r", "t", "b"], false, false);
38896
+ var peg$e22 = peg$classExpectation(["\n"], true, false);
38897
+ var peg$e23 = peg$classExpectation([["A", "Z"], ["a", "z"], ["0", "9"], "_"], false, false);
38898
+ var peg$e24 = peg$literalExpectation("\r", false);
38899
+ var peg$e25 = peg$literalExpectation("\n", false);
38900
+ var peg$e26 = peg$anyExpectation();
38600
38901
  var peg$f0 = function(lines2) {
38601
38902
  const groups = [];
38602
38903
  const services = [];
38904
+ const junctions = [];
38603
38905
  const edges2 = [];
38906
+ const aligns = [];
38604
38907
  let curGroup, curIndent = -1;
38605
38908
  for (const l of lines2.filter(Boolean)) {
38606
38909
  if (l.t === "group") {
38607
- groups.push({ id: l.id, label: l.label, icon: l.icon });
38910
+ groups.push({ id: l.id, label: l.label, icon: l.icon, ...l.inGroup ? { parent: l.inGroup } : {} });
38608
38911
  curGroup = l.id;
38609
38912
  curIndent = l.indent;
38610
38913
  } else if (l.t === "service") {
38611
38914
  const group = l.inGroup || (l.indent > curIndent && curGroup ? curGroup : void 0);
38612
38915
  services.push({ id: l.id, label: l.label, icon: l.icon, ...group ? { group } : {} });
38613
- } else if (l.t === "edge") edges2.push({ from: l.from, fromSide: l.fromSide, to: l.to, toSide: l.toSide });
38916
+ } else if (l.t === "junction") {
38917
+ const group = l.inGroup || (l.indent > curIndent && curGroup ? curGroup : void 0);
38918
+ junctions.push({ id: l.id, ...group ? { group } : {} });
38919
+ } else if (l.t === "edge") {
38920
+ edges2.push({ from: l.from, fromSide: l.fromSide, fromGroup: l.fromGroup, to: l.to, toSide: l.toSide, toGroup: l.toGroup, arrowLeft: l.arrowLeft, arrowRight: l.arrowRight });
38921
+ } else if (l.t === "align") {
38922
+ aligns.push({ axis: l.axis, members: l.members });
38923
+ }
38614
38924
  }
38615
- return { version: "1.0", metadata: {}, groups, services, edges: edges2 };
38925
+ return { version: "1.0", metadata: {}, groups, services, junctions, edges: edges2, aligns };
38926
+ };
38927
+ var peg$f1 = function(ind, id, icon, label, g) {
38928
+ return g;
38616
38929
  };
38617
- var peg$f1 = function(ind, id, icon, label) {
38618
- return { t: "group", indent: ind.length, id, icon: icon.trim(), label: label.trim() };
38930
+ var peg$f2 = function(ind, id, icon, label, inG) {
38931
+ return { t: "group", indent: ind.length, id, icon: icon.trim(), label: label.trim(), inGroup: inG || void 0 };
38619
38932
  };
38620
- var peg$f2 = function(ind, id, icon, label, g) {
38933
+ var peg$f3 = function(ind, id, icon, label, g) {
38621
38934
  return g;
38622
38935
  };
38623
- var peg$f3 = function(ind, id, icon, label, inG) {
38936
+ var peg$f4 = function(ind, id, icon, label, inG) {
38624
38937
  return { t: "service", indent: ind.length, id, icon: icon.trim(), label: label.trim(), inGroup: inG || void 0 };
38625
38938
  };
38626
- var peg$f4 = function(from, fromSide, toSide, to) {
38627
- return { t: "edge", from, fromSide, to, toSide };
38939
+ var peg$f5 = function(ind, id, g) {
38940
+ return g;
38628
38941
  };
38629
- var peg$f5 = function() {
38942
+ var peg$f6 = function(ind, id, inG) {
38943
+ return { t: "junction", indent: ind.length, id, inGroup: inG || void 0 };
38944
+ };
38945
+ var peg$f7 = function(fromEp, fromSide, arrow, toSide, toEp) {
38946
+ return { t: "edge", from: fromEp.id, fromSide, fromGroup: fromEp.grp, to: toEp.id, toSide, toGroup: toEp.grp, arrowLeft: arrow.left, arrowRight: arrow.right };
38947
+ };
38948
+ var peg$f8 = function(id) {
38949
+ return true;
38950
+ };
38951
+ var peg$f9 = function(id, grp) {
38952
+ return { id, grp: grp === true };
38953
+ };
38954
+ var peg$f10 = function() {
38955
+ return { left: true, right: true };
38956
+ };
38957
+ var peg$f11 = function() {
38958
+ return { left: false, right: true };
38959
+ };
38960
+ var peg$f12 = function() {
38961
+ return { left: true, right: false };
38962
+ };
38963
+ var peg$f13 = function() {
38964
+ return { left: false, right: false };
38965
+ };
38966
+ var peg$f14 = function(axis, head, id) {
38967
+ return id;
38968
+ };
38969
+ var peg$f15 = function(axis, head, tail) {
38970
+ return { t: "align", axis: axis.toLowerCase(), members: [head, ...tail] };
38971
+ };
38972
+ var peg$f16 = function() {
38630
38973
  return null;
38631
38974
  };
38632
38975
  var peg$currPos = options.peg$currPos | 0;
@@ -38800,16 +39143,22 @@ function peg$parse21(input, options) {
38800
39143
  if (s0 === peg$FAILED) {
38801
39144
  s0 = peg$parseServiceLine();
38802
39145
  if (s0 === peg$FAILED) {
38803
- s0 = peg$parseEdgeLine();
39146
+ s0 = peg$parseJunctionLine();
38804
39147
  if (s0 === peg$FAILED) {
38805
- s0 = peg$parseBlankLine();
39148
+ s0 = peg$parseAlignLine();
39149
+ if (s0 === peg$FAILED) {
39150
+ s0 = peg$parseEdgeLine();
39151
+ if (s0 === peg$FAILED) {
39152
+ s0 = peg$parseBlankLine();
39153
+ }
39154
+ }
38806
39155
  }
38807
39156
  }
38808
39157
  }
38809
39158
  return s0;
38810
39159
  }
38811
39160
  function peg$parseGroupLine() {
38812
- var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12;
39161
+ var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15;
38813
39162
  s0 = peg$currPos;
38814
39163
  s1 = peg$currPos;
38815
39164
  s2 = [];
@@ -38937,11 +39286,49 @@ function peg$parse21(input, options) {
38937
39286
  }
38938
39287
  }
38939
39288
  if (s10 !== peg$FAILED) {
38940
- s11 = peg$parseRestIgnore();
38941
- s12 = peg$parseLineEnd();
39289
+ s11 = peg$currPos;
39290
+ s12 = peg$parse__();
38942
39291
  if (s12 !== peg$FAILED) {
39292
+ s13 = input.substr(peg$currPos, 2);
39293
+ if (s13.toLowerCase() === peg$c6) {
39294
+ peg$currPos += 2;
39295
+ } else {
39296
+ s13 = peg$FAILED;
39297
+ if (peg$silentFails === 0) {
39298
+ peg$fail(peg$e9);
39299
+ }
39300
+ }
39301
+ if (s13 !== peg$FAILED) {
39302
+ s14 = peg$parse__();
39303
+ if (s14 !== peg$FAILED) {
39304
+ s15 = peg$parseIdent();
39305
+ if (s15 !== peg$FAILED) {
39306
+ peg$savedPos = s11;
39307
+ s11 = peg$f1(s1, s4, s6, s9, s15);
39308
+ } else {
39309
+ peg$currPos = s11;
39310
+ s11 = peg$FAILED;
39311
+ }
39312
+ } else {
39313
+ peg$currPos = s11;
39314
+ s11 = peg$FAILED;
39315
+ }
39316
+ } else {
39317
+ peg$currPos = s11;
39318
+ s11 = peg$FAILED;
39319
+ }
39320
+ } else {
39321
+ peg$currPos = s11;
39322
+ s11 = peg$FAILED;
39323
+ }
39324
+ if (s11 === peg$FAILED) {
39325
+ s11 = null;
39326
+ }
39327
+ s12 = peg$parseRestIgnore();
39328
+ s13 = peg$parseLineEnd();
39329
+ if (s13 !== peg$FAILED) {
38943
39330
  peg$savedPos = s0;
38944
- s0 = peg$f1(s1, s4, s6, s9);
39331
+ s0 = peg$f2(s1, s4, s6, s9, s11);
38945
39332
  } else {
38946
39333
  peg$currPos = s0;
38947
39334
  s0 = peg$FAILED;
@@ -39004,12 +39391,12 @@ function peg$parse21(input, options) {
39004
39391
  }
39005
39392
  s1 = input.substring(s1, peg$currPos);
39006
39393
  s2 = input.substr(peg$currPos, 7);
39007
- if (s2.toLowerCase() === peg$c6) {
39394
+ if (s2.toLowerCase() === peg$c7) {
39008
39395
  peg$currPos += 7;
39009
39396
  } else {
39010
39397
  s2 = peg$FAILED;
39011
39398
  if (peg$silentFails === 0) {
39012
- peg$fail(peg$e9);
39399
+ peg$fail(peg$e10);
39013
39400
  }
39014
39401
  }
39015
39402
  if (s2 !== peg$FAILED) {
@@ -39109,12 +39496,12 @@ function peg$parse21(input, options) {
39109
39496
  s12 = peg$parse__();
39110
39497
  if (s12 !== peg$FAILED) {
39111
39498
  s13 = input.substr(peg$currPos, 2);
39112
- if (s13.toLowerCase() === peg$c7) {
39499
+ if (s13.toLowerCase() === peg$c6) {
39113
39500
  peg$currPos += 2;
39114
39501
  } else {
39115
39502
  s13 = peg$FAILED;
39116
39503
  if (peg$silentFails === 0) {
39117
- peg$fail(peg$e10);
39504
+ peg$fail(peg$e9);
39118
39505
  }
39119
39506
  }
39120
39507
  if (s13 !== peg$FAILED) {
@@ -39123,7 +39510,7 @@ function peg$parse21(input, options) {
39123
39510
  s15 = peg$parseIdent();
39124
39511
  if (s15 !== peg$FAILED) {
39125
39512
  peg$savedPos = s11;
39126
- s11 = peg$f2(s1, s4, s6, s9, s15);
39513
+ s11 = peg$f3(s1, s4, s6, s9, s15);
39127
39514
  } else {
39128
39515
  peg$currPos = s11;
39129
39516
  s11 = peg$FAILED;
@@ -39147,7 +39534,7 @@ function peg$parse21(input, options) {
39147
39534
  s13 = peg$parseLineEnd();
39148
39535
  if (s13 !== peg$FAILED) {
39149
39536
  peg$savedPos = s0;
39150
- s0 = peg$f3(s1, s4, s6, s9, s11);
39537
+ s0 = peg$f4(s1, s4, s6, s9, s11);
39151
39538
  } else {
39152
39539
  peg$currPos = s0;
39153
39540
  s0 = peg$FAILED;
@@ -39182,77 +39569,149 @@ function peg$parse21(input, options) {
39182
39569
  }
39183
39570
  return s0;
39184
39571
  }
39185
- function peg$parseEdgeLine() {
39186
- var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12;
39572
+ function peg$parseJunctionLine() {
39573
+ var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
39187
39574
  s0 = peg$currPos;
39188
- s1 = peg$parse_();
39189
- s2 = peg$parseIdent();
39190
- if (s2 !== peg$FAILED) {
39191
- if (input.charCodeAt(peg$currPos) === 58) {
39192
- s3 = peg$c8;
39575
+ s1 = peg$currPos;
39576
+ s2 = [];
39577
+ s3 = input.charAt(peg$currPos);
39578
+ if (peg$r0.test(s3)) {
39579
+ peg$currPos++;
39580
+ } else {
39581
+ s3 = peg$FAILED;
39582
+ if (peg$silentFails === 0) {
39583
+ peg$fail(peg$e1);
39584
+ }
39585
+ }
39586
+ while (s3 !== peg$FAILED) {
39587
+ s2.push(s3);
39588
+ s3 = input.charAt(peg$currPos);
39589
+ if (peg$r0.test(s3)) {
39193
39590
  peg$currPos++;
39194
39591
  } else {
39195
39592
  s3 = peg$FAILED;
39196
39593
  if (peg$silentFails === 0) {
39197
- peg$fail(peg$e11);
39594
+ peg$fail(peg$e1);
39198
39595
  }
39199
39596
  }
39597
+ }
39598
+ s1 = input.substring(s1, peg$currPos);
39599
+ s2 = input.substr(peg$currPos, 8);
39600
+ if (s2.toLowerCase() === peg$c8) {
39601
+ peg$currPos += 8;
39602
+ } else {
39603
+ s2 = peg$FAILED;
39604
+ if (peg$silentFails === 0) {
39605
+ peg$fail(peg$e11);
39606
+ }
39607
+ }
39608
+ if (s2 !== peg$FAILED) {
39609
+ s3 = peg$parse__();
39200
39610
  if (s3 !== peg$FAILED) {
39201
- s4 = peg$parseSide();
39611
+ s4 = peg$parseIdent();
39202
39612
  if (s4 !== peg$FAILED) {
39203
- s5 = peg$parse_();
39204
- if (input.substr(peg$currPos, 3) === peg$c9) {
39205
- s6 = peg$c9;
39206
- peg$currPos += 3;
39207
- } else {
39208
- s6 = peg$FAILED;
39209
- if (peg$silentFails === 0) {
39210
- peg$fail(peg$e12);
39211
- }
39212
- }
39213
- if (s6 === peg$FAILED) {
39214
- if (input.substr(peg$currPos, 2) === peg$c10) {
39215
- s6 = peg$c10;
39613
+ s5 = peg$currPos;
39614
+ s6 = peg$parse__();
39615
+ if (s6 !== peg$FAILED) {
39616
+ s7 = input.substr(peg$currPos, 2);
39617
+ if (s7.toLowerCase() === peg$c6) {
39216
39618
  peg$currPos += 2;
39217
39619
  } else {
39218
- s6 = peg$FAILED;
39620
+ s7 = peg$FAILED;
39219
39621
  if (peg$silentFails === 0) {
39220
- peg$fail(peg$e13);
39622
+ peg$fail(peg$e9);
39221
39623
  }
39222
39624
  }
39223
- if (s6 === peg$FAILED) {
39224
- if (input.substr(peg$currPos, 4) === peg$c11) {
39225
- s6 = peg$c11;
39226
- peg$currPos += 4;
39227
- } else {
39228
- s6 = peg$FAILED;
39229
- if (peg$silentFails === 0) {
39230
- peg$fail(peg$e14);
39625
+ if (s7 !== peg$FAILED) {
39626
+ s8 = peg$parse__();
39627
+ if (s8 !== peg$FAILED) {
39628
+ s9 = peg$parseIdent();
39629
+ if (s9 !== peg$FAILED) {
39630
+ peg$savedPos = s5;
39631
+ s5 = peg$f5(s1, s4, s9);
39632
+ } else {
39633
+ peg$currPos = s5;
39634
+ s5 = peg$FAILED;
39231
39635
  }
39636
+ } else {
39637
+ peg$currPos = s5;
39638
+ s5 = peg$FAILED;
39232
39639
  }
39640
+ } else {
39641
+ peg$currPos = s5;
39642
+ s5 = peg$FAILED;
39233
39643
  }
39644
+ } else {
39645
+ peg$currPos = s5;
39646
+ s5 = peg$FAILED;
39647
+ }
39648
+ if (s5 === peg$FAILED) {
39649
+ s5 = null;
39650
+ }
39651
+ s6 = peg$parseRestIgnore();
39652
+ s7 = peg$parseLineEnd();
39653
+ if (s7 !== peg$FAILED) {
39654
+ peg$savedPos = s0;
39655
+ s0 = peg$f6(s1, s4, s5);
39656
+ } else {
39657
+ peg$currPos = s0;
39658
+ s0 = peg$FAILED;
39234
39659
  }
39660
+ } else {
39661
+ peg$currPos = s0;
39662
+ s0 = peg$FAILED;
39663
+ }
39664
+ } else {
39665
+ peg$currPos = s0;
39666
+ s0 = peg$FAILED;
39667
+ }
39668
+ } else {
39669
+ peg$currPos = s0;
39670
+ s0 = peg$FAILED;
39671
+ }
39672
+ return s0;
39673
+ }
39674
+ function peg$parseEdgeLine() {
39675
+ var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12;
39676
+ s0 = peg$currPos;
39677
+ s1 = peg$parse_();
39678
+ s2 = peg$parseEdgeEndpoint();
39679
+ if (s2 !== peg$FAILED) {
39680
+ if (input.charCodeAt(peg$currPos) === 58) {
39681
+ s3 = peg$c9;
39682
+ peg$currPos++;
39683
+ } else {
39684
+ s3 = peg$FAILED;
39685
+ if (peg$silentFails === 0) {
39686
+ peg$fail(peg$e12);
39687
+ }
39688
+ }
39689
+ if (s3 !== peg$FAILED) {
39690
+ s4 = peg$parseSide();
39691
+ if (s4 !== peg$FAILED) {
39692
+ s5 = peg$parse_();
39693
+ s6 = peg$parseArrow();
39235
39694
  if (s6 !== peg$FAILED) {
39236
39695
  s7 = peg$parse_();
39237
39696
  s8 = peg$parseSide();
39238
39697
  if (s8 !== peg$FAILED) {
39239
39698
  if (input.charCodeAt(peg$currPos) === 58) {
39240
- s9 = peg$c8;
39699
+ s9 = peg$c9;
39241
39700
  peg$currPos++;
39242
39701
  } else {
39243
39702
  s9 = peg$FAILED;
39244
39703
  if (peg$silentFails === 0) {
39245
- peg$fail(peg$e11);
39704
+ peg$fail(peg$e12);
39246
39705
  }
39247
39706
  }
39248
39707
  if (s9 !== peg$FAILED) {
39249
- s10 = peg$parseIdent();
39708
+ s10 = peg$parseEdgeEndpoint();
39250
39709
  if (s10 !== peg$FAILED) {
39251
39710
  s11 = peg$parseRestIgnore();
39252
39711
  s12 = peg$parseLineEnd();
39253
39712
  if (s12 !== peg$FAILED) {
39254
39713
  peg$savedPos = s0;
39255
- s0 = peg$f4(s2, s4, s8, s10);
39714
+ s0 = peg$f7(s2, s4, s6, s8, s10);
39256
39715
  } else {
39257
39716
  peg$currPos = s0;
39258
39717
  s0 = peg$FAILED;
@@ -39287,6 +39746,222 @@ function peg$parse21(input, options) {
39287
39746
  }
39288
39747
  return s0;
39289
39748
  }
39749
+ function peg$parseEdgeEndpoint() {
39750
+ var s0, s1, s2, s3;
39751
+ s0 = peg$currPos;
39752
+ s1 = peg$parseIdent();
39753
+ if (s1 !== peg$FAILED) {
39754
+ s2 = peg$currPos;
39755
+ if (input.substr(peg$currPos, 7) === peg$c10) {
39756
+ s3 = peg$c10;
39757
+ peg$currPos += 7;
39758
+ } else {
39759
+ s3 = peg$FAILED;
39760
+ if (peg$silentFails === 0) {
39761
+ peg$fail(peg$e13);
39762
+ }
39763
+ }
39764
+ if (s3 !== peg$FAILED) {
39765
+ peg$savedPos = s2;
39766
+ s3 = peg$f8(s1);
39767
+ }
39768
+ s2 = s3;
39769
+ if (s2 === peg$FAILED) {
39770
+ s2 = null;
39771
+ }
39772
+ peg$savedPos = s0;
39773
+ s0 = peg$f9(s1, s2);
39774
+ } else {
39775
+ peg$currPos = s0;
39776
+ s0 = peg$FAILED;
39777
+ }
39778
+ return s0;
39779
+ }
39780
+ function peg$parseArrow() {
39781
+ var s0, s1;
39782
+ s0 = peg$currPos;
39783
+ if (input.substr(peg$currPos, 4) === peg$c11) {
39784
+ s1 = peg$c11;
39785
+ peg$currPos += 4;
39786
+ } else {
39787
+ s1 = peg$FAILED;
39788
+ if (peg$silentFails === 0) {
39789
+ peg$fail(peg$e14);
39790
+ }
39791
+ }
39792
+ if (s1 !== peg$FAILED) {
39793
+ peg$savedPos = s0;
39794
+ s1 = peg$f10();
39795
+ }
39796
+ s0 = s1;
39797
+ if (s0 === peg$FAILED) {
39798
+ s0 = peg$currPos;
39799
+ if (input.substr(peg$currPos, 3) === peg$c12) {
39800
+ s1 = peg$c12;
39801
+ peg$currPos += 3;
39802
+ } else {
39803
+ s1 = peg$FAILED;
39804
+ if (peg$silentFails === 0) {
39805
+ peg$fail(peg$e15);
39806
+ }
39807
+ }
39808
+ if (s1 !== peg$FAILED) {
39809
+ peg$savedPos = s0;
39810
+ s1 = peg$f11();
39811
+ }
39812
+ s0 = s1;
39813
+ if (s0 === peg$FAILED) {
39814
+ s0 = peg$currPos;
39815
+ if (input.substr(peg$currPos, 3) === peg$c13) {
39816
+ s1 = peg$c13;
39817
+ peg$currPos += 3;
39818
+ } else {
39819
+ s1 = peg$FAILED;
39820
+ if (peg$silentFails === 0) {
39821
+ peg$fail(peg$e16);
39822
+ }
39823
+ }
39824
+ if (s1 !== peg$FAILED) {
39825
+ peg$savedPos = s0;
39826
+ s1 = peg$f12();
39827
+ }
39828
+ s0 = s1;
39829
+ if (s0 === peg$FAILED) {
39830
+ s0 = peg$currPos;
39831
+ if (input.substr(peg$currPos, 2) === peg$c14) {
39832
+ s1 = peg$c14;
39833
+ peg$currPos += 2;
39834
+ } else {
39835
+ s1 = peg$FAILED;
39836
+ if (peg$silentFails === 0) {
39837
+ peg$fail(peg$e17);
39838
+ }
39839
+ }
39840
+ if (s1 !== peg$FAILED) {
39841
+ peg$savedPos = s0;
39842
+ s1 = peg$f13();
39843
+ }
39844
+ s0 = s1;
39845
+ }
39846
+ }
39847
+ }
39848
+ return s0;
39849
+ }
39850
+ function peg$parseAlignLine() {
39851
+ var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10;
39852
+ s0 = peg$currPos;
39853
+ s1 = peg$parse_();
39854
+ s2 = input.substr(peg$currPos, 5);
39855
+ if (s2.toLowerCase() === peg$c15) {
39856
+ peg$currPos += 5;
39857
+ } else {
39858
+ s2 = peg$FAILED;
39859
+ if (peg$silentFails === 0) {
39860
+ peg$fail(peg$e18);
39861
+ }
39862
+ }
39863
+ if (s2 !== peg$FAILED) {
39864
+ s3 = peg$parse__();
39865
+ if (s3 !== peg$FAILED) {
39866
+ s4 = input.substr(peg$currPos, 3);
39867
+ if (s4.toLowerCase() === peg$c16) {
39868
+ peg$currPos += 3;
39869
+ } else {
39870
+ s4 = peg$FAILED;
39871
+ if (peg$silentFails === 0) {
39872
+ peg$fail(peg$e19);
39873
+ }
39874
+ }
39875
+ if (s4 === peg$FAILED) {
39876
+ s4 = input.substr(peg$currPos, 6);
39877
+ if (s4.toLowerCase() === peg$c17) {
39878
+ peg$currPos += 6;
39879
+ } else {
39880
+ s4 = peg$FAILED;
39881
+ if (peg$silentFails === 0) {
39882
+ peg$fail(peg$e20);
39883
+ }
39884
+ }
39885
+ }
39886
+ if (s4 !== peg$FAILED) {
39887
+ s5 = peg$parse__();
39888
+ if (s5 !== peg$FAILED) {
39889
+ s6 = peg$parseIdent();
39890
+ if (s6 !== peg$FAILED) {
39891
+ s7 = [];
39892
+ s8 = peg$currPos;
39893
+ s9 = peg$parse__();
39894
+ if (s9 !== peg$FAILED) {
39895
+ s10 = peg$parseIdent();
39896
+ if (s10 !== peg$FAILED) {
39897
+ peg$savedPos = s8;
39898
+ s8 = peg$f14(s4, s6, s10);
39899
+ } else {
39900
+ peg$currPos = s8;
39901
+ s8 = peg$FAILED;
39902
+ }
39903
+ } else {
39904
+ peg$currPos = s8;
39905
+ s8 = peg$FAILED;
39906
+ }
39907
+ if (s8 !== peg$FAILED) {
39908
+ while (s8 !== peg$FAILED) {
39909
+ s7.push(s8);
39910
+ s8 = peg$currPos;
39911
+ s9 = peg$parse__();
39912
+ if (s9 !== peg$FAILED) {
39913
+ s10 = peg$parseIdent();
39914
+ if (s10 !== peg$FAILED) {
39915
+ peg$savedPos = s8;
39916
+ s8 = peg$f14(s4, s6, s10);
39917
+ } else {
39918
+ peg$currPos = s8;
39919
+ s8 = peg$FAILED;
39920
+ }
39921
+ } else {
39922
+ peg$currPos = s8;
39923
+ s8 = peg$FAILED;
39924
+ }
39925
+ }
39926
+ } else {
39927
+ s7 = peg$FAILED;
39928
+ }
39929
+ if (s7 !== peg$FAILED) {
39930
+ s8 = peg$parseRestIgnore();
39931
+ s9 = peg$parseLineEnd();
39932
+ if (s9 !== peg$FAILED) {
39933
+ peg$savedPos = s0;
39934
+ s0 = peg$f15(s4, s6, s7);
39935
+ } else {
39936
+ peg$currPos = s0;
39937
+ s0 = peg$FAILED;
39938
+ }
39939
+ } else {
39940
+ peg$currPos = s0;
39941
+ s0 = peg$FAILED;
39942
+ }
39943
+ } else {
39944
+ peg$currPos = s0;
39945
+ s0 = peg$FAILED;
39946
+ }
39947
+ } else {
39948
+ peg$currPos = s0;
39949
+ s0 = peg$FAILED;
39950
+ }
39951
+ } else {
39952
+ peg$currPos = s0;
39953
+ s0 = peg$FAILED;
39954
+ }
39955
+ } else {
39956
+ peg$currPos = s0;
39957
+ s0 = peg$FAILED;
39958
+ }
39959
+ } else {
39960
+ peg$currPos = s0;
39961
+ s0 = peg$FAILED;
39962
+ }
39963
+ return s0;
39964
+ }
39290
39965
  function peg$parseSide() {
39291
39966
  var s0;
39292
39967
  s0 = input.charAt(peg$currPos);
@@ -39295,7 +39970,7 @@ function peg$parse21(input, options) {
39295
39970
  } else {
39296
39971
  s0 = peg$FAILED;
39297
39972
  if (peg$silentFails === 0) {
39298
- peg$fail(peg$e15);
39973
+ peg$fail(peg$e21);
39299
39974
  }
39300
39975
  }
39301
39976
  return s0;
@@ -39310,7 +39985,7 @@ function peg$parse21(input, options) {
39310
39985
  } else {
39311
39986
  s2 = peg$FAILED;
39312
39987
  if (peg$silentFails === 0) {
39313
- peg$fail(peg$e16);
39988
+ peg$fail(peg$e22);
39314
39989
  }
39315
39990
  }
39316
39991
  while (s2 !== peg$FAILED) {
@@ -39321,7 +39996,7 @@ function peg$parse21(input, options) {
39321
39996
  } else {
39322
39997
  s2 = peg$FAILED;
39323
39998
  if (peg$silentFails === 0) {
39324
- peg$fail(peg$e16);
39999
+ peg$fail(peg$e22);
39325
40000
  }
39326
40001
  }
39327
40002
  }
@@ -39338,7 +40013,7 @@ function peg$parse21(input, options) {
39338
40013
  } else {
39339
40014
  s2 = peg$FAILED;
39340
40015
  if (peg$silentFails === 0) {
39341
- peg$fail(peg$e17);
40016
+ peg$fail(peg$e23);
39342
40017
  }
39343
40018
  }
39344
40019
  if (s2 !== peg$FAILED) {
@@ -39350,7 +40025,7 @@ function peg$parse21(input, options) {
39350
40025
  } else {
39351
40026
  s2 = peg$FAILED;
39352
40027
  if (peg$silentFails === 0) {
39353
- peg$fail(peg$e17);
40028
+ peg$fail(peg$e23);
39354
40029
  }
39355
40030
  }
39356
40031
  }
@@ -39369,29 +40044,29 @@ function peg$parse21(input, options) {
39369
40044
  s0 = peg$currPos;
39370
40045
  s1 = peg$parse_();
39371
40046
  if (input.charCodeAt(peg$currPos) === 13) {
39372
- s2 = peg$c12;
40047
+ s2 = peg$c18;
39373
40048
  peg$currPos++;
39374
40049
  } else {
39375
40050
  s2 = peg$FAILED;
39376
40051
  if (peg$silentFails === 0) {
39377
- peg$fail(peg$e18);
40052
+ peg$fail(peg$e24);
39378
40053
  }
39379
40054
  }
39380
40055
  if (s2 === peg$FAILED) {
39381
40056
  s2 = null;
39382
40057
  }
39383
40058
  if (input.charCodeAt(peg$currPos) === 10) {
39384
- s3 = peg$c13;
40059
+ s3 = peg$c19;
39385
40060
  peg$currPos++;
39386
40061
  } else {
39387
40062
  s3 = peg$FAILED;
39388
40063
  if (peg$silentFails === 0) {
39389
- peg$fail(peg$e19);
40064
+ peg$fail(peg$e25);
39390
40065
  }
39391
40066
  }
39392
40067
  if (s3 !== peg$FAILED) {
39393
40068
  peg$savedPos = s0;
39394
- s0 = peg$f5();
40069
+ s0 = peg$f16();
39395
40070
  } else {
39396
40071
  peg$currPos = s0;
39397
40072
  s0 = peg$FAILED;
@@ -39402,24 +40077,24 @@ function peg$parse21(input, options) {
39402
40077
  var s0, s1, s2;
39403
40078
  s0 = peg$currPos;
39404
40079
  if (input.charCodeAt(peg$currPos) === 13) {
39405
- s1 = peg$c12;
40080
+ s1 = peg$c18;
39406
40081
  peg$currPos++;
39407
40082
  } else {
39408
40083
  s1 = peg$FAILED;
39409
40084
  if (peg$silentFails === 0) {
39410
- peg$fail(peg$e18);
40085
+ peg$fail(peg$e24);
39411
40086
  }
39412
40087
  }
39413
40088
  if (s1 === peg$FAILED) {
39414
40089
  s1 = null;
39415
40090
  }
39416
40091
  if (input.charCodeAt(peg$currPos) === 10) {
39417
- s2 = peg$c13;
40092
+ s2 = peg$c19;
39418
40093
  peg$currPos++;
39419
40094
  } else {
39420
40095
  s2 = peg$FAILED;
39421
40096
  if (peg$silentFails === 0) {
39422
- peg$fail(peg$e19);
40097
+ peg$fail(peg$e25);
39423
40098
  }
39424
40099
  }
39425
40100
  if (s2 !== peg$FAILED) {
@@ -39438,7 +40113,7 @@ function peg$parse21(input, options) {
39438
40113
  } else {
39439
40114
  s1 = peg$FAILED;
39440
40115
  if (peg$silentFails === 0) {
39441
- peg$fail(peg$e20);
40116
+ peg$fail(peg$e26);
39442
40117
  }
39443
40118
  }
39444
40119
  peg$silentFails--;
@@ -39534,7 +40209,7 @@ function peg$parse21(input, options) {
39534
40209
  }
39535
40210
  }
39536
40211
 
39537
- // src/diagrams/triton/architecture/index.ts
40212
+ // src/diagrams/mermaid/architecture/index.ts
39538
40213
  var architecture = {
39539
40214
  parseMermaid(input) {
39540
40215
  return peg$parse21(input);
@@ -39542,8 +40217,8 @@ var architecture = {
39542
40217
  parseYaml(input) {
39543
40218
  return JSON.parse(input);
39544
40219
  },
39545
- layout(ir, theme) {
39546
- return layoutArchitecture(ir, theme);
40220
+ layout(ir, theme, options) {
40221
+ return layoutArchitecture(ir, theme, options);
39547
40222
  }
39548
40223
  };
39549
40224