完成世界书、骰子、apiconfig页面处理

This commit is contained in:
2026-04-30 01:35:10 +08:00
parent a3e3711b2b
commit ba9b925c32
4602 changed files with 785225 additions and 23 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../../../src/diagrams/globalStyles.ts"],
"sourcesContent": ["export const getIconStyles = () => `\n /* Font Awesome icon styling - consolidated */\n .label-icon {\n display: inline-block;\n height: 1em;\n overflow: visible;\n vertical-align: -0.125em;\n }\n \n .node .label-icon path {\n fill: currentColor;\n stroke: revert;\n stroke-width: revert;\n }\n`;\n"],
"mappings": ";;;;;AAAO,IAAM,gBAAgB,6BAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAAN;",
"names": []
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,86 @@
import {
insertEdge,
insertEdgeLabel,
markers_default,
positionEdgeLabel
} from "./chunk-O4XLMI2P.mjs";
import {
insertCluster,
insertNode,
labelHelper
} from "./chunk-KYZI473N.mjs";
import {
interpolateToCurve
} from "./chunk-GEFDOKGD.mjs";
import {
common_default,
getConfig
} from "./chunk-7R4GIKGN.mjs";
import {
__name,
log
} from "./chunk-AGHRB4JF.mjs";
// src/internals.ts
var internalHelpers = {
common: common_default,
getConfig,
insertCluster,
insertEdge,
insertEdgeLabel,
insertMarkers: markers_default,
insertNode,
interpolateToCurve,
labelHelper,
log,
positionEdgeLabel
};
// src/rendering-util/render.ts
var layoutAlgorithms = {};
var registerLayoutLoaders = /* @__PURE__ */ __name((loaders) => {
for (const loader of loaders) {
layoutAlgorithms[loader.name] = loader;
}
}, "registerLayoutLoaders");
var registerDefaultLayoutLoaders = /* @__PURE__ */ __name(() => {
registerLayoutLoaders([
{
name: "dagre",
loader: /* @__PURE__ */ __name(async () => await import("./dagre-KLK3FWXG.mjs"), "loader")
},
...true ? [
{
name: "cose-bilkent",
loader: /* @__PURE__ */ __name(async () => await import("./cose-bilkent-S5V4N54A.mjs"), "loader")
}
] : []
]);
}, "registerDefaultLayoutLoaders");
registerDefaultLayoutLoaders();
var render = /* @__PURE__ */ __name(async (data4Layout, svg) => {
if (!(data4Layout.layoutAlgorithm in layoutAlgorithms)) {
throw new Error(`Unknown layout algorithm: ${data4Layout.layoutAlgorithm}`);
}
const layoutDefinition = layoutAlgorithms[data4Layout.layoutAlgorithm];
const layoutRenderer = await layoutDefinition.loader();
return layoutRenderer.render(data4Layout, svg, internalHelpers, {
algorithm: layoutDefinition.algorithm
});
}, "render");
var getRegisteredLayoutAlgorithm = /* @__PURE__ */ __name((algorithm = "", { fallback = "dagre" } = {}) => {
if (algorithm in layoutAlgorithms) {
return algorithm;
}
if (fallback in layoutAlgorithms) {
log.warn(`Layout algorithm ${algorithm} is not registered. Using ${fallback} as fallback.`);
return fallback;
}
throw new Error(`Both layout algorithms ${algorithm} and ${fallback} are not registered.`);
}, "getRegisteredLayoutAlgorithm");
export {
registerLayoutLoaders,
render,
getRegisteredLayoutAlgorithm
};

View File

@@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../../../src/internals.ts", "../../../src/rendering-util/render.ts"],
"sourcesContent": ["import { getConfig } from './config.js';\nimport common from './diagrams/common/common.js';\nimport { log } from './logger.js';\nimport { insertCluster } from './rendering-util/rendering-elements/clusters.js';\nimport {\n insertEdge,\n insertEdgeLabel,\n positionEdgeLabel,\n} from './rendering-util/rendering-elements/edges.js';\nimport insertMarkers from './rendering-util/rendering-elements/markers.js';\nimport { insertNode } from './rendering-util/rendering-elements/nodes.js';\nimport { labelHelper } from './rendering-util/rendering-elements/shapes/util.js';\nimport { interpolateToCurve } from './utils.js';\n\n/**\n * Internal helpers for mermaid\n * @deprecated - This should not be used by external packages, as the definitions will change without notice.\n */\nexport const internalHelpers = {\n common,\n getConfig,\n insertCluster,\n insertEdge,\n insertEdgeLabel,\n insertMarkers,\n insertNode,\n interpolateToCurve,\n labelHelper,\n log,\n positionEdgeLabel,\n};\n\nexport type InternalHelpers = typeof internalHelpers;\n", "import type { SVG } from '../diagram-api/types.js';\nimport type { InternalHelpers } from '../internals.js';\nimport { internalHelpers } from '../internals.js';\nimport { log } from '../logger.js';\nimport type { LayoutData } from './types.js';\n\n// console.log('MUST be removed, this only for keeping dev server working');\n// import tmp from './layout-algorithms/dagre/index.js';\n\nexport interface RenderOptions {\n algorithm?: string;\n}\n\nexport interface LayoutAlgorithm {\n render(\n layoutData: LayoutData,\n svg: SVG,\n helpers: InternalHelpers,\n options?: RenderOptions\n ): Promise<void>;\n}\n\nexport type LayoutLoader = () => Promise<LayoutAlgorithm>;\nexport interface LayoutLoaderDefinition {\n name: string;\n loader: LayoutLoader;\n algorithm?: string;\n}\n\nconst layoutAlgorithms: Record<string, LayoutLoaderDefinition> = {};\n\nexport const registerLayoutLoaders = (loaders: LayoutLoaderDefinition[]) => {\n for (const loader of loaders) {\n layoutAlgorithms[loader.name] = loader;\n }\n};\n\n// TODO: Should we load dagre without lazy loading?\nconst registerDefaultLayoutLoaders = () => {\n registerLayoutLoaders([\n {\n name: 'dagre',\n loader: async () => await import('./layout-algorithms/dagre/index.js'),\n },\n ...(injected.includeLargeFeatures\n ? [\n {\n name: 'cose-bilkent',\n loader: async () => await import('./layout-algorithms/cose-bilkent/index.js'),\n },\n ]\n : []),\n ]);\n};\n\nregisterDefaultLayoutLoaders();\n\nexport const render = async (data4Layout: LayoutData, svg: SVG) => {\n if (!(data4Layout.layoutAlgorithm in layoutAlgorithms)) {\n throw new Error(`Unknown layout algorithm: ${data4Layout.layoutAlgorithm}`);\n }\n\n const layoutDefinition = layoutAlgorithms[data4Layout.layoutAlgorithm];\n const layoutRenderer = await layoutDefinition.loader();\n return layoutRenderer.render(data4Layout, svg, internalHelpers, {\n algorithm: layoutDefinition.algorithm,\n });\n};\n\n/**\n * Get the registered layout algorithm. If the algorithm is not registered, use the fallback algorithm.\n */\nexport const getRegisteredLayoutAlgorithm = (algorithm = '', { fallback = 'dagre' } = {}) => {\n if (algorithm in layoutAlgorithms) {\n return algorithm;\n }\n if (fallback in layoutAlgorithms) {\n log.warn(`Layout algorithm ${algorithm} is not registered. Using ${fallback} as fallback.`);\n return fallback;\n }\n throw new Error(`Both layout algorithms ${algorithm} and ${fallback} are not registered.`);\n};\n"],
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAkBO,IAAM,kBAAkB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;ACDA,IAAM,mBAA2D,CAAC;AAE3D,IAAM,wBAAwB,wBAAC,YAAsC;AAC1E,aAAW,UAAU,SAAS;AAC5B,qBAAiB,OAAO,IAAI,IAAI;AAAA,EAClC;AACF,GAJqC;AAOrC,IAAM,+BAA+B,6BAAM;AACzC,wBAAsB;AAAA,IACpB;AAAA,MACE,MAAM;AAAA,MACN,QAAQ,mCAAY,MAAM,OAAO,sBAAoC,GAA7D;AAAA,IACV;AAAA,IACA,GAAI,OACA;AAAA,MACE;AAAA,QACE,MAAM;AAAA,QACN,QAAQ,mCAAY,MAAM,OAAO,6BAA2C,GAApE;AAAA,MACV;AAAA,IACF,IACA,CAAC;AAAA,EACP,CAAC;AACH,GAfqC;AAiBrC,6BAA6B;AAEtB,IAAM,SAAS,8BAAO,aAAyB,QAAa;AACjE,MAAI,EAAE,YAAY,mBAAmB,mBAAmB;AACtD,UAAM,IAAI,MAAM,6BAA6B,YAAY,eAAe,EAAE;AAAA,EAC5E;AAEA,QAAM,mBAAmB,iBAAiB,YAAY,eAAe;AACrE,QAAM,iBAAiB,MAAM,iBAAiB,OAAO;AACrD,SAAO,eAAe,OAAO,aAAa,KAAK,iBAAiB;AAAA,IAC9D,WAAW,iBAAiB;AAAA,EAC9B,CAAC;AACH,GAVsB;AAef,IAAM,+BAA+B,wBAAC,YAAY,IAAI,EAAE,WAAW,QAAQ,IAAI,CAAC,MAAM;AAC3F,MAAI,aAAa,kBAAkB;AACjC,WAAO;AAAA,EACT;AACA,MAAI,YAAY,kBAAkB;AAChC,QAAI,KAAK,oBAAoB,SAAS,6BAA6B,QAAQ,eAAe;AAC1F,WAAO;AAAA,EACT;AACA,QAAM,IAAI,MAAM,0BAA0B,SAAS,QAAQ,QAAQ,sBAAsB;AAC3F,GAT4C;",
"names": []
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,41 @@
import {
ClassDB,
classDiagram_default,
classRenderer_v3_unified_default,
styles_default
} from "./chunk-WL4C6EOR.mjs";
import "./chunk-FMBD7UC4.mjs";
import "./chunk-JSJVCQXG.mjs";
import "./chunk-55IACEB6.mjs";
import "./chunk-KX2RTZJC.mjs";
import "./chunk-GLR3WWYH.mjs";
import "./chunk-O4XLMI2P.mjs";
import "./chunk-MX3YWQON.mjs";
import "./chunk-KYZI473N.mjs";
import "./chunk-YBOYWFTD.mjs";
import "./chunk-PQ6SQG4A.mjs";
import "./chunk-PU5JKC2W.mjs";
import "./chunk-GEFDOKGD.mjs";
import "./chunk-7R4GIKGN.mjs";
import {
__name
} from "./chunk-AGHRB4JF.mjs";
// src/diagrams/class/classDiagram-v2.ts
var diagram = {
parser: classDiagram_default,
get db() {
return new ClassDB();
},
renderer: classRenderer_v3_unified_default,
styles: styles_default,
init: /* @__PURE__ */ __name((cnf) => {
if (!cnf.class) {
cnf.class = {};
}
cnf.class.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
}, "init")
};
export {
diagram
};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,245 @@
import {
selectSvgElement
} from "./chunk-HHEYEP7N.mjs";
import {
populateCommonDb
} from "./chunk-4BX2VUAB.mjs";
import {
cleanAndMerge
} from "./chunk-GEFDOKGD.mjs";
import {
clear,
configureSvgSize,
defaultConfig_default,
getAccDescription,
getAccTitle,
getConfig,
getDiagramTitle,
setAccDescription,
setAccTitle,
setDiagramTitle
} from "./chunk-7R4GIKGN.mjs";
import {
__name,
log
} from "./chunk-AGHRB4JF.mjs";
// src/diagrams/packet/db.ts
var DEFAULT_PACKET_CONFIG = defaultConfig_default.packet;
var PacketDB = class {
constructor() {
this.packet = [];
this.setAccTitle = setAccTitle;
this.getAccTitle = getAccTitle;
this.setDiagramTitle = setDiagramTitle;
this.getDiagramTitle = getDiagramTitle;
this.getAccDescription = getAccDescription;
this.setAccDescription = setAccDescription;
}
static {
__name(this, "PacketDB");
}
getConfig() {
const config = cleanAndMerge({
...DEFAULT_PACKET_CONFIG,
...getConfig().packet
});
if (config.showBits) {
config.paddingY += 10;
}
return config;
}
getPacket() {
return this.packet;
}
pushWord(word) {
if (word.length > 0) {
this.packet.push(word);
}
}
clear() {
clear();
this.packet = [];
}
};
// src/diagrams/packet/parser.ts
import { parse } from "@mermaid-js/parser";
var maxPacketSize = 1e4;
var populate = /* @__PURE__ */ __name((ast, db) => {
populateCommonDb(ast, db);
let lastBit = -1;
let word = [];
let row = 1;
const { bitsPerRow } = db.getConfig();
for (let { start, end, bits, label } of ast.blocks) {
if (start !== void 0 && end !== void 0 && end < start) {
throw new Error(`Packet block ${start} - ${end} is invalid. End must be greater than start.`);
}
start ??= lastBit + 1;
if (start !== lastBit + 1) {
throw new Error(
`Packet block ${start} - ${end ?? start} is not contiguous. It should start from ${lastBit + 1}.`
);
}
if (bits === 0) {
throw new Error(`Packet block ${start} is invalid. Cannot have a zero bit field.`);
}
end ??= start + (bits ?? 1) - 1;
bits ??= end - start + 1;
lastBit = end;
log.debug(`Packet block ${start} - ${lastBit} with label ${label}`);
while (word.length <= bitsPerRow + 1 && db.getPacket().length < maxPacketSize) {
const [block, nextBlock] = getNextFittingBlock({ start, end, bits, label }, row, bitsPerRow);
word.push(block);
if (block.end + 1 === row * bitsPerRow) {
db.pushWord(word);
word = [];
row++;
}
if (!nextBlock) {
break;
}
({ start, end, bits, label } = nextBlock);
}
}
db.pushWord(word);
}, "populate");
var getNextFittingBlock = /* @__PURE__ */ __name((block, row, bitsPerRow) => {
if (block.start === void 0) {
throw new Error("start should have been set during first phase");
}
if (block.end === void 0) {
throw new Error("end should have been set during first phase");
}
if (block.start > block.end) {
throw new Error(`Block start ${block.start} is greater than block end ${block.end}.`);
}
if (block.end + 1 <= row * bitsPerRow) {
return [block, void 0];
}
const rowEnd = row * bitsPerRow - 1;
const rowStart = row * bitsPerRow;
return [
{
start: block.start,
end: rowEnd,
label: block.label,
bits: rowEnd - block.start
},
{
start: rowStart,
end: block.end,
label: block.label,
bits: block.end - rowStart
}
];
}, "getNextFittingBlock");
var parser = {
// @ts-expect-error - PacketDB is not assignable to DiagramDB
parser: { yy: void 0 },
parse: /* @__PURE__ */ __name(async (input) => {
const ast = await parse("packet", input);
const db = parser.parser?.yy;
if (!(db instanceof PacketDB)) {
throw new Error(
"parser.parser?.yy was not a PacketDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues."
);
}
log.debug(ast);
populate(ast, db);
}, "parse")
};
// src/diagrams/packet/renderer.ts
var draw = /* @__PURE__ */ __name((_text, id, _version, diagram2) => {
const db = diagram2.db;
const config = db.getConfig();
const { rowHeight, paddingY, bitWidth, bitsPerRow } = config;
const words = db.getPacket();
const title = db.getDiagramTitle();
const totalRowHeight = rowHeight + paddingY;
const svgHeight = totalRowHeight * (words.length + 1) - (title ? 0 : rowHeight);
const svgWidth = bitWidth * bitsPerRow + 2;
const svg = selectSvgElement(id);
svg.attr("viewBox", `0 0 ${svgWidth} ${svgHeight}`);
configureSvgSize(svg, svgHeight, svgWidth, config.useMaxWidth);
for (const [word, packet] of words.entries()) {
drawWord(svg, packet, word, config);
}
svg.append("text").text(title).attr("x", svgWidth / 2).attr("y", svgHeight - totalRowHeight / 2).attr("dominant-baseline", "middle").attr("text-anchor", "middle").attr("class", "packetTitle");
}, "draw");
var drawWord = /* @__PURE__ */ __name((svg, word, rowNumber, { rowHeight, paddingX, paddingY, bitWidth, bitsPerRow, showBits }) => {
const group = svg.append("g");
const wordY = rowNumber * (rowHeight + paddingY) + paddingY;
for (const block of word) {
const blockX = block.start % bitsPerRow * bitWidth + 1;
const width = (block.end - block.start + 1) * bitWidth - paddingX;
group.append("rect").attr("x", blockX).attr("y", wordY).attr("width", width).attr("height", rowHeight).attr("class", "packetBlock");
group.append("text").attr("x", blockX + width / 2).attr("y", wordY + rowHeight / 2).attr("class", "packetLabel").attr("dominant-baseline", "middle").attr("text-anchor", "middle").text(block.label);
if (!showBits) {
continue;
}
const isSingleBlock = block.end === block.start;
const bitNumberY = wordY - 2;
group.append("text").attr("x", blockX + (isSingleBlock ? width / 2 : 0)).attr("y", bitNumberY).attr("class", "packetByte start").attr("dominant-baseline", "auto").attr("text-anchor", isSingleBlock ? "middle" : "start").text(block.start);
if (!isSingleBlock) {
group.append("text").attr("x", blockX + width).attr("y", bitNumberY).attr("class", "packetByte end").attr("dominant-baseline", "auto").attr("text-anchor", "end").text(block.end);
}
}
}, "drawWord");
var renderer = { draw };
// src/diagrams/packet/styles.ts
var defaultPacketStyleOptions = {
byteFontSize: "10px",
startByteColor: "black",
endByteColor: "black",
labelColor: "black",
labelFontSize: "12px",
titleColor: "black",
titleFontSize: "14px",
blockStrokeColor: "black",
blockStrokeWidth: "1",
blockFillColor: "#efefef"
};
var styles = /* @__PURE__ */ __name(({ packet } = {}) => {
const options = cleanAndMerge(defaultPacketStyleOptions, packet);
return `
.packetByte {
font-size: ${options.byteFontSize};
}
.packetByte.start {
fill: ${options.startByteColor};
}
.packetByte.end {
fill: ${options.endByteColor};
}
.packetLabel {
fill: ${options.labelColor};
font-size: ${options.labelFontSize};
}
.packetTitle {
fill: ${options.titleColor};
font-size: ${options.titleFontSize};
}
.packetBlock {
stroke: ${options.blockStrokeColor};
stroke-width: ${options.blockStrokeWidth};
fill: ${options.blockFillColor};
}
`;
}, "styles");
// src/diagrams/packet/diagram.ts
var diagram = {
parser,
get db() {
return new PacketDB();
},
renderer,
styles
};
export {
diagram
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,736 @@
import {
clear,
common_default,
defaultConfig2 as defaultConfig,
getAccDescription,
getAccTitle,
getConfig2 as getConfig,
getDiagramTitle,
setAccDescription,
setAccTitle,
setDiagramTitle,
setupGraphViewbox
} from "./chunk-7R4GIKGN.mjs";
import {
__name
} from "./chunk-AGHRB4JF.mjs";
// src/diagrams/sankey/parser/sankey.jison
var parser = (function() {
var o = /* @__PURE__ */ __name(function(k, v, o2, l) {
for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) ;
return o2;
}, "o"), $V0 = [1, 9], $V1 = [1, 10], $V2 = [1, 5, 10, 12];
var parser2 = {
trace: /* @__PURE__ */ __name(function trace() {
}, "trace"),
yy: {},
symbols_: { "error": 2, "start": 3, "SANKEY": 4, "NEWLINE": 5, "csv": 6, "opt_eof": 7, "record": 8, "csv_tail": 9, "EOF": 10, "field[source]": 11, "COMMA": 12, "field[target]": 13, "field[value]": 14, "field": 15, "escaped": 16, "non_escaped": 17, "DQUOTE": 18, "ESCAPED_TEXT": 19, "NON_ESCAPED_TEXT": 20, "$accept": 0, "$end": 1 },
terminals_: { 2: "error", 4: "SANKEY", 5: "NEWLINE", 10: "EOF", 11: "field[source]", 12: "COMMA", 13: "field[target]", 14: "field[value]", 18: "DQUOTE", 19: "ESCAPED_TEXT", 20: "NON_ESCAPED_TEXT" },
productions_: [0, [3, 4], [6, 2], [9, 2], [9, 0], [7, 1], [7, 0], [8, 5], [15, 1], [15, 1], [16, 3], [17, 1]],
performAction: /* @__PURE__ */ __name(function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
var $0 = $$.length - 1;
switch (yystate) {
case 7:
const source = yy.findOrCreateNode($$[$0 - 4].trim().replaceAll('""', '"'));
const target = yy.findOrCreateNode($$[$0 - 2].trim().replaceAll('""', '"'));
const value = parseFloat($$[$0].trim());
yy.addLink(source, target, value);
break;
case 8:
case 9:
case 11:
this.$ = $$[$0];
break;
case 10:
this.$ = $$[$0 - 1];
break;
}
}, "anonymous"),
table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, { 5: [1, 3] }, { 6: 4, 8: 5, 15: 6, 16: 7, 17: 8, 18: $V0, 20: $V1 }, { 1: [2, 6], 7: 11, 10: [1, 12] }, o($V1, [2, 4], { 9: 13, 5: [1, 14] }), { 12: [1, 15] }, o($V2, [2, 8]), o($V2, [2, 9]), { 19: [1, 16] }, o($V2, [2, 11]), { 1: [2, 1] }, { 1: [2, 5] }, o($V1, [2, 2]), { 6: 17, 8: 5, 15: 6, 16: 7, 17: 8, 18: $V0, 20: $V1 }, { 15: 18, 16: 7, 17: 8, 18: $V0, 20: $V1 }, { 18: [1, 19] }, o($V1, [2, 3]), { 12: [1, 20] }, o($V2, [2, 10]), { 15: 21, 16: 7, 17: 8, 18: $V0, 20: $V1 }, o([1, 5, 10], [2, 7])],
defaultActions: { 11: [2, 1], 12: [2, 5] },
parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
if (hash.recoverable) {
this.trace(str);
} else {
var error = new Error(str);
error.hash = hash;
throw error;
}
}, "parseError"),
parse: /* @__PURE__ */ __name(function parse(input) {
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
var args = lstack.slice.call(arguments, 1);
var lexer2 = Object.create(this.lexer);
var sharedState = { yy: {} };
for (var k in this.yy) {
if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
sharedState.yy[k] = this.yy[k];
}
}
lexer2.setInput(input, sharedState.yy);
sharedState.yy.lexer = lexer2;
sharedState.yy.parser = this;
if (typeof lexer2.yylloc == "undefined") {
lexer2.yylloc = {};
}
var yyloc = lexer2.yylloc;
lstack.push(yyloc);
var ranges = lexer2.options && lexer2.options.ranges;
if (typeof sharedState.yy.parseError === "function") {
this.parseError = sharedState.yy.parseError;
} else {
this.parseError = Object.getPrototypeOf(this).parseError;
}
function popStack(n) {
stack.length = stack.length - 2 * n;
vstack.length = vstack.length - n;
lstack.length = lstack.length - n;
}
__name(popStack, "popStack");
function lex() {
var token;
token = tstack.pop() || lexer2.lex() || EOF;
if (typeof token !== "number") {
if (token instanceof Array) {
tstack = token;
token = tstack.pop();
}
token = self.symbols_[token] || token;
}
return token;
}
__name(lex, "lex");
var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
while (true) {
state = stack[stack.length - 1];
if (this.defaultActions[state]) {
action = this.defaultActions[state];
} else {
if (symbol === null || typeof symbol == "undefined") {
symbol = lex();
}
action = table[state] && table[state][symbol];
}
if (typeof action === "undefined" || !action.length || !action[0]) {
var errStr = "";
expected = [];
for (p in table[state]) {
if (this.terminals_[p] && p > TERROR) {
expected.push("'" + this.terminals_[p] + "'");
}
}
if (lexer2.showPosition) {
errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
} else {
errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
}
this.parseError(errStr, {
text: lexer2.match,
token: this.terminals_[symbol] || symbol,
line: lexer2.yylineno,
loc: yyloc,
expected
});
}
if (action[0] instanceof Array && action.length > 1) {
throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
}
switch (action[0]) {
case 1:
stack.push(symbol);
vstack.push(lexer2.yytext);
lstack.push(lexer2.yylloc);
stack.push(action[1]);
symbol = null;
if (!preErrorSymbol) {
yyleng = lexer2.yyleng;
yytext = lexer2.yytext;
yylineno = lexer2.yylineno;
yyloc = lexer2.yylloc;
if (recovering > 0) {
recovering--;
}
} else {
symbol = preErrorSymbol;
preErrorSymbol = null;
}
break;
case 2:
len = this.productions_[action[1]][1];
yyval.$ = vstack[vstack.length - len];
yyval._$ = {
first_line: lstack[lstack.length - (len || 1)].first_line,
last_line: lstack[lstack.length - 1].last_line,
first_column: lstack[lstack.length - (len || 1)].first_column,
last_column: lstack[lstack.length - 1].last_column
};
if (ranges) {
yyval._$.range = [
lstack[lstack.length - (len || 1)].range[0],
lstack[lstack.length - 1].range[1]
];
}
r = this.performAction.apply(yyval, [
yytext,
yyleng,
yylineno,
sharedState.yy,
action[1],
vstack,
lstack
].concat(args));
if (typeof r !== "undefined") {
return r;
}
if (len) {
stack = stack.slice(0, -1 * len * 2);
vstack = vstack.slice(0, -1 * len);
lstack = lstack.slice(0, -1 * len);
}
stack.push(this.productions_[action[1]][0]);
vstack.push(yyval.$);
lstack.push(yyval._$);
newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
stack.push(newState);
break;
case 3:
return true;
}
}
return true;
}, "parse")
};
var lexer = /* @__PURE__ */ (function() {
var lexer2 = {
EOF: 1,
parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
if (this.yy.parser) {
this.yy.parser.parseError(str, hash);
} else {
throw new Error(str);
}
}, "parseError"),
// resets the lexer, sets new input
setInput: /* @__PURE__ */ __name(function(input, yy) {
this.yy = yy || this.yy || {};
this._input = input;
this._more = this._backtrack = this.done = false;
this.yylineno = this.yyleng = 0;
this.yytext = this.matched = this.match = "";
this.conditionStack = ["INITIAL"];
this.yylloc = {
first_line: 1,
first_column: 0,
last_line: 1,
last_column: 0
};
if (this.options.ranges) {
this.yylloc.range = [0, 0];
}
this.offset = 0;
return this;
}, "setInput"),
// consumes and returns one char from the input
input: /* @__PURE__ */ __name(function() {
var ch = this._input[0];
this.yytext += ch;
this.yyleng++;
this.offset++;
this.match += ch;
this.matched += ch;
var lines = ch.match(/(?:\r\n?|\n).*/g);
if (lines) {
this.yylineno++;
this.yylloc.last_line++;
} else {
this.yylloc.last_column++;
}
if (this.options.ranges) {
this.yylloc.range[1]++;
}
this._input = this._input.slice(1);
return ch;
}, "input"),
// unshifts one char (or a string) into the input
unput: /* @__PURE__ */ __name(function(ch) {
var len = ch.length;
var lines = ch.split(/(?:\r\n?|\n)/g);
this._input = ch + this._input;
this.yytext = this.yytext.substr(0, this.yytext.length - len);
this.offset -= len;
var oldLines = this.match.split(/(?:\r\n?|\n)/g);
this.match = this.match.substr(0, this.match.length - 1);
this.matched = this.matched.substr(0, this.matched.length - 1);
if (lines.length - 1) {
this.yylineno -= lines.length - 1;
}
var r = this.yylloc.range;
this.yylloc = {
first_line: this.yylloc.first_line,
last_line: this.yylineno + 1,
first_column: this.yylloc.first_column,
last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len
};
if (this.options.ranges) {
this.yylloc.range = [r[0], r[0] + this.yyleng - len];
}
this.yyleng = this.yytext.length;
return this;
}, "unput"),
// When called from action, caches matched text and appends it on next action
more: /* @__PURE__ */ __name(function() {
this._more = true;
return this;
}, "more"),
// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
reject: /* @__PURE__ */ __name(function() {
if (this.options.backtrack_lexer) {
this._backtrack = true;
} else {
return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), {
text: "",
token: null,
line: this.yylineno
});
}
return this;
}, "reject"),
// retain first n characters of the match
less: /* @__PURE__ */ __name(function(n) {
this.unput(this.match.slice(n));
}, "less"),
// displays already matched input, i.e. for error messages
pastInput: /* @__PURE__ */ __name(function() {
var past = this.matched.substr(0, this.matched.length - this.match.length);
return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
}, "pastInput"),
// displays upcoming input, i.e. for error messages
upcomingInput: /* @__PURE__ */ __name(function() {
var next = this.match;
if (next.length < 20) {
next += this._input.substr(0, 20 - next.length);
}
return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
}, "upcomingInput"),
// displays the character position where the lexing error occurred, i.e. for error messages
showPosition: /* @__PURE__ */ __name(function() {
var pre = this.pastInput();
var c = new Array(pre.length + 1).join("-");
return pre + this.upcomingInput() + "\n" + c + "^";
}, "showPosition"),
// test the lexed token: return FALSE when not a match, otherwise return token
test_match: /* @__PURE__ */ __name(function(match, indexed_rule) {
var token, lines, backup;
if (this.options.backtrack_lexer) {
backup = {
yylineno: this.yylineno,
yylloc: {
first_line: this.yylloc.first_line,
last_line: this.last_line,
first_column: this.yylloc.first_column,
last_column: this.yylloc.last_column
},
yytext: this.yytext,
match: this.match,
matches: this.matches,
matched: this.matched,
yyleng: this.yyleng,
offset: this.offset,
_more: this._more,
_input: this._input,
yy: this.yy,
conditionStack: this.conditionStack.slice(0),
done: this.done
};
if (this.options.ranges) {
backup.yylloc.range = this.yylloc.range.slice(0);
}
}
lines = match[0].match(/(?:\r\n?|\n).*/g);
if (lines) {
this.yylineno += lines.length;
}
this.yylloc = {
first_line: this.yylloc.last_line,
last_line: this.yylineno + 1,
first_column: this.yylloc.last_column,
last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
};
this.yytext += match[0];
this.match += match[0];
this.matches = match;
this.yyleng = this.yytext.length;
if (this.options.ranges) {
this.yylloc.range = [this.offset, this.offset += this.yyleng];
}
this._more = false;
this._backtrack = false;
this._input = this._input.slice(match[0].length);
this.matched += match[0];
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
if (this.done && this._input) {
this.done = false;
}
if (token) {
return token;
} else if (this._backtrack) {
for (var k in backup) {
this[k] = backup[k];
}
return false;
}
return false;
}, "test_match"),
// return next match in input
next: /* @__PURE__ */ __name(function() {
if (this.done) {
return this.EOF;
}
if (!this._input) {
this.done = true;
}
var token, match, tempMatch, index;
if (!this._more) {
this.yytext = "";
this.match = "";
}
var rules = this._currentRules();
for (var i = 0; i < rules.length; i++) {
tempMatch = this._input.match(this.rules[rules[i]]);
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
match = tempMatch;
index = i;
if (this.options.backtrack_lexer) {
token = this.test_match(tempMatch, rules[i]);
if (token !== false) {
return token;
} else if (this._backtrack) {
match = false;
continue;
} else {
return false;
}
} else if (!this.options.flex) {
break;
}
}
}
if (match) {
token = this.test_match(match, rules[index]);
if (token !== false) {
return token;
}
return false;
}
if (this._input === "") {
return this.EOF;
} else {
return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
text: "",
token: null,
line: this.yylineno
});
}
}, "next"),
// return next match that has a token
lex: /* @__PURE__ */ __name(function lex() {
var r = this.next();
if (r) {
return r;
} else {
return this.lex();
}
}, "lex"),
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
begin: /* @__PURE__ */ __name(function begin(condition) {
this.conditionStack.push(condition);
}, "begin"),
// pop the previously active lexer condition state off the condition stack
popState: /* @__PURE__ */ __name(function popState() {
var n = this.conditionStack.length - 1;
if (n > 0) {
return this.conditionStack.pop();
} else {
return this.conditionStack[0];
}
}, "popState"),
// produce the lexer rule set which is active for the currently active lexer condition state
_currentRules: /* @__PURE__ */ __name(function _currentRules() {
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
} else {
return this.conditions["INITIAL"].rules;
}
}, "_currentRules"),
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
topState: /* @__PURE__ */ __name(function topState(n) {
n = this.conditionStack.length - 1 - Math.abs(n || 0);
if (n >= 0) {
return this.conditionStack[n];
} else {
return "INITIAL";
}
}, "topState"),
// alias for begin(condition)
pushState: /* @__PURE__ */ __name(function pushState(condition) {
this.begin(condition);
}, "pushState"),
// return the number of states currently on the stack
stateStackSize: /* @__PURE__ */ __name(function stateStackSize() {
return this.conditionStack.length;
}, "stateStackSize"),
options: { "case-insensitive": true },
performAction: /* @__PURE__ */ __name(function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
var YYSTATE = YY_START;
switch ($avoiding_name_collisions) {
case 0:
this.pushState("csv");
return 4;
break;
case 1:
this.pushState("csv");
return 4;
break;
case 2:
return 10;
break;
case 3:
return 5;
break;
case 4:
return 12;
break;
case 5:
this.pushState("escaped_text");
return 18;
break;
case 6:
return 20;
break;
case 7:
this.popState("escaped_text");
return 18;
break;
case 8:
return 19;
break;
}
}, "anonymous"),
rules: [/^(?:sankey-beta\b)/i, /^(?:sankey\b)/i, /^(?:$)/i, /^(?:((\u000D\u000A)|(\u000A)))/i, /^(?:(\u002C))/i, /^(?:(\u0022))/i, /^(?:([\u0020-\u0021\u0023-\u002B\u002D-\u007E])*)/i, /^(?:(\u0022)(?!(\u0022)))/i, /^(?:(([\u0020-\u0021\u0023-\u002B\u002D-\u007E])|(\u002C)|(\u000D)|(\u000A)|(\u0022)(\u0022))*)/i],
conditions: { "csv": { "rules": [2, 3, 4, 5, 6, 7, 8], "inclusive": false }, "escaped_text": { "rules": [7, 8], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7, 8], "inclusive": true } }
};
return lexer2;
})();
parser2.lexer = lexer;
function Parser() {
this.yy = {};
}
__name(Parser, "Parser");
Parser.prototype = parser2;
parser2.Parser = Parser;
return new Parser();
})();
parser.parser = parser;
var sankey_default = parser;
// src/diagrams/sankey/sankeyDB.ts
var links = [];
var nodes = [];
var nodesMap = /* @__PURE__ */ new Map();
var clear2 = /* @__PURE__ */ __name(() => {
links = [];
nodes = [];
nodesMap = /* @__PURE__ */ new Map();
clear();
}, "clear");
var SankeyLink = class {
constructor(source, target, value = 0) {
this.source = source;
this.target = target;
this.value = value;
}
static {
__name(this, "SankeyLink");
}
};
var addLink = /* @__PURE__ */ __name((source, target, value) => {
links.push(new SankeyLink(source, target, value));
}, "addLink");
var SankeyNode = class {
constructor(ID) {
this.ID = ID;
}
static {
__name(this, "SankeyNode");
}
};
var findOrCreateNode = /* @__PURE__ */ __name((ID) => {
ID = common_default.sanitizeText(ID, getConfig());
let node = nodesMap.get(ID);
if (node === void 0) {
node = new SankeyNode(ID);
nodesMap.set(ID, node);
nodes.push(node);
}
return node;
}, "findOrCreateNode");
var getNodes = /* @__PURE__ */ __name(() => nodes, "getNodes");
var getLinks = /* @__PURE__ */ __name(() => links, "getLinks");
var getGraph = /* @__PURE__ */ __name(() => ({
nodes: nodes.map((node) => ({ id: node.ID })),
links: links.map((link) => ({
source: link.source.ID,
target: link.target.ID,
value: link.value
}))
}), "getGraph");
var sankeyDB_default = {
nodesMap,
getConfig: /* @__PURE__ */ __name(() => getConfig().sankey, "getConfig"),
getNodes,
getLinks,
getGraph,
addLink,
findOrCreateNode,
getAccTitle,
setAccTitle,
getAccDescription,
setAccDescription,
getDiagramTitle,
setDiagramTitle,
clear: clear2
};
// src/diagrams/sankey/sankeyRenderer.ts
import {
select as d3select,
scaleOrdinal as d3scaleOrdinal,
schemeTableau10 as d3schemeTableau10
} from "d3";
import {
sankey as d3Sankey,
sankeyLinkHorizontal as d3SankeyLinkHorizontal,
sankeyLeft as d3SankeyLeft,
sankeyRight as d3SankeyRight,
sankeyCenter as d3SankeyCenter,
sankeyJustify as d3SankeyJustify
} from "d3-sankey";
// src/rendering-util/uid.ts
var Uid = class _Uid {
static {
__name(this, "Uid");
}
static {
this.count = 0;
}
static next(name) {
return new _Uid(name + ++_Uid.count);
}
constructor(id) {
this.id = id;
this.href = `#${id}`;
}
toString() {
return "url(" + this.href + ")";
}
};
// src/diagrams/sankey/sankeyRenderer.ts
var alignmentsMap = {
left: d3SankeyLeft,
right: d3SankeyRight,
center: d3SankeyCenter,
justify: d3SankeyJustify
};
var draw = /* @__PURE__ */ __name(function(text, id, _version, diagObj) {
const { securityLevel, sankey: conf } = getConfig();
const defaultSankeyConfig = defaultConfig.sankey;
let sandboxElement;
if (securityLevel === "sandbox") {
sandboxElement = d3select("#i" + id);
}
const root = securityLevel === "sandbox" ? d3select(sandboxElement.nodes()[0].contentDocument.body) : d3select("body");
const svg = securityLevel === "sandbox" ? root.select(`[id="${id}"]`) : d3select(`[id="${id}"]`);
const width = conf?.width ?? defaultSankeyConfig.width;
const height = conf?.height ?? defaultSankeyConfig.width;
const useMaxWidth = conf?.useMaxWidth ?? defaultSankeyConfig.useMaxWidth;
const nodeAlignment = conf?.nodeAlignment ?? defaultSankeyConfig.nodeAlignment;
const prefix = conf?.prefix ?? defaultSankeyConfig.prefix;
const suffix = conf?.suffix ?? defaultSankeyConfig.suffix;
const showValues = conf?.showValues ?? defaultSankeyConfig.showValues;
const graph = diagObj.db.getGraph();
const nodeAlign = alignmentsMap[nodeAlignment];
const nodeWidth = 10;
const sankey = d3Sankey().nodeId((d) => d.id).nodeWidth(nodeWidth).nodePadding(10 + (showValues ? 15 : 0)).nodeAlign(nodeAlign).extent([
[0, 0],
[width, height]
]);
sankey(graph);
const colorScheme = d3scaleOrdinal(d3schemeTableau10);
svg.append("g").attr("class", "nodes").selectAll(".node").data(graph.nodes).join("g").attr("class", "node").attr("id", (d) => (d.uid = Uid.next("node-")).id).attr("transform", function(d) {
return "translate(" + d.x0 + "," + d.y0 + ")";
}).attr("x", (d) => d.x0).attr("y", (d) => d.y0).append("rect").attr("height", (d) => {
return d.y1 - d.y0;
}).attr("width", (d) => d.x1 - d.x0).attr("fill", (d) => colorScheme(d.id));
const getText = /* @__PURE__ */ __name(({ id: id2, value }) => {
if (!showValues) {
return id2;
}
return `${id2}
${prefix}${Math.round(value * 100) / 100}${suffix}`;
}, "getText");
svg.append("g").attr("class", "node-labels").attr("font-size", 14).selectAll("text").data(graph.nodes).join("text").attr("x", (d) => d.x0 < width / 2 ? d.x1 + 6 : d.x0 - 6).attr("y", (d) => (d.y1 + d.y0) / 2).attr("dy", `${showValues ? "0" : "0.35"}em`).attr("text-anchor", (d) => d.x0 < width / 2 ? "start" : "end").text(getText);
const link = svg.append("g").attr("class", "links").attr("fill", "none").attr("stroke-opacity", 0.5).selectAll(".link").data(graph.links).join("g").attr("class", "link").style("mix-blend-mode", "multiply");
const linkColor = conf?.linkColor ?? "gradient";
if (linkColor === "gradient") {
const gradient = link.append("linearGradient").attr("id", (d) => (d.uid = Uid.next("linearGradient-")).id).attr("gradientUnits", "userSpaceOnUse").attr("x1", (d) => d.source.x1).attr("x2", (d) => d.target.x0);
gradient.append("stop").attr("offset", "0%").attr("stop-color", (d) => colorScheme(d.source.id));
gradient.append("stop").attr("offset", "100%").attr("stop-color", (d) => colorScheme(d.target.id));
}
let coloring;
switch (linkColor) {
case "gradient":
coloring = /* @__PURE__ */ __name((d) => d.uid, "coloring");
break;
case "source":
coloring = /* @__PURE__ */ __name((d) => colorScheme(d.source.id), "coloring");
break;
case "target":
coloring = /* @__PURE__ */ __name((d) => colorScheme(d.target.id), "coloring");
break;
default:
coloring = linkColor;
}
link.append("path").attr("d", d3SankeyLinkHorizontal()).attr("stroke", coloring).attr("stroke-width", (d) => Math.max(1, d.width));
setupGraphViewbox(void 0, svg, 0, useMaxWidth);
}, "draw");
var sankeyRenderer_default = {
draw
};
// src/diagrams/sankey/sankeyUtils.ts
var prepareTextForParsing = /* @__PURE__ */ __name((text) => {
const textToParse = text.replaceAll(/^[^\S\n\r]+|[^\S\n\r]+$/g, "").replaceAll(/([\n\r])+/g, "\n").trim();
return textToParse;
}, "prepareTextForParsing");
// src/diagrams/sankey/styles.js
var getStyles = /* @__PURE__ */ __name((options) => `.label {
font-family: ${options.fontFamily};
}`, "getStyles");
var styles_default = getStyles;
// src/diagrams/sankey/sankeyDiagram.ts
var originalParse = sankey_default.parse.bind(sankey_default);
sankey_default.parse = (text) => originalParse(prepareTextForParsing(text));
var diagram = {
styles: styles_default,
parser: sankey_default,
db: sankeyDB_default,
renderer: sankeyRenderer_default
};
export {
diagram
};

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
import{a as f}from"./chunk-VELTKBKT.mjs";var d=f((t,r)=>{if(r)return"translate("+-t.width/2+", "+-t.height/2+")";let c=t.x??0,e=t.y??0;return"translate("+-(c+t.width/2)+", "+-(e+t.height/2)+")"},"computeLabelTransform");var s={aggregation:17.25,extension:17.25,composition:17.25,dependency:6,lollipop:13.5,arrow_point:4},T={arrow_point:9,arrow_cross:12.5,arrow_circle:12.5};function x(t,r){if(t===void 0||r===void 0)return{angle:0,deltaX:0,deltaY:0};t=n(t),r=n(r);let[c,e]=[t.x,t.y],[o,i]=[r.x,r.y],l=o-c,p=i-e;return{angle:Math.atan(p/l),deltaX:l,deltaY:p}}f(x,"calculateDeltaAndAngle");var n=f(t=>Array.isArray(t)?{x:t[0],y:t[1]}:t,"pointTransformer"),E=f(t=>({x:f(function(r,c,e){let o=0,i=n(e[0]).x<n(e[e.length-1]).x?"left":"right";if(c===0&&Object.hasOwn(s,t.arrowTypeStart)){let{angle:a,deltaX:m}=x(e[0],e[1]);o=s[t.arrowTypeStart]*Math.cos(a)*(m>=0?1:-1)}else if(c===e.length-1&&Object.hasOwn(s,t.arrowTypeEnd)){let{angle:a,deltaX:m}=x(e[e.length-1],e[e.length-2]);o=s[t.arrowTypeEnd]*Math.cos(a)*(m>=0?1:-1)}let l=Math.abs(n(r).x-n(e[e.length-1]).x),p=Math.abs(n(r).y-n(e[e.length-1]).y),u=Math.abs(n(r).x-n(e[0]).x),b=Math.abs(n(r).y-n(e[0]).y),y=s[t.arrowTypeStart],h=s[t.arrowTypeEnd],g=1;if(l<h&&l>0&&p<h){let a=h+g-l;a*=i==="right"?-1:1,o-=a}if(u<y&&u>0&&b<y){let a=y+g-u;a*=i==="right"?-1:1,o+=a}return n(r).x+o},"x"),y:f(function(r,c,e){let o=0,i=n(e[0]).y<n(e[e.length-1]).y?"down":"up";if(c===0&&Object.hasOwn(s,t.arrowTypeStart)){let{angle:a,deltaY:m}=x(e[0],e[1]);o=s[t.arrowTypeStart]*Math.abs(Math.sin(a))*(m>=0?1:-1)}else if(c===e.length-1&&Object.hasOwn(s,t.arrowTypeEnd)){let{angle:a,deltaY:m}=x(e[e.length-1],e[e.length-2]);o=s[t.arrowTypeEnd]*Math.abs(Math.sin(a))*(m>=0?1:-1)}let l=Math.abs(n(r).y-n(e[e.length-1]).y),p=Math.abs(n(r).x-n(e[e.length-1]).x),u=Math.abs(n(r).y-n(e[0]).y),b=Math.abs(n(r).x-n(e[0]).x),y=s[t.arrowTypeStart],h=s[t.arrowTypeEnd],g=1;if(l<h&&l>0&&p<h){let a=h+g-l;a*=i==="up"?-1:1,o-=a}if(u<y&&u>0&&b<y){let a=y+g-u;a*=i==="up"?-1:1,o+=a}return n(r).y+o},"y")}),"getLineFunctionsWithOffset");export{d as a,s as b,T as c,E as d};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../../../src/diagrams/common/populateCommonDb.ts"],
"sourcesContent": ["import type { DiagramAST } from '@mermaid-js/parser';\nimport type { DiagramDB } from '../../diagram-api/types.js';\n\nexport function populateCommonDb(ast: DiagramAST, db: DiagramDB) {\n if (ast.accDescr) {\n db.setAccDescription?.(ast.accDescr);\n }\n if (ast.accTitle) {\n db.setAccTitle?.(ast.accTitle);\n }\n if (ast.title) {\n db.setDiagramTitle?.(ast.title);\n }\n}\n"],
"mappings": "yCAGO,SAASA,EAAiBC,EAAiBC,EAAe,CAC3DD,EAAI,UACNC,EAAG,oBAAoBD,EAAI,QAAQ,EAEjCA,EAAI,UACNC,EAAG,cAAcD,EAAI,QAAQ,EAE3BA,EAAI,OACNC,EAAG,kBAAkBD,EAAI,KAAK,CAElC,CAVgBE,EAAAH,EAAA",
"names": ["populateCommonDb", "ast", "db", "__name"]
}

View File

@@ -0,0 +1 @@
import{Y as s}from"./chunk-3UWU4A3N.mjs";import{h as e}from"./chunk-MGPAVIPZ.mjs";import{a as n}from"./chunk-VELTKBKT.mjs";var d=n(t=>{let{securityLevel:m}=s(),o=e("body");if(m==="sandbox"){let c=e(`#i${t}`).node()?.contentDocument??document;o=e(c.body)}return o.select(`#${t}`)},"selectSvgElement");export{d as a};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../../../../parser/dist/chunks/mermaid-parser.core/chunk-EGIJ26TM.mjs"],
"sourcesContent": ["import {\n AbstractMermaidTokenBuilder,\n CommonValueConverter,\n InfoGrammarGeneratedModule,\n MermaidGeneratedSharedModule,\n __name\n} from \"./chunk-XZSTWKYB.mjs\";\n\n// src/language/info/module.ts\nimport {\n EmptyFileSystem,\n createDefaultCoreModule,\n createDefaultSharedCoreModule,\n inject\n} from \"langium\";\n\n// src/language/info/tokenBuilder.ts\nvar InfoTokenBuilder = class extends AbstractMermaidTokenBuilder {\n static {\n __name(this, \"InfoTokenBuilder\");\n }\n constructor() {\n super([\"info\", \"showInfo\"]);\n }\n};\n\n// src/language/info/module.ts\nvar InfoModule = {\n parser: {\n TokenBuilder: /* @__PURE__ */ __name(() => new InfoTokenBuilder(), \"TokenBuilder\"),\n ValueConverter: /* @__PURE__ */ __name(() => new CommonValueConverter(), \"ValueConverter\")\n }\n};\nfunction createInfoServices(context = EmptyFileSystem) {\n const shared = inject(\n createDefaultSharedCoreModule(context),\n MermaidGeneratedSharedModule\n );\n const Info = inject(\n createDefaultCoreModule({ shared }),\n InfoGrammarGeneratedModule,\n InfoModule\n );\n shared.ServiceRegistry.register(Info);\n return { shared, Info };\n}\n__name(createInfoServices, \"createInfoServices\");\n\nexport {\n InfoModule,\n createInfoServices\n};\n"],
"mappings": "4IAiBA,IAAIA,EAAmB,cAAcC,CAA4B,CAjBjE,MAiBiE,CAAAC,EAAA,yBAC/D,MAAO,CACLA,EAAO,KAAM,kBAAkB,CACjC,CACA,aAAc,CACZ,MAAM,CAAC,OAAQ,UAAU,CAAC,CAC5B,CACF,EAGIC,EAAa,CACf,OAAQ,CACN,aAA8BD,EAAO,IAAM,IAAIF,EAAoB,cAAc,EACjF,eAAgCE,EAAO,IAAM,IAAIE,EAAwB,gBAAgB,CAC3F,CACF,EACA,SAASC,EAAmBC,EAAUC,EAAiB,CACrD,IAAMC,EAASC,EACbC,EAA8BJ,CAAO,EACrCK,CACF,EACMC,EAAOH,EACXI,EAAwB,CAAE,OAAAL,CAAO,CAAC,EAClCM,EACAX,CACF,EACA,OAAAK,EAAO,gBAAgB,SAASI,CAAI,EAC7B,CAAE,OAAAJ,EAAQ,KAAAI,CAAK,CACxB,CAZSV,EAAAG,EAAA,sBAaTH,EAAOG,EAAoB,oBAAoB",
"names": ["InfoTokenBuilder", "AbstractMermaidTokenBuilder", "__name", "InfoModule", "CommonValueConverter", "createInfoServices", "context", "EmptyFileSystem", "shared", "inject", "createDefaultSharedCoreModule", "MermaidGeneratedSharedModule", "Info", "createDefaultCoreModule", "InfoGrammarGeneratedModule"]
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../../../../parser/dist/chunks/mermaid-parser.core/chunk-7E7YKBS2.mjs"],
"sourcesContent": ["import {\n AbstractMermaidTokenBuilder,\n CommonValueConverter,\n GitGraphGrammarGeneratedModule,\n MermaidGeneratedSharedModule,\n __name\n} from \"./chunk-XZSTWKYB.mjs\";\n\n// src/language/gitGraph/module.ts\nimport {\n inject,\n createDefaultCoreModule,\n createDefaultSharedCoreModule,\n EmptyFileSystem\n} from \"langium\";\n\n// src/language/gitGraph/tokenBuilder.ts\nvar GitGraphTokenBuilder = class extends AbstractMermaidTokenBuilder {\n static {\n __name(this, \"GitGraphTokenBuilder\");\n }\n constructor() {\n super([\"gitGraph\"]);\n }\n};\n\n// src/language/gitGraph/module.ts\nvar GitGraphModule = {\n parser: {\n TokenBuilder: /* @__PURE__ */ __name(() => new GitGraphTokenBuilder(), \"TokenBuilder\"),\n ValueConverter: /* @__PURE__ */ __name(() => new CommonValueConverter(), \"ValueConverter\")\n }\n};\nfunction createGitGraphServices(context = EmptyFileSystem) {\n const shared = inject(\n createDefaultSharedCoreModule(context),\n MermaidGeneratedSharedModule\n );\n const GitGraph = inject(\n createDefaultCoreModule({ shared }),\n GitGraphGrammarGeneratedModule,\n GitGraphModule\n );\n shared.ServiceRegistry.register(GitGraph);\n return { shared, GitGraph };\n}\n__name(createGitGraphServices, \"createGitGraphServices\");\n\nexport {\n GitGraphModule,\n createGitGraphServices\n};\n"],
"mappings": "iJAiBA,IAAIA,EAAuB,cAAcC,CAA4B,CAjBrE,MAiBqE,CAAAC,EAAA,6BACnE,MAAO,CACLA,EAAO,KAAM,sBAAsB,CACrC,CACA,aAAc,CACZ,MAAM,CAAC,UAAU,CAAC,CACpB,CACF,EAGIC,EAAiB,CACnB,OAAQ,CACN,aAA8BD,EAAO,IAAM,IAAIF,EAAwB,cAAc,EACrF,eAAgCE,EAAO,IAAM,IAAIE,EAAwB,gBAAgB,CAC3F,CACF,EACA,SAASC,EAAuBC,EAAUC,EAAiB,CACzD,IAAMC,EAASC,EACbC,EAA8BJ,CAAO,EACrCK,CACF,EACMC,EAAWH,EACfI,EAAwB,CAAE,OAAAL,CAAO,CAAC,EAClCM,EACAX,CACF,EACA,OAAAK,EAAO,gBAAgB,SAASI,CAAQ,EACjC,CAAE,OAAAJ,EAAQ,SAAAI,CAAS,CAC5B,CAZSV,EAAAG,EAAA,0BAaTH,EAAOG,EAAwB,wBAAwB",
"names": ["GitGraphTokenBuilder", "AbstractMermaidTokenBuilder", "__name", "GitGraphModule", "CommonValueConverter", "createGitGraphServices", "context", "EmptyFileSystem", "shared", "inject", "createDefaultSharedCoreModule", "MermaidGeneratedSharedModule", "GitGraph", "createDefaultCoreModule", "GitGraphGrammarGeneratedModule"]
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
import{B as v,D as P,G as S,a as e,c as y,f as i,g as a,i as f,t as b,v as n,y as j,z as d}from"./chunk-JIN56HTB.mjs";import{a as m}from"./chunk-VELTKBKT.mjs";var C=b(Object.keys,Object),T=C;var V=Object.prototype,D=V.hasOwnProperty;function K(r){if(!n(r))return T(r);var t=[];for(var o in Object(r))D.call(r,o)&&o!="constructor"&&t.push(o);return t}m(K,"baseKeys");var O=K;var N=a(e,"DataView"),s=N;var W=a(e,"Promise"),c=W;var B=a(e,"Set"),g=B;var z=a(e,"WeakMap"),u=z;var M="[object Map]",E="[object Object]",h="[object Promise]",x="[object Set]",k="[object WeakMap]",l="[object DataView]",G=i(s),L=i(f),q=i(c),F=i(g),H=i(u),p=y;(s&&p(new s(new ArrayBuffer(1)))!=l||f&&p(new f)!=M||c&&p(c.resolve())!=h||g&&p(new g)!=x||u&&p(new u)!=k)&&(p=m(function(r){var t=y(r),o=t==E?r.constructor:void 0,w=o?i(o):"";if(w)switch(w){case G:return l;case L:return M;case q:return h;case F:return x;case H:return k}return t},"getTag"));var A=p;var I="[object Map]",J="[object Set]",Q=Object.prototype,R=Q.hasOwnProperty;function U(r){if(r==null)return!0;if(v(r)&&(d(r)||typeof r=="string"||typeof r.splice=="function"||P(r)||S(r)||j(r)))return!r.length;var t=A(r);if(t==I||t==J)return!r.size;if(n(r))return!O(r).length;for(var o in r)if(R.call(r,o))return!1;return!0}m(U,"isEmpty");var Cr=U;export{O as a,g as b,A as c,Cr as d};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
import{a as i}from"./chunk-VELTKBKT.mjs";var s=class{constructor(t){this.init=t;this.records=this.init()}static{i(this,"ImperativeState")}reset(){this.records=this.init()}};export{s as a};

View File

@@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../../../src/diagrams/common/svgDrawCommon.ts"],
"sourcesContent": ["import { sanitizeUrl } from '@braintree/sanitize-url';\nimport { select } from 'd3';\nimport type { SVG, SVGGroup } from '../../diagram-api/types.js';\nimport { lineBreakRegex } from './common.js';\nimport type {\n Bound,\n D3ImageElement,\n D3RectElement,\n D3TSpanElement,\n D3TextElement,\n D3UseElement,\n RectData,\n TextData,\n TextObject,\n} from './commonTypes.js';\n\nexport const drawRect = (element: SVG | SVGGroup, rectData: RectData): D3RectElement => {\n const rectElement: D3RectElement = element.append('rect');\n rectElement.attr('x', rectData.x);\n rectElement.attr('y', rectData.y);\n rectElement.attr('fill', rectData.fill);\n rectElement.attr('stroke', rectData.stroke);\n rectElement.attr('width', rectData.width);\n rectElement.attr('height', rectData.height);\n if (rectData.name) {\n rectElement.attr('name', rectData.name);\n }\n if (rectData.rx) {\n rectElement.attr('rx', rectData.rx);\n }\n if (rectData.ry) {\n rectElement.attr('ry', rectData.ry);\n }\n\n if (rectData.attrs !== undefined) {\n for (const attrKey in rectData.attrs) {\n rectElement.attr(attrKey, rectData.attrs[attrKey]);\n }\n }\n\n if (rectData.class) {\n rectElement.attr('class', rectData.class);\n }\n\n return rectElement;\n};\n\n/**\n * Draws a background rectangle\n *\n * @param element - Diagram (reference for bounds)\n * @param bounds - Shape of the rectangle\n */\nexport const drawBackgroundRect = (element: SVG | SVGGroup, bounds: Bound): void => {\n const rectData: RectData = {\n x: bounds.startx,\n y: bounds.starty,\n width: bounds.stopx - bounds.startx,\n height: bounds.stopy - bounds.starty,\n fill: bounds.fill,\n stroke: bounds.stroke,\n class: 'rect',\n };\n const rectElement: D3RectElement = drawRect(element, rectData);\n rectElement.lower();\n};\n\nexport const drawText = (element: SVG | SVGGroup, textData: TextData): D3TextElement => {\n const nText: string = textData.text.replace(lineBreakRegex, ' ');\n\n const textElem: D3TextElement = element.append('text');\n textElem.attr('x', textData.x);\n textElem.attr('y', textData.y);\n textElem.attr('class', 'legend');\n\n textElem.style('text-anchor', textData.anchor);\n if (textData.class) {\n textElem.attr('class', textData.class);\n }\n\n const tspan: D3TSpanElement = textElem.append('tspan');\n tspan.attr('x', textData.x + textData.textMargin * 2);\n tspan.text(nText);\n\n return textElem;\n};\n\nexport const drawImage = (elem: SVG | SVGGroup, x: number, y: number, link: string): void => {\n const imageElement: D3ImageElement = elem.append('image');\n imageElement.attr('x', x);\n imageElement.attr('y', y);\n const sanitizedLink: string = sanitizeUrl(link);\n imageElement.attr('xlink:href', sanitizedLink);\n};\n\nexport const drawEmbeddedImage = (\n element: SVG | SVGGroup,\n x: number,\n y: number,\n link: string\n): void => {\n const imageElement: D3UseElement = element.append('use');\n imageElement.attr('x', x);\n imageElement.attr('y', y);\n const sanitizedLink: string = sanitizeUrl(link);\n imageElement.attr('xlink:href', `#${sanitizedLink}`);\n};\n\nexport const getNoteRect = (): RectData => {\n const noteRectData: RectData = {\n x: 0,\n y: 0,\n width: 100,\n height: 100,\n fill: '#EDF2AE',\n stroke: '#666',\n anchor: 'start',\n rx: 0,\n ry: 0,\n };\n return noteRectData;\n};\n\nexport const getTextObj = (): TextObject => {\n const testObject: TextObject = {\n x: 0,\n y: 0,\n width: 100,\n height: 100,\n 'text-anchor': 'start',\n style: '#666',\n textMargin: 0,\n rx: 0,\n ry: 0,\n tspan: true,\n };\n return testObject;\n};\n\nexport const createTooltip = () => {\n let tooltipElem = select<HTMLDivElement, unknown>('.mermaidTooltip');\n if (tooltipElem.empty()) {\n tooltipElem = select('body')\n .append('div')\n .attr('class', 'mermaidTooltip')\n .style('opacity', 0)\n .style('position', 'absolute')\n .style('text-align', 'center')\n .style('max-width', '200px')\n .style('padding', '2px')\n .style('font-size', '12px')\n .style('background', '#ffffde')\n .style('border', '1px solid #333')\n .style('border-radius', '2px')\n .style('pointer-events', 'none')\n .style('z-index', '100');\n }\n return tooltipElem;\n};\n"],
"mappings": "2KAAA,IAAAA,EAA4B,SAgBrB,IAAMC,EAAWC,EAAA,CAACC,EAAyBC,IAAsC,CACtF,IAAMC,EAA6BF,EAAQ,OAAO,MAAM,EAiBxD,GAhBAE,EAAY,KAAK,IAAKD,EAAS,CAAC,EAChCC,EAAY,KAAK,IAAKD,EAAS,CAAC,EAChCC,EAAY,KAAK,OAAQD,EAAS,IAAI,EACtCC,EAAY,KAAK,SAAUD,EAAS,MAAM,EAC1CC,EAAY,KAAK,QAASD,EAAS,KAAK,EACxCC,EAAY,KAAK,SAAUD,EAAS,MAAM,EACtCA,EAAS,MACXC,EAAY,KAAK,OAAQD,EAAS,IAAI,EAEpCA,EAAS,IACXC,EAAY,KAAK,KAAMD,EAAS,EAAE,EAEhCA,EAAS,IACXC,EAAY,KAAK,KAAMD,EAAS,EAAE,EAGhCA,EAAS,QAAU,OACrB,QAAWE,KAAWF,EAAS,MAC7BC,EAAY,KAAKC,EAASF,EAAS,MAAME,CAAO,CAAC,EAIrD,OAAIF,EAAS,OACXC,EAAY,KAAK,QAASD,EAAS,KAAK,EAGnCC,CACT,EA7BwB,YAqCXE,EAAqBL,EAAA,CAACC,EAAyBK,IAAwB,CAClF,IAAMJ,EAAqB,CACzB,EAAGI,EAAO,OACV,EAAGA,EAAO,OACV,MAAOA,EAAO,MAAQA,EAAO,OAC7B,OAAQA,EAAO,MAAQA,EAAO,OAC9B,KAAMA,EAAO,KACb,OAAQA,EAAO,OACf,MAAO,MACT,EACmCP,EAASE,EAASC,CAAQ,EACjD,MAAM,CACpB,EAZkC,sBAcrBK,EAAWP,EAAA,CAACC,EAAyBO,IAAsC,CACtF,IAAMC,EAAgBD,EAAS,KAAK,QAAQE,EAAgB,GAAG,EAEzDC,EAA0BV,EAAQ,OAAO,MAAM,EACrDU,EAAS,KAAK,IAAKH,EAAS,CAAC,EAC7BG,EAAS,KAAK,IAAKH,EAAS,CAAC,EAC7BG,EAAS,KAAK,QAAS,QAAQ,EAE/BA,EAAS,MAAM,cAAeH,EAAS,MAAM,EACzCA,EAAS,OACXG,EAAS,KAAK,QAASH,EAAS,KAAK,EAGvC,IAAMI,EAAwBD,EAAS,OAAO,OAAO,EACrD,OAAAC,EAAM,KAAK,IAAKJ,EAAS,EAAIA,EAAS,WAAa,CAAC,EACpDI,EAAM,KAAKH,CAAK,EAETE,CACT,EAlBwB,YAoBXE,EAAYb,EAAA,CAACc,EAAsBC,EAAWC,EAAWC,IAAuB,CAC3F,IAAMC,EAA+BJ,EAAK,OAAO,OAAO,EACxDI,EAAa,KAAK,IAAKH,CAAC,EACxBG,EAAa,KAAK,IAAKF,CAAC,EACxB,IAAMG,KAAwB,eAAYF,CAAI,EAC9CC,EAAa,KAAK,aAAcC,CAAa,CAC/C,EANyB,aAQZC,EAAoBpB,EAAA,CAC/BC,EACAc,EACAC,EACAC,IACS,CACT,IAAMC,EAA6BjB,EAAQ,OAAO,KAAK,EACvDiB,EAAa,KAAK,IAAKH,CAAC,EACxBG,EAAa,KAAK,IAAKF,CAAC,EACxB,IAAMG,KAAwB,eAAYF,CAAI,EAC9CC,EAAa,KAAK,aAAc,IAAIC,CAAa,EAAE,CACrD,EAXiC,qBAapBE,EAAcrB,EAAA,KACM,CAC7B,EAAG,EACH,EAAG,EACH,MAAO,IACP,OAAQ,IACR,KAAM,UACN,OAAQ,OACR,OAAQ,QACR,GAAI,EACJ,GAAI,CACN,GAXyB,eAedsB,EAAatB,EAAA,KACO,CAC7B,EAAG,EACH,EAAG,EACH,MAAO,IACP,OAAQ,IACR,cAAe,QACf,MAAO,OACP,WAAY,EACZ,GAAI,EACJ,GAAI,EACJ,MAAO,EACT,GAZwB,cAgBbuB,EAAgBvB,EAAA,IAAM,CACjC,IAAIwB,EAAcC,EAAgC,iBAAiB,EACnE,OAAID,EAAY,MAAM,IACpBA,EAAcC,EAAO,MAAM,EACxB,OAAO,KAAK,EACZ,KAAK,QAAS,gBAAgB,EAC9B,MAAM,UAAW,CAAC,EAClB,MAAM,WAAY,UAAU,EAC5B,MAAM,aAAc,QAAQ,EAC5B,MAAM,YAAa,OAAO,EAC1B,MAAM,UAAW,KAAK,EACtB,MAAM,YAAa,MAAM,EACzB,MAAM,aAAc,SAAS,EAC7B,MAAM,SAAU,gBAAgB,EAChC,MAAM,gBAAiB,KAAK,EAC5B,MAAM,iBAAkB,MAAM,EAC9B,MAAM,UAAW,KAAK,GAEpBD,CACT,EAnB6B",
"names": ["import_sanitize_url", "drawRect", "__name", "element", "rectData", "rectElement", "attrKey", "drawBackgroundRect", "bounds", "drawText", "textData", "nText", "lineBreakRegex", "textElem", "tspan", "drawImage", "elem", "x", "y", "link", "imageElement", "sanitizedLink", "drawEmbeddedImage", "getNoteRect", "getTextObj", "createTooltip", "tooltipElem", "select_default"]
}

View File

@@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../../../../parser/dist/chunks/mermaid-parser.core/chunk-OZEHJAEY.mjs"],
"sourcesContent": ["import {\n AbstractMermaidTokenBuilder,\n AbstractMermaidValueConverter,\n MermaidGeneratedSharedModule,\n TreemapGrammarGeneratedModule,\n __name\n} from \"./chunk-XZSTWKYB.mjs\";\n\n// src/language/treemap/module.ts\nimport {\n EmptyFileSystem,\n createDefaultCoreModule,\n createDefaultSharedCoreModule,\n inject\n} from \"langium\";\n\n// src/language/treemap/tokenBuilder.ts\nvar TreemapTokenBuilder = class extends AbstractMermaidTokenBuilder {\n static {\n __name(this, \"TreemapTokenBuilder\");\n }\n constructor() {\n super([\"treemap\"]);\n }\n};\n\n// src/language/treemap/valueConverter.ts\nvar classDefRegex = /classDef\\s+([A-Z_a-z]\\w+)(?:\\s+([^\\n\\r;]*))?;?/;\nvar TreemapValueConverter = class extends AbstractMermaidValueConverter {\n static {\n __name(this, \"TreemapValueConverter\");\n }\n runCustomConverter(rule, input, _cstNode) {\n if (rule.name === \"NUMBER2\") {\n return parseFloat(input.replace(/,/g, \"\"));\n } else if (rule.name === \"SEPARATOR\") {\n return input.substring(1, input.length - 1);\n } else if (rule.name === \"STRING2\") {\n return input.substring(1, input.length - 1);\n } else if (rule.name === \"INDENTATION\") {\n return input.length;\n } else if (rule.name === \"ClassDef\") {\n if (typeof input !== \"string\") {\n return input;\n }\n const match = classDefRegex.exec(input);\n if (match) {\n return {\n $type: \"ClassDefStatement\",\n className: match[1],\n styleText: match[2] || void 0\n };\n }\n }\n return void 0;\n }\n};\n\n// src/language/treemap/treemap-validator.ts\nfunction registerValidationChecks(services) {\n const validator = services.validation.TreemapValidator;\n const registry = services.validation.ValidationRegistry;\n if (registry) {\n const checks = {\n Treemap: validator.checkSingleRoot.bind(validator)\n // Remove unused validation for TreemapRow\n };\n registry.register(checks, validator);\n }\n}\n__name(registerValidationChecks, \"registerValidationChecks\");\nvar TreemapValidator = class {\n static {\n __name(this, \"TreemapValidator\");\n }\n /**\n * Validates that a treemap has only one root node.\n * A root node is defined as a node that has no indentation.\n */\n checkSingleRoot(doc, accept) {\n let rootNodeIndentation;\n for (const row of doc.TreemapRows) {\n if (!row.item) {\n continue;\n }\n if (rootNodeIndentation === void 0 && // Check if this is a root node (no indentation)\n row.indent === void 0) {\n rootNodeIndentation = 0;\n } else if (row.indent === void 0) {\n accept(\"error\", \"Multiple root nodes are not allowed in a treemap.\", {\n node: row,\n property: \"item\"\n });\n } else if (rootNodeIndentation !== void 0 && rootNodeIndentation >= parseInt(row.indent, 10)) {\n accept(\"error\", \"Multiple root nodes are not allowed in a treemap.\", {\n node: row,\n property: \"item\"\n });\n }\n }\n }\n};\n\n// src/language/treemap/module.ts\nvar TreemapModule = {\n parser: {\n TokenBuilder: /* @__PURE__ */ __name(() => new TreemapTokenBuilder(), \"TokenBuilder\"),\n ValueConverter: /* @__PURE__ */ __name(() => new TreemapValueConverter(), \"ValueConverter\")\n },\n validation: {\n TreemapValidator: /* @__PURE__ */ __name(() => new TreemapValidator(), \"TreemapValidator\")\n }\n};\nfunction createTreemapServices(context = EmptyFileSystem) {\n const shared = inject(\n createDefaultSharedCoreModule(context),\n MermaidGeneratedSharedModule\n );\n const Treemap = inject(\n createDefaultCoreModule({ shared }),\n TreemapGrammarGeneratedModule,\n TreemapModule\n );\n shared.ServiceRegistry.register(Treemap);\n registerValidationChecks(Treemap);\n return { shared, Treemap };\n}\n__name(createTreemapServices, \"createTreemapServices\");\n\nexport {\n TreemapModule,\n createTreemapServices\n};\n"],
"mappings": "4IAiBA,IAAIA,EAAsB,cAAcC,CAA4B,CAjBpE,MAiBoE,CAAAC,EAAA,4BAClE,MAAO,CACLA,EAAO,KAAM,qBAAqB,CACpC,CACA,aAAc,CACZ,MAAM,CAAC,SAAS,CAAC,CACnB,CACF,EAGIC,EAAgB,iDAChBC,EAAwB,cAAcC,CAA8B,CA5BxE,MA4BwE,CAAAH,EAAA,8BACtE,MAAO,CACLA,EAAO,KAAM,uBAAuB,CACtC,CACA,mBAAmBI,EAAMC,EAAOC,EAAU,CACxC,GAAIF,EAAK,OAAS,UAChB,OAAO,WAAWC,EAAM,QAAQ,KAAM,EAAE,CAAC,EACpC,GAAID,EAAK,OAAS,YACvB,OAAOC,EAAM,UAAU,EAAGA,EAAM,OAAS,CAAC,EACrC,GAAID,EAAK,OAAS,UACvB,OAAOC,EAAM,UAAU,EAAGA,EAAM,OAAS,CAAC,EACrC,GAAID,EAAK,OAAS,cACvB,OAAOC,EAAM,OACR,GAAID,EAAK,OAAS,WAAY,CACnC,GAAI,OAAOC,GAAU,SACnB,OAAOA,EAET,IAAME,EAAQN,EAAc,KAAKI,CAAK,EACtC,GAAIE,EACF,MAAO,CACL,MAAO,oBACP,UAAWA,EAAM,CAAC,EAClB,UAAWA,EAAM,CAAC,GAAK,MACzB,CAEJ,CAEF,CACF,EAGA,SAASC,EAAyBC,EAAU,CAC1C,IAAMC,EAAYD,EAAS,WAAW,iBAChCE,EAAWF,EAAS,WAAW,mBACrC,GAAIE,EAAU,CACZ,IAAMC,EAAS,CACb,QAASF,EAAU,gBAAgB,KAAKA,CAAS,CAEnD,EACAC,EAAS,SAASC,EAAQF,CAAS,CACrC,CACF,CAVSV,EAAAQ,EAAA,4BAWTR,EAAOQ,EAA0B,0BAA0B,EAC3D,IAAIK,EAAmB,KAAM,CAvE7B,MAuE6B,CAAAb,EAAA,yBAC3B,MAAO,CACLA,EAAO,KAAM,kBAAkB,CACjC,CAKA,gBAAgBc,EAAKC,EAAQ,CAC3B,IAAIC,EACJ,QAAWC,KAAOH,EAAI,YACfG,EAAI,OAGLD,IAAwB,QAC5BC,EAAI,SAAW,OACbD,EAAsB,EACbC,EAAI,SAAW,OACxBF,EAAO,QAAS,oDAAqD,CACnE,KAAME,EACN,SAAU,MACZ,CAAC,EACQD,IAAwB,QAAUA,GAAuB,SAASC,EAAI,OAAQ,EAAE,GACzFF,EAAO,QAAS,oDAAqD,CACnE,KAAME,EACN,SAAU,MACZ,CAAC,EAGP,CACF,EAGIC,EAAgB,CAClB,OAAQ,CACN,aAA8BlB,EAAO,IAAM,IAAIF,EAAuB,cAAc,EACpF,eAAgCE,EAAO,IAAM,IAAIE,EAAyB,gBAAgB,CAC5F,EACA,WAAY,CACV,iBAAkCF,EAAO,IAAM,IAAIa,EAAoB,kBAAkB,CAC3F,CACF,EACA,SAASM,EAAsBC,EAAUC,EAAiB,CACxD,IAAMC,EAASC,EACbC,EAA8BJ,CAAO,EACrCK,CACF,EACMC,EAAUH,EACdI,EAAwB,CAAE,OAAAL,CAAO,CAAC,EAClCM,EACAV,CACF,EACA,OAAAI,EAAO,gBAAgB,SAASI,CAAO,EACvClB,EAAyBkB,CAAO,EACzB,CAAE,OAAAJ,EAAQ,QAAAI,CAAQ,CAC3B,CAbS1B,EAAAmB,EAAA,yBAcTnB,EAAOmB,EAAuB,uBAAuB",
"names": ["TreemapTokenBuilder", "AbstractMermaidTokenBuilder", "__name", "classDefRegex", "TreemapValueConverter", "AbstractMermaidValueConverter", "rule", "input", "_cstNode", "match", "registerValidationChecks", "services", "validator", "registry", "checks", "TreemapValidator", "doc", "accept", "rootNodeIndentation", "row", "TreemapModule", "createTreemapServices", "context", "EmptyFileSystem", "shared", "inject", "createDefaultSharedCoreModule", "MermaidGeneratedSharedModule", "Treemap", "createDefaultCoreModule", "TreemapGrammarGeneratedModule"]
}

View File

@@ -0,0 +1 @@
import{a,b as o,c as e,d as t}from"./chunk-TFLKLN34.mjs";import"./chunk-KSICW3F5.mjs";import"./chunk-W2A4CRWB.mjs";import"./chunk-TBF5ZNIQ.mjs";import"./chunk-T4EQAHMB.mjs";import"./chunk-SK62O5VA.mjs";import"./chunk-5YHUCXBM.mjs";import"./chunk-3ZBQQEZ6.mjs";import"./chunk-BDKIFH7H.mjs";import"./chunk-XODN6PIJ.mjs";import"./chunk-IWDTEBJL.mjs";import"./chunk-D2KP3OBD.mjs";import"./chunk-YLHEXJF3.mjs";import"./chunk-Q3CC2MQB.mjs";import"./chunk-XBXGYYE5.mjs";import"./chunk-3UWU4A3N.mjs";import"./chunk-MGPAVIPZ.mjs";import"./chunk-JIN56HTB.mjs";import{a as i}from"./chunk-VELTKBKT.mjs";var n={parser:a,get db(){return new o},renderer:t,styles:e,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{n as diagram};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
import{a as r,b as e}from"./chunk-NHJX6F6M.mjs";import"./chunk-GAX3EE6F.mjs";import"./chunk-H3VCZNTA.mjs";import"./chunk-QU3B7NT4.mjs";import"./chunk-JIN56HTB.mjs";import"./chunk-VELTKBKT.mjs";export{r as GitGraphModule,e as createGitGraphServices};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
import{a as e,b as i,c as a,d as o}from"./chunk-33NP3AWU.mjs";import"./chunk-TBF5ZNIQ.mjs";import"./chunk-T4EQAHMB.mjs";import"./chunk-SK62O5VA.mjs";import"./chunk-5YHUCXBM.mjs";import"./chunk-3ZBQQEZ6.mjs";import"./chunk-BDKIFH7H.mjs";import"./chunk-XODN6PIJ.mjs";import"./chunk-IWDTEBJL.mjs";import"./chunk-D2KP3OBD.mjs";import"./chunk-YLHEXJF3.mjs";import"./chunk-Q3CC2MQB.mjs";import"./chunk-XBXGYYE5.mjs";import"./chunk-3UWU4A3N.mjs";import"./chunk-MGPAVIPZ.mjs";import"./chunk-JIN56HTB.mjs";import{a as t}from"./chunk-VELTKBKT.mjs";var f={parser:e,get db(){return new a(2)},renderer:i,styles:o,init:t(r=>{r.state||(r.state={}),r.state.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{f as diagram};

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../../../../parser/dist/chunks/mermaid-parser.core/chunk-EGIJ26TM.mjs"],
"sourcesContent": ["import {\n AbstractMermaidTokenBuilder,\n CommonValueConverter,\n InfoGrammarGeneratedModule,\n MermaidGeneratedSharedModule,\n __name\n} from \"./chunk-XZSTWKYB.mjs\";\n\n// src/language/info/module.ts\nimport {\n EmptyFileSystem,\n createDefaultCoreModule,\n createDefaultSharedCoreModule,\n inject\n} from \"langium\";\n\n// src/language/info/tokenBuilder.ts\nvar InfoTokenBuilder = class extends AbstractMermaidTokenBuilder {\n static {\n __name(this, \"InfoTokenBuilder\");\n }\n constructor() {\n super([\"info\", \"showInfo\"]);\n }\n};\n\n// src/language/info/module.ts\nvar InfoModule = {\n parser: {\n TokenBuilder: /* @__PURE__ */ __name(() => new InfoTokenBuilder(), \"TokenBuilder\"),\n ValueConverter: /* @__PURE__ */ __name(() => new CommonValueConverter(), \"ValueConverter\")\n }\n};\nfunction createInfoServices(context = EmptyFileSystem) {\n const shared = inject(\n createDefaultSharedCoreModule(context),\n MermaidGeneratedSharedModule\n );\n const Info = inject(\n createDefaultCoreModule({ shared }),\n InfoGrammarGeneratedModule,\n InfoModule\n );\n shared.ServiceRegistry.register(Info);\n return { shared, Info };\n}\n__name(createInfoServices, \"createInfoServices\");\n\nexport {\n InfoModule,\n createInfoServices\n};\n"],
"mappings": ";;;;;;;;;;;;;;;;;AAiBA,IAAI,mBAAmB,cAAc,4BAA4B;AAAA,EAjBjE,OAiBiE;AAAA;AAAA;AAAA,EAC/D,OAAO;AACL,IAAAA,QAAO,MAAM,kBAAkB;AAAA,EACjC;AAAA,EACA,cAAc;AACZ,UAAM,CAAC,QAAQ,UAAU,CAAC;AAAA,EAC5B;AACF;AAGA,IAAI,aAAa;AAAA,EACf,QAAQ;AAAA,IACN,cAA8B,gBAAAA,QAAO,MAAM,IAAI,iBAAiB,GAAG,cAAc;AAAA,IACjF,gBAAgC,gBAAAA,QAAO,MAAM,IAAI,qBAAqB,GAAG,gBAAgB;AAAA,EAC3F;AACF;AACA,SAAS,mBAAmB,UAAU,iBAAiB;AACrD,QAAM,SAAS;AAAA,IACb,8BAA8B,OAAO;AAAA,IACrC;AAAA,EACF;AACA,QAAM,OAAO;AAAA,IACX,wBAAwB,EAAE,OAAO,CAAC;AAAA,IAClC;AAAA,IACA;AAAA,EACF;AACA,SAAO,gBAAgB,SAAS,IAAI;AACpC,SAAO,EAAE,QAAQ,KAAK;AACxB;AAZS;AAaTA,QAAO,oBAAoB,oBAAoB;",
"names": ["__name"]
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,68 @@
import {
parseFontSize
} from "./chunk-XCSQNVCT.mjs";
import {
defaultConfig_default,
getConfig2 as getConfig
} from "./chunk-UKMXQNCB.mjs";
import {
__name
} from "./chunk-FQFHLQFH.mjs";
// src/utils/subGraphTitleMargins.ts
var getSubGraphTitleMargins = /* @__PURE__ */ __name(({
flowchart
}) => {
const subGraphTitleTopMargin = flowchart?.subGraphTitleMargin?.top ?? 0;
const subGraphTitleBottomMargin = flowchart?.subGraphTitleMargin?.bottom ?? 0;
const subGraphTitleTotalMargin = subGraphTitleTopMargin + subGraphTitleBottomMargin;
return {
subGraphTitleTopMargin,
subGraphTitleBottomMargin,
subGraphTitleTotalMargin
};
}, "getSubGraphTitleMargins");
// src/rendering-util/rendering-elements/shapes/labelImageUtils.ts
async function configureLabelImages(container, labelText) {
const images = container.getElementsByTagName("img");
if (!images || images.length === 0) {
return;
}
const noImgText = labelText.replace(/<img[^>]*>/g, "").trim() === "";
await Promise.all(
[...images].map(
(img) => new Promise((res) => {
function setupImage() {
img.style.display = "flex";
img.style.flexDirection = "column";
if (noImgText) {
const bodyFontSize = getConfig().fontSize ? getConfig().fontSize : window.getComputedStyle(document.body).fontSize;
const enlargingFactor = 5;
const [parsedBodyFontSize = defaultConfig_default.fontSize] = parseFontSize(bodyFontSize);
const width = parsedBodyFontSize * enlargingFactor + "px";
img.style.minWidth = width;
img.style.maxWidth = width;
} else {
img.style.width = "100%";
}
res(img);
}
__name(setupImage, "setupImage");
setTimeout(() => {
if (img.complete) {
setupImage();
}
});
img.addEventListener("error", setupImage);
img.addEventListener("load", setupImage);
})
)
);
}
__name(configureLabelImages, "configureLabelImages");
export {
configureLabelImages,
getSubGraphTitleMargins
};

View File

@@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../../../../parser/dist/chunks/mermaid-parser.core/chunk-L3YUKLVL.mjs"],
"sourcesContent": ["import {\n AbstractMermaidTokenBuilder,\n CommonValueConverter,\n MermaidGeneratedSharedModule,\n RadarGrammarGeneratedModule,\n __name\n} from \"./chunk-XZSTWKYB.mjs\";\n\n// src/language/radar/module.ts\nimport {\n EmptyFileSystem,\n createDefaultCoreModule,\n createDefaultSharedCoreModule,\n inject\n} from \"langium\";\n\n// src/language/radar/tokenBuilder.ts\nvar RadarTokenBuilder = class extends AbstractMermaidTokenBuilder {\n static {\n __name(this, \"RadarTokenBuilder\");\n }\n constructor() {\n super([\"radar-beta\"]);\n }\n};\n\n// src/language/radar/module.ts\nvar RadarModule = {\n parser: {\n TokenBuilder: /* @__PURE__ */ __name(() => new RadarTokenBuilder(), \"TokenBuilder\"),\n ValueConverter: /* @__PURE__ */ __name(() => new CommonValueConverter(), \"ValueConverter\")\n }\n};\nfunction createRadarServices(context = EmptyFileSystem) {\n const shared = inject(\n createDefaultSharedCoreModule(context),\n MermaidGeneratedSharedModule\n );\n const Radar = inject(\n createDefaultCoreModule({ shared }),\n RadarGrammarGeneratedModule,\n RadarModule\n );\n shared.ServiceRegistry.register(Radar);\n return { shared, Radar };\n}\n__name(createRadarServices, \"createRadarServices\");\n\nexport {\n RadarModule,\n createRadarServices\n};\n"],
"mappings": ";;;;;;;;;;;;;;;;;AAiBA,IAAI,oBAAoB,cAAc,4BAA4B;AAAA,EAjBlE,OAiBkE;AAAA;AAAA;AAAA,EAChE,OAAO;AACL,IAAAA,QAAO,MAAM,mBAAmB;AAAA,EAClC;AAAA,EACA,cAAc;AACZ,UAAM,CAAC,YAAY,CAAC;AAAA,EACtB;AACF;AAGA,IAAI,cAAc;AAAA,EAChB,QAAQ;AAAA,IACN,cAA8B,gBAAAA,QAAO,MAAM,IAAI,kBAAkB,GAAG,cAAc;AAAA,IAClF,gBAAgC,gBAAAA,QAAO,MAAM,IAAI,qBAAqB,GAAG,gBAAgB;AAAA,EAC3F;AACF;AACA,SAAS,oBAAoB,UAAU,iBAAiB;AACtD,QAAM,SAAS;AAAA,IACb,8BAA8B,OAAO;AAAA,IACrC;AAAA,EACF;AACA,QAAM,QAAQ;AAAA,IACZ,wBAAwB,EAAE,OAAO,CAAC;AAAA,IAClC;AAAA,IACA;AAAA,EACF;AACA,SAAO,gBAAgB,SAAS,KAAK;AACrC,SAAO,EAAE,QAAQ,MAAM;AACzB;AAZS;AAaTA,QAAO,qBAAqB,qBAAqB;",
"names": ["__name"]
}

View File

@@ -0,0 +1,54 @@
import {
AbstractMermaidTokenBuilder,
CommonValueConverter,
EmptyFileSystem,
GitGraphGrammarGeneratedModule,
MermaidGeneratedSharedModule,
__name as __name2,
createDefaultCoreModule,
createDefaultSharedCoreModule,
inject,
lib_exports
} from "./chunk-S3MDV2AR.mjs";
import {
__name
} from "./chunk-FQFHLQFH.mjs";
// ../parser/dist/chunks/mermaid-parser.core/chunk-7E7YKBS2.mjs
var GitGraphTokenBuilder = class extends AbstractMermaidTokenBuilder {
static {
__name(this, "GitGraphTokenBuilder");
}
static {
__name2(this, "GitGraphTokenBuilder");
}
constructor() {
super(["gitGraph"]);
}
};
var GitGraphModule = {
parser: {
TokenBuilder: /* @__PURE__ */ __name2(() => new GitGraphTokenBuilder(), "TokenBuilder"),
ValueConverter: /* @__PURE__ */ __name2(() => new CommonValueConverter(), "ValueConverter")
}
};
function createGitGraphServices(context = EmptyFileSystem) {
const shared = inject(
createDefaultSharedCoreModule(context),
MermaidGeneratedSharedModule
);
const GitGraph = inject(
createDefaultCoreModule({ shared }),
GitGraphGrammarGeneratedModule,
GitGraphModule
);
shared.ServiceRegistry.register(GitGraph);
return { shared, GitGraph };
}
__name(createGitGraphServices, "createGitGraphServices");
__name2(createGitGraphServices, "createGitGraphServices");
export {
GitGraphModule,
createGitGraphServices
};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,132 @@
import {
require_dist
} from "./chunk-3OTVAOVH.mjs";
import {
lineBreakRegex
} from "./chunk-UKMXQNCB.mjs";
import {
select_default
} from "./chunk-GRVEB7DL.mjs";
import {
__name,
__toESM
} from "./chunk-FQFHLQFH.mjs";
// src/diagrams/common/svgDrawCommon.ts
var import_sanitize_url = __toESM(require_dist(), 1);
var drawRect = /* @__PURE__ */ __name((element, rectData) => {
const rectElement = element.append("rect");
rectElement.attr("x", rectData.x);
rectElement.attr("y", rectData.y);
rectElement.attr("fill", rectData.fill);
rectElement.attr("stroke", rectData.stroke);
rectElement.attr("width", rectData.width);
rectElement.attr("height", rectData.height);
if (rectData.name) {
rectElement.attr("name", rectData.name);
}
if (rectData.rx) {
rectElement.attr("rx", rectData.rx);
}
if (rectData.ry) {
rectElement.attr("ry", rectData.ry);
}
if (rectData.attrs !== void 0) {
for (const attrKey in rectData.attrs) {
rectElement.attr(attrKey, rectData.attrs[attrKey]);
}
}
if (rectData.class) {
rectElement.attr("class", rectData.class);
}
return rectElement;
}, "drawRect");
var drawBackgroundRect = /* @__PURE__ */ __name((element, bounds) => {
const rectData = {
x: bounds.startx,
y: bounds.starty,
width: bounds.stopx - bounds.startx,
height: bounds.stopy - bounds.starty,
fill: bounds.fill,
stroke: bounds.stroke,
class: "rect"
};
const rectElement = drawRect(element, rectData);
rectElement.lower();
}, "drawBackgroundRect");
var drawText = /* @__PURE__ */ __name((element, textData) => {
const nText = textData.text.replace(lineBreakRegex, " ");
const textElem = element.append("text");
textElem.attr("x", textData.x);
textElem.attr("y", textData.y);
textElem.attr("class", "legend");
textElem.style("text-anchor", textData.anchor);
if (textData.class) {
textElem.attr("class", textData.class);
}
const tspan = textElem.append("tspan");
tspan.attr("x", textData.x + textData.textMargin * 2);
tspan.text(nText);
return textElem;
}, "drawText");
var drawImage = /* @__PURE__ */ __name((elem, x, y, link) => {
const imageElement = elem.append("image");
imageElement.attr("x", x);
imageElement.attr("y", y);
const sanitizedLink = (0, import_sanitize_url.sanitizeUrl)(link);
imageElement.attr("xlink:href", sanitizedLink);
}, "drawImage");
var drawEmbeddedImage = /* @__PURE__ */ __name((element, x, y, link) => {
const imageElement = element.append("use");
imageElement.attr("x", x);
imageElement.attr("y", y);
const sanitizedLink = (0, import_sanitize_url.sanitizeUrl)(link);
imageElement.attr("xlink:href", `#${sanitizedLink}`);
}, "drawEmbeddedImage");
var getNoteRect = /* @__PURE__ */ __name(() => {
const noteRectData = {
x: 0,
y: 0,
width: 100,
height: 100,
fill: "#EDF2AE",
stroke: "#666",
anchor: "start",
rx: 0,
ry: 0
};
return noteRectData;
}, "getNoteRect");
var getTextObj = /* @__PURE__ */ __name(() => {
const testObject = {
x: 0,
y: 0,
width: 100,
height: 100,
"text-anchor": "start",
style: "#666",
textMargin: 0,
rx: 0,
ry: 0,
tspan: true
};
return testObject;
}, "getTextObj");
var createTooltip = /* @__PURE__ */ __name(() => {
let tooltipElem = select_default(".mermaidTooltip");
if (tooltipElem.empty()) {
tooltipElem = select_default("body").append("div").attr("class", "mermaidTooltip").style("opacity", 0).style("position", "absolute").style("text-align", "center").style("max-width", "200px").style("padding", "2px").style("font-size", "12px").style("background", "#ffffde").style("border", "1px solid #333").style("border-radius", "2px").style("pointer-events", "none").style("z-index", "100");
}
return tooltipElem;
}, "createTooltip");
export {
drawRect,
drawBackgroundRect,
drawText,
drawImage,
drawEmbeddedImage,
getNoteRect,
getTextObj,
createTooltip
};

View File

@@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../../../src/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.ts"],
"sourcesContent": ["import { getConfig } from '../../../diagram-api/diagramAPI.js';\nimport type { Node } from '../../types.js';\n\n// Striped fill like start or fork nodes in state diagrams\nexport const solidStateFill = (color: string) => {\n const { handDrawnSeed } = getConfig();\n return {\n fill: color,\n hachureAngle: 120, // angle of hachure,\n hachureGap: 4,\n fillWeight: 2,\n roughness: 0.7,\n stroke: color,\n seed: handDrawnSeed,\n };\n};\n\nexport const compileStyles = (node: Node) => {\n // node.cssCompiledStyles is an array of strings in the form of 'key: value' where key is the css property and value is the value\n // the array is the styles of node from the classes it is using\n // node.cssStyles is an array of styles directly set on the node\n // concat the arrays and remove duplicates such that the values from node.cssStyles are used if there are duplicates\n const stylesMap = styles2Map([\n ...(node.cssCompiledStyles || []),\n ...(node.cssStyles || []),\n ...(node.labelStyle || []),\n ]);\n return { stylesMap, stylesArray: [...stylesMap] };\n};\n\nexport const styles2Map = (styles: string[]) => {\n const styleMap = new Map<string, string>();\n styles.forEach((style) => {\n const [key, value] = style.split(':');\n styleMap.set(key.trim(), value?.trim());\n });\n return styleMap;\n};\nexport const isLabelStyle = (key: string) => {\n return (\n key === 'color' ||\n key === 'font-size' ||\n key === 'font-family' ||\n key === 'font-weight' ||\n key === 'font-style' ||\n key === 'text-decoration' ||\n key === 'text-align' ||\n key === 'text-transform' ||\n key === 'line-height' ||\n key === 'letter-spacing' ||\n key === 'word-spacing' ||\n key === 'text-shadow' ||\n key === 'text-overflow' ||\n key === 'white-space' ||\n key === 'word-wrap' ||\n key === 'word-break' ||\n key === 'overflow-wrap' ||\n key === 'hyphens'\n );\n};\nexport const styles2String = (node: Node) => {\n const { stylesArray } = compileStyles(node);\n const labelStyles: string[] = [];\n const nodeStyles: string[] = [];\n const borderStyles: string[] = [];\n const backgroundStyles: string[] = [];\n\n stylesArray.forEach((style) => {\n const key = style[0];\n if (isLabelStyle(key)) {\n labelStyles.push(style.join(':') + ' !important');\n } else {\n nodeStyles.push(style.join(':') + ' !important');\n if (key.includes('stroke')) {\n borderStyles.push(style.join(':') + ' !important');\n }\n if (key === 'fill') {\n backgroundStyles.push(style.join(':') + ' !important');\n }\n }\n });\n\n return {\n labelStyles: labelStyles.join(';'),\n nodeStyles: nodeStyles.join(';'),\n stylesArray,\n borderStyles,\n backgroundStyles,\n };\n};\n\n// Striped fill like start or fork nodes in state diagrams\n// TODO remove any\nexport const userNodeOverrides = (node: Node, options: any) => {\n const { themeVariables, handDrawnSeed } = getConfig();\n const { nodeBorder, mainBkg } = themeVariables;\n const { stylesMap } = compileStyles(node);\n\n // index the style array to a map object\n const result = Object.assign(\n {\n roughness: 0.7,\n fill: stylesMap.get('fill') || mainBkg,\n fillStyle: 'hachure', // solid fill\n fillWeight: 4,\n hachureGap: 5.2,\n stroke: stylesMap.get('stroke') || nodeBorder,\n seed: handDrawnSeed,\n strokeWidth: stylesMap.get('stroke-width')?.replace('px', '') || 1.3,\n fillLineDash: [0, 0],\n strokeLineDash: getStrokeDashArray(stylesMap.get('stroke-dasharray')),\n },\n options\n );\n return result;\n};\n\nconst getStrokeDashArray = (strokeDasharrayStyle?: string) => {\n if (!strokeDasharrayStyle) {\n return [0, 0];\n }\n const dashArray = strokeDasharrayStyle.trim().split(/\\s+/).map(Number);\n if (dashArray.length === 1) {\n const val = isNaN(dashArray[0]) ? 0 : dashArray[0];\n return [val, val];\n }\n const first = isNaN(dashArray[0]) ? 0 : dashArray[0];\n const second = isNaN(dashArray[1]) ? 0 : dashArray[1];\n return [first, second];\n};\n"],
"mappings": ";;;;;;;;AAIO,IAAM,iBAAiB,wBAAC,UAAkB;AAC/C,QAAM,EAAE,cAAc,IAAI,UAAU;AACpC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,cAAc;AAAA;AAAA,IACd,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,MAAM;AAAA,EACR;AACF,GAX8B;AAavB,IAAM,gBAAgB,wBAAC,SAAe;AAK3C,QAAM,YAAY,WAAW;AAAA,IAC3B,GAAI,KAAK,qBAAqB,CAAC;AAAA,IAC/B,GAAI,KAAK,aAAa,CAAC;AAAA,IACvB,GAAI,KAAK,cAAc,CAAC;AAAA,EAC1B,CAAC;AACD,SAAO,EAAE,WAAW,aAAa,CAAC,GAAG,SAAS,EAAE;AAClD,GAX6B;AAatB,IAAM,aAAa,wBAAC,WAAqB;AAC9C,QAAM,WAAW,oBAAI,IAAoB;AACzC,SAAO,QAAQ,CAAC,UAAU;AACxB,UAAM,CAAC,KAAK,KAAK,IAAI,MAAM,MAAM,GAAG;AACpC,aAAS,IAAI,IAAI,KAAK,GAAG,OAAO,KAAK,CAAC;AAAA,EACxC,CAAC;AACD,SAAO;AACT,GAP0B;AAQnB,IAAM,eAAe,wBAAC,QAAgB;AAC3C,SACE,QAAQ,WACR,QAAQ,eACR,QAAQ,iBACR,QAAQ,iBACR,QAAQ,gBACR,QAAQ,qBACR,QAAQ,gBACR,QAAQ,oBACR,QAAQ,iBACR,QAAQ,oBACR,QAAQ,kBACR,QAAQ,iBACR,QAAQ,mBACR,QAAQ,iBACR,QAAQ,eACR,QAAQ,gBACR,QAAQ,mBACR,QAAQ;AAEZ,GArB4B;AAsBrB,IAAM,gBAAgB,wBAAC,SAAe;AAC3C,QAAM,EAAE,YAAY,IAAI,cAAc,IAAI;AAC1C,QAAM,cAAwB,CAAC;AAC/B,QAAM,aAAuB,CAAC;AAC9B,QAAM,eAAyB,CAAC;AAChC,QAAM,mBAA6B,CAAC;AAEpC,cAAY,QAAQ,CAAC,UAAU;AAC7B,UAAM,MAAM,MAAM,CAAC;AACnB,QAAI,aAAa,GAAG,GAAG;AACrB,kBAAY,KAAK,MAAM,KAAK,GAAG,IAAI,aAAa;AAAA,IAClD,OAAO;AACL,iBAAW,KAAK,MAAM,KAAK,GAAG,IAAI,aAAa;AAC/C,UAAI,IAAI,SAAS,QAAQ,GAAG;AAC1B,qBAAa,KAAK,MAAM,KAAK,GAAG,IAAI,aAAa;AAAA,MACnD;AACA,UAAI,QAAQ,QAAQ;AAClB,yBAAiB,KAAK,MAAM,KAAK,GAAG,IAAI,aAAa;AAAA,MACvD;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL,aAAa,YAAY,KAAK,GAAG;AAAA,IACjC,YAAY,WAAW,KAAK,GAAG;AAAA,IAC/B;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF,GA7B6B;AAiCtB,IAAM,oBAAoB,wBAAC,MAAY,YAAiB;AAC7D,QAAM,EAAE,gBAAgB,cAAc,IAAI,UAAU;AACpD,QAAM,EAAE,YAAY,QAAQ,IAAI;AAChC,QAAM,EAAE,UAAU,IAAI,cAAc,IAAI;AAGxC,QAAM,SAAS,OAAO;AAAA,IACpB;AAAA,MACE,WAAW;AAAA,MACX,MAAM,UAAU,IAAI,MAAM,KAAK;AAAA,MAC/B,WAAW;AAAA;AAAA,MACX,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,QAAQ,UAAU,IAAI,QAAQ,KAAK;AAAA,MACnC,MAAM;AAAA,MACN,aAAa,UAAU,IAAI,cAAc,GAAG,QAAQ,MAAM,EAAE,KAAK;AAAA,MACjE,cAAc,CAAC,GAAG,CAAC;AAAA,MACnB,gBAAgB,mBAAmB,UAAU,IAAI,kBAAkB,CAAC;AAAA,IACtE;AAAA,IACA;AAAA,EACF;AACA,SAAO;AACT,GAtBiC;AAwBjC,IAAM,qBAAqB,wBAAC,yBAAkC;AAC5D,MAAI,CAAC,sBAAsB;AACzB,WAAO,CAAC,GAAG,CAAC;AAAA,EACd;AACA,QAAM,YAAY,qBAAqB,KAAK,EAAE,MAAM,KAAK,EAAE,IAAI,MAAM;AACrE,MAAI,UAAU,WAAW,GAAG;AAC1B,UAAM,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,IAAI,UAAU,CAAC;AACjD,WAAO,CAAC,KAAK,GAAG;AAAA,EAClB;AACA,QAAM,QAAQ,MAAM,UAAU,CAAC,CAAC,IAAI,IAAI,UAAU,CAAC;AACnD,QAAM,SAAS,MAAM,UAAU,CAAC,CAAC,IAAI,IAAI,UAAU,CAAC;AACpD,SAAO,CAAC,OAAO,MAAM;AACvB,GAZ2B;",
"names": []
}

View File

@@ -0,0 +1,21 @@
import {
select_default
} from "./chunk-GRVEB7DL.mjs";
import {
__name
} from "./chunk-FQFHLQFH.mjs";
// src/rendering-util/insertElementsForSize.js
var getDiagramElement = /* @__PURE__ */ __name((id, securityLevel) => {
let sandboxElement;
if (securityLevel === "sandbox") {
sandboxElement = select_default("#i" + id);
}
const root = securityLevel === "sandbox" ? select_default(sandboxElement.nodes()[0].contentDocument.body) : select_default("body");
const svg = root.select(`[id="${id}"]`);
return svg;
}, "getDiagramElement");
export {
getDiagramElement
};

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,45 @@
import {
ClassDB,
classDiagram_default,
classRenderer_v3_unified_default,
styles_default
} from "./chunk-2WLNDWH6.mjs";
import "./chunk-SXA26SXQ.mjs";
import "./chunk-SBHDPRHC.mjs";
import "./chunk-U2CUWHSV.mjs";
import "./chunk-M4FGLBOT.mjs";
import "./chunk-EKL7DDBO.mjs";
import "./chunk-TZW2344G.mjs";
import "./chunk-UYNZS3GD.mjs";
import "./chunk-UAL2TQZE.mjs";
import "./chunk-FWQXANIB.mjs";
import "./chunk-D2KOLKXV.mjs";
import "./chunk-TEV7DDKD.mjs";
import "./chunk-YHLHMBDM.mjs";
import "./chunk-XCSQNVCT.mjs";
import "./chunk-3OTVAOVH.mjs";
import "./chunk-UKMXQNCB.mjs";
import "./chunk-GRVEB7DL.mjs";
import "./chunk-3QJOF6JT.mjs";
import {
__name
} from "./chunk-FQFHLQFH.mjs";
// src/diagrams/class/classDiagram-v2.ts
var diagram = {
parser: classDiagram_default,
get db() {
return new ClassDB();
},
renderer: classRenderer_v3_unified_default,
styles: styles_default,
init: /* @__PURE__ */ __name((cnf) => {
if (!cnf.class) {
cnf.class = {};
}
cnf.class.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
}, "init")
};
export {
diagram
};

View File

@@ -0,0 +1,582 @@
import {
populateCommonDb
} from "./chunk-WASTHULE.mjs";
import {
parse
} from "./chunk-6OSLE3NY.mjs";
import "./chunk-OBMQL7OE.mjs";
import "./chunk-BDXV45HO.mjs";
import "./chunk-ALB5NAU3.mjs";
import "./chunk-LYCWX5BJ.mjs";
import "./chunk-LIIAENVV.mjs";
import "./chunk-NUOAVMUD.mjs";
import {
selectSvgElement
} from "./chunk-NWP4V2O6.mjs";
import {
setupViewPortForSVG
} from "./chunk-M4FGLBOT.mjs";
import {
isLabelStyle,
styles2String
} from "./chunk-TEV7DDKD.mjs";
import {
cleanAndMerge
} from "./chunk-XCSQNVCT.mjs";
import "./chunk-3OTVAOVH.mjs";
import {
clear,
configureSvgSize,
defaultConfig_default,
getAccDescription,
getAccTitle,
getConfig,
getDiagramTitle,
setAccDescription,
setAccTitle,
setDiagramTitle
} from "./chunk-UKMXQNCB.mjs";
import {
format,
hierarchy,
log,
ordinal,
select_default,
treemap_default
} from "./chunk-GRVEB7DL.mjs";
import "./chunk-75NCXSTK.mjs";
import "./chunk-S3MDV2AR.mjs";
import "./chunk-MFRUYFWM.mjs";
import "./chunk-UKL4YMJ2.mjs";
import "./chunk-3QJOF6JT.mjs";
import {
__name
} from "./chunk-FQFHLQFH.mjs";
// src/diagrams/treemap/db.ts
var TreeMapDB = class {
constructor() {
this.nodes = [];
this.levels = /* @__PURE__ */ new Map();
this.outerNodes = [];
this.classes = /* @__PURE__ */ new Map();
this.setAccTitle = setAccTitle;
this.getAccTitle = getAccTitle;
this.setDiagramTitle = setDiagramTitle;
this.getDiagramTitle = getDiagramTitle;
this.getAccDescription = getAccDescription;
this.setAccDescription = setAccDescription;
}
static {
__name(this, "TreeMapDB");
}
getNodes() {
return this.nodes;
}
getConfig() {
const defaultConfig = defaultConfig_default;
const userConfig = getConfig();
return cleanAndMerge({
...defaultConfig.treemap,
...userConfig.treemap ?? {}
});
}
addNode(node, level) {
this.nodes.push(node);
this.levels.set(node, level);
if (level === 0) {
this.outerNodes.push(node);
this.root ??= node;
}
}
getRoot() {
return { name: "", children: this.outerNodes };
}
addClass(id, _style) {
const styleClass = this.classes.get(id) ?? { id, styles: [], textStyles: [] };
const styles = _style.replace(/\\,/g, "\xA7\xA7\xA7").replace(/,/g, ";").replace(/§§§/g, ",").split(";");
if (styles) {
styles.forEach((s) => {
if (isLabelStyle(s)) {
if (styleClass?.textStyles) {
styleClass.textStyles.push(s);
} else {
styleClass.textStyles = [s];
}
}
if (styleClass?.styles) {
styleClass.styles.push(s);
} else {
styleClass.styles = [s];
}
});
}
this.classes.set(id, styleClass);
}
getClasses() {
return this.classes;
}
getStylesForClass(classSelector) {
return this.classes.get(classSelector)?.styles ?? [];
}
clear() {
clear();
this.nodes = [];
this.levels = /* @__PURE__ */ new Map();
this.outerNodes = [];
this.classes = /* @__PURE__ */ new Map();
this.root = void 0;
}
};
// src/diagrams/treemap/utils.ts
function buildHierarchy(items) {
if (!items.length) {
return [];
}
const root = [];
const stack = [];
items.forEach((item) => {
const node = {
name: item.name,
children: item.type === "Leaf" ? void 0 : []
};
node.classSelector = item?.classSelector;
if (item?.cssCompiledStyles) {
node.cssCompiledStyles = item.cssCompiledStyles;
}
if (item.type === "Leaf" && item.value !== void 0) {
node.value = item.value;
}
while (stack.length > 0 && stack[stack.length - 1].level >= item.level) {
stack.pop();
}
if (stack.length === 0) {
root.push(node);
} else {
const parent = stack[stack.length - 1].node;
if (parent.children) {
parent.children.push(node);
} else {
parent.children = [node];
}
}
if (item.type !== "Leaf") {
stack.push({ node, level: item.level });
}
});
return root;
}
__name(buildHierarchy, "buildHierarchy");
// src/diagrams/treemap/parser.ts
var populate = /* @__PURE__ */ __name((ast, db) => {
populateCommonDb(ast, db);
const items = [];
for (const row of ast.TreemapRows ?? []) {
if (row.$type === "ClassDefStatement") {
db.addClass(row.className ?? "", row.styleText ?? "");
}
}
for (const row of ast.TreemapRows ?? []) {
const item = row.item;
if (!item) {
continue;
}
const level = row.indent ? parseInt(row.indent) : 0;
const name = getItemName(item);
const styles = item.classSelector ? db.getStylesForClass(item.classSelector) : [];
const cssCompiledStyles = styles.length > 0 ? styles : void 0;
const itemData = {
level,
name,
type: item.$type,
value: item.value,
classSelector: item.classSelector,
cssCompiledStyles
};
items.push(itemData);
}
const hierarchyNodes = buildHierarchy(items);
const addNodesRecursively = /* @__PURE__ */ __name((nodes, level) => {
for (const node of nodes) {
db.addNode(node, level);
if (node.children && node.children.length > 0) {
addNodesRecursively(node.children, level + 1);
}
}
}, "addNodesRecursively");
addNodesRecursively(hierarchyNodes, 0);
}, "populate");
var getItemName = /* @__PURE__ */ __name((item) => {
return item.name ? String(item.name) : "";
}, "getItemName");
var parser = {
// @ts-expect-error - TreeMapDB is not assignable to DiagramDB
parser: { yy: void 0 },
parse: /* @__PURE__ */ __name(async (text) => {
try {
const parseFunc = parse;
const ast = await parseFunc("treemap", text);
log.debug("Treemap AST:", ast);
const db = parser.parser?.yy;
if (!(db instanceof TreeMapDB)) {
throw new Error(
"parser.parser?.yy was not a TreemapDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues."
);
}
populate(ast, db);
} catch (error) {
log.error("Error parsing treemap:", error);
throw error;
}
}, "parse")
};
// src/diagrams/treemap/renderer.ts
var DEFAULT_INNER_PADDING = 10;
var SECTION_INNER_PADDING = 10;
var SECTION_HEADER_HEIGHT = 25;
var draw = /* @__PURE__ */ __name((_text, id, _version, diagram2) => {
const treemapDb = diagram2.db;
const config = treemapDb.getConfig();
const treemapInnerPadding = config.padding ?? DEFAULT_INNER_PADDING;
const title = treemapDb.getDiagramTitle();
const root = treemapDb.getRoot();
const { themeVariables } = getConfig();
if (!root) {
return;
}
const titleHeight = title ? 30 : 0;
const svg = selectSvgElement(id);
const width = config.nodeWidth ? config.nodeWidth * SECTION_INNER_PADDING : 960;
const height = config.nodeHeight ? config.nodeHeight * SECTION_INNER_PADDING : 500;
const svgWidth = width;
const svgHeight = height + titleHeight;
svg.attr("viewBox", `0 0 ${svgWidth} ${svgHeight}`);
configureSvgSize(svg, svgHeight, svgWidth, config.useMaxWidth);
let valueFormat;
try {
const formatStr = config.valueFormat || ",";
if (formatStr === "$0,0") {
valueFormat = /* @__PURE__ */ __name((value) => "$" + format(",")(value), "valueFormat");
} else if (formatStr.startsWith("$") && formatStr.includes(",")) {
const precision = /\.\d+/.exec(formatStr);
const precisionStr = precision ? precision[0] : "";
valueFormat = /* @__PURE__ */ __name((value) => "$" + format("," + precisionStr)(value), "valueFormat");
} else if (formatStr.startsWith("$")) {
const restOfFormat = formatStr.substring(1);
valueFormat = /* @__PURE__ */ __name((value) => "$" + format(restOfFormat || "")(value), "valueFormat");
} else {
valueFormat = format(formatStr);
}
} catch (error) {
log.error("Error creating format function:", error);
valueFormat = format(",");
}
const colorScale = ordinal().range([
"transparent",
themeVariables.cScale0,
themeVariables.cScale1,
themeVariables.cScale2,
themeVariables.cScale3,
themeVariables.cScale4,
themeVariables.cScale5,
themeVariables.cScale6,
themeVariables.cScale7,
themeVariables.cScale8,
themeVariables.cScale9,
themeVariables.cScale10,
themeVariables.cScale11
]);
const colorScalePeer = ordinal().range([
"transparent",
themeVariables.cScalePeer0,
themeVariables.cScalePeer1,
themeVariables.cScalePeer2,
themeVariables.cScalePeer3,
themeVariables.cScalePeer4,
themeVariables.cScalePeer5,
themeVariables.cScalePeer6,
themeVariables.cScalePeer7,
themeVariables.cScalePeer8,
themeVariables.cScalePeer9,
themeVariables.cScalePeer10,
themeVariables.cScalePeer11
]);
const colorScaleLabel = ordinal().range([
themeVariables.cScaleLabel0,
themeVariables.cScaleLabel1,
themeVariables.cScaleLabel2,
themeVariables.cScaleLabel3,
themeVariables.cScaleLabel4,
themeVariables.cScaleLabel5,
themeVariables.cScaleLabel6,
themeVariables.cScaleLabel7,
themeVariables.cScaleLabel8,
themeVariables.cScaleLabel9,
themeVariables.cScaleLabel10,
themeVariables.cScaleLabel11
]);
if (title) {
svg.append("text").attr("x", svgWidth / 2).attr("y", titleHeight / 2).attr("class", "treemapTitle").attr("text-anchor", "middle").attr("dominant-baseline", "middle").text(title);
}
const g = svg.append("g").attr("transform", `translate(0, ${titleHeight})`).attr("class", "treemapContainer");
const hierarchyRoot = hierarchy(root).sum((d) => d.value ?? 0).sort((a, b) => (b.value ?? 0) - (a.value ?? 0));
const treemapLayout = treemap_default().size([width, height]).paddingTop(
(d) => d.children && d.children.length > 0 ? SECTION_HEADER_HEIGHT + SECTION_INNER_PADDING : 0
).paddingInner(treemapInnerPadding).paddingLeft((d) => d.children && d.children.length > 0 ? SECTION_INNER_PADDING : 0).paddingRight((d) => d.children && d.children.length > 0 ? SECTION_INNER_PADDING : 0).paddingBottom((d) => d.children && d.children.length > 0 ? SECTION_INNER_PADDING : 0).round(true);
const treemapData = treemapLayout(hierarchyRoot);
const branchNodes = treemapData.descendants().filter((d) => d.children && d.children.length > 0);
const sections = g.selectAll(".treemapSection").data(branchNodes).enter().append("g").attr("class", "treemapSection").attr("transform", (d) => `translate(${d.x0},${d.y0})`);
sections.append("rect").attr("width", (d) => d.x1 - d.x0).attr("height", SECTION_HEADER_HEIGHT).attr("class", "treemapSectionHeader").attr("fill", "none").attr("fill-opacity", 0.6).attr("stroke-width", 0.6).attr("style", (d) => {
if (d.depth === 0) {
return "display: none;";
}
return "";
});
sections.append("clipPath").attr("id", (_d, i) => `clip-section-${id}-${i}`).append("rect").attr("width", (d) => Math.max(0, d.x1 - d.x0 - 12)).attr("height", SECTION_HEADER_HEIGHT);
sections.append("rect").attr("width", (d) => d.x1 - d.x0).attr("height", (d) => d.y1 - d.y0).attr("class", (_d, i) => {
return `treemapSection section${i}`;
}).attr("fill", (d) => colorScale(d.data.name)).attr("fill-opacity", 0.6).attr("stroke", (d) => colorScalePeer(d.data.name)).attr("stroke-width", 2).attr("stroke-opacity", 0.4).attr("style", (d) => {
if (d.depth === 0) {
return "display: none;";
}
const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
return styles.nodeStyles + ";" + styles.borderStyles.join(";");
});
sections.append("text").attr("class", "treemapSectionLabel").attr("x", 6).attr("y", SECTION_HEADER_HEIGHT / 2).attr("dominant-baseline", "middle").text((d) => d.depth === 0 ? "" : d.data.name).attr("font-weight", "bold").attr("style", (d) => {
if (d.depth === 0) {
return "display: none;";
}
const labelStyles = "dominant-baseline: middle; font-size: 12px; fill:" + colorScaleLabel(d.data.name) + "; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;";
const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
return labelStyles + styles.labelStyles.replace("color:", "fill:");
}).each(function(d) {
if (d.depth === 0) {
return;
}
const self = select_default(this);
const originalText = d.data.name;
self.text(originalText);
const totalHeaderWidth = d.x1 - d.x0;
const labelXPosition = 6;
let spaceForTextContent;
if (config.showValues !== false && d.value) {
const valueEndsAtXRelative = totalHeaderWidth - 10;
const estimatedValueTextActualWidth = 30;
const gapBetweenLabelAndValue = 10;
const labelMustEndBeforeX = valueEndsAtXRelative - estimatedValueTextActualWidth - gapBetweenLabelAndValue;
spaceForTextContent = labelMustEndBeforeX - labelXPosition;
} else {
const labelOwnRightPadding = 6;
spaceForTextContent = totalHeaderWidth - labelXPosition - labelOwnRightPadding;
}
const minimumWidthToDisplay = 15;
const actualAvailableWidth = Math.max(minimumWidthToDisplay, spaceForTextContent);
const textNode = self.node();
const currentTextContentLength = textNode.getComputedTextLength();
if (currentTextContentLength > actualAvailableWidth) {
const ellipsis = "...";
let currentTruncatedText = originalText;
while (currentTruncatedText.length > 0) {
currentTruncatedText = originalText.substring(0, currentTruncatedText.length - 1);
if (currentTruncatedText.length === 0) {
self.text(ellipsis);
if (textNode.getComputedTextLength() > actualAvailableWidth) {
self.text("");
}
break;
}
self.text(currentTruncatedText + ellipsis);
if (textNode.getComputedTextLength() <= actualAvailableWidth) {
break;
}
}
}
});
if (config.showValues !== false) {
sections.append("text").attr("class", "treemapSectionValue").attr("x", (d) => d.x1 - d.x0 - 10).attr("y", SECTION_HEADER_HEIGHT / 2).attr("text-anchor", "end").attr("dominant-baseline", "middle").text((d) => d.value ? valueFormat(d.value) : "").attr("font-style", "italic").attr("style", (d) => {
if (d.depth === 0) {
return "display: none;";
}
const labelStyles = "text-anchor: end; dominant-baseline: middle; font-size: 10px; fill:" + colorScaleLabel(d.data.name) + "; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;";
const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
return labelStyles + styles.labelStyles.replace("color:", "fill:");
});
}
const leafNodes = treemapData.leaves();
const cell = g.selectAll(".treemapLeafGroup").data(leafNodes).enter().append("g").attr("class", (d, i) => {
return `treemapNode treemapLeafGroup leaf${i}${d.data.classSelector ? ` ${d.data.classSelector}` : ""}x`;
}).attr("transform", (d) => `translate(${d.x0},${d.y0})`);
cell.append("rect").attr("width", (d) => d.x1 - d.x0).attr("height", (d) => d.y1 - d.y0).attr("class", "treemapLeaf").attr("fill", (d) => {
return d.parent ? colorScale(d.parent.data.name) : colorScale(d.data.name);
}).attr("style", (d) => {
const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
return styles.nodeStyles;
}).attr("fill-opacity", 0.3).attr("stroke", (d) => {
return d.parent ? colorScale(d.parent.data.name) : colorScale(d.data.name);
}).attr("stroke-width", 3);
cell.append("clipPath").attr("id", (_d, i) => `clip-${id}-${i}`).append("rect").attr("width", (d) => Math.max(0, d.x1 - d.x0 - 4)).attr("height", (d) => Math.max(0, d.y1 - d.y0 - 4));
const leafLabels = cell.append("text").attr("class", "treemapLabel").attr("x", (d) => (d.x1 - d.x0) / 2).attr("y", (d) => (d.y1 - d.y0) / 2).attr("style", (d) => {
const labelStyles = "text-anchor: middle; dominant-baseline: middle; font-size: 38px;fill:" + colorScaleLabel(d.data.name) + ";";
const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
return labelStyles + styles.labelStyles.replace("color:", "fill:");
}).attr("clip-path", (_d, i) => `url(#clip-${id}-${i})`).text((d) => d.data.name);
leafLabels.each(function(d) {
const self = select_default(this);
const nodeWidth = d.x1 - d.x0;
const nodeHeight = d.y1 - d.y0;
const textNode = self.node();
const padding = 4;
const availableWidth = nodeWidth - 2 * padding;
const availableHeight = nodeHeight - 2 * padding;
if (availableWidth < 10 || availableHeight < 10) {
self.style("display", "none");
return;
}
let currentLabelFontSize = parseInt(self.style("font-size"), 10);
const minLabelFontSize = 8;
const originalValueRelFontSize = 28;
const valueScaleFactor = 0.6;
const minValueFontSize = 6;
const spacingBetweenLabelAndValue = 2;
while (textNode.getComputedTextLength() > availableWidth && currentLabelFontSize > minLabelFontSize) {
currentLabelFontSize--;
self.style("font-size", `${currentLabelFontSize}px`);
}
let prospectiveValueFontSize = Math.max(
minValueFontSize,
Math.min(originalValueRelFontSize, Math.round(currentLabelFontSize * valueScaleFactor))
);
let combinedHeight = currentLabelFontSize + spacingBetweenLabelAndValue + prospectiveValueFontSize;
while (combinedHeight > availableHeight && currentLabelFontSize > minLabelFontSize) {
currentLabelFontSize--;
prospectiveValueFontSize = Math.max(
minValueFontSize,
Math.min(originalValueRelFontSize, Math.round(currentLabelFontSize * valueScaleFactor))
);
if (prospectiveValueFontSize < minValueFontSize && currentLabelFontSize === minLabelFontSize) {
break;
}
self.style("font-size", `${currentLabelFontSize}px`);
combinedHeight = currentLabelFontSize + spacingBetweenLabelAndValue + prospectiveValueFontSize;
if (prospectiveValueFontSize <= minValueFontSize && combinedHeight > availableHeight) {
}
}
self.style("font-size", `${currentLabelFontSize}px`);
if (textNode.getComputedTextLength() > availableWidth || currentLabelFontSize < minLabelFontSize || availableHeight < currentLabelFontSize) {
self.style("display", "none");
}
});
if (config.showValues !== false) {
const leafValues = cell.append("text").attr("class", "treemapValue").attr("x", (d) => (d.x1 - d.x0) / 2).attr("y", function(d) {
return (d.y1 - d.y0) / 2;
}).attr("style", (d) => {
const labelStyles = "text-anchor: middle; dominant-baseline: hanging; font-size: 28px;fill:" + colorScaleLabel(d.data.name) + ";";
const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
return labelStyles + styles.labelStyles.replace("color:", "fill:");
}).attr("clip-path", (_d, i) => `url(#clip-${id}-${i})`).text((d) => d.value ? valueFormat(d.value) : "");
leafValues.each(function(d) {
const valueTextElement = select_default(this);
const parentCellNode = this.parentNode;
if (!parentCellNode) {
valueTextElement.style("display", "none");
return;
}
const labelElement = select_default(parentCellNode).select(".treemapLabel");
if (labelElement.empty() || labelElement.style("display") === "none") {
valueTextElement.style("display", "none");
return;
}
const finalLabelFontSize = parseFloat(labelElement.style("font-size"));
const originalValueFontSize = 28;
const valueScaleFactor = 0.6;
const minValueFontSize = 6;
const spacingBetweenLabelAndValue = 2;
const actualValueFontSize = Math.max(
minValueFontSize,
Math.min(originalValueFontSize, Math.round(finalLabelFontSize * valueScaleFactor))
);
valueTextElement.style("font-size", `${actualValueFontSize}px`);
const labelCenterY = (d.y1 - d.y0) / 2;
const valueTopActualY = labelCenterY + finalLabelFontSize / 2 + spacingBetweenLabelAndValue;
valueTextElement.attr("y", valueTopActualY);
const nodeWidth = d.x1 - d.x0;
const nodeTotalHeight = d.y1 - d.y0;
const cellBottomPadding = 4;
const maxValueBottomY = nodeTotalHeight - cellBottomPadding;
const availableWidthForValue = nodeWidth - 2 * 4;
if (valueTextElement.node().getComputedTextLength() > availableWidthForValue || valueTopActualY + actualValueFontSize > maxValueBottomY || actualValueFontSize < minValueFontSize) {
valueTextElement.style("display", "none");
} else {
valueTextElement.style("display", null);
}
});
}
const diagramPadding = config.diagramPadding ?? 8;
setupViewPortForSVG(svg, diagramPadding, "flowchart", config?.useMaxWidth || false);
}, "draw");
var getClasses = /* @__PURE__ */ __name(function(_text, diagramObj) {
return diagramObj.db.getClasses();
}, "getClasses");
var renderer = { draw, getClasses };
// src/diagrams/treemap/styles.ts
var defaultTreemapStyleOptions = {
sectionStrokeColor: "black",
sectionStrokeWidth: "1",
sectionFillColor: "#efefef",
leafStrokeColor: "black",
leafStrokeWidth: "1",
leafFillColor: "#efefef",
labelColor: "black",
labelFontSize: "12px",
valueFontSize: "10px",
valueColor: "black",
titleColor: "black",
titleFontSize: "14px"
};
var getStyles = /* @__PURE__ */ __name(({
treemap
} = {}) => {
const options = cleanAndMerge(defaultTreemapStyleOptions, treemap);
return `
.treemapNode.section {
stroke: ${options.sectionStrokeColor};
stroke-width: ${options.sectionStrokeWidth};
fill: ${options.sectionFillColor};
}
.treemapNode.leaf {
stroke: ${options.leafStrokeColor};
stroke-width: ${options.leafStrokeWidth};
fill: ${options.leafFillColor};
}
.treemapLabel {
fill: ${options.labelColor};
font-size: ${options.labelFontSize};
}
.treemapValue {
fill: ${options.valueColor};
font-size: ${options.valueFontSize};
}
.treemapTitle {
fill: ${options.titleColor};
font-size: ${options.titleFontSize};
}
`;
}, "getStyles");
var styles_default = getStyles;
// src/diagrams/treemap/diagram.ts
var diagram = {
parser,
get db() {
return new TreeMapDB();
},
renderer,
styles: styles_default
};
export {
diagram
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,7 @@
{
"version": 3,
"sources": [],
"sourcesContent": [],
"mappings": "",
"names": []
}

View File

@@ -0,0 +1,7 @@
{
"version": 3,
"sources": [],
"sourcesContent": [],
"mappings": "",
"names": []
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,13 @@
import {
PacketModule,
createPacketServices
} from "./chunk-OBMQL7OE.mjs";
import "./chunk-S3MDV2AR.mjs";
import "./chunk-MFRUYFWM.mjs";
import "./chunk-UKL4YMJ2.mjs";
import "./chunk-3QJOF6JT.mjs";
import "./chunk-FQFHLQFH.mjs";
export {
PacketModule,
createPacketServices
};

View File

@@ -0,0 +1,236 @@
import {
populateCommonDb
} from "./chunk-WASTHULE.mjs";
import {
parse
} from "./chunk-6OSLE3NY.mjs";
import "./chunk-OBMQL7OE.mjs";
import "./chunk-BDXV45HO.mjs";
import "./chunk-ALB5NAU3.mjs";
import "./chunk-LYCWX5BJ.mjs";
import "./chunk-LIIAENVV.mjs";
import "./chunk-NUOAVMUD.mjs";
import {
selectSvgElement
} from "./chunk-NWP4V2O6.mjs";
import {
cleanAndMerge,
parseFontSize
} from "./chunk-XCSQNVCT.mjs";
import "./chunk-3OTVAOVH.mjs";
import {
clear,
configureSvgSize,
defaultConfig_default,
getAccDescription,
getAccTitle,
getConfig2 as getConfig,
getDiagramTitle,
setAccDescription,
setAccTitle,
setDiagramTitle
} from "./chunk-UKMXQNCB.mjs";
import {
arc_default,
log,
ordinal,
pie_default
} from "./chunk-GRVEB7DL.mjs";
import "./chunk-75NCXSTK.mjs";
import "./chunk-S3MDV2AR.mjs";
import "./chunk-MFRUYFWM.mjs";
import "./chunk-UKL4YMJ2.mjs";
import "./chunk-3QJOF6JT.mjs";
import {
__name
} from "./chunk-FQFHLQFH.mjs";
// src/diagrams/pie/pieDb.ts
var DEFAULT_PIE_CONFIG = defaultConfig_default.pie;
var DEFAULT_PIE_DB = {
sections: /* @__PURE__ */ new Map(),
showData: false,
config: DEFAULT_PIE_CONFIG
};
var sections = DEFAULT_PIE_DB.sections;
var showData = DEFAULT_PIE_DB.showData;
var config = structuredClone(DEFAULT_PIE_CONFIG);
var getConfig2 = /* @__PURE__ */ __name(() => structuredClone(config), "getConfig");
var clear2 = /* @__PURE__ */ __name(() => {
sections = /* @__PURE__ */ new Map();
showData = DEFAULT_PIE_DB.showData;
clear();
}, "clear");
var addSection = /* @__PURE__ */ __name(({ label, value }) => {
if (value < 0) {
throw new Error(
`"${label}" has invalid value: ${value}. Negative values are not allowed in pie charts. All slice values must be >= 0.`
);
}
if (!sections.has(label)) {
sections.set(label, value);
log.debug(`added new section: ${label}, with value: ${value}`);
}
}, "addSection");
var getSections = /* @__PURE__ */ __name(() => sections, "getSections");
var setShowData = /* @__PURE__ */ __name((toggle) => {
showData = toggle;
}, "setShowData");
var getShowData = /* @__PURE__ */ __name(() => showData, "getShowData");
var db = {
getConfig: getConfig2,
clear: clear2,
setDiagramTitle,
getDiagramTitle,
setAccTitle,
getAccTitle,
setAccDescription,
getAccDescription,
addSection,
getSections,
setShowData,
getShowData
};
// src/diagrams/pie/pieParser.ts
var populateDb = /* @__PURE__ */ __name((ast, db2) => {
populateCommonDb(ast, db2);
db2.setShowData(ast.showData);
ast.sections.map(db2.addSection);
}, "populateDb");
var parser = {
parse: /* @__PURE__ */ __name(async (input) => {
const ast = await parse("pie", input);
log.debug(ast);
populateDb(ast, db);
}, "parse")
};
// src/diagrams/pie/pieStyles.ts
var getStyles = /* @__PURE__ */ __name((options) => `
.pieCircle{
stroke: ${options.pieStrokeColor};
stroke-width : ${options.pieStrokeWidth};
opacity : ${options.pieOpacity};
}
.pieOuterCircle{
stroke: ${options.pieOuterStrokeColor};
stroke-width: ${options.pieOuterStrokeWidth};
fill: none;
}
.pieTitleText {
text-anchor: middle;
font-size: ${options.pieTitleTextSize};
fill: ${options.pieTitleTextColor};
font-family: ${options.fontFamily};
}
.slice {
font-family: ${options.fontFamily};
fill: ${options.pieSectionTextColor};
font-size:${options.pieSectionTextSize};
// fill: white;
}
.legend text {
fill: ${options.pieLegendTextColor};
font-family: ${options.fontFamily};
font-size: ${options.pieLegendTextSize};
}
`, "getStyles");
var pieStyles_default = getStyles;
// src/diagrams/pie/pieRenderer.ts
var createPieArcs = /* @__PURE__ */ __name((sections2) => {
const sum = [...sections2.values()].reduce((acc, val) => acc + val, 0);
const pieData = [...sections2.entries()].map(([label, value]) => ({ label, value })).filter((d) => d.value / sum * 100 >= 1).sort((a, b) => b.value - a.value);
const pie = pie_default().value((d) => d.value);
return pie(pieData);
}, "createPieArcs");
var draw = /* @__PURE__ */ __name((text, id, _version, diagObj) => {
log.debug("rendering pie chart\n" + text);
const db2 = diagObj.db;
const globalConfig = getConfig();
const pieConfig = cleanAndMerge(db2.getConfig(), globalConfig.pie);
const MARGIN = 40;
const LEGEND_RECT_SIZE = 18;
const LEGEND_SPACING = 4;
const height = 450;
const pieWidth = height;
const svg = selectSvgElement(id);
const group = svg.append("g");
group.attr("transform", "translate(" + pieWidth / 2 + "," + height / 2 + ")");
const { themeVariables } = globalConfig;
let [outerStrokeWidth] = parseFontSize(themeVariables.pieOuterStrokeWidth);
outerStrokeWidth ??= 2;
const textPosition = pieConfig.textPosition;
const radius = Math.min(pieWidth, height) / 2 - MARGIN;
const arcGenerator = arc_default().innerRadius(0).outerRadius(radius);
const labelArcGenerator = arc_default().innerRadius(radius * textPosition).outerRadius(radius * textPosition);
group.append("circle").attr("cx", 0).attr("cy", 0).attr("r", radius + outerStrokeWidth / 2).attr("class", "pieOuterCircle");
const sections2 = db2.getSections();
const arcs = createPieArcs(sections2);
const myGeneratedColors = [
themeVariables.pie1,
themeVariables.pie2,
themeVariables.pie3,
themeVariables.pie4,
themeVariables.pie5,
themeVariables.pie6,
themeVariables.pie7,
themeVariables.pie8,
themeVariables.pie9,
themeVariables.pie10,
themeVariables.pie11,
themeVariables.pie12
];
let sum = 0;
sections2.forEach((section) => {
sum += section;
});
const filteredArcs = arcs.filter((datum) => (datum.data.value / sum * 100).toFixed(0) !== "0");
const color = ordinal(myGeneratedColors);
group.selectAll("mySlices").data(filteredArcs).enter().append("path").attr("d", arcGenerator).attr("fill", (datum) => {
return color(datum.data.label);
}).attr("class", "pieCircle");
group.selectAll("mySlices").data(filteredArcs).enter().append("text").text((datum) => {
return (datum.data.value / sum * 100).toFixed(0) + "%";
}).attr("transform", (datum) => {
return "translate(" + labelArcGenerator.centroid(datum) + ")";
}).style("text-anchor", "middle").attr("class", "slice");
group.append("text").text(db2.getDiagramTitle()).attr("x", 0).attr("y", -(height - 50) / 2).attr("class", "pieTitleText");
const allSectionData = [...sections2.entries()].map(([label, value]) => ({
label,
value
}));
const legend = group.selectAll(".legend").data(allSectionData).enter().append("g").attr("class", "legend").attr("transform", (_datum, index) => {
const height2 = LEGEND_RECT_SIZE + LEGEND_SPACING;
const offset = height2 * allSectionData.length / 2;
const horizontal = 12 * LEGEND_RECT_SIZE;
const vertical = index * height2 - offset;
return "translate(" + horizontal + "," + vertical + ")";
});
legend.append("rect").attr("width", LEGEND_RECT_SIZE).attr("height", LEGEND_RECT_SIZE).style("fill", (d) => color(d.label)).style("stroke", (d) => color(d.label));
legend.append("text").attr("x", LEGEND_RECT_SIZE + LEGEND_SPACING).attr("y", LEGEND_RECT_SIZE - LEGEND_SPACING).text((d) => {
if (db2.getShowData()) {
return `${d.label} [${d.value}]`;
}
return d.label;
});
const longestTextWidth = Math.max(
...legend.selectAll("text").nodes().map((node) => node?.getBoundingClientRect().width ?? 0)
);
const totalWidth = pieWidth + MARGIN + LEGEND_RECT_SIZE + LEGEND_SPACING + longestTextWidth;
svg.attr("viewBox", `0 0 ${totalWidth} ${height}`);
configureSvgSize(svg, height, totalWidth, pieConfig.useMaxWidth);
}, "draw");
var renderer = { draw };
// src/diagrams/pie/pieDiagram.ts
var diagram = {
parser,
db,
renderer,
styles: pieStyles_default
};
export {
diagram
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,498 @@
import {
StateDB,
stateDiagram_default,
styles_default
} from "./chunk-3VXWS7DV.mjs";
import {
layout
} from "./chunk-6JEIXYVA.mjs";
import {
Graph
} from "./chunk-KACY6BU5.mjs";
import "./chunk-U2CUWHSV.mjs";
import "./chunk-M4FGLBOT.mjs";
import "./chunk-EKL7DDBO.mjs";
import "./chunk-TZW2344G.mjs";
import "./chunk-UYNZS3GD.mjs";
import "./chunk-UAL2TQZE.mjs";
import "./chunk-FWQXANIB.mjs";
import "./chunk-D2KOLKXV.mjs";
import "./chunk-TEV7DDKD.mjs";
import "./chunk-YHLHMBDM.mjs";
import {
utils_default
} from "./chunk-XCSQNVCT.mjs";
import "./chunk-3OTVAOVH.mjs";
import {
common_default,
configureSvgSize,
getConfig2 as getConfig,
getUrl
} from "./chunk-UKMXQNCB.mjs";
import {
basis_default,
line_default,
log,
select_default
} from "./chunk-GRVEB7DL.mjs";
import "./chunk-MFRUYFWM.mjs";
import "./chunk-UKL4YMJ2.mjs";
import "./chunk-3QJOF6JT.mjs";
import {
__name
} from "./chunk-FQFHLQFH.mjs";
// src/diagrams/state/shapes.js
var drawStartState = /* @__PURE__ */ __name((g) => g.append("circle").attr("class", "start-state").attr("r", getConfig().state.sizeUnit).attr("cx", getConfig().state.padding + getConfig().state.sizeUnit).attr("cy", getConfig().state.padding + getConfig().state.sizeUnit), "drawStartState");
var drawDivider = /* @__PURE__ */ __name((g) => g.append("line").style("stroke", "grey").style("stroke-dasharray", "3").attr("x1", getConfig().state.textHeight).attr("class", "divider").attr("x2", getConfig().state.textHeight * 2).attr("y1", 0).attr("y2", 0), "drawDivider");
var drawSimpleState = /* @__PURE__ */ __name((g, stateDef) => {
const state = g.append("text").attr("x", 2 * getConfig().state.padding).attr("y", getConfig().state.textHeight + 2 * getConfig().state.padding).attr("font-size", getConfig().state.fontSize).attr("class", "state-title").text(stateDef.id);
const classBox = state.node().getBBox();
g.insert("rect", ":first-child").attr("x", getConfig().state.padding).attr("y", getConfig().state.padding).attr("width", classBox.width + 2 * getConfig().state.padding).attr("height", classBox.height + 2 * getConfig().state.padding).attr("rx", getConfig().state.radius);
return state;
}, "drawSimpleState");
var drawDescrState = /* @__PURE__ */ __name((g, stateDef) => {
const addTspan = /* @__PURE__ */ __name(function(textEl, txt, isFirst2) {
const tSpan = textEl.append("tspan").attr("x", 2 * getConfig().state.padding).text(txt);
if (!isFirst2) {
tSpan.attr("dy", getConfig().state.textHeight);
}
}, "addTspan");
const title = g.append("text").attr("x", 2 * getConfig().state.padding).attr("y", getConfig().state.textHeight + 1.3 * getConfig().state.padding).attr("font-size", getConfig().state.fontSize).attr("class", "state-title").text(stateDef.descriptions[0]);
const titleBox = title.node().getBBox();
const titleHeight = titleBox.height;
const description = g.append("text").attr("x", getConfig().state.padding).attr(
"y",
titleHeight + getConfig().state.padding * 0.4 + getConfig().state.dividerMargin + getConfig().state.textHeight
).attr("class", "state-description");
let isFirst = true;
let isSecond = true;
stateDef.descriptions.forEach(function(descr) {
if (!isFirst) {
addTspan(description, descr, isSecond);
isSecond = false;
}
isFirst = false;
});
const descrLine = g.append("line").attr("x1", getConfig().state.padding).attr("y1", getConfig().state.padding + titleHeight + getConfig().state.dividerMargin / 2).attr("y2", getConfig().state.padding + titleHeight + getConfig().state.dividerMargin / 2).attr("class", "descr-divider");
const descrBox = description.node().getBBox();
const width = Math.max(descrBox.width, titleBox.width);
descrLine.attr("x2", width + 3 * getConfig().state.padding);
g.insert("rect", ":first-child").attr("x", getConfig().state.padding).attr("y", getConfig().state.padding).attr("width", width + 2 * getConfig().state.padding).attr("height", descrBox.height + titleHeight + 2 * getConfig().state.padding).attr("rx", getConfig().state.radius);
return g;
}, "drawDescrState");
var addTitleAndBox = /* @__PURE__ */ __name((g, stateDef, altBkg) => {
const pad = getConfig().state.padding;
const dblPad = 2 * getConfig().state.padding;
const orgBox = g.node().getBBox();
const orgWidth = orgBox.width;
const orgX = orgBox.x;
const title = g.append("text").attr("x", 0).attr("y", getConfig().state.titleShift).attr("font-size", getConfig().state.fontSize).attr("class", "state-title").text(stateDef.id);
const titleBox = title.node().getBBox();
const titleWidth = titleBox.width + dblPad;
let width = Math.max(titleWidth, orgWidth);
if (width === orgWidth) {
width = width + dblPad;
}
let startX;
const graphBox = g.node().getBBox();
if (stateDef.doc) {
}
startX = orgX - pad;
if (titleWidth > orgWidth) {
startX = (orgWidth - width) / 2 + pad;
}
if (Math.abs(orgX - graphBox.x) < pad && titleWidth > orgWidth) {
startX = orgX - (titleWidth - orgWidth) / 2;
}
const lineY = 1 - getConfig().state.textHeight;
g.insert("rect", ":first-child").attr("x", startX).attr("y", lineY).attr("class", altBkg ? "alt-composit" : "composit").attr("width", width).attr(
"height",
graphBox.height + getConfig().state.textHeight + getConfig().state.titleShift + 1
).attr("rx", "0");
title.attr("x", startX + pad);
if (titleWidth <= orgWidth) {
title.attr("x", orgX + (width - dblPad) / 2 - titleWidth / 2 + pad);
}
g.insert("rect", ":first-child").attr("x", startX).attr(
"y",
getConfig().state.titleShift - getConfig().state.textHeight - getConfig().state.padding
).attr("width", width).attr("height", getConfig().state.textHeight * 3).attr("rx", getConfig().state.radius);
g.insert("rect", ":first-child").attr("x", startX).attr(
"y",
getConfig().state.titleShift - getConfig().state.textHeight - getConfig().state.padding
).attr("width", width).attr("height", graphBox.height + 3 + 2 * getConfig().state.textHeight).attr("rx", getConfig().state.radius);
return g;
}, "addTitleAndBox");
var drawEndState = /* @__PURE__ */ __name((g) => {
g.append("circle").attr("class", "end-state-outer").attr("r", getConfig().state.sizeUnit + getConfig().state.miniPadding).attr(
"cx",
getConfig().state.padding + getConfig().state.sizeUnit + getConfig().state.miniPadding
).attr(
"cy",
getConfig().state.padding + getConfig().state.sizeUnit + getConfig().state.miniPadding
);
return g.append("circle").attr("class", "end-state-inner").attr("r", getConfig().state.sizeUnit).attr("cx", getConfig().state.padding + getConfig().state.sizeUnit + 2).attr("cy", getConfig().state.padding + getConfig().state.sizeUnit + 2);
}, "drawEndState");
var drawForkJoinState = /* @__PURE__ */ __name((g, stateDef) => {
let width = getConfig().state.forkWidth;
let height = getConfig().state.forkHeight;
if (stateDef.parentId) {
let tmp = width;
width = height;
height = tmp;
}
return g.append("rect").style("stroke", "black").style("fill", "black").attr("width", width).attr("height", height).attr("x", getConfig().state.padding).attr("y", getConfig().state.padding);
}, "drawForkJoinState");
var _drawLongText = /* @__PURE__ */ __name((_text, x, y, g) => {
let textHeight = 0;
const textElem = g.append("text");
textElem.style("text-anchor", "start");
textElem.attr("class", "noteText");
let text = _text.replace(/\r\n/g, "<br/>");
text = text.replace(/\n/g, "<br/>");
const lines = text.split(common_default.lineBreakRegex);
let tHeight = 1.25 * getConfig().state.noteMargin;
for (const line of lines) {
const txt = line.trim();
if (txt.length > 0) {
const span = textElem.append("tspan");
span.text(txt);
if (tHeight === 0) {
const textBounds = span.node().getBBox();
tHeight += textBounds.height;
}
textHeight += tHeight;
span.attr("x", x + getConfig().state.noteMargin);
span.attr("y", y + textHeight + 1.25 * getConfig().state.noteMargin);
}
}
return { textWidth: textElem.node().getBBox().width, textHeight };
}, "_drawLongText");
var drawNote = /* @__PURE__ */ __name((text, g) => {
g.attr("class", "state-note");
const note = g.append("rect").attr("x", 0).attr("y", getConfig().state.padding);
const rectElem = g.append("g");
const { textWidth, textHeight } = _drawLongText(text, 0, 0, rectElem);
note.attr("height", textHeight + 2 * getConfig().state.noteMargin);
note.attr("width", textWidth + getConfig().state.noteMargin * 2);
return note;
}, "drawNote");
var drawState = /* @__PURE__ */ __name(function(elem, stateDef) {
const id = stateDef.id;
const stateInfo = {
id,
label: stateDef.id,
width: 0,
height: 0
};
const g = elem.append("g").attr("id", id).attr("class", "stateGroup");
if (stateDef.type === "start") {
drawStartState(g);
}
if (stateDef.type === "end") {
drawEndState(g);
}
if (stateDef.type === "fork" || stateDef.type === "join") {
drawForkJoinState(g, stateDef);
}
if (stateDef.type === "note") {
drawNote(stateDef.note.text, g);
}
if (stateDef.type === "divider") {
drawDivider(g);
}
if (stateDef.type === "default" && stateDef.descriptions.length === 0) {
drawSimpleState(g, stateDef);
}
if (stateDef.type === "default" && stateDef.descriptions.length > 0) {
drawDescrState(g, stateDef);
}
const stateBox = g.node().getBBox();
stateInfo.width = stateBox.width + 2 * getConfig().state.padding;
stateInfo.height = stateBox.height + 2 * getConfig().state.padding;
return stateInfo;
}, "drawState");
var edgeCount = 0;
var drawEdge = /* @__PURE__ */ __name(function(elem, path, relation) {
const getRelationType = /* @__PURE__ */ __name(function(type) {
switch (type) {
case StateDB.relationType.AGGREGATION:
return "aggregation";
case StateDB.relationType.EXTENSION:
return "extension";
case StateDB.relationType.COMPOSITION:
return "composition";
case StateDB.relationType.DEPENDENCY:
return "dependency";
}
}, "getRelationType");
path.points = path.points.filter((p) => !Number.isNaN(p.y));
const lineData = path.points;
const lineFunction = line_default().x(function(d) {
return d.x;
}).y(function(d) {
return d.y;
}).curve(basis_default);
const svgPath = elem.append("path").attr("d", lineFunction(lineData)).attr("id", "edge" + edgeCount).attr("class", "transition");
let url = "";
if (getConfig().state.arrowMarkerAbsolute) {
url = getUrl(true);
}
svgPath.attr(
"marker-end",
"url(" + url + "#" + getRelationType(StateDB.relationType.DEPENDENCY) + "End)"
);
if (relation.title !== void 0) {
const label = elem.append("g").attr("class", "stateLabel");
const { x, y } = utils_default.calcLabelPosition(path.points);
const rows = common_default.getRows(relation.title);
let titleHeight = 0;
const titleRows = [];
let maxWidth = 0;
let minX = 0;
for (let i = 0; i <= rows.length; i++) {
const title = label.append("text").attr("text-anchor", "middle").text(rows[i]).attr("x", x).attr("y", y + titleHeight);
const boundsTmp = title.node().getBBox();
maxWidth = Math.max(maxWidth, boundsTmp.width);
minX = Math.min(minX, boundsTmp.x);
log.info(boundsTmp.x, x, y + titleHeight);
if (titleHeight === 0) {
const titleBox = title.node().getBBox();
titleHeight = titleBox.height;
log.info("Title height", titleHeight, y);
}
titleRows.push(title);
}
let boxHeight = titleHeight * rows.length;
if (rows.length > 1) {
const heightAdj = (rows.length - 1) * titleHeight * 0.5;
titleRows.forEach((title, i) => title.attr("y", y + i * titleHeight - heightAdj));
boxHeight = titleHeight * rows.length;
}
const bounds = label.node().getBBox();
label.insert("rect", ":first-child").attr("class", "box").attr("x", x - maxWidth / 2 - getConfig().state.padding / 2).attr("y", y - boxHeight / 2 - getConfig().state.padding / 2 - 3.5).attr("width", maxWidth + getConfig().state.padding).attr("height", boxHeight + getConfig().state.padding);
log.info(bounds);
}
edgeCount++;
}, "drawEdge");
// src/diagrams/state/stateRenderer.js
var conf;
var transformationLog = {};
var setConf = /* @__PURE__ */ __name(function() {
}, "setConf");
var insertMarkers = /* @__PURE__ */ __name(function(elem) {
elem.append("defs").append("marker").attr("id", "dependencyEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 19,7 L9,13 L14,7 L9,1 Z");
}, "insertMarkers");
var draw = /* @__PURE__ */ __name(function(text, id, _version, diagObj) {
conf = getConfig().state;
const securityLevel = getConfig().securityLevel;
let sandboxElement;
if (securityLevel === "sandbox") {
sandboxElement = select_default("#i" + id);
}
const root = securityLevel === "sandbox" ? select_default(sandboxElement.nodes()[0].contentDocument.body) : select_default("body");
const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document;
log.debug("Rendering diagram " + text);
const diagram2 = root.select(`[id='${id}']`);
insertMarkers(diagram2);
const rootDoc = diagObj.db.getRootDoc();
renderDoc(rootDoc, diagram2, void 0, false, root, doc, diagObj);
const padding = conf.padding;
const bounds = diagram2.node().getBBox();
const width = bounds.width + padding * 2;
const height = bounds.height + padding * 2;
const svgWidth = width * 1.75;
configureSvgSize(diagram2, height, svgWidth, conf.useMaxWidth);
diagram2.attr(
"viewBox",
`${bounds.x - conf.padding} ${bounds.y - conf.padding} ` + width + " " + height
);
}, "draw");
var getLabelWidth = /* @__PURE__ */ __name((text) => {
return text ? text.length * conf.fontSizeFactor : 1;
}, "getLabelWidth");
var renderDoc = /* @__PURE__ */ __name((doc, diagram2, parentId, altBkg, root, domDocument, diagObj) => {
const graph = new Graph({
compound: true,
multigraph: true
});
let i;
let edgeFreeDoc = true;
for (i = 0; i < doc.length; i++) {
if (doc[i].stmt === "relation") {
edgeFreeDoc = false;
break;
}
}
if (parentId) {
graph.setGraph({
rankdir: "LR",
multigraph: true,
compound: true,
// acyclicer: 'greedy',
ranker: "tight-tree",
ranksep: edgeFreeDoc ? 1 : conf.edgeLengthFactor,
nodeSep: edgeFreeDoc ? 1 : 50,
isMultiGraph: true
// ranksep: 5,
// nodesep: 1
});
} else {
graph.setGraph({
rankdir: "TB",
multigraph: true,
compound: true,
// isCompound: true,
// acyclicer: 'greedy',
// ranker: 'longest-path'
ranksep: edgeFreeDoc ? 1 : conf.edgeLengthFactor,
nodeSep: edgeFreeDoc ? 1 : 50,
ranker: "tight-tree",
// ranker: 'network-simplex'
isMultiGraph: true
});
}
graph.setDefaultEdgeLabel(function() {
return {};
});
const states = diagObj.db.getStates();
const relations = diagObj.db.getRelations();
const keys = Object.keys(states);
let first = true;
for (const key of keys) {
const stateDef = states[key];
if (parentId) {
stateDef.parentId = parentId;
}
let node;
if (stateDef.doc) {
let sub = diagram2.append("g").attr("id", stateDef.id).attr("class", "stateGroup");
node = renderDoc(stateDef.doc, sub, stateDef.id, !altBkg, root, domDocument, diagObj);
if (first) {
sub = addTitleAndBox(sub, stateDef, altBkg);
let boxBounds = sub.node().getBBox();
node.width = boxBounds.width;
node.height = boxBounds.height + conf.padding / 2;
transformationLog[stateDef.id] = { y: conf.compositTitleSize };
} else {
let boxBounds = sub.node().getBBox();
node.width = boxBounds.width;
node.height = boxBounds.height;
}
} else {
node = drawState(diagram2, stateDef, graph);
}
if (stateDef.note) {
const noteDef = {
descriptions: [],
id: stateDef.id + "-note",
note: stateDef.note,
type: "note"
};
const note = drawState(diagram2, noteDef, graph);
if (stateDef.note.position === "left of") {
graph.setNode(node.id + "-note", note);
graph.setNode(node.id, node);
} else {
graph.setNode(node.id, node);
graph.setNode(node.id + "-note", note);
}
graph.setParent(node.id, node.id + "-group");
graph.setParent(node.id + "-note", node.id + "-group");
} else {
graph.setNode(node.id, node);
}
}
log.debug("Count=", graph.nodeCount(), graph);
let cnt = 0;
relations.forEach(function(relation) {
cnt++;
log.debug("Setting edge", relation);
graph.setEdge(
relation.id1,
relation.id2,
{
relation,
width: getLabelWidth(relation.title),
height: conf.labelHeight * common_default.getRows(relation.title).length,
labelpos: "c"
},
"id" + cnt
);
});
layout(graph);
log.debug("Graph after layout", graph.nodes());
const svgElem = diagram2.node();
graph.nodes().forEach(function(v) {
if (v !== void 0 && graph.node(v) !== void 0) {
log.warn("Node " + v + ": " + JSON.stringify(graph.node(v)));
root.select("#" + svgElem.id + " #" + v).attr(
"transform",
"translate(" + (graph.node(v).x - graph.node(v).width / 2) + "," + (graph.node(v).y + (transformationLog[v] ? transformationLog[v].y : 0) - graph.node(v).height / 2) + " )"
);
root.select("#" + svgElem.id + " #" + v).attr("data-x-shift", graph.node(v).x - graph.node(v).width / 2);
const dividers = domDocument.querySelectorAll("#" + svgElem.id + " #" + v + " .divider");
dividers.forEach((divider) => {
const parent = divider.parentElement;
let pWidth = 0;
let pShift = 0;
if (parent) {
if (parent.parentElement) {
pWidth = parent.parentElement.getBBox().width;
}
pShift = parseInt(parent.getAttribute("data-x-shift"), 10);
if (Number.isNaN(pShift)) {
pShift = 0;
}
}
divider.setAttribute("x1", 0 - pShift + 8);
divider.setAttribute("x2", pWidth - pShift - 8);
});
} else {
log.debug("No Node " + v + ": " + JSON.stringify(graph.node(v)));
}
});
let stateBox = svgElem.getBBox();
graph.edges().forEach(function(e) {
if (e !== void 0 && graph.edge(e) !== void 0) {
log.debug("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(graph.edge(e)));
drawEdge(diagram2, graph.edge(e), graph.edge(e).relation);
}
});
stateBox = svgElem.getBBox();
const stateInfo = {
id: parentId ? parentId : "root",
label: parentId ? parentId : "root",
width: 0,
height: 0
};
stateInfo.width = stateBox.width + 2 * conf.padding;
stateInfo.height = stateBox.height + 2 * conf.padding;
log.debug("Doc rendered", stateInfo, graph);
return stateInfo;
}, "renderDoc");
var stateRenderer_default = {
setConf,
draw
};
// src/diagrams/state/stateDiagram.ts
var diagram = {
parser: stateDiagram_default,
get db() {
return new StateDB(1);
},
renderer: stateRenderer_default,
styles: styles_default,
init: /* @__PURE__ */ __name((cnf) => {
if (!cnf.state) {
cnf.state = {};
}
cnf.state.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
}, "init")
};
export {
diagram
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,13 @@
import {
TreemapModule,
createTreemapServices
} from "./chunk-NUOAVMUD.mjs";
import "./chunk-S3MDV2AR.mjs";
import "./chunk-MFRUYFWM.mjs";
import "./chunk-UKL4YMJ2.mjs";
import "./chunk-3QJOF6JT.mjs";
import "./chunk-FQFHLQFH.mjs";
export {
TreemapModule,
createTreemapServices
};

View File

@@ -0,0 +1,7 @@
{
"version": 3,
"sources": [],
"sourcesContent": [],
"mappings": "",
"names": []
}

File diff suppressed because one or more lines are too long