1 | import { D as k, x as v, l as f, E as N } from "./mermaid-9357f3d0.js";
|
2 | import { l as I } from "./line-a77fdd5a.js";
|
3 | let E = 0;
|
4 | const O = function(i, e, t, n, r) {
|
5 | const o = function(d) {
|
6 | switch (d) {
|
7 | case r.db.relationType.AGGREGATION:
|
8 | return "aggregation";
|
9 | case r.db.relationType.EXTENSION:
|
10 | return "extension";
|
11 | case r.db.relationType.COMPOSITION:
|
12 | return "composition";
|
13 | case r.db.relationType.DEPENDENCY:
|
14 | return "dependency";
|
15 | case r.db.relationType.LOLLIPOP:
|
16 | return "lollipop";
|
17 | }
|
18 | };
|
19 | e.points = e.points.filter((d) => !Number.isNaN(d.y));
|
20 | const l = e.points, g = I().x(function(d) {
|
21 | return d.x;
|
22 | }).y(function(d) {
|
23 | return d.y;
|
24 | }).curve(k), s = i.append("path").attr("d", g(l)).attr("id", "edge" + E).attr("class", "relation");
|
25 | let p = "";
|
26 | n.arrowMarkerAbsolute && (p = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search, p = p.replace(/\(/g, "\\("), p = p.replace(/\)/g, "\\)")), t.relation.lineType == 1 && s.attr("class", "relation dashed-line"), t.relation.lineType == 10 && s.attr("class", "relation dotted-line"), t.relation.type1 !== "none" && s.attr(
|
27 | "marker-start",
|
28 | "url(" + p + "#" + o(t.relation.type1) + "Start)"
|
29 | ), t.relation.type2 !== "none" && s.attr(
|
30 | "marker-end",
|
31 | "url(" + p + "#" + o(t.relation.type2) + "End)"
|
32 | );
|
33 | let h, a;
|
34 | const c = e.points.length;
|
35 | let b = v.calcLabelPosition(e.points);
|
36 | h = b.x, a = b.y;
|
37 | let u, m, B, T;
|
38 | if (c % 2 !== 0 && c > 1) {
|
39 | let d = v.calcCardinalityPosition(
|
40 | t.relation.type1 !== "none",
|
41 | e.points,
|
42 | e.points[0]
|
43 | ), w = v.calcCardinalityPosition(
|
44 | t.relation.type2 !== "none",
|
45 | e.points,
|
46 | e.points[c - 1]
|
47 | );
|
48 | f.debug("cardinality_1_point " + JSON.stringify(d)), f.debug("cardinality_2_point " + JSON.stringify(w)), u = d.x, m = d.y, B = w.x, T = w.y;
|
49 | }
|
50 | if (t.title !== void 0) {
|
51 | const d = i.append("g").attr("class", "classLabel"), w = d.append("text").attr("class", "label").attr("x", h).attr("y", a).attr("fill", "red").attr("text-anchor", "middle").text(t.title);
|
52 | window.label = w;
|
53 | const y = w.node().getBBox();
|
54 | d.insert("rect", ":first-child").attr("class", "box").attr("x", y.x - n.padding / 2).attr("y", y.y - n.padding / 2).attr("width", y.width + n.padding).attr("height", y.height + n.padding);
|
55 | }
|
56 | f.info("Rendering relation " + JSON.stringify(t)), t.relationTitle1 !== void 0 && t.relationTitle1 !== "none" && i.append("g").attr("class", "cardinality").append("text").attr("class", "type1").attr("x", u).attr("y", m).attr("fill", "black").attr("font-size", "6").text(t.relationTitle1), t.relationTitle2 !== void 0 && t.relationTitle2 !== "none" && i.append("g").attr("class", "cardinality").append("text").attr("class", "type2").attr("x", B).attr("y", T).attr("fill", "black").attr("font-size", "6").text(t.relationTitle2), E++;
|
57 | }, P = function(i, e, t, n) {
|
58 | f.debug("Rendering class ", e, t);
|
59 | const r = e.id, o = {
|
60 | id: r,
|
61 | label: e.id,
|
62 | width: 0,
|
63 | height: 0
|
64 | }, l = i.append("g").attr("id", n.db.lookUpDomId(r)).attr("class", "classGroup");
|
65 | let g;
|
66 | e.link ? g = l.append("svg:a").attr("xlink:href", e.link).attr("target", e.linkTarget).append("text").attr("y", t.textHeight + t.padding).attr("x", 0) : g = l.append("text").attr("y", t.textHeight + t.padding).attr("x", 0);
|
67 | let s = !0;
|
68 | e.annotations.forEach(function(x) {
|
69 | const H = g.append("tspan").text("«" + x + "»");
|
70 | s || H.attr("dy", t.textHeight), s = !1;
|
71 | });
|
72 | let p = C(e);
|
73 | const h = g.append("tspan").text(p).attr("class", "title");
|
74 | s || h.attr("dy", t.textHeight);
|
75 | const a = g.node().getBBox().height, c = l.append("line").attr("x1", 0).attr("y1", t.padding + a + t.dividerMargin / 2).attr("y2", t.padding + a + t.dividerMargin / 2), b = l.append("text").attr("x", t.padding).attr("y", a + t.dividerMargin + t.textHeight).attr("fill", "white").attr("class", "classText");
|
76 | s = !0, e.members.forEach(function(x) {
|
77 | S(b, x, s, t), s = !1;
|
78 | });
|
79 | const u = b.node().getBBox(), m = l.append("line").attr("x1", 0).attr("y1", t.padding + a + t.dividerMargin + u.height).attr("y2", t.padding + a + t.dividerMargin + u.height), B = l.append("text").attr("x", t.padding).attr("y", a + 2 * t.dividerMargin + u.height + t.textHeight).attr("fill", "white").attr("class", "classText");
|
80 | s = !0, e.methods.forEach(function(x) {
|
81 | S(B, x, s, t), s = !1;
|
82 | });
|
83 | const T = l.node().getBBox();
|
84 | var d = " ";
|
85 | e.cssClasses.length > 0 && (d = d + e.cssClasses.join(" "));
|
86 | const y = l.insert("rect", ":first-child").attr("x", 0).attr("y", 0).attr("width", T.width + 2 * t.padding).attr("height", T.height + t.padding + 0.5 * t.dividerMargin).attr("class", d).node().getBBox().width;
|
87 | return g.node().childNodes.forEach(function(x) {
|
88 | x.setAttribute("x", (y - x.getBBox().width) / 2);
|
89 | }), e.tooltip && g.insert("title").text(e.tooltip), c.attr("x2", y), m.attr("x2", y), o.width = y, o.height = T.height + t.padding + 0.5 * t.dividerMargin, o;
|
90 | }, C = function(i) {
|
91 | let e = i.id;
|
92 | return i.type && (e += "<" + i.type + ">"), e;
|
93 | }, A = function(i, e, t, n) {
|
94 | f.debug("Rendering note ", e, t);
|
95 | const r = e.id, o = {
|
96 | id: r,
|
97 | text: e.text,
|
98 | width: 0,
|
99 | height: 0
|
100 | }, l = i.append("g").attr("id", r).attr("class", "classGroup");
|
101 | let g = l.append("text").attr("y", t.textHeight + t.padding).attr("x", 0);
|
102 | const s = JSON.parse(`"${e.text}"`).split(`
|
103 | `);
|
104 | s.forEach(function(c) {
|
105 | f.debug(`Adding line: ${c}`), g.append("tspan").text(c).attr("class", "title").attr("dy", t.textHeight);
|
106 | });
|
107 | const p = l.node().getBBox(), a = l.insert("rect", ":first-child").attr("x", 0).attr("y", 0).attr("width", p.width + 2 * t.padding).attr(
|
108 | "height",
|
109 | p.height + s.length * t.textHeight + t.padding + 0.5 * t.dividerMargin
|
110 | ).node().getBBox().width;
|
111 | return g.node().childNodes.forEach(function(c) {
|
112 | c.setAttribute("x", (a - c.getBBox().width) / 2);
|
113 | }), o.width = a, o.height = p.height + s.length * t.textHeight + t.padding + 0.5 * t.dividerMargin, o;
|
114 | }, M = function(i) {
|
115 | let e = "", t = "", n = "", r = "", o = i.substring(0, 1), l = i.substring(i.length - 1, i.length);
|
116 | o.match(/[#+~-]/) && (r = o);
|
117 | let g = /[\s\w)~]/;
|
118 | l.match(g) || (t = _(l));
|
119 | const s = r === "" ? 0 : 1;
|
120 | let p = t === "" ? i.length : i.length - 1;
|
121 | i = i.substring(s, p);
|
122 | const h = i.indexOf("("), a = i.indexOf(")");
|
123 | if (h > 1 && a > h && a <= i.length) {
|
124 | let b = i.substring(0, h).trim();
|
125 | const u = i.substring(h + 1, a);
|
126 | if (e = r + b + "(" + N(u.trim()) + ")", a < i.length) {
|
127 | let m = i.substring(a + 1, a + 2);
|
128 | t === "" && !m.match(g) ? (t = _(m), n = i.substring(a + 2).trim()) : n = i.substring(a + 1).trim(), n !== "" && (n.charAt(0) === ":" && (n = n.substring(1).trim()), n = " : " + N(n), e += n);
|
129 | }
|
130 | } else
|
131 | e = r + N(i);
|
132 | return {
|
133 | displayText: e,
|
134 | cssStyle: t
|
135 | };
|
136 | }, S = function(i, e, t, n) {
|
137 | let r = M(e);
|
138 | const o = i.append("tspan").attr("x", n.padding).text(r.displayText);
|
139 | r.cssStyle !== "" && o.attr("style", r.cssStyle), t || o.attr("dy", n.textHeight);
|
140 | }, _ = function(i) {
|
141 | switch (i) {
|
142 | case "*":
|
143 | return "font-style:italic;";
|
144 | case "$":
|
145 | return "text-decoration:underline;";
|
146 | default:
|
147 | return "";
|
148 | }
|
149 | }, R = {
|
150 | getClassTitleString: C,
|
151 | drawClass: P,
|
152 | drawEdge: O,
|
153 | drawNote: A,
|
154 | parseMember: M
|
155 | };
|
156 | export {
|
157 | M as p,
|
158 | R as s
|
159 | };
|