@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.cjs CHANGED
@@ -1307,6 +1307,31 @@ function collectIndentedValues(lines, startIndex) {
1307
1307
  }
1308
1308
  return { values, newIndex: j - 1 };
1309
1309
  }
1310
+ function parseSeriesNames(value, lines, lineIndex, palette) {
1311
+ let rawNames;
1312
+ let series;
1313
+ let newIndex = lineIndex;
1314
+ if (value) {
1315
+ series = value;
1316
+ rawNames = value.split(",").map((s) => s.trim()).filter(Boolean);
1317
+ } else {
1318
+ const collected = collectIndentedValues(lines, lineIndex);
1319
+ newIndex = collected.newIndex;
1320
+ rawNames = collected.values;
1321
+ series = rawNames.join(", ");
1322
+ }
1323
+ const names = [];
1324
+ const nameColors = [];
1325
+ for (const raw of rawNames) {
1326
+ const extracted = extractColor(raw, palette);
1327
+ nameColors.push(extracted.color);
1328
+ names.push(extracted.label);
1329
+ }
1330
+ if (names.length === 1) {
1331
+ series = names[0];
1332
+ }
1333
+ return { series, names, nameColors, newIndex };
1334
+ }
1310
1335
  function parsePipeMetadata(segments, aliasMap = /* @__PURE__ */ new Map()) {
1311
1336
  const metadata = {};
1312
1337
  for (let j = 1; j < segments.length; j++) {
@@ -1612,13 +1637,25 @@ var init_participant_inference = __esm({
1612
1637
 
1613
1638
  // src/utils/arrows.ts
1614
1639
  function parseArrow(line7) {
1640
+ if (BIDI_SYNC_RE.test(line7) || BIDI_ASYNC_RE.test(line7)) {
1641
+ return {
1642
+ error: "Bidirectional arrows are no longer supported. Use two separate lines: 'A -msg-> B' and 'B -msg-> A'"
1643
+ };
1644
+ }
1645
+ if (RETURN_SYNC_LABELED_RE.test(line7) || RETURN_ASYNC_LABELED_RE.test(line7)) {
1646
+ const m = line7.match(RETURN_SYNC_LABELED_RE) ?? line7.match(RETURN_ASYNC_LABELED_RE);
1647
+ const from = m[3];
1648
+ const to = m[1];
1649
+ const label = m[2].trim();
1650
+ return {
1651
+ error: `Left-pointing arrows are no longer supported. Write '${from} -${label}-> ${to}' instead`
1652
+ };
1653
+ }
1615
1654
  const patterns = [
1616
- { re: BIDI_SYNC_LABELED_RE, async: false, bidirectional: true },
1617
- { re: BIDI_ASYNC_LABELED_RE, async: true, bidirectional: true },
1618
- { re: SYNC_LABELED_RE, async: false, bidirectional: false },
1619
- { re: ASYNC_LABELED_RE, async: true, bidirectional: false }
1655
+ { re: SYNC_LABELED_RE, async: false },
1656
+ { re: ASYNC_LABELED_RE, async: true }
1620
1657
  ];
1621
- for (const { re, async: isAsync, bidirectional } of patterns) {
1658
+ for (const { re, async: isAsync } of patterns) {
1622
1659
  const m = line7.match(re);
1623
1660
  if (!m) continue;
1624
1661
  const label = m[2].trim();
@@ -1634,21 +1671,22 @@ function parseArrow(line7) {
1634
1671
  from: m[1],
1635
1672
  to: m[3],
1636
1673
  label,
1637
- async: isAsync,
1638
- bidirectional
1674
+ async: isAsync
1639
1675
  };
1640
1676
  }
1641
1677
  return null;
1642
1678
  }
1643
- var BIDI_SYNC_LABELED_RE, BIDI_ASYNC_LABELED_RE, SYNC_LABELED_RE, ASYNC_LABELED_RE, ARROW_CHARS;
1679
+ var SYNC_LABELED_RE, ASYNC_LABELED_RE, RETURN_SYNC_LABELED_RE, RETURN_ASYNC_LABELED_RE, BIDI_SYNC_RE, BIDI_ASYNC_RE, ARROW_CHARS;
1644
1680
  var init_arrows = __esm({
1645
1681
  "src/utils/arrows.ts"() {
1646
1682
  "use strict";
1647
- BIDI_SYNC_LABELED_RE = /^(\S+)\s+<-(.+)->\s+(\S+)$/;
1648
- BIDI_ASYNC_LABELED_RE = /^(\S+)\s+<~(.+)~>\s+(\S+)$/;
1649
1683
  SYNC_LABELED_RE = /^(\S+)\s+-(.+)->\s+(\S+)$/;
1650
1684
  ASYNC_LABELED_RE = /^(\S+)\s+~(.+)~>\s+(\S+)$/;
1651
- ARROW_CHARS = ["->", "~>", "<->", "<~>"];
1685
+ RETURN_SYNC_LABELED_RE = /^(\S+)\s+<-(.+)-\s+(\S+)$/;
1686
+ RETURN_ASYNC_LABELED_RE = /^(\S+)\s+<~(.+)~\s+(\S+)$/;
1687
+ BIDI_SYNC_RE = /^(\S+)\s+<-(.+)->\s+(\S+)$/;
1688
+ BIDI_ASYNC_RE = /^(\S+)\s+<~(.+)~>\s+(\S+)$/;
1689
+ ARROW_CHARS = ["->", "~>"];
1652
1690
  }
1653
1691
  });
1654
1692
 
@@ -1670,36 +1708,6 @@ function isSequenceSection(el) {
1670
1708
  function isSequenceNote(el) {
1671
1709
  return "kind" in el && el.kind === "note";
1672
1710
  }
1673
- function parseReturnLabel(rawLabel) {
1674
- if (!rawLabel) return { label: "" };
1675
- const standaloneMatch = rawLabel.match(/^<-\s*(.*)$/);
1676
- if (standaloneMatch) {
1677
- return {
1678
- label: standaloneMatch[1].trim(),
1679
- standaloneReturn: true
1680
- };
1681
- }
1682
- const arrowReturn = rawLabel.match(ARROW_RETURN_PATTERN);
1683
- if (arrowReturn) {
1684
- return { label: arrowReturn[1].trim(), returnLabel: arrowReturn[2].trim() };
1685
- }
1686
- const umlReturn = rawLabel.match(UML_RETURN_PATTERN);
1687
- if (umlReturn) {
1688
- return { label: umlReturn[1].trim(), returnLabel: umlReturn[2].trim() };
1689
- }
1690
- const lastColon = rawLabel.lastIndexOf(":");
1691
- if (lastColon > 0 && lastColon < rawLabel.length - 1) {
1692
- const afterColon = rawLabel.substring(lastColon + 1);
1693
- if (!afterColon.startsWith("//")) {
1694
- const reqPart = rawLabel.substring(0, lastColon).trim();
1695
- const resPart = afterColon.trim();
1696
- if (reqPart && resPart) {
1697
- return { label: reqPart, returnLabel: resPart };
1698
- }
1699
- }
1700
- }
1701
- return { label: rawLabel };
1702
- }
1703
1711
  function parseSequenceDgmo(content) {
1704
1712
  const result = {
1705
1713
  title: null,
@@ -1799,7 +1807,7 @@ function parseSequenceDgmo(content) {
1799
1807
  continue;
1800
1808
  }
1801
1809
  const colonIndex = trimmed.indexOf(":");
1802
- if (colonIndex > 0 && !trimmed.includes("->") && !trimmed.includes("~>")) {
1810
+ if (colonIndex > 0 && !trimmed.includes("->") && !trimmed.includes("~>") && !trimmed.includes("<-") && !trimmed.includes("<~")) {
1803
1811
  const key = trimmed.substring(0, colonIndex).trim().toLowerCase();
1804
1812
  if (key === "note" || key.startsWith("note ")) {
1805
1813
  } else {
@@ -1928,16 +1936,14 @@ function parseSequenceDgmo(content) {
1928
1936
  }
1929
1937
  if (labeledArrow) {
1930
1938
  contentStarted = true;
1931
- const { from, to, label, async: isAsync2, bidirectional } = labeledArrow;
1939
+ const { from, to, label, async: isAsync } = labeledArrow;
1932
1940
  lastMsgFrom = from;
1933
1941
  const msg = {
1934
1942
  from,
1935
1943
  to,
1936
1944
  label,
1937
- returnLabel: void 0,
1938
1945
  lineNumber,
1939
- ...isAsync2 ? { async: true } : {},
1940
- ...bidirectional ? { bidirectional: true } : {}
1946
+ ...isAsync ? { async: true } : {}
1941
1947
  };
1942
1948
  result.messages.push(msg);
1943
1949
  currentContainer().push(msg);
@@ -1959,72 +1965,61 @@ function parseSequenceDgmo(content) {
1959
1965
  }
1960
1966
  continue;
1961
1967
  }
1962
- const bidiSyncMatch = trimmed.match(
1963
- /^(\S+)\s*<->\s*([^\s:]+)\s*(?::\s*(.+))?$/
1968
+ const colonPostfixSync = trimmed.match(
1969
+ /^(\S+)\s*->\s*([^\s:]+)\s*:\s*(.+)$/
1964
1970
  );
1965
- const bidiAsyncMatch = trimmed.match(
1966
- /^(\S+)\s*<~>\s*([^\s:]+)\s*(?::\s*(.+))?$/
1971
+ const colonPostfixAsync = trimmed.match(
1972
+ /^(\S+)\s*~>\s*([^\s:]+)\s*:\s*(.+)$/
1967
1973
  );
1968
- const bidiMatch = bidiSyncMatch || bidiAsyncMatch;
1969
- if (bidiMatch) {
1970
- contentStarted = true;
1971
- const from = bidiMatch[1];
1972
- const to = bidiMatch[2];
1973
- lastMsgFrom = from;
1974
- const rawLabel = bidiMatch[3]?.trim() || "";
1975
- const isBidiAsync = !!bidiAsyncMatch;
1976
- const msg = {
1977
- from,
1978
- to,
1979
- label: rawLabel,
1974
+ const colonPostfix = colonPostfixSync || colonPostfixAsync;
1975
+ if (colonPostfix) {
1976
+ const a = colonPostfix[1];
1977
+ const b = colonPostfix[2];
1978
+ const msg = colonPostfix[3].trim();
1979
+ const arrowChar = colonPostfixAsync ? "~" : "-";
1980
+ const arrowEnd = colonPostfixAsync ? "~>" : "->";
1981
+ pushError(
1980
1982
  lineNumber,
1981
- bidirectional: true,
1982
- ...isBidiAsync ? { async: true } : {}
1983
- };
1984
- result.messages.push(msg);
1985
- currentContainer().push(msg);
1986
- if (!result.participants.some((p) => p.id === from)) {
1987
- result.participants.push({
1988
- id: from,
1989
- label: from,
1990
- type: inferParticipantType(from),
1991
- lineNumber
1992
- });
1993
- }
1994
- if (!result.participants.some((p) => p.id === to)) {
1995
- result.participants.push({
1996
- id: to,
1997
- label: to,
1998
- type: inferParticipantType(to),
1999
- lineNumber
2000
- });
2001
- }
1983
+ `Colon syntax is no longer supported. Use '${a} ${arrowChar}${msg}${arrowEnd} ${b}' instead`
1984
+ );
2002
1985
  continue;
2003
1986
  }
2004
- let isAsync = false;
2005
- const asyncArrowMatch = trimmed.match(
2006
- /^(\S+)\s*~>\s*([^\s:]+)\s*(?::\s*(.+))?$/
2007
- );
2008
- const syncArrowMatch = trimmed.match(
2009
- /^(\S+)\s*->\s*([^\s:]+)\s*(?::\s*(.+))?$/
1987
+ const bidiPlainMatch = trimmed.match(
1988
+ /^(\S+)\s*(?:<->|<~>)\s*(\S+)/
2010
1989
  );
2011
- const arrowMatch = asyncArrowMatch || syncArrowMatch;
2012
- if (asyncArrowMatch) isAsync = true;
2013
- if (arrowMatch) {
1990
+ if (bidiPlainMatch) {
1991
+ pushError(
1992
+ lineNumber,
1993
+ "Bidirectional arrows are no longer supported. Use two separate lines: 'A -msg-> B' and 'B -msg-> A'"
1994
+ );
1995
+ continue;
1996
+ }
1997
+ const bareReturnSync = trimmed.match(/^(\S+)\s+<-\s+(\S+)$/);
1998
+ const bareReturnAsync = trimmed.match(/^(\S+)\s+<~\s+(\S+)$/);
1999
+ const bareReturn = bareReturnSync || bareReturnAsync;
2000
+ if (bareReturn) {
2001
+ const to = bareReturn[1];
2002
+ const from = bareReturn[2];
2003
+ pushError(
2004
+ lineNumber,
2005
+ `Left-pointing arrows are no longer supported. Write '${from} -> ${to}' instead`
2006
+ );
2007
+ continue;
2008
+ }
2009
+ const bareCallSync = trimmed.match(/^(\S+)\s*->\s*(\S+)$/);
2010
+ const bareCallAsync = trimmed.match(/^(\S+)\s*~>\s*(\S+)$/);
2011
+ const bareCall = bareCallSync || bareCallAsync;
2012
+ if (bareCall) {
2014
2013
  contentStarted = true;
2015
- const from = arrowMatch[1];
2016
- const to = arrowMatch[2];
2014
+ const from = bareCall[1];
2015
+ const to = bareCall[2];
2017
2016
  lastMsgFrom = from;
2018
- const rawLabel = arrowMatch[3]?.trim() || "";
2019
- const { label, returnLabel, standaloneReturn } = isAsync ? { label: rawLabel, returnLabel: void 0, standaloneReturn: void 0 } : parseReturnLabel(rawLabel);
2020
2017
  const msg = {
2021
2018
  from,
2022
2019
  to,
2023
- label,
2024
- returnLabel,
2020
+ label: "",
2025
2021
  lineNumber,
2026
- ...isAsync ? { async: true } : {},
2027
- ...standaloneReturn ? { standaloneReturn: true } : {}
2022
+ ...bareCallAsync ? { async: true } : {}
2028
2023
  };
2029
2024
  result.messages.push(msg);
2030
2025
  currentContainer().push(msg);
@@ -2233,7 +2228,7 @@ function looksLikeSequence(content) {
2233
2228
  return ARROW_PATTERN.test(trimmed);
2234
2229
  });
2235
2230
  }
2236
- 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;
2231
+ var VALID_PARTICIPANT_TYPES, IS_A_PATTERN, POSITION_ONLY_PATTERN, GROUP_HEADING_PATTERN, SECTION_PATTERN, ARROW_PATTERN, NOTE_SINGLE, NOTE_MULTI;
2237
2232
  var init_parser = __esm({
2238
2233
  "src/sequence/parser.ts"() {
2239
2234
  "use strict";
@@ -2256,9 +2251,7 @@ var init_parser = __esm({
2256
2251
  POSITION_ONLY_PATTERN = /^(\S+)\s+position\s+(-?\d+)$/i;
2257
2252
  GROUP_HEADING_PATTERN = /^##\s+(.+?)(?:\(([^)]+)\))?\s*$/;
2258
2253
  SECTION_PATTERN = /^==\s+(.+?)(?:\s*==)?\s*$/;
2259
- ARROW_PATTERN = /\S+\s*(?:<->|<~>|->|~>|-\S+->|~\S+~>|<-\S+->|<~\S+~>)\s*\S+/;
2260
- ARROW_RETURN_PATTERN = /^(.+?)\s*<-\s*(.+)$/;
2261
- UML_RETURN_PATTERN = /^(\w+\([^)]*\))\s*:\s*(.+)$/;
2254
+ ARROW_PATTERN = /\S+\s*(?:<-\S+-|<~\S+~|-\S+->|~\S+~>|->|~>|<-|<~)\s*\S+/;
2262
2255
  NOTE_SINGLE = /^note(?:\s+(right|left)\s+of\s+(\S+))?\s*:\s*(.+)$/i;
2263
2256
  NOTE_MULTI = /^note(?:\s+(right|left)\s+of\s+([^\s:]+))?\s*:?\s*$/i;
2264
2257
  }
@@ -3164,49 +3157,19 @@ function parseChart(content, palette) {
3164
3157
  continue;
3165
3158
  }
3166
3159
  if (key === "series") {
3167
- let rawNames;
3168
- if (value) {
3169
- result.series = value;
3170
- rawNames = value.split(",").map((s) => s.trim()).filter(Boolean);
3171
- } else {
3172
- const collected = collectIndentedValues(lines, i);
3173
- i = collected.newIndex;
3174
- rawNames = collected.values;
3175
- result.series = rawNames.join(", ");
3160
+ const parsed = parseSeriesNames(value, lines, i, palette);
3161
+ i = parsed.newIndex;
3162
+ result.series = parsed.series;
3163
+ if (parsed.names.length > 1) {
3164
+ result.seriesNames = parsed.names;
3176
3165
  }
3177
- const names = [];
3178
- const nameColors = [];
3179
- for (const raw of rawNames) {
3180
- const colorMatch = raw.match(/\(([^)]+)\)\s*$/);
3181
- if (colorMatch) {
3182
- const resolved = resolveColor(colorMatch[1].trim(), palette);
3183
- nameColors.push(resolved);
3184
- names.push(raw.substring(0, colorMatch.index).trim());
3185
- } else {
3186
- nameColors.push(void 0);
3187
- names.push(raw);
3188
- }
3189
- }
3190
- if (names.length === 1) {
3191
- result.series = names[0];
3192
- }
3193
- if (names.length > 1) {
3194
- result.seriesNames = names;
3195
- }
3196
- if (nameColors.some(Boolean)) result.seriesNameColors = nameColors;
3166
+ if (parsed.nameColors.some(Boolean)) result.seriesNameColors = parsed.nameColors;
3197
3167
  continue;
3198
3168
  }
3199
3169
  const parts = value.split(",").map((s) => s.trim());
3200
3170
  const numValue = parseFloat(parts[0]);
3201
3171
  if (!isNaN(numValue)) {
3202
- let rawLabel = trimmed.substring(0, colonIndex).trim();
3203
- let pointColor;
3204
- const colorMatch = rawLabel.match(/\(([^)]+)\)\s*$/);
3205
- if (colorMatch) {
3206
- const resolved = resolveColor(colorMatch[1].trim(), palette);
3207
- pointColor = resolved;
3208
- rawLabel = rawLabel.substring(0, colorMatch.index).trim();
3209
- }
3172
+ const { label: rawLabel, color: pointColor } = extractColor(trimmed.substring(0, colonIndex).trim(), palette);
3210
3173
  const extra = parts.slice(1).map((s) => parseFloat(s)).filter((n) => !isNaN(n));
3211
3174
  result.data.push({
3212
3175
  label: rawLabel,
@@ -3285,13 +3248,10 @@ function parseEChart(content, palette) {
3285
3248
  if (!trimmed) continue;
3286
3249
  const mdCategoryMatch = trimmed.match(/^#{2,}\s+(.+)$/);
3287
3250
  if (mdCategoryMatch) {
3288
- let catName = mdCategoryMatch[1].trim();
3289
- const catColorMatch = catName.match(/\(([^)]+)\)\s*$/);
3290
- if (catColorMatch) {
3291
- const resolved = resolveColor(catColorMatch[1].trim(), palette);
3251
+ const { label: catName, color: catColor } = extractColor(mdCategoryMatch[1].trim(), palette);
3252
+ if (catColor) {
3292
3253
  if (!result.categoryColors) result.categoryColors = {};
3293
- catName = catName.substring(0, catColorMatch.index).trim();
3294
- result.categoryColors[catName] = resolved;
3254
+ result.categoryColors[catName] = catColor;
3295
3255
  }
3296
3256
  currentCategory = catName;
3297
3257
  continue;
@@ -3328,32 +3288,13 @@ function parseEChart(content, palette) {
3328
3288
  continue;
3329
3289
  }
3330
3290
  if (key === "series") {
3331
- let rawNames;
3332
- if (value) {
3333
- result.series = value;
3334
- rawNames = value.split(",").map((s) => s.trim()).filter(Boolean);
3335
- } else {
3336
- const collected = collectIndentedValues(lines, i);
3337
- i = collected.newIndex;
3338
- rawNames = collected.values;
3339
- result.series = rawNames.join(", ");
3340
- }
3341
- const names = [];
3342
- const nameColors = [];
3343
- for (const raw of rawNames) {
3344
- const colorMatch = raw.match(/\(([^)]+)\)\s*$/);
3345
- if (colorMatch) {
3346
- nameColors.push(resolveColor(colorMatch[1].trim(), palette));
3347
- names.push(raw.substring(0, colorMatch.index).trim());
3348
- } else {
3349
- nameColors.push(void 0);
3350
- names.push(raw);
3351
- }
3352
- }
3353
- if (names.length === 1) {
3354
- result.series = names[0];
3291
+ const parsed = parseSeriesNames(value, lines, i, palette);
3292
+ i = parsed.newIndex;
3293
+ result.series = parsed.series;
3294
+ if (parsed.names.length > 1) {
3295
+ result.seriesNames = parsed.names;
3355
3296
  }
3356
- if (nameColors.some(Boolean)) result.seriesNameColors = nameColors;
3297
+ if (parsed.nameColors.some(Boolean)) result.seriesNameColors = parsed.nameColors;
3357
3298
  continue;
3358
3299
  }
3359
3300
  if (key === "xlabel") {
@@ -3415,13 +3356,7 @@ function parseEChart(content, palette) {
3415
3356
  continue;
3416
3357
  }
3417
3358
  if (result.type === "function") {
3418
- let fnName = trimmed.substring(0, colonIndex).trim();
3419
- let fnColor;
3420
- const colorMatch = fnName.match(/\(([^)]+)\)\s*$/);
3421
- if (colorMatch) {
3422
- fnColor = resolveColor(colorMatch[1].trim(), palette);
3423
- fnName = fnName.substring(0, colorMatch.index).trim();
3424
- }
3359
+ const { label: fnName, color: fnColor } = extractColor(trimmed.substring(0, colonIndex).trim(), palette);
3425
3360
  if (!result.functions) result.functions = [];
3426
3361
  result.functions.push({
3427
3362
  name: fnName,
@@ -3436,13 +3371,7 @@ function parseEChart(content, palette) {
3436
3371
  /^(-?[\d.]+)\s*,\s*(-?[\d.]+)(?:\s*,\s*(-?[\d.]+))?$/
3437
3372
  );
3438
3373
  if (scatterMatch) {
3439
- let scatterName = trimmed.substring(0, colonIndex).trim();
3440
- let scatterColor;
3441
- const colorMatch = scatterName.match(/\(([^)]+)\)\s*$/);
3442
- if (colorMatch) {
3443
- scatterColor = resolveColor(colorMatch[1].trim(), palette);
3444
- scatterName = scatterName.substring(0, colorMatch.index).trim();
3445
- }
3374
+ const { label: scatterName, color: scatterColor } = extractColor(trimmed.substring(0, colonIndex).trim(), palette);
3446
3375
  if (!result.scatterPoints) result.scatterPoints = [];
3447
3376
  result.scatterPoints.push({
3448
3377
  name: scatterName,
@@ -3467,13 +3396,7 @@ function parseEChart(content, palette) {
3467
3396
  }
3468
3397
  const numValue = parseFloat(value);
3469
3398
  if (!isNaN(numValue)) {
3470
- let rawLabel = trimmed.substring(0, colonIndex).trim();
3471
- let pointColor;
3472
- const colorMatch = rawLabel.match(/\(([^)]+)\)\s*$/);
3473
- if (colorMatch) {
3474
- pointColor = resolveColor(colorMatch[1].trim(), palette);
3475
- rawLabel = rawLabel.substring(0, colorMatch.index).trim();
3476
- }
3399
+ const { label: rawLabel, color: pointColor } = extractColor(trimmed.substring(0, colonIndex).trim(), palette);
3477
3400
  result.data.push({
3478
3401
  label: rawLabel,
3479
3402
  value: numValue,
@@ -3520,30 +3443,21 @@ function parseEChart(content, palette) {
3520
3443
  }
3521
3444
  return result;
3522
3445
  }
3523
- function buildEChartsOption(parsed, palette, isDark) {
3446
+ function buildChartCommons(parsed, palette, isDark) {
3524
3447
  const textColor = palette.text;
3525
3448
  const axisLineColor = palette.border;
3449
+ const splitLineColor = palette.border;
3526
3450
  const gridOpacity = isDark ? 0.7 : 0.55;
3527
3451
  const colors = getSeriesColors(palette);
3452
+ const titleConfig = parsed.title ? { text: parsed.title, left: "center", top: 8, textStyle: { color: textColor, fontSize: 20, fontWeight: "bold", fontFamily: FONT_FAMILY } } : void 0;
3453
+ const tooltipTheme = { backgroundColor: palette.surface, borderColor: palette.border, textStyle: { color: palette.text } };
3454
+ return { textColor, axisLineColor, splitLineColor, gridOpacity, colors, titleConfig, tooltipTheme };
3455
+ }
3456
+ function buildEChartsOption(parsed, palette, isDark) {
3528
3457
  if (parsed.error) {
3529
3458
  return {};
3530
3459
  }
3531
- const titleConfig = parsed.title ? {
3532
- text: parsed.title,
3533
- left: "center",
3534
- top: 8,
3535
- textStyle: {
3536
- color: textColor,
3537
- fontSize: 20,
3538
- fontWeight: "bold",
3539
- fontFamily: FONT_FAMILY
3540
- }
3541
- } : void 0;
3542
- const tooltipTheme = {
3543
- backgroundColor: palette.surface,
3544
- borderColor: palette.border,
3545
- textStyle: { color: palette.text }
3546
- };
3460
+ const { textColor, axisLineColor, gridOpacity, colors, titleConfig, tooltipTheme } = buildChartCommons(parsed, palette, isDark);
3547
3461
  if (parsed.type === "sankey") {
3548
3462
  return buildSankeyOption(
3549
3463
  parsed,
@@ -3619,8 +3533,7 @@ function buildSankeyOption(parsed, textColor, colors, titleConfig, tooltipTheme)
3619
3533
  }
3620
3534
  }));
3621
3535
  return {
3622
- backgroundColor: "transparent",
3623
- animation: false,
3536
+ ...CHART_BASE,
3624
3537
  title: titleConfig,
3625
3538
  tooltip: {
3626
3539
  show: false,
@@ -3677,8 +3590,7 @@ function buildChordOption(parsed, textColor, colors, titleConfig, tooltipTheme)
3677
3590
  }
3678
3591
  }));
3679
3592
  return {
3680
- backgroundColor: "transparent",
3681
- animation: false,
3593
+ ...CHART_BASE,
3682
3594
  title: titleConfig,
3683
3595
  tooltip: {
3684
3596
  trigger: "item",
@@ -3780,15 +3692,11 @@ function buildFunctionOption(parsed, palette, textColor, axisLineColor, gridOpac
3780
3692
  itemStyle: {
3781
3693
  color: fnColor
3782
3694
  },
3783
- emphasis: {
3784
- focus: "self",
3785
- blurScope: "global"
3786
- }
3695
+ emphasis: EMPHASIS_SELF
3787
3696
  };
3788
3697
  });
3789
3698
  return {
3790
- backgroundColor: "transparent",
3791
- animation: false,
3699
+ ...CHART_BASE,
3792
3700
  title: titleConfig,
3793
3701
  tooltip: {
3794
3702
  trigger: "axis",
@@ -3933,8 +3841,7 @@ function buildScatterOption(parsed, palette, textColor, axisLineColor, gridOpaci
3933
3841
  const xPad = (xMax - xMin) * 0.1 || 1;
3934
3842
  const yPad = (yMax - yMin) * 0.1 || 1;
3935
3843
  return {
3936
- backgroundColor: "transparent",
3937
- animation: false,
3844
+ ...CHART_BASE,
3938
3845
  title: titleConfig,
3939
3846
  tooltip,
3940
3847
  ...legendData && {
@@ -4019,8 +3926,7 @@ function buildHeatmapOption(parsed, palette, textColor, axisLineColor, titleConf
4019
3926
  });
4020
3927
  });
4021
3928
  return {
4022
- backgroundColor: "transparent",
4023
- animation: false,
3929
+ ...CHART_BASE,
4024
3930
  title: titleConfig,
4025
3931
  tooltip: {
4026
3932
  trigger: "item",
@@ -4097,8 +4003,7 @@ function buildHeatmapOption(parsed, palette, textColor, axisLineColor, titleConf
4097
4003
  fontWeight: "bold"
4098
4004
  },
4099
4005
  emphasis: {
4100
- focus: "self",
4101
- blurScope: "global",
4006
+ ...EMPHASIS_SELF,
4102
4007
  itemStyle: {
4103
4008
  shadowBlur: 10,
4104
4009
  shadowColor: "rgba(0, 0, 0, 0.5)"
@@ -4137,8 +4042,7 @@ function buildFunnelOption(parsed, textColor, colors, titleConfig, tooltipTheme)
4137
4042
  minSize: "8%"
4138
4043
  };
4139
4044
  return {
4140
- backgroundColor: "transparent",
4141
- animation: false,
4045
+ ...CHART_BASE,
4142
4046
  title: titleConfig,
4143
4047
  tooltip: {
4144
4048
  trigger: "item",
@@ -4176,8 +4080,7 @@ function buildFunnelOption(parsed, textColor, colors, titleConfig, tooltipTheme)
4176
4080
  lineStyle: { color: textColor, opacity: 0.3 }
4177
4081
  },
4178
4082
  emphasis: {
4179
- focus: "self",
4180
- blurScope: "global",
4083
+ ...EMPHASIS_SELF,
4181
4084
  label: {
4182
4085
  fontSize: 15
4183
4086
  }
@@ -4260,27 +4163,7 @@ function makeGridAxis(type, textColor, axisLineColor, splitLineColor, gridOpacit
4260
4163
  }
4261
4164
  function buildEChartsOptionFromChart(parsed, palette, isDark, chartWidth) {
4262
4165
  if (parsed.error) return {};
4263
- const textColor = palette.text;
4264
- const axisLineColor = palette.border;
4265
- const splitLineColor = palette.border;
4266
- const gridOpacity = isDark ? 0.7 : 0.55;
4267
- const colors = getSeriesColors(palette);
4268
- const titleConfig = parsed.title ? {
4269
- text: parsed.title,
4270
- left: "center",
4271
- top: 8,
4272
- textStyle: {
4273
- color: textColor,
4274
- fontSize: 20,
4275
- fontWeight: "bold",
4276
- fontFamily: FONT_FAMILY
4277
- }
4278
- } : void 0;
4279
- const tooltipTheme = {
4280
- backgroundColor: palette.surface,
4281
- borderColor: palette.border,
4282
- textStyle: { color: palette.text }
4283
- };
4166
+ const { textColor, axisLineColor, splitLineColor, gridOpacity, colors, titleConfig, tooltipTheme } = buildChartCommons(parsed, palette, isDark);
4284
4167
  switch (parsed.type) {
4285
4168
  case "bar":
4286
4169
  return buildBarOption(parsed, textColor, axisLineColor, splitLineColor, gridOpacity, colors, titleConfig, tooltipTheme, chartWidth);
@@ -4300,6 +4183,15 @@ function buildEChartsOptionFromChart(parsed, palette, isDark, chartWidth) {
4300
4183
  return buildPolarAreaOption(parsed, textColor, getSegmentColors(palette, parsed.data.length), titleConfig, tooltipTheme);
4301
4184
  }
4302
4185
  }
4186
+ function makeChartGrid(options) {
4187
+ return {
4188
+ left: options.yLabel ? "12%" : "3%",
4189
+ right: "4%",
4190
+ bottom: options.hasLegend ? "15%" : options.xLabel ? "10%" : "3%",
4191
+ top: options.hasTitle ? "15%" : "5%",
4192
+ containLabel: true
4193
+ };
4194
+ }
4303
4195
  function buildBarOption(parsed, textColor, axisLineColor, splitLineColor, gridOpacity, colors, titleConfig, tooltipTheme, chartWidth) {
4304
4196
  const { xLabel, yLabel } = resolveAxisLabels(parsed);
4305
4197
  const isHorizontal = parsed.orientation === "horizontal";
@@ -4312,31 +4204,21 @@ function buildBarOption(parsed, textColor, axisLineColor, splitLineColor, gridOp
4312
4204
  const categoryAxis = makeGridAxis("category", textColor, axisLineColor, splitLineColor, gridOpacity, isHorizontal ? yLabel : xLabel, labels, hCatGap, !isHorizontal ? chartWidth : void 0);
4313
4205
  const valueAxis = makeGridAxis("value", textColor, axisLineColor, splitLineColor, gridOpacity, isHorizontal ? xLabel : yLabel);
4314
4206
  return {
4315
- backgroundColor: "transparent",
4316
- animation: false,
4207
+ ...CHART_BASE,
4317
4208
  title: titleConfig,
4318
4209
  tooltip: {
4319
4210
  trigger: "axis",
4320
4211
  ...tooltipTheme,
4321
4212
  axisPointer: { type: "shadow" }
4322
4213
  },
4323
- grid: {
4324
- left: yLabel ? "12%" : "3%",
4325
- right: "4%",
4326
- bottom: xLabel ? "10%" : "3%",
4327
- top: parsed.title ? "15%" : "5%",
4328
- containLabel: true
4329
- },
4214
+ grid: makeChartGrid({ xLabel, yLabel, hasTitle: !!parsed.title }),
4330
4215
  xAxis: isHorizontal ? valueAxis : categoryAxis,
4331
4216
  yAxis: isHorizontal ? categoryAxis : valueAxis,
4332
4217
  series: [
4333
4218
  {
4334
4219
  type: "bar",
4335
4220
  data,
4336
- emphasis: {
4337
- focus: "self",
4338
- blurScope: "global"
4339
- }
4221
+ emphasis: EMPHASIS_SELF
4340
4222
  }
4341
4223
  ]
4342
4224
  };
@@ -4347,21 +4229,14 @@ function buildLineOption(parsed, palette, textColor, axisLineColor, splitLineCol
4347
4229
  const labels = parsed.data.map((d) => d.label);
4348
4230
  const values = parsed.data.map((d) => d.value);
4349
4231
  return {
4350
- backgroundColor: "transparent",
4351
- animation: false,
4232
+ ...CHART_BASE,
4352
4233
  title: titleConfig,
4353
4234
  tooltip: {
4354
4235
  trigger: "axis",
4355
4236
  ...tooltipTheme,
4356
4237
  axisPointer: { type: "line" }
4357
4238
  },
4358
- grid: {
4359
- left: yLabel ? "12%" : "3%",
4360
- right: "4%",
4361
- bottom: xLabel ? "10%" : "3%",
4362
- top: parsed.title ? "15%" : "5%",
4363
- containLabel: true
4364
- },
4239
+ grid: makeChartGrid({ xLabel, yLabel, hasTitle: !!parsed.title }),
4365
4240
  xAxis: makeGridAxis("category", textColor, axisLineColor, splitLineColor, gridOpacity, xLabel, labels, void 0, chartWidth),
4366
4241
  yAxis: makeGridAxis("value", textColor, axisLineColor, splitLineColor, gridOpacity, yLabel),
4367
4242
  series: [
@@ -4372,10 +4247,7 @@ function buildLineOption(parsed, palette, textColor, axisLineColor, splitLineCol
4372
4247
  symbolSize: 8,
4373
4248
  lineStyle: { color: lineColor, width: 3 },
4374
4249
  itemStyle: { color: lineColor },
4375
- emphasis: {
4376
- focus: "self",
4377
- blurScope: "global"
4378
- }
4250
+ emphasis: EMPHASIS_SELF
4379
4251
  }
4380
4252
  ]
4381
4253
  };
@@ -4397,15 +4269,11 @@ function buildMultiLineOption(parsed, textColor, axisLineColor, splitLineColor,
4397
4269
  symbolSize: 8,
4398
4270
  lineStyle: { color, width: 3 },
4399
4271
  itemStyle: { color },
4400
- emphasis: {
4401
- focus: "self",
4402
- blurScope: "global"
4403
- }
4272
+ emphasis: EMPHASIS_SELF
4404
4273
  };
4405
4274
  });
4406
4275
  return {
4407
- backgroundColor: "transparent",
4408
- animation: false,
4276
+ ...CHART_BASE,
4409
4277
  title: titleConfig,
4410
4278
  tooltip: {
4411
4279
  trigger: "axis",
@@ -4417,13 +4285,7 @@ function buildMultiLineOption(parsed, textColor, axisLineColor, splitLineColor,
4417
4285
  bottom: 10,
4418
4286
  textStyle: { color: textColor }
4419
4287
  },
4420
- grid: {
4421
- left: yLabel ? "12%" : "3%",
4422
- right: "4%",
4423
- bottom: "15%",
4424
- top: parsed.title ? "15%" : "5%",
4425
- containLabel: true
4426
- },
4288
+ grid: makeChartGrid({ xLabel, yLabel, hasTitle: !!parsed.title, hasLegend: true }),
4427
4289
  xAxis: makeGridAxis("category", textColor, axisLineColor, splitLineColor, gridOpacity, xLabel, labels, void 0, chartWidth),
4428
4290
  yAxis: makeGridAxis("value", textColor, axisLineColor, splitLineColor, gridOpacity, yLabel),
4429
4291
  series
@@ -4435,21 +4297,14 @@ function buildAreaOption(parsed, palette, textColor, axisLineColor, splitLineCol
4435
4297
  const labels = parsed.data.map((d) => d.label);
4436
4298
  const values = parsed.data.map((d) => d.value);
4437
4299
  return {
4438
- backgroundColor: "transparent",
4439
- animation: false,
4300
+ ...CHART_BASE,
4440
4301
  title: titleConfig,
4441
4302
  tooltip: {
4442
4303
  trigger: "axis",
4443
4304
  ...tooltipTheme,
4444
4305
  axisPointer: { type: "line" }
4445
4306
  },
4446
- grid: {
4447
- left: yLabel ? "12%" : "3%",
4448
- right: "4%",
4449
- bottom: xLabel ? "10%" : "3%",
4450
- top: parsed.title ? "15%" : "5%",
4451
- containLabel: true
4452
- },
4307
+ grid: makeChartGrid({ xLabel, yLabel, hasTitle: !!parsed.title }),
4453
4308
  xAxis: makeGridAxis("category", textColor, axisLineColor, splitLineColor, gridOpacity, xLabel, labels, void 0, chartWidth),
4454
4309
  yAxis: makeGridAxis("value", textColor, axisLineColor, splitLineColor, gridOpacity, yLabel),
4455
4310
  series: [
@@ -4461,10 +4316,7 @@ function buildAreaOption(parsed, palette, textColor, axisLineColor, splitLineCol
4461
4316
  lineStyle: { color: lineColor, width: 3 },
4462
4317
  itemStyle: { color: lineColor },
4463
4318
  areaStyle: { opacity: 0.25 },
4464
- emphasis: {
4465
- focus: "self",
4466
- blurScope: "global"
4467
- }
4319
+ emphasis: EMPHASIS_SELF
4468
4320
  }
4469
4321
  ]
4470
4322
  };
@@ -4488,8 +4340,7 @@ function buildPieOption(parsed, textColor, colors, titleConfig, tooltipTheme, is
4488
4340
  itemStyle: { color: d.color ?? colors[i % colors.length] }
4489
4341
  }));
4490
4342
  return {
4491
- backgroundColor: "transparent",
4492
- animation: false,
4343
+ ...CHART_BASE,
4493
4344
  title: titleConfig,
4494
4345
  tooltip: {
4495
4346
  trigger: "item",
@@ -4507,10 +4358,7 @@ function buildPieOption(parsed, textColor, colors, titleConfig, tooltipTheme, is
4507
4358
  fontFamily: FONT_FAMILY
4508
4359
  },
4509
4360
  labelLine: { show: true },
4510
- emphasis: {
4511
- focus: "self",
4512
- blurScope: "global"
4513
- }
4361
+ emphasis: EMPHASIS_SELF
4514
4362
  }
4515
4363
  ]
4516
4364
  };
@@ -4524,8 +4372,7 @@ function buildRadarOption(parsed, palette, textColor, gridOpacity, colors, title
4524
4372
  max: maxValue
4525
4373
  }));
4526
4374
  return {
4527
- backgroundColor: "transparent",
4528
- animation: false,
4375
+ ...CHART_BASE,
4529
4376
  title: titleConfig,
4530
4377
  tooltip: {
4531
4378
  trigger: "item",
@@ -4567,10 +4414,7 @@ function buildRadarOption(parsed, palette, textColor, gridOpacity, colors, title
4567
4414
  }
4568
4415
  }
4569
4416
  ],
4570
- emphasis: {
4571
- focus: "self",
4572
- blurScope: "global"
4573
- }
4417
+ emphasis: EMPHASIS_SELF
4574
4418
  }
4575
4419
  ]
4576
4420
  };
@@ -4582,8 +4426,7 @@ function buildPolarAreaOption(parsed, textColor, colors, titleConfig, tooltipThe
4582
4426
  itemStyle: { color: d.color ?? colors[i % colors.length] }
4583
4427
  }));
4584
4428
  return {
4585
- backgroundColor: "transparent",
4586
- animation: false,
4429
+ ...CHART_BASE,
4587
4430
  title: titleConfig,
4588
4431
  tooltip: {
4589
4432
  trigger: "item",
@@ -4602,10 +4445,7 @@ function buildPolarAreaOption(parsed, textColor, colors, titleConfig, tooltipThe
4602
4445
  fontFamily: FONT_FAMILY
4603
4446
  },
4604
4447
  labelLine: { show: true },
4605
- emphasis: {
4606
- focus: "self",
4607
- blurScope: "global"
4608
- }
4448
+ emphasis: EMPHASIS_SELF
4609
4449
  }
4610
4450
  ]
4611
4451
  };
@@ -4635,10 +4475,7 @@ function buildBarStackedOption(parsed, textColor, axisLineColor, splitLineColor,
4635
4475
  fontWeight: "bold",
4636
4476
  fontFamily: FONT_FAMILY
4637
4477
  },
4638
- emphasis: {
4639
- focus: "self",
4640
- blurScope: "global"
4641
- }
4478
+ emphasis: EMPHASIS_SELF
4642
4479
  };
4643
4480
  });
4644
4481
  const hCatGap = isHorizontal && yLabel ? Math.max(40, Math.max(...labels.map((l) => l.length)) * 8 + 16) : void 0;
@@ -4646,8 +4483,7 @@ function buildBarStackedOption(parsed, textColor, axisLineColor, splitLineColor,
4646
4483
  const hValueGap = isHorizontal && xLabel ? 40 : void 0;
4647
4484
  const valueAxis = makeGridAxis("value", textColor, axisLineColor, splitLineColor, gridOpacity, isHorizontal ? xLabel : yLabel, void 0, hValueGap);
4648
4485
  return {
4649
- backgroundColor: "transparent",
4650
- animation: false,
4486
+ ...CHART_BASE,
4651
4487
  title: titleConfig,
4652
4488
  tooltip: {
4653
4489
  trigger: "axis",
@@ -4659,13 +4495,7 @@ function buildBarStackedOption(parsed, textColor, axisLineColor, splitLineColor,
4659
4495
  bottom: 10,
4660
4496
  textStyle: { color: textColor }
4661
4497
  },
4662
- grid: {
4663
- left: yLabel ? "12%" : "3%",
4664
- right: "4%",
4665
- bottom: "15%",
4666
- top: parsed.title ? "15%" : "5%",
4667
- containLabel: true
4668
- },
4498
+ grid: makeChartGrid({ xLabel, yLabel, hasTitle: !!parsed.title, hasLegend: true }),
4669
4499
  xAxis: isHorizontal ? valueAxis : categoryAxis,
4670
4500
  yAxis: isHorizontal ? categoryAxis : valueAxis,
4671
4501
  series
@@ -4712,31 +4542,22 @@ async function renderEChartsForExport(content, theme, palette, options) {
4712
4542
  chart.dispose();
4713
4543
  }
4714
4544
  }
4715
- var echarts, ECHART_EXPORT_WIDTH, ECHART_EXPORT_HEIGHT, STANDARD_CHART_TYPES;
4545
+ var echarts, EMPHASIS_SELF, CHART_BASE, ECHART_EXPORT_WIDTH, ECHART_EXPORT_HEIGHT;
4716
4546
  var init_echarts = __esm({
4717
4547
  "src/echarts.ts"() {
4718
4548
  "use strict";
4719
4549
  echarts = __toESM(require("echarts"), 1);
4720
4550
  init_fonts();
4721
4551
  init_branding();
4722
- init_colors();
4723
4552
  init_palettes();
4724
4553
  init_chart();
4725
4554
  init_diagnostics();
4726
4555
  init_parsing();
4556
+ init_dgmo_router();
4557
+ EMPHASIS_SELF = { focus: "self", blurScope: "global" };
4558
+ CHART_BASE = { backgroundColor: "transparent", animation: false };
4727
4559
  ECHART_EXPORT_WIDTH = 1200;
4728
4560
  ECHART_EXPORT_HEIGHT = 800;
4729
- STANDARD_CHART_TYPES = /* @__PURE__ */ new Set([
4730
- "bar",
4731
- "line",
4732
- "multi-line",
4733
- "area",
4734
- "pie",
4735
- "doughnut",
4736
- "radar",
4737
- "polar-area",
4738
- "bar-stacked"
4739
- ]);
4740
4561
  }
4741
4562
  });
4742
4563
 
@@ -6066,6 +5887,7 @@ var init_parser7 = __esm({
6066
5887
  var dgmo_router_exports = {};
6067
5888
  __export(dgmo_router_exports, {
6068
5889
  DGMO_CHART_TYPE_MAP: () => DGMO_CHART_TYPE_MAP,
5890
+ STANDARD_CHART_TYPES: () => STANDARD_CHART_TYPES,
6069
5891
  getDgmoFramework: () => getDgmoFramework,
6070
5892
  parseDgmo: () => parseDgmo,
6071
5893
  parseDgmoChartType: () => parseDgmoChartType
@@ -6093,53 +5915,19 @@ function parseDgmoChartType(content) {
6093
5915
  function parseDgmo(content) {
6094
5916
  const chartType = parseDgmoChartType(content);
6095
5917
  if (!chartType) {
6096
- const parsed2 = parseD3(content);
6097
- return { diagnostics: parsed2.diagnostics };
6098
- }
6099
- if (chartType === "sequence") {
6100
- const parsed2 = parseSequenceDgmo(content);
6101
- return { diagnostics: parsed2.diagnostics };
6102
- }
6103
- if (chartType === "flowchart") {
6104
- const parsed2 = parseFlowchart(content);
6105
- return { diagnostics: parsed2.diagnostics };
6106
- }
6107
- if (chartType === "class") {
6108
- const parsed2 = parseClassDiagram(content);
6109
- return { diagnostics: parsed2.diagnostics };
6110
- }
6111
- if (chartType === "er") {
6112
- const parsed2 = parseERDiagram(content);
6113
- return { diagnostics: parsed2.diagnostics };
6114
- }
6115
- if (chartType === "org") {
6116
- const parsed2 = parseOrg(content);
6117
- return { diagnostics: parsed2.diagnostics };
6118
- }
6119
- if (chartType === "kanban") {
6120
- const parsed2 = parseKanban(content);
6121
- return { diagnostics: parsed2.diagnostics };
5918
+ return { diagnostics: parseD3(content).diagnostics };
6122
5919
  }
6123
- if (chartType === "c4") {
6124
- const parsed2 = parseC4(content);
6125
- return { diagnostics: parsed2.diagnostics };
6126
- }
6127
- if (chartType === "initiative-status") {
6128
- const parsed2 = parseInitiativeStatus(content);
6129
- return { diagnostics: parsed2.diagnostics };
6130
- }
6131
- if (STANDARD_CHART_TYPES2.has(chartType)) {
6132
- const parsed2 = parseChart(content);
6133
- return { diagnostics: parsed2.diagnostics };
5920
+ const directParser = PARSE_DISPATCH.get(chartType);
5921
+ if (directParser) return { diagnostics: directParser(content).diagnostics };
5922
+ if (STANDARD_CHART_TYPES.has(chartType)) {
5923
+ return { diagnostics: parseChart(content).diagnostics };
6134
5924
  }
6135
5925
  if (ECHART_TYPES.has(chartType)) {
6136
- const parsed2 = parseEChart(content);
6137
- return { diagnostics: parsed2.diagnostics };
5926
+ return { diagnostics: parseEChart(content).diagnostics };
6138
5927
  }
6139
- const parsed = parseD3(content);
6140
- return { diagnostics: parsed.diagnostics };
5928
+ return { diagnostics: parseD3(content).diagnostics };
6141
5929
  }
6142
- var DGMO_CHART_TYPE_MAP, STANDARD_CHART_TYPES2, ECHART_TYPES;
5930
+ var DGMO_CHART_TYPE_MAP, STANDARD_CHART_TYPES, ECHART_TYPES, PARSE_DISPATCH;
6143
5931
  var init_dgmo_router = __esm({
6144
5932
  "src/dgmo-router.ts"() {
6145
5933
  "use strict";
@@ -6188,7 +5976,7 @@ var init_dgmo_router = __esm({
6188
5976
  c4: "d3",
6189
5977
  "initiative-status": "d3"
6190
5978
  };
6191
- STANDARD_CHART_TYPES2 = /* @__PURE__ */ new Set([
5979
+ STANDARD_CHART_TYPES = /* @__PURE__ */ new Set([
6192
5980
  "bar",
6193
5981
  "line",
6194
5982
  "multi-line",
@@ -6207,6 +5995,16 @@ var init_dgmo_router = __esm({
6207
5995
  "heatmap",
6208
5996
  "funnel"
6209
5997
  ]);
5998
+ PARSE_DISPATCH = /* @__PURE__ */ new Map([
5999
+ ["sequence", (c) => parseSequenceDgmo(c)],
6000
+ ["flowchart", (c) => parseFlowchart(c)],
6001
+ ["class", (c) => parseClassDiagram(c)],
6002
+ ["er", (c) => parseERDiagram(c)],
6003
+ ["org", (c) => parseOrg(c)],
6004
+ ["kanban", (c) => parseKanban(c)],
6005
+ ["c4", (c) => parseC4(c)],
6006
+ ["initiative-status", (c) => parseInitiativeStatus(c)]
6007
+ ]);
6210
6008
  }
6211
6009
  });
6212
6010
 
@@ -12205,38 +12003,18 @@ function buildRenderSequence(messages) {
12205
12003
  type: "return",
12206
12004
  from: top.to,
12207
12005
  to: top.from,
12208
- label: top.returnLabel || "",
12006
+ label: "",
12209
12007
  messageIndex: top.messageIndex
12210
12008
  });
12211
12009
  }
12212
- if (msg.standaloneReturn) {
12213
- for (let si = stack.length - 1; si >= 0; si--) {
12214
- if (stack[si].from === msg.to && stack[si].to === msg.from) {
12215
- stack.splice(si, 1);
12216
- break;
12217
- }
12218
- }
12219
- steps.push({
12220
- type: "return",
12221
- from: msg.from,
12222
- to: msg.to,
12223
- label: msg.label,
12224
- messageIndex: mi
12225
- });
12226
- continue;
12227
- }
12228
12010
  steps.push({
12229
12011
  type: "call",
12230
12012
  from: msg.from,
12231
12013
  to: msg.to,
12232
12014
  label: msg.label,
12233
12015
  messageIndex: mi,
12234
- ...msg.async ? { async: true } : {},
12235
- ...msg.bidirectional ? { bidirectional: true } : {}
12016
+ ...msg.async ? { async: true } : {}
12236
12017
  });
12237
- if (msg.bidirectional) {
12238
- continue;
12239
- }
12240
12018
  if (msg.async) {
12241
12019
  continue;
12242
12020
  }
@@ -12245,14 +12023,13 @@ function buildRenderSequence(messages) {
12245
12023
  type: "return",
12246
12024
  from: msg.to,
12247
12025
  to: msg.from,
12248
- label: msg.returnLabel || "",
12026
+ label: "",
12249
12027
  messageIndex: mi
12250
12028
  });
12251
12029
  } else {
12252
12030
  stack.push({
12253
12031
  from: msg.from,
12254
12032
  to: msg.to,
12255
- returnLabel: msg.returnLabel,
12256
12033
  messageIndex: mi
12257
12034
  });
12258
12035
  }
@@ -12263,7 +12040,7 @@ function buildRenderSequence(messages) {
12263
12040
  type: "return",
12264
12041
  from: top.to,
12265
12042
  to: top.from,
12266
- label: top.returnLabel || "",
12043
+ label: "",
12267
12044
  messageIndex: top.messageIndex
12268
12045
  });
12269
12046
  }
@@ -12728,14 +12505,6 @@ function renderSequenceDiagram(container, parsed, palette, isDark, _onNavigateTo
12728
12505
  "points",
12729
12506
  `0,0 ${ARROWHEAD_SIZE},${ARROWHEAD_SIZE / 2} 0,${ARROWHEAD_SIZE}`
12730
12507
  ).attr("fill", "none").attr("stroke", palette.text).attr("stroke-width", 1.2);
12731
- 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(
12732
- "points",
12733
- `${ARROWHEAD_SIZE},0 0,${ARROWHEAD_SIZE / 2} ${ARROWHEAD_SIZE},${ARROWHEAD_SIZE}`
12734
- ).attr("fill", palette.text);
12735
- 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(
12736
- "points",
12737
- `${ARROWHEAD_SIZE},0 0,${ARROWHEAD_SIZE / 2} ${ARROWHEAD_SIZE},${ARROWHEAD_SIZE}`
12738
- ).attr("fill", "none").attr("stroke", palette.text).attr("stroke-width", 1.2);
12739
12508
  if (title) {
12740
12509
  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);
12741
12510
  if (parsed.titleLineNumber) {
@@ -13016,17 +12785,10 @@ function renderSequenceDiagram(container, parsed, palette, isDark, _onNavigateTo
13016
12785
  const x1 = arrowEdgeX(step.from, i, goingRight ? "right" : "left");
13017
12786
  const x2 = arrowEdgeX(step.to, i, goingRight ? "left" : "right");
13018
12787
  const markerRef = step.async ? "url(#seq-arrowhead-async)" : "url(#seq-arrowhead)";
13019
- const markerStartRef = step.bidirectional ? step.async ? "url(#seq-arrowhead-async-reverse)" : "url(#seq-arrowhead-reverse)" : null;
13020
- 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(
12788
+ 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(
13021
12789
  "data-line-number",
13022
12790
  String(messages[step.messageIndex].lineNumber)
13023
12791
  ).attr("data-msg-index", String(step.messageIndex)).attr("data-step-index", String(i));
13024
- if (markerStartRef) {
13025
- line7.attr("marker-start", markerStartRef);
13026
- }
13027
- if (step.bidirectional && step.async) {
13028
- line7.attr("stroke-dasharray", "6 4");
13029
- }
13030
12792
  if (step.label) {
13031
12793
  const midX = (x1 + x2) / 2;
13032
12794
  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(
@@ -13253,6 +13015,32 @@ var init_renderer7 = __esm({
13253
13015
  });
13254
13016
 
13255
13017
  // src/d3.ts
13018
+ function renderChartTitle(svg, title, titleLineNumber, width, textColor, onClickItem) {
13019
+ if (!title) return;
13020
+ 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);
13021
+ if (titleLineNumber) {
13022
+ titleEl.attr("data-line-number", titleLineNumber);
13023
+ if (onClickItem) {
13024
+ titleEl.on("click", () => onClickItem(titleLineNumber)).on("mouseenter", function() {
13025
+ d3Selection9.select(this).attr("opacity", 0.7);
13026
+ }).on("mouseleave", function() {
13027
+ d3Selection9.select(this).attr("opacity", 1);
13028
+ });
13029
+ }
13030
+ }
13031
+ }
13032
+ function initD3Chart(container, palette, exportDims) {
13033
+ d3Selection9.select(container).selectAll(":not([data-d3-tooltip])").remove();
13034
+ const width = exportDims?.width ?? container.clientWidth;
13035
+ const height = exportDims?.height ?? container.clientHeight;
13036
+ if (width <= 0 || height <= 0) return null;
13037
+ const textColor = palette.text;
13038
+ const mutedColor = palette.border;
13039
+ const bgColor = palette.bg;
13040
+ const colors = getSeriesColors(palette);
13041
+ const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
13042
+ return { svg, width, height, textColor, mutedColor, bgColor, colors };
13043
+ }
13256
13044
  function parseTimelineDate(s) {
13257
13045
  const parts = s.split("-").map((p) => parseInt(p, 10));
13258
13046
  const year = parts[0];
@@ -13815,26 +13603,28 @@ function tokenizeFreeformText(text) {
13815
13603
  }
13816
13604
  return Array.from(counts.entries()).map(([text2, count]) => ({ text: text2, weight: count, lineNumber: 0 })).sort((a, b) => b.weight - a.weight);
13817
13605
  }
13818
- function resolveVerticalCollisions(items, minGap) {
13606
+ function resolveVerticalCollisions(items, minGap, maxY) {
13819
13607
  if (items.length === 0) return [];
13820
13608
  const sorted = items.map((it, i) => ({ ...it, idx: i })).sort((a, b) => a.naturalY - b.naturalY);
13821
13609
  const adjustedY = new Array(items.length);
13822
13610
  let prevBottom = -Infinity;
13823
13611
  for (const item of sorted) {
13824
13612
  const halfH = item.height / 2;
13825
- const top = Math.max(item.naturalY - halfH, prevBottom + minGap);
13613
+ let top = Math.max(item.naturalY - halfH, prevBottom + minGap);
13614
+ if (maxY !== void 0) {
13615
+ top = Math.min(top, maxY - item.height);
13616
+ }
13826
13617
  adjustedY[item.idx] = top + halfH;
13827
13618
  prevBottom = top + item.height;
13828
13619
  }
13829
13620
  return adjustedY;
13830
13621
  }
13831
13622
  function renderSlopeChart(container, parsed, palette, isDark, onClickItem, exportDims) {
13832
- d3Selection9.select(container).selectAll(":not([data-d3-tooltip])").remove();
13833
13623
  const { periods, data, title } = parsed;
13834
13624
  if (data.length === 0 || periods.length < 2) return;
13835
- const width = exportDims?.width ?? container.clientWidth;
13836
- const height = exportDims?.height ?? container.clientHeight;
13837
- if (width <= 0 || height <= 0) return;
13625
+ const init2 = initD3Chart(container, palette, exportDims);
13626
+ if (!init2) return;
13627
+ const { svg, width, height, textColor, mutedColor, bgColor, colors } = init2;
13838
13628
  const maxLabelText = data.reduce((longest, item) => {
13839
13629
  const text = `${item.values[item.values.length - 1]} \u2014 ${item.label}`;
13840
13630
  return text.length > longest.length ? text : longest;
@@ -13847,31 +13637,14 @@ function renderSlopeChart(container, parsed, palette, isDark, onClickItem, expor
13847
13637
  );
13848
13638
  const innerWidth = width - SLOPE_MARGIN.left - rightMargin;
13849
13639
  const innerHeight = height - SLOPE_MARGIN.top - SLOPE_MARGIN.bottom;
13850
- const textColor = palette.text;
13851
- const mutedColor = palette.border;
13852
- const bgColor = palette.bg;
13853
- const colors = getSeriesColors(palette);
13854
13640
  const allValues = data.flatMap((d) => d.values);
13855
13641
  const [minVal, maxVal] = d3Array.extent(allValues);
13856
13642
  const valuePadding = (maxVal - minVal) * 0.1 || 1;
13857
13643
  const yScale = d3Scale.scaleLinear().domain([minVal - valuePadding, maxVal + valuePadding]).range([innerHeight, 0]);
13858
13644
  const xScale = d3Scale.scalePoint().domain(periods).range([0, innerWidth]).padding(0);
13859
- const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
13860
13645
  const g = svg.append("g").attr("transform", `translate(${SLOPE_MARGIN.left},${SLOPE_MARGIN.top})`);
13861
13646
  const tooltip = createTooltip(container, palette, isDark);
13862
- if (title) {
13863
- 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);
13864
- if (parsed.titleLineNumber) {
13865
- titleEl.attr("data-line-number", parsed.titleLineNumber);
13866
- if (onClickItem) {
13867
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
13868
- d3Selection9.select(this).attr("opacity", 0.7);
13869
- }).on("mouseleave", function() {
13870
- d3Selection9.select(this).attr("opacity", 1);
13871
- });
13872
- }
13873
- }
13874
- }
13647
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
13875
13648
  for (const period of periods) {
13876
13649
  const x = xScale(period);
13877
13650
  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);
@@ -13934,13 +13707,13 @@ function renderSlopeChart(container, parsed, palette, isDark, onClickItem, expor
13934
13707
  naturalY: yScale(item.values[pi]),
13935
13708
  height: leftLabelHeight
13936
13709
  }));
13937
- leftLabelCollisions.set(pi, resolveVerticalCollisions(entries, 4));
13710
+ leftLabelCollisions.set(pi, resolveVerticalCollisions(entries, 4, innerHeight));
13938
13711
  }
13939
13712
  const rightEntries = seriesInfo.map((si) => ({
13940
13713
  naturalY: yScale(si.lastVal),
13941
13714
  height: Math.max(si.labelHeight, SLOPE_LABEL_FONT_SIZE * 1.4)
13942
13715
  }));
13943
- const rightAdjustedY = resolveVerticalCollisions(rightEntries, 4);
13716
+ const rightAdjustedY = resolveVerticalCollisions(rightEntries, 4, innerHeight);
13944
13717
  data.forEach((item, idx) => {
13945
13718
  const si = seriesInfo[idx];
13946
13719
  const color = si.color;
@@ -14080,12 +13853,11 @@ function orderArcNodes(links, order, groups) {
14080
13853
  return allNodes;
14081
13854
  }
14082
13855
  function renderArcDiagram(container, parsed, palette, _isDark, onClickItem, exportDims) {
14083
- d3Selection9.select(container).selectAll(":not([data-d3-tooltip])").remove();
14084
13856
  const { links, title, orientation, arcOrder, arcNodeGroups } = parsed;
14085
13857
  if (links.length === 0) return;
14086
- const width = exportDims?.width ?? container.clientWidth;
14087
- const height = exportDims?.height ?? container.clientHeight;
14088
- if (width <= 0 || height <= 0) return;
13858
+ const init2 = initD3Chart(container, palette, exportDims);
13859
+ if (!init2) return;
13860
+ const { svg, width, height, textColor, mutedColor, bgColor, colors } = init2;
14089
13861
  const isVertical = orientation === "vertical";
14090
13862
  const margin = isVertical ? {
14091
13863
  top: ARC_MARGIN.top,
@@ -14095,10 +13867,6 @@ function renderArcDiagram(container, parsed, palette, _isDark, onClickItem, expo
14095
13867
  } : ARC_MARGIN;
14096
13868
  const innerWidth = width - margin.left - margin.right;
14097
13869
  const innerHeight = height - margin.top - margin.bottom;
14098
- const textColor = palette.text;
14099
- const mutedColor = palette.border;
14100
- const bgColor = palette.bg;
14101
- const colors = getSeriesColors(palette);
14102
13870
  const nodes = orderArcNodes(links, arcOrder, arcNodeGroups);
14103
13871
  const nodeColorMap = /* @__PURE__ */ new Map();
14104
13872
  for (const group of arcNodeGroups) {
@@ -14117,21 +13885,8 @@ function renderArcDiagram(container, parsed, palette, _isDark, onClickItem, expo
14117
13885
  const values = links.map((l) => l.value);
14118
13886
  const [minVal, maxVal] = d3Array.extent(values);
14119
13887
  const strokeScale = d3Scale.scaleLinear().domain([minVal, maxVal]).range([1.5, 6]);
14120
- const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
14121
13888
  const g = svg.append("g").attr("transform", `translate(${margin.left},${margin.top})`);
14122
- if (title) {
14123
- 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);
14124
- if (parsed.titleLineNumber) {
14125
- titleEl.attr("data-line-number", parsed.titleLineNumber);
14126
- if (onClickItem) {
14127
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
14128
- d3Selection9.select(this).attr("opacity", 0.7);
14129
- }).on("mouseleave", function() {
14130
- d3Selection9.select(this).attr("opacity", 1);
14131
- });
14132
- }
14133
- }
14134
- }
13889
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
14135
13890
  const neighbors = /* @__PURE__ */ new Map();
14136
13891
  for (const node of nodes) neighbors.set(node, /* @__PURE__ */ new Set());
14137
13892
  for (const link of links) {
@@ -14667,19 +14422,7 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
14667
14422
  const yScale = d3Scale.scaleLinear().domain([minDate - datePadding, maxDate + datePadding]).range([0, innerHeight]);
14668
14423
  const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
14669
14424
  const g = svg.append("g").attr("transform", `translate(${margin.left},${margin.top})`);
14670
- if (title) {
14671
- 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);
14672
- if (parsed.titleLineNumber) {
14673
- titleEl.attr("data-line-number", parsed.titleLineNumber);
14674
- if (onClickItem) {
14675
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
14676
- d3Selection9.select(this).attr("opacity", 0.7);
14677
- }).on("mouseleave", function() {
14678
- d3Selection9.select(this).attr("opacity", 1);
14679
- });
14680
- }
14681
- }
14682
- }
14425
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
14683
14426
  renderEras(
14684
14427
  g,
14685
14428
  timelineEras,
@@ -14782,19 +14525,7 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
14782
14525
  const sorted = timelineEvents.slice().sort((a, b) => parseTimelineDate(a.date) - parseTimelineDate(b.date));
14783
14526
  const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
14784
14527
  const g = svg.append("g").attr("transform", `translate(${margin.left},${margin.top})`);
14785
- if (title) {
14786
- 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);
14787
- if (parsed.titleLineNumber) {
14788
- titleEl.attr("data-line-number", parsed.titleLineNumber);
14789
- if (onClickItem) {
14790
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
14791
- d3Selection9.select(this).attr("opacity", 0.7);
14792
- }).on("mouseleave", function() {
14793
- d3Selection9.select(this).attr("opacity", 1);
14794
- });
14795
- }
14796
- }
14797
- }
14528
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
14798
14529
  renderEras(
14799
14530
  g,
14800
14531
  timelineEras,
@@ -14926,19 +14657,7 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
14926
14657
  const xScale = d3Scale.scaleLinear().domain([minDate - datePadding, maxDate + datePadding]).range([0, innerWidth]);
14927
14658
  const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
14928
14659
  const g = svg.append("g").attr("transform", `translate(${margin.left},${margin.top})`);
14929
- if (title) {
14930
- 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);
14931
- if (parsed.titleLineNumber) {
14932
- titleEl.attr("data-line-number", parsed.titleLineNumber);
14933
- if (onClickItem) {
14934
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
14935
- d3Selection9.select(this).attr("opacity", 0.7);
14936
- }).on("mouseleave", function() {
14937
- d3Selection9.select(this).attr("opacity", 1);
14938
- });
14939
- }
14940
- }
14941
- }
14660
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
14942
14661
  renderEras(
14943
14662
  g,
14944
14663
  timelineEras,
@@ -15081,19 +14800,7 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
15081
14800
  const xScale = d3Scale.scaleLinear().domain([minDate - datePadding, maxDate + datePadding]).range([0, innerWidth]);
15082
14801
  const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
15083
14802
  const g = svg.append("g").attr("transform", `translate(${margin.left},${margin.top})`);
15084
- if (title) {
15085
- 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);
15086
- if (parsed.titleLineNumber) {
15087
- titleEl.attr("data-line-number", parsed.titleLineNumber);
15088
- if (onClickItem) {
15089
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
15090
- d3Selection9.select(this).attr("opacity", 0.7);
15091
- }).on("mouseleave", function() {
15092
- d3Selection9.select(this).attr("opacity", 1);
15093
- });
15094
- }
15095
- }
15096
- }
14803
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
15097
14804
  renderEras(
15098
14805
  g,
15099
14806
  timelineEras,
@@ -15220,17 +14927,13 @@ function getRotateFn(mode) {
15220
14927
  return () => 0;
15221
14928
  }
15222
14929
  function renderWordCloud(container, parsed, palette, _isDark, onClickItem, exportDims) {
15223
- d3Selection9.select(container).selectAll(":not([data-d3-tooltip])").remove();
15224
14930
  const { words, title, cloudOptions } = parsed;
15225
14931
  if (words.length === 0) return;
15226
- const width = exportDims?.width ?? container.clientWidth;
15227
- const height = exportDims?.height ?? container.clientHeight;
15228
- if (width <= 0 || height <= 0) return;
14932
+ const init2 = initD3Chart(container, palette, exportDims);
14933
+ if (!init2) return;
14934
+ const { svg, width, height, textColor, colors } = init2;
15229
14935
  const titleHeight = title ? 40 : 0;
15230
14936
  const cloudHeight = height - titleHeight;
15231
- const textColor = palette.text;
15232
- const bgColor = palette.bg;
15233
- const colors = getSeriesColors(palette);
15234
14937
  const { minSize, maxSize } = cloudOptions;
15235
14938
  const weights = words.map((w) => w.weight);
15236
14939
  const minWeight = Math.min(...weights);
@@ -15241,20 +14944,7 @@ function renderWordCloud(container, parsed, palette, _isDark, onClickItem, expor
15241
14944
  return minSize + t * (maxSize - minSize);
15242
14945
  };
15243
14946
  const rotateFn = getRotateFn(cloudOptions.rotate);
15244
- const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
15245
- if (title) {
15246
- 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);
15247
- if (parsed.titleLineNumber) {
15248
- titleEl.attr("data-line-number", parsed.titleLineNumber);
15249
- if (onClickItem) {
15250
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
15251
- d3Selection9.select(this).attr("opacity", 0.7);
15252
- }).on("mouseleave", function() {
15253
- d3Selection9.select(this).attr("opacity", 1);
15254
- });
15255
- }
15256
- }
15257
- }
14947
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
15258
14948
  const g = svg.append("g").attr(
15259
14949
  "transform",
15260
14950
  `translate(${width / 2},${titleHeight + cloudHeight / 2})`
@@ -15305,12 +14995,7 @@ function renderWordCloudAsync(container, parsed, palette, _isDark, exportDims) {
15305
14995
  };
15306
14996
  const rotateFn = getRotateFn(cloudOptions.rotate);
15307
14997
  const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
15308
- if (title) {
15309
- 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);
15310
- if (parsed.titleLineNumber) {
15311
- titleEl.attr("data-line-number", parsed.titleLineNumber);
15312
- }
15313
- }
14998
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor);
15314
14999
  const g = svg.append("g").attr(
15315
15000
  "transform",
15316
15001
  `translate(${width / 2},${titleHeight + cloudHeight / 2})`
@@ -15441,15 +15126,11 @@ function regionCentroid(circles, inside) {
15441
15126
  return { x: sx / count, y: sy / count };
15442
15127
  }
15443
15128
  function renderVenn(container, parsed, palette, isDark, onClickItem, exportDims) {
15444
- d3Selection9.select(container).selectAll(":not([data-d3-tooltip])").remove();
15445
15129
  const { vennSets, vennOverlaps, vennShowValues, title } = parsed;
15446
15130
  if (vennSets.length < 2) return;
15447
- const width = exportDims?.width ?? container.clientWidth;
15448
- const height = exportDims?.height ?? container.clientHeight;
15449
- if (width <= 0 || height <= 0) return;
15450
- const textColor = palette.text;
15451
- const bgColor = palette.bg;
15452
- const colors = getSeriesColors(palette);
15131
+ const init2 = initD3Chart(container, palette, exportDims);
15132
+ if (!init2) return;
15133
+ const { svg, width, height, textColor, colors } = init2;
15453
15134
  const titleHeight = title ? 40 : 0;
15454
15135
  const radii = vennSets.map((s) => radiusFromArea(s.size));
15455
15136
  const overlapMap = /* @__PURE__ */ new Map();
@@ -15528,21 +15209,8 @@ function renderVenn(container, parsed, palette, isDark, onClickItem, exportDims)
15528
15209
  marginTop,
15529
15210
  marginBottom
15530
15211
  ).map((c) => ({ ...c, y: c.y + titleHeight }));
15531
- const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
15532
15212
  const tooltip = createTooltip(container, palette, isDark);
15533
- if (title) {
15534
- 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);
15535
- if (parsed.titleLineNumber) {
15536
- titleEl.attr("data-line-number", parsed.titleLineNumber);
15537
- if (onClickItem) {
15538
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
15539
- d3Selection9.select(this).attr("opacity", 0.7);
15540
- }).on("mouseleave", function() {
15541
- d3Selection9.select(this).attr("opacity", 1);
15542
- });
15543
- }
15544
- }
15545
- }
15213
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
15546
15214
  const circleEls = [];
15547
15215
  const circleGroup = svg.append("g");
15548
15216
  circles.forEach((c, i) => {
@@ -15686,7 +15354,6 @@ function renderVenn(container, parsed, palette, isDark, onClickItem, exportDims)
15686
15354
  });
15687
15355
  }
15688
15356
  function renderQuadrant(container, parsed, palette, isDark, onClickItem, exportDims) {
15689
- d3Selection9.select(container).selectAll(":not([data-d3-tooltip])").remove();
15690
15357
  const {
15691
15358
  title,
15692
15359
  quadrantLabels,
@@ -15698,12 +15365,10 @@ function renderQuadrant(container, parsed, palette, isDark, onClickItem, exportD
15698
15365
  quadrantYAxisLineNumber
15699
15366
  } = parsed;
15700
15367
  if (quadrantPoints.length === 0) return;
15701
- const width = exportDims?.width ?? container.clientWidth;
15702
- const height = exportDims?.height ?? container.clientHeight;
15703
- if (width <= 0 || height <= 0) return;
15704
- const textColor = palette.text;
15368
+ const init2 = initD3Chart(container, palette, exportDims);
15369
+ if (!init2) return;
15370
+ const { svg, width, height, textColor } = init2;
15705
15371
  const mutedColor = palette.textMuted;
15706
- const bgColor = palette.bg;
15707
15372
  const borderColor = palette.border;
15708
15373
  const defaultColors = [
15709
15374
  palette.colors.blue,
@@ -15718,24 +15383,8 @@ function renderQuadrant(container, parsed, palette, isDark, onClickItem, exportD
15718
15383
  const chartHeight = height - margin.top - margin.bottom;
15719
15384
  const xScale = d3Scale.scaleLinear().domain([0, 1]).range([0, chartWidth]);
15720
15385
  const yScale = d3Scale.scaleLinear().domain([0, 1]).range([chartHeight, 0]);
15721
- const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
15722
15386
  const tooltip = createTooltip(container, palette, isDark);
15723
- if (title) {
15724
- 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(
15725
- "cursor",
15726
- onClickItem && quadrantTitleLineNumber ? "pointer" : "default"
15727
- ).text(title);
15728
- if (quadrantTitleLineNumber) {
15729
- titleText.attr("data-line-number", quadrantTitleLineNumber);
15730
- }
15731
- if (onClickItem && quadrantTitleLineNumber) {
15732
- titleText.on("click", () => onClickItem(quadrantTitleLineNumber)).on("mouseenter", function() {
15733
- d3Selection9.select(this).attr("opacity", 0.7);
15734
- }).on("mouseleave", function() {
15735
- d3Selection9.select(this).attr("opacity", 1);
15736
- });
15737
- }
15738
- }
15387
+ renderChartTitle(svg, title, quadrantTitleLineNumber, width, textColor, onClickItem);
15739
15388
  const chartG = svg.append("g").attr("transform", `translate(${margin.left}, ${margin.top})`);
15740
15389
  const mixHex = (a, b, pct) => {
15741
15390
  const parse = (h) => {
@@ -15984,6 +15633,38 @@ function renderQuadrant(container, parsed, palette, isDark, onClickItem, exportD
15984
15633
  }
15985
15634
  });
15986
15635
  }
15636
+ async function resolveExportPalette(theme, palette) {
15637
+ if (palette) return palette;
15638
+ const { getPalette: getPalette2 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
15639
+ return theme === "dark" ? getPalette2("nord").dark : getPalette2("nord").light;
15640
+ }
15641
+ function createExportContainer(width, height) {
15642
+ const container = document.createElement("div");
15643
+ container.style.width = `${width}px`;
15644
+ container.style.height = `${height}px`;
15645
+ container.style.position = "absolute";
15646
+ container.style.left = "-9999px";
15647
+ document.body.appendChild(container);
15648
+ return container;
15649
+ }
15650
+ function finalizeSvgExport(container, theme, palette, options) {
15651
+ const svgEl = container.querySelector("svg");
15652
+ if (!svgEl) return "";
15653
+ if (theme === "transparent") {
15654
+ svgEl.style.background = "none";
15655
+ } else if (!svgEl.style.background) {
15656
+ svgEl.style.background = palette.bg;
15657
+ }
15658
+ svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
15659
+ svgEl.style.fontFamily = FONT_FAMILY;
15660
+ const svgHtml = svgEl.outerHTML;
15661
+ document.body.removeChild(container);
15662
+ if (options?.branding !== false) {
15663
+ const brandColor = theme === "transparent" ? "#888" : palette.textMuted;
15664
+ return injectBranding(svgHtml, brandColor);
15665
+ }
15666
+ return svgHtml;
15667
+ }
15987
15668
  async function renderD3ForExport(content, theme, palette, orgExportState, options) {
15988
15669
  const { parseDgmoChartType: parseDgmoChartType2 } = await Promise.resolve().then(() => (init_dgmo_router(), dgmo_router_exports));
15989
15670
  const detectedType = parseDgmoChartType2(content);
@@ -15993,8 +15674,7 @@ async function renderD3ForExport(content, theme, palette, orgExportState, option
15993
15674
  const { collapseOrgTree: collapseOrgTree2 } = await Promise.resolve().then(() => (init_collapse(), collapse_exports));
15994
15675
  const { renderOrg: renderOrg2 } = await Promise.resolve().then(() => (init_renderer(), renderer_exports));
15995
15676
  const isDark2 = theme === "dark";
15996
- const { getPalette: getPalette3 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
15997
- const effectivePalette2 = palette ?? (isDark2 ? getPalette3("nord").dark : getPalette3("nord").light);
15677
+ const effectivePalette2 = await resolveExportPalette(theme, palette);
15998
15678
  const orgParsed = parseOrg2(content, effectivePalette2);
15999
15679
  if (orgParsed.error) return "";
16000
15680
  const collapsedNodes = orgExportState?.collapsedNodes;
@@ -16011,83 +15691,28 @@ async function renderD3ForExport(content, theme, palette, orgExportState, option
16011
15691
  const titleOffset = effectiveParsed.title ? 30 : 0;
16012
15692
  const exportWidth = orgLayout.width + PADDING * 2;
16013
15693
  const exportHeight = orgLayout.height + PADDING * 2 + titleOffset;
16014
- const container2 = document.createElement("div");
16015
- container2.style.width = `${exportWidth}px`;
16016
- container2.style.height = `${exportHeight}px`;
16017
- container2.style.position = "absolute";
16018
- container2.style.left = "-9999px";
16019
- document.body.appendChild(container2);
16020
- try {
16021
- renderOrg2(
16022
- container2,
16023
- effectiveParsed,
16024
- orgLayout,
16025
- effectivePalette2,
16026
- isDark2,
16027
- void 0,
16028
- { width: exportWidth, height: exportHeight },
16029
- activeTagGroup,
16030
- hiddenAttributes
16031
- );
16032
- const svgEl = container2.querySelector("svg");
16033
- if (!svgEl) return "";
16034
- if (theme === "transparent") {
16035
- svgEl.style.background = "none";
16036
- } else if (!svgEl.style.background) {
16037
- svgEl.style.background = effectivePalette2.bg;
16038
- }
16039
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16040
- svgEl.style.fontFamily = FONT_FAMILY;
16041
- const svgHtml = svgEl.outerHTML;
16042
- if (options?.branding !== false) {
16043
- const brandColor = theme === "transparent" ? "#888" : effectivePalette2.textMuted;
16044
- return injectBranding(svgHtml, brandColor);
16045
- }
16046
- return svgHtml;
16047
- } finally {
16048
- document.body.removeChild(container2);
16049
- }
15694
+ const container2 = createExportContainer(exportWidth, exportHeight);
15695
+ renderOrg2(container2, effectiveParsed, orgLayout, effectivePalette2, isDark2, void 0, { width: exportWidth, height: exportHeight }, activeTagGroup, hiddenAttributes);
15696
+ return finalizeSvgExport(container2, theme, effectivePalette2, options);
16050
15697
  }
16051
15698
  if (detectedType === "kanban") {
16052
15699
  const { parseKanban: parseKanban2 } = await Promise.resolve().then(() => (init_parser5(), parser_exports5));
16053
15700
  const { renderKanban: renderKanban2 } = await Promise.resolve().then(() => (init_renderer2(), renderer_exports2));
16054
- const isDark2 = theme === "dark";
16055
- const { getPalette: getPalette3 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
16056
- const effectivePalette2 = palette ?? (isDark2 ? getPalette3("nord").dark : getPalette3("nord").light);
15701
+ const effectivePalette2 = await resolveExportPalette(theme, palette);
16057
15702
  const kanbanParsed = parseKanban2(content, effectivePalette2);
16058
15703
  if (kanbanParsed.error || kanbanParsed.columns.length === 0) return "";
16059
15704
  const container2 = document.createElement("div");
16060
15705
  container2.style.position = "absolute";
16061
15706
  container2.style.left = "-9999px";
16062
15707
  document.body.appendChild(container2);
16063
- try {
16064
- renderKanban2(container2, kanbanParsed, effectivePalette2, isDark2);
16065
- const svgEl = container2.querySelector("svg");
16066
- if (!svgEl) return "";
16067
- if (theme === "transparent") {
16068
- svgEl.style.background = "none";
16069
- } else if (!svgEl.style.background) {
16070
- svgEl.style.background = effectivePalette2.bg;
16071
- }
16072
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16073
- svgEl.style.fontFamily = FONT_FAMILY;
16074
- const svgHtml = svgEl.outerHTML;
16075
- if (options?.branding !== false) {
16076
- const brandColor = theme === "transparent" ? "#888" : effectivePalette2.textMuted;
16077
- return injectBranding(svgHtml, brandColor);
16078
- }
16079
- return svgHtml;
16080
- } finally {
16081
- document.body.removeChild(container2);
16082
- }
15708
+ renderKanban2(container2, kanbanParsed, effectivePalette2, theme === "dark");
15709
+ return finalizeSvgExport(container2, theme, effectivePalette2, options);
16083
15710
  }
16084
15711
  if (detectedType === "class") {
16085
15712
  const { parseClassDiagram: parseClassDiagram2 } = await Promise.resolve().then(() => (init_parser2(), parser_exports2));
16086
15713
  const { layoutClassDiagram: layoutClassDiagram2 } = await Promise.resolve().then(() => (init_layout2(), layout_exports2));
16087
15714
  const { renderClassDiagram: renderClassDiagram2 } = await Promise.resolve().then(() => (init_renderer3(), renderer_exports3));
16088
- const isDark2 = theme === "dark";
16089
- const { getPalette: getPalette3 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
16090
- const effectivePalette2 = palette ?? (isDark2 ? getPalette3("nord").dark : getPalette3("nord").light);
15715
+ const effectivePalette2 = await resolveExportPalette(theme, palette);
16091
15716
  const classParsed = parseClassDiagram2(content, effectivePalette2);
16092
15717
  if (classParsed.error || classParsed.classes.length === 0) return "";
16093
15718
  const classLayout = layoutClassDiagram2(classParsed);
@@ -16095,48 +15720,15 @@ async function renderD3ForExport(content, theme, palette, orgExportState, option
16095
15720
  const titleOffset = classParsed.title ? 40 : 0;
16096
15721
  const exportWidth = classLayout.width + PADDING * 2;
16097
15722
  const exportHeight = classLayout.height + PADDING * 2 + titleOffset;
16098
- const container2 = document.createElement("div");
16099
- container2.style.width = `${exportWidth}px`;
16100
- container2.style.height = `${exportHeight}px`;
16101
- container2.style.position = "absolute";
16102
- container2.style.left = "-9999px";
16103
- document.body.appendChild(container2);
16104
- try {
16105
- renderClassDiagram2(
16106
- container2,
16107
- classParsed,
16108
- classLayout,
16109
- effectivePalette2,
16110
- isDark2,
16111
- void 0,
16112
- { width: exportWidth, height: exportHeight }
16113
- );
16114
- const svgEl = container2.querySelector("svg");
16115
- if (!svgEl) return "";
16116
- if (theme === "transparent") {
16117
- svgEl.style.background = "none";
16118
- } else if (!svgEl.style.background) {
16119
- svgEl.style.background = effectivePalette2.bg;
16120
- }
16121
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16122
- svgEl.style.fontFamily = FONT_FAMILY;
16123
- const svgHtml = svgEl.outerHTML;
16124
- if (options?.branding !== false) {
16125
- const brandColor = theme === "transparent" ? "#888" : effectivePalette2.textMuted;
16126
- return injectBranding(svgHtml, brandColor);
16127
- }
16128
- return svgHtml;
16129
- } finally {
16130
- document.body.removeChild(container2);
16131
- }
15723
+ const container2 = createExportContainer(exportWidth, exportHeight);
15724
+ renderClassDiagram2(container2, classParsed, classLayout, effectivePalette2, theme === "dark", void 0, { width: exportWidth, height: exportHeight });
15725
+ return finalizeSvgExport(container2, theme, effectivePalette2, options);
16132
15726
  }
16133
15727
  if (detectedType === "er") {
16134
15728
  const { parseERDiagram: parseERDiagram2 } = await Promise.resolve().then(() => (init_parser3(), parser_exports3));
16135
15729
  const { layoutERDiagram: layoutERDiagram2 } = await Promise.resolve().then(() => (init_layout3(), layout_exports3));
16136
15730
  const { renderERDiagram: renderERDiagram2 } = await Promise.resolve().then(() => (init_renderer4(), renderer_exports4));
16137
- const isDark2 = theme === "dark";
16138
- const { getPalette: getPalette3 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
16139
- const effectivePalette2 = palette ?? (isDark2 ? getPalette3("nord").dark : getPalette3("nord").light);
15731
+ const effectivePalette2 = await resolveExportPalette(theme, palette);
16140
15732
  const erParsed = parseERDiagram2(content, effectivePalette2);
16141
15733
  if (erParsed.error || erParsed.tables.length === 0) return "";
16142
15734
  const erLayout = layoutERDiagram2(erParsed);
@@ -16144,48 +15736,15 @@ async function renderD3ForExport(content, theme, palette, orgExportState, option
16144
15736
  const titleOffset = erParsed.title ? 40 : 0;
16145
15737
  const exportWidth = erLayout.width + PADDING * 2;
16146
15738
  const exportHeight = erLayout.height + PADDING * 2 + titleOffset;
16147
- const container2 = document.createElement("div");
16148
- container2.style.width = `${exportWidth}px`;
16149
- container2.style.height = `${exportHeight}px`;
16150
- container2.style.position = "absolute";
16151
- container2.style.left = "-9999px";
16152
- document.body.appendChild(container2);
16153
- try {
16154
- renderERDiagram2(
16155
- container2,
16156
- erParsed,
16157
- erLayout,
16158
- effectivePalette2,
16159
- isDark2,
16160
- void 0,
16161
- { width: exportWidth, height: exportHeight }
16162
- );
16163
- const svgEl = container2.querySelector("svg");
16164
- if (!svgEl) return "";
16165
- if (theme === "transparent") {
16166
- svgEl.style.background = "none";
16167
- } else if (!svgEl.style.background) {
16168
- svgEl.style.background = effectivePalette2.bg;
16169
- }
16170
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16171
- svgEl.style.fontFamily = FONT_FAMILY;
16172
- const svgHtml = svgEl.outerHTML;
16173
- if (options?.branding !== false) {
16174
- const brandColor = theme === "transparent" ? "#888" : effectivePalette2.textMuted;
16175
- return injectBranding(svgHtml, brandColor);
16176
- }
16177
- return svgHtml;
16178
- } finally {
16179
- document.body.removeChild(container2);
16180
- }
15739
+ const container2 = createExportContainer(exportWidth, exportHeight);
15740
+ renderERDiagram2(container2, erParsed, erLayout, effectivePalette2, theme === "dark", void 0, { width: exportWidth, height: exportHeight });
15741
+ return finalizeSvgExport(container2, theme, effectivePalette2, options);
16181
15742
  }
16182
15743
  if (detectedType === "initiative-status") {
16183
15744
  const { parseInitiativeStatus: parseInitiativeStatus2 } = await Promise.resolve().then(() => (init_parser7(), parser_exports7));
16184
15745
  const { layoutInitiativeStatus: layoutInitiativeStatus2 } = await Promise.resolve().then(() => (init_layout4(), layout_exports4));
16185
15746
  const { renderInitiativeStatus: renderInitiativeStatus2 } = await Promise.resolve().then(() => (init_renderer5(), renderer_exports5));
16186
- const isDark2 = theme === "dark";
16187
- const { getPalette: getPalette3 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
16188
- const effectivePalette2 = palette ?? (isDark2 ? getPalette3("nord").dark : getPalette3("nord").light);
15747
+ const effectivePalette2 = await resolveExportPalette(theme, palette);
16189
15748
  const isParsed = parseInitiativeStatus2(content);
16190
15749
  if (isParsed.error || isParsed.nodes.length === 0) return "";
16191
15750
  const isLayout = layoutInitiativeStatus2(isParsed);
@@ -16193,48 +15752,15 @@ async function renderD3ForExport(content, theme, palette, orgExportState, option
16193
15752
  const titleOffset = isParsed.title ? 40 : 0;
16194
15753
  const exportWidth = isLayout.width + PADDING * 2;
16195
15754
  const exportHeight = isLayout.height + PADDING * 2 + titleOffset;
16196
- const container2 = document.createElement("div");
16197
- container2.style.width = `${exportWidth}px`;
16198
- container2.style.height = `${exportHeight}px`;
16199
- container2.style.position = "absolute";
16200
- container2.style.left = "-9999px";
16201
- document.body.appendChild(container2);
16202
- try {
16203
- renderInitiativeStatus2(
16204
- container2,
16205
- isParsed,
16206
- isLayout,
16207
- effectivePalette2,
16208
- isDark2,
16209
- void 0,
16210
- { width: exportWidth, height: exportHeight }
16211
- );
16212
- const svgEl = container2.querySelector("svg");
16213
- if (!svgEl) return "";
16214
- if (theme === "transparent") {
16215
- svgEl.style.background = "none";
16216
- } else if (!svgEl.style.background) {
16217
- svgEl.style.background = effectivePalette2.bg;
16218
- }
16219
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16220
- svgEl.style.fontFamily = FONT_FAMILY;
16221
- const svgHtml = svgEl.outerHTML;
16222
- if (options?.branding !== false) {
16223
- const brandColor = theme === "transparent" ? "#888" : effectivePalette2.textMuted;
16224
- return injectBranding(svgHtml, brandColor);
16225
- }
16226
- return svgHtml;
16227
- } finally {
16228
- document.body.removeChild(container2);
16229
- }
15755
+ const container2 = createExportContainer(exportWidth, exportHeight);
15756
+ renderInitiativeStatus2(container2, isParsed, isLayout, effectivePalette2, theme === "dark", void 0, { width: exportWidth, height: exportHeight });
15757
+ return finalizeSvgExport(container2, theme, effectivePalette2, options);
16230
15758
  }
16231
15759
  if (detectedType === "c4") {
16232
15760
  const { parseC4: parseC42 } = await Promise.resolve().then(() => (init_parser6(), parser_exports6));
16233
15761
  const { layoutC4Context: layoutC4Context2, layoutC4Containers: layoutC4Containers2, layoutC4Components: layoutC4Components2, layoutC4Deployment: layoutC4Deployment2 } = await Promise.resolve().then(() => (init_layout5(), layout_exports5));
16234
15762
  const { renderC4Context: renderC4Context2, renderC4Containers: renderC4Containers2 } = await Promise.resolve().then(() => (init_renderer6(), renderer_exports6));
16235
- const isDark2 = theme === "dark";
16236
- const { getPalette: getPalette3 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
16237
- const effectivePalette2 = palette ?? (isDark2 ? getPalette3("nord").dark : getPalette3("nord").light);
15763
+ const effectivePalette2 = await resolveExportPalette(theme, palette);
16238
15764
  const c4Parsed = parseC42(content, effectivePalette2);
16239
15765
  if (c4Parsed.error || c4Parsed.elements.length === 0) return "";
16240
15766
  const c4Level = options?.c4Level ?? "context";
@@ -16246,81 +15772,22 @@ async function renderD3ForExport(content, theme, palette, orgExportState, option
16246
15772
  const titleOffset = c4Parsed.title ? 40 : 0;
16247
15773
  const exportWidth = c4Layout.width + PADDING * 2;
16248
15774
  const exportHeight = c4Layout.height + PADDING * 2 + titleOffset;
16249
- const container2 = document.createElement("div");
16250
- container2.style.width = `${exportWidth}px`;
16251
- container2.style.height = `${exportHeight}px`;
16252
- container2.style.position = "absolute";
16253
- container2.style.left = "-9999px";
16254
- document.body.appendChild(container2);
16255
- try {
16256
- const renderFn = c4Level === "deployment" || c4Level === "components" && c4System && c4Container || c4Level === "containers" && c4System ? renderC4Containers2 : renderC4Context2;
16257
- renderFn(
16258
- container2,
16259
- c4Parsed,
16260
- c4Layout,
16261
- effectivePalette2,
16262
- isDark2,
16263
- void 0,
16264
- { width: exportWidth, height: exportHeight }
16265
- );
16266
- const svgEl = container2.querySelector("svg");
16267
- if (!svgEl) return "";
16268
- if (theme === "transparent") {
16269
- svgEl.style.background = "none";
16270
- } else if (!svgEl.style.background) {
16271
- svgEl.style.background = effectivePalette2.bg;
16272
- }
16273
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16274
- svgEl.style.fontFamily = FONT_FAMILY;
16275
- const svgHtml = svgEl.outerHTML;
16276
- if (options?.branding !== false) {
16277
- const brandColor = theme === "transparent" ? "#888" : effectivePalette2.textMuted;
16278
- return injectBranding(svgHtml, brandColor);
16279
- }
16280
- return svgHtml;
16281
- } finally {
16282
- document.body.removeChild(container2);
16283
- }
15775
+ const container2 = createExportContainer(exportWidth, exportHeight);
15776
+ const renderFn = c4Level === "deployment" || c4Level === "components" && c4System && c4Container || c4Level === "containers" && c4System ? renderC4Containers2 : renderC4Context2;
15777
+ renderFn(container2, c4Parsed, c4Layout, effectivePalette2, theme === "dark", void 0, { width: exportWidth, height: exportHeight });
15778
+ return finalizeSvgExport(container2, theme, effectivePalette2, options);
16284
15779
  }
16285
15780
  if (detectedType === "flowchart") {
16286
15781
  const { parseFlowchart: parseFlowchart2 } = await Promise.resolve().then(() => (init_flowchart_parser(), flowchart_parser_exports));
16287
15782
  const { layoutGraph: layoutGraph2 } = await Promise.resolve().then(() => (init_layout6(), layout_exports6));
16288
15783
  const { renderFlowchart: renderFlowchart2 } = await Promise.resolve().then(() => (init_flowchart_renderer(), flowchart_renderer_exports));
16289
- const isDark2 = theme === "dark";
16290
- const { getPalette: getPalette3 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
16291
- const effectivePalette2 = palette ?? (isDark2 ? getPalette3("nord").dark : getPalette3("nord").light);
15784
+ const effectivePalette2 = await resolveExportPalette(theme, palette);
16292
15785
  const fcParsed = parseFlowchart2(content, effectivePalette2);
16293
15786
  if (fcParsed.error || fcParsed.nodes.length === 0) return "";
16294
15787
  const layout = layoutGraph2(fcParsed);
16295
- const container2 = document.createElement("div");
16296
- container2.style.width = `${EXPORT_WIDTH}px`;
16297
- container2.style.height = `${EXPORT_HEIGHT}px`;
16298
- container2.style.position = "absolute";
16299
- container2.style.left = "-9999px";
16300
- document.body.appendChild(container2);
16301
- try {
16302
- renderFlowchart2(container2, fcParsed, layout, effectivePalette2, isDark2, void 0, {
16303
- width: EXPORT_WIDTH,
16304
- height: EXPORT_HEIGHT
16305
- });
16306
- const svgEl = container2.querySelector("svg");
16307
- if (!svgEl) return "";
16308
- if (theme === "transparent") {
16309
- svgEl.style.background = "none";
16310
- } else if (!svgEl.style.background) {
16311
- svgEl.style.background = effectivePalette2.bg;
16312
- }
16313
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16314
- svgEl.style.fontFamily = FONT_FAMILY;
16315
- const svgHtml = svgEl.outerHTML;
16316
- if (options?.branding !== false) {
16317
- const brandColor = theme === "transparent" ? "#888" : effectivePalette2.textMuted;
16318
- return injectBranding(svgHtml, brandColor);
16319
- }
16320
- return svgHtml;
16321
- } finally {
16322
- document.body.removeChild(container2);
16323
- }
15788
+ const container2 = createExportContainer(EXPORT_WIDTH, EXPORT_HEIGHT);
15789
+ renderFlowchart2(container2, fcParsed, layout, effectivePalette2, theme === "dark", void 0, { width: EXPORT_WIDTH, height: EXPORT_HEIGHT });
15790
+ return finalizeSvgExport(container2, theme, effectivePalette2, options);
16324
15791
  }
16325
15792
  const parsed = parseD3(content, palette);
16326
15793
  if (parsed.error && parsed.type !== "sequence") {
@@ -16336,56 +15803,32 @@ async function renderD3ForExport(content, theme, palette, orgExportState, option
16336
15803
  if (parsed.type === "venn" && parsed.vennSets.length < 2) return "";
16337
15804
  if (parsed.type === "quadrant" && parsed.quadrantPoints.length === 0)
16338
15805
  return "";
15806
+ const effectivePalette = await resolveExportPalette(theme, palette);
16339
15807
  const isDark = theme === "dark";
16340
- const { getPalette: getPalette2 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
16341
- const effectivePalette = palette ?? (isDark ? getPalette2("nord").dark : getPalette2("nord").light);
16342
- const container = document.createElement("div");
16343
- container.style.width = `${EXPORT_WIDTH}px`;
16344
- container.style.height = `${EXPORT_HEIGHT}px`;
16345
- container.style.position = "absolute";
16346
- container.style.left = "-9999px";
16347
- document.body.appendChild(container);
15808
+ const container = createExportContainer(EXPORT_WIDTH, EXPORT_HEIGHT);
16348
15809
  const dims = { width: EXPORT_WIDTH, height: EXPORT_HEIGHT };
16349
- try {
16350
- if (parsed.type === "sequence") {
16351
- const { parseSequenceDgmo: parseSequenceDgmo2 } = await Promise.resolve().then(() => (init_parser(), parser_exports));
16352
- const { renderSequenceDiagram: renderSequenceDiagram2 } = await Promise.resolve().then(() => (init_renderer7(), renderer_exports7));
16353
- const seqParsed = parseSequenceDgmo2(content);
16354
- if (seqParsed.error || seqParsed.participants.length === 0) return "";
16355
- renderSequenceDiagram2(container, seqParsed, effectivePalette, isDark, void 0, {
16356
- exportWidth: EXPORT_WIDTH
16357
- });
16358
- } else if (parsed.type === "wordcloud") {
16359
- await renderWordCloudAsync(container, parsed, effectivePalette, isDark, dims);
16360
- } else if (parsed.type === "arc") {
16361
- renderArcDiagram(container, parsed, effectivePalette, isDark, void 0, dims);
16362
- } else if (parsed.type === "timeline") {
16363
- renderTimeline(container, parsed, effectivePalette, isDark, void 0, dims);
16364
- } else if (parsed.type === "venn") {
16365
- renderVenn(container, parsed, effectivePalette, isDark, void 0, dims);
16366
- } else if (parsed.type === "quadrant") {
16367
- renderQuadrant(container, parsed, effectivePalette, isDark, void 0, dims);
16368
- } else {
16369
- renderSlopeChart(container, parsed, effectivePalette, isDark, void 0, dims);
16370
- }
16371
- const svgEl = container.querySelector("svg");
16372
- if (!svgEl) return "";
16373
- if (theme === "transparent") {
16374
- svgEl.style.background = "none";
16375
- } else if (!svgEl.style.background) {
16376
- svgEl.style.background = effectivePalette.bg;
16377
- }
16378
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16379
- svgEl.style.fontFamily = FONT_FAMILY;
16380
- const svgHtml = svgEl.outerHTML;
16381
- if (options?.branding !== false) {
16382
- const brandColor = theme === "transparent" ? "#888" : effectivePalette.textMuted;
16383
- return injectBranding(svgHtml, brandColor);
16384
- }
16385
- return svgHtml;
16386
- } finally {
16387
- document.body.removeChild(container);
15810
+ if (parsed.type === "sequence") {
15811
+ const { parseSequenceDgmo: parseSequenceDgmo2 } = await Promise.resolve().then(() => (init_parser(), parser_exports));
15812
+ const { renderSequenceDiagram: renderSequenceDiagram2 } = await Promise.resolve().then(() => (init_renderer7(), renderer_exports7));
15813
+ const seqParsed = parseSequenceDgmo2(content);
15814
+ if (seqParsed.error || seqParsed.participants.length === 0) return "";
15815
+ renderSequenceDiagram2(container, seqParsed, effectivePalette, isDark, void 0, {
15816
+ exportWidth: EXPORT_WIDTH
15817
+ });
15818
+ } else if (parsed.type === "wordcloud") {
15819
+ await renderWordCloudAsync(container, parsed, effectivePalette, isDark, dims);
15820
+ } else if (parsed.type === "arc") {
15821
+ renderArcDiagram(container, parsed, effectivePalette, isDark, void 0, dims);
15822
+ } else if (parsed.type === "timeline") {
15823
+ renderTimeline(container, parsed, effectivePalette, isDark, void 0, dims);
15824
+ } else if (parsed.type === "venn") {
15825
+ renderVenn(container, parsed, effectivePalette, isDark, void 0, dims);
15826
+ } else if (parsed.type === "quadrant") {
15827
+ renderQuadrant(container, parsed, effectivePalette, isDark, void 0, dims);
15828
+ } else {
15829
+ renderSlopeChart(container, parsed, effectivePalette, isDark, void 0, dims);
16388
15830
  }
15831
+ return finalizeSvgExport(container, theme, effectivePalette, options);
16389
15832
  }
16390
15833
  var d3Scale, d3Selection9, d3Shape6, d3Array, import_d3_cloud, DEFAULT_CLOUD_OPTIONS, STOP_WORDS, SLOPE_MARGIN, SLOPE_LABEL_FONT_SIZE, SLOPE_CHAR_WIDTH, ARC_MARGIN, MONTH_ABBR, EXPORT_WIDTH, EXPORT_HEIGHT;
16391
15834
  var init_d3 = __esm({
@@ -16547,6 +15990,7 @@ var index_exports = {};
16547
15990
  __export(index_exports, {
16548
15991
  DGMO_CHART_TYPE_MAP: () => DGMO_CHART_TYPE_MAP,
16549
15992
  RULE_COUNT: () => RULE_COUNT,
15993
+ STANDARD_CHART_TYPES: () => STANDARD_CHART_TYPES,
16550
15994
  addDurationToDate: () => addDurationToDate,
16551
15995
  applyGroupOrdering: () => applyGroupOrdering,
16552
15996
  applyPositionOverrides: () => applyPositionOverrides,
@@ -17229,6 +16673,7 @@ init_branding();
17229
16673
  0 && (module.exports = {
17230
16674
  DGMO_CHART_TYPE_MAP,
17231
16675
  RULE_COUNT,
16676
+ STANDARD_CHART_TYPES,
17232
16677
  addDurationToDate,
17233
16678
  applyGroupOrdering,
17234
16679
  applyPositionOverrides,