UNPKG

24.3 kBJavaScriptView Raw
1import { d as db, p as parser } from "./flowDb-c1833063.js";
2import { select, curveLinear, line } from "d3";
3import { a as insertMarkers, e as insertNode, l as labelHelper, f as insertEdgeLabel, k as getLineFunctionsWithOffset, m as addEdgeMarkers } from "./edges-066a5561.js";
4import { l as log, F as getConfig, o as setupGraphViewbox, k as getStylesFromArray, n as interpolateToCurve, e as common } from "./mermaid-6dc72991.js";
5import ELK from "elkjs/lib/elk.bundled.js";
6import "./createText-ca0c5216.js";
7import "mdast-util-from-markdown";
8import "ts-dedent";
9import "dayjs";
10import "@braintree/sanitize-url";
11import "dompurify";
12import "khroma";
13import "lodash-es/memoize.js";
14import "lodash-es/merge.js";
15import "stylis";
16import "lodash-es/isEmpty.js";
17const findCommonAncestor = (id1, id2, treeData) => {
18 const { parentById } = treeData;
19 const visited = /* @__PURE__ */ new Set();
20 let currentId = id1;
21 while (currentId) {
22 visited.add(currentId);
23 if (currentId === id2) {
24 return currentId;
25 }
26 currentId = parentById[currentId];
27 }
28 currentId = id2;
29 while (currentId) {
30 if (visited.has(currentId)) {
31 return currentId;
32 }
33 currentId = parentById[currentId];
34 }
35 return "root";
36};
37const elk = new ELK();
38let portPos = {};
39const conf = {};
40let nodeDb = {};
41const addVertices = async function(vert, svgId, root, doc, diagObj, parentLookupDb, graph) {
42 const svg = root.select(`[id="${svgId}"]`);
43 const nodes = svg.insert("g").attr("class", "nodes");
44 const keys = Object.keys(vert);
45 await Promise.all(
46 keys.map(async function(id) {
47 const vertex = vert[id];
48 let classStr = "default";
49 if (vertex.classes.length > 0) {
50 classStr = vertex.classes.join(" ");
51 }
52 classStr = classStr + " flowchart-label";
53 const styles2 = getStylesFromArray(vertex.styles);
54 let vertexText = vertex.text !== void 0 ? vertex.text : vertex.id;
55 const labelData = { width: 0, height: 0 };
56 const ports = [
57 {
58 id: vertex.id + "-west",
59 layoutOptions: {
60 "port.side": "WEST"
61 }
62 },
63 {
64 id: vertex.id + "-east",
65 layoutOptions: {
66 "port.side": "EAST"
67 }
68 },
69 {
70 id: vertex.id + "-south",
71 layoutOptions: {
72 "port.side": "SOUTH"
73 }
74 },
75 {
76 id: vertex.id + "-north",
77 layoutOptions: {
78 "port.side": "NORTH"
79 }
80 }
81 ];
82 let radius = 0;
83 let _shape = "";
84 let layoutOptions = {};
85 switch (vertex.type) {
86 case "round":
87 radius = 5;
88 _shape = "rect";
89 break;
90 case "square":
91 _shape = "rect";
92 break;
93 case "diamond":
94 _shape = "question";
95 layoutOptions = {
96 portConstraints: "FIXED_SIDE"
97 };
98 break;
99 case "hexagon":
100 _shape = "hexagon";
101 break;
102 case "odd":
103 _shape = "rect_left_inv_arrow";
104 break;
105 case "lean_right":
106 _shape = "lean_right";
107 break;
108 case "lean_left":
109 _shape = "lean_left";
110 break;
111 case "trapezoid":
112 _shape = "trapezoid";
113 break;
114 case "inv_trapezoid":
115 _shape = "inv_trapezoid";
116 break;
117 case "odd_right":
118 _shape = "rect_left_inv_arrow";
119 break;
120 case "circle":
121 _shape = "circle";
122 break;
123 case "ellipse":
124 _shape = "ellipse";
125 break;
126 case "stadium":
127 _shape = "stadium";
128 break;
129 case "subroutine":
130 _shape = "subroutine";
131 break;
132 case "cylinder":
133 _shape = "cylinder";
134 break;
135 case "group":
136 _shape = "rect";
137 break;
138 case "doublecircle":
139 _shape = "doublecircle";
140 break;
141 default:
142 _shape = "rect";
143 }
144 const node = {
145 labelStyle: styles2.labelStyle,
146 shape: _shape,
147 labelText: vertexText,
148 labelType: vertex.labelType,
149 rx: radius,
150 ry: radius,
151 class: classStr,
152 style: styles2.style,
153 id: vertex.id,
154 link: vertex.link,
155 linkTarget: vertex.linkTarget,
156 tooltip: diagObj.db.getTooltip(vertex.id) || "",
157 domId: diagObj.db.lookUpDomId(vertex.id),
158 haveCallback: vertex.haveCallback,
159 width: vertex.type === "group" ? 500 : void 0,
160 dir: vertex.dir,
161 type: vertex.type,
162 props: vertex.props,
163 padding: getConfig().flowchart.padding
164 };
165 let boundingBox;
166 let nodeEl;
167 if (node.type !== "group") {
168 nodeEl = await insertNode(nodes, node, vertex.dir);
169 boundingBox = nodeEl.node().getBBox();
170 } else {
171 doc.createElementNS("http://www.w3.org/2000/svg", "text");
172 const { shapeSvg, bbox } = await labelHelper(nodes, node, void 0, true);
173 labelData.width = bbox.width;
174 labelData.wrappingWidth = getConfig().flowchart.wrappingWidth;
175 labelData.height = bbox.height;
176 labelData.labelNode = shapeSvg.node();
177 node.labelData = labelData;
178 }
179 const data = {
180 id: vertex.id,
181 ports: vertex.type === "diamond" ? ports : [],
182 // labelStyle: styles.labelStyle,
183 // shape: _shape,
184 layoutOptions,
185 labelText: vertexText,
186 labelData,
187 // labels: [{ text: vertexText }],
188 // rx: radius,
189 // ry: radius,
190 // class: classStr,
191 // style: styles.style,
192 // link: vertex.link,
193 // linkTarget: vertex.linkTarget,
194 // tooltip: diagObj.db.getTooltip(vertex.id) || '',
195 domId: diagObj.db.lookUpDomId(vertex.id),
196 // haveCallback: vertex.haveCallback,
197 width: boundingBox == null ? void 0 : boundingBox.width,
198 height: boundingBox == null ? void 0 : boundingBox.height,
199 // dir: vertex.dir,
200 type: vertex.type,
201 // props: vertex.props,
202 // padding: getConfig().flowchart.padding,
203 // boundingBox,
204 el: nodeEl,
205 parent: parentLookupDb.parentById[vertex.id]
206 };
207 nodeDb[node.id] = data;
208 })
209 );
210 return graph;
211};
212const getNextPosition = (position, edgeDirection, graphDirection) => {
213 const portPos2 = {
214 TB: {
215 in: {
216 north: "north"
217 },
218 out: {
219 south: "west",
220 west: "east",
221 east: "south"
222 }
223 },
224 LR: {
225 in: {
226 west: "west"
227 },
228 out: {
229 east: "south",
230 south: "north",
231 north: "east"
232 }
233 },
234 RL: {
235 in: {
236 east: "east"
237 },
238 out: {
239 west: "north",
240 north: "south",
241 south: "west"
242 }
243 },
244 BT: {
245 in: {
246 south: "south"
247 },
248 out: {
249 north: "east",
250 east: "west",
251 west: "north"
252 }
253 }
254 };
255 portPos2.TD = portPos2.TB;
256 return portPos2[graphDirection][edgeDirection][position];
257};
258const getNextPort = (node, edgeDirection, graphDirection) => {
259 log.info("getNextPort", { node, edgeDirection, graphDirection });
260 if (!portPos[node]) {
261 switch (graphDirection) {
262 case "TB":
263 case "TD":
264 portPos[node] = {
265 inPosition: "north",
266 outPosition: "south"
267 };
268 break;
269 case "BT":
270 portPos[node] = {
271 inPosition: "south",
272 outPosition: "north"
273 };
274 break;
275 case "RL":
276 portPos[node] = {
277 inPosition: "east",
278 outPosition: "west"
279 };
280 break;
281 case "LR":
282 portPos[node] = {
283 inPosition: "west",
284 outPosition: "east"
285 };
286 break;
287 }
288 }
289 const result = edgeDirection === "in" ? portPos[node].inPosition : portPos[node].outPosition;
290 if (edgeDirection === "in") {
291 portPos[node].inPosition = getNextPosition(
292 portPos[node].inPosition,
293 edgeDirection,
294 graphDirection
295 );
296 } else {
297 portPos[node].outPosition = getNextPosition(
298 portPos[node].outPosition,
299 edgeDirection,
300 graphDirection
301 );
302 }
303 return result;
304};
305const getEdgeStartEndPoint = (edge, dir) => {
306 let source = edge.start;
307 let target = edge.end;
308 const sourceId = source;
309 const targetId = target;
310 const startNode = nodeDb[source];
311 const endNode = nodeDb[target];
312 if (!startNode || !endNode) {
313 return { source, target };
314 }
315 if (startNode.type === "diamond") {
316 source = `${source}-${getNextPort(source, "out", dir)}`;
317 }
318 if (endNode.type === "diamond") {
319 target = `${target}-${getNextPort(target, "in", dir)}`;
320 }
321 return { source, target, sourceId, targetId };
322};
323const addEdges = function(edges, diagObj, graph, svg) {
324 log.info("abc78 edges = ", edges);
325 const labelsEl = svg.insert("g").attr("class", "edgeLabels");
326 let linkIdCnt = {};
327 let dir = diagObj.db.getDirection();
328 let defaultStyle;
329 let defaultLabelStyle;
330 if (edges.defaultStyle !== void 0) {
331 const defaultStyles = getStylesFromArray(edges.defaultStyle);
332 defaultStyle = defaultStyles.style;
333 defaultLabelStyle = defaultStyles.labelStyle;
334 }
335 edges.forEach(function(edge) {
336 const linkIdBase = "L-" + edge.start + "-" + edge.end;
337 if (linkIdCnt[linkIdBase] === void 0) {
338 linkIdCnt[linkIdBase] = 0;
339 log.info("abc78 new entry", linkIdBase, linkIdCnt[linkIdBase]);
340 } else {
341 linkIdCnt[linkIdBase]++;
342 log.info("abc78 new entry", linkIdBase, linkIdCnt[linkIdBase]);
343 }
344 let linkId = linkIdBase + "-" + linkIdCnt[linkIdBase];
345 log.info("abc78 new link id to be used is", linkIdBase, linkId, linkIdCnt[linkIdBase]);
346 const linkNameStart = "LS-" + edge.start;
347 const linkNameEnd = "LE-" + edge.end;
348 const edgeData = { style: "", labelStyle: "" };
349 edgeData.minlen = edge.length || 1;
350 if (edge.type === "arrow_open") {
351 edgeData.arrowhead = "none";
352 } else {
353 edgeData.arrowhead = "normal";
354 }
355 edgeData.arrowTypeStart = "arrow_open";
356 edgeData.arrowTypeEnd = "arrow_open";
357 switch (edge.type) {
358 case "double_arrow_cross":
359 edgeData.arrowTypeStart = "arrow_cross";
360 case "arrow_cross":
361 edgeData.arrowTypeEnd = "arrow_cross";
362 break;
363 case "double_arrow_point":
364 edgeData.arrowTypeStart = "arrow_point";
365 case "arrow_point":
366 edgeData.arrowTypeEnd = "arrow_point";
367 break;
368 case "double_arrow_circle":
369 edgeData.arrowTypeStart = "arrow_circle";
370 case "arrow_circle":
371 edgeData.arrowTypeEnd = "arrow_circle";
372 break;
373 }
374 let style = "";
375 let labelStyle = "";
376 switch (edge.stroke) {
377 case "normal":
378 style = "fill:none;";
379 if (defaultStyle !== void 0) {
380 style = defaultStyle;
381 }
382 if (defaultLabelStyle !== void 0) {
383 labelStyle = defaultLabelStyle;
384 }
385 edgeData.thickness = "normal";
386 edgeData.pattern = "solid";
387 break;
388 case "dotted":
389 edgeData.thickness = "normal";
390 edgeData.pattern = "dotted";
391 edgeData.style = "fill:none;stroke-width:2px;stroke-dasharray:3;";
392 break;
393 case "thick":
394 edgeData.thickness = "thick";
395 edgeData.pattern = "solid";
396 edgeData.style = "stroke-width: 3.5px;fill:none;";
397 break;
398 }
399 if (edge.style !== void 0) {
400 const styles2 = getStylesFromArray(edge.style);
401 style = styles2.style;
402 labelStyle = styles2.labelStyle;
403 }
404 edgeData.style = edgeData.style += style;
405 edgeData.labelStyle = edgeData.labelStyle += labelStyle;
406 if (edge.interpolate !== void 0) {
407 edgeData.curve = interpolateToCurve(edge.interpolate, curveLinear);
408 } else if (edges.defaultInterpolate !== void 0) {
409 edgeData.curve = interpolateToCurve(edges.defaultInterpolate, curveLinear);
410 } else {
411 edgeData.curve = interpolateToCurve(conf.curve, curveLinear);
412 }
413 if (edge.text === void 0) {
414 if (edge.style !== void 0) {
415 edgeData.arrowheadStyle = "fill: #333";
416 }
417 } else {
418 edgeData.arrowheadStyle = "fill: #333";
419 edgeData.labelpos = "c";
420 }
421 edgeData.labelType = edge.labelType;
422 edgeData.label = edge.text.replace(common.lineBreakRegex, "\n");
423 if (edge.style === void 0) {
424 edgeData.style = edgeData.style || "stroke: #333; stroke-width: 1.5px;fill:none;";
425 }
426 edgeData.labelStyle = edgeData.labelStyle.replace("color:", "fill:");
427 edgeData.id = linkId;
428 edgeData.classes = "flowchart-link " + linkNameStart + " " + linkNameEnd;
429 const labelEl = insertEdgeLabel(labelsEl, edgeData);
430 const { source, target, sourceId, targetId } = getEdgeStartEndPoint(edge, dir);
431 log.debug("abc78 source and target", source, target);
432 graph.edges.push({
433 id: "e" + edge.start + edge.end,
434 sources: [source],
435 targets: [target],
436 sourceId,
437 targetId,
438 labelEl,
439 labels: [
440 {
441 width: edgeData.width,
442 height: edgeData.height,
443 orgWidth: edgeData.width,
444 orgHeight: edgeData.height,
445 text: edgeData.label,
446 layoutOptions: {
447 "edgeLabels.inline": "true",
448 "edgeLabels.placement": "CENTER"
449 }
450 }
451 ],
452 edgeData
453 });
454 });
455 return graph;
456};
457const addMarkersToEdge = function(svgPath, edgeData, diagramType, arrowMarkerAbsolute, id) {
458 let url = "";
459 if (arrowMarkerAbsolute) {
460 url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search;
461 url = url.replace(/\(/g, "\\(");
462 url = url.replace(/\)/g, "\\)");
463 }
464 addEdgeMarkers(svgPath, edgeData, url, id, diagramType);
465};
466const getClasses = function(text, diagObj) {
467 log.info("Extracting classes");
468 return diagObj.db.getClasses();
469};
470const addSubGraphs = function(db2) {
471 const parentLookupDb = { parentById: {}, childrenById: {} };
472 const subgraphs = db2.getSubGraphs();
473 log.info("Subgraphs - ", subgraphs);
474 subgraphs.forEach(function(subgraph) {
475 subgraph.nodes.forEach(function(node) {
476 parentLookupDb.parentById[node] = subgraph.id;
477 if (parentLookupDb.childrenById[subgraph.id] === void 0) {
478 parentLookupDb.childrenById[subgraph.id] = [];
479 }
480 parentLookupDb.childrenById[subgraph.id].push(node);
481 });
482 });
483 subgraphs.forEach(function(subgraph) {
484 ({ id: subgraph.id });
485 if (parentLookupDb.parentById[subgraph.id] !== void 0) {
486 parentLookupDb.parentById[subgraph.id];
487 }
488 });
489 return parentLookupDb;
490};
491const calcOffset = function(src, dest, parentLookupDb) {
492 const ancestor = findCommonAncestor(src, dest, parentLookupDb);
493 if (ancestor === void 0 || ancestor === "root") {
494 return { x: 0, y: 0 };
495 }
496 const ancestorOffset = nodeDb[ancestor].offset;
497 return { x: ancestorOffset.posX, y: ancestorOffset.posY };
498};
499const insertEdge = function(edgesEl, edge, edgeData, diagObj, parentLookupDb, id) {
500 const offset = calcOffset(edge.sourceId, edge.targetId, parentLookupDb);
501 const src = edge.sections[0].startPoint;
502 const dest = edge.sections[0].endPoint;
503 const segments = edge.sections[0].bendPoints ? edge.sections[0].bendPoints : [];
504 const segPoints = segments.map((segment) => [segment.x + offset.x, segment.y + offset.y]);
505 const points = [
506 [src.x + offset.x, src.y + offset.y],
507 ...segPoints,
508 [dest.x + offset.x, dest.y + offset.y]
509 ];
510 const { x, y } = getLineFunctionsWithOffset(edge.edgeData);
511 const curve = line().x(x).y(y).curve(curveLinear);
512 const edgePath = edgesEl.insert("path").attr("d", curve(points)).attr("class", "path " + edgeData.classes).attr("fill", "none");
513 const edgeG = edgesEl.insert("g").attr("class", "edgeLabel");
514 const edgeWithLabel = select(edgeG.node().appendChild(edge.labelEl));
515 const box = edgeWithLabel.node().firstChild.getBoundingClientRect();
516 edgeWithLabel.attr("width", box.width);
517 edgeWithLabel.attr("height", box.height);
518 edgeG.attr(
519 "transform",
520 `translate(${edge.labels[0].x + offset.x}, ${edge.labels[0].y + offset.y})`
521 );
522 addMarkersToEdge(edgePath, edgeData, diagObj.type, diagObj.arrowMarkerAbsolute, id);
523};
524const insertChildren = (nodeArray, parentLookupDb) => {
525 nodeArray.forEach((node) => {
526 if (!node.children) {
527 node.children = [];
528 }
529 const childIds = parentLookupDb.childrenById[node.id];
530 if (childIds) {
531 childIds.forEach((childId) => {
532 node.children.push(nodeDb[childId]);
533 });
534 }
535 insertChildren(node.children, parentLookupDb);
536 });
537};
538const draw = async function(text, id, _version, diagObj) {
539 var _a;
540 diagObj.db.clear();
541 nodeDb = {};
542 portPos = {};
543 diagObj.db.setGen("gen-2");
544 diagObj.parser.parse(text);
545 const renderEl = select("body").append("div").attr("style", "height:400px").attr("id", "cy");
546 let graph = {
547 id: "root",
548 layoutOptions: {
549 "elk.hierarchyHandling": "INCLUDE_CHILDREN",
550 "org.eclipse.elk.padding": "[top=100, left=100, bottom=110, right=110]",
551 "elk.layered.spacing.edgeNodeBetweenLayers": "30",
552 // 'elk.layered.mergeEdges': 'true',
553 "elk.direction": "DOWN"
554 // 'elk.ports.sameLayerEdges': true,
555 // 'nodePlacement.strategy': 'SIMPLE',
556 },
557 children: [],
558 edges: []
559 };
560 log.info("Drawing flowchart using v3 renderer", elk);
561 let dir = diagObj.db.getDirection();
562 switch (dir) {
563 case "BT":
564 graph.layoutOptions["elk.direction"] = "UP";
565 break;
566 case "TB":
567 graph.layoutOptions["elk.direction"] = "DOWN";
568 break;
569 case "LR":
570 graph.layoutOptions["elk.direction"] = "RIGHT";
571 break;
572 case "RL":
573 graph.layoutOptions["elk.direction"] = "LEFT";
574 break;
575 }
576 const { securityLevel, flowchart: conf2 } = getConfig();
577 let sandboxElement;
578 if (securityLevel === "sandbox") {
579 sandboxElement = select("#i" + id);
580 }
581 const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
582 const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document;
583 const svg = root.select(`[id="${id}"]`);
584 const markers = ["point", "circle", "cross"];
585 insertMarkers(svg, markers, diagObj.type, id);
586 const vert = diagObj.db.getVertices();
587 let subG;
588 const subGraphs = diagObj.db.getSubGraphs();
589 log.info("Subgraphs - ", subGraphs);
590 for (let i = subGraphs.length - 1; i >= 0; i--) {
591 subG = subGraphs[i];
592 diagObj.db.addVertex(
593 subG.id,
594 { text: subG.title, type: subG.labelType },
595 "group",
596 void 0,
597 subG.classes,
598 subG.dir
599 );
600 }
601 const subGraphsEl = svg.insert("g").attr("class", "subgraphs");
602 const parentLookupDb = addSubGraphs(diagObj.db);
603 graph = await addVertices(vert, id, root, doc, diagObj, parentLookupDb, graph);
604 const edgesEl = svg.insert("g").attr("class", "edges edgePath");
605 const edges = diagObj.db.getEdges();
606 graph = addEdges(edges, diagObj, graph, svg);
607 const nodes = Object.keys(nodeDb);
608 nodes.forEach((nodeId) => {
609 const node = nodeDb[nodeId];
610 if (!node.parent) {
611 graph.children.push(node);
612 }
613 if (parentLookupDb.childrenById[nodeId] !== void 0) {
614 node.labels = [
615 {
616 text: node.labelText,
617 layoutOptions: {
618 "nodeLabels.placement": "[H_CENTER, V_TOP, INSIDE]"
619 },
620 width: node.labelData.width,
621 height: node.labelData.height
622 // width: 100,
623 // height: 100,
624 }
625 ];
626 delete node.x;
627 delete node.y;
628 delete node.width;
629 delete node.height;
630 }
631 });
632 insertChildren(graph.children, parentLookupDb);
633 log.info("after layout", JSON.stringify(graph, null, 2));
634 const g = await elk.layout(graph);
635 drawNodes(0, 0, g.children, svg, subGraphsEl, diagObj, 0);
636 log.info("after layout", g);
637 (_a = g.edges) == null ? void 0 : _a.map((edge) => {
638 insertEdge(edgesEl, edge, edge.edgeData, diagObj, parentLookupDb, id);
639 });
640 setupGraphViewbox({}, svg, conf2.diagramPadding, conf2.useMaxWidth);
641 renderEl.remove();
642};
643const drawNodes = (relX, relY, nodeArray, svg, subgraphsEl, diagObj, depth) => {
644 nodeArray.forEach(function(node) {
645 if (node) {
646 nodeDb[node.id].offset = {
647 posX: node.x + relX,
648 posY: node.y + relY,
649 x: relX,
650 y: relY,
651 depth,
652 width: node.width,
653 height: node.height
654 };
655 if (node.type === "group") {
656 const subgraphEl = subgraphsEl.insert("g").attr("class", "subgraph");
657 subgraphEl.insert("rect").attr("class", "subgraph subgraph-lvl-" + depth % 5 + " node").attr("x", node.x + relX).attr("y", node.y + relY).attr("width", node.width).attr("height", node.height);
658 const label = subgraphEl.insert("g").attr("class", "label");
659 const labelCentering = getConfig().flowchart.htmlLabels ? node.labelData.width / 2 : 0;
660 label.attr(
661 "transform",
662 `translate(${node.labels[0].x + relX + node.x + labelCentering}, ${node.labels[0].y + relY + node.y + 3})`
663 );
664 label.node().appendChild(node.labelData.labelNode);
665 log.info("Id (UGH)= ", node.type, node.labels);
666 } else {
667 log.info("Id (UGH)= ", node.id);
668 node.el.attr(
669 "transform",
670 `translate(${node.x + relX + node.width / 2}, ${node.y + relY + node.height / 2})`
671 );
672 }
673 }
674 });
675 nodeArray.forEach(function(node) {
676 if (node && node.type === "group") {
677 drawNodes(relX + node.x, relY + node.y, node.children, svg, subgraphsEl, diagObj, depth + 1);
678 }
679 });
680};
681const renderer = {
682 getClasses,
683 draw
684};
685const genSections = (options) => {
686 let sections = "";
687 for (let i = 0; i < 5; i++) {
688 sections += `
689 .subgraph-lvl-${i} {
690 fill: ${options[`surface${i}`]};
691 stroke: ${options[`surfacePeer${i}`]};
692 }
693 `;
694 }
695 return sections;
696};
697const getStyles = (options) => `.label {
698 font-family: ${options.fontFamily};
699 color: ${options.nodeTextColor || options.textColor};
700 }
701 .cluster-label text {
702 fill: ${options.titleColor};
703 }
704 .cluster-label span {
705 color: ${options.titleColor};
706 }
707
708 .label text,span {
709 fill: ${options.nodeTextColor || options.textColor};
710 color: ${options.nodeTextColor || options.textColor};
711 }
712
713 .node rect,
714 .node circle,
715 .node ellipse,
716 .node polygon,
717 .node path {
718 fill: ${options.mainBkg};
719 stroke: ${options.nodeBorder};
720 stroke-width: 1px;
721 }
722
723 .node .label {
724 text-align: center;
725 }
726 .node.clickable {
727 cursor: pointer;
728 }
729
730 .arrowheadPath {
731 fill: ${options.arrowheadColor};
732 }
733
734 .edgePath .path {
735 stroke: ${options.lineColor};
736 stroke-width: 2.0px;
737 }
738
739 .flowchart-link {
740 stroke: ${options.lineColor};
741 fill: none;
742 }
743
744 .edgeLabel {
745 background-color: ${options.edgeLabelBackground};
746 rect {
747 opacity: 0.85;
748 background-color: ${options.edgeLabelBackground};
749 fill: ${options.edgeLabelBackground};
750 }
751 text-align: center;
752 }
753
754 .cluster rect {
755 fill: ${options.clusterBkg};
756 stroke: ${options.clusterBorder};
757 stroke-width: 1px;
758 }
759
760 .cluster text {
761 fill: ${options.titleColor};
762 }
763
764 .cluster span {
765 color: ${options.titleColor};
766 }
767 /* .cluster div {
768 color: ${options.titleColor};
769 } */
770
771 div.mermaidTooltip {
772 position: absolute;
773 text-align: center;
774 max-width: 200px;
775 padding: 2px;
776 font-family: ${options.fontFamily};
777 font-size: 12px;
778 background: ${options.tertiaryColor};
779 border: 1px solid ${options.border2};
780 border-radius: 2px;
781 pointer-events: none;
782 z-index: 100;
783 }
784
785 .flowchartTitleText {
786 text-anchor: middle;
787 font-size: 18px;
788 fill: ${options.textColor};
789 }
790 .subgraph {
791 stroke-width:2;
792 rx:3;
793 }
794 // .subgraph-lvl-1 {
795 // fill:#ccc;
796 // // stroke:black;
797 // }
798
799 .flowchart-label text {
800 text-anchor: middle;
801 }
802
803 ${genSections(options)}
804`;
805const styles = getStyles;
806const diagram = {
807 db,
808 renderer,
809 parser,
810 styles
811};
812export {
813 diagram
814};