@diagrammo/dgmo 0.3.2 → 0.4.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.
package/dist/index.js CHANGED
@@ -1285,6 +1285,31 @@ function collectIndentedValues(lines, startIndex) {
1285
1285
  }
1286
1286
  return { values, newIndex: j - 1 };
1287
1287
  }
1288
+ function parseSeriesNames(value, lines, lineIndex, palette) {
1289
+ let rawNames;
1290
+ let series;
1291
+ let newIndex = lineIndex;
1292
+ if (value) {
1293
+ series = value;
1294
+ rawNames = value.split(",").map((s) => s.trim()).filter(Boolean);
1295
+ } else {
1296
+ const collected = collectIndentedValues(lines, lineIndex);
1297
+ newIndex = collected.newIndex;
1298
+ rawNames = collected.values;
1299
+ series = rawNames.join(", ");
1300
+ }
1301
+ const names = [];
1302
+ const nameColors = [];
1303
+ for (const raw of rawNames) {
1304
+ const extracted = extractColor(raw, palette);
1305
+ nameColors.push(extracted.color);
1306
+ names.push(extracted.label);
1307
+ }
1308
+ if (names.length === 1) {
1309
+ series = names[0];
1310
+ }
1311
+ return { series, names, nameColors, newIndex };
1312
+ }
1288
1313
  function parsePipeMetadata(segments, aliasMap = /* @__PURE__ */ new Map()) {
1289
1314
  const metadata = {};
1290
1315
  for (let j = 1; j < segments.length; j++) {
@@ -1590,13 +1615,25 @@ var init_participant_inference = __esm({
1590
1615
 
1591
1616
  // src/utils/arrows.ts
1592
1617
  function parseArrow(line7) {
1618
+ if (BIDI_SYNC_RE.test(line7) || BIDI_ASYNC_RE.test(line7)) {
1619
+ return {
1620
+ error: "Bidirectional arrows are no longer supported. Use two separate lines: 'A -msg-> B' and 'B -msg-> A'"
1621
+ };
1622
+ }
1623
+ if (RETURN_SYNC_LABELED_RE.test(line7) || RETURN_ASYNC_LABELED_RE.test(line7)) {
1624
+ const m = line7.match(RETURN_SYNC_LABELED_RE) ?? line7.match(RETURN_ASYNC_LABELED_RE);
1625
+ const from = m[3];
1626
+ const to = m[1];
1627
+ const label = m[2].trim();
1628
+ return {
1629
+ error: `Left-pointing arrows are no longer supported. Write '${from} -${label}-> ${to}' instead`
1630
+ };
1631
+ }
1593
1632
  const patterns = [
1594
- { re: BIDI_SYNC_LABELED_RE, async: false, bidirectional: true },
1595
- { re: BIDI_ASYNC_LABELED_RE, async: true, bidirectional: true },
1596
- { re: SYNC_LABELED_RE, async: false, bidirectional: false },
1597
- { re: ASYNC_LABELED_RE, async: true, bidirectional: false }
1633
+ { re: SYNC_LABELED_RE, async: false },
1634
+ { re: ASYNC_LABELED_RE, async: true }
1598
1635
  ];
1599
- for (const { re, async: isAsync, bidirectional } of patterns) {
1636
+ for (const { re, async: isAsync } of patterns) {
1600
1637
  const m = line7.match(re);
1601
1638
  if (!m) continue;
1602
1639
  const label = m[2].trim();
@@ -1612,21 +1649,22 @@ function parseArrow(line7) {
1612
1649
  from: m[1],
1613
1650
  to: m[3],
1614
1651
  label,
1615
- async: isAsync,
1616
- bidirectional
1652
+ async: isAsync
1617
1653
  };
1618
1654
  }
1619
1655
  return null;
1620
1656
  }
1621
- var BIDI_SYNC_LABELED_RE, BIDI_ASYNC_LABELED_RE, SYNC_LABELED_RE, ASYNC_LABELED_RE, ARROW_CHARS;
1657
+ var SYNC_LABELED_RE, ASYNC_LABELED_RE, RETURN_SYNC_LABELED_RE, RETURN_ASYNC_LABELED_RE, BIDI_SYNC_RE, BIDI_ASYNC_RE, ARROW_CHARS;
1622
1658
  var init_arrows = __esm({
1623
1659
  "src/utils/arrows.ts"() {
1624
1660
  "use strict";
1625
- BIDI_SYNC_LABELED_RE = /^(\S+)\s+<-(.+)->\s+(\S+)$/;
1626
- BIDI_ASYNC_LABELED_RE = /^(\S+)\s+<~(.+)~>\s+(\S+)$/;
1627
1661
  SYNC_LABELED_RE = /^(\S+)\s+-(.+)->\s+(\S+)$/;
1628
1662
  ASYNC_LABELED_RE = /^(\S+)\s+~(.+)~>\s+(\S+)$/;
1629
- ARROW_CHARS = ["->", "~>", "<->", "<~>"];
1663
+ RETURN_SYNC_LABELED_RE = /^(\S+)\s+<-(.+)-\s+(\S+)$/;
1664
+ RETURN_ASYNC_LABELED_RE = /^(\S+)\s+<~(.+)~\s+(\S+)$/;
1665
+ BIDI_SYNC_RE = /^(\S+)\s+<-(.+)->\s+(\S+)$/;
1666
+ BIDI_ASYNC_RE = /^(\S+)\s+<~(.+)~>\s+(\S+)$/;
1667
+ ARROW_CHARS = ["->", "~>"];
1630
1668
  }
1631
1669
  });
1632
1670
 
@@ -1648,36 +1686,6 @@ function isSequenceSection(el) {
1648
1686
  function isSequenceNote(el) {
1649
1687
  return "kind" in el && el.kind === "note";
1650
1688
  }
1651
- function parseReturnLabel(rawLabel) {
1652
- if (!rawLabel) return { label: "" };
1653
- const standaloneMatch = rawLabel.match(/^<-\s*(.*)$/);
1654
- if (standaloneMatch) {
1655
- return {
1656
- label: standaloneMatch[1].trim(),
1657
- standaloneReturn: true
1658
- };
1659
- }
1660
- const arrowReturn = rawLabel.match(ARROW_RETURN_PATTERN);
1661
- if (arrowReturn) {
1662
- return { label: arrowReturn[1].trim(), returnLabel: arrowReturn[2].trim() };
1663
- }
1664
- const umlReturn = rawLabel.match(UML_RETURN_PATTERN);
1665
- if (umlReturn) {
1666
- return { label: umlReturn[1].trim(), returnLabel: umlReturn[2].trim() };
1667
- }
1668
- const lastColon = rawLabel.lastIndexOf(":");
1669
- if (lastColon > 0 && lastColon < rawLabel.length - 1) {
1670
- const afterColon = rawLabel.substring(lastColon + 1);
1671
- if (!afterColon.startsWith("//")) {
1672
- const reqPart = rawLabel.substring(0, lastColon).trim();
1673
- const resPart = afterColon.trim();
1674
- if (reqPart && resPart) {
1675
- return { label: reqPart, returnLabel: resPart };
1676
- }
1677
- }
1678
- }
1679
- return { label: rawLabel };
1680
- }
1681
1689
  function parseSequenceDgmo(content) {
1682
1690
  const result = {
1683
1691
  title: null,
@@ -1777,7 +1785,7 @@ function parseSequenceDgmo(content) {
1777
1785
  continue;
1778
1786
  }
1779
1787
  const colonIndex = trimmed.indexOf(":");
1780
- if (colonIndex > 0 && !trimmed.includes("->") && !trimmed.includes("~>")) {
1788
+ if (colonIndex > 0 && !trimmed.includes("->") && !trimmed.includes("~>") && !trimmed.includes("<-") && !trimmed.includes("<~")) {
1781
1789
  const key = trimmed.substring(0, colonIndex).trim().toLowerCase();
1782
1790
  if (key === "note" || key.startsWith("note ")) {
1783
1791
  } else {
@@ -1906,16 +1914,14 @@ function parseSequenceDgmo(content) {
1906
1914
  }
1907
1915
  if (labeledArrow) {
1908
1916
  contentStarted = true;
1909
- const { from, to, label, async: isAsync2, bidirectional } = labeledArrow;
1917
+ const { from, to, label, async: isAsync } = labeledArrow;
1910
1918
  lastMsgFrom = from;
1911
1919
  const msg = {
1912
1920
  from,
1913
1921
  to,
1914
1922
  label,
1915
- returnLabel: void 0,
1916
1923
  lineNumber,
1917
- ...isAsync2 ? { async: true } : {},
1918
- ...bidirectional ? { bidirectional: true } : {}
1924
+ ...isAsync ? { async: true } : {}
1919
1925
  };
1920
1926
  result.messages.push(msg);
1921
1927
  currentContainer().push(msg);
@@ -1937,72 +1943,61 @@ function parseSequenceDgmo(content) {
1937
1943
  }
1938
1944
  continue;
1939
1945
  }
1940
- const bidiSyncMatch = trimmed.match(
1941
- /^(\S+)\s*<->\s*([^\s:]+)\s*(?::\s*(.+))?$/
1946
+ const colonPostfixSync = trimmed.match(
1947
+ /^(\S+)\s*->\s*([^\s:]+)\s*:\s*(.+)$/
1942
1948
  );
1943
- const bidiAsyncMatch = trimmed.match(
1944
- /^(\S+)\s*<~>\s*([^\s:]+)\s*(?::\s*(.+))?$/
1949
+ const colonPostfixAsync = trimmed.match(
1950
+ /^(\S+)\s*~>\s*([^\s:]+)\s*:\s*(.+)$/
1945
1951
  );
1946
- const bidiMatch = bidiSyncMatch || bidiAsyncMatch;
1947
- if (bidiMatch) {
1948
- contentStarted = true;
1949
- const from = bidiMatch[1];
1950
- const to = bidiMatch[2];
1951
- lastMsgFrom = from;
1952
- const rawLabel = bidiMatch[3]?.trim() || "";
1953
- const isBidiAsync = !!bidiAsyncMatch;
1954
- const msg = {
1955
- from,
1956
- to,
1957
- label: rawLabel,
1952
+ const colonPostfix = colonPostfixSync || colonPostfixAsync;
1953
+ if (colonPostfix) {
1954
+ const a = colonPostfix[1];
1955
+ const b = colonPostfix[2];
1956
+ const msg = colonPostfix[3].trim();
1957
+ const arrowChar = colonPostfixAsync ? "~" : "-";
1958
+ const arrowEnd = colonPostfixAsync ? "~>" : "->";
1959
+ pushError(
1958
1960
  lineNumber,
1959
- bidirectional: true,
1960
- ...isBidiAsync ? { async: true } : {}
1961
- };
1962
- result.messages.push(msg);
1963
- currentContainer().push(msg);
1964
- if (!result.participants.some((p) => p.id === from)) {
1965
- result.participants.push({
1966
- id: from,
1967
- label: from,
1968
- type: inferParticipantType(from),
1969
- lineNumber
1970
- });
1971
- }
1972
- if (!result.participants.some((p) => p.id === to)) {
1973
- result.participants.push({
1974
- id: to,
1975
- label: to,
1976
- type: inferParticipantType(to),
1977
- lineNumber
1978
- });
1979
- }
1961
+ `Colon syntax is no longer supported. Use '${a} ${arrowChar}${msg}${arrowEnd} ${b}' instead`
1962
+ );
1980
1963
  continue;
1981
1964
  }
1982
- let isAsync = false;
1983
- const asyncArrowMatch = trimmed.match(
1984
- /^(\S+)\s*~>\s*([^\s:]+)\s*(?::\s*(.+))?$/
1985
- );
1986
- const syncArrowMatch = trimmed.match(
1987
- /^(\S+)\s*->\s*([^\s:]+)\s*(?::\s*(.+))?$/
1965
+ const bidiPlainMatch = trimmed.match(
1966
+ /^(\S+)\s*(?:<->|<~>)\s*(\S+)/
1988
1967
  );
1989
- const arrowMatch = asyncArrowMatch || syncArrowMatch;
1990
- if (asyncArrowMatch) isAsync = true;
1991
- if (arrowMatch) {
1968
+ if (bidiPlainMatch) {
1969
+ pushError(
1970
+ lineNumber,
1971
+ "Bidirectional arrows are no longer supported. Use two separate lines: 'A -msg-> B' and 'B -msg-> A'"
1972
+ );
1973
+ continue;
1974
+ }
1975
+ const bareReturnSync = trimmed.match(/^(\S+)\s+<-\s+(\S+)$/);
1976
+ const bareReturnAsync = trimmed.match(/^(\S+)\s+<~\s+(\S+)$/);
1977
+ const bareReturn = bareReturnSync || bareReturnAsync;
1978
+ if (bareReturn) {
1979
+ const to = bareReturn[1];
1980
+ const from = bareReturn[2];
1981
+ pushError(
1982
+ lineNumber,
1983
+ `Left-pointing arrows are no longer supported. Write '${from} -> ${to}' instead`
1984
+ );
1985
+ continue;
1986
+ }
1987
+ const bareCallSync = trimmed.match(/^(\S+)\s*->\s*(\S+)$/);
1988
+ const bareCallAsync = trimmed.match(/^(\S+)\s*~>\s*(\S+)$/);
1989
+ const bareCall = bareCallSync || bareCallAsync;
1990
+ if (bareCall) {
1992
1991
  contentStarted = true;
1993
- const from = arrowMatch[1];
1994
- const to = arrowMatch[2];
1992
+ const from = bareCall[1];
1993
+ const to = bareCall[2];
1995
1994
  lastMsgFrom = from;
1996
- const rawLabel = arrowMatch[3]?.trim() || "";
1997
- const { label, returnLabel, standaloneReturn } = isAsync ? { label: rawLabel, returnLabel: void 0, standaloneReturn: void 0 } : parseReturnLabel(rawLabel);
1998
1995
  const msg = {
1999
1996
  from,
2000
1997
  to,
2001
- label,
2002
- returnLabel,
1998
+ label: "",
2003
1999
  lineNumber,
2004
- ...isAsync ? { async: true } : {},
2005
- ...standaloneReturn ? { standaloneReturn: true } : {}
2000
+ ...bareCallAsync ? { async: true } : {}
2006
2001
  };
2007
2002
  result.messages.push(msg);
2008
2003
  currentContainer().push(msg);
@@ -2211,7 +2206,7 @@ function looksLikeSequence(content) {
2211
2206
  return ARROW_PATTERN.test(trimmed);
2212
2207
  });
2213
2208
  }
2214
- var VALID_PARTICIPANT_TYPES, IS_A_PATTERN, POSITION_ONLY_PATTERN, GROUP_HEADING_PATTERN, SECTION_PATTERN, ARROW_PATTERN, ARROW_RETURN_PATTERN, UML_RETURN_PATTERN, NOTE_SINGLE, NOTE_MULTI;
2209
+ var VALID_PARTICIPANT_TYPES, IS_A_PATTERN, POSITION_ONLY_PATTERN, GROUP_HEADING_PATTERN, SECTION_PATTERN, ARROW_PATTERN, NOTE_SINGLE, NOTE_MULTI;
2215
2210
  var init_parser = __esm({
2216
2211
  "src/sequence/parser.ts"() {
2217
2212
  "use strict";
@@ -2234,9 +2229,7 @@ var init_parser = __esm({
2234
2229
  POSITION_ONLY_PATTERN = /^(\S+)\s+position\s+(-?\d+)$/i;
2235
2230
  GROUP_HEADING_PATTERN = /^##\s+(.+?)(?:\(([^)]+)\))?\s*$/;
2236
2231
  SECTION_PATTERN = /^==\s+(.+?)(?:\s*==)?\s*$/;
2237
- ARROW_PATTERN = /\S+\s*(?:<->|<~>|->|~>|-\S+->|~\S+~>|<-\S+->|<~\S+~>)\s*\S+/;
2238
- ARROW_RETURN_PATTERN = /^(.+?)\s*<-\s*(.+)$/;
2239
- UML_RETURN_PATTERN = /^(\w+\([^)]*\))\s*:\s*(.+)$/;
2232
+ ARROW_PATTERN = /\S+\s*(?:<-\S+-|<~\S+~|-\S+->|~\S+~>|->|~>|<-|<~)\s*\S+/;
2240
2233
  NOTE_SINGLE = /^note(?:\s+(right|left)\s+of\s+(\S+))?\s*:\s*(.+)$/i;
2241
2234
  NOTE_MULTI = /^note(?:\s+(right|left)\s+of\s+([^\s:]+))?\s*:?\s*$/i;
2242
2235
  }
@@ -3142,49 +3135,19 @@ function parseChart(content, palette) {
3142
3135
  continue;
3143
3136
  }
3144
3137
  if (key === "series") {
3145
- let rawNames;
3146
- if (value) {
3147
- result.series = value;
3148
- rawNames = value.split(",").map((s) => s.trim()).filter(Boolean);
3149
- } else {
3150
- const collected = collectIndentedValues(lines, i);
3151
- i = collected.newIndex;
3152
- rawNames = collected.values;
3153
- result.series = rawNames.join(", ");
3138
+ const parsed = parseSeriesNames(value, lines, i, palette);
3139
+ i = parsed.newIndex;
3140
+ result.series = parsed.series;
3141
+ if (parsed.names.length > 1) {
3142
+ result.seriesNames = parsed.names;
3154
3143
  }
3155
- const names = [];
3156
- const nameColors = [];
3157
- for (const raw of rawNames) {
3158
- const colorMatch = raw.match(/\(([^)]+)\)\s*$/);
3159
- if (colorMatch) {
3160
- const resolved = resolveColor(colorMatch[1].trim(), palette);
3161
- nameColors.push(resolved);
3162
- names.push(raw.substring(0, colorMatch.index).trim());
3163
- } else {
3164
- nameColors.push(void 0);
3165
- names.push(raw);
3166
- }
3167
- }
3168
- if (names.length === 1) {
3169
- result.series = names[0];
3170
- }
3171
- if (names.length > 1) {
3172
- result.seriesNames = names;
3173
- }
3174
- if (nameColors.some(Boolean)) result.seriesNameColors = nameColors;
3144
+ if (parsed.nameColors.some(Boolean)) result.seriesNameColors = parsed.nameColors;
3175
3145
  continue;
3176
3146
  }
3177
3147
  const parts = value.split(",").map((s) => s.trim());
3178
3148
  const numValue = parseFloat(parts[0]);
3179
3149
  if (!isNaN(numValue)) {
3180
- let rawLabel = trimmed.substring(0, colonIndex).trim();
3181
- let pointColor;
3182
- const colorMatch = rawLabel.match(/\(([^)]+)\)\s*$/);
3183
- if (colorMatch) {
3184
- const resolved = resolveColor(colorMatch[1].trim(), palette);
3185
- pointColor = resolved;
3186
- rawLabel = rawLabel.substring(0, colorMatch.index).trim();
3187
- }
3150
+ const { label: rawLabel, color: pointColor } = extractColor(trimmed.substring(0, colonIndex).trim(), palette);
3188
3151
  const extra = parts.slice(1).map((s) => parseFloat(s)).filter((n) => !isNaN(n));
3189
3152
  result.data.push({
3190
3153
  label: rawLabel,
@@ -3264,13 +3227,10 @@ function parseEChart(content, palette) {
3264
3227
  if (!trimmed) continue;
3265
3228
  const mdCategoryMatch = trimmed.match(/^#{2,}\s+(.+)$/);
3266
3229
  if (mdCategoryMatch) {
3267
- let catName = mdCategoryMatch[1].trim();
3268
- const catColorMatch = catName.match(/\(([^)]+)\)\s*$/);
3269
- if (catColorMatch) {
3270
- const resolved = resolveColor(catColorMatch[1].trim(), palette);
3230
+ const { label: catName, color: catColor } = extractColor(mdCategoryMatch[1].trim(), palette);
3231
+ if (catColor) {
3271
3232
  if (!result.categoryColors) result.categoryColors = {};
3272
- catName = catName.substring(0, catColorMatch.index).trim();
3273
- result.categoryColors[catName] = resolved;
3233
+ result.categoryColors[catName] = catColor;
3274
3234
  }
3275
3235
  currentCategory = catName;
3276
3236
  continue;
@@ -3307,32 +3267,13 @@ function parseEChart(content, palette) {
3307
3267
  continue;
3308
3268
  }
3309
3269
  if (key === "series") {
3310
- let rawNames;
3311
- if (value) {
3312
- result.series = value;
3313
- rawNames = value.split(",").map((s) => s.trim()).filter(Boolean);
3314
- } else {
3315
- const collected = collectIndentedValues(lines, i);
3316
- i = collected.newIndex;
3317
- rawNames = collected.values;
3318
- result.series = rawNames.join(", ");
3319
- }
3320
- const names = [];
3321
- const nameColors = [];
3322
- for (const raw of rawNames) {
3323
- const colorMatch = raw.match(/\(([^)]+)\)\s*$/);
3324
- if (colorMatch) {
3325
- nameColors.push(resolveColor(colorMatch[1].trim(), palette));
3326
- names.push(raw.substring(0, colorMatch.index).trim());
3327
- } else {
3328
- nameColors.push(void 0);
3329
- names.push(raw);
3330
- }
3331
- }
3332
- if (names.length === 1) {
3333
- result.series = names[0];
3270
+ const parsed = parseSeriesNames(value, lines, i, palette);
3271
+ i = parsed.newIndex;
3272
+ result.series = parsed.series;
3273
+ if (parsed.names.length > 1) {
3274
+ result.seriesNames = parsed.names;
3334
3275
  }
3335
- if (nameColors.some(Boolean)) result.seriesNameColors = nameColors;
3276
+ if (parsed.nameColors.some(Boolean)) result.seriesNameColors = parsed.nameColors;
3336
3277
  continue;
3337
3278
  }
3338
3279
  if (key === "xlabel") {
@@ -3394,13 +3335,7 @@ function parseEChart(content, palette) {
3394
3335
  continue;
3395
3336
  }
3396
3337
  if (result.type === "function") {
3397
- let fnName = trimmed.substring(0, colonIndex).trim();
3398
- let fnColor;
3399
- const colorMatch = fnName.match(/\(([^)]+)\)\s*$/);
3400
- if (colorMatch) {
3401
- fnColor = resolveColor(colorMatch[1].trim(), palette);
3402
- fnName = fnName.substring(0, colorMatch.index).trim();
3403
- }
3338
+ const { label: fnName, color: fnColor } = extractColor(trimmed.substring(0, colonIndex).trim(), palette);
3404
3339
  if (!result.functions) result.functions = [];
3405
3340
  result.functions.push({
3406
3341
  name: fnName,
@@ -3415,13 +3350,7 @@ function parseEChart(content, palette) {
3415
3350
  /^(-?[\d.]+)\s*,\s*(-?[\d.]+)(?:\s*,\s*(-?[\d.]+))?$/
3416
3351
  );
3417
3352
  if (scatterMatch) {
3418
- let scatterName = trimmed.substring(0, colonIndex).trim();
3419
- let scatterColor;
3420
- const colorMatch = scatterName.match(/\(([^)]+)\)\s*$/);
3421
- if (colorMatch) {
3422
- scatterColor = resolveColor(colorMatch[1].trim(), palette);
3423
- scatterName = scatterName.substring(0, colorMatch.index).trim();
3424
- }
3353
+ const { label: scatterName, color: scatterColor } = extractColor(trimmed.substring(0, colonIndex).trim(), palette);
3425
3354
  if (!result.scatterPoints) result.scatterPoints = [];
3426
3355
  result.scatterPoints.push({
3427
3356
  name: scatterName,
@@ -3446,13 +3375,7 @@ function parseEChart(content, palette) {
3446
3375
  }
3447
3376
  const numValue = parseFloat(value);
3448
3377
  if (!isNaN(numValue)) {
3449
- let rawLabel = trimmed.substring(0, colonIndex).trim();
3450
- let pointColor;
3451
- const colorMatch = rawLabel.match(/\(([^)]+)\)\s*$/);
3452
- if (colorMatch) {
3453
- pointColor = resolveColor(colorMatch[1].trim(), palette);
3454
- rawLabel = rawLabel.substring(0, colorMatch.index).trim();
3455
- }
3378
+ const { label: rawLabel, color: pointColor } = extractColor(trimmed.substring(0, colonIndex).trim(), palette);
3456
3379
  result.data.push({
3457
3380
  label: rawLabel,
3458
3381
  value: numValue,
@@ -3499,30 +3422,21 @@ function parseEChart(content, palette) {
3499
3422
  }
3500
3423
  return result;
3501
3424
  }
3502
- function buildEChartsOption(parsed, palette, isDark) {
3425
+ function buildChartCommons(parsed, palette, isDark) {
3503
3426
  const textColor = palette.text;
3504
3427
  const axisLineColor = palette.border;
3428
+ const splitLineColor = palette.border;
3505
3429
  const gridOpacity = isDark ? 0.7 : 0.55;
3506
3430
  const colors = getSeriesColors(palette);
3431
+ const titleConfig = parsed.title ? { text: parsed.title, left: "center", top: 8, textStyle: { color: textColor, fontSize: 20, fontWeight: "bold", fontFamily: FONT_FAMILY } } : void 0;
3432
+ const tooltipTheme = { backgroundColor: palette.surface, borderColor: palette.border, textStyle: { color: palette.text } };
3433
+ return { textColor, axisLineColor, splitLineColor, gridOpacity, colors, titleConfig, tooltipTheme };
3434
+ }
3435
+ function buildEChartsOption(parsed, palette, isDark) {
3507
3436
  if (parsed.error) {
3508
3437
  return {};
3509
3438
  }
3510
- const titleConfig = parsed.title ? {
3511
- text: parsed.title,
3512
- left: "center",
3513
- top: 8,
3514
- textStyle: {
3515
- color: textColor,
3516
- fontSize: 20,
3517
- fontWeight: "bold",
3518
- fontFamily: FONT_FAMILY
3519
- }
3520
- } : void 0;
3521
- const tooltipTheme = {
3522
- backgroundColor: palette.surface,
3523
- borderColor: palette.border,
3524
- textStyle: { color: palette.text }
3525
- };
3439
+ const { textColor, axisLineColor, gridOpacity, colors, titleConfig, tooltipTheme } = buildChartCommons(parsed, palette, isDark);
3526
3440
  if (parsed.type === "sankey") {
3527
3441
  return buildSankeyOption(
3528
3442
  parsed,
@@ -3598,8 +3512,7 @@ function buildSankeyOption(parsed, textColor, colors, titleConfig, tooltipTheme)
3598
3512
  }
3599
3513
  }));
3600
3514
  return {
3601
- backgroundColor: "transparent",
3602
- animation: false,
3515
+ ...CHART_BASE,
3603
3516
  title: titleConfig,
3604
3517
  tooltip: {
3605
3518
  show: false,
@@ -3656,8 +3569,7 @@ function buildChordOption(parsed, textColor, colors, titleConfig, tooltipTheme)
3656
3569
  }
3657
3570
  }));
3658
3571
  return {
3659
- backgroundColor: "transparent",
3660
- animation: false,
3572
+ ...CHART_BASE,
3661
3573
  title: titleConfig,
3662
3574
  tooltip: {
3663
3575
  trigger: "item",
@@ -3759,15 +3671,11 @@ function buildFunctionOption(parsed, palette, textColor, axisLineColor, gridOpac
3759
3671
  itemStyle: {
3760
3672
  color: fnColor
3761
3673
  },
3762
- emphasis: {
3763
- focus: "self",
3764
- blurScope: "global"
3765
- }
3674
+ emphasis: EMPHASIS_SELF
3766
3675
  };
3767
3676
  });
3768
3677
  return {
3769
- backgroundColor: "transparent",
3770
- animation: false,
3678
+ ...CHART_BASE,
3771
3679
  title: titleConfig,
3772
3680
  tooltip: {
3773
3681
  trigger: "axis",
@@ -3912,8 +3820,7 @@ function buildScatterOption(parsed, palette, textColor, axisLineColor, gridOpaci
3912
3820
  const xPad = (xMax - xMin) * 0.1 || 1;
3913
3821
  const yPad = (yMax - yMin) * 0.1 || 1;
3914
3822
  return {
3915
- backgroundColor: "transparent",
3916
- animation: false,
3823
+ ...CHART_BASE,
3917
3824
  title: titleConfig,
3918
3825
  tooltip,
3919
3826
  ...legendData && {
@@ -3998,8 +3905,7 @@ function buildHeatmapOption(parsed, palette, textColor, axisLineColor, titleConf
3998
3905
  });
3999
3906
  });
4000
3907
  return {
4001
- backgroundColor: "transparent",
4002
- animation: false,
3908
+ ...CHART_BASE,
4003
3909
  title: titleConfig,
4004
3910
  tooltip: {
4005
3911
  trigger: "item",
@@ -4076,8 +3982,7 @@ function buildHeatmapOption(parsed, palette, textColor, axisLineColor, titleConf
4076
3982
  fontWeight: "bold"
4077
3983
  },
4078
3984
  emphasis: {
4079
- focus: "self",
4080
- blurScope: "global",
3985
+ ...EMPHASIS_SELF,
4081
3986
  itemStyle: {
4082
3987
  shadowBlur: 10,
4083
3988
  shadowColor: "rgba(0, 0, 0, 0.5)"
@@ -4116,8 +4021,7 @@ function buildFunnelOption(parsed, textColor, colors, titleConfig, tooltipTheme)
4116
4021
  minSize: "8%"
4117
4022
  };
4118
4023
  return {
4119
- backgroundColor: "transparent",
4120
- animation: false,
4024
+ ...CHART_BASE,
4121
4025
  title: titleConfig,
4122
4026
  tooltip: {
4123
4027
  trigger: "item",
@@ -4155,8 +4059,7 @@ function buildFunnelOption(parsed, textColor, colors, titleConfig, tooltipTheme)
4155
4059
  lineStyle: { color: textColor, opacity: 0.3 }
4156
4060
  },
4157
4061
  emphasis: {
4158
- focus: "self",
4159
- blurScope: "global",
4062
+ ...EMPHASIS_SELF,
4160
4063
  label: {
4161
4064
  fontSize: 15
4162
4065
  }
@@ -4239,27 +4142,7 @@ function makeGridAxis(type, textColor, axisLineColor, splitLineColor, gridOpacit
4239
4142
  }
4240
4143
  function buildEChartsOptionFromChart(parsed, palette, isDark, chartWidth) {
4241
4144
  if (parsed.error) return {};
4242
- const textColor = palette.text;
4243
- const axisLineColor = palette.border;
4244
- const splitLineColor = palette.border;
4245
- const gridOpacity = isDark ? 0.7 : 0.55;
4246
- const colors = getSeriesColors(palette);
4247
- const titleConfig = parsed.title ? {
4248
- text: parsed.title,
4249
- left: "center",
4250
- top: 8,
4251
- textStyle: {
4252
- color: textColor,
4253
- fontSize: 20,
4254
- fontWeight: "bold",
4255
- fontFamily: FONT_FAMILY
4256
- }
4257
- } : void 0;
4258
- const tooltipTheme = {
4259
- backgroundColor: palette.surface,
4260
- borderColor: palette.border,
4261
- textStyle: { color: palette.text }
4262
- };
4145
+ const { textColor, axisLineColor, splitLineColor, gridOpacity, colors, titleConfig, tooltipTheme } = buildChartCommons(parsed, palette, isDark);
4263
4146
  switch (parsed.type) {
4264
4147
  case "bar":
4265
4148
  return buildBarOption(parsed, textColor, axisLineColor, splitLineColor, gridOpacity, colors, titleConfig, tooltipTheme, chartWidth);
@@ -4279,6 +4162,15 @@ function buildEChartsOptionFromChart(parsed, palette, isDark, chartWidth) {
4279
4162
  return buildPolarAreaOption(parsed, textColor, getSegmentColors(palette, parsed.data.length), titleConfig, tooltipTheme);
4280
4163
  }
4281
4164
  }
4165
+ function makeChartGrid(options) {
4166
+ return {
4167
+ left: options.yLabel ? "12%" : "3%",
4168
+ right: "4%",
4169
+ bottom: options.hasLegend ? "15%" : options.xLabel ? "10%" : "3%",
4170
+ top: options.hasTitle ? "15%" : "5%",
4171
+ containLabel: true
4172
+ };
4173
+ }
4282
4174
  function buildBarOption(parsed, textColor, axisLineColor, splitLineColor, gridOpacity, colors, titleConfig, tooltipTheme, chartWidth) {
4283
4175
  const { xLabel, yLabel } = resolveAxisLabels(parsed);
4284
4176
  const isHorizontal = parsed.orientation === "horizontal";
@@ -4291,31 +4183,21 @@ function buildBarOption(parsed, textColor, axisLineColor, splitLineColor, gridOp
4291
4183
  const categoryAxis = makeGridAxis("category", textColor, axisLineColor, splitLineColor, gridOpacity, isHorizontal ? yLabel : xLabel, labels, hCatGap, !isHorizontal ? chartWidth : void 0);
4292
4184
  const valueAxis = makeGridAxis("value", textColor, axisLineColor, splitLineColor, gridOpacity, isHorizontal ? xLabel : yLabel);
4293
4185
  return {
4294
- backgroundColor: "transparent",
4295
- animation: false,
4186
+ ...CHART_BASE,
4296
4187
  title: titleConfig,
4297
4188
  tooltip: {
4298
4189
  trigger: "axis",
4299
4190
  ...tooltipTheme,
4300
4191
  axisPointer: { type: "shadow" }
4301
4192
  },
4302
- grid: {
4303
- left: yLabel ? "12%" : "3%",
4304
- right: "4%",
4305
- bottom: xLabel ? "10%" : "3%",
4306
- top: parsed.title ? "15%" : "5%",
4307
- containLabel: true
4308
- },
4193
+ grid: makeChartGrid({ xLabel, yLabel, hasTitle: !!parsed.title }),
4309
4194
  xAxis: isHorizontal ? valueAxis : categoryAxis,
4310
4195
  yAxis: isHorizontal ? categoryAxis : valueAxis,
4311
4196
  series: [
4312
4197
  {
4313
4198
  type: "bar",
4314
4199
  data,
4315
- emphasis: {
4316
- focus: "self",
4317
- blurScope: "global"
4318
- }
4200
+ emphasis: EMPHASIS_SELF
4319
4201
  }
4320
4202
  ]
4321
4203
  };
@@ -4326,21 +4208,14 @@ function buildLineOption(parsed, palette, textColor, axisLineColor, splitLineCol
4326
4208
  const labels = parsed.data.map((d) => d.label);
4327
4209
  const values = parsed.data.map((d) => d.value);
4328
4210
  return {
4329
- backgroundColor: "transparent",
4330
- animation: false,
4211
+ ...CHART_BASE,
4331
4212
  title: titleConfig,
4332
4213
  tooltip: {
4333
4214
  trigger: "axis",
4334
4215
  ...tooltipTheme,
4335
4216
  axisPointer: { type: "line" }
4336
4217
  },
4337
- grid: {
4338
- left: yLabel ? "12%" : "3%",
4339
- right: "4%",
4340
- bottom: xLabel ? "10%" : "3%",
4341
- top: parsed.title ? "15%" : "5%",
4342
- containLabel: true
4343
- },
4218
+ grid: makeChartGrid({ xLabel, yLabel, hasTitle: !!parsed.title }),
4344
4219
  xAxis: makeGridAxis("category", textColor, axisLineColor, splitLineColor, gridOpacity, xLabel, labels, void 0, chartWidth),
4345
4220
  yAxis: makeGridAxis("value", textColor, axisLineColor, splitLineColor, gridOpacity, yLabel),
4346
4221
  series: [
@@ -4351,10 +4226,7 @@ function buildLineOption(parsed, palette, textColor, axisLineColor, splitLineCol
4351
4226
  symbolSize: 8,
4352
4227
  lineStyle: { color: lineColor, width: 3 },
4353
4228
  itemStyle: { color: lineColor },
4354
- emphasis: {
4355
- focus: "self",
4356
- blurScope: "global"
4357
- }
4229
+ emphasis: EMPHASIS_SELF
4358
4230
  }
4359
4231
  ]
4360
4232
  };
@@ -4376,15 +4248,11 @@ function buildMultiLineOption(parsed, textColor, axisLineColor, splitLineColor,
4376
4248
  symbolSize: 8,
4377
4249
  lineStyle: { color, width: 3 },
4378
4250
  itemStyle: { color },
4379
- emphasis: {
4380
- focus: "self",
4381
- blurScope: "global"
4382
- }
4251
+ emphasis: EMPHASIS_SELF
4383
4252
  };
4384
4253
  });
4385
4254
  return {
4386
- backgroundColor: "transparent",
4387
- animation: false,
4255
+ ...CHART_BASE,
4388
4256
  title: titleConfig,
4389
4257
  tooltip: {
4390
4258
  trigger: "axis",
@@ -4396,13 +4264,7 @@ function buildMultiLineOption(parsed, textColor, axisLineColor, splitLineColor,
4396
4264
  bottom: 10,
4397
4265
  textStyle: { color: textColor }
4398
4266
  },
4399
- grid: {
4400
- left: yLabel ? "12%" : "3%",
4401
- right: "4%",
4402
- bottom: "15%",
4403
- top: parsed.title ? "15%" : "5%",
4404
- containLabel: true
4405
- },
4267
+ grid: makeChartGrid({ xLabel, yLabel, hasTitle: !!parsed.title, hasLegend: true }),
4406
4268
  xAxis: makeGridAxis("category", textColor, axisLineColor, splitLineColor, gridOpacity, xLabel, labels, void 0, chartWidth),
4407
4269
  yAxis: makeGridAxis("value", textColor, axisLineColor, splitLineColor, gridOpacity, yLabel),
4408
4270
  series
@@ -4414,21 +4276,14 @@ function buildAreaOption(parsed, palette, textColor, axisLineColor, splitLineCol
4414
4276
  const labels = parsed.data.map((d) => d.label);
4415
4277
  const values = parsed.data.map((d) => d.value);
4416
4278
  return {
4417
- backgroundColor: "transparent",
4418
- animation: false,
4279
+ ...CHART_BASE,
4419
4280
  title: titleConfig,
4420
4281
  tooltip: {
4421
4282
  trigger: "axis",
4422
4283
  ...tooltipTheme,
4423
4284
  axisPointer: { type: "line" }
4424
4285
  },
4425
- grid: {
4426
- left: yLabel ? "12%" : "3%",
4427
- right: "4%",
4428
- bottom: xLabel ? "10%" : "3%",
4429
- top: parsed.title ? "15%" : "5%",
4430
- containLabel: true
4431
- },
4286
+ grid: makeChartGrid({ xLabel, yLabel, hasTitle: !!parsed.title }),
4432
4287
  xAxis: makeGridAxis("category", textColor, axisLineColor, splitLineColor, gridOpacity, xLabel, labels, void 0, chartWidth),
4433
4288
  yAxis: makeGridAxis("value", textColor, axisLineColor, splitLineColor, gridOpacity, yLabel),
4434
4289
  series: [
@@ -4440,10 +4295,7 @@ function buildAreaOption(parsed, palette, textColor, axisLineColor, splitLineCol
4440
4295
  lineStyle: { color: lineColor, width: 3 },
4441
4296
  itemStyle: { color: lineColor },
4442
4297
  areaStyle: { opacity: 0.25 },
4443
- emphasis: {
4444
- focus: "self",
4445
- blurScope: "global"
4446
- }
4298
+ emphasis: EMPHASIS_SELF
4447
4299
  }
4448
4300
  ]
4449
4301
  };
@@ -4467,8 +4319,7 @@ function buildPieOption(parsed, textColor, colors, titleConfig, tooltipTheme, is
4467
4319
  itemStyle: { color: d.color ?? colors[i % colors.length] }
4468
4320
  }));
4469
4321
  return {
4470
- backgroundColor: "transparent",
4471
- animation: false,
4322
+ ...CHART_BASE,
4472
4323
  title: titleConfig,
4473
4324
  tooltip: {
4474
4325
  trigger: "item",
@@ -4486,10 +4337,7 @@ function buildPieOption(parsed, textColor, colors, titleConfig, tooltipTheme, is
4486
4337
  fontFamily: FONT_FAMILY
4487
4338
  },
4488
4339
  labelLine: { show: true },
4489
- emphasis: {
4490
- focus: "self",
4491
- blurScope: "global"
4492
- }
4340
+ emphasis: EMPHASIS_SELF
4493
4341
  }
4494
4342
  ]
4495
4343
  };
@@ -4503,8 +4351,7 @@ function buildRadarOption(parsed, palette, textColor, gridOpacity, colors, title
4503
4351
  max: maxValue
4504
4352
  }));
4505
4353
  return {
4506
- backgroundColor: "transparent",
4507
- animation: false,
4354
+ ...CHART_BASE,
4508
4355
  title: titleConfig,
4509
4356
  tooltip: {
4510
4357
  trigger: "item",
@@ -4546,10 +4393,7 @@ function buildRadarOption(parsed, palette, textColor, gridOpacity, colors, title
4546
4393
  }
4547
4394
  }
4548
4395
  ],
4549
- emphasis: {
4550
- focus: "self",
4551
- blurScope: "global"
4552
- }
4396
+ emphasis: EMPHASIS_SELF
4553
4397
  }
4554
4398
  ]
4555
4399
  };
@@ -4561,8 +4405,7 @@ function buildPolarAreaOption(parsed, textColor, colors, titleConfig, tooltipThe
4561
4405
  itemStyle: { color: d.color ?? colors[i % colors.length] }
4562
4406
  }));
4563
4407
  return {
4564
- backgroundColor: "transparent",
4565
- animation: false,
4408
+ ...CHART_BASE,
4566
4409
  title: titleConfig,
4567
4410
  tooltip: {
4568
4411
  trigger: "item",
@@ -4581,10 +4424,7 @@ function buildPolarAreaOption(parsed, textColor, colors, titleConfig, tooltipThe
4581
4424
  fontFamily: FONT_FAMILY
4582
4425
  },
4583
4426
  labelLine: { show: true },
4584
- emphasis: {
4585
- focus: "self",
4586
- blurScope: "global"
4587
- }
4427
+ emphasis: EMPHASIS_SELF
4588
4428
  }
4589
4429
  ]
4590
4430
  };
@@ -4614,10 +4454,7 @@ function buildBarStackedOption(parsed, textColor, axisLineColor, splitLineColor,
4614
4454
  fontWeight: "bold",
4615
4455
  fontFamily: FONT_FAMILY
4616
4456
  },
4617
- emphasis: {
4618
- focus: "self",
4619
- blurScope: "global"
4620
- }
4457
+ emphasis: EMPHASIS_SELF
4621
4458
  };
4622
4459
  });
4623
4460
  const hCatGap = isHorizontal && yLabel ? Math.max(40, Math.max(...labels.map((l) => l.length)) * 8 + 16) : void 0;
@@ -4625,8 +4462,7 @@ function buildBarStackedOption(parsed, textColor, axisLineColor, splitLineColor,
4625
4462
  const hValueGap = isHorizontal && xLabel ? 40 : void 0;
4626
4463
  const valueAxis = makeGridAxis("value", textColor, axisLineColor, splitLineColor, gridOpacity, isHorizontal ? xLabel : yLabel, void 0, hValueGap);
4627
4464
  return {
4628
- backgroundColor: "transparent",
4629
- animation: false,
4465
+ ...CHART_BASE,
4630
4466
  title: titleConfig,
4631
4467
  tooltip: {
4632
4468
  trigger: "axis",
@@ -4638,13 +4474,7 @@ function buildBarStackedOption(parsed, textColor, axisLineColor, splitLineColor,
4638
4474
  bottom: 10,
4639
4475
  textStyle: { color: textColor }
4640
4476
  },
4641
- grid: {
4642
- left: yLabel ? "12%" : "3%",
4643
- right: "4%",
4644
- bottom: "15%",
4645
- top: parsed.title ? "15%" : "5%",
4646
- containLabel: true
4647
- },
4477
+ grid: makeChartGrid({ xLabel, yLabel, hasTitle: !!parsed.title, hasLegend: true }),
4648
4478
  xAxis: isHorizontal ? valueAxis : categoryAxis,
4649
4479
  yAxis: isHorizontal ? categoryAxis : valueAxis,
4650
4480
  series
@@ -4691,30 +4521,21 @@ async function renderEChartsForExport(content, theme, palette, options) {
4691
4521
  chart.dispose();
4692
4522
  }
4693
4523
  }
4694
- var ECHART_EXPORT_WIDTH, ECHART_EXPORT_HEIGHT, STANDARD_CHART_TYPES;
4524
+ var EMPHASIS_SELF, CHART_BASE, ECHART_EXPORT_WIDTH, ECHART_EXPORT_HEIGHT;
4695
4525
  var init_echarts = __esm({
4696
4526
  "src/echarts.ts"() {
4697
4527
  "use strict";
4698
4528
  init_fonts();
4699
4529
  init_branding();
4700
- init_colors();
4701
4530
  init_palettes();
4702
4531
  init_chart();
4703
4532
  init_diagnostics();
4704
4533
  init_parsing();
4534
+ init_dgmo_router();
4535
+ EMPHASIS_SELF = { focus: "self", blurScope: "global" };
4536
+ CHART_BASE = { backgroundColor: "transparent", animation: false };
4705
4537
  ECHART_EXPORT_WIDTH = 1200;
4706
4538
  ECHART_EXPORT_HEIGHT = 800;
4707
- STANDARD_CHART_TYPES = /* @__PURE__ */ new Set([
4708
- "bar",
4709
- "line",
4710
- "multi-line",
4711
- "area",
4712
- "pie",
4713
- "doughnut",
4714
- "radar",
4715
- "polar-area",
4716
- "bar-stacked"
4717
- ]);
4718
4539
  }
4719
4540
  });
4720
4541
 
@@ -6044,6 +5865,7 @@ var init_parser7 = __esm({
6044
5865
  var dgmo_router_exports = {};
6045
5866
  __export(dgmo_router_exports, {
6046
5867
  DGMO_CHART_TYPE_MAP: () => DGMO_CHART_TYPE_MAP,
5868
+ STANDARD_CHART_TYPES: () => STANDARD_CHART_TYPES,
6047
5869
  getDgmoFramework: () => getDgmoFramework,
6048
5870
  parseDgmo: () => parseDgmo,
6049
5871
  parseDgmoChartType: () => parseDgmoChartType
@@ -6071,53 +5893,19 @@ function parseDgmoChartType(content) {
6071
5893
  function parseDgmo(content) {
6072
5894
  const chartType = parseDgmoChartType(content);
6073
5895
  if (!chartType) {
6074
- const parsed2 = parseD3(content);
6075
- return { diagnostics: parsed2.diagnostics };
6076
- }
6077
- if (chartType === "sequence") {
6078
- const parsed2 = parseSequenceDgmo(content);
6079
- return { diagnostics: parsed2.diagnostics };
6080
- }
6081
- if (chartType === "flowchart") {
6082
- const parsed2 = parseFlowchart(content);
6083
- return { diagnostics: parsed2.diagnostics };
6084
- }
6085
- if (chartType === "class") {
6086
- const parsed2 = parseClassDiagram(content);
6087
- return { diagnostics: parsed2.diagnostics };
6088
- }
6089
- if (chartType === "er") {
6090
- const parsed2 = parseERDiagram(content);
6091
- return { diagnostics: parsed2.diagnostics };
6092
- }
6093
- if (chartType === "org") {
6094
- const parsed2 = parseOrg(content);
6095
- return { diagnostics: parsed2.diagnostics };
6096
- }
6097
- if (chartType === "kanban") {
6098
- const parsed2 = parseKanban(content);
6099
- return { diagnostics: parsed2.diagnostics };
5896
+ return { diagnostics: parseD3(content).diagnostics };
6100
5897
  }
6101
- if (chartType === "c4") {
6102
- const parsed2 = parseC4(content);
6103
- return { diagnostics: parsed2.diagnostics };
6104
- }
6105
- if (chartType === "initiative-status") {
6106
- const parsed2 = parseInitiativeStatus(content);
6107
- return { diagnostics: parsed2.diagnostics };
6108
- }
6109
- if (STANDARD_CHART_TYPES2.has(chartType)) {
6110
- const parsed2 = parseChart(content);
6111
- return { diagnostics: parsed2.diagnostics };
5898
+ const directParser = PARSE_DISPATCH.get(chartType);
5899
+ if (directParser) return { diagnostics: directParser(content).diagnostics };
5900
+ if (STANDARD_CHART_TYPES.has(chartType)) {
5901
+ return { diagnostics: parseChart(content).diagnostics };
6112
5902
  }
6113
5903
  if (ECHART_TYPES.has(chartType)) {
6114
- const parsed2 = parseEChart(content);
6115
- return { diagnostics: parsed2.diagnostics };
5904
+ return { diagnostics: parseEChart(content).diagnostics };
6116
5905
  }
6117
- const parsed = parseD3(content);
6118
- return { diagnostics: parsed.diagnostics };
5906
+ return { diagnostics: parseD3(content).diagnostics };
6119
5907
  }
6120
- var DGMO_CHART_TYPE_MAP, STANDARD_CHART_TYPES2, ECHART_TYPES;
5908
+ var DGMO_CHART_TYPE_MAP, STANDARD_CHART_TYPES, ECHART_TYPES, PARSE_DISPATCH;
6121
5909
  var init_dgmo_router = __esm({
6122
5910
  "src/dgmo-router.ts"() {
6123
5911
  "use strict";
@@ -6166,7 +5954,7 @@ var init_dgmo_router = __esm({
6166
5954
  c4: "d3",
6167
5955
  "initiative-status": "d3"
6168
5956
  };
6169
- STANDARD_CHART_TYPES2 = /* @__PURE__ */ new Set([
5957
+ STANDARD_CHART_TYPES = /* @__PURE__ */ new Set([
6170
5958
  "bar",
6171
5959
  "line",
6172
5960
  "multi-line",
@@ -6185,6 +5973,16 @@ var init_dgmo_router = __esm({
6185
5973
  "heatmap",
6186
5974
  "funnel"
6187
5975
  ]);
5976
+ PARSE_DISPATCH = /* @__PURE__ */ new Map([
5977
+ ["sequence", (c) => parseSequenceDgmo(c)],
5978
+ ["flowchart", (c) => parseFlowchart(c)],
5979
+ ["class", (c) => parseClassDiagram(c)],
5980
+ ["er", (c) => parseERDiagram(c)],
5981
+ ["org", (c) => parseOrg(c)],
5982
+ ["kanban", (c) => parseKanban(c)],
5983
+ ["c4", (c) => parseC4(c)],
5984
+ ["initiative-status", (c) => parseInitiativeStatus(c)]
5985
+ ]);
6188
5986
  }
6189
5987
  });
6190
5988
 
@@ -12184,38 +11982,18 @@ function buildRenderSequence(messages) {
12184
11982
  type: "return",
12185
11983
  from: top.to,
12186
11984
  to: top.from,
12187
- label: top.returnLabel || "",
11985
+ label: "",
12188
11986
  messageIndex: top.messageIndex
12189
11987
  });
12190
11988
  }
12191
- if (msg.standaloneReturn) {
12192
- for (let si = stack.length - 1; si >= 0; si--) {
12193
- if (stack[si].from === msg.to && stack[si].to === msg.from) {
12194
- stack.splice(si, 1);
12195
- break;
12196
- }
12197
- }
12198
- steps.push({
12199
- type: "return",
12200
- from: msg.from,
12201
- to: msg.to,
12202
- label: msg.label,
12203
- messageIndex: mi
12204
- });
12205
- continue;
12206
- }
12207
11989
  steps.push({
12208
11990
  type: "call",
12209
11991
  from: msg.from,
12210
11992
  to: msg.to,
12211
11993
  label: msg.label,
12212
11994
  messageIndex: mi,
12213
- ...msg.async ? { async: true } : {},
12214
- ...msg.bidirectional ? { bidirectional: true } : {}
11995
+ ...msg.async ? { async: true } : {}
12215
11996
  });
12216
- if (msg.bidirectional) {
12217
- continue;
12218
- }
12219
11997
  if (msg.async) {
12220
11998
  continue;
12221
11999
  }
@@ -12224,14 +12002,13 @@ function buildRenderSequence(messages) {
12224
12002
  type: "return",
12225
12003
  from: msg.to,
12226
12004
  to: msg.from,
12227
- label: msg.returnLabel || "",
12005
+ label: "",
12228
12006
  messageIndex: mi
12229
12007
  });
12230
12008
  } else {
12231
12009
  stack.push({
12232
12010
  from: msg.from,
12233
12011
  to: msg.to,
12234
- returnLabel: msg.returnLabel,
12235
12012
  messageIndex: mi
12236
12013
  });
12237
12014
  }
@@ -12242,7 +12019,7 @@ function buildRenderSequence(messages) {
12242
12019
  type: "return",
12243
12020
  from: top.to,
12244
12021
  to: top.from,
12245
- label: top.returnLabel || "",
12022
+ label: "",
12246
12023
  messageIndex: top.messageIndex
12247
12024
  });
12248
12025
  }
@@ -12707,14 +12484,6 @@ function renderSequenceDiagram(container, parsed, palette, isDark, _onNavigateTo
12707
12484
  "points",
12708
12485
  `0,0 ${ARROWHEAD_SIZE},${ARROWHEAD_SIZE / 2} 0,${ARROWHEAD_SIZE}`
12709
12486
  ).attr("fill", "none").attr("stroke", palette.text).attr("stroke-width", 1.2);
12710
- defs.append("marker").attr("id", "seq-arrowhead-reverse").attr("viewBox", `0 0 ${ARROWHEAD_SIZE} ${ARROWHEAD_SIZE}`).attr("refX", 0).attr("refY", ARROWHEAD_SIZE / 2).attr("markerWidth", ARROWHEAD_SIZE).attr("markerHeight", ARROWHEAD_SIZE).attr("orient", "auto").append("polygon").attr(
12711
- "points",
12712
- `${ARROWHEAD_SIZE},0 0,${ARROWHEAD_SIZE / 2} ${ARROWHEAD_SIZE},${ARROWHEAD_SIZE}`
12713
- ).attr("fill", palette.text);
12714
- defs.append("marker").attr("id", "seq-arrowhead-async-reverse").attr("viewBox", `0 0 ${ARROWHEAD_SIZE} ${ARROWHEAD_SIZE}`).attr("refX", 0).attr("refY", ARROWHEAD_SIZE / 2).attr("markerWidth", ARROWHEAD_SIZE).attr("markerHeight", ARROWHEAD_SIZE).attr("orient", "auto").append("polyline").attr(
12715
- "points",
12716
- `${ARROWHEAD_SIZE},0 0,${ARROWHEAD_SIZE / 2} ${ARROWHEAD_SIZE},${ARROWHEAD_SIZE}`
12717
- ).attr("fill", "none").attr("stroke", palette.text).attr("stroke-width", 1.2);
12718
12487
  if (title) {
12719
12488
  const titleEl = svg.append("text").attr("class", "chart-title").attr("x", svgWidth / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", palette.text).attr("font-size", 20).attr("font-weight", "bold").text(title);
12720
12489
  if (parsed.titleLineNumber) {
@@ -12995,17 +12764,10 @@ function renderSequenceDiagram(container, parsed, palette, isDark, _onNavigateTo
12995
12764
  const x1 = arrowEdgeX(step.from, i, goingRight ? "right" : "left");
12996
12765
  const x2 = arrowEdgeX(step.to, i, goingRight ? "left" : "right");
12997
12766
  const markerRef = step.async ? "url(#seq-arrowhead-async)" : "url(#seq-arrowhead)";
12998
- const markerStartRef = step.bidirectional ? step.async ? "url(#seq-arrowhead-async-reverse)" : "url(#seq-arrowhead-reverse)" : null;
12999
- const line7 = svg.append("line").attr("x1", x1).attr("y1", y).attr("x2", x2).attr("y2", y).attr("stroke", palette.text).attr("stroke-width", 1.2).attr("marker-end", markerRef).attr("class", "message-arrow").attr(
12767
+ svg.append("line").attr("x1", x1).attr("y1", y).attr("x2", x2).attr("y2", y).attr("stroke", palette.text).attr("stroke-width", 1.2).attr("marker-end", markerRef).attr("class", "message-arrow").attr(
13000
12768
  "data-line-number",
13001
12769
  String(messages[step.messageIndex].lineNumber)
13002
12770
  ).attr("data-msg-index", String(step.messageIndex)).attr("data-step-index", String(i));
13003
- if (markerStartRef) {
13004
- line7.attr("marker-start", markerStartRef);
13005
- }
13006
- if (step.bidirectional && step.async) {
13007
- line7.attr("stroke-dasharray", "6 4");
13008
- }
13009
12771
  if (step.label) {
13010
12772
  const midX = (x1 + x2) / 2;
13011
12773
  const labelEl = svg.append("text").attr("x", midX).attr("y", y - 8).attr("text-anchor", "middle").attr("fill", palette.text).attr("font-size", 12).attr("class", "message-label").attr(
@@ -13236,6 +12998,32 @@ import * as d3Selection9 from "d3-selection";
13236
12998
  import * as d3Shape6 from "d3-shape";
13237
12999
  import * as d3Array from "d3-array";
13238
13000
  import cloud from "d3-cloud";
13001
+ function renderChartTitle(svg, title, titleLineNumber, width, textColor, onClickItem) {
13002
+ if (!title) return;
13003
+ const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && titleLineNumber ? "pointer" : "default").text(title);
13004
+ if (titleLineNumber) {
13005
+ titleEl.attr("data-line-number", titleLineNumber);
13006
+ if (onClickItem) {
13007
+ titleEl.on("click", () => onClickItem(titleLineNumber)).on("mouseenter", function() {
13008
+ d3Selection9.select(this).attr("opacity", 0.7);
13009
+ }).on("mouseleave", function() {
13010
+ d3Selection9.select(this).attr("opacity", 1);
13011
+ });
13012
+ }
13013
+ }
13014
+ }
13015
+ function initD3Chart(container, palette, exportDims) {
13016
+ d3Selection9.select(container).selectAll(":not([data-d3-tooltip])").remove();
13017
+ const width = exportDims?.width ?? container.clientWidth;
13018
+ const height = exportDims?.height ?? container.clientHeight;
13019
+ if (width <= 0 || height <= 0) return null;
13020
+ const textColor = palette.text;
13021
+ const mutedColor = palette.border;
13022
+ const bgColor = palette.bg;
13023
+ const colors = getSeriesColors(palette);
13024
+ const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
13025
+ return { svg, width, height, textColor, mutedColor, bgColor, colors };
13026
+ }
13239
13027
  function parseTimelineDate(s) {
13240
13028
  const parts = s.split("-").map((p) => parseInt(p, 10));
13241
13029
  const year = parts[0];
@@ -13798,26 +13586,28 @@ function tokenizeFreeformText(text) {
13798
13586
  }
13799
13587
  return Array.from(counts.entries()).map(([text2, count]) => ({ text: text2, weight: count, lineNumber: 0 })).sort((a, b) => b.weight - a.weight);
13800
13588
  }
13801
- function resolveVerticalCollisions(items, minGap) {
13589
+ function resolveVerticalCollisions(items, minGap, maxY) {
13802
13590
  if (items.length === 0) return [];
13803
13591
  const sorted = items.map((it, i) => ({ ...it, idx: i })).sort((a, b) => a.naturalY - b.naturalY);
13804
13592
  const adjustedY = new Array(items.length);
13805
13593
  let prevBottom = -Infinity;
13806
13594
  for (const item of sorted) {
13807
13595
  const halfH = item.height / 2;
13808
- const top = Math.max(item.naturalY - halfH, prevBottom + minGap);
13596
+ let top = Math.max(item.naturalY - halfH, prevBottom + minGap);
13597
+ if (maxY !== void 0) {
13598
+ top = Math.min(top, maxY - item.height);
13599
+ }
13809
13600
  adjustedY[item.idx] = top + halfH;
13810
13601
  prevBottom = top + item.height;
13811
13602
  }
13812
13603
  return adjustedY;
13813
13604
  }
13814
13605
  function renderSlopeChart(container, parsed, palette, isDark, onClickItem, exportDims) {
13815
- d3Selection9.select(container).selectAll(":not([data-d3-tooltip])").remove();
13816
13606
  const { periods, data, title } = parsed;
13817
13607
  if (data.length === 0 || periods.length < 2) return;
13818
- const width = exportDims?.width ?? container.clientWidth;
13819
- const height = exportDims?.height ?? container.clientHeight;
13820
- if (width <= 0 || height <= 0) return;
13608
+ const init2 = initD3Chart(container, palette, exportDims);
13609
+ if (!init2) return;
13610
+ const { svg, width, height, textColor, mutedColor, bgColor, colors } = init2;
13821
13611
  const maxLabelText = data.reduce((longest, item) => {
13822
13612
  const text = `${item.values[item.values.length - 1]} \u2014 ${item.label}`;
13823
13613
  return text.length > longest.length ? text : longest;
@@ -13830,31 +13620,14 @@ function renderSlopeChart(container, parsed, palette, isDark, onClickItem, expor
13830
13620
  );
13831
13621
  const innerWidth = width - SLOPE_MARGIN.left - rightMargin;
13832
13622
  const innerHeight = height - SLOPE_MARGIN.top - SLOPE_MARGIN.bottom;
13833
- const textColor = palette.text;
13834
- const mutedColor = palette.border;
13835
- const bgColor = palette.bg;
13836
- const colors = getSeriesColors(palette);
13837
13623
  const allValues = data.flatMap((d) => d.values);
13838
13624
  const [minVal, maxVal] = d3Array.extent(allValues);
13839
13625
  const valuePadding = (maxVal - minVal) * 0.1 || 1;
13840
13626
  const yScale = d3Scale.scaleLinear().domain([minVal - valuePadding, maxVal + valuePadding]).range([innerHeight, 0]);
13841
13627
  const xScale = d3Scale.scalePoint().domain(periods).range([0, innerWidth]).padding(0);
13842
- const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
13843
13628
  const g = svg.append("g").attr("transform", `translate(${SLOPE_MARGIN.left},${SLOPE_MARGIN.top})`);
13844
13629
  const tooltip = createTooltip(container, palette, isDark);
13845
- if (title) {
13846
- const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
13847
- if (parsed.titleLineNumber) {
13848
- titleEl.attr("data-line-number", parsed.titleLineNumber);
13849
- if (onClickItem) {
13850
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
13851
- d3Selection9.select(this).attr("opacity", 0.7);
13852
- }).on("mouseleave", function() {
13853
- d3Selection9.select(this).attr("opacity", 1);
13854
- });
13855
- }
13856
- }
13857
- }
13630
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
13858
13631
  for (const period of periods) {
13859
13632
  const x = xScale(period);
13860
13633
  g.append("text").attr("x", x).attr("y", -15).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "18px").attr("font-weight", "600").text(period);
@@ -13917,13 +13690,13 @@ function renderSlopeChart(container, parsed, palette, isDark, onClickItem, expor
13917
13690
  naturalY: yScale(item.values[pi]),
13918
13691
  height: leftLabelHeight
13919
13692
  }));
13920
- leftLabelCollisions.set(pi, resolveVerticalCollisions(entries, 4));
13693
+ leftLabelCollisions.set(pi, resolveVerticalCollisions(entries, 4, innerHeight));
13921
13694
  }
13922
13695
  const rightEntries = seriesInfo.map((si) => ({
13923
13696
  naturalY: yScale(si.lastVal),
13924
13697
  height: Math.max(si.labelHeight, SLOPE_LABEL_FONT_SIZE * 1.4)
13925
13698
  }));
13926
- const rightAdjustedY = resolveVerticalCollisions(rightEntries, 4);
13699
+ const rightAdjustedY = resolveVerticalCollisions(rightEntries, 4, innerHeight);
13927
13700
  data.forEach((item, idx) => {
13928
13701
  const si = seriesInfo[idx];
13929
13702
  const color = si.color;
@@ -14063,12 +13836,11 @@ function orderArcNodes(links, order, groups) {
14063
13836
  return allNodes;
14064
13837
  }
14065
13838
  function renderArcDiagram(container, parsed, palette, _isDark, onClickItem, exportDims) {
14066
- d3Selection9.select(container).selectAll(":not([data-d3-tooltip])").remove();
14067
13839
  const { links, title, orientation, arcOrder, arcNodeGroups } = parsed;
14068
13840
  if (links.length === 0) return;
14069
- const width = exportDims?.width ?? container.clientWidth;
14070
- const height = exportDims?.height ?? container.clientHeight;
14071
- if (width <= 0 || height <= 0) return;
13841
+ const init2 = initD3Chart(container, palette, exportDims);
13842
+ if (!init2) return;
13843
+ const { svg, width, height, textColor, mutedColor, bgColor, colors } = init2;
14072
13844
  const isVertical = orientation === "vertical";
14073
13845
  const margin = isVertical ? {
14074
13846
  top: ARC_MARGIN.top,
@@ -14078,10 +13850,6 @@ function renderArcDiagram(container, parsed, palette, _isDark, onClickItem, expo
14078
13850
  } : ARC_MARGIN;
14079
13851
  const innerWidth = width - margin.left - margin.right;
14080
13852
  const innerHeight = height - margin.top - margin.bottom;
14081
- const textColor = palette.text;
14082
- const mutedColor = palette.border;
14083
- const bgColor = palette.bg;
14084
- const colors = getSeriesColors(palette);
14085
13853
  const nodes = orderArcNodes(links, arcOrder, arcNodeGroups);
14086
13854
  const nodeColorMap = /* @__PURE__ */ new Map();
14087
13855
  for (const group of arcNodeGroups) {
@@ -14100,21 +13868,8 @@ function renderArcDiagram(container, parsed, palette, _isDark, onClickItem, expo
14100
13868
  const values = links.map((l) => l.value);
14101
13869
  const [minVal, maxVal] = d3Array.extent(values);
14102
13870
  const strokeScale = d3Scale.scaleLinear().domain([minVal, maxVal]).range([1.5, 6]);
14103
- const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
14104
13871
  const g = svg.append("g").attr("transform", `translate(${margin.left},${margin.top})`);
14105
- if (title) {
14106
- const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
14107
- if (parsed.titleLineNumber) {
14108
- titleEl.attr("data-line-number", parsed.titleLineNumber);
14109
- if (onClickItem) {
14110
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
14111
- d3Selection9.select(this).attr("opacity", 0.7);
14112
- }).on("mouseleave", function() {
14113
- d3Selection9.select(this).attr("opacity", 1);
14114
- });
14115
- }
14116
- }
14117
- }
13872
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
14118
13873
  const neighbors = /* @__PURE__ */ new Map();
14119
13874
  for (const node of nodes) neighbors.set(node, /* @__PURE__ */ new Set());
14120
13875
  for (const link of links) {
@@ -14650,19 +14405,7 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
14650
14405
  const yScale = d3Scale.scaleLinear().domain([minDate - datePadding, maxDate + datePadding]).range([0, innerHeight]);
14651
14406
  const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
14652
14407
  const g = svg.append("g").attr("transform", `translate(${margin.left},${margin.top})`);
14653
- if (title) {
14654
- const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
14655
- if (parsed.titleLineNumber) {
14656
- titleEl.attr("data-line-number", parsed.titleLineNumber);
14657
- if (onClickItem) {
14658
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
14659
- d3Selection9.select(this).attr("opacity", 0.7);
14660
- }).on("mouseleave", function() {
14661
- d3Selection9.select(this).attr("opacity", 1);
14662
- });
14663
- }
14664
- }
14665
- }
14408
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
14666
14409
  renderEras(
14667
14410
  g,
14668
14411
  timelineEras,
@@ -14765,19 +14508,7 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
14765
14508
  const sorted = timelineEvents.slice().sort((a, b) => parseTimelineDate(a.date) - parseTimelineDate(b.date));
14766
14509
  const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
14767
14510
  const g = svg.append("g").attr("transform", `translate(${margin.left},${margin.top})`);
14768
- if (title) {
14769
- const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
14770
- if (parsed.titleLineNumber) {
14771
- titleEl.attr("data-line-number", parsed.titleLineNumber);
14772
- if (onClickItem) {
14773
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
14774
- d3Selection9.select(this).attr("opacity", 0.7);
14775
- }).on("mouseleave", function() {
14776
- d3Selection9.select(this).attr("opacity", 1);
14777
- });
14778
- }
14779
- }
14780
- }
14511
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
14781
14512
  renderEras(
14782
14513
  g,
14783
14514
  timelineEras,
@@ -14909,19 +14640,7 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
14909
14640
  const xScale = d3Scale.scaleLinear().domain([minDate - datePadding, maxDate + datePadding]).range([0, innerWidth]);
14910
14641
  const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
14911
14642
  const g = svg.append("g").attr("transform", `translate(${margin.left},${margin.top})`);
14912
- if (title) {
14913
- const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
14914
- if (parsed.titleLineNumber) {
14915
- titleEl.attr("data-line-number", parsed.titleLineNumber);
14916
- if (onClickItem) {
14917
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
14918
- d3Selection9.select(this).attr("opacity", 0.7);
14919
- }).on("mouseleave", function() {
14920
- d3Selection9.select(this).attr("opacity", 1);
14921
- });
14922
- }
14923
- }
14924
- }
14643
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
14925
14644
  renderEras(
14926
14645
  g,
14927
14646
  timelineEras,
@@ -15064,19 +14783,7 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
15064
14783
  const xScale = d3Scale.scaleLinear().domain([minDate - datePadding, maxDate + datePadding]).range([0, innerWidth]);
15065
14784
  const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
15066
14785
  const g = svg.append("g").attr("transform", `translate(${margin.left},${margin.top})`);
15067
- if (title) {
15068
- const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
15069
- if (parsed.titleLineNumber) {
15070
- titleEl.attr("data-line-number", parsed.titleLineNumber);
15071
- if (onClickItem) {
15072
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
15073
- d3Selection9.select(this).attr("opacity", 0.7);
15074
- }).on("mouseleave", function() {
15075
- d3Selection9.select(this).attr("opacity", 1);
15076
- });
15077
- }
15078
- }
15079
- }
14786
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
15080
14787
  renderEras(
15081
14788
  g,
15082
14789
  timelineEras,
@@ -15203,17 +14910,13 @@ function getRotateFn(mode) {
15203
14910
  return () => 0;
15204
14911
  }
15205
14912
  function renderWordCloud(container, parsed, palette, _isDark, onClickItem, exportDims) {
15206
- d3Selection9.select(container).selectAll(":not([data-d3-tooltip])").remove();
15207
14913
  const { words, title, cloudOptions } = parsed;
15208
14914
  if (words.length === 0) return;
15209
- const width = exportDims?.width ?? container.clientWidth;
15210
- const height = exportDims?.height ?? container.clientHeight;
15211
- if (width <= 0 || height <= 0) return;
14915
+ const init2 = initD3Chart(container, palette, exportDims);
14916
+ if (!init2) return;
14917
+ const { svg, width, height, textColor, colors } = init2;
15212
14918
  const titleHeight = title ? 40 : 0;
15213
14919
  const cloudHeight = height - titleHeight;
15214
- const textColor = palette.text;
15215
- const bgColor = palette.bg;
15216
- const colors = getSeriesColors(palette);
15217
14920
  const { minSize, maxSize } = cloudOptions;
15218
14921
  const weights = words.map((w) => w.weight);
15219
14922
  const minWeight = Math.min(...weights);
@@ -15224,20 +14927,7 @@ function renderWordCloud(container, parsed, palette, _isDark, onClickItem, expor
15224
14927
  return minSize + t * (maxSize - minSize);
15225
14928
  };
15226
14929
  const rotateFn = getRotateFn(cloudOptions.rotate);
15227
- const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
15228
- if (title) {
15229
- const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
15230
- if (parsed.titleLineNumber) {
15231
- titleEl.attr("data-line-number", parsed.titleLineNumber);
15232
- if (onClickItem) {
15233
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
15234
- d3Selection9.select(this).attr("opacity", 0.7);
15235
- }).on("mouseleave", function() {
15236
- d3Selection9.select(this).attr("opacity", 1);
15237
- });
15238
- }
15239
- }
15240
- }
14930
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
15241
14931
  const g = svg.append("g").attr(
15242
14932
  "transform",
15243
14933
  `translate(${width / 2},${titleHeight + cloudHeight / 2})`
@@ -15288,12 +14978,7 @@ function renderWordCloudAsync(container, parsed, palette, _isDark, exportDims) {
15288
14978
  };
15289
14979
  const rotateFn = getRotateFn(cloudOptions.rotate);
15290
14980
  const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
15291
- if (title) {
15292
- const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").text(title);
15293
- if (parsed.titleLineNumber) {
15294
- titleEl.attr("data-line-number", parsed.titleLineNumber);
15295
- }
15296
- }
14981
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor);
15297
14982
  const g = svg.append("g").attr(
15298
14983
  "transform",
15299
14984
  `translate(${width / 2},${titleHeight + cloudHeight / 2})`
@@ -15424,15 +15109,11 @@ function regionCentroid(circles, inside) {
15424
15109
  return { x: sx / count, y: sy / count };
15425
15110
  }
15426
15111
  function renderVenn(container, parsed, palette, isDark, onClickItem, exportDims) {
15427
- d3Selection9.select(container).selectAll(":not([data-d3-tooltip])").remove();
15428
15112
  const { vennSets, vennOverlaps, vennShowValues, title } = parsed;
15429
15113
  if (vennSets.length < 2) return;
15430
- const width = exportDims?.width ?? container.clientWidth;
15431
- const height = exportDims?.height ?? container.clientHeight;
15432
- if (width <= 0 || height <= 0) return;
15433
- const textColor = palette.text;
15434
- const bgColor = palette.bg;
15435
- const colors = getSeriesColors(palette);
15114
+ const init2 = initD3Chart(container, palette, exportDims);
15115
+ if (!init2) return;
15116
+ const { svg, width, height, textColor, colors } = init2;
15436
15117
  const titleHeight = title ? 40 : 0;
15437
15118
  const radii = vennSets.map((s) => radiusFromArea(s.size));
15438
15119
  const overlapMap = /* @__PURE__ */ new Map();
@@ -15511,21 +15192,8 @@ function renderVenn(container, parsed, palette, isDark, onClickItem, exportDims)
15511
15192
  marginTop,
15512
15193
  marginBottom
15513
15194
  ).map((c) => ({ ...c, y: c.y + titleHeight }));
15514
- const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
15515
15195
  const tooltip = createTooltip(container, palette, isDark);
15516
- if (title) {
15517
- const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
15518
- if (parsed.titleLineNumber) {
15519
- titleEl.attr("data-line-number", parsed.titleLineNumber);
15520
- if (onClickItem) {
15521
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
15522
- d3Selection9.select(this).attr("opacity", 0.7);
15523
- }).on("mouseleave", function() {
15524
- d3Selection9.select(this).attr("opacity", 1);
15525
- });
15526
- }
15527
- }
15528
- }
15196
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
15529
15197
  const circleEls = [];
15530
15198
  const circleGroup = svg.append("g");
15531
15199
  circles.forEach((c, i) => {
@@ -15669,7 +15337,6 @@ function renderVenn(container, parsed, palette, isDark, onClickItem, exportDims)
15669
15337
  });
15670
15338
  }
15671
15339
  function renderQuadrant(container, parsed, palette, isDark, onClickItem, exportDims) {
15672
- d3Selection9.select(container).selectAll(":not([data-d3-tooltip])").remove();
15673
15340
  const {
15674
15341
  title,
15675
15342
  quadrantLabels,
@@ -15681,12 +15348,10 @@ function renderQuadrant(container, parsed, palette, isDark, onClickItem, exportD
15681
15348
  quadrantYAxisLineNumber
15682
15349
  } = parsed;
15683
15350
  if (quadrantPoints.length === 0) return;
15684
- const width = exportDims?.width ?? container.clientWidth;
15685
- const height = exportDims?.height ?? container.clientHeight;
15686
- if (width <= 0 || height <= 0) return;
15687
- const textColor = palette.text;
15351
+ const init2 = initD3Chart(container, palette, exportDims);
15352
+ if (!init2) return;
15353
+ const { svg, width, height, textColor } = init2;
15688
15354
  const mutedColor = palette.textMuted;
15689
- const bgColor = palette.bg;
15690
15355
  const borderColor = palette.border;
15691
15356
  const defaultColors = [
15692
15357
  palette.colors.blue,
@@ -15701,24 +15366,8 @@ function renderQuadrant(container, parsed, palette, isDark, onClickItem, exportD
15701
15366
  const chartHeight = height - margin.top - margin.bottom;
15702
15367
  const xScale = d3Scale.scaleLinear().domain([0, 1]).range([0, chartWidth]);
15703
15368
  const yScale = d3Scale.scaleLinear().domain([0, 1]).range([chartHeight, 0]);
15704
- const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
15705
15369
  const tooltip = createTooltip(container, palette, isDark);
15706
- if (title) {
15707
- const titleText = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style(
15708
- "cursor",
15709
- onClickItem && quadrantTitleLineNumber ? "pointer" : "default"
15710
- ).text(title);
15711
- if (quadrantTitleLineNumber) {
15712
- titleText.attr("data-line-number", quadrantTitleLineNumber);
15713
- }
15714
- if (onClickItem && quadrantTitleLineNumber) {
15715
- titleText.on("click", () => onClickItem(quadrantTitleLineNumber)).on("mouseenter", function() {
15716
- d3Selection9.select(this).attr("opacity", 0.7);
15717
- }).on("mouseleave", function() {
15718
- d3Selection9.select(this).attr("opacity", 1);
15719
- });
15720
- }
15721
- }
15370
+ renderChartTitle(svg, title, quadrantTitleLineNumber, width, textColor, onClickItem);
15722
15371
  const chartG = svg.append("g").attr("transform", `translate(${margin.left}, ${margin.top})`);
15723
15372
  const mixHex = (a, b, pct) => {
15724
15373
  const parse = (h) => {
@@ -15967,6 +15616,38 @@ function renderQuadrant(container, parsed, palette, isDark, onClickItem, exportD
15967
15616
  }
15968
15617
  });
15969
15618
  }
15619
+ async function resolveExportPalette(theme, palette) {
15620
+ if (palette) return palette;
15621
+ const { getPalette: getPalette2 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
15622
+ return theme === "dark" ? getPalette2("nord").dark : getPalette2("nord").light;
15623
+ }
15624
+ function createExportContainer(width, height) {
15625
+ const container = document.createElement("div");
15626
+ container.style.width = `${width}px`;
15627
+ container.style.height = `${height}px`;
15628
+ container.style.position = "absolute";
15629
+ container.style.left = "-9999px";
15630
+ document.body.appendChild(container);
15631
+ return container;
15632
+ }
15633
+ function finalizeSvgExport(container, theme, palette, options) {
15634
+ const svgEl = container.querySelector("svg");
15635
+ if (!svgEl) return "";
15636
+ if (theme === "transparent") {
15637
+ svgEl.style.background = "none";
15638
+ } else if (!svgEl.style.background) {
15639
+ svgEl.style.background = palette.bg;
15640
+ }
15641
+ svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
15642
+ svgEl.style.fontFamily = FONT_FAMILY;
15643
+ const svgHtml = svgEl.outerHTML;
15644
+ document.body.removeChild(container);
15645
+ if (options?.branding !== false) {
15646
+ const brandColor = theme === "transparent" ? "#888" : palette.textMuted;
15647
+ return injectBranding(svgHtml, brandColor);
15648
+ }
15649
+ return svgHtml;
15650
+ }
15970
15651
  async function renderD3ForExport(content, theme, palette, orgExportState, options) {
15971
15652
  const { parseDgmoChartType: parseDgmoChartType2 } = await Promise.resolve().then(() => (init_dgmo_router(), dgmo_router_exports));
15972
15653
  const detectedType = parseDgmoChartType2(content);
@@ -15976,8 +15657,7 @@ async function renderD3ForExport(content, theme, palette, orgExportState, option
15976
15657
  const { collapseOrgTree: collapseOrgTree2 } = await Promise.resolve().then(() => (init_collapse(), collapse_exports));
15977
15658
  const { renderOrg: renderOrg2 } = await Promise.resolve().then(() => (init_renderer(), renderer_exports));
15978
15659
  const isDark2 = theme === "dark";
15979
- const { getPalette: getPalette3 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
15980
- const effectivePalette2 = palette ?? (isDark2 ? getPalette3("nord").dark : getPalette3("nord").light);
15660
+ const effectivePalette2 = await resolveExportPalette(theme, palette);
15981
15661
  const orgParsed = parseOrg2(content, effectivePalette2);
15982
15662
  if (orgParsed.error) return "";
15983
15663
  const collapsedNodes = orgExportState?.collapsedNodes;
@@ -15994,83 +15674,28 @@ async function renderD3ForExport(content, theme, palette, orgExportState, option
15994
15674
  const titleOffset = effectiveParsed.title ? 30 : 0;
15995
15675
  const exportWidth = orgLayout.width + PADDING * 2;
15996
15676
  const exportHeight = orgLayout.height + PADDING * 2 + titleOffset;
15997
- const container2 = document.createElement("div");
15998
- container2.style.width = `${exportWidth}px`;
15999
- container2.style.height = `${exportHeight}px`;
16000
- container2.style.position = "absolute";
16001
- container2.style.left = "-9999px";
16002
- document.body.appendChild(container2);
16003
- try {
16004
- renderOrg2(
16005
- container2,
16006
- effectiveParsed,
16007
- orgLayout,
16008
- effectivePalette2,
16009
- isDark2,
16010
- void 0,
16011
- { width: exportWidth, height: exportHeight },
16012
- activeTagGroup,
16013
- hiddenAttributes
16014
- );
16015
- const svgEl = container2.querySelector("svg");
16016
- if (!svgEl) return "";
16017
- if (theme === "transparent") {
16018
- svgEl.style.background = "none";
16019
- } else if (!svgEl.style.background) {
16020
- svgEl.style.background = effectivePalette2.bg;
16021
- }
16022
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16023
- svgEl.style.fontFamily = FONT_FAMILY;
16024
- const svgHtml = svgEl.outerHTML;
16025
- if (options?.branding !== false) {
16026
- const brandColor = theme === "transparent" ? "#888" : effectivePalette2.textMuted;
16027
- return injectBranding(svgHtml, brandColor);
16028
- }
16029
- return svgHtml;
16030
- } finally {
16031
- document.body.removeChild(container2);
16032
- }
15677
+ const container2 = createExportContainer(exportWidth, exportHeight);
15678
+ renderOrg2(container2, effectiveParsed, orgLayout, effectivePalette2, isDark2, void 0, { width: exportWidth, height: exportHeight }, activeTagGroup, hiddenAttributes);
15679
+ return finalizeSvgExport(container2, theme, effectivePalette2, options);
16033
15680
  }
16034
15681
  if (detectedType === "kanban") {
16035
15682
  const { parseKanban: parseKanban2 } = await Promise.resolve().then(() => (init_parser5(), parser_exports5));
16036
15683
  const { renderKanban: renderKanban2 } = await Promise.resolve().then(() => (init_renderer2(), renderer_exports2));
16037
- const isDark2 = theme === "dark";
16038
- const { getPalette: getPalette3 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
16039
- const effectivePalette2 = palette ?? (isDark2 ? getPalette3("nord").dark : getPalette3("nord").light);
15684
+ const effectivePalette2 = await resolveExportPalette(theme, palette);
16040
15685
  const kanbanParsed = parseKanban2(content, effectivePalette2);
16041
15686
  if (kanbanParsed.error || kanbanParsed.columns.length === 0) return "";
16042
15687
  const container2 = document.createElement("div");
16043
15688
  container2.style.position = "absolute";
16044
15689
  container2.style.left = "-9999px";
16045
15690
  document.body.appendChild(container2);
16046
- try {
16047
- renderKanban2(container2, kanbanParsed, effectivePalette2, isDark2);
16048
- const svgEl = container2.querySelector("svg");
16049
- if (!svgEl) return "";
16050
- if (theme === "transparent") {
16051
- svgEl.style.background = "none";
16052
- } else if (!svgEl.style.background) {
16053
- svgEl.style.background = effectivePalette2.bg;
16054
- }
16055
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16056
- svgEl.style.fontFamily = FONT_FAMILY;
16057
- const svgHtml = svgEl.outerHTML;
16058
- if (options?.branding !== false) {
16059
- const brandColor = theme === "transparent" ? "#888" : effectivePalette2.textMuted;
16060
- return injectBranding(svgHtml, brandColor);
16061
- }
16062
- return svgHtml;
16063
- } finally {
16064
- document.body.removeChild(container2);
16065
- }
15691
+ renderKanban2(container2, kanbanParsed, effectivePalette2, theme === "dark");
15692
+ return finalizeSvgExport(container2, theme, effectivePalette2, options);
16066
15693
  }
16067
15694
  if (detectedType === "class") {
16068
15695
  const { parseClassDiagram: parseClassDiagram2 } = await Promise.resolve().then(() => (init_parser2(), parser_exports2));
16069
15696
  const { layoutClassDiagram: layoutClassDiagram2 } = await Promise.resolve().then(() => (init_layout2(), layout_exports2));
16070
15697
  const { renderClassDiagram: renderClassDiagram2 } = await Promise.resolve().then(() => (init_renderer3(), renderer_exports3));
16071
- const isDark2 = theme === "dark";
16072
- const { getPalette: getPalette3 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
16073
- const effectivePalette2 = palette ?? (isDark2 ? getPalette3("nord").dark : getPalette3("nord").light);
15698
+ const effectivePalette2 = await resolveExportPalette(theme, palette);
16074
15699
  const classParsed = parseClassDiagram2(content, effectivePalette2);
16075
15700
  if (classParsed.error || classParsed.classes.length === 0) return "";
16076
15701
  const classLayout = layoutClassDiagram2(classParsed);
@@ -16078,48 +15703,15 @@ async function renderD3ForExport(content, theme, palette, orgExportState, option
16078
15703
  const titleOffset = classParsed.title ? 40 : 0;
16079
15704
  const exportWidth = classLayout.width + PADDING * 2;
16080
15705
  const exportHeight = classLayout.height + PADDING * 2 + titleOffset;
16081
- const container2 = document.createElement("div");
16082
- container2.style.width = `${exportWidth}px`;
16083
- container2.style.height = `${exportHeight}px`;
16084
- container2.style.position = "absolute";
16085
- container2.style.left = "-9999px";
16086
- document.body.appendChild(container2);
16087
- try {
16088
- renderClassDiagram2(
16089
- container2,
16090
- classParsed,
16091
- classLayout,
16092
- effectivePalette2,
16093
- isDark2,
16094
- void 0,
16095
- { width: exportWidth, height: exportHeight }
16096
- );
16097
- const svgEl = container2.querySelector("svg");
16098
- if (!svgEl) return "";
16099
- if (theme === "transparent") {
16100
- svgEl.style.background = "none";
16101
- } else if (!svgEl.style.background) {
16102
- svgEl.style.background = effectivePalette2.bg;
16103
- }
16104
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16105
- svgEl.style.fontFamily = FONT_FAMILY;
16106
- const svgHtml = svgEl.outerHTML;
16107
- if (options?.branding !== false) {
16108
- const brandColor = theme === "transparent" ? "#888" : effectivePalette2.textMuted;
16109
- return injectBranding(svgHtml, brandColor);
16110
- }
16111
- return svgHtml;
16112
- } finally {
16113
- document.body.removeChild(container2);
16114
- }
15706
+ const container2 = createExportContainer(exportWidth, exportHeight);
15707
+ renderClassDiagram2(container2, classParsed, classLayout, effectivePalette2, theme === "dark", void 0, { width: exportWidth, height: exportHeight });
15708
+ return finalizeSvgExport(container2, theme, effectivePalette2, options);
16115
15709
  }
16116
15710
  if (detectedType === "er") {
16117
15711
  const { parseERDiagram: parseERDiagram2 } = await Promise.resolve().then(() => (init_parser3(), parser_exports3));
16118
15712
  const { layoutERDiagram: layoutERDiagram2 } = await Promise.resolve().then(() => (init_layout3(), layout_exports3));
16119
15713
  const { renderERDiagram: renderERDiagram2 } = await Promise.resolve().then(() => (init_renderer4(), renderer_exports4));
16120
- const isDark2 = theme === "dark";
16121
- const { getPalette: getPalette3 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
16122
- const effectivePalette2 = palette ?? (isDark2 ? getPalette3("nord").dark : getPalette3("nord").light);
15714
+ const effectivePalette2 = await resolveExportPalette(theme, palette);
16123
15715
  const erParsed = parseERDiagram2(content, effectivePalette2);
16124
15716
  if (erParsed.error || erParsed.tables.length === 0) return "";
16125
15717
  const erLayout = layoutERDiagram2(erParsed);
@@ -16127,48 +15719,15 @@ async function renderD3ForExport(content, theme, palette, orgExportState, option
16127
15719
  const titleOffset = erParsed.title ? 40 : 0;
16128
15720
  const exportWidth = erLayout.width + PADDING * 2;
16129
15721
  const exportHeight = erLayout.height + PADDING * 2 + titleOffset;
16130
- const container2 = document.createElement("div");
16131
- container2.style.width = `${exportWidth}px`;
16132
- container2.style.height = `${exportHeight}px`;
16133
- container2.style.position = "absolute";
16134
- container2.style.left = "-9999px";
16135
- document.body.appendChild(container2);
16136
- try {
16137
- renderERDiagram2(
16138
- container2,
16139
- erParsed,
16140
- erLayout,
16141
- effectivePalette2,
16142
- isDark2,
16143
- void 0,
16144
- { width: exportWidth, height: exportHeight }
16145
- );
16146
- const svgEl = container2.querySelector("svg");
16147
- if (!svgEl) return "";
16148
- if (theme === "transparent") {
16149
- svgEl.style.background = "none";
16150
- } else if (!svgEl.style.background) {
16151
- svgEl.style.background = effectivePalette2.bg;
16152
- }
16153
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16154
- svgEl.style.fontFamily = FONT_FAMILY;
16155
- const svgHtml = svgEl.outerHTML;
16156
- if (options?.branding !== false) {
16157
- const brandColor = theme === "transparent" ? "#888" : effectivePalette2.textMuted;
16158
- return injectBranding(svgHtml, brandColor);
16159
- }
16160
- return svgHtml;
16161
- } finally {
16162
- document.body.removeChild(container2);
16163
- }
15722
+ const container2 = createExportContainer(exportWidth, exportHeight);
15723
+ renderERDiagram2(container2, erParsed, erLayout, effectivePalette2, theme === "dark", void 0, { width: exportWidth, height: exportHeight });
15724
+ return finalizeSvgExport(container2, theme, effectivePalette2, options);
16164
15725
  }
16165
15726
  if (detectedType === "initiative-status") {
16166
15727
  const { parseInitiativeStatus: parseInitiativeStatus2 } = await Promise.resolve().then(() => (init_parser7(), parser_exports7));
16167
15728
  const { layoutInitiativeStatus: layoutInitiativeStatus2 } = await Promise.resolve().then(() => (init_layout4(), layout_exports4));
16168
15729
  const { renderInitiativeStatus: renderInitiativeStatus2 } = await Promise.resolve().then(() => (init_renderer5(), renderer_exports5));
16169
- const isDark2 = theme === "dark";
16170
- const { getPalette: getPalette3 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
16171
- const effectivePalette2 = palette ?? (isDark2 ? getPalette3("nord").dark : getPalette3("nord").light);
15730
+ const effectivePalette2 = await resolveExportPalette(theme, palette);
16172
15731
  const isParsed = parseInitiativeStatus2(content);
16173
15732
  if (isParsed.error || isParsed.nodes.length === 0) return "";
16174
15733
  const isLayout = layoutInitiativeStatus2(isParsed);
@@ -16176,48 +15735,15 @@ async function renderD3ForExport(content, theme, palette, orgExportState, option
16176
15735
  const titleOffset = isParsed.title ? 40 : 0;
16177
15736
  const exportWidth = isLayout.width + PADDING * 2;
16178
15737
  const exportHeight = isLayout.height + PADDING * 2 + titleOffset;
16179
- const container2 = document.createElement("div");
16180
- container2.style.width = `${exportWidth}px`;
16181
- container2.style.height = `${exportHeight}px`;
16182
- container2.style.position = "absolute";
16183
- container2.style.left = "-9999px";
16184
- document.body.appendChild(container2);
16185
- try {
16186
- renderInitiativeStatus2(
16187
- container2,
16188
- isParsed,
16189
- isLayout,
16190
- effectivePalette2,
16191
- isDark2,
16192
- void 0,
16193
- { width: exportWidth, height: exportHeight }
16194
- );
16195
- const svgEl = container2.querySelector("svg");
16196
- if (!svgEl) return "";
16197
- if (theme === "transparent") {
16198
- svgEl.style.background = "none";
16199
- } else if (!svgEl.style.background) {
16200
- svgEl.style.background = effectivePalette2.bg;
16201
- }
16202
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16203
- svgEl.style.fontFamily = FONT_FAMILY;
16204
- const svgHtml = svgEl.outerHTML;
16205
- if (options?.branding !== false) {
16206
- const brandColor = theme === "transparent" ? "#888" : effectivePalette2.textMuted;
16207
- return injectBranding(svgHtml, brandColor);
16208
- }
16209
- return svgHtml;
16210
- } finally {
16211
- document.body.removeChild(container2);
16212
- }
15738
+ const container2 = createExportContainer(exportWidth, exportHeight);
15739
+ renderInitiativeStatus2(container2, isParsed, isLayout, effectivePalette2, theme === "dark", void 0, { width: exportWidth, height: exportHeight });
15740
+ return finalizeSvgExport(container2, theme, effectivePalette2, options);
16213
15741
  }
16214
15742
  if (detectedType === "c4") {
16215
15743
  const { parseC4: parseC42 } = await Promise.resolve().then(() => (init_parser6(), parser_exports6));
16216
15744
  const { layoutC4Context: layoutC4Context2, layoutC4Containers: layoutC4Containers2, layoutC4Components: layoutC4Components2, layoutC4Deployment: layoutC4Deployment2 } = await Promise.resolve().then(() => (init_layout5(), layout_exports5));
16217
15745
  const { renderC4Context: renderC4Context2, renderC4Containers: renderC4Containers2 } = await Promise.resolve().then(() => (init_renderer6(), renderer_exports6));
16218
- const isDark2 = theme === "dark";
16219
- const { getPalette: getPalette3 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
16220
- const effectivePalette2 = palette ?? (isDark2 ? getPalette3("nord").dark : getPalette3("nord").light);
15746
+ const effectivePalette2 = await resolveExportPalette(theme, palette);
16221
15747
  const c4Parsed = parseC42(content, effectivePalette2);
16222
15748
  if (c4Parsed.error || c4Parsed.elements.length === 0) return "";
16223
15749
  const c4Level = options?.c4Level ?? "context";
@@ -16229,81 +15755,22 @@ async function renderD3ForExport(content, theme, palette, orgExportState, option
16229
15755
  const titleOffset = c4Parsed.title ? 40 : 0;
16230
15756
  const exportWidth = c4Layout.width + PADDING * 2;
16231
15757
  const exportHeight = c4Layout.height + PADDING * 2 + titleOffset;
16232
- const container2 = document.createElement("div");
16233
- container2.style.width = `${exportWidth}px`;
16234
- container2.style.height = `${exportHeight}px`;
16235
- container2.style.position = "absolute";
16236
- container2.style.left = "-9999px";
16237
- document.body.appendChild(container2);
16238
- try {
16239
- const renderFn = c4Level === "deployment" || c4Level === "components" && c4System && c4Container || c4Level === "containers" && c4System ? renderC4Containers2 : renderC4Context2;
16240
- renderFn(
16241
- container2,
16242
- c4Parsed,
16243
- c4Layout,
16244
- effectivePalette2,
16245
- isDark2,
16246
- void 0,
16247
- { width: exportWidth, height: exportHeight }
16248
- );
16249
- const svgEl = container2.querySelector("svg");
16250
- if (!svgEl) return "";
16251
- if (theme === "transparent") {
16252
- svgEl.style.background = "none";
16253
- } else if (!svgEl.style.background) {
16254
- svgEl.style.background = effectivePalette2.bg;
16255
- }
16256
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16257
- svgEl.style.fontFamily = FONT_FAMILY;
16258
- const svgHtml = svgEl.outerHTML;
16259
- if (options?.branding !== false) {
16260
- const brandColor = theme === "transparent" ? "#888" : effectivePalette2.textMuted;
16261
- return injectBranding(svgHtml, brandColor);
16262
- }
16263
- return svgHtml;
16264
- } finally {
16265
- document.body.removeChild(container2);
16266
- }
15758
+ const container2 = createExportContainer(exportWidth, exportHeight);
15759
+ const renderFn = c4Level === "deployment" || c4Level === "components" && c4System && c4Container || c4Level === "containers" && c4System ? renderC4Containers2 : renderC4Context2;
15760
+ renderFn(container2, c4Parsed, c4Layout, effectivePalette2, theme === "dark", void 0, { width: exportWidth, height: exportHeight });
15761
+ return finalizeSvgExport(container2, theme, effectivePalette2, options);
16267
15762
  }
16268
15763
  if (detectedType === "flowchart") {
16269
15764
  const { parseFlowchart: parseFlowchart2 } = await Promise.resolve().then(() => (init_flowchart_parser(), flowchart_parser_exports));
16270
15765
  const { layoutGraph: layoutGraph2 } = await Promise.resolve().then(() => (init_layout6(), layout_exports6));
16271
15766
  const { renderFlowchart: renderFlowchart2 } = await Promise.resolve().then(() => (init_flowchart_renderer(), flowchart_renderer_exports));
16272
- const isDark2 = theme === "dark";
16273
- const { getPalette: getPalette3 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
16274
- const effectivePalette2 = palette ?? (isDark2 ? getPalette3("nord").dark : getPalette3("nord").light);
15767
+ const effectivePalette2 = await resolveExportPalette(theme, palette);
16275
15768
  const fcParsed = parseFlowchart2(content, effectivePalette2);
16276
15769
  if (fcParsed.error || fcParsed.nodes.length === 0) return "";
16277
15770
  const layout = layoutGraph2(fcParsed);
16278
- const container2 = document.createElement("div");
16279
- container2.style.width = `${EXPORT_WIDTH}px`;
16280
- container2.style.height = `${EXPORT_HEIGHT}px`;
16281
- container2.style.position = "absolute";
16282
- container2.style.left = "-9999px";
16283
- document.body.appendChild(container2);
16284
- try {
16285
- renderFlowchart2(container2, fcParsed, layout, effectivePalette2, isDark2, void 0, {
16286
- width: EXPORT_WIDTH,
16287
- height: EXPORT_HEIGHT
16288
- });
16289
- const svgEl = container2.querySelector("svg");
16290
- if (!svgEl) return "";
16291
- if (theme === "transparent") {
16292
- svgEl.style.background = "none";
16293
- } else if (!svgEl.style.background) {
16294
- svgEl.style.background = effectivePalette2.bg;
16295
- }
16296
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16297
- svgEl.style.fontFamily = FONT_FAMILY;
16298
- const svgHtml = svgEl.outerHTML;
16299
- if (options?.branding !== false) {
16300
- const brandColor = theme === "transparent" ? "#888" : effectivePalette2.textMuted;
16301
- return injectBranding(svgHtml, brandColor);
16302
- }
16303
- return svgHtml;
16304
- } finally {
16305
- document.body.removeChild(container2);
16306
- }
15771
+ const container2 = createExportContainer(EXPORT_WIDTH, EXPORT_HEIGHT);
15772
+ renderFlowchart2(container2, fcParsed, layout, effectivePalette2, theme === "dark", void 0, { width: EXPORT_WIDTH, height: EXPORT_HEIGHT });
15773
+ return finalizeSvgExport(container2, theme, effectivePalette2, options);
16307
15774
  }
16308
15775
  const parsed = parseD3(content, palette);
16309
15776
  if (parsed.error && parsed.type !== "sequence") {
@@ -16319,56 +15786,32 @@ async function renderD3ForExport(content, theme, palette, orgExportState, option
16319
15786
  if (parsed.type === "venn" && parsed.vennSets.length < 2) return "";
16320
15787
  if (parsed.type === "quadrant" && parsed.quadrantPoints.length === 0)
16321
15788
  return "";
15789
+ const effectivePalette = await resolveExportPalette(theme, palette);
16322
15790
  const isDark = theme === "dark";
16323
- const { getPalette: getPalette2 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
16324
- const effectivePalette = palette ?? (isDark ? getPalette2("nord").dark : getPalette2("nord").light);
16325
- const container = document.createElement("div");
16326
- container.style.width = `${EXPORT_WIDTH}px`;
16327
- container.style.height = `${EXPORT_HEIGHT}px`;
16328
- container.style.position = "absolute";
16329
- container.style.left = "-9999px";
16330
- document.body.appendChild(container);
15791
+ const container = createExportContainer(EXPORT_WIDTH, EXPORT_HEIGHT);
16331
15792
  const dims = { width: EXPORT_WIDTH, height: EXPORT_HEIGHT };
16332
- try {
16333
- if (parsed.type === "sequence") {
16334
- const { parseSequenceDgmo: parseSequenceDgmo2 } = await Promise.resolve().then(() => (init_parser(), parser_exports));
16335
- const { renderSequenceDiagram: renderSequenceDiagram2 } = await Promise.resolve().then(() => (init_renderer7(), renderer_exports7));
16336
- const seqParsed = parseSequenceDgmo2(content);
16337
- if (seqParsed.error || seqParsed.participants.length === 0) return "";
16338
- renderSequenceDiagram2(container, seqParsed, effectivePalette, isDark, void 0, {
16339
- exportWidth: EXPORT_WIDTH
16340
- });
16341
- } else if (parsed.type === "wordcloud") {
16342
- await renderWordCloudAsync(container, parsed, effectivePalette, isDark, dims);
16343
- } else if (parsed.type === "arc") {
16344
- renderArcDiagram(container, parsed, effectivePalette, isDark, void 0, dims);
16345
- } else if (parsed.type === "timeline") {
16346
- renderTimeline(container, parsed, effectivePalette, isDark, void 0, dims);
16347
- } else if (parsed.type === "venn") {
16348
- renderVenn(container, parsed, effectivePalette, isDark, void 0, dims);
16349
- } else if (parsed.type === "quadrant") {
16350
- renderQuadrant(container, parsed, effectivePalette, isDark, void 0, dims);
16351
- } else {
16352
- renderSlopeChart(container, parsed, effectivePalette, isDark, void 0, dims);
16353
- }
16354
- const svgEl = container.querySelector("svg");
16355
- if (!svgEl) return "";
16356
- if (theme === "transparent") {
16357
- svgEl.style.background = "none";
16358
- } else if (!svgEl.style.background) {
16359
- svgEl.style.background = effectivePalette.bg;
16360
- }
16361
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16362
- svgEl.style.fontFamily = FONT_FAMILY;
16363
- const svgHtml = svgEl.outerHTML;
16364
- if (options?.branding !== false) {
16365
- const brandColor = theme === "transparent" ? "#888" : effectivePalette.textMuted;
16366
- return injectBranding(svgHtml, brandColor);
16367
- }
16368
- return svgHtml;
16369
- } finally {
16370
- document.body.removeChild(container);
15793
+ if (parsed.type === "sequence") {
15794
+ const { parseSequenceDgmo: parseSequenceDgmo2 } = await Promise.resolve().then(() => (init_parser(), parser_exports));
15795
+ const { renderSequenceDiagram: renderSequenceDiagram2 } = await Promise.resolve().then(() => (init_renderer7(), renderer_exports7));
15796
+ const seqParsed = parseSequenceDgmo2(content);
15797
+ if (seqParsed.error || seqParsed.participants.length === 0) return "";
15798
+ renderSequenceDiagram2(container, seqParsed, effectivePalette, isDark, void 0, {
15799
+ exportWidth: EXPORT_WIDTH
15800
+ });
15801
+ } else if (parsed.type === "wordcloud") {
15802
+ await renderWordCloudAsync(container, parsed, effectivePalette, isDark, dims);
15803
+ } else if (parsed.type === "arc") {
15804
+ renderArcDiagram(container, parsed, effectivePalette, isDark, void 0, dims);
15805
+ } else if (parsed.type === "timeline") {
15806
+ renderTimeline(container, parsed, effectivePalette, isDark, void 0, dims);
15807
+ } else if (parsed.type === "venn") {
15808
+ renderVenn(container, parsed, effectivePalette, isDark, void 0, dims);
15809
+ } else if (parsed.type === "quadrant") {
15810
+ renderQuadrant(container, parsed, effectivePalette, isDark, void 0, dims);
15811
+ } else {
15812
+ renderSlopeChart(container, parsed, effectivePalette, isDark, void 0, dims);
16371
15813
  }
15814
+ return finalizeSvgExport(container, theme, effectivePalette, options);
16372
15815
  }
16373
15816
  var DEFAULT_CLOUD_OPTIONS, STOP_WORDS, SLOPE_MARGIN, SLOPE_LABEL_FONT_SIZE, SLOPE_CHAR_WIDTH, ARC_MARGIN, MONTH_ABBR, EXPORT_WIDTH, EXPORT_HEIGHT;
16374
15817
  var init_d3 = __esm({
@@ -17089,6 +16532,7 @@ init_branding();
17089
16532
  export {
17090
16533
  DGMO_CHART_TYPE_MAP,
17091
16534
  RULE_COUNT,
16535
+ STANDARD_CHART_TYPES,
17092
16536
  addDurationToDate,
17093
16537
  applyGroupOrdering,
17094
16538
  applyPositionOverrides,