bg-editor 0.0.7 → 0.0.8

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 (58) hide show
  1. package/dist/umo-editor.js +89809 -7
  2. package/package.json +21 -1
  3. package/dist/_baseUniq-CK68Es8H.js +0 -473
  4. package/dist/arc-cD-4ba7d.js +0 -84
  5. package/dist/architecture-U656AL7Q-jxTBuJdN.js +0 -6
  6. package/dist/architectureDiagram-VXUJARFQ-D3XlpFhb.js +0 -4660
  7. package/dist/blockDiagram-VD42YOAC-BslbvMOG.js +0 -2262
  8. package/dist/c4Diagram-YG6GDRKO-DD3uWYPM.js +0 -1581
  9. package/dist/channel-DjTSKqWx.js +0 -6
  10. package/dist/chunk-4BX2VUAB-lfhsh4gk.js +0 -9
  11. package/dist/chunk-55IACEB6-O42zw0MT.js +0 -9
  12. package/dist/chunk-B4BG7PRW-CAose2Ox.js +0 -1376
  13. package/dist/chunk-DI55MBZ5-DkOlwdzs.js +0 -1371
  14. package/dist/chunk-FMBD7UC4-XviEvZms.js +0 -20
  15. package/dist/chunk-QN33PNHL-CNGSzgpw.js +0 -20
  16. package/dist/chunk-QZHKN3VN-CRgLUJXR.js +0 -16
  17. package/dist/chunk-TZMSLE5B-BkHNUxTN.js +0 -65
  18. package/dist/classDiagram-2ON5EDUG-Cakz_SCw.js +0 -17
  19. package/dist/classDiagram-v2-WZHVMYZB-Cakz_SCw.js +0 -17
  20. package/dist/clone-CIrbb4_D.js +0 -9
  21. package/dist/cose-bilkent-S5V4N54A-EoSlB5N_.js +0 -2606
  22. package/dist/cytoscape.esm-DoU_GB5M.js +0 -18732
  23. package/dist/dagre-6UL2VRFP-BPH1NIvl.js +0 -444
  24. package/dist/defaultLocale-DEnRyJdC.js +0 -172
  25. package/dist/diagram-PSM6KHXK-DCRoLhFv.js +0 -396
  26. package/dist/diagram-QEK2KX5R-2gxFpsCA.js +0 -218
  27. package/dist/diagram-S2PKOQOG-BIPpN2G8.js +0 -143
  28. package/dist/erDiagram-Q2GNP2WA-pfb2dpnp.js +0 -842
  29. package/dist/flowDiagram-NV44I4VS-Dv631-Fh.js +0 -1621
  30. package/dist/ganttDiagram-LVOFAZNH-BOKYXijK.js +0 -2500
  31. package/dist/gitGraph-F6HP7TQM-CRerkbyh.js +0 -6
  32. package/dist/gitGraphDiagram-NY62KEGX-CgO9x7O1.js +0 -700
  33. package/dist/graph-CG-rVaun.js +0 -382
  34. package/dist/index-LPeu-5gp.js +0 -164788
  35. package/dist/info-NVLQJR56-CZcMDuD4.js +0 -6
  36. package/dist/infoDiagram-ER5ION4S-CpfjxDXT.js +0 -25
  37. package/dist/init-Dbt-6wo9.js +0 -17
  38. package/dist/journeyDiagram-XKPGCS4Q-D4m1xk_j.js +0 -837
  39. package/dist/kanban-definition-3W4ZIXB7-GUMW-GDO.js +0 -719
  40. package/dist/layout-C7pGfQvF.js +0 -1416
  41. package/dist/linear-CQdBpz9H.js +0 -260
  42. package/dist/mermaid-parser.core-C3Lk4un7.js +0 -14143
  43. package/dist/min-D7xNMq31.js +0 -39
  44. package/dist/mindmap-definition-VGOIOE7T-GfQh2q9s.js +0 -784
  45. package/dist/ordinal-mgyNSFm_.js +0 -62
  46. package/dist/packet-BFZMPI3H-DughJE3g.js +0 -6
  47. package/dist/pie-7BOR55EZ-B1py7mee.js +0 -6
  48. package/dist/pieDiagram-ADFJNKIX-DENmX4xL.js +0 -162
  49. package/dist/quadrantDiagram-AYHSOK5B-BFVycH-W.js +0 -1023
  50. package/dist/radar-NHE76QYJ-DuTW4rXt.js +0 -6
  51. package/dist/requirementDiagram-UZGBJVZJ-f8rb43Mp.js +0 -851
  52. package/dist/sankeyDiagram-TZEHDZUN-CUN0tZ5p.js +0 -811
  53. package/dist/sequenceDiagram-WL72ISMW-7X4nul9T.js +0 -2512
  54. package/dist/stateDiagram-FKZM4ZOC-CypL793K.js +0 -264
  55. package/dist/stateDiagram-v2-4FDKWEC3-D5vS5FM5.js +0 -17
  56. package/dist/timeline-definition-IT6M3QCI-B_WOoOGO.js +0 -798
  57. package/dist/treemap-KMMF4GRG-BzINyJBJ.js +0 -6
  58. package/dist/xychartDiagram-PRI3JC2R-Llw16NDY.js +0 -1341
@@ -1,700 +0,0 @@
1
- import "./style.css";
2
- import { p as Y } from "./chunk-4BX2VUAB-lfhsh4gk.js";
3
- import { I as K } from "./chunk-QZHKN3VN-CRgLUJXR.js";
4
- import { _ as l, q as U, p as V, s as X, g as J, a as Q, b as Z, l as m, c as rr, d as er, u as tr, C as ar, y as sr, k as C, D as nr, E as or, F as cr, G as ir } from "./index-LPeu-5gp.js";
5
- import { p as dr } from "./mermaid-parser.core-C3Lk4un7.js";
6
- var x = {
7
- NORMAL: 0,
8
- REVERSE: 1,
9
- HIGHLIGHT: 2,
10
- MERGE: 3,
11
- CHERRY_PICK: 4
12
- }, hr = cr.gitGraph, I = /* @__PURE__ */ l(() => nr({
13
- ...hr,
14
- ...or().gitGraph
15
- }), "getConfig"), c = new K(() => {
16
- const t = I(), r = t.mainBranchName, s = t.mainBranchOrder;
17
- return {
18
- mainBranchName: r,
19
- commits: /* @__PURE__ */ new Map(),
20
- head: null,
21
- branchConfig: /* @__PURE__ */ new Map([[r, { name: r, order: s }]]),
22
- branches: /* @__PURE__ */ new Map([[r, null]]),
23
- currBranch: r,
24
- direction: "LR",
25
- seq: 0,
26
- options: {}
27
- };
28
- });
29
- function A() {
30
- return ir({ length: 7 });
31
- }
32
- l(A, "getID");
33
- function F(t, r) {
34
- const s = /* @__PURE__ */ Object.create(null);
35
- return t.reduce((n, e) => {
36
- const a = r(e);
37
- return s[a] || (s[a] = !0, n.push(e)), n;
38
- }, []);
39
- }
40
- l(F, "uniqBy");
41
- var lr = /* @__PURE__ */ l(function(t) {
42
- c.records.direction = t;
43
- }, "setDirection"), $r = /* @__PURE__ */ l(function(t) {
44
- m.debug("options str", t), t = t?.trim(), t = t || "{}";
45
- try {
46
- c.records.options = JSON.parse(t);
47
- } catch (r) {
48
- m.error("error while parsing gitGraph options", r.message);
49
- }
50
- }, "setOptions"), fr = /* @__PURE__ */ l(function() {
51
- return c.records.options;
52
- }, "getOptions"), gr = /* @__PURE__ */ l(function(t) {
53
- let r = t.msg, s = t.id;
54
- const n = t.type;
55
- let e = t.tags;
56
- m.info("commit", r, s, n, e), m.debug("Entering commit:", r, s, n, e);
57
- const a = I();
58
- s = C.sanitizeText(s, a), r = C.sanitizeText(r, a), e = e?.map((o) => C.sanitizeText(o, a));
59
- const d = {
60
- id: s || c.records.seq + "-" + A(),
61
- message: r,
62
- seq: c.records.seq++,
63
- type: n ?? x.NORMAL,
64
- tags: e ?? [],
65
- parents: c.records.head == null ? [] : [c.records.head.id],
66
- branch: c.records.currBranch
67
- };
68
- c.records.head = d, m.info("main branch", a.mainBranchName), c.records.commits.has(d.id) && m.warn(`Commit ID ${d.id} already exists`), c.records.commits.set(d.id, d), c.records.branches.set(c.records.currBranch, d.id), m.debug("in pushCommit " + d.id);
69
- }, "commit"), yr = /* @__PURE__ */ l(function(t) {
70
- let r = t.name;
71
- const s = t.order;
72
- if (r = C.sanitizeText(r, I()), c.records.branches.has(r))
73
- throw new Error(
74
- `Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${r}")`
75
- );
76
- c.records.branches.set(r, c.records.head != null ? c.records.head.id : null), c.records.branchConfig.set(r, { name: r, order: s }), z(r), m.debug("in createBranch");
77
- }, "branch"), ur = /* @__PURE__ */ l((t) => {
78
- let r = t.branch, s = t.id;
79
- const n = t.type, e = t.tags, a = I();
80
- r = C.sanitizeText(r, a), s && (s = C.sanitizeText(s, a));
81
- const d = c.records.branches.get(c.records.currBranch), o = c.records.branches.get(r), f = d ? c.records.commits.get(d) : void 0, h = o ? c.records.commits.get(o) : void 0;
82
- if (f && h && f.branch === r)
83
- throw new Error(`Cannot merge branch '${r}' into itself.`);
84
- if (c.records.currBranch === r) {
85
- const i = new Error('Incorrect usage of "merge". Cannot merge a branch to itself');
86
- throw i.hash = {
87
- text: `merge ${r}`,
88
- token: `merge ${r}`,
89
- expected: ["branch abc"]
90
- }, i;
91
- }
92
- if (f === void 0 || !f) {
93
- const i = new Error(
94
- `Incorrect usage of "merge". Current branch (${c.records.currBranch})has no commits`
95
- );
96
- throw i.hash = {
97
- text: `merge ${r}`,
98
- token: `merge ${r}`,
99
- expected: ["commit"]
100
- }, i;
101
- }
102
- if (!c.records.branches.has(r)) {
103
- const i = new Error(
104
- 'Incorrect usage of "merge". Branch to be merged (' + r + ") does not exist"
105
- );
106
- throw i.hash = {
107
- text: `merge ${r}`,
108
- token: `merge ${r}`,
109
- expected: [`branch ${r}`]
110
- }, i;
111
- }
112
- if (h === void 0 || !h) {
113
- const i = new Error(
114
- 'Incorrect usage of "merge". Branch to be merged (' + r + ") has no commits"
115
- );
116
- throw i.hash = {
117
- text: `merge ${r}`,
118
- token: `merge ${r}`,
119
- expected: ['"commit"']
120
- }, i;
121
- }
122
- if (f === h) {
123
- const i = new Error('Incorrect usage of "merge". Both branches have same head');
124
- throw i.hash = {
125
- text: `merge ${r}`,
126
- token: `merge ${r}`,
127
- expected: ["branch abc"]
128
- }, i;
129
- }
130
- if (s && c.records.commits.has(s)) {
131
- const i = new Error(
132
- 'Incorrect usage of "merge". Commit with id:' + s + " already exists, use different custom id"
133
- );
134
- throw i.hash = {
135
- text: `merge ${r} ${s} ${n} ${e?.join(" ")}`,
136
- token: `merge ${r} ${s} ${n} ${e?.join(" ")}`,
137
- expected: [
138
- `merge ${r} ${s}_UNIQUE ${n} ${e?.join(" ")}`
139
- ]
140
- }, i;
141
- }
142
- const $ = o || "", g = {
143
- id: s || `${c.records.seq}-${A()}`,
144
- message: `merged branch ${r} into ${c.records.currBranch}`,
145
- seq: c.records.seq++,
146
- parents: c.records.head == null ? [] : [c.records.head.id, $],
147
- branch: c.records.currBranch,
148
- type: x.MERGE,
149
- customType: n,
150
- customId: !!s,
151
- tags: e ?? []
152
- };
153
- c.records.head = g, c.records.commits.set(g.id, g), c.records.branches.set(c.records.currBranch, g.id), m.debug(c.records.branches), m.debug("in mergeBranch");
154
- }, "merge"), pr = /* @__PURE__ */ l(function(t) {
155
- let r = t.id, s = t.targetId, n = t.tags, e = t.parent;
156
- m.debug("Entering cherryPick:", r, s, n);
157
- const a = I();
158
- if (r = C.sanitizeText(r, a), s = C.sanitizeText(s, a), n = n?.map((f) => C.sanitizeText(f, a)), e = C.sanitizeText(e, a), !r || !c.records.commits.has(r)) {
159
- const f = new Error(
160
- 'Incorrect usage of "cherryPick". Source commit id should exist and provided'
161
- );
162
- throw f.hash = {
163
- text: `cherryPick ${r} ${s}`,
164
- token: `cherryPick ${r} ${s}`,
165
- expected: ["cherry-pick abc"]
166
- }, f;
167
- }
168
- const d = c.records.commits.get(r);
169
- if (d === void 0 || !d)
170
- throw new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');
171
- if (e && !(Array.isArray(d.parents) && d.parents.includes(e)))
172
- throw new Error(
173
- "Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit."
174
- );
175
- const o = d.branch;
176
- if (d.type === x.MERGE && !e)
177
- throw new Error(
178
- "Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified."
179
- );
180
- if (!s || !c.records.commits.has(s)) {
181
- if (o === c.records.currBranch) {
182
- const g = new Error(
183
- 'Incorrect usage of "cherryPick". Source commit is already on current branch'
184
- );
185
- throw g.hash = {
186
- text: `cherryPick ${r} ${s}`,
187
- token: `cherryPick ${r} ${s}`,
188
- expected: ["cherry-pick abc"]
189
- }, g;
190
- }
191
- const f = c.records.branches.get(c.records.currBranch);
192
- if (f === void 0 || !f) {
193
- const g = new Error(
194
- `Incorrect usage of "cherry-pick". Current branch (${c.records.currBranch})has no commits`
195
- );
196
- throw g.hash = {
197
- text: `cherryPick ${r} ${s}`,
198
- token: `cherryPick ${r} ${s}`,
199
- expected: ["cherry-pick abc"]
200
- }, g;
201
- }
202
- const h = c.records.commits.get(f);
203
- if (h === void 0 || !h) {
204
- const g = new Error(
205
- `Incorrect usage of "cherry-pick". Current branch (${c.records.currBranch})has no commits`
206
- );
207
- throw g.hash = {
208
- text: `cherryPick ${r} ${s}`,
209
- token: `cherryPick ${r} ${s}`,
210
- expected: ["cherry-pick abc"]
211
- }, g;
212
- }
213
- const $ = {
214
- id: c.records.seq + "-" + A(),
215
- message: `cherry-picked ${d?.message} into ${c.records.currBranch}`,
216
- seq: c.records.seq++,
217
- parents: c.records.head == null ? [] : [c.records.head.id, d.id],
218
- branch: c.records.currBranch,
219
- type: x.CHERRY_PICK,
220
- tags: n ? n.filter(Boolean) : [
221
- `cherry-pick:${d.id}${d.type === x.MERGE ? `|parent:${e}` : ""}`
222
- ]
223
- };
224
- c.records.head = $, c.records.commits.set($.id, $), c.records.branches.set(c.records.currBranch, $.id), m.debug(c.records.branches), m.debug("in cherryPick");
225
- }
226
- }, "cherryPick"), z = /* @__PURE__ */ l(function(t) {
227
- if (t = C.sanitizeText(t, I()), c.records.branches.has(t)) {
228
- c.records.currBranch = t;
229
- const r = c.records.branches.get(c.records.currBranch);
230
- r === void 0 || !r ? c.records.head = null : c.records.head = c.records.commits.get(r) ?? null;
231
- } else {
232
- const r = new Error(
233
- `Trying to checkout branch which is not yet created. (Help try using "branch ${t}")`
234
- );
235
- throw r.hash = {
236
- text: `checkout ${t}`,
237
- token: `checkout ${t}`,
238
- expected: [`branch ${t}`]
239
- }, r;
240
- }
241
- }, "checkout");
242
- function H(t, r, s) {
243
- const n = t.indexOf(r);
244
- n === -1 ? t.push(s) : t.splice(n, 1, s);
245
- }
246
- l(H, "upsert");
247
- function P(t) {
248
- const r = t.reduce((e, a) => e.seq > a.seq ? e : a, t[0]);
249
- let s = "";
250
- t.forEach(function(e) {
251
- e === r ? s += " *" : s += " |";
252
- });
253
- const n = [s, r.id, r.seq];
254
- for (const e in c.records.branches)
255
- c.records.branches.get(e) === r.id && n.push(e);
256
- if (m.debug(n.join(" ")), r.parents && r.parents.length == 2 && r.parents[0] && r.parents[1]) {
257
- const e = c.records.commits.get(r.parents[0]);
258
- H(t, r, e), r.parents[1] && t.push(c.records.commits.get(r.parents[1]));
259
- } else {
260
- if (r.parents.length == 0)
261
- return;
262
- if (r.parents[0]) {
263
- const e = c.records.commits.get(r.parents[0]);
264
- H(t, r, e);
265
- }
266
- }
267
- t = F(t, (e) => e.id), P(t);
268
- }
269
- l(P, "prettyPrintCommitHistory");
270
- var xr = /* @__PURE__ */ l(function() {
271
- m.debug(c.records.commits);
272
- const t = N()[0];
273
- P([t]);
274
- }, "prettyPrint"), mr = /* @__PURE__ */ l(function() {
275
- c.reset(), sr();
276
- }, "clear"), br = /* @__PURE__ */ l(function() {
277
- return [...c.records.branchConfig.values()].map((r, s) => r.order !== null && r.order !== void 0 ? r : {
278
- ...r,
279
- order: parseFloat(`0.${s}`)
280
- }).sort((r, s) => (r.order ?? 0) - (s.order ?? 0)).map(({ name: r }) => ({ name: r }));
281
- }, "getBranchesAsObjArray"), wr = /* @__PURE__ */ l(function() {
282
- return c.records.branches;
283
- }, "getBranches"), vr = /* @__PURE__ */ l(function() {
284
- return c.records.commits;
285
- }, "getCommits"), N = /* @__PURE__ */ l(function() {
286
- const t = [...c.records.commits.values()];
287
- return t.forEach(function(r) {
288
- m.debug(r.id);
289
- }), t.sort((r, s) => r.seq - s.seq), t;
290
- }, "getCommitsArray"), Cr = /* @__PURE__ */ l(function() {
291
- return c.records.currBranch;
292
- }, "getCurrentBranch"), Er = /* @__PURE__ */ l(function() {
293
- return c.records.direction;
294
- }, "getDirection"), Tr = /* @__PURE__ */ l(function() {
295
- return c.records.head;
296
- }, "getHead"), S = {
297
- commitType: x,
298
- getConfig: I,
299
- setDirection: lr,
300
- setOptions: $r,
301
- getOptions: fr,
302
- commit: gr,
303
- branch: yr,
304
- merge: ur,
305
- cherryPick: pr,
306
- checkout: z,
307
- //reset,
308
- prettyPrint: xr,
309
- clear: mr,
310
- getBranchesAsObjArray: br,
311
- getBranches: wr,
312
- getCommits: vr,
313
- getCommitsArray: N,
314
- getCurrentBranch: Cr,
315
- getDirection: Er,
316
- getHead: Tr,
317
- setAccTitle: Z,
318
- getAccTitle: Q,
319
- getAccDescription: J,
320
- setAccDescription: X,
321
- setDiagramTitle: V,
322
- getDiagramTitle: U
323
- }, Br = /* @__PURE__ */ l((t, r) => {
324
- Y(t, r), t.dir && r.setDirection(t.dir);
325
- for (const s of t.statements)
326
- Lr(s, r);
327
- }, "populate"), Lr = /* @__PURE__ */ l((t, r) => {
328
- const n = {
329
- Commit: /* @__PURE__ */ l((e) => r.commit(kr(e)), "Commit"),
330
- Branch: /* @__PURE__ */ l((e) => r.branch(Mr(e)), "Branch"),
331
- Merge: /* @__PURE__ */ l((e) => r.merge(Ir(e)), "Merge"),
332
- Checkout: /* @__PURE__ */ l((e) => r.checkout(Rr(e)), "Checkout"),
333
- CherryPicking: /* @__PURE__ */ l((e) => r.cherryPick(Gr(e)), "CherryPicking")
334
- }[t.$type];
335
- n ? n(t) : m.error(`Unknown statement type: ${t.$type}`);
336
- }, "parseStatement"), kr = /* @__PURE__ */ l((t) => ({
337
- id: t.id,
338
- msg: t.message ?? "",
339
- type: t.type !== void 0 ? x[t.type] : x.NORMAL,
340
- tags: t.tags ?? void 0
341
- }), "parseCommit"), Mr = /* @__PURE__ */ l((t) => ({
342
- name: t.name,
343
- order: t.order ?? 0
344
- }), "parseBranch"), Ir = /* @__PURE__ */ l((t) => ({
345
- branch: t.branch,
346
- id: t.id ?? "",
347
- type: t.type !== void 0 ? x[t.type] : void 0,
348
- tags: t.tags ?? void 0
349
- }), "parseMerge"), Rr = /* @__PURE__ */ l((t) => t.branch, "parseCheckout"), Gr = /* @__PURE__ */ l((t) => ({
350
- id: t.id,
351
- targetId: "",
352
- tags: t.tags?.length === 0 ? void 0 : t.tags,
353
- parent: t.parent
354
- }), "parseCherryPicking"), Or = {
355
- parse: /* @__PURE__ */ l(async (t) => {
356
- const r = await dr("gitGraph", t);
357
- m.debug(r), Br(r, S);
358
- }, "parse")
359
- }, qr = rr(), v = qr?.gitGraph, L = 10, k = 40, E = 4, T = 2, M = 8, b = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Map(), O = 30, R = /* @__PURE__ */ new Map(), q = [], B = 0, u = "LR", Ar = /* @__PURE__ */ l(() => {
360
- b.clear(), w.clear(), R.clear(), B = 0, q = [], u = "LR";
361
- }, "clear"), W = /* @__PURE__ */ l((t) => {
362
- const r = document.createElementNS("http://www.w3.org/2000/svg", "text");
363
- return (typeof t == "string" ? t.split(/\\n|\n|<br\s*\/?>/gi) : t).forEach((n) => {
364
- const e = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
365
- e.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve"), e.setAttribute("dy", "1em"), e.setAttribute("x", "0"), e.setAttribute("class", "row"), e.textContent = n.trim(), r.appendChild(e);
366
- }), r;
367
- }, "drawText"), j = /* @__PURE__ */ l((t) => {
368
- let r, s, n;
369
- return u === "BT" ? (s = /* @__PURE__ */ l((e, a) => e <= a, "comparisonFunc"), n = 1 / 0) : (s = /* @__PURE__ */ l((e, a) => e >= a, "comparisonFunc"), n = 0), t.forEach((e) => {
370
- const a = u === "TB" || u == "BT" ? w.get(e)?.y : w.get(e)?.x;
371
- a !== void 0 && s(a, n) && (r = e, n = a);
372
- }), r;
373
- }, "findClosestParent"), _r = /* @__PURE__ */ l((t) => {
374
- let r = "", s = 1 / 0;
375
- return t.forEach((n) => {
376
- const e = w.get(n).y;
377
- e <= s && (r = n, s = e);
378
- }), r || void 0;
379
- }, "findClosestParentBT"), Hr = /* @__PURE__ */ l((t, r, s) => {
380
- let n = s, e = s;
381
- const a = [];
382
- t.forEach((d) => {
383
- const o = r.get(d);
384
- if (!o)
385
- throw new Error(`Commit not found for key ${d}`);
386
- o.parents.length ? (n = Dr(o), e = Math.max(n, e)) : a.push(o), Fr(o, n);
387
- }), n = e, a.forEach((d) => {
388
- zr(d, n, s);
389
- }), t.forEach((d) => {
390
- const o = r.get(d);
391
- if (o?.parents.length) {
392
- const f = _r(o.parents);
393
- n = w.get(f).y - k, n <= e && (e = n);
394
- const h = b.get(o.branch).pos, $ = n - L;
395
- w.set(o.id, { x: h, y: $ });
396
- }
397
- });
398
- }, "setParallelBTPos"), Pr = /* @__PURE__ */ l((t) => {
399
- const r = j(t.parents.filter((n) => n !== null));
400
- if (!r)
401
- throw new Error(`Closest parent not found for commit ${t.id}`);
402
- const s = w.get(r)?.y;
403
- if (s === void 0)
404
- throw new Error(`Closest parent position not found for commit ${t.id}`);
405
- return s;
406
- }, "findClosestParentPos"), Dr = /* @__PURE__ */ l((t) => Pr(t) + k, "calculateCommitPosition"), Fr = /* @__PURE__ */ l((t, r) => {
407
- const s = b.get(t.branch);
408
- if (!s)
409
- throw new Error(`Branch not found for commit ${t.id}`);
410
- const n = s.pos, e = r + L;
411
- return w.set(t.id, { x: n, y: e }), { x: n, y: e };
412
- }, "setCommitPosition"), zr = /* @__PURE__ */ l((t, r, s) => {
413
- const n = b.get(t.branch);
414
- if (!n)
415
- throw new Error(`Branch not found for commit ${t.id}`);
416
- const e = r + s, a = n.pos;
417
- w.set(t.id, { x: a, y: e });
418
- }, "setRootPosition"), Nr = /* @__PURE__ */ l((t, r, s, n, e, a) => {
419
- if (a === x.HIGHLIGHT)
420
- t.append("rect").attr("x", s.x - 10).attr("y", s.y - 10).attr("width", 20).attr("height", 20).attr(
421
- "class",
422
- `commit ${r.id} commit-highlight${e % M} ${n}-outer`
423
- ), t.append("rect").attr("x", s.x - 6).attr("y", s.y - 6).attr("width", 12).attr("height", 12).attr(
424
- "class",
425
- `commit ${r.id} commit${e % M} ${n}-inner`
426
- );
427
- else if (a === x.CHERRY_PICK)
428
- t.append("circle").attr("cx", s.x).attr("cy", s.y).attr("r", 10).attr("class", `commit ${r.id} ${n}`), t.append("circle").attr("cx", s.x - 3).attr("cy", s.y + 2).attr("r", 2.75).attr("fill", "#fff").attr("class", `commit ${r.id} ${n}`), t.append("circle").attr("cx", s.x + 3).attr("cy", s.y + 2).attr("r", 2.75).attr("fill", "#fff").attr("class", `commit ${r.id} ${n}`), t.append("line").attr("x1", s.x + 3).attr("y1", s.y + 1).attr("x2", s.x).attr("y2", s.y - 5).attr("stroke", "#fff").attr("class", `commit ${r.id} ${n}`), t.append("line").attr("x1", s.x - 3).attr("y1", s.y + 1).attr("x2", s.x).attr("y2", s.y - 5).attr("stroke", "#fff").attr("class", `commit ${r.id} ${n}`);
429
- else {
430
- const d = t.append("circle");
431
- if (d.attr("cx", s.x), d.attr("cy", s.y), d.attr("r", r.type === x.MERGE ? 9 : 10), d.attr("class", `commit ${r.id} commit${e % M}`), a === x.MERGE) {
432
- const o = t.append("circle");
433
- o.attr("cx", s.x), o.attr("cy", s.y), o.attr("r", 6), o.attr(
434
- "class",
435
- `commit ${n} ${r.id} commit${e % M}`
436
- );
437
- }
438
- a === x.REVERSE && t.append("path").attr(
439
- "d",
440
- `M ${s.x - 5},${s.y - 5}L${s.x + 5},${s.y + 5}M${s.x - 5},${s.y + 5}L${s.x + 5},${s.y - 5}`
441
- ).attr("class", `commit ${n} ${r.id} commit${e % M}`);
442
- }
443
- }, "drawCommitBullet"), Sr = /* @__PURE__ */ l((t, r, s, n) => {
444
- if (r.type !== x.CHERRY_PICK && (r.customId && r.type === x.MERGE || r.type !== x.MERGE) && v?.showCommitLabel) {
445
- const e = t.append("g"), a = e.insert("rect").attr("class", "commit-label-bkg"), d = e.append("text").attr("x", n).attr("y", s.y + 25).attr("class", "commit-label").text(r.id), o = d.node()?.getBBox();
446
- if (o && (a.attr("x", s.posWithOffset - o.width / 2 - T).attr("y", s.y + 13.5).attr("width", o.width + 2 * T).attr("height", o.height + 2 * T), u === "TB" || u === "BT" ? (a.attr("x", s.x - (o.width + 4 * E + 5)).attr("y", s.y - 12), d.attr("x", s.x - (o.width + 4 * E)).attr("y", s.y + o.height - 12)) : d.attr("x", s.posWithOffset - o.width / 2), v.rotateCommitLabel))
447
- if (u === "TB" || u === "BT")
448
- d.attr(
449
- "transform",
450
- "rotate(-45, " + s.x + ", " + s.y + ")"
451
- ), a.attr(
452
- "transform",
453
- "rotate(-45, " + s.x + ", " + s.y + ")"
454
- );
455
- else {
456
- const f = -7.5 - (o.width + 10) / 25 * 9.5, h = 10 + o.width / 25 * 8.5;
457
- e.attr(
458
- "transform",
459
- "translate(" + f + ", " + h + ") rotate(-45, " + n + ", " + s.y + ")"
460
- );
461
- }
462
- }
463
- }, "drawCommitLabel"), Wr = /* @__PURE__ */ l((t, r, s, n) => {
464
- if (r.tags.length > 0) {
465
- let e = 0, a = 0, d = 0;
466
- const o = [];
467
- for (const f of r.tags.reverse()) {
468
- const h = t.insert("polygon"), $ = t.append("circle"), g = t.append("text").attr("y", s.y - 16 - e).attr("class", "tag-label").text(f), i = g.node()?.getBBox();
469
- if (!i)
470
- throw new Error("Tag bbox not found");
471
- a = Math.max(a, i.width), d = Math.max(d, i.height), g.attr("x", s.posWithOffset - i.width / 2), o.push({
472
- tag: g,
473
- hole: $,
474
- rect: h,
475
- yOffset: e
476
- }), e += 20;
477
- }
478
- for (const { tag: f, hole: h, rect: $, yOffset: g } of o) {
479
- const i = d / 2, y = s.y - 19.2 - g;
480
- if ($.attr("class", "tag-label-bkg").attr(
481
- "points",
482
- `
483
- ${n - a / 2 - E / 2},${y + T}
484
- ${n - a / 2 - E / 2},${y - T}
485
- ${s.posWithOffset - a / 2 - E},${y - i - T}
486
- ${s.posWithOffset + a / 2 + E},${y - i - T}
487
- ${s.posWithOffset + a / 2 + E},${y + i + T}
488
- ${s.posWithOffset - a / 2 - E},${y + i + T}`
489
- ), h.attr("cy", y).attr("cx", n - a / 2 + E / 2).attr("r", 1.5).attr("class", "tag-hole"), u === "TB" || u === "BT") {
490
- const p = n + g;
491
- $.attr("class", "tag-label-bkg").attr(
492
- "points",
493
- `
494
- ${s.x},${p + 2}
495
- ${s.x},${p - 2}
496
- ${s.x + L},${p - i - 2}
497
- ${s.x + L + a + 4},${p - i - 2}
498
- ${s.x + L + a + 4},${p + i + 2}
499
- ${s.x + L},${p + i + 2}`
500
- ).attr("transform", "translate(12,12) rotate(45, " + s.x + "," + n + ")"), h.attr("cx", s.x + E / 2).attr("cy", p).attr("transform", "translate(12,12) rotate(45, " + s.x + "," + n + ")"), f.attr("x", s.x + 5).attr("y", p + 3).attr("transform", "translate(14,14) rotate(45, " + s.x + "," + n + ")");
501
- }
502
- }
503
- }
504
- }, "drawCommitTags"), jr = /* @__PURE__ */ l((t) => {
505
- switch (t.customType ?? t.type) {
506
- case x.NORMAL:
507
- return "commit-normal";
508
- case x.REVERSE:
509
- return "commit-reverse";
510
- case x.HIGHLIGHT:
511
- return "commit-highlight";
512
- case x.MERGE:
513
- return "commit-merge";
514
- case x.CHERRY_PICK:
515
- return "commit-cherry-pick";
516
- default:
517
- return "commit-normal";
518
- }
519
- }, "getCommitClassType"), Yr = /* @__PURE__ */ l((t, r, s, n) => {
520
- const e = { x: 0, y: 0 };
521
- if (t.parents.length > 0) {
522
- const a = j(t.parents);
523
- if (a) {
524
- const d = n.get(a) ?? e;
525
- return r === "TB" ? d.y + k : r === "BT" ? (n.get(t.id) ?? e).y - k : d.x + k;
526
- }
527
- } else
528
- return r === "TB" ? O : r === "BT" ? (n.get(t.id) ?? e).y - k : 0;
529
- return 0;
530
- }, "calculatePosition"), Kr = /* @__PURE__ */ l((t, r, s) => {
531
- const n = u === "BT" && s ? r : r + L, e = u === "TB" || u === "BT" ? n : b.get(t.branch)?.pos, a = u === "TB" || u === "BT" ? b.get(t.branch)?.pos : n;
532
- if (a === void 0 || e === void 0)
533
- throw new Error(`Position were undefined for commit ${t.id}`);
534
- return { x: a, y: e, posWithOffset: n };
535
- }, "getCommitPosition"), D = /* @__PURE__ */ l((t, r, s) => {
536
- if (!v)
537
- throw new Error("GitGraph config not found");
538
- const n = t.append("g").attr("class", "commit-bullets"), e = t.append("g").attr("class", "commit-labels");
539
- let a = u === "TB" || u === "BT" ? O : 0;
540
- const d = [...r.keys()], o = v?.parallelCommits ?? !1, f = /* @__PURE__ */ l(($, g) => {
541
- const i = r.get($)?.seq, y = r.get(g)?.seq;
542
- return i !== void 0 && y !== void 0 ? i - y : 0;
543
- }, "sortKeys");
544
- let h = d.sort(f);
545
- u === "BT" && (o && Hr(h, r, a), h = h.reverse()), h.forEach(($) => {
546
- const g = r.get($);
547
- if (!g)
548
- throw new Error(`Commit not found for key ${$}`);
549
- o && (a = Yr(g, u, a, w));
550
- const i = Kr(g, a, o);
551
- if (s) {
552
- const y = jr(g), p = g.customType ?? g.type, _ = b.get(g.branch)?.index ?? 0;
553
- Nr(n, g, i, y, _, p), Sr(e, g, i, a), Wr(e, g, i, a);
554
- }
555
- u === "TB" || u === "BT" ? w.set(g.id, { x: i.x, y: i.posWithOffset }) : w.set(g.id, { x: i.posWithOffset, y: i.y }), a = u === "BT" && o ? a + k : a + k + L, a > B && (B = a);
556
- });
557
- }, "drawCommits"), Ur = /* @__PURE__ */ l((t, r, s, n, e) => {
558
- const d = (u === "TB" || u === "BT" ? s.x < n.x : s.y < n.y) ? r.branch : t.branch, o = /* @__PURE__ */ l((h) => h.branch === d, "isOnBranchToGetCurve"), f = /* @__PURE__ */ l((h) => h.seq > t.seq && h.seq < r.seq, "isBetweenCommits");
559
- return [...e.values()].some((h) => f(h) && o(h));
560
- }, "shouldRerouteArrow"), G = /* @__PURE__ */ l((t, r, s = 0) => {
561
- const n = t + Math.abs(t - r) / 2;
562
- if (s > 5)
563
- return n;
564
- if (q.every((d) => Math.abs(d - n) >= 10))
565
- return q.push(n), n;
566
- const a = Math.abs(t - r);
567
- return G(t, r - a / 5, s + 1);
568
- }, "findLane"), Vr = /* @__PURE__ */ l((t, r, s, n) => {
569
- const e = w.get(r.id), a = w.get(s.id);
570
- if (e === void 0 || a === void 0)
571
- throw new Error(`Commit positions not found for commits ${r.id} and ${s.id}`);
572
- const d = Ur(r, s, e, a, n);
573
- let o = "", f = "", h = 0, $ = 0, g = b.get(s.branch)?.index;
574
- s.type === x.MERGE && r.id !== s.parents[0] && (g = b.get(r.branch)?.index);
575
- let i;
576
- if (d) {
577
- o = "A 10 10, 0, 0, 0,", f = "A 10 10, 0, 0, 1,", h = 10, $ = 10;
578
- const y = e.y < a.y ? G(e.y, a.y) : G(a.y, e.y), p = e.x < a.x ? G(e.x, a.x) : G(a.x, e.x);
579
- u === "TB" ? e.x < a.x ? i = `M ${e.x} ${e.y} L ${p - h} ${e.y} ${f} ${p} ${e.y + $} L ${p} ${a.y - h} ${o} ${p + $} ${a.y} L ${a.x} ${a.y}` : (g = b.get(r.branch)?.index, i = `M ${e.x} ${e.y} L ${p + h} ${e.y} ${o} ${p} ${e.y + $} L ${p} ${a.y - h} ${f} ${p - $} ${a.y} L ${a.x} ${a.y}`) : u === "BT" ? e.x < a.x ? i = `M ${e.x} ${e.y} L ${p - h} ${e.y} ${o} ${p} ${e.y - $} L ${p} ${a.y + h} ${f} ${p + $} ${a.y} L ${a.x} ${a.y}` : (g = b.get(r.branch)?.index, i = `M ${e.x} ${e.y} L ${p + h} ${e.y} ${f} ${p} ${e.y - $} L ${p} ${a.y + h} ${o} ${p - $} ${a.y} L ${a.x} ${a.y}`) : e.y < a.y ? i = `M ${e.x} ${e.y} L ${e.x} ${y - h} ${o} ${e.x + $} ${y} L ${a.x - h} ${y} ${f} ${a.x} ${y + $} L ${a.x} ${a.y}` : (g = b.get(r.branch)?.index, i = `M ${e.x} ${e.y} L ${e.x} ${y + h} ${f} ${e.x + $} ${y} L ${a.x - h} ${y} ${o} ${a.x} ${y - $} L ${a.x} ${a.y}`);
580
- } else
581
- o = "A 20 20, 0, 0, 0,", f = "A 20 20, 0, 0, 1,", h = 20, $ = 20, u === "TB" ? (e.x < a.x && (s.type === x.MERGE && r.id !== s.parents[0] ? i = `M ${e.x} ${e.y} L ${e.x} ${a.y - h} ${o} ${e.x + $} ${a.y} L ${a.x} ${a.y}` : i = `M ${e.x} ${e.y} L ${a.x - h} ${e.y} ${f} ${a.x} ${e.y + $} L ${a.x} ${a.y}`), e.x > a.x && (o = "A 20 20, 0, 0, 0,", f = "A 20 20, 0, 0, 1,", h = 20, $ = 20, s.type === x.MERGE && r.id !== s.parents[0] ? i = `M ${e.x} ${e.y} L ${e.x} ${a.y - h} ${f} ${e.x - $} ${a.y} L ${a.x} ${a.y}` : i = `M ${e.x} ${e.y} L ${a.x + h} ${e.y} ${o} ${a.x} ${e.y + $} L ${a.x} ${a.y}`), e.x === a.x && (i = `M ${e.x} ${e.y} L ${a.x} ${a.y}`)) : u === "BT" ? (e.x < a.x && (s.type === x.MERGE && r.id !== s.parents[0] ? i = `M ${e.x} ${e.y} L ${e.x} ${a.y + h} ${f} ${e.x + $} ${a.y} L ${a.x} ${a.y}` : i = `M ${e.x} ${e.y} L ${a.x - h} ${e.y} ${o} ${a.x} ${e.y - $} L ${a.x} ${a.y}`), e.x > a.x && (o = "A 20 20, 0, 0, 0,", f = "A 20 20, 0, 0, 1,", h = 20, $ = 20, s.type === x.MERGE && r.id !== s.parents[0] ? i = `M ${e.x} ${e.y} L ${e.x} ${a.y + h} ${o} ${e.x - $} ${a.y} L ${a.x} ${a.y}` : i = `M ${e.x} ${e.y} L ${a.x - h} ${e.y} ${o} ${a.x} ${e.y - $} L ${a.x} ${a.y}`), e.x === a.x && (i = `M ${e.x} ${e.y} L ${a.x} ${a.y}`)) : (e.y < a.y && (s.type === x.MERGE && r.id !== s.parents[0] ? i = `M ${e.x} ${e.y} L ${a.x - h} ${e.y} ${f} ${a.x} ${e.y + $} L ${a.x} ${a.y}` : i = `M ${e.x} ${e.y} L ${e.x} ${a.y - h} ${o} ${e.x + $} ${a.y} L ${a.x} ${a.y}`), e.y > a.y && (s.type === x.MERGE && r.id !== s.parents[0] ? i = `M ${e.x} ${e.y} L ${a.x - h} ${e.y} ${o} ${a.x} ${e.y - $} L ${a.x} ${a.y}` : i = `M ${e.x} ${e.y} L ${e.x} ${a.y + h} ${f} ${e.x + $} ${a.y} L ${a.x} ${a.y}`), e.y === a.y && (i = `M ${e.x} ${e.y} L ${a.x} ${a.y}`));
582
- if (i === void 0)
583
- throw new Error("Line definition not found");
584
- t.append("path").attr("d", i).attr("class", "arrow arrow" + g % M);
585
- }, "drawArrow"), Xr = /* @__PURE__ */ l((t, r) => {
586
- const s = t.append("g").attr("class", "commit-arrows");
587
- [...r.keys()].forEach((n) => {
588
- const e = r.get(n);
589
- e.parents && e.parents.length > 0 && e.parents.forEach((a) => {
590
- Vr(s, r.get(a), e, r);
591
- });
592
- });
593
- }, "drawArrows"), Jr = /* @__PURE__ */ l((t, r) => {
594
- const s = t.append("g");
595
- r.forEach((n, e) => {
596
- const a = e % M, d = b.get(n.name)?.pos;
597
- if (d === void 0)
598
- throw new Error(`Position not found for branch ${n.name}`);
599
- const o = s.append("line");
600
- o.attr("x1", 0), o.attr("y1", d), o.attr("x2", B), o.attr("y2", d), o.attr("class", "branch branch" + a), u === "TB" ? (o.attr("y1", O), o.attr("x1", d), o.attr("y2", B), o.attr("x2", d)) : u === "BT" && (o.attr("y1", B), o.attr("x1", d), o.attr("y2", O), o.attr("x2", d)), q.push(d);
601
- const f = n.name, h = W(f), $ = s.insert("rect"), i = s.insert("g").attr("class", "branchLabel").insert("g").attr("class", "label branch-label" + a);
602
- i.node().appendChild(h);
603
- const y = h.getBBox();
604
- $.attr("class", "branchLabelBkg label" + a).attr("rx", 4).attr("ry", 4).attr("x", -y.width - 4 - (v?.rotateCommitLabel === !0 ? 30 : 0)).attr("y", -y.height / 2 + 8).attr("width", y.width + 18).attr("height", y.height + 4), i.attr(
605
- "transform",
606
- "translate(" + (-y.width - 14 - (v?.rotateCommitLabel === !0 ? 30 : 0)) + ", " + (d - y.height / 2 - 1) + ")"
607
- ), u === "TB" ? ($.attr("x", d - y.width / 2 - 10).attr("y", 0), i.attr("transform", "translate(" + (d - y.width / 2 - 5) + ", 0)")) : u === "BT" ? ($.attr("x", d - y.width / 2 - 10).attr("y", B), i.attr("transform", "translate(" + (d - y.width / 2 - 5) + ", " + B + ")")) : $.attr("transform", "translate(-19, " + (d - y.height / 2) + ")");
608
- });
609
- }, "drawBranches"), Qr = /* @__PURE__ */ l(function(t, r, s, n, e) {
610
- return b.set(t, { pos: r, index: s }), r += 50 + (e ? 40 : 0) + (u === "TB" || u === "BT" ? n.width / 2 : 0), r;
611
- }, "setBranchPosition"), Zr = /* @__PURE__ */ l(function(t, r, s, n) {
612
- if (Ar(), m.debug("in gitgraph renderer", t + `
613
- `, "id:", r, s), !v)
614
- throw new Error("GitGraph config not found");
615
- const e = v.rotateCommitLabel ?? !1, a = n.db;
616
- R = a.getCommits();
617
- const d = a.getBranchesAsObjArray();
618
- u = a.getDirection();
619
- const o = er(`[id="${r}"]`);
620
- let f = 0;
621
- d.forEach((h, $) => {
622
- const g = W(h.name), i = o.append("g"), y = i.insert("g").attr("class", "branchLabel"), p = y.insert("g").attr("class", "label branch-label");
623
- p.node()?.appendChild(g);
624
- const _ = g.getBBox();
625
- f = Qr(h.name, f, $, _, e), p.remove(), y.remove(), i.remove();
626
- }), D(o, R, !1), v.showBranches && Jr(o, d), Xr(o, R), D(o, R, !0), tr.insertTitle(
627
- o,
628
- "gitTitleText",
629
- v.titleTopMargin ?? 0,
630
- a.getDiagramTitle()
631
- ), ar(
632
- void 0,
633
- o,
634
- v.diagramPadding,
635
- v.useMaxWidth
636
- );
637
- }, "draw"), re = {
638
- draw: Zr
639
- }, ee = /* @__PURE__ */ l((t) => `
640
- .commit-id,
641
- .commit-msg,
642
- .branch-label {
643
- fill: lightgrey;
644
- color: lightgrey;
645
- font-family: 'trebuchet ms', verdana, arial, sans-serif;
646
- font-family: var(--mermaid-font-family);
647
- }
648
- ${[0, 1, 2, 3, 4, 5, 6, 7].map(
649
- (r) => `
650
- .branch-label${r} { fill: ${t["gitBranchLabel" + r]}; }
651
- .commit${r} { stroke: ${t["git" + r]}; fill: ${t["git" + r]}; }
652
- .commit-highlight${r} { stroke: ${t["gitInv" + r]}; fill: ${t["gitInv" + r]}; }
653
- .label${r} { fill: ${t["git" + r]}; }
654
- .arrow${r} { stroke: ${t["git" + r]}; }
655
- `
656
- ).join(`
657
- `)}
658
-
659
- .branch {
660
- stroke-width: 1;
661
- stroke: ${t.lineColor};
662
- stroke-dasharray: 2;
663
- }
664
- .commit-label { font-size: ${t.commitLabelFontSize}; fill: ${t.commitLabelColor};}
665
- .commit-label-bkg { font-size: ${t.commitLabelFontSize}; fill: ${t.commitLabelBackground}; opacity: 0.5; }
666
- .tag-label { font-size: ${t.tagLabelFontSize}; fill: ${t.tagLabelColor};}
667
- .tag-label-bkg { fill: ${t.tagLabelBackground}; stroke: ${t.tagLabelBorder}; }
668
- .tag-hole { fill: ${t.textColor}; }
669
-
670
- .commit-merge {
671
- stroke: ${t.primaryColor};
672
- fill: ${t.primaryColor};
673
- }
674
- .commit-reverse {
675
- stroke: ${t.primaryColor};
676
- fill: ${t.primaryColor};
677
- stroke-width: 3;
678
- }
679
- .commit-highlight-outer {
680
- }
681
- .commit-highlight-inner {
682
- stroke: ${t.primaryColor};
683
- fill: ${t.primaryColor};
684
- }
685
-
686
- .arrow { stroke-width: 8; stroke-linecap: round; fill: none}
687
- .gitTitleText {
688
- text-anchor: middle;
689
- font-size: 18px;
690
- fill: ${t.textColor};
691
- }
692
- `, "getStyles"), te = ee, ie = {
693
- parser: Or,
694
- db: S,
695
- renderer: re,
696
- styles: te
697
- };
698
- export {
699
- ie as diagram
700
- };