@tldraw/mermaid 5.1.0 → 5.2.0-canary.019da1aa690a

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 (36) hide show
  1. package/README.md +7 -1
  2. package/dist-cjs/createMermaidDiagram.js +5 -5
  3. package/dist-cjs/createMermaidDiagram.js.map +3 -3
  4. package/dist-cjs/flowchartDiagram.js +7 -3
  5. package/dist-cjs/flowchartDiagram.js.map +2 -2
  6. package/dist-cjs/index.js +1 -1
  7. package/dist-cjs/mindmapDiagram.js +1 -1
  8. package/dist-cjs/mindmapDiagram.js.map +2 -2
  9. package/dist-cjs/sequenceDiagram.js +20 -1
  10. package/dist-cjs/sequenceDiagram.js.map +2 -2
  11. package/dist-cjs/stateDiagram.js +7 -3
  12. package/dist-cjs/stateDiagram.js.map +2 -2
  13. package/dist-cjs/svgParsing.js +2 -2
  14. package/dist-cjs/svgParsing.js.map +2 -2
  15. package/dist-esm/createMermaidDiagram.mjs +1 -1
  16. package/dist-esm/createMermaidDiagram.mjs.map +2 -2
  17. package/dist-esm/flowchartDiagram.mjs +7 -3
  18. package/dist-esm/flowchartDiagram.mjs.map +2 -2
  19. package/dist-esm/index.mjs +1 -1
  20. package/dist-esm/mindmapDiagram.mjs +1 -1
  21. package/dist-esm/mindmapDiagram.mjs.map +2 -2
  22. package/dist-esm/sequenceDiagram.mjs +20 -1
  23. package/dist-esm/sequenceDiagram.mjs.map +2 -2
  24. package/dist-esm/stateDiagram.mjs +7 -3
  25. package/dist-esm/stateDiagram.mjs.map +2 -2
  26. package/dist-esm/svgParsing.mjs +2 -2
  27. package/dist-esm/svgParsing.mjs.map +2 -2
  28. package/package.json +9 -6
  29. package/src/createMermaidDiagram.ts +7 -1
  30. package/src/flowchartDiagram.ts +8 -3
  31. package/src/layoutParsing.test.ts +71 -0
  32. package/src/mindmapDiagram.ts +1 -1
  33. package/src/sequenceDiagram.ts +19 -0
  34. package/src/stateDiagram.ts +10 -3
  35. package/src/svgParsing.test.ts +58 -0
  36. package/src/svgParsing.ts +6 -2
package/README.md CHANGED
@@ -183,6 +183,12 @@ The `mermaid` dependency is roughly 2 MB. The paste handler above already lazy-l
183
183
 
184
184
  See the [Mermaid diagrams example](https://github.com/tldraw/tldraw/tree/main/apps/examples/src/examples/use-cases/hundred-mermaids) in the examples app for a runnable demo that renders many diagram types at once. Run it locally with `yarn dev` from the repo root and visit `localhost:5420`.
185
185
 
186
+ ## Documentation
187
+
188
+ Documentation for the most recent release can be found on [tldraw.dev/docs](https://tldraw.dev/docs), including [reference docs](https://tldraw.dev/reference/editor/Editor). Our release notes can be found [here](https://tldraw.dev/releases).
189
+
190
+ For more agent-friendly docs, see our [LLMs.txt](https://tldraw.dev/llms.txt).
191
+
186
192
  ## License
187
193
 
188
194
  This project is part of the tldraw SDK. It is provided under the [tldraw SDK license](https://github.com/tldraw/tldraw/blob/main/LICENSE.md).
@@ -197,7 +203,7 @@ You can find tldraw on npm [here](https://www.npmjs.com/package/@tldraw/tldraw?a
197
203
 
198
204
  ## Contribution
199
205
 
200
- Please see our [contributing guide](https://github.com/tldraw/tldraw/blob/main/CONTRIBUTING.md). Found a bug? Please [submit an issue](https://github.com/tldraw/tldraw/issues/new).
206
+ Found a bug? Please [submit an issue](https://github.com/tldraw/tldraw/issues/new).
201
207
 
202
208
  ## Community
203
209
 
@@ -32,7 +32,6 @@ __export(createMermaidDiagram_exports, {
32
32
  createMermaidDiagram: () => createMermaidDiagram
33
33
  });
34
34
  module.exports = __toCommonJS(createMermaidDiagram_exports);
35
- var import_mermaid = __toESM(require("mermaid"), 1);
36
35
  var import_flowchartDiagram = require("./flowchartDiagram");
37
36
  var import_mindmapDiagram = require("./mindmapDiagram");
38
37
  var import_renderBlueprint = require("./renderBlueprint");
@@ -59,7 +58,8 @@ const MERMAID_CONFIG = {
59
58
  themeVariables: { fontSize: `${18 * FONT_INFLATE}px` }
60
59
  };
61
60
  async function createMermaidDiagram(editor, text, options = {}) {
62
- import_mermaid.default.initialize({
61
+ const mermaid = (await import("mermaid")).default;
62
+ mermaid.initialize({
63
63
  ...MERMAID_CONFIG,
64
64
  ...options.mermaidConfig ?? {},
65
65
  flowchart: { ...MERMAID_CONFIG.flowchart, ...options.mermaidConfig?.flowchart },
@@ -68,7 +68,7 @@ async function createMermaidDiagram(editor, text, options = {}) {
68
68
  sequence: { ...MERMAID_CONFIG.sequence, ...options.mermaidConfig?.sequence },
69
69
  themeVariables: { ...MERMAID_CONFIG.themeVariables, ...options.mermaidConfig?.themeVariables }
70
70
  });
71
- const parsedResult = await import_mermaid.default.parse(text, { suppressErrors: true });
71
+ const parsedResult = await mermaid.parse(text, { suppressErrors: true });
72
72
  if (!parsedResult) {
73
73
  throw new MermaidDiagramError("not a mermaid diagram", "parse");
74
74
  }
@@ -79,7 +79,7 @@ async function createMermaidDiagram(editor, text, options = {}) {
79
79
  offscreen.style.overflow = "hidden";
80
80
  document.body.appendChild(offscreen);
81
81
  try {
82
- const parsedSvg = (await import_mermaid.default.render(`mermaid-${nextMermaidId++}`, text, offscreen)).svg;
82
+ const parsedSvg = (await mermaid.render(`mermaid-${nextMermaidId++}`, text, offscreen)).svg;
83
83
  let liveSvg = offscreen.querySelector("svg");
84
84
  if (!liveSvg) {
85
85
  offscreen.innerHTML = parsedSvg;
@@ -88,7 +88,7 @@ async function createMermaidDiagram(editor, text, options = {}) {
88
88
  throw new MermaidDiagramError(parsedResult.diagramType, "parse");
89
89
  }
90
90
  }
91
- const diagramResult = await import_mermaid.default.mermaidAPI.getDiagramFromText(text);
91
+ const diagramResult = await mermaid.mermaidAPI.getDiagramFromText(text);
92
92
  let blueprint;
93
93
  switch (parsedResult.diagramType) {
94
94
  case "flowchart-v2": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/createMermaidDiagram.ts"],
4
- "sourcesContent": ["let nextMermaidId = 0\n\nimport mermaid from 'mermaid'\nimport type { FlowDB } from 'mermaid/dist/diagrams/flowchart/flowDb.d.ts'\nimport type { FlowEdge, FlowSubGraph, FlowVertex } from 'mermaid/dist/diagrams/flowchart/types.js'\nimport type { MindmapDB } from 'mermaid/dist/diagrams/mindmap/mindmapDb.d.ts'\nimport type { SequenceDB } from 'mermaid/dist/diagrams/sequence/sequenceDb.d.ts'\nimport type { StateDB } from 'mermaid/dist/diagrams/state/stateDb.d.ts'\nimport { Editor } from 'tldraw'\nimport { flowchartToBlueprint, parseFlowchartLayout } from './flowchartDiagram'\nimport { mindmapToBlueprint, parseMindmapLayout } from './mindmapDiagram'\nimport { BlueprintRenderingOptions, renderBlueprint } from './renderBlueprint'\nimport { countSequenceEvents, parseSequenceLayout, sequenceToBlueprint } from './sequenceDiagram'\nimport { parseStateDiagramLayout, stateToBlueprint } from './stateDiagram'\n\n/** @public */\nexport class MermaidDiagramError extends Error {\n\tconstructor(\n\t\tpublic diagramType: string,\n\t\tpublic type: 'parse' | 'unsupported'\n\t) {\n\t\tsuper(`mermaid diagram error: ${diagramType}`)\n\t\tthis.name = 'MermaidDiagramError'\n\t}\n}\n\n// Inflate the font size so Mermaid's layout engine allocates larger nodes,\n// compensating for tldraw's hand-drawn font being wider than Mermaid's default.\nconst FONT_INFLATE = 1.4\n\nconst MERMAID_CONFIG = {\n\tstartOnLoad: false,\n\tflowchart: { nodeSpacing: 80, rankSpacing: 80, padding: 20 },\n\tstate: { nodeSpacing: 80, rankSpacing: 80, padding: 20 },\n\tmindmap: { padding: 20 },\n\tsequence: { actorMargin: 50, noteMargin: 20 },\n\tthemeVariables: { fontSize: `${18 * FONT_INFLATE}px` },\n}\n\n/** @public */\nexport interface MermaidDiagramOptions {\n\tmermaidConfig?: Record<string, any>\n\tblueprintRender?: BlueprintRenderingOptions\n\tonUnsupportedDiagram?(svg: string): Promise<void>\n}\n\n/**\n * Parse mermaid text and create tldraw shapes for supported diagram types.\n * Returns the SVG string for supported diagrams, or `null` when the diagram type\n * is unsupported (after calling `onUnsupportedDiagram` if provided).\n * Throws {@link MermaidDiagramError} if parsing fails.\n * @public\n */\nexport async function createMermaidDiagram(\n\teditor: Editor,\n\ttext: string,\n\toptions: MermaidDiagramOptions = {}\n): Promise<void> {\n\tmermaid.initialize({\n\t\t...MERMAID_CONFIG,\n\t\t...(options.mermaidConfig ?? {}),\n\t\tflowchart: { ...MERMAID_CONFIG.flowchart, ...options.mermaidConfig?.flowchart },\n\t\tstate: { ...MERMAID_CONFIG.state, ...options.mermaidConfig?.state },\n\t\tmindmap: { ...MERMAID_CONFIG.mindmap, ...options.mermaidConfig?.mindmap },\n\t\tsequence: { ...MERMAID_CONFIG.sequence, ...options.mermaidConfig?.sequence },\n\t\tthemeVariables: { ...MERMAID_CONFIG.themeVariables, ...options.mermaidConfig?.themeVariables },\n\t})\n\n\tconst parsedResult = await mermaid.parse(text, { suppressErrors: true })\n\n\tif (!parsedResult) {\n\t\tthrow new MermaidDiagramError('not a mermaid diagram', 'parse')\n\t}\n\n\tconst offscreen = document.createElement('div')\n\toffscreen.style.position = 'absolute'\n\toffscreen.style.left = '-9999px'\n\toffscreen.style.top = '-9999px'\n\toffscreen.style.overflow = 'hidden'\n\tdocument.body.appendChild(offscreen)\n\n\ttry {\n\t\tconst parsedSvg = (await mermaid.render(`mermaid-${nextMermaidId++}`, text, offscreen)).svg\n\n\t\t// Reuse the live SVG that mermaid.render() already mounted into the\n\t\t// offscreen container. This avoids a second DOM mount and ensures\n\t\t// getBBox() works for every diagram type (state diagrams in particular\n\t\t// lack explicit dimension attributes and rely on live layout).\n\t\tlet liveSvg = offscreen.querySelector('svg')\n\n\t\tif (!liveSvg) {\n\t\t\toffscreen.innerHTML = parsedSvg\n\t\t\tliveSvg = offscreen.querySelector('svg')\n\t\t\tif (!liveSvg) {\n\t\t\t\tthrow new MermaidDiagramError(parsedResult.diagramType, 'parse')\n\t\t\t}\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\tconst diagramResult = await mermaid.mermaidAPI.getDiagramFromText(text)\n\n\t\tlet blueprint\n\t\tswitch (parsedResult.diagramType) {\n\t\t\tcase 'flowchart-v2': {\n\t\t\t\tconst db = diagramResult.db as FlowDB\n\t\t\t\tconst vertices = db.getVertices() as Map<string, FlowVertex>\n\t\t\t\tconst edges = db.getEdges() as FlowEdge[]\n\t\t\t\tconst subGraphs = db.getSubGraphs() as FlowSubGraph[]\n\t\t\t\tconst classes = db.getClasses()\n\t\t\t\tconst layout = parseFlowchartLayout(liveSvg)\n\t\t\t\tblueprint = flowchartToBlueprint(layout, vertices, edges, subGraphs, classes)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'sequence': {\n\t\t\t\tconst db = diagramResult.db as SequenceDB\n\t\t\t\tconst actors = db.getActors()\n\t\t\t\tconst actorKeys = db.getActorKeys()\n\t\t\t\tconst messages = db.getMessages()\n\t\t\t\tconst layout = parseSequenceLayout(liveSvg, actorKeys.length, countSequenceEvents(messages))\n\t\t\t\tblueprint = sequenceToBlueprint(\n\t\t\t\t\tlayout,\n\t\t\t\t\tactors,\n\t\t\t\t\tactorKeys,\n\t\t\t\t\tmessages,\n\t\t\t\t\tdb.getCreatedActors(),\n\t\t\t\t\tdb.getDestroyedActors()\n\t\t\t\t)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'state':\n\t\t\tcase 'stateDiagram': {\n\t\t\t\tconst db = diagramResult.db as StateDB\n\t\t\t\tconst states = db.getStates()\n\t\t\t\tconst relations = db.getRelations()\n\t\t\t\tconst classes = db.getClasses()\n\t\t\t\tconst layout = parseStateDiagramLayout(liveSvg)\n\t\t\t\tblueprint = stateToBlueprint(layout, states, relations, classes)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'mindmap': {\n\t\t\t\tconst db = diagramResult.db as MindmapDB\n\t\t\t\tconst tree = db.getMindmap()\n\t\t\t\tif (tree) {\n\t\t\t\t\tdb.assignSections(tree)\n\t\t\t\t\tconst layout = parseMindmapLayout(liveSvg)\n\t\t\t\t\tblueprint = mindmapToBlueprint(layout, tree, liveSvg)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tif (options.onUnsupportedDiagram) {\n\t\t\t\t\tawait options.onUnsupportedDiagram(parsedSvg)\n\t\t\t\t} else {\n\t\t\t\t\tthrow new MermaidDiagramError(parsedResult.diagramType, 'unsupported')\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t}\n\n\t\tif (blueprint) {\n\t\t\trenderBlueprint(editor, blueprint, options.blueprintRender)\n\t\t}\n\t} catch (e) {\n\t\tif (e instanceof MermaidDiagramError) throw e\n\t\tconsole.error(e)\n\t\tthrow new MermaidDiagramError(parsedResult.diagramType, 'parse')\n\t} finally {\n\t\toffscreen.remove()\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,qBAAoB;AAOpB,8BAA2D;AAC3D,4BAAuD;AACvD,6BAA2D;AAC3D,6BAA8E;AAC9E,0BAA0D;AAb1D,IAAI,gBAAgB;AAgBb,MAAM,4BAA4B,MAAM;AAAA,EAC9C,YACQ,aACA,MACN;AACD,UAAM,0BAA0B,WAAW,EAAE;AAHtC;AACA;AAGP,SAAK,OAAO;AAAA,EACb;AAAA,EALQ;AAAA,EACA;AAKT;AAIA,MAAM,eAAe;AAErB,MAAM,iBAAiB;AAAA,EACtB,aAAa;AAAA,EACb,WAAW,EAAE,aAAa,IAAI,aAAa,IAAI,SAAS,GAAG;AAAA,EAC3D,OAAO,EAAE,aAAa,IAAI,aAAa,IAAI,SAAS,GAAG;AAAA,EACvD,SAAS,EAAE,SAAS,GAAG;AAAA,EACvB,UAAU,EAAE,aAAa,IAAI,YAAY,GAAG;AAAA,EAC5C,gBAAgB,EAAE,UAAU,GAAG,KAAK,YAAY,KAAK;AACtD;AAgBA,eAAsB,qBACrB,QACA,MACA,UAAiC,CAAC,GAClB;AAChB,iBAAAA,QAAQ,WAAW;AAAA,IAClB,GA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,EACD,SAAS,GAAG;AACX,QAAI,aAAa,oBAAqB,OAAM;AAC5C,YAAQ,MAAM,CAAC;AACf,UAAM,IAAI,oBAAoB,aAAa,aAAa,OAAO;AAAA,EAChE,UAAE;AACD,cAAU,OAAO;AAAA,EAClB;AACD;",
6
- "names": ["mermaid"]
4
+ "sourcesContent": ["let nextMermaidId = 0\n\nimport type { FlowDB } from 'mermaid/dist/diagrams/flowchart/flowDb.d.ts'\nimport type { FlowEdge, FlowSubGraph, FlowVertex } from 'mermaid/dist/diagrams/flowchart/types.js'\nimport type { MindmapDB } from 'mermaid/dist/diagrams/mindmap/mindmapDb.d.ts'\nimport type { SequenceDB } from 'mermaid/dist/diagrams/sequence/sequenceDb.d.ts'\nimport type { StateDB } from 'mermaid/dist/diagrams/state/stateDb.d.ts'\nimport { Editor } from 'tldraw'\nimport { flowchartToBlueprint, parseFlowchartLayout } from './flowchartDiagram'\nimport { mindmapToBlueprint, parseMindmapLayout } from './mindmapDiagram'\nimport { BlueprintRenderingOptions, renderBlueprint } from './renderBlueprint'\nimport { countSequenceEvents, parseSequenceLayout, sequenceToBlueprint } from './sequenceDiagram'\nimport { parseStateDiagramLayout, stateToBlueprint } from './stateDiagram'\n\n/** @public */\nexport class MermaidDiagramError extends Error {\n\tconstructor(\n\t\tpublic diagramType: string,\n\t\tpublic type: 'parse' | 'unsupported'\n\t) {\n\t\tsuper(`mermaid diagram error: ${diagramType}`)\n\t\tthis.name = 'MermaidDiagramError'\n\t}\n}\n\n// Inflate the font size so Mermaid's layout engine allocates larger nodes,\n// compensating for tldraw's hand-drawn font being wider than Mermaid's default.\nconst FONT_INFLATE = 1.4\n\nconst MERMAID_CONFIG = {\n\tstartOnLoad: false,\n\tflowchart: { nodeSpacing: 80, rankSpacing: 80, padding: 20 },\n\tstate: { nodeSpacing: 80, rankSpacing: 80, padding: 20 },\n\tmindmap: { padding: 20 },\n\tsequence: { actorMargin: 50, noteMargin: 20 },\n\tthemeVariables: { fontSize: `${18 * FONT_INFLATE}px` },\n}\n\n/** @public */\nexport interface MermaidDiagramOptions {\n\tmermaidConfig?: Record<string, any>\n\tblueprintRender?: BlueprintRenderingOptions\n\tonUnsupportedDiagram?(svg: string): Promise<void>\n}\n\n/**\n * Parse mermaid text and create tldraw shapes for supported diagram types.\n * Returns the SVG string for supported diagrams, or `null` when the diagram type\n * is unsupported (after calling `onUnsupportedDiagram` if provided).\n * Throws {@link MermaidDiagramError} if parsing fails.\n * @public\n */\nexport async function createMermaidDiagram(\n\teditor: Editor,\n\ttext: string,\n\toptions: MermaidDiagramOptions = {}\n): Promise<void> {\n\t// load mermaid lazily: it's a large, ESM-only dependency only needed when a\n\t// diagram is actually created. a dynamic import() works from CommonJS (unlike\n\t// a static import, which compiles to require(<esm>) and throws\n\t// ERR_REQUIRE_ESM on Node <20.19, Jest, and ts-node) and avoids pulling\n\t// mermaid in when @tldraw/mermaid is merely imported.\n\tconst mermaid = (await import('mermaid')).default\n\n\tmermaid.initialize({\n\t\t...MERMAID_CONFIG,\n\t\t...(options.mermaidConfig ?? {}),\n\t\tflowchart: { ...MERMAID_CONFIG.flowchart, ...options.mermaidConfig?.flowchart },\n\t\tstate: { ...MERMAID_CONFIG.state, ...options.mermaidConfig?.state },\n\t\tmindmap: { ...MERMAID_CONFIG.mindmap, ...options.mermaidConfig?.mindmap },\n\t\tsequence: { ...MERMAID_CONFIG.sequence, ...options.mermaidConfig?.sequence },\n\t\tthemeVariables: { ...MERMAID_CONFIG.themeVariables, ...options.mermaidConfig?.themeVariables },\n\t})\n\n\tconst parsedResult = await mermaid.parse(text, { suppressErrors: true })\n\n\tif (!parsedResult) {\n\t\tthrow new MermaidDiagramError('not a mermaid diagram', 'parse')\n\t}\n\n\tconst offscreen = document.createElement('div')\n\toffscreen.style.position = 'absolute'\n\toffscreen.style.left = '-9999px'\n\toffscreen.style.top = '-9999px'\n\toffscreen.style.overflow = 'hidden'\n\tdocument.body.appendChild(offscreen)\n\n\ttry {\n\t\tconst parsedSvg = (await mermaid.render(`mermaid-${nextMermaidId++}`, text, offscreen)).svg\n\n\t\t// Reuse the live SVG that mermaid.render() already mounted into the\n\t\t// offscreen container. This avoids a second DOM mount and ensures\n\t\t// getBBox() works for every diagram type (state diagrams in particular\n\t\t// lack explicit dimension attributes and rely on live layout).\n\t\tlet liveSvg = offscreen.querySelector('svg')\n\n\t\tif (!liveSvg) {\n\t\t\toffscreen.innerHTML = parsedSvg\n\t\t\tliveSvg = offscreen.querySelector('svg')\n\t\t\tif (!liveSvg) {\n\t\t\t\tthrow new MermaidDiagramError(parsedResult.diagramType, 'parse')\n\t\t\t}\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\tconst diagramResult = await mermaid.mermaidAPI.getDiagramFromText(text)\n\n\t\tlet blueprint\n\t\tswitch (parsedResult.diagramType) {\n\t\t\tcase 'flowchart-v2': {\n\t\t\t\tconst db = diagramResult.db as FlowDB\n\t\t\t\tconst vertices = db.getVertices() as Map<string, FlowVertex>\n\t\t\t\tconst edges = db.getEdges() as FlowEdge[]\n\t\t\t\tconst subGraphs = db.getSubGraphs() as FlowSubGraph[]\n\t\t\t\tconst classes = db.getClasses()\n\t\t\t\tconst layout = parseFlowchartLayout(liveSvg)\n\t\t\t\tblueprint = flowchartToBlueprint(layout, vertices, edges, subGraphs, classes)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'sequence': {\n\t\t\t\tconst db = diagramResult.db as SequenceDB\n\t\t\t\tconst actors = db.getActors()\n\t\t\t\tconst actorKeys = db.getActorKeys()\n\t\t\t\tconst messages = db.getMessages()\n\t\t\t\tconst layout = parseSequenceLayout(liveSvg, actorKeys.length, countSequenceEvents(messages))\n\t\t\t\tblueprint = sequenceToBlueprint(\n\t\t\t\t\tlayout,\n\t\t\t\t\tactors,\n\t\t\t\t\tactorKeys,\n\t\t\t\t\tmessages,\n\t\t\t\t\tdb.getCreatedActors(),\n\t\t\t\t\tdb.getDestroyedActors()\n\t\t\t\t)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'state':\n\t\t\tcase 'stateDiagram': {\n\t\t\t\tconst db = diagramResult.db as StateDB\n\t\t\t\tconst states = db.getStates()\n\t\t\t\tconst relations = db.getRelations()\n\t\t\t\tconst classes = db.getClasses()\n\t\t\t\tconst layout = parseStateDiagramLayout(liveSvg)\n\t\t\t\tblueprint = stateToBlueprint(layout, states, relations, classes)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'mindmap': {\n\t\t\t\tconst db = diagramResult.db as MindmapDB\n\t\t\t\tconst tree = db.getMindmap()\n\t\t\t\tif (tree) {\n\t\t\t\t\tdb.assignSections(tree)\n\t\t\t\t\tconst layout = parseMindmapLayout(liveSvg)\n\t\t\t\t\tblueprint = mindmapToBlueprint(layout, tree, liveSvg)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tif (options.onUnsupportedDiagram) {\n\t\t\t\t\tawait options.onUnsupportedDiagram(parsedSvg)\n\t\t\t\t} else {\n\t\t\t\t\tthrow new MermaidDiagramError(parsedResult.diagramType, 'unsupported')\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t}\n\n\t\tif (blueprint) {\n\t\t\trenderBlueprint(editor, blueprint, options.blueprintRender)\n\t\t}\n\t} catch (e) {\n\t\tif (e instanceof MermaidDiagramError) throw e\n\t\tconsole.error(e)\n\t\tthrow new MermaidDiagramError(parsedResult.diagramType, 'parse')\n\t} finally {\n\t\toffscreen.remove()\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,8BAA2D;AAC3D,4BAAuD;AACvD,6BAA2D;AAC3D,6BAA8E;AAC9E,0BAA0D;AAZ1D,IAAI,gBAAgB;AAeb,MAAM,4BAA4B,MAAM;AAAA,EAC9C,YACQ,aACA,MACN;AACD,UAAM,0BAA0B,WAAW,EAAE;AAHtC;AACA;AAGP,SA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AO;AAC/D;AAAA,MACD;AAAA,MACA,KAAK,WAAW;AACf,cAAM,KAAK,cAAc;AACzB,cAAM,OAAO,GAAG,WAAW;AAC3B,YAAI,MAAM;AACT,aAAG,eAAe,IAAI;AACtB,gBAAM,aAAS,0CAAmB,OAAO;AACzC,0BAAY,0CAAmB,QAAQ,MAAM,OAAO;AAAA,QACrD;AACA;AAAA,MACD;AAAA,MACA;AACC,YAAI,QAAQ,sBAAsB;AACjC,gBAAM,QAAQ,qBAAqB,SAAS;AAAA,QAC7C,OAAO;AACN,gBAAM,IAAI,oBAAoB,aAAa,aAAa,aAAa;AAAA,QACtE;AACA;AAAA,IACF;AAEA,QAAI,WAAW;AACd,kDAAgB,QAAQ,WAAW,QAAQ,eAAe;AAAA,IAC3D;AAAA,EACD,SAAS,GAAG;AACX,QAAI,aAAa,oBAAqB,OAAM;AAC5C,YAAQ,MAAM,CAAC;AACf,UAAM,IAAI,oBAAoB,aAAa,aAAa,OAAO;AAAA,EAChE,UAAE;AACD,cAAU,OAAO;AAAA,EAClB;AACD;",
6
+ "names": []
7
7
  }
@@ -56,12 +56,16 @@ function buildHierarchy(subGraphs) {
56
56
  }
57
57
  function parseFlowchartLayout(root) {
58
58
  const nodes = (0, import_svgParsing.parseNodesFromSvg)(root, ".node", (domId) => {
59
- const match = domId.match(/^flowchart-(.+)-\d+$/);
59
+ const match = domId.match(/^(?:mermaid-\d+-)?flowchart-(.+)-\d+$/);
60
60
  return match ? match[1] : domId;
61
61
  });
62
- const clusters = (0, import_svgParsing.parseClustersFromSvg)(root, ".cluster");
62
+ const clusters = (0, import_svgParsing.parseClustersFromSvg)(
63
+ root,
64
+ ".cluster",
65
+ (domId) => domId.replace(/^mermaid-\d+-/, "")
66
+ );
63
67
  const edges = (0, import_svgParsing.parseAllEdgePointsFromSvg)(root, (dataId) => {
64
- const match = dataId.match(/^L_(.+)_([^_]+)_\d+$/);
68
+ const match = dataId.match(/(?:^|-)L_(.+)_([^_]+)_\d+$/);
65
69
  return match ? { start: match[1], end: match[2] } : null;
66
70
  });
67
71
  (0, import_svgParsing.scaleLayout)(nodes, clusters, edges, import_utils.LAYOUT_SCALE);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/flowchartDiagram.ts"],
4
- "sourcesContent": ["import type {\n\tFlowClass,\n\tFlowEdge,\n\tFlowSubGraph,\n\tFlowVertex,\n} from 'mermaid/dist/diagrams/flowchart/types.js'\nimport { TLArrowShapeArrowheadStyle, TLDefaultDashStyle } from 'tldraw'\nimport type {\n\tDiagramMermaidBlueprint,\n\tMermaidBlueprintEdge,\n\tMermaidBlueprintNode,\n} from './blueprint'\nimport { buildClassDefColorMap, parseCssStyles, parseNodeInlineColor } from './colors'\nimport {\n\tbuildNodeCentersFromSvg,\n\tparseAllEdgePointsFromSvg,\n\tparseClustersFromSvg,\n\ttype ParsedDiagramLayout,\n\tparseNodesFromSvg,\n\tscaleLayout,\n} from './svgParsing'\nimport { getArrowBend, LAYOUT_SCALE, orderTopDown } from './utils'\n\nfunction mapEdgeTypeToArrowhead(type: string | undefined): TLArrowShapeArrowheadStyle {\n\tif (!type) return 'arrow'\n\n\tif (type.includes('point')) return 'arrow'\n\tif (type.includes('circle')) return 'dot'\n\tif (type.includes('cross')) return 'bar'\n\tif (type.includes('open')) return 'none'\n\n\treturn 'arrow'\n}\n\nfunction mapEdgeStrokeToDash(stroke: string | undefined): TLDefaultDashStyle {\n\tif (!stroke) return 'solid'\n\tif (stroke === 'dotted') return 'dotted'\n\treturn 'solid'\n}\n\nconst FRAME_TOP_PAD = 14\n\nfunction buildHierarchy(subGraphs: FlowSubGraph[]) {\n\tconst subGraphIds = new Set(subGraphs.map((subGraph) => subGraph.id))\n\tconst nodeToSubGraph = new Map<string, string>()\n\tconst subGraphParent = new Map<string, string>()\n\tfor (const subGraph of subGraphs) {\n\t\tfor (const nodeId of subGraph.nodes) {\n\t\t\tif (subGraphIds.has(nodeId)) {\n\t\t\t\tsubGraphParent.set(nodeId, subGraph.id)\n\t\t\t} else if (!nodeToSubGraph.has(nodeId)) {\n\t\t\t\tnodeToSubGraph.set(nodeId, subGraph.id)\n\t\t\t}\n\t\t}\n\t}\n\treturn { nodeToSubGraph, subGraphParent }\n}\n\n/** Parse flowchart-specific SVG layout data for use by {@link flowchartToBlueprint}. */\nexport function parseFlowchartLayout(root: Element): ParsedDiagramLayout {\n\tconst nodes = parseNodesFromSvg(root, '.node', (domId) => {\n\t\tconst match = domId.match(/^flowchart-(.+)-\\d+$/)\n\t\treturn match ? match[1] : domId\n\t})\n\tconst clusters = parseClustersFromSvg(root, '.cluster')\n\tconst edges = parseAllEdgePointsFromSvg(root, (dataId) => {\n\t\tconst match = dataId.match(/^L_(.+)_([^_]+)_\\d+$/)\n\t\treturn match ? { start: match[1], end: match[2] } : null\n\t})\n\tscaleLayout(nodes, clusters, edges, LAYOUT_SCALE)\n\treturn { nodes, clusters, edges }\n}\n\n/** Convert a parsed Mermaid flowchart into a tldraw blueprint of nodes and edges. */\nexport function flowchartToBlueprint(\n\tlayout: ParsedDiagramLayout,\n\tvertices: Map<string, FlowVertex>,\n\tedges: FlowEdge[],\n\tsubGraphs?: FlowSubGraph[],\n\tclassDefs?: Map<string, FlowClass>\n): DiagramMermaidBlueprint {\n\tconst nodeColorMap = classDefs ? buildClassDefColorMap(classDefs, vertices) : new Map()\n\tconst { nodes: svgNodes, clusters: svgClusters, edges: svgEdges } = layout\n\tconst nodeCenters = buildNodeCentersFromSvg(svgNodes, svgClusters)\n\n\tconst allSubGraphs = subGraphs || []\n\tconst { nodeToSubGraph, subGraphParent } = buildHierarchy(allSubGraphs)\n\n\tconst nodes: MermaidBlueprintNode[] = []\n\tconst blueprintEdges: MermaidBlueprintEdge[] = []\n\n\t// Frames for subgraphs\n\tfor (const subGraph of orderTopDown(\n\t\tallSubGraphs,\n\t\t(subGraph) => subGraph.id,\n\t\t(subGraph) => subGraphParent.get(subGraph.id)\n\t)) {\n\t\tconst cluster = svgClusters.get(subGraph.id)\n\t\tif (!cluster) continue\n\n\t\tconst id = subGraph.id\n\t\tconst kind = 'subgraph'\n\t\tnodes.push({\n\t\t\tid,\n\t\t\tkind,\n\t\t\tx: cluster.topLeft.x,\n\t\t\ty: cluster.topLeft.y - FRAME_TOP_PAD,\n\t\t\tw: cluster.width,\n\t\t\th: cluster.height + FRAME_TOP_PAD,\n\t\t\tparentId: subGraphParent.get(subGraph.id),\n\t\t\tlabel: subGraph.title || subGraph.id,\n\t\t\tfill: 'semi',\n\t\t\tcolor: 'black',\n\t\t\tdash: 'draw',\n\t\t\tsize: 's',\n\t\t\talign: 'middle',\n\t\t\tverticalAlign: 'start',\n\t\t})\n\t}\n\n\t// Node shapes\n\tfor (const [id, vertex] of vertices) {\n\t\tconst svgNode = svgNodes.get(id)\n\t\tif (!svgNode) continue\n\n\t\tconst kind = vertex.type ?? 'rect'\n\t\tconst colors = nodeColorMap.get(id) ?? parseNodeInlineColor(vertex.styles)\n\n\t\tlet { width: w, height: h } = svgNode\n\t\tif (vertex.type === 'circle' || vertex.type === 'doublecircle') {\n\t\t\tw = h = Math.max(w, h)\n\t\t}\n\n\t\tnodes.push({\n\t\t\tid,\n\t\t\tkind,\n\t\t\tx: svgNode.center.x - w / 2,\n\t\t\ty: svgNode.center.y - h / 2,\n\t\t\tw,\n\t\t\th,\n\t\t\tparentId: nodeToSubGraph.get(id),\n\t\t\tlabel: vertex.text || undefined,\n\t\t\t...(colors?.fillColor && { fill: 'solid' as const }),\n\t\t\t...(colors && { color: colors.strokeColor ?? colors.fillColor }),\n\t\t\talign: 'middle',\n\t\t\tverticalAlign: 'middle',\n\t\t\tsize: 'm',\n\t\t})\n\t}\n\n\t// Edges: match DB edges to SVG edges by proximity, compute bends\n\tconst claimed = new Set<number>()\n\tfor (const edge of edges) {\n\t\tconst startCenter = nodeCenters.get(edge.start)\n\t\tconst endCenter = nodeCenters.get(edge.end)\n\n\t\tlet bend = 0\n\t\tif (startCenter && endCenter) {\n\t\t\tlet bestIndex = -1\n\t\t\tlet bestDist = Infinity\n\t\t\tfor (let i = 0; i < svgEdges.length; i++) {\n\t\t\t\tif (claimed.has(i) || svgEdges[i].points.length < 2) continue\n\n\t\t\t\tconst points = svgEdges[i].points\n\t\t\t\tconst distance =\n\t\t\t\t\tMath.hypot(points[0].x - startCenter.x, points[0].y - startCenter.y) +\n\t\t\t\t\tMath.hypot(\n\t\t\t\t\t\tpoints[points.length - 1].x - endCenter.x,\n\t\t\t\t\t\tpoints[points.length - 1].y - endCenter.y\n\t\t\t\t\t)\n\t\t\t\tif (distance < bestDist) {\n\t\t\t\t\tbestDist = distance\n\t\t\t\t\tbestIndex = i\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (bestIndex >= 0) {\n\t\t\t\tclaimed.add(bestIndex)\n\t\t\t\tbend = getArrowBend(svgEdges[bestIndex])\n\t\t\t}\n\t\t}\n\n\t\tconst cssOverrides = edge.style ? parseCssStyles(edge.style) : undefined\n\t\tconst arrowheadEnd = mapEdgeTypeToArrowhead(edge.type)\n\t\tconst dash = cssOverrides?.dashOverride ?? mapEdgeStrokeToDash(edge.stroke)\n\t\tconst size = cssOverrides?.sizeOverride ?? (edge.stroke === 'thick' ? 'l' : 's')\n\n\t\tblueprintEdges.push({\n\t\t\tstartNodeId: edge.start,\n\t\t\tendNodeId: edge.end,\n\t\t\tlabel: edge.text,\n\t\t\tbend,\n\t\t\tarrowheadEnd,\n\t\t\tarrowheadStart: edge.type?.includes('double_arrow') ? arrowheadEnd : undefined,\n\t\t\tdash,\n\t\t\tsize,\n\t\t\tcolor: cssOverrides?.color,\n\t\t})\n\t}\n\n\tconst nodeIds = new Set(nodes.map((n) => n.id))\n\tconst validEdges = blueprintEdges.filter(\n\t\t(e) => nodeIds.has(e.startNodeId) && nodeIds.has(e.endNodeId)\n\t)\n\treturn { diagramKind: 'flowchart', nodes, edges: validEdges }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;A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YAAI,WAAW,UAAU;AACxB,qBAAW;AACX,sBAAY;AAAA,QACb;AAAA,MACD;AACA,UAAI,aAAa,GAAG;AACnB,gBAAQ,IAAI,SAAS;AACrB,mBAAO,2BAAa,SAAS,SAAS,CAAC;AAAA,MACxC;AAAA,IACD;AAEA,UAAM,eAAe,KAAK,YAAQ,8BAAe,KAAK,KAAK,IAAI;AAC/D,UAAM,eAAe,uBAAuB,KAAK,IAAI;AACrD,UAAM,OAAO,cAAc,gBAAgB,oBAAoB,KAAK,MAAM;AAC1E,UAAM,OAAO,cAAc,iBAAiB,KAAK,WAAW,UAAU,MAAM;AAE5E,mBAAe,KAAK;AAAA,MACnB,aAAa,KAAK;AAAA,MAClB,WAAW,KAAK;AAAA,MAChB,OAAO,KAAK;AAAA,MACZ;AAAA,MACA;AAAA,MACA,gBAAgB,KAAK,MAAM,SAAS,cAAc,IAAI,eAAe;AAAA,MACrE;AAAA,MACA;AAAA,MACA,OAAO,cAAc;AAAA,IACtB,CAAC;AAAA,EACF;AAEA,QAAM,UAAU,IAAI,IAAI,MAAM,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;AAC9C,QAAM,aAAa,eAAe;AAAA,IACjC,CAAC,MAAM,QAAQ,IAAI,EAAE,WAAW,KAAK,QAAQ,IAAI,EAAE,SAAS;AAAA,EAC7D;AACA,SAAO,EAAE,aAAa,aAAa,OAAO,OAAO,WAAW;AAC7D;",
4
+ "sourcesContent": ["import type {\n\tFlowClass,\n\tFlowEdge,\n\tFlowSubGraph,\n\tFlowVertex,\n} from 'mermaid/dist/diagrams/flowchart/types.js'\nimport { TLArrowShapeArrowheadStyle, TLDefaultDashStyle } from 'tldraw'\nimport type {\n\tDiagramMermaidBlueprint,\n\tMermaidBlueprintEdge,\n\tMermaidBlueprintNode,\n} from './blueprint'\nimport { buildClassDefColorMap, parseCssStyles, parseNodeInlineColor } from './colors'\nimport {\n\tbuildNodeCentersFromSvg,\n\tparseAllEdgePointsFromSvg,\n\tparseClustersFromSvg,\n\ttype ParsedDiagramLayout,\n\tparseNodesFromSvg,\n\tscaleLayout,\n} from './svgParsing'\nimport { getArrowBend, LAYOUT_SCALE, orderTopDown } from './utils'\n\nfunction mapEdgeTypeToArrowhead(type: string | undefined): TLArrowShapeArrowheadStyle {\n\tif (!type) return 'arrow'\n\n\tif (type.includes('point')) return 'arrow'\n\tif (type.includes('circle')) return 'dot'\n\tif (type.includes('cross')) return 'bar'\n\tif (type.includes('open')) return 'none'\n\n\treturn 'arrow'\n}\n\nfunction mapEdgeStrokeToDash(stroke: string | undefined): TLDefaultDashStyle {\n\tif (!stroke) return 'solid'\n\tif (stroke === 'dotted') return 'dotted'\n\treturn 'solid'\n}\n\nconst FRAME_TOP_PAD = 14\n\nfunction buildHierarchy(subGraphs: FlowSubGraph[]) {\n\tconst subGraphIds = new Set(subGraphs.map((subGraph) => subGraph.id))\n\tconst nodeToSubGraph = new Map<string, string>()\n\tconst subGraphParent = new Map<string, string>()\n\tfor (const subGraph of subGraphs) {\n\t\tfor (const nodeId of subGraph.nodes) {\n\t\t\tif (subGraphIds.has(nodeId)) {\n\t\t\t\tsubGraphParent.set(nodeId, subGraph.id)\n\t\t\t} else if (!nodeToSubGraph.has(nodeId)) {\n\t\t\t\tnodeToSubGraph.set(nodeId, subGraph.id)\n\t\t\t}\n\t\t}\n\t}\n\treturn { nodeToSubGraph, subGraphParent }\n}\n\n/** Parse flowchart-specific SVG layout data for use by {@link flowchartToBlueprint}. */\nexport function parseFlowchartLayout(root: Element): ParsedDiagramLayout {\n\t// Mermaid 11.15 prefixes node and cluster dom ids with the diagram id (e.g.\n\t// `mermaid-0-flowchart-s1-0` instead of `flowchart-s1-0`), so tolerate that\n\t// optional `mermaid-<n>-` prefix when reading the clean id.\n\tconst nodes = parseNodesFromSvg(root, '.node', (domId) => {\n\t\tconst match = domId.match(/^(?:mermaid-\\d+-)?flowchart-(.+)-\\d+$/)\n\t\treturn match ? match[1] : domId\n\t})\n\tconst clusters = parseClustersFromSvg(root, '.cluster', (domId) =>\n\t\tdomId.replace(/^mermaid-\\d+-/, '')\n\t)\n\tconst edges = parseAllEdgePointsFromSvg(root, (dataId) => {\n\t\tconst match = dataId.match(/(?:^|-)L_(.+)_([^_]+)_\\d+$/)\n\t\treturn match ? { start: match[1], end: match[2] } : null\n\t})\n\tscaleLayout(nodes, clusters, edges, LAYOUT_SCALE)\n\treturn { nodes, clusters, edges }\n}\n\n/** Convert a parsed Mermaid flowchart into a tldraw blueprint of nodes and edges. */\nexport function flowchartToBlueprint(\n\tlayout: ParsedDiagramLayout,\n\tvertices: Map<string, FlowVertex>,\n\tedges: FlowEdge[],\n\tsubGraphs?: FlowSubGraph[],\n\tclassDefs?: Map<string, FlowClass>\n): DiagramMermaidBlueprint {\n\tconst nodeColorMap = classDefs ? buildClassDefColorMap(classDefs, vertices) : new Map()\n\tconst { nodes: svgNodes, clusters: svgClusters, edges: svgEdges } = layout\n\tconst nodeCenters = buildNodeCentersFromSvg(svgNodes, svgClusters)\n\n\tconst allSubGraphs = subGraphs || []\n\tconst { nodeToSubGraph, subGraphParent } = buildHierarchy(allSubGraphs)\n\n\tconst nodes: MermaidBlueprintNode[] = []\n\tconst blueprintEdges: MermaidBlueprintEdge[] = []\n\n\t// Frames for subgraphs\n\tfor (const subGraph of orderTopDown(\n\t\tallSubGraphs,\n\t\t(subGraph) => subGraph.id,\n\t\t(subGraph) => subGraphParent.get(subGraph.id)\n\t)) {\n\t\tconst cluster = svgClusters.get(subGraph.id)\n\t\tif (!cluster) continue\n\n\t\tconst id = subGraph.id\n\t\tconst kind = 'subgraph'\n\t\tnodes.push({\n\t\t\tid,\n\t\t\tkind,\n\t\t\tx: cluster.topLeft.x,\n\t\t\ty: cluster.topLeft.y - FRAME_TOP_PAD,\n\t\t\tw: cluster.width,\n\t\t\th: cluster.height + FRAME_TOP_PAD,\n\t\t\tparentId: subGraphParent.get(subGraph.id),\n\t\t\tlabel: subGraph.title || subGraph.id,\n\t\t\tfill: 'semi',\n\t\t\tcolor: 'black',\n\t\t\tdash: 'draw',\n\t\t\tsize: 's',\n\t\t\talign: 'middle',\n\t\t\tverticalAlign: 'start',\n\t\t})\n\t}\n\n\t// Node shapes\n\tfor (const [id, vertex] of vertices) {\n\t\tconst svgNode = svgNodes.get(id)\n\t\tif (!svgNode) continue\n\n\t\tconst kind = vertex.type ?? 'rect'\n\t\tconst colors = nodeColorMap.get(id) ?? parseNodeInlineColor(vertex.styles)\n\n\t\tlet { width: w, height: h } = svgNode\n\t\tif (vertex.type === 'circle' || vertex.type === 'doublecircle') {\n\t\t\tw = h = Math.max(w, h)\n\t\t}\n\n\t\tnodes.push({\n\t\t\tid,\n\t\t\tkind,\n\t\t\tx: svgNode.center.x - w / 2,\n\t\t\ty: svgNode.center.y - h / 2,\n\t\t\tw,\n\t\t\th,\n\t\t\tparentId: nodeToSubGraph.get(id),\n\t\t\tlabel: vertex.text || undefined,\n\t\t\t...(colors?.fillColor && { fill: 'solid' as const }),\n\t\t\t...(colors && { color: colors.strokeColor ?? colors.fillColor }),\n\t\t\talign: 'middle',\n\t\t\tverticalAlign: 'middle',\n\t\t\tsize: 'm',\n\t\t})\n\t}\n\n\t// Edges: match DB edges to SVG edges by proximity, compute bends\n\tconst claimed = new Set<number>()\n\tfor (const edge of edges) {\n\t\tconst startCenter = nodeCenters.get(edge.start)\n\t\tconst endCenter = nodeCenters.get(edge.end)\n\n\t\tlet bend = 0\n\t\tif (startCenter && endCenter) {\n\t\t\tlet bestIndex = -1\n\t\t\tlet bestDist = Infinity\n\t\t\tfor (let i = 0; i < svgEdges.length; i++) {\n\t\t\t\tif (claimed.has(i) || svgEdges[i].points.length < 2) continue\n\n\t\t\t\tconst points = svgEdges[i].points\n\t\t\t\tconst distance =\n\t\t\t\t\tMath.hypot(points[0].x - startCenter.x, points[0].y - startCenter.y) +\n\t\t\t\t\tMath.hypot(\n\t\t\t\t\t\tpoints[points.length - 1].x - endCenter.x,\n\t\t\t\t\t\tpoints[points.length - 1].y - endCenter.y\n\t\t\t\t\t)\n\t\t\t\tif (distance < bestDist) {\n\t\t\t\t\tbestDist = distance\n\t\t\t\t\tbestIndex = i\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (bestIndex >= 0) {\n\t\t\t\tclaimed.add(bestIndex)\n\t\t\t\tbend = getArrowBend(svgEdges[bestIndex])\n\t\t\t}\n\t\t}\n\n\t\tconst cssOverrides = edge.style ? parseCssStyles(edge.style) : undefined\n\t\tconst arrowheadEnd = mapEdgeTypeToArrowhead(edge.type)\n\t\tconst dash = cssOverrides?.dashOverride ?? mapEdgeStrokeToDash(edge.stroke)\n\t\tconst size = cssOverrides?.sizeOverride ?? (edge.stroke === 'thick' ? 'l' : 's')\n\n\t\tblueprintEdges.push({\n\t\t\tstartNodeId: edge.start,\n\t\t\tendNodeId: edge.end,\n\t\t\tlabel: edge.text,\n\t\t\tbend,\n\t\t\tarrowheadEnd,\n\t\t\tarrowheadStart: edge.type?.includes('double_arrow') ? arrowheadEnd : undefined,\n\t\t\tdash,\n\t\t\tsize,\n\t\t\tcolor: cssOverrides?.color,\n\t\t})\n\t}\n\n\tconst nodeIds = new Set(nodes.map((n) => n.id))\n\tconst validEdges = blueprintEdges.filter(\n\t\t(e) => nodeIds.has(e.startNodeId) && nodeIds.has(e.endNodeId)\n\t)\n\treturn { diagramKind: 'flowchart', nodes, edges: validEdges }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,oBAA4E;AAC5E,wBAOO;AACP,mBAAyD;AAEzD,SAAS,uBAAuB,MAAsD;AACrF,MAAI,CAAC,KAAM,QAAO;AAElB,MAAI,KAAK,SAAS,OAAO,EAAG,QAAO;AACnC,MAAI,KAAK,SAAS,QAAQ,EAAG,QAAO;AACpC,MAAI,KAAK,SAAS,OAAO,EAAG,QAAO;AACnC,MAAI,KAAK,SAAS,MAAM,EAAG,QAAO;AAElC,SAAO;AACR;AAEA,SAAS,oBAAoB,QAAgD;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uBAAuB,KAAK,IAAI;AACrD,UAAM,OAAO,cAAc,gBAAgB,oBAAoB,KAAK,MAAM;AAC1E,UAAM,OAAO,cAAc,iBAAiB,KAAK,WAAW,UAAU,MAAM;AAE5E,mBAAe,KAAK;AAAA,MACnB,aAAa,KAAK;AAAA,MAClB,WAAW,KAAK;AAAA,MAChB,OAAO,KAAK;AAAA,MACZ;AAAA,MACA;AAAA,MACA,gBAAgB,KAAK,MAAM,SAAS,cAAc,IAAI,eAAe;AAAA,MACrE;AAAA,MACA;AAAA,MACA,OAAO,cAAc;AAAA,IACtB,CAAC;AAAA,EACF;AAEA,QAAM,UAAU,IAAI,IAAI,MAAM,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;AAC9C,QAAM,aAAa,eAAe;AAAA,IACjC,CAAC,MAAM,QAAQ,IAAI,EAAE,WAAW,KAAK,QAAQ,IAAI,EAAE,SAAS;AAAA,EAC7D;AACA,SAAO,EAAE,aAAa,aAAa,OAAO,OAAO,WAAW;AAC7D;",
6
6
  "names": ["subGraph"]
7
7
  }
package/dist-cjs/index.js CHANGED
@@ -35,7 +35,7 @@ var import_mermaidNodeCreateShape = require("./mermaidNodeCreateShape");
35
35
  var import_renderBlueprint = require("./renderBlueprint");
36
36
  (0, import_utils.registerTldrawLibraryVersion)(
37
37
  "@tldraw/mermaid",
38
- "5.1.0",
38
+ "5.2.0-canary.019da1aa690a",
39
39
  "cjs"
40
40
  );
41
41
  //# sourceMappingURL=index.js.map
@@ -55,7 +55,7 @@ function flattenMindmapTree(node, parentId, out) {
55
55
  }
56
56
  }
57
57
  function parseMindmapNodeId(domId) {
58
- const match = domId.match(/^node_(\d+)$/);
58
+ const match = domId.match(/^(?:mermaid-\d+-)?node_(\d+)$/);
59
59
  return match ? match[1] : domId;
60
60
  }
61
61
  function parseMindmapLayout(root) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/mindmapDiagram.ts"],
4
- "sourcesContent": ["import type { MindmapNode } from 'mermaid/dist/diagrams/mindmap/mindmapTypes.js'\nimport type { TLDefaultColorStyle, TLDefaultSizeStyle } from 'tldraw'\nimport type {\n\tDiagramMermaidBlueprint,\n\tMermaidBlueprintEdge,\n\tMermaidBlueprintNode,\n} from './blueprint'\nimport { parseRgbToTldrawColor } from './colors'\nimport { parseNodesFromSvg, scaleLayout } from './svgParsing'\nimport type { ParsedNode } from './svgParsing'\nimport { LAYOUT_SCALE } from './utils'\n\n/** Mermaid mindmap node `type` integers (`kind` on blueprint nodes is `String(type)`). @public */\nexport const MERMAID_MINDMAP_NODE_TYPE = {\n\tDEFAULT: 0,\n\tROUNDED_RECT: 1,\n\tRECT: 2,\n\tCIRCLE: 3,\n\tCLOUD: 4,\n\tBANG: 5,\n\tHEXAGON: 6,\n} as const\n\nfunction getEdgeSizeForLevel(parentLevel: number): TLDefaultSizeStyle {\n\tif (parentLevel <= 0) return 'l'\n\tif (parentLevel === 1) return 'm'\n\treturn 's'\n}\n\ninterface FlatNode {\n\tid: string\n\tlabel: string\n\ttype: number\n\tlevel: number\n\tparentId: string | undefined\n\tsection: number | undefined\n\tisRoot: boolean\n}\n\nfunction flattenMindmapTree(\n\tnode: MindmapNode,\n\tparentId: string | undefined,\n\tout: FlatNode[]\n): void {\n\tout.push({\n\t\tid: String(node.id),\n\t\tlabel: node.descr,\n\t\ttype: node.type,\n\t\tlevel: node.level,\n\t\tparentId,\n\t\tsection: node.section,\n\t\tisRoot: !!node.isRoot,\n\t})\n\tfor (const child of node.children) {\n\t\tflattenMindmapTree(child, String(node.id), out)\n\t}\n}\n\n/**\n * Pre-parsed SVG layout for mindmap diagram converters.\n * Contains already-scaled node positions extracted from the SVG.\n */\nexport interface ParsedMindmapLayout {\n\tnodes: Map<string, ParsedNode>\n}\n\nfunction parseMindmapNodeId(domId: string): string {\n\tconst match = domId.match(/^node_(\\d+)$/)\n\treturn match ? match[1] : domId\n}\n\n/** Parse mindmap-specific SVG layout data for use by {@link mindmapToBlueprint}. */\nexport function parseMindmapLayout(root: Element): ParsedMindmapLayout {\n\tconst nodes = parseNodesFromSvg(root, '.node', parseMindmapNodeId)\n\tscaleLayout(nodes, new Map(), [], LAYOUT_SCALE)\n\treturn { nodes }\n}\n\n/** Convert a parsed Mermaid mindmap into a tldraw blueprint of nodes and edges. */\nexport function mindmapToBlueprint(\n\tlayout: ParsedMindmapLayout,\n\tmindmapTree: MindmapNode,\n\tsvgRoot: Element\n): DiagramMermaidBlueprint {\n\tconst flatNodes: FlatNode[] = []\n\tflattenMindmapTree(mindmapTree, undefined, flatNodes)\n\n\tconst { nodes: svgNodes } = layout\n\n\tconst nodeColors = new Map<string, TLDefaultColorStyle>()\n\tfor (const el of svgRoot.querySelectorAll('.node')) {\n\t\tconst rawId = el.getAttribute('id') || ''\n\t\tconst id = parseMindmapNodeId(rawId)\n\t\tconst shape =\n\t\t\tel.querySelector('rect, circle, ellipse, polygon, path') ??\n\t\t\tel.querySelector('.label-container')\n\t\tif (shape) {\n\t\t\tconst parsed = parseRgbToTldrawColor(getComputedStyle(shape as Element).fill)\n\t\t\tif (parsed) nodeColors.set(id, parsed.color)\n\t\t}\n\t}\n\n\tconst nodes: MermaidBlueprintNode[] = []\n\tconst edges: MermaidBlueprintEdge[] = []\n\tconst levelById = new Map(flatNodes.map((n) => [n.id, n.level]))\n\n\tfor (const flatNode of flatNodes) {\n\t\tconst svgNode = svgNodes.get(flatNode.id)\n\t\tif (!svgNode) continue\n\n\t\tconst kind = String(flatNode.type)\n\t\tconst color = nodeColors.get(flatNode.id) ?? 'black'\n\n\t\tlet { width: w, height: h } = svgNode\n\t\tif (flatNode.type === MERMAID_MINDMAP_NODE_TYPE.CIRCLE) {\n\t\t\tw = h = Math.max(w, h)\n\t\t}\n\n\t\tconst id = flatNode.id\n\t\tnodes.push({\n\t\t\tid,\n\t\t\tkind,\n\t\t\tx: svgNode.center.x - w / 2,\n\t\t\ty: svgNode.center.y - h / 2,\n\t\t\tw,\n\t\t\th,\n\t\t\tlabel: flatNode.label || undefined,\n\t\t\tfill: 'solid',\n\t\t\tcolor,\n\t\t\tsize: flatNode.isRoot ? 'l' : 'm',\n\t\t\talign: 'middle',\n\t\t\tverticalAlign: 'middle',\n\t\t})\n\n\t\t// Edge from parent to this node\n\t\tif (flatNode.parentId) {\n\t\t\tconst parentLevel = levelById.get(flatNode.parentId) ?? 0\n\t\t\tedges.push({\n\t\t\t\tstartNodeId: flatNode.parentId,\n\t\t\t\tendNodeId: flatNode.id,\n\t\t\t\tbend: 0,\n\t\t\t\tarrowheadEnd: 'none',\n\t\t\t\tarrowheadStart: 'none',\n\t\t\t\tsize: getEdgeSizeForLevel(parentLevel),\n\t\t\t\tcolor,\n\t\t\t})\n\t\t}\n\t}\n\n\tconst nodeIds = new Set(nodes.map((n) => n.id))\n\tconst validEdges = edges.filter((e) => nodeIds.has(e.startNodeId) && nodeIds.has(e.endNodeId))\n\treturn { diagramKind: 'mindmap', nodes, edges: validEdges }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,oBAAsC;AACtC,wBAA+C;AAE/C,mBAA6B;AAGtB,MAAM,4BAA4B;AAAA,EACxC,SAAS;AAAA,EACT,cAAc;AAAA,EACd,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,MAAM;AAAA,EACN,SAAS;AACV;AAEA,SAAS,oBAAoB,aAAyC;AACrE,MAAI,eAAe,EAAG,QAAO;AAC7B,MAAI,gBAAgB,EAAG,QAAO;AAC9B,SAAO;AACR;AAYA,SAAS,mBACR,MACA,UACA,KACO;AACP,MAAI,KAAK;AAAA,IACR,IAAI,OAAO,KAAK,EAAE;AAAA,IAClB,OAAO,KAAK;AAAA,IACZ,MAAM,KAAK;AAAA,IACX,OAAO,KAAK;AAAA,IACZ;AAAA,IACA,SAAS,KAAK;AAAA,IACd,QAAQ,CAAC,CAAC,KAAK;AAAA,EAChB,CAAC;AACD,aAAW,SA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C9B,QAAI,SAAS,SAAS,0BAA0B,QAAQ;AACvD,UAAI,IAAI,KAAK,IAAI,GAAG,CAAC;AAAA,IACtB;AAEA,UAAM,KAAK,SAAS;AACpB,UAAM,KAAK;AAAA,MACV;AAAA,MACA;AAAA,MACA,GAAG,QAAQ,OAAO,IAAI,IAAI;AAAA,MAC1B,GAAG,QAAQ,OAAO,IAAI,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,OAAO,SAAS,SAAS;AAAA,MACzB,MAAM;AAAA,MACN;AAAA,MACA,MAAM,SAAS,SAAS,MAAM;AAAA,MAC9B,OAAO;AAAA,MACP,eAAe;AAAA,IAChB,CAAC;AAGD,QAAI,SAAS,UAAU;AACtB,YAAM,cAAc,UAAU,IAAI,SAAS,QAAQ,KAAK;AACxD,YAAM,KAAK;AAAA,QACV,aAAa,SAAS;AAAA,QACtB,WAAW,SAAS;AAAA,QACpB,MAAM;AAAA,QACN,cAAc;AAAA,QACd,gBAAgB;AAAA,QAChB,MAAM,oBAAoB,WAAW;AAAA,QACrC;AAAA,MACD,CAAC;AAAA,IACF;AAAA,EACD;AAEA,QAAM,UAAU,IAAI,IAAI,MAAM,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;AAC9C,QAAM,aAAa,MAAM,OAAO,CAAC,MAAM,QAAQ,IAAI,EAAE,WAAW,KAAK,QAAQ,IAAI,EAAE,SAAS,CAAC;AAC7F,SAAO,EAAE,aAAa,WAAW,OAAO,OAAO,WAAW;AAC3D;",
4
+ "sourcesContent": ["import type { MindmapNode } from 'mermaid/dist/diagrams/mindmap/mindmapTypes.js'\nimport type { TLDefaultColorStyle, TLDefaultSizeStyle } from 'tldraw'\nimport type {\n\tDiagramMermaidBlueprint,\n\tMermaidBlueprintEdge,\n\tMermaidBlueprintNode,\n} from './blueprint'\nimport { parseRgbToTldrawColor } from './colors'\nimport { parseNodesFromSvg, scaleLayout } from './svgParsing'\nimport type { ParsedNode } from './svgParsing'\nimport { LAYOUT_SCALE } from './utils'\n\n/** Mermaid mindmap node `type` integers (`kind` on blueprint nodes is `String(type)`). @public */\nexport const MERMAID_MINDMAP_NODE_TYPE = {\n\tDEFAULT: 0,\n\tROUNDED_RECT: 1,\n\tRECT: 2,\n\tCIRCLE: 3,\n\tCLOUD: 4,\n\tBANG: 5,\n\tHEXAGON: 6,\n} as const\n\nfunction getEdgeSizeForLevel(parentLevel: number): TLDefaultSizeStyle {\n\tif (parentLevel <= 0) return 'l'\n\tif (parentLevel === 1) return 'm'\n\treturn 's'\n}\n\ninterface FlatNode {\n\tid: string\n\tlabel: string\n\ttype: number\n\tlevel: number\n\tparentId: string | undefined\n\tsection: number | undefined\n\tisRoot: boolean\n}\n\nfunction flattenMindmapTree(\n\tnode: MindmapNode,\n\tparentId: string | undefined,\n\tout: FlatNode[]\n): void {\n\tout.push({\n\t\tid: String(node.id),\n\t\tlabel: node.descr,\n\t\ttype: node.type,\n\t\tlevel: node.level,\n\t\tparentId,\n\t\tsection: node.section,\n\t\tisRoot: !!node.isRoot,\n\t})\n\tfor (const child of node.children) {\n\t\tflattenMindmapTree(child, String(node.id), out)\n\t}\n}\n\n/**\n * Pre-parsed SVG layout for mindmap diagram converters.\n * Contains already-scaled node positions extracted from the SVG.\n */\nexport interface ParsedMindmapLayout {\n\tnodes: Map<string, ParsedNode>\n}\n\nfunction parseMindmapNodeId(domId: string): string {\n\tconst match = domId.match(/^(?:mermaid-\\d+-)?node_(\\d+)$/)\n\treturn match ? match[1] : domId\n}\n\n/** Parse mindmap-specific SVG layout data for use by {@link mindmapToBlueprint}. */\nexport function parseMindmapLayout(root: Element): ParsedMindmapLayout {\n\tconst nodes = parseNodesFromSvg(root, '.node', parseMindmapNodeId)\n\tscaleLayout(nodes, new Map(), [], LAYOUT_SCALE)\n\treturn { nodes }\n}\n\n/** Convert a parsed Mermaid mindmap into a tldraw blueprint of nodes and edges. */\nexport function mindmapToBlueprint(\n\tlayout: ParsedMindmapLayout,\n\tmindmapTree: MindmapNode,\n\tsvgRoot: Element\n): DiagramMermaidBlueprint {\n\tconst flatNodes: FlatNode[] = []\n\tflattenMindmapTree(mindmapTree, undefined, flatNodes)\n\n\tconst { nodes: svgNodes } = layout\n\n\tconst nodeColors = new Map<string, TLDefaultColorStyle>()\n\tfor (const el of svgRoot.querySelectorAll('.node')) {\n\t\tconst rawId = el.getAttribute('id') || ''\n\t\tconst id = parseMindmapNodeId(rawId)\n\t\tconst shape =\n\t\t\tel.querySelector('rect, circle, ellipse, polygon, path') ??\n\t\t\tel.querySelector('.label-container')\n\t\tif (shape) {\n\t\t\tconst parsed = parseRgbToTldrawColor(getComputedStyle(shape as Element).fill)\n\t\t\tif (parsed) nodeColors.set(id, parsed.color)\n\t\t}\n\t}\n\n\tconst nodes: MermaidBlueprintNode[] = []\n\tconst edges: MermaidBlueprintEdge[] = []\n\tconst levelById = new Map(flatNodes.map((n) => [n.id, n.level]))\n\n\tfor (const flatNode of flatNodes) {\n\t\tconst svgNode = svgNodes.get(flatNode.id)\n\t\tif (!svgNode) continue\n\n\t\tconst kind = String(flatNode.type)\n\t\tconst color = nodeColors.get(flatNode.id) ?? 'black'\n\n\t\tlet { width: w, height: h } = svgNode\n\t\tif (flatNode.type === MERMAID_MINDMAP_NODE_TYPE.CIRCLE) {\n\t\t\tw = h = Math.max(w, h)\n\t\t}\n\n\t\tconst id = flatNode.id\n\t\tnodes.push({\n\t\t\tid,\n\t\t\tkind,\n\t\t\tx: svgNode.center.x - w / 2,\n\t\t\ty: svgNode.center.y - h / 2,\n\t\t\tw,\n\t\t\th,\n\t\t\tlabel: flatNode.label || undefined,\n\t\t\tfill: 'solid',\n\t\t\tcolor,\n\t\t\tsize: flatNode.isRoot ? 'l' : 'm',\n\t\t\talign: 'middle',\n\t\t\tverticalAlign: 'middle',\n\t\t})\n\n\t\t// Edge from parent to this node\n\t\tif (flatNode.parentId) {\n\t\t\tconst parentLevel = levelById.get(flatNode.parentId) ?? 0\n\t\t\tedges.push({\n\t\t\t\tstartNodeId: flatNode.parentId,\n\t\t\t\tendNodeId: flatNode.id,\n\t\t\t\tbend: 0,\n\t\t\t\tarrowheadEnd: 'none',\n\t\t\t\tarrowheadStart: 'none',\n\t\t\t\tsize: getEdgeSizeForLevel(parentLevel),\n\t\t\t\tcolor,\n\t\t\t})\n\t\t}\n\t}\n\n\tconst nodeIds = new Set(nodes.map((n) => n.id))\n\tconst validEdges = edges.filter((e) => nodeIds.has(e.startNodeId) && nodeIds.has(e.endNodeId))\n\treturn { diagramKind: 'mindmap', nodes, edges: validEdges }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,oBAAsC;AACtC,wBAA+C;AAE/C,mBAA6B;AAGtB,MAAM,4BAA4B;AAAA,EACxC,SAAS;AAAA,EACT,cAAc;AAAA,EACd,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,MAAM;AAAA,EACN,SAAS;AACV;AAEA,SAAS,oBAAoB,aAAyC;AACrE,MAAI,eAAe,EAAG,QAAO;AAC7B,MAAI,gBAAgB,EAAG,QAAO;AAC9B,SAAO;AACR;AAYA,SAAS,mBACR,MACA,UACA,KACO;AACP,MAAI,KAAK;AAAA,IACR,IAAI,OAAO,KAAK,EAAE;AAAA,IAClB,OAAO,KAAK;AAAA,IACZ,MAAM,KAAK;AAAA,IACX,OAAO,KAAK;AAAA,IACZ;AAAA,IACA,SAAS,KAAK;AAAA,IACd,QAAQ,CAAC,CAAC,KAAK;AAAA,EAChB,CAAC;AACD,aAAW,SAAS,KAAK,UAAU;AAClC,uBAAmB,OAAO,OAAO,KAAK,EAAE,GAAG,GAAG;AAAA,EAC/C;AACD;AAUA,SAAS,mBAAmB,OAAuB;AAClD,QAAM,QAAQ,MAAM,MAAM,+BAA+B;AACzD,SAAO,QAAQ,MAAM,CAAC,IAAI;AAC3B;AAGO,SAAS,mBAAmB,MAAoC;AACtE,QAAM,YAAQ,qCAAkB,MAAM,SA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AAA,MACA;AAAA,MACA,OAAO,SAAS,SAAS;AAAA,MACzB,MAAM;AAAA,MACN;AAAA,MACA,MAAM,SAAS,SAAS,MAAM;AAAA,MAC9B,OAAO;AAAA,MACP,eAAe;AAAA,IAChB,CAAC;AAGD,QAAI,SAAS,UAAU;AACtB,YAAM,cAAc,UAAU,IAAI,SAAS,QAAQ,KAAK;AACxD,YAAM,KAAK;AAAA,QACV,aAAa,SAAS;AAAA,QACtB,WAAW,SAAS;AAAA,QACpB,MAAM;AAAA,QACN,cAAc;AAAA,QACd,gBAAgB;AAAA,QAChB,MAAM,oBAAoB,WAAW;AAAA,QACrC;AAAA,MACD,CAAC;AAAA,IACF;AAAA,EACD;AAEA,QAAM,UAAU,IAAI,IAAI,MAAM,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;AAC9C,QAAM,aAAa,MAAM,OAAO,CAAC,MAAM,QAAQ,IAAI,EAAE,WAAW,KAAK,QAAQ,IAAI,EAAE,SAAS,CAAC;AAC7F,SAAO,EAAE,aAAa,WAAW,OAAO,OAAO,WAAW;AAC3D;",
6
6
  "names": []
7
7
  }
@@ -57,7 +57,26 @@ const LINETYPE = {
57
57
  BREAK_END: 31,
58
58
  PAR_OVER_START: 32,
59
59
  BIDIRECTIONAL_SOLID: 33,
60
- BIDIRECTIONAL_DOTTED: 34
60
+ BIDIRECTIONAL_DOTTED: 34,
61
+ SOLID_TOP: 41,
62
+ SOLID_BOTTOM: 42,
63
+ STICK_TOP: 43,
64
+ STICK_BOTTOM: 44,
65
+ SOLID_ARROW_TOP_REVERSE: 45,
66
+ SOLID_ARROW_BOTTOM_REVERSE: 46,
67
+ STICK_ARROW_TOP_REVERSE: 47,
68
+ STICK_ARROW_BOTTOM_REVERSE: 48,
69
+ SOLID_TOP_DOTTED: 51,
70
+ SOLID_BOTTOM_DOTTED: 52,
71
+ STICK_TOP_DOTTED: 53,
72
+ STICK_BOTTOM_DOTTED: 54,
73
+ SOLID_ARROW_TOP_REVERSE_DOTTED: 55,
74
+ SOLID_ARROW_BOTTOM_REVERSE_DOTTED: 56,
75
+ STICK_ARROW_TOP_REVERSE_DOTTED: 57,
76
+ STICK_ARROW_BOTTOM_REVERSE_DOTTED: 58,
77
+ CENTRAL_CONNECTION: 59,
78
+ CENTRAL_CONNECTION_REVERSE: 60,
79
+ CENTRAL_CONNECTION_DUAL: 61
61
80
  };
62
81
  const PLACEMENT = {
63
82
  LEFTOF: 0,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/sequenceDiagram.ts"],
4
- "sourcesContent": ["import type { SequenceDB } from 'mermaid/dist/diagrams/sequence/sequenceDb.d.ts'\nimport type { Actor, Message } from 'mermaid/dist/diagrams/sequence/types.js'\nimport { TLArrowShapeArrowheadStyle, TLDefaultDashStyle } from 'tldraw'\nimport type {\n\tDiagramMermaidBlueprint,\n\tMermaidBlueprintEdge,\n\tMermaidBlueprintNode,\n\tMermaidBlueprintLineNode,\n} from './blueprint'\nimport { parseRgbToTldrawColor } from './colors'\nimport { getAccumulatedTranslate } from './svgParsing'\n\nexport interface SvgRect {\n\tx: number\n\ty: number\n\tw: number\n\th: number\n}\n\nexport interface ActorLayout {\n\tx: number\n\ty: number\n\tw: number\n\th: number\n\tbottomY: number\n}\n\nexport interface ParsedSequenceLayout {\n\tactorLayouts: ActorLayout[]\n\tnoteRects: SvgRect[]\n}\n\nconst LINETYPE = {\n\tSOLID: 0,\n\tDOTTED: 1,\n\tNOTE: 2,\n\tSOLID_CROSS: 3,\n\tDOTTED_CROSS: 4,\n\tSOLID_OPEN: 5,\n\tDOTTED_OPEN: 6,\n\tLOOP_START: 10,\n\tLOOP_END: 11,\n\tALT_START: 12,\n\tALT_ELSE: 13,\n\tALT_END: 14,\n\tOPT_START: 15,\n\tOPT_END: 16,\n\tACTIVE_START: 17,\n\tACTIVE_END: 18,\n\tPAR_START: 19,\n\tPAR_AND: 20,\n\tPAR_END: 21,\n\tRECT_START: 22,\n\tRECT_END: 23,\n\tSOLID_POINT: 24,\n\tDOTTED_POINT: 25,\n\tAUTONUMBER: 26,\n\tCRITICAL_START: 27,\n\tCRITICAL_OPTION: 28,\n\tCRITICAL_END: 29,\n\tBREAK_START: 30,\n\tBREAK_END: 31,\n\tPAR_OVER_START: 32,\n\tBIDIRECTIONAL_SOLID: 33,\n\tBIDIRECTIONAL_DOTTED: 34,\n} as const satisfies SequenceDB['LINETYPE']\n\nconst PLACEMENT = {\n\tLEFTOF: 0,\n\tRIGHTOF: 1,\n\tOVER: 2,\n} as const satisfies SequenceDB['PLACEMENT']\n\nconst signalTypes: number[] = [\n\tLINETYPE.SOLID,\n\tLINETYPE.DOTTED,\n\tLINETYPE.SOLID_CROSS,\n\tLINETYPE.DOTTED_CROSS,\n\tLINETYPE.SOLID_OPEN,\n\tLINETYPE.DOTTED_OPEN,\n\tLINETYPE.SOLID_POINT,\n\tLINETYPE.DOTTED_POINT,\n\tLINETYPE.BIDIRECTIONAL_SOLID,\n\tLINETYPE.BIDIRECTIONAL_DOTTED,\n]\n\nfunction isSignalMessage(type: number | undefined): boolean {\n\tif (type === undefined) return false\n\treturn signalTypes.includes(type)\n}\n\nfunction isNoteMessage(type: number | undefined): boolean {\n\treturn type === LINETYPE.NOTE\n}\n\nfunction isActiveStart(type: number | undefined): boolean {\n\treturn type === LINETYPE.ACTIVE_START\n}\n\nfunction isActiveEnd(type: number | undefined): boolean {\n\treturn type === LINETYPE.ACTIVE_END\n}\n\nfunction isAutonumber(type: number | undefined): boolean {\n\treturn type === LINETYPE.AUTONUMBER\n}\n\n/** Returns the fragment keyword (e.g. \"loop\", \"opt\") if this message starts a combined fragment, or null. */\nfunction getFragmentStartKeyword(type: number | undefined): string | null {\n\tif (type === undefined) return null\n\tif (type === LINETYPE.LOOP_START) return 'loop'\n\tif (type === LINETYPE.ALT_START) return 'alt'\n\tif (type === LINETYPE.OPT_START) return 'opt'\n\tif (type === LINETYPE.PAR_START) return 'par'\n\tif (type === LINETYPE.RECT_START) return 'rect'\n\tif (type === LINETYPE.CRITICAL_START) return 'critical'\n\tif (type === LINETYPE.BREAK_START) return 'break'\n\tif (type === LINETYPE.PAR_OVER_START) return 'par'\n\treturn null\n}\n\nfunction isFragmentEnd(type: number | undefined): boolean {\n\tif (type === undefined) return false\n\tconst endTypes: number[] = [\n\t\tLINETYPE.LOOP_END,\n\t\tLINETYPE.ALT_END,\n\t\tLINETYPE.OPT_END,\n\t\tLINETYPE.PAR_END,\n\t\tLINETYPE.RECT_END,\n\t\tLINETYPE.CRITICAL_END,\n\t\tLINETYPE.BREAK_END,\n\t]\n\treturn endTypes.includes(type)\n}\n\n/** Returns a keyword if this message is a section separator within a combined fragment, or null. */\nfunction getFragmentSeparatorKeyword(type: number | undefined): string | null {\n\tif (type === LINETYPE.ALT_ELSE) return 'else'\n\tif (type === LINETYPE.PAR_AND) return 'and'\n\tif (type === LINETYPE.CRITICAL_OPTION) return 'option'\n\treturn null\n}\n\n/** Map a Mermaid LINETYPE value to tldraw arrow props. */\nfunction mapLineTypeToArrowProps(type: number): {\n\tdash: TLDefaultDashStyle\n\tarrowheadEnd: TLArrowShapeArrowheadStyle\n} {\n\tswitch (type) {\n\t\tcase LINETYPE.SOLID:\n\t\t\treturn { dash: 'solid', arrowheadEnd: 'arrow' }\n\t\tcase LINETYPE.DOTTED:\n\t\t\treturn { dash: 'dotted', arrowheadEnd: 'arrow' }\n\t\tcase LINETYPE.SOLID_CROSS:\n\t\t\treturn { dash: 'solid', arrowheadEnd: 'bar' }\n\t\tcase LINETYPE.DOTTED_CROSS:\n\t\t\treturn { dash: 'dotted', arrowheadEnd: 'bar' }\n\t\tcase LINETYPE.SOLID_OPEN:\n\t\t\treturn { dash: 'solid', arrowheadEnd: 'none' }\n\t\tcase LINETYPE.DOTTED_OPEN:\n\t\t\treturn { dash: 'dotted', arrowheadEnd: 'none' }\n\t\tcase LINETYPE.SOLID_POINT:\n\t\t\treturn { dash: 'solid', arrowheadEnd: 'arrow' }\n\t\tcase LINETYPE.DOTTED_POINT:\n\t\t\treturn { dash: 'dotted', arrowheadEnd: 'arrow' }\n\t\tcase LINETYPE.BIDIRECTIONAL_SOLID:\n\t\t\treturn { dash: 'solid', arrowheadEnd: 'arrow' }\n\t\tcase LINETYPE.BIDIRECTIONAL_DOTTED:\n\t\t\treturn { dash: 'dotted', arrowheadEnd: 'arrow' }\n\t\tdefault:\n\t\t\treturn { dash: 'solid', arrowheadEnd: 'arrow' }\n\t}\n}\n\nfunction isBidirectional(type: number): boolean {\n\treturn type === LINETYPE.BIDIRECTIONAL_SOLID || type === LINETYPE.BIDIRECTIONAL_DOTTED\n}\n\nconst TARGET_ACTOR_SPACING = 300\nconst MIN_VERTICAL_GAP = 400\nconst FALLBACK_ACTOR_WIDTH = 200\nconst FALLBACK_ACTOR_HEIGHT = 70\nconst FALLBACK_ACTOR_SPACING = 100\nconst FALLBACK_EVENT_SPACING = 80\nconst FALLBACK_NOTE_WIDTH = 120\nconst FALLBACK_NOTE_HEIGHT = 50\nconst NOTE_PADDING = 5\n// tldraw's hand-drawn font is wider than Mermaid's default, so we estimate\n// the minimum note width from the label text to prevent wrapping.\nconst NOTE_CHAR_WIDTH = 11\nconst NOTE_TEXT_PADDING = 40\nconst FRAGMENT_PADDING_X = 30\nconst FRAGMENT_PADDING_TOP = 50\nconst FRAGMENT_PADDING_BOTTOM = 25\nconst ACTOR_PADDING_WIDTH = 30\nconst ACTOR_PADDING_HEIGHT = 10\nconst SELF_MSG_Y_OFFSET = 0.04\nconst SELF_MSG_BEND = -80\nconst ACTIVATION_BOX_WIDTH = 20\nconst ACTIVATION_NEST_OFFSET = 6\nconst ACTIVATION_PAD_RATIO = 0.15\nconst FRAGMENT_SECTION_LABEL_HEIGHT = 25\nconst FRAGMENT_SECTION_LABEL_PADDING = 5\n\ninterface FragmentSection {\n\ttitle: string\n\tfirstEventIndex: number\n}\n\ninterface OpenFragment {\n\tkeyword: string\n\tsections: FragmentSection[]\n\tfirstEventIndex: number\n\tactorKeys: Set<string>\n}\n\ninterface FragmentSpan extends OpenFragment {\n\tlastEventIndex: number\n}\n\ninterface ActivationSpan {\n\tparticipantKey: string\n\tstartEventIndex: number\n\tendEventIndex: number\n}\n\nfunction parseSvgRects(root: Element, selector: string): SvgRect[] {\n\tconst results: SvgRect[] = []\n\tfor (const rect of root.querySelectorAll(selector)) {\n\t\tconst ancestor = getAccumulatedTranslate(rect)\n\t\tconst x = parseFloat(rect.getAttribute('x') || '0')\n\t\tconst y = parseFloat(rect.getAttribute('y') || '0')\n\t\tconst w = parseFloat(rect.getAttribute('width') || '0')\n\t\tconst h = parseFloat(rect.getAttribute('height') || '0')\n\t\tif (w > 0 && h > 0) {\n\t\t\tresults.push({\n\t\t\t\tx: Number.isFinite(ancestor.x + x) ? ancestor.x + x : 0,\n\t\t\t\ty: Number.isFinite(ancestor.y + y) ? ancestor.y + y : 0,\n\t\t\t\tw,\n\t\t\t\th,\n\t\t\t})\n\t\t}\n\t}\n\treturn results\n}\n\n/**\n * Stick-figure (actor) participants use SVG <line> elements instead of <rect>.\n * We derive bounding rectangles from the min/max coordinates of each actor-man group.\n */\nfunction parseActorManRects(root: Element): SvgRect[] {\n\tconst results: SvgRect[] = []\n\tfor (const group of root.querySelectorAll('g.actor-man')) {\n\t\tconst ancestor = getAccumulatedTranslate(group)\n\t\tlet minX = Infinity\n\t\tlet minY = Infinity\n\t\tlet maxX = -Infinity\n\t\tlet maxY = -Infinity\n\t\tfor (const line of group.querySelectorAll('line')) {\n\t\t\tfor (const attr of ['x1', 'x2']) {\n\t\t\t\tconst coord = parseFloat(line.getAttribute(attr) || '0')\n\t\t\t\tif (coord < minX) minX = coord\n\t\t\t\tif (coord > maxX) maxX = coord\n\t\t\t}\n\t\t\tfor (const attr of ['y1', 'y2']) {\n\t\t\t\tconst coord = parseFloat(line.getAttribute(attr) || '0')\n\t\t\t\tif (coord < minY) minY = coord\n\t\t\t\tif (coord > maxY) maxY = coord\n\t\t\t}\n\t\t}\n\t\tif (Number.isFinite(minX) && Number.isFinite(minY)) {\n\t\t\tresults.push({\n\t\t\t\tx: ancestor.x + minX,\n\t\t\t\ty: ancestor.y + minY,\n\t\t\t\tw: maxX - minX || FALLBACK_ACTOR_WIDTH,\n\t\t\t\th: maxY - minY || FALLBACK_ACTOR_HEIGHT,\n\t\t\t})\n\t\t}\n\t}\n\treturn results\n}\n\nfunction computeActorLayouts(root: Element, actorCount: number, eventCount: number): ActorLayout[] {\n\tconst byX = (a: SvgRect, b: SvgRect) => a.x - b.x\n\tlet top = parseSvgRects(root, 'rect.actor-top').sort(byX)\n\tlet bottom = parseSvgRects(root, 'rect.actor-bottom').sort(byX)\n\n\tconst actorManRects = parseActorManRects(root).sort(byX)\n\tif (actorManRects.length > 0 && (top.length < actorCount || bottom.length < actorCount)) {\n\t\tconst midY =\n\t\t\ttop.length > 0 && bottom.length > 0\n\t\t\t\t? (Math.max(...top.map((r) => r.y + r.h)) + Math.min(...bottom.map((r) => r.y))) / 2\n\t\t\t\t: actorManRects.length >= 2\n\t\t\t\t\t? (actorManRects[0].y + actorManRects[actorManRects.length - 1].y) / 2\n\t\t\t\t\t: 0\n\t\tfor (const rect of actorManRects) {\n\t\t\tif (rect.y < midY) top.push(rect)\n\t\t\telse bottom.push(rect)\n\t\t}\n\t\ttop.sort(byX)\n\t\tbottom.sort(byX)\n\t}\n\n\tif (top.length < actorCount || bottom.length < actorCount) {\n\t\tconst all = parseSvgRects(root, 'rect[class*=\"actor\"]').sort((a, b) => a.y - b.y)\n\t\tif (all.length >= 2 * actorCount) {\n\t\t\tlet maxGap = 0\n\t\t\tlet splitAt = actorCount\n\t\t\tfor (let i = 1; i < all.length; i++) {\n\t\t\t\tconst gap = all[i].y - all[i - 1].y\n\t\t\t\tif (gap > maxGap) {\n\t\t\t\t\tmaxGap = gap\n\t\t\t\t\tsplitAt = i\n\t\t\t\t}\n\t\t\t}\n\t\t\ttop = all.slice(0, splitAt).sort(byX).slice(0, actorCount)\n\t\t\tbottom = all.slice(splitAt).sort(byX).slice(0, actorCount)\n\t\t} else {\n\t\t\ttop = []\n\t\t\tbottom = []\n\t\t}\n\t} else {\n\t\ttop = top.slice(0, actorCount)\n\t\tbottom = bottom.slice(0, actorCount)\n\t}\n\n\tif (actorManRects.length > 0) {\n\t\tconst actorManSet = new Set<SvgRect>(actorManRects)\n\t\tconst regularTops = top.filter((r) => !actorManSet.has(r))\n\t\tconst regularBottoms = bottom.filter((r) => !actorManSet.has(r))\n\t\tconst refHeight =\n\t\t\tregularTops.length > 0 ? Math.max(...regularTops.map((r) => r.h)) : FALLBACK_ACTOR_HEIGHT\n\t\tconst refWidth =\n\t\t\tregularTops.length > 0 ? Math.max(...regularTops.map((r) => r.w)) : FALLBACK_ACTOR_WIDTH\n\t\tconst refTopY = regularTops.length > 0 ? Math.min(...regularTops.map((r) => r.y)) : undefined\n\t\tconst refBottomEndY =\n\t\t\tregularBottoms.length > 0 ? Math.max(...regularBottoms.map((r) => r.y + r.h)) : undefined\n\n\t\tfor (const rect of top) {\n\t\t\tif (!actorManSet.has(rect)) continue\n\t\t\tconst centerY = rect.y + rect.h / 2\n\t\t\trect.h = refHeight\n\t\t\trect.w = Math.max(rect.w, refWidth)\n\t\t\trect.y = refTopY !== undefined ? refTopY : centerY - refHeight / 2\n\t\t}\n\t\tfor (const rect of bottom) {\n\t\t\tif (!actorManSet.has(rect)) continue\n\t\t\tconst centerY = rect.y + rect.h / 2\n\t\t\trect.h = refHeight\n\t\t\trect.w = Math.max(rect.w, refWidth)\n\t\t\trect.y = refBottomEndY !== undefined ? refBottomEndY - refHeight : centerY - refHeight / 2\n\t\t}\n\t}\n\n\tif (top.length >= actorCount && bottom.length >= actorCount) {\n\t\tconst svgCenters = top.map((r) => r.x + r.w / 2)\n\t\tconst spacings: number[] = []\n\t\tfor (let i = 1; i < svgCenters.length; i++) {\n\t\t\tspacings.push(svgCenters[i] - svgCenters[i - 1])\n\t\t}\n\t\tconst minSpacing = spacings.length > 0 ? Math.min(...spacings) : 1\n\t\tconst scale = Math.max(1, TARGET_ACTOR_SPACING / minSpacing)\n\n\t\tconst xCenters = svgCenters.map((c) => (c - svgCenters[0]) * scale)\n\t\tconst totalSpan = xCenters.length > 1 ? xCenters[xCenters.length - 1] : 0\n\n\t\tconst topRowBottom = Math.max(...top.map((r) => r.y + r.h))\n\t\tconst bottomRowTop = Math.min(...bottom.map((r) => r.y))\n\t\tconst yStretch = Math.max(0, MIN_VERTICAL_GAP - (bottomRowTop - topRowBottom))\n\t\tconst topMinY = Math.min(...top.map((r) => r.y))\n\t\tconst bottomMaxY = Math.max(...bottom.map((r) => r.y + r.h))\n\t\tconst originY = -(bottomMaxY + yStretch + topMinY) / 2\n\n\t\treturn top.map((topRect, i) => {\n\t\t\tconst w = topRect.w + ACTOR_PADDING_WIDTH\n\t\t\tconst h = topRect.h + ACTOR_PADDING_HEIGHT\n\t\t\treturn {\n\t\t\t\tx: xCenters[i] - totalSpan / 2 - w / 2,\n\t\t\t\ty: originY + topRect.y,\n\t\t\t\tw,\n\t\t\t\th,\n\t\t\t\tbottomY: originY + bottom[i].y + yStretch,\n\t\t\t}\n\t\t})\n\t}\n\n\tconst fallbackLifelineHeight = Math.max(300, eventCount * FALLBACK_EVENT_SPACING)\n\tconst totalWidth = actorCount * FALLBACK_ACTOR_WIDTH + (actorCount - 1) * FALLBACK_ACTOR_SPACING\n\tconst totalHeight = FALLBACK_ACTOR_HEIGHT * 2 + fallbackLifelineHeight\n\tconst startX = -totalWidth / 2\n\tconst startY = -totalHeight / 2\n\treturn Array.from({ length: actorCount }, (_, i) => ({\n\t\tx: startX + i * (FALLBACK_ACTOR_WIDTH + FALLBACK_ACTOR_SPACING),\n\t\ty: startY,\n\t\tw: FALLBACK_ACTOR_WIDTH,\n\t\th: FALLBACK_ACTOR_HEIGHT,\n\t\tbottomY: startY + totalHeight - FALLBACK_ACTOR_HEIGHT,\n\t}))\n}\n\nfunction getMessageLabel(msg: Message): string | undefined {\n\treturn typeof msg.message === 'string' ? msg.message : undefined\n}\n\n/** Count how many renderable events (signals + notes) a message list contains. */\nexport function countSequenceEvents(messages: Message[]): number {\n\tlet count = 0\n\tfor (const msg of messages) {\n\t\tif (isAutonumber(msg.type)) continue\n\t\tif (getFragmentStartKeyword(msg.type)) continue\n\t\tif (isFragmentEnd(msg.type)) continue\n\t\tif (getFragmentSeparatorKeyword(msg.type)) continue\n\t\tif (isActiveStart(msg.type) || isActiveEnd(msg.type)) continue\n\t\tconst isEvent =\n\t\t\t(isSignalMessage(msg.type) && msg.from && msg.to) || (isNoteMessage(msg.type) && msg.from)\n\t\tif (isEvent) count++\n\t}\n\treturn count\n}\n\n/** Parse sequence-diagram SVG layout data for use by {@link sequenceToBlueprint}. */\nexport function parseSequenceLayout(\n\troot: Element,\n\tactorCount: number,\n\teventCount: number\n): ParsedSequenceLayout {\n\treturn {\n\t\tactorLayouts: computeActorLayouts(root, actorCount, eventCount),\n\t\tnoteRects: parseSvgRects(root, 'rect.note'),\n\t}\n}\n\n/**\n * Build a complete blueprint for a sequence diagram:\n * top actors, lifelines, bottom actors, fragments, notes, and signal edges.\n */\nexport function sequenceToBlueprint(\n\tlayout: ParsedSequenceLayout,\n\tactors: Map<string, Actor>,\n\tactorKeys: string[],\n\tmessages: Message[],\n\tcreatedActors: Map<string, number> = new Map(),\n\tdestroyedActors: Map<string, number> = new Map()\n): DiagramMermaidBlueprint {\n\tconst actorCount = actorKeys.length\n\tconst keyIndex = new Map(actorKeys.map((key, i) => [key, i]))\n\n\tconst fragments: FragmentSpan[] = []\n\tconst fragmentStack: OpenFragment[] = []\n\tconst events: Message[] = []\n\tconst activationStack = new Map<string, number[]>()\n\tconst activationSpans: ActivationSpan[] = []\n\n\tlet autonumberStart = 0\n\tlet autonumberStep = 0\n\tlet autonumberVisible = false\n\n\tfor (const msg of messages) {\n\t\tif (isAutonumber(msg.type)) {\n\t\t\tautonumberStart = 1\n\t\t\tautonumberStep = 1\n\t\t\tautonumberVisible = true\n\t\t\tcontinue\n\t\t}\n\n\t\tconst keyword = getFragmentStartKeyword(msg.type)\n\t\tif (keyword) {\n\t\t\tfragmentStack.push({\n\t\t\t\tkeyword,\n\t\t\t\tsections: [{ title: getMessageLabel(msg) ?? '', firstEventIndex: events.length }],\n\t\t\t\tfirstEventIndex: events.length,\n\t\t\t\tactorKeys: new Set(),\n\t\t\t})\n\t\t\tcontinue\n\t\t}\n\n\t\tif (isFragmentEnd(msg.type)) {\n\t\t\tconst frag = fragmentStack.pop()\n\t\t\tif (frag) fragments.push({ ...frag, lastEventIndex: events.length - 1 })\n\t\t\tcontinue\n\t\t}\n\n\t\tif (getFragmentSeparatorKeyword(msg.type)) {\n\t\t\tconst current = fragmentStack[fragmentStack.length - 1]\n\t\t\tif (current) {\n\t\t\t\tcurrent.sections.push({\n\t\t\t\t\ttitle: getMessageLabel(msg) ?? '',\n\t\t\t\t\tfirstEventIndex: events.length,\n\t\t\t\t})\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tif (isActiveStart(msg.type)) {\n\t\t\tconst key = msg.from ?? msg.to\n\t\t\tif (key) {\n\t\t\t\tif (!activationStack.has(key)) activationStack.set(key, [])\n\t\t\t\t// Explicit `activate` follows the triggering arrow,\n\t\t\t\t// so the activation starts at the previous event.\n\t\t\t\tactivationStack.get(key)!.push(Math.max(0, events.length - 1))\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tif (isActiveEnd(msg.type)) {\n\t\t\tconst key = msg.from ?? msg.to\n\t\t\tif (key) {\n\t\t\t\tconst startIdx = activationStack.get(key)?.pop()\n\t\t\t\tif (startIdx !== undefined) {\n\t\t\t\t\tactivationSpans.push({\n\t\t\t\t\t\tparticipantKey: key,\n\t\t\t\t\t\tstartEventIndex: startIdx,\n\t\t\t\t\t\tendEventIndex: Math.max(events.length - 1, startIdx),\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tconst isEvent =\n\t\t\t(isSignalMessage(msg.type) && msg.from && msg.to) || (isNoteMessage(msg.type) && msg.from)\n\t\tif (!isEvent) continue\n\n\t\tfor (const frag of fragmentStack) {\n\t\t\tif (msg.from) frag.actorKeys.add(msg.from)\n\t\t\tif (msg.to) frag.actorKeys.add(msg.to)\n\t\t}\n\t\tevents.push(msg)\n\t}\n\n\tconst layouts = layout.actorLayouts\n\n\t// Pre-compute lifecycle event indices for created/destroyed actors.\n\t// We scan events for the first signal targeting each created actor\n\t// and the first signal from each destroyed actor.\n\tconst creationEventIndex = new Map<string, number>()\n\tconst destructionEventIndex = new Map<string, number>()\n\tfor (let i = 0; i < events.length; i++) {\n\t\tconst ev = events[i]\n\t\tif (!isSignalMessage(ev.type)) continue\n\n\t\tif (ev.to && createdActors.has(ev.to) && !creationEventIndex.has(ev.to)) {\n\t\t\tcreationEventIndex.set(ev.to, i)\n\t\t}\n\t\tif (ev.from && destroyedActors.has(ev.from) && !destructionEventIndex.has(ev.from)) {\n\t\t\tdestructionEventIndex.set(ev.from, i)\n\t\t}\n\t}\n\n\t// Build blueprint\n\tconst svgNoteRects = layout.noteRects\n\tlet svgNoteIndex = 0\n\tconst nodes: MermaidBlueprintNode[] = []\n\tconst lines: MermaidBlueprintLineNode[] = []\n\tconst edges: MermaidBlueprintEdge[] = []\n\n\tconst { y: firstY, h: firstH, bottomY: firstBottomY } = layouts[0]\n\tconst lifelineTop = firstY + firstH\n\tconst eventStep = (firstBottomY - lifelineTop) / (events.length + 1)\n\n\t// --- Z-order: lifelines -> activations -> fragments -> actor boxes -> notes/arrows ---\n\n\t// 1. Lifelines (behind everything)\n\tfor (let i = 0; i < actorCount; i++) {\n\t\tconst key = actorKeys[i]\n\t\tconst { x, y, w, h, bottomY } = layouts[i]\n\n\t\tconst isCreated = creationEventIndex.has(key)\n\t\tconst isDestroyed = destructionEventIndex.has(key)\n\t\tconst eventY = isCreated ? lifelineTop + eventStep * (creationEventIndex.get(key)! + 1) : 0\n\t\tconst topY = isCreated ? eventY + h / 2 : y + h\n\t\tconst botY = isDestroyed\n\t\t\t? lifelineTop + eventStep * (destructionEventIndex.get(key)! + 1)\n\t\t\t: bottomY\n\n\t\tconst lifelineHeight = botY - topY\n\t\tif (lifelineHeight > 0) {\n\t\t\tlines.push({ id: `lifeline-${key}`, x: x + w / 2, y: topY, endY: lifelineHeight })\n\t\t}\n\t}\n\n\t// 2. Activation boxes (just after lifelines)\n\tconst activationPad = eventStep * ACTIVATION_PAD_RATIO\n\tconst sortedSpans = activationSpans\n\t\t.map((span, origIdx) => ({ ...span, origIdx }))\n\t\t.sort((a, b) => {\n\t\t\tconst sizeA = a.endEventIndex - a.startEventIndex\n\t\t\tconst sizeB = b.endEventIndex - b.startEventIndex\n\t\t\treturn sizeB - sizeA || a.origIdx - b.origIdx\n\t\t})\n\n\tfor (let i = 0; i < sortedSpans.length; i++) {\n\t\tconst span = sortedSpans[i]\n\t\tconst actorIdx = keyIndex.get(span.participantKey)\n\t\tif (actorIdx === undefined) continue\n\n\t\tconst spanSize = span.endEventIndex - span.startEventIndex\n\t\tlet depth = 0\n\t\tfor (const other of sortedSpans) {\n\t\t\tif (other === span) continue\n\t\t\tconst sameParticipant = other.participantKey === span.participantKey\n\t\t\tconst containsSpan =\n\t\t\t\tother.startEventIndex <= span.startEventIndex && other.endEventIndex >= span.endEventIndex\n\t\t\tconst strictlyLarger = other.endEventIndex - other.startEventIndex > spanSize\n\t\t\tif (sameParticipant && containsSpan && strictlyLarger) depth++\n\t\t}\n\n\t\tconst layout = layouts[actorIdx]\n\t\tconst lifelineCenterX = layout.x + layout.w / 2\n\t\tconst boxTop = lifelineTop + eventStep * (span.startEventIndex + 1) - activationPad\n\t\tconst boxBottom = lifelineTop + eventStep * (span.endEventIndex + 1) + activationPad\n\n\t\tconst id = `activation-${span.origIdx}`\n\t\tconst kind = 'sequence_activation'\n\t\tnodes.push({\n\t\t\tid,\n\t\t\tkind,\n\t\t\tx: lifelineCenterX - ACTIVATION_BOX_WIDTH / 2 + depth * ACTIVATION_NEST_OFFSET,\n\t\t\ty: boxTop,\n\t\t\tw: ACTIVATION_BOX_WIDTH,\n\t\t\th: boxBottom - boxTop,\n\t\t\tfill: 'solid',\n\t\t\tcolor: 'light-violet',\n\t\t\tsize: 's',\n\t\t})\n\t}\n\n\t// 3. Fragments\n\tfor (let fragmentIndex = 0; fragmentIndex < fragments.length; fragmentIndex++) {\n\t\tconst fragment = fragments[fragmentIndex]\n\t\tif (fragment.lastEventIndex < fragment.firstEventIndex) continue\n\n\t\tconst fragTop = lifelineTop + eventStep * (fragment.firstEventIndex + 1) - FRAGMENT_PADDING_TOP\n\t\tconst fragBottom =\n\t\t\tlifelineTop + eventStep * (fragment.lastEventIndex + 1) + FRAGMENT_PADDING_BOTTOM\n\t\tconst indices = [...fragment.actorKeys].map((k) => keyIndex.get(k)!).filter((idx) => idx >= 0)\n\t\tif (indices.length === 0) continue\n\n\t\tconst minIndex = Math.min(...indices)\n\t\tconst maxIndex = Math.max(...indices)\n\t\tconst leftX = layouts[minIndex].x - FRAGMENT_PADDING_X\n\t\tconst fragW = layouts[maxIndex].x + layouts[maxIndex].w + FRAGMENT_PADDING_X - leftX\n\t\tconst fragH = fragBottom - fragTop\n\n\t\tconst rgbColor =\n\t\t\tfragment.keyword === 'rect' ? parseRgbToTldrawColor(fragment.sections[0].title) : null\n\t\tconst fragId = `fragment-${fragmentIndex}`\n\t\tconst fragKind = 'sequence_fragment'\n\t\tif (rgbColor) {\n\t\t\tnodes.push({\n\t\t\t\tid: fragId,\n\t\t\t\tkind: fragKind,\n\t\t\t\tx: leftX,\n\t\t\t\ty: fragTop,\n\t\t\t\tw: fragW,\n\t\t\t\th: fragH,\n\t\t\t\tfill: rgbColor.hasAlpha ? 'semi' : 'solid',\n\t\t\t\tcolor: rgbColor.color,\n\t\t\t\tsize: 's',\n\t\t\t})\n\t\t} else {\n\t\t\tnodes.push({\n\t\t\t\tid: fragId,\n\t\t\t\tkind: fragKind,\n\t\t\t\tx: leftX,\n\t\t\t\ty: fragTop,\n\t\t\t\tw: fragW,\n\t\t\t\th: fragH,\n\t\t\t\tdash: 'dashed',\n\t\t\t\tfill: 'none',\n\t\t\t\tcolor: 'light-blue',\n\t\t\t\tsize: 's',\n\t\t\t\talign: 'start',\n\t\t\t\tverticalAlign: 'start',\n\t\t\t\tlabel: `${fragment.keyword} [${fragment.sections[0].title}]`,\n\t\t\t})\n\n\t\t\tfor (let s = 1; s < fragment.sections.length; s++) {\n\t\t\t\tconst section = fragment.sections[s]\n\t\t\t\tconst sepY = lifelineTop + eventStep * (section.firstEventIndex + 0.5)\n\n\t\t\t\tlines.push({\n\t\t\t\t\tid: `fragment-${fragmentIndex}-sep-${s}`,\n\t\t\t\t\tx: leftX,\n\t\t\t\t\ty: sepY,\n\t\t\t\t\tendX: fragW,\n\t\t\t\t\tendY: 0,\n\t\t\t\t\tdash: 'dashed',\n\t\t\t\t\tcolor: 'light-blue',\n\t\t\t\t\tsize: 's',\n\t\t\t\t})\n\n\t\t\t\tconst secId = `fragment-${fragmentIndex}-section-${s}`\n\t\t\t\tconst secKind = 'sequence_fragment_section'\n\t\t\t\tnodes.push({\n\t\t\t\t\tid: secId,\n\t\t\t\t\tkind: secKind,\n\t\t\t\t\tx: leftX + FRAGMENT_SECTION_LABEL_PADDING,\n\t\t\t\t\ty: sepY + FRAGMENT_SECTION_LABEL_PADDING,\n\t\t\t\t\tw: fragW - FRAGMENT_SECTION_LABEL_PADDING * 2,\n\t\t\t\t\th: FRAGMENT_SECTION_LABEL_HEIGHT,\n\t\t\t\t\tfill: 'none',\n\t\t\t\t\tdash: 'dashed',\n\t\t\t\t\tcolor: 'light-blue',\n\t\t\t\t\tsize: 's',\n\t\t\t\t\talign: 'start',\n\t\t\t\t\tverticalAlign: 'start',\n\t\t\t\t\tlabel: `[${section.title}]`,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\n\t// 4. Actor boxes (top and bottom)\n\tfor (let i = 0; i < actorCount; i++) {\n\t\tconst key = actorKeys[i]\n\t\tconst actor = actors.get(key)\n\t\tif (!actor) continue\n\t\tconst { x, y, w, h, bottomY } = layouts[i]\n\t\tconst isCreated = creationEventIndex.has(key)\n\t\tconst isDestroyed = destructionEventIndex.has(key)\n\t\tconst kind = actor.type\n\t\tconst label = actor.description || actor.name || key\n\t\tconst shared = {\n\t\t\tkind,\n\t\t\tlabel,\n\t\t\talign: 'middle' as const,\n\t\t\tverticalAlign: 'middle' as const,\n\t\t\tsize: 's' as const,\n\t\t}\n\n\t\tconst creationY = isCreated ? lifelineTop + eventStep * (creationEventIndex.get(key)! + 1) : 0\n\t\tconst topY = isCreated ? creationY - h / 2 : y\n\t\tconst topId = `actor-top-${key}`\n\t\tnodes.push({\n\t\t\tid: topId,\n\t\t\tx,\n\t\t\ty: topY,\n\t\t\tw,\n\t\t\th,\n\t\t\t...shared,\n\t\t})\n\n\t\tif (!isDestroyed) {\n\t\t\tconst botId = `actor-bottom-${key}`\n\t\t\tnodes.push({\n\t\t\t\tid: botId,\n\t\t\t\tx,\n\t\t\t\ty: bottomY,\n\t\t\t\tw,\n\t\t\t\th,\n\t\t\t\t...shared,\n\t\t\t})\n\t\t}\n\t}\n\n\t// 5. Events: signals and notes\n\tconst pendingCreations = new Set(createdActors.keys())\n\tlet sequenceNumber = autonumberStart\n\n\tfor (let eventIndex = 0; eventIndex < events.length; eventIndex++) {\n\t\tconst msg = events[eventIndex]\n\t\tconst anchor = (eventIndex + 1) / (events.length + 1)\n\n\t\tif (isSignalMessage(msg.type)) {\n\t\t\tconst fromKey = msg.from!\n\t\t\tconst toKey = msg.to!\n\t\t\tif (!keyIndex.has(fromKey) || !keyIndex.has(toKey)) continue\n\n\t\t\tconst isCreationMessage = pendingCreations.has(toKey)\n\t\t\tif (isCreationMessage) pendingCreations.delete(toKey)\n\n\t\t\tconst msgType = msg.type ?? LINETYPE.SOLID\n\t\t\tconst { dash, arrowheadEnd } = mapLineTypeToArrowProps(msgType)\n\t\t\tconst isSelf = fromKey === toKey\n\t\t\tconst bidir = !isSelf && isBidirectional(msgType)\n\n\t\t\tconst edge: MermaidBlueprintEdge = {\n\t\t\t\tstartNodeId: `lifeline-${fromKey}`,\n\t\t\t\tendNodeId: isCreationMessage ? `actor-top-${toKey}` : `lifeline-${toKey}`,\n\t\t\t\tlabel: getMessageLabel(msg),\n\t\t\t\tbend: isSelf ? SELF_MSG_BEND : 0,\n\t\t\t\tdash,\n\t\t\t\tarrowheadEnd,\n\t\t\t\tarrowheadStart: bidir ? 'arrow' : 'none',\n\t\t\t\tsize: 's',\n\t\t\t\tanchorStartY: isSelf ? anchor - SELF_MSG_Y_OFFSET : anchor,\n\t\t\t\tanchorEndY: isCreationMessage ? 0.5 : isSelf ? anchor + SELF_MSG_Y_OFFSET : anchor,\n\t\t\t\tisExact: true,\n\t\t\t\tisPrecise: true,\n\t\t\t\t...(isCreationMessage && { isExactEnd: false, isPreciseEnd: false }),\n\t\t\t}\n\n\t\t\tif (autonumberVisible) {\n\t\t\t\tedge.decoration = { type: 'autonumber', value: String(sequenceNumber) }\n\t\t\t\tsequenceNumber += autonumberStep\n\t\t\t}\n\n\t\t\tedges.push(edge)\n\t\t} else if (isNoteMessage(msg.type)) {\n\t\t\tconst eventY = lifelineTop + eventStep * (eventIndex + 1)\n\t\t\tconst fromKey = msg.from!\n\t\t\tconst fromIdx = keyIndex.get(fromKey)\n\t\t\tconst toIdx = keyIndex.get(msg.to ?? fromKey)\n\t\t\tif (fromIdx === undefined) continue\n\n\t\t\tconst label = getMessageLabel(msg)\n\t\t\t// Mermaid types `placement` as a string enum but the runtime value is numeric\n\t\t\tconst msgPlacement = msg.placement as unknown as number | undefined\n\t\t\tconst fromCenterX = layouts[fromIdx].x + layouts[fromIdx].w / 2\n\t\t\tconst toCenterX = toIdx !== undefined ? layouts[toIdx].x + layouts[toIdx].w / 2 : fromCenterX\n\t\t\tconst isSpanning =\n\t\t\t\tmsgPlacement === PLACEMENT.OVER && msg.from !== msg.to && toIdx !== undefined\n\n\t\t\tconst svgNote = svgNoteRects[svgNoteIndex++]\n\t\t\tconst noteHeight = svgNote?.h ?? FALLBACK_NOTE_HEIGHT\n\t\t\tconst textWidth = label ? label.length * NOTE_CHAR_WIDTH + NOTE_TEXT_PADDING : 0\n\t\t\tconst baseWidth = Math.max(svgNote?.w ?? FALLBACK_NOTE_WIDTH, textWidth)\n\t\t\tconst noteWidth = isSpanning\n\t\t\t\t? Math.max(baseWidth, Math.abs(toCenterX - fromCenterX) + NOTE_PADDING)\n\t\t\t\t: baseWidth\n\n\t\t\tlet noteX: number\n\t\t\tif (msgPlacement === PLACEMENT.LEFTOF) {\n\t\t\t\tnoteX = fromCenterX - noteWidth - NOTE_PADDING\n\t\t\t} else if (msgPlacement === PLACEMENT.RIGHTOF) {\n\t\t\t\tnoteX = fromCenterX + NOTE_PADDING\n\t\t\t} else if (isSpanning) {\n\t\t\t\tnoteX = (fromCenterX + toCenterX) / 2 - noteWidth / 2\n\t\t\t} else {\n\t\t\t\tnoteX = fromCenterX - noteWidth / 2\n\t\t\t}\n\n\t\t\tconst noteId = `note-${eventIndex}`\n\t\t\tconst noteKind = 'sequence_note'\n\t\t\tnodes.push({\n\t\t\t\tid: noteId,\n\t\t\t\tkind: noteKind,\n\t\t\t\tx: noteX,\n\t\t\t\ty: eventY - noteHeight / 2,\n\t\t\t\tw: noteWidth,\n\t\t\t\th: noteHeight,\n\t\t\t\tfill: 'solid',\n\t\t\t\tcolor: 'yellow',\n\t\t\t\tdash: 'draw',\n\t\t\t\tsize: 's',\n\t\t\t\talign: 'middle',\n\t\t\t\tverticalAlign: 'middle',\n\t\t\t\tlabel,\n\t\t\t})\n\t\t}\n\t}\n\n\treturn {\n\t\tdiagramKind: 'sequence',\n\t\tnodes,\n\t\tedges,\n\t\tlines,\n\t\tgroups: actorKeys.map((key) => {\n\t\t\tconst group = [`actor-top-${key}`, `lifeline-${key}`]\n\t\t\tif (!destructionEventIndex.has(key)) {\n\t\t\t\tgroup.push(`actor-bottom-${key}`)\n\t\t\t}\n\t\t\treturn group\n\t\t}),\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AACN,gBAAQ,cAAc,YAAY;AAAA,MACnC;AAEA,YAAM,SAAS,QAAQ,UAAU;AACjC,YAAM,WAAW;AACjB,YAAM,KAAK;AAAA,QACV,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,GAAG;AAAA,QACH,GAAG,SAAS,aAAa;AAAA,QACzB,GAAG;AAAA,QACH,GAAG;AAAA,QACH,MAAM;AAAA,QACN,OAAO;AAAA,QACP,MAAM;AAAA,QACN,MAAM;AAAA,QACN,OAAO;AAAA,QACP,eAAe;AAAA,QACf;AAAA,MACD,CAAC;AAAA,IACF;AAAA,EACD;AAEA,SAAO;AAAA,IACN,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ,UAAU,IAAI,CAAC,QAAQ;AAC9B,YAAM,QAAQ,CAAC,aAAa,GAAG,IAAI,YAAY,GAAG,EAAE;AACpD,UAAI,CAAC,sBAAsB,IAAI,GAAG,GAAG;AACpC,cAAM,KAAK,gBAAgB,GAAG,EAAE;AAAA,MACjC;AACA,aAAO;AAAA,IACR,CAAC;AAAA,EACF;AACD;",
4
+ "sourcesContent": ["import type { SequenceDB } from 'mermaid/dist/diagrams/sequence/sequenceDb.d.ts'\nimport type { Actor, Message } from 'mermaid/dist/diagrams/sequence/types.js'\nimport { TLArrowShapeArrowheadStyle, TLDefaultDashStyle } from 'tldraw'\nimport type {\n\tDiagramMermaidBlueprint,\n\tMermaidBlueprintEdge,\n\tMermaidBlueprintNode,\n\tMermaidBlueprintLineNode,\n} from './blueprint'\nimport { parseRgbToTldrawColor } from './colors'\nimport { getAccumulatedTranslate } from './svgParsing'\n\nexport interface SvgRect {\n\tx: number\n\ty: number\n\tw: number\n\th: number\n}\n\nexport interface ActorLayout {\n\tx: number\n\ty: number\n\tw: number\n\th: number\n\tbottomY: number\n}\n\nexport interface ParsedSequenceLayout {\n\tactorLayouts: ActorLayout[]\n\tnoteRects: SvgRect[]\n}\n\nconst LINETYPE = {\n\tSOLID: 0,\n\tDOTTED: 1,\n\tNOTE: 2,\n\tSOLID_CROSS: 3,\n\tDOTTED_CROSS: 4,\n\tSOLID_OPEN: 5,\n\tDOTTED_OPEN: 6,\n\tLOOP_START: 10,\n\tLOOP_END: 11,\n\tALT_START: 12,\n\tALT_ELSE: 13,\n\tALT_END: 14,\n\tOPT_START: 15,\n\tOPT_END: 16,\n\tACTIVE_START: 17,\n\tACTIVE_END: 18,\n\tPAR_START: 19,\n\tPAR_AND: 20,\n\tPAR_END: 21,\n\tRECT_START: 22,\n\tRECT_END: 23,\n\tSOLID_POINT: 24,\n\tDOTTED_POINT: 25,\n\tAUTONUMBER: 26,\n\tCRITICAL_START: 27,\n\tCRITICAL_OPTION: 28,\n\tCRITICAL_END: 29,\n\tBREAK_START: 30,\n\tBREAK_END: 31,\n\tPAR_OVER_START: 32,\n\tBIDIRECTIONAL_SOLID: 33,\n\tBIDIRECTIONAL_DOTTED: 34,\n\tSOLID_TOP: 41,\n\tSOLID_BOTTOM: 42,\n\tSTICK_TOP: 43,\n\tSTICK_BOTTOM: 44,\n\tSOLID_ARROW_TOP_REVERSE: 45,\n\tSOLID_ARROW_BOTTOM_REVERSE: 46,\n\tSTICK_ARROW_TOP_REVERSE: 47,\n\tSTICK_ARROW_BOTTOM_REVERSE: 48,\n\tSOLID_TOP_DOTTED: 51,\n\tSOLID_BOTTOM_DOTTED: 52,\n\tSTICK_TOP_DOTTED: 53,\n\tSTICK_BOTTOM_DOTTED: 54,\n\tSOLID_ARROW_TOP_REVERSE_DOTTED: 55,\n\tSOLID_ARROW_BOTTOM_REVERSE_DOTTED: 56,\n\tSTICK_ARROW_TOP_REVERSE_DOTTED: 57,\n\tSTICK_ARROW_BOTTOM_REVERSE_DOTTED: 58,\n\tCENTRAL_CONNECTION: 59,\n\tCENTRAL_CONNECTION_REVERSE: 60,\n\tCENTRAL_CONNECTION_DUAL: 61,\n} as const satisfies SequenceDB['LINETYPE']\n\nconst PLACEMENT = {\n\tLEFTOF: 0,\n\tRIGHTOF: 1,\n\tOVER: 2,\n} as const satisfies SequenceDB['PLACEMENT']\n\nconst signalTypes: number[] = [\n\tLINETYPE.SOLID,\n\tLINETYPE.DOTTED,\n\tLINETYPE.SOLID_CROSS,\n\tLINETYPE.DOTTED_CROSS,\n\tLINETYPE.SOLID_OPEN,\n\tLINETYPE.DOTTED_OPEN,\n\tLINETYPE.SOLID_POINT,\n\tLINETYPE.DOTTED_POINT,\n\tLINETYPE.BIDIRECTIONAL_SOLID,\n\tLINETYPE.BIDIRECTIONAL_DOTTED,\n]\n\nfunction isSignalMessage(type: number | undefined): boolean {\n\tif (type === undefined) return false\n\treturn signalTypes.includes(type)\n}\n\nfunction isNoteMessage(type: number | undefined): boolean {\n\treturn type === LINETYPE.NOTE\n}\n\nfunction isActiveStart(type: number | undefined): boolean {\n\treturn type === LINETYPE.ACTIVE_START\n}\n\nfunction isActiveEnd(type: number | undefined): boolean {\n\treturn type === LINETYPE.ACTIVE_END\n}\n\nfunction isAutonumber(type: number | undefined): boolean {\n\treturn type === LINETYPE.AUTONUMBER\n}\n\n/** Returns the fragment keyword (e.g. \"loop\", \"opt\") if this message starts a combined fragment, or null. */\nfunction getFragmentStartKeyword(type: number | undefined): string | null {\n\tif (type === undefined) return null\n\tif (type === LINETYPE.LOOP_START) return 'loop'\n\tif (type === LINETYPE.ALT_START) return 'alt'\n\tif (type === LINETYPE.OPT_START) return 'opt'\n\tif (type === LINETYPE.PAR_START) return 'par'\n\tif (type === LINETYPE.RECT_START) return 'rect'\n\tif (type === LINETYPE.CRITICAL_START) return 'critical'\n\tif (type === LINETYPE.BREAK_START) return 'break'\n\tif (type === LINETYPE.PAR_OVER_START) return 'par'\n\treturn null\n}\n\nfunction isFragmentEnd(type: number | undefined): boolean {\n\tif (type === undefined) return false\n\tconst endTypes: number[] = [\n\t\tLINETYPE.LOOP_END,\n\t\tLINETYPE.ALT_END,\n\t\tLINETYPE.OPT_END,\n\t\tLINETYPE.PAR_END,\n\t\tLINETYPE.RECT_END,\n\t\tLINETYPE.CRITICAL_END,\n\t\tLINETYPE.BREAK_END,\n\t]\n\treturn endTypes.includes(type)\n}\n\n/** Returns a keyword if this message is a section separator within a combined fragment, or null. */\nfunction getFragmentSeparatorKeyword(type: number | undefined): string | null {\n\tif (type === LINETYPE.ALT_ELSE) return 'else'\n\tif (type === LINETYPE.PAR_AND) return 'and'\n\tif (type === LINETYPE.CRITICAL_OPTION) return 'option'\n\treturn null\n}\n\n/** Map a Mermaid LINETYPE value to tldraw arrow props. */\nfunction mapLineTypeToArrowProps(type: number): {\n\tdash: TLDefaultDashStyle\n\tarrowheadEnd: TLArrowShapeArrowheadStyle\n} {\n\tswitch (type) {\n\t\tcase LINETYPE.SOLID:\n\t\t\treturn { dash: 'solid', arrowheadEnd: 'arrow' }\n\t\tcase LINETYPE.DOTTED:\n\t\t\treturn { dash: 'dotted', arrowheadEnd: 'arrow' }\n\t\tcase LINETYPE.SOLID_CROSS:\n\t\t\treturn { dash: 'solid', arrowheadEnd: 'bar' }\n\t\tcase LINETYPE.DOTTED_CROSS:\n\t\t\treturn { dash: 'dotted', arrowheadEnd: 'bar' }\n\t\tcase LINETYPE.SOLID_OPEN:\n\t\t\treturn { dash: 'solid', arrowheadEnd: 'none' }\n\t\tcase LINETYPE.DOTTED_OPEN:\n\t\t\treturn { dash: 'dotted', arrowheadEnd: 'none' }\n\t\tcase LINETYPE.SOLID_POINT:\n\t\t\treturn { dash: 'solid', arrowheadEnd: 'arrow' }\n\t\tcase LINETYPE.DOTTED_POINT:\n\t\t\treturn { dash: 'dotted', arrowheadEnd: 'arrow' }\n\t\tcase LINETYPE.BIDIRECTIONAL_SOLID:\n\t\t\treturn { dash: 'solid', arrowheadEnd: 'arrow' }\n\t\tcase LINETYPE.BIDIRECTIONAL_DOTTED:\n\t\t\treturn { dash: 'dotted', arrowheadEnd: 'arrow' }\n\t\tdefault:\n\t\t\treturn { dash: 'solid', arrowheadEnd: 'arrow' }\n\t}\n}\n\nfunction isBidirectional(type: number): boolean {\n\treturn type === LINETYPE.BIDIRECTIONAL_SOLID || type === LINETYPE.BIDIRECTIONAL_DOTTED\n}\n\nconst TARGET_ACTOR_SPACING = 300\nconst MIN_VERTICAL_GAP = 400\nconst FALLBACK_ACTOR_WIDTH = 200\nconst FALLBACK_ACTOR_HEIGHT = 70\nconst FALLBACK_ACTOR_SPACING = 100\nconst FALLBACK_EVENT_SPACING = 80\nconst FALLBACK_NOTE_WIDTH = 120\nconst FALLBACK_NOTE_HEIGHT = 50\nconst NOTE_PADDING = 5\n// tldraw's hand-drawn font is wider than Mermaid's default, so we estimate\n// the minimum note width from the label text to prevent wrapping.\nconst NOTE_CHAR_WIDTH = 11\nconst NOTE_TEXT_PADDING = 40\nconst FRAGMENT_PADDING_X = 30\nconst FRAGMENT_PADDING_TOP = 50\nconst FRAGMENT_PADDING_BOTTOM = 25\nconst ACTOR_PADDING_WIDTH = 30\nconst ACTOR_PADDING_HEIGHT = 10\nconst SELF_MSG_Y_OFFSET = 0.04\nconst SELF_MSG_BEND = -80\nconst ACTIVATION_BOX_WIDTH = 20\nconst ACTIVATION_NEST_OFFSET = 6\nconst ACTIVATION_PAD_RATIO = 0.15\nconst FRAGMENT_SECTION_LABEL_HEIGHT = 25\nconst FRAGMENT_SECTION_LABEL_PADDING = 5\n\ninterface FragmentSection {\n\ttitle: string\n\tfirstEventIndex: number\n}\n\ninterface OpenFragment {\n\tkeyword: string\n\tsections: FragmentSection[]\n\tfirstEventIndex: number\n\tactorKeys: Set<string>\n}\n\ninterface FragmentSpan extends OpenFragment {\n\tlastEventIndex: number\n}\n\ninterface ActivationSpan {\n\tparticipantKey: string\n\tstartEventIndex: number\n\tendEventIndex: number\n}\n\nfunction parseSvgRects(root: Element, selector: string): SvgRect[] {\n\tconst results: SvgRect[] = []\n\tfor (const rect of root.querySelectorAll(selector)) {\n\t\tconst ancestor = getAccumulatedTranslate(rect)\n\t\tconst x = parseFloat(rect.getAttribute('x') || '0')\n\t\tconst y = parseFloat(rect.getAttribute('y') || '0')\n\t\tconst w = parseFloat(rect.getAttribute('width') || '0')\n\t\tconst h = parseFloat(rect.getAttribute('height') || '0')\n\t\tif (w > 0 && h > 0) {\n\t\t\tresults.push({\n\t\t\t\tx: Number.isFinite(ancestor.x + x) ? ancestor.x + x : 0,\n\t\t\t\ty: Number.isFinite(ancestor.y + y) ? ancestor.y + y : 0,\n\t\t\t\tw,\n\t\t\t\th,\n\t\t\t})\n\t\t}\n\t}\n\treturn results\n}\n\n/**\n * Stick-figure (actor) participants use SVG <line> elements instead of <rect>.\n * We derive bounding rectangles from the min/max coordinates of each actor-man group.\n */\nfunction parseActorManRects(root: Element): SvgRect[] {\n\tconst results: SvgRect[] = []\n\tfor (const group of root.querySelectorAll('g.actor-man')) {\n\t\tconst ancestor = getAccumulatedTranslate(group)\n\t\tlet minX = Infinity\n\t\tlet minY = Infinity\n\t\tlet maxX = -Infinity\n\t\tlet maxY = -Infinity\n\t\tfor (const line of group.querySelectorAll('line')) {\n\t\t\tfor (const attr of ['x1', 'x2']) {\n\t\t\t\tconst coord = parseFloat(line.getAttribute(attr) || '0')\n\t\t\t\tif (coord < minX) minX = coord\n\t\t\t\tif (coord > maxX) maxX = coord\n\t\t\t}\n\t\t\tfor (const attr of ['y1', 'y2']) {\n\t\t\t\tconst coord = parseFloat(line.getAttribute(attr) || '0')\n\t\t\t\tif (coord < minY) minY = coord\n\t\t\t\tif (coord > maxY) maxY = coord\n\t\t\t}\n\t\t}\n\t\tif (Number.isFinite(minX) && Number.isFinite(minY)) {\n\t\t\tresults.push({\n\t\t\t\tx: ancestor.x + minX,\n\t\t\t\ty: ancestor.y + minY,\n\t\t\t\tw: maxX - minX || FALLBACK_ACTOR_WIDTH,\n\t\t\t\th: maxY - minY || FALLBACK_ACTOR_HEIGHT,\n\t\t\t})\n\t\t}\n\t}\n\treturn results\n}\n\nfunction computeActorLayouts(root: Element, actorCount: number, eventCount: number): ActorLayout[] {\n\tconst byX = (a: SvgRect, b: SvgRect) => a.x - b.x\n\tlet top = parseSvgRects(root, 'rect.actor-top').sort(byX)\n\tlet bottom = parseSvgRects(root, 'rect.actor-bottom').sort(byX)\n\n\tconst actorManRects = parseActorManRects(root).sort(byX)\n\tif (actorManRects.length > 0 && (top.length < actorCount || bottom.length < actorCount)) {\n\t\tconst midY =\n\t\t\ttop.length > 0 && bottom.length > 0\n\t\t\t\t? (Math.max(...top.map((r) => r.y + r.h)) + Math.min(...bottom.map((r) => r.y))) / 2\n\t\t\t\t: actorManRects.length >= 2\n\t\t\t\t\t? (actorManRects[0].y + actorManRects[actorManRects.length - 1].y) / 2\n\t\t\t\t\t: 0\n\t\tfor (const rect of actorManRects) {\n\t\t\tif (rect.y < midY) top.push(rect)\n\t\t\telse bottom.push(rect)\n\t\t}\n\t\ttop.sort(byX)\n\t\tbottom.sort(byX)\n\t}\n\n\tif (top.length < actorCount || bottom.length < actorCount) {\n\t\tconst all = parseSvgRects(root, 'rect[class*=\"actor\"]').sort((a, b) => a.y - b.y)\n\t\tif (all.length >= 2 * actorCount) {\n\t\t\tlet maxGap = 0\n\t\t\tlet splitAt = actorCount\n\t\t\tfor (let i = 1; i < all.length; i++) {\n\t\t\t\tconst gap = all[i].y - all[i - 1].y\n\t\t\t\tif (gap > maxGap) {\n\t\t\t\t\tmaxGap = gap\n\t\t\t\t\tsplitAt = i\n\t\t\t\t}\n\t\t\t}\n\t\t\ttop = all.slice(0, splitAt).sort(byX).slice(0, actorCount)\n\t\t\tbottom = all.slice(splitAt).sort(byX).slice(0, actorCount)\n\t\t} else {\n\t\t\ttop = []\n\t\t\tbottom = []\n\t\t}\n\t} else {\n\t\ttop = top.slice(0, actorCount)\n\t\tbottom = bottom.slice(0, actorCount)\n\t}\n\n\tif (actorManRects.length > 0) {\n\t\tconst actorManSet = new Set<SvgRect>(actorManRects)\n\t\tconst regularTops = top.filter((r) => !actorManSet.has(r))\n\t\tconst regularBottoms = bottom.filter((r) => !actorManSet.has(r))\n\t\tconst refHeight =\n\t\t\tregularTops.length > 0 ? Math.max(...regularTops.map((r) => r.h)) : FALLBACK_ACTOR_HEIGHT\n\t\tconst refWidth =\n\t\t\tregularTops.length > 0 ? Math.max(...regularTops.map((r) => r.w)) : FALLBACK_ACTOR_WIDTH\n\t\tconst refTopY = regularTops.length > 0 ? Math.min(...regularTops.map((r) => r.y)) : undefined\n\t\tconst refBottomEndY =\n\t\t\tregularBottoms.length > 0 ? Math.max(...regularBottoms.map((r) => r.y + r.h)) : undefined\n\n\t\tfor (const rect of top) {\n\t\t\tif (!actorManSet.has(rect)) continue\n\t\t\tconst centerY = rect.y + rect.h / 2\n\t\t\trect.h = refHeight\n\t\t\trect.w = Math.max(rect.w, refWidth)\n\t\t\trect.y = refTopY !== undefined ? refTopY : centerY - refHeight / 2\n\t\t}\n\t\tfor (const rect of bottom) {\n\t\t\tif (!actorManSet.has(rect)) continue\n\t\t\tconst centerY = rect.y + rect.h / 2\n\t\t\trect.h = refHeight\n\t\t\trect.w = Math.max(rect.w, refWidth)\n\t\t\trect.y = refBottomEndY !== undefined ? refBottomEndY - refHeight : centerY - refHeight / 2\n\t\t}\n\t}\n\n\tif (top.length >= actorCount && bottom.length >= actorCount) {\n\t\tconst svgCenters = top.map((r) => r.x + r.w / 2)\n\t\tconst spacings: number[] = []\n\t\tfor (let i = 1; i < svgCenters.length; i++) {\n\t\t\tspacings.push(svgCenters[i] - svgCenters[i - 1])\n\t\t}\n\t\tconst minSpacing = spacings.length > 0 ? Math.min(...spacings) : 1\n\t\tconst scale = Math.max(1, TARGET_ACTOR_SPACING / minSpacing)\n\n\t\tconst xCenters = svgCenters.map((c) => (c - svgCenters[0]) * scale)\n\t\tconst totalSpan = xCenters.length > 1 ? xCenters[xCenters.length - 1] : 0\n\n\t\tconst topRowBottom = Math.max(...top.map((r) => r.y + r.h))\n\t\tconst bottomRowTop = Math.min(...bottom.map((r) => r.y))\n\t\tconst yStretch = Math.max(0, MIN_VERTICAL_GAP - (bottomRowTop - topRowBottom))\n\t\tconst topMinY = Math.min(...top.map((r) => r.y))\n\t\tconst bottomMaxY = Math.max(...bottom.map((r) => r.y + r.h))\n\t\tconst originY = -(bottomMaxY + yStretch + topMinY) / 2\n\n\t\treturn top.map((topRect, i) => {\n\t\t\tconst w = topRect.w + ACTOR_PADDING_WIDTH\n\t\t\tconst h = topRect.h + ACTOR_PADDING_HEIGHT\n\t\t\treturn {\n\t\t\t\tx: xCenters[i] - totalSpan / 2 - w / 2,\n\t\t\t\ty: originY + topRect.y,\n\t\t\t\tw,\n\t\t\t\th,\n\t\t\t\tbottomY: originY + bottom[i].y + yStretch,\n\t\t\t}\n\t\t})\n\t}\n\n\tconst fallbackLifelineHeight = Math.max(300, eventCount * FALLBACK_EVENT_SPACING)\n\tconst totalWidth = actorCount * FALLBACK_ACTOR_WIDTH + (actorCount - 1) * FALLBACK_ACTOR_SPACING\n\tconst totalHeight = FALLBACK_ACTOR_HEIGHT * 2 + fallbackLifelineHeight\n\tconst startX = -totalWidth / 2\n\tconst startY = -totalHeight / 2\n\treturn Array.from({ length: actorCount }, (_, i) => ({\n\t\tx: startX + i * (FALLBACK_ACTOR_WIDTH + FALLBACK_ACTOR_SPACING),\n\t\ty: startY,\n\t\tw: FALLBACK_ACTOR_WIDTH,\n\t\th: FALLBACK_ACTOR_HEIGHT,\n\t\tbottomY: startY + totalHeight - FALLBACK_ACTOR_HEIGHT,\n\t}))\n}\n\nfunction getMessageLabel(msg: Message): string | undefined {\n\treturn typeof msg.message === 'string' ? msg.message : undefined\n}\n\n/** Count how many renderable events (signals + notes) a message list contains. */\nexport function countSequenceEvents(messages: Message[]): number {\n\tlet count = 0\n\tfor (const msg of messages) {\n\t\tif (isAutonumber(msg.type)) continue\n\t\tif (getFragmentStartKeyword(msg.type)) continue\n\t\tif (isFragmentEnd(msg.type)) continue\n\t\tif (getFragmentSeparatorKeyword(msg.type)) continue\n\t\tif (isActiveStart(msg.type) || isActiveEnd(msg.type)) continue\n\t\tconst isEvent =\n\t\t\t(isSignalMessage(msg.type) && msg.from && msg.to) || (isNoteMessage(msg.type) && msg.from)\n\t\tif (isEvent) count++\n\t}\n\treturn count\n}\n\n/** Parse sequence-diagram SVG layout data for use by {@link sequenceToBlueprint}. */\nexport function parseSequenceLayout(\n\troot: Element,\n\tactorCount: number,\n\teventCount: number\n): ParsedSequenceLayout {\n\treturn {\n\t\tactorLayouts: computeActorLayouts(root, actorCount, eventCount),\n\t\tnoteRects: parseSvgRects(root, 'rect.note'),\n\t}\n}\n\n/**\n * Build a complete blueprint for a sequence diagram:\n * top actors, lifelines, bottom actors, fragments, notes, and signal edges.\n */\nexport function sequenceToBlueprint(\n\tlayout: ParsedSequenceLayout,\n\tactors: Map<string, Actor>,\n\tactorKeys: string[],\n\tmessages: Message[],\n\tcreatedActors: Map<string, number> = new Map(),\n\tdestroyedActors: Map<string, number> = new Map()\n): DiagramMermaidBlueprint {\n\tconst actorCount = actorKeys.length\n\tconst keyIndex = new Map(actorKeys.map((key, i) => [key, i]))\n\n\tconst fragments: FragmentSpan[] = []\n\tconst fragmentStack: OpenFragment[] = []\n\tconst events: Message[] = []\n\tconst activationStack = new Map<string, number[]>()\n\tconst activationSpans: ActivationSpan[] = []\n\n\tlet autonumberStart = 0\n\tlet autonumberStep = 0\n\tlet autonumberVisible = false\n\n\tfor (const msg of messages) {\n\t\tif (isAutonumber(msg.type)) {\n\t\t\tautonumberStart = 1\n\t\t\tautonumberStep = 1\n\t\t\tautonumberVisible = true\n\t\t\tcontinue\n\t\t}\n\n\t\tconst keyword = getFragmentStartKeyword(msg.type)\n\t\tif (keyword) {\n\t\t\tfragmentStack.push({\n\t\t\t\tkeyword,\n\t\t\t\tsections: [{ title: getMessageLabel(msg) ?? '', firstEventIndex: events.length }],\n\t\t\t\tfirstEventIndex: events.length,\n\t\t\t\tactorKeys: new Set(),\n\t\t\t})\n\t\t\tcontinue\n\t\t}\n\n\t\tif (isFragmentEnd(msg.type)) {\n\t\t\tconst frag = fragmentStack.pop()\n\t\t\tif (frag) fragments.push({ ...frag, lastEventIndex: events.length - 1 })\n\t\t\tcontinue\n\t\t}\n\n\t\tif (getFragmentSeparatorKeyword(msg.type)) {\n\t\t\tconst current = fragmentStack[fragmentStack.length - 1]\n\t\t\tif (current) {\n\t\t\t\tcurrent.sections.push({\n\t\t\t\t\ttitle: getMessageLabel(msg) ?? '',\n\t\t\t\t\tfirstEventIndex: events.length,\n\t\t\t\t})\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tif (isActiveStart(msg.type)) {\n\t\t\tconst key = msg.from ?? msg.to\n\t\t\tif (key) {\n\t\t\t\tif (!activationStack.has(key)) activationStack.set(key, [])\n\t\t\t\t// Explicit `activate` follows the triggering arrow,\n\t\t\t\t// so the activation starts at the previous event.\n\t\t\t\tactivationStack.get(key)!.push(Math.max(0, events.length - 1))\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tif (isActiveEnd(msg.type)) {\n\t\t\tconst key = msg.from ?? msg.to\n\t\t\tif (key) {\n\t\t\t\tconst startIdx = activationStack.get(key)?.pop()\n\t\t\t\tif (startIdx !== undefined) {\n\t\t\t\t\tactivationSpans.push({\n\t\t\t\t\t\tparticipantKey: key,\n\t\t\t\t\t\tstartEventIndex: startIdx,\n\t\t\t\t\t\tendEventIndex: Math.max(events.length - 1, startIdx),\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tconst isEvent =\n\t\t\t(isSignalMessage(msg.type) && msg.from && msg.to) || (isNoteMessage(msg.type) && msg.from)\n\t\tif (!isEvent) continue\n\n\t\tfor (const frag of fragmentStack) {\n\t\t\tif (msg.from) frag.actorKeys.add(msg.from)\n\t\t\tif (msg.to) frag.actorKeys.add(msg.to)\n\t\t}\n\t\tevents.push(msg)\n\t}\n\n\tconst layouts = layout.actorLayouts\n\n\t// Pre-compute lifecycle event indices for created/destroyed actors.\n\t// We scan events for the first signal targeting each created actor\n\t// and the first signal from each destroyed actor.\n\tconst creationEventIndex = new Map<string, number>()\n\tconst destructionEventIndex = new Map<string, number>()\n\tfor (let i = 0; i < events.length; i++) {\n\t\tconst ev = events[i]\n\t\tif (!isSignalMessage(ev.type)) continue\n\n\t\tif (ev.to && createdActors.has(ev.to) && !creationEventIndex.has(ev.to)) {\n\t\t\tcreationEventIndex.set(ev.to, i)\n\t\t}\n\t\tif (ev.from && destroyedActors.has(ev.from) && !destructionEventIndex.has(ev.from)) {\n\t\t\tdestructionEventIndex.set(ev.from, i)\n\t\t}\n\t}\n\n\t// Build blueprint\n\tconst svgNoteRects = layout.noteRects\n\tlet svgNoteIndex = 0\n\tconst nodes: MermaidBlueprintNode[] = []\n\tconst lines: MermaidBlueprintLineNode[] = []\n\tconst edges: MermaidBlueprintEdge[] = []\n\n\tconst { y: firstY, h: firstH, bottomY: firstBottomY } = layouts[0]\n\tconst lifelineTop = firstY + firstH\n\tconst eventStep = (firstBottomY - lifelineTop) / (events.length + 1)\n\n\t// --- Z-order: lifelines -> activations -> fragments -> actor boxes -> notes/arrows ---\n\n\t// 1. Lifelines (behind everything)\n\tfor (let i = 0; i < actorCount; i++) {\n\t\tconst key = actorKeys[i]\n\t\tconst { x, y, w, h, bottomY } = layouts[i]\n\n\t\tconst isCreated = creationEventIndex.has(key)\n\t\tconst isDestroyed = destructionEventIndex.has(key)\n\t\tconst eventY = isCreated ? lifelineTop + eventStep * (creationEventIndex.get(key)! + 1) : 0\n\t\tconst topY = isCreated ? eventY + h / 2 : y + h\n\t\tconst botY = isDestroyed\n\t\t\t? lifelineTop + eventStep * (destructionEventIndex.get(key)! + 1)\n\t\t\t: bottomY\n\n\t\tconst lifelineHeight = botY - topY\n\t\tif (lifelineHeight > 0) {\n\t\t\tlines.push({ id: `lifeline-${key}`, x: x + w / 2, y: topY, endY: lifelineHeight })\n\t\t}\n\t}\n\n\t// 2. Activation boxes (just after lifelines)\n\tconst activationPad = eventStep * ACTIVATION_PAD_RATIO\n\tconst sortedSpans = activationSpans\n\t\t.map((span, origIdx) => ({ ...span, origIdx }))\n\t\t.sort((a, b) => {\n\t\t\tconst sizeA = a.endEventIndex - a.startEventIndex\n\t\t\tconst sizeB = b.endEventIndex - b.startEventIndex\n\t\t\treturn sizeB - sizeA || a.origIdx - b.origIdx\n\t\t})\n\n\tfor (let i = 0; i < sortedSpans.length; i++) {\n\t\tconst span = sortedSpans[i]\n\t\tconst actorIdx = keyIndex.get(span.participantKey)\n\t\tif (actorIdx === undefined) continue\n\n\t\tconst spanSize = span.endEventIndex - span.startEventIndex\n\t\tlet depth = 0\n\t\tfor (const other of sortedSpans) {\n\t\t\tif (other === span) continue\n\t\t\tconst sameParticipant = other.participantKey === span.participantKey\n\t\t\tconst containsSpan =\n\t\t\t\tother.startEventIndex <= span.startEventIndex && other.endEventIndex >= span.endEventIndex\n\t\t\tconst strictlyLarger = other.endEventIndex - other.startEventIndex > spanSize\n\t\t\tif (sameParticipant && containsSpan && strictlyLarger) depth++\n\t\t}\n\n\t\tconst layout = layouts[actorIdx]\n\t\tconst lifelineCenterX = layout.x + layout.w / 2\n\t\tconst boxTop = lifelineTop + eventStep * (span.startEventIndex + 1) - activationPad\n\t\tconst boxBottom = lifelineTop + eventStep * (span.endEventIndex + 1) + activationPad\n\n\t\tconst id = `activation-${span.origIdx}`\n\t\tconst kind = 'sequence_activation'\n\t\tnodes.push({\n\t\t\tid,\n\t\t\tkind,\n\t\t\tx: lifelineCenterX - ACTIVATION_BOX_WIDTH / 2 + depth * ACTIVATION_NEST_OFFSET,\n\t\t\ty: boxTop,\n\t\t\tw: ACTIVATION_BOX_WIDTH,\n\t\t\th: boxBottom - boxTop,\n\t\t\tfill: 'solid',\n\t\t\tcolor: 'light-violet',\n\t\t\tsize: 's',\n\t\t})\n\t}\n\n\t// 3. Fragments\n\tfor (let fragmentIndex = 0; fragmentIndex < fragments.length; fragmentIndex++) {\n\t\tconst fragment = fragments[fragmentIndex]\n\t\tif (fragment.lastEventIndex < fragment.firstEventIndex) continue\n\n\t\tconst fragTop = lifelineTop + eventStep * (fragment.firstEventIndex + 1) - FRAGMENT_PADDING_TOP\n\t\tconst fragBottom =\n\t\t\tlifelineTop + eventStep * (fragment.lastEventIndex + 1) + FRAGMENT_PADDING_BOTTOM\n\t\tconst indices = [...fragment.actorKeys].map((k) => keyIndex.get(k)!).filter((idx) => idx >= 0)\n\t\tif (indices.length === 0) continue\n\n\t\tconst minIndex = Math.min(...indices)\n\t\tconst maxIndex = Math.max(...indices)\n\t\tconst leftX = layouts[minIndex].x - FRAGMENT_PADDING_X\n\t\tconst fragW = layouts[maxIndex].x + layouts[maxIndex].w + FRAGMENT_PADDING_X - leftX\n\t\tconst fragH = fragBottom - fragTop\n\n\t\tconst rgbColor =\n\t\t\tfragment.keyword === 'rect' ? parseRgbToTldrawColor(fragment.sections[0].title) : null\n\t\tconst fragId = `fragment-${fragmentIndex}`\n\t\tconst fragKind = 'sequence_fragment'\n\t\tif (rgbColor) {\n\t\t\tnodes.push({\n\t\t\t\tid: fragId,\n\t\t\t\tkind: fragKind,\n\t\t\t\tx: leftX,\n\t\t\t\ty: fragTop,\n\t\t\t\tw: fragW,\n\t\t\t\th: fragH,\n\t\t\t\tfill: rgbColor.hasAlpha ? 'semi' : 'solid',\n\t\t\t\tcolor: rgbColor.color,\n\t\t\t\tsize: 's',\n\t\t\t})\n\t\t} else {\n\t\t\tnodes.push({\n\t\t\t\tid: fragId,\n\t\t\t\tkind: fragKind,\n\t\t\t\tx: leftX,\n\t\t\t\ty: fragTop,\n\t\t\t\tw: fragW,\n\t\t\t\th: fragH,\n\t\t\t\tdash: 'dashed',\n\t\t\t\tfill: 'none',\n\t\t\t\tcolor: 'light-blue',\n\t\t\t\tsize: 's',\n\t\t\t\talign: 'start',\n\t\t\t\tverticalAlign: 'start',\n\t\t\t\tlabel: `${fragment.keyword} [${fragment.sections[0].title}]`,\n\t\t\t})\n\n\t\t\tfor (let s = 1; s < fragment.sections.length; s++) {\n\t\t\t\tconst section = fragment.sections[s]\n\t\t\t\tconst sepY = lifelineTop + eventStep * (section.firstEventIndex + 0.5)\n\n\t\t\t\tlines.push({\n\t\t\t\t\tid: `fragment-${fragmentIndex}-sep-${s}`,\n\t\t\t\t\tx: leftX,\n\t\t\t\t\ty: sepY,\n\t\t\t\t\tendX: fragW,\n\t\t\t\t\tendY: 0,\n\t\t\t\t\tdash: 'dashed',\n\t\t\t\t\tcolor: 'light-blue',\n\t\t\t\t\tsize: 's',\n\t\t\t\t})\n\n\t\t\t\tconst secId = `fragment-${fragmentIndex}-section-${s}`\n\t\t\t\tconst secKind = 'sequence_fragment_section'\n\t\t\t\tnodes.push({\n\t\t\t\t\tid: secId,\n\t\t\t\t\tkind: secKind,\n\t\t\t\t\tx: leftX + FRAGMENT_SECTION_LABEL_PADDING,\n\t\t\t\t\ty: sepY + FRAGMENT_SECTION_LABEL_PADDING,\n\t\t\t\t\tw: fragW - FRAGMENT_SECTION_LABEL_PADDING * 2,\n\t\t\t\t\th: FRAGMENT_SECTION_LABEL_HEIGHT,\n\t\t\t\t\tfill: 'none',\n\t\t\t\t\tdash: 'dashed',\n\t\t\t\t\tcolor: 'light-blue',\n\t\t\t\t\tsize: 's',\n\t\t\t\t\talign: 'start',\n\t\t\t\t\tverticalAlign: 'start',\n\t\t\t\t\tlabel: `[${section.title}]`,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\n\t// 4. Actor boxes (top and bottom)\n\tfor (let i = 0; i < actorCount; i++) {\n\t\tconst key = actorKeys[i]\n\t\tconst actor = actors.get(key)\n\t\tif (!actor) continue\n\t\tconst { x, y, w, h, bottomY } = layouts[i]\n\t\tconst isCreated = creationEventIndex.has(key)\n\t\tconst isDestroyed = destructionEventIndex.has(key)\n\t\tconst kind = actor.type\n\t\tconst label = actor.description || actor.name || key\n\t\tconst shared = {\n\t\t\tkind,\n\t\t\tlabel,\n\t\t\talign: 'middle' as const,\n\t\t\tverticalAlign: 'middle' as const,\n\t\t\tsize: 's' as const,\n\t\t}\n\n\t\tconst creationY = isCreated ? lifelineTop + eventStep * (creationEventIndex.get(key)! + 1) : 0\n\t\tconst topY = isCreated ? creationY - h / 2 : y\n\t\tconst topId = `actor-top-${key}`\n\t\tnodes.push({\n\t\t\tid: topId,\n\t\t\tx,\n\t\t\ty: topY,\n\t\t\tw,\n\t\t\th,\n\t\t\t...shared,\n\t\t})\n\n\t\tif (!isDestroyed) {\n\t\t\tconst botId = `actor-bottom-${key}`\n\t\t\tnodes.push({\n\t\t\t\tid: botId,\n\t\t\t\tx,\n\t\t\t\ty: bottomY,\n\t\t\t\tw,\n\t\t\t\th,\n\t\t\t\t...shared,\n\t\t\t})\n\t\t}\n\t}\n\n\t// 5. Events: signals and notes\n\tconst pendingCreations = new Set(createdActors.keys())\n\tlet sequenceNumber = autonumberStart\n\n\tfor (let eventIndex = 0; eventIndex < events.length; eventIndex++) {\n\t\tconst msg = events[eventIndex]\n\t\tconst anchor = (eventIndex + 1) / (events.length + 1)\n\n\t\tif (isSignalMessage(msg.type)) {\n\t\t\tconst fromKey = msg.from!\n\t\t\tconst toKey = msg.to!\n\t\t\tif (!keyIndex.has(fromKey) || !keyIndex.has(toKey)) continue\n\n\t\t\tconst isCreationMessage = pendingCreations.has(toKey)\n\t\t\tif (isCreationMessage) pendingCreations.delete(toKey)\n\n\t\t\tconst msgType = msg.type ?? LINETYPE.SOLID\n\t\t\tconst { dash, arrowheadEnd } = mapLineTypeToArrowProps(msgType)\n\t\t\tconst isSelf = fromKey === toKey\n\t\t\tconst bidir = !isSelf && isBidirectional(msgType)\n\n\t\t\tconst edge: MermaidBlueprintEdge = {\n\t\t\t\tstartNodeId: `lifeline-${fromKey}`,\n\t\t\t\tendNodeId: isCreationMessage ? `actor-top-${toKey}` : `lifeline-${toKey}`,\n\t\t\t\tlabel: getMessageLabel(msg),\n\t\t\t\tbend: isSelf ? SELF_MSG_BEND : 0,\n\t\t\t\tdash,\n\t\t\t\tarrowheadEnd,\n\t\t\t\tarrowheadStart: bidir ? 'arrow' : 'none',\n\t\t\t\tsize: 's',\n\t\t\t\tanchorStartY: isSelf ? anchor - SELF_MSG_Y_OFFSET : anchor,\n\t\t\t\tanchorEndY: isCreationMessage ? 0.5 : isSelf ? anchor + SELF_MSG_Y_OFFSET : anchor,\n\t\t\t\tisExact: true,\n\t\t\t\tisPrecise: true,\n\t\t\t\t...(isCreationMessage && { isExactEnd: false, isPreciseEnd: false }),\n\t\t\t}\n\n\t\t\tif (autonumberVisible) {\n\t\t\t\tedge.decoration = { type: 'autonumber', value: String(sequenceNumber) }\n\t\t\t\tsequenceNumber += autonumberStep\n\t\t\t}\n\n\t\t\tedges.push(edge)\n\t\t} else if (isNoteMessage(msg.type)) {\n\t\t\tconst eventY = lifelineTop + eventStep * (eventIndex + 1)\n\t\t\tconst fromKey = msg.from!\n\t\t\tconst fromIdx = keyIndex.get(fromKey)\n\t\t\tconst toIdx = keyIndex.get(msg.to ?? fromKey)\n\t\t\tif (fromIdx === undefined) continue\n\n\t\t\tconst label = getMessageLabel(msg)\n\t\t\t// Mermaid types `placement` as a string enum but the runtime value is numeric\n\t\t\tconst msgPlacement = msg.placement as unknown as number | undefined\n\t\t\tconst fromCenterX = layouts[fromIdx].x + layouts[fromIdx].w / 2\n\t\t\tconst toCenterX = toIdx !== undefined ? layouts[toIdx].x + layouts[toIdx].w / 2 : fromCenterX\n\t\t\tconst isSpanning =\n\t\t\t\tmsgPlacement === PLACEMENT.OVER && msg.from !== msg.to && toIdx !== undefined\n\n\t\t\tconst svgNote = svgNoteRects[svgNoteIndex++]\n\t\t\tconst noteHeight = svgNote?.h ?? FALLBACK_NOTE_HEIGHT\n\t\t\tconst textWidth = label ? label.length * NOTE_CHAR_WIDTH + NOTE_TEXT_PADDING : 0\n\t\t\tconst baseWidth = Math.max(svgNote?.w ?? FALLBACK_NOTE_WIDTH, textWidth)\n\t\t\tconst noteWidth = isSpanning\n\t\t\t\t? Math.max(baseWidth, Math.abs(toCenterX - fromCenterX) + NOTE_PADDING)\n\t\t\t\t: baseWidth\n\n\t\t\tlet noteX: number\n\t\t\tif (msgPlacement === PLACEMENT.LEFTOF) {\n\t\t\t\tnoteX = fromCenterX - noteWidth - NOTE_PADDING\n\t\t\t} else if (msgPlacement === PLACEMENT.RIGHTOF) {\n\t\t\t\tnoteX = fromCenterX + NOTE_PADDING\n\t\t\t} else if (isSpanning) {\n\t\t\t\tnoteX = (fromCenterX + toCenterX) / 2 - noteWidth / 2\n\t\t\t} else {\n\t\t\t\tnoteX = fromCenterX - noteWidth / 2\n\t\t\t}\n\n\t\t\tconst noteId = `note-${eventIndex}`\n\t\t\tconst noteKind = 'sequence_note'\n\t\t\tnodes.push({\n\t\t\t\tid: noteId,\n\t\t\t\tkind: noteKind,\n\t\t\t\tx: noteX,\n\t\t\t\ty: eventY - noteHeight / 2,\n\t\t\t\tw: noteWidth,\n\t\t\t\th: noteHeight,\n\t\t\t\tfill: 'solid',\n\t\t\t\tcolor: 'yellow',\n\t\t\t\tdash: 'draw',\n\t\t\t\tsize: 's',\n\t\t\t\talign: 'middle',\n\t\t\t\tverticalAlign: 'middle',\n\t\t\t\tlabel,\n\t\t\t})\n\t\t}\n\t}\n\n\treturn {\n\t\tdiagramKind: 'sequence',\n\t\tnodes,\n\t\tedges,\n\t\tlines,\n\t\tgroups: actorKeys.map((key) => {\n\t\t\tconst group = [`actor-top-${key}`, `lifeline-${key}`]\n\t\t\tif (!destructionEventIndex.has(key)) {\n\t\t\t\tgroup.push(`actor-bottom-${key}`)\n\t\t\t}\n\t\t\treturn group\n\t\t}),\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,oBAAsC;AACtC,wBAAwC;AAsBxC,MAAM,WAAW;AAAA,EAChB,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AAAA,EACb,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,WAA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vB,WAAW,YAAY;AACtB,iBAAS,cAAc,aAAa,IAAI,YAAY;AAAA,MACrD,OAAO;AACN,gBAAQ,cAAc,YAAY;AAAA,MACnC;AAEA,YAAM,SAAS,QAAQ,UAAU;AACjC,YAAM,WAAW;AACjB,YAAM,KAAK;AAAA,QACV,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,GAAG;AAAA,QACH,GAAG,SAAS,aAAa;AAAA,QACzB,GAAG;AAAA,QACH,GAAG;AAAA,QACH,MAAM;AAAA,QACN,OAAO;AAAA,QACP,MAAM;AAAA,QACN,MAAM;AAAA,QACN,OAAO;AAAA,QACP,eAAe;AAAA,QACf;AAAA,MACD,CAAC;AAAA,IACF;AAAA,EACD;AAEA,SAAO;AAAA,IACN,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ,UAAU,IAAI,CAAC,QAAQ;AAC9B,YAAM,QAAQ,CAAC,aAAa,GAAG,IAAI,YAAY,GAAG,EAAE;AACpD,UAAI,CAAC,sBAAsB,IAAI,GAAG,GAAG;AACpC,cAAM,KAAK,gBAAgB,GAAG,EAAE;AAAA,MACjC;AACA,aAAO;AAAA,IACR,CAAC;AAAA,EACF;AACD;",
6
6
  "names": ["layout"]
7
7
  }
@@ -175,12 +175,16 @@ function parseStateDiagramLayout(root) {
175
175
  const nodes = (0, import_svgParsing.parseNodesFromSvg)(
176
176
  root,
177
177
  ".node",
178
- (domId) => domId.match(/^state-(.+)-\d+$/)?.[1] ?? domId
178
+ (domId) => domId.match(/^(?:mermaid-\d+-)?state-(.+)-\d+$/)?.[1] ?? domId
179
+ );
180
+ const clusters = (0, import_svgParsing.parseClustersFromSvg)(
181
+ root,
182
+ ".statediagram-cluster",
183
+ (domId) => domId.match(/^(?:mermaid-\d+-)?state-(.+)-\d+$/)?.[1] ?? domId
179
184
  );
180
- const clusters = (0, import_svgParsing.parseClustersFromSvg)(root, ".statediagram-cluster");
181
185
  const edges = (0, import_svgParsing.parseAllEdgePointsFromSvg)(
182
186
  root,
183
- (dataId) => /^edge\d+$/.test(dataId) ? { start: "", end: "" } : null
187
+ (dataId) => /(?:^|-)edge\d+$/.test(dataId) ? { start: "", end: "" } : null
184
188
  );
185
189
  (0, import_svgParsing.scaleLayout)(nodes, clusters, edges, import_utils.LAYOUT_SCALE);
186
190
  return { nodes, clusters, edges };