UNPKG

better-mermaid

Version:

Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.

1,635 lines (1,598 loc) 145 kB
import { version } from "./chunks/mermaid.esm/chunk-WQ2KQLPX.mjs"; import { selectSvgElement } from "./chunks/mermaid.esm/chunk-NHHPMVCG.mjs"; import { dedent } from "./chunks/mermaid.esm/chunk-5PZZPJGE.mjs"; import { isEmpty_default } from "./chunks/mermaid.esm/chunk-3FCBLY7Z.mjs"; import { cleanAndMerge, decodeEntities, encodeEntities, isDetailedError, removeDirectives, utils_default } from "./chunks/mermaid.esm/chunk-WWBCIV6K.mjs"; import "./chunks/mermaid.esm/chunk-A6W4AWM4.mjs"; import "./chunks/mermaid.esm/chunk-TNAZEAIZ.mjs"; import { UnknownDiagramError, addDirective, configureSvgSize, defaultConfig, detectType, detectors, evaluate, frontMatterRegex, getConfig, getDiagram, getDiagramLoader, getSiteConfig, log, registerDiagram, registerLazyLoadedDiagrams, require_purify, reset, saveConfigFromInitialize, select_default, setConfig, setLogLevel, setSiteConfig, styles_default, themes_default, updateSiteConfig } from "./chunks/mermaid.esm/chunk-3NFSSYB3.mjs"; import { __name, __toESM } from "./chunks/mermaid.esm/chunk-N5XDFYNB.mjs"; // ../../node_modules/.pnpm/stylis@4.3.2/node_modules/stylis/src/Enum.js var COMMENT = "comm"; var RULESET = "rule"; var DECLARATION = "decl"; var IMPORT = "@import"; var KEYFRAMES = "@keyframes"; var LAYER = "@layer"; // ../../node_modules/.pnpm/stylis@4.3.2/node_modules/stylis/src/Utility.js var abs = Math.abs; var from = String.fromCharCode; function trim(value) { return value.trim(); } __name(trim, "trim"); function replace(value, pattern, replacement) { return value.replace(pattern, replacement); } __name(replace, "replace"); function indexof(value, search, position2) { return value.indexOf(search, position2); } __name(indexof, "indexof"); function charat(value, index) { return value.charCodeAt(index) | 0; } __name(charat, "charat"); function substr(value, begin, end) { return value.slice(begin, end); } __name(substr, "substr"); function strlen(value) { return value.length; } __name(strlen, "strlen"); function sizeof(value) { return value.length; } __name(sizeof, "sizeof"); function append(value, array) { return array.push(value), value; } __name(append, "append"); // ../../node_modules/.pnpm/stylis@4.3.2/node_modules/stylis/src/Tokenizer.js var line = 1; var column = 1; var length = 0; var position = 0; var character = 0; var characters = ""; function node(value, root, parent, type2, props, children, length2, siblings) { return { value, root, parent, type: type2, props, children, line, column, length: length2, return: "", siblings }; } __name(node, "node"); function char() { return character; } __name(char, "char"); function prev() { character = position > 0 ? charat(characters, --position) : 0; if (column--, character === 10) column = 1, line--; return character; } __name(prev, "prev"); function next() { character = position < length ? charat(characters, position++) : 0; if (column++, character === 10) column = 1, line++; return character; } __name(next, "next"); function peek() { return charat(characters, position); } __name(peek, "peek"); function caret() { return position; } __name(caret, "caret"); function slice(begin, end) { return substr(characters, begin, end); } __name(slice, "slice"); function token(type2) { switch (type2) { case 0: case 9: case 10: case 13: case 32: return 5; case 33: case 43: case 44: case 47: case 62: case 64: case 126: case 59: case 123: case 125: return 4; case 58: return 3; case 34: case 39: case 40: case 91: return 2; case 41: case 93: return 1; } return 0; } __name(token, "token"); function alloc(value) { return line = column = 1, length = strlen(characters = value), position = 0, []; } __name(alloc, "alloc"); function dealloc(value) { return characters = "", value; } __name(dealloc, "dealloc"); function delimit(type2) { return trim(slice(position - 1, delimiter(type2 === 91 ? type2 + 2 : type2 === 40 ? type2 + 1 : type2))); } __name(delimit, "delimit"); function whitespace(type2) { while (character = peek()) if (character < 33) next(); else break; return token(type2) > 2 || token(character) > 3 ? "" : " "; } __name(whitespace, "whitespace"); function escaping(index, count) { while (--count && next()) if (character < 48 || character > 102 || character > 57 && character < 65 || character > 70 && character < 97) break; return slice(index, caret() + (count < 6 && peek() == 32 && next() == 32)); } __name(escaping, "escaping"); function delimiter(type2) { while (next()) switch (character) { case type2: return position; case 34: case 39: if (type2 !== 34 && type2 !== 39) delimiter(character); break; case 40: if (type2 === 41) delimiter(type2); break; case 92: next(); break; } return position; } __name(delimiter, "delimiter"); function commenter(type2, index) { while (next()) if (type2 + character === 47 + 10) break; else if (type2 + character === 42 + 42 && peek() === 47) break; return "/*" + slice(index, position - 1) + "*" + from(type2 === 47 ? type2 : next()); } __name(commenter, "commenter"); function identifier(index) { while (!token(peek())) next(); return slice(index, position); } __name(identifier, "identifier"); // ../../node_modules/.pnpm/stylis@4.3.2/node_modules/stylis/src/Parser.js function compile(value) { return dealloc(parse("", null, null, null, [""], value = alloc(value), 0, [0], value)); } __name(compile, "compile"); function parse(value, root, parent, rule, rules, rulesets, pseudo, points, declarations) { var index = 0; var offset = 0; var length2 = pseudo; var atrule = 0; var property = 0; var previous = 0; var variable = 1; var scanning = 1; var ampersand = 1; var character2 = 0; var type2 = ""; var props = rules; var children = rulesets; var reference = rule; var characters2 = type2; while (scanning) switch (previous = character2, character2 = next()) { case 40: if (previous != 108 && charat(characters2, length2 - 1) == 58) { if (indexof(characters2 += replace(delimit(character2), "&", "&\f"), "&\f", abs(index ? points[index - 1] : 0)) != -1) ampersand = -1; break; } case 34: case 39: case 91: characters2 += delimit(character2); break; case 9: case 10: case 13: case 32: characters2 += whitespace(previous); break; case 92: characters2 += escaping(caret() - 1, 7); continue; case 47: switch (peek()) { case 42: case 47: append(comment(commenter(next(), caret()), root, parent, declarations), declarations); break; default: characters2 += "/"; } break; case 123 * variable: points[index++] = strlen(characters2) * ampersand; case 125 * variable: case 59: case 0: switch (character2) { case 0: case 125: scanning = 0; case 59 + offset: if (ampersand == -1) characters2 = replace(characters2, /\f/g, ""); if (property > 0 && strlen(characters2) - length2) append(property > 32 ? declaration(characters2 + ";", rule, parent, length2 - 1, declarations) : declaration(replace(characters2, " ", "") + ";", rule, parent, length2 - 2, declarations), declarations); break; case 59: characters2 += ";"; default: append(reference = ruleset(characters2, root, parent, index, offset, rules, points, type2, props = [], children = [], length2, rulesets), rulesets); if (character2 === 123) if (offset === 0) parse(characters2, root, reference, reference, props, rulesets, length2, points, children); else switch (atrule === 99 && charat(characters2, 3) === 110 ? 100 : atrule) { case 100: case 108: case 109: case 115: parse(value, reference, reference, rule && append(ruleset(value, reference, reference, 0, 0, rules, points, type2, rules, props = [], length2, children), children), rules, children, length2, points, rule ? props : children); break; default: parse(characters2, reference, reference, reference, [""], children, 0, points, children); } } index = offset = property = 0, variable = ampersand = 1, type2 = characters2 = "", length2 = pseudo; break; case 58: length2 = 1 + strlen(characters2), property = previous; default: if (variable < 1) { if (character2 == 123) --variable; else if (character2 == 125 && variable++ == 0 && prev() == 125) continue; } switch (characters2 += from(character2), character2 * variable) { case 38: ampersand = offset > 0 ? 1 : (characters2 += "\f", -1); break; case 44: points[index++] = (strlen(characters2) - 1) * ampersand, ampersand = 1; break; case 64: if (peek() === 45) characters2 += delimit(next()); atrule = peek(), offset = length2 = strlen(type2 = characters2 += identifier(caret())), character2++; break; case 45: if (previous === 45 && strlen(characters2) == 2) variable = 0; } } return rulesets; } __name(parse, "parse"); function ruleset(value, root, parent, index, offset, rules, points, type2, props, children, length2, siblings) { var post = offset - 1; var rule = offset === 0 ? rules : [""]; var size = sizeof(rule); for (var i = 0, j = 0, k = 0; i < index; ++i) for (var x = 0, y = substr(value, post + 1, post = abs(j = points[i])), z = value; x < size; ++x) if (z = trim(j > 0 ? rule[x] + " " + y : replace(y, /&\f/g, rule[x]))) props[k++] = z; return node(value, root, parent, offset === 0 ? RULESET : type2, props, children, length2, siblings); } __name(ruleset, "ruleset"); function comment(value, root, parent, siblings) { return node(value, root, parent, COMMENT, from(char()), substr(value, 2, -2), 0, siblings); } __name(comment, "comment"); function declaration(value, root, parent, length2, siblings) { return node(value, root, parent, DECLARATION, substr(value, 0, length2), substr(value, length2 + 1, -1), length2, siblings); } __name(declaration, "declaration"); // ../../node_modules/.pnpm/stylis@4.3.2/node_modules/stylis/src/Serializer.js function serialize(children, callback) { var output = ""; for (var i = 0; i < children.length; i++) output += callback(children[i], i, children, callback) || ""; return output; } __name(serialize, "serialize"); function stringify(element, index, children, callback) { switch (element.type) { case LAYER: if (element.children.length) break; case IMPORT: case DECLARATION: return element.return = element.return || element.value; case COMMENT: return ""; case KEYFRAMES: return element.return = element.value + "{" + serialize(element.children, callback) + "}"; case RULESET: if (!strlen(element.value = element.props.join(","))) return ""; } return strlen(children = serialize(element.children, callback)) ? element.return = element.value + "{" + children + "}" : ""; } __name(stringify, "stringify"); // src/diagrams/c4/c4Detector.ts var id = "c4"; var detector = /* @__PURE__ */ __name((txt) => { return /^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(txt); }, "detector"); var loader = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.esm/c4Diagram-IUKRJHA5.mjs"); return { id, diagram: diagram2 }; }, "loader"); var plugin = { id, detector, loader }; var c4Detector_default = plugin; // src/diagrams/flowchart/flowDetector.ts var id2 = "flowchart"; var detector2 = /* @__PURE__ */ __name((txt, config) => { if (config?.flowchart?.defaultRenderer === "dagre-wrapper" || config?.flowchart?.defaultRenderer === "elk") { return false; } return /^\s*graph/.test(txt); }, "detector"); var loader2 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.esm/flowDiagram-E57WTSN3.mjs"); return { id: id2, diagram: diagram2 }; }, "loader"); var plugin2 = { id: id2, detector: detector2, loader: loader2 }; var flowDetector_default = plugin2; // src/diagrams/flowchart/flowDetector-v2.ts var id3 = "flowchart-v2"; var detector3 = /* @__PURE__ */ __name((txt, config) => { if (config?.flowchart?.defaultRenderer === "dagre-d3" || config?.flowchart?.defaultRenderer === "elk") { return false; } if (/^\s*graph/.test(txt) && config?.flowchart?.defaultRenderer === "dagre-wrapper") { return true; } return /^\s*flowchart/.test(txt); }, "detector"); var loader3 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.esm/flowDiagram-v2-ZH6S6JJX.mjs"); return { id: id3, diagram: diagram2 }; }, "loader"); var plugin3 = { id: id3, detector: detector3, loader: loader3 }; var flowDetector_v2_default = plugin3; // src/diagrams/er/erDetector.ts var id4 = "er"; var detector4 = /* @__PURE__ */ __name((txt) => { return /^\s*erDiagram/.test(txt); }, "detector"); var loader4 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.esm/erDiagram-FNUFBC42.mjs"); return { id: id4, diagram: diagram2 }; }, "loader"); var plugin4 = { id: id4, detector: detector4, loader: loader4 }; var erDetector_default = plugin4; // src/diagrams/git/gitGraphDetector.ts var id5 = "gitGraph"; var detector5 = /* @__PURE__ */ __name((txt) => { return /^\s*gitGraph/.test(txt); }, "detector"); var loader5 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.esm/gitGraphDiagram-FJKRIPXU.mjs"); return { id: id5, diagram: diagram2 }; }, "loader"); var plugin5 = { id: id5, detector: detector5, loader: loader5 }; var gitGraphDetector_default = plugin5; // src/diagrams/gantt/ganttDetector.ts var id6 = "gantt"; var detector6 = /* @__PURE__ */ __name((txt) => { return /^\s*gantt/.test(txt); }, "detector"); var loader6 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.esm/ganttDiagram-QPPY3KYO.mjs"); return { id: id6, diagram: diagram2 }; }, "loader"); var plugin6 = { id: id6, detector: detector6, loader: loader6 }; var ganttDetector_default = plugin6; // src/diagrams/info/infoDetector.ts var id7 = "info"; var detector7 = /* @__PURE__ */ __name((txt) => { return /^\s*info/.test(txt); }, "detector"); var loader7 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.esm/infoDiagram-6JP6MW3J.mjs"); return { id: id7, diagram: diagram2 }; }, "loader"); var info = { id: id7, detector: detector7, loader: loader7 }; // src/diagrams/pie/pieDetector.ts var id8 = "pie"; var detector8 = /* @__PURE__ */ __name((txt) => { return /^\s*pie/.test(txt); }, "detector"); var loader8 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.esm/pieDiagram-2BCRGBP6.mjs"); return { id: id8, diagram: diagram2 }; }, "loader"); var pie = { id: id8, detector: detector8, loader: loader8 }; // src/diagrams/quadrant-chart/quadrantDetector.ts var id9 = "quadrantChart"; var detector9 = /* @__PURE__ */ __name((txt) => { return /^\s*quadrantChart/.test(txt); }, "detector"); var loader9 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.esm/quadrantDiagram-URLAIDFT.mjs"); return { id: id9, diagram: diagram2 }; }, "loader"); var plugin7 = { id: id9, detector: detector9, loader: loader9 }; var quadrantDetector_default = plugin7; // src/diagrams/xychart/xychartDetector.ts var id10 = "xychart"; var detector10 = /* @__PURE__ */ __name((txt) => { return /^\s*xychart-beta/.test(txt); }, "detector"); var loader10 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.esm/xychartDiagram-X5JPAZUH.mjs"); return { id: id10, diagram: diagram2 }; }, "loader"); var plugin8 = { id: id10, detector: detector10, loader: loader10 }; var xychartDetector_default = plugin8; // src/diagrams/requirement/requirementDetector.ts var id11 = "requirement"; var detector11 = /* @__PURE__ */ __name((txt) => { return /^\s*requirement(Diagram)?/.test(txt); }, "detector"); var loader11 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.esm/requirementDiagram-P2ENE5MN.mjs"); return { id: id11, diagram: diagram2 }; }, "loader"); var plugin9 = { id: id11, detector: detector11, loader: loader11 }; var requirementDetector_default = plugin9; // src/diagrams/sequence/sequenceDetector.ts var id12 = "sequence"; var detector12 = /* @__PURE__ */ __name((txt) => { return /^\s*sequenceDiagram/.test(txt); }, "detector"); var loader12 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.esm/sequenceDiagram-BYGRHM4M.mjs"); return { id: id12, diagram: diagram2 }; }, "loader"); var plugin10 = { id: id12, detector: detector12, loader: loader12 }; var sequenceDetector_default = plugin10; // src/diagrams/class/classDetector.ts var id13 = "class"; var detector13 = /* @__PURE__ */ __name((txt, config) => { if (config?.class?.defaultRenderer === "dagre-wrapper") { return false; } return /^\s*classDiagram/.test(txt); }, "detector"); var loader13 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.esm/classDiagram-RX7I4B6U.mjs"); return { id: id13, diagram: diagram2 }; }, "loader"); var plugin11 = { id: id13, detector: detector13, loader: loader13 }; var classDetector_default = plugin11; // src/diagrams/class/classDetector-V2.ts var id14 = "classDiagram"; var detector14 = /* @__PURE__ */ __name((txt, config) => { if (/^\s*classDiagram/.test(txt) && config?.class?.defaultRenderer === "dagre-wrapper") { return true; } return /^\s*classDiagram-v2/.test(txt); }, "detector"); var loader14 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.esm/classDiagram-v2-6F7YWPUJ.mjs"); return { id: id14, diagram: diagram2 }; }, "loader"); var plugin12 = { id: id14, detector: detector14, loader: loader14 }; var classDetector_V2_default = plugin12; // src/diagrams/state/stateDetector.ts var id15 = "state"; var detector15 = /* @__PURE__ */ __name((txt, config) => { if (config?.state?.defaultRenderer === "dagre-wrapper") { return false; } return /^\s*stateDiagram/.test(txt); }, "detector"); var loader15 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.esm/stateDiagram-44FBNIT4.mjs"); return { id: id15, diagram: diagram2 }; }, "loader"); var plugin13 = { id: id15, detector: detector15, loader: loader15 }; var stateDetector_default = plugin13; // src/diagrams/state/stateDetector-V2.ts var id16 = "stateDiagram"; var detector16 = /* @__PURE__ */ __name((txt, config) => { if (/^\s*stateDiagram-v2/.test(txt)) { return true; } if (/^\s*stateDiagram/.test(txt) && config?.state?.defaultRenderer === "dagre-wrapper") { return true; } return false; }, "detector"); var loader16 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.esm/stateDiagram-v2-E5RCKZZT.mjs"); return { id: id16, diagram: diagram2 }; }, "loader"); var plugin14 = { id: id16, detector: detector16, loader: loader16 }; var stateDetector_V2_default = plugin14; // src/diagrams/user-journey/journeyDetector.ts var id17 = "journey"; var detector17 = /* @__PURE__ */ __name((txt) => { return /^\s*journey/.test(txt); }, "detector"); var loader17 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.esm/journeyDiagram-4HNOFHWX.mjs"); return { id: id17, diagram: diagram2 }; }, "loader"); var plugin15 = { id: id17, detector: detector17, loader: loader17 }; var journeyDetector_default = plugin15; // src/diagrams/error/errorRenderer.ts var draw = /* @__PURE__ */ __name((_text, id24, version2) => { log.debug("rendering svg for syntax error\n"); const svg = selectSvgElement(id24); const g = svg.append("g"); svg.attr("viewBox", "0 0 2412 512"); configureSvgSize(svg, 100, 512, true); g.append("path").attr("class", "error-icon").attr( "d", "m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z" ); g.append("path").attr("class", "error-icon").attr( "d", "m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z" ); g.append("path").attr("class", "error-icon").attr( "d", "m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z" ); g.append("path").attr("class", "error-icon").attr( "d", "m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z" ); g.append("path").attr("class", "error-icon").attr( "d", "m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z" ); g.append("path").attr("class", "error-icon").attr( "d", "m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z" ); g.append("text").attr("class", "error-text").attr("x", 1440).attr("y", 250).attr("font-size", "150px").style("text-anchor", "middle").text("Syntax error in text"); g.append("text").attr("class", "error-text").attr("x", 1250).attr("y", 400).attr("font-size", "100px").style("text-anchor", "middle").text(`mermaid version ${version2}`); }, "draw"); var renderer = { draw }; var errorRenderer_default = renderer; // src/diagrams/error/errorDiagram.ts var diagram = { db: {}, renderer, parser: { parse: () => { return; } } }; var errorDiagram_default = diagram; // src/diagrams/flowchart/elk/detector.ts var id18 = "flowchart-elk"; var detector18 = /* @__PURE__ */ __name((txt, config) => { if ( // If diagram explicitly states flowchart-elk /^\s*flowchart-elk/.test(txt) || // If a flowchart/graph diagram has their default renderer set to elk /^\s*flowchart|graph/.test(txt) && config?.flowchart?.defaultRenderer === "elk" ) { setTimeout( () => log.warn( "flowchart-elk was moved to an external package in Mermaid v11. Please refer [release notes](link) for more details. This diagram will be rendered using `dagre` layout as a fallback." ), 500 ); return true; } return false; }, "detector"); var loader18 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.esm/flowDiagram-v2-ZH6S6JJX.mjs"); return { id: id18, diagram: diagram2 }; }, "loader"); var plugin16 = { id: id18, detector: detector18, loader: loader18 }; var detector_default = plugin16; // src/diagrams/timeline/detector.ts var id19 = "timeline"; var detector19 = /* @__PURE__ */ __name((txt) => { return /^\s*timeline/.test(txt); }, "detector"); var loader19 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.esm/timeline-definition-7HBUFA7D.mjs"); return { id: id19, diagram: diagram2 }; }, "loader"); var plugin17 = { id: id19, detector: detector19, loader: loader19 }; var detector_default2 = plugin17; // src/diagrams/mindmap/detector.ts var id20 = "mindmap"; var detector20 = /* @__PURE__ */ __name((txt) => { return /^\s*mindmap/.test(txt); }, "detector"); var loader20 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.esm/mindmap-definition-5GC6ODE4.mjs"); return { id: id20, diagram: diagram2 }; }, "loader"); var plugin18 = { id: id20, detector: detector20, loader: loader20 }; var detector_default3 = plugin18; // src/diagrams/sankey/sankeyDetector.ts var id21 = "sankey"; var detector21 = /* @__PURE__ */ __name((txt) => { return /^\s*sankey-beta/.test(txt); }, "detector"); var loader21 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.esm/sankeyDiagram-BGLVMNGT.mjs"); return { id: id21, diagram: diagram2 }; }, "loader"); var plugin19 = { id: id21, detector: detector21, loader: loader21 }; var sankeyDetector_default = plugin19; // src/diagrams/packet/detector.ts var id22 = "packet"; var detector22 = /* @__PURE__ */ __name((txt) => { return /^\s*packet-beta/.test(txt); }, "detector"); var loader22 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.esm/diagram-H73FXXIG.mjs"); return { id: id22, diagram: diagram2 }; }, "loader"); var packet = { id: id22, detector: detector22, loader: loader22 }; // src/diagrams/block/blockDetector.ts var id23 = "block"; var detector23 = /* @__PURE__ */ __name((txt) => { return /^\s*block-beta/.test(txt); }, "detector"); var loader23 = /* @__PURE__ */ __name(async () => { const { diagram: diagram2 } = await import("./chunks/mermaid.esm/blockDiagram-KWD2NIA3.mjs"); return { id: id23, diagram: diagram2 }; }, "loader"); var plugin20 = { id: id23, detector: detector23, loader: loader23 }; var blockDetector_default = plugin20; // src/diagram-api/diagram-orchestration.ts var hasLoadedDiagrams = false; var addDiagrams = /* @__PURE__ */ __name(() => { if (hasLoadedDiagrams) { return; } hasLoadedDiagrams = true; registerDiagram("error", errorDiagram_default, (text) => { return text.toLowerCase().trim() === "error"; }); registerDiagram( "---", // --- diagram type may appear if YAML front-matter is not parsed correctly { db: { clear: () => { } }, styles: {}, // should never be used renderer: { draw: () => { } }, parser: { parse: () => { throw new Error( "Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks" ); } }, init: () => null // no op }, (text) => { return text.toLowerCase().trimStart().startsWith("---"); } ); registerLazyLoadedDiagrams( c4Detector_default, classDetector_V2_default, classDetector_default, erDetector_default, ganttDetector_default, info, pie, requirementDetector_default, sequenceDetector_default, detector_default, flowDetector_v2_default, flowDetector_default, detector_default3, detector_default2, gitGraphDetector_default, stateDetector_V2_default, stateDetector_default, journeyDetector_default, quadrantDetector_default, sankeyDetector_default, packet, xychartDetector_default, blockDetector_default ); }, "addDiagrams"); // src/Diagram.ts var Diagram = class _Diagram { constructor(type2, text, db, parser, renderer2) { this.type = type2; this.text = text; this.db = db; this.parser = parser; this.renderer = renderer2; } static { __name(this, "Diagram"); } static async fromText(text, metadata = {}) { const config = getConfig(); const type2 = detectType(text, config); text = encodeEntities(text) + "\n"; try { getDiagram(type2); } catch (e) { const loader25 = getDiagramLoader(type2); if (!loader25) { throw new UnknownDiagramError(`Diagram ${type2} not found.`); } const { id: id24, diagram: diagram2 } = await loader25(); registerDiagram(id24, diagram2); } const { db, parser, renderer: renderer2, init: init2 } = getDiagram(type2); if (parser.parser) { parser.parser.yy = db; } db.clear?.(); init2?.(config); if (metadata.title) { db.setDiagramTitle?.(metadata.title); } await parser.parse(text); return new _Diagram(type2, text, db, parser, renderer2); } async render(id24, version2) { await this.renderer.draw(this.text, id24, version2, this); } getParser() { return this.parser; } getType() { return this.type; } }; // src/interactionDb.ts var interactionFunctions = []; var attachFunctions = /* @__PURE__ */ __name(() => { interactionFunctions.forEach((f) => { f(); }); interactionFunctions = []; }, "attachFunctions"); // src/mermaidAPI.ts var import_dompurify = __toESM(require_purify(), 1); // src/accessibility.ts var SVG_ROLE = "graphics-document document"; function setA11yDiagramInfo(svg, diagramType) { svg.attr("role", SVG_ROLE); if (diagramType !== "") { svg.attr("aria-roledescription", diagramType); } } __name(setA11yDiagramInfo, "setA11yDiagramInfo"); function addSVGa11yTitleDescription(svg, a11yTitle, a11yDesc, baseId) { if (svg.insert === void 0) { return; } if (a11yDesc) { const descId = `chart-desc-${baseId}`; svg.attr("aria-describedby", descId); svg.insert("desc", ":first-child").attr("id", descId).text(a11yDesc); } if (a11yTitle) { const titleId = `chart-title-${baseId}`; svg.attr("aria-labelledby", titleId); svg.insert("title", ":first-child").attr("id", titleId).text(a11yTitle); } } __name(addSVGa11yTitleDescription, "addSVGa11yTitleDescription"); // src/diagram-api/comments.ts var cleanupComments = /* @__PURE__ */ __name((text) => { return text.replace(/^\s*%%(?!{)[^\n]+\n?/gm, "").trimStart(); }, "cleanupComments"); // ../../node_modules/.pnpm/js-yaml@4.1.0/node_modules/js-yaml/dist/js-yaml.mjs function isNothing(subject) { return typeof subject === "undefined" || subject === null; } __name(isNothing, "isNothing"); function isObject(subject) { return typeof subject === "object" && subject !== null; } __name(isObject, "isObject"); function toArray(sequence) { if (Array.isArray(sequence)) return sequence; else if (isNothing(sequence)) return []; return [sequence]; } __name(toArray, "toArray"); function extend(target, source) { var index, length2, key, sourceKeys; if (source) { sourceKeys = Object.keys(source); for (index = 0, length2 = sourceKeys.length; index < length2; index += 1) { key = sourceKeys[index]; target[key] = source[key]; } } return target; } __name(extend, "extend"); function repeat(string, count) { var result = "", cycle; for (cycle = 0; cycle < count; cycle += 1) { result += string; } return result; } __name(repeat, "repeat"); function isNegativeZero(number) { return number === 0 && Number.NEGATIVE_INFINITY === 1 / number; } __name(isNegativeZero, "isNegativeZero"); var isNothing_1 = isNothing; var isObject_1 = isObject; var toArray_1 = toArray; var repeat_1 = repeat; var isNegativeZero_1 = isNegativeZero; var extend_1 = extend; var common = { isNothing: isNothing_1, isObject: isObject_1, toArray: toArray_1, repeat: repeat_1, isNegativeZero: isNegativeZero_1, extend: extend_1 }; function formatError(exception2, compact) { var where = "", message = exception2.reason || "(unknown reason)"; if (!exception2.mark) return message; if (exception2.mark.name) { where += 'in "' + exception2.mark.name + '" '; } where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")"; if (!compact && exception2.mark.snippet) { where += "\n\n" + exception2.mark.snippet; } return message + " " + where; } __name(formatError, "formatError"); function YAMLException$1(reason, mark) { Error.call(this); this.name = "YAMLException"; this.reason = reason; this.mark = mark; this.message = formatError(this, false); if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } else { this.stack = new Error().stack || ""; } } __name(YAMLException$1, "YAMLException$1"); YAMLException$1.prototype = Object.create(Error.prototype); YAMLException$1.prototype.constructor = YAMLException$1; YAMLException$1.prototype.toString = /* @__PURE__ */ __name(function toString(compact) { return this.name + ": " + formatError(this, compact); }, "toString"); var exception = YAMLException$1; function getLine(buffer, lineStart, lineEnd, position2, maxLineLength) { var head = ""; var tail = ""; var maxHalfLength = Math.floor(maxLineLength / 2) - 1; if (position2 - lineStart > maxHalfLength) { head = " ... "; lineStart = position2 - maxHalfLength + head.length; } if (lineEnd - position2 > maxHalfLength) { tail = " ..."; lineEnd = position2 + maxHalfLength - tail.length; } return { str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail, pos: position2 - lineStart + head.length // relative position }; } __name(getLine, "getLine"); function padStart(string, max) { return common.repeat(" ", max - string.length) + string; } __name(padStart, "padStart"); function makeSnippet(mark, options) { options = Object.create(options || null); if (!mark.buffer) return null; if (!options.maxLength) options.maxLength = 79; if (typeof options.indent !== "number") options.indent = 1; if (typeof options.linesBefore !== "number") options.linesBefore = 3; if (typeof options.linesAfter !== "number") options.linesAfter = 2; var re = /\r?\n|\r|\0/g; var lineStarts = [0]; var lineEnds = []; var match; var foundLineNo = -1; while (match = re.exec(mark.buffer)) { lineEnds.push(match.index); lineStarts.push(match.index + match[0].length); if (mark.position <= match.index && foundLineNo < 0) { foundLineNo = lineStarts.length - 2; } } if (foundLineNo < 0) foundLineNo = lineStarts.length - 1; var result = "", i, line2; var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length; var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3); for (i = 1; i <= options.linesBefore; i++) { if (foundLineNo - i < 0) break; line2 = getLine( mark.buffer, lineStarts[foundLineNo - i], lineEnds[foundLineNo - i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), maxLineLength ); result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line2.str + "\n" + result; } line2 = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength); result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line2.str + "\n"; result += common.repeat("-", options.indent + lineNoLength + 3 + line2.pos) + "^\n"; for (i = 1; i <= options.linesAfter; i++) { if (foundLineNo + i >= lineEnds.length) break; line2 = getLine( mark.buffer, lineStarts[foundLineNo + i], lineEnds[foundLineNo + i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), maxLineLength ); result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line2.str + "\n"; } return result.replace(/\n$/, ""); } __name(makeSnippet, "makeSnippet"); var snippet = makeSnippet; var TYPE_CONSTRUCTOR_OPTIONS = [ "kind", "multi", "resolve", "construct", "instanceOf", "predicate", "represent", "representName", "defaultStyle", "styleAliases" ]; var YAML_NODE_KINDS = [ "scalar", "sequence", "mapping" ]; function compileStyleAliases(map2) { var result = {}; if (map2 !== null) { Object.keys(map2).forEach(function(style) { map2[style].forEach(function(alias) { result[String(alias)] = style; }); }); } return result; } __name(compileStyleAliases, "compileStyleAliases"); function Type$1(tag, options) { options = options || {}; Object.keys(options).forEach(function(name) { if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); } }); this.options = options; this.tag = tag; this.kind = options["kind"] || null; this.resolve = options["resolve"] || function() { return true; }; this.construct = options["construct"] || function(data) { return data; }; this.instanceOf = options["instanceOf"] || null; this.predicate = options["predicate"] || null; this.represent = options["represent"] || null; this.representName = options["representName"] || null; this.defaultStyle = options["defaultStyle"] || null; this.multi = options["multi"] || false; this.styleAliases = compileStyleAliases(options["styleAliases"] || null); if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); } } __name(Type$1, "Type$1"); var type = Type$1; function compileList(schema2, name) { var result = []; schema2[name].forEach(function(currentType) { var newIndex = result.length; result.forEach(function(previousType, previousIndex) { if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) { newIndex = previousIndex; } }); result[newIndex] = currentType; }); return result; } __name(compileList, "compileList"); function compileMap() { var result = { scalar: {}, sequence: {}, mapping: {}, fallback: {}, multi: { scalar: [], sequence: [], mapping: [], fallback: [] } }, index, length2; function collectType(type2) { if (type2.multi) { result.multi[type2.kind].push(type2); result.multi["fallback"].push(type2); } else { result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2; } } __name(collectType, "collectType"); for (index = 0, length2 = arguments.length; index < length2; index += 1) { arguments[index].forEach(collectType); } return result; } __name(compileMap, "compileMap"); function Schema$1(definition) { return this.extend(definition); } __name(Schema$1, "Schema$1"); Schema$1.prototype.extend = /* @__PURE__ */ __name(function extend2(definition) { var implicit = []; var explicit = []; if (definition instanceof type) { explicit.push(definition); } else if (Array.isArray(definition)) { explicit = explicit.concat(definition); } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) { if (definition.implicit) implicit = implicit.concat(definition.implicit); if (definition.explicit) explicit = explicit.concat(definition.explicit); } else { throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })"); } implicit.forEach(function(type$1) { if (!(type$1 instanceof type)) { throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object."); } if (type$1.loadKind && type$1.loadKind !== "scalar") { throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported."); } if (type$1.multi) { throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit."); } }); explicit.forEach(function(type$1) { if (!(type$1 instanceof type)) { throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object."); } }); var result = Object.create(Schema$1.prototype); result.implicit = (this.implicit || []).concat(implicit); result.explicit = (this.explicit || []).concat(explicit); result.compiledImplicit = compileList(result, "implicit"); result.compiledExplicit = compileList(result, "explicit"); result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit); return result; }, "extend"); var schema = Schema$1; var str = new type("tag:yaml.org,2002:str", { kind: "scalar", construct: function(data) { return data !== null ? data : ""; } }); var seq = new type("tag:yaml.org,2002:seq", { kind: "sequence", construct: function(data) { return data !== null ? data : []; } }); var map = new type("tag:yaml.org,2002:map", { kind: "mapping", construct: function(data) { return data !== null ? data : {}; } }); var failsafe = new schema({ explicit: [ str, seq, map ] }); function resolveYamlNull(data) { if (data === null) return true; var max = data.length; return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL"); } __name(resolveYamlNull, "resolveYamlNull"); function constructYamlNull() { return null; } __name(constructYamlNull, "constructYamlNull"); function isNull(object) { return object === null; } __name(isNull, "isNull"); var _null = new type("tag:yaml.org,2002:null", { kind: "scalar", resolve: resolveYamlNull, construct: constructYamlNull, predicate: isNull, represent: { canonical: function() { return "~"; }, lowercase: function() { return "null"; }, uppercase: function() { return "NULL"; }, camelcase: function() { return "Null"; }, empty: function() { return ""; } }, defaultStyle: "lowercase" }); function resolveYamlBoolean(data) { if (data === null) return false; var max = data.length; return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE"); } __name(resolveYamlBoolean, "resolveYamlBoolean"); function constructYamlBoolean(data) { return data === "true" || data === "True" || data === "TRUE"; } __name(constructYamlBoolean, "constructYamlBoolean"); function isBoolean(object) { return Object.prototype.toString.call(object) === "[object Boolean]"; } __name(isBoolean, "isBoolean"); var bool = new type("tag:yaml.org,2002:bool", { kind: "scalar", resolve: resolveYamlBoolean, construct: constructYamlBoolean, predicate: isBoolean, represent: { lowercase: function(object) { return object ? "true" : "false"; }, uppercase: function(object) { return object ? "TRUE" : "FALSE"; }, camelcase: function(object) { return object ? "True" : "False"; } }, defaultStyle: "lowercase" }); function isHexCode(c) { return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102; } __name(isHexCode, "isHexCode"); function isOctCode(c) { return 48 <= c && c <= 55; } __name(isOctCode, "isOctCode"); function isDecCode(c) { return 48 <= c && c <= 57; } __name(isDecCode, "isDecCode"); function resolveYamlInteger(data) { if (data === null) return false; var max = data.length, index = 0, hasDigits = false, ch; if (!max) return false; ch = data[index]; if (ch === "-" || ch === "+") { ch = data[++index]; } if (ch === "0") { if (index + 1 === max) return true; ch = data[++index]; if (ch === "b") { index++; for (; index < max; index++) { ch = data[index]; if (ch === "_") continue; if (ch !== "0" && ch !== "1") return false; hasDigits = true; } return hasDigits && ch !== "_"; } if (ch === "x") { index++; for (; index < max; index++) { ch = data[index]; if (ch === "_") continue; if (!isHexCode(data.charCodeAt(index))) return false; hasDigits = true; } return hasDigits && ch !== "_"; } if (ch === "o") { index++; for (; index < max; index++) { ch = data[index]; if (ch === "_") continue; if (!isOctCode(data.charCodeAt(index))) return false; hasDigits = true; } return hasDigits && ch !== "_"; } } if (ch === "_") return false; for (; index < max; index++) { ch = data[index]; if (ch === "_") continue; if (!isDecCode(data.charCodeAt(index))) { return false; } hasDigits = true; } if (!hasDigits || ch === "_") return false; return true; } __name(resolveYamlInteger, "resolveYamlInteger"); function constructYamlInteger(data) { var value = data, sign = 1, ch; if (value.indexOf("_") !== -1) { value = value.replace(/_/g, ""); } ch = value[0]; if (ch === "-" || ch === "+") { if (ch === "-") sign = -1; value = value.slice(1); ch = value[0]; } if (value === "0") return 0; if (ch === "0") { if (value[1] === "b") return sign * parseInt(value.slice(2), 2); if (value[1] === "x") return sign * parseInt(value.slice(2), 16); if (value[1] === "o") return sign * parseInt(value.slice(2), 8); } return sign * parseInt(value, 10); } __name(constructYamlInteger, "constructYamlInteger"); function isInteger(object) { return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object)); } __name(isInteger, "isInteger"); var int = new type("tag:yaml.org,2002:int", { kind: "scalar", resolve: resolveYamlInteger, construct: constructYamlInteger, predicate: isInteger, represent: { binary: function(obj) { return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1); }, octal: function(obj) { return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1); }, decimal: function(obj) { return obj.toString(10); }, /* eslint-disable max-len */ hexadecimal: function(obj) { return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1); } }, defaultStyle: "decimal", styleAliases: { binary: [2, "bin"], octal: [8, "oct"], decimal: [10, "dec"], hexadecimal: [16, "hex"] } }); var YAML_FLOAT_PATTERN = new RegExp( // 2.5e4, 2.5 and integers "^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$" ); function resolveYamlFloat(data) { if (data === null) return false; if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_` // Probably should update regexp & check speed data[data.length - 1] === "_") { return false; } return true; } __name(resolveYamlFloat, "resolveYamlFloat"); function constructYamlFloat(data) { var value, sign; value = data.replace(/_/g, "").toLowerCase(); sign = value[0] === "-" ? -1 : 1; if ("+-".indexOf(value[0]) >= 0) { value = value.slice(1); } if (value === ".inf") { return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; } else if (value === ".nan") { return NaN; } return sign * parseFloat(value, 10); } __name(constructYamlFloat, "constructYamlFloat"); var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; function representYamlFloat(object, style) { var res; if (isNaN(object)) { switch (style) { case "lowercase": return ".nan"; case "uppercase": return ".NAN"; case "camelcase": return ".NaN"; } } else if (Number.POSITIVE_INFINITY === object) { switch (style) { case "lowercase": return ".inf"; case "uppercase": return ".INF"; case "camelcase": return ".Inf"; } } else if (Number.NEGATIVE_INFINITY === object) { switch (style) { case "lowercase": return "-.inf"; case "uppercase": return "-.INF"; case "camelcase": return "-.Inf"; } } else if (common.isNegativeZero(object)) { return "-0.0"; } res = object.toString(10); return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res; } __name(representYamlFloat, "representYamlFloat"); function isFloat(object) { return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object)); } __name(isFloat, "isFloat"); var float = new type("tag:yaml.org,2002:float", { kind: "scalar", resolve: resolveYamlFloat, construct: constructYamlFloat, predicate: is