@superdoc-dev/cli 0.2.0-next.106 → 0.2.0-next.107

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +1945 -122
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -37760,7 +37760,7 @@ var init_remark_gfm_z_sDF4ss_es = __esm(() => {
37760
37760
  emptyOptions2 = {};
37761
37761
  });
37762
37762
 
37763
- // ../../packages/superdoc/dist/chunks/SuperConverter-Cx2VynBq.es.js
37763
+ // ../../packages/superdoc/dist/chunks/SuperConverter-BDyjQdwB.es.js
37764
37764
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
37765
37765
  const fieldValue = extension$1.config[field];
37766
37766
  if (typeof fieldValue === "function")
@@ -48346,6 +48346,182 @@ function parseRelativeHeight(value) {
48346
48346
  return null;
48347
48347
  return isValidRelativeHeight(parsed) ? parsed : null;
48348
48348
  }
48349
+ function normalizeChartTarget(target) {
48350
+ let cleaned = target;
48351
+ if (cleaned.startsWith("/"))
48352
+ cleaned = cleaned.slice(1);
48353
+ if (cleaned.startsWith("./"))
48354
+ cleaned = cleaned.slice(2);
48355
+ while (cleaned.startsWith("../"))
48356
+ cleaned = cleaned.slice(3);
48357
+ if (!cleaned.startsWith("word/"))
48358
+ cleaned = `word/${cleaned}`;
48359
+ return cleaned;
48360
+ }
48361
+ function resolveChartPart(docx, chartRelId, filename) {
48362
+ if (!chartRelId || !docx)
48363
+ return null;
48364
+ const chartRel = findChild(docx[`word/_rels/${filename || "document.xml"}.rels`] || docx["word/_rels/document.xml.rels"], "Relationships")?.elements?.find((el) => getAttr(el, "Id") === chartRelId);
48365
+ if (!chartRel)
48366
+ return null;
48367
+ const target = getAttr(chartRel, "Target");
48368
+ if (!target)
48369
+ return null;
48370
+ return {
48371
+ chartPartPath: normalizeChartTarget(target),
48372
+ chartRel
48373
+ };
48374
+ }
48375
+ function parseChartXml(chartXml) {
48376
+ const chartSpace = chartXml?.name === "c:chartSpace" ? chartXml : findChild(chartXml, "c:chartSpace");
48377
+ const chart = findChild(chartSpace, "c:chart");
48378
+ if (!chart)
48379
+ return null;
48380
+ const plotArea = findChild(chart, "c:plotArea");
48381
+ if (!plotArea)
48382
+ return null;
48383
+ const chartTypeEntry = findChartTypeElement(plotArea);
48384
+ if (!chartTypeEntry)
48385
+ return null;
48386
+ const { element: chartTypeEl, chartType } = chartTypeEntry;
48387
+ const subType = extractGrouping(chartTypeEl);
48388
+ const barDirection = extractBarDirection(chartTypeEl);
48389
+ const series = parseSeries(chartTypeEl, chartType);
48390
+ const categoryAxis = parseAxis(plotArea, "c:catAx");
48391
+ const valueAxis = parseAxis(plotArea, "c:valAx");
48392
+ const legendPosition = parseLegendPosition(chart);
48393
+ const styleId = parseStyleId(chartSpace);
48394
+ return {
48395
+ chartType,
48396
+ ...subType && { subType },
48397
+ ...barDirection && { barDirection },
48398
+ series,
48399
+ ...categoryAxis && { categoryAxis },
48400
+ ...valueAxis && { valueAxis },
48401
+ ...legendPosition && { legendPosition },
48402
+ ...styleId != null && { styleId }
48403
+ };
48404
+ }
48405
+ function findChartTypeElement(plotArea) {
48406
+ for (const el of plotArea.elements || [])
48407
+ if (CHART_TYPE_NAMES.has(el.name))
48408
+ return {
48409
+ element: el,
48410
+ chartType: CHART_TYPE_MAP[el.name]
48411
+ };
48412
+ for (const el of plotArea.elements || [])
48413
+ if (el.name?.startsWith("c:") && el.name.endsWith("Chart"))
48414
+ return {
48415
+ element: el,
48416
+ chartType: el.name.replace("c:", "")
48417
+ };
48418
+ return null;
48419
+ }
48420
+ function extractGrouping(chartTypeEl) {
48421
+ return getAttr(findChild(chartTypeEl, "c:grouping"), "val") || undefined;
48422
+ }
48423
+ function extractBarDirection(chartTypeEl) {
48424
+ const val = getAttr(findChild(chartTypeEl, "c:barDir"), "val");
48425
+ return val === "col" || val === "bar" ? val : undefined;
48426
+ }
48427
+ function parseSeries(chartTypeEl, chartType) {
48428
+ return findChildren$1(chartTypeEl, "c:ser").map((seriesEl) => parseOneSeries(seriesEl, chartType));
48429
+ }
48430
+ function parseOneSeries(serEl, chartType) {
48431
+ const name = extractSeriesName(serEl);
48432
+ const categories = extractCachedStrings(findChild(serEl, "c:cat"));
48433
+ const values = extractCachedNumbers(findChild(serEl, "c:val"));
48434
+ const xValues = extractCachedNumbers(findChild(serEl, "c:xVal"));
48435
+ const yValues = extractCachedNumbers(findChild(serEl, "c:yVal"));
48436
+ const bubbleSizes = extractCachedNumbers(findChild(serEl, "c:bubbleSize"));
48437
+ if (chartType === "scatterChart" || chartType === "bubbleChart") {
48438
+ const parsedCategoryValues = categories.map((value) => Number(value));
48439
+ const numericCategoryValues = parsedCategoryValues.every((value) => Number.isFinite(value)) ? parsedCategoryValues : [];
48440
+ const seriesXValues = xValues.length ? xValues : numericCategoryValues;
48441
+ const seriesYValues = yValues.length ? yValues : values;
48442
+ return {
48443
+ name,
48444
+ categories: categories.length ? categories : seriesXValues.map((value, index2) => formatChartLabel(value, index2 + 1)),
48445
+ values: seriesYValues,
48446
+ ...seriesXValues.length ? { xValues: seriesXValues } : {},
48447
+ ...chartType === "bubbleChart" && bubbleSizes.length ? { bubbleSizes } : {}
48448
+ };
48449
+ }
48450
+ return {
48451
+ name,
48452
+ categories,
48453
+ values
48454
+ };
48455
+ }
48456
+ function formatChartLabel(value, fallbackIndex) {
48457
+ if (!Number.isFinite(value))
48458
+ return `Category ${fallbackIndex}`;
48459
+ if (Number.isInteger(value))
48460
+ return String(value);
48461
+ return String(Number(value.toFixed(3)));
48462
+ }
48463
+ function extractSeriesName(serEl) {
48464
+ return findChild(findChild(findChild(findChild(findChild(serEl, "c:tx"), "c:strRef"), "c:strCache"), "c:pt"), "c:v")?.elements?.[0]?.text ?? `Series ${getAttr(findChild(serEl, "c:idx"), "val") ?? ""}`.trim();
48465
+ }
48466
+ function extractCachedStrings(parentEl) {
48467
+ if (!parentEl)
48468
+ return [];
48469
+ const strCache = findChild(findChild(parentEl, "c:strRef"), "c:strCache");
48470
+ const numCache = findChild(findChild(parentEl, "c:numRef"), "c:numCache");
48471
+ const cache = strCache || numCache;
48472
+ if (!cache)
48473
+ return [];
48474
+ return findChildren$1(cache, "c:pt").sort((a, b) => (Number(getAttr(a, "idx")) || 0) - (Number(getAttr(b, "idx")) || 0)).map((pt) => findChild(pt, "c:v")?.elements?.[0]?.text ?? "");
48475
+ }
48476
+ function extractCachedNumbers(parentEl) {
48477
+ if (!parentEl)
48478
+ return [];
48479
+ const numCache = findChild(findChild(parentEl, "c:numRef"), "c:numCache");
48480
+ if (!numCache)
48481
+ return [];
48482
+ return findChildren$1(numCache, "c:pt").sort((a, b) => (Number(getAttr(a, "idx")) || 0) - (Number(getAttr(b, "idx")) || 0)).map((pt) => {
48483
+ const text$2 = findChild(pt, "c:v")?.elements?.[0]?.text;
48484
+ const num = Number(text$2);
48485
+ return Number.isFinite(num) ? num : 0;
48486
+ });
48487
+ }
48488
+ function parseAxis(plotArea, axisName) {
48489
+ const axis = findChild(plotArea, axisName);
48490
+ if (!axis)
48491
+ return;
48492
+ const title = extractAxisTitle(findChild(axis, "c:title"));
48493
+ const orientation = getAttr(findChild(findChild(axis, "c:scaling"), "c:orientation"), "val");
48494
+ const config$39 = {};
48495
+ if (title)
48496
+ config$39.title = title;
48497
+ if (orientation === "minMax" || orientation === "maxMin")
48498
+ config$39.orientation = orientation;
48499
+ return Object.keys(config$39).length > 0 ? config$39 : undefined;
48500
+ }
48501
+ function extractAxisTitle(titleEl) {
48502
+ if (!titleEl)
48503
+ return;
48504
+ return findChild(findChild(findChild(findChild(findChild(titleEl, "c:tx"), "c:rich"), "a:p"), "a:r"), "a:t")?.elements?.[0]?.text || undefined;
48505
+ }
48506
+ function parseLegendPosition(chart) {
48507
+ const legend = findChild(chart, "c:legend");
48508
+ if (!legend)
48509
+ return;
48510
+ return getAttr(findChild(legend, "c:legendPos"), "val") || undefined;
48511
+ }
48512
+ function parseStyleId(chartSpace) {
48513
+ const altContent = findChild(chartSpace, "mc:AlternateContent");
48514
+ if (altContent) {
48515
+ const val$1 = getAttr(findChild(findChild(altContent, "mc:Choice"), "c14:style"), "val");
48516
+ if (val$1 != null)
48517
+ return Number(val$1);
48518
+ const fallbackVal = getAttr(findChild(findChild(altContent, "mc:Fallback"), "c:style"), "val");
48519
+ if (fallbackVal != null)
48520
+ return Number(fallbackVal);
48521
+ }
48522
+ const val = getAttr(findChild(chartSpace, "c:style"), "val");
48523
+ return val != null ? Number(val) : undefined;
48524
+ }
48349
48525
  function handleImageNode(node3, params, isAnchor) {
48350
48526
  if (!node3)
48351
48527
  return null;
@@ -48479,6 +48655,8 @@ function handleImageNode(node3, params, isAnchor) {
48479
48655
  horizontal: positionHValue,
48480
48656
  top: positionVValue
48481
48657
  }, anchorData, wrap$1, isHidden);
48658
+ if (uri === "http://schemas.openxmlformats.org/drawingml/2006/chart")
48659
+ return handleChartDrawing(params, node3, graphicData, size, padding, marginOffset, anchorData, wrap$1, isAnchor);
48482
48660
  const picture = graphicData?.elements.find((el) => el.name === "pic:pic");
48483
48661
  if (!picture || !picture.elements)
48484
48662
  return null;
@@ -55607,6 +55785,8 @@ function decode$46(params) {
55607
55785
  return null;
55608
55786
  if (node3.attrs.isPict)
55609
55787
  return null;
55788
+ if (node3.type === "chart" && node3.attrs.originalXml)
55789
+ return wrapTextInRun(carbonCopy(node3.attrs.originalXml), []);
55610
55790
  return wrapTextInRun({
55611
55791
  name: "w:drawing",
55612
55792
  elements: [(node3.attrs.isAnchor ? translator$197 : translator$198).decode(params)]
@@ -58320,6 +58500,7 @@ function exportSchemaToJson(params) {
58320
58500
  contentBlock: translator$27,
58321
58501
  vectorShape: translateVectorShape,
58322
58502
  shapeGroup: translateShapeGroup,
58503
+ chart: translator$10,
58323
58504
  structuredContent: translator$7,
58324
58505
  structuredContentBlock: translator$7,
58325
58506
  documentPartObject: translator$7,
@@ -66728,7 +66909,7 @@ var isRegExp = (value) => {
66728
66909
  i2++;
66729
66910
  }
66730
66911
  return { processedNodes };
66731
- }, HEADER_FOOTER_FILENAME_PATTERN, DRAWING_XML_TAG = "w:drawing", SHAPE_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", GROUP_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup", SD_IMAGE_ID_NAMESPACE = "7c9e6679-7425-40de-944b-e07fc1f90ae7", normalizeTargetPath$1 = (targetPath = "") => {
66912
+ }, HEADER_FOOTER_FILENAME_PATTERN, CHART_TYPE_MAP, CHART_TYPE_NAMES, findChild = (node3, name) => node3?.elements?.find((el) => el.name === name), findChildren$1 = (node3, name) => node3?.elements?.filter((el) => el.name === name) ?? [], getAttr = (node3, attr) => node3?.attributes?.[attr], DRAWING_XML_TAG = "w:drawing", SHAPE_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", GROUP_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup", SD_IMAGE_ID_NAMESPACE = "7c9e6679-7425-40de-944b-e07fc1f90ae7", normalizeTargetPath$1 = (targetPath = "") => {
66732
66913
  if (!targetPath)
66733
66914
  return targetPath;
66734
66915
  const trimmed = targetPath.replace(/^\/+/, "");
@@ -67005,6 +67186,39 @@ var isRegExp = (value) => {
67005
67186
  originalAttributes: node3?.attributes
67006
67187
  }
67007
67188
  };
67189
+ }, handleChartDrawing = (params, node3, graphicData, size, padding, marginOffset, anchorData, wrap$1, isAnchor) => {
67190
+ const chartRelId = graphicData?.elements?.find((el) => el.name === "c:chart")?.attributes?.["r:id"];
67191
+ if (!chartRelId)
67192
+ return null;
67193
+ const { docx, filename } = params;
67194
+ const resolved = resolveChartPart(docx, chartRelId, filename);
67195
+ if (!resolved)
67196
+ return null;
67197
+ const { chartPartPath } = resolved;
67198
+ const chartXml = docx[chartPartPath];
67199
+ const chartData = chartXml ? parseChartXml(chartXml) : null;
67200
+ const drawingNode = params.nodes?.[0];
67201
+ const { order: order2, originalChildren } = collectPreservedDrawingChildren(node3);
67202
+ return {
67203
+ type: "chart",
67204
+ attrs: {
67205
+ width: size.width || 400,
67206
+ height: size.height || 300,
67207
+ chartData,
67208
+ chartRelId,
67209
+ chartPartPath,
67210
+ isAnchor,
67211
+ anchorData,
67212
+ wrap: wrap$1,
67213
+ padding,
67214
+ marginOffset,
67215
+ originalAttributes: node3?.attributes,
67216
+ originalChildren,
67217
+ originalChildOrder: order2,
67218
+ originalXml: drawingNode ? carbonCopy(drawingNode) : null,
67219
+ drawingContent: drawingNode || null
67220
+ }
67221
+ };
67008
67222
  }, buildShapePlaceholder = (node3, size, padding, marginOffset, shapeType) => {
67009
67223
  const attrs = {
67010
67224
  drawingContent: {
@@ -72817,7 +73031,7 @@ var isRegExp = (value) => {
72817
73031
  state.kern = kernNode.attributes["w:val"];
72818
73032
  }
72819
73033
  }, SuperConverter;
72820
- var init_SuperConverter_Cx2VynBq_es = __esm(() => {
73034
+ var init_SuperConverter_BDyjQdwB_es = __esm(() => {
72821
73035
  init_rolldown_runtime_B2q5OVn9_es();
72822
73036
  init_jszip_ChlR43oI_es();
72823
73037
  init_xml_js_DLE8mr0n_es();
@@ -97932,6 +98146,26 @@ var init_SuperConverter_Cx2VynBq_es = __esm(() => {
97932
98146
  SKIP_FIELD_PROCESSING_NODE_NAMES$1 = new Set(["w:drawing", "w:pict"]);
97933
98147
  SKIP_FIELD_PROCESSING_NODE_NAMES = new Set(["w:drawing", "w:pict"]);
97934
98148
  HEADER_FOOTER_FILENAME_PATTERN = /^(header|footer)\d*\.xml$/i;
98149
+ CHART_TYPE_MAP = {
98150
+ "c:barChart": "barChart",
98151
+ "c:bar3DChart": "barChart",
98152
+ "c:lineChart": "lineChart",
98153
+ "c:line3DChart": "lineChart",
98154
+ "c:pieChart": "pieChart",
98155
+ "c:pie3DChart": "pieChart",
98156
+ "c:ofPieChart": "ofPieChart",
98157
+ "c:areaChart": "areaChart",
98158
+ "c:area3DChart": "areaChart",
98159
+ "c:scatterChart": "scatterChart",
98160
+ "c:bubbleChart": "bubbleChart",
98161
+ "c:bubble3DChart": "bubbleChart",
98162
+ "c:doughnutChart": "doughnutChart",
98163
+ "c:radarChart": "radarChart",
98164
+ "c:stockChart": "stockChart",
98165
+ "c:surfaceChart": "surfaceChart",
98166
+ "c:surface3DChart": "surfaceChart"
98167
+ };
98168
+ CHART_TYPE_NAMES = new Set(Object.keys(CHART_TYPE_MAP));
97935
98169
  init_dist();
97936
98170
  DEFAULT_ALLOWED_PROTOCOLS = [
97937
98171
  "http",
@@ -132185,9 +132419,9 @@ var init_remark_gfm_CjV8kaUy_es = __esm(() => {
132185
132419
  init_remark_gfm_z_sDF4ss_es();
132186
132420
  });
132187
132421
 
132188
- // ../../packages/superdoc/dist/chunks/src-CJCOedws.es.js
132189
- var exports_src_CJCOedws_es = {};
132190
- __export(exports_src_CJCOedws_es, {
132422
+ // ../../packages/superdoc/dist/chunks/src-asiscfsz.es.js
132423
+ var exports_src_asiscfsz_es = {};
132424
+ __export(exports_src_asiscfsz_es, {
132191
132425
  zt: () => defineMark,
132192
132426
  z: () => cM,
132193
132427
  yt: () => removeAwarenessStates,
@@ -140530,11 +140764,11 @@ function ensureSectPrElement(current) {
140530
140764
  return cloneXmlElement(current);
140531
140765
  return createSectPrElement();
140532
140766
  }
140533
- function findChild(element3, childName) {
140767
+ function findChild2(element3, childName) {
140534
140768
  return element3.elements?.find((entry) => entry?.name === childName);
140535
140769
  }
140536
140770
  function ensureChild(element3, childName) {
140537
- const existing = findChild(element3, childName);
140771
+ const existing = findChild2(element3, childName);
140538
140772
  if (existing)
140539
140773
  return existing;
140540
140774
  const created = {
@@ -140587,7 +140821,7 @@ function writeSectPrBreakType(sectPr, breakType) {
140587
140821
  setStringAttr(ensureChild(sectPr, "w:type"), "w:val", breakType);
140588
140822
  }
140589
140823
  function readSectPrMargins(sectPr) {
140590
- const pgMar = findChild(sectPr, "w:pgMar");
140824
+ const pgMar = findChild2(sectPr, "w:pgMar");
140591
140825
  if (!pgMar)
140592
140826
  return {};
140593
140827
  return {
@@ -140621,7 +140855,7 @@ function writeSectPrHeaderFooterMargins(sectPr, margins) {
140621
140855
  setStringAttr(pgMar, "w:footer", toTwipsString(margins.footer));
140622
140856
  }
140623
140857
  function readSectPrPageSetup(sectPr) {
140624
- const pgSz = findChild(sectPr, "w:pgSz");
140858
+ const pgSz = findChild2(sectPr, "w:pgSz");
140625
140859
  if (!pgSz)
140626
140860
  return;
140627
140861
  const width = toInchesFromTwips(pgSz.attributes?.["w:w"]);
@@ -140660,7 +140894,7 @@ function writeSectPrPageSetup(sectPr, setup) {
140660
140894
  }
140661
140895
  }
140662
140896
  function readSectPrColumns(sectPr) {
140663
- const cols = findChild(sectPr, "w:cols");
140897
+ const cols = findChild2(sectPr, "w:cols");
140664
140898
  if (!cols)
140665
140899
  return;
140666
140900
  const count = toPositiveInteger(cols.attributes?.["w:num"]);
@@ -140684,7 +140918,7 @@ function writeSectPrColumns(sectPr, columns) {
140684
140918
  setBooleanAttr(cols, "w:equalWidth", columns.equalWidth);
140685
140919
  }
140686
140920
  function readSectPrLineNumbering(sectPr) {
140687
- const lnNumType = findChild(sectPr, "w:lnNumType");
140921
+ const lnNumType = findChild2(sectPr, "w:lnNumType");
140688
140922
  if (!lnNumType)
140689
140923
  return;
140690
140924
  const restartRaw = asString$1(lnNumType.attributes?.["w:restart"]);
@@ -140713,7 +140947,7 @@ function writeSectPrLineNumbering(sectPr, numbering) {
140713
140947
  setStringAttr(lnNumType, "w:restart", numbering.restart);
140714
140948
  }
140715
140949
  function readSectPrPageNumbering(sectPr) {
140716
- const pgNumType = findChild(sectPr, "w:pgNumType");
140950
+ const pgNumType = findChild2(sectPr, "w:pgNumType");
140717
140951
  if (!pgNumType)
140718
140952
  return;
140719
140953
  const formatRaw = asString$1(pgNumType.attributes?.["w:fmt"]);
@@ -140743,14 +140977,14 @@ function writeSectPrTitlePage(sectPr, enabled) {
140743
140977
  removeChildren(sectPr, (entry) => entry.name === "w:titlePg");
140744
140978
  }
140745
140979
  function readSectPrVerticalAlign(sectPr) {
140746
- const raw = asString$1(findChild(sectPr, "w:vAlign")?.attributes?.["w:val"]);
140980
+ const raw = asString$1(findChild2(sectPr, "w:vAlign")?.attributes?.["w:val"]);
140747
140981
  return isKnownValue(raw, SECTION_VERTICAL_ALIGN_VALUES) ? raw : undefined;
140748
140982
  }
140749
140983
  function writeSectPrVerticalAlign(sectPr, value) {
140750
140984
  setStringAttr(ensureChild(sectPr, "w:vAlign"), "w:val", value);
140751
140985
  }
140752
140986
  function readSectPrDirection(sectPr) {
140753
- const bidi = findChild(sectPr, "w:bidi");
140987
+ const bidi = findChild2(sectPr, "w:bidi");
140754
140988
  if (!bidi)
140755
140989
  return;
140756
140990
  return toBooleanAttr(bidi.attributes?.["w:val"]) === false ? "ltr" : "rtl";
@@ -140837,13 +141071,13 @@ function writeBorderSpec(parent, edge, border) {
140837
141071
  setBooleanAttr(edgeElement, "w:frame", border.frame);
140838
141072
  }
140839
141073
  function readSectPrPageBorders(sectPr) {
140840
- const pgBorders = findChild(sectPr, "w:pgBorders");
141074
+ const pgBorders = findChild2(sectPr, "w:pgBorders");
140841
141075
  if (!pgBorders)
140842
141076
  return;
140843
- const top$1 = readBorderSpec(findChild(pgBorders, "w:top"));
140844
- const right$1 = readBorderSpec(findChild(pgBorders, "w:right"));
140845
- const bottom$1 = readBorderSpec(findChild(pgBorders, "w:bottom"));
140846
- const left$1 = readBorderSpec(findChild(pgBorders, "w:left"));
141077
+ const top$1 = readBorderSpec(findChild2(pgBorders, "w:top"));
141078
+ const right$1 = readBorderSpec(findChild2(pgBorders, "w:right"));
141079
+ const bottom$1 = readBorderSpec(findChild2(pgBorders, "w:bottom"));
141080
+ const left$1 = readBorderSpec(findChild2(pgBorders, "w:left"));
140847
141081
  const display = toPageBorderDisplay(pgBorders.attributes?.["w:display"]);
140848
141082
  const offsetFrom = toPageBorderOffsetFrom(pgBorders.attributes?.["w:offsetFrom"]);
140849
141083
  const zOrder = toPageBorderZOrder(pgBorders.attributes?.["w:zOrder"]);
@@ -164591,6 +164825,994 @@ function k0(t) {
164591
164825
  ${o}
164592
164826
  </svg>`;
164593
164827
  }
164828
+ function createChartElement(doc$2, chartData, geometry) {
164829
+ const container = doc$2.createElement("div");
164830
+ container.classList.add("superdoc-chart");
164831
+ container.style.width = "100%";
164832
+ container.style.height = "100%";
164833
+ container.style.position = "relative";
164834
+ if (!chartData || !chartData.series?.length)
164835
+ return createChartPlaceholder(doc$2, container, "No chart data");
164836
+ if (chartData.chartType === "barChart")
164837
+ return renderBarChart(doc$2, container, chartData, geometry);
164838
+ if (chartData.chartType === "lineChart")
164839
+ return renderLineChart(doc$2, container, chartData, geometry);
164840
+ if (chartData.chartType === "stockChart")
164841
+ return renderLineChart(doc$2, container, chartData, geometry);
164842
+ if (chartData.chartType === "areaChart")
164843
+ return renderAreaChart(doc$2, container, chartData, geometry);
164844
+ if (chartData.chartType === "scatterChart")
164845
+ return renderScatterChart(doc$2, container, chartData, geometry);
164846
+ if (chartData.chartType === "bubbleChart")
164847
+ return renderBubbleChart(doc$2, container, chartData, geometry);
164848
+ if (chartData.chartType === "radarChart")
164849
+ return renderRadarChart(doc$2, container, chartData, geometry);
164850
+ if (chartData.chartType === "pieChart")
164851
+ return renderPieChart(doc$2, container, chartData, geometry);
164852
+ if (chartData.chartType === "doughnutChart")
164853
+ return renderDoughnutChart(doc$2, container, chartData, geometry);
164854
+ if (chartData.chartType === "ofPieChart")
164855
+ return renderPieChart(doc$2, container, chartData, geometry);
164856
+ return createChartPlaceholder(doc$2, container, `Chart: ${chartData.chartType}`);
164857
+ }
164858
+ function createChartPlaceholder(doc$2, container, label) {
164859
+ container.style.display = "flex";
164860
+ container.style.alignItems = "center";
164861
+ container.style.justifyContent = "center";
164862
+ container.style.background = PLACEHOLDER_BG;
164863
+ container.style.border = `1px solid ${PLACEHOLDER_BORDER}`;
164864
+ container.style.borderRadius = "4px";
164865
+ container.style.color = PLACEHOLDER_TEXT_COLOR;
164866
+ container.style.fontSize = "13px";
164867
+ container.style.fontFamily = FONT_FAMILY;
164868
+ const icon = doc$2.createElement("span");
164869
+ icon.textContent = "\uD83D\uDCCA ";
164870
+ container.appendChild(icon);
164871
+ const text5 = doc$2.createElement("span");
164872
+ text5.textContent = label;
164873
+ container.appendChild(text5);
164874
+ return container;
164875
+ }
164876
+ function formatTickValue(value) {
164877
+ if (Math.abs(value) >= 1e6)
164878
+ return `${(value / 1e6).toFixed(1)}M`;
164879
+ if (Math.abs(value) >= 1000)
164880
+ return `${(value / 1000).toFixed(1)}K`;
164881
+ return Number.isInteger(value) ? String(value) : value.toFixed(1);
164882
+ }
164883
+ function applyGuardrails(chart) {
164884
+ let truncated = false;
164885
+ let series = chart.series;
164886
+ if (series.length > MAX_RENDERED_SERIES) {
164887
+ series = series.slice(0, MAX_RENDERED_SERIES);
164888
+ truncated = true;
164889
+ }
164890
+ series = series.map((s2) => {
164891
+ if (s2.values.length <= MAX_POINTS_PER_SERIES && s2.categories.length <= MAX_POINTS_PER_SERIES)
164892
+ return s2;
164893
+ truncated = true;
164894
+ return {
164895
+ name: s2.name,
164896
+ categories: s2.categories.slice(0, MAX_POINTS_PER_SERIES),
164897
+ values: s2.values.slice(0, MAX_POINTS_PER_SERIES),
164898
+ ...s2.xValues && { xValues: s2.xValues.slice(0, MAX_POINTS_PER_SERIES) },
164899
+ ...s2.bubbleSizes && { bubbleSizes: s2.bubbleSizes.slice(0, MAX_POINTS_PER_SERIES) }
164900
+ };
164901
+ });
164902
+ return {
164903
+ series,
164904
+ truncated
164905
+ };
164906
+ }
164907
+ function computeBarLayout(width, height, series) {
164908
+ const plotWidth = Math.max(1, width - CHART_PADDING.left - CHART_PADDING.right);
164909
+ const plotHeight = Math.max(1, height - CHART_PADDING.top - CHART_PADDING.bottom);
164910
+ const allValues = series.flatMap((s2) => s2.values);
164911
+ const maxValue = Math.max(0, ...allValues);
164912
+ const minValue = Math.min(0, ...allValues);
164913
+ const valueRange = Math.max(1, maxValue - minValue);
164914
+ const categories = series[0]?.categories ?? [];
164915
+ const categoryCount = Math.max(1, categories.length);
164916
+ const seriesCount = series.length;
164917
+ const groupWidth = plotWidth / categoryCount;
164918
+ const barGap = Math.max(1, groupWidth * 0.1);
164919
+ const totalBarWidth = groupWidth - barGap * 2;
164920
+ return {
164921
+ plotWidth,
164922
+ plotHeight,
164923
+ groupWidth,
164924
+ barWidth: Math.max(1, totalBarWidth / seriesCount),
164925
+ barGap,
164926
+ baselineY: CHART_PADDING.top + plotHeight * (maxValue / valueRange),
164927
+ valueRange,
164928
+ minValue,
164929
+ maxValue
164930
+ };
164931
+ }
164932
+ function renderBars(doc$2, svg2, series, layout) {
164933
+ const { groupWidth, barGap, barWidth, baselineY, valueRange, plotHeight } = layout;
164934
+ for (let si = 0;si < series.length; si++) {
164935
+ const s2 = series[si];
164936
+ const color2 = SERIES_COLORS[si % SERIES_COLORS.length];
164937
+ for (let ci = 0;ci < s2.values.length; ci++) {
164938
+ const value = s2.values[ci];
164939
+ const barHeight = Math.abs(value / valueRange) * plotHeight;
164940
+ const x = CHART_PADDING.left + ci * groupWidth + barGap + si * barWidth;
164941
+ const y$1 = value >= 0 ? baselineY - barHeight : baselineY;
164942
+ const rect = doc$2.createElementNS(SVG_NS, "rect");
164943
+ rect.setAttribute("x", String(x));
164944
+ rect.setAttribute("y", String(y$1));
164945
+ rect.setAttribute("width", String(barWidth));
164946
+ rect.setAttribute("height", String(Math.max(0.5, barHeight)));
164947
+ rect.setAttribute("fill", color2);
164948
+ svg2.appendChild(rect);
164949
+ }
164950
+ }
164951
+ }
164952
+ function renderAxes(doc$2, svg2, layout) {
164953
+ const { plotWidth, plotHeight, baselineY } = layout;
164954
+ const vAxis = doc$2.createElementNS(SVG_NS, "line");
164955
+ vAxis.setAttribute("x1", String(CHART_PADDING.left));
164956
+ vAxis.setAttribute("y1", String(CHART_PADDING.top));
164957
+ vAxis.setAttribute("x2", String(CHART_PADDING.left));
164958
+ vAxis.setAttribute("y2", String(CHART_PADDING.top + plotHeight));
164959
+ vAxis.setAttribute("stroke", AXIS_COLOR);
164960
+ vAxis.setAttribute("stroke-width", "1");
164961
+ svg2.appendChild(vAxis);
164962
+ const hAxis = doc$2.createElementNS(SVG_NS, "line");
164963
+ hAxis.setAttribute("x1", String(CHART_PADDING.left));
164964
+ hAxis.setAttribute("y1", String(baselineY));
164965
+ hAxis.setAttribute("x2", String(CHART_PADDING.left + plotWidth));
164966
+ hAxis.setAttribute("y2", String(baselineY));
164967
+ hAxis.setAttribute("stroke", AXIS_COLOR);
164968
+ hAxis.setAttribute("stroke-width", "1");
164969
+ svg2.appendChild(hAxis);
164970
+ }
164971
+ function renderCategoryLabels(doc$2, svg2, categories, layout, width) {
164972
+ const { groupWidth, plotHeight } = layout;
164973
+ const categoryCount = Math.max(1, categories.length);
164974
+ const fontSize$1 = Math.max(8, Math.min(12, width / categoryCount / 5));
164975
+ for (let ci = 0;ci < categories.length; ci++) {
164976
+ const labelX = CHART_PADDING.left + ci * groupWidth + groupWidth / 2;
164977
+ const label = doc$2.createElementNS(SVG_NS, "text");
164978
+ label.setAttribute("x", String(labelX));
164979
+ label.setAttribute("y", String(CHART_PADDING.top + plotHeight + 16));
164980
+ label.setAttribute("text-anchor", "middle");
164981
+ label.setAttribute("font-size", String(fontSize$1));
164982
+ label.setAttribute("fill", LABEL_COLOR);
164983
+ label.setAttribute("font-family", FONT_FAMILY);
164984
+ label.textContent = categories[ci] ?? "";
164985
+ svg2.appendChild(label);
164986
+ }
164987
+ }
164988
+ function renderValueTicks(doc$2, svg2, layout, height) {
164989
+ const { plotWidth, plotHeight, valueRange, minValue } = layout;
164990
+ const tickStep = valueRange / VALUE_TICK_COUNT;
164991
+ const fontSize$1 = Math.max(8, Math.min(11, height / 30));
164992
+ for (let i$1 = 0;i$1 <= VALUE_TICK_COUNT; i$1++) {
164993
+ const tickValue = minValue + tickStep * i$1;
164994
+ const tickY = CHART_PADDING.top + plotHeight - plotHeight * (tickValue - minValue) / valueRange;
164995
+ const label = doc$2.createElementNS(SVG_NS, "text");
164996
+ label.setAttribute("x", String(CHART_PADDING.left - 6));
164997
+ label.setAttribute("y", String(tickY + 3));
164998
+ label.setAttribute("text-anchor", "end");
164999
+ label.setAttribute("font-size", String(fontSize$1));
165000
+ label.setAttribute("fill", TICK_LABEL_COLOR);
165001
+ label.setAttribute("font-family", FONT_FAMILY);
165002
+ label.textContent = formatTickValue(tickValue);
165003
+ svg2.appendChild(label);
165004
+ if (i$1 > 0 && i$1 < VALUE_TICK_COUNT) {
165005
+ const gridLine = doc$2.createElementNS(SVG_NS, "line");
165006
+ gridLine.setAttribute("x1", String(CHART_PADDING.left));
165007
+ gridLine.setAttribute("y1", String(tickY));
165008
+ gridLine.setAttribute("x2", String(CHART_PADDING.left + plotWidth));
165009
+ gridLine.setAttribute("y2", String(tickY));
165010
+ gridLine.setAttribute("stroke", GRID_COLOR);
165011
+ gridLine.setAttribute("stroke-width", "0.5");
165012
+ svg2.appendChild(gridLine);
165013
+ }
165014
+ }
165015
+ }
165016
+ function renderLegend(doc$2, svg2, series, height) {
165017
+ const legendY = height - 12;
165018
+ let legendX = CHART_PADDING.left;
165019
+ for (let si = 0;si < series.length; si++) {
165020
+ const s2 = series[si];
165021
+ const color2 = SERIES_COLORS[si % SERIES_COLORS.length];
165022
+ const swatch = doc$2.createElementNS(SVG_NS, "rect");
165023
+ swatch.setAttribute("x", String(legendX));
165024
+ swatch.setAttribute("y", String(legendY - 8));
165025
+ swatch.setAttribute("width", "10");
165026
+ swatch.setAttribute("height", "10");
165027
+ swatch.setAttribute("fill", color2);
165028
+ svg2.appendChild(swatch);
165029
+ const label = doc$2.createElementNS(SVG_NS, "text");
165030
+ label.setAttribute("x", String(legendX + 14));
165031
+ label.setAttribute("y", String(legendY));
165032
+ label.setAttribute("font-size", "10");
165033
+ label.setAttribute("fill", LABEL_COLOR);
165034
+ label.setAttribute("font-family", FONT_FAMILY);
165035
+ label.textContent = s2.name;
165036
+ svg2.appendChild(label);
165037
+ legendX += 14 + s2.name.length * 6 + 16;
165038
+ }
165039
+ }
165040
+ function renderTruncationIndicator(doc$2, svg2, width) {
165041
+ const indicator = doc$2.createElementNS(SVG_NS, "text");
165042
+ indicator.setAttribute("x", String(width - 8));
165043
+ indicator.setAttribute("y", "14");
165044
+ indicator.setAttribute("text-anchor", "end");
165045
+ indicator.setAttribute("font-size", "10");
165046
+ indicator.setAttribute("fill", PLACEHOLDER_TEXT_COLOR);
165047
+ indicator.setAttribute("font-family", FONT_FAMILY);
165048
+ indicator.textContent = "Data truncated for display";
165049
+ svg2.appendChild(indicator);
165050
+ }
165051
+ function toCartesianLayout(width, height, series, forceZeroMin = false) {
165052
+ const plotWidth = Math.max(1, width - CHART_PADDING.left - CHART_PADDING.right);
165053
+ const plotHeight = Math.max(1, height - CHART_PADDING.top - CHART_PADDING.bottom);
165054
+ const values = series.flatMap((s2) => s2.values).filter((v) => Number.isFinite(v));
165055
+ let minValue = values.length ? Math.min(...values) : 0;
165056
+ let maxValue = values.length ? Math.max(...values) : 1;
165057
+ if (forceZeroMin) {
165058
+ minValue = Math.min(0, minValue);
165059
+ maxValue = Math.max(0, maxValue);
165060
+ }
165061
+ if (maxValue === minValue) {
165062
+ minValue -= 1;
165063
+ maxValue += 1;
165064
+ }
165065
+ const valueRange = Math.max(1, maxValue - minValue);
165066
+ const zeroRatio = (0 - minValue) / valueRange;
165067
+ const baselineRatio = Math.max(0, Math.min(1, zeroRatio));
165068
+ const baselineY = CHART_PADDING.top + plotHeight - plotHeight * baselineRatio;
165069
+ const categoryCount = Math.max(1, series[0]?.categories?.length ?? series[0]?.values?.length ?? 1);
165070
+ return {
165071
+ plotWidth,
165072
+ plotHeight,
165073
+ minValue,
165074
+ maxValue,
165075
+ valueRange,
165076
+ baselineY,
165077
+ categoryCount
165078
+ };
165079
+ }
165080
+ function pointX(layout, index2) {
165081
+ if (layout.categoryCount <= 1)
165082
+ return CHART_PADDING.left + layout.plotWidth / 2;
165083
+ return CHART_PADDING.left + layout.plotWidth * index2 / (layout.categoryCount - 1);
165084
+ }
165085
+ function pointY(layout, value) {
165086
+ return CHART_PADDING.top + layout.plotHeight - (value - layout.minValue) / layout.valueRange * layout.plotHeight;
165087
+ }
165088
+ function renderCartesianAxes(doc$2, svg2, layout) {
165089
+ const vAxis = doc$2.createElementNS(SVG_NS, "line");
165090
+ vAxis.setAttribute("x1", String(CHART_PADDING.left));
165091
+ vAxis.setAttribute("y1", String(CHART_PADDING.top));
165092
+ vAxis.setAttribute("x2", String(CHART_PADDING.left));
165093
+ vAxis.setAttribute("y2", String(CHART_PADDING.top + layout.plotHeight));
165094
+ vAxis.setAttribute("stroke", AXIS_COLOR);
165095
+ vAxis.setAttribute("stroke-width", "1");
165096
+ svg2.appendChild(vAxis);
165097
+ const hAxis = doc$2.createElementNS(SVG_NS, "line");
165098
+ hAxis.setAttribute("x1", String(CHART_PADDING.left));
165099
+ hAxis.setAttribute("y1", String(layout.baselineY));
165100
+ hAxis.setAttribute("x2", String(CHART_PADDING.left + layout.plotWidth));
165101
+ hAxis.setAttribute("y2", String(layout.baselineY));
165102
+ hAxis.setAttribute("stroke", AXIS_COLOR);
165103
+ hAxis.setAttribute("stroke-width", "1");
165104
+ svg2.appendChild(hAxis);
165105
+ }
165106
+ function renderPointCategoryLabels(doc$2, svg2, categories, layout, width) {
165107
+ const labels = categories.length ? categories : Array.from({ length: layout.categoryCount }, (_$1, i$1) => String(i$1 + 1));
165108
+ const categoryCount = Math.max(1, labels.length);
165109
+ const fontSize$1 = Math.max(8, Math.min(12, width / categoryCount / 4));
165110
+ for (let i$1 = 0;i$1 < labels.length; i$1++) {
165111
+ const label = doc$2.createElementNS(SVG_NS, "text");
165112
+ label.setAttribute("x", String(pointX(layout, i$1)));
165113
+ label.setAttribute("y", String(CHART_PADDING.top + layout.plotHeight + 16));
165114
+ label.setAttribute("text-anchor", "middle");
165115
+ label.setAttribute("font-size", String(fontSize$1));
165116
+ label.setAttribute("fill", LABEL_COLOR);
165117
+ label.setAttribute("font-family", FONT_FAMILY);
165118
+ label.textContent = labels[i$1] ?? "";
165119
+ svg2.appendChild(label);
165120
+ }
165121
+ }
165122
+ function renderCartesianValueTicks(doc$2, svg2, layout, height) {
165123
+ const tickStep = layout.valueRange / VALUE_TICK_COUNT;
165124
+ const fontSize$1 = Math.max(8, Math.min(11, height / 30));
165125
+ for (let i$1 = 0;i$1 <= VALUE_TICK_COUNT; i$1++) {
165126
+ const tickValue = layout.minValue + tickStep * i$1;
165127
+ const tickY = CHART_PADDING.top + layout.plotHeight - layout.plotHeight * (tickValue - layout.minValue) / layout.valueRange;
165128
+ const label = doc$2.createElementNS(SVG_NS, "text");
165129
+ label.setAttribute("x", String(CHART_PADDING.left - 6));
165130
+ label.setAttribute("y", String(tickY + 3));
165131
+ label.setAttribute("text-anchor", "end");
165132
+ label.setAttribute("font-size", String(fontSize$1));
165133
+ label.setAttribute("fill", TICK_LABEL_COLOR);
165134
+ label.setAttribute("font-family", FONT_FAMILY);
165135
+ label.textContent = formatTickValue(tickValue);
165136
+ svg2.appendChild(label);
165137
+ if (i$1 > 0 && i$1 < VALUE_TICK_COUNT) {
165138
+ const grid = doc$2.createElementNS(SVG_NS, "line");
165139
+ grid.setAttribute("x1", String(CHART_PADDING.left));
165140
+ grid.setAttribute("y1", String(tickY));
165141
+ grid.setAttribute("x2", String(CHART_PADDING.left + layout.plotWidth));
165142
+ grid.setAttribute("y2", String(tickY));
165143
+ grid.setAttribute("stroke", GRID_COLOR);
165144
+ grid.setAttribute("stroke-width", "0.5");
165145
+ svg2.appendChild(grid);
165146
+ }
165147
+ }
165148
+ }
165149
+ function toXYPoints(series) {
165150
+ const yValues = series.values;
165151
+ const xValues = series.xValues?.length ? series.xValues : yValues.map((_$1, index2) => index2 + 1);
165152
+ const sizes = series.bubbleSizes ?? [];
165153
+ const count = Math.min(xValues.length, yValues.length);
165154
+ const points = [];
165155
+ for (let i$1 = 0;i$1 < count; i$1++) {
165156
+ const x = xValues[i$1];
165157
+ const y$1 = yValues[i$1];
165158
+ if (!Number.isFinite(x) || !Number.isFinite(y$1))
165159
+ continue;
165160
+ const size$2 = sizes[i$1];
165161
+ points.push({
165162
+ x,
165163
+ y: y$1,
165164
+ ...Number.isFinite(size$2) ? { size: size$2 } : {}
165165
+ });
165166
+ }
165167
+ return points;
165168
+ }
165169
+ function toXYLayout(width, height, points, forceZeroMin = false) {
165170
+ const plotWidth = Math.max(1, width - CHART_PADDING.left - CHART_PADDING.right);
165171
+ const plotHeight = Math.max(1, height - CHART_PADDING.top - CHART_PADDING.bottom);
165172
+ let minX = points.length ? Math.min(...points.map((point5) => point5.x)) : 0;
165173
+ let maxX = points.length ? Math.max(...points.map((point5) => point5.x)) : 1;
165174
+ let minY = points.length ? Math.min(...points.map((point5) => point5.y)) : 0;
165175
+ let maxY = points.length ? Math.max(...points.map((point5) => point5.y)) : 1;
165176
+ if (forceZeroMin) {
165177
+ minX = Math.min(0, minX);
165178
+ maxX = Math.max(0, maxX);
165179
+ minY = Math.min(0, minY);
165180
+ maxY = Math.max(0, maxY);
165181
+ }
165182
+ if (maxX === minX) {
165183
+ minX -= 1;
165184
+ maxX += 1;
165185
+ }
165186
+ if (maxY === minY) {
165187
+ minY -= 1;
165188
+ maxY += 1;
165189
+ }
165190
+ const xRange = Math.max(1, maxX - minX);
165191
+ const yRange = Math.max(1, maxY - minY);
165192
+ const axisXRatio = Math.max(0, Math.min(1, (0 - minX) / xRange));
165193
+ const axisYRatio = Math.max(0, Math.min(1, (0 - minY) / yRange));
165194
+ const axisX = CHART_PADDING.left + plotWidth * axisXRatio;
165195
+ const axisY = CHART_PADDING.top + plotHeight - plotHeight * axisYRatio;
165196
+ return {
165197
+ plotWidth,
165198
+ plotHeight,
165199
+ minX,
165200
+ maxX,
165201
+ xRange,
165202
+ minY,
165203
+ maxY,
165204
+ yRange,
165205
+ axisX,
165206
+ axisY
165207
+ };
165208
+ }
165209
+ function xyToSvgX(layout, xValue) {
165210
+ return CHART_PADDING.left + (xValue - layout.minX) / layout.xRange * layout.plotWidth;
165211
+ }
165212
+ function xyToSvgY(layout, yValue) {
165213
+ return CHART_PADDING.top + layout.plotHeight - (yValue - layout.minY) / layout.yRange * layout.plotHeight;
165214
+ }
165215
+ function renderXYAxes(doc$2, svg2, layout) {
165216
+ const yAxis = doc$2.createElementNS(SVG_NS, "line");
165217
+ yAxis.setAttribute("x1", String(layout.axisX));
165218
+ yAxis.setAttribute("y1", String(CHART_PADDING.top));
165219
+ yAxis.setAttribute("x2", String(layout.axisX));
165220
+ yAxis.setAttribute("y2", String(CHART_PADDING.top + layout.plotHeight));
165221
+ yAxis.setAttribute("stroke", AXIS_COLOR);
165222
+ yAxis.setAttribute("stroke-width", "1");
165223
+ svg2.appendChild(yAxis);
165224
+ const xAxis = doc$2.createElementNS(SVG_NS, "line");
165225
+ xAxis.setAttribute("x1", String(CHART_PADDING.left));
165226
+ xAxis.setAttribute("y1", String(layout.axisY));
165227
+ xAxis.setAttribute("x2", String(CHART_PADDING.left + layout.plotWidth));
165228
+ xAxis.setAttribute("y2", String(layout.axisY));
165229
+ xAxis.setAttribute("stroke", AXIS_COLOR);
165230
+ xAxis.setAttribute("stroke-width", "1");
165231
+ svg2.appendChild(xAxis);
165232
+ }
165233
+ function renderXYTicks(doc$2, svg2, layout, height) {
165234
+ const fontSize$1 = Math.max(8, Math.min(11, height / 30));
165235
+ for (let i$1 = 0;i$1 <= VALUE_TICK_COUNT; i$1++) {
165236
+ const tickRatio = i$1 / VALUE_TICK_COUNT;
165237
+ const yValue = layout.minY + layout.yRange * tickRatio;
165238
+ const y$1 = CHART_PADDING.top + layout.plotHeight - layout.plotHeight * tickRatio;
165239
+ const yLabel = doc$2.createElementNS(SVG_NS, "text");
165240
+ yLabel.setAttribute("x", String(CHART_PADDING.left - 6));
165241
+ yLabel.setAttribute("y", String(y$1 + 3));
165242
+ yLabel.setAttribute("text-anchor", "end");
165243
+ yLabel.setAttribute("font-size", String(fontSize$1));
165244
+ yLabel.setAttribute("fill", TICK_LABEL_COLOR);
165245
+ yLabel.setAttribute("font-family", FONT_FAMILY);
165246
+ yLabel.textContent = formatTickValue(yValue);
165247
+ svg2.appendChild(yLabel);
165248
+ if (i$1 > 0 && i$1 < VALUE_TICK_COUNT) {
165249
+ const grid = doc$2.createElementNS(SVG_NS, "line");
165250
+ grid.setAttribute("x1", String(CHART_PADDING.left));
165251
+ grid.setAttribute("y1", String(y$1));
165252
+ grid.setAttribute("x2", String(CHART_PADDING.left + layout.plotWidth));
165253
+ grid.setAttribute("y2", String(y$1));
165254
+ grid.setAttribute("stroke", GRID_COLOR);
165255
+ grid.setAttribute("stroke-width", "0.5");
165256
+ svg2.appendChild(grid);
165257
+ }
165258
+ const xValue = layout.minX + layout.xRange * tickRatio;
165259
+ const x = CHART_PADDING.left + layout.plotWidth * tickRatio;
165260
+ const xLabel = doc$2.createElementNS(SVG_NS, "text");
165261
+ xLabel.setAttribute("x", String(x));
165262
+ xLabel.setAttribute("y", String(CHART_PADDING.top + layout.plotHeight + 16));
165263
+ xLabel.setAttribute("text-anchor", "middle");
165264
+ xLabel.setAttribute("font-size", String(fontSize$1));
165265
+ xLabel.setAttribute("fill", TICK_LABEL_COLOR);
165266
+ xLabel.setAttribute("font-family", FONT_FAMILY);
165267
+ xLabel.textContent = formatTickValue(xValue);
165268
+ svg2.appendChild(xLabel);
165269
+ }
165270
+ }
165271
+ function estimateScatterBubbleElements(pointsBySeries, hasLegend) {
165272
+ const points = pointsBySeries.reduce((sum, seriesPoints) => sum + seriesPoints.length, 0);
165273
+ const axes = 2;
165274
+ const ticks = (VALUE_TICK_COUNT + 1) * 2;
165275
+ const gridLines = Math.max(0, VALUE_TICK_COUNT - 1);
165276
+ const legend = hasLegend ? pointsBySeries.length * 2 : 0;
165277
+ return points + axes + ticks + gridLines + legend;
165278
+ }
165279
+ function renderScatterChart(doc$2, container, chart, geometry) {
165280
+ const { width, height } = geometry;
165281
+ const { series, truncated } = applyGuardrails(chart);
165282
+ const pointsBySeries = series.map(toXYPoints);
165283
+ const allPoints = pointsBySeries.flat();
165284
+ if (allPoints.length === 0)
165285
+ return createChartPlaceholder(doc$2, container, "No chart data");
165286
+ const hasLegend = chart.legendPosition !== undefined;
165287
+ const estimated = estimateScatterBubbleElements(pointsBySeries, hasLegend);
165288
+ if (estimated > SVG_ELEMENT_BUDGET)
165289
+ return createChartPlaceholder(doc$2, container, `Chart too complex for inline rendering (${estimated} elements)`);
165290
+ const layout = toXYLayout(width, height, allPoints, false);
165291
+ const svg2 = doc$2.createElementNS(SVG_NS, "svg");
165292
+ svg2.setAttribute("viewBox", `0 0 ${width} ${height}`);
165293
+ svg2.setAttribute("width", "100%");
165294
+ svg2.setAttribute("height", "100%");
165295
+ svg2.style.display = "block";
165296
+ renderXYAxes(doc$2, svg2, layout);
165297
+ renderXYTicks(doc$2, svg2, layout, height);
165298
+ for (let si = 0;si < pointsBySeries.length; si++) {
165299
+ const points = pointsBySeries[si];
165300
+ const color2 = SERIES_COLORS[si % SERIES_COLORS.length];
165301
+ for (const point5 of points) {
165302
+ const marker = doc$2.createElementNS(SVG_NS, "circle");
165303
+ marker.setAttribute("cx", String(xyToSvgX(layout, point5.x)));
165304
+ marker.setAttribute("cy", String(xyToSvgY(layout, point5.y)));
165305
+ marker.setAttribute("r", "3");
165306
+ marker.setAttribute("fill", color2);
165307
+ marker.setAttribute("fill-opacity", "0.85");
165308
+ svg2.appendChild(marker);
165309
+ }
165310
+ }
165311
+ if (hasLegend)
165312
+ renderLegend(doc$2, svg2, series, height);
165313
+ if (truncated)
165314
+ renderTruncationIndicator(doc$2, svg2, width);
165315
+ container.appendChild(svg2);
165316
+ return container;
165317
+ }
165318
+ function renderBubbleChart(doc$2, container, chart, geometry) {
165319
+ const { width, height } = geometry;
165320
+ const { series, truncated } = applyGuardrails(chart);
165321
+ const pointsBySeries = series.map(toXYPoints);
165322
+ const allPoints = pointsBySeries.flat();
165323
+ if (allPoints.length === 0)
165324
+ return createChartPlaceholder(doc$2, container, "No chart data");
165325
+ const hasLegend = chart.legendPosition !== undefined;
165326
+ const estimated = estimateScatterBubbleElements(pointsBySeries, hasLegend);
165327
+ if (estimated > SVG_ELEMENT_BUDGET)
165328
+ return createChartPlaceholder(doc$2, container, `Chart too complex for inline rendering (${estimated} elements)`);
165329
+ const layout = toXYLayout(width, height, allPoints, false);
165330
+ const allSizes = allPoints.map((point5) => point5.size).filter((size$2) => size$2 != null && size$2 > 0);
165331
+ const maxBubbleSize = allSizes.length ? Math.max(...allSizes) : 1;
165332
+ const svg2 = doc$2.createElementNS(SVG_NS, "svg");
165333
+ svg2.setAttribute("viewBox", `0 0 ${width} ${height}`);
165334
+ svg2.setAttribute("width", "100%");
165335
+ svg2.setAttribute("height", "100%");
165336
+ svg2.style.display = "block";
165337
+ renderXYAxes(doc$2, svg2, layout);
165338
+ renderXYTicks(doc$2, svg2, layout, height);
165339
+ for (let si = 0;si < pointsBySeries.length; si++) {
165340
+ const points = pointsBySeries[si];
165341
+ const color2 = SERIES_COLORS[si % SERIES_COLORS.length];
165342
+ for (const point5 of points) {
165343
+ const size$2 = point5.size && point5.size > 0 ? point5.size : maxBubbleSize * 0.5;
165344
+ const radius = maxBubbleSize > 0 ? 4 + size$2 / maxBubbleSize * 10 : 6;
165345
+ const bubble = doc$2.createElementNS(SVG_NS, "circle");
165346
+ bubble.setAttribute("cx", String(xyToSvgX(layout, point5.x)));
165347
+ bubble.setAttribute("cy", String(xyToSvgY(layout, point5.y)));
165348
+ bubble.setAttribute("r", String(Math.max(2, radius)));
165349
+ bubble.setAttribute("fill", color2);
165350
+ bubble.setAttribute("fill-opacity", "0.45");
165351
+ bubble.setAttribute("stroke", color2);
165352
+ bubble.setAttribute("stroke-width", "1");
165353
+ svg2.appendChild(bubble);
165354
+ }
165355
+ }
165356
+ if (hasLegend)
165357
+ renderLegend(doc$2, svg2, series, height);
165358
+ if (truncated)
165359
+ renderTruncationIndicator(doc$2, svg2, width);
165360
+ container.appendChild(svg2);
165361
+ return container;
165362
+ }
165363
+ function estimateRadarElements(series, categoryCount, hasLegend) {
165364
+ const grid = 4 + categoryCount;
165365
+ const labels = categoryCount;
165366
+ const seriesElements = series.reduce((sum, s2) => sum + 1 + Math.min(categoryCount, s2.values.length), 0);
165367
+ const legend = hasLegend ? series.length * 2 : 0;
165368
+ return grid + labels + seriesElements + legend;
165369
+ }
165370
+ function renderRadarChart(doc$2, container, chart, geometry) {
165371
+ const { width, height } = geometry;
165372
+ const { series, truncated } = applyGuardrails(chart);
165373
+ const categories = series[0]?.categories ?? [];
165374
+ const categoryCount = Math.max(3, categories.length, ...series.map((oneSeries) => oneSeries.values.length));
165375
+ const hasLegend = chart.legendPosition !== undefined;
165376
+ const estimated = estimateRadarElements(series, categoryCount, hasLegend);
165377
+ if (estimated > SVG_ELEMENT_BUDGET)
165378
+ return createChartPlaceholder(doc$2, container, `Chart too complex for inline rendering (${estimated} elements)`);
165379
+ const allValues = series.flatMap((oneSeries) => oneSeries.values).filter((value) => Number.isFinite(value));
165380
+ const maxValue = allValues.length ? Math.max(...allValues) : 1;
165381
+ const minValue = allValues.length ? Math.min(...allValues) : 0;
165382
+ const valueRange = Math.max(1, maxValue - Math.min(0, minValue));
165383
+ const svg2 = doc$2.createElementNS(SVG_NS, "svg");
165384
+ svg2.setAttribute("viewBox", `0 0 ${width} ${height}`);
165385
+ svg2.setAttribute("width", "100%");
165386
+ svg2.setAttribute("height", "100%");
165387
+ svg2.style.display = "block";
165388
+ const legendSpace = hasLegend ? 34 : 10;
165389
+ const radius = Math.max(10, Math.min(width - 60, height - legendSpace - 60) / 2);
165390
+ const centerX = width / 2;
165391
+ const centerY = CHART_PADDING.top + (height - CHART_PADDING.top - legendSpace) / 2;
165392
+ const ringCount = 4;
165393
+ for (let ring = 1;ring <= ringCount; ring++) {
165394
+ const ringRadius = radius * ring / ringCount;
165395
+ const ringPoints = [];
165396
+ for (let i$1 = 0;i$1 < categoryCount; i$1++) {
165397
+ const angle = -Math.PI / 2 + i$1 * Math.PI * 2 / categoryCount;
165398
+ ringPoints.push(`${centerX + ringRadius * Math.cos(angle)},${centerY + ringRadius * Math.sin(angle)}`);
165399
+ }
165400
+ const polygon = doc$2.createElementNS(SVG_NS, "polygon");
165401
+ polygon.setAttribute("points", ringPoints.join(" "));
165402
+ polygon.setAttribute("fill", "none");
165403
+ polygon.setAttribute("stroke", GRID_COLOR);
165404
+ polygon.setAttribute("stroke-width", "0.8");
165405
+ svg2.appendChild(polygon);
165406
+ }
165407
+ for (let i$1 = 0;i$1 < categoryCount; i$1++) {
165408
+ const angle = -Math.PI / 2 + i$1 * Math.PI * 2 / categoryCount;
165409
+ const x = centerX + radius * Math.cos(angle);
165410
+ const y$1 = centerY + radius * Math.sin(angle);
165411
+ const spoke = doc$2.createElementNS(SVG_NS, "line");
165412
+ spoke.setAttribute("x1", String(centerX));
165413
+ spoke.setAttribute("y1", String(centerY));
165414
+ spoke.setAttribute("x2", String(x));
165415
+ spoke.setAttribute("y2", String(y$1));
165416
+ spoke.setAttribute("stroke", GRID_COLOR);
165417
+ spoke.setAttribute("stroke-width", "0.8");
165418
+ svg2.appendChild(spoke);
165419
+ const labelRadius = radius + 14;
165420
+ const labelX = centerX + labelRadius * Math.cos(angle);
165421
+ const labelY = centerY + labelRadius * Math.sin(angle);
165422
+ const label = doc$2.createElementNS(SVG_NS, "text");
165423
+ label.setAttribute("x", String(labelX));
165424
+ label.setAttribute("y", String(labelY));
165425
+ label.setAttribute("font-size", "10");
165426
+ label.setAttribute("fill", LABEL_COLOR);
165427
+ label.setAttribute("font-family", FONT_FAMILY);
165428
+ label.setAttribute("text-anchor", Math.abs(Math.cos(angle)) < 0.2 ? "middle" : Math.cos(angle) > 0 ? "start" : "end");
165429
+ label.textContent = categories[i$1] ?? `Category ${i$1 + 1}`;
165430
+ svg2.appendChild(label);
165431
+ }
165432
+ for (let si = 0;si < series.length; si++) {
165433
+ const oneSeries = series[si];
165434
+ const color2 = SERIES_COLORS[si % SERIES_COLORS.length];
165435
+ const points = [];
165436
+ const pointPositions = [];
165437
+ const pointCount = Math.min(categoryCount, oneSeries.values.length);
165438
+ for (let i$1 = 0;i$1 < pointCount; i$1++) {
165439
+ const value = oneSeries.values[i$1] ?? 0;
165440
+ const pointRadius = Math.max(0, (value - Math.min(0, minValue)) / valueRange) * radius;
165441
+ const angle = -Math.PI / 2 + i$1 * Math.PI * 2 / categoryCount;
165442
+ const x = centerX + pointRadius * Math.cos(angle);
165443
+ const y$1 = centerY + pointRadius * Math.sin(angle);
165444
+ points.push(`${x},${y$1}`);
165445
+ pointPositions.push({
165446
+ x,
165447
+ y: y$1
165448
+ });
165449
+ }
165450
+ if (points.length > 0) {
165451
+ const polygon = doc$2.createElementNS(SVG_NS, "polygon");
165452
+ polygon.setAttribute("points", points.join(" "));
165453
+ polygon.setAttribute("fill", color2);
165454
+ polygon.setAttribute("fill-opacity", "0.18");
165455
+ polygon.setAttribute("stroke", color2);
165456
+ polygon.setAttribute("stroke-width", "1.8");
165457
+ svg2.appendChild(polygon);
165458
+ }
165459
+ for (const point5 of pointPositions) {
165460
+ const marker = doc$2.createElementNS(SVG_NS, "circle");
165461
+ marker.setAttribute("cx", String(point5.x));
165462
+ marker.setAttribute("cy", String(point5.y));
165463
+ marker.setAttribute("r", "2.5");
165464
+ marker.setAttribute("fill", color2);
165465
+ svg2.appendChild(marker);
165466
+ }
165467
+ }
165468
+ if (hasLegend)
165469
+ renderLegend(doc$2, svg2, series, height);
165470
+ if (truncated)
165471
+ renderTruncationIndicator(doc$2, svg2, width);
165472
+ container.appendChild(svg2);
165473
+ return container;
165474
+ }
165475
+ function estimateLineAreaElements(series, categories, hasLegend, withMarkers) {
165476
+ const points = series.reduce((sum, s2) => sum + s2.values.length, 0);
165477
+ const pathPerSeries = series.length;
165478
+ const markerCount = withMarkers ? points : 0;
165479
+ const axes = 2;
165480
+ const valueTicks = (VALUE_TICK_COUNT + 1) * 2;
165481
+ const categoryLabels = categories.length;
165482
+ const legend = hasLegend ? series.length * 2 : 0;
165483
+ return pathPerSeries + markerCount + axes + valueTicks + categoryLabels + legend;
165484
+ }
165485
+ function normalizePieSlices(series) {
165486
+ let truncated = false;
165487
+ const maxCount = Math.min(series.values.length, MAX_POINTS_PER_SERIES);
165488
+ if (series.values.length > maxCount)
165489
+ truncated = true;
165490
+ const slices = [];
165491
+ for (let i$1 = 0;i$1 < maxCount; i$1++) {
165492
+ const raw = Number(series.values[i$1]);
165493
+ const value = Number.isFinite(raw) && raw > 0 ? raw : 0;
165494
+ slices.push({
165495
+ label: series.categories[i$1] ?? `Category ${i$1 + 1}`,
165496
+ value,
165497
+ color: SERIES_COLORS[i$1 % SERIES_COLORS.length]
165498
+ });
165499
+ }
165500
+ return {
165501
+ slices,
165502
+ truncated
165503
+ };
165504
+ }
165505
+ function renderPieSlices(doc$2, svg2, slices, centerX, centerY, radius) {
165506
+ const total = slices.reduce((sum, slice2) => sum + slice2.value, 0);
165507
+ if (total <= 0)
165508
+ return;
165509
+ let start$1 = -Math.PI / 2;
165510
+ for (const slice2 of slices) {
165511
+ if (slice2.value <= 0)
165512
+ continue;
165513
+ const sweep = slice2.value / total * Math.PI * 2;
165514
+ if (sweep >= Math.PI * 2 - 0.0001) {
165515
+ const full = doc$2.createElementNS(SVG_NS, "circle");
165516
+ full.setAttribute("cx", String(centerX));
165517
+ full.setAttribute("cy", String(centerY));
165518
+ full.setAttribute("r", String(radius));
165519
+ full.setAttribute("fill", slice2.color);
165520
+ full.setAttribute("stroke", "#fff");
165521
+ full.setAttribute("stroke-width", String(Math.max(1, radius * 0.01)));
165522
+ svg2.appendChild(full);
165523
+ break;
165524
+ }
165525
+ const end$1 = start$1 + sweep;
165526
+ const x1 = centerX + radius * Math.cos(start$1);
165527
+ const y1 = centerY + radius * Math.sin(start$1);
165528
+ const x2 = centerX + radius * Math.cos(end$1);
165529
+ const y2 = centerY + radius * Math.sin(end$1);
165530
+ const largeArc = sweep > Math.PI ? 1 : 0;
165531
+ const path2 = doc$2.createElementNS(SVG_NS, "path");
165532
+ path2.setAttribute("d", `M ${centerX} ${centerY} L ${x1} ${y1} A ${radius} ${radius} 0 ${largeArc} 1 ${x2} ${y2} Z`);
165533
+ path2.setAttribute("fill", slice2.color);
165534
+ path2.setAttribute("stroke", "#fff");
165535
+ path2.setAttribute("stroke-width", String(Math.max(1, radius * 0.01)));
165536
+ svg2.appendChild(path2);
165537
+ start$1 = end$1;
165538
+ }
165539
+ }
165540
+ function renderPieLegend(doc$2, svg2, slices, width, height) {
165541
+ const totalWidth = slices.reduce((acc, slice2) => acc + 14 + slice2.label.length * 6 + 16, 0);
165542
+ let legendX = Math.max(10, (width - totalWidth) / 2);
165543
+ const legendY = height - 14;
165544
+ for (const slice2 of slices) {
165545
+ const swatch = doc$2.createElementNS(SVG_NS, "rect");
165546
+ swatch.setAttribute("x", String(legendX));
165547
+ swatch.setAttribute("y", String(legendY - 8));
165548
+ swatch.setAttribute("width", "10");
165549
+ swatch.setAttribute("height", "10");
165550
+ swatch.setAttribute("fill", slice2.color);
165551
+ svg2.appendChild(swatch);
165552
+ const label = doc$2.createElementNS(SVG_NS, "text");
165553
+ label.setAttribute("x", String(legendX + 14));
165554
+ label.setAttribute("y", String(legendY));
165555
+ label.setAttribute("font-size", "10");
165556
+ label.setAttribute("fill", LABEL_COLOR);
165557
+ label.setAttribute("font-family", FONT_FAMILY);
165558
+ label.textContent = slice2.label;
165559
+ svg2.appendChild(label);
165560
+ legendX += 14 + slice2.label.length * 6 + 16;
165561
+ }
165562
+ }
165563
+ function renderPieChart(doc$2, container, chart, geometry) {
165564
+ const series = chart.series[0];
165565
+ if (!series)
165566
+ return createChartPlaceholder(doc$2, container, "No chart data");
165567
+ const { slices, truncated } = normalizePieSlices(series);
165568
+ if (slices.reduce((sum, slice2) => sum + slice2.value, 0) <= 0)
165569
+ return createChartPlaceholder(doc$2, container, "No chart data");
165570
+ if (slices.length * 3 > SVG_ELEMENT_BUDGET)
165571
+ return createChartPlaceholder(doc$2, container, "Chart too large");
165572
+ const { width, height } = geometry;
165573
+ const hasLegend = chart.legendPosition !== undefined;
165574
+ const title = series.name?.trim() || "";
165575
+ const hasTitle = title.length > 0;
165576
+ const titleSpace = hasTitle ? 34 : 10;
165577
+ const legendSpace = hasLegend ? 40 : 10;
165578
+ const plotWidth = Math.max(1, width - 20);
165579
+ const plotHeight = Math.max(1, height - titleSpace - legendSpace);
165580
+ const centerX = width / 2;
165581
+ const centerY = titleSpace + plotHeight / 2;
165582
+ const radius = Math.max(8, Math.min(plotWidth, plotHeight) * 0.45);
165583
+ const svg2 = doc$2.createElementNS(SVG_NS, "svg");
165584
+ svg2.setAttribute("viewBox", `0 0 ${width} ${height}`);
165585
+ svg2.setAttribute("width", "100%");
165586
+ svg2.setAttribute("height", "100%");
165587
+ svg2.style.display = "block";
165588
+ if (hasTitle) {
165589
+ const titleEl = doc$2.createElementNS(SVG_NS, "text");
165590
+ titleEl.setAttribute("x", String(centerX));
165591
+ titleEl.setAttribute("y", "24");
165592
+ titleEl.setAttribute("text-anchor", "middle");
165593
+ titleEl.setAttribute("font-size", String(Math.max(12, Math.min(22, width / 18))));
165594
+ titleEl.setAttribute("fill", AXIS_COLOR);
165595
+ titleEl.setAttribute("font-family", FONT_FAMILY);
165596
+ titleEl.textContent = title;
165597
+ svg2.appendChild(titleEl);
165598
+ }
165599
+ renderPieSlices(doc$2, svg2, slices, centerX, centerY, radius);
165600
+ if (hasLegend)
165601
+ renderPieLegend(doc$2, svg2, slices, width, height);
165602
+ if (truncated)
165603
+ renderTruncationIndicator(doc$2, svg2, width);
165604
+ container.appendChild(svg2);
165605
+ return container;
165606
+ }
165607
+ function renderLineChart(doc$2, container, chart, geometry) {
165608
+ const { width, height } = geometry;
165609
+ const { series, truncated } = applyGuardrails(chart);
165610
+ const categories = series[0]?.categories ?? [];
165611
+ const hasLegend = chart.legendPosition !== undefined;
165612
+ const estimated = estimateLineAreaElements(series, categories, hasLegend, true);
165613
+ if (estimated > SVG_ELEMENT_BUDGET)
165614
+ return createChartPlaceholder(doc$2, container, `Chart too complex for inline rendering (${estimated} elements)`);
165615
+ const layout = toCartesianLayout(width, height, series, false);
165616
+ const svg2 = doc$2.createElementNS(SVG_NS, "svg");
165617
+ svg2.setAttribute("viewBox", `0 0 ${width} ${height}`);
165618
+ svg2.setAttribute("width", "100%");
165619
+ svg2.setAttribute("height", "100%");
165620
+ svg2.style.display = "block";
165621
+ renderCartesianAxes(doc$2, svg2, layout);
165622
+ renderCartesianValueTicks(doc$2, svg2, layout, height);
165623
+ renderPointCategoryLabels(doc$2, svg2, categories, layout, width);
165624
+ for (let si = 0;si < series.length; si++) {
165625
+ const s2 = series[si];
165626
+ const color2 = SERIES_COLORS[si % SERIES_COLORS.length];
165627
+ const points = [];
165628
+ for (let i$1 = 0;i$1 < s2.values.length; i$1++) {
165629
+ const x = pointX(layout, i$1);
165630
+ const y$1 = pointY(layout, s2.values[i$1] ?? 0);
165631
+ points.push(`${x},${y$1}`);
165632
+ }
165633
+ if (points.length === 0)
165634
+ continue;
165635
+ const line = doc$2.createElementNS(SVG_NS, "polyline");
165636
+ line.setAttribute("points", points.join(" "));
165637
+ line.setAttribute("fill", "none");
165638
+ line.setAttribute("stroke", color2);
165639
+ line.setAttribute("stroke-width", "2");
165640
+ svg2.appendChild(line);
165641
+ for (let i$1 = 0;i$1 < s2.values.length; i$1++) {
165642
+ const marker = doc$2.createElementNS(SVG_NS, "circle");
165643
+ marker.setAttribute("cx", String(pointX(layout, i$1)));
165644
+ marker.setAttribute("cy", String(pointY(layout, s2.values[i$1] ?? 0)));
165645
+ marker.setAttribute("r", "2.5");
165646
+ marker.setAttribute("fill", color2);
165647
+ svg2.appendChild(marker);
165648
+ }
165649
+ }
165650
+ if (hasLegend)
165651
+ renderLegend(doc$2, svg2, series, height);
165652
+ if (truncated)
165653
+ renderTruncationIndicator(doc$2, svg2, width);
165654
+ container.appendChild(svg2);
165655
+ return container;
165656
+ }
165657
+ function renderAreaChart(doc$2, container, chart, geometry) {
165658
+ const { width, height } = geometry;
165659
+ const { series, truncated } = applyGuardrails(chart);
165660
+ const categories = series[0]?.categories ?? [];
165661
+ const hasLegend = chart.legendPosition !== undefined;
165662
+ const estimated = estimateLineAreaElements(series, categories, hasLegend, false) + series.length;
165663
+ if (estimated > SVG_ELEMENT_BUDGET)
165664
+ return createChartPlaceholder(doc$2, container, `Chart too complex for inline rendering (${estimated} elements)`);
165665
+ const layout = toCartesianLayout(width, height, series, true);
165666
+ const svg2 = doc$2.createElementNS(SVG_NS, "svg");
165667
+ svg2.setAttribute("viewBox", `0 0 ${width} ${height}`);
165668
+ svg2.setAttribute("width", "100%");
165669
+ svg2.setAttribute("height", "100%");
165670
+ svg2.style.display = "block";
165671
+ renderCartesianAxes(doc$2, svg2, layout);
165672
+ renderCartesianValueTicks(doc$2, svg2, layout, height);
165673
+ renderPointCategoryLabels(doc$2, svg2, categories, layout, width);
165674
+ for (let si = 0;si < series.length; si++) {
165675
+ const s2 = series[si];
165676
+ if (s2.values.length === 0)
165677
+ continue;
165678
+ const color2 = SERIES_COLORS[si % SERIES_COLORS.length];
165679
+ const pathParts = [`M ${pointX(layout, 0)} ${layout.baselineY}`];
165680
+ for (let i$1 = 0;i$1 < s2.values.length; i$1++)
165681
+ pathParts.push(`L ${pointX(layout, i$1)} ${pointY(layout, s2.values[i$1] ?? 0)}`);
165682
+ const lastX = pointX(layout, Math.max(0, s2.values.length - 1));
165683
+ pathParts.push(`L ${lastX} ${layout.baselineY} Z`);
165684
+ const area = doc$2.createElementNS(SVG_NS, "path");
165685
+ area.setAttribute("d", pathParts.join(" "));
165686
+ area.setAttribute("fill", color2);
165687
+ area.setAttribute("fill-opacity", "0.35");
165688
+ area.setAttribute("stroke", color2);
165689
+ area.setAttribute("stroke-width", "1.5");
165690
+ svg2.appendChild(area);
165691
+ }
165692
+ if (hasLegend)
165693
+ renderLegend(doc$2, svg2, series, height);
165694
+ if (truncated)
165695
+ renderTruncationIndicator(doc$2, svg2, width);
165696
+ container.appendChild(svg2);
165697
+ return container;
165698
+ }
165699
+ function renderDoughnutSlices(doc$2, svg2, slices, centerX, centerY, outerRadius, innerRadius) {
165700
+ const total = slices.reduce((sum, slice2) => sum + slice2.value, 0);
165701
+ if (total <= 0)
165702
+ return;
165703
+ let start$1 = -Math.PI / 2;
165704
+ for (const slice2 of slices) {
165705
+ if (slice2.value <= 0)
165706
+ continue;
165707
+ const sweep = slice2.value / total * Math.PI * 2;
165708
+ if (sweep >= Math.PI * 2 - 0.0001) {
165709
+ const ring = doc$2.createElementNS(SVG_NS, "circle");
165710
+ ring.setAttribute("cx", String(centerX));
165711
+ ring.setAttribute("cy", String(centerY));
165712
+ ring.setAttribute("r", String((outerRadius + innerRadius) / 2));
165713
+ ring.setAttribute("fill", "none");
165714
+ ring.setAttribute("stroke", slice2.color);
165715
+ ring.setAttribute("stroke-width", String(Math.max(1, outerRadius - innerRadius)));
165716
+ svg2.appendChild(ring);
165717
+ break;
165718
+ }
165719
+ const end$1 = start$1 + sweep;
165720
+ const x1 = centerX + outerRadius * Math.cos(start$1);
165721
+ const y1 = centerY + outerRadius * Math.sin(start$1);
165722
+ const x2 = centerX + outerRadius * Math.cos(end$1);
165723
+ const y2 = centerY + outerRadius * Math.sin(end$1);
165724
+ const ix1 = centerX + innerRadius * Math.cos(start$1);
165725
+ const iy1 = centerY + innerRadius * Math.sin(start$1);
165726
+ const ix2 = centerX + innerRadius * Math.cos(end$1);
165727
+ const iy2 = centerY + innerRadius * Math.sin(end$1);
165728
+ const largeArc = sweep > Math.PI ? 1 : 0;
165729
+ const path2 = doc$2.createElementNS(SVG_NS, "path");
165730
+ path2.setAttribute("d", `M ${x1} ${y1} A ${outerRadius} ${outerRadius} 0 ${largeArc} 1 ${x2} ${y2} L ${ix2} ${iy2} A ${innerRadius} ${innerRadius} 0 ${largeArc} 0 ${ix1} ${iy1} Z`);
165731
+ path2.setAttribute("fill", slice2.color);
165732
+ path2.setAttribute("stroke", "#fff");
165733
+ path2.setAttribute("stroke-width", "1");
165734
+ svg2.appendChild(path2);
165735
+ start$1 = end$1;
165736
+ }
165737
+ }
165738
+ function renderDoughnutChart(doc$2, container, chart, geometry) {
165739
+ const series = chart.series[0];
165740
+ if (!series)
165741
+ return createChartPlaceholder(doc$2, container, "No chart data");
165742
+ const { slices, truncated } = normalizePieSlices(series);
165743
+ if (slices.reduce((sum, slice2) => sum + slice2.value, 0) <= 0)
165744
+ return createChartPlaceholder(doc$2, container, "No chart data");
165745
+ if (slices.length * 3 > SVG_ELEMENT_BUDGET)
165746
+ return createChartPlaceholder(doc$2, container, "Chart too large");
165747
+ const { width, height } = geometry;
165748
+ const hasLegend = chart.legendPosition !== undefined;
165749
+ const title = series.name?.trim() || "";
165750
+ const hasTitle = title.length > 0;
165751
+ const titleSpace = hasTitle ? 34 : 10;
165752
+ const legendSpace = hasLegend ? 40 : 10;
165753
+ const plotWidth = Math.max(1, width - 20);
165754
+ const plotHeight = Math.max(1, height - titleSpace - legendSpace);
165755
+ const centerX = width / 2;
165756
+ const centerY = titleSpace + plotHeight / 2;
165757
+ const outerRadius = Math.max(8, Math.min(plotWidth, plotHeight) * 0.45);
165758
+ const innerRadius = Math.max(2, outerRadius * 0.58);
165759
+ const svg2 = doc$2.createElementNS(SVG_NS, "svg");
165760
+ svg2.setAttribute("viewBox", `0 0 ${width} ${height}`);
165761
+ svg2.setAttribute("width", "100%");
165762
+ svg2.setAttribute("height", "100%");
165763
+ svg2.style.display = "block";
165764
+ if (hasTitle) {
165765
+ const titleEl = doc$2.createElementNS(SVG_NS, "text");
165766
+ titleEl.setAttribute("x", String(centerX));
165767
+ titleEl.setAttribute("y", "24");
165768
+ titleEl.setAttribute("text-anchor", "middle");
165769
+ titleEl.setAttribute("font-size", String(Math.max(12, Math.min(22, width / 18))));
165770
+ titleEl.setAttribute("fill", AXIS_COLOR);
165771
+ titleEl.setAttribute("font-family", FONT_FAMILY);
165772
+ titleEl.textContent = title;
165773
+ svg2.appendChild(titleEl);
165774
+ }
165775
+ renderDoughnutSlices(doc$2, svg2, slices, centerX, centerY, outerRadius, innerRadius);
165776
+ if (hasLegend)
165777
+ renderPieLegend(doc$2, svg2, slices, width, height);
165778
+ if (truncated)
165779
+ renderTruncationIndicator(doc$2, svg2, width);
165780
+ container.appendChild(svg2);
165781
+ return container;
165782
+ }
165783
+ function estimateSvgElements(series, categories, hasLegend) {
165784
+ const bars = series.reduce((sum, s2) => sum + s2.values.length, 0);
165785
+ const axes = 2;
165786
+ const categoryLabels = categories.length;
165787
+ const valueTicks = (VALUE_TICK_COUNT + 1) * 2;
165788
+ const legend = hasLegend ? series.length * 2 : 0;
165789
+ return bars + axes + categoryLabels + valueTicks + legend;
165790
+ }
165791
+ function renderBarChart(doc$2, container, chart, geometry) {
165792
+ const { width, height } = geometry;
165793
+ const { series, truncated } = applyGuardrails(chart);
165794
+ const categories = series[0]?.categories ?? [];
165795
+ const hasLegend = chart.legendPosition !== undefined;
165796
+ const estimated = estimateSvgElements(series, categories, hasLegend);
165797
+ if (estimated > SVG_ELEMENT_BUDGET)
165798
+ return createChartPlaceholder(doc$2, container, `Chart too complex for inline rendering (${estimated} elements)`);
165799
+ const svg2 = doc$2.createElementNS(SVG_NS, "svg");
165800
+ svg2.setAttribute("viewBox", `0 0 ${width} ${height}`);
165801
+ svg2.setAttribute("width", "100%");
165802
+ svg2.setAttribute("height", "100%");
165803
+ svg2.style.display = "block";
165804
+ const layout = computeBarLayout(width, height, series);
165805
+ renderBars(doc$2, svg2, series, layout);
165806
+ renderAxes(doc$2, svg2, layout);
165807
+ renderCategoryLabels(doc$2, svg2, categories, layout, width);
165808
+ renderValueTicks(doc$2, svg2, layout, height);
165809
+ if (hasLegend)
165810
+ renderLegend(doc$2, svg2, series, height);
165811
+ if (truncated)
165812
+ renderTruncationIndicator(doc$2, svg2, width);
165813
+ container.appendChild(svg2);
165814
+ return container;
165815
+ }
164594
165816
  function assertPmPositions(run2, context) {
164595
165817
  const hasPmStart = run2.pmStart != null;
164596
165818
  const hasPmEnd = run2.pmEnd != null;
@@ -167424,7 +168646,7 @@ function coerceBoolean(value) {
167424
168646
  return false;
167425
168647
  }
167426
168648
  }
167427
- function toBoxSpacing$1(spacing) {
168649
+ function toBoxSpacing(spacing) {
167428
168650
  if (!spacing)
167429
168651
  return;
167430
168652
  const result = {};
@@ -167714,7 +168936,7 @@ function hydrateImageBlocks(blocks2, mediaFiles) {
167714
168936
  });
167715
168937
  }
167716
168938
  function isGradientFill(value) {
167717
- if (!isPlainObject$2(value))
168939
+ if (!isPlainObject$1(value))
167718
168940
  return false;
167719
168941
  if (value.type !== "gradient")
167720
168942
  return false;
@@ -167728,13 +168950,13 @@ function isGradientFill(value) {
167728
168950
  if (!Array.isArray(value.stops) || value.stops.length === 0)
167729
168951
  return false;
167730
168952
  return value.stops.every((stop) => {
167731
- if (!isPlainObject$2(stop))
168953
+ if (!isPlainObject$1(stop))
167732
168954
  return false;
167733
168955
  return typeof stop.position === "number" && Number.isFinite(stop.position) && typeof stop.color === "string" && (stop.alpha === undefined || typeof stop.alpha === "number" && Number.isFinite(stop.alpha));
167734
168956
  });
167735
168957
  }
167736
168958
  function isSolidFillWithAlpha(value) {
167737
- return isPlainObject$2(value) && value.type === "solidWithAlpha" && typeof value.color === "string" && typeof value.alpha === "number";
168959
+ return isPlainObject$1(value) && value.type === "solidWithAlpha" && typeof value.color === "string" && typeof value.alpha === "number";
167738
168960
  }
167739
168961
  function normalizeFillColor(value) {
167740
168962
  if (value === null)
@@ -167753,13 +168975,13 @@ function normalizeStrokeColor(value) {
167753
168975
  return value;
167754
168976
  }
167755
168977
  function normalizeTextContent(value) {
167756
- if (!isPlainObject$2(value))
168978
+ if (!isPlainObject$1(value))
167757
168979
  return;
167758
168980
  if (!Array.isArray(value.parts))
167759
168981
  return;
167760
168982
  if (value.parts.length === 0)
167761
168983
  return;
167762
- const validParts = value.parts.filter((p$12) => isPlainObject$2(p$12) && typeof p$12.text === "string");
168984
+ const validParts = value.parts.filter((p$12) => isPlainObject$1(p$12) && typeof p$12.text === "string");
167763
168985
  if (validParts.length === 0)
167764
168986
  return;
167765
168987
  const result = { parts: validParts };
@@ -167778,7 +169000,7 @@ function normalizeTextVerticalAlign(value) {
167778
169000
  return value;
167779
169001
  }
167780
169002
  function normalizeTextInsets(value) {
167781
- if (!isPlainObject$2(value))
169003
+ if (!isPlainObject$1(value))
167782
169004
  return;
167783
169005
  const top$1 = pickNumber(value.top);
167784
169006
  const right$1 = pickNumber(value.right);
@@ -167803,7 +169025,7 @@ function coerceRelativeHeight(raw) {
167803
169025
  }
167804
169026
  }
167805
169027
  function normalizeZIndex(originalAttributes) {
167806
- if (!isPlainObject$2(originalAttributes))
169028
+ if (!isPlainObject$1(originalAttributes))
167807
169029
  return;
167808
169030
  const relativeHeight = coerceRelativeHeight(originalAttributes.relativeHeight);
167809
169031
  if (relativeHeight === undefined)
@@ -173308,8 +174530,8 @@ function imageNodeToRun({ node: node3, positions, sdtMetadata }) {
173308
174530
  const size$2 = attrs.size ?? {};
173309
174531
  const width = typeof size$2.width === "number" && Number.isFinite(size$2.width) && size$2.width > 0 ? size$2.width : DEFAULT_IMAGE_DIMENSION_PX;
173310
174532
  const height = typeof size$2.height === "number" && Number.isFinite(size$2.height) && size$2.height > 0 ? size$2.height : DEFAULT_IMAGE_DIMENSION_PX;
173311
- const wrap4 = isPlainObject$2(attrs.wrap) ? attrs.wrap : {};
173312
- const wrapAttrs = isPlainObject$2(wrap4.attrs) ? wrap4.attrs : {};
174533
+ const wrap4 = isPlainObject$1(attrs.wrap) ? attrs.wrap : {};
174534
+ const wrapAttrs = isPlainObject$1(wrap4.attrs) ? wrap4.attrs : {};
173313
174535
  const run2 = {
173314
174536
  kind: "image",
173315
174537
  src,
@@ -173342,7 +174564,7 @@ function imageNodeToRun({ node: node3, positions, sdtMetadata }) {
173342
174564
  }
173343
174565
  if (sdtMetadata)
173344
174566
  run2.sdt = sdtMetadata;
173345
- const transformData = isPlainObject$2(attrs.transformData) ? attrs.transformData : undefined;
174567
+ const transformData = isPlainObject$1(attrs.transformData) ? attrs.transformData : undefined;
173346
174568
  if (transformData) {
173347
174569
  const rotation = typeof transformData.rotation === "number" ? transformData.rotation : undefined;
173348
174570
  if (rotation !== undefined)
@@ -173469,7 +174691,7 @@ function lineBreakNodeToRun({ node: node3, positions, sdtMetadata }) {
173469
174691
  return lineBreakRun;
173470
174692
  }
173471
174693
  function vectorShapeNodeToDrawingBlock(node3, nextBlockId, positions) {
173472
- const rawAttrs = getAttrs$1(node3);
174694
+ const rawAttrs = getAttrs$2(node3);
173473
174695
  if (isHiddenDrawing$1(rawAttrs))
173474
174696
  return null;
173475
174697
  const effectExtent = normalizeEffectExtent(rawAttrs.effectExtent);
@@ -173489,7 +174711,7 @@ function vectorShapeNodeToDrawingBlock(node3, nextBlockId, positions) {
173489
174711
  });
173490
174712
  }
173491
174713
  function shapeGroupNodeToDrawingBlock(node3, nextBlockId, positions) {
173492
- const rawAttrs = getAttrs$1(node3);
174714
+ const rawAttrs = getAttrs$2(node3);
173493
174715
  if (isHiddenDrawing$1(rawAttrs))
173494
174716
  return null;
173495
174717
  const groupTransform = isShapeGroupTransform(rawAttrs.groupTransform) ? { ...rawAttrs.groupTransform } : undefined;
@@ -173509,7 +174731,7 @@ function shapeGroupNodeToDrawingBlock(node3, nextBlockId, positions) {
173509
174731
  });
173510
174732
  }
173511
174733
  function shapeContainerNodeToDrawingBlock(node3, nextBlockId, positions) {
173512
- const rawAttrs = getAttrs$1(node3);
174734
+ const rawAttrs = getAttrs$2(node3);
173513
174735
  if (isHiddenDrawing$1(rawAttrs))
173514
174736
  return null;
173515
174737
  return buildDrawingBlock(rawAttrs, nextBlockId, positions, node3, {
@@ -173521,7 +174743,7 @@ function shapeContainerNodeToDrawingBlock(node3, nextBlockId, positions) {
173521
174743
  }, "vectorShape");
173522
174744
  }
173523
174745
  function shapeTextboxNodeToDrawingBlock(node3, nextBlockId, positions) {
173524
- const rawAttrs = getAttrs$1(node3);
174746
+ const rawAttrs = getAttrs$2(node3);
173525
174747
  if (isHiddenDrawing$1(rawAttrs))
173526
174748
  return null;
173527
174749
  return buildDrawingBlock(rawAttrs, nextBlockId, positions, node3, {
@@ -173565,12 +174787,12 @@ function handleShapeTextboxNode(node3, context) {
173565
174787
  }
173566
174788
  }
173567
174789
  function contentBlockNodeToDrawingBlock(node3, nextBlockId, positions) {
173568
- const rawAttrs = getAttrs(node3);
174790
+ const rawAttrs = getAttrs$1(node3);
173569
174791
  const indentLeft = pickNumber(rawAttrs.hrIndentLeft);
173570
174792
  const indentRight = pickNumber(rawAttrs.hrIndentRight);
173571
174793
  if (rawAttrs.horizontalRule !== true)
173572
174794
  return null;
173573
- const size$2 = isPlainObject$2(rawAttrs.size) ? rawAttrs.size : undefined;
174795
+ const size$2 = isPlainObject$1(rawAttrs.size) ? rawAttrs.size : undefined;
173574
174796
  const { width, isFullWidth } = parseFullWidth(size$2?.width);
173575
174797
  const height = pickNumber(size$2?.height);
173576
174798
  if (!height || height <= 0)
@@ -173609,7 +174831,7 @@ function inlineContentBlockConverter(node3, { positions, nextBlockId, paragraphA
173609
174831
  }
173610
174832
  } : node3, nextBlockId, positions);
173611
174833
  }
173612
- function toBoxSpacing(spacing) {
174834
+ function toBoxSpacing$1(spacing) {
173613
174835
  if (!spacing)
173614
174836
  return;
173615
174837
  const result = {};
@@ -173641,7 +174863,7 @@ function imageNodeToBlock(node3, nextBlockId, positions, _trackedMeta, _trackedC
173641
174863
  const width = typeof size$2.width === "number" && Number.isFinite(size$2.width) ? size$2.width : undefined;
173642
174864
  const height = typeof size$2.height === "number" && Number.isFinite(size$2.height) ? size$2.height : undefined;
173643
174865
  const explicitDisplay = typeof attrs.display === "string" ? attrs.display : undefined;
173644
- const normalizedWrap = normalizeWrap$1(attrs.wrap);
174866
+ const normalizedWrap = normalizeWrap$2(attrs.wrap);
173645
174867
  let anchor = normalizeAnchorData(attrs.anchorData, attrs, normalizedWrap?.behindDoc);
173646
174868
  if (!anchor && normalizedWrap) {
173647
174869
  anchor = { isAnchored: true };
@@ -173656,7 +174878,7 @@ function imageNodeToBlock(node3, nextBlockId, positions, _trackedMeta, _trackedC
173656
174878
  const objectFit = isAllowedObjectFit(explicitObjectFit) ? explicitObjectFit : shouldCover ? "cover" : display === "inline" ? "scale-down" : isAnchor ? "contain" : "contain";
173657
174879
  const zIndexFromRelativeHeight = normalizeZIndex(attrs.originalAttributes);
173658
174880
  const zIndex = resolveFloatingZIndex(anchor?.behindDoc === true, zIndexFromRelativeHeight);
173659
- const transformData = isPlainObject$1(attrs.transformData) ? attrs.transformData : undefined;
174881
+ const transformData = isPlainObject$2(attrs.transformData) ? attrs.transformData : undefined;
173660
174882
  const rotation = typeof transformData?.rotation === "number" ? transformData.rotation : undefined;
173661
174883
  const flipH = typeof transformData?.horizontalFlip === "boolean" ? transformData.horizontalFlip : undefined;
173662
174884
  const flipV = typeof transformData?.verticalFlip === "boolean" ? transformData.verticalFlip : undefined;
@@ -173670,8 +174892,8 @@ function imageNodeToBlock(node3, nextBlockId, positions, _trackedMeta, _trackedC
173670
174892
  title: typeof attrs.title === "string" ? attrs.title : undefined,
173671
174893
  objectFit,
173672
174894
  display,
173673
- padding: toBoxSpacing(attrs.padding),
173674
- margin: toBoxSpacing(attrs.marginOffset),
174895
+ padding: toBoxSpacing$1(attrs.padding),
174896
+ margin: toBoxSpacing$1(attrs.marginOffset),
173675
174897
  anchor,
173676
174898
  wrap: normalizedWrap,
173677
174899
  ...zIndex !== undefined && { zIndex },
@@ -173697,6 +174919,49 @@ function handleImageNode2(node3, context) {
173697
174919
  return imageBlock;
173698
174920
  }
173699
174921
  }
174922
+ function chartNodeToDrawingBlock(node3, nextBlockId, positions) {
174923
+ const rawAttrs = getAttrs(node3);
174924
+ const chartData = rawAttrs.chartData && typeof rawAttrs.chartData === "object" ? rawAttrs.chartData : EMPTY_CHART_DATA;
174925
+ const geometry = {
174926
+ width: coercePositiveNumber(rawAttrs.width, 400),
174927
+ height: coercePositiveNumber(rawAttrs.height, 300),
174928
+ rotation: 0,
174929
+ flipH: false,
174930
+ flipV: false
174931
+ };
174932
+ const normalizedWrap = normalizeWrap$1(rawAttrs.wrap);
174933
+ const anchor = normalizeAnchor(rawAttrs.anchorData, rawAttrs, normalizedWrap?.behindDoc);
174934
+ const pos = positions.get(node3);
174935
+ const attrsWithPm = { ...rawAttrs };
174936
+ if (pos) {
174937
+ attrsWithPm.pmStart = pos.start;
174938
+ attrsWithPm.pmEnd = pos.end;
174939
+ }
174940
+ const resolvedZIndex = resolveFloatingZIndex(anchor?.behindDoc === true || normalizedWrap?.behindDoc === true, normalizeZIndex(rawAttrs.originalAttributes), 1);
174941
+ return {
174942
+ kind: "drawing",
174943
+ id: nextBlockId("drawing"),
174944
+ drawingKind: "chart",
174945
+ geometry,
174946
+ chartData,
174947
+ chartRelId: typeof rawAttrs.chartRelId === "string" ? rawAttrs.chartRelId : undefined,
174948
+ chartPartPath: typeof rawAttrs.chartPartPath === "string" ? rawAttrs.chartPartPath : undefined,
174949
+ padding: toBoxSpacing(rawAttrs.padding),
174950
+ margin: toBoxSpacing(rawAttrs.marginOffset),
174951
+ anchor,
174952
+ wrap: normalizedWrap,
174953
+ zIndex: resolvedZIndex,
174954
+ drawingContentId: typeof rawAttrs.drawingContentId === "string" ? rawAttrs.drawingContentId : undefined,
174955
+ drawingContent: toDrawingContentSnapshot(rawAttrs.drawingContent),
174956
+ attrs: attrsWithPm
174957
+ };
174958
+ }
174959
+ function handleChartNode(node3, context) {
174960
+ const { blocks: blocks2, recordBlockKind, nextBlockId, positions } = context;
174961
+ const drawingBlock = chartNodeToDrawingBlock(node3, nextBlockId, positions);
174962
+ blocks2.push(drawingBlock);
174963
+ recordBlockKind?.(drawingBlock.kind);
174964
+ }
173700
174965
  function normalizeCellSpacing(raw) {
173701
174966
  if (raw == null)
173702
174967
  return {
@@ -182017,6 +183282,86 @@ function generateTransforms(attrs) {
182017
183282
  transforms.push(`scaleY(-1)`);
182018
183283
  return transforms;
182019
183284
  }
183285
+ function countChartNodes(doc$2) {
183286
+ let count = 0;
183287
+ doc$2.descendants((node3) => {
183288
+ if (node3.type.name === "chart")
183289
+ count++;
183290
+ return node3.type.name !== "chart";
183291
+ });
183292
+ return count;
183293
+ }
183294
+ function collectChartNodes(doc$2) {
183295
+ let charts = chartPositionCache.get(doc$2);
183296
+ if (charts)
183297
+ return charts;
183298
+ charts = [];
183299
+ doc$2.descendants((node3, pos) => {
183300
+ if (node3.type.name === "chart")
183301
+ charts.push({
183302
+ pos,
183303
+ node: node3
183304
+ });
183305
+ return node3.type.name !== "chart";
183306
+ });
183307
+ chartPositionCache.set(doc$2, charts);
183308
+ return charts;
183309
+ }
183310
+ function transactionInsertsChart(tr) {
183311
+ for (const step3 of tr.steps) {
183312
+ const slice2 = step3.slice;
183313
+ if (!slice2 || !slice2.content.size)
183314
+ continue;
183315
+ let found2 = false;
183316
+ slice2.content.descendants((node3) => {
183317
+ if (node3.type.name === "chart")
183318
+ found2 = true;
183319
+ return !found2;
183320
+ });
183321
+ if (found2)
183322
+ return true;
183323
+ }
183324
+ return false;
183325
+ }
183326
+ function isChartMutation(tr, oldDoc) {
183327
+ if (transactionInsertsChart(tr))
183328
+ return true;
183329
+ const oldCharts = collectChartNodes(oldDoc);
183330
+ if (oldCharts.length === 0)
183331
+ return false;
183332
+ const newDoc = tr.doc;
183333
+ for (const { pos, node: oldNode } of oldCharts) {
183334
+ const mappedPos = tr.mapping.map(pos);
183335
+ const nodeAfter = newDoc.resolve(mappedPos).nodeAfter;
183336
+ if (!nodeAfter || nodeAfter.type.name !== "chart")
183337
+ return true;
183338
+ if (oldNode.attrs !== nodeAfter.attrs) {
183339
+ if (JSON.stringify(oldNode.attrs) !== JSON.stringify(nodeAfter.attrs))
183340
+ return true;
183341
+ }
183342
+ }
183343
+ return false;
183344
+ }
183345
+ function createChartImmutabilityPlugin() {
183346
+ return new Plugin({
183347
+ key: CHART_IMMUTABILITY_KEY,
183348
+ state: {
183349
+ init(_$1, state) {
183350
+ return countChartNodes(state.doc);
183351
+ },
183352
+ apply(_tr, oldCount) {
183353
+ return oldCount;
183354
+ }
183355
+ },
183356
+ filterTransaction(tr, state) {
183357
+ if (!tr.docChanged)
183358
+ return true;
183359
+ if ((CHART_IMMUTABILITY_KEY.getState(state) ?? 0) === 0)
183360
+ return !transactionInsertsChart(tr);
183361
+ return !isChartMutation(tr, state.doc);
183362
+ }
183363
+ });
183364
+ }
182020
183365
  function createCascadeToggleCommands({ markName, setCommand, unsetCommand, toggleCommand, negationAttrs, isNegation, extendEmptyMarkRange } = {}) {
182021
183366
  if (!markName)
182022
183367
  throw new Error("createCascadeToggleCommands requires a markName");
@@ -200249,7 +201594,7 @@ var Node$13 = class Node$14 {
200249
201594
  if (current.trim())
200250
201595
  parts.push(current.trim());
200251
201596
  return parts;
200252
- }, _, F, X, p3 = "http://schemas.openxmlformats.org/drawingml/2006/main", G, c0, n0 = 100, o0, u0 = (t) => h$1(t, p3, "path").length > 0, M0, r0, DOM_CLASS_NAMES, hashParagraphBorder$1 = (border) => {
201597
+ }, _, F, X, p3 = "http://schemas.openxmlformats.org/drawingml/2006/main", G, c0, n0 = 100, o0, u0 = (t) => h$1(t, p3, "path").length > 0, M0, r0, DOM_CLASS_NAMES, MAX_RENDERED_SERIES = 20, MAX_POINTS_PER_SERIES = 500, SVG_ELEMENT_BUDGET = 5000, SERIES_COLORS, AXIS_COLOR = "#595959", GRID_COLOR = "#E0E0E0", LABEL_COLOR = "#333", TICK_LABEL_COLOR = "#666", FONT_FAMILY = "Calibri, Arial, sans-serif", PLACEHOLDER_BG = "#f8f9fa", PLACEHOLDER_BORDER = "#dee2e6", PLACEHOLDER_TEXT_COLOR = "#6c757d", SVG_NS = "http://www.w3.org/2000/svg", CHART_PADDING, VALUE_TICK_COUNT = 5, hashParagraphBorder$1 = (border) => {
200253
201598
  const parts = [];
200254
201599
  if (border.style !== undefined)
200255
201600
  parts.push(`s:${border.style}`);
@@ -201194,7 +202539,7 @@ var Node$13 = class Node$14 {
201194
202539
  if (pt == null || !Number.isFinite(pt))
201195
202540
  return;
201196
202541
  return pt * PX_PER_PT2;
201197
- }, isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value), isPlainObject$2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value), normalizePrefix = (value) => {
202542
+ }, isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value), isPlainObject$1 = (value) => value !== null && typeof value === "object" && !Array.isArray(value), normalizePrefix = (value) => {
201198
202543
  if (!value)
201199
202544
  return "";
201200
202545
  return String(value);
@@ -201212,7 +202557,7 @@ var Node$13 = class Node$14 {
201212
202557
  if (!trimmed || trimmed === "auto" || trimmed === "none")
201213
202558
  return;
201214
202559
  return trimmed.startsWith("#") ? trimmed : `#${trimmed}`;
201215
- }, toBoolean$1 = (value) => {
202560
+ }, toBoolean = (value) => {
201216
202561
  if (typeof value === "boolean")
201217
202562
  return value;
201218
202563
  if (typeof value === "string") {
@@ -202435,7 +203780,7 @@ var Node$13 = class Node$14 {
202435
203780
  this.onMouseLeave = null;
202436
203781
  this.hoveredSdtId = null;
202437
203782
  }
202438
- }, LIST_MARKER_GAP = 8, DEFAULT_PAGE_HEIGHT_PX = 1056, DEFAULT_VIRTUALIZED_PAGE_GAP = 72, COMMENT_EXTERNAL_COLOR = "#B1124B", COMMENT_INTERNAL_COLOR = "#078383", COMMENT_INACTIVE_ALPHA = "40", COMMENT_ACTIVE_ALPHA = "66", COMMENT_FADED_ALPHA = "20", LINK_DATASET_KEYS, MAX_HREF_LENGTH = 2048, SAFE_ANCHOR_PATTERN, MAX_DATA_URL_LENGTH, VALID_IMAGE_DATA_URL, MAX_RESIZE_MULTIPLIER = 3, FALLBACK_MAX_DIMENSION = 1000, MIN_IMAGE_DIMENSION = 20, AMBIGUOUS_LINK_PATTERNS, linkMetrics, TRACK_CHANGE_BASE_CLASS, TRACK_CHANGE_FOCUSED_CLASS = "track-change-focused", TRACK_CHANGE_MODIFIER_CLASS, LINK_TARGET_SET, normalizeAnchor = (value) => {
203783
+ }, LIST_MARKER_GAP = 8, DEFAULT_PAGE_HEIGHT_PX = 1056, DEFAULT_VIRTUALIZED_PAGE_GAP = 72, COMMENT_EXTERNAL_COLOR = "#B1124B", COMMENT_INTERNAL_COLOR = "#078383", COMMENT_INACTIVE_ALPHA = "40", COMMENT_ACTIVE_ALPHA = "66", COMMENT_FADED_ALPHA = "20", LINK_DATASET_KEYS, MAX_HREF_LENGTH = 2048, SAFE_ANCHOR_PATTERN, MAX_DATA_URL_LENGTH, VALID_IMAGE_DATA_URL, MAX_RESIZE_MULTIPLIER = 3, FALLBACK_MAX_DIMENSION = 1000, MIN_IMAGE_DIMENSION = 20, AMBIGUOUS_LINK_PATTERNS, linkMetrics, TRACK_CHANGE_BASE_CLASS, TRACK_CHANGE_FOCUSED_CLASS = "track-change-focused", TRACK_CHANGE_MODIFIER_CLASS, LINK_TARGET_SET, normalizeAnchor$1 = (value) => {
202439
203784
  if (typeof value !== "string")
202440
203785
  return null;
202441
203786
  const trimmed = value.trim();
@@ -202858,6 +204203,15 @@ var Node$13 = class Node$14 {
202858
204203
  childSignature
202859
204204
  ].join("|");
202860
204205
  }
204206
+ if (block.drawingKind === "chart")
204207
+ return [
204208
+ "drawing:chart",
204209
+ block.chartData?.chartType ?? "",
204210
+ block.chartData?.series?.length ?? 0,
204211
+ block.geometry.width,
204212
+ block.geometry.height,
204213
+ block.chartRelId ?? ""
204214
+ ].join("|");
202861
204215
  return `drawing:unknown:${block.id}`;
202862
204216
  }
202863
204217
  if (block.kind === "table") {
@@ -204829,20 +206183,20 @@ var Node$13 = class Node$14 {
204829
206183
  id: nextBlockId(kind),
204830
206184
  attrs: node3.attrs || {}
204831
206185
  };
204832
- }, WRAP_TYPES$1, WRAP_TEXT_VALUES$1, H_RELATIVE_VALUES$1, V_RELATIVE_VALUES$1, H_ALIGN_VALUES$1, V_ALIGN_VALUES$1, getAttrs$1 = (node3) => {
204833
- return isPlainObject$2(node3.attrs) ? node3.attrs : {};
206186
+ }, WRAP_TYPES$2, WRAP_TEXT_VALUES$2, H_RELATIVE_VALUES$2, V_RELATIVE_VALUES$2, H_ALIGN_VALUES$1, V_ALIGN_VALUES$1, getAttrs$2 = (node3) => {
206187
+ return isPlainObject$1(node3.attrs) ? node3.attrs : {};
204834
206188
  }, isHiddenDrawing$1 = (attrs) => {
204835
- if (toBoolean$1(attrs.hidden) === true)
206189
+ if (toBoolean(attrs.hidden) === true)
204836
206190
  return true;
204837
206191
  return typeof attrs.visibility === "string" && attrs.visibility.toLowerCase() === "hidden";
204838
206192
  }, normalizeWrapType$1 = (value) => {
204839
206193
  if (typeof value !== "string")
204840
206194
  return;
204841
- return WRAP_TYPES$1.has(value) ? value : undefined;
206195
+ return WRAP_TYPES$2.has(value) ? value : undefined;
204842
206196
  }, normalizeWrapText$1 = (value) => {
204843
206197
  if (typeof value !== "string")
204844
206198
  return;
204845
- return WRAP_TEXT_VALUES$1.has(value) ? value : undefined;
206199
+ return WRAP_TEXT_VALUES$2.has(value) ? value : undefined;
204846
206200
  }, normalizePolygon$1 = (value) => {
204847
206201
  if (!Array.isArray(value))
204848
206202
  return;
@@ -204857,14 +206211,14 @@ var Node$13 = class Node$14 {
204857
206211
  polygon.push([x, y$1]);
204858
206212
  });
204859
206213
  return polygon.length > 0 ? polygon : undefined;
204860
- }, normalizeWrap$2 = (value) => {
204861
- if (!isPlainObject$2(value))
206214
+ }, normalizeWrap$3 = (value) => {
206215
+ if (!isPlainObject$1(value))
204862
206216
  return;
204863
206217
  const type = normalizeWrapType$1(value.type);
204864
206218
  if (!type || type === "Inline")
204865
206219
  return;
204866
206220
  const wrap4 = { type };
204867
- const attrs = isPlainObject$2(value.attrs) ? value.attrs : {};
206221
+ const attrs = isPlainObject$1(value.attrs) ? value.attrs : {};
204868
206222
  const wrapText = normalizeWrapText$1(attrs.wrapText);
204869
206223
  if (wrapText)
204870
206224
  wrap4.wrapText = wrapText;
@@ -204883,7 +206237,7 @@ var Node$13 = class Node$14 {
204883
206237
  const polygon = normalizePolygon$1(attrs.polygon);
204884
206238
  if (polygon)
204885
206239
  wrap4.polygon = polygon;
204886
- const behindDoc = toBoolean$1(attrs.behindDoc);
206240
+ const behindDoc = toBoolean(attrs.behindDoc);
204887
206241
  if (behindDoc != null)
204888
206242
  wrap4.behindDoc = behindDoc;
204889
206243
  return wrap4;
@@ -204896,18 +206250,18 @@ var Node$13 = class Node$14 {
204896
206250
  return;
204897
206251
  return allowed.has(value) ? value : undefined;
204898
206252
  }, normalizeAnchorData$1 = (value, attrs, wrapBehindDoc) => {
204899
- const raw = isPlainObject$2(value) ? value : undefined;
204900
- const marginOffset = isPlainObject$2(attrs.marginOffset) ? attrs.marginOffset : undefined;
204901
- const simplePos = isPlainObject$2(attrs.simplePos) ? attrs.simplePos : undefined;
204902
- const originalAttrs = isPlainObject$2(attrs.originalAttributes) ? attrs.originalAttributes : undefined;
206253
+ const raw = isPlainObject$1(value) ? value : undefined;
206254
+ const marginOffset = isPlainObject$1(attrs.marginOffset) ? attrs.marginOffset : undefined;
206255
+ const simplePos = isPlainObject$1(attrs.simplePos) ? attrs.simplePos : undefined;
206256
+ const originalAttrs = isPlainObject$1(attrs.originalAttributes) ? attrs.originalAttributes : undefined;
204903
206257
  const isAnchored = attrs.isAnchor === true || Boolean(raw);
204904
206258
  const anchor = {};
204905
206259
  if (isAnchored)
204906
206260
  anchor.isAnchored = true;
204907
- const hRelative = normalizeAnchorRelative$1(raw?.hRelativeFrom, H_RELATIVE_VALUES$1);
206261
+ const hRelative = normalizeAnchorRelative$1(raw?.hRelativeFrom, H_RELATIVE_VALUES$2);
204908
206262
  if (hRelative)
204909
206263
  anchor.hRelativeFrom = hRelative;
204910
- const vRelative = normalizeAnchorRelative$1(raw?.vRelativeFrom, V_RELATIVE_VALUES$1);
206264
+ const vRelative = normalizeAnchorRelative$1(raw?.vRelativeFrom, V_RELATIVE_VALUES$2);
204911
206265
  if (vRelative)
204912
206266
  anchor.vRelativeFrom = vRelative;
204913
206267
  const alignH = normalizeAnchorAlign$1(raw?.alignH, H_ALIGN_VALUES$1);
@@ -204922,12 +206276,12 @@ var Node$13 = class Node$14 {
204922
206276
  const offsetV = pickNumber(marginOffset?.top ?? marginOffset?.vertical ?? raw?.offsetV ?? simplePos?.y);
204923
206277
  if (offsetV != null)
204924
206278
  anchor.offsetV = offsetV;
204925
- const behindDoc = toBoolean$1(raw?.behindDoc ?? wrapBehindDoc ?? originalAttrs?.behindDoc);
206279
+ const behindDoc = toBoolean(raw?.behindDoc ?? wrapBehindDoc ?? originalAttrs?.behindDoc);
204926
206280
  if (behindDoc != null)
204927
206281
  anchor.behindDoc = behindDoc;
204928
206282
  return anchor.isAnchored || anchor.hRelativeFrom != null || anchor.vRelativeFrom != null || anchor.alignH != null || anchor.alignV != null || anchor.offsetH != null || anchor.offsetV != null || anchor.behindDoc != null ? anchor : undefined;
204929
206283
  }, buildDrawingBlock = (rawAttrs, nextBlockId, positions, node3, geometry, drawingKind, extraProps) => {
204930
- const normalizedWrap = normalizeWrap$2(rawAttrs.wrap);
206284
+ const normalizedWrap = normalizeWrap$3(rawAttrs.wrap);
204931
206285
  const baseAnchor = normalizeAnchorData$1(rawAttrs.anchorData, rawAttrs, normalizedWrap?.behindDoc);
204932
206286
  const pos = positions.get(node3);
204933
206287
  const attrsWithPm = { ...rawAttrs };
@@ -204940,8 +206294,8 @@ var Node$13 = class Node$14 {
204940
206294
  kind: "drawing",
204941
206295
  id: nextBlockId("drawing"),
204942
206296
  drawingKind,
204943
- padding: toBoxSpacing$1(rawAttrs.padding),
204944
- margin: toBoxSpacing$1(rawAttrs.marginOffset) ?? toBoxSpacing$1(rawAttrs.margin),
206297
+ padding: toBoxSpacing(rawAttrs.padding),
206298
+ margin: toBoxSpacing(rawAttrs.marginOffset) ?? toBoxSpacing(rawAttrs.margin),
204945
206299
  anchor: baseAnchor,
204946
206300
  wrap: normalizedWrap,
204947
206301
  zIndex: resolvedZIndex,
@@ -204960,8 +206314,8 @@ var Node$13 = class Node$14 {
204960
206314
  textInsets: normalizeTextInsets(rawAttrs.textInsets),
204961
206315
  ...extraProps
204962
206316
  };
204963
- }, getAttrs = (node3) => {
204964
- return isPlainObject$2(node3.attrs) ? { ...node3.attrs } : {};
206317
+ }, getAttrs$1 = (node3) => {
206318
+ return isPlainObject$1(node3.attrs) ? { ...node3.attrs } : {};
204965
206319
  }, parseFullWidth = (value) => {
204966
206320
  if (typeof value === "string") {
204967
206321
  const trimmed = value.trim();
@@ -204979,20 +206333,20 @@ var Node$13 = class Node$14 {
204979
206333
  width: pickNumber(value) ?? null,
204980
206334
  isFullWidth: false
204981
206335
  };
204982
- }, WRAP_TYPES, WRAP_TEXT_VALUES, H_RELATIVE_VALUES, V_RELATIVE_VALUES, H_ALIGN_VALUES, V_ALIGN_VALUES, isPlainObject$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), isAllowedObjectFit = (value) => {
206336
+ }, WRAP_TYPES$1, WRAP_TEXT_VALUES$1, H_RELATIVE_VALUES$1, V_RELATIVE_VALUES$1, H_ALIGN_VALUES, V_ALIGN_VALUES, isPlainObject$2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), isAllowedObjectFit = (value) => {
204983
206337
  return value === "contain" || value === "cover" || value === "fill" || value === "scale-down";
204984
206338
  }, isHiddenDrawing = (attrs) => {
204985
- if (toBoolean(attrs.hidden) === true)
206339
+ if (toBoolean$1(attrs.hidden) === true)
204986
206340
  return true;
204987
206341
  return typeof attrs.visibility === "string" && attrs.visibility.toLowerCase() === "hidden";
204988
206342
  }, normalizeWrapType = (value) => {
204989
206343
  if (typeof value !== "string")
204990
206344
  return;
204991
- return WRAP_TYPES.has(value) ? value : undefined;
206345
+ return WRAP_TYPES$1.has(value) ? value : undefined;
204992
206346
  }, normalizeWrapText = (value) => {
204993
206347
  if (typeof value !== "string")
204994
206348
  return;
204995
- return WRAP_TEXT_VALUES.has(value) ? value : undefined;
206349
+ return WRAP_TEXT_VALUES$1.has(value) ? value : undefined;
204996
206350
  }, normalizePolygon = (value) => {
204997
206351
  if (!Array.isArray(value))
204998
206352
  return;
@@ -205007,7 +206361,7 @@ var Node$13 = class Node$14 {
205007
206361
  polygon.push([x, y$1]);
205008
206362
  });
205009
206363
  return polygon.length > 0 ? polygon : undefined;
205010
- }, toBoolean = (value) => {
206364
+ }, toBoolean$1 = (value) => {
205011
206365
  if (value === undefined || value === null)
205012
206366
  return;
205013
206367
  if (typeof value === "boolean")
@@ -205025,14 +206379,14 @@ var Node$13 = class Node$14 {
205025
206379
  if (normalized === "0" || normalized === "false")
205026
206380
  return false;
205027
206381
  }
205028
- }, normalizeWrap$1 = (value) => {
205029
- if (!isPlainObject$1(value))
206382
+ }, normalizeWrap$2 = (value) => {
206383
+ if (!isPlainObject$2(value))
205030
206384
  return;
205031
206385
  const type = normalizeWrapType(value.type);
205032
206386
  if (!type)
205033
206387
  return;
205034
206388
  const wrap4 = { type };
205035
- const attrs = isPlainObject$1(value.attrs) ? value.attrs : {};
206389
+ const attrs = isPlainObject$2(value.attrs) ? value.attrs : {};
205036
206390
  const wrapText = normalizeWrapText(attrs.wrapText);
205037
206391
  if (wrapText)
205038
206392
  wrap4.wrapText = wrapText;
@@ -205051,7 +206405,7 @@ var Node$13 = class Node$14 {
205051
206405
  const polygon = normalizePolygon(attrs.polygon);
205052
206406
  if (polygon)
205053
206407
  wrap4.polygon = polygon;
205054
- const behindDoc = toBoolean(attrs.behindDoc);
206408
+ const behindDoc = toBoolean$1(attrs.behindDoc);
205055
206409
  if (behindDoc != null)
205056
206410
  wrap4.behindDoc = behindDoc;
205057
206411
  return wrap4;
@@ -205064,18 +206418,18 @@ var Node$13 = class Node$14 {
205064
206418
  return;
205065
206419
  return allowed.has(value) ? value : undefined;
205066
206420
  }, normalizeAnchorData = (value, attrs, wrapBehindDoc) => {
205067
- const raw = isPlainObject$1(value) ? value : undefined;
205068
- const marginOffset = isPlainObject$1(attrs.marginOffset) ? attrs.marginOffset : undefined;
205069
- const simplePos = isPlainObject$1(attrs.simplePos) ? attrs.simplePos : undefined;
205070
- const originalAttrs = isPlainObject$1(attrs.originalAttributes) ? attrs.originalAttributes : undefined;
206421
+ const raw = isPlainObject$2(value) ? value : undefined;
206422
+ const marginOffset = isPlainObject$2(attrs.marginOffset) ? attrs.marginOffset : undefined;
206423
+ const simplePos = isPlainObject$2(attrs.simplePos) ? attrs.simplePos : undefined;
206424
+ const originalAttrs = isPlainObject$2(attrs.originalAttributes) ? attrs.originalAttributes : undefined;
205071
206425
  const isAnchored = attrs.isAnchor === true || Boolean(raw);
205072
206426
  const anchor = {};
205073
206427
  if (isAnchored)
205074
206428
  anchor.isAnchored = true;
205075
- const hRelative = normalizeAnchorRelative(raw?.hRelativeFrom, H_RELATIVE_VALUES);
206429
+ const hRelative = normalizeAnchorRelative(raw?.hRelativeFrom, H_RELATIVE_VALUES$1);
205076
206430
  if (hRelative)
205077
206431
  anchor.hRelativeFrom = hRelative;
205078
- const vRelative = normalizeAnchorRelative(raw?.vRelativeFrom, V_RELATIVE_VALUES);
206432
+ const vRelative = normalizeAnchorRelative(raw?.vRelativeFrom, V_RELATIVE_VALUES$1);
205079
206433
  if (vRelative)
205080
206434
  anchor.vRelativeFrom = vRelative;
205081
206435
  const alignH = normalizeAnchorAlign(raw?.alignH, H_ALIGN_VALUES);
@@ -205090,11 +206444,64 @@ var Node$13 = class Node$14 {
205090
206444
  const offsetV = pickNumber(marginOffset?.top ?? marginOffset?.vertical ?? raw?.offsetV ?? simplePos?.y);
205091
206445
  if (offsetV != null)
205092
206446
  anchor.offsetV = offsetV;
205093
- const behindDoc = toBoolean(raw?.behindDoc ?? wrapBehindDoc ?? originalAttrs?.behindDoc);
206447
+ const behindDoc = toBoolean$1(raw?.behindDoc ?? wrapBehindDoc ?? originalAttrs?.behindDoc);
205094
206448
  if (behindDoc != null)
205095
206449
  anchor.behindDoc = behindDoc;
205096
206450
  return anchor.isAnchored || anchor.hRelativeFrom != null || anchor.vRelativeFrom != null || anchor.alignH != null || anchor.alignV != null || anchor.offsetH != null || anchor.offsetV != null || anchor.behindDoc != null ? anchor : undefined;
205097
- }, hydrateTableStyleAttrs = (tableNode, context, effectiveStyleId) => {
206451
+ }, WRAP_TYPES, WRAP_TEXT_VALUES, H_RELATIVE_VALUES, V_RELATIVE_VALUES, getAttrs = (node3) => {
206452
+ return isPlainObject$1(node3.attrs) ? node3.attrs : {};
206453
+ }, normalizeWrap$1 = (value) => {
206454
+ if (!isPlainObject$1(value))
206455
+ return;
206456
+ const type = typeof value.type === "string" && WRAP_TYPES.has(value.type) ? value.type : undefined;
206457
+ if (!type || type === "Inline")
206458
+ return;
206459
+ const wrap4 = { type };
206460
+ const attrs = isPlainObject$1(value.attrs) ? value.attrs : {};
206461
+ const wrapText = typeof attrs.wrapText === "string" && WRAP_TEXT_VALUES.has(attrs.wrapText) ? attrs.wrapText : undefined;
206462
+ if (wrapText)
206463
+ wrap4.wrapText = wrapText;
206464
+ const distTop = pickNumber(attrs.distTop ?? attrs.distT);
206465
+ if (distTop != null)
206466
+ wrap4.distTop = distTop;
206467
+ const distBottom = pickNumber(attrs.distBottom ?? attrs.distB);
206468
+ if (distBottom != null)
206469
+ wrap4.distBottom = distBottom;
206470
+ const distLeft = pickNumber(attrs.distLeft ?? attrs.distL);
206471
+ if (distLeft != null)
206472
+ wrap4.distLeft = distLeft;
206473
+ const distRight = pickNumber(attrs.distRight ?? attrs.distR);
206474
+ if (distRight != null)
206475
+ wrap4.distRight = distRight;
206476
+ const behindDoc = toBoolean(attrs.behindDoc);
206477
+ if (behindDoc != null)
206478
+ wrap4.behindDoc = behindDoc;
206479
+ return wrap4;
206480
+ }, normalizeAnchor = (value, attrs, wrapBehindDoc) => {
206481
+ const raw = isPlainObject$1(value) ? value : undefined;
206482
+ const marginOffset = isPlainObject$1(attrs.marginOffset) ? attrs.marginOffset : undefined;
206483
+ const simplePos = isPlainObject$1(attrs.simplePos) ? attrs.simplePos : undefined;
206484
+ const isAnchored = attrs.isAnchor === true || Boolean(raw);
206485
+ const anchor = {};
206486
+ if (isAnchored)
206487
+ anchor.isAnchored = true;
206488
+ const hRelative = typeof raw?.hRelativeFrom === "string" && H_RELATIVE_VALUES.has(raw.hRelativeFrom) ? raw.hRelativeFrom : undefined;
206489
+ if (hRelative)
206490
+ anchor.hRelativeFrom = hRelative;
206491
+ const vRelative = typeof raw?.vRelativeFrom === "string" && V_RELATIVE_VALUES.has(raw.vRelativeFrom) ? raw.vRelativeFrom : undefined;
206492
+ if (vRelative)
206493
+ anchor.vRelativeFrom = vRelative;
206494
+ const offsetH = pickNumber(marginOffset?.horizontal ?? marginOffset?.left ?? raw?.offsetH ?? simplePos?.x);
206495
+ if (offsetH != null)
206496
+ anchor.offsetH = offsetH;
206497
+ const offsetV = pickNumber(marginOffset?.top ?? marginOffset?.vertical ?? raw?.offsetV ?? simplePos?.y);
206498
+ if (offsetV != null)
206499
+ anchor.offsetV = offsetV;
206500
+ const behindDoc = toBoolean(raw?.behindDoc ?? wrapBehindDoc);
206501
+ if (behindDoc != null)
206502
+ anchor.behindDoc = behindDoc;
206503
+ return anchor.isAnchored || anchor.hRelativeFrom != null || anchor.vRelativeFrom != null || anchor.offsetH != null || anchor.offsetV != null || anchor.behindDoc != null ? anchor : undefined;
206504
+ }, EMPTY_CHART_DATA, hydrateTableStyleAttrs = (tableNode, context, effectiveStyleId) => {
205098
206505
  const hydration = {};
205099
206506
  const tableProps = tableNode.attrs?.tableProperties ?? null;
205100
206507
  let inlineBorders;
@@ -206711,6 +208118,8 @@ var Node$13 = class Node$14 {
206711
208118
  return drawingGeometryEqual(a2.geometry, b$1.geometry) && a2.shapeKind === b$1.shapeKind && a2.fillColor === b$1.fillColor && a2.strokeColor === b$1.strokeColor && a2.strokeWidth === b$1.strokeWidth;
206712
208119
  if (a2.drawingKind === "shapeGroup" && b$1.drawingKind === "shapeGroup")
206713
208120
  return drawingGeometryEqual(a2.geometry, b$1.geometry) && shapeGroupTransformEqual(a2.groupTransform, b$1.groupTransform) && shapeGroupSizeEqual(a2.size, b$1.size) && shapeGroupChildrenEqual(a2.shapes, b$1.shapes);
208121
+ if (a2.drawingKind === "chart" && b$1.drawingKind === "chart")
208122
+ return drawingGeometryEqual(a2.geometry, b$1.geometry) && a2.chartRelId === b$1.chartRelId && jsonEqual(a2.chartData, b$1.chartData);
206714
208123
  return true;
206715
208124
  }, boxSpacingEqual = (a2, b$1) => {
206716
208125
  if (a2 === b$1)
@@ -214464,7 +215873,7 @@ var Node$13 = class Node$14 {
214464
215873
  update() {
214465
215874
  return false;
214466
215875
  }
214467
- }, ShapeGroup, sharedAttributes$2 = () => ({
215876
+ }, ShapeGroup, CHART_IMMUTABILITY_KEY, chartPositionCache, Chart, sharedAttributes$2 = () => ({
214468
215877
  originalName: { default: null },
214469
215878
  originalXml: { default: null }
214470
215879
  }), hiddenRender = (type) => ["sd-passthrough", {
@@ -215148,6 +216557,7 @@ var Node$13 = class Node$14 {
215148
216557
  TextTransform,
215149
216558
  VectorShape,
215150
216559
  ShapeGroup,
216560
+ Chart,
215151
216561
  PermStart,
215152
216562
  PermEnd,
215153
216563
  PermStartBlock,
@@ -216864,9 +218274,9 @@ var Node$13 = class Node$14 {
216864
218274
  trackedChanges: context.trackedChanges ?? []
216865
218275
  });
216866
218276
  }, _hoisted_1$6, _hoisted_2$2, _hoisted_3, _hoisted_4, ContextMenu_default, _hoisted_1$5, BasicUpload_default, _hoisted_1$4, MIN_WIDTH = 200, PPI = 96, alignment = "flex-end", Ruler_default, GenericPopover_default, _hoisted_1$3, _hoisted_2$1, RESIZE_HANDLE_WIDTH_PX = 9, RESIZE_HANDLE_HEIGHT_PX = 9, RESIZE_HANDLE_OFFSET_PX = 4, DRAG_OVERLAY_EXTENSION_PX = 1000, MIN_DRAG_OVERLAY_WIDTH_PX = 2000, THROTTLE_INTERVAL_MS = 16, MIN_RESIZE_DELTA_PX = 1, TableResizeOverlay_default, _hoisted_1$2, OVERLAY_EXPANSION_PX = 2000, RESIZE_HANDLE_SIZE_PX = 12, MOUSE_MOVE_THROTTLE_MS = 16, DIMENSION_CHANGE_THRESHOLD_PX = 1, Z_INDEX_OVERLAY = 10, Z_INDEX_HANDLE = 15, Z_INDEX_GUIDELINE = 20, ImageResizeOverlay_default, LINK_CLICK_DEBOUNCE_MS = 300, CURSOR_UPDATE_TIMEOUT_MS = 10, POPOVER_VERTICAL_OFFSET_PX = 15, LinkClickHandler_default, _hoisted_1$1, _hoisted_2, DOCX2 = "application/vnd.openxmlformats-officedocument.wordprocessingml.document", TABLE_RESIZE_HOVER_THRESHOLD = 8, TABLE_RESIZE_THROTTLE_MS = 16, SuperEditor_default, _hoisted_1, SuperInput_default, SlashMenu, Extensions;
216867
- var init_src_CJCOedws_es = __esm(() => {
218277
+ var init_src_asiscfsz_es = __esm(() => {
216868
218278
  init_rolldown_runtime_B2q5OVn9_es();
216869
- init_SuperConverter_Cx2VynBq_es();
218279
+ init_SuperConverter_BDyjQdwB_es();
216870
218280
  init_jszip_ChlR43oI_es();
216871
218281
  init_uuid_qzgm05fK_es();
216872
218282
  init_constants_CMPtQbp7_es();
@@ -231111,6 +232521,20 @@ function print() { __p += __j.call(arguments, '') }
231111
232521
  INLINE_IMAGE: "superdoc-inline-image",
231112
232522
  INLINE_IMAGE_CLIP_WRAPPER: "superdoc-inline-image-clip-wrapper"
231113
232523
  };
232524
+ SERIES_COLORS = [
232525
+ "#4472C4",
232526
+ "#ED7D31",
232527
+ "#A5A5A5",
232528
+ "#FFC000",
232529
+ "#5B9BD5",
232530
+ "#70AD47"
232531
+ ];
232532
+ CHART_PADDING = {
232533
+ top: 30,
232534
+ right: 20,
232535
+ bottom: 50,
232536
+ left: 60
232537
+ };
231114
232538
  init_dist();
231115
232539
  globalValidationStats = new ValidationStatsCollector;
231116
232540
  TICK_SPACING_PX = DEFAULT_PPI / 8;
@@ -232933,6 +234357,8 @@ function print() { __p += __j.call(arguments, '') }
232933
234357
  return this.createVectorShapeElement(block, fragment2.geometry, true, 1, 1, context);
232934
234358
  if (block.drawingKind === "shapeGroup")
232935
234359
  return this.createShapeGroupElement(block, context);
234360
+ if (block.drawingKind === "chart")
234361
+ return this.createChartElement(block);
232936
234362
  return this.createDrawingPlaceholder();
232937
234363
  }
232938
234364
  createDrawingImageElement(block) {
@@ -233430,6 +234856,9 @@ function print() { __p += __j.call(arguments, '') }
233430
234856
  placeholder.style.border = "1px dashed rgba(15, 23, 42, 0.3)";
233431
234857
  return placeholder;
233432
234858
  }
234859
+ createChartElement(block) {
234860
+ return createChartElement(this.doc, block.chartData, block.geometry);
234861
+ }
233433
234862
  renderTableFragment(fragment2, context, sdtBoundary) {
233434
234863
  if (!this.doc)
233435
234864
  throw new Error("DomPainter: document is not available");
@@ -233448,6 +234877,8 @@ function print() { __p += __j.call(arguments, '') }
233448
234877
  return this.createShapeGroupElement(block, context);
233449
234878
  if (block.drawingKind === "vectorShape")
233450
234879
  return this.createVectorShapeElement(block, block.geometry, false, 1, 1, context);
234880
+ if (block.drawingKind === "chart")
234881
+ return this.createChartElement(block);
233451
234882
  return this.createDrawingPlaceholder();
233452
234883
  };
233453
234884
  return renderTableFragment({
@@ -233482,7 +234913,7 @@ function print() { __p += __j.call(arguments, '') }
233482
234913
  buildLinkRenderData(link2) {
233483
234914
  const dataset = buildLinkDataset(link2);
233484
234915
  const sanitized = typeof link2.href === "string" ? sanitizeHref(link2.href) : null;
233485
- const anchorHref = normalizeAnchor(link2.anchor ?? link2.name ?? "");
234916
+ const anchorHref = normalizeAnchor$1(link2.anchor ?? link2.name ?? "");
233486
234917
  let href = sanitized?.href ?? anchorHref;
233487
234918
  if (link2.version === 2)
233488
234919
  href = appendDocLocation(href, link2.docLocation ?? null);
@@ -234774,7 +236205,7 @@ function print() { __p += __j.call(arguments, '') }
234774
236205
  }
234775
236206
  };
234776
236207
  sdtMetadataCache = /* @__PURE__ */ new Map;
234777
- WRAP_TYPES$1 = new Set([
236208
+ WRAP_TYPES$2 = new Set([
234778
236209
  "None",
234779
236210
  "Square",
234780
236211
  "Tight",
@@ -234782,18 +236213,18 @@ function print() { __p += __j.call(arguments, '') }
234782
236213
  "TopAndBottom",
234783
236214
  "Inline"
234784
236215
  ]);
234785
- WRAP_TEXT_VALUES$1 = new Set([
236216
+ WRAP_TEXT_VALUES$2 = new Set([
234786
236217
  "bothSides",
234787
236218
  "left",
234788
236219
  "right",
234789
236220
  "largest"
234790
236221
  ]);
234791
- H_RELATIVE_VALUES$1 = new Set([
236222
+ H_RELATIVE_VALUES$2 = new Set([
234792
236223
  "column",
234793
236224
  "page",
234794
236225
  "margin"
234795
236226
  ]);
234796
- V_RELATIVE_VALUES$1 = new Set([
236227
+ V_RELATIVE_VALUES$2 = new Set([
234797
236228
  "paragraph",
234798
236229
  "page",
234799
236230
  "margin"
@@ -234808,7 +236239,7 @@ function print() { __p += __j.call(arguments, '') }
234808
236239
  "center",
234809
236240
  "bottom"
234810
236241
  ]);
234811
- WRAP_TYPES = new Set([
236242
+ WRAP_TYPES$1 = new Set([
234812
236243
  "None",
234813
236244
  "Square",
234814
236245
  "Tight",
@@ -234816,18 +236247,18 @@ function print() { __p += __j.call(arguments, '') }
234816
236247
  "TopAndBottom",
234817
236248
  "Inline"
234818
236249
  ]);
234819
- WRAP_TEXT_VALUES = new Set([
236250
+ WRAP_TEXT_VALUES$1 = new Set([
234820
236251
  "bothSides",
234821
236252
  "left",
234822
236253
  "right",
234823
236254
  "largest"
234824
236255
  ]);
234825
- H_RELATIVE_VALUES = new Set([
236256
+ H_RELATIVE_VALUES$1 = new Set([
234826
236257
  "column",
234827
236258
  "page",
234828
236259
  "margin"
234829
236260
  ]);
234830
- V_RELATIVE_VALUES = new Set([
236261
+ V_RELATIVE_VALUES$1 = new Set([
234831
236262
  "paragraph",
234832
236263
  "page",
234833
236264
  "margin"
@@ -234842,6 +236273,34 @@ function print() { __p += __j.call(arguments, '') }
234842
236273
  "center",
234843
236274
  "bottom"
234844
236275
  ]);
236276
+ WRAP_TYPES = new Set([
236277
+ "None",
236278
+ "Square",
236279
+ "Tight",
236280
+ "Through",
236281
+ "TopAndBottom",
236282
+ "Inline"
236283
+ ]);
236284
+ WRAP_TEXT_VALUES = new Set([
236285
+ "bothSides",
236286
+ "left",
236287
+ "right",
236288
+ "largest"
236289
+ ]);
236290
+ H_RELATIVE_VALUES = new Set([
236291
+ "column",
236292
+ "page",
236293
+ "margin"
236294
+ ]);
236295
+ V_RELATIVE_VALUES = new Set([
236296
+ "paragraph",
236297
+ "page",
236298
+ "margin"
236299
+ ]);
236300
+ EMPTY_CHART_DATA = {
236301
+ chartType: "unknown",
236302
+ series: []
236303
+ };
234845
236304
  INLINE_CONVERTERS_REGISTRY = {
234846
236305
  footnoteReference: { inlineConverter: footnoteReferenceToBlock },
234847
236306
  endnoteReference: { inlineConverter: endnoteReferenceToBlock },
@@ -234886,7 +236345,8 @@ function print() { __p += __j.call(arguments, '') }
234886
236345
  vectorShape: vectorShapeNodeToDrawingBlock,
234887
236346
  shapeGroup: shapeGroupNodeToDrawingBlock,
234888
236347
  shapeContainer: shapeContainerNodeToDrawingBlock,
234889
- shapeTextbox: shapeTextboxNodeToDrawingBlock
236348
+ shapeTextbox: shapeTextboxNodeToDrawingBlock,
236349
+ chart: chartNodeToDrawingBlock
234890
236350
  };
234891
236351
  DEFAULT_SIZE = 10 / 0.75;
234892
236352
  nodeHandlers2 = {
@@ -234903,7 +236363,8 @@ function print() { __p += __j.call(arguments, '') }
234903
236363
  vectorShape: handleVectorShapeNode,
234904
236364
  shapeGroup: handleShapeGroupNode,
234905
236365
  shapeContainer: handleShapeContainerNode,
234906
- shapeTextbox: handleShapeTextboxNode
236366
+ shapeTextbox: handleShapeTextboxNode,
236367
+ chart: handleChartNode
234907
236368
  };
234908
236369
  converters = {
234909
236370
  contentBlockNodeToDrawingBlock,
@@ -234912,6 +236373,7 @@ function print() { __p += __j.call(arguments, '') }
234912
236373
  shapeGroupNodeToDrawingBlock,
234913
236374
  shapeContainerNodeToDrawingBlock,
234914
236375
  shapeTextboxNodeToDrawingBlock,
236376
+ chartNodeToDrawingBlock,
234915
236377
  tableNodeToBlock,
234916
236378
  paragraphToFlowBlocks
234917
236379
  };
@@ -244493,6 +245955,104 @@ function print() { __p += __j.call(arguments, '') }
244493
245955
  };
244494
245956
  }
244495
245957
  });
245958
+ CHART_IMMUTABILITY_KEY = new PluginKey("chartImmutability");
245959
+ chartPositionCache = /* @__PURE__ */ new WeakMap;
245960
+ Chart = Node$13.create({
245961
+ name: "chart",
245962
+ group: "inline",
245963
+ inline: true,
245964
+ atom: true,
245965
+ draggable: false,
245966
+ selectable: true,
245967
+ addOptions() {
245968
+ return { htmlAttributes: {} };
245969
+ },
245970
+ addAttributes() {
245971
+ return {
245972
+ width: {
245973
+ default: 400,
245974
+ renderDOM: (attrs) => {
245975
+ if (attrs.width == null)
245976
+ return {};
245977
+ return { "data-width": attrs.width };
245978
+ }
245979
+ },
245980
+ height: {
245981
+ default: 300,
245982
+ renderDOM: (attrs) => {
245983
+ if (attrs.height == null)
245984
+ return {};
245985
+ return { "data-height": attrs.height };
245986
+ }
245987
+ },
245988
+ chartData: {
245989
+ default: null,
245990
+ rendered: false
245991
+ },
245992
+ chartRelId: {
245993
+ default: null,
245994
+ rendered: false
245995
+ },
245996
+ chartPartPath: {
245997
+ default: null,
245998
+ rendered: false
245999
+ },
246000
+ isAnchor: {
246001
+ default: false,
246002
+ rendered: false
246003
+ },
246004
+ anchorData: {
246005
+ default: null,
246006
+ rendered: false
246007
+ },
246008
+ wrap: {
246009
+ default: null,
246010
+ rendered: false
246011
+ },
246012
+ padding: {
246013
+ default: null,
246014
+ rendered: false
246015
+ },
246016
+ marginOffset: {
246017
+ default: null,
246018
+ rendered: false
246019
+ },
246020
+ originalAttributes: {
246021
+ default: null,
246022
+ rendered: false
246023
+ },
246024
+ originalChildren: {
246025
+ default: null,
246026
+ rendered: false
246027
+ },
246028
+ originalChildOrder: {
246029
+ default: null,
246030
+ rendered: false
246031
+ },
246032
+ originalXml: {
246033
+ default: null,
246034
+ rendered: false
246035
+ },
246036
+ drawingContent: {
246037
+ ...Attribute2.json,
246038
+ default: null,
246039
+ rendered: false
246040
+ }
246041
+ };
246042
+ },
246043
+ parseDOM() {
246044
+ return [{ tag: "sd-chart" }];
246045
+ },
246046
+ renderDOM({ htmlAttributes }) {
246047
+ return ["sd-chart", {
246048
+ ...htmlAttributes,
246049
+ style: "display: inline-block;"
246050
+ }];
246051
+ },
246052
+ addPmPlugins() {
246053
+ return [createChartImmutabilityPlugin()];
246054
+ }
246055
+ });
244496
246056
  PassthroughBlock = Node$13.create({
244497
246057
  name: "passthroughBlock",
244498
246058
  group: "block",
@@ -249485,8 +251045,8 @@ function print() { __p += __j.call(arguments, '') }
249485
251045
  return isObjectLike_default(value) && hasOwnProperty$8.call(value, "callee") && !propertyIsEnumerable$1.call(value, "callee");
249486
251046
  };
249487
251047
  stubFalse_default = stubFalse;
249488
- freeExports$2 = typeof exports_src_CJCOedws_es == "object" && exports_src_CJCOedws_es && !exports_src_CJCOedws_es.nodeType && exports_src_CJCOedws_es;
249489
- freeModule$2 = freeExports$2 && typeof module_src_CJCOedws_es == "object" && module_src_CJCOedws_es && !module_src_CJCOedws_es.nodeType && module_src_CJCOedws_es;
251048
+ freeExports$2 = typeof exports_src_asiscfsz_es == "object" && exports_src_asiscfsz_es && !exports_src_asiscfsz_es.nodeType && exports_src_asiscfsz_es;
251049
+ freeModule$2 = freeExports$2 && typeof module_src_asiscfsz_es == "object" && module_src_asiscfsz_es && !module_src_asiscfsz_es.nodeType && module_src_asiscfsz_es;
249490
251050
  Buffer$1 = freeModule$2 && freeModule$2.exports === freeExports$2 ? _root_default.Buffer : undefined;
249491
251051
  isBuffer_default = (Buffer$1 ? Buffer$1.isBuffer : undefined) || stubFalse_default;
249492
251052
  typedArrayTags = {};
@@ -249494,8 +251054,8 @@ function print() { __p += __j.call(arguments, '') }
249494
251054
  typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] = typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] = typedArrayTags[dataViewTag$2] = typedArrayTags[dateTag$1] = typedArrayTags[errorTag$1] = typedArrayTags[funcTag] = typedArrayTags[mapTag$2] = typedArrayTags[numberTag$1] = typedArrayTags[objectTag$3] = typedArrayTags[regexpTag$1] = typedArrayTags[setTag$2] = typedArrayTags[stringTag$1] = typedArrayTags[weakMapTag$1] = false;
249495
251055
  _baseIsTypedArray_default = baseIsTypedArray;
249496
251056
  _baseUnary_default = baseUnary;
249497
- freeExports$1 = typeof exports_src_CJCOedws_es == "object" && exports_src_CJCOedws_es && !exports_src_CJCOedws_es.nodeType && exports_src_CJCOedws_es;
249498
- freeModule$1 = freeExports$1 && typeof module_src_CJCOedws_es == "object" && module_src_CJCOedws_es && !module_src_CJCOedws_es.nodeType && module_src_CJCOedws_es;
251057
+ freeExports$1 = typeof exports_src_asiscfsz_es == "object" && exports_src_asiscfsz_es && !exports_src_asiscfsz_es.nodeType && exports_src_asiscfsz_es;
251058
+ freeModule$1 = freeExports$1 && typeof module_src_asiscfsz_es == "object" && module_src_asiscfsz_es && !module_src_asiscfsz_es.nodeType && module_src_asiscfsz_es;
249499
251059
  freeProcess = freeModule$1 && freeModule$1.exports === freeExports$1 && _freeGlobal_default.process;
249500
251060
  _nodeUtil_default = function() {
249501
251061
  try {
@@ -249600,8 +251160,8 @@ function print() { __p += __j.call(arguments, '') }
249600
251160
  Stack.prototype.has = _stackHas_default;
249601
251161
  Stack.prototype.set = _stackSet_default;
249602
251162
  _Stack_default = Stack;
249603
- freeExports = typeof exports_src_CJCOedws_es == "object" && exports_src_CJCOedws_es && !exports_src_CJCOedws_es.nodeType && exports_src_CJCOedws_es;
249604
- freeModule = freeExports && typeof module_src_CJCOedws_es == "object" && module_src_CJCOedws_es && !module_src_CJCOedws_es.nodeType && module_src_CJCOedws_es;
251163
+ freeExports = typeof exports_src_asiscfsz_es == "object" && exports_src_asiscfsz_es && !exports_src_asiscfsz_es.nodeType && exports_src_asiscfsz_es;
251164
+ freeModule = freeExports && typeof module_src_asiscfsz_es == "object" && module_src_asiscfsz_es && !module_src_asiscfsz_es.nodeType && module_src_asiscfsz_es;
249605
251165
  Buffer4 = freeModule && freeModule.exports === freeExports ? _root_default.Buffer : undefined;
249606
251166
  allocUnsafe = Buffer4 ? Buffer4.allocUnsafe : undefined;
249607
251167
  _cloneBuffer_default = cloneBuffer;
@@ -257681,8 +259241,8 @@ var init_zipper_DqXT7uTa_es = __esm(() => {
257681
259241
 
257682
259242
  // ../../packages/superdoc/dist/super-editor.es.js
257683
259243
  var init_super_editor_es = __esm(() => {
257684
- init_src_CJCOedws_es();
257685
- init_SuperConverter_Cx2VynBq_es();
259244
+ init_src_asiscfsz_es();
259245
+ init_SuperConverter_BDyjQdwB_es();
257686
259246
  init_jszip_ChlR43oI_es();
257687
259247
  init_xml_js_DLE8mr0n_es();
257688
259248
  init_constants_CMPtQbp7_es();
@@ -264124,11 +265684,11 @@ function ensureSectPrElement2(current) {
264124
265684
  return cloneXmlElement2(current);
264125
265685
  return createSectPrElement2();
264126
265686
  }
264127
- function findChild2(element3, childName) {
265687
+ function findChild3(element3, childName) {
264128
265688
  return element3.elements?.find((entry) => entry?.name === childName);
264129
265689
  }
264130
265690
  function ensureChild2(element3, childName) {
264131
- const existing = findChild2(element3, childName);
265691
+ const existing = findChild3(element3, childName);
264132
265692
  if (existing)
264133
265693
  return existing;
264134
265694
  const created = { type: "element", name: childName, attributes: {}, elements: [] };
@@ -264163,7 +265723,7 @@ function writeSectPrBreakType2(sectPr, breakType) {
264163
265723
  setStringAttr2(typeNode, "w:val", breakType);
264164
265724
  }
264165
265725
  function readSectPrMargins2(sectPr) {
264166
- const pgMar = findChild2(sectPr, "w:pgMar");
265726
+ const pgMar = findChild3(sectPr, "w:pgMar");
264167
265727
  if (!pgMar)
264168
265728
  return {};
264169
265729
  return {
@@ -264197,7 +265757,7 @@ function writeSectPrHeaderFooterMargins2(sectPr, margins) {
264197
265757
  setStringAttr2(pgMar, "w:footer", toTwipsString2(margins.footer));
264198
265758
  }
264199
265759
  function readSectPrPageSetup2(sectPr) {
264200
- const pgSz = findChild2(sectPr, "w:pgSz");
265760
+ const pgSz = findChild3(sectPr, "w:pgSz");
264201
265761
  if (!pgSz)
264202
265762
  return;
264203
265763
  const width = toInchesFromTwips2(pgSz.attributes?.["w:w"]);
@@ -264233,7 +265793,7 @@ function writeSectPrPageSetup2(sectPr, setup) {
264233
265793
  }
264234
265794
  }
264235
265795
  function readSectPrColumns2(sectPr) {
264236
- const cols = findChild2(sectPr, "w:cols");
265796
+ const cols = findChild3(sectPr, "w:cols");
264237
265797
  if (!cols)
264238
265798
  return;
264239
265799
  const count = toPositiveInteger2(cols.attributes?.["w:num"]);
@@ -264253,7 +265813,7 @@ function writeSectPrColumns2(sectPr, columns) {
264253
265813
  setBooleanAttr2(cols, "w:equalWidth", columns.equalWidth);
264254
265814
  }
264255
265815
  function readSectPrLineNumbering2(sectPr) {
264256
- const lnNumType = findChild2(sectPr, "w:lnNumType");
265816
+ const lnNumType = findChild3(sectPr, "w:lnNumType");
264257
265817
  if (!lnNumType)
264258
265818
  return;
264259
265819
  const restartRaw = asString2(lnNumType.attributes?.["w:restart"]);
@@ -264282,7 +265842,7 @@ function writeSectPrLineNumbering2(sectPr, numbering) {
264282
265842
  setStringAttr2(lnNumType, "w:restart", numbering.restart);
264283
265843
  }
264284
265844
  function readSectPrPageNumbering2(sectPr) {
264285
- const pgNumType = findChild2(sectPr, "w:pgNumType");
265845
+ const pgNumType = findChild3(sectPr, "w:pgNumType");
264286
265846
  if (!pgNumType)
264287
265847
  return;
264288
265848
  const formatRaw = asString2(pgNumType.attributes?.["w:fmt"]);
@@ -264309,7 +265869,7 @@ function writeSectPrTitlePage2(sectPr, enabled) {
264309
265869
  removeChildren2(sectPr, (entry) => entry.name === "w:titlePg");
264310
265870
  }
264311
265871
  function readSectPrVerticalAlign2(sectPr) {
264312
- const vAlign = findChild2(sectPr, "w:vAlign");
265872
+ const vAlign = findChild3(sectPr, "w:vAlign");
264313
265873
  const raw = asString2(vAlign?.attributes?.["w:val"]);
264314
265874
  return isKnownValue2(raw, SECTION_VERTICAL_ALIGN_VALUES2) ? raw : undefined;
264315
265875
  }
@@ -264318,7 +265878,7 @@ function writeSectPrVerticalAlign2(sectPr, value) {
264318
265878
  setStringAttr2(vAlign, "w:val", value);
264319
265879
  }
264320
265880
  function readSectPrDirection2(sectPr) {
264321
- const bidi = findChild2(sectPr, "w:bidi");
265881
+ const bidi = findChild3(sectPr, "w:bidi");
264322
265882
  if (!bidi)
264323
265883
  return;
264324
265884
  const value = toBooleanAttr2(bidi.attributes?.["w:val"]);
@@ -264401,13 +265961,13 @@ function writeBorderSpec2(parent, edge, border) {
264401
265961
  setBooleanAttr2(edgeElement, "w:frame", border.frame);
264402
265962
  }
264403
265963
  function readSectPrPageBorders2(sectPr) {
264404
- const pgBorders = findChild2(sectPr, "w:pgBorders");
265964
+ const pgBorders = findChild3(sectPr, "w:pgBorders");
264405
265965
  if (!pgBorders)
264406
265966
  return;
264407
- const top = readBorderSpec2(findChild2(pgBorders, "w:top"));
264408
- const right2 = readBorderSpec2(findChild2(pgBorders, "w:right"));
264409
- const bottom2 = readBorderSpec2(findChild2(pgBorders, "w:bottom"));
264410
- const left2 = readBorderSpec2(findChild2(pgBorders, "w:left"));
265967
+ const top = readBorderSpec2(findChild3(pgBorders, "w:top"));
265968
+ const right2 = readBorderSpec2(findChild3(pgBorders, "w:right"));
265969
+ const bottom2 = readBorderSpec2(findChild3(pgBorders, "w:bottom"));
265970
+ const left2 = readBorderSpec2(findChild3(pgBorders, "w:left"));
264411
265971
  const display = toPageBorderDisplay2(pgBorders.attributes?.["w:display"]);
264412
265972
  const offsetFrom = toPageBorderOffsetFrom2(pgBorders.attributes?.["w:offsetFrom"]);
264413
265973
  const zOrder = toPageBorderZOrder2(pgBorders.attributes?.["w:zOrder"]);
@@ -305409,6 +306969,227 @@ function parseRelativeHeight2(value) {
305409
306969
  }
305410
306970
  var RELATIVE_HEIGHT_MIN2 = 0, RELATIVE_HEIGHT_MAX2 = 4294967295;
305411
306971
 
306972
+ // ../../packages/super-editor/src/core/super-converter/v3/handlers/wp/helpers/chart-helpers.js
306973
+ function normalizeChartTarget2(target) {
306974
+ let cleaned = target;
306975
+ if (cleaned.startsWith("/"))
306976
+ cleaned = cleaned.slice(1);
306977
+ if (cleaned.startsWith("./"))
306978
+ cleaned = cleaned.slice(2);
306979
+ while (cleaned.startsWith("../"))
306980
+ cleaned = cleaned.slice(3);
306981
+ if (!cleaned.startsWith("word/"))
306982
+ cleaned = `word/${cleaned}`;
306983
+ return cleaned;
306984
+ }
306985
+ function resolveChartPart2(docx, chartRelId, filename) {
306986
+ if (!chartRelId || !docx)
306987
+ return null;
306988
+ const currentFile = filename || "document.xml";
306989
+ const rels = docx[`word/_rels/${currentFile}.rels`] || docx["word/_rels/document.xml.rels"];
306990
+ const relationships = findChild4(rels, "Relationships");
306991
+ const chartRel = relationships?.elements?.find((el) => getAttr2(el, "Id") === chartRelId);
306992
+ if (!chartRel)
306993
+ return null;
306994
+ const target = getAttr2(chartRel, "Target");
306995
+ if (!target)
306996
+ return null;
306997
+ const chartPartPath = normalizeChartTarget2(target);
306998
+ return { chartPartPath, chartRel };
306999
+ }
307000
+ function parseChartXml2(chartXml) {
307001
+ const chartSpace = chartXml?.name === "c:chartSpace" ? chartXml : findChild4(chartXml, "c:chartSpace");
307002
+ const chart = findChild4(chartSpace, "c:chart");
307003
+ if (!chart)
307004
+ return null;
307005
+ const plotArea = findChild4(chart, "c:plotArea");
307006
+ if (!plotArea)
307007
+ return null;
307008
+ const chartTypeEntry = findChartTypeElement2(plotArea);
307009
+ if (!chartTypeEntry)
307010
+ return null;
307011
+ const { element: chartTypeEl, chartType } = chartTypeEntry;
307012
+ const subType = extractGrouping2(chartTypeEl);
307013
+ const barDirection = extractBarDirection2(chartTypeEl);
307014
+ const series = parseSeries2(chartTypeEl, chartType);
307015
+ const categoryAxis = parseAxis2(plotArea, "c:catAx");
307016
+ const valueAxis = parseAxis2(plotArea, "c:valAx");
307017
+ const legendPosition = parseLegendPosition2(chart);
307018
+ const styleId = parseStyleId2(chartSpace);
307019
+ return {
307020
+ chartType,
307021
+ ...subType && { subType },
307022
+ ...barDirection && { barDirection },
307023
+ series,
307024
+ ...categoryAxis && { categoryAxis },
307025
+ ...valueAxis && { valueAxis },
307026
+ ...legendPosition && { legendPosition },
307027
+ ...styleId != null && { styleId }
307028
+ };
307029
+ }
307030
+ function findChartTypeElement2(plotArea) {
307031
+ for (const el of plotArea.elements || []) {
307032
+ if (CHART_TYPE_NAMES2.has(el.name)) {
307033
+ return { element: el, chartType: CHART_TYPE_MAP2[el.name] };
307034
+ }
307035
+ }
307036
+ for (const el of plotArea.elements || []) {
307037
+ if (el.name?.startsWith("c:") && el.name.endsWith("Chart")) {
307038
+ return { element: el, chartType: el.name.replace("c:", "") };
307039
+ }
307040
+ }
307041
+ return null;
307042
+ }
307043
+ function extractGrouping2(chartTypeEl) {
307044
+ const grouping = findChild4(chartTypeEl, "c:grouping");
307045
+ return getAttr2(grouping, "val") || undefined;
307046
+ }
307047
+ function extractBarDirection2(chartTypeEl) {
307048
+ const barDir = findChild4(chartTypeEl, "c:barDir");
307049
+ const val = getAttr2(barDir, "val");
307050
+ return val === "col" || val === "bar" ? val : undefined;
307051
+ }
307052
+ function parseSeries2(chartTypeEl, chartType) {
307053
+ return findChildren3(chartTypeEl, "c:ser").map((seriesEl) => parseOneSeries2(seriesEl, chartType));
307054
+ }
307055
+ function parseOneSeries2(serEl, chartType) {
307056
+ const name = extractSeriesName2(serEl);
307057
+ const categories = extractCachedStrings2(findChild4(serEl, "c:cat"));
307058
+ const values2 = extractCachedNumbers2(findChild4(serEl, "c:val"));
307059
+ const xValues = extractCachedNumbers2(findChild4(serEl, "c:xVal"));
307060
+ const yValues = extractCachedNumbers2(findChild4(serEl, "c:yVal"));
307061
+ const bubbleSizes = extractCachedNumbers2(findChild4(serEl, "c:bubbleSize"));
307062
+ if (chartType === "scatterChart" || chartType === "bubbleChart") {
307063
+ const parsedCategoryValues = categories.map((value) => Number(value));
307064
+ const numericCategoryValues = parsedCategoryValues.every((value) => Number.isFinite(value)) ? parsedCategoryValues : [];
307065
+ const seriesXValues = xValues.length ? xValues : numericCategoryValues;
307066
+ const seriesYValues = yValues.length ? yValues : values2;
307067
+ const seriesCategories = categories.length ? categories : seriesXValues.map((value, index3) => formatChartLabel2(value, index3 + 1));
307068
+ const seriesData = {
307069
+ name,
307070
+ categories: seriesCategories,
307071
+ values: seriesYValues,
307072
+ ...seriesXValues.length ? { xValues: seriesXValues } : {},
307073
+ ...chartType === "bubbleChart" && bubbleSizes.length ? { bubbleSizes } : {}
307074
+ };
307075
+ return seriesData;
307076
+ }
307077
+ return { name, categories, values: values2 };
307078
+ }
307079
+ function formatChartLabel2(value, fallbackIndex) {
307080
+ if (!Number.isFinite(value))
307081
+ return `Category ${fallbackIndex}`;
307082
+ if (Number.isInteger(value))
307083
+ return String(value);
307084
+ return String(Number(value.toFixed(3)));
307085
+ }
307086
+ function extractSeriesName2(serEl) {
307087
+ const tx = findChild4(serEl, "c:tx");
307088
+ const strRef = findChild4(tx, "c:strRef");
307089
+ const strCache = findChild4(strRef, "c:strCache");
307090
+ const pt = findChild4(strCache, "c:pt");
307091
+ const v = findChild4(pt, "c:v");
307092
+ return v?.elements?.[0]?.text ?? `Series ${getAttr2(findChild4(serEl, "c:idx"), "val") ?? ""}`.trim();
307093
+ }
307094
+ function extractCachedStrings2(parentEl) {
307095
+ if (!parentEl)
307096
+ return [];
307097
+ const strRef = findChild4(parentEl, "c:strRef");
307098
+ const strCache = findChild4(strRef, "c:strCache");
307099
+ const numRef = findChild4(parentEl, "c:numRef");
307100
+ const numCache = findChild4(numRef, "c:numCache");
307101
+ const cache2 = strCache || numCache;
307102
+ if (!cache2)
307103
+ return [];
307104
+ return findChildren3(cache2, "c:pt").sort((a2, b2) => (Number(getAttr2(a2, "idx")) || 0) - (Number(getAttr2(b2, "idx")) || 0)).map((pt) => findChild4(pt, "c:v")?.elements?.[0]?.text ?? "");
307105
+ }
307106
+ function extractCachedNumbers2(parentEl) {
307107
+ if (!parentEl)
307108
+ return [];
307109
+ const numRef = findChild4(parentEl, "c:numRef");
307110
+ const numCache = findChild4(numRef, "c:numCache");
307111
+ if (!numCache)
307112
+ return [];
307113
+ return findChildren3(numCache, "c:pt").sort((a2, b2) => (Number(getAttr2(a2, "idx")) || 0) - (Number(getAttr2(b2, "idx")) || 0)).map((pt) => {
307114
+ const text7 = findChild4(pt, "c:v")?.elements?.[0]?.text;
307115
+ const num = Number(text7);
307116
+ return Number.isFinite(num) ? num : 0;
307117
+ });
307118
+ }
307119
+ function parseAxis2(plotArea, axisName) {
307120
+ const axis = findChild4(plotArea, axisName);
307121
+ if (!axis)
307122
+ return;
307123
+ const titleEl = findChild4(axis, "c:title");
307124
+ const title = extractAxisTitle2(titleEl);
307125
+ const scaling = findChild4(axis, "c:scaling");
307126
+ const orientation = getAttr2(findChild4(scaling, "c:orientation"), "val");
307127
+ const config12 = {};
307128
+ if (title)
307129
+ config12.title = title;
307130
+ if (orientation === "minMax" || orientation === "maxMin")
307131
+ config12.orientation = orientation;
307132
+ return Object.keys(config12).length > 0 ? config12 : undefined;
307133
+ }
307134
+ function extractAxisTitle2(titleEl) {
307135
+ if (!titleEl)
307136
+ return;
307137
+ const tx = findChild4(titleEl, "c:tx");
307138
+ const rich = findChild4(tx, "c:rich");
307139
+ const p4 = findChild4(rich, "a:p");
307140
+ const r2 = findChild4(p4, "a:r");
307141
+ const t = findChild4(r2, "a:t");
307142
+ return t?.elements?.[0]?.text || undefined;
307143
+ }
307144
+ function parseLegendPosition2(chart) {
307145
+ const legend = findChild4(chart, "c:legend");
307146
+ if (!legend)
307147
+ return;
307148
+ const legendPos = findChild4(legend, "c:legendPos");
307149
+ return getAttr2(legendPos, "val") || undefined;
307150
+ }
307151
+ function parseStyleId2(chartSpace) {
307152
+ const altContent = findChild4(chartSpace, "mc:AlternateContent");
307153
+ if (altContent) {
307154
+ const choice = findChild4(altContent, "mc:Choice");
307155
+ const c14Style = findChild4(choice, "c14:style");
307156
+ const val2 = getAttr2(c14Style, "val");
307157
+ if (val2 != null)
307158
+ return Number(val2);
307159
+ const fallback = findChild4(altContent, "mc:Fallback");
307160
+ const fallbackStyle = findChild4(fallback, "c:style");
307161
+ const fallbackVal = getAttr2(fallbackStyle, "val");
307162
+ if (fallbackVal != null)
307163
+ return Number(fallbackVal);
307164
+ }
307165
+ const cStyle = findChild4(chartSpace, "c:style");
307166
+ const val = getAttr2(cStyle, "val");
307167
+ return val != null ? Number(val) : undefined;
307168
+ }
307169
+ var CHART_URI = "http://schemas.openxmlformats.org/drawingml/2006/chart", CHART_TYPE_MAP2, CHART_TYPE_NAMES2, findChild4 = (node4, name) => node4?.elements?.find((el) => el.name === name), findChildren3 = (node4, name) => node4?.elements?.filter((el) => el.name === name) ?? [], getAttr2 = (node4, attr) => node4?.attributes?.[attr];
307170
+ var init_chart_helpers = __esm(() => {
307171
+ CHART_TYPE_MAP2 = {
307172
+ "c:barChart": "barChart",
307173
+ "c:bar3DChart": "barChart",
307174
+ "c:lineChart": "lineChart",
307175
+ "c:line3DChart": "lineChart",
307176
+ "c:pieChart": "pieChart",
307177
+ "c:pie3DChart": "pieChart",
307178
+ "c:ofPieChart": "ofPieChart",
307179
+ "c:areaChart": "areaChart",
307180
+ "c:area3DChart": "areaChart",
307181
+ "c:scatterChart": "scatterChart",
307182
+ "c:bubbleChart": "bubbleChart",
307183
+ "c:bubble3DChart": "bubbleChart",
307184
+ "c:doughnutChart": "doughnutChart",
307185
+ "c:radarChart": "radarChart",
307186
+ "c:stockChart": "stockChart",
307187
+ "c:surfaceChart": "surfaceChart",
307188
+ "c:surface3DChart": "surfaceChart"
307189
+ };
307190
+ CHART_TYPE_NAMES2 = new Set(Object.keys(CHART_TYPE_MAP2));
307191
+ });
307192
+
305412
307193
  // ../../packages/super-editor/src/core/super-converter/v3/handlers/wp/helpers/encode-image-node-helpers.js
305413
307194
  function handleImageNode3(node4, params3, isAnchor) {
305414
307195
  if (!node4)
@@ -305554,6 +307335,9 @@ function handleImageNode3(node4, params3, isAnchor) {
305554
307335
  };
305555
307336
  return handleShapeGroup2(params3, node4, graphicData, size3, padding, shapeMarginOffset, anchorData, wrap6, isHidden2);
305556
307337
  }
307338
+ if (uri === CHART_URI) {
307339
+ return handleChartDrawing2(params3, node4, graphicData, size3, padding, marginOffset, anchorData, wrap6, isAnchor);
307340
+ }
305557
307341
  const picture = graphicData?.elements.find((el) => el.name === "pic:pic");
305558
307342
  if (!picture || !picture.elements) {
305559
307343
  return null;
@@ -306224,6 +308008,40 @@ var DRAWING_XML_TAG2 = "w:drawing", SHAPE_URI2 = "http://schemas.microsoft.com/o
306224
308008
  }
306225
308009
  };
306226
308010
  return result;
308011
+ }, handleChartDrawing2 = (params3, node4, graphicData, size3, padding, marginOffset, anchorData, wrap6, isAnchor) => {
308012
+ const chartEl = graphicData?.elements?.find((el) => el.name === "c:chart");
308013
+ const chartRelId = chartEl?.attributes?.["r:id"];
308014
+ if (!chartRelId)
308015
+ return null;
308016
+ const { docx, filename } = params3;
308017
+ const resolved = resolveChartPart2(docx, chartRelId, filename);
308018
+ if (!resolved)
308019
+ return null;
308020
+ const { chartPartPath } = resolved;
308021
+ const chartXml = docx[chartPartPath];
308022
+ const chartData = chartXml ? parseChartXml2(chartXml) : null;
308023
+ const drawingNode = params3.nodes?.[0];
308024
+ const { order: order4, originalChildren } = collectPreservedDrawingChildren2(node4);
308025
+ return {
308026
+ type: "chart",
308027
+ attrs: {
308028
+ width: size3.width || 400,
308029
+ height: size3.height || 300,
308030
+ chartData,
308031
+ chartRelId,
308032
+ chartPartPath,
308033
+ isAnchor,
308034
+ anchorData,
308035
+ wrap: wrap6,
308036
+ padding,
308037
+ marginOffset,
308038
+ originalAttributes: node4?.attributes,
308039
+ originalChildren,
308040
+ originalChildOrder: order4,
308041
+ originalXml: drawingNode ? carbonCopy2(drawingNode) : null,
308042
+ drawingContent: drawingNode || null
308043
+ }
308044
+ };
306227
308045
  }, buildShapePlaceholder2 = (node4, size3, padding, marginOffset, shapeType) => {
306228
308046
  const attrs = {
306229
308047
  drawingContent: {
@@ -306282,6 +308100,7 @@ var init_encode_image_node_helpers = __esm(() => {
306282
308100
  init_metafile_converter();
306283
308101
  init_tiff_converter();
306284
308102
  init_textbox_content_helpers();
308103
+ init_chart_helpers();
306285
308104
  });
306286
308105
 
306287
308106
  // ../../packages/super-editor/src/core/super-converter/v3/handlers/wp/anchor/helpers/handle-anchor-node.js
@@ -307240,6 +309059,9 @@ function decode38(params3) {
307240
309059
  if (node4.attrs.isPict) {
307241
309060
  return null;
307242
309061
  }
309062
+ if (node4.type === "chart" && node4.attrs.originalXml) {
309063
+ return wrapTextInRun2(carbonCopy2(node4.attrs.originalXml), []);
309064
+ }
307243
309065
  const childTranslator = node4.attrs.isAnchor ? translator131 : translator132;
307244
309066
  const resultNode = childTranslator.decode(params3);
307245
309067
  return wrapTextInRun2({
@@ -316334,6 +318156,7 @@ function exportSchemaToJson2(params3) {
316334
318156
  contentBlock: translator216,
316335
318157
  vectorShape: translateVectorShape2,
316336
318158
  shapeGroup: translateShapeGroup2,
318159
+ chart: translator133,
316337
318160
  structuredContent: translator134,
316338
318161
  structuredContentBlock: translator134,
316339
318162
  documentPartObject: translator134,
@@ -330010,7 +331833,7 @@ var flatten3 = (node4, descend = true) => {
330010
331833
  }
330011
331834
  });
330012
331835
  return result;
330013
- }, findChildren4 = (node4, predicate, descend) => {
331836
+ }, findChildren5 = (node4, predicate, descend) => {
330014
331837
  if (!node4) {
330015
331838
  throw new Error('Invalid "node" parameter');
330016
331839
  } else if (!predicate) {
@@ -330018,7 +331841,7 @@ var flatten3 = (node4, descend = true) => {
330018
331841
  }
330019
331842
  return flatten3(node4, descend).filter((child) => predicate(child.node));
330020
331843
  }, findInlineNodes2 = (node4, descend) => {
330021
- return findChildren4(node4, (child) => child.isInline, descend);
331844
+ return findChildren5(node4, (child) => child.isInline, descend);
330022
331845
  };
330023
331846
 
330024
331847
  // ../../packages/super-editor/src/extensions/track-changes/trackChangesHelpers/getTrackChanges.js