UNPKG

4.67 kBJavaScriptView Raw
1import { p as W, d as M, s as H } from "./styles-83c6d4e6.js";
2import { c as S, l as d, j as m, k as X } from "./mermaid-9357f3d0.js";
3import { G as Y, l as Z } from "./layout-816c0a3e.js";
4import { s as l } from "./svgDraw-c2b80d25.js";
5import "./line-a77fdd5a.js";
6import "./array-2ff2c7a6.js";
7import "./constant-2fe7eae5.js";
8let h = {};
9const g = 20, p = function(r) {
10 const o = Object.entries(h).find((k) => k[1].label === r);
11 if (o)
12 return o[0];
13}, D = function(r) {
14 r.append("defs").append("marker").attr("id", "extensionStart").attr("class", "extension").attr("refX", 0).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 1,7 L18,13 V 1 Z"), r.append("defs").append("marker").attr("id", "extensionEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 1,1 V 13 L18,7 Z"), r.append("defs").append("marker").attr("id", "compositionStart").attr("class", "extension").attr("refX", 0).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"), r.append("defs").append("marker").attr("id", "compositionEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"), r.append("defs").append("marker").attr("id", "aggregationStart").attr("class", "extension").attr("refX", 0).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"), r.append("defs").append("marker").attr("id", "aggregationEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"), r.append("defs").append("marker").attr("id", "dependencyStart").attr("class", "extension").attr("refX", 0).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 5,7 L9,13 L1,7 L9,1 Z"), r.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 18,7 L9,13 L14,7 L9,1 Z");
15}, $ = function(r, o, k, a) {
16 const c = S().class;
17 h = {}, d.info("Rendering diagram " + r);
18 const L = S().securityLevel;
19 let y;
20 L === "sandbox" && (y = m("#i" + o));
21 const x = L === "sandbox" ? m(y.nodes()[0].contentDocument.body) : m("body"), n = x.select(`[id='${o}']`);
22 D(n);
23 const e = new Y({
24 multigraph: !0
25 });
26 e.setGraph({
27 isMultiGraph: !0
28 }), e.setDefaultEdgeLabel(function() {
29 return {};
30 });
31 const u = a.db.getClasses(), N = Object.keys(u);
32 for (const t of N) {
33 const s = u[t], i = l.drawClass(n, s, c, a);
34 h[i.id] = i, e.setNode(i.id, i), d.info("Org height: " + i.height);
35 }
36 a.db.getRelations().forEach(function(t) {
37 d.info(
38 "tjoho" + p(t.id1) + p(t.id2) + JSON.stringify(t)
39 ), e.setEdge(
40 p(t.id1),
41 p(t.id2),
42 {
43 relation: t
44 },
45 t.title || "DEFAULT"
46 );
47 }), a.db.getNotes().forEach(function(t) {
48 d.debug(`Adding note: ${JSON.stringify(t)}`);
49 const s = l.drawNote(n, t, c, a);
50 h[s.id] = s, e.setNode(s.id, s), t.class && t.class in u && e.setEdge(
51 t.id,
52 p(t.class),
53 {
54 relation: {
55 id1: t.id,
56 id2: t.class,
57 relation: {
58 type1: "none",
59 type2: "none",
60 lineType: 10
61 }
62 }
63 },
64 "DEFAULT"
65 );
66 }), Z(e), e.nodes().forEach(function(t) {
67 t !== void 0 && e.node(t) !== void 0 && (d.debug("Node " + t + ": " + JSON.stringify(e.node(t))), x.select("#" + (a.db.lookUpDomId(t) || t)).attr(
68 "transform",
69 "translate(" + (e.node(t).x - e.node(t).width / 2) + "," + (e.node(t).y - e.node(t).height / 2) + " )"
70 ));
71 }), e.edges().forEach(function(t) {
72 t !== void 0 && e.edge(t) !== void 0 && (d.debug("Edge " + t.v + " -> " + t.w + ": " + JSON.stringify(e.edge(t))), l.drawEdge(n, e.edge(t), e.edge(t).relation, c, a));
73 });
74 const f = n.node().getBBox(), E = f.width + g * 2, b = f.height + g * 2;
75 X(n, b, E, c.useMaxWidth);
76 const w = `${f.x - g} ${f.y - g} ${E} ${b}`;
77 d.debug(`viewBox ${w}`), n.attr("viewBox", w);
78}, B = {
79 draw: $
80}, V = {
81 parser: W,
82 db: M,
83 renderer: B,
84 styles: H,
85 init: (r) => {
86 r.class || (r.class = {}), r.class.arrowMarkerAbsolute = r.arrowMarkerAbsolute, M.clear();
87 }
88};
89export {
90 V as diagram
91};