@openpresentation/opf 0.36.0 → 0.37.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/THIRD-PARTY-NOTICES.md +99 -0
  2. package/dist/browser.js +19 -19
  3. package/dist/{catalog-refs-BgotJhR5.d.ts → catalog-refs-BeRgtpZS.d.ts} +4 -4
  4. package/dist/{catalog-schemas-BX-VEc5Q.d.ts → catalog-schemas-CwY-3cCP.d.ts} +1 -1
  5. package/dist/{chunk-6WVPFWPD.js → chunk-434E2RWO.js} +4 -4
  6. package/dist/{chunk-OFL3WY6F.js → chunk-63Y75CCK.js} +77 -15
  7. package/dist/{chunk-O65COLKF.js → chunk-BPILTZUJ.js} +118 -19
  8. package/dist/{chunk-4FA4AZXY.js → chunk-DDD4WUEH.js} +2375 -825
  9. package/dist/{chunk-MS2LPR7F.js → chunk-DMV3G65U.js} +1 -1
  10. package/dist/{chunk-AZELWKG2.js → chunk-EHYAVRL3.js} +5 -4
  11. package/dist/{chunk-7JE3XTL7.js → chunk-HBO64RWP.js} +4 -4
  12. package/dist/{chunk-J7FUSZZ5.js → chunk-HOK3DZA6.js} +6 -6
  13. package/dist/chunk-I4NQP7Z4.js +1 -0
  14. package/dist/{chunk-2NIID3QD.js → chunk-ITGR2RW2.js} +6 -6
  15. package/dist/chunk-IW4TXMJY.js +646 -0
  16. package/dist/{chunk-SER6GJTT.js → chunk-KB7TPZQI.js} +23 -6
  17. package/dist/{chunk-VDZXNNZF.js → chunk-M4IPCFDV.js} +1 -1
  18. package/dist/{chunk-F5SY7MSA.js → chunk-MNJ4JV7I.js} +1 -1
  19. package/dist/{chunk-XRMYP4JD.js → chunk-ORVMHVOS.js} +86 -2
  20. package/dist/{chunk-BPSZ7OWD.js → chunk-PDBZN7EJ.js} +26 -21
  21. package/dist/{chunk-3KPTVK77.js → chunk-Q2L5ERNK.js} +1248 -120
  22. package/dist/{chunk-HHQROUYC.js → chunk-QFT4R2IL.js} +4405 -2808
  23. package/dist/chunk-QQBOI5XI.js +86 -0
  24. package/dist/{chunk-TJMESSBQ.js → chunk-SIF5JDZC.js} +109 -9
  25. package/dist/{chunk-GNKOQ6NA.js → chunk-XY332BQP.js} +4 -4
  26. package/dist/{chunk-APCNAAA7.js → chunk-ZB427MLO.js} +2 -2
  27. package/dist/{composition-CSM7YfBl.d.ts → composition-DiKC371V.d.ts} +707 -134
  28. package/dist/composition.d.ts +3 -3
  29. package/dist/composition.js +1 -1
  30. package/dist/{conversion-CL7ipVGO.d.ts → conversion-DBkC9Y2e.d.ts} +6 -6
  31. package/dist/conversion-P56LOOE2.js +25 -0
  32. package/dist/convert.d.ts +5 -5
  33. package/dist/convert.js +63 -23
  34. package/dist/data.d.ts +41 -3
  35. package/dist/data.js +2 -2
  36. package/dist/{deck-report-DhsB0SUz.d.ts → deck-report-BwgsIRAf.d.ts} +3 -3
  37. package/dist/deck.d.ts +6 -6
  38. package/dist/deck.js +11 -11
  39. package/dist/diff.js +4 -4
  40. package/dist/docs.js +43 -31
  41. package/dist/examples.js +2338 -392
  42. package/dist/font-policy.js +1 -1
  43. package/dist/format.js +2 -2
  44. package/dist/ids.d.ts +17 -4
  45. package/dist/ids.js +4 -4
  46. package/dist/index.d.ts +140 -23
  47. package/dist/index.js +22 -22
  48. package/dist/markdown.d.ts +2 -2
  49. package/dist/markdown.js +8 -8
  50. package/dist/metric-data-B4Q8RFRR.d.ts +382 -0
  51. package/dist/node-engine.d.ts +6 -6
  52. package/dist/node-engine.js +21 -21
  53. package/dist/{pagination-BSqq32xt.d.ts → pagination-C9qnH_n-.d.ts} +5 -5
  54. package/dist/pagination.d.ts +4 -4
  55. package/dist/pagination.js +4 -4
  56. package/dist/patch.js +3 -3
  57. package/dist/precompiled.js +2 -2
  58. package/dist/{presentation-Dx-kZC8Y.d.ts → presentation-DmOhusrX.d.ts} +541 -110
  59. package/dist/schema-engine-ajv.js +1 -1
  60. package/dist/schema-engine-precompiled.js +2 -2
  61. package/dist/schema.d.ts +2 -2
  62. package/dist/schema.js +3 -3
  63. package/dist/schemas.d.ts +46 -2
  64. package/dist/schemas.js +1 -1
  65. package/dist/shape-engine-eager.js +2 -2
  66. package/dist/shape-engine-lazy.js +1 -1
  67. package/dist/{shape-engine-module-N74FCHGY.js → shape-engine-module-YU2XGIQN.js} +2 -2
  68. package/dist/shape-geometry.js +1 -1
  69. package/dist/source.js +10 -11
  70. package/dist/spec/reference/engine-defaults.json +1 -1
  71. package/dist/spec/reference/engine-vocabularies.json +1 -0
  72. package/dist/spec/schemas/font-scheme.schema.json +9 -7
  73. package/dist/spec/schemas/layout.schema.json +5 -4
  74. package/dist/spec/schemas/narrative.schema.json +1 -0
  75. package/dist/spec/schemas/opf.schema.json +661 -98
  76. package/dist/types.d.ts +16 -12
  77. package/dist/{validation-types-bnrso0JL.d.ts → validation-types-CV-ngACL.d.ts} +49 -6
  78. package/dist/validator.d.ts +5 -5
  79. package/dist/validator.js +3 -3
  80. package/dist/yaml.d.ts +2 -2
  81. package/dist/yaml.js +7 -7
  82. package/package.json +7 -6
  83. package/dist/chart-data-B_k-WTex.d.ts +0 -194
  84. package/dist/chunk-6VGLE7C5.js +0 -3983
  85. package/dist/chunk-SEC4IOOS.js +0 -1
  86. package/dist/chunk-WCPDN7AY.js +0 -642
  87. package/dist/conversion-FTGQLJK7.js +0 -25
@@ -1,8 +1,7 @@
1
1
  import { original } from './chunk-JBARNYFR.js';
2
- import { schemas, schemaEntries } from './chunk-3KPTVK77.js';
3
- import { SHAPE_BLOCK_KEYS, VARIABLE_KINDS, resolveChartData, chartPaletteForFill, chartSeriesPalette, chartSchemeSeries, chartSlicePlan, CHART_SERIES_MIN_LIGHTNESS_STEP, normalizeHexColor, resolveChartColors, colorContrast, languageOfText, imageBackground, CODE_NOMINAL_SIZE, QUOTE_NOMINAL_SIZE, TABLE_NOMINAL_SIZE, LIST_NOMINAL_SIZE, PROSE_NOMINAL_SIZE, quoteMarksFor, quoteLanguage, emphasisSurface, textInkBox, tableGrid, metricValueColor, timelineTextColor, LOGO_SHAPES, visitContentPayloads, resolveReference, intrinsicImageSize, layoutTable, nearestGridCell, colorTransform, applyColorTransform, resolveColorRef, readingRows, visualReadingOrder, numberingSystemExtension, isSupportedNumberingSystem, plainLanguageTag, supportedNumberingSystems, catalogGroupSource, resolveDesignRecords, resolveFontFamilies, checkCatalogsOption, provenanceOf, unresolvedReference, OPFUnresolvedReferenceError, composeSlide, resolveColorRoles, layoutVariantApplies, resolveCanvasDimensions, resolveSlideVariables, registeredCatalog, embeddedCopy, renamedLayout, renamedLayoutTitlePosition, layoutVariantKind, deckBackgroundIsChosen, LONE_DISPLAY_SIZES, normalizeColorVariant, layoutColorVariant, inlineDatasets, hasBuiltinDependency, isRecord, hasContentVariables, isTemplate, instantiateForValidation, layoutTemplateIssues, REMOVED_DESIGN_KEYS, deckBackgroundIsFixed, resolveScriptFonts, lonePayload, annotationText, isLayoutTemplate, layoutTemplate, statementMessage, messageWords, SHORT_MESSAGE_WORDS, catalogReferenceSites, parseReference, catalogGroupDeclared, pointerPath, unusedDatasets, documentIcons, iconIssue, walkCitationRuns, HALF_STEPPED, MAX_COMPOSITION_DEPTH, isOverlayConnector, connectorAdjustPreset, shapeIssues, pathFor, overlayIssues, datasetDiagnostics, defaultSlideBackground, removedLayoutAuto, renamedLayoutChangesDrawing, catalogRecords, collectCitations, resolveSlideDirection, isGridCell, gridCellSpan, numberingFindings, chartDrawDiagnostics, resolveTableData, resolveChartOptions, chartOptionTarget, codeHighlightLines, relatedName, chartNumberFixesByCell, catalogKinds, representablePositionBox, PositionRangeError, cellsInReadingOrder, isShapeBlock, OPFCompositionError } from './chunk-HHQROUYC.js';
2
+ import { schemas, schemaEntries } from './chunk-Q2L5ERNK.js';
3
+ import { SHAPE_BLOCK_KEYS, VARIABLE_KINDS, resolveChartData, chartPaletteForFill, chartSeriesPalette, chartSchemeSeries, chartSlicePlan, CHART_SERIES_MIN_LIGHTNESS_STEP, normalizeHexColor, resolveChartColors, colorContrast, languageOfText, imageBackground, CODE_NOMINAL_SIZE, QUOTE_NOMINAL_SIZE, TABLE_NOMINAL_SIZE, LIST_NOMINAL_SIZE, PROSE_NOMINAL_SIZE, variableDeclarations, isTemplate, resolveVariables, listVariables, instantiateForValidation, translationAt, emphasisSurface, textInkBox, tableGrid, metricValueColor, timelineTextColor, LOGO_SHAPES, visitContentPayloads, resolveReference, intrinsicImageSize, layoutTable, coerceVariableValue, nearestGridCell, colorTransform, applyColorTransform, resolveColorRef, tableRows, readingRows, visualReadingOrder, numberingSystemExtension, isSupportedNumberingSystem, plainLanguageTag, supportedNumberingSystems, catalogGroupSource, resolveDesignRecords, resolveFontFamilies, checkCatalogsOption, provenanceOf, unresolvedReference, OPFUnresolvedReferenceError, composeSlide, resolveScriptFonts, isRecord, resolveColorRoles, layoutVariantApplies, resolveCanvasDimensions, resolveSlideVariables, registeredCatalog, embeddedCopy, renamedLayout, renamedLayoutTitlePosition, layoutVariantKind, deckBackgroundIsChosen, LONE_DISPLAY_SIZES, normalizeColorVariant, layoutColorVariant, OPFCompositionError, inlineDatasets, hasBuiltinDependency, hasContentVariables, layoutTemplateIssues, REMOVED_DESIGN_KEYS, deckBackgroundIsFixed, lonePayload, annotationText, isLayoutTemplate, layoutTemplate, statementMessage, messageWords, SHORT_MESSAGE_WORDS, defaultSlideBackground, suggestCellTypeFix, catalogReferenceSites, parseReference, catalogGroupDeclared, pointerPath, unusedDatasets, documentIcons, iconIssue, walkCitationRuns, HALF_STEPPED, MAX_COMPOSITION_DEPTH, isOverlayConnector, connectorAdjustPreset, shapeIssues, pathFor, overlayIssues, datasetDiagnostics, removedLayoutAuto, renamedLayoutChangesDrawing, catalogRecords, collectCitations, visitPayloadItems, entryId, resolveSlideDirection, isGridCell, gridCellSpan, numberingFindings, dataSourcesOf, resolveDataSource, isDatasetRef, chartDrawDiagnostics, resolveTableData, resolveMetric, resolveChartOptions, chartOptionTarget, codeHighlightLines, relatedName, chartNumberFixesByCell, catalogKinds, representablePositionBox, PositionRangeError, cellsInReadingOrder, isShapeBlock, rowCells } from './chunk-QFT4R2IL.js';
4
4
  import { schemaEngine } from '#schema-engine';
5
- import { parseTree, printParseErrorCode, getNodePath } from 'jsonc-parser';
6
5
 
7
6
  // src/catalog-schemas.ts
8
7
  var CATALOG_SCHEMA = 4;
@@ -23,6 +22,91 @@ var catalogSchemaNames = {
23
22
  iconSets: "iconSet"
24
23
  };
25
24
 
25
+ // src/data-source-checks.ts
26
+ var record = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
27
+ var segment = (key3) => String(key3).replaceAll("~", "~0").replaceAll("/", "~1");
28
+ var at = (base, ...keys) => `${base}${keys.map((key3) => `/${segment(key3)}`).join("")}`;
29
+ var DURATION = /^P(?=\d|T\d)(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?=\d)(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/;
30
+ var INSTANT = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(Z|[+-]\d{2}:\d{2})?)?$/;
31
+ function parseInstant(text2) {
32
+ if (typeof text2 !== "string") return void 0;
33
+ const match2 = INSTANT.exec(text2.trim());
34
+ if (!match2) return void 0;
35
+ const [, year, month, day, hour = "0", minute = "0", second = "0", zone] = match2;
36
+ const parts2 = [Number(year), Number(month), Number(day), Number(hour), Number(minute), Number(second)];
37
+ const ms = Date.UTC(parts2[0], parts2[1] - 1, parts2[2], parts2[3], parts2[4], parts2[5]);
38
+ const check = new Date(ms);
39
+ if (check.getUTCFullYear() !== parts2[0] || check.getUTCMonth() !== parts2[1] - 1 || check.getUTCDate() !== parts2[2] || parts2[3] > 23 || parts2[4] > 59 || parts2[5] > 59) return void 0;
40
+ if (zone === void 0 || zone === "Z") return ms;
41
+ const sign = zone[0] === "-" ? -1 : 1;
42
+ return ms - sign * (Number(zone.slice(1, 3)) * 60 + Number(zone.slice(4, 6))) * 6e4;
43
+ }
44
+ function addDuration(start, duration) {
45
+ if (typeof duration !== "string") return void 0;
46
+ const match2 = DURATION.exec(duration.trim());
47
+ if (!match2) return void 0;
48
+ const [, years = "0", months = "0", weeks = "0", days = "0", hours = "0", minutes = "0", seconds = "0"] = match2;
49
+ const date = new Date(start);
50
+ const total = date.getUTCFullYear() * 12 + date.getUTCMonth() + Number(years) * 12 + Number(months);
51
+ const year = Math.floor(total / 12), month = total % 12;
52
+ const last = new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
53
+ const moved = Date.UTC(year, month, Math.min(date.getUTCDate(), last), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), date.getUTCMilliseconds());
54
+ return moved + ((Number(weeks) * 7 + Number(days)) * 24 * 60 * 60 + Number(hours) * 3600 + Number(minutes) * 60 + Number(seconds)) * 1e3;
55
+ }
56
+ var SECRET_NAME_TOKENS = /* @__PURE__ */ new Set(["key", "apikey", "token", "secret", "password", "passwd", "pwd", "signature", "sig", "auth", "authorization", "authentication", "oauth", "credential", "credentials", "bearer", "sas"]);
57
+ var SECRET_COMPOUND = /^(?:api|access|secret|private|public|client|auth|refresh|session|bearer|id|app|license)(?:key|token|secret|password|signature)$/;
58
+ function nameTokens(name) {
59
+ return name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map((token) => token.toLowerCase());
60
+ }
61
+ function credentialInSrc(src) {
62
+ if (typeof src !== "string") return void 0;
63
+ const authority = /^[a-z][a-z0-9+.-]*:\/\/([^/?#]*)/i.exec(src.trim());
64
+ if (!authority) return void 0;
65
+ const host = authority[1], userEnd = host.lastIndexOf("@");
66
+ if (userEnd >= 0) {
67
+ const separator = host.indexOf(":");
68
+ if (separator >= 0 && separator < userEnd && host.slice(separator + 1, userEnd).length > 0) return "a user and password";
69
+ }
70
+ const query = /\?([^#]*)/.exec(src)?.[1];
71
+ if (query) {
72
+ for (const pair of query.split("&")) {
73
+ const raw = pair.split("=")[0];
74
+ let name = raw;
75
+ try {
76
+ name = decodeURIComponent(raw.replaceAll("+", " "));
77
+ } catch {
78
+ }
79
+ if (name && nameTokens(name).some((token) => SECRET_NAME_TOKENS.has(token) || SECRET_COMPOUND.test(token))) return `a query parameter named ${JSON.stringify(name)}`;
80
+ }
81
+ }
82
+ return void 0;
83
+ }
84
+ function credentialDiagnostics(source, path, diagnostics) {
85
+ if (!record(source)) return;
86
+ const reason = credentialInSrc(source.src);
87
+ if (reason) diagnostics.push({ code: "datasource-credentials", severity: "warning", path: at(path, "src"), message: `the data source's src carries ${reason}; a data source never holds credentials, so remove it and keep the secret in the host's own store` });
88
+ }
89
+ function provenanceDiagnostics(node, path, document, options2 = {}) {
90
+ const diagnostics = [];
91
+ if (!record(node)) return diagnostics;
92
+ const { datasource } = node;
93
+ if (record(datasource)) credentialDiagnostics(datasource, at(path, "datasource"), diagnostics);
94
+ if (options2.asOf !== void 0 && typeof node.retrieved === "string") {
95
+ const source = resolveDataSource(datasource, document);
96
+ const asOf = parseInstant(options2.asOf), retrieved = parseInstant(node.retrieved);
97
+ const due = source?.refreshEvery !== void 0 && retrieved !== void 0 ? addDuration(retrieved, source.refreshEvery) : void 0;
98
+ if (asOf !== void 0 && due !== void 0 && due < asOf) {
99
+ diagnostics.push({ code: "dataset-stale", severity: "warning", path: at(path, "retrieved"), message: `retrieved ${node.retrieved}, and its data source refreshes every ${source.refreshEvery}, so as of ${options2.asOf} the data is stale; take it from the data source again and update retrieved` });
100
+ }
101
+ }
102
+ return diagnostics;
103
+ }
104
+ function dataSourceDiagnostics(document) {
105
+ const diagnostics = [];
106
+ for (const [id, source] of Object.entries(dataSourcesOf(document))) credentialDiagnostics(source, at("/datasources", id), diagnostics);
107
+ return diagnostics;
108
+ }
109
+
26
110
  // src/annotation-validation.ts
27
111
  var issue = (path, message, params2) => ({ path, message, keyword: "opf", schemaPath: "#/x-opf-semantics", params: params2 });
28
112
  var pointer = (dotted2) => `/${dotted2.split(".").map((part2) => part2.replaceAll("~", "~0").replaceAll("/", "~1")).join("/")}`;
@@ -53,9 +137,9 @@ function annotationIssues(value) {
53
137
  if (Array.isArray(table.columns)) table.columns.forEach((column, index) => {
54
138
  cell(column, `${pathFor(tablePath, "columns")}/${index}`);
55
139
  });
56
- if (Array.isArray(table.rows)) table.rows.forEach((row, rowIndex) => {
57
- if (Array.isArray(row)) row.forEach((entry2, cellIndex) => {
58
- cell(entry2, `${pathFor(tablePath, "rows")}/${rowIndex}/${cellIndex}`);
140
+ tableRows(table).forEach((row, rowIndex) => {
141
+ row.cells.forEach((entry2, cellIndex) => {
142
+ cell(entry2, `${pathFor(tablePath, "rows")}/${rowIndex}${row.object ? "/cells" : ""}/${cellIndex}`);
59
143
  });
60
144
  });
61
145
  }
@@ -89,6 +173,57 @@ function unusedReferenceWarnings(value) {
89
173
  return value.references.flatMap((reference, index) => isRecord(reference) && typeof reference.id === "string" && unused.includes(reference.id) ? [issue(`/references/${index}`, `reference '${reference.id}' is never cited; cite it with a run's cite field or remove it`, { code: "unused-reference", id: reference.id })] : []);
90
174
  }
91
175
 
176
+ // src/slide-links.ts
177
+ var PREFIX = "slide:";
178
+ function slideLinkId(link) {
179
+ return typeof link === "string" && link.startsWith(PREFIX) && link.length > PREFIX.length ? link.slice(PREFIX.length) : void 0;
180
+ }
181
+ function slideLink(id) {
182
+ return `${PREFIX}${id}`;
183
+ }
184
+ var pointerToken = (key3) => String(key3).replaceAll("~", "~0").replaceAll("/", "~1");
185
+ function collectSlideLinks(value, base = "") {
186
+ const found = [];
187
+ const visit2 = (node, pointer5, depth2) => {
188
+ if (depth2 > 64) return;
189
+ if (Array.isArray(node)) {
190
+ for (const [index, child] of node.entries()) visit2(child, `${pointer5}/${index}`, depth2 + 1);
191
+ return;
192
+ }
193
+ if (!isRecord(node)) return;
194
+ for (const [key3, child] of Object.entries(node)) {
195
+ if (key3 === "extensions") continue;
196
+ if (key3 === "link") {
197
+ const id = slideLinkId(child);
198
+ if (id !== void 0) found.push({ pointer: `${pointer5}/link`, id });
199
+ continue;
200
+ }
201
+ visit2(child, `${pointer5}/${pointerToken(key3)}`, depth2 + 1);
202
+ }
203
+ };
204
+ visit2(value, base, 0);
205
+ return found;
206
+ }
207
+ function slideLinkIssues(value, otherSlides = []) {
208
+ if (!isRecord(value) || !Array.isArray(value.slides)) return [];
209
+ const ids = new Set(otherSlides);
210
+ for (const slide of value.slides) if (isRecord(slide) && typeof slide.id === "string") ids.add(slide.id);
211
+ const issues = [];
212
+ value.slides.forEach((slide, index) => {
213
+ for (const { pointer: pointer5, id } of collectSlideLinks(slide, `/slides/${index}`)) {
214
+ if (ids.has(id)) continue;
215
+ issues.push({
216
+ path: pointer5,
217
+ message: `unknown slide '${id}'; a slide link names the 'id' of a slide of this document (assignIds gives every slide one)`,
218
+ keyword: "opf",
219
+ schemaPath: "#/x-opf-semantics",
220
+ params: { code: "slide-link-unknown", id }
221
+ });
222
+ }
223
+ });
224
+ return issues;
225
+ }
226
+
92
227
  // src/finding-text-util.ts
93
228
  var WORDS = { object: "an object", array: "a list", string: "text", number: "a number", integer: "a whole number", boolean: "true or false", null: "null" };
94
229
  var KIND_WORDS = { layouts: "layout", themes: "theme", colorSchemes: "color scheme", fontSchemes: "font scheme", narratives: "narrative", audiences: "audience", purposes: "purpose", tones: "tone", languages: "language" };
@@ -103,7 +238,7 @@ function pointerOf(segments) {
103
238
  return segments.map((part2) => `/${String(part2).replaceAll("~", "~0").replaceAll("/", "~1")}`).join("");
104
239
  }
105
240
  var code = (value) => `\`${String(value)}\``;
106
- var isIndex = (segment) => /^\d+$/.test(String(segment));
241
+ var isIndex = (segment2) => /^\d+$/.test(String(segment2));
107
242
  function cap(text2) {
108
243
  return text2.startsWith("`") ? text2 : text2.charAt(0).toUpperCase() + text2.slice(1);
109
244
  }
@@ -111,7 +246,7 @@ function fieldLabel(segments) {
111
246
  if (!segments.length) return "the deck";
112
247
  const last = segments[segments.length - 1];
113
248
  if (isIndex(last)) {
114
- const owner = [...segments].reverse().find((segment) => !isIndex(segment));
249
+ const owner = [...segments].reverse().find((segment2) => !isIndex(segment2));
115
250
  return owner === "slides" ? `slide ${Number(last) + 1}` : owner ? `${owner} entry ${Number(last) + 1}` : `entry ${Number(last) + 1}`;
116
251
  }
117
252
  return code(last);
@@ -183,9 +318,9 @@ function asNext(text2) {
183
318
  var isRecord2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
184
319
  function readAt(document, segments) {
185
320
  let value = document;
186
- for (const segment of segments) {
187
- if (Array.isArray(value)) value = value[Number(segment)];
188
- else if (isRecord2(value)) value = value[segment];
321
+ for (const segment2 of segments) {
322
+ if (Array.isArray(value)) value = value[Number(segment2)];
323
+ else if (isRecord2(value)) value = value[segment2];
189
324
  else return void 0;
190
325
  }
191
326
  return value;
@@ -261,9 +396,9 @@ function analyze(engine, rootId, union) {
261
396
  const lead = ranked[0];
262
397
  if (!lead) {
263
398
  const rootTypes = reduced.map((result) => result.errors.filter((error) => depth(error.instancePath) === base && error.keyword === "type"));
264
- const plain = rootTypes.every((list, index) => list.length === reduced[index]?.errors.length && list.length > 0);
399
+ const plain2 = rootTypes.every((list, index) => list.length === reduced[index]?.errors.length && list.length > 0);
265
400
  const types = [...new Set(rootTypes.flatMap((list) => list.flatMap((error) => [error.params.type].flat())))].map(String);
266
- return { union, span, replacement: [{ ...union, message: plain ? `must be ${named(types)}` : union.message, alternatives: summary(reduced) }] };
401
+ return { union, span, replacement: [{ ...union, message: plain2 ? `must be ${named(types)}` : union.message, alternatives: summary(reduced) }] };
267
402
  }
268
403
  let top = ranked.filter((result) => reach(result.errors) === reach(lead.errors));
269
404
  const keys = isObject(union.data) ? Object.keys(union.data) : [];
@@ -295,7 +430,8 @@ function analyze(engine, rootId, union) {
295
430
  }
296
431
  const chosen = top.flatMap((result) => result.errors).map((error, index) => {
297
432
  const mapped = { ...error, parentSchema: original(error.parentSchema), schema: original(error.schema) };
298
- if (index === 0 && others.length) mapped.alternatives = summary(others);
433
+ const rowUnion = /\/table\/rows\/\d+$/.test(union.instancePath);
434
+ if (index === 0 && others.length && !(rowUnion && mapped.alternatives !== void 0)) mapped.alternatives = summary(others);
299
435
  return mapped;
300
436
  });
301
437
  return { union, span, replacement: chosen };
@@ -402,8 +538,8 @@ function rememberValidationDefinition(issue2, parentSchema, keyword) {
402
538
  uri: `${entry2.schema.$id}#${current.pointer}`
403
539
  });
404
540
  for (const [key3, value] of Object.entries(current.value)) {
405
- const segment = key3.replaceAll("~", "~0").replaceAll("/", "~1");
406
- stack.push({ value, pointer: `${current.pointer}/${segment}` });
541
+ const segment2 = key3.replaceAll("~", "~0").replaceAll("/", "~1");
542
+ stack.push({ value, pointer: `${current.pointer}/${segment2}` });
407
543
  }
408
544
  }
409
545
  }
@@ -430,6 +566,7 @@ var rootPayloadFields = [
430
566
  "bullets",
431
567
  "image",
432
568
  "video",
569
+ "embed",
433
570
  "chart",
434
571
  "table",
435
572
  "code",
@@ -467,6 +604,10 @@ var contentKindSpecs = {
467
604
  fields: ["video"],
468
605
  required: ["video"]
469
606
  },
607
+ embed: {
608
+ fields: ["embed"],
609
+ required: ["embed"]
610
+ },
470
611
  code: {
471
612
  fields: ["code"],
472
613
  required: ["code"]
@@ -494,7 +635,7 @@ var contentKindSpecs = {
494
635
  requireAny: ["shape", "path"]
495
636
  }
496
637
  };
497
- var captionableKinds = /* @__PURE__ */ new Set(["image", "chart", "table", "video", "diagram"]);
638
+ var captionableKinds = /* @__PURE__ */ new Set(["image", "chart", "table", "video", "embed", "diagram"]);
498
639
  var imageOptionFields = ["fit", "focus", "aspectRatio", "shape", "adjust", "stroke", "opacity", "recolor", "overlay", "placement", "portrait"];
499
640
  var shapeImageFields = /* @__PURE__ */ new Set(["aspectRatio", "shape", "adjust", "stroke", "opacity"]);
500
641
  var shapeOptionFields = SHAPE_BLOCK_KEYS.filter((field) => field !== "path");
@@ -546,17 +687,17 @@ function isEnUkTag(value) {
546
687
  }
547
688
  var EN_UK_MESSAGE = "Use 'en-GB' for UK English; 'en-UK' is not a valid BCP-47 region tag";
548
689
  function enUkIssues(language, path) {
549
- const at2 = isEnUkTag(language) ? path : isRecord(language) && isEnUkTag(language.bcp47) ? `${path}/bcp47` : void 0;
550
- return at2 ? [semanticIssue(at2, EN_UK_MESSAGE, { replacement: "en-GB" })] : [];
690
+ const at3 = isEnUkTag(language) ? path : isRecord(language) && isEnUkTag(language.bcp47) ? `${path}/bcp47` : void 0;
691
+ return at3 ? [semanticIssue(at3, EN_UK_MESSAGE, { replacement: "en-GB" })] : [];
551
692
  }
552
693
  function overlayAnchorSizeWarnings(value) {
553
694
  const issues = [];
554
695
  if (isRecord(value) && Array.isArray(value.slides)) value.slides.forEach((slide, index) => {
555
696
  if (isRecord(slide) && Array.isArray(slide.shapes)) slide.shapes.forEach((entry2, shapeIndex) => {
556
- const at2 = isRecord(entry2) ? entry2.at : void 0;
557
- if (isRecord(at2)) for (const key3 of ["width", "height"]) {
558
- const size = at2[key3];
559
- if (typeof size === "number" && size > 4 && size <= 8 && !hasOwn(at2, `${key3}Px`))
697
+ const at3 = isRecord(entry2) ? entry2.at : void 0;
698
+ if (isRecord(at3)) for (const key3 of ["width", "height"]) {
699
+ const size = at3[key3];
700
+ if (typeof size === "number" && size > 4 && size <= 8 && !hasOwn(at3, `${key3}Px`))
560
701
  issues.push(semanticIssue(`/slides/${index}/shapes/${shapeIndex}/at/${key3}`, `at.${key3} is ${size}, a fraction; pixels are ${key3}Px`, { code: "shape-anchor-size-unit", key: key3, size }));
561
702
  }
562
703
  });
@@ -577,6 +718,7 @@ function inferredKinds(value) {
577
718
  if (hasOwn(value, "items")) kinds.push("list");
578
719
  if (hasOwn(value, "image")) kinds.push("image");
579
720
  if (hasOwn(value, "video")) kinds.push("video");
721
+ if (hasOwn(value, "embed")) kinds.push("embed");
580
722
  if (hasOwn(value, "chart")) kinds.push("chart");
581
723
  if (hasOwn(value, "table")) kinds.push("table");
582
724
  if (hasOwn(value, "code")) kinds.push("code");
@@ -597,7 +739,7 @@ function validateContentPayload(value, path, options2 = {}) {
597
739
  const explicitType = value.type;
598
740
  const payloadFields = presentFields(value, rootPayloadFields);
599
741
  const hasBlocks = hasOwn(value, "blocks");
600
- const captionIssue = (reason, params2 = {}) => semanticIssue(pathFor(path, "caption"), `caption is only valid on an image, chart, table, video or diagram payload; ${reason}`, { code: "caption-unsupported-payload", ...params2 });
742
+ const captionIssue = (reason, params2 = {}) => semanticIssue(pathFor(path, "caption"), `caption is only valid on an image, chart, table, video, embed or diagram payload; ${reason}`, { code: "caption-unsupported-payload", ...params2 });
601
743
  const imageOptionIssues = (reason, params2 = {}, except = /* @__PURE__ */ new Set()) => {
602
744
  for (const field of imageOptionFields) if (hasOwn(value, field) && !except.has(field)) issues.push(semanticIssue(pathFor(path, field), `${field} is only valid on an image payload; ${reason}`, { code: "image-option-unsupported-payload", field, ...params2 }));
603
745
  };
@@ -662,19 +804,19 @@ function validateContentPayload(value, path, options2 = {}) {
662
804
  if (resolvedKind !== "image") imageOptionIssues(`this payload is '${resolvedKind}'`, { type: resolvedKind }, resolvedKind === "shape" ? shapeImageFields : void 0);
663
805
  if (resolvedKind !== "shape") shapeOptionIssues(`this payload is '${resolvedKind}'`, { type: resolvedKind });
664
806
  if (resolvedKind === "shape" || resolvedKind === "image")
665
- for (const issue2 of shapeIssues(value, (...keys) => keys.reduce((at2, key3) => pathFor(at2, key3), path))) issues.push(semanticIssue(issue2.path, issue2.message, { code: issue2.code, ...issue2.params }));
807
+ for (const issue2 of shapeIssues(value, (...keys) => keys.reduce((at3, key3) => pathFor(at3, key3), path))) issues.push(semanticIssue(issue2.path, issue2.message, { code: issue2.code, ...issue2.params }));
666
808
  if (resolvedKind === "image" && isRecord(value.image) && Array.isArray(value.image.callouts)) {
667
809
  value.image.callouts.forEach((callout, index) => {
668
810
  if (!isRecord(callout)) return;
669
811
  for (const key3 of ["x", "y"]) if (typeof callout[key3] === "number" && !Number.isFinite(callout[key3])) issues.push(semanticIssue(`${pathFor(path, "image")}/callouts/${index}/${key3}`, "an image callout origin must be a finite signed fraction", { key: key3 }));
670
812
  const canvas = options2.canvas;
671
813
  if (canvas && ["x", "y", "width", "height"].every((key3) => typeof callout[key3] === "number" && Number.isFinite(callout[key3]))) {
672
- const at2 = `${pathFor(path, "image")}/callouts/${index}`, frame = callout;
814
+ const at3 = `${pathFor(path, "image")}/callouts/${index}`, frame = callout;
673
815
  try {
674
- representablePositionBox({ x: frame.x * canvas.width, y: frame.y * canvas.height, width: frame.width * canvas.width, height: frame.height * canvas.height }, at2.replace(/^\//, "").replaceAll("/", "."));
816
+ representablePositionBox({ x: frame.x * canvas.width, y: frame.y * canvas.height, width: frame.width * canvas.width, height: frame.height * canvas.height }, at3.replace(/^\//, "").replaceAll("/", "."));
675
817
  } catch (error) {
676
818
  if (!(error instanceof PositionRangeError)) throw error;
677
- issues.push(semanticIssue(`${at2}/${error.coordinate}`, error.message, { key: error.coordinate }));
819
+ issues.push(semanticIssue(`${at3}/${error.coordinate}`, error.message, { key: error.coordinate }));
678
820
  }
679
821
  }
680
822
  });
@@ -733,8 +875,8 @@ function validateSlideCells(slide, slidePath) {
733
875
  for (let right = left + 1; right < cells.length; right += 1) {
734
876
  const a = gridCellSpan(cells[left]), b = gridCellSpan(cells[right]);
735
877
  if (!a || !b || !intersects(a.rows, b.rows) || !intersects(a.columns, b.columns)) continue;
736
- const at2 = placed.find(({ block }) => block.region === cells[right]);
737
- issues.push(semanticIssue(pathFor(pathFor(pathFor(slidePath, "blocks"), String(at2.index)), "region"), `cells '${cells[left]}' and '${cells[right]}' overlap`, { cells: [cells[left], cells[right]] }));
878
+ const at3 = placed.find(({ block }) => block.region === cells[right]);
879
+ issues.push(semanticIssue(pathFor(pathFor(pathFor(slidePath, "blocks"), String(at3.index)), "region"), `cells '${cells[left]}' and '${cells[right]}' overlap`, { cells: [cells[left], cells[right]] }));
738
880
  }
739
881
  }
740
882
  return issues;
@@ -757,13 +899,13 @@ function deckMetadataIssues(value) {
757
899
  }
758
900
  }
759
901
  for (const { entry: entry2, path } of entries("speaker")) {
760
- if (typeof entry2.organizationId === "string" && !organizationIds.has(entry2.organizationId)) {
761
- issues.push(semanticIssue(`${path}/organizationId`, `organizationId '${entry2.organizationId}' names no organization in the presentation; use the id of an entry in organization`, { id: entry2.organizationId }));
902
+ if (typeof entry2.organization === "string" && !organizationIds.has(entry2.organization)) {
903
+ issues.push(semanticIssue(`${path}/organization`, `organization '${entry2.organization}' names no organization in the presentation; use the id of an entry in organization`, { id: entry2.organization }));
762
904
  }
763
905
  }
764
906
  return issues;
765
907
  }
766
- function presentationSemanticIssues(value, catalogs) {
908
+ function presentationSemanticIssues(value, catalogs, slideLinks) {
767
909
  if (!isRecord(value) || !Array.isArray(value.slides)) {
768
910
  return [];
769
911
  }
@@ -800,13 +942,22 @@ function presentationSemanticIssues(value, catalogs) {
800
942
  const seen = documentIds.get(slide.id);
801
943
  if (seen === "slide") issues.push(semanticIssue(`${slidePath}/id`, "slide ids must be unique within a presentation", { id: slide.id }));
802
944
  else if (seen === "payload") issues.push(semanticIssue(`${slidePath}/id`, "slide id duplicates a content payload id; ids must be unique among slide and payload ids within a presentation", { id: slide.id }));
945
+ else if (seen === "entry") issues.push(semanticIssue(`${slidePath}/id`, "slide id duplicates a list item, bullet, timeline event or table row id; ids are unique across the whole presentation", { id: slide.id }));
803
946
  else documentIds.set(slide.id, "slide");
804
947
  }
948
+ const claimEntries = (owner, path) => visitPayloadItems(owner, path, (kind, entry2, entryPath) => {
949
+ const id = entryId(entry2);
950
+ if (id === void 0) return;
951
+ if (documentIds.has(id)) issues.push(semanticIssue(`${entryPath}/id`, `${kind === "event" ? "timeline event" : kind === "row" ? "table row" : kind} ids must be unique among every slide, payload, overlay, list item, bullet, timeline event and table row id within a presentation`, { id }));
952
+ else documentIds.set(id, "entry");
953
+ });
954
+ claimEntries(slide, slidePath);
805
955
  visitContentPayloads(slide, slidePath, (payload, path) => {
806
956
  if (typeof payload.id === "string") {
807
957
  if (documentIds.has(payload.id)) issues.push(semanticIssue(`${path}/id`, "content payload ids must be unique among slide and payload ids within a presentation", { id: payload.id }));
808
958
  else documentIds.set(payload.id, "payload");
809
959
  }
960
+ claimEntries(payload, path);
810
961
  });
811
962
  if (Array.isArray(slide.shapes)) slide.shapes.forEach((entry2, shapeIndex) => {
812
963
  if (!isRecord(entry2)) return;
@@ -816,7 +967,7 @@ function presentationSemanticIssues(value, catalogs) {
816
967
  else documentIds.set(entry2.id, "payload");
817
968
  }
818
969
  const checked = isOverlayConnector(entry2) ? isRecord(entry2.adjust) ? { shape: connectorAdjustPreset(entry2), adjust: entry2.adjust } : void 0 : entry2;
819
- if (checked) for (const issue2 of shapeIssues(checked, (...keys) => keys.reduce((at2, key3) => pathFor(at2, key3), entryPath))) issues.push(semanticIssue(issue2.path, issue2.message, { code: issue2.code, ...issue2.params }));
970
+ if (checked) for (const issue2 of shapeIssues(checked, (...keys) => keys.reduce((at3, key3) => pathFor(at3, key3), entryPath))) issues.push(semanticIssue(issue2.path, issue2.message, { code: issue2.code, ...issue2.params }));
820
971
  });
821
972
  for (const issue2 of overlayIssues(slide, slidePath, value, canvasForOverlays(slide, index))) issues.push(semanticIssue(issue2.path, issue2.message, { ...issue2.code ? { code: issue2.code } : {}, ...issue2.params }));
822
973
  issues.push(...enUkIssues(slide.language, `${slidePath}/language`));
@@ -831,9 +982,16 @@ function presentationSemanticIssues(value, catalogs) {
831
982
  };
832
983
  payloadNumberingIssues(slide, slidePath);
833
984
  visitContentPayloads(slide, slidePath, payloadNumberingIssues);
985
+ const payloadEmbedIssues = (payload, path) => {
986
+ const embed = payload.embed, address = isRecord(embed) ? embed.src : embed, part2 = credentialInSrc(address);
987
+ if (part2 !== void 0) issues.push(semanticIssue(isRecord(embed) ? pathFor(pathFor(path, "embed"), "src") : pathFor(path, "embed"), `This embed's address carries what looks like a credential (${part2}). Anyone with the deck can read it.`, { code: "embed-credentials", credential: part2 }));
988
+ };
989
+ payloadEmbedIssues(slide, slidePath);
990
+ visitContentPayloads(slide, slidePath, payloadEmbedIssues);
834
991
  }
835
992
  });
836
993
  issues.push(...annotationIssues(value));
994
+ if (slideLinks !== false) issues.push(...slideLinkIssues(value, slideLinks));
837
995
  return issues;
838
996
  }
839
997
  function canvasSize(dimensions) {
@@ -924,7 +1082,7 @@ function chartTypeWarnings(payload, path) {
924
1082
  }
925
1083
  return issues;
926
1084
  }
927
- function dataIssues(value) {
1085
+ function dataIssues(value, asOf) {
928
1086
  const out = { errors: [], warnings: [] };
929
1087
  if (!isRecord(value) || !Array.isArray(value.slides)) return out;
930
1088
  const seen = /* @__PURE__ */ new Set();
@@ -933,17 +1091,22 @@ function dataIssues(value) {
933
1091
  const key3 = `${diagnostic.code}|${diagnostic.path}`;
934
1092
  if (seen.has(key3)) continue;
935
1093
  seen.add(key3);
936
- (diagnostic.severity === "error" ? out.errors : out.warnings).push(semanticIssue(diagnostic.path, diagnostic.message, { code: diagnostic.code }));
1094
+ const fix = diagnostic.fix;
1095
+ (diagnostic.severity === "error" ? out.errors : out.warnings).push(semanticIssue(diagnostic.path, diagnostic.message, { code: diagnostic.code, ...diagnostic.aggregate ? { aggregate: true } : {}, ...fix ? { fix } : {} }));
937
1096
  }
938
1097
  };
939
1098
  add(datasetDiagnostics(value));
1099
+ add(dataSourceDiagnostics(value));
1100
+ for (const [id, dataset] of Object.entries(isRecord(value.datasets) ? value.datasets : {})) add(provenanceDiagnostics(dataset, `/datasets/${id.replaceAll("~", "~0").replaceAll("/", "~1")}`, value, { asOf }));
940
1101
  const payload = (node, path) => {
941
1102
  if (isRecord(node.chart)) {
942
1103
  const resolved2 = resolveChartData(node.chart, value, { path: pathFor(path, "chart") });
1104
+ if (isRecord(node.chart.data) && !isDatasetRef(node.chart.data)) add(provenanceDiagnostics(node.chart.data, pathFor(pathFor(path, "chart"), "data"), value, { asOf }));
943
1105
  add(resolved2.diagnostics);
944
1106
  add(chartDrawDiagnostics(node.chart, resolved2, pathFor(path, "chart"), { language: typeof value.language === "string" ? value.language : void 0 }));
945
1107
  }
946
1108
  if (isRecord(node.table)) add(resolveTableData(node.table, value, { path: pathFor(path, "table") }).diagnostics);
1109
+ if (isRecord(node.metric)) add(resolveMetric(node.metric, value, { path: pathFor(path, "metric"), ...typeof value.language === "string" ? { language: value.language } : {} }).diagnostics);
947
1110
  };
948
1111
  value.slides.forEach((slide, index) => {
949
1112
  if (!isRecord(slide)) return;
@@ -1047,9 +1210,9 @@ function variableReferenceWarnings(value) {
1047
1210
  if (Array.isArray(node.rows)) {
1048
1211
  const rowsPath = pathFor(path, "rows");
1049
1212
  node.rows.forEach((row, rowIndex) => {
1050
- if (!Array.isArray(row)) return;
1051
- row.forEach((cell, cellIndex) => {
1052
- tableCell(cell, `${rowsPath}/${rowIndex}/${cellIndex}`);
1213
+ const cellsPath = isRecord(row) ? `${rowsPath}/${rowIndex}/cells` : `${rowsPath}/${rowIndex}`;
1214
+ rowCells(row).forEach((cell, cellIndex) => {
1215
+ tableCell(cell, `${cellsPath}/${cellIndex}`);
1053
1216
  });
1054
1217
  });
1055
1218
  }
@@ -1210,6 +1373,15 @@ var datasetTableMessage = (field) => `'${field}' is not allowed on a dataset-bac
1210
1373
  function dataUnionErrors(errors, value) {
1211
1374
  let kept = errors;
1212
1375
  for (const union of errors) {
1376
+ if (union.keyword !== "oneOf" || !/\/table\/rows\/\d+$/.test(union.instancePath) || !union.schemaPath.endsWith("/$defs/TableRow/oneOf")) continue;
1377
+ const target = pointerValue(value, union.instancePath);
1378
+ const other = Array.isArray(target) ? 1 : isRecord(target) ? 0 : void 0;
1379
+ if (other === void 0) continue;
1380
+ const prefix = `${union.instancePath}/`;
1381
+ const otherBranch = `/$defs/TableRow/oneOf/${other}/`;
1382
+ kept = kept.filter((error) => error !== union && !(error.schemaPath.includes(otherBranch) && (error.instancePath === union.instancePath || error.instancePath.startsWith(prefix))));
1383
+ }
1384
+ for (const union of kept) {
1213
1385
  if (union.keyword !== "oneOf") continue;
1214
1386
  const chartData = /\/chart\/data$/.test(union.instancePath) && /\/properties\/data\/oneOf$/.test(union.schemaPath);
1215
1387
  const header = /\/table\/columns\/\d+$/.test(union.instancePath) && /\/properties\/columns\/items\/oneOf$/.test(union.schemaPath);
@@ -1249,7 +1421,8 @@ function validateAgainstSchema(value, schemaOrKind = "presentation", options2 =
1249
1421
  subject = view.presentation;
1250
1422
  unfilledVariables = view.unfilled;
1251
1423
  for (const entry2 of view.diagnostics) {
1252
- if (entry2.code === "variable-example-used" || entry2.code === "variable-rich-flattened" || entry2.code === "variable-unfilled") continue;
1424
+ if (entry2.code === "variable-example-used" || entry2.code === "variable-rich-flattened" || entry2.code === "variable-unfilled" || entry2.code === "variable-translations-removed") continue;
1425
+ if (entry2.code === "variable-overflow") continue;
1253
1426
  const issue2 = semanticIssue(entry2.path, entry2.message, { id: entry2.id, code: entry2.code });
1254
1427
  (entry2.severity === "error" ? variableIssues.errors : variableIssues.warnings).push(issue2);
1255
1428
  }
@@ -1269,9 +1442,9 @@ function validateAgainstSchema(value, schemaOrKind = "presentation", options2 =
1269
1442
  if (resolved2.schemaName === "layout" && valid) for (const issue2 of layoutTemplateIssues(subject)) errors.push(semanticIssue(issue2.path, issue2.message, { code: issue2.code }));
1270
1443
  const warnings = [];
1271
1444
  if (resolved2.schemaName === "presentation") {
1272
- errors.push(...presentationSemanticIssues(subject, options2.catalogs));
1445
+ errors.push(...presentationSemanticIssues(subject, options2.catalogs, options2.slideLinks));
1273
1446
  errors.push(...variableIssues.errors);
1274
- const data = dataIssues(subject);
1447
+ const data = dataIssues(subject, options2.asOf);
1275
1448
  errors.push(...data.errors);
1276
1449
  warnings.push(...presentationReferenceWarnings(subject, options2.catalogs));
1277
1450
  warnings.push(...data.warnings);
@@ -1297,9 +1470,9 @@ function recordIssues(kind, id, value) {
1297
1470
  const schemaName = catalogSchemaNames[kind];
1298
1471
  return validateAgainstSchema(object(value) ? { $schema: schemas[schemaName].$id, id, ...value } : value, kind);
1299
1472
  }
1300
- function embeddedRecordInvalid(kind, id, record) {
1301
- if (object(record) && (Object.hasOwn(record, "$schema") || Object.hasOwn(record, "id"))) return false;
1302
- return !recordIssues(kind, id, record).valid;
1473
+ function embeddedRecordInvalid(kind, id, record2) {
1474
+ if (object(record2) && (Object.hasOwn(record2, "$schema") || Object.hasOwn(record2, "id"))) return false;
1475
+ return !recordIssues(kind, id, record2).valid;
1303
1476
  }
1304
1477
  function resolvesToValidRecord(document, kind, reference, options2 = {}) {
1305
1478
  const found = resolveReference(document, kind, reference, options2);
@@ -1312,9 +1485,9 @@ function resolveNarrative(document, options2 = {}) {
1312
1485
  if (!isRec(document) || typeof document.narrative !== "string") return void 0;
1313
1486
  const found = resolveReference(document, "narratives", document.narrative, { catalogs: options2.catalogs ?? [] });
1314
1487
  if (!found) return void 0;
1315
- const record = found.record;
1316
- const beats = Array.isArray(record.beats) ? record.beats.flatMap((beat) => isRec(beat) && typeof beat.id === "string" ? [beat.id] : []) : [];
1317
- return { record, origin: found.origin, beats };
1488
+ const record2 = found.record;
1489
+ const beats = Array.isArray(record2.beats) ? record2.beats.flatMap((beat) => isRec(beat) && typeof beat.id === "string" ? [beat.id] : []) : [];
1490
+ return { record: record2, origin: found.origin, beats };
1318
1491
  }
1319
1492
  function slideBeatReferences(document) {
1320
1493
  if (!isRec(document) || !Array.isArray(document.slides)) return [];
@@ -1324,8 +1497,8 @@ function slideBeatReferences(document) {
1324
1497
  const path = `/slides/${index}/beat`;
1325
1498
  if (typeof slide.beat === "string") references.push({ path, slide: index, beat: slide.beat });
1326
1499
  else if (Array.isArray(slide.beat))
1327
- slide.beat.forEach((beat, at2) => {
1328
- if (typeof beat === "string") references.push({ path: `${path}/${at2}`, slide: index, beat });
1500
+ slide.beat.forEach((beat, at3) => {
1501
+ if (typeof beat === "string") references.push({ path: `${path}/${at3}`, slide: index, beat });
1329
1502
  });
1330
1503
  });
1331
1504
  return references;
@@ -1339,14 +1512,14 @@ function unreferencedBeats(document, narrative) {
1339
1512
  if (referenced.size === 0) return [];
1340
1513
  return narrative.beats.flatMap((beat, index) => referenced.has(beat) ? [] : [{ beat, index }]);
1341
1514
  }
1342
- function durationRange(record) {
1343
- if (!isRec(record) || !isRec(record.duration)) return void 0;
1515
+ function durationRange(record2) {
1516
+ if (!isRec(record2) || !isRec(record2.duration)) return void 0;
1344
1517
  const bound = (value) => typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
1345
- const min = bound(record.duration.min), max = bound(record.duration.max);
1518
+ const min = bound(record2.duration.min), max = bound(record2.duration.max);
1346
1519
  return min === void 0 && max === void 0 ? void 0 : { ...min !== void 0 ? { min } : {}, ...max !== void 0 ? { max } : {} };
1347
1520
  }
1348
- function durationRangeInverted(record) {
1349
- const range = durationRange(record);
1521
+ function durationRangeInverted(record2) {
1522
+ const range = durationRange(record2);
1350
1523
  return range?.min !== void 0 && range.max !== void 0 && range.min > range.max;
1351
1524
  }
1352
1525
  function durationOutsideNarrative(document, narrative) {
@@ -1366,7 +1539,7 @@ function describeDurationRange(range) {
1366
1539
  var rec = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
1367
1540
  var toRgb = (hex) => {
1368
1541
  const n = normalizeHexColor(hex) ?? "#000000";
1369
- return [1, 3, 5].map((at2) => Number.parseInt(n.slice(at2, at2 + 2), 16));
1542
+ return [1, 3, 5].map((at3) => Number.parseInt(n.slice(at3, at3 + 2), 16));
1370
1543
  };
1371
1544
  var toHex = (rgb) => `#${rgb.map((c) => Math.max(0, Math.min(255, Math.round(c))).toString(16).padStart(2, "0")).join("").toUpperCase()}`;
1372
1545
  var linear = (c) => {
@@ -1548,7 +1721,7 @@ function colorChoice(levels, scheme, variables = {}) {
1548
1721
  if (variantOnly || definition === void 0 || definition === null || definition === false) continue;
1549
1722
  if (themeSlot) return { variant: { background: themeSlot } };
1550
1723
  if (isPicture) {
1551
- const tone = rec(definition).tone ?? pictureTone(definition, scheme, variables);
1724
+ const tone = rec(definition).appearance ?? pictureTone(definition, scheme, variables);
1552
1725
  if (tone === "dark" || tone === "light") return { variant: { background: tone === "dark" ? "dark1" : "light1" } };
1553
1726
  variantOnly = true;
1554
1727
  picture = { definition };
@@ -1700,64 +1873,62 @@ function textValues(slide, slidePath) {
1700
1873
  for (const field of ["title", "subtitle", "tag"])
1701
1874
  if (isText(slide[field])) out.push({ path: pointer2(...splitPointer(slidePath), field), value: slide[field], role: field, payload: slidePath, field });
1702
1875
  for (const payload of slidePayloads(slide, slidePath)) {
1703
- const node = payload.node, at2 = (...tail) => pointer2(...splitPointer(payload.path), ...tail);
1876
+ const node = payload.node, at3 = (...tail) => pointer2(...splitPointer(payload.path), ...tail);
1704
1877
  const push = (path, value, role, field) => {
1705
1878
  if (isText(value)) out.push({ path, value, role, payload: payload.path, field });
1706
1879
  };
1707
- push(at2("text"), node.text, "body", "text");
1880
+ push(at3("text"), node.text, "body", "text");
1708
1881
  for (const field of ["items", "bullets"])
1709
1882
  if (Array.isArray(node[field]))
1710
1883
  node[field].forEach((entry2, index) => {
1711
- if (isText(entry2)) push(at2(field, index), entry2, "list", field);
1884
+ if (isText(entry2)) push(at3(field, index), entry2, "list", field);
1712
1885
  else if (entry2 && typeof entry2 === "object") {
1713
- push(at2(field, index, "text"), entry2.text, "list", field);
1714
- push(at2(field, index, "description"), entry2.description, "list-description", field);
1886
+ push(at3(field, index, "text"), entry2.text, "list", field);
1887
+ push(at3(field, index, "description"), entry2.description, "list-description", field);
1715
1888
  }
1716
1889
  });
1717
1890
  const table = rec(node.table);
1718
1891
  if (Array.isArray(table.columns))
1719
1892
  table.columns.forEach((cell, c) => {
1720
1893
  const styled = rec(cell);
1721
- if (!Object.hasOwn(styled, "value") && typeof styled.name === "string") push(at2("table", "columns", c, "name"), styled.name, "table-header", "table");
1894
+ if (!Object.hasOwn(styled, "value") && typeof styled.name === "string") push(at3("table", "columns", c, "name"), styled.name, "table-header", "table");
1722
1895
  else {
1723
1896
  const value = Object.hasOwn(styled, "value") ? styled.value : cell;
1724
- push(at2("table", "columns", c, ...Object.hasOwn(styled, "value") ? ["value"] : []), value, "table-header", "table");
1897
+ push(at3("table", "columns", c, ...Object.hasOwn(styled, "value") ? ["value"] : []), value, "table-header", "table");
1725
1898
  }
1726
1899
  });
1727
- if (Array.isArray(table.rows))
1728
- table.rows.forEach((row, r) => {
1729
- if (!Array.isArray(row)) return;
1730
- row.forEach((cell, c) => {
1731
- const styled = rec(cell);
1732
- const value = Object.hasOwn(styled, "value") ? styled.value : cell;
1733
- push(at2("table", "rows", r, c, ...Object.hasOwn(styled, "value") ? ["value"] : []), value, "table", "table");
1734
- });
1900
+ tableRows(table).forEach((row, r) => {
1901
+ row.cells.forEach((cell, c) => {
1902
+ const styled = rec(cell);
1903
+ const value = Object.hasOwn(styled, "value") ? styled.value : cell;
1904
+ push(at3("table", "rows", r, ...row.object ? ["cells"] : [], c, ...Object.hasOwn(styled, "value") ? ["value"] : []), value, "table", "table");
1735
1905
  });
1906
+ });
1736
1907
  const callouts = rec(node.image).callouts;
1737
1908
  if (Array.isArray(callouts)) callouts.forEach((callout, index) => {
1738
- push(at2("image", "callouts", index, "text"), rec(callout).text, "callout", "image");
1909
+ push(at3("image", "callouts", index, "text"), rec(callout).text, "callout", "image");
1739
1910
  });
1740
1911
  const quote = node.quote;
1741
- if (typeof quote === "string") push(at2("quote"), quote, "quote", "quote");
1912
+ if (typeof quote === "string") push(at3("quote"), quote, "quote", "quote");
1742
1913
  else if (quote && typeof quote === "object") {
1743
- push(at2("quote", "text"), quote.text, "quote", "quote");
1744
- push(at2("quote", "attribution"), quote.attribution, "quote-footer", "quote");
1745
- push(at2("quote", "role"), quote.role, "quote-footer", "quote");
1746
- push(at2("quote", "source"), quote.source, "quote-footer", "quote");
1914
+ push(at3("quote", "text"), quote.text, "quote", "quote");
1915
+ push(at3("quote", "attribution"), quote.attribution, "quote-footer", "quote");
1916
+ push(at3("quote", "role"), quote.role, "quote-footer", "quote");
1917
+ push(at3("quote", "source"), quote.source, "quote-footer", "quote");
1747
1918
  }
1748
1919
  const metric = node.metric;
1749
- if (typeof metric === "string") push(at2("metric"), metric, "metric", "metric");
1920
+ if (typeof metric === "string") push(at3("metric"), metric, "metric", "metric");
1750
1921
  else if (metric && typeof metric === "object")
1751
1922
  for (const key3 of ["value", "label", "unit", "delta"]) {
1752
1923
  const value = metric[key3];
1753
- if (typeof value === "string") push(at2("metric", key3), value, "metric", "metric");
1924
+ if (typeof value === "string") push(at3("metric", key3), value, "metric", "metric");
1754
1925
  }
1755
1926
  const timeline = node.timeline, events = Array.isArray(timeline) ? timeline : Array.isArray(rec(timeline).events) ? rec(timeline).events : [];
1756
- if (typeof rec(timeline).name === "string") push(at2("timeline", "name"), rec(timeline).name, "timeline", "timeline");
1927
+ if (typeof rec(timeline).name === "string") push(at3("timeline", "name"), rec(timeline).name, "timeline", "timeline");
1757
1928
  events.forEach((event, index) => {
1758
1929
  const base = Array.isArray(timeline) ? ["timeline", index] : ["timeline", "events", index];
1759
- push(at2(...base, "when"), event?.when, "timeline", "timeline");
1760
- push(at2(...base, "what"), event?.what, "timeline", "timeline");
1930
+ push(at3(...base, "when"), event?.when, "timeline", "timeline");
1931
+ push(at3(...base, "what"), event?.what, "timeline", "timeline");
1761
1932
  });
1762
1933
  }
1763
1934
  return out;
@@ -1800,10 +1971,10 @@ var isLogoReference = (value) => typeof value === "string" && value.startsWith("
1800
1971
  function assetRefs(document, slide, slidePath, includeDeck) {
1801
1972
  const out = [];
1802
1973
  for (const payload of slidePayloads(slide, slidePath)) {
1803
- const at2 = (...tail) => pointer2(...splitPointer(payload.path), ...tail);
1804
- if (payload.node.image !== void 0 && !isLogoReference(payload.node.image)) out.push({ path: at2("image"), value: payload.node.image, kind: "image" });
1805
- if (payload.node.video !== void 0) out.push({ path: at2("video"), value: payload.node.video, kind: "video" });
1806
- if (rec(payload.node.quote).photo !== void 0) out.push({ path: at2("quote", "photo"), value: rec(payload.node.quote).photo, kind: "quote-photo" });
1974
+ const at3 = (...tail) => pointer2(...splitPointer(payload.path), ...tail);
1975
+ if (payload.node.image !== void 0 && !isLogoReference(payload.node.image)) out.push({ path: at3("image"), value: payload.node.image, kind: "image" });
1976
+ if (payload.node.video !== void 0) out.push({ path: at3("video"), value: payload.node.video, kind: "video" });
1977
+ if (rec(payload.node.quote).photo !== void 0) out.push({ path: at3("quote", "photo"), value: rec(payload.node.quote).photo, kind: "quote-photo" });
1807
1978
  }
1808
1979
  const designRefs = (design, base) => {
1809
1980
  for (const kind of ["header", "footer"])
@@ -1890,6 +2061,8 @@ var formatRules = [
1890
2061
  rule("reference-id-duplicate", "format", "error", "Two references share an id.", "A citation names a reference by id; a repeated id makes it ambiguous which entry is cited.", { standard: SCHEMA }),
1891
2062
  rule("cite-unknown-reference", "format", "error", "A citation names a reference that does not exist.", "A cited id with no entry in `references` has nothing to show in the footnote area.", { standard: SCHEMA }),
1892
2063
  rule("cite-unsupported-location", "format", "error", "A citation or footnote sits where no engine draws it.", "`cite` and `footnote` apply to runs in text, bullets and list items; table cells, captions, and reference and footnote texts have no marker.", { standard: SCHEMA }),
2064
+ rule("embed-credentials", "content", "warning", "An embed address carries what looks like a credential.", "An embed `src` is stored in the deck and linked from every export, so anyone who has the deck can read a user name and password in it, or a query parameter named like a secret (`key`, `token`, `secret`, `password`, `sig`, `signature`, `auth`, alone or in a longer name such as `api_key`). Put the secret where the host that shows the page holds it.", { standard: SCHEMA, approximations: "Matches the parameter names by word, not by letters: `api_key` and `accessToken` match, `monkey` does not. The value is never read, and nothing is fetched." }),
2065
+ rule("slide-link-unknown", "format", "error", "A link names a slide the document does not have.", "A `slide:<id>` link jumps to the slide with that `id`; an id no slide has leaves the link with nowhere to go in the preview, in PDF and in PowerPoint. A slide with no `id` cannot be linked to; `assignIds` gives every slide one.", { standard: SCHEMA }),
1893
2066
  rule("caption-unsupported-payload", "format", "error", "A caption is on a payload that cannot carry one.", "A caption belongs to exactly one image, chart, table, video or diagram; a group, text or code block has no place to draw it.", { standard: SCHEMA }),
1894
2067
  rule("image-option-unsupported-payload", "format", "error", "An image option is on a payload that is not an image.", "`fit`, `focus`, the image treatments (`shape`, `adjust`, `stroke`, `opacity`, `recolor`, `overlay`, `aspectRatio`), `placement` and `portrait` describe how a picture is drawn; a group, text or chart block has no picture for them to apply to. A shape block takes `shape`, `adjust`, `stroke`, `opacity` and `aspectRatio` too.", { standard: SCHEMA }),
1895
2068
  rule("shape-option-unsupported-payload", "format", "error", "A shape option is on a payload that is not a shape block.", "`fill`, `style`, `rotate`, `flip`, `anchor`, `padding`, `textDirection`, `alt`, `decorative`, `hidden`, `link` and the effects (`shadow`, `innerShadow`, `glow`, `softEdge`, `reflection`, `blur`) describe how a shape block is drawn; a text, chart or image block, or a group, has no shape for them to apply to.", { standard: SCHEMA }),
@@ -1903,6 +2076,7 @@ var formatRules = [
1903
2076
  rule("image-placement-invalid", "format", "error", "An image placement cannot be honored.", "A placed image bleeds to a slide edge and the rest of the slide composes beside it. Only a top-level block (slides.N.blocks.I) can do that, and a slide edge holds one placed image; a block in a group or in a cell of the slide grid, or a second block on the same edge, has nowhere to go.", { standard: SCHEMA }),
1904
2077
  rule("layout-placeholder-group", "format", "error", "A layout record's placeholder group breaks a nesting rule.", "A placeholder group arranges body regions inside one cell of its layout record. Groups nest at most three levels inside a record, and a group holds body regions and groups only: the headings (title, subtitle, tag) stay at the record's top level, where the engine places them. Composition cannot use a record that breaks either rule.", { standard: SCHEMA }),
1905
2078
  rule("dataset-unknown", "format", "error", "A chart or table names a dataset that does not exist.", "The data cannot be drawn without the dataset it refers to.", { standard: SCHEMA }),
2079
+ rule("datasource-unknown", "format", "error", "A dataset or chart data names a data source that does not exist.", 'A string `datasource` is the id of an entry in the top-level `datasources` map. An id that is not there says nothing about where the data came from. A file or a URL is written as an inline data source object, `{ "src": "./revenue.csv" }`.', { standard: SCHEMA }),
1906
2080
  rule("dataset-field-unknown", "format", "error", "A table asks a dataset for a column it does not have.", "The column cannot be shown when the dataset has no column of that name.", { standard: SCHEMA }),
1907
2081
  rule("data-column-duplicate", "format", "error", "A dataset or table has two columns with the same name.", "Series, mappings and fields address columns by name, so a repeated name makes them ambiguous.", { standard: SCHEMA }),
1908
2082
  rule("chart-mapping-unknown-column", "format", "error", "A chart mapping names a column the data does not have.", "The series cannot be built from a column that is not there.", { standard: SCHEMA }),
@@ -1912,6 +2086,7 @@ var formatRules = [
1912
2086
  rule("variable-invalid-value", "format", "error", "A variable value does not match its declared type.", "A number variable given text, or a date given a non-date, cannot be filled into the deck.", { standard: SCHEMA }),
1913
2087
  rule("variable-unknown-builtin", "format", "error", "A token names a built-in variable that does not exist.", "The `deck.`, `speaker.`, `organization.` and `slide.` names (and `speakers`) are reserved for built-in variables; a name under them that is not a built-in can never be filled, so the token would show literally. The slide-scoped `slide.number`, `slide.section` and `deck.slideCount` are inline tokens only, so `var:slide.*` and `var:deck.slideCount` are reported too; organization logos are whole-field references only (`var:organization.logo.icon`), so a `{{organization.logo}}` token, an unknown logo shape or an unknown organization id is reported.", { standard: SCHEMA }),
1914
2088
  rule("table-highlight-unknown-name", "format", "error", "A table highlight names a row the table does not have.", "`table.highlight` emphasizes body rows by their first-column text; a name that matches no row highlights nothing, so the table is not drawn as authored.", { standard: SCHEMA }),
2089
+ rule("table-color-scale-unknown-column", "format", "error", "A table color scale names a column the table does not have.", "`table.colorScale.columns` names the columns to shade by header text (a dataset-backed table by dataset column name after `fields`); a name that matches no column shades nothing, so the table is not drawn as authored.", { standard: SCHEMA }),
1915
2090
  rule("chart-highlight-unknown-name", "format", "error", "A chart highlight names a series or category the chart does not have.", "`chart.highlight` emphasizes marks by name; a name that matches no series or category in the chart data highlights nothing, so the chart is not drawn as authored.", { standard: SCHEMA }),
1916
2091
  rule("variable-format", "format", "error", "A variable cannot be formatted.", "A number or date format that does not apply to the value leaves the token unreadable.", { standard: SCHEMA }),
1917
2092
  rule(
@@ -1998,6 +2173,8 @@ var referenceRules = [
1998
2173
  rule("variable-unknown", "references", "warning", "A `{{token}}` names a variable that is not declared.", "An undeclared token is shown literally.", { standard: SCHEMA }),
1999
2174
  rule("variable-unknown-value", "references", "warning", "A value was supplied for a variable that is not declared.", "The value is never used.", { standard: SCHEMA }),
2000
2175
  rule("variable-unused", "references", "warning", "A variable is declared but never used.", "A declaration nothing refers to has no effect.", { standard: SCHEMA }),
2176
+ rule("variable-translation-duplicate", "references", "warning", "Two translations of a variable have the same language tag.", "Language tags compare without regard to case, so 'de-AT' and 'de-at' name one language. The first in document order is used; the other is never drawn.", { standard: SCHEMA }),
2177
+ rule("variable-translation-unused", "references", "warning", "A translation of a variable is never drawn.", "A translation is drawn on a slide whose declared language (else the deck's) selects it. When no slide and not the deck declares a language that selects it, it has no effect. A language read from the text does not select a translation.", { standard: SCHEMA, approximations: "Reads the declared language of the deck and of each slide, not where the variable is used." }),
2001
2178
  rule("variable-reference-unknown", "references", "warning", "A `var:` color names a variable that is not declared.", "An undeclared color variable falls back to a default color.", { standard: SCHEMA })
2002
2179
  ];
2003
2180
  var policyRules = [
@@ -2020,8 +2197,22 @@ var dataRules = [
2020
2197
  'A chart plots numbers. A text cell such as "12%" is plotted as a gap. When every text value of a column is written in one display style the finding carries the fix that stores the numbers and gives the column the matching format.',
2021
2198
  { standard: SCHEMA }
2022
2199
  ),
2200
+ rule("data-cell-type", "content", "warning", "A data cell does not match its column's declared type.", 'A dataset or chart data column may declare what its cells hold (`type`: text, number, date or boolean). A cell of another kind is reported; null is a gap in any type. A number is a finite number, so the string "12" is not one (the safe fix stores it as 12), and a date is any time label the time-order rule reads (2026-03, Q1 2026, Jan). Nothing is drawn differently: it is advice that the column says one thing and holds another. More than five mismatches in a column are one finding for the column.', { standard: SCHEMA }),
2201
+ rule("metric-data-stale", "content", "warning", "A metric's written value or change differs from the one its data computes.", "A metric linked to data draws the computed number, and keeps the last computed number as its written value and delta for readers that do not compute. When the two differ, those readers show a number the data no longer gives. The safe fix writes the computed number.", { standard: SCHEMA }),
2202
+ rule("metric-data-aggregate", "content", "warning", "A metric asks an aggregate that its column refuses.", "Sum, mean, minimum and maximum read numbers, and a column typed text or boolean has none. The written value is drawn instead.", { standard: SCHEMA }),
2203
+ rule("metric-data-empty", "content", "warning", "A metric's data link gives no value.", "No row of the dataset meets the filter, or none of the kept cells is usable for the aggregate. The written value is drawn instead.", { standard: SCHEMA }),
2204
+ rule("metric-data-delta", "content", "warning", "A metric's change cannot be computed.", "A previous row needs two kept rows, a baseline needs a row that meets its filter, a percent needs a comparison value other than 0, and the value must be a number. The value is still drawn, with no change.", { standard: SCHEMA }),
2205
+ rule("metric-unit-repeated", "content", "warning", "A metric's unit is already printed by its number format.", "The unit is printed after the value, so a format that already writes the same text as a prefix or suffix draws it twice.", { standard: SCHEMA }),
2206
+ rule("datasource-credentials", "content", "warning", "A data source holds a credential.", "A data source says where data lives and never holds credentials. A `src` with a user and password, or a query parameter named like a key or a token, writes a secret into a document that is shared, versioned and exported. Keep the secret in the host's own store and name the connection in `connector` or `extensions`.", { standard: SCHEMA }),
2207
+ rule("dataset-stale", "content", "warning", "A dataset is older than its data source says it should be.", "A data source may say how often it is meant to be taken again (`refreshEvery`, an ISO 8601 duration). Given a date to check as of, a dataset whose `retrieved` is older than that is reported. Core has no clock, so without a date nothing is reported, and no engine takes the data again.", { standard: SCHEMA }),
2023
2208
  rule("chart-mapping-adapted", "content", "warning", "A chart mapping entry is ignored.", "A mapping that names a column the chart type cannot use is left out of the chart.", { standard: SCHEMA }),
2024
2209
  rule("chart-highlight-adapted", "content", "warning", "A chart highlight is adapted by the chart type.", "A highlight the chart type cannot show as authored (a category highlight on a chart without categories, for example) is adapted by every engine, so the emphasis is not exactly what was written.", { standard: SCHEMA }),
2210
+ rule("table-color-scale-no-data", "content", "warning", "A table color scale has no numbers to shade.", "None of the named columns holds a number cell, so no cell is shaded. A dataset-backed table can lose its numbers on a refresh; the scale returns when they do.", { standard: SCHEMA }),
2211
+ rule("table-color-scale-range", "content", "warning", "A table color scale has an empty range or a center outside it.", "A pinned `min` that is not below `max`, or a `center` outside the range, leaves part of the scale unused: every value draws in one end color.", { standard: SCHEMA }),
2212
+ rule("chart-bands-order", "content", "warning", "Chart bands are not in increasing order.", "Each band runs from the previous band's `to` to its own, so the `to` values must increase. Every engine draws unordered bands sorted by `to`; the warning says the list does not read as it draws.", { standard: SCHEMA }),
2213
+ rule("metric-gauge-range", "content", "warning", "A metric gauge has an empty range, or a value, target or band outside it.", "A gauge draws its value on an arc from `min` to `max`. A `max` not above `min` draws no gauge; a value outside the range keeps its real number while its arc stops at the end, a target outside it is not drawn, and a band end outside it is drawn to the end of the range.", { standard: SCHEMA }),
2214
+ rule("metric-gauge-value", "content", "warning", "A metric with a gauge has no number to draw.", "A gauge draws a number on its arc. A metric whose drawn value is text (a string literal, or a computed value that is not a number) is drawn without its gauge.", { standard: SCHEMA }),
2215
+ rule("chart-bands-unsupported", "content", "warning", "A chart has bands but its type does not draw them.", "Bands shade ranges of a value axis behind the data: bar, column, line and area charts (and their stacked forms) and the bullet chart draw them. On a pie, doughnut, scatter, radar, combo or Office 2016 construct they are ignored by every engine.", { standard: SCHEMA }),
2025
2216
  rule("chart-series-dropped", "content", "warning", "A chart series is not drawn by the chart type.", "A treemap, histogram, one-series Pareto, waterfall, funnel, map or single-series pie plots one value series, and a scatter plots no X column without numbers. Every engine leaves the same columns out (LH-60), so the warning names them instead of losing them silently.", { standard: SCHEMA, approximations: "Read from the drawn chart (chartDrawPlan): a world chart over categories that are mostly not places and a Pareto chart of several series are drawn as columns, a box-and-whisker chart with one value per category as one box per series and a pie or doughnut of several series as nested rings, and none of those drops a series." }),
2026
2217
  rule("code-highlight-out-of-range", "content", "warning", "A code highlight marks a line the code does not have.", "Marked lines count from 1 by line break in code.source; an entry past the last line marks nothing.", { standard: SCHEMA }),
2027
2218
  rule("code-highlight-range-reversed", "content", "warning", "A code highlight range ends before it starts.", "A range written end before start marks nothing; write the smaller line number first.", { standard: SCHEMA }),
@@ -2391,15 +2582,16 @@ var layoutMonotonyRule = rule(
2391
2582
  approximations: "Compares the layout reference of each slide (a catalog prefix is ignored). Cover, section and closing slides, slides with no body content and slides without a layout record (automatic composition) break a run and are not counted; hidden slides are skipped. One finding per run, at its first slide."
2392
2583
  }
2393
2584
  );
2394
- var straightQuotesRule = rule(
2395
- "straight-quotes",
2396
- "content",
2397
- "info",
2398
- `Text uses straight quotation marks (" or ') where the language has typographic ones.`,
2399
- "Straight marks are a typewriter substitute. Typeset text uses the quotation marks of its language (\u201C\u2026\u201D in English, \xAB\u2026\xBB in French, \u201E\u2026\u201C in German), and a deck that mixes them with the marks the engine draws around quotes looks unfinished.",
2585
+ var variableOverflowRule = rule(
2586
+ "variable-overflow",
2587
+ "layout",
2588
+ "warning",
2589
+ "A variable's value is longer than the room its declaration allows.",
2590
+ "A template slot is sized for a short value. A value over the declaration's maxLength, a list over its maxItems, or text that takes more lines than maxLines where it is drawn still draws, but not as the template was designed; the finding is raised before the deck is exported, not found on one slide of a batch.",
2400
2591
  {
2401
- standard: "The quotation marks of the deck language, as the engines draw them around a quote (QUOTE_MARKS in core).",
2402
- approximations: "Checks titles, subtitles, tags, body text, list items and descriptions, and quotes; not table cells, metrics, timelines, code or runs with `code: true`. A `\"` after a digit is an inch mark and a `'` between letters or after a digit is an apostrophe or a foot mark; single quotes count only as a pair around words. A language with no typographic marks of its own (one OPF draws ASCII quotes for) is not checked. When only double quotes are found, the finding carries a patch to the language's marks."
2592
+ cost: "composition",
2593
+ standard: "The variable declaration's maxLength, maxLines and maxItems (spec/schemas/opf.schema.json, TextVariable and ListVariable).",
2594
+ approximations: "maxLength counts characters as a reader sees them (grapheme clusters, Intl.Segmenter), not code units, and maxItems counts entries; both are read on the value (the declared value, or the value given to the check with `values`) and reported once at the declaration. maxLines is read from composition at each place the variable is drawn, with the fonts and measurement of the check: a title, a subtitle, a tag, a text block or a list entry, on its own or inside longer text (then the lines are those the variable's own characters occupy). One finding per place, naming the slide. A place composition does not break into lines (a table cell, a chart label, text in a shape) and a value the layout reshapes are not measured. A variable with no value or example is not measured, and neither is a type sample."
2403
2595
  }
2404
2596
  );
2405
2597
  var PIE_MAX_SLICES = 5;
@@ -2463,7 +2655,7 @@ var implementedRules = [
2463
2655
  centeredBodyRule,
2464
2656
  tightSpacingRule,
2465
2657
  layoutMonotonyRule,
2466
- straightQuotesRule,
2658
+ variableOverflowRule,
2467
2659
  chartDualAxisRule,
2468
2660
  chartPieManySlicesRule
2469
2661
  ];
@@ -2523,7 +2715,7 @@ function collectSamples(context) {
2523
2715
  const scale = Math.min(design.dimensions.width, design.dimensions.height) / 720;
2524
2716
  for (const item of composition.items) {
2525
2717
  const itemDesign = item.emphasis && surfaceDesign ? surfaceDesign : design;
2526
- if (["chart", "image", "video", "code"].includes(item.field) || item.type === "chart" || item.type === "image" || item.type === "video" || item.type === "code") continue;
2718
+ if (["chart", "image", "video", "embed", "code"].includes(item.field) || item.type === "chart" || item.type === "image" || item.type === "video" || item.type === "embed" || item.type === "code") continue;
2527
2719
  const backdrop = item.emphasis && emphasisBackdrop ? emphasisBackdrop : item.frameBox ? surface : slideBackdrop(context, textInkBox(item, measurement));
2528
2720
  const itemPath = pointerOfDotted(item.path);
2529
2721
  const heading = item.field === "title" || item.field === "subtitle" || item.field === "tag";
@@ -3177,10 +3369,10 @@ function canonicalJson(value) {
3177
3369
  if (Array.isArray(item)) {
3178
3370
  text2 = `[${item.map((entry2) => write(entry2) ?? "null").join(",")}]`;
3179
3371
  } else {
3180
- const record = item;
3372
+ const record2 = item;
3181
3373
  const members = [];
3182
- for (const key3 of Object.keys(record).sort()) {
3183
- const member = write(record[key3]);
3374
+ for (const key3 of Object.keys(record2).sort()) {
3375
+ const member = write(record2[key3]);
3184
3376
  if (member !== void 0) members.push(`${JSON.stringify(key3)}:${member}`);
3185
3377
  }
3186
3378
  text2 = `{${members.join(",")}}`;
@@ -3363,7 +3555,7 @@ function renamedRegion(layout, region) {
3363
3555
  const names2 = Object.hasOwn(RENAMED_REGIONS, layout) ? RENAMED_REGIONS[layout] : void 0;
3364
3556
  return names2 && Object.hasOwn(names2, region) ? names2[region] : void 0;
3365
3557
  }
3366
- function layoutRegionNames(record) {
3558
+ function layoutRegionNames(record2) {
3367
3559
  const names2 = /* @__PURE__ */ new Set();
3368
3560
  const walk2 = (regions) => {
3369
3561
  if (!Array.isArray(regions)) return;
@@ -3373,16 +3565,16 @@ function layoutRegionNames(record) {
3373
3565
  walk2(region.regions);
3374
3566
  }
3375
3567
  };
3376
- walk2(rec2(record).regions);
3568
+ walk2(rec2(record2).regions);
3377
3569
  return names2;
3378
3570
  }
3379
- function layoutRecordIssues(id, record) {
3380
- return validateAgainstSchema(isRec2(record) ? { $schema: schemas[catalogSchemaNames.layouts].$id, id, ...record } : record, "layouts").errors;
3571
+ function layoutRecordIssues(id, record2) {
3572
+ return validateAgainstSchema(isRec2(record2) ? { $schema: schemas[catalogSchemaNames.layouts].$id, id, ...record2 } : record2, "layouts").errors;
3381
3573
  }
3382
3574
  function staleLayoutCopy(document, group, id, options2 = {}) {
3383
3575
  if (group === "custom") return void 0;
3384
- const record = embeddedLayouts(document, group)[id];
3385
- if (!isRec2(record)) return void 0;
3576
+ const record2 = embeddedLayouts(document, group)[id];
3577
+ if (!isRec2(record2)) return void 0;
3386
3578
  const registered = rec2(registeredCatalog(catalogGroupSource(document, group, options2), options2)?.layouts);
3387
3579
  const base = { group, id, path: pointer3(["catalogs", group, "layouts", id]) };
3388
3580
  if (isRec2(registered[id])) return { ...base, current: embeddedCopy(registered[id]) };
@@ -3412,11 +3604,11 @@ function pinOperations(document, index, layout, before, next) {
3412
3604
  const names2 = layoutRegionNames(next);
3413
3605
  const blocks = slideAt(document, index).blocks;
3414
3606
  const ops = [];
3415
- (Array.isArray(blocks) ? blocks : []).forEach((block, at2) => {
3607
+ (Array.isArray(blocks) ? blocks : []).forEach((block, at3) => {
3416
3608
  const pin = rec2(block).region;
3417
3609
  if (typeof pin !== "string" || names2.has(pin) || !before.has(pin)) return;
3418
3610
  const renamed = renamedRegion(layout, pin);
3419
- if (renamed !== void 0 && names2.has(renamed)) ops.push({ op: "replace", path: pointer3(["slides", index, "blocks", at2, "region"]), value: renamed });
3611
+ if (renamed !== void 0 && names2.has(renamed)) ops.push({ op: "replace", path: pointer3(["slides", index, "blocks", at3, "region"]), value: renamed });
3420
3612
  });
3421
3613
  return ops;
3422
3614
  }
@@ -3457,8 +3649,8 @@ function staleCopyFix(document, copy, options2 = {}) {
3457
3649
  return copy.renamed ? { id: "rename-layout", title: `Use layout ${copy.renamed.id} and drop the old copy of ${copy.id}`, ...marks } : { id: "use-current-record", title: `Take the current ${copy.id} record`, ...marks };
3458
3650
  }
3459
3651
  var applyOperation = (root, operation) => {
3460
- const segmentsOf2 = (path) => path.slice(1).split("/").map((segment) => segment.replaceAll("~1", "/").replaceAll("~0", "~"));
3461
- const parentOf2 = (segments2) => segments2.slice(0, -1).reduce((node, segment) => node[segment], root);
3652
+ const segmentsOf2 = (path) => path.slice(1).split("/").map((segment2) => segment2.replaceAll("~1", "/").replaceAll("~0", "~"));
3653
+ const parentOf2 = (segments2) => segments2.slice(0, -1).reduce((node, segment2) => node[segment2], root);
3462
3654
  const segments = segmentsOf2(operation.path);
3463
3655
  if (operation.op === "move") {
3464
3656
  const from = segmentsOf2(operation.from);
@@ -3472,8 +3664,8 @@ function refreshStaleLayouts(document, options2 = {}) {
3472
3664
  const refreshed = [];
3473
3665
  for (const [group, value] of Object.entries(rec2(document.catalogs))) {
3474
3666
  if (group === "custom" || !isRec2(value) || !isRec2(value.layouts)) continue;
3475
- for (const [id, record] of Object.entries(value.layouts)) {
3476
- if (!layoutRecordIssues(id, record).length) continue;
3667
+ for (const [id, record2] of Object.entries(value.layouts)) {
3668
+ if (!layoutRecordIssues(id, record2).length) continue;
3477
3669
  const copy = staleLayoutCopy(document, group, id, options2);
3478
3670
  if (!copy || !(copy.current || copy.renamed?.current)) continue;
3479
3671
  const patch2 = staleCopyPatch(document, copy, options2);
@@ -3534,6 +3726,8 @@ var layoutRules = [
3534
3726
  context.report(shapeOffSlideRule, { path, slide, message: diagnostic.message, help: "Write the position as fractions (0.2 for 20%), move the shape so part of it is on the slide, or remove it. A shape may hang over an edge; only one with nothing on the slide is reported." });
3535
3727
  else if (diagnostic.code === "chart-label-collision")
3536
3728
  context.report(chartLabelCollisionRule, { path, slide, message: diagnostic.message, help: "Put the label at the other end of its line (labelPosition 'start' or 'end'), shorten it, or give the chart more room. Its text and value are kept." });
3729
+ else if (diagnostic.code === "chart-band-labels-in-legend") continue;
3730
+ else if (diagnostic.code === "metric-gauge-dropped") continue;
3537
3731
  else if (diagnostic.code === "timeline-period-short")
3538
3732
  context.report(timelinePeriodShortRule, { path, slide, message: diagnostic.message, help: "Give the timeline more room, or make its shortest period longer relative to the others." });
3539
3733
  else if (Object.hasOwn(REGION_RULES, diagnostic.code)) {
@@ -3566,7 +3760,7 @@ var layoutRules = [
3566
3760
  path,
3567
3761
  slide,
3568
3762
  message: `${label} is drawn at ${round2(sizePx * PX_TO_PT2)} pt${scale === 1 ? "" : " (reference slide size)"}, below the ${context.thresholds.minFontSizePt} pt minimum.`,
3569
- help: "Shorten the text or give it more room so it can be drawn larger; check composition.minFontSize and run fontSize settings that force small type.",
3763
+ help: "Shorten the text or give it more room so it can be drawn larger; check composition.minFontSizePx and run fontSize settings that force small type.",
3570
3764
  measured: { sizePt: round2(sizePx * PX_TO_PT2, 2), minimumPt: context.thresholds.minFontSizePt }
3571
3765
  });
3572
3766
  };
@@ -3725,7 +3919,7 @@ var contentRules = [
3725
3919
  if (slide.slide.layout === "blank") continue;
3726
3920
  const has = (value) => value !== void 0 && value !== null && !(typeof value === "string" && value.trim() === "") && !(Array.isArray(value) && value.length === 0);
3727
3921
  const hasText = slide.texts.some((tv) => plainText(tv.value).trim() !== "");
3728
- const hasObject = slidePayloads(slide.slide, slide.path).some((p) => ["image", "video", "chart", "table", "code", "metric", "quote", "timeline", "diagram"].some((field) => has(p.node[field])));
3922
+ const hasObject = slidePayloads(slide.slide, slide.path).some((p) => ["image", "video", "embed", "chart", "table", "code", "metric", "quote", "timeline", "diagram"].some((field) => has(p.node[field])));
3729
3923
  const hasBackgroundImage = imageBackground(rec(slide.slide.design).background) !== void 0;
3730
3924
  if (hasText || hasObject || hasBackgroundImage) continue;
3731
3925
  context.report(emptySlideRule, { path: slide.path, slide, message: `Slide ${slide.index + 1} has no title and no content.`, help: "Add content, delete the slide, or give it the blank layout if it is intentionally empty." });
@@ -3764,7 +3958,7 @@ function fittedSize(item, slide, document) {
3764
3958
  if (item.field === "code") return body(item.codeLayout?.parts);
3765
3959
  if (item.field === "table") {
3766
3960
  try {
3767
- const table = layoutTable(item.value, item.box, { scale: canvasScale(slide.composition), minFontSize: item.composition.minFontSize, fontFamily: slide.design.fonts.body, textMeasurement: slide.measurement, path: item.path, presentation: document });
3961
+ const table = layoutTable(item.value, item.box, { scale: canvasScale(slide.composition), minFontSizePx: item.composition.minFontSizePx, fontFamily: slide.design.fonts.body, textMeasurement: slide.measurement, path: item.path, presentation: document });
3768
3962
  if (table.overflow) return void 0;
3769
3963
  const sizes = table.rows.flatMap((row) => row.cells.filter((cell) => !cell.header).map((cell) => cell.fit.fontSize));
3770
3964
  return sizes.length ? Math.min(...sizes) : void 0;
@@ -3913,7 +4107,7 @@ var tightSpacing = {
3913
4107
  }
3914
4108
  }
3915
4109
  };
3916
- var hasBody = (slide) => slide.payloads.some((payload) => ["text", "items", "bullets", "image", "video", "chart", "table", "code", "metric", "quote", "timeline", "diagram", "blocks"].some((field) => {
4110
+ var hasBody = (slide) => slide.payloads.some((payload) => ["text", "items", "bullets", "image", "video", "embed", "chart", "table", "code", "metric", "quote", "timeline", "diagram", "blocks"].some((field) => {
3917
4111
  const value = payload.node[field];
3918
4112
  return value !== void 0 && value !== null && !(Array.isArray(value) && value.length === 0) && !(typeof value === "string" && value.trim() === "");
3919
4113
  }));
@@ -3947,63 +4141,7 @@ var layoutMonotony = {
3947
4141
  flush();
3948
4142
  }
3949
4143
  };
3950
- var PROSE_ROLES = /* @__PURE__ */ new Set(["title", "subtitle", "tag", "body", "list", "list-description", "quote", "quote-footer"]);
3951
- var LETTER = /[\p{L}\p{N}]/u;
3952
- var OPENING = /[\s([{—–-]/u;
3953
- function straightQuoteMarks(text2) {
3954
- let double = 0, single = 0, open = false;
3955
- for (let i = 0; i < text2.length; i++) {
3956
- const char = text2[i], before = text2[i - 1] ?? "", after = text2[i + 1] ?? "";
3957
- if (char === '"') {
3958
- if (!/\d/.test(before)) double++;
3959
- } else if (char === "'") {
3960
- const wordAfter = LETTER.test(after), opens = before === "" || OPENING.test(before);
3961
- if (LETTER.test(before) && wordAfter || /\d/.test(before)) continue;
3962
- if (opens && wordAfter && !/\d/.test(after)) open = true;
3963
- else if (!opens && !wordAfter && open) {
3964
- single += 2;
3965
- open = false;
3966
- }
3967
- }
3968
- }
3969
- return { double, single };
3970
- }
3971
- function curlDoubleQuotes(text2, marks) {
3972
- return text2.replace(/(^|.)"/gsu, (whole, before) => /\d/.test(before) ? whole : `${before}${before === "" || OPENING.test(before) ? marks.open : marks.close}`);
3973
- }
3974
- var straightQuotes = {
3975
- info: straightQuotesRule,
3976
- run(context) {
3977
- for (const slide of context.slides) {
3978
- const marks = quoteMarksFor(quoteLanguage(context.document, slide.index));
3979
- if (marks.open === '"') continue;
3980
- for (const tv of slide.texts) {
3981
- if (!PROSE_ROLES.has(tv.role)) continue;
3982
- let double = 0, single = 0;
3983
- const fixes = [];
3984
- for (const run of runsOf(tv)) {
3985
- if (run.style.code === true) continue;
3986
- const found = straightQuoteMarks(run.text);
3987
- double += found.double;
3988
- single += found.single;
3989
- if (found.double) fixes.push({ op: "replace", path: run.index === -1 ? run.path : `${run.path}${typeof tv.value !== "string" && typeof tv.value[run.index] === "string" ? "" : "/text"}`, value: curlDoubleQuotes(run.text, marks) });
3990
- }
3991
- if (!double && !single) continue;
3992
- const kinds = [double ? `${double} straight double quote${double === 1 ? "" : "s"} (")` : "", single ? `${single} straight single quotes (')` : ""].filter(Boolean).join(" and ");
3993
- const text2 = plainText(tv.value);
3994
- context.report(straightQuotesRule, {
3995
- path: tv.path,
3996
- slide,
3997
- message: `Text has ${kinds}: ${JSON.stringify(text2.length > 60 ? `${text2.slice(0, 57)}...` : text2)}.`,
3998
- help: `Use the typographic quotation marks of the deck's language (${marks.open}...${marks.close}).${tv.role === "quote" ? " A quote payload adds its own marks around the whole quote." : ""}`,
3999
- measured: { double, single, open: marks.open, close: marks.close },
4000
- ...!single && fixes.length ? { fixes: [{ id: "use-typographic-quotes", title: `Use ${marks.open}${marks.close}`, kind: "patch", safe: false, patch: fixes }] } : {}
4001
- });
4002
- }
4003
- }
4004
- }
4005
- };
4006
- var layoutFindingRules = [textShrunk, centeredBody, tightSpacing, layoutMonotony, straightQuotes];
4144
+ var layoutFindingRules = [textShrunk, centeredBody, tightSpacing, layoutMonotony];
4007
4145
 
4008
4146
  // src/rules-chart-findings.ts
4009
4147
  var chartPath = (payloadPath, slidePath) => `${payloadPath === slidePath ? slidePath : payloadPath}/chart`;
@@ -4050,109 +4188,609 @@ var chartPieManySlices = {
4050
4188
  };
4051
4189
  var chartFindingRules = [chartDualAxis, chartPieManySlices];
4052
4190
 
4053
- // src/validation-rules.ts
4054
- var ruleImplementations = [...accessibilityRules, ...layoutContentRules, ...languageTagRules, ...layoutFindingRules, ...chartFindingRules];
4055
-
4056
- // src/chart-shape.ts
4057
- var FOREIGN_CHART_KEYS = ["categories", "series", "labels", "datasets"];
4058
- var CHART_DEFINITION = "https://openpresentation.org/schema/opf/v1#/$defs/Chart";
4059
- var isRecord3 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
4060
- var isCell = (value) => value === null || ["string", "number", "boolean"].includes(typeof value);
4061
- function foreignChartKeys(chart) {
4062
- if (!isRecord3(chart) || Object.hasOwn(chart, "data")) return [];
4063
- return FOREIGN_CHART_KEYS.filter((key3) => Object.hasOwn(chart, key3));
4064
- }
4065
- function convertChartData(chart) {
4066
- const labels = chart.categories ?? chart.labels;
4067
- const series = chart.series ?? chart.datasets;
4068
- if (!Array.isArray(labels) || !labels.length || !labels.every(isCell) || !Array.isArray(series) || !series.length) return void 0;
4069
- const columns = ["Category"];
4070
- const values = [];
4071
- for (const [index, entry2] of series.entries()) {
4072
- if (!isRecord3(entry2)) return void 0;
4073
- const list = entry2.values ?? entry2.data;
4074
- const name = entry2.name ?? entry2.label;
4075
- if (!Array.isArray(list) || list.length !== labels.length || !list.every(isCell)) return void 0;
4076
- columns.push(typeof name === "string" && name ? name : `Series ${index + 1}`);
4077
- values.push(list);
4191
+ // src/drawn-font-families.ts
4192
+ function resolveDrawnFontFamilies(families, measurement, keepsName) {
4193
+ const resolve2 = measurement?.resolveStyle;
4194
+ if (typeof resolve2 !== "function") return families;
4195
+ const drawn = { ...families };
4196
+ for (const role of ["heading", "body", "code", "accent"]) {
4197
+ const named = families[role];
4198
+ if (typeof named !== "string" || !named) continue;
4199
+ try {
4200
+ const resolved2 = resolve2.call(measurement, { fontFamily: named, fontWeight: role === "heading" ? 700 : 400 });
4201
+ let keep3;
4202
+ if (keepsName) keep3 = keepsName(named, resolved2.fontFamily);
4203
+ else {
4204
+ const regular = role === "heading" ? resolve2.call(measurement, { fontFamily: named, fontWeight: 400 }) : resolved2;
4205
+ const encoded = resolved2.symbolEncoding != null;
4206
+ keep3 = encoded || regular.fontWeight !== void 0 && regular.fontWeight !== 400 && resolved2.fontFamily.toLowerCase() !== named.toLowerCase();
4207
+ }
4208
+ if (!keep3) drawn[role] = resolved2.fontFamily;
4209
+ } catch {
4210
+ }
4078
4211
  }
4079
- if (new Set(columns).size !== columns.length) return void 0;
4080
- return { columns, rows: labels.map((label, row) => [label, ...values.map((list) => list[row])]) };
4081
- }
4082
- function chartShapePatch(chart, path) {
4083
- if (!isRecord3(chart)) return void 0;
4084
- const data = convertChartData(chart);
4085
- const keys = foreignChartKeys(chart);
4086
- if (!data || !keys.length) return void 0;
4087
- return [{ op: "add", path: `${path}/data`, value: data }, ...keys.map((key3) => ({ op: "remove", path: `${path}/${key3}` }))];
4088
- }
4089
- var SHOWN_ROWS = 3;
4090
- var json = (value) => JSON.stringify(value);
4091
- function dataExample(chart) {
4092
- const data = convertChartData(chart);
4093
- if (!data) return '"data": { "columns": ["Category", "Series name"], "rows": [["Q1", 3], ["Q2", 8]] }';
4094
- const rows = data.rows.slice(0, SHOWN_ROWS).map(json);
4095
- return `"data": { "columns": ${json(data.columns)}, "rows": [${rows.join(",")}${data.rows.length > SHOWN_ROWS ? ",..." : ""}] }`;
4212
+ return drawn;
4096
4213
  }
4097
- function chartShapeHelp(chart) {
4098
- const keys = foreignChartKeys(chart);
4099
- if (!keys.length || !isRecord3(chart)) return void 0;
4100
- const names2 = keys.map((key3) => `"${key3}"`).join(" and ");
4101
- const example = dataExample(chart);
4102
- const next = `replace ${names2} with ${example}. The first column holds the category labels and each further column is one series.`;
4214
+
4215
+ // src/script-measurement.ts
4216
+ function scriptProfile(presentation, slideIndex, options2, language) {
4217
+ let resolved2;
4218
+ try {
4219
+ resolved2 = resolveScriptFonts(presentation, { slideIndex, ...options2.catalogs !== void 0 ? { catalogs: options2.catalogs } : {}, ...language === void 0 ? {} : { language } });
4220
+ } catch {
4221
+ resolved2 = void 0;
4222
+ }
4223
+ const slots = (role) => {
4224
+ const latin = options2.fontFamilies[role];
4225
+ const slot = (key3) => !resolved2 || resolved2.sources[key3] === "latin" || resolved2.sources[key3] === "schemeFamily" ? latin : resolved2[role][key3] ?? latin;
4226
+ return { latin, eastAsian: slot("eastAsian"), complexScript: slot("complexScript") };
4227
+ };
4103
4228
  return {
4104
- message: `The chart has ${names2} (the Chart.js and ECharts shape), but an OPF chart keeps its values in "data": { "columns", "rows" }.`,
4105
- next,
4106
- help: `OPF charts use "data": { "columns", "rows" }, not ${names2}. Replace ${names2} with ${example}; the first column holds the category labels and each further column is one series. See the Chart definition: ${CHART_DEFINITION} (opf schema presentation '/$defs/Chart').`
4229
+ heading: slots("heading"),
4230
+ body: slots("body"),
4231
+ ...resolved2?.supplement ? { supplement: resolved2.supplement } : {},
4232
+ script: resolved2?.script ?? "Zzzz",
4233
+ ...resolved2 ? { scriptRole: resolved2.scriptRole, bcp47: resolved2.bcp47, lang: resolved2.lang, languageSource: resolved2.languageSource, direction: resolved2.direction } : {},
4234
+ rtl: resolved2?.rtl === true,
4235
+ serif: options2.serif
4107
4236
  };
4108
4237
  }
4109
-
4110
- // src/check-document.ts
4111
- var own = (value, key3) => Object.hasOwn(value, key3);
4112
- var object2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
4113
- var primitive = (value) => value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value);
4114
- var pointer4 = (parts2) => parts2.length ? "/" + parts2.map((part2) => String(part2).replaceAll("~", "~0").replaceAll("/", "~1")).join("/") : "";
4115
- function parts(path) {
4116
- if (path === "") return [];
4117
- if (!path.startsWith("/") || /~(?![01])/.test(path))
4118
- throw new TypeError(`Invalid contract JSON Pointer: ${path}`);
4119
- return path.slice(1).split("/").map((part2) => part2.replaceAll("~1", "/").replaceAll("~0", "~"));
4238
+ function slideScriptMeasurement(presentation, slideIndex, measurement, options2) {
4239
+ const forScripts = measurement.forScripts;
4240
+ if (typeof forScripts !== "function") return measurement;
4241
+ const deckProfile = scriptProfile(presentation, slideIndex, options2);
4242
+ const deck = forScripts.call(measurement, deckProfile);
4243
+ const languages = /* @__PURE__ */ new Map();
4244
+ const forLanguage = (lang) => {
4245
+ if (typeof lang !== "string" || !lang) return void 0;
4246
+ if (!languages.has(lang)) {
4247
+ let own4;
4248
+ try {
4249
+ const profile = scriptProfile(presentation, slideIndex, options2, lang);
4250
+ own4 = profile.languageSource === "option" && profile.bcp47?.toLowerCase() !== deckProfile.bcp47?.toLowerCase() ? forScripts.call(measurement, profile) : void 0;
4251
+ } catch {
4252
+ own4 = void 0;
4253
+ }
4254
+ languages.set(lang, own4);
4255
+ }
4256
+ return languages.get(lang);
4257
+ };
4258
+ const pick = (style) => forLanguage(style?.lang) ?? deck;
4259
+ const scripted = { ...deck, measure: (text2, size, style) => pick(style).measure(text2, size, style) };
4260
+ if (typeof deck.resolveStyle === "function") scripted.resolveStyle = (style) => deck.resolveStyle.call(deck, style);
4261
+ if (typeof deck.outlineBounds === "function")
4262
+ scripted.outlineBounds = (text2, size, style) => {
4263
+ const own4 = pick(style);
4264
+ return typeof own4.outlineBounds === "function" ? own4.outlineBounds(text2, size, style) : deck.outlineBounds.call(deck, text2, size, style);
4265
+ };
4266
+ return scripted;
4120
4267
  }
4121
- function at(value, path) {
4122
- return parts(path).reduce(
4123
- (current, key3) => object2(current) || Array.isArray(current) ? own(current, key3) ? current[key3] : void 0 : void 0,
4124
- value
4125
- );
4268
+ function resolveSlideScriptMeasurement(presentation, slideIndex, measurement, options2 = {}) {
4269
+ if (typeof measurement.forScripts !== "function") return measurement;
4270
+ const { fontScheme } = resolveDesignRecords(presentation, slideIndex, options2.catalogs !== void 0 ? { catalogs: options2.catalogs } : {});
4271
+ const resolved2 = resolveFontFamilies(fontScheme);
4272
+ const fontFamilies = { heading: options2.fontFamilies?.heading ?? resolved2.heading, body: options2.fontFamilies?.body ?? resolved2.body };
4273
+ return slideScriptMeasurement(presentation, slideIndex, measurement, { ...options2.catalogs !== void 0 ? { catalogs: options2.catalogs } : {}, fontFamilies, serif: fontScheme.type === "serif" });
4126
4274
  }
4127
- function checkDocumentOptions(options2) {
4128
- checkCatalogsOption(options2.catalogs, "validate");
4129
- if (options2.contracts !== void 0 && !Array.isArray(options2.contracts))
4130
- throw new TypeError("Validate contracts must be an array.");
4131
- for (const contract2 of options2.contracts ?? []) {
4132
- if (!object2(contract2) || Object.keys(contract2).some(
4133
- (key3) => ![
4134
- "path",
4135
- "allowedValues",
4136
- "severity",
4137
- "message",
4138
- "documentation"
4139
- ].includes(key3)
4140
- ) || typeof contract2.path !== "string" || !Array.isArray(contract2.allowedValues) || !contract2.allowedValues.every(primitive) || contract2.severity !== void 0 && (typeof contract2.severity !== "string" || !["error", "warning", "info"].includes(contract2.severity)) || contract2.message !== void 0 && typeof contract2.message !== "string" || contract2.documentation !== void 0 && typeof contract2.documentation !== "string")
4141
- throw new TypeError(
4142
- "Invalid contract: provide a path and primitive allowedValues, with optional severity, message and documentation."
4143
- );
4144
- parts(contract2.path);
4275
+
4276
+ // src/message-surface.ts
4277
+ var rec3 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
4278
+ var MESSAGE_SURFACE_SLOT = "accent1";
4279
+ var MESSAGE_SURFACE_CONTRAST = 4.5;
4280
+ function messageKind(slide, layout) {
4281
+ const lone = lonePayload(slide);
4282
+ if (lone?.field !== "text" || annotationText(slide.subtitle).trim()) return void 0;
4283
+ let plan;
4284
+ try {
4285
+ plan = isLayoutTemplate(layout) ? layoutTemplate(layout) : void 0;
4286
+ } catch {
4287
+ return void 0;
4145
4288
  }
4289
+ if (plan?.stack !== void 0 && statementMessage(slide, plan) !== void 0) return "statement-message";
4290
+ if (plan && (plan.regions.length > 1 || plan.regions.some((region) => region.role === "media" || region.flow === "grid" || region.flow === "row"))) return void 0;
4291
+ const value = lone.host.text;
4292
+ const cited = Array.isArray(value) && value.some((run) => run && typeof run === "object" && (run.cite !== void 0 || run.footnote !== void 0));
4293
+ return !cited && messageWords(value) > 0 && messageWords(value) <= SHORT_MESSAGE_WORDS ? "display-message" : void 0;
4146
4294
  }
4147
- function finding(ruleId, data) {
4148
- const info = ruleInfo(ruleId);
4149
- const { severity, scope, ...rest } = data;
4150
- return { ruleId, severity: severity ?? info.severity, category: info.category, scope: scope ?? "document", ...rest };
4295
+ function lchOf(hex) {
4296
+ const lin = (at3) => {
4297
+ const value = Number.parseInt(hex.slice(at3, at3 + 2), 16) / 255;
4298
+ return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
4299
+ };
4300
+ const [r, g, b] = [lin(1), lin(3), lin(5)];
4301
+ const x = (0.4124564 * r + 0.3575761 * g + 0.1804375 * b) / 0.95047, y = 0.2126729 * r + 0.7151522 * g + 0.072175 * b, z = (0.0193339 * r + 0.119192 * g + 0.9503041 * b) / 1.08883;
4302
+ const f = (t) => t > 216 / 24389 ? Math.cbrt(t) : (24389 / 27 * t + 16) / 116;
4303
+ const [fx, fy, fz] = [f(x), f(y), f(z)];
4304
+ return { L: 116 * fy - 16, C: Math.hypot(500 * (fx - fy), 200 * (fy - fz)) };
4151
4305
  }
4152
- var issueRuleId = (issue2) => typeof issue2.params.code === "string" && issue2.keyword === "opf" ? `opf/${issue2.params.code}` : "opf/schema";
4153
- function issueFinding(issue2, ruleId = issueRuleId(issue2), schemaName = "presentation", prefix = "", scope = "document", severity) {
4154
- const path = prefix + (issue2.path === "/" ? "" : issue2.path) + (issue2.keyword === "additionalProperties" && typeof issue2.params.additionalProperty === "string" ? pointer4([issue2.params.additionalProperty]) : ""), entry2 = schemaEntries.find((entry3) => entry3.name === schemaName);
4155
- if (!entry2) throw new TypeError(`Unknown schema ${schemaName}`);
4306
+ var MESSAGE_SURFACE_MAX_LIGHTNESS = 60;
4307
+ var MESSAGE_SURFACE_MAX_CHROMA = 80;
4308
+ function resolveMessageSurface(presentation, slide, layout, context) {
4309
+ const deckDesign = rec3(rec3(presentation).design);
4310
+ const kind = messageKind(slide, layout), named = layoutVariantKind(layout);
4311
+ if (kind === void 0 || !(named === void 0 || named === "surface") || deckBackgroundIsChosen(deckDesign, context.theme.background) || !layoutVariantApplies(slide.design, layout, deckDesign, context.theme.background, true)) return void 0;
4312
+ const below = colorChoice([deckDesign, context.theme], context.colorScheme, context.variables);
4313
+ const variant = { background: MESSAGE_SURFACE_SLOT, ...below.variant?.accents ? { accents: below.variant.accents } : {} };
4314
+ const plain2 = resolveColorRoles(context.colorScheme, { background: below.background, variant: below.variant });
4315
+ const deliberate = [deckDesign, ...context.themeChosen ? [context.theme] : []].some((level) => level.background !== void 0 || level.variant !== void 0);
4316
+ if (plain2.dark && deliberate) return void 0;
4317
+ const accent = resolveColorRoles(context.colorScheme, { variant }), shade = lchOf(accent.background.slice(0, 7).toUpperCase());
4318
+ if (accent.background.toUpperCase() === plain2.background.toUpperCase() || (colorContrast(accent.text, accent.background) ?? 0) < MESSAGE_SURFACE_CONTRAST || shade.L > MESSAGE_SURFACE_MAX_LIGHTNESS || shade.C > MESSAGE_SURFACE_MAX_CHROMA) return void 0;
4319
+ return { kind, variant };
4320
+ }
4321
+ function drawsAccentByDesign(presentation, host, record2, theme) {
4322
+ const deckDesign = rec3(rec3(presentation).design), own4 = normalizeColorVariant(rec3(host.design).variant), named = layoutColorVariant(record2);
4323
+ if (own4) return own4.background.startsWith("accent");
4324
+ return named !== void 0 && layoutVariantApplies(host.design, record2, deckDesign, theme.background) && named.background.startsWith("accent");
4325
+ }
4326
+ function messageDisplayed(result, kind) {
4327
+ const scale = Math.min(result.width, result.height) / 720, size = (field) => result.items.find((item) => item.field === field)?.text?.fontSize;
4328
+ const text2 = size("text"), title = size("title");
4329
+ if (kind === "statement-message") return text2 !== void 0 && text2 / scale >= LONE_DISPLAY_SIZES.text - 1e-6 || title !== void 0 && title / scale > 54 + 1e-6;
4330
+ return text2 !== void 0 && text2 / scale > LONE_DISPLAY_SIZES.text + 1e-6;
4331
+ }
4332
+
4333
+ // src/slide-context.ts
4334
+ var rec4 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
4335
+ function unpathed(measurement) {
4336
+ const bare = (style) => ({ ...style, path: void 0 });
4337
+ return {
4338
+ ...measurement,
4339
+ measure: (text2, size, style) => measurement.measure(text2, size, bare(style)),
4340
+ ...measurement.resolveStyle ? { resolveStyle: (style) => measurement.resolveStyle(bare(style)) } : {},
4341
+ ...measurement.outlineBounds ? { outlineBounds: (text2, size, style) => measurement.outlineBounds(text2, size, bare(style)) } : {},
4342
+ ...measurement.forScripts ? { forScripts: (profile) => unpathed(measurement.forScripts(profile)) } : {}
4343
+ };
4344
+ }
4345
+ function resolveSlideContext(presentation, index, options2 = {}) {
4346
+ const deck = rec4(presentation);
4347
+ const slides = Array.isArray(deck.slides) ? deck.slides : [];
4348
+ if (!Number.isInteger(index) || index < 0 || index >= slides.length) throw new RangeError(`Slide index ${String(index)} is outside the presentation's ${slides.length} slides.`);
4349
+ const slide = rec4(slides[index]);
4350
+ const catalogs = { catalogs: checkCatalogsOption(options2.catalogs, "resolveSlideContext") };
4351
+ const records = resolveDesignRecords(presentation, index, catalogs);
4352
+ const diagnostics = [...records.diagnostics];
4353
+ const { theme, colorScheme, fontScheme } = records;
4354
+ const design = { ...rec4(deck.design), ...rec4(slide.design) };
4355
+ let layout;
4356
+ let layoutProvenance;
4357
+ if (typeof slide.layout === "string") {
4358
+ const found = resolveReference(presentation, "layouts", slide.layout, catalogs);
4359
+ if (found) {
4360
+ layout = { ...found.record };
4361
+ layoutProvenance = provenanceOf(found);
4362
+ } else diagnostics.push(unresolvedReference(presentation, "layouts", slide.layout, `slides.${index}.layout`, catalogs));
4363
+ }
4364
+ if (options2.strictReferences && diagnostics.length) throw new OPFUnresolvedReferenceError(diagnostics);
4365
+ const candidate = resolveMessageSurface(presentation, slide, layout, { theme, colorScheme, variables: rec4(deck.variables), themeChosen: records.provenance.theme !== void 0 });
4366
+ const build = (surface) => {
4367
+ const levels = colorLevels(rec4(slide.design), layout, rec4(deck.design), theme, colorScheme, rec4(deck.variables), surface?.variant);
4368
+ const roles2 = resolveColorRoles(colorScheme, colorChoice(levels, colorScheme, rec4(deck.variables)));
4369
+ const layoutVariant2 = levels.length > 3 && layoutVariantApplies(slide.design, layout, deck.design, theme.background, surface) ? levels[1].variant : void 0;
4370
+ const composeOptions2 = {
4371
+ ...resolveCanvasDimensions(design.dimensions ?? theme.dimensions),
4372
+ ...layout ? { layout } : {},
4373
+ presentation,
4374
+ slideIndex: index,
4375
+ slideNumber: options2.slideNumber ?? index + 1,
4376
+ slideCount: options2.slideCount ?? slides.length,
4377
+ fontFamilies: resolveFontFamilies(fontScheme),
4378
+ darkBackground: roles2.dark,
4379
+ ...surface ? { messageSurface: surface, resolveRunColor: (reference) => resolveColorRef(reference, { colorScheme, roles: roles2, variables: rec4(deck.variables), fallback: "" }) || void 0 } : {},
4380
+ // LH-02: the colors the automatic scrim of a picture background is sized for.
4381
+ roles: { text: roles2.text, textSecondary: roles2.textSecondary, primary: roles2.primary, background: roles2.background },
4382
+ ...theme.background !== void 0 ? { themeBackground: theme.background } : {},
4383
+ // OPF 0.19: a theme may carry the shared design keys (between the deck's design and the layout record's).
4384
+ ...theme.design !== void 0 && rec4(theme.design) === theme.design ? { themeDesign: theme.design } : {},
4385
+ ...options2.fonts?.textMeasurement ? { textMeasurement: options2.fonts.textMeasurement } : {},
4386
+ ...options2.date !== void 0 ? { date: options2.date } : {}
4387
+ };
4388
+ return { levels, roles: roles2, layoutVariant: layoutVariant2, composeOptions: composeOptions2 };
4389
+ };
4390
+ const variablesOf = (made) => resolveSlideVariables(slide, { slideNumber: made.composeOptions.slideNumber, slideCount: made.composeOptions.slideCount, presentation, darkBackground: made.composeOptions.darkBackground === true });
4391
+ let messageSurface = candidate, built = build(candidate);
4392
+ if (candidate) {
4393
+ const plain2 = build(void 0);
4394
+ const host = plain2.composeOptions.textMeasurement;
4395
+ const measurement = host ? unpathed(slideScriptMeasurement(presentation, index, host, { ...catalogs, fontFamilies: resolveFontFamilies(fontScheme), serif: fontScheme.type === "serif" })) : host;
4396
+ let displayed = false;
4397
+ try {
4398
+ displayed = messageDisplayed(composeSlide(variablesOf(plain2), { ...plain2.composeOptions, ...measurement ? { textMeasurement: measurement } : {} }), candidate.kind);
4399
+ } catch {
4400
+ displayed = false;
4401
+ }
4402
+ if (displayed && index > 0) {
4403
+ const before = rec4(slides[index - 1]), record2 = typeof before.layout === "string" ? resolveReference(presentation, "layouts", before.layout, catalogs)?.record : void 0;
4404
+ if (drawsAccentByDesign(presentation, before, record2, theme) || resolveSlideContext(presentation, index - 1, { ...options2, slideNumber: void 0 }).resolved.messageSurface !== void 0) displayed = false;
4405
+ }
4406
+ if (!displayed) {
4407
+ messageSurface = void 0;
4408
+ built = plain2;
4409
+ }
4410
+ }
4411
+ const { roles, layoutVariant, composeOptions } = built;
4412
+ const resolvedSlide = variablesOf(built);
4413
+ return { slide: resolvedSlide, options: composeOptions, diagnostics, resolved: { theme, colorScheme, roles, fontScheme, fontSchemePath: records.fontSchemePath, ...layout ? { layout } : {}, ...layoutVariant ? { layoutVariant } : {}, ...messageSurface ? { messageSurface } : {}, provenance: { ...layoutProvenance ? { layout: layoutProvenance } : {}, ...records.provenance } } };
4414
+ }
4415
+
4416
+ // src/rule-slides.ts
4417
+ var measurementFor = (options2, index) => {
4418
+ const measurement = options2.fonts?.textMeasurement;
4419
+ return typeof measurement === "function" ? measurement(index) : measurement;
4420
+ };
4421
+ var lazy = (compute) => {
4422
+ let done = false;
4423
+ let value;
4424
+ return () => {
4425
+ if (!done) {
4426
+ value = compute();
4427
+ done = true;
4428
+ }
4429
+ return value;
4430
+ };
4431
+ };
4432
+ function relax(value) {
4433
+ const copy = JSON.parse(JSON.stringify(value));
4434
+ const walk2 = (node) => {
4435
+ if (Array.isArray(node)) return node.forEach(walk2);
4436
+ if (node && typeof node === "object") {
4437
+ const object3 = node;
4438
+ if (object3.overflow === "error") object3.overflow = "warn";
4439
+ for (const child of Object.values(object3)) walk2(child);
4440
+ }
4441
+ };
4442
+ walk2(copy);
4443
+ return copy;
4444
+ }
4445
+ function buildSlides(document, options2, memo) {
4446
+ const slides = Array.isArray(document.slides) ? document.slides : [];
4447
+ return slides.map((slide, index) => {
4448
+ const path = pointer2("slides", index);
4449
+ const baseContext = lazy(() => resolveSlideContext(document, index, { catalogs: options2.catalogs, date: "2000-01-01" }));
4450
+ const measurement = lazy(() => {
4451
+ const host = measurementFor(options2, index);
4452
+ if (!host) return void 0;
4453
+ const { resolved: resolved3 } = baseContext();
4454
+ return slideScriptMeasurement(document, index, host, { catalogs: options2.catalogs, fontFamilies: resolveFontFamilies(resolved3.fontScheme), serif: resolved3.fontScheme.type === "serif" });
4455
+ });
4456
+ const resolved2 = lazy(() => {
4457
+ const textMeasurement = measurement();
4458
+ const slideContext = baseContext();
4459
+ return textMeasurement ? { ...slideContext, options: { ...slideContext.options, textMeasurement } } : slideContext;
4460
+ });
4461
+ const design = lazy(() => resolveDesign(document, index, resolved2()));
4462
+ const layout = lazy(() => resolved2().options.layout);
4463
+ const compute = () => {
4464
+ const result = { layoutDiagnostics: [] };
4465
+ let fontFamilies;
4466
+ const compose = (input, withLayout) => {
4467
+ const options3 = resolved2().options;
4468
+ fontFamilies ??= options3.fontFamilies && resolveDrawnFontFamilies(options3.fontFamilies, options3.textMeasurement);
4469
+ return composeSlide(input, { ...options3, ...fontFamilies ? { fontFamilies } : {}, layout: withLayout });
4470
+ };
4471
+ try {
4472
+ result.composition = compose(resolved2().slide, layout());
4473
+ result.layoutDiagnostics.push(...result.composition.diagnostics.map((diagnostic) => ({ diagnostic, strict: false })));
4474
+ } catch (error) {
4475
+ if (error instanceof OPFCompositionError) {
4476
+ result.layoutDiagnostics.push(...error.diagnostics.map((diagnostic) => ({ diagnostic, strict: true })));
4477
+ try {
4478
+ const relaxedLayout = layout();
4479
+ result.composition = compose(relax(resolved2().slide), relaxedLayout ? relax(relaxedLayout) : void 0);
4480
+ } catch (second) {
4481
+ result.layoutError = second instanceof Error ? second.message : String(second);
4482
+ }
4483
+ } else result.layoutError = error instanceof Error ? error.message : String(error);
4484
+ }
4485
+ return result;
4486
+ };
4487
+ const composed = lazy(() => memo ? memo(index, compute) : compute());
4488
+ const payloads = lazy(() => slidePayloads(slide, path));
4489
+ const texts = lazy(() => textValues(slide, path));
4490
+ const rtl = lazy(() => {
4491
+ try {
4492
+ return resolveScriptFonts(document, { slideIndex: index }).rtl === true;
4493
+ } catch {
4494
+ return false;
4495
+ }
4496
+ });
4497
+ const context = { index, slide, path, ...typeof slide.id === "string" ? { id: slide.id } : {} };
4498
+ return Object.defineProperties(context, {
4499
+ design: { get: design, enumerable: true },
4500
+ layout: { get: layout, enumerable: true },
4501
+ composition: { get: () => composed().composition, enumerable: true },
4502
+ layoutDiagnostics: { get: () => composed().layoutDiagnostics, enumerable: true },
4503
+ layoutError: { get: () => composed().layoutError, enumerable: true },
4504
+ measurement: { get: measurement, enumerable: true },
4505
+ payloads: { get: payloads, enumerable: true },
4506
+ texts: { get: texts, enumerable: true },
4507
+ rtl: { get: rtl, enumerable: true }
4508
+ });
4509
+ });
4510
+ }
4511
+
4512
+ // src/rules-variable-overflow.ts
4513
+ var plain = (value) => typeof value === "string" ? value : Array.isArray(value) ? value.map((run) => typeof run === "string" ? run : typeof rec(run).text === "string" ? rec(run).text : "").join("") : "";
4514
+ function drawnValue(declaration, values) {
4515
+ if (Object.hasOwn(values, declaration.id) && values[declaration.id] !== null && values[declaration.id] !== void 0) {
4516
+ const coerced = coerceVariableValue(declaration.kind, values[declaration.id]);
4517
+ if (coerced.ok) return coerced.value;
4518
+ }
4519
+ return declaration.value ?? declaration.example;
4520
+ }
4521
+ function composedLines(slide, place) {
4522
+ const composition = slide.composition;
4523
+ if (!composition) return void 0;
4524
+ let best = [];
4525
+ let bestDepth = -1;
4526
+ const offer = (path, lines) => {
4527
+ if (!lines || lines.length === 0) return;
4528
+ const at3 = pointerOfDotted(path);
4529
+ if (at3 !== place && !place.startsWith(`${at3}/`)) return;
4530
+ if (at3.length > bestDepth) {
4531
+ bestDepth = at3.length;
4532
+ best = [];
4533
+ }
4534
+ if (at3.length === bestDepth) best.push([...lines]);
4535
+ };
4536
+ for (const item of composition.items) {
4537
+ const text2 = item.text;
4538
+ if (!text2) continue;
4539
+ if (text2.listEntries) {
4540
+ for (const entry2 of text2.listEntries) {
4541
+ if (entry2.textPath) offer(entry2.textPath, entry2.text.lines);
4542
+ if (entry2.descriptionPath && entry2.description) offer(entry2.descriptionPath, entry2.description.lines);
4543
+ }
4544
+ continue;
4545
+ }
4546
+ offer(item.path, text2.lines);
4547
+ }
4548
+ return best.length ? best.flat() : void 0;
4549
+ }
4550
+ function linesOfValue(lines, value, occurrence) {
4551
+ const squash = (text2) => text2.replace(/\s+/gu, "").toLowerCase();
4552
+ const needle = squash(value);
4553
+ if (!needle) return void 0;
4554
+ const spans = [];
4555
+ let at3 = 0;
4556
+ for (const line2 of lines) {
4557
+ const length = squash(line2).length;
4558
+ spans.push({ start: at3, end: at3 + length });
4559
+ at3 += length;
4560
+ }
4561
+ const hay = lines.map(squash).join("");
4562
+ let start = -1;
4563
+ for (let found = 0, from = 0; found <= occurrence; found++) {
4564
+ start = hay.indexOf(needle, from);
4565
+ if (start < 0) return void 0;
4566
+ from = start + needle.length;
4567
+ }
4568
+ const end = start + needle.length;
4569
+ return spans.filter((span) => span.end > span.start && span.start < end && span.end > start).length;
4570
+ }
4571
+ var slideOf = (path) => {
4572
+ const match2 = /^\/slides\/(\d+)(?:\/|$)/.exec(path);
4573
+ return match2 ? Number(match2[1]) : void 0;
4574
+ };
4575
+ function measuredOf(message) {
4576
+ const found = /has (\d+) (characters|items); its (maxLength|maxItems) is (\d+)/.exec(message);
4577
+ return found ? { [found[2]]: Number(found[1]), [found[3]]: Number(found[4]) } : void 0;
4578
+ }
4579
+ function overflow(context) {
4580
+ const document = context.document;
4581
+ const declared = variableDeclarations(document).filter((entry2) => entry2.maxLength !== void 0 || entry2.maxLines !== void 0 || entry2.maxItems !== void 0);
4582
+ if (!declared.length) return;
4583
+ const values = context.options.values ?? {};
4584
+ const template = context.options.template ?? isTemplate(document);
4585
+ for (const entry2 of resolveVariables(document, values, { template, partial: true }).diagnostics) {
4586
+ if (entry2.code !== "variable-overflow") continue;
4587
+ const measured = measuredOf(entry2.message);
4588
+ context.report(variableOverflowRule, {
4589
+ path: entry2.path,
4590
+ message: entry2.message,
4591
+ help: "Shorten the value, or raise the limit in the declaration if the layout has the room.",
4592
+ ...measured ? { measured } : {}
4593
+ });
4594
+ }
4595
+ const limited = declared.filter((entry2) => entry2.kind === "text" && entry2.maxLines !== void 0);
4596
+ if (!limited.length) return;
4597
+ const uses = /* @__PURE__ */ new Map();
4598
+ for (const info of listVariables(document, values)) if (info.uses.length && info.maxLines !== void 0 && info.kind === "text") uses.set(info.id, info.uses);
4599
+ if (!uses.size) return;
4600
+ const view = instantiateForValidation(document, values, template).presentation;
4601
+ const drawn = buildSlides(view, context.options);
4602
+ const seen = /* @__PURE__ */ new Map();
4603
+ for (const declaration of limited) {
4604
+ const value = drawnValue(declaration, values);
4605
+ if (declaration.maxLines === void 0) continue;
4606
+ for (const use of uses.get(declaration.id) ?? []) {
4607
+ const index = slideOf(use.path);
4608
+ if (index === void 0) continue;
4609
+ const given = Object.hasOwn(values, declaration.id) && values[declaration.id] !== null && values[declaration.id] !== void 0;
4610
+ const picked = given ? void 0 : translationAt(declaration, document, use.path);
4611
+ const drawnHere = picked ? picked.value : value;
4612
+ if (drawnHere === void 0) continue;
4613
+ const text2 = plain(drawnHere);
4614
+ const slide = drawn[index];
4615
+ const source = context.slides[index];
4616
+ if (!slide || !source) continue;
4617
+ const key3 = `${declaration.id}\0${use.path}`;
4618
+ const occurrence = seen.get(key3) ?? 0;
4619
+ seen.set(key3, occurrence + 1);
4620
+ const lines = composedLines(slide, use.path);
4621
+ if (!lines) continue;
4622
+ const taken = linesOfValue(lines, text2, occurrence);
4623
+ if (taken === void 0 || taken <= declaration.maxLines) continue;
4624
+ context.report(variableOverflowRule, {
4625
+ path: use.path,
4626
+ slide: source,
4627
+ message: `'${declaration.id}' takes ${taken} lines here; its maxLines is ${declaration.maxLines}.`,
4628
+ help: "Shorten the value, widen the place it is drawn in, or raise maxLines in the declaration if the slide has the room.",
4629
+ measured: { lines: taken, maxLines: declaration.maxLines }
4630
+ });
4631
+ }
4632
+ }
4633
+ }
4634
+ var variableOverflow = { info: variableOverflowRule, run: overflow };
4635
+ var variableOverflowRules = [variableOverflow];
4636
+
4637
+ // src/validation-rules.ts
4638
+ var ruleImplementations = [...accessibilityRules, ...layoutContentRules, ...languageTagRules, ...layoutFindingRules, ...variableOverflowRules, ...chartFindingRules];
4639
+
4640
+ // src/chart-shape.ts
4641
+ var FOREIGN_CHART_KEYS = ["categories", "series", "labels", "datasets"];
4642
+ var CHART_DEFINITION = "https://openpresentation.org/schema/opf/v1#/$defs/Chart";
4643
+ var isRecord3 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
4644
+ var isCell = (value) => value === null || ["string", "number", "boolean"].includes(typeof value);
4645
+ function foreignChartKeys(chart) {
4646
+ if (!isRecord3(chart) || Object.hasOwn(chart, "data")) return [];
4647
+ return FOREIGN_CHART_KEYS.filter((key3) => Object.hasOwn(chart, key3));
4648
+ }
4649
+ function convertChartData(chart) {
4650
+ const labels = chart.categories ?? chart.labels;
4651
+ const series = chart.series ?? chart.datasets;
4652
+ if (!Array.isArray(labels) || !labels.length || !labels.every(isCell) || !Array.isArray(series) || !series.length) return void 0;
4653
+ const columns = ["Category"];
4654
+ const values = [];
4655
+ for (const [index, entry2] of series.entries()) {
4656
+ if (!isRecord3(entry2)) return void 0;
4657
+ const list = entry2.values ?? entry2.data;
4658
+ const name = entry2.name ?? entry2.label;
4659
+ if (!Array.isArray(list) || list.length !== labels.length || !list.every(isCell)) return void 0;
4660
+ columns.push(typeof name === "string" && name ? name : `Series ${index + 1}`);
4661
+ values.push(list);
4662
+ }
4663
+ if (new Set(columns).size !== columns.length) return void 0;
4664
+ return { columns, rows: labels.map((label, row) => [label, ...values.map((list) => list[row])]) };
4665
+ }
4666
+ function chartShapePatch(chart, path) {
4667
+ if (!isRecord3(chart)) return void 0;
4668
+ const data = convertChartData(chart);
4669
+ const keys = foreignChartKeys(chart);
4670
+ if (!data || !keys.length) return void 0;
4671
+ return [{ op: "add", path: `${path}/data`, value: data }, ...keys.map((key3) => ({ op: "remove", path: `${path}/${key3}` }))];
4672
+ }
4673
+ var SHOWN_ROWS = 3;
4674
+ var json = (value) => JSON.stringify(value);
4675
+ function dataExample(chart) {
4676
+ const data = convertChartData(chart);
4677
+ if (!data) return '"data": { "columns": ["Category", "Series name"], "rows": [["Q1", 3], ["Q2", 8]] }';
4678
+ const rows = data.rows.slice(0, SHOWN_ROWS).map(json);
4679
+ return `"data": { "columns": ${json(data.columns)}, "rows": [${rows.join(",")}${data.rows.length > SHOWN_ROWS ? ",..." : ""}] }`;
4680
+ }
4681
+ function chartShapeHelp(chart) {
4682
+ const keys = foreignChartKeys(chart);
4683
+ if (!keys.length || !isRecord3(chart)) return void 0;
4684
+ const names2 = keys.map((key3) => `"${key3}"`).join(" and ");
4685
+ const example = dataExample(chart);
4686
+ const next = `replace ${names2} with ${example}. The first column holds the category labels and each further column is one series.`;
4687
+ return {
4688
+ message: `The chart has ${names2} (the Chart.js and ECharts shape), but an OPF chart keeps its values in "data": { "columns", "rows" }.`,
4689
+ next,
4690
+ help: `OPF charts use "data": { "columns", "rows" }, not ${names2}. Replace ${names2} with ${example}; the first column holds the category labels and each further column is one series. See the Chart definition: ${CHART_DEFINITION} (opf schema presentation '/$defs/Chart').`
4691
+ };
4692
+ }
4693
+
4694
+ // src/generated/version.ts
4695
+ var OPF_CORE_VERSION = "0.37.1";
4696
+
4697
+ // src/renamed-keys.ts
4698
+ var KEY_RENAMES = Object.freeze([
4699
+ { from: "languageFamily", to: "scriptGroup", note: 'Its values are "latin", "eastAsian" and "complexScript"; "ea" and "cs" are no longer accepted.' },
4700
+ { from: "verticalAlign", to: "anchor" },
4701
+ { from: "organizationId", to: "organization" },
4702
+ { from: "minFontSize", to: "minFontSizePx", note: "The numbers are unchanged: reference pixels." },
4703
+ { from: "maxFontSize", to: "maxFontSizePx", note: "The numbers are unchanged: reference pixels." },
4704
+ { from: "url", to: "link", at: (segments) => segments.at(-3) === "references", note: 'A reference link is an http or https address, a "mailto:" or a "tel:" link.' },
4705
+ { from: "tone", to: "appearance", at: (segments) => segments.at(-2) === "background" },
4706
+ { from: "line", to: "lineSeries", at: (segments) => segments.at(-2) === "chart" }
4707
+ ]);
4708
+ function renamedKeyAt(segments) {
4709
+ const name = segments.at(-1);
4710
+ return name === void 0 ? void 0 : KEY_RENAMES.find((entry2) => entry2.from === name && (entry2.at === void 0 || entry2.at(segments)));
4711
+ }
4712
+ var AUTHORED_KEYS = /* @__PURE__ */ new Set(["extensions", "datasets"]);
4713
+ var RENAMED_SCRIPT_GROUP_VALUES = Object.freeze({ ea: "eastAsian", cs: "complexScript" });
4714
+ function renamedScriptGroupValue(value) {
4715
+ return typeof value === "string" && Object.hasOwn(RENAMED_SCRIPT_GROUP_VALUES, value) ? RENAMED_SCRIPT_GROUP_VALUES[value] : void 0;
4716
+ }
4717
+ var renamedKeyMessage = (entry2, bothPresent) => `"${entry2.from}" was renamed "${entry2.to}" in OPF 0.37${bothPresent ? `, and this object has both: remove one` : ""}.`;
4718
+ var renamedValueMessage = (from, to) => `"${from}" is written "${to}" since OPF 0.37.`;
4719
+ var LOOKS_LIKE_HOST_AND_PATH = /^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)+(:\d+)?([/?#]\S*)?$/;
4720
+ function renameRecordKeys(value, segments = []) {
4721
+ if (Array.isArray(value)) {
4722
+ let changed2 = false;
4723
+ const next = value.map((entry2, index) => {
4724
+ const rewritten = renameRecordKeys(entry2, [...segments, String(index)]);
4725
+ if (rewritten !== entry2) changed2 = true;
4726
+ return rewritten;
4727
+ });
4728
+ return changed2 ? next : value;
4729
+ }
4730
+ if (!isRecord2(value)) return value;
4731
+ let changed = false;
4732
+ const entries = [];
4733
+ for (const [key3, child] of Object.entries(value)) {
4734
+ const path = [...segments, key3];
4735
+ const rename = renamedKeyAt(path);
4736
+ const name = rename && !Object.hasOwn(value, rename.to) ? rename.to : key3;
4737
+ let rewritten = AUTHORED_KEYS.has(key3) ? child : renameRecordKeys(child, path);
4738
+ if (name === "scriptGroup") {
4739
+ const long = renamedScriptGroupValue(rewritten);
4740
+ if (long !== void 0) rewritten = long;
4741
+ }
4742
+ if (name !== key3 || rewritten !== child) changed = true;
4743
+ entries.push([name, rewritten]);
4744
+ }
4745
+ return changed ? Object.fromEntries(entries) : value;
4746
+ }
4747
+
4748
+ // src/check-document.ts
4749
+ var own = (value, key3) => Object.hasOwn(value, key3);
4750
+ var object2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
4751
+ var primitive = (value) => value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value);
4752
+ var pointer4 = (parts2) => parts2.length ? "/" + parts2.map((part2) => String(part2).replaceAll("~", "~0").replaceAll("/", "~1")).join("/") : "";
4753
+ function parts(path) {
4754
+ if (path === "") return [];
4755
+ if (!path.startsWith("/") || /~(?![01])/.test(path))
4756
+ throw new TypeError(`Invalid contract JSON Pointer: ${path}`);
4757
+ return path.slice(1).split("/").map((part2) => part2.replaceAll("~1", "/").replaceAll("~0", "~"));
4758
+ }
4759
+ function at2(value, path) {
4760
+ return parts(path).reduce(
4761
+ (current, key3) => object2(current) || Array.isArray(current) ? own(current, key3) ? current[key3] : void 0 : void 0,
4762
+ value
4763
+ );
4764
+ }
4765
+ function checkDocumentOptions(options2) {
4766
+ checkCatalogsOption(options2.catalogs, "validate");
4767
+ if (options2.contracts !== void 0 && !Array.isArray(options2.contracts))
4768
+ throw new TypeError("Validate contracts must be an array.");
4769
+ for (const contract2 of options2.contracts ?? []) {
4770
+ if (!object2(contract2) || Object.keys(contract2).some(
4771
+ (key3) => ![
4772
+ "path",
4773
+ "allowedValues",
4774
+ "severity",
4775
+ "message",
4776
+ "documentation"
4777
+ ].includes(key3)
4778
+ ) || typeof contract2.path !== "string" || !Array.isArray(contract2.allowedValues) || !contract2.allowedValues.every(primitive) || contract2.severity !== void 0 && (typeof contract2.severity !== "string" || !["error", "warning", "info"].includes(contract2.severity)) || contract2.message !== void 0 && typeof contract2.message !== "string" || contract2.documentation !== void 0 && typeof contract2.documentation !== "string")
4779
+ throw new TypeError(
4780
+ "Invalid contract: provide a path and primitive allowedValues, with optional severity, message and documentation."
4781
+ );
4782
+ parts(contract2.path);
4783
+ }
4784
+ }
4785
+ function finding(ruleId, data) {
4786
+ const info = ruleInfo(ruleId);
4787
+ const { severity, scope, ...rest } = data;
4788
+ return { ruleId, severity: severity ?? info.severity, category: info.category, scope: scope ?? "document", ...rest };
4789
+ }
4790
+ var issueRuleId = (issue2) => typeof issue2.params.code === "string" && issue2.keyword === "opf" ? `opf/${issue2.params.code}` : "opf/schema";
4791
+ function issueFinding(issue2, ruleId = issueRuleId(issue2), schemaName = "presentation", prefix = "", scope = "document", severity) {
4792
+ const path = prefix + (issue2.path === "/" ? "" : issue2.path) + (issue2.keyword === "additionalProperties" && typeof issue2.params.additionalProperty === "string" ? pointer4([issue2.params.additionalProperty]) : ""), entry2 = schemaEntries.find((entry3) => entry3.name === schemaName);
4793
+ if (!entry2) throw new TypeError(`Unknown schema ${schemaName}`);
4156
4794
  const precise = validationDefinition(issue2);
4157
4795
  const definition = precise?.uri ?? (issue2.keyword === "opf" ? "packages/javascript/src/schema-check.ts" : issue2.schemaPath.startsWith("#") ? entry2.schema.$id + issue2.schemaPath : issue2.schemaPath);
4158
4796
  const lookup = [
@@ -4163,7 +4801,7 @@ function issueFinding(issue2, ruleId = issueRuleId(issue2), schemaName = "presen
4163
4801
  ];
4164
4802
  let help = "Inspect this schema constraint and preserve unrelated content. Errors inside oneOf/anyOf branches may describe alternatives; retain the intended form.";
4165
4803
  if (issue2.keyword === "required" && issue2.params.missingProperty === "id" && /^\/(organization|speaker)(\/\d+)?$/.test(issue2.path))
4166
- help = `Add an "id" next to "name": organizations and speakers are found by id (speaker.organizationId, {{organization.<id>.name}}, the editor and the PPTX round trip), for example "id": "acme" (letters, digits, "-" and "_", unique in the deck).`;
4804
+ help = `Add an "id" next to "name": organizations and speakers are found by id (speaker.organization, {{organization.<id>.name}}, the editor and the PPTX round trip), for example "id": "acme" (letters, digits, "-" and "_", unique in the deck).`;
4167
4805
  else if (issue2.keyword === "required")
4168
4806
  help = `Add the required ${JSON.stringify(issue2.params.missingProperty)} field in this object, using the intended schema form.`;
4169
4807
  else if (issue2.keyword === "additionalProperties")
@@ -4184,6 +4822,8 @@ function issueFinding(issue2, ruleId = issueRuleId(issue2), schemaName = "presen
4184
4822
  help = `Write ${JSON.stringify(nearest2[0].value)} instead; ${JSON.stringify(typedName)} is not a field of this object.`;
4185
4823
  else if (typedName !== void 0 && typeof nearest2[0]?.value === "string")
4186
4824
  help = `Did you mean ${JSON.stringify(nearest2[0].value)}? ${JSON.stringify(typedName)} is not a field of this object. To keep custom metadata, put it in extensions; do not delete authored content to clear this error.`;
4825
+ const unknownKey = typedName !== void 0 && nearest2.length === 0 && renamedKeyAt(splitPointer(path)) === void 0;
4826
+ if (unknownKey) help = `${help} This validator is OPF ${OPF_CORE_VERSION}; a later OPF release may define ${JSON.stringify(typedName)}.`;
4187
4827
  return finding(ruleId, {
4188
4828
  ...severity ? { severity } : {},
4189
4829
  path,
@@ -4192,7 +4832,7 @@ function issueFinding(issue2, ruleId = issueRuleId(issue2), schemaName = "presen
4192
4832
  help,
4193
4833
  definition,
4194
4834
  lookup,
4195
- validation: issue2,
4835
+ validation: unknownKey ? { ...issue2, params: { ...issue2.params, validatorVersion: OPF_CORE_VERSION } } : issue2,
4196
4836
  ...allowed.length ? {
4197
4837
  suggestions: allowed.map((value) => ({
4198
4838
  value,
@@ -4244,7 +4884,7 @@ function resolve(cursor, seen = /* @__PURE__ */ new Set()) {
4244
4884
  seen.add(id);
4245
4885
  const [base, fragment = ""] = ref.split("#"), root = base ? schemaEntries.find((entry2) => entry2.schema.$id === base)?.schema : cursor.root;
4246
4886
  if (!root) return { ...cursor, schema: {} };
4247
- const target = at(root, fragment);
4887
+ const target = at2(root, fragment);
4248
4888
  if (!object2(target)) return { ...cursor, schema: {} };
4249
4889
  const resolved2 = resolve(
4250
4890
  { schema: target, root, path: fragment },
@@ -4378,16 +5018,16 @@ function embeddedRecordFindings(document, options2, findings) {
4378
5018
  if (!object2(document) || !object2(document.catalogs)) return invalid;
4379
5019
  for (const [group, value] of Object.entries(document.catalogs)) {
4380
5020
  if (!object2(value)) continue;
4381
- for (const [id, record] of Object.entries(object2(value.iconSets) ? value.iconSets : {})) {
4382
- if (object2(record) && (Object.hasOwn(record, "$schema") || Object.hasOwn(record, "id"))) continue;
4383
- const validation = validateAgainstSchema(object2(record) ? { $schema: schemas.iconSet.$id, id, ...record } : record, "iconSets");
5021
+ for (const [id, record2] of Object.entries(object2(value.iconSets) ? value.iconSets : {})) {
5022
+ if (object2(record2) && (Object.hasOwn(record2, "$schema") || Object.hasOwn(record2, "id"))) continue;
5023
+ const validation = validateAgainstSchema(object2(record2) ? { $schema: schemas.iconSet.$id, id, ...record2 } : record2, "iconSets");
4384
5024
  for (const issue2 of validation.errors) findings.push(issueFinding(issue2, "opf/catalog-record", "iconSet", pointer4(["catalogs", group, "iconSets", id]), "document"));
4385
5025
  }
4386
5026
  for (const kind of catalogKinds)
4387
- for (const [id, record] of Object.entries(object2(value[kind]) ? value[kind] : {})) {
5027
+ for (const [id, record2] of Object.entries(object2(value[kind]) ? value[kind] : {})) {
4388
5028
  const path = pointer4(["catalogs", group, kind, id]);
4389
- if (object2(record) && (Object.hasOwn(record, "$schema") || Object.hasOwn(record, "id"))) continue;
4390
- const validation = recordIssues(kind, id, record);
5029
+ if (object2(record2) && (Object.hasOwn(record2, "$schema") || Object.hasOwn(record2, "id"))) continue;
5030
+ const validation = recordIssues(kind, id, record2);
4391
5031
  for (const issue2 of validation.errors) findings.push(issueFinding(issue2, recordRuleId(issue2), catalogSchemaNames[kind], path, "document"));
4392
5032
  if (!validation.valid) invalid.add(recordKey(group, kind, id));
4393
5033
  if (group === "custom") continue;
@@ -4441,9 +5081,23 @@ function chartNumberFixPaths(document) {
4441
5081
  }
4442
5082
  var HELP = {
4443
5083
  "chart-value-not-numeric": 'Write chart values as numbers (or strict decimal strings such as "12.5" or "1e6"); put currency, percent and units in the column format ({ "name": "Revenue", "format": "$#,##0" }). The value is plotted as a gap.',
5084
+ "data-cell-type": "Write the cell as the column declares (a number as a number, text as text, a date as a time label, a boolean as true or false), or change the column's `type` to what it holds. A mismatched cell is still read as it was before; nothing is drawn differently.",
5085
+ "metric-data-stale": "Write the computed number as the metric's value or delta (apply the fix), or change the data link so it computes what the slide says. Readers that do not compute draw the written number.",
5086
+ "metric-data-aggregate": "Use an aggregate that fits the column (first, last or count work on any column), or link a column typed number.",
5087
+ "metric-data-empty": "Check the filter and the field: no row meets the filter, or none of the cells is usable for the aggregate. The written value is shown until the link computes a number.",
5088
+ "metric-data-delta": 'Give the change something to compare with: two rows for "previous", a baseline filter that meets a row, a comparison value other than 0 for a percent, or write the change in a column and use `field`. No change is shown until then.',
5089
+ "metric-unit-repeated": "Drop the unit, or take the unit's text out of the number format: the unit is printed after the value, and the format already prints it.",
5090
+ "datasource-credentials": "Remove the user, password, key or token from the data source and keep the secret in your own store; name the connection in `connector` or `extensions`. A data source never holds credentials.",
5091
+ "dataset-stale": "Take the data from its data source again and update `retrieved`, or change the data source's `refreshEvery` to how often the data really needs taking.",
4444
5092
  "chart-mapping-adapted": "Choose a compatible chart type or mapping for the selected data. The message explains how the mapping or drawing was adapted.",
5093
+ "chart-bands-order": "Write the bands in increasing order of their to values. Every engine draws them sorted.",
5094
+ "chart-bands-unsupported": "Use a bar, column, line, area or bullet chart for bands, or remove the bands.",
5095
+ "metric-gauge-range": "Write the gauge's max above its min, and keep the value, the target and each band's to between them. A value outside the range still prints its real number; its arc stops at the end.",
5096
+ "metric-gauge-value": "Give the metric a number value (a number, or a data link that computes one), or remove the gauge.",
4445
5097
  "chart-series-dropped": "The chart type plots one series. Use a chart type that plots every series (column, bar, line), or one chart per series.",
4446
5098
  "chart-highlight-adapted": "The highlight is adapted by every engine. Name a series or category the chart type can emphasize, or remove the entry.",
5099
+ "table-color-scale-no-data": "Name columns that hold numbers, or remove the color scale. A cell is shaded only when its value is a finite number.",
5100
+ "table-color-scale-range": "Pin min below max, and keep center between them, or leave the range to the data.",
4447
5101
  "slide-theme-dimensions": "A PPTX has one slide size. Set design.dimensions on the deck, or give every slide the same theme dimensions.",
4448
5102
  "code-highlight-out-of-range": "Marked lines count from 1 by line break in code.source. The entry marks nothing past the last line; change it to a line the code has, or remove it.",
4449
5103
  "code-highlight-range-reversed": "Write the range with the smaller line number first, or remove it. A reversed range marks nothing.",
@@ -4451,6 +5105,8 @@ var HELP = {
4451
5105
  "variable-unknown": "Declare the variable in the top-level variables map, or write '\\{{' for literal braces.",
4452
5106
  "variable-unknown-value": "Remove the supplied value, or declare the variable it belongs to.",
4453
5107
  "variable-unused": "Reference the variable as {{id}} or var:id where it belongs, or remove its declaration.",
5108
+ "variable-translation-duplicate": "Remove one of the two keys: the language tag compares without regard to case, and the first in the document is the one drawn.",
5109
+ "variable-translation-unused": "Declare the language ('language' on the deck or a slide) that selects the translation, fix its tag, or remove it.",
4454
5110
  "variable-group-omitted": "Give one of the variables a value to draw the group, make one of them required, or move the content that should always show out of the group.",
4455
5111
  "variable-reference-unknown": "Declare the variable in the top-level variables map, or use another color.",
4456
5112
  "run-color-unrecognized": "Use a #RRGGBB hex color, a color-scheme name or a var: reference to a declared color variable.",
@@ -4463,7 +5119,7 @@ function semanticHelp(issue2) {
4463
5119
  if (params2.code === "shape-option-unsupported-payload" && field === "alt" && params2.type === "image") return `A picture's alt text goes inside its image object: { "image": { "src": "...", "alt": "..." } }.`;
4464
5120
  if (params2.code === "shape-option-unsupported-payload" && field) return `Remove ${quoted3}, or draw this as a shape: a shape block ({ "shape": ... } with no "image") or an overlay shape in the slide's "shapes".`;
4465
5121
  if (params2.code === "number-format-invalid") return 'Write a pattern with a numeric part, such as "0%", "0.0", "#,##0" or "$#,##0.00", optionally followed by a negative and a zero section after ";" ("+0%;-0%", "0;(0);0"; at most three, each with a numeric part). A negative section prints no minus of its own. There is no text section, color or condition.';
4466
- if (params2.code === "caption-unsupported-payload") return "Put the caption on the image, chart, table, video or diagram it describes, or write it as a text block of its own.";
5122
+ if (params2.code === "caption-unsupported-payload") return "Put the caption on the image, chart, table, video, embed or diagram it describes, or write it as a text block of its own.";
4467
5123
  if (Array.isArray(params2.incompatible) && params2.incompatible.includes("bullets") && params2.type === "list") return 'For a list, write the entries under "items". To keep "bullets" (talking points, which belong to a text payload), remove "type" or write "type": "text".';
4468
5124
  return "Resolve the reported structural conflict while preserving every content field. Preview the result after editing.";
4469
5125
  }
@@ -4472,27 +5128,27 @@ var BACKGROUND_HELP = `A background is a string (a theme slot such as "light1",
4472
5128
  function collapseAuthoringShapes(document, findings) {
4473
5129
  const valueAt = (path) => {
4474
5130
  let node = document;
4475
- for (const segment of splitPointer(path)) node = Array.isArray(node) ? node[Number(segment)] : isRecord(node) ? node[segment] : void 0;
5131
+ for (const segment2 of splitPointer(path)) node = Array.isArray(node) ? node[Number(segment2)] : isRecord(node) ? node[segment2] : void 0;
4476
5132
  return node;
4477
5133
  };
4478
5134
  const schema = (entry2) => entry2?.ruleId === "opf/schema";
4479
5135
  const fills = /* @__PURE__ */ new Map();
4480
5136
  for (const entry2 of findings) {
4481
5137
  if (!schema(entry2)) continue;
4482
- const at2 = /^(.*\/fill)(?:\/[^/]+)?$/.exec(entry2.path)?.[1];
4483
- if (!at2 || fills.has(at2) || at2.endsWith("/style/fill")) continue;
4484
- const fill = valueAt(at2);
5138
+ const at3 = /^(.*\/fill)(?:\/[^/]+)?$/.exec(entry2.path)?.[1];
5139
+ if (!at3 || fills.has(at3) || at3.endsWith("/style/fill")) continue;
5140
+ const fill = valueAt(at3);
4485
5141
  if (!isRecord(fill) || Object.hasOwn(fill, "lighten") || Object.hasOwn(fill, "darken")) continue;
4486
5142
  const solid = (fill.type === "solid" || fill.type === void 0) && fill.color !== void 0 && !Object.hasOwn(fill, "gradient") && !Object.hasOwn(fill, "pattern");
4487
5143
  const typed = fill.type === "gradient" && isRecord(fill.gradient) || fill.type === "pattern" && isRecord(fill.pattern);
4488
5144
  if (!solid && !typed) continue;
4489
5145
  const color = typeof fill.color === "string" ? JSON.stringify(fill.color) : '"accent1"';
4490
- fills.set(at2, {
5146
+ fills.set(at3, {
4491
5147
  ...entry2,
4492
- path: at2,
5148
+ path: at3,
4493
5149
  message: solid ? `A shape's solid fill is the color itself, not an object: write "fill": ${color}.` : `A shape's fill has no "type": write "fill": { ${JSON.stringify(fill.type)}: { ... } }.`,
4494
5150
  help: solid ? `Write "fill": ${color}. A fill is "none", a color ("accent1", "#1E40AF", or { "color": "accent1", "lighten": 0.4 }), { "gradient": { ... } } or { "pattern": { ... } }; only a slide background takes { "type": "solid", ... }.` : `Remove "type": a fill is told apart by its key, { "gradient": { ... } } or { "pattern": { ... } }; only a slide background takes "type".`,
4495
- fixes: [solid && typeof fill.color === "string" ? { id: "fill-color", title: `Write the fill as ${color}`, kind: "patch", safe: false, patch: [{ op: "replace", path: at2, value: fill.color }] } : { id: "fill-remove-type", title: 'Remove "type"', kind: "patch", safe: false, patch: [{ op: "remove", path: `${at2}/type` }] }]
5151
+ fixes: [solid && typeof fill.color === "string" ? { id: "fill-color", title: `Write the fill as ${color}`, kind: "patch", safe: false, patch: [{ op: "replace", path: at3, value: fill.color }] } : { id: "fill-remove-type", title: 'Remove "type"', kind: "patch", safe: false, patch: [{ op: "remove", path: `${at3}/type` }] }]
4496
5152
  });
4497
5153
  }
4498
5154
  if (fills.size) {
@@ -4500,38 +5156,38 @@ function collapseAuthoringShapes(document, findings) {
4500
5156
  for (let index = 0; index < findings.length; index++) {
4501
5157
  const entry2 = findings[index];
4502
5158
  if (!schema(entry2)) continue;
4503
- const at2 = [...fills.keys()].find((path) => entry2.path === path || entry2.path.startsWith(`${path}/`));
4504
- if (!at2) continue;
4505
- if (seen.has(at2)) {
5159
+ const at3 = [...fills.keys()].find((path) => entry2.path === path || entry2.path.startsWith(`${path}/`));
5160
+ if (!at3) continue;
5161
+ if (seen.has(at3)) {
4506
5162
  findings.splice(index--, 1);
4507
5163
  continue;
4508
5164
  }
4509
- seen.add(at2);
4510
- findings[index] = fills.get(at2);
5165
+ seen.add(at3);
5166
+ findings[index] = fills.get(at3);
4511
5167
  }
4512
5168
  }
4513
5169
  const backgrounds = /* @__PURE__ */ new Set();
4514
5170
  for (const entry2 of findings) {
4515
5171
  if (!schema(entry2)) continue;
4516
- const at2 = /^((?:.*\/)?design\/background)(?:\/.*)?$/.exec(entry2.path)?.[1];
4517
- if (!at2 || backgrounds.has(at2)) continue;
4518
- const background = valueAt(at2), type = isRecord(background) ? background.type : void 0;
5172
+ const at3 = /^((?:.*\/)?design\/background)(?:\/.*)?$/.exec(entry2.path)?.[1];
5173
+ if (!at3 || backgrounds.has(at3)) continue;
5174
+ const background = valueAt(at3), type = isRecord(background) ? background.type : void 0;
4519
5175
  if (typeof background === "string" || isRecord(background) && typeof type === "string" && BACKGROUND_TYPES.includes(type)) continue;
4520
- backgrounds.add(at2);
5176
+ backgrounds.add(at3);
4521
5177
  }
4522
- for (const at2 of backgrounds) {
4523
- const background = valueAt(at2), type = isRecord(background) ? background.type : void 0;
4524
- const first = findings.findIndex((entry2) => schema(entry2) && (entry2.path === at2 || entry2.path.startsWith(`${at2}/`)));
5178
+ for (const at3 of backgrounds) {
5179
+ const background = valueAt(at3), type = isRecord(background) ? background.type : void 0;
5180
+ const first = findings.findIndex((entry2) => schema(entry2) && (entry2.path === at3 || entry2.path.startsWith(`${at3}/`)));
4525
5181
  const { fixes: _fixes, suggestions: _suggestions, ...kept } = findings[first];
4526
5182
  const one = {
4527
5183
  ...kept,
4528
- path: at2,
5184
+ path: at3,
4529
5185
  message: isRecord(background) ? type === void 0 ? 'A background object needs a "type".' : `${JSON.stringify(type)} is not a background type.` : "This is not a background OPF can read.",
4530
5186
  help: BACKGROUND_HELP
4531
5187
  };
4532
5188
  for (let index = findings.length - 1; index >= 0; index--) {
4533
5189
  const entry2 = findings[index];
4534
- if (schema(entry2) && (entry2.path === at2 || entry2.path.startsWith(`${at2}/`))) findings.splice(index, 1);
5190
+ if (schema(entry2) && (entry2.path === at3 || entry2.path.startsWith(`${at3}/`))) findings.splice(index, 1);
4535
5191
  }
4536
5192
  findings.splice(first, 0, one);
4537
5193
  }
@@ -4544,8 +5200,8 @@ function collapseAuthoringShapes(document, findings) {
4544
5200
  for (const [index, entry2] of findings.entries()) {
4545
5201
  if (!schema(entry2) || entry2.validation?.keyword !== "maximum") continue;
4546
5202
  const match2 = /^(\/slides\/\d+\/shapes\/\d+\/at)\/(width|height)$/.exec(entry2.path);
4547
- const at2 = match2?.[1] ? valueAt(match2[1]) : void 0, key3 = match2?.[2], size = key3 && isRecord(at2) ? at2[key3] : void 0;
4548
- if (!key3 || !isRecord(at2) || typeof size !== "number" || !(size > 8 && size <= 1280) || Object.hasOwn(at2, `${key3}Px`)) continue;
5203
+ const at3 = match2?.[1] ? valueAt(match2[1]) : void 0, key3 = match2?.[2], size = key3 && isRecord(at3) ? at3[key3] : void 0;
5204
+ if (!key3 || !isRecord(at3) || typeof size !== "number" || !(size > 8 && size <= 1280) || Object.hasOwn(at3, `${key3}Px`)) continue;
4549
5205
  const px = `${key3}Px`;
4550
5206
  findings[index] = {
4551
5207
  ...entry2,
@@ -4561,7 +5217,7 @@ function collapseAuthoringShapes(document, findings) {
4561
5217
  if (isRecord(payload) && payload.type === "list" && Object.hasOwn(payload, "bullets")) findings.splice(index, 1);
4562
5218
  }
4563
5219
  const OPTION_RULES = ["opf/image-option-unsupported-payload", "opf/shape-option-unsupported-payload", "opf/caption-unsupported-payload"];
4564
- const optionDefinition = (entry2) => entry2.validation?.keyword === "required" && /^must have required property '(?:image|shape|path|chart|table|video|diagram)'/.test(entry2.message) || entry2.validation?.keyword === "not" && entry2.message === "must NOT be valid" || (entry2.validation?.keyword === "anyOf" || entry2.validation?.keyword === "oneOf") && /must match a schema in anyOf|must match exactly one schema/.test(entry2.message);
5220
+ const optionDefinition = (entry2) => entry2.validation?.keyword === "required" && /^must have required property '(?:image|shape|path|chart|table|video|embed|diagram)'/.test(entry2.message) || entry2.validation?.keyword === "not" && entry2.message === "must NOT be valid" || (entry2.validation?.keyword === "anyOf" || entry2.validation?.keyword === "oneOf") && /must match a schema in anyOf|must match exactly one schema/.test(entry2.message);
4565
5221
  for (let index = findings.length - 1; index >= 0; index--) {
4566
5222
  const entry2 = findings[index];
4567
5223
  if (!schema(entry2) || !optionDefinition(entry2)) continue;
@@ -4575,8 +5231,8 @@ function collapseAuthoringShapes(document, findings) {
4575
5231
  const value = valueAt(entry2.path);
4576
5232
  if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || Array.isArray(value)) payloadSlots.set(entry2.path, value);
4577
5233
  }
4578
- for (const [at2, value] of payloadSlots) {
4579
- const first = findings.findIndex((entry2) => schema(entry2) && entry2.path === at2);
5234
+ for (const [at3, value] of payloadSlots) {
5235
+ const first = findings.findIndex((entry2) => schema(entry2) && entry2.path === at3);
4580
5236
  const text2 = typeof value === "string";
4581
5237
  const write = text2 ? `{ "text": ${JSON.stringify(value)} }` : Array.isArray(value) ? '{ "items": [ ... ] } for a list, or { "blocks": [ ... ] } for several blocks' : '{ "text": "..." }';
4582
5238
  const { fixes: _fixes, suggestions: _suggestions, ...kept } = findings[first];
@@ -4584,11 +5240,11 @@ function collapseAuthoringShapes(document, findings) {
4584
5240
  ...kept,
4585
5241
  message: `A block holds a content payload (an object), not ${text2 ? "a bare string" : Array.isArray(value) ? "a list" : "a " + typeof value}.`,
4586
5242
  help: `Write ${write}. A payload names its kind by its key: "text", "items" (a list), "image", "chart", "table", or "blocks" to stack several; see docs/dynamic-composition.md.`,
4587
- ...text2 ? { fixes: [{ id: "wrap-text", title: 'Write the string as { "text": ... }', kind: "patch", safe: false, patch: [{ op: "replace", path: at2, value: { text: value } }] }] } : {}
5243
+ ...text2 ? { fixes: [{ id: "wrap-text", title: 'Write the string as { "text": ... }', kind: "patch", safe: false, patch: [{ op: "replace", path: at3, value: { text: value } }] }] } : {}
4588
5244
  };
4589
5245
  for (let index = findings.length - 1; index >= 0; index--) {
4590
5246
  const entry2 = findings[index];
4591
- if (schema(entry2) && entry2.path === at2) findings.splice(index, 1);
5247
+ if (schema(entry2) && entry2.path === at3) findings.splice(index, 1);
4592
5248
  }
4593
5249
  findings.splice(first, 0, one);
4594
5250
  }
@@ -4596,7 +5252,7 @@ function collapseAuthoringShapes(document, findings) {
4596
5252
  function collapseChartShape(document, findings) {
4597
5253
  const chartAt = (path) => {
4598
5254
  let node = document;
4599
- for (const segment of splitPointer(path)) node = Array.isArray(node) ? node[Number(segment)] : isRecord(node) ? node[segment] : void 0;
5255
+ for (const segment2 of splitPointer(path)) node = Array.isArray(node) ? node[Number(segment2)] : isRecord(node) ? node[segment2] : void 0;
4600
5256
  return node;
4601
5257
  };
4602
5258
  const collapsed = /* @__PURE__ */ new Set();
@@ -4618,8 +5274,8 @@ function collapseChartShape(document, findings) {
4618
5274
  for (let index = findings.length - 1; index >= 0; index--) {
4619
5275
  const entry2 = findings[index];
4620
5276
  if (entry2?.ruleId !== "opf/schema" || entry2.validation?.keyword !== "additionalProperties") continue;
4621
- const at2 = entry2.path.lastIndexOf("/");
4622
- if (collapsed.has(entry2.path.slice(0, at2)) && FOREIGN_CHART_KEYS.includes(entry2.path.slice(at2 + 1))) findings.splice(index, 1);
5277
+ const at3 = entry2.path.lastIndexOf("/");
5278
+ if (collapsed.has(entry2.path.slice(0, at3)) && FOREIGN_CHART_KEYS.includes(entry2.path.slice(at3 + 1))) findings.splice(index, 1);
4623
5279
  }
4624
5280
  }
4625
5281
  function engineFindings(document, engine, enabled) {
@@ -4652,6 +5308,12 @@ function engineFindings(document, engine, enabled) {
4652
5308
  const found = issueFinding(issue2, ruleId, "presentation", "", "document", code2 === "variable-group-omitted" ? "info" : "warning");
4653
5309
  const help = HELP[code2];
4654
5310
  if (help) found.help = help;
5311
+ if (code2 === "data-cell-type") {
5312
+ const fix = suggestCellTypeFix(document, issue2.path, issue2.params.aggregate === true);
5313
+ if (fix) found.fixes = [{ id: "store-cell-type", title: fix.title, kind: "patch", safe: true, patch: fix.patches }];
5314
+ }
5315
+ const metricFix = issue2.params.fix;
5316
+ if (code2 === "metric-data-stale" && metricFix) found.fixes = [{ id: "update-metric-data", title: metricFix.title, kind: "patch", safe: true, patch: metricFix.patch }];
4655
5317
  if (code2 === "shape-anchor-size-unit") {
4656
5318
  const key3 = String(issue2.params.key), px = `${key3}Px`;
4657
5319
  found.help = `Did you mean "${px}"? "${key3}" is a fraction of the block.`;
@@ -4768,14 +5430,23 @@ function contentReferenceFindings(document, options2, findings) {
4768
5430
  const stale = embeddedInvalid && site.kind === "layouts" ? staleLayoutCopy(document, embeddedInvalid.group, embeddedInvalid.id, options2) : void 0;
4769
5431
  const diagnostic = unresolvedReference(document, site.kind, site.reference, path, options2);
4770
5432
  if (removedLayoutAuto(site.kind, site.reference)) {
5433
+ const dropRecord = embeddedInvalid !== void 0 && embeddedInvalid.id === "auto" && lastLayoutAutoSite(document, embeddedInvalid.group, options2, site.path);
4771
5434
  findings.push(
4772
5435
  finding("opf/unresolved-reference", {
4773
5436
  path,
4774
5437
  message: diagnostic.message,
4775
- help: 'OPF 0.35 removed layout "auto". Delete the layout key: a slide without one is composed automatically, which is what "auto" did.',
5438
+ help: `OPF 0.35 removed layout "auto". Delete the layout key: a slide without one is composed automatically, which is what "auto" did.${dropRecord ? ` The fix also removes the embedded layout "auto" in catalogs.${embeddedInvalid.group}, which fails the layout schema and which no slide names after it.` : ""}`,
4776
5439
  definition: `${schemas.presentation.$id}#/$defs/Slide`,
4777
5440
  lookup: ["opf", "catalog", site.kind],
4778
- fixes: [{ id: "remove-layout-auto", title: "Delete layout (automatic composition)", kind: "patch", safe: true, patch: [{ op: "remove", path }] }]
5441
+ fixes: [
5442
+ {
5443
+ id: "remove-layout-auto",
5444
+ title: dropRecord ? 'Delete layout (automatic composition) and the embedded layout record "auto"' : "Delete layout (automatic composition)",
5445
+ kind: "patch",
5446
+ safe: true,
5447
+ patch: [{ op: "remove", path }, ...dropRecord ? [{ op: "remove", path: pointer4(["catalogs", embeddedInvalid.group, "layouts", "auto"]) }] : []]
5448
+ }
5449
+ ]
4779
5450
  })
4780
5451
  );
4781
5452
  continue;
@@ -4803,14 +5474,14 @@ function contentReferenceFindings(document, options2, findings) {
4803
5474
  continue;
4804
5475
  }
4805
5476
  if (embeddedInvalid) {
4806
- const at2 = pointer4(["catalogs", embeddedInvalid.group, site.kind, embeddedInvalid.id]);
5477
+ const at3 = pointer4(["catalogs", embeddedInvalid.group, site.kind, embeddedInvalid.id]);
4807
5478
  const fix = stale ? staleCopyFix(document, stale, options2) : void 0;
4808
5479
  const noun = KIND_SINGULAR[site.kind];
4809
5480
  findings.push(
4810
5481
  finding("opf/unresolved-reference", {
4811
5482
  path,
4812
- message: `${noun[0].toUpperCase()}${noun.slice(1)} '${site.reference}' is embedded in catalogs.${embeddedInvalid.group}, but the record fails the ${noun} schema: see the opf/catalog-record findings at ${at2}.`,
4813
- help: stale ? staleCopyCause(stale) : `Fix the record with the fixes of its findings at ${at2}, then validate again.`,
5483
+ message: `${noun[0].toUpperCase()}${noun.slice(1)} '${site.reference}' is embedded in catalogs.${embeddedInvalid.group}, but the record fails the ${noun} schema: see the opf/catalog-record findings at ${at3}.`,
5484
+ help: stale ? staleCopyCause(stale) : `Fix the record with the fixes of its findings at ${at3}, then validate again.`,
4814
5485
  definition: `${schemas.presentation.$id}#/$defs/Catalogs`,
4815
5486
  lookup: ["opf", "catalog", site.kind],
4816
5487
  ...fix ? { fixes: [fix] } : {}
@@ -4958,8 +5629,8 @@ function narrativeFindings(document, options2) {
4958
5629
  );
4959
5630
  }
4960
5631
  for (const [group, value] of Object.entries(object2(document.catalogs) ? document.catalogs : {}))
4961
- for (const [id, record] of Object.entries(object2(value) && object2(value.narratives) ? value.narratives : {})) {
4962
- if (durationRangeInverted(record))
5632
+ for (const [id, record2] of Object.entries(object2(value) && object2(value.narratives) ? value.narratives : {})) {
5633
+ if (durationRangeInverted(record2))
4963
5634
  findings.push(
4964
5635
  finding("opf/narrative-duration-range", {
4965
5636
  path: pointer4(["catalogs", group, "narratives", id, "duration"]),
@@ -5021,6 +5692,984 @@ function contractFindings(document, contracts) {
5021
5692
  }
5022
5693
  return findings;
5023
5694
  }
5695
+ function lastLayoutAutoSite(document, group, options2, last) {
5696
+ let latest;
5697
+ for (const site of catalogReferenceSites(document)) {
5698
+ if (site.kind !== "layouts") continue;
5699
+ const found = resolveReference(document, site.kind, site.reference, { ...options2, ...site.group !== void 0 ? { group: site.group } : {} });
5700
+ if (found?.origin !== "document" || found.group !== group || found.id !== "auto") continue;
5701
+ if (!removedLayoutAuto(site.kind, site.reference)) return false;
5702
+ latest = site.path;
5703
+ }
5704
+ return latest !== void 0 && latest.length === last.length && latest.every((key3, at3) => key3 === last[at3]);
5705
+ }
5706
+
5707
+ // ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/scanner.js
5708
+ function createScanner(text2, ignoreTrivia = false) {
5709
+ const len = text2.length;
5710
+ let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
5711
+ function scanHexDigits(count, exact) {
5712
+ let digits = 0;
5713
+ let value2 = 0;
5714
+ while (digits < count || false) {
5715
+ let ch = text2.charCodeAt(pos);
5716
+ if (ch >= 48 && ch <= 57) {
5717
+ value2 = value2 * 16 + ch - 48;
5718
+ } else if (ch >= 65 && ch <= 70) {
5719
+ value2 = value2 * 16 + ch - 65 + 10;
5720
+ } else if (ch >= 97 && ch <= 102) {
5721
+ value2 = value2 * 16 + ch - 97 + 10;
5722
+ } else {
5723
+ break;
5724
+ }
5725
+ pos++;
5726
+ digits++;
5727
+ }
5728
+ if (digits < count) {
5729
+ value2 = -1;
5730
+ }
5731
+ return value2;
5732
+ }
5733
+ function setPosition(newPosition) {
5734
+ pos = newPosition;
5735
+ value = "";
5736
+ tokenOffset = 0;
5737
+ token = 16;
5738
+ scanError = 0;
5739
+ }
5740
+ function scanNumber() {
5741
+ let start = pos;
5742
+ if (text2.charCodeAt(pos) === 48) {
5743
+ pos++;
5744
+ } else {
5745
+ pos++;
5746
+ while (pos < text2.length && isDigit(text2.charCodeAt(pos))) {
5747
+ pos++;
5748
+ }
5749
+ }
5750
+ if (pos < text2.length && text2.charCodeAt(pos) === 46) {
5751
+ pos++;
5752
+ if (pos < text2.length && isDigit(text2.charCodeAt(pos))) {
5753
+ pos++;
5754
+ while (pos < text2.length && isDigit(text2.charCodeAt(pos))) {
5755
+ pos++;
5756
+ }
5757
+ } else {
5758
+ scanError = 3;
5759
+ return text2.substring(start, pos);
5760
+ }
5761
+ }
5762
+ let end = pos;
5763
+ if (pos < text2.length && (text2.charCodeAt(pos) === 69 || text2.charCodeAt(pos) === 101)) {
5764
+ pos++;
5765
+ if (pos < text2.length && text2.charCodeAt(pos) === 43 || text2.charCodeAt(pos) === 45) {
5766
+ pos++;
5767
+ }
5768
+ if (pos < text2.length && isDigit(text2.charCodeAt(pos))) {
5769
+ pos++;
5770
+ while (pos < text2.length && isDigit(text2.charCodeAt(pos))) {
5771
+ pos++;
5772
+ }
5773
+ end = pos;
5774
+ } else {
5775
+ scanError = 3;
5776
+ }
5777
+ }
5778
+ return text2.substring(start, end);
5779
+ }
5780
+ function scanString() {
5781
+ let result = "", start = pos;
5782
+ while (true) {
5783
+ if (pos >= len) {
5784
+ result += text2.substring(start, pos);
5785
+ scanError = 2;
5786
+ break;
5787
+ }
5788
+ const ch = text2.charCodeAt(pos);
5789
+ if (ch === 34) {
5790
+ result += text2.substring(start, pos);
5791
+ pos++;
5792
+ break;
5793
+ }
5794
+ if (ch === 92) {
5795
+ result += text2.substring(start, pos);
5796
+ pos++;
5797
+ if (pos >= len) {
5798
+ scanError = 2;
5799
+ break;
5800
+ }
5801
+ const ch2 = text2.charCodeAt(pos++);
5802
+ switch (ch2) {
5803
+ case 34:
5804
+ result += '"';
5805
+ break;
5806
+ case 92:
5807
+ result += "\\";
5808
+ break;
5809
+ case 47:
5810
+ result += "/";
5811
+ break;
5812
+ case 98:
5813
+ result += "\b";
5814
+ break;
5815
+ case 102:
5816
+ result += "\f";
5817
+ break;
5818
+ case 110:
5819
+ result += "\n";
5820
+ break;
5821
+ case 114:
5822
+ result += "\r";
5823
+ break;
5824
+ case 116:
5825
+ result += " ";
5826
+ break;
5827
+ case 117:
5828
+ const ch3 = scanHexDigits(4);
5829
+ if (ch3 >= 0) {
5830
+ result += String.fromCharCode(ch3);
5831
+ } else {
5832
+ scanError = 4;
5833
+ }
5834
+ break;
5835
+ default:
5836
+ scanError = 5;
5837
+ }
5838
+ start = pos;
5839
+ continue;
5840
+ }
5841
+ if (ch >= 0 && ch <= 31) {
5842
+ if (isLineBreak(ch)) {
5843
+ result += text2.substring(start, pos);
5844
+ scanError = 2;
5845
+ break;
5846
+ } else {
5847
+ scanError = 6;
5848
+ }
5849
+ }
5850
+ pos++;
5851
+ }
5852
+ return result;
5853
+ }
5854
+ function scanNext() {
5855
+ value = "";
5856
+ scanError = 0;
5857
+ tokenOffset = pos;
5858
+ lineStartOffset = lineNumber;
5859
+ prevTokenLineStartOffset = tokenLineStartOffset;
5860
+ if (pos >= len) {
5861
+ tokenOffset = len;
5862
+ return token = 17;
5863
+ }
5864
+ let code2 = text2.charCodeAt(pos);
5865
+ if (isWhiteSpace(code2)) {
5866
+ do {
5867
+ pos++;
5868
+ value += String.fromCharCode(code2);
5869
+ code2 = text2.charCodeAt(pos);
5870
+ } while (isWhiteSpace(code2));
5871
+ return token = 15;
5872
+ }
5873
+ if (isLineBreak(code2)) {
5874
+ pos++;
5875
+ value += String.fromCharCode(code2);
5876
+ if (code2 === 13 && text2.charCodeAt(pos) === 10) {
5877
+ pos++;
5878
+ value += "\n";
5879
+ }
5880
+ lineNumber++;
5881
+ tokenLineStartOffset = pos;
5882
+ return token = 14;
5883
+ }
5884
+ switch (code2) {
5885
+ // tokens: []{}:,
5886
+ case 123:
5887
+ pos++;
5888
+ return token = 1;
5889
+ case 125:
5890
+ pos++;
5891
+ return token = 2;
5892
+ case 91:
5893
+ pos++;
5894
+ return token = 3;
5895
+ case 93:
5896
+ pos++;
5897
+ return token = 4;
5898
+ case 58:
5899
+ pos++;
5900
+ return token = 6;
5901
+ case 44:
5902
+ pos++;
5903
+ return token = 5;
5904
+ // strings
5905
+ case 34:
5906
+ pos++;
5907
+ value = scanString();
5908
+ return token = 10;
5909
+ // comments
5910
+ case 47:
5911
+ const start = pos - 1;
5912
+ if (text2.charCodeAt(pos + 1) === 47) {
5913
+ pos += 2;
5914
+ while (pos < len) {
5915
+ if (isLineBreak(text2.charCodeAt(pos))) {
5916
+ break;
5917
+ }
5918
+ pos++;
5919
+ }
5920
+ value = text2.substring(start, pos);
5921
+ return token = 12;
5922
+ }
5923
+ if (text2.charCodeAt(pos + 1) === 42) {
5924
+ pos += 2;
5925
+ const safeLength = len - 1;
5926
+ let commentClosed = false;
5927
+ while (pos < safeLength) {
5928
+ const ch = text2.charCodeAt(pos);
5929
+ if (ch === 42 && text2.charCodeAt(pos + 1) === 47) {
5930
+ pos += 2;
5931
+ commentClosed = true;
5932
+ break;
5933
+ }
5934
+ pos++;
5935
+ if (isLineBreak(ch)) {
5936
+ if (ch === 13 && text2.charCodeAt(pos) === 10) {
5937
+ pos++;
5938
+ }
5939
+ lineNumber++;
5940
+ tokenLineStartOffset = pos;
5941
+ }
5942
+ }
5943
+ if (!commentClosed) {
5944
+ pos++;
5945
+ scanError = 1;
5946
+ }
5947
+ value = text2.substring(start, pos);
5948
+ return token = 13;
5949
+ }
5950
+ value += String.fromCharCode(code2);
5951
+ pos++;
5952
+ return token = 16;
5953
+ // numbers
5954
+ case 45:
5955
+ value += String.fromCharCode(code2);
5956
+ pos++;
5957
+ if (pos === len || !isDigit(text2.charCodeAt(pos))) {
5958
+ return token = 16;
5959
+ }
5960
+ // found a minus, followed by a number so
5961
+ // we fall through to proceed with scanning
5962
+ // numbers
5963
+ case 48:
5964
+ case 49:
5965
+ case 50:
5966
+ case 51:
5967
+ case 52:
5968
+ case 53:
5969
+ case 54:
5970
+ case 55:
5971
+ case 56:
5972
+ case 57:
5973
+ value += scanNumber();
5974
+ return token = 11;
5975
+ // literals and unknown symbols
5976
+ default:
5977
+ while (pos < len && isUnknownContentCharacter(code2)) {
5978
+ pos++;
5979
+ code2 = text2.charCodeAt(pos);
5980
+ }
5981
+ if (tokenOffset !== pos) {
5982
+ value = text2.substring(tokenOffset, pos);
5983
+ switch (value) {
5984
+ case "true":
5985
+ return token = 8;
5986
+ case "false":
5987
+ return token = 9;
5988
+ case "null":
5989
+ return token = 7;
5990
+ }
5991
+ return token = 16;
5992
+ }
5993
+ value += String.fromCharCode(code2);
5994
+ pos++;
5995
+ return token = 16;
5996
+ }
5997
+ }
5998
+ function isUnknownContentCharacter(code2) {
5999
+ if (isWhiteSpace(code2) || isLineBreak(code2)) {
6000
+ return false;
6001
+ }
6002
+ switch (code2) {
6003
+ case 125:
6004
+ case 93:
6005
+ case 123:
6006
+ case 91:
6007
+ case 34:
6008
+ case 58:
6009
+ case 44:
6010
+ case 47:
6011
+ return false;
6012
+ }
6013
+ return true;
6014
+ }
6015
+ function scanNextNonTrivia() {
6016
+ let result;
6017
+ do {
6018
+ result = scanNext();
6019
+ } while (result >= 12 && result <= 15);
6020
+ return result;
6021
+ }
6022
+ return {
6023
+ setPosition,
6024
+ getPosition: () => pos,
6025
+ scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
6026
+ getToken: () => token,
6027
+ getTokenValue: () => value,
6028
+ getTokenOffset: () => tokenOffset,
6029
+ getTokenLength: () => pos - tokenOffset,
6030
+ getTokenStartLine: () => lineStartOffset,
6031
+ getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
6032
+ getTokenError: () => scanError
6033
+ };
6034
+ }
6035
+ function isWhiteSpace(ch) {
6036
+ return ch === 32 || ch === 9;
6037
+ }
6038
+ function isLineBreak(ch) {
6039
+ return ch === 10 || ch === 13;
6040
+ }
6041
+ function isDigit(ch) {
6042
+ return ch >= 48 && ch <= 57;
6043
+ }
6044
+ var CharacterCodes;
6045
+ (function(CharacterCodes2) {
6046
+ CharacterCodes2[CharacterCodes2["lineFeed"] = 10] = "lineFeed";
6047
+ CharacterCodes2[CharacterCodes2["carriageReturn"] = 13] = "carriageReturn";
6048
+ CharacterCodes2[CharacterCodes2["space"] = 32] = "space";
6049
+ CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0";
6050
+ CharacterCodes2[CharacterCodes2["_1"] = 49] = "_1";
6051
+ CharacterCodes2[CharacterCodes2["_2"] = 50] = "_2";
6052
+ CharacterCodes2[CharacterCodes2["_3"] = 51] = "_3";
6053
+ CharacterCodes2[CharacterCodes2["_4"] = 52] = "_4";
6054
+ CharacterCodes2[CharacterCodes2["_5"] = 53] = "_5";
6055
+ CharacterCodes2[CharacterCodes2["_6"] = 54] = "_6";
6056
+ CharacterCodes2[CharacterCodes2["_7"] = 55] = "_7";
6057
+ CharacterCodes2[CharacterCodes2["_8"] = 56] = "_8";
6058
+ CharacterCodes2[CharacterCodes2["_9"] = 57] = "_9";
6059
+ CharacterCodes2[CharacterCodes2["a"] = 97] = "a";
6060
+ CharacterCodes2[CharacterCodes2["b"] = 98] = "b";
6061
+ CharacterCodes2[CharacterCodes2["c"] = 99] = "c";
6062
+ CharacterCodes2[CharacterCodes2["d"] = 100] = "d";
6063
+ CharacterCodes2[CharacterCodes2["e"] = 101] = "e";
6064
+ CharacterCodes2[CharacterCodes2["f"] = 102] = "f";
6065
+ CharacterCodes2[CharacterCodes2["g"] = 103] = "g";
6066
+ CharacterCodes2[CharacterCodes2["h"] = 104] = "h";
6067
+ CharacterCodes2[CharacterCodes2["i"] = 105] = "i";
6068
+ CharacterCodes2[CharacterCodes2["j"] = 106] = "j";
6069
+ CharacterCodes2[CharacterCodes2["k"] = 107] = "k";
6070
+ CharacterCodes2[CharacterCodes2["l"] = 108] = "l";
6071
+ CharacterCodes2[CharacterCodes2["m"] = 109] = "m";
6072
+ CharacterCodes2[CharacterCodes2["n"] = 110] = "n";
6073
+ CharacterCodes2[CharacterCodes2["o"] = 111] = "o";
6074
+ CharacterCodes2[CharacterCodes2["p"] = 112] = "p";
6075
+ CharacterCodes2[CharacterCodes2["q"] = 113] = "q";
6076
+ CharacterCodes2[CharacterCodes2["r"] = 114] = "r";
6077
+ CharacterCodes2[CharacterCodes2["s"] = 115] = "s";
6078
+ CharacterCodes2[CharacterCodes2["t"] = 116] = "t";
6079
+ CharacterCodes2[CharacterCodes2["u"] = 117] = "u";
6080
+ CharacterCodes2[CharacterCodes2["v"] = 118] = "v";
6081
+ CharacterCodes2[CharacterCodes2["w"] = 119] = "w";
6082
+ CharacterCodes2[CharacterCodes2["x"] = 120] = "x";
6083
+ CharacterCodes2[CharacterCodes2["y"] = 121] = "y";
6084
+ CharacterCodes2[CharacterCodes2["z"] = 122] = "z";
6085
+ CharacterCodes2[CharacterCodes2["A"] = 65] = "A";
6086
+ CharacterCodes2[CharacterCodes2["B"] = 66] = "B";
6087
+ CharacterCodes2[CharacterCodes2["C"] = 67] = "C";
6088
+ CharacterCodes2[CharacterCodes2["D"] = 68] = "D";
6089
+ CharacterCodes2[CharacterCodes2["E"] = 69] = "E";
6090
+ CharacterCodes2[CharacterCodes2["F"] = 70] = "F";
6091
+ CharacterCodes2[CharacterCodes2["G"] = 71] = "G";
6092
+ CharacterCodes2[CharacterCodes2["H"] = 72] = "H";
6093
+ CharacterCodes2[CharacterCodes2["I"] = 73] = "I";
6094
+ CharacterCodes2[CharacterCodes2["J"] = 74] = "J";
6095
+ CharacterCodes2[CharacterCodes2["K"] = 75] = "K";
6096
+ CharacterCodes2[CharacterCodes2["L"] = 76] = "L";
6097
+ CharacterCodes2[CharacterCodes2["M"] = 77] = "M";
6098
+ CharacterCodes2[CharacterCodes2["N"] = 78] = "N";
6099
+ CharacterCodes2[CharacterCodes2["O"] = 79] = "O";
6100
+ CharacterCodes2[CharacterCodes2["P"] = 80] = "P";
6101
+ CharacterCodes2[CharacterCodes2["Q"] = 81] = "Q";
6102
+ CharacterCodes2[CharacterCodes2["R"] = 82] = "R";
6103
+ CharacterCodes2[CharacterCodes2["S"] = 83] = "S";
6104
+ CharacterCodes2[CharacterCodes2["T"] = 84] = "T";
6105
+ CharacterCodes2[CharacterCodes2["U"] = 85] = "U";
6106
+ CharacterCodes2[CharacterCodes2["V"] = 86] = "V";
6107
+ CharacterCodes2[CharacterCodes2["W"] = 87] = "W";
6108
+ CharacterCodes2[CharacterCodes2["X"] = 88] = "X";
6109
+ CharacterCodes2[CharacterCodes2["Y"] = 89] = "Y";
6110
+ CharacterCodes2[CharacterCodes2["Z"] = 90] = "Z";
6111
+ CharacterCodes2[CharacterCodes2["asterisk"] = 42] = "asterisk";
6112
+ CharacterCodes2[CharacterCodes2["backslash"] = 92] = "backslash";
6113
+ CharacterCodes2[CharacterCodes2["closeBrace"] = 125] = "closeBrace";
6114
+ CharacterCodes2[CharacterCodes2["closeBracket"] = 93] = "closeBracket";
6115
+ CharacterCodes2[CharacterCodes2["colon"] = 58] = "colon";
6116
+ CharacterCodes2[CharacterCodes2["comma"] = 44] = "comma";
6117
+ CharacterCodes2[CharacterCodes2["dot"] = 46] = "dot";
6118
+ CharacterCodes2[CharacterCodes2["doubleQuote"] = 34] = "doubleQuote";
6119
+ CharacterCodes2[CharacterCodes2["minus"] = 45] = "minus";
6120
+ CharacterCodes2[CharacterCodes2["openBrace"] = 123] = "openBrace";
6121
+ CharacterCodes2[CharacterCodes2["openBracket"] = 91] = "openBracket";
6122
+ CharacterCodes2[CharacterCodes2["plus"] = 43] = "plus";
6123
+ CharacterCodes2[CharacterCodes2["slash"] = 47] = "slash";
6124
+ CharacterCodes2[CharacterCodes2["formFeed"] = 12] = "formFeed";
6125
+ CharacterCodes2[CharacterCodes2["tab"] = 9] = "tab";
6126
+ })(CharacterCodes || (CharacterCodes = {}));
6127
+
6128
+ // ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/string-intern.js
6129
+ new Array(20).fill(0).map((_, index) => {
6130
+ return " ".repeat(index);
6131
+ });
6132
+ var maxCachedValues = 200;
6133
+ ({
6134
+ " ": {
6135
+ "\n": new Array(maxCachedValues).fill(0).map((_, index) => {
6136
+ return "\n" + " ".repeat(index);
6137
+ }),
6138
+ "\r": new Array(maxCachedValues).fill(0).map((_, index) => {
6139
+ return "\r" + " ".repeat(index);
6140
+ }),
6141
+ "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
6142
+ return "\r\n" + " ".repeat(index);
6143
+ })
6144
+ },
6145
+ " ": {
6146
+ "\n": new Array(maxCachedValues).fill(0).map((_, index) => {
6147
+ return "\n" + " ".repeat(index);
6148
+ }),
6149
+ "\r": new Array(maxCachedValues).fill(0).map((_, index) => {
6150
+ return "\r" + " ".repeat(index);
6151
+ }),
6152
+ "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
6153
+ return "\r\n" + " ".repeat(index);
6154
+ })
6155
+ }
6156
+ });
6157
+
6158
+ // ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/parser.js
6159
+ var ParseOptions;
6160
+ (function(ParseOptions2) {
6161
+ ParseOptions2.DEFAULT = {
6162
+ allowTrailingComma: false
6163
+ };
6164
+ })(ParseOptions || (ParseOptions = {}));
6165
+ function parseTree(text2, errors = [], options2 = ParseOptions.DEFAULT) {
6166
+ let currentParent = { type: "array", offset: -1, length: -1, children: [], parent: void 0 };
6167
+ function ensurePropertyComplete(endOffset) {
6168
+ if (currentParent.type === "property") {
6169
+ currentParent.length = endOffset - currentParent.offset;
6170
+ currentParent = currentParent.parent;
6171
+ }
6172
+ }
6173
+ function onValue(valueNode) {
6174
+ currentParent.children.push(valueNode);
6175
+ return valueNode;
6176
+ }
6177
+ const visitor = {
6178
+ onObjectBegin: (offset) => {
6179
+ currentParent = onValue({ type: "object", offset, length: -1, parent: currentParent, children: [] });
6180
+ },
6181
+ onObjectProperty: (name, offset, length) => {
6182
+ currentParent = onValue({ type: "property", offset, length: -1, parent: currentParent, children: [] });
6183
+ currentParent.children.push({ type: "string", value: name, offset, length, parent: currentParent });
6184
+ },
6185
+ onObjectEnd: (offset, length) => {
6186
+ ensurePropertyComplete(offset + length);
6187
+ currentParent.length = offset + length - currentParent.offset;
6188
+ currentParent = currentParent.parent;
6189
+ ensurePropertyComplete(offset + length);
6190
+ },
6191
+ onArrayBegin: (offset, length) => {
6192
+ currentParent = onValue({ type: "array", offset, length: -1, parent: currentParent, children: [] });
6193
+ },
6194
+ onArrayEnd: (offset, length) => {
6195
+ currentParent.length = offset + length - currentParent.offset;
6196
+ currentParent = currentParent.parent;
6197
+ ensurePropertyComplete(offset + length);
6198
+ },
6199
+ onLiteralValue: (value, offset, length) => {
6200
+ onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });
6201
+ ensurePropertyComplete(offset + length);
6202
+ },
6203
+ onSeparator: (sep, offset, length) => {
6204
+ if (currentParent.type === "property") {
6205
+ if (sep === ":") {
6206
+ currentParent.colonOffset = offset;
6207
+ } else if (sep === ",") {
6208
+ ensurePropertyComplete(offset);
6209
+ }
6210
+ }
6211
+ },
6212
+ onError: (error, offset, length) => {
6213
+ errors.push({ error, offset, length });
6214
+ }
6215
+ };
6216
+ visit(text2, visitor, options2);
6217
+ const result = currentParent.children[0];
6218
+ if (result) {
6219
+ delete result.parent;
6220
+ }
6221
+ return result;
6222
+ }
6223
+ function getNodePath(node) {
6224
+ if (!node.parent || !node.parent.children) {
6225
+ return [];
6226
+ }
6227
+ const path = getNodePath(node.parent);
6228
+ if (node.parent.type === "property") {
6229
+ const key3 = node.parent.children[0].value;
6230
+ path.push(key3);
6231
+ } else if (node.parent.type === "array") {
6232
+ const index = node.parent.children.indexOf(node);
6233
+ if (index !== -1) {
6234
+ path.push(index);
6235
+ }
6236
+ }
6237
+ return path;
6238
+ }
6239
+ function contains(node, offset, includeRightBound = false) {
6240
+ return offset >= node.offset && offset < node.offset + node.length || includeRightBound && offset === node.offset + node.length;
6241
+ }
6242
+ function findNodeAtOffset(node, offset, includeRightBound = false) {
6243
+ if (contains(node, offset, includeRightBound)) {
6244
+ const children = node.children;
6245
+ if (Array.isArray(children)) {
6246
+ for (let i = 0; i < children.length && children[i].offset <= offset; i++) {
6247
+ const item = findNodeAtOffset(children[i], offset, includeRightBound);
6248
+ if (item) {
6249
+ return item;
6250
+ }
6251
+ }
6252
+ }
6253
+ return node;
6254
+ }
6255
+ return void 0;
6256
+ }
6257
+ function visit(text2, visitor, options2 = ParseOptions.DEFAULT) {
6258
+ const _scanner = createScanner(text2, false);
6259
+ const _jsonPath = [];
6260
+ let suppressedCallbacks = 0;
6261
+ function toNoArgVisit(visitFunction) {
6262
+ return visitFunction ? () => suppressedCallbacks === 0 && visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
6263
+ }
6264
+ function toOneArgVisit(visitFunction) {
6265
+ return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
6266
+ }
6267
+ function toOneArgVisitWithPath(visitFunction) {
6268
+ return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
6269
+ }
6270
+ function toBeginVisit(visitFunction) {
6271
+ return visitFunction ? () => {
6272
+ if (suppressedCallbacks > 0) {
6273
+ suppressedCallbacks++;
6274
+ } else {
6275
+ let cbReturn = visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice());
6276
+ if (cbReturn === false) {
6277
+ suppressedCallbacks = 1;
6278
+ }
6279
+ }
6280
+ } : () => true;
6281
+ }
6282
+ function toEndVisit(visitFunction) {
6283
+ return visitFunction ? () => {
6284
+ if (suppressedCallbacks > 0) {
6285
+ suppressedCallbacks--;
6286
+ }
6287
+ if (suppressedCallbacks === 0) {
6288
+ visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter());
6289
+ }
6290
+ } : () => true;
6291
+ }
6292
+ const onObjectBegin = toBeginVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toEndVisit(visitor.onObjectEnd), onArrayBegin = toBeginVisit(visitor.onArrayBegin), onArrayEnd = toEndVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
6293
+ const disallowComments = options2 && options2.disallowComments;
6294
+ const allowTrailingComma = options2 && options2.allowTrailingComma;
6295
+ function scanNext() {
6296
+ while (true) {
6297
+ const token = _scanner.scan();
6298
+ switch (_scanner.getTokenError()) {
6299
+ case 4:
6300
+ handleError(
6301
+ 14
6302
+ /* ParseErrorCode.InvalidUnicode */
6303
+ );
6304
+ break;
6305
+ case 5:
6306
+ handleError(
6307
+ 15
6308
+ /* ParseErrorCode.InvalidEscapeCharacter */
6309
+ );
6310
+ break;
6311
+ case 3:
6312
+ handleError(
6313
+ 13
6314
+ /* ParseErrorCode.UnexpectedEndOfNumber */
6315
+ );
6316
+ break;
6317
+ case 1:
6318
+ if (!disallowComments) {
6319
+ handleError(
6320
+ 11
6321
+ /* ParseErrorCode.UnexpectedEndOfComment */
6322
+ );
6323
+ }
6324
+ break;
6325
+ case 2:
6326
+ handleError(
6327
+ 12
6328
+ /* ParseErrorCode.UnexpectedEndOfString */
6329
+ );
6330
+ break;
6331
+ case 6:
6332
+ handleError(
6333
+ 16
6334
+ /* ParseErrorCode.InvalidCharacter */
6335
+ );
6336
+ break;
6337
+ }
6338
+ switch (token) {
6339
+ case 12:
6340
+ case 13:
6341
+ if (disallowComments) {
6342
+ handleError(
6343
+ 10
6344
+ /* ParseErrorCode.InvalidCommentToken */
6345
+ );
6346
+ } else {
6347
+ onComment();
6348
+ }
6349
+ break;
6350
+ case 16:
6351
+ handleError(
6352
+ 1
6353
+ /* ParseErrorCode.InvalidSymbol */
6354
+ );
6355
+ break;
6356
+ case 15:
6357
+ case 14:
6358
+ break;
6359
+ default:
6360
+ return token;
6361
+ }
6362
+ }
6363
+ }
6364
+ function handleError(error, skipUntilAfter = [], skipUntil = []) {
6365
+ onError(error);
6366
+ if (skipUntilAfter.length + skipUntil.length > 0) {
6367
+ let token = _scanner.getToken();
6368
+ while (token !== 17) {
6369
+ if (skipUntilAfter.indexOf(token) !== -1) {
6370
+ scanNext();
6371
+ break;
6372
+ } else if (skipUntil.indexOf(token) !== -1) {
6373
+ break;
6374
+ }
6375
+ token = scanNext();
6376
+ }
6377
+ }
6378
+ }
6379
+ function parseString(isValue) {
6380
+ const value = _scanner.getTokenValue();
6381
+ if (isValue) {
6382
+ onLiteralValue(value);
6383
+ } else {
6384
+ onObjectProperty(value);
6385
+ _jsonPath.push(value);
6386
+ }
6387
+ scanNext();
6388
+ return true;
6389
+ }
6390
+ function parseLiteral() {
6391
+ switch (_scanner.getToken()) {
6392
+ case 11:
6393
+ const tokenValue = _scanner.getTokenValue();
6394
+ let value = Number(tokenValue);
6395
+ if (isNaN(value)) {
6396
+ handleError(
6397
+ 2
6398
+ /* ParseErrorCode.InvalidNumberFormat */
6399
+ );
6400
+ value = 0;
6401
+ }
6402
+ onLiteralValue(value);
6403
+ break;
6404
+ case 7:
6405
+ onLiteralValue(null);
6406
+ break;
6407
+ case 8:
6408
+ onLiteralValue(true);
6409
+ break;
6410
+ case 9:
6411
+ onLiteralValue(false);
6412
+ break;
6413
+ default:
6414
+ return false;
6415
+ }
6416
+ scanNext();
6417
+ return true;
6418
+ }
6419
+ function parseProperty() {
6420
+ if (_scanner.getToken() !== 10) {
6421
+ handleError(3, [], [
6422
+ 2,
6423
+ 5
6424
+ /* SyntaxKind.CommaToken */
6425
+ ]);
6426
+ return false;
6427
+ }
6428
+ parseString(false);
6429
+ if (_scanner.getToken() === 6) {
6430
+ onSeparator(":");
6431
+ scanNext();
6432
+ if (!parseValue()) {
6433
+ handleError(4, [], [
6434
+ 2,
6435
+ 5
6436
+ /* SyntaxKind.CommaToken */
6437
+ ]);
6438
+ }
6439
+ } else {
6440
+ handleError(5, [], [
6441
+ 2,
6442
+ 5
6443
+ /* SyntaxKind.CommaToken */
6444
+ ]);
6445
+ }
6446
+ _jsonPath.pop();
6447
+ return true;
6448
+ }
6449
+ function parseObject() {
6450
+ onObjectBegin();
6451
+ scanNext();
6452
+ let needsComma = false;
6453
+ while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17) {
6454
+ if (_scanner.getToken() === 5) {
6455
+ if (!needsComma) {
6456
+ handleError(4, [], []);
6457
+ }
6458
+ onSeparator(",");
6459
+ scanNext();
6460
+ if (_scanner.getToken() === 2 && allowTrailingComma) {
6461
+ break;
6462
+ }
6463
+ } else if (needsComma) {
6464
+ handleError(6, [], []);
6465
+ }
6466
+ if (!parseProperty()) {
6467
+ handleError(4, [], [
6468
+ 2,
6469
+ 5
6470
+ /* SyntaxKind.CommaToken */
6471
+ ]);
6472
+ }
6473
+ needsComma = true;
6474
+ }
6475
+ onObjectEnd();
6476
+ if (_scanner.getToken() !== 2) {
6477
+ handleError(7, [
6478
+ 2
6479
+ /* SyntaxKind.CloseBraceToken */
6480
+ ], []);
6481
+ } else {
6482
+ scanNext();
6483
+ }
6484
+ return true;
6485
+ }
6486
+ function parseArray() {
6487
+ onArrayBegin();
6488
+ scanNext();
6489
+ let isFirstElement = true;
6490
+ let needsComma = false;
6491
+ while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17) {
6492
+ if (_scanner.getToken() === 5) {
6493
+ if (!needsComma) {
6494
+ handleError(4, [], []);
6495
+ }
6496
+ onSeparator(",");
6497
+ scanNext();
6498
+ if (_scanner.getToken() === 4 && allowTrailingComma) {
6499
+ break;
6500
+ }
6501
+ } else if (needsComma) {
6502
+ handleError(6, [], []);
6503
+ }
6504
+ if (isFirstElement) {
6505
+ _jsonPath.push(0);
6506
+ isFirstElement = false;
6507
+ } else {
6508
+ _jsonPath[_jsonPath.length - 1]++;
6509
+ }
6510
+ if (!parseValue()) {
6511
+ handleError(4, [], [
6512
+ 4,
6513
+ 5
6514
+ /* SyntaxKind.CommaToken */
6515
+ ]);
6516
+ }
6517
+ needsComma = true;
6518
+ }
6519
+ onArrayEnd();
6520
+ if (!isFirstElement) {
6521
+ _jsonPath.pop();
6522
+ }
6523
+ if (_scanner.getToken() !== 4) {
6524
+ handleError(8, [
6525
+ 4
6526
+ /* SyntaxKind.CloseBracketToken */
6527
+ ], []);
6528
+ } else {
6529
+ scanNext();
6530
+ }
6531
+ return true;
6532
+ }
6533
+ function parseValue() {
6534
+ switch (_scanner.getToken()) {
6535
+ case 3:
6536
+ return parseArray();
6537
+ case 1:
6538
+ return parseObject();
6539
+ case 10:
6540
+ return parseString(true);
6541
+ default:
6542
+ return parseLiteral();
6543
+ }
6544
+ }
6545
+ scanNext();
6546
+ if (_scanner.getToken() === 17) {
6547
+ if (options2.allowEmptyContent) {
6548
+ return true;
6549
+ }
6550
+ handleError(4, [], []);
6551
+ return false;
6552
+ }
6553
+ if (!parseValue()) {
6554
+ handleError(4, [], []);
6555
+ return false;
6556
+ }
6557
+ if (_scanner.getToken() !== 17) {
6558
+ handleError(9, [], []);
6559
+ }
6560
+ return true;
6561
+ }
6562
+ function getNodeType(value) {
6563
+ switch (typeof value) {
6564
+ case "boolean":
6565
+ return "boolean";
6566
+ case "number":
6567
+ return "number";
6568
+ case "string":
6569
+ return "string";
6570
+ case "object": {
6571
+ if (!value) {
6572
+ return "null";
6573
+ } else if (Array.isArray(value)) {
6574
+ return "array";
6575
+ }
6576
+ return "object";
6577
+ }
6578
+ default:
6579
+ return "null";
6580
+ }
6581
+ }
6582
+
6583
+ // ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/main.js
6584
+ var ScanError;
6585
+ (function(ScanError2) {
6586
+ ScanError2[ScanError2["None"] = 0] = "None";
6587
+ ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
6588
+ ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
6589
+ ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
6590
+ ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode";
6591
+ ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
6592
+ ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter";
6593
+ })(ScanError || (ScanError = {}));
6594
+ var SyntaxKind;
6595
+ (function(SyntaxKind2) {
6596
+ SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken";
6597
+ SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken";
6598
+ SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken";
6599
+ SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken";
6600
+ SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken";
6601
+ SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken";
6602
+ SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword";
6603
+ SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword";
6604
+ SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword";
6605
+ SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral";
6606
+ SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral";
6607
+ SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia";
6608
+ SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
6609
+ SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia";
6610
+ SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia";
6611
+ SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown";
6612
+ SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF";
6613
+ })(SyntaxKind || (SyntaxKind = {}));
6614
+ var parseTree2 = parseTree;
6615
+ var findNodeAtOffset2 = findNodeAtOffset;
6616
+ var getNodePath2 = getNodePath;
6617
+ var ParseErrorCode;
6618
+ (function(ParseErrorCode2) {
6619
+ ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol";
6620
+ ParseErrorCode2[ParseErrorCode2["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
6621
+ ParseErrorCode2[ParseErrorCode2["PropertyNameExpected"] = 3] = "PropertyNameExpected";
6622
+ ParseErrorCode2[ParseErrorCode2["ValueExpected"] = 4] = "ValueExpected";
6623
+ ParseErrorCode2[ParseErrorCode2["ColonExpected"] = 5] = "ColonExpected";
6624
+ ParseErrorCode2[ParseErrorCode2["CommaExpected"] = 6] = "CommaExpected";
6625
+ ParseErrorCode2[ParseErrorCode2["CloseBraceExpected"] = 7] = "CloseBraceExpected";
6626
+ ParseErrorCode2[ParseErrorCode2["CloseBracketExpected"] = 8] = "CloseBracketExpected";
6627
+ ParseErrorCode2[ParseErrorCode2["EndOfFileExpected"] = 9] = "EndOfFileExpected";
6628
+ ParseErrorCode2[ParseErrorCode2["InvalidCommentToken"] = 10] = "InvalidCommentToken";
6629
+ ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
6630
+ ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
6631
+ ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
6632
+ ParseErrorCode2[ParseErrorCode2["InvalidUnicode"] = 14] = "InvalidUnicode";
6633
+ ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
6634
+ ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
6635
+ })(ParseErrorCode || (ParseErrorCode = {}));
6636
+ function printParseErrorCode(code2) {
6637
+ switch (code2) {
6638
+ case 1:
6639
+ return "InvalidSymbol";
6640
+ case 2:
6641
+ return "InvalidNumberFormat";
6642
+ case 3:
6643
+ return "PropertyNameExpected";
6644
+ case 4:
6645
+ return "ValueExpected";
6646
+ case 5:
6647
+ return "ColonExpected";
6648
+ case 6:
6649
+ return "CommaExpected";
6650
+ case 7:
6651
+ return "CloseBraceExpected";
6652
+ case 8:
6653
+ return "CloseBracketExpected";
6654
+ case 9:
6655
+ return "EndOfFileExpected";
6656
+ case 10:
6657
+ return "InvalidCommentToken";
6658
+ case 11:
6659
+ return "UnexpectedEndOfComment";
6660
+ case 12:
6661
+ return "UnexpectedEndOfString";
6662
+ case 13:
6663
+ return "UnexpectedEndOfNumber";
6664
+ case 14:
6665
+ return "InvalidUnicode";
6666
+ case 15:
6667
+ return "InvalidEscapeCharacter";
6668
+ case 16:
6669
+ return "InvalidCharacter";
6670
+ }
6671
+ return "<unknown ParseErrorCode>";
6672
+ }
5024
6673
 
5025
6674
  // src/patch.ts
5026
6675
  var OPFPatchError = class extends Error {
@@ -5119,10 +6768,10 @@ function indexOfId(array, id) {
5119
6768
  }
5120
6769
  return found;
5121
6770
  }
5122
- function uniqueIdAt(array, at2) {
5123
- const item = array[at2];
6771
+ function uniqueIdAt(array, at3) {
6772
+ const item = array[at3];
5124
6773
  if (!isObject2(item) || !own2(item, "id") || typeof item.id !== "string" || item.id === "") return void 0;
5125
- return indexOfId(array, item.id) === at2 ? item.id : void 0;
6774
+ return indexOfId(array, item.id) === at3 ? item.id : void 0;
5126
6775
  }
5127
6776
  function resolveTokens(document, tokens, pointer5) {
5128
6777
  const out = [];
@@ -5130,10 +6779,10 @@ function resolveTokens(document, tokens, pointer5) {
5130
6779
  for (const token of tokens) {
5131
6780
  let resolved2 = token;
5132
6781
  if (walking && Array.isArray(cursor) && isIdToken(token)) {
5133
- const at2 = indexOfId(cursor, token.slice(1));
5134
- if (at2 === -1) throw new OPFPatchError("patch-id-not-found", `No element of ${formatPointer(out) || "/"} has the id '${token.slice(1)}'.`, { path: pointer5 });
5135
- if (at2 === -2) throw new OPFPatchError("patch-id-ambiguous", `More than one element of ${formatPointer(out) || "/"} has the id '${token.slice(1)}'.`, { path: pointer5 });
5136
- resolved2 = String(at2);
6782
+ const at3 = indexOfId(cursor, token.slice(1));
6783
+ if (at3 === -1) throw new OPFPatchError("patch-id-not-found", `No element of ${formatPointer(out) || "/"} has the id '${token.slice(1)}'.`, { path: pointer5 });
6784
+ if (at3 === -2) throw new OPFPatchError("patch-id-ambiguous", `More than one element of ${formatPointer(out) || "/"} has the id '${token.slice(1)}'.`, { path: pointer5 });
6785
+ resolved2 = String(at3);
5137
6786
  }
5138
6787
  out.push(resolved2);
5139
6788
  if (walking) {
@@ -5174,16 +6823,16 @@ function readPointer(document, pointer5) {
5174
6823
  let value = document;
5175
6824
  for (const token of tokens) {
5176
6825
  if (Array.isArray(value)) {
5177
- let at2;
6826
+ let at3;
5178
6827
  if (isIdToken(token)) {
5179
- at2 = indexOfId(value, token.slice(1));
5180
- if (at2 < 0) return { found: false };
6828
+ at3 = indexOfId(value, token.slice(1));
6829
+ if (at3 < 0) return { found: false };
5181
6830
  } else {
5182
6831
  if (!INDEX_TOKEN.test(token)) return { found: false };
5183
- at2 = Number(token);
6832
+ at3 = Number(token);
5184
6833
  }
5185
- if (!Number.isSafeInteger(at2) || at2 >= value.length) return { found: false };
5186
- value = value[at2];
6834
+ if (!Number.isSafeInteger(at3) || at3 >= value.length) return { found: false };
6835
+ value = value[at3];
5187
6836
  } else if (value && typeof value === "object" && own2(value, token)) value = value[token];
5188
6837
  else return { found: false };
5189
6838
  }
@@ -5201,9 +6850,9 @@ var hasPointer = (document, pointer5) => readPointer(document, pointer5).found;
5201
6850
  function arrayIndex(token, length, allowEnd, path) {
5202
6851
  if (allowEnd && token === "-") return length;
5203
6852
  if (!INDEX_TOKEN.test(token)) throw new OPFPatchError("invalid-array-index", `Invalid array index: ${token}`, { path });
5204
- const at2 = Number(token);
5205
- if (!Number.isSafeInteger(at2) || at2 > length || !allowEnd && at2 >= length) throw new OPFPatchError("invalid-array-index", `Array index out of bounds: ${token}`, { path });
5206
- return at2;
6853
+ const at3 = Number(token);
6854
+ if (!Number.isSafeInteger(at3) || at3 > length || !allowEnd && at3 >= length) throw new OPFPatchError("invalid-array-index", `Array index out of bounds: ${token}`, { path });
6855
+ return at3;
5207
6856
  }
5208
6857
  function normalizePatch(patch2) {
5209
6858
  if (!Array.isArray(patch2)) throw new OPFPatchError("invalid-patch", "A JSON Patch must be an array of operations.");
@@ -5249,14 +6898,14 @@ function addAt(document, path, value) {
5249
6898
  if (!tokens.length) return { document: clone(value), inverse: { op: "replace", path: "", value: clone(document) }, pointer: "" };
5250
6899
  const { parent, key: key3 } = parentOf(document, tokens, path);
5251
6900
  if (Array.isArray(parent)) {
5252
- const at2 = arrayIndex(key3, parent.length, true, path);
5253
- parent.splice(at2, 0, clone(value));
5254
- const pointer6 = formatPointer([...tokens.slice(0, -1), at2]);
6901
+ const at3 = arrayIndex(key3, parent.length, true, path);
6902
+ parent.splice(at3, 0, clone(value));
6903
+ const pointer6 = formatPointer([...tokens.slice(0, -1), at3]);
5255
6904
  return { document, inverse: { op: "remove", path: pointer6 }, pointer: pointer6 };
5256
6905
  }
5257
- const record = parent;
5258
- const previous = own2(record, key3) ? record[key3] : NONE;
5259
- Object.defineProperty(record, key3, { value: clone(value), enumerable: true, configurable: true, writable: true });
6906
+ const record2 = parent;
6907
+ const previous = own2(record2, key3) ? record2[key3] : NONE;
6908
+ Object.defineProperty(record2, key3, { value: clone(value), enumerable: true, configurable: true, writable: true });
5260
6909
  const pointer5 = formatPointer(tokens);
5261
6910
  return { document, inverse: previous === NONE ? { op: "remove", path: pointer5 } : { op: "replace", path: pointer5, value: clone(previous) }, pointer: pointer5 };
5262
6911
  }
@@ -5267,15 +6916,15 @@ function replaceAt(document, path, value) {
5267
6916
  let previous;
5268
6917
  let pointer5 = formatPointer(tokens);
5269
6918
  if (Array.isArray(parent)) {
5270
- const at2 = arrayIndex(key3, parent.length, false, path);
5271
- previous = parent[at2];
5272
- parent[at2] = clone(value);
5273
- pointer5 = formatPointer([...tokens.slice(0, -1), at2]);
6919
+ const at3 = arrayIndex(key3, parent.length, false, path);
6920
+ previous = parent[at3];
6921
+ parent[at3] = clone(value);
6922
+ pointer5 = formatPointer([...tokens.slice(0, -1), at3]);
5274
6923
  } else {
5275
- const record = parent;
5276
- if (!own2(record, key3)) throw new OPFPatchError("patch-path-missing", `Patch path does not exist: ${path}.`, { path });
5277
- previous = record[key3];
5278
- Object.defineProperty(record, key3, { value: clone(value), enumerable: true, configurable: true, writable: true });
6924
+ const record2 = parent;
6925
+ if (!own2(record2, key3)) throw new OPFPatchError("patch-path-missing", `Patch path does not exist: ${path}.`, { path });
6926
+ previous = record2[key3];
6927
+ Object.defineProperty(record2, key3, { value: clone(value), enumerable: true, configurable: true, writable: true });
5279
6928
  }
5280
6929
  return { document, inverse: { op: "replace", path: pointer5, value: clone(previous) }, pointer: pointer5 };
5281
6930
  }
@@ -5285,16 +6934,16 @@ function removeAt(document, path) {
5285
6934
  const { parent, key: key3 } = parentOf(document, tokens, path);
5286
6935
  let previous;
5287
6936
  if (Array.isArray(parent)) {
5288
- const at2 = arrayIndex(key3, parent.length, false, path);
5289
- previous = parent[at2];
5290
- parent.splice(at2, 1);
5291
- const pointer6 = formatPointer([...tokens.slice(0, -1), at2]);
6937
+ const at3 = arrayIndex(key3, parent.length, false, path);
6938
+ previous = parent[at3];
6939
+ parent.splice(at3, 1);
6940
+ const pointer6 = formatPointer([...tokens.slice(0, -1), at3]);
5292
6941
  return { document, inverse: { op: "add", path: pointer6, value: clone(previous) }, pointer: pointer6 };
5293
6942
  }
5294
- const record = parent;
5295
- if (!own2(record, key3)) throw new OPFPatchError("patch-path-missing", `Patch path does not exist: ${path}.`, { path });
5296
- previous = record[key3];
5297
- delete record[key3];
6943
+ const record2 = parent;
6944
+ if (!own2(record2, key3)) throw new OPFPatchError("patch-path-missing", `Patch path does not exist: ${path}.`, { path });
6945
+ previous = record2[key3];
6946
+ delete record2[key3];
5298
6947
  const pointer5 = formatPointer(tokens);
5299
6948
  return { document, inverse: { op: "add", path: pointer5, value: clone(previous) }, pointer: pointer5 };
5300
6949
  }
@@ -5462,7 +7111,7 @@ var CATALOG_KIND = /* @__PURE__ */ Symbol.for("@openpresentation/opf:catalog-kin
5462
7111
  var catalogKindOfNode = /* @__PURE__ */ new WeakMap();
5463
7112
  var kindOfNode = (node) => catalogKindOfNode.get(node) ?? node[CATALOG_KIND];
5464
7113
  function splitOpfPath(path) {
5465
- if (Array.isArray(path)) return path.map((segment) => String(segment));
7114
+ if (Array.isArray(path)) return path.map((segment2) => String(segment2));
5466
7115
  if (typeof path !== "string") throw new TypeError("An OPF path must be a string or an array of segments.");
5467
7116
  if (path === "") return [];
5468
7117
  if (path.startsWith("/")) return parsePointer(path);
@@ -5554,13 +7203,13 @@ function score2(schema, value) {
5554
7203
  if (own3(schema, "const")) return JSON.stringify(schema.const) === JSON.stringify(value) ? 100 : -100;
5555
7204
  if (schema.enum && !schema.enum.includes(value)) return -100;
5556
7205
  let result = 1;
5557
- const record = value;
7206
+ const record2 = value;
5558
7207
  for (const [key3, child] of Object.entries(schema.properties ?? {})) {
5559
- if (!record || !own3(record, key3)) continue;
5560
- if (own3(child, "const")) result += record[key3] === child.const ? 100 : -1e3;
7208
+ if (!record2 || !own3(record2, key3)) continue;
7209
+ if (own3(child, "const")) result += record2[key3] === child.const ? 100 : -1e3;
5561
7210
  else result += 1;
5562
7211
  }
5563
- for (const key3 of schema.required ?? []) if (!record || !own3(record, key3)) result -= 2;
7212
+ for (const key3 of schema.required ?? []) if (!record2 || !own3(record2, key3)) result -= 2;
5564
7213
  return result;
5565
7214
  }
5566
7215
  function activeSchema(schema, value, root = presentationSchema) {
@@ -5644,7 +7293,7 @@ function createSchemaValue(schema, root = presentationSchema, depth2 = 0) {
5644
7293
  function listSchemaFields() {
5645
7294
  const result = [];
5646
7295
  for (const [name, root] of Object.entries(schemas)) {
5647
- const visit = (schema, path) => {
7296
+ const visit2 = (schema, path) => {
5648
7297
  if (!schema || typeof schema !== "object") return;
5649
7298
  for (const [key3, child] of Object.entries(schema.properties ?? {})) {
5650
7299
  result.push({
@@ -5656,18 +7305,18 @@ function listSchemaFields() {
5656
7305
  type: child.type ?? null,
5657
7306
  values: child.enum ?? (own3(child, "const") ? [child.const] : null)
5658
7307
  });
5659
- visit(child, [...path, "properties", key3]);
7308
+ visit2(child, [...path, "properties", key3]);
5660
7309
  }
5661
- for (const [key3, child] of Object.entries(schema.$defs ?? {})) visit(child, [...path, "$defs", key3]);
7310
+ for (const [key3, child] of Object.entries(schema.$defs ?? {})) visit2(child, [...path, "$defs", key3]);
5662
7311
  for (const keyword of ["oneOf", "anyOf", "allOf"]) {
5663
7312
  const members = schema[keyword] ?? [];
5664
- for (let index = 0; index < members.length; index++) visit(members[index], [...path, keyword, String(index)]);
7313
+ for (let index = 0; index < members.length; index++) visit2(members[index], [...path, keyword, String(index)]);
5665
7314
  }
5666
- if (schema.items) visit(schema.items, [...path, "items"]);
5667
- if (typeof schema.additionalProperties === "object") visit(schema.additionalProperties, [...path, "additionalProperties"]);
5668
- for (const [key3, child] of Object.entries(schema.patternProperties ?? {})) visit(child, [...path, "patternProperties", key3]);
7315
+ if (schema.items) visit2(schema.items, [...path, "items"]);
7316
+ if (typeof schema.additionalProperties === "object") visit2(schema.additionalProperties, [...path, "additionalProperties"]);
7317
+ for (const [key3, child] of Object.entries(schema.patternProperties ?? {})) visit2(child, [...path, "patternProperties", key3]);
5669
7318
  };
5670
- visit(root, []);
7319
+ visit2(root, []);
5671
7320
  }
5672
7321
  return result;
5673
7322
  }
@@ -5911,9 +7560,9 @@ function applyTextEdits(text2, edits) {
5911
7560
  function rememberByText(read, size = 2) {
5912
7561
  const kept = [];
5913
7562
  return (text2) => {
5914
- const at2 = kept.findIndex((entry2) => entry2.text === text2);
5915
- if (at2 >= 0) {
5916
- const [entry2] = kept.splice(at2, 1);
7563
+ const at3 = kept.findIndex((entry2) => entry2.text === text2);
7564
+ if (at3 >= 0) {
7565
+ const [entry2] = kept.splice(at3, 1);
5917
7566
  kept.unshift(entry2);
5918
7567
  return entry2.value;
5919
7568
  }
@@ -6708,10 +8357,10 @@ var Analyzer = class {
6708
8357
  })();
6709
8358
  const hint = valueHint(path);
6710
8359
  const gap = this.text[colon.end] === " " || this.text[colon.end] === " " ? 0 : 1;
6711
- const at2 = colon.end + (gap === 0 ? 1 : 0);
6712
- const edits = [{ offset: at2, length: 0, insert: `${gap ? " " : ""}${hint.insert}` }];
6713
- if (needsComma) edits.push({ offset: at2, length: 0, insert: "," });
6714
- const fixes = [{ id: "add-value", title: hint.title, safe: false, edits, caret: at2 + (gap ? 1 : 0) + hint.caret }];
8360
+ const at3 = colon.end + (gap === 0 ? 1 : 0);
8361
+ const edits = [{ offset: at3, length: 0, insert: `${gap ? " " : ""}${hint.insert}` }];
8362
+ if (needsComma) edits.push({ offset: at3, length: 0, insert: "," });
8363
+ const fixes = [{ id: "add-value", title: hint.title, safe: false, edits, caret: at3 + (gap ? 1 : 0) + hint.caret }];
6715
8364
  fixes.push({ id: "remove-key", title: `Remove ${JSON.stringify(key3)}`, safe: false, edits: this.removeEntry(keyToken.start, colon.end) });
6716
8365
  this.structural({
6717
8366
  code: "missing-value",
@@ -6947,7 +8596,7 @@ function analyzeJsonSyntax(text2, options2 = {}) {
6947
8596
 
6948
8597
  // src/check-source.ts
6949
8598
  function parseSource(source) {
6950
- const errors = [], tree = parseTree(
8599
+ const errors = [], tree = parseTree2(
6951
8600
  source.startsWith("\uFEFF") ? " " + source.slice(1) : source,
6952
8601
  errors,
6953
8602
  {
@@ -6991,7 +8640,7 @@ function parseSource(source) {
6991
8640
  if (keys.has(key3.value))
6992
8641
  duplicates.push(
6993
8642
  finding("opf/duplicate-key", {
6994
- path: pointer4(getNodePath(key3)),
8643
+ path: pointer4(getNodePath2(key3)),
6995
8644
  message: `Duplicate JSON property ${JSON.stringify(key3.value)}.`,
6996
8645
  help: "Resolve the duplicate explicitly, preserving the intended content from both occurrences. JSON.parse would otherwise hide an earlier value.",
6997
8646
  location: location(key3.offset, key3.length)
@@ -7078,9 +8727,9 @@ function slideRef(finding2, helpers) {
7078
8727
  if (typeof layout === "string" && layout) return `Slide ${number} (layout ${code(layout)})`;
7079
8728
  return `Slide ${number}`;
7080
8729
  }
7081
- var lastName = (segments) => [...segments].reverse().find((segment) => !isIndex(segment));
8730
+ var lastName = (segments) => [...segments].reverse().find((segment2) => !isIndex(segment2));
7082
8731
  function dotted(segments) {
7083
- return segments.reduce((out, segment) => isIndex(segment) ? `${out}[${segment}]` : out ? `${out}.${segment}` : segment, "");
8732
+ return segments.reduce((out, segment2) => isIndex(segment2) ? `${out}[${segment2}]` : out ? `${out}.${segment2}` : segment2, "");
7084
8733
  }
7085
8734
  function keysAt(helpers, path) {
7086
8735
  const value = helpers.valueAt(path);
@@ -7116,7 +8765,7 @@ function chooseNext(value, candidates, alternative = "", max = 3) {
7116
8765
  return alternative ? sentence(alternative) : "choose a different value.";
7117
8766
  }
7118
8767
  function kindPhrase(kind) {
7119
- const phrases = { text: "text", code: "code", list: "a list", chart: "a chart", table: "a table", image: "an image", video: "a video", metric: "a metric", quote: "a quote", timeline: "a timeline", shape: "a shape", group: "a group" };
8768
+ const phrases = { text: "text", code: "code", list: "a list", chart: "a chart", table: "a table", image: "an image", video: "a video", embed: "an embed", metric: "a metric", quote: "a quote", timeline: "a timeline", shape: "a shape", group: "a group" };
7120
8769
  return phrases[kind] ?? `${/^[aeiou]/i.test(kind) ? "an" : "a"} ${kind}`;
7121
8770
  }
7122
8771
  function freshName(base, taken = []) {
@@ -7127,7 +8776,7 @@ function freshName(base, taken = []) {
7127
8776
  }
7128
8777
  return `${base}-2`;
7129
8778
  }
7130
- var BLOCK_KINDS = ["chart", "image", "video", "table", "code", "metric", "quote", "timeline", "diagram", "items", "bullets", "text"];
8779
+ var BLOCK_KINDS = ["chart", "image", "video", "embed", "table", "code", "metric", "quote", "timeline", "diagram", "items", "bullets", "text"];
7131
8780
  function blockKind(node) {
7132
8781
  if (!isRecord2(node)) return void 0;
7133
8782
  if (typeof node.type === "string" && node.type !== "group") return node.type;
@@ -7182,7 +8831,7 @@ var textOnImage = (finding2) => {
7182
8831
  if (best !== void 0)
7183
8832
  return {
7184
8833
  message: `This text is too faint on the picture: at most ${num(best, 1)}:1 over any part of it here${needed !== void 0 ? `, and ${num(needed)}:1 is needed` : ""}.`,
7185
- next: `set the background's ${code("tone")} so the text color follows the picture, or give the text a readable color.`
8834
+ next: `set the background's ${code("appearance")} so the text color follows the picture, or give the text a readable color.`
7186
8835
  };
7187
8836
  if (scrim !== void 0)
7188
8837
  return {
@@ -7304,10 +8953,10 @@ var missingLanguage = (_finding, context, helpers) => ({
7304
8953
  next: (context.format ?? helpers.format) === "json" ? `add ${code('"language": "en-US"')} (or the language the text is written in) to the deck.` : `add ${code("language: en-US")} (or the language the text is written in) to the deck.`
7305
8954
  });
7306
8955
  var chartOptionAdapted = (finding2, _context, helpers) => {
7307
- const at2 = helpers.segments.indexOf("chart");
7308
- const option = at2 >= 0 ? helpers.segments.slice(at2 + 1).join(".") : lastName(helpers.segments) ?? "";
8956
+ const at3 = helpers.segments.indexOf("chart");
8957
+ const option = at3 >= 0 ? helpers.segments.slice(at3 + 1).join(".") : lastName(helpers.segments) ?? "";
7309
8958
  if (!option) return void 0;
7310
- const type = at2 >= 0 ? helpers.valueAt([...helpers.segments.slice(0, at2 + 1), "type"]) : void 0;
8959
+ const type = at3 >= 0 ? helpers.valueAt([...helpers.segments.slice(0, at3 + 1), "type"]) : void 0;
7311
8960
  const typeName = typeof type === "string" ? type : match(finding2.message, /^A '(.+?)' chart/)?.[1];
7312
8961
  const adaptation = finding2.message.includes(";") ? cap(finding2.message.slice(finding2.message.indexOf(";") + 1).trim()) : "";
7313
8962
  return {
@@ -7334,7 +8983,7 @@ var layoutFailed = (finding2, _context, helpers) => {
7334
8983
  next: "fix the composition setting or content named above."
7335
8984
  };
7336
8985
  };
7337
- var minFontSize = (finding2) => {
8986
+ var minFontSizePx = (finding2) => {
7338
8987
  const size = measuredNumber(finding2, "sizePt");
7339
8988
  const minimum = measuredNumber(finding2, "minimumPt");
7340
8989
  if (size === void 0 || minimum === void 0) return void 0;
@@ -7350,8 +8999,8 @@ function regionNamesOf(slideLayout, helpers) {
7350
8999
  const colon = slideLayout.indexOf(":");
7351
9000
  const group = colon > 0 ? slideLayout.slice(0, colon) : void 0;
7352
9001
  const id = colon > 0 ? slideLayout.slice(colon + 1) : slideLayout;
7353
- const record = (group ? [group] : ["custom", "default"]).map((name) => helpers.valueAt(["catalogs", name, "layouts", id])).find(isRecord2);
7354
- if (!record) return void 0;
9002
+ const record2 = (group ? [group] : ["custom", "default"]).map((name) => helpers.valueAt(["catalogs", name, "layouts", id])).find(isRecord2);
9003
+ if (!record2) return void 0;
7355
9004
  const names2 = [];
7356
9005
  const walk2 = (list) => {
7357
9006
  if (!Array.isArray(list)) return;
@@ -7361,7 +9010,7 @@ function regionNamesOf(slideLayout, helpers) {
7361
9010
  walk2(entry2.regions);
7362
9011
  }
7363
9012
  };
7364
- walk2(record.regions);
9013
+ walk2(record2.regions);
7365
9014
  return { id: slideLayout, names: names2 };
7366
9015
  }
7367
9016
  var regionUnknown = (finding2, _context, helpers) => {
@@ -7430,9 +9079,9 @@ var regionFull = (finding2) => {
7430
9079
  var layoutUnplaced = (finding2, _context, helpers) => {
7431
9080
  const kind = blockKind(helpers.valueAt(helpers.segments));
7432
9081
  const what = kind ? `this ${kind} block` : "this block";
7433
- const overflow = match(finding2.message, /drawn in '(.+?)' beyond its (\d+) block/);
9082
+ const overflow2 = match(finding2.message, /drawn in '(.+?)' beyond its (\d+) block/);
7434
9083
  return {
7435
- message: overflow ? `No region has room for ${what}; it is drawn in ${code(overflow[1])}, beyond its ${overflow[2]} block${overflow[2] === "1" ? "" : "s"}.` : `No region has room for ${what}; it is drawn in the overflow area.`,
9084
+ message: overflow2 ? `No region has room for ${what}; it is drawn in ${code(overflow2[1])}, beyond its ${overflow2[2]} block${overflow2[2] === "1" ? "" : "s"}.` : `No region has room for ${what}; it is drawn in the overflow area.`,
7436
9085
  next: "paginate the slide, choose a layout with more room, or remove a block."
7437
9086
  };
7438
9087
  };
@@ -7481,6 +9130,27 @@ var textShrunk2 = (finding2) => {
7481
9130
  next: `split it with ${code("opf paginate")}, move detail to the speaker notes, or shorten the text.`
7482
9131
  };
7483
9132
  };
9133
+ var variableOverflow2 = (finding2) => {
9134
+ const id = match(finding2.message, /^'([a-z][a-z0-9-]*)'/)?.[1];
9135
+ if (!id) return void 0;
9136
+ const lines = measuredNumber(finding2, "lines");
9137
+ const maxLines = measuredNumber(finding2, "maxLines");
9138
+ if (lines !== void 0 && maxLines !== void 0) {
9139
+ return {
9140
+ message: `Variable ${code(id)} takes ${lines} lines${onSlide(finding2)}, over its ${code("maxLines")} of ${maxLines}.`,
9141
+ next: `shorten the value, draw it in a wider place, or raise ${code("maxLines")} if the slide has the room.`
9142
+ };
9143
+ }
9144
+ const characters = measuredNumber(finding2, "characters");
9145
+ const maxLength = measuredNumber(finding2, "maxLength");
9146
+ if (characters !== void 0 && maxLength !== void 0) {
9147
+ return { message: `Variable ${code(id)} has ${characters} characters, over its ${code("maxLength")} of ${maxLength}.`, next: `shorten the value to ${maxLength} characters or fewer, or raise ${code("maxLength")}.` };
9148
+ }
9149
+ const items = measuredNumber(finding2, "items");
9150
+ const maxItems = measuredNumber(finding2, "maxItems");
9151
+ if (items === void 0 || maxItems === void 0) return void 0;
9152
+ return { message: `Variable ${code(id)} has ${items} items, over its ${code("maxItems")} of ${maxItems}.`, next: `give it ${maxItems} items or fewer, or raise ${code("maxItems")}.` };
9153
+ };
7484
9154
  var centeredBody2 = (finding2) => {
7485
9155
  const lines = measuredNumber(finding2, "lines");
7486
9156
  const characters = measuredNumber(finding2, "characters");
@@ -7522,17 +9192,6 @@ var layoutMonotony2 = (finding2) => {
7522
9192
  next: "give some of them the layout their content asks for (a comparison, a chart, a statement, a picture), or merge or split slides."
7523
9193
  };
7524
9194
  };
7525
- var straightQuotes2 = (finding2) => {
7526
- const open = measuredText(finding2, "open");
7527
- const close = measuredText(finding2, "close");
7528
- const text2 = unquote(match(finding2.message, /: ("(?:[^"\\]|\\.)*")\.$/)?.[1]);
7529
- if (!open || !close) return void 0;
7530
- const fix = finding2.fixes?.find((entry2) => entry2.id === "use-typographic-quotes");
7531
- return {
7532
- message: `${text2 ? `${code(brief(text2, 50))} uses` : "This text uses"} straight quotation marks; this deck's language uses ${open}\u2026${close}.`,
7533
- next: fix ? `apply the quick fix, or type ${open} and ${close} instead.` : `type ${open} and ${close} instead, and the matching single marks.`
7534
- };
7535
- };
7536
9195
  var chartDualAxis2 = (finding2) => {
7537
9196
  const names2 = match(finding2.message, /^The combo chart plots (.+) on a second value axis/)?.[1];
7538
9197
  return {
@@ -7554,10 +9213,45 @@ var chartValueNotNumeric = (finding2) => {
7554
9213
  const fix = finding2.fixes?.find((entry2) => entry2.id === "store-chart-numbers");
7555
9214
  if (!value) return void 0;
7556
9215
  return {
7557
- message: `${code(value)} is text, so it is plotted as a gap.`,
7558
- next: fix ? `${sentence((fix.title.charAt(0).toLowerCase() + fix.title.slice(1)).replace(/\.$/, ""))}` : `write a number (12, -3.5, 1e6) and put units, currency or percent in the column ${code("format")}.`
9216
+ message: `${code(value)} is text, so it is plotted as a gap.`,
9217
+ next: fix ? `${sentence((fix.title.charAt(0).toLowerCase() + fix.title.slice(1)).replace(/\.$/, ""))}` : `write a number (12, -3.5, 1e6) and put units, currency or percent in the column ${code("format")}.`
9218
+ };
9219
+ };
9220
+ var dataCellType = (finding2) => {
9221
+ const fix = finding2.fixes?.find((entry2) => entry2.id === "store-cell-type");
9222
+ return {
9223
+ message: keep(cap(finding2.message)),
9224
+ next: fix ? `${sentence((fix.title.charAt(0).toLowerCase() + fix.title.slice(1)).replace(/\.$/, ""))}, or change the column's ${code("type")} to what it holds.` : `write the cell as the column declares, or change the column's ${code("type")} to what it holds.`
7559
9225
  };
7560
9226
  };
9227
+ var datasourceCredentials = (finding2) => ({
9228
+ message: keep(cap(finding2.message)),
9229
+ next: "remove the credential from the data source and keep the secret in your own store; name the connection in `connector` or `extensions`."
9230
+ });
9231
+ var datasetStale = (finding2) => ({
9232
+ message: keep(cap(finding2.message)),
9233
+ next: "take the data from its data source again and update `retrieved`, or change the data source's `refreshEvery`."
9234
+ });
9235
+ var metricDataStale = (finding2) => ({
9236
+ message: keep(cap(finding2.message)),
9237
+ next: "apply the fix, which writes the computed number; or change the data link to compute what the slide says."
9238
+ });
9239
+ var metricDataAggregate = (finding2) => ({
9240
+ message: keep(cap(finding2.message)),
9241
+ next: "use first, last or count, which fit any column, or link a column typed number."
9242
+ });
9243
+ var metricDataEmpty = (finding2) => ({
9244
+ message: keep(cap(finding2.message)),
9245
+ next: "check the filter and the field: a row has to meet the filter and give a usable cell."
9246
+ });
9247
+ var metricDataDelta = (finding2) => ({
9248
+ message: keep(cap(finding2.message)),
9249
+ next: "give the change something to compare with, or write the change in a column and use `field`."
9250
+ });
9251
+ var metricUnitRepeated = (finding2) => ({
9252
+ message: keep(cap(finding2.message)),
9253
+ next: "drop the unit, or take its text out of the number format."
9254
+ });
7561
9255
  var chartMappingAdapted = (finding2) => ({
7562
9256
  message: keep(cap(finding2.message)),
7563
9257
  next: "remove that mapping entry, or name a different column."
@@ -7566,6 +9260,13 @@ var chartSeriesDropped = (finding2) => ({
7566
9260
  message: keep(cap(finding2.message)),
7567
9261
  next: "use a chart type that plots every series, or one chart per series."
7568
9262
  });
9263
+ var embedCredentials = (finding2) => {
9264
+ const part2 = match(finding2.message, /carries what looks like a credential \((.+?)\)\./)?.[1];
9265
+ return {
9266
+ message: `This embed's address carries what looks like a credential${part2 ? ` (${part2})` : ""}, and anyone with the deck can read it.`,
9267
+ next: "take the credential out of `src`: the host that shows the page holds it."
9268
+ };
9269
+ };
7569
9270
  var chartHighlightAdapted = (finding2) => {
7570
9271
  const name = unquote(match(finding2.message, /^highlight names \w+ ("(?:[^"\\]|\\.)*"), which is not plotted as a series/)?.[1]);
7571
9272
  if (!name) return void 0;
@@ -7574,6 +9275,30 @@ var chartHighlightAdapted = (finding2) => {
7574
9275
  next: "name a series the chart plots, or remove the entry."
7575
9276
  };
7576
9277
  };
9278
+ var chartBandsOrder = (finding2) => finding2.message.startsWith("The bands are not in increasing order") ? {
9279
+ message: "The bands are not in increasing order of their `to` values, so they are drawn sorted.",
9280
+ next: "write each band's `to` above the previous one."
9281
+ } : void 0;
9282
+ var chartBandsUnsupported = (finding2) => finding2.message.startsWith("This chart type does not draw bands") ? {
9283
+ message: "This chart type does not draw bands, so they are ignored.",
9284
+ next: "use a bar, column, line, area or bullet chart, or remove the bands."
9285
+ } : void 0;
9286
+ var metricGaugeRange = (finding2) => finding2.message.startsWith("The gauge's") ? {
9287
+ message: finding2.message,
9288
+ next: "write the gauge's max above its min, and keep the value, the target and the bands between them."
9289
+ } : void 0;
9290
+ var metricGaugeValue = (finding2) => finding2.message.startsWith("A gauge needs a number") ? {
9291
+ message: "A gauge needs a number, and this metric's value is text, so it is drawn without its gauge.",
9292
+ next: "give the metric a number value, or remove the gauge."
9293
+ } : void 0;
9294
+ var tableColorScaleNoData = (finding2) => finding2.message.startsWith("The color scale's columns hold no numbers") ? {
9295
+ message: "None of the color scale's columns holds a number, so no cell is shaded.",
9296
+ next: "name columns that hold numbers, or remove the color scale."
9297
+ } : void 0;
9298
+ var tableColorScaleRange = (finding2) => finding2.message.startsWith("The color scale's range is empty") ? {
9299
+ message: "The color scale's range is empty or its center is outside it, so part of the scale is unused.",
9300
+ next: "pin min below max and keep center between them, or leave the range to the data."
9301
+ } : void 0;
7577
9302
  var codeHighlightOutOfRange = (finding2) => {
7578
9303
  const found = match(finding2.message, /line (\d+) is past the last line \(the code has (\d+) lines?\)/);
7579
9304
  if (!found) return void 0;
@@ -7693,7 +9418,7 @@ var AUDIT_TEXT = {
7693
9418
  "opf/text-overflow": textOverflow,
7694
9419
  "opf/unresolved-content": unresolvedContent,
7695
9420
  "opf/layout-failed": layoutFailed,
7696
- "opf/min-font-size": minFontSize,
9421
+ "opf/min-font-size": minFontSizePx,
7697
9422
  "opf/region-unknown": regionUnknown,
7698
9423
  "opf/region-kind": regionKind,
7699
9424
  "opf/region-full": regionFull,
@@ -7708,8 +9433,23 @@ var AUDIT_TEXT = {
7708
9433
  "opf/image-resolution": imageResolution,
7709
9434
  "opf/chart-value-not-numeric": chartValueNotNumeric,
7710
9435
  "opf/chart-mapping-adapted": chartMappingAdapted,
9436
+ "opf/data-cell-type": dataCellType,
9437
+ "opf/datasource-credentials": datasourceCredentials,
9438
+ "opf/dataset-stale": datasetStale,
9439
+ "opf/metric-data-stale": metricDataStale,
9440
+ "opf/metric-data-aggregate": metricDataAggregate,
9441
+ "opf/metric-data-empty": metricDataEmpty,
9442
+ "opf/metric-data-delta": metricDataDelta,
9443
+ "opf/metric-unit-repeated": metricUnitRepeated,
7711
9444
  "opf/chart-highlight-adapted": chartHighlightAdapted,
9445
+ "opf/table-color-scale-no-data": tableColorScaleNoData,
9446
+ "opf/table-color-scale-range": tableColorScaleRange,
7712
9447
  "opf/chart-series-dropped": chartSeriesDropped,
9448
+ "opf/embed-credentials": embedCredentials,
9449
+ "opf/chart-bands-order": chartBandsOrder,
9450
+ "opf/chart-bands-unsupported": chartBandsUnsupported,
9451
+ "opf/metric-gauge-range": metricGaugeRange,
9452
+ "opf/metric-gauge-value": metricGaugeValue,
7713
9453
  "opf/code-highlight-out-of-range": codeHighlightOutOfRange,
7714
9454
  "opf/code-highlight-range-reversed": codeHighlightRangeReversed,
7715
9455
  "opf/variable-builtin-missing": variableBuiltinMissing,
@@ -7722,10 +9462,10 @@ var AUDIT_TEXT = {
7722
9462
  "opf/empty-slide": emptySlide,
7723
9463
  "opf/language-tag": languageTag,
7724
9464
  "opf/text-shrunk": textShrunk2,
9465
+ "opf/variable-overflow": variableOverflow2,
7725
9466
  "opf/centered-body": centeredBody2,
7726
9467
  "opf/tight-spacing": tightSpacing2,
7727
9468
  "opf/layout-monotony": layoutMonotony2,
7728
- "opf/straight-quotes": straightQuotes2,
7729
9469
  "opf/chart-dual-axis": chartDualAxis2,
7730
9470
  "opf/chart-pie-many-slices": chartPieManySlices2
7731
9471
  };
@@ -7769,6 +9509,15 @@ var citeUnknownReference = (finding2, _context, helpers) => {
7769
9509
  next: chooseNext(id, ids, add)
7770
9510
  };
7771
9511
  };
9512
+ var slideLinkUnknown = (finding2, _context, helpers) => {
9513
+ const id = text(params(finding2).id) ?? unquote(match(finding2.message, /^unknown slide '(.+?)'/)?.[1]);
9514
+ const ids = idsAt(helpers, ["slides"]);
9515
+ const add = `give a slide the id ${code(id)}`;
9516
+ return {
9517
+ message: `${code(`link: "slide:${id}"`)} names a slide the document does not have.`,
9518
+ next: ids.length ? chooseNext(id, ids, add) : `${add} (assignIds gives every slide one), or link to another target.`
9519
+ };
9520
+ };
7772
9521
  var citeUnsupportedLocation = (finding2) => {
7773
9522
  const where = match(finding2.message, /^cite and footnote are not supported in ([^;]+);/)?.[1];
7774
9523
  const inReferences = /^reference text cannot cite/.test(finding2.message);
@@ -7784,8 +9533,8 @@ var captionUnsupportedPayload = (finding2) => {
7784
9533
  const kind = type ?? (/a group cannot carry one/.test(finding2.message) ? "group" : void 0);
7785
9534
  const is = kind ? kindPhrase(kind) : "not one of those";
7786
9535
  return {
7787
- message: `A ${code("caption")} belongs to one image, chart, table, video or diagram; this block is ${is}.`,
7788
- next: `put the ${code("caption")} on the image, chart, table, video or diagram it describes, or remove it.`
9536
+ message: `A ${code("caption")} belongs to one image, chart, table, video, embed or diagram; this block is ${is}.`,
9537
+ next: `put the ${code("caption")} on the image, chart, table, video, embed or diagram it describes, or remove it.`
7789
9538
  };
7790
9539
  };
7791
9540
  var imageOptionUnsupportedPayload = (finding2) => {
@@ -7884,8 +9633,13 @@ var layoutPlaceholderGroup = (finding2) => {
7884
9633
  };
7885
9634
  };
7886
9635
  function datasetOf(helpers) {
7887
- const at2 = helpers.segments.findIndex((segment) => segment === "fields" || segment === "columns" || segment === "mapping" || segment === "highlight");
7888
- const parent = at2 > 0 ? helpers.segments.slice(0, at2) : helpers.segments.slice(0, -1);
9636
+ const link = helpers.segments.lastIndexOf("data");
9637
+ if (link > 0 && helpers.segments[link - 1] === "metric") {
9638
+ const value = helpers.valueAt([...helpers.segments.slice(0, link + 1), "dataset"]);
9639
+ if (isText2(value)) return value;
9640
+ }
9641
+ const at3 = helpers.segments.findIndex((segment2) => segment2 === "fields" || segment2 === "columns" || segment2 === "mapping" || segment2 === "highlight");
9642
+ const parent = at3 > 0 ? helpers.segments.slice(0, at3) : helpers.segments.slice(0, -1);
7889
9643
  for (const candidate of [parent, [...parent, "data"]]) {
7890
9644
  const value = helpers.valueAt([...candidate, "dataset"]);
7891
9645
  if (isText2(value)) return value;
@@ -7902,6 +9656,16 @@ var datasetUnknown = (finding2, _context, helpers) => {
7902
9656
  next: chooseNext(id, ids, `add ${code(`datasets.${id}`)}`)
7903
9657
  };
7904
9658
  };
9659
+ var datasourceUnknown = (finding2, _context, helpers) => {
9660
+ const id = unquote(match(finding2.message, /^unknown data source '(.+?)'/)?.[1]) || String(helpers.valueAt(helpers.segments) ?? "");
9661
+ if (!id) return void 0;
9662
+ const ids = keysAt(helpers, ["datasources"]);
9663
+ const here = ids.length ? `Data sources in this deck: ${plainList(ids)}.` : "This deck has no data sources.";
9664
+ return {
9665
+ message: `${code(`datasource: "${id}"`)} does not exist. ${here}`,
9666
+ next: chooseNext(id, ids, `add ${code(`datasources.${id}`)}, or write the data source inline as an object such as ${code('{ "src": "./data.csv" }')}`)
9667
+ };
9668
+ };
7905
9669
  var datasetFieldUnknown = (finding2, _context, helpers) => {
7906
9670
  const found = match(finding2.message, /^field ("(?:[^"\\]|\\.)*") is not a column of the dataset; use one of (.+)$/);
7907
9671
  if (!found) return void 0;
@@ -7981,6 +9745,16 @@ var tableHighlightUnknownName = (finding2) => {
7981
9745
  next: keys.length ? chooseNext(name, keys) : "name a row by the text of its first cell, or remove the entry."
7982
9746
  };
7983
9747
  };
9748
+ var tableColorScaleUnknownColumn = (finding2) => {
9749
+ const column = match(finding2.message, /^The color scale names ("(?:[^"\\]|\\.)*"), which is no column of this table\. Columns: (.+)\.$/);
9750
+ if (!column) return void 0;
9751
+ const name = unquote(column[1]);
9752
+ const columns = column[2] === "none" ? [] : unquoteList(column[2]);
9753
+ return {
9754
+ message: `${code(`colorScale.columns: "${name}"`)} matches no column.${columns.length ? ` Available: ${plainList(columns)}.` : ""}`,
9755
+ next: columns.length ? chooseNext(name, columns) : "give the table a header row, or remove the color scale."
9756
+ };
9757
+ };
7984
9758
  var tokenOf = (finding2, id) => finding2.message.includes(`var:${id}`) ? code(`var:${id}`) : code(`{{${id}}}`);
7985
9759
  var SAMPLE_BY_KIND = {
7986
9760
  number: "a plain number such as 42",
@@ -8076,6 +9850,17 @@ var variableUnused = (finding2, _context, helpers) => {
8076
9850
  next: `use it as ${code(`{{${id}}}`)} or ${code(`var:${id}`)} where it belongs, or remove its declaration.`
8077
9851
  };
8078
9852
  };
9853
+ var variableTranslationDuplicate = (finding2, _context, helpers) => {
9854
+ const id = text(params(finding2).id) ?? helpers.segments.at(-2);
9855
+ if (!id) return void 0;
9856
+ return { message: `Variable ${code(id)} has two translations whose language tags differ only in case.`, next: "remove one of the two keys: the first in the document is the one that is drawn." };
9857
+ };
9858
+ var variableTranslationUnused = (finding2, _context, helpers) => {
9859
+ const id = text(params(finding2).id) ?? helpers.segments.at(-3);
9860
+ const tag = helpers.segments.at(-1);
9861
+ if (!id || !tag) return void 0;
9862
+ return { message: `The ${code(tag)} translation of ${code(id)} is never drawn: no slide and not the deck declares a language that selects it.`, next: `set ${code("language")} on the deck or on a slide, fix the tag, or remove the translation.` };
9863
+ };
8079
9864
  var variableReferenceUnknown = (finding2, _context, helpers) => {
8080
9865
  const id = text(params(finding2).id) ?? match(finding2.message, /^unknown variable '(.+?)'/)?.[1];
8081
9866
  if (!id) return void 0;
@@ -8153,9 +9938,9 @@ var catalogRecord = (finding2, context) => {
8153
9938
  if (root !== "catalogs" || !kind || !id) return void 0;
8154
9939
  const inner = describeFinding({ ...finding2, ruleId: "opf/schema" }, context);
8155
9940
  const registered = finding2.scope === "context";
8156
- const record = `${registered ? "The registered" : "The embedded"} ${KIND_SINGULAR2(kind)} ${code(id)}`;
9941
+ const record2 = `${registered ? "The registered" : "The embedded"} ${KIND_SINGULAR2(kind)} ${code(id)}`;
8157
9942
  return {
8158
- message: `${record} is invalid: ${inner.message.charAt(0).toLowerCase()}${inner.message.slice(1)}`,
9943
+ message: `${record2} is invalid: ${inner.message.charAt(0).toLowerCase()}${inner.message.slice(1)}`,
8159
9944
  next: inner.next ?? `fix the record; references to it are reported too.`
8160
9945
  };
8161
9946
  };
@@ -8342,6 +10127,7 @@ var FORMAT_TEXT = {
8342
10127
  "opf/schema": schemaPlain,
8343
10128
  "opf/reference-id-duplicate": referenceIdDuplicate,
8344
10129
  "opf/cite-unknown-reference": citeUnknownReference,
10130
+ "opf/slide-link-unknown": slideLinkUnknown,
8345
10131
  "opf/cite-unsupported-location": citeUnsupportedLocation,
8346
10132
  "opf/caption-unsupported-payload": captionUnsupportedPayload,
8347
10133
  "opf/image-option-unsupported-payload": imageOptionUnsupportedPayload,
@@ -8356,6 +10142,7 @@ var FORMAT_TEXT = {
8356
10142
  "opf/connector-end-missing": connectorEndMissing,
8357
10143
  "opf/layout-placeholder-group": layoutPlaceholderGroup,
8358
10144
  "opf/dataset-unknown": datasetUnknown,
10145
+ "opf/datasource-unknown": datasourceUnknown,
8359
10146
  "opf/dataset-field-unknown": datasetFieldUnknown,
8360
10147
  "opf/data-column-duplicate": dataColumnDuplicate,
8361
10148
  "opf/chart-mapping-unknown-column": chartMappingUnknownColumn,
@@ -8366,6 +10153,7 @@ var FORMAT_TEXT = {
8366
10153
  "opf/variable-unknown-builtin": variableUnknownBuiltin,
8367
10154
  "opf/chart-highlight-unknown-name": chartHighlightUnknownName,
8368
10155
  "opf/table-highlight-unknown-name": tableHighlightUnknownName,
10156
+ "opf/table-color-scale-unknown-column": tableColorScaleUnknownColumn,
8369
10157
  "opf/variable-format": variableFormat,
8370
10158
  "opf/variable-unfilled": variableUnfilled,
8371
10159
  "opf/run-color-unrecognized": runColorUnrecognized,
@@ -8388,6 +10176,8 @@ var FORMAT_TEXT = {
8388
10176
  "opf/variable-unknown": variableUnknown,
8389
10177
  "opf/variable-unknown-value": variableUnknownValue,
8390
10178
  "opf/variable-unused": variableUnused,
10179
+ "opf/variable-translation-duplicate": variableTranslationDuplicate,
10180
+ "opf/variable-translation-unused": variableTranslationUnused,
8391
10181
  "opf/variable-reference-unknown": variableReferenceUnknown,
8392
10182
  "opf/contract": contract
8393
10183
  };
@@ -8587,9 +10377,12 @@ var PATTERN_PHRASES = Object.freeze({
8587
10377
  "^\\s*-?[0-9.]+([ ,]+-?[0-9.]+){3}\\s*$": { what: "a viewBox of four numbers, `minX minY width height`, like `0 0 24 24`", next: "write four numbers separated by spaces." },
8588
10378
  "^[a-z][A-Za-z0-9]*$": { what: "an adjust value name like `adj` or `adj1` (a letter, then letters and digits)", next: "use the name of one of the preset's adjust values (docs/shapes.md lists them)." },
8589
10379
  "^\\d{4}-\\d{2}-\\d{2}$": { what: "a date written year-month-day, like `2026-10-24`", next: "write the date as YYYY-MM-DD." },
8590
- "^(?:https?://|mailto:|tel:)\\S+$": { what: "a web, email or phone address (`https://\u2026`, `mailto:\u2026` or `tel:\u2026`)", next: "start with https://, mailto: or tel:, and leave out spaces." },
8591
10380
  "^(https?://|mailto:|tel:)\\S+$": { what: "a web, email or phone address (`https://\u2026`, `mailto:\u2026` or `tel:\u2026`)", next: "start with https://, mailto: or tel:, and leave out spaces." },
10381
+ "^P(?=\\d|T\\d)(?:\\d+Y)?(?:\\d+M)?(?:\\d+W)?(?:\\d+D)?(?:T(?=\\d)(?:\\d+H)?(?:\\d+M)?(?:\\d+(?:\\.\\d+)?S)?)?$": { what: "an ISO 8601 duration like `P1D` (a day), `P1W`, `P3M` or `PT6H`", next: "write `P`, then the amount and a unit letter (Y, M, W, D), and after a `T` any hours, minutes or seconds." },
10382
+ "^(?:https?://|mailto:|tel:)\\S+$": { what: "a web, email or phone address (`https://\u2026`, `mailto:\u2026` or `tel:\u2026`)", next: "start with https://, mailto: or tel:, and leave out spaces." },
10383
+ "^(https?://|mailto:|tel:|slide:)\\S+$": { what: "a web, email or phone address (`https://\u2026`, `mailto:\u2026` or `tel:\u2026`) or a slide of this deck (`slide:pricing`)", next: "start with https://, mailto:, tel: or slide:, and leave out spaces." },
8592
10384
  "^(?:[a-z][a-z0-9-]*:[a-z0-9][a-z0-9-]*|[a-z][a-z0-9-]*|(?:asset:|https://|data:|\\./|\\.\\./)\\S+)$": { what: "an icon like `lucide:truck` (a set and a name), the name of one of the deck's `icons`, or an SVG source (`asset:`, `https://`, `data:`, `./`)", next: "write the set and the icon name, such as lucide:truck (search_icons finds names), or the name of one of the deck's icons." },
10385
+ "^https://[^\\s/?#]+[^\\s]*$": { what: "an `https://` address of a web page, without spaces", next: "write the page's address starting with https://; http:, relative paths and other schemes are not embedded." },
8593
10386
  "^(asset:|https://|data:|\\./|\\.\\./)": { what: "a source that starts with `asset:`, `https://`, `data:`, `./` or `../`", next: "register the file under `assets` and write `asset:` and its id, or give an https:// address." },
8594
10387
  "^(?:https://[^\\s]+|pkg:[^\\s]+)$": { what: "an `https://` address or a `pkg:` reference", next: "write an address that starts with https:// or pkg:, without spaces." },
8595
10388
  "^(?:[A-Za-z]{2,3}|[iIxX])(?:-[A-Za-z0-9]{1,8})*$": { what: LANGUAGE, next: "write a language and, if needed, a region: `en-US`, `pt-BR`, `de`." },
@@ -8622,16 +10415,16 @@ function schemaKeys(segments, context) {
8622
10415
  if (context.keysOf) return context.keysOf(segments);
8623
10416
  return attempt(() => [...new Set(schemaVariants(schemaAtPath(context.document, segments)).flatMap((variant) => Object.keys(variant.properties ?? {})))], []);
8624
10417
  }
8625
- function starterText(schema, property, format) {
10418
+ function starterText(schema, property, format2) {
8626
10419
  const example = schema?.examples?.find((value) => typeof value === "string" && !value.includes("..."));
8627
10420
  const type = Array.isArray(schema?.type) ? schema?.type[0] : schema?.type;
8628
- if (example !== void 0) return format === "json" ? JSON.stringify(example) : String(example);
10421
+ if (example !== void 0) return format2 === "json" ? JSON.stringify(example) : String(example);
8629
10422
  if (type === "object") return "{ \u2026 }";
8630
10423
  if (type === "array") return "[ \u2026 ]";
8631
10424
  if (type === "number" || type === "integer") return "0";
8632
10425
  if (type === "boolean") return "false";
8633
- if (property === "id") return format === "json" ? '"acme"' : "acme";
8634
- return format === "json" ? '"\u2026"' : "\u2026";
10426
+ if (property === "id") return format2 === "json" ? '"acme"' : "acme";
10427
+ return format2 === "json" ? '"\u2026"' : "\u2026";
8635
10428
  }
8636
10429
  function describeSchema(finding2, context, helpers) {
8637
10430
  const { keyword, params: params2 = {}, alternatives } = finding2.validation ?? { keyword: "" };
@@ -8639,7 +10432,7 @@ function describeSchema(finding2, context, helpers) {
8639
10432
  const label = fieldLabel(segments);
8640
10433
  const actual = helpers.valueAt(segments);
8641
10434
  const chord = helpers.chord;
8642
- const format = helpers.format;
10435
+ const format2 = helpers.format;
8643
10436
  switch (keyword) {
8644
10437
  case "required": {
8645
10438
  const property = String(params2.missingProperty ?? "");
@@ -8647,7 +10440,7 @@ function describeSchema(finding2, context, helpers) {
8647
10440
  const shape = property === "data" ? chartShapeHelp(actual) : void 0;
8648
10441
  if (shape) return { message: shape.message, next: shape.next };
8649
10442
  const schema = context.schemaAt ? context.schemaAt([...segments, property]) : attempt(() => schemaAtPath(context.document, [...segments, property]), void 0);
8650
- if (format === "json") {
10443
+ if (format2 === "json") {
8651
10444
  const sample2 = property === "slides" ? '[ { "title": "\u2026" } ]' : starterText(schema, property, "json");
8652
10445
  return { message: `${cap(where)} is missing ${code(property)}.`, next: `add "${property}": ${sample2}.` };
8653
10446
  }
@@ -8865,417 +10658,173 @@ function schemaFixes(finding2, document) {
8865
10658
  function listColumnsChangeDrawing(region) {
8866
10659
  if (!isRecord2(region) || region.listColumns !== "auto") return true;
8867
10660
  const accepts = Array.isArray(region.accepts) ? region.accepts : [];
8868
- const arrangement = region.arrangement ?? region.sequence;
8869
- return !(accepts[0] === "list" && (arrangement === void 0 || arrangement === "numbered"));
8870
- }
8871
- var REMOVED_LIST_COLUMNS = `OPF 0.35 removed the region key listColumns. Delete it: a list of more than 6 entries flows into up to three columns in any region without an arrangement (or with the numbered one) when that sets it at least as large as one column; a list payload's own columns (1, 2, 3 or "auto") still chooses.`;
8872
- function removedKeyRepair(finding2, document, options2) {
8873
- const validation = finding2.validation;
8874
- if (!validation || finding2.ruleId !== "opf/schema" && finding2.ruleId !== "opf/catalog-record") return void 0;
8875
- const segments = segmentsOf(finding2.path);
8876
- if (validation.keyword === "additionalProperties" && segments.length === 3 && segments[0] === "slides" && readAt(document, segments) !== void 0 && nearestGridCell(segments[2]) !== void 0) return cellKeyRepair(document, segments.slice(0, 2), segments[2], options2);
8877
- const inRegion = segments.at(-3) === "regions";
8878
- if (validation.keyword === "additionalProperties" && inRegion && (segments.at(-1) === "sequence" || segments.at(-1) === "pyramidDirection")) {
8879
- const parent = segments.slice(0, -1), region = readAt(document, parent), value = readAt(document, segments);
8880
- if (!isRecord2(region) || value === void 0) return void 0;
8881
- const arrangement = region.arrangement;
8882
- if (segments.at(-1) === "sequence") {
8883
- const help2 = `OPF 0.35 replaced the region key sequence with arrangement: a region has one arrangement, a sequence ("steps" or "numbered") or a diagram. Write "arrangement": ${JSON.stringify(value)} in its place.`;
8884
- if (arrangement !== void 0 || value !== "steps" && value !== "numbered") return { help: `${help2}${arrangement !== void 0 ? ` This region also has "arrangement": ${JSON.stringify(arrangement)}; keep one of the two.` : ""}`, fixes: [] };
8885
- return { help: help2, fixes: [patch("use-arrangement", `Write arrangement ${value}`, [{ op: "move", from: finding2.path, path: pointerOf([...parent, "arrangement"]) }], true)] };
8886
- }
8887
- const help = 'OPF 0.35 removed the region key pyramidDirection: "arrangement": "inverted-pyramid" draws the pyramid upside down (what "down" did), and "arrangement": "pyramid" draws it upright ("up", the default).';
8888
- if (arrangement !== "pyramid") return { help, fixes: [] };
8889
- if (value === "down") return { help, fixes: [patch("use-inverted-pyramid", "Write arrangement inverted-pyramid", [{ op: "remove", path: finding2.path }, { op: "replace", path: pointerOf([...parent, "arrangement"]), value: "inverted-pyramid" }], true)] };
8890
- if (value === "up") return { help, fixes: [patch("use-pyramid", "Keep arrangement pyramid (upright)", [{ op: "remove", path: finding2.path }], true)] };
8891
- return { help, fixes: [] };
8892
- }
8893
- if (validation.keyword === "enum" && inRegion && segments.at(-1) === "arrangement") {
8894
- const value = readAt(document, segments), renamed = value === "flow" ? "process" : value === "vertical-flow" ? "vertical-process" : void 0;
8895
- if (renamed === void 0) return void 0;
8896
- return { help: `OPF 0.35 renamed the arrangement "${String(value)}" to "${renamed}", PowerPoint's name (${renamed === "process" ? "Basic Process" : "Vertical Process"}); it draws the same.`, fixes: [patch("rename-arrangement", `Write arrangement ${renamed}`, [{ op: "replace", path: finding2.path, value: renamed }], true)] };
8897
- }
8898
- const alignment = segments.at(-1);
8899
- if (validation.keyword === "enum" && finding2.ruleId === "opf/catalog-record" && segments.at(-2) === "design" && (alignment === "titleAlignment" || alignment === "contentAlignment")) {
8900
- const value = readAt(document, segments), next = value === "left" ? "start" : value === "right" ? "end" : void 0;
8901
- if (next === void 0) return void 0;
8902
- return { help: `OPF 0.34 renamed the alignment "${String(value)}" to "${next}" (the start and end of the reading direction; the left and right edges of a left-to-right deck).`, fixes: [patch(`change-to:${next}`, `Change to ${next}`, [{ op: "replace", path: finding2.path, value: next }], true)] };
8903
- }
8904
- if (validation.keyword === "enum" && inRegion && segments.at(-1) === "role" && readAt(document, segments) === "secondary") {
8905
- return {
8906
- help: `OPF 0.35 removed the role "secondary" (bound after primary, before supporting): a region's role is "primary" (the default), "media" or "supporting". Write "supporting" for a region that takes what the primary regions leave, or "primary".`,
8907
- fixes: [patch("change-to:supporting", "Change to supporting", [{ op: "replace", path: finding2.path, value: "supporting" }]), patch("change-to:primary", "Change to primary", [{ op: "replace", path: finding2.path, value: "primary" }])]
8908
- };
8909
- }
8910
- if (validation.keyword === "additionalProperties") {
8911
- const name = segments.at(-1) ?? "";
8912
- if (name === "listColumns" && segments.at(-3) === "regions" && readAt(document, segments) !== void 0) return { help: REMOVED_LIST_COLUMNS, fixes: [patch("remove:listColumns", "Delete listColumns", [{ op: "remove", path: finding2.path }], true, listColumnsChangeDrawing(readAt(document, segments.slice(0, -1))))] };
8913
- if (segments.at(-2) !== "design" || !Object.hasOwn(REMOVED_DESIGN_KEYS, name) || readAt(document, segments) === void 0) return void 0;
8914
- const marks = REMOVED_DESIGN_KEY_FIXES[name] ?? { safe: true, changesDrawing: () => true };
8915
- return { help: REMOVED_DESIGN_KEYS[name], fixes: [patch(`remove:${name}`, `Delete design.${name}`, removedDesignKeyOperations(document, segments), marks.safe, marks.changesDrawing(segments))] };
8916
- }
8917
- if (validation.keyword === "pattern" && segments.at(-1) === "region" && segments.at(-3) === "blocks" && segments[0] === "slides" && segments.length === 5) {
8918
- const typed = readAt(document, segments), near = typeof typed === "string" ? nearestGridCell(typed) : void 0;
8919
- if (!near?.help) return void 0;
8920
- return { help: `${JSON.stringify(typed)} is no cell of the slide's grid. ${near.help}`, fixes: near.cell ? [patch(`change-to:${near.cell}`, `Change to ${near.cell}`, [{ op: "replace", path: finding2.path, value: near.cell }])] : [] };
8921
- }
8922
- if (validation.keyword === "enum" && segments.at(-1) === "flow" && segments.at(-3) === "regions" && readAt(document, segments) === "none") {
8923
- const parent = segments.slice(0, -1), region = readAt(document, parent);
8924
- const help = 'OPF 0.35 removed flow "none": a region of one block says "max": 1 (blocks no region had room for still join it), and its flow is "auto", "grid", "row" or "column".';
8925
- if (!isRecord2(region) || region.max !== void 0 && region.max !== 1) return { help, fixes: [] };
8926
- return { help, fixes: [patch("use-max-1", "Write max 1 (a region of one block)", [{ op: "remove", path: finding2.path }, { op: "add", path: pointerOf([...parent, "max"]), value: 1 }], true)] };
8927
- }
8928
- return void 0;
8929
- }
8930
- var ROOT_CONTENT = ["type", "text", "items", "bullets", "image", "video", "chart", "table", "code", "metric", "quote", "timeline", "diagram", "shape", "path", "blocks"];
8931
- function removedCellKeys(slide) {
8932
- if (!isRecord2(slide)) return [];
8933
- const found = Object.keys(slide).flatMap((key3) => {
8934
- const cell = nearestGridCell(key3)?.cell;
8935
- return cell ? [{ key: key3, cell }] : [];
8936
- });
8937
- const order2 = cellsInReadingOrder(found);
8938
- return order2.flatMap((cell) => found.filter((entry2) => entry2.cell === cell));
8939
- }
8940
- function cellKeysAsBlocks(slide, placed) {
8941
- const keys = removedCellKeys(slide);
8942
- if (!keys.length || !isRecord2(slide) || ROOT_CONTENT.some((field) => slide[field] !== void 0) || keys.some(({ key: key3 }) => !isRecord2(slide[key3]))) return void 0;
8943
- const blocks = keys.map(({ key: key3, cell }) => {
8944
- const { id, region: _ignored, ...rest } = slide[key3];
8945
- return { ...id !== void 0 ? { id } : {}, ...placed ? { region: cell } : {}, ...rest };
8946
- });
8947
- return { keys: keys.map(({ key: key3 }) => key3), blocks };
8948
- }
8949
- function cellKeyRepair(document, slideSegments, key3, options2) {
8950
- const slide = readAt(document, slideSegments), near = nearestGridCell(key3);
8951
- const layout = isRecord2(slide) && slide.layout !== void 0 && (slide.layout !== "auto" || resolvesToValidRecord(document, "layouts", "auto", options2));
8952
- const example = near.cell ? `{ "region": "${near.cell}", ... }` : '{ "region": "top:start", ... }';
8953
- const help = `OPF 0.35 removed the slide keys that placed content in the cells of a slide's 3 x 3 grid (the promoted regions): a block of the slide's blocks names its cell with "region", as ${example}. Blocks that name the same cell stack in it, and a slide places every block in a cell or none.` + (layout ? " This slide also has a layout, and a cell word names no region of a layout: the fix keeps the layout and moves each cell's content into a block without region, which binds to the layout's regions by kind, so the slide draws on its layout. To keep a grid of cells instead, remove layout and name the cells on the blocks." : "") + (near.help ? ` ${near.help}` : "");
8954
- const moved = near.cell ? cellKeysAsBlocks(slide, !layout) : void 0;
8955
- if (!moved) return { help, fixes: [], dropSuggestions: true };
8956
- const operations = [...moved.keys.map((name) => ({ op: "remove", path: pointerOf([...slideSegments, name]) })), { op: "add", path: pointerOf([...slideSegments, "blocks"]), value: moved.blocks }];
8957
- return { help, fixes: [layout ? patch("cells-to-layout-blocks", "Move the regions into blocks of the layout", operations, true, true) : patch("cells-to-blocks", "Move the regions into blocks with region", operations, true)], dropSuggestions: true };
8958
- }
8959
-
8960
- // src/drawn-font-families.ts
8961
- function resolveDrawnFontFamilies(families, measurement, keepsName) {
8962
- const resolve2 = measurement?.resolveStyle;
8963
- if (typeof resolve2 !== "function") return families;
8964
- const drawn = { ...families };
8965
- for (const role of ["heading", "body", "code", "accent"]) {
8966
- const named = families[role];
8967
- if (typeof named !== "string" || !named) continue;
8968
- try {
8969
- const resolved2 = resolve2.call(measurement, { fontFamily: named, fontWeight: role === "heading" ? 700 : 400 });
8970
- let keep3;
8971
- if (keepsName) keep3 = keepsName(named, resolved2.fontFamily);
8972
- else {
8973
- const regular = role === "heading" ? resolve2.call(measurement, { fontFamily: named, fontWeight: 400 }) : resolved2;
8974
- const encoded = resolved2.symbolEncoding != null;
8975
- keep3 = encoded || regular.fontWeight !== void 0 && regular.fontWeight !== 400 && resolved2.fontFamily.toLowerCase() !== named.toLowerCase();
8976
- }
8977
- if (!keep3) drawn[role] = resolved2.fontFamily;
8978
- } catch {
8979
- }
8980
- }
8981
- return drawn;
8982
- }
8983
-
8984
- // src/script-measurement.ts
8985
- function scriptProfile(presentation, slideIndex, options2, language) {
8986
- let resolved2;
8987
- try {
8988
- resolved2 = resolveScriptFonts(presentation, { slideIndex, ...options2.catalogs !== void 0 ? { catalogs: options2.catalogs } : {}, ...language === void 0 ? {} : { language } });
8989
- } catch {
8990
- resolved2 = void 0;
8991
- }
8992
- const slots = (role) => {
8993
- const latin = options2.fontFamilies[role];
8994
- const slot = (key3) => !resolved2 || resolved2.sources[key3] === "latin" || resolved2.sources[key3] === "schemeFamily" ? latin : resolved2[role][key3] ?? latin;
8995
- return { latin, eastAsian: slot("eastAsian"), complexScript: slot("complexScript") };
8996
- };
8997
- return {
8998
- heading: slots("heading"),
8999
- body: slots("body"),
9000
- ...resolved2?.supplement ? { supplement: resolved2.supplement } : {},
9001
- script: resolved2?.script ?? "Zzzz",
9002
- ...resolved2 ? { scriptRole: resolved2.scriptRole, bcp47: resolved2.bcp47, lang: resolved2.lang, languageSource: resolved2.languageSource, direction: resolved2.direction } : {},
9003
- rtl: resolved2?.rtl === true,
9004
- serif: options2.serif
9005
- };
9006
- }
9007
- function slideScriptMeasurement(presentation, slideIndex, measurement, options2) {
9008
- const forScripts = measurement.forScripts;
9009
- if (typeof forScripts !== "function") return measurement;
9010
- const deckProfile = scriptProfile(presentation, slideIndex, options2);
9011
- const deck = forScripts.call(measurement, deckProfile);
9012
- const languages = /* @__PURE__ */ new Map();
9013
- const forLanguage = (lang) => {
9014
- if (typeof lang !== "string" || !lang) return void 0;
9015
- if (!languages.has(lang)) {
9016
- let own4;
9017
- try {
9018
- const profile = scriptProfile(presentation, slideIndex, options2, lang);
9019
- own4 = profile.languageSource === "option" && profile.bcp47?.toLowerCase() !== deckProfile.bcp47?.toLowerCase() ? forScripts.call(measurement, profile) : void 0;
9020
- } catch {
9021
- own4 = void 0;
9022
- }
9023
- languages.set(lang, own4);
9024
- }
9025
- return languages.get(lang);
9026
- };
9027
- const pick = (style) => forLanguage(style?.lang) ?? deck;
9028
- const scripted = { ...deck, measure: (text2, size, style) => pick(style).measure(text2, size, style) };
9029
- if (typeof deck.resolveStyle === "function") scripted.resolveStyle = (style) => deck.resolveStyle.call(deck, style);
9030
- if (typeof deck.outlineBounds === "function")
9031
- scripted.outlineBounds = (text2, size, style) => {
9032
- const own4 = pick(style);
9033
- return typeof own4.outlineBounds === "function" ? own4.outlineBounds(text2, size, style) : deck.outlineBounds.call(deck, text2, size, style);
9034
- };
9035
- return scripted;
9036
- }
9037
- function resolveSlideScriptMeasurement(presentation, slideIndex, measurement, options2 = {}) {
9038
- if (typeof measurement.forScripts !== "function") return measurement;
9039
- const { fontScheme } = resolveDesignRecords(presentation, slideIndex, options2.catalogs !== void 0 ? { catalogs: options2.catalogs } : {});
9040
- const resolved2 = resolveFontFamilies(fontScheme);
9041
- const fontFamilies = { heading: options2.fontFamilies?.heading ?? resolved2.heading, body: options2.fontFamilies?.body ?? resolved2.body };
9042
- return slideScriptMeasurement(presentation, slideIndex, measurement, { ...options2.catalogs !== void 0 ? { catalogs: options2.catalogs } : {}, fontFamilies, serif: fontScheme.type === "serif" });
9043
- }
9044
-
9045
- // src/message-surface.ts
9046
- var rec3 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
9047
- var MESSAGE_SURFACE_SLOT = "accent1";
9048
- var MESSAGE_SURFACE_CONTRAST = 4.5;
9049
- function messageKind(slide, layout) {
9050
- const lone = lonePayload(slide);
9051
- if (lone?.field !== "text" || annotationText(slide.subtitle).trim()) return void 0;
9052
- let plan;
9053
- try {
9054
- plan = isLayoutTemplate(layout) ? layoutTemplate(layout) : void 0;
9055
- } catch {
9056
- return void 0;
9057
- }
9058
- if (plan?.stack !== void 0 && statementMessage(slide, plan) !== void 0) return "statement-message";
9059
- if (plan && (plan.regions.length > 1 || plan.regions.some((region) => region.role === "media" || region.flow === "grid" || region.flow === "row"))) return void 0;
9060
- const value = lone.host.text;
9061
- const cited = Array.isArray(value) && value.some((run) => run && typeof run === "object" && (run.cite !== void 0 || run.footnote !== void 0));
9062
- return !cited && messageWords(value) > 0 && messageWords(value) <= SHORT_MESSAGE_WORDS ? "display-message" : void 0;
9063
- }
9064
- function lchOf(hex) {
9065
- const lin = (at2) => {
9066
- const value = Number.parseInt(hex.slice(at2, at2 + 2), 16) / 255;
9067
- return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
9068
- };
9069
- const [r, g, b] = [lin(1), lin(3), lin(5)];
9070
- const x = (0.4124564 * r + 0.3575761 * g + 0.1804375 * b) / 0.95047, y = 0.2126729 * r + 0.7151522 * g + 0.072175 * b, z = (0.0193339 * r + 0.119192 * g + 0.9503041 * b) / 1.08883;
9071
- const f = (t) => t > 216 / 24389 ? Math.cbrt(t) : (24389 / 27 * t + 16) / 116;
9072
- const [fx, fy, fz] = [f(x), f(y), f(z)];
9073
- return { L: 116 * fy - 16, C: Math.hypot(500 * (fx - fy), 200 * (fy - fz)) };
9074
- }
9075
- var MESSAGE_SURFACE_MAX_LIGHTNESS = 60;
9076
- var MESSAGE_SURFACE_MAX_CHROMA = 80;
9077
- function resolveMessageSurface(presentation, slide, layout, context) {
9078
- const deckDesign = rec3(rec3(presentation).design);
9079
- const kind = messageKind(slide, layout), named = layoutVariantKind(layout);
9080
- if (kind === void 0 || !(named === void 0 || named === "surface") || deckBackgroundIsChosen(deckDesign, context.theme.background) || !layoutVariantApplies(slide.design, layout, deckDesign, context.theme.background, true)) return void 0;
9081
- const below = colorChoice([deckDesign, context.theme], context.colorScheme, context.variables);
9082
- const variant = { background: MESSAGE_SURFACE_SLOT, ...below.variant?.accents ? { accents: below.variant.accents } : {} };
9083
- const plain = resolveColorRoles(context.colorScheme, { background: below.background, variant: below.variant });
9084
- const deliberate = [deckDesign, ...context.themeChosen ? [context.theme] : []].some((level) => level.background !== void 0 || level.variant !== void 0);
9085
- if (plain.dark && deliberate) return void 0;
9086
- const accent = resolveColorRoles(context.colorScheme, { variant }), shade = lchOf(accent.background.slice(0, 7).toUpperCase());
9087
- if (accent.background.toUpperCase() === plain.background.toUpperCase() || (colorContrast(accent.text, accent.background) ?? 0) < MESSAGE_SURFACE_CONTRAST || shade.L > MESSAGE_SURFACE_MAX_LIGHTNESS || shade.C > MESSAGE_SURFACE_MAX_CHROMA) return void 0;
9088
- return { kind, variant };
9089
- }
9090
- function drawsAccentByDesign(presentation, host, record, theme) {
9091
- const deckDesign = rec3(rec3(presentation).design), own4 = normalizeColorVariant(rec3(host.design).variant), named = layoutColorVariant(record);
9092
- if (own4) return own4.background.startsWith("accent");
9093
- return named !== void 0 && layoutVariantApplies(host.design, record, deckDesign, theme.background) && named.background.startsWith("accent");
9094
- }
9095
- function messageDisplayed(result, kind) {
9096
- const scale = Math.min(result.width, result.height) / 720, size = (field) => result.items.find((item) => item.field === field)?.text?.fontSize;
9097
- const text2 = size("text"), title = size("title");
9098
- if (kind === "statement-message") return text2 !== void 0 && text2 / scale >= LONE_DISPLAY_SIZES.text - 1e-6 || title !== void 0 && title / scale > 54 + 1e-6;
9099
- return text2 !== void 0 && text2 / scale > LONE_DISPLAY_SIZES.text + 1e-6;
10661
+ const arrangement = region.arrangement ?? region.sequence;
10662
+ return !(accepts[0] === "list" && (arrangement === void 0 || arrangement === "numbered"));
9100
10663
  }
9101
-
9102
- // src/slide-context.ts
9103
- var rec4 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
9104
- function unpathed(measurement) {
9105
- const bare = (style) => ({ ...style, path: void 0 });
10664
+ function sheetReference(name) {
10665
+ return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name) ? name : `'${name.replaceAll("'", "''")}'`;
10666
+ }
10667
+ function datasourceStringRepair(finding2, document, segments) {
10668
+ const parent = segments.slice(0, -1), owner = readAt(document, parent), value = readAt(document, segments);
10669
+ const where = parent.length === 2 && parent[0] === "datasets" ? "dataset" : parent.at(-1) === "data" && parent.at(-2) === "chart" ? "chart data" : void 0;
10670
+ if (where === void 0 || !isRecord2(owner) || typeof value !== "string") return void 0;
9106
10671
  return {
9107
- ...measurement,
9108
- measure: (text2, size, style) => measurement.measure(text2, size, bare(style)),
9109
- ...measurement.resolveStyle ? { resolveStyle: (style) => measurement.resolveStyle(bare(style)) } : {},
9110
- ...measurement.outlineBounds ? { outlineBounds: (text2, size, style) => measurement.outlineBounds(text2, size, bare(style)) } : {},
9111
- ...measurement.forScripts ? { forScripts: (profile) => unpathed(measurement.forScripts(profile)) } : {}
9112
- };
10672
+ help: `A string \`datasource\` is only ever the id of an entry of the root \`datasources\` map (letters, digits, dots, hyphens and underscores). A file or a URL is written as an inline data source: { "src": ${JSON.stringify(value)} }.`,
10673
+ fixes: [patch("datasource-to-src", `Write the ${where}'s datasource as { "src": ${JSON.stringify(value)} }`, [{ op: "replace", path: finding2.path, value: { src: value } }])]
10674
+ };
10675
+ }
10676
+ var REMOVED_SOURCE = 'OPF 0.37 removed the nested `source` object. Where the data came from is written in the keys of the dataset or chart data itself: `datasource` (the id of an entry of the root `datasources` map, or an inline data source such as { "src": "./revenue.csv" }), `query` (the sheet and range, "FY26!A1:C13"), `retrieved`, `version`, `sha256` and `generator`.';
10677
+ function sourceRepair(finding2, document, segments) {
10678
+ const parent = segments.slice(0, -1), owner = readAt(document, parent), old = readAt(document, segments);
10679
+ const where = parent.length === 2 && parent[0] === "datasets" ? "dataset" : parent.at(-1) === "data" && parent.at(-2) === "chart" ? "chart data" : void 0;
10680
+ if (where === void 0 || !isRecord2(owner) || !isRecord2(old)) return void 0;
10681
+ const text2 = (value) => typeof value === "string" && value !== "" ? value : void 0;
10682
+ const src = text2(old.src), description = text2(old.description), retrieved = text2(old.retrieved), sheet = text2(old.sheet), range = text2(old.range);
10683
+ const query = sheet !== void 0 && range !== void 0 ? `${sheetReference(sheet)}!${range}` : sheet !== void 0 ? sheetReference(sheet) : range;
10684
+ const dropped = Array.isArray(old.fields) && old.fields.length ? " Its `fields` list is dropped: the data holds its own columns." : "";
10685
+ const help = `${REMOVED_SOURCE}${dropped}`;
10686
+ const writes = [];
10687
+ if (src !== void 0) writes.push(["datasource", { src, ...description !== void 0 ? { description } : {} }]);
10688
+ if (query !== void 0) writes.push(["query", query]);
10689
+ if (retrieved !== void 0) writes.push(["retrieved", retrieved]);
10690
+ if (writes.some(([key3]) => Object.hasOwn(owner, key3))) return { help, fixes: [] };
10691
+ const operations = [{ op: "remove", path: finding2.path }, ...writes.map(([key3, value]) => ({ op: "add", path: pointerOf([...parent, key3]), value }))];
10692
+ const title = `Write the ${where}'s ${writes.map(([key3]) => key3).join(", ") || "provenance"} keys in place of source${dropped ? " (fields is dropped)" : ""}`;
10693
+ return { help, fixes: [patch("use-datasource", title, operations, true)] };
9113
10694
  }
9114
- function resolveSlideContext(presentation, index, options2 = {}) {
9115
- const deck = rec4(presentation);
9116
- const slides = Array.isArray(deck.slides) ? deck.slides : [];
9117
- if (!Number.isInteger(index) || index < 0 || index >= slides.length) throw new RangeError(`Slide index ${String(index)} is outside the presentation's ${slides.length} slides.`);
9118
- const slide = rec4(slides[index]);
9119
- const catalogs = { catalogs: checkCatalogsOption(options2.catalogs, "resolveSlideContext") };
9120
- const records = resolveDesignRecords(presentation, index, catalogs);
9121
- const diagnostics = [...records.diagnostics];
9122
- const { theme, colorScheme, fontScheme } = records;
9123
- const design = { ...rec4(deck.design), ...rec4(slide.design) };
9124
- let layout;
9125
- let layoutProvenance;
9126
- if (typeof slide.layout === "string") {
9127
- const found = resolveReference(presentation, "layouts", slide.layout, catalogs);
9128
- if (found) {
9129
- layout = { ...found.record };
9130
- layoutProvenance = provenanceOf(found);
9131
- } else diagnostics.push(unresolvedReference(presentation, "layouts", slide.layout, `slides.${index}.layout`, catalogs));
10695
+ var REMOVED_LIST_COLUMNS = `OPF 0.35 removed the region key listColumns. Delete it: a list of more than 6 entries flows into up to three columns in any region without an arrangement (or with the numbered one) when that sets it at least as large as one column; a list payload's own columns (1, 2, 3 or "auto") still chooses.`;
10696
+ function renamedKeyRepair(finding2, document) {
10697
+ const validation = finding2.validation;
10698
+ if (!validation || finding2.ruleId !== "opf/schema" && finding2.ruleId !== "opf/catalog-record") return void 0;
10699
+ const segments = segmentsOf(finding2.path);
10700
+ if (validation.keyword === "additionalProperties") {
10701
+ const rename = renamedKeyAt(segments);
10702
+ if (!rename) return void 0;
10703
+ const parent = segments.slice(0, -1), owner = readAt(document, parent);
10704
+ if (!isRecord2(owner) || !Object.hasOwn(owner, rename.from)) return void 0;
10705
+ const both = Object.hasOwn(owner, rename.to);
10706
+ const note = rename.note ? ` ${rename.note}` : "";
10707
+ const help = both ? `OPF 0.37 renamed "${rename.from}" to "${rename.to}".${note} This object has both: keep "${rename.to}" and remove "${rename.from}".` : `OPF 0.37 renamed "${rename.from}" to "${rename.to}".${note} It draws the same; the fix renames it.`;
10708
+ const fixes = both ? [] : [patch("rename-key", `Rename ${rename.from} to ${rename.to}`, [{ op: "move", from: finding2.path, path: pointerOf([...parent, rename.to]) }], true)];
10709
+ return { help, message: renamedKeyMessage(rename, both), dropSuggestions: true, exclusive: true, fixes };
10710
+ }
10711
+ if (validation.keyword === "enum" && segments.at(-1) === "scriptGroup") {
10712
+ const old = readAt(document, segments), long = renamedScriptGroupValue(old);
10713
+ if (long === void 0) return void 0;
10714
+ return {
10715
+ help: `OPF 0.37 writes the script groups of a font scheme "latin", "eastAsian" and "complexScript"; "${String(old)}" is "${long}". It draws the same.`,
10716
+ message: renamedValueMessage(String(old), long),
10717
+ exclusive: true,
10718
+ fixes: [patch("rename-value", `Write ${long}`, [{ op: "replace", path: finding2.path, value: long }], true)]
10719
+ };
9132
10720
  }
9133
- if (options2.strictReferences && diagnostics.length) throw new OPFUnresolvedReferenceError(diagnostics);
9134
- const candidate = resolveMessageSurface(presentation, slide, layout, { theme, colorScheme, variables: rec4(deck.variables), themeChosen: records.provenance.theme !== void 0 });
9135
- const build = (surface) => {
9136
- const levels = colorLevels(rec4(slide.design), layout, rec4(deck.design), theme, colorScheme, rec4(deck.variables), surface?.variant);
9137
- const roles2 = resolveColorRoles(colorScheme, colorChoice(levels, colorScheme, rec4(deck.variables)));
9138
- const layoutVariant2 = levels.length > 3 && layoutVariantApplies(slide.design, layout, deck.design, theme.background, surface) ? levels[1].variant : void 0;
9139
- const composeOptions2 = {
9140
- ...resolveCanvasDimensions(design.dimensions ?? theme.dimensions),
9141
- ...layout ? { layout } : {},
9142
- presentation,
9143
- slideIndex: index,
9144
- slideNumber: options2.slideNumber ?? index + 1,
9145
- slideCount: options2.slideCount ?? slides.length,
9146
- fontFamilies: resolveFontFamilies(fontScheme),
9147
- darkBackground: roles2.dark,
9148
- ...surface ? { messageSurface: surface, resolveRunColor: (reference) => resolveColorRef(reference, { colorScheme, roles: roles2, variables: rec4(deck.variables), fallback: "" }) || void 0 } : {},
9149
- // LH-02: the colors the automatic scrim of a picture background is sized for.
9150
- roles: { text: roles2.text, textSecondary: roles2.textSecondary, primary: roles2.primary, background: roles2.background },
9151
- ...theme.background !== void 0 ? { themeBackground: theme.background } : {},
9152
- // OPF 0.19: a theme may carry the shared design keys (between the deck's design and the layout record's).
9153
- ...theme.design !== void 0 && rec4(theme.design) === theme.design ? { themeDesign: theme.design } : {},
9154
- ...options2.fonts?.textMeasurement ? { textMeasurement: options2.fonts.textMeasurement } : {},
9155
- ...options2.date !== void 0 ? { date: options2.date } : {}
10721
+ if (validation.keyword === "pattern" && segments.at(-1) === "link" && segments.at(-3) === "references") {
10722
+ const value = readAt(document, segments);
10723
+ if (typeof value !== "string" || !LOOKS_LIKE_HOST_AND_PATH.test(value)) return void 0;
10724
+ return {
10725
+ help: `A reference's link is an http or https address, a "mailto:" or a "tel:" link. "${value}" looks like an address without its scheme; "https://${value}" is a guess the author confirms, so the fix is not applied by default.`,
10726
+ exclusive: true,
10727
+ fixes: [patch("add-https", "Add https://", [{ op: "replace", path: finding2.path, value: `https://${value}` }])]
9156
10728
  };
9157
- return { levels, roles: roles2, layoutVariant: layoutVariant2, composeOptions: composeOptions2 };
9158
- };
9159
- const variablesOf = (made) => resolveSlideVariables(slide, { slideNumber: made.composeOptions.slideNumber, slideCount: made.composeOptions.slideCount, presentation, darkBackground: made.composeOptions.darkBackground === true });
9160
- let messageSurface = candidate, built = build(candidate);
9161
- if (candidate) {
9162
- const plain = build(void 0);
9163
- const host = plain.composeOptions.textMeasurement;
9164
- const measurement = host ? unpathed(slideScriptMeasurement(presentation, index, host, { ...catalogs, fontFamilies: resolveFontFamilies(fontScheme), serif: fontScheme.type === "serif" })) : host;
9165
- let displayed = false;
9166
- try {
9167
- displayed = messageDisplayed(composeSlide(variablesOf(plain), { ...plain.composeOptions, ...measurement ? { textMeasurement: measurement } : {} }), candidate.kind);
9168
- } catch {
9169
- displayed = false;
9170
- }
9171
- if (displayed && index > 0) {
9172
- const before = rec4(slides[index - 1]), record = typeof before.layout === "string" ? resolveReference(presentation, "layouts", before.layout, catalogs)?.record : void 0;
9173
- if (drawsAccentByDesign(presentation, before, record, theme) || resolveSlideContext(presentation, index - 1, { ...options2, slideNumber: void 0 }).resolved.messageSurface !== void 0) displayed = false;
9174
- }
9175
- if (!displayed) {
9176
- messageSurface = void 0;
9177
- built = plain;
9178
- }
9179
10729
  }
9180
- const { roles, layoutVariant, composeOptions } = built;
9181
- const resolvedSlide = variablesOf(built);
9182
- return { slide: resolvedSlide, options: composeOptions, diagnostics, resolved: { theme, colorScheme, roles, fontScheme, fontSchemePath: records.fontSchemePath, ...layout ? { layout } : {}, ...layoutVariant ? { layoutVariant } : {}, ...messageSurface ? { messageSurface } : {}, provenance: { ...layoutProvenance ? { layout: layoutProvenance } : {}, ...records.provenance } } };
10730
+ return void 0;
9183
10731
  }
9184
-
9185
- // src/rule-slides.ts
9186
- var measurementFor = (options2, index) => {
9187
- const measurement = options2.fonts?.textMeasurement;
9188
- return typeof measurement === "function" ? measurement(index) : measurement;
9189
- };
9190
- var lazy = (compute) => {
9191
- let done = false;
9192
- let value;
9193
- return () => {
9194
- if (!done) {
9195
- value = compute();
9196
- done = true;
9197
- }
9198
- return value;
9199
- };
9200
- };
9201
- function relax(value) {
9202
- const copy = JSON.parse(JSON.stringify(value));
9203
- const walk2 = (node) => {
9204
- if (Array.isArray(node)) return node.forEach(walk2);
9205
- if (node && typeof node === "object") {
9206
- const object3 = node;
9207
- if (object3.overflow === "error") object3.overflow = "warn";
9208
- for (const child of Object.values(object3)) walk2(child);
10732
+ function removedKeyRepair(finding2, document, options2) {
10733
+ const validation = finding2.validation;
10734
+ if (!validation || finding2.ruleId !== "opf/schema" && finding2.ruleId !== "opf/catalog-record") return void 0;
10735
+ const renamed = renamedKeyRepair(finding2, document);
10736
+ if (renamed) return renamed;
10737
+ const segments = segmentsOf(finding2.path);
10738
+ if (validation.keyword === "additionalProperties" && segments.length === 3 && segments[0] === "slides" && readAt(document, segments) !== void 0 && nearestGridCell(segments[2]) !== void 0) return cellKeyRepair(document, segments.slice(0, 2), segments[2], options2);
10739
+ if (validation.keyword === "pattern" && finding2.ruleId === "opf/schema" && segments.at(-1) === "datasource") {
10740
+ const repaired = datasourceStringRepair(finding2, document, segments);
10741
+ if (repaired) return repaired;
10742
+ }
10743
+ if (validation.keyword === "additionalProperties" && finding2.ruleId === "opf/schema" && segments.at(-1) === "source") {
10744
+ const repaired = sourceRepair(finding2, document, segments);
10745
+ if (repaired) return repaired;
10746
+ }
10747
+ const inRegion = segments.at(-3) === "regions";
10748
+ if (validation.keyword === "additionalProperties" && inRegion && (segments.at(-1) === "sequence" || segments.at(-1) === "pyramidDirection")) {
10749
+ const parent = segments.slice(0, -1), region = readAt(document, parent), value = readAt(document, segments);
10750
+ if (!isRecord2(region) || value === void 0) return void 0;
10751
+ const arrangement = region.arrangement;
10752
+ if (segments.at(-1) === "sequence") {
10753
+ const help2 = `OPF 0.35 replaced the region key sequence with arrangement: a region has one arrangement, a sequence ("steps" or "numbered") or a diagram. Write "arrangement": ${JSON.stringify(value)} in its place.`;
10754
+ if (arrangement !== void 0 || value !== "steps" && value !== "numbered") return { help: `${help2}${arrangement !== void 0 ? ` This region also has "arrangement": ${JSON.stringify(arrangement)}; keep one of the two.` : ""}`, fixes: [] };
10755
+ return { help: help2, fixes: [patch("use-arrangement", `Write arrangement ${value}`, [{ op: "move", from: finding2.path, path: pointerOf([...parent, "arrangement"]) }], true)] };
9209
10756
  }
9210
- };
9211
- walk2(copy);
9212
- return copy;
9213
- }
9214
- function buildSlides(document, options2, memo) {
9215
- const slides = Array.isArray(document.slides) ? document.slides : [];
9216
- return slides.map((slide, index) => {
9217
- const path = pointer2("slides", index);
9218
- const baseContext = lazy(() => resolveSlideContext(document, index, { catalogs: options2.catalogs, date: "2000-01-01" }));
9219
- const measurement = lazy(() => {
9220
- const host = measurementFor(options2, index);
9221
- if (!host) return void 0;
9222
- const { resolved: resolved3 } = baseContext();
9223
- return slideScriptMeasurement(document, index, host, { catalogs: options2.catalogs, fontFamilies: resolveFontFamilies(resolved3.fontScheme), serif: resolved3.fontScheme.type === "serif" });
9224
- });
9225
- const resolved2 = lazy(() => {
9226
- const textMeasurement = measurement();
9227
- const slideContext = baseContext();
9228
- return textMeasurement ? { ...slideContext, options: { ...slideContext.options, textMeasurement } } : slideContext;
9229
- });
9230
- const design = lazy(() => resolveDesign(document, index, resolved2()));
9231
- const layout = lazy(() => resolved2().options.layout);
9232
- const compute = () => {
9233
- const result = { layoutDiagnostics: [] };
9234
- let fontFamilies;
9235
- const compose = (input, withLayout) => {
9236
- const options3 = resolved2().options;
9237
- fontFamilies ??= options3.fontFamilies && resolveDrawnFontFamilies(options3.fontFamilies, options3.textMeasurement);
9238
- return composeSlide(input, { ...options3, ...fontFamilies ? { fontFamilies } : {}, layout: withLayout });
9239
- };
9240
- try {
9241
- result.composition = compose(resolved2().slide, layout());
9242
- result.layoutDiagnostics.push(...result.composition.diagnostics.map((diagnostic) => ({ diagnostic, strict: false })));
9243
- } catch (error) {
9244
- if (error instanceof OPFCompositionError) {
9245
- result.layoutDiagnostics.push(...error.diagnostics.map((diagnostic) => ({ diagnostic, strict: true })));
9246
- try {
9247
- const relaxedLayout = layout();
9248
- result.composition = compose(relax(resolved2().slide), relaxedLayout ? relax(relaxedLayout) : void 0);
9249
- } catch (second) {
9250
- result.layoutError = second instanceof Error ? second.message : String(second);
9251
- }
9252
- } else result.layoutError = error instanceof Error ? error.message : String(error);
9253
- }
9254
- return result;
10757
+ const help = 'OPF 0.35 removed the region key pyramidDirection: "arrangement": "inverted-pyramid" draws the pyramid upside down (what "down" did), and "arrangement": "pyramid" draws it upright ("up", the default).';
10758
+ if (arrangement !== "pyramid") return { help, fixes: [] };
10759
+ if (value === "down") return { help, fixes: [patch("use-inverted-pyramid", "Write arrangement inverted-pyramid", [{ op: "remove", path: finding2.path }, { op: "replace", path: pointerOf([...parent, "arrangement"]), value: "inverted-pyramid" }], true)] };
10760
+ if (value === "up") return { help, fixes: [patch("use-pyramid", "Keep arrangement pyramid (upright)", [{ op: "remove", path: finding2.path }], true)] };
10761
+ return { help, fixes: [] };
10762
+ }
10763
+ if (validation.keyword === "enum" && inRegion && segments.at(-1) === "arrangement") {
10764
+ const value = readAt(document, segments), renamed2 = value === "flow" ? "process" : value === "vertical-flow" ? "vertical-process" : void 0;
10765
+ if (renamed2 === void 0) return void 0;
10766
+ return { help: `OPF 0.35 renamed the arrangement "${String(value)}" to "${renamed2}", PowerPoint's name (${renamed2 === "process" ? "Basic Process" : "Vertical Process"}); it draws the same.`, fixes: [patch("rename-arrangement", `Write arrangement ${renamed2}`, [{ op: "replace", path: finding2.path, value: renamed2 }], true)] };
10767
+ }
10768
+ const alignment = segments.at(-1);
10769
+ if (validation.keyword === "enum" && finding2.ruleId === "opf/catalog-record" && segments.at(-2) === "design" && (alignment === "titleAlignment" || alignment === "contentAlignment")) {
10770
+ const value = readAt(document, segments), next = value === "left" ? "start" : value === "right" ? "end" : void 0;
10771
+ if (next === void 0) return void 0;
10772
+ return { help: `OPF 0.34 renamed the alignment "${String(value)}" to "${next}" (the start and end of the reading direction; the left and right edges of a left-to-right deck).`, fixes: [patch(`change-to:${next}`, `Change to ${next}`, [{ op: "replace", path: finding2.path, value: next }], true)] };
10773
+ }
10774
+ if (validation.keyword === "enum" && inRegion && segments.at(-1) === "role" && readAt(document, segments) === "secondary") {
10775
+ return {
10776
+ help: `OPF 0.35 removed the role "secondary" (bound after primary, before supporting): a region's role is "primary" (the default), "media" or "supporting". Write "supporting" for a region that takes what the primary regions leave, or "primary".`,
10777
+ fixes: [patch("change-to:supporting", "Change to supporting", [{ op: "replace", path: finding2.path, value: "supporting" }]), patch("change-to:primary", "Change to primary", [{ op: "replace", path: finding2.path, value: "primary" }])]
9255
10778
  };
9256
- const composed = lazy(() => memo ? memo(index, compute) : compute());
9257
- const payloads = lazy(() => slidePayloads(slide, path));
9258
- const texts = lazy(() => textValues(slide, path));
9259
- const rtl = lazy(() => {
9260
- try {
9261
- return resolveScriptFonts(document, { slideIndex: index }).rtl === true;
9262
- } catch {
9263
- return false;
9264
- }
9265
- });
9266
- const context = { index, slide, path, ...typeof slide.id === "string" ? { id: slide.id } : {} };
9267
- return Object.defineProperties(context, {
9268
- design: { get: design, enumerable: true },
9269
- layout: { get: layout, enumerable: true },
9270
- composition: { get: () => composed().composition, enumerable: true },
9271
- layoutDiagnostics: { get: () => composed().layoutDiagnostics, enumerable: true },
9272
- layoutError: { get: () => composed().layoutError, enumerable: true },
9273
- measurement: { get: measurement, enumerable: true },
9274
- payloads: { get: payloads, enumerable: true },
9275
- texts: { get: texts, enumerable: true },
9276
- rtl: { get: rtl, enumerable: true }
9277
- });
10779
+ }
10780
+ if (validation.keyword === "additionalProperties") {
10781
+ const name = segments.at(-1) ?? "";
10782
+ if (name === "listColumns" && segments.at(-3) === "regions" && readAt(document, segments) !== void 0) return { help: REMOVED_LIST_COLUMNS, fixes: [patch("remove:listColumns", "Delete listColumns", [{ op: "remove", path: finding2.path }], true, listColumnsChangeDrawing(readAt(document, segments.slice(0, -1))))] };
10783
+ if (segments.at(-2) !== "design" || !Object.hasOwn(REMOVED_DESIGN_KEYS, name) || readAt(document, segments) === void 0) return void 0;
10784
+ const marks = REMOVED_DESIGN_KEY_FIXES[name] ?? { safe: true, changesDrawing: () => true };
10785
+ return { help: REMOVED_DESIGN_KEYS[name], fixes: [patch(`remove:${name}`, `Delete design.${name}`, removedDesignKeyOperations(document, segments), marks.safe, marks.changesDrawing(segments))] };
10786
+ }
10787
+ if (validation.keyword === "pattern" && segments.at(-1) === "region" && segments.at(-3) === "blocks" && segments[0] === "slides" && segments.length === 5) {
10788
+ const typed = readAt(document, segments), near = typeof typed === "string" ? nearestGridCell(typed) : void 0;
10789
+ if (!near?.help) return void 0;
10790
+ return { help: `${JSON.stringify(typed)} is no cell of the slide's grid. ${near.help}`, fixes: near.cell ? [patch(`change-to:${near.cell}`, `Change to ${near.cell}`, [{ op: "replace", path: finding2.path, value: near.cell }])] : [] };
10791
+ }
10792
+ if (validation.keyword === "enum" && segments.at(-1) === "flow" && segments.at(-3) === "regions" && readAt(document, segments) === "none") {
10793
+ const parent = segments.slice(0, -1), region = readAt(document, parent);
10794
+ const help = 'OPF 0.35 removed flow "none": a region of one block says "max": 1 (blocks no region had room for still join it), and its flow is "auto", "grid", "row" or "column".';
10795
+ if (!isRecord2(region) || region.max !== void 0 && region.max !== 1) return { help, fixes: [] };
10796
+ return { help, fixes: [patch("use-max-1", "Write max 1 (a region of one block)", [{ op: "remove", path: finding2.path }, { op: "add", path: pointerOf([...parent, "max"]), value: 1 }], true)] };
10797
+ }
10798
+ return void 0;
10799
+ }
10800
+ var ROOT_CONTENT = ["type", "text", "items", "bullets", "image", "video", "embed", "chart", "table", "code", "metric", "quote", "timeline", "diagram", "shape", "path", "blocks"];
10801
+ function removedCellKeys(slide) {
10802
+ if (!isRecord2(slide)) return [];
10803
+ const found = Object.keys(slide).flatMap((key3) => {
10804
+ const cell = nearestGridCell(key3)?.cell;
10805
+ return cell ? [{ key: key3, cell }] : [];
10806
+ });
10807
+ const order2 = cellsInReadingOrder(found);
10808
+ return order2.flatMap((cell) => found.filter((entry2) => entry2.cell === cell));
10809
+ }
10810
+ function cellKeysAsBlocks(slide, placed) {
10811
+ const keys = removedCellKeys(slide);
10812
+ if (!keys.length || !isRecord2(slide) || ROOT_CONTENT.some((field) => slide[field] !== void 0) || keys.some(({ key: key3 }) => !isRecord2(slide[key3]))) return void 0;
10813
+ const blocks = keys.map(({ key: key3, cell }) => {
10814
+ const { id, region: _ignored, ...rest } = slide[key3];
10815
+ return { ...id !== void 0 ? { id } : {}, ...placed ? { region: cell } : {}, ...rest };
9278
10816
  });
10817
+ return { keys: keys.map(({ key: key3 }) => key3), blocks };
10818
+ }
10819
+ function cellKeyRepair(document, slideSegments, key3, options2) {
10820
+ const slide = readAt(document, slideSegments), near = nearestGridCell(key3);
10821
+ const layout = isRecord2(slide) && slide.layout !== void 0 && (slide.layout !== "auto" || resolvesToValidRecord(document, "layouts", "auto", options2));
10822
+ const example = near.cell ? `{ "region": "${near.cell}", ... }` : '{ "region": "top:start", ... }';
10823
+ const help = `OPF 0.35 removed the slide keys that placed content in the cells of a slide's 3 x 3 grid (the promoted regions): a block of the slide's blocks names its cell with "region", as ${example}. Blocks that name the same cell stack in it, and a slide places every block in a cell or none.` + (layout ? " This slide also has a layout, and a cell word names no region of a layout: the fix keeps the layout and moves each cell's content into a block without region, which binds to the layout's regions by kind, so the slide draws on its layout. To keep a grid of cells instead, remove layout and name the cells on the blocks." : "") + (near.help ? ` ${near.help}` : "");
10824
+ const moved = near.cell ? cellKeysAsBlocks(slide, !layout) : void 0;
10825
+ if (!moved) return { help, fixes: [], dropSuggestions: true };
10826
+ const operations = [...moved.keys.map((name) => ({ op: "remove", path: pointerOf([...slideSegments, name]) })), { op: "add", path: pointerOf([...slideSegments, "blocks"]), value: moved.blocks }];
10827
+ return { help, fixes: [layout ? patch("cells-to-layout-blocks", "Move the regions into blocks of the layout", operations, true, true) : patch("cells-to-blocks", "Move the regions into blocks with region", operations, true)], dropSuggestions: true };
9279
10828
  }
9280
10829
 
9281
10830
  // src/validation-cache.ts
@@ -9488,7 +11037,7 @@ var ValidationCompositionCache = class {
9488
11037
 
9489
11038
  // src/validator.ts
9490
11039
  var SEVERITIES = ["error", "warning", "info"];
9491
- var OPTION_KEYS = ["only", "ignore", "severity", "ignorePaths", "catalogs", "contracts", "thresholds", "fonts", "chartPalette", "template", "values"];
11040
+ var OPTION_KEYS = ["only", "ignore", "severity", "ignorePaths", "catalogs", "contracts", "thresholds", "fonts", "chartPalette", "template", "values", "asOf", "slideLinks"];
9492
11041
  var isObject3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
9493
11042
  var OPFValidationError = class extends Error {
9494
11043
  /** The full report that failed. */
@@ -9567,6 +11116,7 @@ function resolveOptions(options2) {
9567
11116
  throw new TypeError("Validate chartPalette must be an array of #RRGGBB colors.");
9568
11117
  if (options2.template !== void 0 && typeof options2.template !== "boolean") throw new TypeError("Validate template must be true or false.");
9569
11118
  if (options2.values !== void 0 && !isObject3(options2.values)) throw new TypeError("Validate values must be an object keyed by variable id.");
11119
+ if (options2.asOf !== void 0 && parseInstant(options2.asOf) === void 0) throw new TypeError("Validate asOf must be an ISO 8601 date (2026-11-25) or date-time (2026-11-25T09:30:00Z).");
9570
11120
  const level = (info) => severity.get(info.id) ?? severity.get(info.category);
9571
11121
  const off = (info) => level(info) === "off" || !!ignore?.rules.has(info.id) || !!ignore?.categories.has(info.category);
9572
11122
  return {
@@ -9590,7 +11140,7 @@ var categoryOrder = (category) => {
9590
11140
  };
9591
11141
  var auditInfos = ruleImplementations.flatMap((entry2) => [entry2.info, ...entry2.also ?? []]);
9592
11142
  var isLayoutRule = (info) => info.category === "layout" && info.cost === "composition";
9593
- function slideOf(path) {
11143
+ function slideOf2(path) {
9594
11144
  const match2 = /^\/slides\/(\d+)(?:\/|$)/.exec(path);
9595
11145
  return match2 ? Number(match2[1]) : void 0;
9596
11146
  }
@@ -9622,7 +11172,7 @@ function syntaxReport(parsed, run) {
9622
11172
  return { valid: tally.error === 0, schemaValid: null, findings, counts: tally, checks };
9623
11173
  }
9624
11174
  function validateDocument(document, run, parsed, cache) {
9625
- const engine = validateAgainstSchema(document, "presentation", { template: run.options.template, values: run.options.values, ...run.options.catalogs ? { catalogs: run.options.catalogs } : {} });
11175
+ const engine = validateAgainstSchema(document, "presentation", { template: run.options.template, values: run.options.values, ...run.options.asOf !== void 0 ? { asOf: run.options.asOf } : {}, ...run.options.catalogs ? { catalogs: run.options.catalogs } : {}, ...run.options.slideLinks !== void 0 ? { slideLinks: run.options.slideLinks } : {} });
9626
11176
  const schemaValid = engine.errors.length === 0;
9627
11177
  const slides = isObject3(document) && Array.isArray(document.slides) ? document.slides : [];
9628
11178
  const auditWanted = auditInfos.some((info) => run.enabled(info));
@@ -9686,7 +11236,7 @@ function validateDocument(document, run, parsed, cache) {
9686
11236
  if (!STALE_RECORD_RULES.has(entry2.ruleId) || entry2.scope === "context") return void 0;
9687
11237
  const match2 = /^\/catalogs\/([^/]+)\/layouts\/([^/]+)(?:\/|$)/.exec(entry2.path);
9688
11238
  if (!match2) return void 0;
9689
- const [group, id] = [match2[1], match2[2]].map((segment) => segment.replaceAll("~1", "/").replaceAll("~0", "~"));
11239
+ const [group, id] = [match2[1], match2[2]].map((segment2) => segment2.replaceAll("~1", "/").replaceAll("~0", "~"));
9690
11240
  let found = staleCopies.get(`${group}/${id}`);
9691
11241
  if (!found) {
9692
11242
  const copy = staleLayoutCopy(document, group, id, run.options);
@@ -9702,7 +11252,7 @@ function validateDocument(document, run, parsed, cache) {
9702
11252
  const override = info ? run.severity(info) : void 0;
9703
11253
  let next = override && override !== entry2.severity ? { ...entry2, severity: override } : entry2;
9704
11254
  if (info && run.ignored(info, splitPointer(next.path))) continue;
9705
- const index = slideOf(next.path);
11255
+ const index = slideOf2(next.path);
9706
11256
  if (next.slide === void 0 && index !== void 0 && next.scope !== "context") {
9707
11257
  const id = isObject3(slides[index]) ? slides[index].id : void 0;
9708
11258
  next.slide = index;
@@ -9714,7 +11264,7 @@ function validateDocument(document, run, parsed, cache) {
9714
11264
  }
9715
11265
  const removed = next.scope !== "context" ? removedKeyRepair(next, document, run.options) : void 0;
9716
11266
  if (removed) next = withRepair(next, removed);
9717
- if (next.ruleId === "opf/schema" && next.fixes === void 0 && next.scope !== "context") {
11267
+ if (next.ruleId === "opf/schema" && next.fixes === void 0 && next.scope !== "context" && !removed?.exclusive) {
9718
11268
  const fixes = schemaFixes(next, document);
9719
11269
  if (fixes.length) next.fixes = fixes;
9720
11270
  }
@@ -9784,7 +11334,7 @@ function assertValid(value, options2 = {}) {
9784
11334
  }
9785
11335
  function withRepair(finding2, removed) {
9786
11336
  const { suggestions, ...rest } = finding2;
9787
- return { ...removed.dropSuggestions ? rest : { ...rest, ...suggestions ? { suggestions } : {} }, help: removed.help, ...removed.fixes.length ? { fixes: removed.fixes } : {} };
11337
+ return { ...removed.dropSuggestions ? rest : { ...rest, ...suggestions ? { suggestions } : {} }, ...removed.message ? { message: removed.message } : {}, help: removed.help, ...removed.fixes.length ? { fixes: removed.fixes } : {} };
9788
11338
  }
9789
11339
  function validateCatalogRecord(kind, value) {
9790
11340
  const kinds = Object.keys(catalogSchemaNames);
@@ -9812,4 +11362,4 @@ function assertValidCatalogRecord(kind, value) {
9812
11362
  if (!report2.valid) throw new OPFValidationError(report2);
9813
11363
  }
9814
11364
 
9815
- export { BLOCK_AS_VALUES, BLOCK_OPTION_KEYS, CATALOG_SCHEMA, COMMON_KEYS, DEFAULT_VALIDATION_THRESHOLDS, FENCE_ATTRIBUTES, FENCE_KINDS, LINE_KEYWORDS, METRIC_KEYS, OPFPatchError, OPFPatchHashError, OPFPatchValidationError, OPFValidationError, PATTERN_PHRASES, SLIDE_OPTION_KEYS, SOURCE_EXPLAIN, SPAN_FLAGS, SPAN_VALUES, UNRANKED_PRIORITY, activeSchema, analyzeJsonSyntax, applyPatch, applyPatchWithInverse, applyTextEdits, assertValid, assertValidCatalogRecord, catalogDisplayKinds, catalogIconKinds, catalogKindAt, catalogSchemaNames, createLocator, createSchemaValue, createValidator, describeField, describeFinding, distance, documentHash, escapePointerToken, findValidationRule, formatPointer, getAtPointer, hasPointer, idToken, invertPatch, isIdToken, jsonEqual, listSchemaFields, nearest, normalizePatch, parsePointer, parseSource, pointerFromPath, readPointer, refreshStaleLayouts, rememberByText, resolveDrawnFontFamilies, resolveIdPatch, resolveIdPointer, resolveSchema, resolveSlideContext, resolveSlideScriptMeasurement, ruleDocumentation, schemaAtPath, schemaCatalogKinds, schemaLabel, schemaType, schemaVariants, segmentsOf, splitOpfPath, splitPointer2 as splitPointer, starterValue, toIdPatch, toIdPointer, unescapePointerToken, validate, validateCatalogRecord, validationCategories, validationRules, walkPatch };
11365
+ export { BLOCK_AS_VALUES, BLOCK_OPTION_KEYS, CATALOG_SCHEMA, COMMON_KEYS, DEFAULT_VALIDATION_THRESHOLDS, FENCE_ATTRIBUTES, FENCE_KINDS, LINE_KEYWORDS, METRIC_KEYS, OPFPatchError, OPFPatchHashError, OPFPatchValidationError, OPFValidationError, PATTERN_PHRASES, SLIDE_OPTION_KEYS, SOURCE_EXPLAIN, SPAN_FLAGS, SPAN_VALUES, UNRANKED_PRIORITY, activeSchema, analyzeJsonSyntax, applyPatch, applyPatchWithInverse, applyTextEdits, assertValid, assertValidCatalogRecord, catalogDisplayKinds, catalogIconKinds, catalogKindAt, catalogSchemaNames, collectSlideLinks, createLocator, createSchemaValue, createValidator, credentialInSrc, describeField, describeFinding, distance, documentHash, escapePointerToken, findNodeAtOffset2 as findNodeAtOffset, findValidationRule, formatPointer, getAtPointer, getNodePath2 as getNodePath, hasPointer, idToken, invertPatch, isIdToken, jsonEqual, listSchemaFields, nearest, normalizePatch, parseInstant, parsePointer, parseSource, parseTree2 as parseTree, pointerFromPath, readPointer, refreshStaleLayouts, rememberByText, renameRecordKeys, resolveDrawnFontFamilies, resolveIdPatch, resolveIdPointer, resolveSchema, resolveSlideContext, resolveSlideScriptMeasurement, ruleDocumentation, schemaAtPath, schemaCatalogKinds, schemaLabel, schemaType, schemaVariants, segmentsOf, slideLink, slideLinkId, splitOpfPath, splitPointer2 as splitPointer, starterValue, toIdPatch, toIdPointer, unescapePointerToken, validate, validateCatalogRecord, validationCategories, validationRules, walkPatch };