@8btc/xcanvas 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/README.md +70 -0
  2. package/dist/Tableau10-BqnYsPR6.js +9 -0
  3. package/dist/XCanvas-BxdLBkBz.js +27732 -0
  4. package/dist/_commonjs-dynamic-modules-TGKdzP3c.js +6 -0
  5. package/dist/ar-SA-G6X2FPQ2-DjqDLLYL.js +41 -0
  6. package/dist/arc-D1qX5GFf.js +132 -0
  7. package/dist/array-DgktLKBx.js +6 -0
  8. package/dist/az-AZ-76LH7QW2-D7LOsF3_.js +32 -0
  9. package/dist/bg-BG-XCXSNQG7-WI4tFn23.js +36 -0
  10. package/dist/blockDiagram-38ab4fdb-DtemKfEh.js +1811 -0
  11. package/dist/bn-BD-2XOGV67Q-Bugx_8fy.js +36 -0
  12. package/dist/c4Diagram-3d4e48cf-Byd2vU9K.js +2463 -0
  13. package/dist/ca-ES-6MX7JW3Y-6rFwKGsQ.js +39 -0
  14. package/dist/channel-BT_3Ze-Y.js +7 -0
  15. package/dist/chunk-EIO257PC-C7qD7hGu.js +1641 -0
  16. package/dist/classDiagram-70f12bd4-CwfYadk-.js +354 -0
  17. package/dist/classDiagram-v2-f2320105-B28MuM8f.js +284 -0
  18. package/dist/clone-D2FUK8WY.js +8 -0
  19. package/dist/createText-2e5e7dd3-Ca1JfQaJ.js +4914 -0
  20. package/dist/cs-CZ-2BRQDIVT-Dhd8XszK.js +42 -0
  21. package/dist/da-DK-5WZEPLOC-BhL87sSs.js +36 -0
  22. package/dist/de-DE-XR44H4JA-xSrZSV0J.js +39 -0
  23. package/dist/directory-open-01563666-XowynPwH.js +14 -0
  24. package/dist/directory-open-4ed118d0-BwYbu9dw.js +55 -0
  25. package/dist/edges-e0da2a9e-9VbVapWU.js +1840 -0
  26. package/dist/el-GR-BZB4AONW-DQORZ_pY.js +41 -0
  27. package/dist/en-B4ZKOASM-D2BVbEdz.js +39 -0
  28. package/dist/erDiagram-9861fffd-D4S9QDes.js +1318 -0
  29. package/dist/es-ES-U4NZUMDT-C0Q89-0V.js +40 -0
  30. package/dist/eu-ES-A7QVB2H4-BwBW3cEw.js +42 -0
  31. package/dist/fa-IR-HGAKTJCU-DtZ74rm4.js +39 -0
  32. package/dist/fi-FI-Z5N7JZ37-QvQan48z.js +37 -0
  33. package/dist/file-open-002ab408-BNIYSKAV.js +18 -0
  34. package/dist/file-open-7c801643-B_l1UXdI.js +15 -0
  35. package/dist/file-save-3189631c-vzijizFw.js +23 -0
  36. package/dist/file-save-745eba88-B5-wM56X.js +25 -0
  37. package/dist/flowDb-956e92f1-S6T8ppJw.js +1713 -0
  38. package/dist/flowDiagram-66a62f08-C6TTwS5_.js +1264 -0
  39. package/dist/flowDiagram-v2-96b9c2cf-CzfeUNGP.js +24 -0
  40. package/dist/flowchart-elk-definition-4a651766-CRv1kWtk.js +92922 -0
  41. package/dist/fr-FR-RHASNOE6-CZFiweNU.js +40 -0
  42. package/dist/ganttDiagram-c361ad54-CAnfd8Sw.js +3420 -0
  43. package/dist/gitGraphDiagram-72cf32ee-CSGI-xRI.js +1790 -0
  44. package/dist/gl-ES-HMX3MZ6V-Bqv2xL-V.js +41 -0
  45. package/dist/graph-Ct2tKpKj.js +1253 -0
  46. package/dist/he-IL-6SHJWFNN-kso30jhn.js +41 -0
  47. package/dist/hi-IN-IWLTKZ5I-Busk5oaa.js +35 -0
  48. package/dist/hu-HU-A5ZG7DT2-xSR2C2H0.js +38 -0
  49. package/dist/id-ID-SAP4L64H-BQQZYm1L.js +41 -0
  50. package/dist/image-EDRW2JGV-Cx7o2kxD.js +6 -0
  51. package/dist/image-blob-reduce.esm-BKPqMdie.js +2396 -0
  52. package/dist/index-3862675e-B3j3w-v_.js +663 -0
  53. package/dist/index-CLOU2Ikr.js +14364 -0
  54. package/dist/index.css +450 -0
  55. package/dist/index.d.ts +40 -0
  56. package/dist/index.js +7 -0
  57. package/dist/index.umd.cjs +235477 -0
  58. package/dist/infoDiagram-f8f76790-NqA75uBo.js +510 -0
  59. package/dist/init-ZxktEp_H.js +16 -0
  60. package/dist/it-IT-JPQ66NNP-CAMVZrYt.js +42 -0
  61. package/dist/ja-JP-DBVTYXUO-CAX8A_Uj.js +39 -0
  62. package/dist/journeyDiagram-49397b02-By5oBzsZ.js +1182 -0
  63. package/dist/kaa-6HZHGXH3-4-o94cPY.js +32 -0
  64. package/dist/kab-KAB-ZGHBKWFO-CgyjjBvZ.js +39 -0
  65. package/dist/katex-C-jAQc2m.js +14516 -0
  66. package/dist/kk-KZ-P5N5QNE5-BEqZcwLA.js +32 -0
  67. package/dist/km-KH-HSX4SM5Z-DvKDbeH4.js +42 -0
  68. package/dist/ko-KR-MTYHY66A-DKCuAbKE.js +40 -0
  69. package/dist/ku-TR-6OUDTVRD-CNUs4cCe.js +40 -0
  70. package/dist/layout-AJxYKqQV.js +2292 -0
  71. package/dist/line-DJIf5OM8.js +45 -0
  72. package/dist/linear-Cfj4s4vI.js +539 -0
  73. package/dist/lt-LT-XHIRWOB4-gouzGdoW.js +34 -0
  74. package/dist/lv-LV-5QDEKY6T-CTvg1XFv.js +38 -0
  75. package/dist/mindmap-definition-fc14e90a-CBlwH_UF.js +35283 -0
  76. package/dist/mr-IN-CRQNXWMA-QeYm06Kq.js +44 -0
  77. package/dist/my-MM-5M5IBNSE-DG3k9ORf.js +32 -0
  78. package/dist/nb-NO-T6EIAALU-Cj995Nmg.js +41 -0
  79. package/dist/nl-NL-IS3SIHDZ-B-2H7xey.js +39 -0
  80. package/dist/nn-NO-6E72VCQL-DrAwKKTN.js +39 -0
  81. package/dist/oc-FR-POXYY2M6-CeyJD7tq.js +39 -0
  82. package/dist/ordinal-DSZU4PqD.js +76 -0
  83. package/dist/pa-IN-N4M65BXN-DHzi6mjo.js +35 -0
  84. package/dist/path-Cp2qmpkd.js +109 -0
  85. package/dist/percentages-BXMCSKIN-CDYsTuua.js +6 -0
  86. package/dist/pica-CzzcRNRD.js +1702 -0
  87. package/dist/pieDiagram-8a3498a8-DueGoZOh.js +768 -0
  88. package/dist/pl-PL-T2D74RX3-BBNEV2c6.js +40 -0
  89. package/dist/pt-BR-5N22H2LF-D2cTx_F0.js +40 -0
  90. package/dist/pt-PT-UZXXM6DQ-BddvLLsF.js +40 -0
  91. package/dist/quadrantDiagram-120e2f19-Tb6_oGIn.js +1198 -0
  92. package/dist/requirementDiagram-deff3bca-CEeg0ep-.js +1089 -0
  93. package/dist/ro-RO-JPDTUUEW-DynuW50i.js +42 -0
  94. package/dist/roundRect-CjfubgrN.js +152 -0
  95. package/dist/ru-RU-B4JR7IUQ-B5Hecrew.js +40 -0
  96. package/dist/sankeyDiagram-04a897e0-CGTLQ8Gm.js +1172 -0
  97. package/dist/sequenceDiagram-704730f1-CZ72D-Nd.js +3336 -0
  98. package/dist/si-LK-N5RQ5JYF-BGMa93tc.js +32 -0
  99. package/dist/sk-SK-C5VTKIMK-BttCAlBm.js +37 -0
  100. package/dist/sl-SI-NN7IZMDC-DTC59nzG.js +37 -0
  101. package/dist/stateDiagram-587899a1-XISZzz_f.js +451 -0
  102. package/dist/stateDiagram-v2-d93cdb3a-DbCcmzTc.js +319 -0
  103. package/dist/styles-6aaf32cf-CyfdkEib.js +1363 -0
  104. package/dist/styles-9a916d00-zQ92RrTB.js +1483 -0
  105. package/dist/styles-c10674c1-BWmkigmR.js +571 -0
  106. package/dist/subset-shared.chunk-BuFt2PpZ.js +8 -0
  107. package/dist/subset-worker.chunk-CgaFXU4O.js +14 -0
  108. package/dist/sv-SE-XGPEYMSR-BPDlPxC1.js +41 -0
  109. package/dist/svgDrawCommon-08f97a94-CJ0lufOi.js +100 -0
  110. package/dist/ta-IN-2NMHFXQM-CI1ZsNk9.js +40 -0
  111. package/dist/th-TH-HPSO5L25-CUM-w2Qt.js +33 -0
  112. package/dist/timeline-definition-85554ec2-DV6084Gl.js +1210 -0
  113. package/dist/tr-TR-DEFEU3FU-CGpyf_vD.js +38 -0
  114. package/dist/uk-UA-QMV73CPH-Bg15Mv3J.js +37 -0
  115. package/dist/vi-VN-M7AON7JQ-AYmca9so.js +36 -0
  116. package/dist/vite.svg +1 -0
  117. package/dist/xychartDiagram-e933f94c-P1e6EEaH.js +1796 -0
  118. package/dist/zh-CN-LNUGB5OW-Dem2Cc-c.js +41 -0
  119. package/dist/zh-HK-E62DVLB3-BjsDyiLI.js +32 -0
  120. package/dist/zh-TW-RAJ6MFWO-IDAsc9Pz.js +40 -0
  121. package/package.json +52 -0
@@ -0,0 +1,354 @@
1
+ import { s as styles, d as db, p as parser$1 } from "./styles-9a916d00-zQ92RrTB.js";
2
+ import { g as getConfig, l as log$1, d as select, e as configureSvgSize, t as curveBasis, u as utils, Y as parseGenericTypes } from "./index-CLOU2Ikr.js";
3
+ import { G as Graph } from "./graph-Ct2tKpKj.js";
4
+ import { l as layout } from "./layout-AJxYKqQV.js";
5
+ import { l as line } from "./line-DJIf5OM8.js";
6
+ let edgeCount = 0;
7
+ const drawEdge = function(elem, path, relation, conf, diagObj) {
8
+ const getRelationType = function(type) {
9
+ switch (type) {
10
+ case diagObj.db.relationType.AGGREGATION:
11
+ return "aggregation";
12
+ case diagObj.db.relationType.EXTENSION:
13
+ return "extension";
14
+ case diagObj.db.relationType.COMPOSITION:
15
+ return "composition";
16
+ case diagObj.db.relationType.DEPENDENCY:
17
+ return "dependency";
18
+ case diagObj.db.relationType.LOLLIPOP:
19
+ return "lollipop";
20
+ }
21
+ };
22
+ path.points = path.points.filter((p) => !Number.isNaN(p.y));
23
+ const lineData = path.points;
24
+ const lineFunction = line().x(function(d) {
25
+ return d.x;
26
+ }).y(function(d) {
27
+ return d.y;
28
+ }).curve(curveBasis);
29
+ const svgPath = elem.append("path").attr("d", lineFunction(lineData)).attr("id", "edge" + edgeCount).attr("class", "relation");
30
+ let url = "";
31
+ if (conf.arrowMarkerAbsolute) {
32
+ url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search;
33
+ url = url.replace(/\(/g, "\\(");
34
+ url = url.replace(/\)/g, "\\)");
35
+ }
36
+ if (relation.relation.lineType == 1) {
37
+ svgPath.attr("class", "relation dashed-line");
38
+ }
39
+ if (relation.relation.lineType == 10) {
40
+ svgPath.attr("class", "relation dotted-line");
41
+ }
42
+ if (relation.relation.type1 !== "none") {
43
+ svgPath.attr(
44
+ "marker-start",
45
+ "url(" + url + "#" + getRelationType(relation.relation.type1) + "Start)"
46
+ );
47
+ }
48
+ if (relation.relation.type2 !== "none") {
49
+ svgPath.attr(
50
+ "marker-end",
51
+ "url(" + url + "#" + getRelationType(relation.relation.type2) + "End)"
52
+ );
53
+ }
54
+ let x, y;
55
+ const l = path.points.length;
56
+ let labelPosition = utils.calcLabelPosition(path.points);
57
+ x = labelPosition.x;
58
+ y = labelPosition.y;
59
+ let p1_card_x, p1_card_y;
60
+ let p2_card_x, p2_card_y;
61
+ if (l % 2 !== 0 && l > 1) {
62
+ let cardinality_1_point = utils.calcCardinalityPosition(
63
+ relation.relation.type1 !== "none",
64
+ path.points,
65
+ path.points[0]
66
+ );
67
+ let cardinality_2_point = utils.calcCardinalityPosition(
68
+ relation.relation.type2 !== "none",
69
+ path.points,
70
+ path.points[l - 1]
71
+ );
72
+ log$1.debug("cardinality_1_point " + JSON.stringify(cardinality_1_point));
73
+ log$1.debug("cardinality_2_point " + JSON.stringify(cardinality_2_point));
74
+ p1_card_x = cardinality_1_point.x;
75
+ p1_card_y = cardinality_1_point.y;
76
+ p2_card_x = cardinality_2_point.x;
77
+ p2_card_y = cardinality_2_point.y;
78
+ }
79
+ if (relation.title !== void 0) {
80
+ const g = elem.append("g").attr("class", "classLabel");
81
+ const label = g.append("text").attr("class", "label").attr("x", x).attr("y", y).attr("fill", "red").attr("text-anchor", "middle").text(relation.title);
82
+ window.label = label;
83
+ const bounds = label.node().getBBox();
84
+ g.insert("rect", ":first-child").attr("class", "box").attr("x", bounds.x - conf.padding / 2).attr("y", bounds.y - conf.padding / 2).attr("width", bounds.width + conf.padding).attr("height", bounds.height + conf.padding);
85
+ }
86
+ log$1.info("Rendering relation " + JSON.stringify(relation));
87
+ if (relation.relationTitle1 !== void 0 && relation.relationTitle1 !== "none") {
88
+ const g = elem.append("g").attr("class", "cardinality");
89
+ g.append("text").attr("class", "type1").attr("x", p1_card_x).attr("y", p1_card_y).attr("fill", "black").attr("font-size", "6").text(relation.relationTitle1);
90
+ }
91
+ if (relation.relationTitle2 !== void 0 && relation.relationTitle2 !== "none") {
92
+ const g = elem.append("g").attr("class", "cardinality");
93
+ g.append("text").attr("class", "type2").attr("x", p2_card_x).attr("y", p2_card_y).attr("fill", "black").attr("font-size", "6").text(relation.relationTitle2);
94
+ }
95
+ edgeCount++;
96
+ };
97
+ const drawClass = function(elem, classDef, conf, diagObj) {
98
+ log$1.debug("Rendering class ", classDef, conf);
99
+ const id = classDef.id;
100
+ const classInfo = {
101
+ id,
102
+ label: classDef.id,
103
+ width: 0,
104
+ height: 0
105
+ };
106
+ const g = elem.append("g").attr("id", diagObj.db.lookUpDomId(id)).attr("class", "classGroup");
107
+ let title;
108
+ if (classDef.link) {
109
+ title = g.append("svg:a").attr("xlink:href", classDef.link).attr("target", classDef.linkTarget).append("text").attr("y", conf.textHeight + conf.padding).attr("x", 0);
110
+ } else {
111
+ title = g.append("text").attr("y", conf.textHeight + conf.padding).attr("x", 0);
112
+ }
113
+ let isFirst = true;
114
+ classDef.annotations.forEach(function(member) {
115
+ const titleText2 = title.append("tspan").text("«" + member + "»");
116
+ if (!isFirst) {
117
+ titleText2.attr("dy", conf.textHeight);
118
+ }
119
+ isFirst = false;
120
+ });
121
+ let classTitleString = getClassTitleString(classDef);
122
+ const classTitle = title.append("tspan").text(classTitleString).attr("class", "title");
123
+ if (!isFirst) {
124
+ classTitle.attr("dy", conf.textHeight);
125
+ }
126
+ const titleHeight = title.node().getBBox().height;
127
+ let membersLine;
128
+ let membersBox;
129
+ let methodsLine;
130
+ if (classDef.members.length > 0) {
131
+ membersLine = g.append("line").attr("x1", 0).attr("y1", conf.padding + titleHeight + conf.dividerMargin / 2).attr("y2", conf.padding + titleHeight + conf.dividerMargin / 2);
132
+ const members = g.append("text").attr("x", conf.padding).attr("y", titleHeight + conf.dividerMargin + conf.textHeight).attr("fill", "white").attr("class", "classText");
133
+ isFirst = true;
134
+ classDef.members.forEach(function(member) {
135
+ addTspan(members, member, isFirst, conf);
136
+ isFirst = false;
137
+ });
138
+ membersBox = members.node().getBBox();
139
+ }
140
+ if (classDef.methods.length > 0) {
141
+ methodsLine = g.append("line").attr("x1", 0).attr("y1", conf.padding + titleHeight + conf.dividerMargin + membersBox.height).attr("y2", conf.padding + titleHeight + conf.dividerMargin + membersBox.height);
142
+ const methods = g.append("text").attr("x", conf.padding).attr("y", titleHeight + 2 * conf.dividerMargin + membersBox.height + conf.textHeight).attr("fill", "white").attr("class", "classText");
143
+ isFirst = true;
144
+ classDef.methods.forEach(function(method) {
145
+ addTspan(methods, method, isFirst, conf);
146
+ isFirst = false;
147
+ });
148
+ }
149
+ const classBox = g.node().getBBox();
150
+ var cssClassStr = " ";
151
+ if (classDef.cssClasses.length > 0) {
152
+ cssClassStr = cssClassStr + classDef.cssClasses.join(" ");
153
+ }
154
+ const rect = g.insert("rect", ":first-child").attr("x", 0).attr("y", 0).attr("width", classBox.width + 2 * conf.padding).attr("height", classBox.height + conf.padding + 0.5 * conf.dividerMargin).attr("class", cssClassStr);
155
+ const rectWidth = rect.node().getBBox().width;
156
+ title.node().childNodes.forEach(function(x) {
157
+ x.setAttribute("x", (rectWidth - x.getBBox().width) / 2);
158
+ });
159
+ if (classDef.tooltip) {
160
+ title.insert("title").text(classDef.tooltip);
161
+ }
162
+ if (membersLine) {
163
+ membersLine.attr("x2", rectWidth);
164
+ }
165
+ if (methodsLine) {
166
+ methodsLine.attr("x2", rectWidth);
167
+ }
168
+ classInfo.width = rectWidth;
169
+ classInfo.height = classBox.height + conf.padding + 0.5 * conf.dividerMargin;
170
+ return classInfo;
171
+ };
172
+ const getClassTitleString = function(classDef) {
173
+ let classTitleString = classDef.id;
174
+ if (classDef.type) {
175
+ classTitleString += "<" + parseGenericTypes(classDef.type) + ">";
176
+ }
177
+ return classTitleString;
178
+ };
179
+ const drawNote = function(elem, note, conf, diagObj) {
180
+ log$1.debug("Rendering note ", note, conf);
181
+ const id = note.id;
182
+ const noteInfo = {
183
+ id,
184
+ text: note.text,
185
+ width: 0,
186
+ height: 0
187
+ };
188
+ const g = elem.append("g").attr("id", id).attr("class", "classGroup");
189
+ let text = g.append("text").attr("y", conf.textHeight + conf.padding).attr("x", 0);
190
+ const lines = JSON.parse(`"${note.text}"`).split("\n");
191
+ lines.forEach(function(line2) {
192
+ log$1.debug(`Adding line: ${line2}`);
193
+ text.append("tspan").text(line2).attr("class", "title").attr("dy", conf.textHeight);
194
+ });
195
+ const noteBox = g.node().getBBox();
196
+ const rect = g.insert("rect", ":first-child").attr("x", 0).attr("y", 0).attr("width", noteBox.width + 2 * conf.padding).attr(
197
+ "height",
198
+ noteBox.height + lines.length * conf.textHeight + conf.padding + 0.5 * conf.dividerMargin
199
+ );
200
+ const rectWidth = rect.node().getBBox().width;
201
+ text.node().childNodes.forEach(function(x) {
202
+ x.setAttribute("x", (rectWidth - x.getBBox().width) / 2);
203
+ });
204
+ noteInfo.width = rectWidth;
205
+ noteInfo.height = noteBox.height + lines.length * conf.textHeight + conf.padding + 0.5 * conf.dividerMargin;
206
+ return noteInfo;
207
+ };
208
+ const addTspan = function(textEl, member, isFirst, conf) {
209
+ const { displayText, cssStyle } = member.getDisplayDetails();
210
+ const tSpan = textEl.append("tspan").attr("x", conf.padding).text(displayText);
211
+ if (cssStyle !== "") {
212
+ tSpan.attr("style", member.cssStyle);
213
+ }
214
+ if (!isFirst) {
215
+ tSpan.attr("dy", conf.textHeight);
216
+ }
217
+ };
218
+ const svgDraw = {
219
+ getClassTitleString,
220
+ drawClass,
221
+ drawEdge,
222
+ drawNote
223
+ };
224
+ let idCache = {};
225
+ const padding = 20;
226
+ const getGraphId = function(label) {
227
+ const foundEntry = Object.entries(idCache).find((entry) => entry[1].label === label);
228
+ if (foundEntry) {
229
+ return foundEntry[0];
230
+ }
231
+ };
232
+ const insertMarkers = function(elem) {
233
+ elem.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");
234
+ elem.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");
235
+ elem.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");
236
+ elem.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");
237
+ elem.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");
238
+ elem.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");
239
+ elem.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");
240
+ 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 18,7 L9,13 L14,7 L9,1 Z");
241
+ };
242
+ const draw = function(text, id, _version, diagObj) {
243
+ const conf = getConfig().class;
244
+ idCache = {};
245
+ log$1.info("Rendering diagram " + text);
246
+ const securityLevel = getConfig().securityLevel;
247
+ let sandboxElement;
248
+ if (securityLevel === "sandbox") {
249
+ sandboxElement = select("#i" + id);
250
+ }
251
+ const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
252
+ const diagram2 = root.select(`[id='${id}']`);
253
+ insertMarkers(diagram2);
254
+ const g = new Graph({
255
+ multigraph: true
256
+ });
257
+ g.setGraph({
258
+ isMultiGraph: true
259
+ });
260
+ g.setDefaultEdgeLabel(function() {
261
+ return {};
262
+ });
263
+ const classes = diagObj.db.getClasses();
264
+ const keys = Object.keys(classes);
265
+ for (const key of keys) {
266
+ const classDef = classes[key];
267
+ const node = svgDraw.drawClass(diagram2, classDef, conf, diagObj);
268
+ idCache[node.id] = node;
269
+ g.setNode(node.id, node);
270
+ log$1.info("Org height: " + node.height);
271
+ }
272
+ const relations = diagObj.db.getRelations();
273
+ relations.forEach(function(relation) {
274
+ log$1.info(
275
+ // cspell:ignore tjoho
276
+ "tjoho" + getGraphId(relation.id1) + getGraphId(relation.id2) + JSON.stringify(relation)
277
+ );
278
+ g.setEdge(
279
+ getGraphId(relation.id1),
280
+ getGraphId(relation.id2),
281
+ {
282
+ relation
283
+ },
284
+ relation.title || "DEFAULT"
285
+ );
286
+ });
287
+ const notes = diagObj.db.getNotes();
288
+ notes.forEach(function(note) {
289
+ log$1.debug(`Adding note: ${JSON.stringify(note)}`);
290
+ const node = svgDraw.drawNote(diagram2, note, conf, diagObj);
291
+ idCache[node.id] = node;
292
+ g.setNode(node.id, node);
293
+ if (note.class && note.class in classes) {
294
+ g.setEdge(
295
+ note.id,
296
+ getGraphId(note.class),
297
+ {
298
+ relation: {
299
+ id1: note.id,
300
+ id2: note.class,
301
+ relation: {
302
+ type1: "none",
303
+ type2: "none",
304
+ lineType: 10
305
+ }
306
+ }
307
+ },
308
+ "DEFAULT"
309
+ );
310
+ }
311
+ });
312
+ layout(g);
313
+ g.nodes().forEach(function(v) {
314
+ if (v !== void 0 && g.node(v) !== void 0) {
315
+ log$1.debug("Node " + v + ": " + JSON.stringify(g.node(v)));
316
+ root.select("#" + (diagObj.db.lookUpDomId(v) || v)).attr(
317
+ "transform",
318
+ "translate(" + (g.node(v).x - g.node(v).width / 2) + "," + (g.node(v).y - g.node(v).height / 2) + " )"
319
+ );
320
+ }
321
+ });
322
+ g.edges().forEach(function(e) {
323
+ if (e !== void 0 && g.edge(e) !== void 0) {
324
+ log$1.debug("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(g.edge(e)));
325
+ svgDraw.drawEdge(diagram2, g.edge(e), g.edge(e).relation, conf, diagObj);
326
+ }
327
+ });
328
+ const svgBounds = diagram2.node().getBBox();
329
+ const width = svgBounds.width + padding * 2;
330
+ const height = svgBounds.height + padding * 2;
331
+ configureSvgSize(diagram2, height, width, conf.useMaxWidth);
332
+ const vBox = `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`;
333
+ log$1.debug(`viewBox ${vBox}`);
334
+ diagram2.attr("viewBox", vBox);
335
+ };
336
+ const renderer = {
337
+ draw
338
+ };
339
+ const diagram = {
340
+ parser: parser$1,
341
+ db,
342
+ renderer,
343
+ styles,
344
+ init: (cnf) => {
345
+ if (!cnf.class) {
346
+ cnf.class = {};
347
+ }
348
+ cnf.class.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
349
+ db.clear();
350
+ }
351
+ };
352
+ export {
353
+ diagram
354
+ };
@@ -0,0 +1,284 @@
1
+ import { s as styles, d as db, p as parser$1 } from "./styles-9a916d00-zQ92RrTB.js";
2
+ import { l as log$1, g as getConfig, d as select, u as utils, _ as setupGraphViewbox$1, k as common$1, $ as getStylesFromArray, a0 as interpolateToCurve, a1 as curveLinear } from "./index-CLOU2Ikr.js";
3
+ import { G as Graph } from "./graph-Ct2tKpKj.js";
4
+ import { r as render } from "./index-3862675e-B3j3w-v_.js";
5
+ import "./layout-AJxYKqQV.js";
6
+ const sanitizeText = (txt) => common$1.sanitizeText(txt, getConfig());
7
+ let conf = {
8
+ dividerMargin: 10,
9
+ padding: 5,
10
+ textHeight: 10,
11
+ curve: void 0
12
+ };
13
+ const addNamespaces = function(namespaces, g, _id, diagObj) {
14
+ const keys = Object.keys(namespaces);
15
+ log$1.info("keys:", keys);
16
+ log$1.info(namespaces);
17
+ keys.forEach(function(id) {
18
+ var _a, _b;
19
+ const vertex = namespaces[id];
20
+ const shape = "rect";
21
+ const node = {
22
+ shape,
23
+ id: vertex.id,
24
+ domId: vertex.domId,
25
+ labelText: sanitizeText(vertex.id),
26
+ labelStyle: "",
27
+ style: "fill: none; stroke: black",
28
+ // TODO V10: Flowchart ? Keeping flowchart for backwards compatibility. Remove in next major release
29
+ padding: ((_a = getConfig().flowchart) == null ? void 0 : _a.padding) ?? ((_b = getConfig().class) == null ? void 0 : _b.padding)
30
+ };
31
+ g.setNode(vertex.id, node);
32
+ addClasses(vertex.classes, g, _id, diagObj, vertex.id);
33
+ log$1.info("setNode", node);
34
+ });
35
+ };
36
+ const addClasses = function(classes, g, _id, diagObj, parent) {
37
+ const keys = Object.keys(classes);
38
+ log$1.info("keys:", keys);
39
+ log$1.info(classes);
40
+ keys.filter((id) => classes[id].parent == parent).forEach(function(id) {
41
+ var _a, _b;
42
+ const vertex = classes[id];
43
+ const cssClassStr = vertex.cssClasses.join(" ");
44
+ const styles2 = getStylesFromArray(vertex.styles);
45
+ const vertexText = vertex.label ?? vertex.id;
46
+ const radius = 0;
47
+ const shape = "class_box";
48
+ const node = {
49
+ labelStyle: styles2.labelStyle,
50
+ shape,
51
+ labelText: sanitizeText(vertexText),
52
+ classData: vertex,
53
+ rx: radius,
54
+ ry: radius,
55
+ class: cssClassStr,
56
+ style: styles2.style,
57
+ id: vertex.id,
58
+ domId: vertex.domId,
59
+ tooltip: diagObj.db.getTooltip(vertex.id, parent) || "",
60
+ haveCallback: vertex.haveCallback,
61
+ link: vertex.link,
62
+ width: vertex.type === "group" ? 500 : void 0,
63
+ type: vertex.type,
64
+ // TODO V10: Flowchart ? Keeping flowchart for backwards compatibility. Remove in next major release
65
+ padding: ((_a = getConfig().flowchart) == null ? void 0 : _a.padding) ?? ((_b = getConfig().class) == null ? void 0 : _b.padding)
66
+ };
67
+ g.setNode(vertex.id, node);
68
+ if (parent) {
69
+ g.setParent(vertex.id, parent);
70
+ }
71
+ log$1.info("setNode", node);
72
+ });
73
+ };
74
+ const addNotes = function(notes, g, startEdgeId, classes) {
75
+ log$1.info(notes);
76
+ notes.forEach(function(note, i) {
77
+ var _a, _b;
78
+ const vertex = note;
79
+ const cssNoteStr = "";
80
+ const styles2 = { labelStyle: "", style: "" };
81
+ const vertexText = vertex.text;
82
+ const radius = 0;
83
+ const shape = "note";
84
+ const node = {
85
+ labelStyle: styles2.labelStyle,
86
+ shape,
87
+ labelText: sanitizeText(vertexText),
88
+ noteData: vertex,
89
+ rx: radius,
90
+ ry: radius,
91
+ class: cssNoteStr,
92
+ style: styles2.style,
93
+ id: vertex.id,
94
+ domId: vertex.id,
95
+ tooltip: "",
96
+ type: "note",
97
+ // TODO V10: Flowchart ? Keeping flowchart for backwards compatibility. Remove in next major release
98
+ padding: ((_a = getConfig().flowchart) == null ? void 0 : _a.padding) ?? ((_b = getConfig().class) == null ? void 0 : _b.padding)
99
+ };
100
+ g.setNode(vertex.id, node);
101
+ log$1.info("setNode", node);
102
+ if (!vertex.class || !(vertex.class in classes)) {
103
+ return;
104
+ }
105
+ const edgeId = startEdgeId + i;
106
+ const edgeData = {
107
+ id: `edgeNote${edgeId}`,
108
+ //Set relationship style and line type
109
+ classes: "relation",
110
+ pattern: "dotted",
111
+ // Set link type for rendering
112
+ arrowhead: "none",
113
+ //Set edge extra labels
114
+ startLabelRight: "",
115
+ endLabelLeft: "",
116
+ //Set relation arrow types
117
+ arrowTypeStart: "none",
118
+ arrowTypeEnd: "none",
119
+ style: "fill:none",
120
+ labelStyle: "",
121
+ curve: interpolateToCurve(conf.curve, curveLinear)
122
+ };
123
+ g.setEdge(vertex.id, vertex.class, edgeData, edgeId);
124
+ });
125
+ };
126
+ const addRelations = function(relations, g) {
127
+ const conf2 = getConfig().flowchart;
128
+ let cnt = 0;
129
+ relations.forEach(function(edge) {
130
+ var _a;
131
+ cnt++;
132
+ const edgeData = {
133
+ //Set relationship style and line type
134
+ classes: "relation",
135
+ pattern: edge.relation.lineType == 1 ? "dashed" : "solid",
136
+ id: `id_${edge.id1}_${edge.id2}_${cnt}`,
137
+ // Set link type for rendering
138
+ arrowhead: edge.type === "arrow_open" ? "none" : "normal",
139
+ //Set edge extra labels
140
+ startLabelRight: edge.relationTitle1 === "none" ? "" : edge.relationTitle1,
141
+ endLabelLeft: edge.relationTitle2 === "none" ? "" : edge.relationTitle2,
142
+ //Set relation arrow types
143
+ arrowTypeStart: getArrowMarker(edge.relation.type1),
144
+ arrowTypeEnd: getArrowMarker(edge.relation.type2),
145
+ style: "fill:none",
146
+ labelStyle: "",
147
+ curve: interpolateToCurve(conf2 == null ? void 0 : conf2.curve, curveLinear)
148
+ };
149
+ log$1.info(edgeData, edge);
150
+ if (edge.style !== void 0) {
151
+ const styles2 = getStylesFromArray(edge.style);
152
+ edgeData.style = styles2.style;
153
+ edgeData.labelStyle = styles2.labelStyle;
154
+ }
155
+ edge.text = edge.title;
156
+ if (edge.text === void 0) {
157
+ if (edge.style !== void 0) {
158
+ edgeData.arrowheadStyle = "fill: #333";
159
+ }
160
+ } else {
161
+ edgeData.arrowheadStyle = "fill: #333";
162
+ edgeData.labelpos = "c";
163
+ if (((_a = getConfig().flowchart) == null ? void 0 : _a.htmlLabels) ?? getConfig().htmlLabels) {
164
+ edgeData.labelType = "html";
165
+ edgeData.label = '<span class="edgeLabel">' + edge.text + "</span>";
166
+ } else {
167
+ edgeData.labelType = "text";
168
+ edgeData.label = edge.text.replace(common$1.lineBreakRegex, "\n");
169
+ if (edge.style === void 0) {
170
+ edgeData.style = edgeData.style || "stroke: #333; stroke-width: 1.5px;fill:none";
171
+ }
172
+ edgeData.labelStyle = edgeData.labelStyle.replace("color:", "fill:");
173
+ }
174
+ }
175
+ g.setEdge(edge.id1, edge.id2, edgeData, cnt);
176
+ });
177
+ };
178
+ const setConf = function(cnf) {
179
+ conf = {
180
+ ...conf,
181
+ ...cnf
182
+ };
183
+ };
184
+ const draw = async function(text, id, _version, diagObj) {
185
+ log$1.info("Drawing class - ", id);
186
+ const conf2 = getConfig().flowchart ?? getConfig().class;
187
+ const securityLevel = getConfig().securityLevel;
188
+ log$1.info("config:", conf2);
189
+ const nodeSpacing = (conf2 == null ? void 0 : conf2.nodeSpacing) ?? 50;
190
+ const rankSpacing = (conf2 == null ? void 0 : conf2.rankSpacing) ?? 50;
191
+ const g = new Graph({
192
+ multigraph: true,
193
+ compound: true
194
+ }).setGraph({
195
+ rankdir: diagObj.db.getDirection(),
196
+ nodesep: nodeSpacing,
197
+ ranksep: rankSpacing,
198
+ marginx: 8,
199
+ marginy: 8
200
+ }).setDefaultEdgeLabel(function() {
201
+ return {};
202
+ });
203
+ const namespaces = diagObj.db.getNamespaces();
204
+ const classes = diagObj.db.getClasses();
205
+ const relations = diagObj.db.getRelations();
206
+ const notes = diagObj.db.getNotes();
207
+ log$1.info(relations);
208
+ addNamespaces(namespaces, g, id, diagObj);
209
+ addClasses(classes, g, id, diagObj);
210
+ addRelations(relations, g);
211
+ addNotes(notes, g, relations.length + 1, classes);
212
+ let sandboxElement;
213
+ if (securityLevel === "sandbox") {
214
+ sandboxElement = select("#i" + id);
215
+ }
216
+ const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
217
+ const svg = root.select(`[id="${id}"]`);
218
+ const element = root.select("#" + id + " g");
219
+ await render(
220
+ element,
221
+ g,
222
+ ["aggregation", "extension", "composition", "dependency", "lollipop"],
223
+ "classDiagram",
224
+ id
225
+ );
226
+ utils.insertTitle(svg, "classTitleText", (conf2 == null ? void 0 : conf2.titleTopMargin) ?? 5, diagObj.db.getDiagramTitle());
227
+ setupGraphViewbox$1(g, svg, conf2 == null ? void 0 : conf2.diagramPadding, conf2 == null ? void 0 : conf2.useMaxWidth);
228
+ if (!(conf2 == null ? void 0 : conf2.htmlLabels)) {
229
+ const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document;
230
+ const labels = doc.querySelectorAll('[id="' + id + '"] .edgeLabel .label');
231
+ for (const label of labels) {
232
+ const dim = label.getBBox();
233
+ const rect = doc.createElementNS("http://www.w3.org/2000/svg", "rect");
234
+ rect.setAttribute("rx", 0);
235
+ rect.setAttribute("ry", 0);
236
+ rect.setAttribute("width", dim.width);
237
+ rect.setAttribute("height", dim.height);
238
+ label.insertBefore(rect, label.firstChild);
239
+ }
240
+ }
241
+ };
242
+ function getArrowMarker(type) {
243
+ let marker;
244
+ switch (type) {
245
+ case 0:
246
+ marker = "aggregation";
247
+ break;
248
+ case 1:
249
+ marker = "extension";
250
+ break;
251
+ case 2:
252
+ marker = "composition";
253
+ break;
254
+ case 3:
255
+ marker = "dependency";
256
+ break;
257
+ case 4:
258
+ marker = "lollipop";
259
+ break;
260
+ default:
261
+ marker = "none";
262
+ }
263
+ return marker;
264
+ }
265
+ const renderer = {
266
+ setConf,
267
+ draw
268
+ };
269
+ const diagram = {
270
+ parser: parser$1,
271
+ db,
272
+ renderer,
273
+ styles,
274
+ init: (cnf) => {
275
+ if (!cnf.class) {
276
+ cnf.class = {};
277
+ }
278
+ cnf.class.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
279
+ db.clear();
280
+ }
281
+ };
282
+ export {
283
+ diagram
284
+ };
@@ -0,0 +1,8 @@
1
+ import { b as baseClone } from "./graph-Ct2tKpKj.js";
2
+ var CLONE_SYMBOLS_FLAG = 4;
3
+ function clone(value) {
4
+ return baseClone(value, CLONE_SYMBOLS_FLAG);
5
+ }
6
+ export {
7
+ clone as c
8
+ };