1 | import { aq as lineBreakRegex, e as dist } from "./mermaid-dcacb631.js";
|
2 | const drawRect = (element, rectData) => {
|
3 | const rectElement = element.append("rect");
|
4 | rectElement.attr("x", rectData.x);
|
5 | rectElement.attr("y", rectData.y);
|
6 | rectElement.attr("fill", rectData.fill);
|
7 | rectElement.attr("stroke", rectData.stroke);
|
8 | rectElement.attr("width", rectData.width);
|
9 | rectElement.attr("height", rectData.height);
|
10 | if (rectData.name) {
|
11 | rectElement.attr("name", rectData.name);
|
12 | }
|
13 | rectData.rx !== void 0 && rectElement.attr("rx", rectData.rx);
|
14 | rectData.ry !== void 0 && rectElement.attr("ry", rectData.ry);
|
15 | if (rectData.attrs !== void 0) {
|
16 | for (const attrKey in rectData.attrs) {
|
17 | rectElement.attr(attrKey, rectData.attrs[attrKey]);
|
18 | }
|
19 | }
|
20 | rectData.class !== void 0 && rectElement.attr("class", rectData.class);
|
21 | return rectElement;
|
22 | };
|
23 | const drawBackgroundRect = (element, bounds) => {
|
24 | const rectData = {
|
25 | x: bounds.startx,
|
26 | y: bounds.starty,
|
27 | width: bounds.stopx - bounds.startx,
|
28 | height: bounds.stopy - bounds.starty,
|
29 | fill: bounds.fill,
|
30 | stroke: bounds.stroke,
|
31 | class: "rect"
|
32 | };
|
33 | const rectElement = drawRect(element, rectData);
|
34 | rectElement.lower();
|
35 | };
|
36 | const drawText = (element, textData) => {
|
37 | const nText = textData.text.replace(lineBreakRegex, " ");
|
38 | const textElem = element.append("text");
|
39 | textElem.attr("x", textData.x);
|
40 | textElem.attr("y", textData.y);
|
41 | textElem.attr("class", "legend");
|
42 | textElem.style("text-anchor", textData.anchor);
|
43 | textData.class !== void 0 && textElem.attr("class", textData.class);
|
44 | const tspan = textElem.append("tspan");
|
45 | tspan.attr("x", textData.x + textData.textMargin * 2);
|
46 | tspan.text(nText);
|
47 | return textElem;
|
48 | };
|
49 | const drawImage = (elem, x, y, link) => {
|
50 | const imageElement = elem.append("image");
|
51 | imageElement.attr("x", x);
|
52 | imageElement.attr("y", y);
|
53 | const sanitizedLink = dist.sanitizeUrl(link);
|
54 | imageElement.attr("xlink:href", sanitizedLink);
|
55 | };
|
56 | const drawEmbeddedImage = (element, x, y, link) => {
|
57 | const imageElement = element.append("use");
|
58 | imageElement.attr("x", x);
|
59 | imageElement.attr("y", y);
|
60 | const sanitizedLink = dist.sanitizeUrl(link);
|
61 | imageElement.attr("xlink:href", `#${sanitizedLink}`);
|
62 | };
|
63 | const getNoteRect = () => {
|
64 | const noteRectData = {
|
65 | x: 0,
|
66 | y: 0,
|
67 | width: 100,
|
68 | height: 100,
|
69 | fill: "#EDF2AE",
|
70 | stroke: "#666",
|
71 | anchor: "start",
|
72 | rx: 0,
|
73 | ry: 0
|
74 | };
|
75 | return noteRectData;
|
76 | };
|
77 | const getTextObj = () => {
|
78 | const testObject = {
|
79 | x: 0,
|
80 | y: 0,
|
81 | width: 100,
|
82 | height: 100,
|
83 | "text-anchor": "start",
|
84 | style: "#666",
|
85 | textMargin: 0,
|
86 | rx: 0,
|
87 | ry: 0,
|
88 | tspan: true
|
89 | };
|
90 | return testObject;
|
91 | };
|
92 | export {
|
93 | drawBackgroundRect as a,
|
94 | drawEmbeddedImage as b,
|
95 | drawImage as c,
|
96 | drawRect as d,
|
97 | getTextObj as e,
|
98 | drawText as f,
|
99 | getNoteRect as g
|
100 | };
|