@openpresentation/opf 0.34.2 → 0.35.0

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 (89) hide show
  1. package/README.md +6 -6
  2. package/dist/browser.js +19 -19
  3. package/dist/{catalog-refs-wtuudZTe.d.ts → catalog-refs-BgotJhR5.d.ts} +105 -95
  4. package/dist/{catalog-schemas-CSxuFtsu.d.ts → catalog-schemas-BX-VEc5Q.d.ts} +1 -1
  5. package/dist/{chunk-RM4Z7ZSW.js → chunk-2GCTKQDD.js} +4 -4
  6. package/dist/{chunk-VI7VWDTN.js → chunk-3KPTVK77.js} +75 -283
  7. package/dist/{chunk-AQ3WR3H7.js → chunk-3ZTKRX7F.js} +4 -6
  8. package/dist/{chunk-IDYYLJCQ.js → chunk-4UMZDDJG.js} +11 -29
  9. package/dist/{chunk-NLJFNCZ4.js → chunk-6JHV2K67.js} +6 -6
  10. package/dist/{chunk-FK5XG742.js → chunk-6VGLE7C5.js} +114 -2
  11. package/dist/{chunk-V4G3BYPY.js → chunk-7KUUIL7W.js} +7 -7
  12. package/dist/{chunk-PHOSM2RA.js → chunk-ARPMSD7V.js} +1 -1
  13. package/dist/{chunk-UKI43JE6.js → chunk-GGN3NQDK.js} +1 -1
  14. package/dist/{chunk-XLXCXEVF.js → chunk-GKUAVSXU.js} +3 -10
  15. package/dist/{chunk-HX4HEJB4.js → chunk-HORPH6O7.js} +7 -6
  16. package/dist/{chunk-KJFCHCWV.js → chunk-JQNT37IO.js} +4 -13
  17. package/dist/{chunk-WBPXRUZT.js → chunk-KNMMEE67.js} +795 -467
  18. package/dist/{chunk-IGT4523S.js → chunk-LDLLZQPP.js} +706 -432
  19. package/dist/{chunk-6MSH3KCZ.js → chunk-MS2LPR7F.js} +1 -5
  20. package/dist/{chunk-NMZCPZ3R.js → chunk-MVPQEMCP.js} +97 -15
  21. package/dist/{chunk-P2X4BBW2.js → chunk-NPRNWPP4.js} +1 -1
  22. package/dist/{chunk-EQCZ2SFD.js → chunk-P2ACZJUL.js} +6 -6
  23. package/dist/chunk-SEC4IOOS.js +1 -0
  24. package/dist/{chunk-VVPPMHP6.js → chunk-VMPOCXTE.js} +5 -17
  25. package/dist/{chunk-MDAXXFAY.js → chunk-ZZWX4W2G.js} +2 -2
  26. package/dist/{composition-DF07Ha4R.d.ts → composition-BmJfljJl.d.ts} +198 -114
  27. package/dist/composition.d.ts +2 -2
  28. package/dist/composition.js +1 -1
  29. package/dist/{conversion-52ki0lfZ.d.ts → conversion-BbXhlurO.d.ts} +7 -7
  30. package/dist/conversion-VWCH3NKR.js +25 -0
  31. package/dist/convert.d.ts +11 -11
  32. package/dist/convert.js +61 -86
  33. package/dist/data.d.ts +1 -1
  34. package/dist/data.js +2 -2
  35. package/dist/{deck-report-C3EsoHC3.d.ts → deck-report-BYkbL7uT.d.ts} +3 -3
  36. package/dist/deck.d.ts +6 -6
  37. package/dist/deck.js +11 -11
  38. package/dist/diagram-engine-eager.js +1 -1
  39. package/dist/diagram-engine-lazy.js +1 -1
  40. package/dist/{diagram-plantuml-XRZ6VAOL.js → diagram-plantuml-GWXGKY7R.js} +1 -1
  41. package/dist/diff.d.ts +2 -2
  42. package/dist/diff.js +4 -4
  43. package/dist/docs.js +39 -39
  44. package/dist/examples.js +6336 -8170
  45. package/dist/{finding-l9dlQ2NF.d.ts → finding-mcHslZLA.d.ts} +6 -2
  46. package/dist/font-policy.d.ts +16 -2
  47. package/dist/font-policy.js +1 -1
  48. package/dist/format.js +2 -2
  49. package/dist/ids.d.ts +2 -2
  50. package/dist/ids.js +4 -4
  51. package/dist/index.d.ts +125 -27
  52. package/dist/index.js +24 -23
  53. package/dist/markdown.d.ts +1 -1
  54. package/dist/markdown.js +8 -8
  55. package/dist/node-engine.d.ts +6 -6
  56. package/dist/node-engine.js +21 -21
  57. package/dist/{pagination-Do7vNgU-.d.ts → pagination-C0FPjO29.d.ts} +4 -4
  58. package/dist/pagination.d.ts +3 -3
  59. package/dist/pagination.js +4 -4
  60. package/dist/patch.d.ts +4 -4
  61. package/dist/patch.js +3 -3
  62. package/dist/precompiled.js +2 -2
  63. package/dist/{presentation-ANs2WkaS.d.ts → presentation-Dx-kZC8Y.d.ts} +25 -81
  64. package/dist/repo-readme.js +1 -1
  65. package/dist/schema-engine-ajv.js +1 -1
  66. package/dist/schema-engine-precompiled.js +2 -2
  67. package/dist/schema.d.ts +5 -7
  68. package/dist/schema.js +3 -3
  69. package/dist/schemas.js +1 -1
  70. package/dist/source.js +10 -10
  71. package/dist/spec/reference/engine-defaults.json +1 -1
  72. package/dist/spec/reference/engine-vocabularies.json +43 -43
  73. package/dist/spec/reference/font-policy.json +114 -2
  74. package/dist/spec/reference/font-policy.schema.json +45 -1
  75. package/dist/spec/schemas/color-scheme.schema.json +2 -2
  76. package/dist/spec/schemas/finding.schema.json +2 -1
  77. package/dist/spec/schemas/layout.schema.json +27 -85
  78. package/dist/spec/schemas/opf.schema.json +26 -175
  79. package/dist/spec/schemas/theme.schema.json +10 -10
  80. package/dist/symbol-font-encodings.d.ts +2 -2
  81. package/dist/types.d.ts +74 -86
  82. package/dist/{validation-types-BNS41nzb.d.ts → validation-types-DKIe1RQW.d.ts} +5 -5
  83. package/dist/validator.d.ts +5 -7
  84. package/dist/validator.js +3 -3
  85. package/dist/yaml.d.ts +1 -1
  86. package/dist/yaml.js +7 -7
  87. package/package.json +5 -5
  88. package/dist/chunk-HSXWDXKM.js +0 -1
  89. package/dist/conversion-F3HSCFOV.js +0 -25
@@ -1,6 +1,6 @@
1
1
  import { original } from './chunk-JBARNYFR.js';
2
- import { schemas, schemaEntries } from './chunk-VI7VWDTN.js';
3
- import { promotedRegionKeys, SHAPE_BLOCK_KEYS, VARIABLE_KINDS, resolveChartData, chartPaletteForFill, chartSeriesPalette, chartSchemeSeries, chartSlicePlan, CHART_SERIES_MIN_LIGHTNESS_STEP, normalizeHexColor, resolveChartColors, colorContrast, 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, intrinsicImageSize, resolveReference, layoutTable, colorTransform, applyColorTransform, resolveColorRef, readingRows, visualReadingOrder, numberingSystemExtension, isSupportedNumberingSystem, plainLanguageTag, supportedNumberingSystems, resolveDesignRecords, resolveFontFamilies, checkCatalogsOption, provenanceOf, unresolvedReference, OPFUnresolvedReferenceError, composeSlide, resolveColorRoles, layoutVariantApplies, resolveCanvasDimensions, resolveSlideVariables, layoutVariantKind, deckBackgroundIsChosen, LONE_DISPLAY_SIZES, normalizeColorVariant, layoutColorVariant, inlineDatasets, hasBuiltinDependency, isRecord, hasContentVariables, isTemplate, instantiateForValidation, layoutTemplateIssues, 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, catalogRecords, collectCitations, resolveSlideDirection, numberingFindings, chartDrawDiagnostics, resolveTableData, resolveChartOptions, chartOptionTarget, codeHighlightLines, relatedName, chartNumberFixesByCell, catalogKinds, catalogGroupSource, registeredCatalog, representablePositionBox, PositionRangeError, isShapeBlock, OPFCompositionError } from './chunk-IGT4523S.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-LDLLZQPP.js';
4
4
  import { schemaEngine } from '#schema-engine';
5
5
  import { parseTree, printParseErrorCode, getNodePath } from 'jsonc-parser';
6
6
 
@@ -25,7 +25,7 @@ var catalogSchemaNames = {
25
25
 
26
26
  // src/annotation-validation.ts
27
27
  var issue = (path, message, params2) => ({ path, message, keyword: "opf", schemaPath: "#/x-opf-semantics", params: params2 });
28
- var pointer = (dotted2) => `/${dotted2.split(".").map((part) => part.replaceAll("~", "~0").replaceAll("/", "~1")).join("/")}`;
28
+ var pointer = (dotted2) => `/${dotted2.split(".").map((part2) => part2.replaceAll("~", "~0").replaceAll("/", "~1")).join("/")}`;
29
29
  function markedRuns(value) {
30
30
  if (!Array.isArray(value)) return [];
31
31
  return value.flatMap((run, index) => isRecord(run) && (run.cite !== void 0 || run.footnote !== void 0) ? [index] : []);
@@ -97,10 +97,10 @@ var ALIASES = { middle: "center", centre: "center", centered: "center", centred:
97
97
  function segmentsOf(path) {
98
98
  if (Array.isArray(path)) return path.map(String);
99
99
  if (typeof path !== "string" || path === "" || path === "/") return [];
100
- return path.replace(/^\//, "").split("/").map((part) => part.replaceAll("~1", "/").replaceAll("~0", "~"));
100
+ return path.replace(/^\//, "").split("/").map((part2) => part2.replaceAll("~1", "/").replaceAll("~0", "~"));
101
101
  }
102
102
  function pointerOf(segments) {
103
- return segments.map((part) => `/${String(part).replaceAll("~", "~0").replaceAll("/", "~1")}`).join("");
103
+ return segments.map((part2) => `/${String(part2).replaceAll("~", "~0").replaceAll("/", "~1")}`).join("");
104
104
  }
105
105
  var code = (value) => `\`${String(value)}\``;
106
106
  var isIndex = (segment) => /^\d+$/.test(String(segment));
@@ -198,7 +198,7 @@ function respellings(typed, declared) {
198
198
  }
199
199
  var isUnion = (error) => (error.keyword === "oneOf" || error.keyword === "anyOf") && Array.isArray(error.schema);
200
200
  var key = (error) => `${error.instancePath}\0${error.keyword}\0${error.message}\0${JSON.stringify(error.params)}`;
201
- var depth = (pointer4) => pointer4 ? pointer4.split("/").length - 1 : 0;
201
+ var depth = (pointer5) => pointer5 ? pointer5.split("/").length - 1 : 0;
202
202
  function branchLabel(branch, index) {
203
203
  if (typeof branch.$ref === "string") return branch.$ref.slice(branch.$ref.lastIndexOf("/") + 1);
204
204
  if (typeof branch.type === "string") return branch.type;
@@ -423,7 +423,6 @@ function validationDefinition(issue2) {
423
423
 
424
424
  // src/schema-check.ts
425
425
  var schemaNameByCatalogKind = catalogSchemaNames;
426
- var promotedRegionKeySet = new Set(promotedRegionKeys);
427
426
  var rootPayloadFields = [
428
427
  "type",
429
428
  "text",
@@ -499,22 +498,6 @@ var captionableKinds = /* @__PURE__ */ new Set(["image", "chart", "table", "vide
499
498
  var imageOptionFields = ["fit", "focus", "aspectRatio", "shape", "adjust", "stroke", "opacity", "recolor", "overlay", "placement", "portrait"];
500
499
  var shapeImageFields = /* @__PURE__ */ new Set(["aspectRatio", "shape", "adjust", "stroke", "opacity"]);
501
500
  var shapeOptionFields = SHAPE_BLOCK_KEYS.filter((field) => field !== "path");
502
- var columnSpans = {
503
- start: [0],
504
- center: [1],
505
- end: [2],
506
- "start+center": [0, 1],
507
- "center+end": [1, 2],
508
- "start+center+end": [0, 1, 2]
509
- };
510
- var rowSpans = {
511
- top: [0],
512
- middle: [1],
513
- bottom: [2],
514
- "top+middle": [0, 1],
515
- "middle+bottom": [1, 2],
516
- "top+middle+bottom": [0, 1, 2]
517
- };
518
501
  function isSchemaName(value) {
519
502
  return typeof value === "string" && hasOwn(schemas, value);
520
503
  }
@@ -622,7 +605,7 @@ function validateContentPayload(value, path, options2 = {}) {
622
605
  for (const field of shapeOptionFields) if (hasOwn(value, field) && !(field === "hidden" && options2.slideRoot)) issues.push(semanticIssue(pathFor(path, field), `${field} is only valid on a shape block; ${reason}`, { code: "shape-option-unsupported-payload", field, ...params2 }));
623
606
  };
624
607
  if (hasOwn(value, "placement") && !options2.topLevel && !hasBlocks && explicitType !== "group" && inferredKinds(value).includes("image")) {
625
- issues.push(semanticIssue(pathFor(path, "placement"), "placement is only valid on a top-level block (slides.N.blocks.I); a block inside a group or a promoted region cannot bleed to a slide edge", { code: "image-placement-invalid" }));
608
+ issues.push(semanticIssue(pathFor(path, "placement"), "placement is only valid on a top-level block (slides.N.blocks.I); a block inside a group cannot bleed to a slide edge", { code: "image-placement-invalid" }));
626
609
  }
627
610
  if (hasBlocks || explicitType === "group") {
628
611
  if (hasOwn(value, "caption")) issues.push(captionIssue("a group cannot carry one"));
@@ -724,64 +707,34 @@ function validateContentPayload(value, path, options2 = {}) {
724
707
  }
725
708
  return issues;
726
709
  }
727
- function slideRegion(key3) {
728
- if (key3.includes(":")) {
729
- const [rowPart, columnPart] = key3.split(":");
730
- if (!rowPart || !columnPart) return void 0;
731
- const rows = rowSpans[rowPart];
732
- const columns = columnSpans[columnPart];
733
- return rows && columns ? { rows, columns } : void 0;
734
- }
735
- if (key3 in columnSpans) {
736
- const columns = columnSpans[key3];
737
- return columns ? { rows: [0, 1, 2], columns } : void 0;
738
- }
739
- if (key3 in rowSpans) {
740
- const rows = rowSpans[key3];
741
- return rows ? { rows, columns: [0, 1, 2] } : void 0;
742
- }
743
- return void 0;
710
+ function validateSlideRoot(slide, slidePath, canvas) {
711
+ return presentFields(slide, rootPayloadFields).length > 0 ? validateContentPayload(slide, slidePath, { slideRoot: true, ...canvas ? { canvas } : {} }) : [];
744
712
  }
745
713
  function intersects(left, right) {
746
714
  return left.some((value) => right.includes(value));
747
715
  }
748
- function regionsOverlap(left, right) {
749
- return intersects(left.rows, right.rows) && intersects(left.columns, right.columns);
750
- }
751
- function validateSlideRegions(slide, slidePath, canvas) {
716
+ function validateSlideCells(slide, slidePath) {
752
717
  const issues = [];
753
- const regionKeys = Object.keys(slide).filter((key3) => promotedRegionKeySet.has(key3));
754
- const rootFields = presentFields(slide, rootPayloadFields);
755
- if (regionKeys.length > 0 && rootFields.length > 0) {
756
- issues.push(semanticIssue(slidePath, "root content payload fields cannot be mixed with promoted region keys", {
757
- rootFields,
758
- regionKeys
759
- }));
760
- }
761
- if (regionKeys.length === 0 && rootFields.length > 0) {
762
- issues.push(...validateContentPayload(slide, slidePath, { slideRoot: true, ...canvas ? { canvas } : {} }));
763
- }
764
- for (const key3 of regionKeys) {
765
- const value = slide[key3];
766
- if (isRecord(value)) {
767
- issues.push(...validateContentPayload(value, pathFor(slidePath, key3), canvas ? { canvas } : {}));
768
- }
769
- }
770
- for (let leftIndex = 0; leftIndex < regionKeys.length; leftIndex += 1) {
771
- const leftKey = regionKeys[leftIndex];
772
- if (!leftKey) continue;
773
- const leftRegion = slideRegion(leftKey);
774
- if (!leftRegion) continue;
775
- for (let rightIndex = leftIndex + 1; rightIndex < regionKeys.length; rightIndex += 1) {
776
- const rightKey = regionKeys[rightIndex];
777
- if (!rightKey) continue;
778
- const rightRegion = slideRegion(rightKey);
779
- if (!rightRegion) continue;
780
- if (regionsOverlap(leftRegion, rightRegion)) {
781
- issues.push(semanticIssue(slidePath, `promoted region keys '${leftKey}' and '${rightKey}' overlap`, {
782
- regionKeys: [leftKey, rightKey]
783
- }));
784
- }
718
+ if (slide.layout !== void 0 || !Array.isArray(slide.blocks)) return issues;
719
+ const blocks = slide.blocks.flatMap((block, index) => isRecord(block) ? [{ block, index }] : []);
720
+ const placed = blocks.filter(({ block }) => isGridCell(block.region));
721
+ if (!placed.length) return issues;
722
+ const cells = [...new Set(placed.map(({ block }) => String(block.region)))];
723
+ for (const { block, index } of blocks) {
724
+ if (isGridCell(block.region) || typeof block.region === "string" && /[:+]/.test(block.region)) continue;
725
+ const path = pathFor(pathFor(slidePath, "blocks"), String(index));
726
+ const meant = typeof block.region === "string" ? nearestGridCell(block.region)?.cell : void 0;
727
+ issues.push(semanticIssue(typeof block.region === "string" ? pathFor(path, "region") : path, typeof block.region === "string" ? `a slide places every block in a cell of its grid or none: '${block.region}' is no cell (${meant ? `write '${meant}': layout words follow the deck's direction` : `write one of the cells the other blocks use, such as '${cells[0]}', or give the slide a layout`})` : `a slide places every block in a cell of its grid or none: give this block a 'region' cell too (the other blocks use ${cells.map((cell) => `'${cell}'`).join(", ")})`, { cells }));
728
+ }
729
+ for (const { block, index } of placed) {
730
+ if (hasOwn(block, "placement")) issues.push(semanticIssue(pathFor(pathFor(pathFor(slidePath, "blocks"), String(index)), "placement"), "placement is only valid on a top-level block of a slide whose blocks are not in cells; a block in a cell of the slide's grid cannot bleed to a slide edge", { code: "image-placement-invalid" }));
731
+ }
732
+ for (let left = 0; left < cells.length; left += 1) {
733
+ for (let right = left + 1; right < cells.length; right += 1) {
734
+ const a = gridCellSpan(cells[left]), b = gridCellSpan(cells[right]);
735
+ 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]] }));
785
738
  }
786
739
  }
787
740
  return issues;
@@ -839,7 +792,7 @@ function presentationSemanticIssues(value, catalogs) {
839
792
  const canvas = deckCanvas();
840
793
  return canvas ? { ...canvas, rtl: resolveSlideDirection(value, index) === "rtl" } : void 0;
841
794
  };
842
- const hasCallouts = (node, depth2 = 0) => isRecord(node) && depth2 <= 34 && Object.entries(node).some(([key3, entry2]) => key3 === "callouts" ? Array.isArray(entry2) && entry2.length > 0 : key3 === "image" || key3 === "blocks" || promotedRegionKeySet.has(key3) ? Array.isArray(entry2) ? entry2.some((item) => hasCallouts(item, depth2 + 1)) : hasCallouts(entry2, depth2 + 1) : false);
795
+ const hasCallouts = (node, depth2 = 0) => isRecord(node) && depth2 <= 34 && Object.entries(node).some(([key3, entry2]) => key3 === "callouts" ? Array.isArray(entry2) && entry2.length > 0 : key3 === "image" || key3 === "blocks" ? Array.isArray(entry2) ? entry2.some((item) => hasCallouts(item, depth2 + 1)) : hasCallouts(entry2, depth2 + 1) : false);
843
796
  value.slides.forEach((slide, index) => {
844
797
  if (isRecord(slide)) {
845
798
  const slidePath = `/slides/${index}`;
@@ -867,7 +820,7 @@ function presentationSemanticIssues(value, catalogs) {
867
820
  });
868
821
  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 }));
869
822
  issues.push(...enUkIssues(slide.language, `${slidePath}/language`));
870
- issues.push(...validateSlideRegions(slide, slidePath, hasCallouts(slide) ? deckCanvas() : void 0));
823
+ issues.push(...validateSlideRoot(slide, slidePath, hasCallouts(slide) ? deckCanvas() : void 0), ...validateSlideCells(slide, slidePath));
871
824
  const payloadTableIssues = (payload, path) => {
872
825
  if (isRecord(payload.table)) for (const issue2 of tableGrid(payload.table).issues) issues.push(semanticIssue(pathFor(path, "table") + issue2.path.slice(5).replaceAll(".", "/"), issue2.message));
873
826
  };
@@ -1179,11 +1132,6 @@ function presentationReferenceWarnings(value, catalogs) {
1179
1132
  };
1180
1133
  highlightWarnings(slide, slidePath);
1181
1134
  visitContentPayloads(slide, slidePath, highlightWarnings);
1182
- for (const key3 of Object.keys(slide)) {
1183
- if (promotedRegionKeySet.has(key3)) {
1184
- issues.push(...chartTypeWarnings(slide[key3], pathFor(slidePath, key3)));
1185
- }
1186
- }
1187
1135
  });
1188
1136
  return issues;
1189
1137
  }
@@ -1198,7 +1146,6 @@ function contentDepthIssues(value) {
1198
1146
  if (Array.isArray(slide.blocks)) slide.blocks.forEach((block, i) => {
1199
1147
  stack.push({ value: block, path: `/slides/${index}/blocks/${i}`, depth: 0, ancestors: [] });
1200
1148
  });
1201
- for (const key3 of promotedRegionKeys) if (hasOwn(slide, key3)) stack.push({ value: slide[key3], path: `/slides/${index}/${key3}`, depth: 0, ancestors: [] });
1202
1149
  });
1203
1150
  while (stack.length) {
1204
1151
  const entry2 = stack.pop();
@@ -1249,9 +1196,9 @@ function typedVariableErrors(errors, value) {
1249
1196
  }
1250
1197
  return kept;
1251
1198
  }
1252
- function pointerValue(root, pointer4) {
1199
+ function pointerValue(root, pointer5) {
1253
1200
  let current = root;
1254
- for (const token of pointer4.split("/").slice(1)) {
1201
+ for (const token of pointer5.split("/").slice(1)) {
1255
1202
  const key3 = token.replaceAll("~1", "/").replaceAll("~0", "~");
1256
1203
  if (Array.isArray(current)) current = current[Number(key3)];
1257
1204
  else if (isRecord(current) && hasOwn(current, key3)) current = current[key3];
@@ -1459,10 +1406,10 @@ var CVD_MATRICES = {
1459
1406
  [4733e-6, 0.691367, 0.3039]
1460
1407
  ]
1461
1408
  };
1462
- var visionModels = ["protanopia", "deuteranopia", "tritanopia", "greyscale"];
1409
+ var visionModels = ["protanopia", "deuteranopia", "tritanopia", "grayscale"];
1463
1410
  function simulateVision(hex, model) {
1464
1411
  const rgb = toRgb(hex).map(linear);
1465
- if (model === "greyscale") {
1412
+ if (model === "grayscale") {
1466
1413
  const y = 0.2126 * (rgb[0] ?? 0) + 0.7152 * (rgb[1] ?? 0) + 0.0722 * (rgb[2] ?? 0);
1467
1414
  const v = delinear(y);
1468
1415
  return toHex([v, v, v]);
@@ -1670,7 +1617,7 @@ function resolveTextColor(reference, design, fallback) {
1670
1617
  fallback
1671
1618
  });
1672
1619
  }
1673
- var GREY_RAMP = [0, 32, 64, 96, 128, 160, 192, 224, 255].map((v) => toHex([v, v, v]));
1620
+ var GRAY_RAMP = [0, 32, 64, 96, 128, 160, 192, 224, 255].map((v) => toHex([v, v, v]));
1674
1621
  function backdropColors(backdrop, box, size, layer) {
1675
1622
  switch (backdrop.kind) {
1676
1623
  case "solid":
@@ -1697,9 +1644,9 @@ function backdropColors(backdrop, box, size, layer) {
1697
1644
  }
1698
1645
  case "image": {
1699
1646
  const opacity = layer?.opacity ?? backdrop.opacity;
1700
- const ramp = layer?.grays ? [.../* @__PURE__ */ new Set([layer.grays[0], ...[0, 32, 64, 96, 128, 160, 192, 224, 255].filter((v) => v > layer.grays[0] && v < layer.grays[1]), layer.grays[1]])].map((v) => toHex([v, v, v])) : GREY_RAMP;
1701
- const colors = ramp.map((grey) => {
1702
- const pixel = layer?.duotone ? blend(layer.duotone[1], layer.duotone[0], toRgb(grey)[0] / 255) : grey;
1647
+ const ramp = layer?.grays ? [.../* @__PURE__ */ new Set([layer.grays[0], ...[0, 32, 64, 96, 128, 160, 192, 224, 255].filter((v) => v > layer.grays[0] && v < layer.grays[1]), layer.grays[1]])].map((v) => toHex([v, v, v])) : GRAY_RAMP;
1648
+ const colors = ramp.map((gray) => {
1649
+ const pixel = layer?.duotone ? blend(layer.duotone[1], layer.duotone[0], toRgb(gray)[0] / 255) : gray;
1703
1650
  let color = blend(pixel, backdrop.base, opacity);
1704
1651
  if (layer?.overlay) color = blend(layer.overlay.color, color, layer.overlay.opacity);
1705
1652
  return color;
@@ -1725,8 +1672,8 @@ function readableColor(candidates, sample, minimum) {
1725
1672
  }
1726
1673
 
1727
1674
  // src/rule-content.ts
1728
- var pointer2 = (...parts2) => parts2.length ? "/" + parts2.map((part) => String(part).replaceAll("~", "~0").replaceAll("/", "~1")).join("/") : "";
1729
- var pointerOfDotted = (path) => "/" + path.split(".").map((part) => part.replaceAll("~", "~0").replaceAll("/", "~1")).join("/");
1675
+ var pointer2 = (...parts2) => parts2.length ? "/" + parts2.map((part2) => String(part2).replaceAll("~", "~0").replaceAll("/", "~1")).join("/") : "";
1676
+ var pointerOfDotted = (path) => "/" + path.split(".").map((part2) => part2.replaceAll("~", "~0").replaceAll("/", "~1")).join("/");
1730
1677
  function slidePayloads(slide, slidePath) {
1731
1678
  const out = [{ path: slidePath, node: slide, root: true }];
1732
1679
  visitContentPayloads(slide, slidePath, (node, path) => out.push({ path, node, root: false }));
@@ -1801,7 +1748,7 @@ function textValues(slide, slidePath) {
1801
1748
  return out;
1802
1749
  }
1803
1750
  function splitPointer(path) {
1804
- return path === "" ? [] : path.slice(1).split("/").map((part) => part.replaceAll("~1", "/").replaceAll("~0", "~"));
1751
+ return path === "" ? [] : path.slice(1).split("/").map((part2) => part2.replaceAll("~1", "/").replaceAll("~0", "~"));
1805
1752
  }
1806
1753
  var plainText = (value) => typeof value === "string" ? value : value.map((run) => typeof run === "string" ? run : typeof rec(run).text === "string" ? rec(run).text : "").join("");
1807
1754
  function runsOf(tv) {
@@ -1937,7 +1884,7 @@ var formatRules = [
1937
1884
  rule("shape-anchor-missing", "format", "error", "An overlay shape has no resolvable block or qualified plotted chart point.", "An overlay shape placed with `at` sits against a composed block of its slide, named by the block's `id`. A chart point also requires a unique plotted category and series in a qualified shared plot. When an identity or geometry is missing, the shape is not drawn.", { standard: SCHEMA }),
1938
1885
  rule("shape-anchor-size-unit", "format", "warning", "A pixel size is under a fraction key.", "In `at`, `width` and `height` are fractions of the block (up to 8); pixels are `widthPx` and `heightPx`. A value above 4 and up to 8 is reported here; above 8 it is a schema error that offers the same rename.", { standard: SCHEMA }),
1939
1886
  rule("connector-end-missing", "format", "error", "A connector end names no block or overlay shape on the slide.", "A connector joins two shapes of its slide, each named by the `id` of a block or an overlay shape. With an end that names nothing (or names a connector) there is nothing to glue it to, so it is not drawn.", { standard: SCHEMA }),
1940
- rule("image-placement-invalid", "format", "error", "An image placement cannot be honoured.", "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 a promoted region, or a second block on the same edge, has nowhere to go.", { standard: SCHEMA }),
1887
+ 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 }),
1941
1888
  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 }),
1942
1889
  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 }),
1943
1890
  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 }),
@@ -1949,19 +1896,19 @@ var formatRules = [
1949
1896
  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 }),
1950
1897
  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 }),
1951
1898
  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 }),
1952
- rule("chart-highlight-unknown-name", "format", "error", "A chart highlight names a series or category the chart does not have.", "`chart.highlight` emphasises 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 }),
1899
+ 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 }),
1953
1900
  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 }),
1954
1901
  rule(
1955
1902
  "variable-unfilled",
1956
1903
  "format",
1957
1904
  "error",
1958
1905
  "A required template variable has no value.",
1959
- "A variable a deck declares as required, with no value, is template scaffolding: `{{name}}` tokens show up literally and colour variables fall back to a default. A normal deck must be filled, so this is an error and the deck is not valid; a template (`template: true`) is incomplete on purpose, so it is a warning.",
1906
+ "A variable a deck declares as required, with no value, is template scaffolding: `{{name}}` tokens show up literally and color variables fall back to a default. A normal deck must be filled, so this is an error and the deck is not valid; a template (`template: true`) is incomplete on purpose, so it is a warning.",
1960
1907
  {
1961
- approximations: "Required variables are those the variable machinery reports as unfilled for the document (declared, no value, not `required: false`, not given by the `values` option). For a document that declares no content variables, `{{id}}` / `{{id|format}}` tokens (`{{` escapes) left in any string outside `variables`, `extensions`, `catalogs` and `assets` are reported as warnings. `var:` colour references with no declaration are reported as `opf/variable-reference-unknown`. Fill a template with `opf fill` or `resolveVariables` to clear the findings."
1908
+ approximations: "Required variables are those the variable machinery reports as unfilled for the document (declared, no value, not `required: false`, not given by the `values` option). For a document that declares no content variables, `{{id}}` / `{{id|format}}` tokens (`{{` escapes) left in any string outside `variables`, `extensions`, `catalogs` and `assets` are reported as warnings. `var:` color references with no declaration are reported as `opf/variable-reference-unknown`. Fill a template with `opf fill` or `resolveVariables` to clear the findings."
1962
1909
  }
1963
1910
  ),
1964
- rule("run-color-unrecognized", "format", "warning", "A text run colour is none of the documented forms.", "Run colours are open strings so imported decks stay valid, but a value that is not a hex colour, a colour-scheme name or a `var:` reference falls back to the theme colour.", { standard: SCHEMA }),
1911
+ rule("run-color-unrecognized", "format", "warning", "A text run color is none of the documented forms.", "Run colors are open strings so imported decks stay valid, but a value that is not a hex color, a color-scheme name or a `var:` reference falls back to the theme color.", { standard: SCHEMA }),
1965
1912
  rule("numbering-start-ignored", "format", "warning", "A list entry sets `start` where nothing is numbered.", "A start value only restarts an auto-number; without `numbering` on the payload it has no effect.", { standard: SCHEMA }),
1966
1913
  rule(
1967
1914
  "slide-size-out-of-range",
@@ -1971,7 +1918,7 @@ var formatRules = [
1971
1918
  "The schema accepts any positive custom `widthInches` and `heightInches`, but a PPTX stores the size as `p:sldSz` with each side between 914400 and 51206400 EMU, which is 1 to 56 inches. A custom size outside that range exports a file that does not conform to the standard, which PowerPoint may reject or clamp. It is a warning because the document is still correct OPF and the preview draws it.",
1972
1919
  {
1973
1920
  standard: "ECMA-376 / ISO/IEC 29500-1 section 19.2.1.39 (p:sldSz) and section 19.7.17 (ST_SlideSizeCoordinate): 914400 to 51206400 EMU",
1974
- approximations: "Checks the deck's resolved size: `design.dimensions`, else the resolved theme's `dimensions`. Inches are converted to EMU as the PPTX exporter does (`Math.round(inches * 914400)`), so a side of exactly 1 in or 56 in passes. A slide-level theme with another size is `opf/slide-theme-dimensions`. Presets are always in range. PowerPoint's own behaviour at the limits was not measured."
1921
+ approximations: "Checks the deck's resolved size: `design.dimensions`, else the resolved theme's `dimensions`. Inches are converted to EMU as the PPTX exporter does (`Math.round(inches * 914400)`), so a side of exactly 1 in or 56 in passes. A slide-level theme with another size is `opf/slide-theme-dimensions`. Presets are always in range. PowerPoint's own behavior at the limits was not measured."
1975
1922
  }
1976
1923
  )
1977
1924
  ];
@@ -2006,7 +1953,7 @@ var referenceRules = [
2006
1953
  "references",
2007
1954
  "error",
2008
1955
  "A layout template's regions are not valid.",
2009
- "Region names are unique across the whole record and may not be tag, auto or a promoted-region word (start, center, end, top, middle, bottom), so a Markdown block's region= stays unambiguous; title and subtitle name the heading regions, which take only a size, an anchor and (the title) a rule; a subtitle region needs a title region; a region accepts at least one content kind; a region with flow 'none' holds one block; overflowRegion must name a body region. composeSlide refuses such a record.",
1956
+ "Region names are unique across the whole record and may not be tag, auto or a cell word of the slide grid (start, center, end, top, middle, bottom), so a block's region (and a Markdown block's region=) stays unambiguous; title and subtitle name the heading regions, which take only a size, an anchor and (the title) a rule; a subtitle region needs a title region; a region accepts at least one content kind; overflowRegion must name a body region. composeSlide refuses such a record.",
2010
1957
  { standard: "spec/schemas/layout.schema.json and the region rules (docs/layout-templates.md)" }
2011
1958
  ),
2012
1959
  rule(
@@ -2014,7 +1961,7 @@ var referenceRules = [
2014
1961
  "references",
2015
1962
  "warning",
2016
1963
  "A content reference resolves nowhere.",
2017
- "A layout, theme, colour scheme, font scheme, narrative, audience, purpose or tone reference that neither the document embeds nor a registered catalog defines falls back: a slide composes automatically, a design uses the engine default. A strict export fails instead. A slide with no layout is automatic composition and is never reported.",
1964
+ "A layout, theme, color scheme, font scheme, narrative, audience, purpose or tone reference that neither the document embeds nor a registered catalog defines falls back: a slide composes automatically, a design uses the engine default. A strict export fails instead. A slide with no layout is automatic composition and is never reported. A layout id that OPF has removed is reported with the safe fix that writes its replacement or deletes the key.",
2018
1965
  { standard: SCHEMA, approximations: 'Resolved like every engine resolves it: catalogs.custom, then the records embedded under catalogs.default, then the catalog registered for its source (the first registered catalog when `default` is omitted); `name:id` in catalogs.<name>, then the catalog registered for its source. Nothing is fetched. Free-form audience and purpose text is not a reference. It is a warning, not an error, because catalogs are open and a host may register the id; `--fail-on warning` is the check that a deck is done. With a catalog registered, the hint names the nearest records that exist ("Did you mean `two-column`?").' }
2019
1966
  ),
2020
1967
  rule(
@@ -2035,7 +1982,7 @@ var referenceRules = [
2035
1982
  rule("variable-unknown", "references", "warning", "A `{{token}}` names a variable that is not declared.", "An undeclared token is shown literally.", { standard: SCHEMA }),
2036
1983
  rule("variable-unknown-value", "references", "warning", "A value was supplied for a variable that is not declared.", "The value is never used.", { standard: SCHEMA }),
2037
1984
  rule("variable-unused", "references", "warning", "A variable is declared but never used.", "A declaration nothing refers to has no effect.", { standard: SCHEMA }),
2038
- rule("variable-reference-unknown", "references", "warning", "A `var:` colour names a variable that is not declared.", "An undeclared colour variable falls back to a default colour.", { standard: SCHEMA })
1985
+ 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 })
2039
1986
  ];
2040
1987
  var policyRules = [
2041
1988
  rule(
@@ -2063,7 +2010,7 @@ var dataRules = [
2063
2010
  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 }),
2064
2011
  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 }),
2065
2012
  rule("variable-builtin-missing", "content", "warning", "A built-in variable has no value in this document.", "A `{{deck.*}}`, `{{speaker.*}}` or `{{organization.*}}` token whose field the document does not set resolves to nothing, so the text shows a gap; a `var:organization.logo` reference to an organization without a logo draws no image. `{{slide.section}}` is checked per slide: a slide without a `section` that uses it, in its own text or in the header or footer it inherits, is reported at that slide.", { standard: SCHEMA }),
2066
- rule("variable-group-omitted", "content", "info", "A group is drawn only when one of its optional variables has a value.", "A group (a block or promoted region with `blocks`) whose content variables are all optional (`required: false`) and all unfilled is left out whole when the deck is filled: its pictures, cards and other text go with the fields the variables would fill, so a slide never draws a card around a picture with no text. Validation fills every variable with its example or a sample, so it reports the group here instead.", { standard: SCHEMA, approximations: "Counts the declared text, number, date, image, url and list variables the group uses as `{{id}}` or `var:id`, at any depth; color variables and built-ins do not count. A group that uses none, or any required or filled one, is kept and not reported." }),
2013
+ rule("variable-group-omitted", "content", "info", "A group is drawn only when one of its optional variables has a value.", "A group (a block with `blocks`) whose content variables are all optional (`required: false`) and all unfilled is left out whole when the deck is filled: its pictures, cards and other text go with the fields the variables would fill, so a slide never draws a card around a picture with no text. Validation fills every variable with its example or a sample, so it reports the group here instead.", { standard: SCHEMA, approximations: "Counts the declared text, number, date, image, url and list variables the group uses as `{{id}}` or `var:id`, at any depth; color variables and built-ins do not count. A group that uses none, or any required or filled one, is kept and not reported." }),
2067
2014
  rule("duration-outside-narrative", "content", "warning", "The target duration is outside the range the narrative suits.", "A narrative records the talk lengths it suits. A deck whose duration is outside that range probably needs a different narrative or a different length; nothing is drawn or exported differently.", { standard: SCHEMA }),
2068
2015
  rule("narrative-duration-range", "content", "warning", "An inline narrative duration range has min greater than max.", "A range with its bounds swapped matches no duration, so the duration check cannot help.", { standard: "spec/schemas/narrative.schema.json" })
2069
2016
  ];
@@ -2071,13 +2018,13 @@ var contrastRule = rule(
2071
2018
  "text-contrast",
2072
2019
  "accessibility",
2073
2020
  "warning",
2074
- "Text colour has too little contrast against the background it sits on.",
2075
- "Low-contrast text is hard or impossible to read for people with low vision, colour-vision differences, glare on a projector or a poor display. WCAG sets 4.5:1 for normal text and 3:1 for large text.",
2021
+ "Text color has too little contrast against the background it sits on.",
2022
+ "Low-contrast text is hard or impossible to read for people with low vision, color-vision differences, glare on a projector or a poor display. WCAG sets 4.5:1 for normal text and 3:1 for large text.",
2076
2023
  {
2077
2024
  standard: "WCAG 2.2 SC 1.4.3 Contrast (Minimum), level AA",
2078
2025
  thresholds: ["contrastNormal", "contrastLarge"],
2079
2026
  cost: "composition",
2080
- approximations: "Computed on sRGB colours with the WCAG relative-luminance formula, against the background the preview draws: a solid or theme colour, the card surface, a table cell fill, every colour a gradient takes under the text box (sampled on a 5x5 grid, angle respected), or both colours of a pattern. Anti-aliasing, text shadows and font weight are not modelled. Text colour is the preview's (the scheme's text role or dark1 on a light background and light1 on a dark one, chosen from the background luminance, where a gradient or picture background uses the scheme's default background colour), so a default can fail on a dark gradient. A link with no colour of its own is measured in the scheme's hyperlink colour."
2027
+ approximations: "Computed on sRGB colors with the WCAG relative-luminance formula, against the background the preview draws: a solid or theme color, the card surface, a table cell fill, every color a gradient takes under the text box (sampled on a 5x5 grid, angle respected), or both colors of a pattern. Anti-aliasing, text shadows and font weight are not modeled. Text color is the preview's (the scheme's text role or dark1 on a light background and light1 on a dark one, chosen from the background luminance, where a gradient or picture background uses the scheme's default background color), so a default can fail on a dark gradient. A link with no color of its own is measured in the scheme's hyperlink color."
2081
2028
  }
2082
2029
  );
2083
2030
  var onImageRule = rule(
@@ -2137,7 +2084,7 @@ var readingOrderRule = rule(
2137
2084
  {
2138
2085
  standard: 'WCAG 2.2 SC 1.3.2 Meaningful Sequence, level A (PowerPoint: "Check reading order")',
2139
2086
  cost: "composition",
2140
- approximations: "Compares the composed content order with a visual order recomputed from the composed boxes: items whose vertical centres fall in the same row are ordered along the reading direction (a right-to-left deck is checked by rows only), rows from top to bottom. A block is one unit (RR-105): blocks are ordered by the boxes that hold them, and a group's own items are read, in their own visual order, before the next block, so cards side by side (a picture over a name) read card by card. Headings are expected first. Content drawn entirely above the title, over the columns of the title, is reported; content in a column beside the title is read after it. Free-form overlap is not analysed. On a slide with a template layout (OPF 0.19) the expected order is the binding order instead (the regions in reading order, then the blocks of each region), and items outside a region (placed images, the row below the grid) are not compared."
2087
+ approximations: "Compares the composed content order with a visual order recomputed from the composed boxes: items whose vertical centers fall in the same row are ordered along the reading direction (a right-to-left deck is checked by rows only), rows from top to bottom. A block is one unit (RR-105): blocks are ordered by the boxes that hold them, and a group's own items are read, in their own visual order, before the next block, so cards side by side (a picture over a name) read card by card. Headings are expected first. Content drawn entirely above the title, over the columns of the title, is reported; content in a column beside the title is read after it. Free-form overlap is not analyzed. On a slide with a template layout (OPF 0.19) the expected order is the binding order instead (the regions in reading order, then the blocks of each region), and items outside a region (placed images, the row below the grid) are not compared."
2141
2088
  }
2142
2089
  );
2143
2090
  var linkRule = rule(
@@ -2152,12 +2099,12 @@ var chartColorRule = rule(
2152
2099
  "chart-color-only",
2153
2100
  "accessibility",
2154
2101
  "info",
2155
- "Chart series may be indistinguishable without colour vision.",
2156
- "OPF charts have no data labels or patterns, so series are told apart by colour alone (and legend order). Colours that look alike to someone with colour-vision deficiency, or when printed in greyscale, make series impossible to tell apart.",
2102
+ "Chart series may be indistinguishable without color vision.",
2103
+ "OPF charts have no data labels or patterns, so series are told apart by color alone (and legend order). Colors that look alike to someone with color-vision deficiency, or when printed in grayscale, make series impossible to tell apart.",
2157
2104
  {
2158
2105
  standard: "WCAG 2.2 SC 1.4.1 Use of Color, level A",
2159
2106
  thresholds: ["minSeriesColorDifference"],
2160
- approximations: "Uses the engine's series palette (ValidateOptions.chartPalette; default chartSeriesPalette of each slide color scheme (accent1 to accent6, then their tints), adjusted for the slide background and softened like the engines draw them, LH-105) in series order: series i takes color i, pie/doughnut/treemap/funnel slices take colours per category. Pairs are compared by CIE76 distance after simulating protanopia, deuteranopia, tritanopia (Machado 2009, severity 1) and greyscale. Neighbouring series (and neighbouring slices, on a pie or doughnut the last beside the first, which the engines move off the first by at most 20 L* or, where that is not enough, separate with a surface-colored slice border that this rule accepts, LH-161) must also differ by at least 11 in CIE L* (the lightness step the engines keep when they adjust a palette), since lightness is the cue left without hue (LH-35); a pair under it is reported as a lightness pair. Single-series charts and chart types without a series legend are skipped."
2107
+ approximations: "Uses the engine's series palette (ValidateOptions.chartPalette; default chartSeriesPalette of each slide color scheme (accent1 to accent6, then their tints), adjusted for the slide background and softened like the engines draw them, LH-105) in series order: series i takes color i, pie/doughnut/treemap/funnel slices take colors per category. Pairs are compared by CIE76 distance after simulating protanopia, deuteranopia, tritanopia (Machado 2009, severity 1) and grayscale. Neighboring series (and neighboring slices, on a pie or doughnut the last beside the first, which the engines move off the first by at most 20 L* or, where that is not enough, separate with a surface-colored slice border that this rule accepts, LH-161) must also differ by at least 11 in CIE L* (the lightness step the engines keep when they adjust a palette), since lightness is the cue left without hue (LH-35); a pair under it is reported as a lightness pair. Single-series charts and chart types without a series legend are skipped."
2161
2108
  }
2162
2109
  );
2163
2110
  var chartAltRule = rule(
@@ -2172,11 +2119,11 @@ var chartColorsRule = rule(
2172
2119
  "chart-colors-adjusted",
2173
2120
  "accessibility",
2174
2121
  "warning",
2175
- "A chart colour cannot be used as authored.",
2176
- "`chart.colors` sets the colour of series 1, 2, 3 and so on. A colour that cannot be resolved (a `var:` colour variable the deck does not define, or a name that is not a colour) is ignored and the deck palette colour of that position is used. A colour with under 3:1 contrast against the slide background the chart stands on is kept for its hue but drawn lighter or darker, so the chart does not show the colour that was written.",
2122
+ "A chart color cannot be used as authored.",
2123
+ "`chart.colors` sets the color of series 1, 2, 3 and so on. A color that cannot be resolved (a `var:` color variable the deck does not define, or a name that is not a color) is ignored and the deck palette color of that position is used. A color with under 3:1 contrast against the slide background the chart stands on is kept for its hue but drawn lighter or darker, so the chart does not show the color that was written.",
2177
2124
  {
2178
2125
  standard: "WCAG 2.2 SC 1.4.11 Non-text Contrast, level AA",
2179
- approximations: "Resolves each entry like any colour reference (hex, colour-scheme slot or role, `var:` variable) against the slide's scheme and compares it with the slide background (no chart has a panel, LH-105; a chart in a card stands on the card, which is not measured) by WCAG contrast; 3:1 is the threshold the engines enforce. Translucent colours and unresolved backgrounds are not measured. Colours that look alike to colour-vision deficiency are reported by opf/chart-color-only, which judges the authored colours."
2126
+ approximations: "Resolves each entry like any color reference (hex, color-scheme slot or role, `var:` variable) against the slide's scheme and compares it with the slide background (no chart has a panel, LH-105; a chart in a card stands on the card, which is not measured) by WCAG contrast; 3:1 is the threshold the engines enforce. Translucent colors and unresolved backgrounds are not measured. Colors that look alike to color-vision deficiency are reported by opf/chart-color-only, which judges the authored colors."
2180
2127
  }
2181
2128
  );
2182
2129
  var languageRule = rule(
@@ -2185,7 +2132,7 @@ var languageRule = rule(
2185
2132
  "info",
2186
2133
  "The presentation does not declare its language.",
2187
2134
  "Screen readers and text-to-speech choose pronunciation and hyphenation from the declared language; spell checkers and translation tools use it too.",
2188
- { standard: "WCAG 2.2 SC 3.1.1 Language of Page, level A", approximations: "Only the presentation-level `language` is checked, not the language of individual runs (`TextRun.language`; opf/language-tag checks how those tags are written)." }
2135
+ { standard: "WCAG 2.2 SC 3.1.1 Language of Page, level A", approximations: "Only the presentation-level `language` is checked, not the language of individual runs (`TextRun.language`; opf/language-tag checks how those tags are written). With no language set, a slide whose letters are mostly Arabic-script or Hebrew is laid out as Arabic or Hebrew, right to left (OPF 0.35); the message names those slides." }
2189
2136
  );
2190
2137
  var MAX_FURNITURE_LINES = 2;
2191
2138
  var overflowRule = rule(
@@ -2264,8 +2211,8 @@ var arrangementAdaptedRule = rule(
2264
2211
  "arrangement-adapted",
2265
2212
  "layout",
2266
2213
  "info",
2267
- "A pyramid, matrix, cycle, row of chevrons or flow is drawn another way.",
2268
- "A `pyramid`, `matrix`, `cycle`, `chevrons`, `flow` or `vertical-flow` region draws a list of one level of short entries as that diagram (docs/smartart.md). A matrix needs exactly four entries for its quadrants; with another count its entries are drawn as a grid of cards. A list the arrangement does not draw (nested entries, descriptions, icons, numbering, too many entries), or whose entries fit neither PowerPoint's design nor OPF's at the list's size, is drawn as a list.",
2214
+ "A diagram arrangement (a pyramid, matrix, cycle, row of chevrons, process, tree or Venn) is drawn another way.",
2215
+ "A region whose `arrangement` is `pyramid`, `inverted-pyramid`, `matrix`, `cycle`, `chevrons`, `process`, `vertical-process`, `org-chart`, `hierarchy` or `venn` draws a list of one level of short entries as that diagram (docs/smartart.md). A matrix needs exactly four entries for its quadrants; with another count its entries are drawn as a grid of cards. A list the arrangement does not draw (nested entries, descriptions, icons, numbering, too many entries), or whose entries fit neither PowerPoint's design nor OPF's at the list's size, is drawn as a list.",
2269
2216
  { cost: "composition" }
2270
2217
  );
2271
2218
  var shapeOffSlideRule = rule(
@@ -2456,7 +2403,7 @@ var chartPieManySlicesRule = rule(
2456
2403
  "content",
2457
2404
  "info",
2458
2405
  `A pie or doughnut chart has more than ${PIE_MAX_SLICES} slices.`,
2459
- "People compare angles and areas poorly, and past a few slices the small ones cannot be told apart or labelled. Bars along one axis show the same parts of a whole and let them be compared and ranked (Few, Show Me the Numbers).",
2406
+ "People compare angles and areas poorly, and past a few slices the small ones cannot be told apart or labeled. Bars along one axis show the same parts of a whole and let them be compared and ranked (Few, Show Me the Numbers).",
2460
2407
  {
2461
2408
  standard: `Stephen Few, Show Me the Numbers (2012), on pie charts; more than ${PIE_MAX_SLICES} categories.`,
2462
2409
  approximations: "Counts the rows (categories) of a `pie` or `doughnut` chart as its data resolves; a doughnut of several series (nested rings) counts the categories of a ring. Treemaps and funnels are not checked."
@@ -2595,18 +2542,18 @@ function collectSamples(context) {
2595
2542
  const valueColor = item.metricLayout ? metricValueColor(itemDesign.colors.primary, item.frameBox && !item.emphasis ? design.neutrals.card.hex : itemDesign.colors.background, itemDesign.colors.text) : itemDesign.colors.primary;
2596
2543
  const valueRole = (role) => role === "value" || role === "unit" && item.metricLayout?.arrangement === "inline-unit";
2597
2544
  if (layoutOf)
2598
- for (const part of layoutOf.parts) {
2599
- if (!part.fit || part.visible === false) continue;
2600
- const role = String(part.role ?? "");
2545
+ for (const part2 of layoutOf.parts) {
2546
+ if (!part2.fit || part2.visible === false) continue;
2547
+ const role = String(part2.role ?? "");
2601
2548
  parts2.push({
2602
- path: typeof part.path === "string" && part.path.startsWith("slides.") ? pointerOfDotted(part.path) : itemPath,
2603
- sizePx: part.fit.fontSize / scale,
2604
- color: role === "footer" ? itemDesign.colors.mutedText : valueRole(role) && item.metricLayout ? valueColor : item.timelineLayout ? timelineTextColor(part, { background: itemDesign.colors.background, primary: itemDesign.colors.primary, text: itemDesign.colors.text, mutedText: itemDesign.colors.mutedText }) : itemDesign.colors.text,
2549
+ path: typeof part2.path === "string" && part2.path.startsWith("slides.") ? pointerOfDotted(part2.path) : itemPath,
2550
+ sizePx: part2.fit.fontSize / scale,
2551
+ color: role === "footer" ? itemDesign.colors.mutedText : valueRole(role) && item.metricLayout ? valueColor : item.timelineLayout ? timelineTextColor(part2, { background: itemDesign.colors.background, primary: itemDesign.colors.primary, text: itemDesign.colors.text, mutedText: itemDesign.colors.mutedText }) : itemDesign.colors.text,
2605
2552
  label: item.field === "quote" ? role === "footer" ? "Quote attribution" : "Quote" : item.field === "metric" ? role === "value" ? "Metric value" : "Metric label" : "Timeline text"
2606
2553
  });
2607
2554
  }
2608
2555
  else parts2.push({ path: itemPath, sizePx: baseSize, color: itemDesign.colors.text, label: heading || item.field === "text" ? label : item.field === "items" || item.field === "bullets" ? "List text" : label });
2609
- for (const part of parts2) samples.push({ path: part.path, color: part.color, sizePx: part.sizePx, bold, backdrop, source: "default", label: part.label });
2556
+ for (const part2 of parts2) samples.push({ path: part2.path, color: part2.color, sizePx: part2.sizePx, bold, backdrop, source: "default", label: part2.label });
2610
2557
  const owners = textValues({ [item.field]: item.value }, "");
2611
2558
  for (const owner of owners) {
2612
2559
  if (typeof owner.value === "string") continue;
@@ -2617,13 +2564,13 @@ function collectSamples(context) {
2617
2564
  const color = resolveTextColor(run.style.color, itemDesign, itemDesign.colors.text);
2618
2565
  if (!color) continue;
2619
2566
  const size = typeof run.style.fontSize === "number" ? run.style.fontSize / PX_TO_PT : baseSize;
2620
- samples.push({ path: `${run.path}/color`, color, sizePx: size, bold: Boolean(run.style.bold) || bold, backdrop, source: "override", colorPath: `${run.path}/color`, label: "Coloured text" });
2567
+ samples.push({ path: `${run.path}/color`, color, sizePx: size, bold: Boolean(run.style.bold) || bold, backdrop, source: "override", colorPath: `${run.path}/color`, label: "Colored text" });
2621
2568
  }
2622
2569
  }
2623
2570
  }
2624
- for (const part of composition.furniture?.parts ?? [])
2625
- if (part.type === "text")
2626
- samples.push({ path: pointerOfDotted(part.sourcePath ?? part.path), color: design.colors.mutedText, sizePx: (part.fit?.fontSize ?? 13 * scale) / scale, bold: false, backdrop: slideBackdrop(context, part.box), source: "default", label: part.kind === "header" ? "Header text" : "Footer text" });
2571
+ for (const part2 of composition.furniture?.parts ?? [])
2572
+ if (part2.type === "text")
2573
+ samples.push({ path: pointerOfDotted(part2.sourcePath ?? part2.path), color: design.colors.mutedText, sizePx: (part2.fit?.fontSize ?? 13 * scale) / scale, bold: false, backdrop: slideBackdrop(context, part2.box), source: "default", label: part2.kind === "header" ? "Header text" : "Footer text" });
2627
2574
  return samples;
2628
2575
  }
2629
2576
  var contrastRules = [
@@ -2646,7 +2593,7 @@ var contrastRules = [
2646
2593
  path: sample.path,
2647
2594
  slide,
2648
2595
  severity: "warning",
2649
- message: `${sample.label} colour ${sample.color} is too faint on this background picture: over every colour the picture can show here its contrast is at most ${best.toFixed(1)}:1, and ${needed}:1 is needed at this size.`,
2596
+ message: `${sample.label} color ${sample.color} is too faint on this background picture: over every color the picture can show here its contrast is at most ${best.toFixed(1)}:1, and ${needed}:1 is needed at this size.`,
2650
2597
  help: "Set the background's tone (dark or light) so the text color follows the picture, give the text a readable color, or make the overlay strong enough for the text to read.",
2651
2598
  measured: { ratio: round(worst.ratio), best: round(best), needed, textColor: sample.color }
2652
2599
  });
@@ -2675,14 +2622,14 @@ var contrastRules = [
2675
2622
  const preferred = readableColor([slide.design.colors.text], sample.backdrop, needed);
2676
2623
  if (preferred !== void 0) {
2677
2624
  const value = preferred.toUpperCase() === slide.design.colors.text.toUpperCase() ? "text" : preferred;
2678
- fixes.push({ id: "use-readable-color", title: value === "text" ? "Use the slide text colour" : `Use ${preferred}`, kind: "patch", safe: true, patch: [{ op: "replace", path: sample.colorPath, value }] });
2625
+ fixes.push({ id: "use-readable-color", title: value === "text" ? "Use the slide text color" : `Use ${preferred}`, kind: "patch", safe: false, patch: [{ op: "replace", path: sample.colorPath, value }] });
2679
2626
  }
2680
2627
  }
2681
2628
  const diagnostic = context.report(contrastRule, {
2682
2629
  path: sample.path,
2683
2630
  slide,
2684
- message: `${sample.label} colour ${sample.color} on ${worst.against} has a contrast ratio of ${worst.ratio.toFixed(2)}:1; ${needed}:1 is needed for ${large ? "large" : "normal"} text.`,
2685
- help: sample.source === "override" ? "Pick a colour with enough contrast against the background, or remove this colour override so the theme chooses a readable text colour." : "The theme text colour is unreadable on this background. Change the slide or deck background, the colour scheme (dark1/light1), or give the text an explicit readable colour.",
2631
+ message: `${sample.label} color ${sample.color} on ${worst.against} has a contrast ratio of ${worst.ratio.toFixed(2)}:1; ${needed}:1 is needed for ${large ? "large" : "normal"} text.`,
2632
+ help: sample.source === "override" ? "Pick a color with enough contrast against the background, or remove this color override so the theme chooses a readable text color." : "The theme text color is unreadable on this background. Change the slide or deck background, the color scheme (dark1/light1), or give the text an explicit readable color.",
2686
2633
  measured: { ratio: round(worst.ratio), needed, large, sizePt: round(sample.sizePx * PX_TO_PT), textColor: sample.color, backgroundColor: worst.against },
2687
2634
  fixes
2688
2635
  });
@@ -2855,7 +2802,7 @@ var readingOrderRules = [
2855
2802
  path: pointerOfDotted(composed[index]),
2856
2803
  slide,
2857
2804
  message: `Reading order differs from visual order: ${JSON.stringify(name(composed[index]))} is read at ${ordinal(index)} but appears at ${ordinal(visual.indexOf(composed[index]))}. Composed order: ${composed.map(name).join(", ")}; visual order: ${visual.map(name).join(", ")}.`,
2858
- help: "Reorder the blocks (or rename promoted regions) so the composed order follows the visual order, or use blocks with an explicit composition instead of region keys.",
2805
+ help: "Reorder the blocks (or place them in other cells of the slide's grid) so the composed order follows the visual order, or use blocks with an explicit composition instead of cells.",
2859
2806
  measured: { firstMismatch: index, composed: composed.length }
2860
2807
  });
2861
2808
  }
@@ -2981,7 +2928,7 @@ var chartRules = [
2981
2928
  context.report(chartColorRule, {
2982
2929
  path: `${payload.path === slide.path ? slide.path : payload.path}/chart`,
2983
2930
  slide,
2984
- message: `${slices ? "Slices" : "Series"} may be hard to tell apart without colour: ${pairs.slice(0, 3).map(describe2).join("; ")}${cycles ? `${pairs.length ? "; " : ""}${count} ${slices ? "slices" : "series"} exceed the ${palette.length}-colour palette, so colours repeat` : ""}.`,
2931
+ message: `${slices ? "Slices" : "Series"} may be hard to tell apart without color: ${pairs.slice(0, 3).map(describe2).join("; ")}${cycles ? `${pairs.length ? "; " : ""}${count} ${slices ? "slices" : "series"} exceed the ${palette.length}-color palette, so colors repeat` : ""}.`,
2985
2932
  help: "Show fewer series per chart (split into two charts), state the key values in the slide text or a table next to the chart, or choose a chart type whose categories sit on an axis instead of in a legend.",
2986
2933
  measured: { series: count, confusablePairs: pairs.length, minDifference: pairs[0] ? round(pairs[0].difference) : null }
2987
2934
  });
@@ -3004,8 +2951,8 @@ var chartRules = [
3004
2951
  context.report(chartColorsRule, {
3005
2952
  path,
3006
2953
  slide,
3007
- message: `Chart colour ${index + 1} (${JSON.stringify(entry2)}) cannot be resolved, so the palette colour of that position is used.`,
3008
- help: 'Use a hex colour, a colour-scheme name such as "accent2", or the id of a colour variable the deck defines (var:<id>).'
2954
+ message: `Chart color ${index + 1} (${JSON.stringify(entry2)}) cannot be resolved, so the palette color of that position is used.`,
2955
+ help: 'Use a hex color, a color-scheme name such as "accent2", or the id of a color variable the deck defines (var:<id>).'
3009
2956
  });
3010
2957
  return;
3011
2958
  }
@@ -3014,8 +2961,8 @@ var chartRules = [
3014
2961
  context.report(chartColorsRule, {
3015
2962
  path,
3016
2963
  slide,
3017
- message: `Chart colour ${index + 1} (${color}) has ${contrast.toFixed(1)}:1 contrast against the slide background (${surface}); it is drawn lighter or darker to reach 3:1.`,
3018
- help: "Choose a colour that already has at least 3:1 contrast against the slide background, so the chart shows the colour you wrote.",
2964
+ message: `Chart color ${index + 1} (${color}) has ${contrast.toFixed(1)}:1 contrast against the slide background (${surface}); it is drawn lighter or darker to reach 3:1.`,
2965
+ help: "Choose a color that already has at least 3:1 contrast against the slide background, so the chart shows the color you wrote.",
3019
2966
  measured: { contrast: round(contrast), panel: surface }
3020
2967
  });
3021
2968
  });
@@ -3066,10 +3013,23 @@ var languageRules = [
3066
3013
  info: languageRule,
3067
3014
  run(context) {
3068
3015
  if (context.document.language !== void 0) return;
3016
+ const read = /* @__PURE__ */ new Map();
3017
+ for (const slide of context.slides) {
3018
+ const tag = slide.slide.language === void 0 ? languageOfText(context.document, slide.index) : void 0;
3019
+ if (tag) read.set(tag, [...read.get(tag) ?? [], slide.index + 1]);
3020
+ }
3021
+ const NAMES = { ar: "Arabic", he: "Hebrew" };
3022
+ const list = (numbers) => numbers.length === 1 ? `slide ${numbers[0]} is` : `slides ${numbers.slice(0, -1).join(", ")} and ${numbers.at(-1)} are`;
3023
+ const notes = [...read].map(([tag, numbers]) => {
3024
+ const name = NAMES[tag] ?? tag;
3025
+ const who = numbers.length === context.slides.length ? numbers.length === 1 ? "Its slide is" : "Its slides are" : `${list(numbers).replace(/^s/, "S")}`;
3026
+ return `${who} written in the ${name} script, so OPF lays ${numbers.length === 1 ? "it" : "them"} out as ${name} ("${tag}"): right to left, with that language's default fonts.`;
3027
+ });
3028
+ const first = [...read.keys()][0];
3069
3029
  context.report(languageRule, {
3070
3030
  path: "",
3071
- message: "The presentation has no language set.",
3072
- help: 'Set `language` to a BCP 47 tag, for example "en-US".',
3031
+ message: ["The presentation has no language set.", ...notes].join(" "),
3032
+ help: !first ? 'Set `language` to a BCP 47 tag, for example "en-US".' : read.size === 1 && read.get(first)?.length === context.slides.length ? `Set \`language\` to say so, for example "${first}", or to another BCP 47 tag to choose differently.` : `Set the deck's \`language\` to its main language, and \`language\` on those slides to say so (for example "${first}") or to choose differently.`,
3073
3033
  fixes: [{ id: "focus-language", title: "Set the language", kind: "focus", safe: true, focus: { path: "/language", field: "language" } }]
3074
3034
  });
3075
3035
  }
@@ -3187,11 +3147,347 @@ var languageTagRules = [
3187
3147
  }
3188
3148
  ];
3189
3149
 
3150
+ // src/document-hash.ts
3151
+ function canonicalJson(value) {
3152
+ const stack = [];
3153
+ const write = (item) => {
3154
+ if (item === null || typeof item === "boolean" || typeof item === "string") return JSON.stringify(item);
3155
+ if (typeof item === "number") return JSON.stringify(item);
3156
+ if (typeof item === "bigint") throw new TypeError("A BigInt is not JSON.");
3157
+ if (typeof item !== "object") return void 0;
3158
+ if (stack.includes(item)) throw new TypeError("A cyclic value has no canonical JSON.");
3159
+ stack.push(item);
3160
+ let text2;
3161
+ if (Array.isArray(item)) {
3162
+ text2 = `[${item.map((entry2) => write(entry2) ?? "null").join(",")}]`;
3163
+ } else {
3164
+ const record = item;
3165
+ const members = [];
3166
+ for (const key3 of Object.keys(record).sort()) {
3167
+ const member = write(record[key3]);
3168
+ if (member !== void 0) members.push(`${JSON.stringify(key3)}:${member}`);
3169
+ }
3170
+ text2 = `{${members.join(",")}}`;
3171
+ }
3172
+ stack.pop();
3173
+ return text2;
3174
+ };
3175
+ return write(value) ?? "null";
3176
+ }
3177
+ var K = new Uint32Array([
3178
+ 1116352408,
3179
+ 1899447441,
3180
+ 3049323471,
3181
+ 3921009573,
3182
+ 961987163,
3183
+ 1508970993,
3184
+ 2453635748,
3185
+ 2870763221,
3186
+ 3624381080,
3187
+ 310598401,
3188
+ 607225278,
3189
+ 1426881987,
3190
+ 1925078388,
3191
+ 2162078206,
3192
+ 2614888103,
3193
+ 3248222580,
3194
+ 3835390401,
3195
+ 4022224774,
3196
+ 264347078,
3197
+ 604807628,
3198
+ 770255983,
3199
+ 1249150122,
3200
+ 1555081692,
3201
+ 1996064986,
3202
+ 2554220882,
3203
+ 2821834349,
3204
+ 2952996808,
3205
+ 3210313671,
3206
+ 3336571891,
3207
+ 3584528711,
3208
+ 113926993,
3209
+ 338241895,
3210
+ 666307205,
3211
+ 773529912,
3212
+ 1294757372,
3213
+ 1396182291,
3214
+ 1695183700,
3215
+ 1986661051,
3216
+ 2177026350,
3217
+ 2456956037,
3218
+ 2730485921,
3219
+ 2820302411,
3220
+ 3259730800,
3221
+ 3345764771,
3222
+ 3516065817,
3223
+ 3600352804,
3224
+ 4094571909,
3225
+ 275423344,
3226
+ 430227734,
3227
+ 506948616,
3228
+ 659060556,
3229
+ 883997877,
3230
+ 958139571,
3231
+ 1322822218,
3232
+ 1537002063,
3233
+ 1747873779,
3234
+ 1955562222,
3235
+ 2024104815,
3236
+ 2227730452,
3237
+ 2361852424,
3238
+ 2428436474,
3239
+ 2756734187,
3240
+ 3204031479,
3241
+ 3329325298
3242
+ ]);
3243
+ function sha256Hex(bytes) {
3244
+ const length = bytes.length;
3245
+ const padded = new Uint8Array(length + 9 + 63 >> 6 << 6);
3246
+ padded.set(bytes);
3247
+ padded[length] = 128;
3248
+ const view = new DataView(padded.buffer);
3249
+ view.setUint32(padded.length - 8, Math.floor(length / 536870912), false);
3250
+ view.setUint32(padded.length - 4, length << 3 >>> 0, false);
3251
+ const h = new Uint32Array([1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]);
3252
+ const w = new Uint32Array(64);
3253
+ for (let offset = 0; offset < padded.length; offset += 64) {
3254
+ for (let i = 0; i < 16; i += 1) w[i] = view.getUint32(offset + i * 4, false);
3255
+ for (let i = 16; i < 64; i += 1) {
3256
+ const a2 = w[i - 15], b2 = w[i - 2];
3257
+ const s0 = (a2 >>> 7 | a2 << 25) ^ (a2 >>> 18 | a2 << 14) ^ a2 >>> 3;
3258
+ const s1 = (b2 >>> 17 | b2 << 15) ^ (b2 >>> 19 | b2 << 13) ^ b2 >>> 10;
3259
+ w[i] = w[i - 16] + s0 + w[i - 7] + s1 | 0;
3260
+ }
3261
+ let a = h[0], b = h[1], c = h[2], d = h[3], e = h[4], f = h[5], g = h[6], hh = h[7];
3262
+ for (let i = 0; i < 64; i += 1) {
3263
+ const s1 = (e >>> 6 | e << 26) ^ (e >>> 11 | e << 21) ^ (e >>> 25 | e << 7);
3264
+ const choose = e & f ^ ~e & g;
3265
+ const t1 = hh + s1 + choose + K[i] + w[i] | 0;
3266
+ const s0 = (a >>> 2 | a << 30) ^ (a >>> 13 | a << 19) ^ (a >>> 22 | a << 10);
3267
+ const majority = a & b ^ a & c ^ b & c;
3268
+ const t2 = s0 + majority | 0;
3269
+ hh = g;
3270
+ g = f;
3271
+ f = e;
3272
+ e = d + t1 | 0;
3273
+ d = c;
3274
+ c = b;
3275
+ b = a;
3276
+ a = t1 + t2 | 0;
3277
+ }
3278
+ h[0] = h[0] + a | 0;
3279
+ h[1] = h[1] + b | 0;
3280
+ h[2] = h[2] + c | 0;
3281
+ h[3] = h[3] + d | 0;
3282
+ h[4] = h[4] + e | 0;
3283
+ h[5] = h[5] + f | 0;
3284
+ h[6] = h[6] + g | 0;
3285
+ h[7] = h[7] + hh | 0;
3286
+ }
3287
+ let hex = "";
3288
+ for (const word of h) hex += word.toString(16).padStart(8, "0");
3289
+ return hex;
3290
+ }
3291
+ function documentHash(document) {
3292
+ return `sha256:${sha256Hex(new TextEncoder().encode(canonicalJson(document)))}`;
3293
+ }
3294
+ var HASH_PATTERN = /^(?:sha256:)?([0-9a-fA-F]{64})$/;
3295
+ function normalizeDocumentHash(value) {
3296
+ if (typeof value !== "string") return void 0;
3297
+ const match2 = HASH_PATTERN.exec(value);
3298
+ return match2 ? `sha256:${match2[1].toLowerCase()}` : void 0;
3299
+ }
3300
+
3301
+ // src/stale-records.ts
3302
+ var isRec2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
3303
+ var rec2 = (value) => isRec2(value) ? value : {};
3304
+ var part = (value) => String(value).replaceAll("~", "~0").replaceAll("/", "~1");
3305
+ var pointer3 = (segments) => `/${segments.map(part).join("/")}`;
3306
+ var slideAt = (document, index) => {
3307
+ const slides = rec2(document).slides;
3308
+ return Array.isArray(slides) ? rec2(slides[index]) : {};
3309
+ };
3310
+ var embeddedLayouts = (document, group) => rec2(rec2(rec2(rec2(document).catalogs)[group]).layouts);
3311
+ var RENAMED_REGIONS = Object.freeze({
3312
+ agenda: { items: "body" },
3313
+ "agenda-split": { items: "body" },
3314
+ chart: { charts: "body", note: "aside" },
3315
+ "chart-beside": { chart: "body", notes: "aside" },
3316
+ chevrons: { stages: "body" },
3317
+ closing: { details: "body" },
3318
+ code: { code: "body", notes: "aside" },
3319
+ comparison: { verdict: "aside" },
3320
+ cycle: { stages: "body" },
3321
+ dashboard: { kpis: "lead", charts: "body" },
3322
+ faq: { questions: "body" },
3323
+ flow: { stages: "body" },
3324
+ gallery: { pictures: "body" },
3325
+ hero: { support: "body" },
3326
+ hierarchy: { nodes: "body" },
3327
+ "inverted-pyramid": { levels: "body" },
3328
+ logos: { logos: "body" },
3329
+ matrix: { quadrants: "body" },
3330
+ metrics: { metrics: "body", note: "aside" },
3331
+ "org-chart": { people: "body" },
3332
+ pillars: { pillars: "body" },
3333
+ process: { steps: "body", stages: "body" },
3334
+ pyramid: { levels: "body" },
3335
+ quote: { quotes: "body" },
3336
+ scorecard: { cards: "body" },
3337
+ statement: { message: "body" },
3338
+ table: { table: "body", note: "aside" },
3339
+ "table-beside": { table: "body", notes: "aside" },
3340
+ team: { people: "body" },
3341
+ timeline: { timeline: "body", notes: "aside" },
3342
+ venn: { sets: "body" },
3343
+ "vertical-flow": { stages: "body" },
3344
+ "vertical-process": { stages: "body" }
3345
+ });
3346
+ function renamedRegion(layout, region) {
3347
+ const names2 = Object.hasOwn(RENAMED_REGIONS, layout) ? RENAMED_REGIONS[layout] : void 0;
3348
+ return names2 && Object.hasOwn(names2, region) ? names2[region] : void 0;
3349
+ }
3350
+ function layoutRegionNames(record) {
3351
+ const names2 = /* @__PURE__ */ new Set();
3352
+ const walk2 = (regions) => {
3353
+ if (!Array.isArray(regions)) return;
3354
+ for (const region of regions) {
3355
+ if (!isRec2(region)) continue;
3356
+ if (typeof region.name === "string") names2.add(region.name);
3357
+ walk2(region.regions);
3358
+ }
3359
+ };
3360
+ walk2(rec2(record).regions);
3361
+ return names2;
3362
+ }
3363
+ function layoutRecordIssues(id, record) {
3364
+ return validateAgainstSchema(isRec2(record) ? { $schema: schemas[catalogSchemaNames.layouts].$id, id, ...record } : record, "layouts").errors;
3365
+ }
3366
+ function staleLayoutCopy(document, group, id, options2 = {}) {
3367
+ if (group === "custom") return void 0;
3368
+ const record = embeddedLayouts(document, group)[id];
3369
+ if (!isRec2(record)) return void 0;
3370
+ const registered = rec2(registeredCatalog(catalogGroupSource(document, group, options2), options2)?.layouts);
3371
+ const base = { group, id, path: pointer3(["catalogs", group, "layouts", id]) };
3372
+ if (isRec2(registered[id])) return { ...base, current: embeddedCopy(registered[id]) };
3373
+ const next = renamedLayout("layouts", id);
3374
+ if (next === void 0) return void 0;
3375
+ const position = renamedLayoutTitlePosition("layouts", id);
3376
+ return { ...base, renamed: { id: next, ...isRec2(registered[next]) ? { current: embeddedCopy(registered[next]) } : {}, ...position ? { titlePosition: position } : {} } };
3377
+ }
3378
+ function staleCopyCause(copy) {
3379
+ const head = `catalogs.${copy.group}.layouts.${copy.id} is a copy of the built-in layout '${copy.id}' from before OPF 0.35${copy.renamed ? `, which 0.35 removed (use '${copy.renamed.id}')` : ""}; 0.35 changed the keys of the built-in records, so the copy fails the 0.35 layout schema.`;
3380
+ const mirror = `catalogs.${copy.group} mirrors the built-in records (keep a customized layout in catalogs.custom), and the 0.35 engine draws the slides, which may look different.`;
3381
+ if (copy.renamed) return `${head} The fix rename-layout (\`opf fix -i\` and \`opf embed -i\` apply it) moves its slides to '${copy.renamed.id}'${copy.renamed.titlePosition ? ` with design.titlePosition "${copy.renamed.titlePosition}"` : ""} and drops the copy; ${mirror}`;
3382
+ return `${head} The fix use-current-record (\`opf fix -i\` and \`opf embed -i\` apply it) replaces it with the current record and renames the region pins of its slides; ${mirror}`;
3383
+ }
3384
+ function slidesUsing(document, copy, options2) {
3385
+ const slides = rec2(document).slides;
3386
+ const using = [];
3387
+ (Array.isArray(slides) ? slides : []).forEach((slide, index) => {
3388
+ const reference = rec2(slide).layout;
3389
+ if (typeof reference !== "string") return;
3390
+ const found = resolveReference(document, "layouts", reference, options2);
3391
+ if (found?.origin === "document" && found.group === copy.group && found.id === copy.id) using.push({ index, reference });
3392
+ });
3393
+ return using;
3394
+ }
3395
+ function pinOperations(document, index, layout, before, next) {
3396
+ const names2 = layoutRegionNames(next);
3397
+ const blocks = slideAt(document, index).blocks;
3398
+ const ops = [];
3399
+ (Array.isArray(blocks) ? blocks : []).forEach((block, at2) => {
3400
+ const pin = rec2(block).region;
3401
+ if (typeof pin !== "string" || names2.has(pin) || !before.has(pin)) return;
3402
+ const renamed = renamedRegion(layout, pin);
3403
+ if (renamed !== void 0 && names2.has(renamed)) ops.push({ op: "replace", path: pointer3(["slides", index, "blocks", at2, "region"]), value: renamed });
3404
+ });
3405
+ return ops;
3406
+ }
3407
+ function titlePositionOperations(document, index, position) {
3408
+ if (position === void 0) return [];
3409
+ const design = slideAt(document, index).design;
3410
+ if (isRec2(design) && design.titlePosition !== void 0) return [];
3411
+ return isRec2(design) ? [{ op: "add", path: pointer3(["slides", index, "design", "titlePosition"]), value: position }] : [{ op: "add", path: pointer3(["slides", index, "design"]), value: { titlePosition: position } }];
3412
+ }
3413
+ function droppedCopyOperations(document, copy) {
3414
+ if (!copy.renamed) return [];
3415
+ const ops = [{ op: "remove", path: copy.path }];
3416
+ if (copy.renamed.current && !Object.hasOwn(embeddedLayouts(document, copy.group), copy.renamed.id)) ops.push({ op: "add", path: pointer3(["catalogs", copy.group, "layouts", copy.renamed.id]), value: copy.renamed.current });
3417
+ return ops;
3418
+ }
3419
+ function staleCopyUsers(document, copy, options2 = {}) {
3420
+ return slidesUsing(document, copy, options2).map((entry2) => entry2.index);
3421
+ }
3422
+ function staleCopyPatch(document, copy, options2 = {}) {
3423
+ const before = layoutRegionNames(embeddedLayouts(document, copy.group)[copy.id]);
3424
+ const using = slidesUsing(document, copy, options2);
3425
+ if (copy.current) return [{ op: "replace", path: copy.path, value: copy.current }, ...using.flatMap(({ index }) => pinOperations(document, index, copy.id, before, copy.current))];
3426
+ if (!copy.renamed) return void 0;
3427
+ const replacement = copy.renamed.current ?? embeddedLayouts(document, copy.group)[copy.renamed.id];
3428
+ const ops = [];
3429
+ for (const { index, reference } of using) {
3430
+ ops.push({ op: "replace", path: pointer3(["slides", index, "layout"]), value: renamedLayout("layouts", reference) ?? copy.renamed.id }, ...titlePositionOperations(document, index, copy.renamed.titlePosition));
3431
+ if (isRec2(replacement)) ops.push(...pinOperations(document, index, copy.id, before, replacement));
3432
+ }
3433
+ return [...ops, ...droppedCopyOperations(document, copy)];
3434
+ }
3435
+ var recordChanged = (document, copy, target) => !isRec2(target) || documentHash(embeddedLayouts(document, copy.group)[copy.id]) !== documentHash(target);
3436
+ var replacementOf = (document, copy) => copy.current ?? copy.renamed?.current ?? (copy.renamed ? embeddedLayouts(document, copy.group)[copy.renamed.id] : void 0);
3437
+ function staleCopyFix(document, copy, options2 = {}) {
3438
+ const patch2 = staleCopyPatch(document, copy, options2);
3439
+ if (!patch2) return void 0;
3440
+ const marks = { kind: "patch", safe: true, ...recordChanged(document, copy, replacementOf(document, copy)) ? { changesDrawing: true } : {}, patch: patch2 };
3441
+ 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 };
3442
+ }
3443
+ var applyOperation = (root, operation) => {
3444
+ const segmentsOf2 = (path) => path.slice(1).split("/").map((segment) => segment.replaceAll("~1", "/").replaceAll("~0", "~"));
3445
+ const parentOf2 = (segments2) => segments2.slice(0, -1).reduce((node, segment) => node[segment], root);
3446
+ const segments = segmentsOf2(operation.path);
3447
+ if (operation.op === "move") {
3448
+ const from = segmentsOf2(operation.from);
3449
+ const value = parentOf2(from)[from.at(-1)];
3450
+ delete parentOf2(from)[from.at(-1)];
3451
+ parentOf2(segments)[segments.at(-1)] = value;
3452
+ } else if (operation.op === "remove") delete parentOf2(segments)[segments.at(-1)];
3453
+ else if (operation.op === "add" || operation.op === "replace") parentOf2(segments)[segments.at(-1)] = structuredClone(operation.value);
3454
+ };
3455
+ function refreshStaleLayouts(document, options2 = {}) {
3456
+ const refreshed = [];
3457
+ for (const [group, value] of Object.entries(rec2(document.catalogs))) {
3458
+ if (group === "custom" || !isRec2(value) || !isRec2(value.layouts)) continue;
3459
+ for (const [id, record] of Object.entries(value.layouts)) {
3460
+ if (!layoutRecordIssues(id, record).length) continue;
3461
+ const copy = staleLayoutCopy(document, group, id, options2);
3462
+ if (!copy || !(copy.current || copy.renamed?.current)) continue;
3463
+ const patch2 = staleCopyPatch(document, copy, options2);
3464
+ if (!patch2) continue;
3465
+ const changed = recordChanged(document, copy, replacementOf(document, copy));
3466
+ for (const operation of patch2) applyOperation(document, operation);
3467
+ const source = catalogGroupSource(document, group, options2);
3468
+ refreshed.push({ group, kind: "layouts", id, ...source !== void 0 ? { source } : {}, how: copy.renamed ? "renamed" : "current", ...copy.renamed ? { renamedTo: copy.renamed.id } : {}, ...changed ? { changesDrawing: true } : {}, references: patch2.filter((operation) => operation.path.startsWith("/slides/")).map((operation) => operation.path) });
3469
+ }
3470
+ }
3471
+ return refreshed;
3472
+ }
3473
+
3190
3474
  // src/rules-layout-content.ts
3191
3475
  var PX_TO_PT2 = 0.75;
3192
3476
  var round2 = (value, places = 1) => Math.round(value * 10 ** places) / 10 ** places;
3193
3477
  var pointAnchorRule = ruleInfo("opf/shape-anchor-missing");
3194
3478
  var REGION_RULES = { "region-unknown": regionUnknownRule, "region-kind": regionKindRule, "region-full": regionFullRule, "layout-unplaced": unplacedRule };
3479
+ function renamedPin(context, slide, path, pin) {
3480
+ const reference = slide.slide.layout;
3481
+ if (typeof pin !== "string" || typeof reference !== "string") return void 0;
3482
+ const found = resolveReference(context.document, "layouts", reference, { ...context.options.catalogs ? { catalogs: context.options.catalogs } : {} });
3483
+ if (!found || found.group !== "default") return void 0;
3484
+ const next = renamedRegion(found.id, pin);
3485
+ if (next === void 0 || !layoutRegionNames(found.record).has(next)) return void 0;
3486
+ return {
3487
+ help: `OPF 0.35 renamed region '${pin}' of the built-in layout '${found.id}' to '${next}' (the built-in layouts use the standard region names). Rename the pin (fix rename-region), which puts the block back in that region.`,
3488
+ fix: { id: "rename-region", title: `Pin to ${next}`, kind: "patch", safe: true, patch: [{ op: "replace", path, value: next }] }
3489
+ };
3490
+ }
3195
3491
  var layoutRules = [
3196
3492
  {
3197
3493
  info: overflowRule,
@@ -3224,11 +3520,12 @@ var layoutRules = [
3224
3520
  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." });
3225
3521
  else if (diagnostic.code === "timeline-period-short")
3226
3522
  context.report(timelinePeriodShortRule, { path, slide, message: diagnostic.message, help: "Give the timeline more room, or make its shortest period longer relative to the others." });
3227
- else if (Object.hasOwn(REGION_RULES, diagnostic.code))
3228
- context.report(REGION_RULES[diagnostic.code], { path, slide, message: diagnostic.message, help: diagnostic.code === "layout-unplaced" ? "Paginate the slide, choose a layout with more room, pin the block to a region with room, or remove a block." : "Pin the block to a region of the layout that accepts it and has room, or remove the pin." });
3229
- else if (diagnostic.message.startsWith("The diagram cannot be drawn"))
3523
+ else if (Object.hasOwn(REGION_RULES, diagnostic.code)) {
3524
+ const renamed = diagnostic.code === "region-unknown" ? renamedPin(context, slide, path, diagnostic.region) : void 0;
3525
+ context.report(REGION_RULES[diagnostic.code], { path, slide, message: diagnostic.message, help: renamed?.help ?? (diagnostic.code === "layout-unplaced" ? "Paginate the slide, choose a layout with more room, pin the block to a region with room, or remove a block." : "Pin the block to a region of the layout that accepts it and has room, or remove the pin."), ...renamed ? { fixes: [renamed.fix] } : {} });
3526
+ } else if (diagnostic.message.startsWith("The diagram cannot be drawn"))
3230
3527
  context.report(unresolvedRule, { path, slide: path.startsWith("/slides/") ? slide : void 0, message: diagnostic.message, help: "Fix the diagram source where the message points. OPF refuses what it does not draw: write it in the form the diagrams guide lists for that syntax, or remove it." });
3231
- else context.report(unresolvedRule, { path, slide: path.startsWith("/slides/") ? slide : void 0, message: diagnostic.message, help: "Supply what the message asks for, or remove the setting that cannot be honoured." });
3528
+ else context.report(unresolvedRule, { path, slide: path.startsWith("/slides/") ? slide : void 0, message: diagnostic.message, help: "Supply what the message asks for, or remove the setting that cannot be honored." });
3232
3529
  }
3233
3530
  for (const tv of slide.texts)
3234
3531
  for (const run of runsOf(tv))
@@ -3260,7 +3557,7 @@ var layoutRules = [
3260
3557
  for (const item of composition.items) {
3261
3558
  if (item.field === "code" || item.field === "table" || item.type === "code" || item.type === "table") continue;
3262
3559
  const layout = item.quoteLayout ?? item.metricLayout ?? item.timelineLayout;
3263
- if (layout) small(pointerOfDotted(item.path), layout.parts.map((part) => part.visible === false ? void 0 : part.fit?.fontSize), "The smallest text");
3560
+ if (layout) small(pointerOfDotted(item.path), layout.parts.map((part2) => part2.visible === false ? void 0 : part2.fit?.fontSize), "The smallest text");
3264
3561
  else small(pointerOfDotted(item.path), [item.text?.fontSize], item.field === "title" ? "Title" : "Text");
3265
3562
  }
3266
3563
  }
@@ -3271,17 +3568,17 @@ var layoutRules = [
3271
3568
  run(context) {
3272
3569
  const reported = /* @__PURE__ */ new Set();
3273
3570
  for (const slide of context.slides)
3274
- for (const part of slide.composition?.furniture?.parts ?? []) {
3275
- if (part.type !== "text" || part.fit.lines.length <= MAX_FURNITURE_LINES) continue;
3276
- const path = pointerOfDotted(part.sourcePath ?? part.path);
3571
+ for (const part2 of slide.composition?.furniture?.parts ?? []) {
3572
+ if (part2.type !== "text" || part2.fit.lines.length <= MAX_FURNITURE_LINES) continue;
3573
+ const path = pointerOfDotted(part2.sourcePath ?? part2.path);
3277
3574
  if (reported.has(path)) continue;
3278
3575
  reported.add(path);
3279
3576
  context.report(furnitureWrapsRule, {
3280
3577
  path,
3281
3578
  slide,
3282
- message: `The ${part.kind} ${part.zone} text wraps onto ${part.fit.lines.length} lines (at most ${MAX_FURNITURE_LINES}).`,
3579
+ message: `The ${part2.kind} ${part2.zone} text wraps onto ${part2.fit.lines.length} lines (at most ${MAX_FURNITURE_LINES}).`,
3283
3580
  help: "Shorten the text, or move sources and notes to a caption or the speaker notes; keep the footer for short repeated text.",
3284
- measured: { lines: part.fit.lines.length, maximumLines: MAX_FURNITURE_LINES }
3581
+ measured: { lines: part2.fit.lines.length, maximumLines: MAX_FURNITURE_LINES }
3285
3582
  });
3286
3583
  }
3287
3584
  }
@@ -3444,7 +3741,7 @@ function setsRunSize(value, depth2 = 0) {
3444
3741
  var ROLE_SIZE = { text: PROSE_NOMINAL_SIZE, items: LIST_NOMINAL_SIZE, bullets: LIST_NOMINAL_SIZE, table: TABLE_NOMINAL_SIZE, quote: QUOTE_NOMINAL_SIZE, code: CODE_NOMINAL_SIZE };
3445
3742
  function fittedSize(item, slide, document) {
3446
3743
  const body = (parts2) => {
3447
- const fit = parts2?.find((part) => part.role === "body")?.fit;
3744
+ const fit = parts2?.find((part2) => part2.role === "body")?.fit;
3448
3745
  return fit && !fit.overflow ? fit.fontSize : void 0;
3449
3746
  };
3450
3747
  if (item.field === "quote") return body(item.quoteLayout?.parts);
@@ -3500,7 +3797,7 @@ function itemText(item) {
3500
3797
  return value.map((entry2) => {
3501
3798
  if (typeof entry2 === "string" || Array.isArray(entry2)) return plainText(entry2);
3502
3799
  const text2 = rec(entry2).text, description = rec(entry2).description;
3503
- return [text2, description].map((part) => typeof part === "string" || Array.isArray(part) ? plainText(part) : "").join(" ");
3800
+ return [text2, description].map((part2) => typeof part2 === "string" || Array.isArray(part2) ? plainText(part2) : "").join(" ");
3504
3801
  }).join("\n");
3505
3802
  }
3506
3803
  var centeredBody = {
@@ -3798,12 +4095,12 @@ function chartShapeHelp(chart) {
3798
4095
  var own = (value, key3) => Object.hasOwn(value, key3);
3799
4096
  var object = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
3800
4097
  var primitive = (value) => value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value);
3801
- var pointer3 = (parts2) => parts2.length ? "/" + parts2.map((part) => String(part).replaceAll("~", "~0").replaceAll("/", "~1")).join("/") : "";
4098
+ var pointer4 = (parts2) => parts2.length ? "/" + parts2.map((part2) => String(part2).replaceAll("~", "~0").replaceAll("/", "~1")).join("/") : "";
3802
4099
  function parts(path) {
3803
4100
  if (path === "") return [];
3804
4101
  if (!path.startsWith("/") || /~(?![01])/.test(path))
3805
4102
  throw new TypeError(`Invalid contract JSON Pointer: ${path}`);
3806
- return path.slice(1).split("/").map((part) => part.replaceAll("~1", "/").replaceAll("~0", "~"));
4103
+ return path.slice(1).split("/").map((part2) => part2.replaceAll("~1", "/").replaceAll("~0", "~"));
3807
4104
  }
3808
4105
  function at(value, path) {
3809
4106
  return parts(path).reduce(
@@ -3838,7 +4135,7 @@ function finding(ruleId, data) {
3838
4135
  }
3839
4136
  var issueRuleId = (issue2) => typeof issue2.params.code === "string" && issue2.keyword === "opf" ? `opf/${issue2.params.code}` : "opf/schema";
3840
4137
  function issueFinding(issue2, ruleId = issueRuleId(issue2), schemaName = "presentation", prefix = "", scope = "document", severity) {
3841
- const path = prefix + (issue2.path === "/" ? "" : issue2.path) + (issue2.keyword === "additionalProperties" && typeof issue2.params.additionalProperty === "string" ? pointer3([issue2.params.additionalProperty]) : ""), entry2 = schemaEntries.find((entry3) => entry3.name === schemaName);
4138
+ 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);
3842
4139
  if (!entry2) throw new TypeError(`Unknown schema ${schemaName}`);
3843
4140
  const precise = validationDefinition(issue2);
3844
4141
  const definition = precise?.uri ?? (issue2.keyword === "opf" ? "packages/javascript/src/schema-check.ts" : issue2.schemaPath.startsWith("#") ? entry2.schema.$id + issue2.schemaPath : issue2.schemaPath);
@@ -3871,12 +4168,6 @@ function issueFinding(issue2, ruleId = issueRuleId(issue2), schemaName = "presen
3871
4168
  help = `Write ${JSON.stringify(nearest2[0].value)} instead; ${JSON.stringify(typedName)} is not a field of this object.`;
3872
4169
  else if (typedName !== void 0 && typeof nearest2[0]?.value === "string")
3873
4170
  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.`;
3874
- const regionKey = typedName !== void 0 && nearest2[0]?.value !== logicalName(typedName) && /^\/slides\/\d+$/.test(issue2.path) ? regionKeyHelp(typedName) : void 0;
3875
- if (regionKey) {
3876
- help = regionKey.help;
3877
- if (regionKey.suggestion && !nearest2.some((entry3) => entry3.value === regionKey.suggestion))
3878
- nearest2.unshift({ value: regionKey.suggestion, label: regionKey.suggestion, origin: "schema", definition: `${String(entry2.schema.$id)}#/$defs/Slide/properties/${regionKey.suggestion}` });
3879
- }
3880
4171
  return finding(ruleId, {
3881
4172
  ...severity ? { severity } : {},
3882
4173
  path,
@@ -3906,32 +4197,7 @@ function foreignObjectHelp(issue2) {
3906
4197
  return `Rewrite ${many} in one of the forms this place takes, moving the authored content into the fields that form has; do not delete it to clear this error.`;
3907
4198
  }
3908
4199
  var NEAREST_PROPERTIES = 3;
3909
- var REGION_ROWS = ["top", "middle", "bottom"];
3910
- var REGION_COLUMNS = ["start", "center", "end"];
3911
- function regionKeyHelp(typed) {
3912
- const halves = logicalName(typed).split(":");
3913
- if (halves.length > 2 || halves.some((half) => half === "")) return void 0;
3914
- const words = halves.map((half) => half.split("+"));
3915
- if (!words.every((list) => list.every((word) => REGION_ROWS.includes(word) || REGION_COLUMNS.includes(word)))) return void 0;
3916
- const isRows = (list) => list.every((word) => REGION_ROWS.includes(word)), isColumns = (list) => list.every((word) => REGION_COLUMNS.includes(word));
3917
- if (words.some((list) => !isRows(list) && !isColumns(list))) return { help: `A region key does not mix rows (top, middle, bottom) and columns (start, center, end) in one half: write rows, a colon, then columns, such as "top:start" or "middle+bottom:center+end".` };
3918
- if (words.length === 2 && isColumns(words[0]) && isRows(words[1])) {
3919
- const swapped = `${halves[1]}:${halves[0]}`;
3920
- return { help: `Rows come before the colon and columns after it: write "${swapped}".`, ...promotedRegionKeys.includes(swapped) ? { suggestion: swapped } : {} };
3921
- }
3922
- if (words.length === 2 && (!isRows(words[0]) || !isColumns(words[1]))) return { help: 'A region key with a colon names rows before it and columns after it, such as "top:start" or "middle+bottom:center+end".' };
3923
- const order2 = (list, vocabulary) => [...new Set(list)].map((word) => vocabulary.indexOf(word)).sort((a, b) => a - b);
3924
- const rows = words.length === 2 || isRows(words[0]) ? order2(words[0], REGION_ROWS) : [], columns = order2(words[words.length - 1], REGION_COLUMNS);
3925
- const hasRows = words.length === 2 || isRows(words[0]), hasColumns = words.length === 2 || isColumns(words[0]);
3926
- const adjacent = (indexes) => indexes.every((index, at2) => at2 === 0 || index === indexes[at2 - 1] + 1);
3927
- if (hasRows && !adjacent(rows) || hasColumns && !adjacent(columns))
3928
- return { help: `A span covers adjacent rows or columns: "top+bottom" and "start+end" skip the middle one. Write "top+middle+bottom" or "start+center+end", or use one region for each part.` };
3929
- const canonical2 = (indexes, vocabulary) => indexes.map((index) => vocabulary[index]).join("+");
3930
- const key3 = words.length === 2 ? `${canonical2(rows, REGION_ROWS)}:${canonical2(columns, REGION_COLUMNS)}` : hasRows ? canonical2(rows, REGION_ROWS) : canonical2(columns, REGION_COLUMNS);
3931
- if (key3 === typed) return void 0;
3932
- return promotedRegionKeys.includes(key3) ? { help: `Write "${key3}": the names of a span go in reading order (top, middle, bottom; start, center, end), rows before the colon and columns after it.`, suggestion: key3 } : void 0;
3933
- }
3934
- var logicalName = (name) => name.split(":").map((part) => part.split("+").map((word) => word === "left" ? "start" : word === "right" ? "end" : word).join("+")).join(":");
4200
+ var logicalName = (name) => name.split(":").map((part2) => part2.split("+").map((word) => word === "left" ? "start" : word === "right" ? "end" : word).join("+")).join(":");
3935
4201
  function nearestProperties(issue2, fallbackRoot, pointerToKeyword, schemaName) {
3936
4202
  const typed = issue2.params.additionalProperty;
3937
4203
  if (typeof typed !== "string" || pointerToKeyword === void 0) return [];
@@ -4023,7 +4289,7 @@ function childCursor(cursors, key3) {
4023
4289
  return {
4024
4290
  schema,
4025
4291
  root: cursor.root,
4026
- path: `${cursor.path}/${keyword}${name === void 0 ? "" : pointer3([name])}`
4292
+ path: `${cursor.path}/${keyword}${name === void 0 ? "" : pointer4([name])}`
4027
4293
  };
4028
4294
  }
4029
4295
  }
@@ -4053,7 +4319,7 @@ function fields(document) {
4053
4319
  )
4054
4320
  );
4055
4321
  result.push({
4056
- path: pointer3(entry2.path),
4322
+ path: pointer4(entry2.path),
4057
4323
  value: entry2.value,
4058
4324
  cursor: resolved2,
4059
4325
  assetReference: assetReference2
@@ -4103,11 +4369,11 @@ function embeddedRecordFindings(document, options2, findings) {
4103
4369
  for (const [id, record] of Object.entries(object(value.iconSets) ? value.iconSets : {})) {
4104
4370
  if (object(record) && (Object.hasOwn(record, "$schema") || Object.hasOwn(record, "id"))) continue;
4105
4371
  const validation = validateAgainstSchema(object(record) ? { $schema: schemas.iconSet.$id, id, ...record } : record, "iconSets");
4106
- for (const issue2 of validation.errors) findings.push(issueFinding(issue2, "opf/catalog-record", "iconSet", pointer3(["catalogs", group, "iconSets", id]), "document"));
4372
+ for (const issue2 of validation.errors) findings.push(issueFinding(issue2, "opf/catalog-record", "iconSet", pointer4(["catalogs", group, "iconSets", id]), "document"));
4107
4373
  }
4108
4374
  for (const kind of catalogKinds)
4109
4375
  for (const [id, record] of Object.entries(object(value[kind]) ? value[kind] : {})) {
4110
- const path = pointer3(["catalogs", group, kind, id]);
4376
+ const path = pointer4(["catalogs", group, kind, id]);
4111
4377
  if (object(record) && (Object.hasOwn(record, "$schema") || Object.hasOwn(record, "id"))) continue;
4112
4378
  const validation = recordIssues(kind, id, record);
4113
4379
  for (const issue2 of validation.errors) findings.push(issueFinding(issue2, recordRuleId(issue2), catalogSchemaNames[kind], path, "document"));
@@ -4165,7 +4431,7 @@ var HELP = {
4165
4431
  "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.',
4166
4432
  "chart-mapping-adapted": "Choose a compatible chart type or mapping for the selected data. The message explains how the mapping or drawing was adapted.",
4167
4433
  "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.",
4168
- "chart-highlight-adapted": "The highlight is adapted by every engine. Name a series or category the chart type can emphasise, or remove the entry.",
4434
+ "chart-highlight-adapted": "The highlight is adapted by every engine. Name a series or category the chart type can emphasize, or remove the entry.",
4169
4435
  "slide-theme-dimensions": "A PPTX has one slide size. Set design.dimensions on the deck, or give every slide the same theme dimensions.",
4170
4436
  "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.",
4171
4437
  "code-highlight-range-reversed": "Write the range with the smaller line number first, or remove it. A reversed range marks nothing.",
@@ -4174,8 +4440,8 @@ var HELP = {
4174
4440
  "variable-unknown-value": "Remove the supplied value, or declare the variable it belongs to.",
4175
4441
  "variable-unused": "Reference the variable as {{id}} or var:id where it belongs, or remove its declaration.",
4176
4442
  "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.",
4177
- "variable-reference-unknown": "Declare the variable in the top-level variables map, or use another colour.",
4178
- "run-color-unrecognized": "Use a #RRGGBB hex colour, a colour-scheme name or a var: reference to a declared colour variable.",
4443
+ "variable-reference-unknown": "Declare the variable in the top-level variables map, or use another color.",
4444
+ "run-color-unrecognized": "Use a #RRGGBB hex color, a color-scheme name or a var: reference to a declared color variable.",
4179
4445
  "numbering-start-ignored": "Add a 'numbering' field to the payload, or remove 'start'.",
4180
4446
  "slide-size-out-of-range": "Use a custom widthInches and heightInches between 1 and 56, or a preset. PowerPoint stores the slide size in 914400 to 51206400 EMU per side."
4181
4447
  };
@@ -4293,8 +4559,7 @@ function collapseAuthoringShapes(document, findings) {
4293
4559
  const payloadSlots = /* @__PURE__ */ new Map();
4294
4560
  for (const entry2 of findings) {
4295
4561
  if (!schema(entry2) || payloadSlots.has(entry2.path)) continue;
4296
- const key3 = /^\/slides\/\d+\/([^/]+)$/.exec(entry2.path)?.[1], inBlocks = /^\/slides\/\d+\/blocks\/\d+$/.test(entry2.path);
4297
- if (!inBlocks && !(key3 !== void 0 && promotedRegionKeys.includes(key3))) continue;
4562
+ if (!/^\/slides\/\d+\/blocks\/\d+$/.test(entry2.path)) continue;
4298
4563
  const value = valueAt(entry2.path);
4299
4564
  if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || Array.isArray(value)) payloadSlots.set(entry2.path, value);
4300
4565
  }
@@ -4305,7 +4570,7 @@ function collapseAuthoringShapes(document, findings) {
4305
4570
  const { fixes: _fixes, suggestions: _suggestions, ...kept } = findings[first];
4306
4571
  const one = {
4307
4572
  ...kept,
4308
- message: `A region holds a content payload (an object), not ${text2 ? "a bare string" : Array.isArray(value) ? "a list" : "a " + typeof value}.`,
4573
+ message: `A block holds a content payload (an object), not ${text2 ? "a bare string" : Array.isArray(value) ? "a list" : "a " + typeof value}.`,
4309
4574
  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.`,
4310
4575
  ...text2 ? { fixes: [{ id: "wrap-text", title: 'Write the string as { "text": ... }', kind: "patch", safe: false, patch: [{ op: "replace", path: at2, value: { text: value } }] }] } : {}
4311
4576
  };
@@ -4391,7 +4656,7 @@ function variableFindings(document, engine, schemaValid) {
4391
4656
  for (const id of engine.unfilledVariables ?? [])
4392
4657
  findings.push(
4393
4658
  finding("opf/variable-unfilled", {
4394
- path: pointer3(["variables", id]),
4659
+ path: pointer4(["variables", id]),
4395
4660
  message: `Template variable ${JSON.stringify(id)} has no value.`,
4396
4661
  help: "This document is a template: fill it with its values (opf fill, or resolveVariables) before using it as a deck.",
4397
4662
  severity: "warning"
@@ -4416,7 +4681,7 @@ function variableFindings(document, engine, schemaValid) {
4416
4681
  if (match2[1])
4417
4682
  findings.push(
4418
4683
  finding("opf/variable-unfilled", {
4419
- path: pointer3(path),
4684
+ path: pointer4(path),
4420
4685
  message: `Template variable ${JSON.stringify(match2[0])} is still in the text.`,
4421
4686
  help: "Declare the variable and fill it, or replace the token with the real value.",
4422
4687
  severity: "warning"
@@ -4484,13 +4749,66 @@ function contentReferenceFindings(document, options2, findings) {
4484
4749
  if (found?.origin === "host" && !registeredChecked.has(recordKey(found.group, site.kind, found.id))) {
4485
4750
  registeredChecked.add(recordKey(found.group, site.kind, found.id));
4486
4751
  for (const issue2 of recordIssues(site.kind, found.id, found.record).errors)
4487
- findings.push(issueFinding(issue2, recordRuleId(issue2), catalogSchemaNames[site.kind], pointer3(["catalogs", found.group, site.kind, found.id]), "context"));
4752
+ findings.push(issueFinding(issue2, recordRuleId(issue2), catalogSchemaNames[site.kind], pointer4(["catalogs", found.group, site.kind, found.id]), "context"));
4488
4753
  }
4489
4754
  if (found && !(found.origin === "document" && invalid.has(recordKey(found.group, site.kind, found.id)))) continue;
4755
+ const embeddedInvalid = found?.origin === "document" ? found : void 0;
4756
+ const stale = embeddedInvalid && site.kind === "layouts" ? staleLayoutCopy(document, embeddedInvalid.group, embeddedInvalid.id, options2) : void 0;
4490
4757
  const diagnostic = unresolvedReference(document, site.kind, site.reference, path, options2);
4758
+ if (removedLayoutAuto(site.kind, site.reference)) {
4759
+ findings.push(
4760
+ finding("opf/unresolved-reference", {
4761
+ path,
4762
+ message: diagnostic.message,
4763
+ help: 'OPF 0.35 removed layout "auto". Delete the layout key: a slide without one is composed automatically, which is what "auto" did.',
4764
+ definition: `${schemas.presentation.$id}#/$defs/Slide`,
4765
+ lookup: ["opf", "catalog", site.kind],
4766
+ fixes: [{ id: "remove-layout-auto", title: "Delete layout (automatic composition)", kind: "patch", safe: true, patch: [{ op: "remove", path }] }]
4767
+ })
4768
+ );
4769
+ continue;
4770
+ }
4771
+ const renamed = renamedLayout(site.kind, site.reference);
4772
+ if (renamed !== void 0) {
4773
+ const position = renamedLayoutTitlePosition(site.kind, site.reference);
4774
+ const slideAt2 = site.path.slice(0, -1);
4775
+ const slide = slideAt2.reduce((value, key3) => isRecord(value) || Array.isArray(value) ? value[key3] : void 0, document);
4776
+ const design = slide && typeof slide.design === "object" && slide.design !== null && !Array.isArray(slide.design) ? slide.design : void 0;
4777
+ const setPosition = position !== void 0 && design?.titlePosition === void 0;
4778
+ const positionOp = !setPosition ? [] : design ? [{ op: "add", path: pointer4([...slideAt2, "design", "titlePosition"]), value: position }] : [{ op: "add", path: pointer4([...slideAt2, "design"]), value: { titlePosition: position } }];
4779
+ const dropCopy = stale?.renamed && staleCopyUsers(document, stale, options2).length <= 1 ? droppedCopyOperations(document, stale) : [];
4780
+ const what = renamed.endsWith("vertical-process") ? "" : renamed.endsWith("agenda") ? ' with its title beside the list (design.titlePosition "start")' : " (a short list as boxes joined by arrows, longer steps as numbered steps)";
4781
+ findings.push(
4782
+ finding("opf/unresolved-reference", {
4783
+ path,
4784
+ message: diagnostic.message,
4785
+ help: `OPF 0.35 removed layout "${site.reference}"; use "${renamed}", which draws the same content${what}.${position ? ` The fix sets the layout and${setPosition ? "" : " leaves"} the slide's design.titlePosition${setPosition ? ` to "${position}"` : " as the slide sets it"}.` : ""}`,
4786
+ definition: `${schemas.presentation.$id}#/$defs/Slide`,
4787
+ lookup: ["opf", "catalog", site.kind],
4788
+ fixes: [{ id: "rename-layout", title: setPosition ? `Use layout ${renamed} with the title beside it` : `Use layout ${renamed}`, kind: "patch", safe: true, ...stale || renamedLayoutChangesDrawing(site.kind, site.reference) ? { changesDrawing: true } : {}, patch: [{ op: "replace", path, value: renamed }, ...positionOp, ...dropCopy] }]
4789
+ })
4790
+ );
4791
+ continue;
4792
+ }
4793
+ if (embeddedInvalid) {
4794
+ const at2 = pointer4(["catalogs", embeddedInvalid.group, site.kind, embeddedInvalid.id]);
4795
+ const fix = stale ? staleCopyFix(document, stale, options2) : void 0;
4796
+ const noun = KIND_SINGULAR[site.kind];
4797
+ findings.push(
4798
+ finding("opf/unresolved-reference", {
4799
+ path,
4800
+ 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}.`,
4801
+ help: stale ? staleCopyCause(stale) : `Fix the record with the fixes of its findings at ${at2}, then validate again.`,
4802
+ definition: `${schemas.presentation.$id}#/$defs/Catalogs`,
4803
+ lookup: ["opf", "catalog", site.kind],
4804
+ ...fix ? { fixes: [fix] } : {}
4805
+ })
4806
+ );
4807
+ continue;
4808
+ }
4491
4809
  const records = catalogRecords(document, site.kind, options2);
4492
4810
  const near = new Set(nearMisses(site.reference, records.map((entry2) => entry2.reference)));
4493
- const suggestions = records.filter((entry2) => near.has(entry2.reference)).map((entry2) => ({ value: entry2.reference, label: typeof entry2.record.name === "string" ? entry2.record.name : entry2.reference, origin: entry2.origin === "host" ? "registered" : "document", definition: entry2.origin === "document" ? `document#${pointer3(["catalogs", entry2.group, site.kind, entry2.id])}` : `${entry2.source ?? "context"}#/${site.kind}/${entry2.id}` })).sort((a, b) => distance2(site.reference, a.value) - distance2(site.reference, b.value) || (a.value < b.value ? -1 : a.value > b.value ? 1 : 0)).slice(0, 5);
4811
+ const suggestions = records.filter((entry2) => near.has(entry2.reference)).map((entry2) => ({ value: entry2.reference, label: typeof entry2.record.name === "string" ? entry2.record.name : entry2.reference, origin: entry2.origin === "host" ? "registered" : "document", definition: entry2.origin === "document" ? `document#${pointer4(["catalogs", entry2.group, site.kind, entry2.id])}` : `${entry2.source ?? "context"}#/${site.kind}/${entry2.id}` })).sort((a, b) => distance2(site.reference, a.value) - distance2(site.reference, b.value) || (a.value < b.value ? -1 : a.value > b.value ? 1 : 0)).slice(0, 5);
4494
4812
  const suggested = suggestions.length > 0;
4495
4813
  findings.push(
4496
4814
  finding("opf/unresolved-reference", {
@@ -4526,7 +4844,7 @@ function referenceFindings(document, engine, options2) {
4526
4844
  value: `asset:${id2}`,
4527
4845
  label: id2,
4528
4846
  origin: "document",
4529
- definition: `document#${pointer3(["assets", id2])}`
4847
+ definition: `document#${pointer4(["assets", id2])}`
4530
4848
  }))
4531
4849
  })
4532
4850
  );
@@ -4543,7 +4861,7 @@ function referenceFindings(document, engine, options2) {
4543
4861
  for (const id2 of cycle) reportedCycles.add(id2);
4544
4862
  findings.push(
4545
4863
  finding("opf/asset-cycle", {
4546
- path: pointer3(["assets", current]),
4864
+ path: pointer4(["assets", current]),
4547
4865
  message: `Asset references form a cycle: ${[...cycle, current].map((id2) => JSON.stringify(id2)).join(" \u2192 ")}.`,
4548
4866
  help: "Replace one link with the intended concrete source. Preserve the original asset metadata; no files or URLs were fetched."
4549
4867
  })
@@ -4632,7 +4950,7 @@ function narrativeFindings(document, options2) {
4632
4950
  if (durationRangeInverted(record))
4633
4951
  findings.push(
4634
4952
  finding("opf/narrative-duration-range", {
4635
- path: pointer3(["catalogs", group, "narratives", id, "duration"]),
4953
+ path: pointer4(["catalogs", group, "narratives", id, "duration"]),
4636
4954
  message: "The narrative duration range has min greater than max.",
4637
4955
  help: "Swap the bounds so min is the shortest and max the longest talk length, in minutes.",
4638
4956
  definition: schemas.narrative.$id + "#/properties/duration",
@@ -4652,7 +4970,7 @@ function contractFindings(document, contracts) {
4652
4970
  if (entry2.depth === pattern.length) {
4653
4971
  if (contract2.allowedValues.some((value) => Object.is(value, entry2.value)))
4654
4972
  continue;
4655
- const path = pointer3(entry2.path), definition = contract2.documentation ?? `context#/contracts/${index}`, values = {
4973
+ const path = pointer4(entry2.path), definition = contract2.documentation ?? `context#/contracts/${index}`, values = {
4656
4974
  path,
4657
4975
  value: JSON.stringify(entry2.value),
4658
4976
  allowed: contract2.allowedValues.map((value) => JSON.stringify(value)).join(", "),
@@ -4692,157 +5010,6 @@ function contractFindings(document, contracts) {
4692
5010
  return findings;
4693
5011
  }
4694
5012
 
4695
- // src/document-hash.ts
4696
- function canonicalJson(value) {
4697
- const stack = [];
4698
- const write = (item) => {
4699
- if (item === null || typeof item === "boolean" || typeof item === "string") return JSON.stringify(item);
4700
- if (typeof item === "number") return JSON.stringify(item);
4701
- if (typeof item === "bigint") throw new TypeError("A BigInt is not JSON.");
4702
- if (typeof item !== "object") return void 0;
4703
- if (stack.includes(item)) throw new TypeError("A cyclic value has no canonical JSON.");
4704
- stack.push(item);
4705
- let text2;
4706
- if (Array.isArray(item)) {
4707
- text2 = `[${item.map((entry2) => write(entry2) ?? "null").join(",")}]`;
4708
- } else {
4709
- const record = item;
4710
- const members = [];
4711
- for (const key3 of Object.keys(record).sort()) {
4712
- const member = write(record[key3]);
4713
- if (member !== void 0) members.push(`${JSON.stringify(key3)}:${member}`);
4714
- }
4715
- text2 = `{${members.join(",")}}`;
4716
- }
4717
- stack.pop();
4718
- return text2;
4719
- };
4720
- return write(value) ?? "null";
4721
- }
4722
- var K = new Uint32Array([
4723
- 1116352408,
4724
- 1899447441,
4725
- 3049323471,
4726
- 3921009573,
4727
- 961987163,
4728
- 1508970993,
4729
- 2453635748,
4730
- 2870763221,
4731
- 3624381080,
4732
- 310598401,
4733
- 607225278,
4734
- 1426881987,
4735
- 1925078388,
4736
- 2162078206,
4737
- 2614888103,
4738
- 3248222580,
4739
- 3835390401,
4740
- 4022224774,
4741
- 264347078,
4742
- 604807628,
4743
- 770255983,
4744
- 1249150122,
4745
- 1555081692,
4746
- 1996064986,
4747
- 2554220882,
4748
- 2821834349,
4749
- 2952996808,
4750
- 3210313671,
4751
- 3336571891,
4752
- 3584528711,
4753
- 113926993,
4754
- 338241895,
4755
- 666307205,
4756
- 773529912,
4757
- 1294757372,
4758
- 1396182291,
4759
- 1695183700,
4760
- 1986661051,
4761
- 2177026350,
4762
- 2456956037,
4763
- 2730485921,
4764
- 2820302411,
4765
- 3259730800,
4766
- 3345764771,
4767
- 3516065817,
4768
- 3600352804,
4769
- 4094571909,
4770
- 275423344,
4771
- 430227734,
4772
- 506948616,
4773
- 659060556,
4774
- 883997877,
4775
- 958139571,
4776
- 1322822218,
4777
- 1537002063,
4778
- 1747873779,
4779
- 1955562222,
4780
- 2024104815,
4781
- 2227730452,
4782
- 2361852424,
4783
- 2428436474,
4784
- 2756734187,
4785
- 3204031479,
4786
- 3329325298
4787
- ]);
4788
- function sha256Hex(bytes) {
4789
- const length = bytes.length;
4790
- const padded = new Uint8Array(length + 9 + 63 >> 6 << 6);
4791
- padded.set(bytes);
4792
- padded[length] = 128;
4793
- const view = new DataView(padded.buffer);
4794
- view.setUint32(padded.length - 8, Math.floor(length / 536870912), false);
4795
- view.setUint32(padded.length - 4, length << 3 >>> 0, false);
4796
- const h = new Uint32Array([1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]);
4797
- const w = new Uint32Array(64);
4798
- for (let offset = 0; offset < padded.length; offset += 64) {
4799
- for (let i = 0; i < 16; i += 1) w[i] = view.getUint32(offset + i * 4, false);
4800
- for (let i = 16; i < 64; i += 1) {
4801
- const a2 = w[i - 15], b2 = w[i - 2];
4802
- const s0 = (a2 >>> 7 | a2 << 25) ^ (a2 >>> 18 | a2 << 14) ^ a2 >>> 3;
4803
- const s1 = (b2 >>> 17 | b2 << 15) ^ (b2 >>> 19 | b2 << 13) ^ b2 >>> 10;
4804
- w[i] = w[i - 16] + s0 + w[i - 7] + s1 | 0;
4805
- }
4806
- let a = h[0], b = h[1], c = h[2], d = h[3], e = h[4], f = h[5], g = h[6], hh = h[7];
4807
- for (let i = 0; i < 64; i += 1) {
4808
- const s1 = (e >>> 6 | e << 26) ^ (e >>> 11 | e << 21) ^ (e >>> 25 | e << 7);
4809
- const choose = e & f ^ ~e & g;
4810
- const t1 = hh + s1 + choose + K[i] + w[i] | 0;
4811
- const s0 = (a >>> 2 | a << 30) ^ (a >>> 13 | a << 19) ^ (a >>> 22 | a << 10);
4812
- const majority = a & b ^ a & c ^ b & c;
4813
- const t2 = s0 + majority | 0;
4814
- hh = g;
4815
- g = f;
4816
- f = e;
4817
- e = d + t1 | 0;
4818
- d = c;
4819
- c = b;
4820
- b = a;
4821
- a = t1 + t2 | 0;
4822
- }
4823
- h[0] = h[0] + a | 0;
4824
- h[1] = h[1] + b | 0;
4825
- h[2] = h[2] + c | 0;
4826
- h[3] = h[3] + d | 0;
4827
- h[4] = h[4] + e | 0;
4828
- h[5] = h[5] + f | 0;
4829
- h[6] = h[6] + g | 0;
4830
- h[7] = h[7] + hh | 0;
4831
- }
4832
- let hex = "";
4833
- for (const word of h) hex += word.toString(16).padStart(8, "0");
4834
- return hex;
4835
- }
4836
- function documentHash(document) {
4837
- return `sha256:${sha256Hex(new TextEncoder().encode(canonicalJson(document)))}`;
4838
- }
4839
- var HASH_PATTERN = /^(?:sha256:)?([0-9a-fA-F]{64})$/;
4840
- function normalizeDocumentHash(value) {
4841
- if (typeof value !== "string") return void 0;
4842
- const match2 = HASH_PATTERN.exec(value);
4843
- return match2 ? `sha256:${match2[1].toLowerCase()}` : void 0;
4844
- }
4845
-
4846
5013
  // src/patch.ts
4847
5014
  var OPFPatchError = class extends Error {
4848
5015
  code;
@@ -4902,11 +5069,11 @@ function escapePointerToken(token) {
4902
5069
  function unescapePointerToken(token) {
4903
5070
  return token.replaceAll("~1", "/").replaceAll("~0", "~");
4904
5071
  }
4905
- function parsePointer(pointer4) {
4906
- if (typeof pointer4 !== "string" || pointer4 !== "" && !pointer4.startsWith("/") || /~(?![01])/u.test(pointer4)) {
4907
- throw new OPFPatchError("invalid-json-pointer", "Expected a JSON Pointer (empty string or /path with ~0 and ~1 escapes).", { path: typeof pointer4 === "string" ? pointer4 : void 0 });
5072
+ function parsePointer(pointer5) {
5073
+ if (typeof pointer5 !== "string" || pointer5 !== "" && !pointer5.startsWith("/") || /~(?![01])/u.test(pointer5)) {
5074
+ throw new OPFPatchError("invalid-json-pointer", "Expected a JSON Pointer (empty string or /path with ~0 and ~1 escapes).", { path: typeof pointer5 === "string" ? pointer5 : void 0 });
4908
5075
  }
4909
- return pointer4 === "" ? [] : pointer4.slice(1).split("/").map(unescapePointerToken);
5076
+ return pointer5 === "" ? [] : pointer5.slice(1).split("/").map(unescapePointerToken);
4910
5077
  }
4911
5078
  function formatPointer(tokens) {
4912
5079
  return tokens.length ? `/${tokens.map(escapePointerToken).join("/")}` : "";
@@ -4921,9 +5088,9 @@ function pointerFromPath(path) {
4921
5088
  }
4922
5089
  return formatPointer(path.split(".").filter(Boolean));
4923
5090
  }
4924
- function splitPointer2(pointer4) {
4925
- const tokens = parsePointer(pointer4);
4926
- if (!tokens.length) throw new OPFPatchError("invalid-json-pointer", "The root pointer has no parent.", { path: pointer4 });
5091
+ function splitPointer2(pointer5) {
5092
+ const tokens = parsePointer(pointer5);
5093
+ if (!tokens.length) throw new OPFPatchError("invalid-json-pointer", "The root pointer has no parent.", { path: pointer5 });
4927
5094
  return { parent: formatPointer(tokens.slice(0, -1)), token: tokens[tokens.length - 1] };
4928
5095
  }
4929
5096
  var isIdToken = (token) => token.length > 1 && token.startsWith("@");
@@ -4945,15 +5112,15 @@ function uniqueIdAt(array, at2) {
4945
5112
  if (!isObject2(item) || !own2(item, "id") || typeof item.id !== "string" || item.id === "") return void 0;
4946
5113
  return indexOfId(array, item.id) === at2 ? item.id : void 0;
4947
5114
  }
4948
- function resolveTokens(document, tokens, pointer4) {
5115
+ function resolveTokens(document, tokens, pointer5) {
4949
5116
  const out = [];
4950
5117
  let cursor = document, walking = true;
4951
5118
  for (const token of tokens) {
4952
5119
  let resolved2 = token;
4953
5120
  if (walking && Array.isArray(cursor) && isIdToken(token)) {
4954
5121
  const at2 = indexOfId(cursor, token.slice(1));
4955
- if (at2 === -1) throw new OPFPatchError("patch-id-not-found", `No element of ${formatPointer(out) || "/"} has the id '${token.slice(1)}'.`, { path: pointer4 });
4956
- if (at2 === -2) throw new OPFPatchError("patch-id-ambiguous", `More than one element of ${formatPointer(out) || "/"} has the id '${token.slice(1)}'.`, { path: pointer4 });
5122
+ if (at2 === -1) throw new OPFPatchError("patch-id-not-found", `No element of ${formatPointer(out) || "/"} has the id '${token.slice(1)}'.`, { path: pointer5 });
5123
+ if (at2 === -2) throw new OPFPatchError("patch-id-ambiguous", `More than one element of ${formatPointer(out) || "/"} has the id '${token.slice(1)}'.`, { path: pointer5 });
4957
5124
  resolved2 = String(at2);
4958
5125
  }
4959
5126
  out.push(resolved2);
@@ -4965,9 +5132,9 @@ function resolveTokens(document, tokens, pointer4) {
4965
5132
  }
4966
5133
  return out;
4967
5134
  }
4968
- function resolveIdPointer(document, pointer4) {
4969
- const tokens = parsePointer(pointer4);
4970
- return tokens.some(isIdToken) ? formatPointer(resolveTokens(document, tokens, pointer4)) : pointer4;
5135
+ function resolveIdPointer(document, pointer5) {
5136
+ const tokens = parsePointer(pointer5);
5137
+ return tokens.some(isIdToken) ? formatPointer(resolveTokens(document, tokens, pointer5)) : pointer5;
4971
5138
  }
4972
5139
  function idTokens(document, tokens, convertLast) {
4973
5140
  const out = [];
@@ -4987,11 +5154,11 @@ function idTokens(document, tokens, convertLast) {
4987
5154
  });
4988
5155
  return out;
4989
5156
  }
4990
- function toIdPointer(document, pointer4, options2 = {}) {
4991
- return formatPointer(idTokens(document, resolveTokens(document, parsePointer(pointer4), pointer4), !options2.keepLast));
5157
+ function toIdPointer(document, pointer5, options2 = {}) {
5158
+ return formatPointer(idTokens(document, resolveTokens(document, parsePointer(pointer5), pointer5), !options2.keepLast));
4992
5159
  }
4993
- function readPointer(document, pointer4) {
4994
- const tokens = typeof pointer4 === "string" ? parsePointer(pointer4) : pointer4;
5160
+ function readPointer(document, pointer5) {
5161
+ const tokens = typeof pointer5 === "string" ? parsePointer(pointer5) : pointer5;
4995
5162
  let value = document;
4996
5163
  for (const token of tokens) {
4997
5164
  if (Array.isArray(value)) {
@@ -5010,15 +5177,15 @@ function readPointer(document, pointer4) {
5010
5177
  }
5011
5178
  return { found: true, value };
5012
5179
  }
5013
- function getAtPointer(document, pointer4) {
5014
- const result = readPointer(document, pointer4);
5180
+ function getAtPointer(document, pointer5) {
5181
+ const result = readPointer(document, pointer5);
5015
5182
  if (!result.found) {
5016
- const shown = typeof pointer4 === "string" ? pointer4 : formatPointer(pointer4);
5183
+ const shown = typeof pointer5 === "string" ? pointer5 : formatPointer(pointer5);
5017
5184
  throw new OPFPatchError("patch-path-missing", `Patch path does not exist: ${shown || "/"}`, { path: shown });
5018
5185
  }
5019
5186
  return result.value;
5020
5187
  }
5021
- var hasPointer = (document, pointer4) => readPointer(document, pointer4).found;
5188
+ var hasPointer = (document, pointer5) => readPointer(document, pointer5).found;
5022
5189
  function arrayIndex(token, length, allowEnd, path) {
5023
5190
  if (allowEnd && token === "-") return length;
5024
5191
  if (!INDEX_TOKEN.test(token)) throw new OPFPatchError("invalid-array-index", `Invalid array index: ${token}`, { path });
@@ -5072,33 +5239,33 @@ function addAt(document, path, value) {
5072
5239
  if (Array.isArray(parent)) {
5073
5240
  const at2 = arrayIndex(key3, parent.length, true, path);
5074
5241
  parent.splice(at2, 0, clone(value));
5075
- const pointer5 = formatPointer([...tokens.slice(0, -1), at2]);
5076
- return { document, inverse: { op: "remove", path: pointer5 }, pointer: pointer5 };
5242
+ const pointer6 = formatPointer([...tokens.slice(0, -1), at2]);
5243
+ return { document, inverse: { op: "remove", path: pointer6 }, pointer: pointer6 };
5077
5244
  }
5078
5245
  const record = parent;
5079
5246
  const previous = own2(record, key3) ? record[key3] : NONE;
5080
5247
  Object.defineProperty(record, key3, { value: clone(value), enumerable: true, configurable: true, writable: true });
5081
- const pointer4 = formatPointer(tokens);
5082
- return { document, inverse: previous === NONE ? { op: "remove", path: pointer4 } : { op: "replace", path: pointer4, value: clone(previous) }, pointer: pointer4 };
5248
+ const pointer5 = formatPointer(tokens);
5249
+ return { document, inverse: previous === NONE ? { op: "remove", path: pointer5 } : { op: "replace", path: pointer5, value: clone(previous) }, pointer: pointer5 };
5083
5250
  }
5084
5251
  function replaceAt(document, path, value) {
5085
5252
  const tokens = resolveTokens(document, parsePointer(path), path);
5086
5253
  if (!tokens.length) return { document: clone(value), inverse: { op: "replace", path: "", value: clone(document) }, pointer: "" };
5087
5254
  const { parent, key: key3 } = parentOf(document, tokens, path);
5088
5255
  let previous;
5089
- let pointer4 = formatPointer(tokens);
5256
+ let pointer5 = formatPointer(tokens);
5090
5257
  if (Array.isArray(parent)) {
5091
5258
  const at2 = arrayIndex(key3, parent.length, false, path);
5092
5259
  previous = parent[at2];
5093
5260
  parent[at2] = clone(value);
5094
- pointer4 = formatPointer([...tokens.slice(0, -1), at2]);
5261
+ pointer5 = formatPointer([...tokens.slice(0, -1), at2]);
5095
5262
  } else {
5096
5263
  const record = parent;
5097
5264
  if (!own2(record, key3)) throw new OPFPatchError("patch-path-missing", `Patch path does not exist: ${path}.`, { path });
5098
5265
  previous = record[key3];
5099
5266
  Object.defineProperty(record, key3, { value: clone(value), enumerable: true, configurable: true, writable: true });
5100
5267
  }
5101
- return { document, inverse: { op: "replace", path: pointer4, value: clone(previous) }, pointer: pointer4 };
5268
+ return { document, inverse: { op: "replace", path: pointer5, value: clone(previous) }, pointer: pointer5 };
5102
5269
  }
5103
5270
  function removeAt(document, path) {
5104
5271
  const tokens = resolveTokens(document, parsePointer(path), path);
@@ -5109,15 +5276,15 @@ function removeAt(document, path) {
5109
5276
  const at2 = arrayIndex(key3, parent.length, false, path);
5110
5277
  previous = parent[at2];
5111
5278
  parent.splice(at2, 1);
5112
- const pointer5 = formatPointer([...tokens.slice(0, -1), at2]);
5113
- return { document, inverse: { op: "add", path: pointer5, value: clone(previous) }, pointer: pointer5 };
5279
+ const pointer6 = formatPointer([...tokens.slice(0, -1), at2]);
5280
+ return { document, inverse: { op: "add", path: pointer6, value: clone(previous) }, pointer: pointer6 };
5114
5281
  }
5115
5282
  const record = parent;
5116
5283
  if (!own2(record, key3)) throw new OPFPatchError("patch-path-missing", `Patch path does not exist: ${path}.`, { path });
5117
5284
  previous = record[key3];
5118
5285
  delete record[key3];
5119
- const pointer4 = formatPointer(tokens);
5120
- return { document, inverse: { op: "add", path: pointer4, value: clone(previous) }, pointer: pointer4 };
5286
+ const pointer5 = formatPointer(tokens);
5287
+ return { document, inverse: { op: "add", path: pointer5, value: clone(previous) }, pointer: pointer5 };
5121
5288
  }
5122
5289
  function applyOne(document, operation) {
5123
5290
  switch (operation.op) {
@@ -5220,7 +5387,7 @@ function toIdPatch(document, patch2) {
5220
5387
  const pending = /* @__PURE__ */ new Map();
5221
5388
  walkPatch(document, patch2, {
5222
5389
  before: (index, operation, working) => {
5223
- const named = (pointer4) => toIdPointer(working, pointer4);
5390
+ const named = (pointer5) => toIdPointer(working, pointer5);
5224
5391
  switch (operation.op) {
5225
5392
  case "replace":
5226
5393
  case "remove":
@@ -5289,17 +5456,17 @@ function splitOpfPath(path) {
5289
5456
  if (path.startsWith("/")) return parsePointer(path);
5290
5457
  return path.split(".").filter(Boolean);
5291
5458
  }
5292
- function readSchemaPointer(target, pointer4) {
5459
+ function readSchemaPointer(target, pointer5) {
5293
5460
  let current = target;
5294
- for (const token of parsePointer(pointer4)) {
5461
+ for (const token of parsePointer(pointer5)) {
5295
5462
  if (current === null || typeof current !== "object" || !own3(current, token)) return void 0;
5296
5463
  current = current[token];
5297
5464
  }
5298
5465
  return current;
5299
5466
  }
5300
5467
  for (const [key3, kind] of Object.entries(schemaCatalogKinds)) {
5301
- const [name = "", pointer4 = ""] = key3.split("#");
5302
- const node = readSchemaPointer(schemas[name], pointer4);
5468
+ const [name = "", pointer5 = ""] = key3.split("#");
5469
+ const node = readSchemaPointer(schemas[name], pointer5);
5303
5470
  if (node === void 0 || node === null || typeof node !== "object") throw new Error(`schemaCatalogKinds: ${key3} is not a schema node.`);
5304
5471
  catalogKindOfNode.set(node, kind);
5305
5472
  }
@@ -5503,10 +5670,6 @@ var COMMON_KEYS = Object.freeze({
5503
5670
  var UNRANKED_PRIORITY = 1e6;
5504
5671
  var DEFINITION_LISTS = { Slide: COMMON_KEYS.slide, Design: COMMON_KEYS.design, SlideDesign: COMMON_KEYS.design };
5505
5672
  var ADVANCED_KEYS = /* @__PURE__ */ new Set(["extensions", "$schema"]);
5506
- var REGION_KEY = /^(?:(?:top|middle|bottom)(?:\+(?:top|middle|bottom))*)?(?::)?(?:(?:start|center|end)(?:\+(?:start|center|end))*)?$/;
5507
- function isPromotedRegionKey(key3) {
5508
- return key3 !== "" && key3 !== ":" && REGION_KEY.test(key3);
5509
- }
5510
5673
  var uniq = (items) => [...new Set(items)];
5511
5674
  function variantType(variant) {
5512
5675
  if (typeof variant.type === "string") return variant.type;
@@ -5580,7 +5743,7 @@ function objectForm(variants, value) {
5580
5743
  const required = used.length ? (used[0]?.required ?? []).filter((key3) => used.every((variant) => (variant.required ?? []).includes(key3))) : [];
5581
5744
  return { properties, required };
5582
5745
  }
5583
- function childrenOf(form, list, isSlide, root) {
5746
+ function childrenOf(form, list, root) {
5584
5747
  const children = [];
5585
5748
  for (const [key3, raw] of form.properties) {
5586
5749
  const resolved2 = resolveSchema(raw, root);
@@ -5592,7 +5755,7 @@ function childrenOf(form, list, isSlide, root) {
5592
5755
  types: uniq(variants.map(variantType)),
5593
5756
  typeLabel: typeLabelOf(raw, variants, root),
5594
5757
  required: form.required.includes(key3),
5595
- advanced: ADVANCED_KEYS.has(key3) || isSlide && isPromotedRegionKey(key3),
5758
+ advanced: ADVANCED_KEYS.has(key3),
5596
5759
  priority: priorityOf(list, key3),
5597
5760
  ...description ? { description } : {},
5598
5761
  ...catalogKind ? { catalogKind } : {},
@@ -5606,7 +5769,7 @@ function childrenOf(form, list, isSlide, root) {
5606
5769
  }
5607
5770
  function nodeSegments(path) {
5608
5771
  const parts2 = splitOpfPath(path);
5609
- const shown = Array.isArray(path) ? [...path] : parts2.map((part) => /^(?:0|[1-9][0-9]*)$/.test(part) ? Number(part) : part);
5772
+ const shown = Array.isArray(path) ? [...path] : parts2.map((part2) => /^(?:0|[1-9][0-9]*)$/.test(part2) ? Number(part2) : part2);
5610
5773
  return { parts: parts2, shown };
5611
5774
  }
5612
5775
  var MAX_ITEM_DEPTH = 3;
@@ -5618,9 +5781,9 @@ function describeAt(presentation, path, depth2) {
5618
5781
  } catch {
5619
5782
  return unknownField(Array.isArray(path) ? [...path] : [], "");
5620
5783
  }
5621
- const pointer4 = formatPointer(parts2);
5784
+ const pointer5 = formatPointer(parts2);
5622
5785
  const found = walk(presentation, parts2, presentationSchema);
5623
- if (!found.known) return unknownField(shown, pointer4);
5786
+ if (!found.known) return unknownField(shown, pointer5);
5624
5787
  const { raw, schema, root, parent, value } = found;
5625
5788
  const variants = schemaVariants(raw, root);
5626
5789
  const inherited = schema.description;
@@ -5655,7 +5818,7 @@ function describeAt(presentation, path, depth2) {
5655
5818
  const info = {
5656
5819
  known: true,
5657
5820
  path: shown,
5658
- pointer: pointer4,
5821
+ pointer: pointer5,
5659
5822
  ...key3 !== void 0 ? { key: key3 } : {},
5660
5823
  types: uniq(infos2.map((variant) => variant.type)),
5661
5824
  ...description ? { description } : {},
@@ -5669,7 +5832,7 @@ function describeAt(presentation, path, depth2) {
5669
5832
  ...catalogKind ? { catalogKind } : {},
5670
5833
  variants: infos2,
5671
5834
  primary,
5672
- children: childrenOf(form, list, definition === "Slide", root),
5835
+ children: childrenOf(form, list, root),
5673
5836
  requiredChildren: form.required,
5674
5837
  freeText
5675
5838
  };
@@ -5684,8 +5847,8 @@ function describeAt(presentation, path, depth2) {
5684
5847
  if (info.entryInfo) info.entryInfo.path = [...shown, "*"];
5685
5848
  return info;
5686
5849
  }
5687
- function unknownField(path, pointer4) {
5688
- return { known: false, path, pointer: pointer4, types: [], required: false, examples: [], variants: [], primary: 0, children: [], requiredChildren: [], freeText: false };
5850
+ function unknownField(path, pointer5) {
5851
+ return { known: false, path, pointer: pointer5, types: [], required: false, examples: [], variants: [], primary: 0, children: [], requiredChildren: [], freeText: false };
5689
5852
  }
5690
5853
  function describeField(path, document) {
5691
5854
  return describeAt(document, path, 0);
@@ -6816,7 +6979,7 @@ function parseSource(source) {
6816
6979
  if (keys.has(key3.value))
6817
6980
  duplicates.push(
6818
6981
  finding("opf/duplicate-key", {
6819
- path: pointer3(getNodePath(key3)),
6982
+ path: pointer4(getNodePath(key3)),
6820
6983
  message: `Duplicate JSON property ${JSON.stringify(key3.value)}.`,
6821
6984
  help: "Resolve the duplicate explicitly, preserving the intended content from both occurrences. JSON.parse would otherwise hide an earlier value.",
6822
6985
  location: location(key3.offset, key3.length)
@@ -6836,9 +6999,9 @@ function parseSource(source) {
6836
6999
  let node = tree;
6837
7000
  const found = [];
6838
7001
  const wanted = parts(path);
6839
- for (const part of wanted) {
6840
- const next = node?.type === "array" ? node.children?.[Number(part)] : node?.type === "object" ? node.children?.find(
6841
- (property) => property.children?.[0]?.value === part
7002
+ for (const part2 of wanted) {
7003
+ const next = node?.type === "array" ? node.children?.[Number(part2)] : node?.type === "object" ? node.children?.find(
7004
+ (property) => property.children?.[0]?.value === part2
6842
7005
  )?.children?.[1] : void 0;
6843
7006
  if (!next) break;
6844
7007
  node = next;
@@ -6859,10 +7022,7 @@ function sentence(text2) {
6859
7022
  const trimmed = text2.trim();
6860
7023
  return ENDS.test(trimmed) ? trimmed : `${trimmed}.`;
6861
7024
  }
6862
- function us(text2) {
6863
- return text2.replace(/colour/g, "color").replace(/Colour/g, "Color");
6864
- }
6865
- var keep = (text2) => sentence(us(text2));
7025
+ var keep = (text2) => sentence(text2);
6866
7026
  function match(text2, regex) {
6867
7027
  return regex.exec(text2) ?? void 0;
6868
7028
  }
@@ -6965,7 +7125,7 @@ function blockKind(node) {
6965
7125
  }
6966
7126
  function helpAsNext(finding2, fallback) {
6967
7127
  const help = finding2.help?.trim();
6968
- return help ? sentence(asNext(us(help))) : fallback;
7128
+ return help ? sentence(asNext(help)) : fallback;
6969
7129
  }
6970
7130
  var isText2 = (value) => typeof value === "string" && value !== "";
6971
7131
  function brief(text2, max = 40) {
@@ -6989,8 +7149,8 @@ var textContrast = (finding2) => {
6989
7149
  const foreground = measuredText(finding2, "textColor");
6990
7150
  const background = measuredText(finding2, "backgroundColor");
6991
7151
  if (ratio === void 0 || needed === void 0) return void 0;
6992
- const label = match(finding2.message, /^(.+?) colou?r /)?.[1];
6993
- const subject = label && !/^(Text|Colou?red text)$/.test(label) ? us(label) : "Text";
7152
+ const label = match(finding2.message, /^(.+?) color /)?.[1];
7153
+ const subject = label && !/^(Text|Colored text)$/.test(label) ? label : "Text";
6994
7154
  const colors = foreground && background ? ` ${code(foreground)} on ${code(background)}` : "";
6995
7155
  const large = finding2.measured?.large === true ? " for large text" : finding2.measured?.large === false ? " for normal-size text" : "";
6996
7156
  const also = measuredNumber(finding2, "alsoAffected");
@@ -7047,7 +7207,7 @@ var poorAltText = (finding2) => {
7047
7207
  const chart = found[1] === "Chart";
7048
7208
  const problem = found[4].replace(/^is a generic word, not what the data shows$/, "is a generic word");
7049
7209
  return {
7050
- message: `Alt text ${code(brief(alt, 50))} ${us(problem)}, so it doesn't describe the ${chart ? "chart" : "picture"}.`,
7210
+ message: `Alt text ${code(brief(alt, 50))} ${problem}, so it doesn't describe the ${chart ? "chart" : "picture"}.`,
7051
7211
  next: chart ? "state what the chart shows: its point and the key numbers, in a sentence or two." : `describe what the picture shows, in plain words and without a leading "image of".`
7052
7212
  };
7053
7213
  };
@@ -7087,18 +7247,18 @@ var linkText = (finding2) => {
7087
7247
  return { message, next: `say what is at ${destination}, for example the page or file name.` };
7088
7248
  };
7089
7249
  var chartColorOnly = (finding2) => {
7090
- const parts2 = match(finding2.message, /^(Series|Slices) may be hard to tell apart without colou?r/);
7250
+ const parts2 = match(finding2.message, /^(Series|Slices) may be hard to tell apart without color/);
7091
7251
  const noun = parts2?.[1] === "Slices" ? "slices" : "series";
7092
7252
  const pairs = measuredNumber(finding2, "confusablePairs");
7093
- const repeat = match(finding2.message, /(\d+) (?:series|slices) exceed the (\d+)-colou?r palette/);
7253
+ const repeat = match(finding2.message, /(\d+) (?:series|slices) exceed the (\d+)-color palette/);
7094
7254
  const count = measuredNumber(finding2, "series");
7095
7255
  const message = pairs !== void 0 ? `Some ${noun} differ by color only: ${pairs === 1 ? "one pair looks" : `${pairs} pairs look`} alike to color-blind viewers or in grayscale.${repeat ? ` ${repeat[1]} ${noun} exceed the ${repeat[2]}-color palette, so colors repeat.` : ""}` : `${cap(noun)} differ by color only${count !== void 0 ? ` (${count} ${noun})` : ""}.`;
7096
7256
  return { message, next: `add data labels or a direct legend, choose more distinct ${code("colors")}, or show fewer ${noun}.` };
7097
7257
  };
7098
7258
  var chartColorsAdjusted = (finding2, _context, helpers) => {
7099
- const index = match(finding2.message, /^Chart colou?r (\d+) /)?.[1] ?? (isText2(helpers.segments.at(-1)) ? String(Number(helpers.segments.at(-1)) + 1) : void 0);
7259
+ const index = match(finding2.message, /^Chart color (\d+) /)?.[1] ?? (isText2(helpers.segments.at(-1)) ? String(Number(helpers.segments.at(-1)) + 1) : void 0);
7100
7260
  const value = helpers.valueAt(helpers.segments);
7101
- const shown = typeof value === "string" ? value : unquote(match(finding2.message, /^Chart colou?r \d+ \((.+?)\) /)?.[1]);
7261
+ const shown = typeof value === "string" ? value : unquote(match(finding2.message, /^Chart color \d+ \((.+?)\) /)?.[1]);
7102
7262
  const contrast = measuredNumber(finding2, "contrast");
7103
7263
  const panel = measuredText(finding2, "panel");
7104
7264
  const label = index ? `Chart color ${index}` : "A chart color";
@@ -7137,7 +7297,7 @@ var chartOptionAdapted = (finding2, _context, helpers) => {
7137
7297
  if (!option) return void 0;
7138
7298
  const type = at2 >= 0 ? helpers.valueAt([...helpers.segments.slice(0, at2 + 1), "type"]) : void 0;
7139
7299
  const typeName = typeof type === "string" ? type : match(finding2.message, /^A '(.+?)' chart/)?.[1];
7140
- const adaptation = finding2.message.includes(";") ? cap(us(finding2.message.slice(finding2.message.indexOf(";") + 1).trim())) : "";
7300
+ const adaptation = finding2.message.includes(";") ? cap(finding2.message.slice(finding2.message.indexOf(";") + 1).trim()) : "";
7141
7301
  return {
7142
7302
  message: `${code(option)} isn't supported by ${typeName ? `a ${typeName}` : "this"} chart and is adapted.${adaptation ? ` ${sentence(adaptation)}` : ""}`,
7143
7303
  next: `remove ${code(option)}, or choose a chart type that can show it.`
@@ -7158,7 +7318,7 @@ var unresolvedContent = (finding2) => ({
7158
7318
  var layoutFailed = (finding2, _context, helpers) => {
7159
7319
  const reason = match(finding2.message, /^Layout failed: (.+)$/)?.[1];
7160
7320
  return {
7161
- message: `${slideRef(finding2, helpers)} couldn't be laid out${reason ? `: ${sentence(us(reason)).replace(/\.$/, "")}` : ""}, so the geometry checks were skipped.`,
7321
+ message: `${slideRef(finding2, helpers)} couldn't be laid out${reason ? `: ${sentence(reason).replace(/\.$/, "")}` : ""}, so the geometry checks were skipped.`,
7162
7322
  next: "fix the composition setting or content named above."
7163
7323
  };
7164
7324
  };
@@ -7169,7 +7329,7 @@ var minFontSize = (finding2) => {
7169
7329
  const run = /^Text run is set to/.test(finding2.message);
7170
7330
  const label = run ? "A text run" : match(finding2.message, /^(.+?) is drawn at/)?.[1] ?? "Text";
7171
7331
  return {
7172
- message: `${cap(us(label))}${onSlide(finding2)} ${run ? "is set to" : "is drawn at"} ${num(size, 1)} pt, below the ${num(minimum, 1)} pt readable minimum.`,
7332
+ message: `${cap(label)}${onSlide(finding2)} ${run ? "is set to" : "is drawn at"} ${num(size, 1)} pt, below the ${num(minimum, 1)} pt readable minimum.`,
7173
7333
  next: run ? `raise ${code("fontSize")} to at least ${num(minimum, 1)}.` : "shorten the text, give it more room or split the slide, so it can be drawn larger."
7174
7334
  };
7175
7335
  };
@@ -7198,6 +7358,16 @@ var regionUnknown = (finding2, _context, helpers) => {
7198
7358
  const slide = slideNumber(finding2);
7199
7359
  const layout = slide ? regionNamesOf(helpers.valueAt(["slides", String(slide - 1), "layout"]), helpers) : void 0;
7200
7360
  const known = layout?.names ?? [];
7361
+ const renamed = (finding2.fixes ?? []).find((fix) => fix.id === "rename-region" && fix.kind === "patch");
7362
+ const next = renamed?.kind === "patch" ? renamed.patch?.[0]?.value : void 0;
7363
+ if (typeof next === "string") {
7364
+ const reference = slide ? helpers.valueAt(["slides", String(slide - 1), "layout"]) : void 0;
7365
+ const id = layout?.id ?? (typeof reference === "string" ? reference : void 0);
7366
+ return {
7367
+ message: `Block pinned to region ${code(region)}, which OPF 0.35 renamed ${code(next)}${id ? ` in layout ${code(id)}` : ""}.`,
7368
+ next: `pin it to ${code(next)} (the fix does).`
7369
+ };
7370
+ }
7201
7371
  return {
7202
7372
  message: layout ? `Block pinned to region ${code(region)}; layout ${code(layout.id)} has ${andList(known)}.` : `A block is pinned to region ${code(region)}, which the slide's layout doesn't have.`,
7203
7373
  next: known.length ? chooseNext(region, known, `remove ${code("region")}`) : `pin it to a region the layout has, or remove ${code("region")}.`
@@ -7681,7 +7851,7 @@ var imagePlacementInvalid = (finding2) => {
7681
7851
  };
7682
7852
  }
7683
7853
  return {
7684
- message: `${code("placement")} can't be used here: a block inside a group or a region can't bleed to a slide edge.`,
7854
+ message: `${code("placement")} can't be used here: a block inside a group or in a cell of the slide's grid can't bleed to a slide edge.`,
7685
7855
  next: `use ${code("placement")} on a top-level block of the slide, one per slide edge, or remove it.`
7686
7856
  };
7687
7857
  };
@@ -7758,7 +7928,7 @@ var numberFormatInvalid = (finding2, _context, helpers) => {
7758
7928
  const reason = match(finding2.message, /^Number format '.*?' ((?:needs|scales|has|uses|asks|allows|is)\b.+)$/)?.[1];
7759
7929
  const subject = typeof value === "string" && value ? `${code(value)} is not a number format OPF can read` : "This is not a number format OPF can read";
7760
7930
  return {
7761
- message: `${subject}.${reason ? ` It ${sentence(us(reason))}` : ""}`,
7931
+ message: `${subject}.${reason ? ` It ${sentence(reason)}` : ""}`,
7762
7932
  next: `write a format such as ${code("0.0")}, ${code("#,##0")}, ${code("0%")} or ${code("$#,##0.00")}.`
7763
7933
  };
7764
7934
  };
@@ -7806,7 +7976,7 @@ var variableInvalidValue = (finding2) => {
7806
7976
  if (!id) return void 0;
7807
7977
  const kind = found?.[2] ?? "";
7808
7978
  return {
7809
- message: `The value given for ${code(id)} does not fit its type${kind ? ` (${kind})` : ""}${found?.[3] ? `: ${us(found[3])}` : ""}.`,
7979
+ message: `The value given for ${code(id)} does not fit its type${kind ? ` (${kind})` : ""}${found?.[3] ? `: ${found[3]}` : ""}.`,
7810
7980
  next: `give it ${SAMPLE_BY_KIND[kind] ?? "a value of the declared type"}.`
7811
7981
  };
7812
7982
  };
@@ -7828,7 +7998,7 @@ var variableFormat = (finding2, _context, helpers) => {
7828
7998
  const reason = match(finding2.message, /^(?:Number|Date) format '.*?' (.+)$/)?.[1];
7829
7999
  const kind = id ? helpers.valueAt(["variables", id, "type"]) : void 0;
7830
8000
  return {
7831
- message: `The format${typeof declared === "string" ? ` ${code(declared)}` : ""} does not apply to ${kind ? `a ${String(kind)}` : "this"} value${id ? ` (${code(id)})` : ""}${reason ? `: it ${sentence(us(reason)).replace(/\.$/, "")}` : ""}.`,
8001
+ message: `The format${typeof declared === "string" ? ` ${code(declared)}` : ""} does not apply to ${kind ? `a ${String(kind)}` : "this"} value${id ? ` (${code(id)})` : ""}${reason ? `: it ${sentence(reason).replace(/\.$/, "")}` : ""}.`,
7832
8002
  next: `change the ${code("format")} of ${id ? code(id) : "the variable"} to one that fits its values, such as ${kind === "date" ? code("MMMM d, yyyy") : code("#,##0.0")}.`
7833
8003
  };
7834
8004
  };
@@ -7958,7 +8128,7 @@ var assetCycle = (finding2) => {
7958
8128
  };
7959
8129
  var KIND_SINGULAR2 = (kind) => KIND_WORDS[kind] ?? kind.replace(/s$/, "");
7960
8130
  var catalogRecord = (finding2, context) => {
7961
- const [root, group, kind, id] = finding2.path.split("/").slice(1).map((part) => part.replaceAll("~1", "/").replaceAll("~0", "~"));
8131
+ const [root, group, kind, id] = finding2.path.split("/").slice(1).map((part2) => part2.replaceAll("~1", "/").replaceAll("~0", "~"));
7962
8132
  if (root !== "catalogs" || !kind || !id) return void 0;
7963
8133
  const inner = describeFinding({ ...finding2, ruleId: "opf/schema" }, context);
7964
8134
  const registered = finding2.scope === "context";
@@ -7969,7 +8139,7 @@ var catalogRecord = (finding2, context) => {
7969
8139
  };
7970
8140
  };
7971
8141
  function layoutSpot(finding2) {
7972
- const parts2 = finding2.path.split("/").slice(1).map((part) => part.replaceAll("~1", "/").replaceAll("~0", "~"));
8142
+ const parts2 = finding2.path.split("/").slice(1).map((part2) => part2.replaceAll("~1", "/").replaceAll("~0", "~"));
7973
8143
  if (parts2[0] === "catalogs" && parts2[2] === "layouts") return { id: parts2[3], spot: dotted(parts2.slice(4)) };
7974
8144
  return { spot: dotted(parts2) };
7975
8145
  }
@@ -7977,7 +8147,7 @@ var layoutTemplate2 = (finding2) => {
7977
8147
  const { id, spot } = layoutSpot(finding2);
7978
8148
  const detail = finding2.message.trim().replace(/\.$/, "");
7979
8149
  return {
7980
- message: `The layout's region list is malformed${spot ? ` at ${code(spot)}` : ""}${id ? ` (layout ${code(id)})` : ""}: ${us(detail)}.`,
8150
+ message: `The layout's region list is malformed${spot ? ` at ${code(spot)}` : ""}${id ? ` (layout ${code(id)})` : ""}: ${detail}.`,
7981
8151
  next: spot ? `correct ${code(spot)} as described; the layout is not used until it is valid.` : "correct the layout as described; it is not used until it is valid."
7982
8152
  };
7983
8153
  };
@@ -8007,7 +8177,7 @@ var layoutRegion = (finding2) => {
8007
8177
  };
8008
8178
  }
8009
8179
  return {
8010
- message: `A region of the layout is not valid${spot ? ` at ${code(spot)}` : ""}${id ? ` (layout ${code(id)})` : ""}: ${us(detail)}.`,
8180
+ message: `A region of the layout is not valid${spot ? ` at ${code(spot)}` : ""}${id ? ` (layout ${code(id)})` : ""}: ${detail}.`,
8011
8181
  next: spot ? `correct ${code(spot)} as described.` : "correct the layout as described."
8012
8182
  };
8013
8183
  };
@@ -8020,6 +8190,26 @@ var unresolvedReference2 = (finding2, _context, helpers) => {
8020
8190
  return typeof value === "string" ? value : void 0;
8021
8191
  })();
8022
8192
  if (!reference) return void 0;
8193
+ if (kind === "layouts" && reference === "auto" && /removed layout 'auto'/.test(finding2.message)) {
8194
+ return {
8195
+ message: `Layout ${code("auto")} was removed in OPF 0.35: a slide without ${code("layout")} composes automatically, which is what ${code("auto")} did.`,
8196
+ next: `delete the ${code("layout")} key (the fix does).`
8197
+ };
8198
+ }
8199
+ const replaced = kind === "layouts" ? /removed layout '.+?' \(use '(.+?)'(?: with design\.titlePosition '(.+?)')?\)/.exec(finding2.message) : void 0;
8200
+ const renamed = replaced?.[1], position = replaced?.[2];
8201
+ if (renamed && position) {
8202
+ return {
8203
+ message: `Layout ${code(reference)} was removed in OPF 0.35: ${code(renamed)} with the title beside the body (${code(`design.titlePosition: "${position}"`)}) replaced it.`,
8204
+ next: `change the layout to ${code(renamed)} and set the slide's ${code("design.titlePosition")} to ${code(position)} (the fix does both).`
8205
+ };
8206
+ }
8207
+ if (renamed) {
8208
+ return {
8209
+ message: `Layout ${code(reference)} was removed in OPF 0.35: ${code(renamed)} replaced it.`,
8210
+ next: `change the layout to ${code(renamed)} (the fix does).`
8211
+ };
8212
+ }
8023
8213
  const noun = cap(KIND_SINGULAR2(kind || (found?.[1] ?? "catalog record").toLowerCase()));
8024
8214
  const colon = reference.indexOf(":");
8025
8215
  const group = colon > 0 ? reference.slice(0, colon) : void 0;
@@ -8028,9 +8218,10 @@ var unresolvedReference2 = (finding2, _context, helpers) => {
8028
8218
  const embedded = kind && embeddedIn.some((name) => isRecord2(helpers.valueAt(["catalogs", name, kind, bare])));
8029
8219
  const suggestions = (finding2.suggestions ?? []).slice(0, 5).map((entry2) => String(entry2.value));
8030
8220
  if (embedded) {
8221
+ const current = (finding2.fixes ?? []).some((fix) => fix.id === "use-current-record" || fix.id === "rename-layout");
8031
8222
  return {
8032
- message: `${noun} ${code(reference)} is embedded but invalid, so it is not used and ${FALLBACK(kind)}.`,
8033
- next: `fix the record named in the other problems, or remove the reference.`
8223
+ message: `${noun} ${code(reference)} is embedded, but the record is invalid.`,
8224
+ next: current ? `take the current record (the fix does, as do ${code("opf fix -i")} and ${code("opf embed -i")}).` : `fix the record named in the other problems, or remove the reference.`
8034
8225
  };
8035
8226
  }
8036
8227
  const message = group && /declares no catalogs\./.test(finding2.message) ? `${noun} ${code(reference)} uses catalog group ${code(group)}, which the deck does not declare, so ${FALLBACK(kind)}.` : `${noun} ${code(reference)} is not embedded or in a registered catalog, so ${FALLBACK(kind)}.`;
@@ -8364,6 +8555,7 @@ var PATTERN_PHRASES = Object.freeze({
8364
8555
  "\\S": { what: "a label with at least one non-whitespace character", next: "write a nonblank label, or omit it." },
8365
8556
  "^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$": { what: "a hex color like `#1F4E79` (3, 6 or 8 hex digits)", next: "write the color as #RRGGBB." },
8366
8557
  "^[a-z][a-z0-9-]*$": { what: ID, next: ID_NEXT },
8558
+ "^([a-z][a-z0-9-]*|(top|middle|bottom|top\\+middle|middle\\+bottom|top\\+middle\\+bottom)(:(start|center|end|start\\+center|center\\+end|start\\+center\\+end))?|start|center|end|start\\+center|center\\+end|start\\+center\\+end)$": { what: "a region of the slide's layout (lowercase letters, digits and hyphens, like `aside`) or, on a slide without a layout, a cell of its grid like `start`, `top:end` or `middle+bottom:center+end`", next: "name a region of the layout, or a cell: rows (top, middle, bottom) before the colon and columns (start, center, end) after it, each span in reading order." },
8367
8559
  "^[a-z0-9][a-z0-9-]*$": { what: "an id of lowercase letters, digits and hyphens, like `my-chart`", next: ID_NEXT },
8368
8560
  "^(?:[a-z][a-z0-9-]*:)?[a-z][a-z0-9-]*$": { what: "a catalog id like `pillars` or `acme:hero` (lowercase letters, digits and hyphens)", next: "use the id of a record, with the catalog group in front when it has one." },
8369
8561
  "^[a-zA-Z0-9][a-zA-Z0-9._-]*$": { what: "an id of letters, digits, dots, hyphens and underscores that starts with a letter or digit, like `logo-2`", next: "use letters, digits, dots, hyphens and underscores, without spaces." },
@@ -8498,6 +8690,11 @@ function describeSchema(finding2, context, helpers) {
8498
8690
  case "additionalProperties": {
8499
8691
  const name = String(params2.additionalProperty ?? segments.at(-1) ?? "");
8500
8692
  const parent = segments.slice(0, -1);
8693
+ const cell = parent.length === 2 && parent[0] === "slides" ? nearestGridCell(name) : void 0;
8694
+ if (cell) return {
8695
+ message: `${code(name)} is a slide key OPF 0.35 removed: a block of the slide's ${code("blocks")} names its cell with ${code("region")}.`,
8696
+ next: `apply the fix that moves it into a block, or write ${code(`{ "region": "${cell.cell ?? "top:start"}", ... }`)} in the slide's ${code("blocks")}.`
8697
+ };
8501
8698
  const allowed = schemaKeys(parent, context);
8502
8699
  const suggested = finding2.suggestions?.[0]?.value;
8503
8700
  const hint = typeof suggested === "string" && allowed.includes(suggested) ? suggested : nearest(name, allowed).close[0];
@@ -8568,7 +8765,16 @@ function starterValue(document, segments, property) {
8568
8765
 
8569
8766
  // src/schema-fixes.ts
8570
8767
  var MAX_CHANGES = 5;
8571
- var patch = (id, title, operations, safe2 = false) => ({ id, title, kind: "patch", safe: safe2, patch: operations });
8768
+ var patch = (id, title, operations, safe2 = false, changesDrawing = false) => ({ id, title, kind: "patch", safe: safe2, ...changesDrawing ? { changesDrawing: true } : {}, patch: operations });
8769
+ var REMOVED_DESIGN_KEY_FIXES = Object.freeze({
8770
+ contentDirection: { safe: true, changesDrawing: () => true },
8771
+ chartPrimary: { safe: true, changesDrawing: (segments) => !(segments[0] === "catalogs" && segments[2] === "layouts") }
8772
+ });
8773
+ function removedDesignKeyOperations(document, segments) {
8774
+ const parent = segments.slice(0, -1), design = readAt(document, parent);
8775
+ const alone = isRecord2(design) && Object.keys(design).length === 1;
8776
+ return [{ op: "remove", path: pointerOf(alone ? parent : segments) }];
8777
+ }
8572
8778
  var allowsKey = (document, segments, key3) => {
8573
8779
  try {
8574
8780
  return schemaVariants(schemaAtPath(document, segments)).some((variant) => Object.hasOwn(variant.properties ?? {}, key3));
@@ -8634,6 +8840,101 @@ function schemaFixes(finding2, document) {
8634
8840
  return [];
8635
8841
  }
8636
8842
  }
8843
+ function listColumnsChangeDrawing(region) {
8844
+ if (!isRecord2(region) || region.listColumns !== "auto") return true;
8845
+ const accepts = Array.isArray(region.accepts) ? region.accepts : [];
8846
+ const arrangement = region.arrangement ?? region.sequence;
8847
+ return !(accepts[0] === "list" && (arrangement === void 0 || arrangement === "numbered"));
8848
+ }
8849
+ 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.`;
8850
+ function removedKeyRepair(finding2, document) {
8851
+ const validation = finding2.validation;
8852
+ if (!validation || finding2.ruleId !== "opf/schema" && finding2.ruleId !== "opf/catalog-record") return void 0;
8853
+ const segments = segmentsOf(finding2.path);
8854
+ 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]);
8855
+ const inRegion = segments.at(-3) === "regions";
8856
+ if (validation.keyword === "additionalProperties" && inRegion && (segments.at(-1) === "sequence" || segments.at(-1) === "pyramidDirection")) {
8857
+ const parent = segments.slice(0, -1), region = readAt(document, parent), value = readAt(document, segments);
8858
+ if (!isRecord2(region) || value === void 0) return void 0;
8859
+ const arrangement = region.arrangement;
8860
+ if (segments.at(-1) === "sequence") {
8861
+ 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.`;
8862
+ 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: [] };
8863
+ return { help: help2, fixes: [patch("use-arrangement", `Write arrangement ${value}`, [{ op: "move", from: finding2.path, path: pointerOf([...parent, "arrangement"]) }], true)] };
8864
+ }
8865
+ 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).';
8866
+ if (arrangement !== "pyramid") return { help, fixes: [] };
8867
+ 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)] };
8868
+ if (value === "up") return { help, fixes: [patch("use-pyramid", "Keep arrangement pyramid (upright)", [{ op: "remove", path: finding2.path }], true)] };
8869
+ return { help, fixes: [] };
8870
+ }
8871
+ if (validation.keyword === "enum" && inRegion && segments.at(-1) === "arrangement") {
8872
+ const value = readAt(document, segments), renamed = value === "flow" ? "process" : value === "vertical-flow" ? "vertical-process" : void 0;
8873
+ if (renamed === void 0) return void 0;
8874
+ 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)] };
8875
+ }
8876
+ const alignment = segments.at(-1);
8877
+ if (validation.keyword === "enum" && finding2.ruleId === "opf/catalog-record" && segments.at(-2) === "design" && (alignment === "titleAlignment" || alignment === "contentAlignment")) {
8878
+ const value = readAt(document, segments), next = value === "left" ? "start" : value === "right" ? "end" : void 0;
8879
+ if (next === void 0) return void 0;
8880
+ 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)] };
8881
+ }
8882
+ if (validation.keyword === "enum" && inRegion && segments.at(-1) === "role" && readAt(document, segments) === "secondary") {
8883
+ return {
8884
+ 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".`,
8885
+ 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" }])]
8886
+ };
8887
+ }
8888
+ if (validation.keyword === "additionalProperties") {
8889
+ const name = segments.at(-1) ?? "";
8890
+ 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))))] };
8891
+ if (segments.at(-2) !== "design" || !Object.hasOwn(REMOVED_DESIGN_KEYS, name) || readAt(document, segments) === void 0) return void 0;
8892
+ const marks = REMOVED_DESIGN_KEY_FIXES[name] ?? { safe: true, changesDrawing: () => true };
8893
+ return { help: REMOVED_DESIGN_KEYS[name], fixes: [patch(`remove:${name}`, `Delete design.${name}`, removedDesignKeyOperations(document, segments), marks.safe, marks.changesDrawing(segments))] };
8894
+ }
8895
+ if (validation.keyword === "pattern" && segments.at(-1) === "region" && segments.at(-3) === "blocks" && segments[0] === "slides" && segments.length === 5) {
8896
+ const typed = readAt(document, segments), near = typeof typed === "string" ? nearestGridCell(typed) : void 0;
8897
+ if (!near?.help) return void 0;
8898
+ 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 }])] : [] };
8899
+ }
8900
+ if (validation.keyword === "enum" && segments.at(-1) === "flow" && segments.at(-3) === "regions" && readAt(document, segments) === "none") {
8901
+ const parent = segments.slice(0, -1), region = readAt(document, parent);
8902
+ 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".';
8903
+ if (!isRecord2(region) || region.max !== void 0 && region.max !== 1) return { help, fixes: [] };
8904
+ 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)] };
8905
+ }
8906
+ return void 0;
8907
+ }
8908
+ var ROOT_CONTENT = ["type", "text", "items", "bullets", "image", "video", "chart", "table", "code", "metric", "quote", "timeline", "diagram", "shape", "path", "blocks"];
8909
+ function removedCellKeys(slide) {
8910
+ if (!isRecord2(slide)) return [];
8911
+ const found = Object.keys(slide).flatMap((key3) => {
8912
+ const cell = nearestGridCell(key3)?.cell;
8913
+ return cell ? [{ key: key3, cell }] : [];
8914
+ });
8915
+ const order2 = cellsInReadingOrder(found);
8916
+ return order2.flatMap((cell) => found.filter((entry2) => entry2.cell === cell));
8917
+ }
8918
+ function cellKeysAsBlocks(slide) {
8919
+ const keys = removedCellKeys(slide);
8920
+ if (!keys.length || !isRecord2(slide) || ROOT_CONTENT.some((field) => slide[field] !== void 0) || keys.some(({ key: key3 }) => !isRecord2(slide[key3]))) return void 0;
8921
+ const placed = slide.layout === void 0;
8922
+ const blocks = keys.map(({ key: key3, cell }) => {
8923
+ const { id, region: _ignored, ...rest } = slide[key3];
8924
+ return { ...id !== void 0 ? { id } : {}, ...placed ? { region: cell } : {}, ...rest };
8925
+ });
8926
+ return { keys: keys.map(({ key: key3 }) => key3), blocks };
8927
+ }
8928
+ function cellKeyRepair(document, slideSegments, key3) {
8929
+ const slide = readAt(document, slideSegments), near = nearestGridCell(key3);
8930
+ const layout = isRecord2(slide) && slide.layout !== void 0;
8931
+ const example = near.cell ? `{ "region": "${near.cell}", ... }` : '{ "region": "top:start", ... }';
8932
+ 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}` : "");
8933
+ const moved = near.cell ? cellKeysAsBlocks(slide) : void 0;
8934
+ if (!moved) return { help, fixes: [], dropSuggestions: true };
8935
+ const operations = [...moved.keys.map((name) => ({ op: "remove", path: pointerOf([...slideSegments, name]) })), { op: "add", path: pointerOf([...slideSegments, "blocks"]), value: moved.blocks }];
8936
+ 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 };
8937
+ }
8637
8938
 
8638
8939
  // src/drawn-font-families.ts
8639
8940
  function resolveDrawnFontFamilies(families, measurement, keepsName) {
@@ -8721,7 +9022,7 @@ function resolveSlideScriptMeasurement(presentation, slideIndex, measurement, op
8721
9022
  }
8722
9023
 
8723
9024
  // src/message-surface.ts
8724
- var rec2 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
9025
+ var rec3 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
8725
9026
  var MESSAGE_SURFACE_SLOT = "accent1";
8726
9027
  var MESSAGE_SURFACE_CONTRAST = 4.5;
8727
9028
  function messageKind(slide, layout) {
@@ -8734,7 +9035,7 @@ function messageKind(slide, layout) {
8734
9035
  return void 0;
8735
9036
  }
8736
9037
  if (plan?.stack !== void 0 && statementMessage(slide, plan) !== void 0) return "statement-message";
8737
- if (plan && (plan.regions.length > 1 || plan.regions.some((region) => region.role === "media" || region.flow === "grid"))) return void 0;
9038
+ if (plan && (plan.regions.length > 1 || plan.regions.some((region) => region.role === "media" || region.flow === "grid" || region.flow === "row"))) return void 0;
8738
9039
  const value = lone.host.text;
8739
9040
  const cited = Array.isArray(value) && value.some((run) => run && typeof run === "object" && (run.cite !== void 0 || run.footnote !== void 0));
8740
9041
  return !cited && messageWords(value) > 0 && messageWords(value) <= SHORT_MESSAGE_WORDS ? "display-message" : void 0;
@@ -8753,7 +9054,7 @@ function lchOf(hex) {
8753
9054
  var MESSAGE_SURFACE_MAX_LIGHTNESS = 60;
8754
9055
  var MESSAGE_SURFACE_MAX_CHROMA = 80;
8755
9056
  function resolveMessageSurface(presentation, slide, layout, context) {
8756
- const deckDesign = rec2(rec2(presentation).design);
9057
+ const deckDesign = rec3(rec3(presentation).design);
8757
9058
  const kind = messageKind(slide, layout), named = layoutVariantKind(layout);
8758
9059
  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;
8759
9060
  const below = colorChoice([deckDesign, context.theme], context.colorScheme, context.variables);
@@ -8766,7 +9067,7 @@ function resolveMessageSurface(presentation, slide, layout, context) {
8766
9067
  return { kind, variant };
8767
9068
  }
8768
9069
  function drawsAccentByDesign(presentation, host, record, theme) {
8769
- const deckDesign = rec2(rec2(presentation).design), own4 = normalizeColorVariant(rec2(host.design).variant), named = layoutColorVariant(record);
9070
+ const deckDesign = rec3(rec3(presentation).design), own4 = normalizeColorVariant(rec3(host.design).variant), named = layoutColorVariant(record);
8770
9071
  if (own4) return own4.background.startsWith("accent");
8771
9072
  return named !== void 0 && layoutVariantApplies(host.design, record, deckDesign, theme.background) && named.background.startsWith("accent");
8772
9073
  }
@@ -8778,7 +9079,7 @@ function messageDisplayed(result, kind) {
8778
9079
  }
8779
9080
 
8780
9081
  // src/slide-context.ts
8781
- var rec3 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
9082
+ var rec4 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
8782
9083
  function unpathed(measurement) {
8783
9084
  const bare = (style) => ({ ...style, path: void 0 });
8784
9085
  return {
@@ -8790,18 +9091,18 @@ function unpathed(measurement) {
8790
9091
  };
8791
9092
  }
8792
9093
  function resolveSlideContext(presentation, index, options2 = {}) {
8793
- const deck = rec3(presentation);
9094
+ const deck = rec4(presentation);
8794
9095
  const slides = Array.isArray(deck.slides) ? deck.slides : [];
8795
9096
  if (!Number.isInteger(index) || index < 0 || index >= slides.length) throw new RangeError(`Slide index ${String(index)} is outside the presentation's ${slides.length} slides.`);
8796
- const slide = rec3(slides[index]);
9097
+ const slide = rec4(slides[index]);
8797
9098
  const catalogs = { catalogs: checkCatalogsOption(options2.catalogs, "resolveSlideContext") };
8798
9099
  const records = resolveDesignRecords(presentation, index, catalogs);
8799
9100
  const diagnostics = [...records.diagnostics];
8800
9101
  const { theme, colorScheme, fontScheme } = records;
8801
- const design = { ...rec3(deck.design), ...rec3(slide.design) };
9102
+ const design = { ...rec4(deck.design), ...rec4(slide.design) };
8802
9103
  let layout;
8803
9104
  let layoutProvenance;
8804
- if (typeof slide.layout === "string" && slide.layout !== "auto") {
9105
+ if (typeof slide.layout === "string") {
8805
9106
  const found = resolveReference(presentation, "layouts", slide.layout, catalogs);
8806
9107
  if (found) {
8807
9108
  layout = { ...found.record };
@@ -8809,10 +9110,10 @@ function resolveSlideContext(presentation, index, options2 = {}) {
8809
9110
  } else diagnostics.push(unresolvedReference(presentation, "layouts", slide.layout, `slides.${index}.layout`, catalogs));
8810
9111
  }
8811
9112
  if (options2.strictReferences && diagnostics.length) throw new OPFUnresolvedReferenceError(diagnostics);
8812
- const candidate = resolveMessageSurface(presentation, slide, layout, { theme, colorScheme, variables: rec3(deck.variables), themeChosen: records.provenance.theme !== void 0 });
9113
+ const candidate = resolveMessageSurface(presentation, slide, layout, { theme, colorScheme, variables: rec4(deck.variables), themeChosen: records.provenance.theme !== void 0 });
8813
9114
  const build = (surface) => {
8814
- const levels = colorLevels(rec3(slide.design), layout, rec3(deck.design), theme, colorScheme, rec3(deck.variables), surface?.variant);
8815
- const roles2 = resolveColorRoles(colorScheme, colorChoice(levels, colorScheme, rec3(deck.variables)));
9115
+ const levels = colorLevels(rec4(slide.design), layout, rec4(deck.design), theme, colorScheme, rec4(deck.variables), surface?.variant);
9116
+ const roles2 = resolveColorRoles(colorScheme, colorChoice(levels, colorScheme, rec4(deck.variables)));
8816
9117
  const layoutVariant2 = levels.length > 3 && layoutVariantApplies(slide.design, layout, deck.design, theme.background, surface) ? levels[1].variant : void 0;
8817
9118
  const composeOptions2 = {
8818
9119
  ...resolveCanvasDimensions(design.dimensions ?? theme.dimensions),
@@ -8823,12 +9124,12 @@ function resolveSlideContext(presentation, index, options2 = {}) {
8823
9124
  slideCount: options2.slideCount ?? slides.length,
8824
9125
  fontFamilies: resolveFontFamilies(fontScheme),
8825
9126
  darkBackground: roles2.dark,
8826
- ...surface ? { messageSurface: surface, resolveRunColor: (reference) => resolveColorRef(reference, { colorScheme, roles: roles2, variables: rec3(deck.variables), fallback: "" }) || void 0 } : {},
9127
+ ...surface ? { messageSurface: surface, resolveRunColor: (reference) => resolveColorRef(reference, { colorScheme, roles: roles2, variables: rec4(deck.variables), fallback: "" }) || void 0 } : {},
8827
9128
  // LH-02: the colors the automatic scrim of a picture background is sized for.
8828
9129
  roles: { text: roles2.text, textSecondary: roles2.textSecondary, primary: roles2.primary, background: roles2.background },
8829
9130
  ...theme.background !== void 0 ? { themeBackground: theme.background } : {},
8830
9131
  // OPF 0.19: a theme may carry the shared design keys (between the deck's design and the layout record's).
8831
- ...theme.design !== void 0 && rec3(theme.design) === theme.design ? { themeDesign: theme.design } : {},
9132
+ ...theme.design !== void 0 && rec4(theme.design) === theme.design ? { themeDesign: theme.design } : {},
8832
9133
  ...options2.fonts?.textMeasurement ? { textMeasurement: options2.fonts.textMeasurement } : {},
8833
9134
  ...options2.date !== void 0 ? { date: options2.date } : {}
8834
9135
  };
@@ -8847,7 +9148,7 @@ function resolveSlideContext(presentation, index, options2 = {}) {
8847
9148
  displayed = false;
8848
9149
  }
8849
9150
  if (displayed && index > 0) {
8850
- const before = rec3(slides[index - 1]), record = typeof before.layout === "string" && before.layout !== "auto" ? resolveReference(presentation, "layouts", before.layout, catalogs)?.record : void 0;
9151
+ const before = rec4(slides[index - 1]), record = typeof before.layout === "string" ? resolveReference(presentation, "layouts", before.layout, catalogs)?.record : void 0;
8851
9152
  if (drawsAccentByDesign(presentation, before, record, theme) || resolveSlideContext(presentation, index - 1, { ...options2, slideNumber: void 0 }).resolved.messageSurface !== void 0) displayed = false;
8852
9153
  }
8853
9154
  if (!displayed) {
@@ -8963,28 +9264,28 @@ var MAX_KEY_BYTES = 2 * 1024 * 1024;
8963
9264
  function key2(value, opaque) {
8964
9265
  let bytes = 0;
8965
9266
  const seen = /* @__PURE__ */ new Set();
8966
- const part = (text2) => {
9267
+ const part2 = (text2) => {
8967
9268
  bytes += text2.length * 2;
8968
9269
  if (bytes > MAX_KEY_BYTES) throw new RangeError("Review cache key budget exceeded.");
8969
9270
  return text2;
8970
9271
  };
8971
9272
  const walk2 = (node, depth2) => {
8972
9273
  if (depth2 > 128) throw new RangeError("Review cache key depth exceeded.");
8973
- if (node === null) return part("null;");
8974
- if (node === void 0) return part("undefined;");
8975
- if (typeof node === "string") return part(`s${JSON.stringify(node)}`);
8976
- if (typeof node === "boolean") return part(node ? "true;" : "false;");
8977
- if (typeof node === "number" && Number.isFinite(node)) return part(`n${Object.is(node, -0) ? "-0" : node};`);
9274
+ if (node === null) return part2("null;");
9275
+ if (node === void 0) return part2("undefined;");
9276
+ if (typeof node === "string") return part2(`s${JSON.stringify(node)}`);
9277
+ if (typeof node === "boolean") return part2(node ? "true;" : "false;");
9278
+ if (typeof node === "number" && Number.isFinite(node)) return part2(`n${Object.is(node, -0) ? "-0" : node};`);
8978
9279
  if (typeof node === "function" && opaque) {
8979
9280
  opaque.push(node);
8980
- return part(`f${opaque.length};`);
9281
+ return part2(`f${opaque.length};`);
8981
9282
  }
8982
9283
  if (typeof node !== "object" || seen.has(node) || !Array.isArray(node) && ![Object.prototype, null].includes(Object.getPrototypeOf(node))) throw new TypeError("Opaque review cache input.");
8983
9284
  seen.add(node);
8984
9285
  const descriptors = Object.getOwnPropertyDescriptors(node);
8985
9286
  if (Array.isArray(node) ? Reflect.ownKeys(node).length !== node.length + 1 || Object.keys(node).some((name, i) => name !== String(i)) : Object.values(descriptors).some((descriptor) => !descriptor.enumerable)) throw new TypeError("Non-JSON review cache input.");
8986
9287
  if (Reflect.ownKeys(node).some((name) => typeof name === "symbol") || Object.values(descriptors).some((descriptor) => !("value" in descriptor))) throw new TypeError("Opaque review cache input.");
8987
- const result = Array.isArray(node) ? part("a[") + Array.from({ length: node.length }, (_, i) => Object.hasOwn(node, i) ? walk2(node[i], depth2 + 1) : part("hole;")).join("") + part("]") : part("o{") + Object.keys(node).map((name) => part(JSON.stringify(name)) + walk2(node[name], depth2 + 1)).join("") + part("}");
9288
+ const result = Array.isArray(node) ? part2("a[") + Array.from({ length: node.length }, (_, i) => Object.hasOwn(node, i) ? walk2(node[i], depth2 + 1) : part2("hole;")).join("") + part2("]") : part2("o{") + Object.keys(node).map((name) => part2(JSON.stringify(name)) + walk2(node[name], depth2 + 1)).join("") + part2("}");
8988
9289
  seen.delete(node);
8989
9290
  return result;
8990
9291
  };
@@ -9242,7 +9543,7 @@ function resolveOptions(options2) {
9242
9543
  if (measurement !== void 0 && typeof measurement !== "function" && !isObject3(measurement)) throw new TypeError("Validate fonts.textMeasurement must be a text measurement, or a function of the slide index.");
9243
9544
  }
9244
9545
  if (options2.chartPalette !== void 0 && (!Array.isArray(options2.chartPalette) || !options2.chartPalette.every((color) => typeof color === "string" && /^#[0-9a-fA-F]{6}$/.test(color))))
9245
- throw new TypeError("Validate chartPalette must be an array of #RRGGBB colours.");
9546
+ throw new TypeError("Validate chartPalette must be an array of #RRGGBB colors.");
9246
9547
  if (options2.template !== void 0 && typeof options2.template !== "boolean") throw new TypeError("Validate template must be true or false.");
9247
9548
  if (options2.values !== void 0 && !isObject3(options2.values)) throw new TypeError("Validate values must be an object keyed by variable id.");
9248
9549
  const level = (info) => severity.get(info.id) ?? severity.get(info.category);
@@ -9255,12 +9556,13 @@ function resolveOptions(options2) {
9255
9556
  const value = level(info);
9256
9557
  return value === "off" ? void 0 : value;
9257
9558
  },
9258
- ignored: (info, path) => ignorePaths.some((entry2) => entry2.match(info) && entry2.path.every((part, index) => path[index] === part)),
9559
+ ignored: (info, path) => ignorePaths.some((entry2) => entry2.match(info) && entry2.path.every((part2, index) => path[index] === part2)),
9259
9560
  thresholds,
9260
9561
  chartPalette: options2.chartPalette
9261
9562
  };
9262
9563
  }
9263
9564
  var order = new Map(validationRules.map((info, index) => [info.id, index]));
9565
+ var STALE_RECORD_RULES = /* @__PURE__ */ new Set(["opf/catalog-record", "opf/layout-template", "opf/layout-region"]);
9264
9566
  var categoryOrder = (category) => {
9265
9567
  const index = validationCategories.indexOf(category);
9266
9568
  return index < 0 ? validationCategories.length : index;
@@ -9358,11 +9660,26 @@ function validateDocument(document, run, parsed, cache) {
9358
9660
  entry2.run(context);
9359
9661
  }
9360
9662
  }
9663
+ const staleCopies = /* @__PURE__ */ new Map();
9664
+ const staleRepair = (entry2) => {
9665
+ if (!STALE_RECORD_RULES.has(entry2.ruleId) || entry2.scope === "context") return void 0;
9666
+ const match2 = /^\/catalogs\/([^/]+)\/layouts\/([^/]+)(?:\/|$)/.exec(entry2.path);
9667
+ if (!match2) return void 0;
9668
+ const [group, id] = [match2[1], match2[2]].map((segment) => segment.replaceAll("~1", "/").replaceAll("~0", "~"));
9669
+ let found = staleCopies.get(`${group}/${id}`);
9670
+ if (!found) {
9671
+ const copy = staleLayoutCopy(document, group, id, run.options);
9672
+ const fix = copy ? staleCopyFix(document, copy, run.options) : void 0;
9673
+ found = copy ? { copy, ...fix ? { fix } : {} } : {};
9674
+ staleCopies.set(`${group}/${id}`, found);
9675
+ }
9676
+ return found.copy ? { cause: staleCopyCause(found.copy), fix: found.fix } : void 0;
9677
+ };
9361
9678
  const finished = [];
9362
9679
  for (const entry2 of findings) {
9363
9680
  const info = findValidationRule(entry2.ruleId);
9364
9681
  const override = info ? run.severity(info) : void 0;
9365
- const next = override && override !== entry2.severity ? { ...entry2, severity: override } : entry2;
9682
+ let next = override && override !== entry2.severity ? { ...entry2, severity: override } : entry2;
9366
9683
  if (info && run.ignored(info, splitPointer(next.path))) continue;
9367
9684
  const index = slideOf(next.path);
9368
9685
  if (next.slide === void 0 && index !== void 0 && next.scope !== "context") {
@@ -9374,10 +9691,14 @@ function validateDocument(document, run, parsed, cache) {
9374
9691
  const location = parsed.locate(next.path);
9375
9692
  if (location) next.location = location;
9376
9693
  }
9694
+ const removed = next.scope !== "context" ? removedKeyRepair(next, document) : void 0;
9695
+ if (removed) next = withRepair(next, removed);
9377
9696
  if (next.ruleId === "opf/schema" && next.fixes === void 0 && next.scope !== "context") {
9378
9697
  const fixes = schemaFixes(next, document);
9379
9698
  if (fixes.length) next.fixes = fixes;
9380
9699
  }
9700
+ const stale = staleRepair(next);
9701
+ if (stale) next = { ...next, message: `${stale.cause.split("; ")[0]}: ${next.message}`, help: next.help ? `${stale.cause} ${next.help}` : stale.cause, ...stale.fix ? { fixes: [stale.fix] } : {} };
9381
9702
  finished.push(next);
9382
9703
  }
9383
9704
  finished.sort(
@@ -9440,11 +9761,18 @@ function assertValid(value, options2 = {}) {
9440
9761
  const report2 = validate(value, options2);
9441
9762
  if (!report2.valid) throw new OPFValidationError(report2);
9442
9763
  }
9764
+ function withRepair(finding2, removed) {
9765
+ const { suggestions, ...rest } = finding2;
9766
+ return { ...removed.dropSuggestions ? rest : { ...rest, ...suggestions ? { suggestions } : {} }, help: removed.help, ...removed.fixes.length ? { fixes: removed.fixes } : {} };
9767
+ }
9443
9768
  function validateCatalogRecord(kind, value) {
9444
9769
  const kinds = Object.keys(catalogSchemaNames);
9445
9770
  if (!kinds.includes(kind)) throw new TypeError(`Unknown catalog kind ${JSON.stringify(kind)}. Kinds: ${kinds.join(", ")}.`);
9446
9771
  const engine = validateAgainstSchema(value, kind);
9447
- const findings = engine.errors.map((issue2) => issueFinding(issue2, issueRuleId(issue2), engine.schemaName));
9772
+ const findings = engine.errors.map((issue2) => {
9773
+ const found = issueFinding(issue2, issueRuleId(issue2), engine.schemaName), removed = removedKeyRepair(found, value);
9774
+ return removed ? withRepair(found, removed) : found;
9775
+ });
9448
9776
  const tally = counts(findings);
9449
9777
  const checks = {
9450
9778
  syntax: "not-applicable",
@@ -9463,4 +9791,4 @@ function assertValidCatalogRecord(kind, value) {
9463
9791
  if (!report2.valid) throw new OPFValidationError(report2);
9464
9792
  }
9465
9793
 
9466
- 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, isPromotedRegionKey, jsonEqual, listSchemaFields, nearest, normalizePatch, parsePointer, parseSource, pointerFromPath, readPointer, rememberByText, resolveDrawnFontFamilies, resolveIdPatch, resolveIdPointer, resolveSchema, resolveSlideContext, resolveSlideScriptMeasurement, ruleDocumentation, schemaAtPath, schemaCatalogKinds, schemaLabel, schemaType, schemaVariants, segmentsOf, splitOpfPath, splitPointer2 as splitPointer, starterValue, toIdPatch, toIdPointer, unescapePointerToken, us, validate, validateCatalogRecord, validationCategories, validationRules, walkPatch };
9794
+ 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 };