@openpresentation/opf 0.33.0 → 0.34.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 (93) hide show
  1. package/README.md +3 -3
  2. package/dist/browser.js +20 -19
  3. package/dist/catalog-refs-CoIrOdAw.d.ts +937 -0
  4. package/dist/{catalog-schemas-CQTM-G8p.d.ts → catalog-schemas-FjLRPtjB.d.ts} +1 -1
  5. package/dist/{chart-data-oIZQlFGi.d.ts → chart-data-B_k-WTex.d.ts} +7 -4
  6. package/dist/{chunk-XIOC6N5P.js → chunk-244OPLAV.js} +1 -1
  7. package/dist/{chunk-S5QRGMUQ.js → chunk-2HX4BGAS.js} +6 -6
  8. package/dist/{chunk-Y557TYML.js → chunk-36DLVJGW.js} +19 -16
  9. package/dist/{chunk-VKEYV3ZK.js → chunk-3THGTDL2.js} +2 -2
  10. package/dist/{chunk-ABWEUXLV.js → chunk-42JBXJKW.js} +117 -21
  11. package/dist/chunk-BLCDUM7B.js +7 -0
  12. package/dist/{chunk-OPVJLL7H.js → chunk-CJVKOJ6B.js} +11841 -8687
  13. package/dist/{chunk-BI4ERFAA.js → chunk-DQ7QYOUV.js} +48 -13
  14. package/dist/{chunk-KVHNDHVS.js → chunk-F6BXO4AI.js} +1 -1
  15. package/dist/{chunk-UK3J6FSU.js → chunk-FAXO3SUE.js} +858 -268
  16. package/dist/{chunk-XANW7MB7.js → chunk-FIQMAIZV.js} +4 -4
  17. package/dist/{chunk-PJSPHHRK.js → chunk-FK5XG742.js} +3 -16
  18. package/dist/{chunk-R6C6BQOG.js → chunk-HHVQ2SDT.js} +1 -1
  19. package/dist/{chunk-DAS75LGR.js → chunk-HUGVYHZ2.js} +4 -4
  20. package/dist/{chunk-QF5RSRXU.js → chunk-LCT5ZV3Q.js} +750 -199
  21. package/dist/chunk-NLJFNCZ4.js +1560 -0
  22. package/dist/{chunk-VSBZC2PR.js → chunk-QGJVOPLG.js} +3 -3
  23. package/dist/{chunk-E7WQHMCL.js → chunk-QGTJF7HV.js} +16 -14
  24. package/dist/{chunk-VMBLNCX2.js → chunk-RUV7CCE6.js} +117 -30
  25. package/dist/{chunk-YS333HLA.js → chunk-U7TYSPYM.js} +2 -2
  26. package/dist/chunk-UJZN2ZH6.js +1 -0
  27. package/dist/{chunk-IJXKVM4W.js → chunk-VDZXNNZF.js} +1 -1
  28. package/dist/{chunk-YYT6N7AI.js → chunk-WCPDN7AY.js} +1 -1
  29. package/dist/{chunk-QD6DPS7X.js → chunk-WMFT5R7I.js} +2 -2
  30. package/dist/{chunk-INIMUBSE.js → chunk-XJUMFH33.js} +1 -1
  31. package/dist/{composition-zMiIgzip.d.ts → composition-CvtvgBDE.d.ts} +1360 -1531
  32. package/dist/composition.d.ts +3 -3
  33. package/dist/composition.js +2 -1
  34. package/dist/{conversion-mNth9XKm.d.ts → conversion-B_5AKTYQ.d.ts} +25 -7
  35. package/dist/conversion-CMBGOTAC.js +25 -0
  36. package/dist/convert.d.ts +4 -4
  37. package/dist/convert.js +15 -11
  38. package/dist/data.d.ts +2 -2
  39. package/dist/data.js +3 -2
  40. package/dist/{deck-report-BSlRiR0_.d.ts → deck-report-BVlQZ42f.d.ts} +3 -3
  41. package/dist/deck.d.ts +6 -6
  42. package/dist/deck.js +12 -11
  43. package/dist/diagram-engine-eager.js +5 -1
  44. package/dist/diagram-engine-lazy.js +13 -0
  45. package/dist/diagram-plantuml-XRZ6VAOL.js +3 -0
  46. package/dist/diff.js +5 -4
  47. package/dist/docs.js +64 -52
  48. package/dist/examples.js +4070 -1083
  49. package/dist/font-policy.js +1 -1
  50. package/dist/format.js +2 -2
  51. package/dist/ids.js +5 -4
  52. package/dist/index.d.ts +18 -16
  53. package/dist/index.js +35 -24
  54. package/dist/markdown.d.ts +2 -2
  55. package/dist/markdown.js +9 -8
  56. package/dist/node-engine.d.ts +43 -11
  57. package/dist/node-engine.js +45 -26
  58. package/dist/{pagination-CYzNMazO.d.ts → pagination-CZQQYk7L.d.ts} +4 -3
  59. package/dist/pagination.d.ts +4 -4
  60. package/dist/pagination.js +5 -4
  61. package/dist/patch.js +4 -3
  62. package/dist/precompiled.js +2 -2
  63. package/dist/{presentation-CXhfpB_z.d.ts → presentation-s9262acV.d.ts} +357 -230
  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 +3 -3
  68. package/dist/schema.js +4 -3
  69. package/dist/schemas.d.ts +16 -0
  70. package/dist/schemas.js +1 -1
  71. package/dist/shape-engine-eager.js +2 -2
  72. package/dist/shape-engine-lazy.js +1 -1
  73. package/dist/{shape-engine-module-BK7JNEUV.js → shape-engine-module-N74FCHGY.js} +2 -2
  74. package/dist/shape-geometry.js +1 -1
  75. package/dist/source.d.ts +10 -5
  76. package/dist/source.js +11 -10
  77. package/dist/spec/reference/engine-vocabularies.json +135 -0
  78. package/dist/spec/reference/font-policy.json +3 -16
  79. package/dist/spec/reference/preset-geometry.json +3 -3
  80. package/dist/spec/schemas/icon-set.schema.json +1 -1
  81. package/dist/spec/schemas/layout.schema.json +71 -25
  82. package/dist/spec/schemas/opf.schema.json +540 -168
  83. package/dist/spec/schemas/theme.schema.json +11 -5
  84. package/dist/types.d.ts +81 -73
  85. package/dist/{validation-types-COwTel3H.d.ts → validation-types-CYbsUuZ9.d.ts} +8 -5
  86. package/dist/validator.d.ts +34 -7
  87. package/dist/validator.js +4 -3
  88. package/dist/yaml.d.ts +2 -2
  89. package/dist/yaml.js +8 -7
  90. package/package.json +6 -6
  91. package/dist/catalog-refs-B_0_vZg0.d.ts +0 -134
  92. package/dist/chunk-ZXOIGUHX.js +0 -1
  93. package/dist/conversion-POHRAMSN.js +0 -24
@@ -1,6 +1,6 @@
1
1
  import { original } from './chunk-JBARNYFR.js';
2
- import { schemas, schemaEntries } from './chunk-QF5RSRXU.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, readingRows, visualReadingOrder, intrinsicImageSize, resolveReference, layoutTable, colorTransform, applyColorTransform, resolveColorRef, resolveDesignRecords, resolveFontFamilies, checkCatalogsOption, provenanceOf, unresolvedReference, OPFUnresolvedReferenceError, composeSlide, resolveColorRoles, layoutVariantApplies, resolveCanvasDimensions, resolveSlideVariables, layoutVariantKind, deckBackgroundIsChosen, LONE_DISPLAY_SIZES, normalizeColorVariant, layoutColorVariant, isRecord, hasContentVariables, isTemplate, instantiateForValidation, layoutTemplateIssues, deckBackgroundIsFixed, resolveScriptFonts, lonePayload, annotationText, isLayoutTemplate, layoutTemplate, statementMessage, messageWords, SHORT_MESSAGE_WORDS, catalogReferenceSites, parseReference, catalogGroupDeclared, pointerPath, unusedDatasets, documentIcons, iconIssue, MAX_COMPOSITION_DEPTH, isOverlayConnector, connectorAdjustPreset, shapeIssues, pathFor, overlayIssues, datasetDiagnostics, defaultSlideBackground, catalogRecords, collectCitations, numberingFindings, walkCitationRuns, chartDrawDiagnostics, resolveTableData, resolveChartOptions, chartOptionTarget, codeHighlightLines, chartNumberFixesByCell, catalogKinds, catalogGroupSource, registeredCatalog, isShapeBlock, OPFCompositionError } from './chunk-OPVJLL7H.js';
2
+ import { schemas, schemaEntries } from './chunk-LCT5ZV3Q.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, chartNumberFixesByCell, catalogKinds, catalogGroupSource, registeredCatalog, representablePositionBox, PositionRangeError, isShapeBlock, OPFCompositionError } from './chunk-CJVKOJ6B.js';
4
4
  import { schemaEngine } from '#schema-engine';
5
5
  import { parseTree, printParseErrorCode, getNodePath } from 'jsonc-parser';
6
6
 
@@ -200,8 +200,8 @@ function rememberValidationDefinition(issue2, parentSchema, keyword) {
200
200
  pointer: current.pointer,
201
201
  uri: `${entry2.schema.$id}#${current.pointer}`
202
202
  });
203
- for (const [key2, value] of Object.entries(current.value)) {
204
- const segment = key2.replaceAll("~", "~0").replaceAll("/", "~1");
203
+ for (const [key3, value] of Object.entries(current.value)) {
204
+ const segment = key3.replaceAll("~", "~0").replaceAll("/", "~1");
205
205
  stack.push({ value, pointer: `${current.pointer}/${segment}` });
206
206
  }
207
207
  }
@@ -299,12 +299,12 @@ var imageOptionFields = ["fit", "focus", "aspectRatio", "shape", "adjust", "stro
299
299
  var shapeImageFields = /* @__PURE__ */ new Set(["aspectRatio", "shape", "adjust", "stroke", "opacity"]);
300
300
  var shapeOptionFields = SHAPE_BLOCK_KEYS.filter((field) => field !== "path");
301
301
  var columnSpans = {
302
- left: [0],
302
+ start: [0],
303
303
  center: [1],
304
- right: [2],
305
- "left+center": [0, 1],
306
- "center+right": [1, 2],
307
- "left+center+right": [0, 1, 2]
304
+ end: [2],
305
+ "start+center": [0, 1],
306
+ "center+end": [1, 2],
307
+ "start+center+end": [0, 1, 2]
308
308
  };
309
309
  var rowSpans = {
310
310
  top: [0],
@@ -354,12 +354,31 @@ function semanticIssue(path, message, params2 = {}) {
354
354
  params: params2
355
355
  };
356
356
  }
357
- function hasOwn(value, key2) {
358
- return Object.hasOwn(value, key2);
357
+ function hasOwn(value, key3) {
358
+ return Object.hasOwn(value, key3);
359
359
  }
360
360
  function isEnUkTag(value) {
361
361
  return typeof value === "string" && value.toLowerCase() === "en-uk";
362
362
  }
363
+ var EN_UK_MESSAGE = "Use 'en-GB' for UK English; 'en-UK' is not a valid BCP-47 region tag";
364
+ function enUkIssues(language, path) {
365
+ const at2 = isEnUkTag(language) ? path : isRecord(language) && isEnUkTag(language.bcp47) ? `${path}/bcp47` : void 0;
366
+ return at2 ? [semanticIssue(at2, EN_UK_MESSAGE, { replacement: "en-GB" })] : [];
367
+ }
368
+ function overlayAnchorSizeWarnings(value) {
369
+ const issues = [];
370
+ if (isRecord(value) && Array.isArray(value.slides)) value.slides.forEach((slide, index) => {
371
+ if (isRecord(slide) && Array.isArray(slide.shapes)) slide.shapes.forEach((entry2, shapeIndex) => {
372
+ const at2 = isRecord(entry2) ? entry2.at : void 0;
373
+ if (isRecord(at2)) for (const key3 of ["width", "height"]) {
374
+ const size = at2[key3];
375
+ if (typeof size === "number" && size > 4 && size <= 8 && !hasOwn(at2, `${key3}Px`))
376
+ issues.push(semanticIssue(`/slides/${index}/shapes/${shapeIndex}/at/${key3}`, `at.${key3} is ${size}, a fraction; pixels are ${key3}Px`, { code: "shape-anchor-size-unit", key: key3, size }));
377
+ }
378
+ });
379
+ });
380
+ return issues;
381
+ }
363
382
  function presentFields(value, fields2) {
364
383
  return fields2.filter((field) => hasOwn(value, field));
365
384
  }
@@ -394,7 +413,7 @@ function validateContentPayload(value, path, options2 = {}) {
394
413
  const explicitType = value.type;
395
414
  const payloadFields = presentFields(value, rootPayloadFields);
396
415
  const hasBlocks = hasOwn(value, "blocks");
397
- const captionIssue = (reason, params2 = {}) => semanticIssue(pathFor(path, "caption"), `caption is only valid on an image, chart, table or video payload; ${reason}`, { code: "caption-unsupported-payload", ...params2 });
416
+ const captionIssue = (reason, params2 = {}) => semanticIssue(pathFor(path, "caption"), `caption is only valid on an image, chart, table, video or diagram payload; ${reason}`, { code: "caption-unsupported-payload", ...params2 });
398
417
  const imageOptionIssues = (reason, params2 = {}, except = /* @__PURE__ */ new Set()) => {
399
418
  for (const field of imageOptionFields) if (hasOwn(value, field) && !except.has(field)) issues.push(semanticIssue(pathFor(path, field), `${field} is only valid on an image payload; ${reason}`, { code: "image-option-unsupported-payload", field, ...params2 }));
400
419
  };
@@ -413,7 +432,7 @@ function validateContentPayload(value, path, options2 = {}) {
413
432
  if (incompatible2.length) issues.push(semanticIssue(path, "blocks cannot be mixed with leaf payload fields", { fields: incompatible2 }));
414
433
  if (!Array.isArray(value.blocks) || value.blocks.length === 0 && !options2.slideRoot) issues.push(semanticIssue(pathFor(path, "blocks"), "a group requires at least one block"));
415
434
  if (Array.isArray(value.blocks)) value.blocks.forEach((block, index) => {
416
- if (isRecord(block)) issues.push(...validateContentPayload(block, `${pathFor(path, "blocks")}/${index}`, { topLevel: options2.slideRoot === true }));
435
+ if (isRecord(block)) issues.push(...validateContentPayload(block, `${pathFor(path, "blocks")}/${index}`, { topLevel: options2.slideRoot === true, ...options2.canvas ? { canvas: options2.canvas } : {} }));
417
436
  });
418
437
  if (options2.slideRoot && Array.isArray(value.blocks)) {
419
438
  const edges = /* @__PURE__ */ new Map();
@@ -459,13 +478,30 @@ function validateContentPayload(value, path, options2 = {}) {
459
478
  if (resolvedKind !== "image") imageOptionIssues(`this payload is '${resolvedKind}'`, { type: resolvedKind }, resolvedKind === "shape" ? shapeImageFields : void 0);
460
479
  if (resolvedKind !== "shape") shapeOptionIssues(`this payload is '${resolvedKind}'`, { type: resolvedKind });
461
480
  if (resolvedKind === "shape" || resolvedKind === "image")
462
- for (const issue2 of shapeIssues(value, (...keys) => keys.reduce((at2, key2) => pathFor(at2, key2), path))) issues.push(semanticIssue(issue2.path, issue2.message, { code: issue2.code, ...issue2.params }));
481
+ for (const issue2 of shapeIssues(value, (...keys) => keys.reduce((at2, key3) => pathFor(at2, key3), path))) issues.push(semanticIssue(issue2.path, issue2.message, { code: issue2.code, ...issue2.params }));
482
+ if (resolvedKind === "image" && isRecord(value.image) && Array.isArray(value.image.callouts)) {
483
+ value.image.callouts.forEach((callout, index) => {
484
+ if (!isRecord(callout)) return;
485
+ for (const key3 of ["x", "y"]) if (typeof callout[key3] === "number" && !Number.isFinite(callout[key3])) issues.push(semanticIssue(`${pathFor(path, "image")}/callouts/${index}/${key3}`, "an image callout origin must be a finite signed fraction", { key: key3 }));
486
+ const canvas = options2.canvas;
487
+ if (canvas && ["x", "y", "width", "height"].every((key3) => typeof callout[key3] === "number" && Number.isFinite(callout[key3]))) {
488
+ const at2 = `${pathFor(path, "image")}/callouts/${index}`, frame = callout;
489
+ try {
490
+ representablePositionBox({ x: frame.x * canvas.width, y: frame.y * canvas.height, width: frame.width * canvas.width, height: frame.height * canvas.height }, at2.replace(/^\//, "").replaceAll("/", "."));
491
+ } catch (error) {
492
+ if (!(error instanceof PositionRangeError)) throw error;
493
+ issues.push(semanticIssue(`${at2}/${error.coordinate}`, error.message, { key: error.coordinate }));
494
+ }
495
+ }
496
+ });
497
+ }
463
498
  const allowedFields = /* @__PURE__ */ new Set([
464
499
  "type",
465
500
  ...spec.fields
466
501
  ]);
502
+ const listOfBullets = resolvedKind === "list" && hasOwn(value, "bullets") && !hasOwn(value, "items");
467
503
  for (const required of spec.required) {
468
- if (!hasOwn(value, required)) {
504
+ if (!hasOwn(value, required) && !listOfBullets) {
469
505
  issues.push(semanticIssue(path, `content payload type '${resolvedKind}' requires '${required}'`, {
470
506
  type: resolvedKind,
471
507
  required
@@ -480,27 +516,27 @@ function validateContentPayload(value, path, options2 = {}) {
480
516
  }
481
517
  const incompatible = payloadFields.filter((field) => !allowedFields.has(field));
482
518
  if (incompatible.length > 0) {
483
- issues.push(semanticIssue(path, `content payload type '${resolvedKind}' cannot include incompatible fields: ${incompatible.join(", ")}`, {
519
+ issues.push(semanticIssue(path, listOfBullets && incompatible.length === 1 ? "'bullets' belongs to a text payload, so it cannot be a 'list': write the entries under 'items', or remove 'type'" : `content payload type '${resolvedKind}' cannot include incompatible fields: ${incompatible.join(", ")}`, {
484
520
  type: resolvedKind,
485
521
  incompatible
486
522
  }));
487
523
  }
488
524
  return issues;
489
525
  }
490
- function slideRegion(key2) {
491
- if (key2.includes(":")) {
492
- const [rowPart, columnPart] = key2.split(":");
526
+ function slideRegion(key3) {
527
+ if (key3.includes(":")) {
528
+ const [rowPart, columnPart] = key3.split(":");
493
529
  if (!rowPart || !columnPart) return void 0;
494
530
  const rows = rowSpans[rowPart];
495
531
  const columns = columnSpans[columnPart];
496
532
  return rows && columns ? { rows, columns } : void 0;
497
533
  }
498
- if (key2 in columnSpans) {
499
- const columns = columnSpans[key2];
534
+ if (key3 in columnSpans) {
535
+ const columns = columnSpans[key3];
500
536
  return columns ? { rows: [0, 1, 2], columns } : void 0;
501
537
  }
502
- if (key2 in rowSpans) {
503
- const rows = rowSpans[key2];
538
+ if (key3 in rowSpans) {
539
+ const rows = rowSpans[key3];
504
540
  return rows ? { rows, columns: [0, 1, 2] } : void 0;
505
541
  }
506
542
  return void 0;
@@ -511,9 +547,9 @@ function intersects(left, right) {
511
547
  function regionsOverlap(left, right) {
512
548
  return intersects(left.rows, right.rows) && intersects(left.columns, right.columns);
513
549
  }
514
- function validateSlideRegions(slide, slidePath) {
550
+ function validateSlideRegions(slide, slidePath, canvas) {
515
551
  const issues = [];
516
- const regionKeys = Object.keys(slide).filter((key2) => promotedRegionKeySet.has(key2));
552
+ const regionKeys = Object.keys(slide).filter((key3) => promotedRegionKeySet.has(key3));
517
553
  const rootFields = presentFields(slide, rootPayloadFields);
518
554
  if (regionKeys.length > 0 && rootFields.length > 0) {
519
555
  issues.push(semanticIssue(slidePath, "root content payload fields cannot be mixed with promoted region keys", {
@@ -522,12 +558,12 @@ function validateSlideRegions(slide, slidePath) {
522
558
  }));
523
559
  }
524
560
  if (regionKeys.length === 0 && rootFields.length > 0) {
525
- issues.push(...validateContentPayload(slide, slidePath, { slideRoot: true }));
561
+ issues.push(...validateContentPayload(slide, slidePath, { slideRoot: true, ...canvas ? { canvas } : {} }));
526
562
  }
527
- for (const key2 of regionKeys) {
528
- const value = slide[key2];
563
+ for (const key3 of regionKeys) {
564
+ const value = slide[key3];
529
565
  if (isRecord(value)) {
530
- issues.push(...validateContentPayload(value, pathFor(slidePath, key2)));
566
+ issues.push(...validateContentPayload(value, pathFor(slidePath, key3), canvas ? { canvas } : {}));
531
567
  }
532
568
  }
533
569
  for (let leftIndex = 0; leftIndex < regionKeys.length; leftIndex += 1) {
@@ -551,19 +587,19 @@ function validateSlideRegions(slide, slidePath) {
551
587
  }
552
588
  function deckMetadataIssues(value) {
553
589
  const issues = [];
554
- const entries = (key2) => {
555
- const field = value[key2];
556
- if (Array.isArray(field)) return field.flatMap((entry2, index) => isRecord(entry2) ? [{ entry: entry2, path: `/${key2}/${index}` }] : []);
557
- return isRecord(field) ? [{ entry: field, path: `/${key2}` }] : [];
590
+ const entries = (key3) => {
591
+ const field = value[key3];
592
+ if (Array.isArray(field)) return field.flatMap((entry2, index) => isRecord(entry2) ? [{ entry: entry2, path: `/${key3}/${index}` }] : []);
593
+ return isRecord(field) ? [{ entry: field, path: `/${key3}` }] : [];
558
594
  };
559
595
  const organizationIds = /* @__PURE__ */ new Set();
560
- for (const key2 of ["organization", "speaker"]) {
596
+ for (const key3 of ["organization", "speaker"]) {
561
597
  const seen = /* @__PURE__ */ new Set();
562
- for (const { entry: entry2, path } of entries(key2)) {
598
+ for (const { entry: entry2, path } of entries(key3)) {
563
599
  if (typeof entry2.id !== "string") continue;
564
- if (seen.has(entry2.id)) issues.push(semanticIssue(`${path}/id`, `${key2} ids must be unique within a presentation`, { id: entry2.id }));
600
+ if (seen.has(entry2.id)) issues.push(semanticIssue(`${path}/id`, `${key3} ids must be unique within a presentation`, { id: entry2.id }));
565
601
  seen.add(entry2.id);
566
- if (key2 === "organization") organizationIds.add(entry2.id);
602
+ if (key3 === "organization") organizationIds.add(entry2.id);
567
603
  }
568
604
  }
569
605
  for (const { entry: entry2, path } of entries("speaker")) {
@@ -573,25 +609,36 @@ function deckMetadataIssues(value) {
573
609
  }
574
610
  return issues;
575
611
  }
576
- function presentationSemanticIssues(value) {
612
+ function presentationSemanticIssues(value, catalogs) {
577
613
  if (!isRecord(value) || !Array.isArray(value.slides)) {
578
614
  return [];
579
615
  }
580
616
  const issues = [];
581
- if (isEnUkTag(value.language)) {
582
- issues.push(semanticIssue("/language", "Use 'en-GB' for UK English; 'en-UK' is not a valid BCP-47 region tag", {
583
- replacement: "en-GB"
584
- }));
585
- } else if (isRecord(value.language) && isEnUkTag(value.language.bcp47)) {
586
- issues.push(semanticIssue("/language/bcp47", "Use 'en-GB' for UK English; 'en-UK' is not a valid BCP-47 region tag", {
587
- replacement: "en-GB"
588
- }));
589
- }
617
+ issues.push(...enUkIssues(value.language, "/language"));
590
618
  issues.push(...deckMetadataIssues(value));
591
619
  if (isRecord(value.variables) && hasOwn(value.variables, "speakers")) {
592
620
  issues.push(semanticIssue("/variables/speakers", "'speakers' is reserved for the built-in list of speaker names; choose another variable id", { id: "speakers" }));
593
621
  }
594
622
  const documentIds = /* @__PURE__ */ new Map();
623
+ let overlayCanvas, overlayCanvasResolved = false;
624
+ const deckCanvas = () => {
625
+ if (!overlayCanvasResolved) {
626
+ overlayCanvasResolved = true;
627
+ const design = isRecord(value.design) ? value.design : {};
628
+ const dimensions = design.dimensions ?? resolveDesignRecords(value, void 0, { catalogs: catalogs ?? [] }).theme.dimensions;
629
+ try {
630
+ overlayCanvas = resolveCanvasDimensions(dimensions);
631
+ } catch {
632
+ }
633
+ }
634
+ return overlayCanvas;
635
+ };
636
+ const canvasForOverlays = (slide, index) => {
637
+ if (!Array.isArray(slide.shapes) || !slide.shapes.some((shape) => isRecord(shape) && shape.connector === void 0 && ["x", "y", "width", "height"].every((key3) => typeof shape[key3] === "number" && Number.isFinite(shape[key3])))) return void 0;
638
+ const canvas = deckCanvas();
639
+ return canvas ? { ...canvas, rtl: resolveSlideDirection(value, index) === "rtl" } : void 0;
640
+ };
641
+ 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);
595
642
  value.slides.forEach((slide, index) => {
596
643
  if (isRecord(slide)) {
597
644
  const slidePath = `/slides/${index}`;
@@ -615,10 +662,11 @@ function presentationSemanticIssues(value) {
615
662
  else documentIds.set(entry2.id, "payload");
616
663
  }
617
664
  const checked = isOverlayConnector(entry2) ? isRecord(entry2.adjust) ? { shape: connectorAdjustPreset(entry2), adjust: entry2.adjust } : void 0 : entry2;
618
- if (checked) for (const issue2 of shapeIssues(checked, (...keys) => keys.reduce((at2, key2) => pathFor(at2, key2), entryPath))) issues.push(semanticIssue(issue2.path, issue2.message, { code: issue2.code, ...issue2.params }));
665
+ if (checked) for (const issue2 of shapeIssues(checked, (...keys) => keys.reduce((at2, key3) => pathFor(at2, key3), entryPath))) issues.push(semanticIssue(issue2.path, issue2.message, { code: issue2.code, ...issue2.params }));
619
666
  });
620
- for (const issue2 of overlayIssues(slide, slidePath)) issues.push(semanticIssue(issue2.path, issue2.message, { ...issue2.code ? { code: issue2.code } : {}, ...issue2.params }));
621
- issues.push(...validateSlideRegions(slide, slidePath));
667
+ 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 }));
668
+ issues.push(...enUkIssues(slide.language, `${slidePath}/language`));
669
+ issues.push(...validateSlideRegions(slide, slidePath, hasCallouts(slide) ? deckCanvas() : void 0));
622
670
  const payloadTableIssues = (payload, path) => {
623
671
  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));
624
672
  };
@@ -728,9 +776,9 @@ function dataIssues(value) {
728
776
  const seen = /* @__PURE__ */ new Set();
729
777
  const add = (diagnostics) => {
730
778
  for (const diagnostic of diagnostics) {
731
- const key2 = `${diagnostic.code}|${diagnostic.path}`;
732
- if (seen.has(key2)) continue;
733
- seen.add(key2);
779
+ const key3 = `${diagnostic.code}|${diagnostic.path}`;
780
+ if (seen.has(key3)) continue;
781
+ seen.add(key3);
734
782
  (diagnostic.severity === "error" ? out.errors : out.warnings).push(semanticIssue(diagnostic.path, diagnostic.message, { code: diagnostic.code }));
735
783
  }
736
784
  };
@@ -888,6 +936,9 @@ function variableReferenceWarnings(value) {
888
936
  textEntries(node.items, pathFor(path, "items"));
889
937
  textEntries(node.bullets, pathFor(path, "bullets"));
890
938
  table(node.table, pathFor(path, "table"));
939
+ if (isRecord(node.chart) && Array.isArray(node.chart.referenceLines)) node.chart.referenceLines.forEach((line2, index) => {
940
+ if (isRecord(line2) && isRecord(line2.stroke)) colorRef(line2.stroke.color, `${path}/chart/referenceLines/${index}/stroke/color`);
941
+ });
891
942
  };
892
943
  value.slides.forEach((slide, index) => {
893
944
  if (!isRecord(slide)) return;
@@ -927,24 +978,16 @@ function presentationReferenceWarnings(value, catalogs) {
927
978
  };
928
979
  highlightWarnings(slide, slidePath);
929
980
  visitContentPayloads(slide, slidePath, highlightWarnings);
930
- for (const key2 of Object.keys(slide)) {
931
- if (promotedRegionKeySet.has(key2)) {
932
- issues.push(...chartTypeWarnings(slide[key2], pathFor(slidePath, key2)));
981
+ for (const key3 of Object.keys(slide)) {
982
+ if (promotedRegionKeySet.has(key3)) {
983
+ issues.push(...chartTypeWarnings(slide[key3], pathFor(slidePath, key3)));
933
984
  }
934
985
  }
935
986
  });
936
987
  return issues;
937
988
  }
938
989
  function validateLanguageSemantics(value) {
939
- if (!isRecord(value)) {
940
- return [];
941
- }
942
- if (isEnUkTag(value.bcp47)) {
943
- return [semanticIssue("/bcp47", "Use 'en-GB' for UK English; 'en-UK' is not a valid BCP-47 region tag", {
944
- replacement: "en-GB"
945
- })];
946
- }
947
- return [];
990
+ return isRecord(value) ? enUkIssues(value.bcp47, "/bcp47") : [];
948
991
  }
949
992
  function contentDepthIssues(value) {
950
993
  if (!isRecord(value) || !Array.isArray(value.slides)) return [];
@@ -954,7 +997,7 @@ function contentDepthIssues(value) {
954
997
  if (Array.isArray(slide.blocks)) slide.blocks.forEach((block, i) => {
955
998
  stack.push({ value: block, path: `/slides/${index}/blocks/${i}`, depth: 0, ancestors: [] });
956
999
  });
957
- for (const key2 of promotedRegionKeys) if (hasOwn(slide, key2)) stack.push({ value: slide[key2], path: `/slides/${index}/${key2}`, depth: 0, ancestors: [] });
1000
+ for (const key3 of promotedRegionKeys) if (hasOwn(slide, key3)) stack.push({ value: slide[key3], path: `/slides/${index}/${key3}`, depth: 0, ancestors: [] });
958
1001
  });
959
1002
  while (stack.length) {
960
1003
  const entry2 = stack.pop();
@@ -1008,9 +1051,9 @@ function typedVariableErrors(errors, value) {
1008
1051
  function pointerValue(root, pointer4) {
1009
1052
  let current = root;
1010
1053
  for (const token of pointer4.split("/").slice(1)) {
1011
- const key2 = token.replaceAll("~1", "/").replaceAll("~0", "~");
1012
- if (Array.isArray(current)) current = current[Number(key2)];
1013
- else if (isRecord(current) && hasOwn(current, key2)) current = current[key2];
1054
+ const key3 = token.replaceAll("~1", "/").replaceAll("~0", "~");
1055
+ if (Array.isArray(current)) current = current[Number(key3)];
1056
+ else if (isRecord(current) && hasOwn(current, key3)) current = current[key3];
1014
1057
  else return void 0;
1015
1058
  }
1016
1059
  return current;
@@ -1078,12 +1121,13 @@ function validateAgainstSchema(value, schemaOrKind = "presentation", options2 =
1078
1121
  if (resolved.schemaName === "layout" && valid) for (const issue2 of layoutTemplateIssues(subject)) errors.push(semanticIssue(issue2.path, issue2.message, { code: issue2.code }));
1079
1122
  const warnings = [];
1080
1123
  if (resolved.schemaName === "presentation") {
1081
- errors.push(...presentationSemanticIssues(subject));
1124
+ errors.push(...presentationSemanticIssues(subject, options2.catalogs));
1082
1125
  errors.push(...variableIssues.errors);
1083
1126
  const data = dataIssues(subject);
1084
1127
  errors.push(...data.errors);
1085
1128
  warnings.push(...presentationReferenceWarnings(subject, options2.catalogs));
1086
1129
  warnings.push(...data.warnings);
1130
+ warnings.push(...overlayAnchorSizeWarnings(subject));
1087
1131
  warnings.push(...variableIssues.warnings);
1088
1132
  } else if (resolved.schemaName === "language") {
1089
1133
  errors.push(...validateLanguageSemantics(value));
@@ -1299,6 +1343,31 @@ function decisionColor(definition, scheme, variables = {}) {
1299
1343
  }
1300
1344
  }
1301
1345
  var THEME_SLOTS = /* @__PURE__ */ new Set(["light1", "light2", "dark1", "dark2"]);
1346
+ var PICTURE_STEPS = [0, 32, 64, 96, 128, 160, 192, 224, 255];
1347
+ var TONE_MARGIN = 1.2;
1348
+ function pictureColors(definition, scheme, variables = {}, grays) {
1349
+ const picture = imageBackground(definition);
1350
+ if (!picture) return [];
1351
+ const resolve2 = (value, fallback) => backgroundColorRef(value, scheme, variables, fallback);
1352
+ const recolor = rec(picture.recolor);
1353
+ const steps = PICTURE_STEPS;
1354
+ const duotone = recolor.dark !== void 0 && recolor.light !== void 0;
1355
+ const dark = duotone ? resolve2(recolor.dark, "#000000") : "#000000", light = duotone ? resolve2(recolor.light, "#FFFFFF") : "#FFFFFF";
1356
+ const base = defaultSlideBackground(scheme), opacity = picture.opacity ?? 1;
1357
+ const pixels = steps.map((step) => blend(blend(light, dark, step / 255), base, opacity));
1358
+ const overlay = rec(picture.overlay), alpha = typeof overlay.opacity === "number" ? Math.max(0, Math.min(1, overlay.opacity)) : void 0;
1359
+ if (overlay.color === void 0 || alpha === void 0) return pixels;
1360
+ const color = resolve2(overlay.color, "#000000"), covered = pixels.map((pixel) => blend(color, pixel, alpha));
1361
+ return overlay.edge === void 0 ? covered : [...pixels, ...covered];
1362
+ }
1363
+ function pictureTone(definition, scheme, variables = {}, grays) {
1364
+ const picture = imageBackground(definition);
1365
+ if (!picture || picture.recolor === void 0 && picture.overlay === void 0 && picture.opacity === void 0 && true) return void 0;
1366
+ const colors = pictureColors(definition, scheme, variables);
1367
+ const worst = (text2) => Math.min(...colors.map((color) => contrastRatio(text2, color)));
1368
+ const onDark = worst(resolveColorRoles(scheme, { variant: { background: "dark1" } }).text), onLight = worst(resolveColorRoles(scheme, { variant: { background: "light1" } }).text);
1369
+ return onDark >= onLight * TONE_MARGIN ? "dark" : onLight >= onDark * TONE_MARGIN ? "light" : void 0;
1370
+ }
1302
1371
  function colorChoice(levels, scheme, variables = {}) {
1303
1372
  let variantOnly = false;
1304
1373
  let picture;
@@ -1316,7 +1385,7 @@ function colorChoice(levels, scheme, variables = {}) {
1316
1385
  if (variantOnly || definition === void 0 || definition === null || definition === false) continue;
1317
1386
  if (themeSlot) return { variant: { background: themeSlot } };
1318
1387
  if (isPicture) {
1319
- const tone = rec(definition).tone;
1388
+ const tone = rec(definition).tone ?? pictureTone(definition, scheme, variables);
1320
1389
  if (tone === "dark" || tone === "light") return { variant: { background: tone === "dark" ? "dark1" : "light1" } };
1321
1390
  variantOnly = true;
1322
1391
  picture = { definition };
@@ -1429,10 +1498,13 @@ function backdropColors(backdrop, box, size, layer) {
1429
1498
  const opacity = layer?.opacity ?? backdrop.opacity;
1430
1499
  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;
1431
1500
  const colors = ramp.map((grey) => {
1432
- let color = blend(grey, backdrop.base, opacity);
1501
+ const pixel = layer?.duotone ? blend(layer.duotone[1], layer.duotone[0], toRgb(grey)[0] / 255) : grey;
1502
+ let color = blend(pixel, backdrop.base, opacity);
1433
1503
  if (layer?.overlay) color = blend(layer.overlay.color, color, layer.overlay.opacity);
1434
1504
  return color;
1435
1505
  });
1506
+ const band = layer?.band;
1507
+ if (band) return { colors: [...band.whole ? [] : colors, ...colors.map((color) => blend(band.color, color, band.opacity))], unknown: true };
1436
1508
  return { colors, unknown: true };
1437
1509
  }
1438
1510
  }
@@ -1498,6 +1570,10 @@ function textValues(slide, slidePath) {
1498
1570
  push(at2("table", "rows", r, c, ...Object.hasOwn(styled, "value") ? ["value"] : []), value, "table", "table");
1499
1571
  });
1500
1572
  });
1573
+ const callouts = rec(node.image).callouts;
1574
+ if (Array.isArray(callouts)) callouts.forEach((callout, index) => {
1575
+ push(at2("image", "callouts", index, "text"), rec(callout).text, "callout", "image");
1576
+ });
1501
1577
  const quote = node.quote;
1502
1578
  if (typeof quote === "string") push(at2("quote"), quote, "quote", "quote");
1503
1579
  else if (quote && typeof quote === "object") {
@@ -1509,9 +1585,9 @@ function textValues(slide, slidePath) {
1509
1585
  const metric = node.metric;
1510
1586
  if (typeof metric === "string") push(at2("metric"), metric, "metric", "metric");
1511
1587
  else if (metric && typeof metric === "object")
1512
- for (const key2 of ["value", "label", "unit", "delta"]) {
1513
- const value = metric[key2];
1514
- if (typeof value === "string") push(at2("metric", key2), value, "metric", "metric");
1588
+ for (const key3 of ["value", "label", "unit", "delta"]) {
1589
+ const value = metric[key3];
1590
+ if (typeof value === "string") push(at2("metric", key3), value, "metric", "metric");
1515
1591
  }
1516
1592
  const timeline = node.timeline, events = Array.isArray(timeline) ? timeline : Array.isArray(rec(timeline).events) ? rec(timeline).events : [];
1517
1593
  if (typeof rec(timeline).name === "string") push(at2("timeline", "name"), rec(timeline).name, "timeline", "timeline");
@@ -1537,7 +1613,12 @@ function runsOf(tv) {
1537
1613
  valuePath: tv.path
1538
1614
  }));
1539
1615
  }
1540
- function altOf(value, assets) {
1616
+ function altOf(value, assets, variables, template) {
1617
+ if (typeof value === "string" && value.startsWith("var:")) {
1618
+ const variable = rec(rec(variables)[value.slice(4)]);
1619
+ const resolved = variable.type === "image" ? variable.value ?? (template === true ? variable.example : void 0) : void 0;
1620
+ return resolved === void 0 || typeof resolved === "string" && resolved.startsWith("var:") ? void 0 : altOf(resolved, assets);
1621
+ }
1541
1622
  const own4 = typeof value === "object" && value !== null ? value.alt : void 0;
1542
1623
  if (typeof own4 === "string") return own4;
1543
1624
  let source = typeof value === "string" ? value : rec(value).src;
@@ -1563,7 +1644,7 @@ function assetRefs(document, slide, slidePath, includeDeck) {
1563
1644
  }
1564
1645
  const designRefs = (design, base) => {
1565
1646
  for (const kind of ["header", "footer"])
1566
- for (const zone of ["left", "center", "right"]) {
1647
+ for (const zone of ["start", "center", "end"]) {
1567
1648
  const item = rec(rec(design[kind])[zone]);
1568
1649
  if (item.image !== void 0 && !isLogoReference(item.image)) out.push({ path: `${base}/${kind}/${zone}/image`, value: item.image, kind: "furniture" });
1569
1650
  }
@@ -1646,13 +1727,14 @@ var formatRules = [
1646
1727
  rule("reference-id-duplicate", "format", "error", "Two references share an id.", "A citation names a reference by id; a repeated id makes it ambiguous which entry is cited.", { standard: SCHEMA }),
1647
1728
  rule("cite-unknown-reference", "format", "error", "A citation names a reference that does not exist.", "A cited id with no entry in `references` has nothing to show in the footnote area.", { standard: SCHEMA }),
1648
1729
  rule("cite-unsupported-location", "format", "error", "A citation or footnote sits where no engine draws it.", "`cite` and `footnote` apply to runs in text, bullets and list items; table cells, captions, and reference and footnote texts have no marker.", { standard: SCHEMA }),
1649
- rule("caption-unsupported-payload", "format", "error", "A caption is on a payload that cannot carry one.", "A caption belongs to exactly one image, chart, table or video; a group, text or code block has no place to draw it.", { standard: SCHEMA }),
1730
+ rule("caption-unsupported-payload", "format", "error", "A caption is on a payload that cannot carry one.", "A caption belongs to exactly one image, chart, table, video or diagram; a group, text or code block has no place to draw it.", { standard: SCHEMA }),
1650
1731
  rule("image-option-unsupported-payload", "format", "error", "An image option is on a payload that is not an image.", "`fit`, `focus`, the image treatments (`shape`, `adjust`, `stroke`, `opacity`, `recolor`, `overlay`, `aspectRatio`), `placement` and `portrait` describe how a picture is drawn; a group, text or chart block has no picture for them to apply to. A shape block takes `shape`, `adjust`, `stroke`, `opacity` and `aspectRatio` too.", { standard: SCHEMA }),
1651
1732
  rule("shape-option-unsupported-payload", "format", "error", "A shape option is on a payload that is not a shape block.", "`fill`, `style`, `rotate`, `flip`, `anchor`, `padding`, `textDirection`, `alt`, `decorative`, `hidden`, `link` and the effects (`shadow`, `innerShadow`, `glow`, `softEdge`, `reflection`, `blur`) describe how a shape block is drawn; a text, chart or image block, or a group, has no shape for them to apply to.", { standard: SCHEMA }),
1652
1733
  rule("shape-adjust-unknown", "format", "warning", "An adjust value names a guide the preset does not have.", "Each preset has its own adjust handles (DrawingML's avLst guides: `adj`, `adj1`, `adj2`, ...); a name the preset does not have changes nothing, and a custom `path` has none. The preset's default is drawn.", { standard: "ECMA-376 Part 1, 20.1.10.56 (ST_ShapeType) and presetShapeDefinitions.xml" }),
1653
1734
  rule("shape-adjust-range", "format", "warning", "An adjust value is outside the range of the preset's handle.", "An adjust value outside the range its handle allows is pinned by the preset's own formulas, so the shape is not drawn as the value says; core draws the preset's default instead and both engines agree.", { standard: "ECMA-376 Part 1, 20.1.10.56 (ST_ShapeType) and presetShapeDefinitions.xml", approximations: "Ranges are checked at a square shape of the default size; a handle whose range depends on the shape's proportions is checked at those proportions when the shape is drawn." }),
1654
1735
  rule("shape-link-hidden", "format", "warning", "A hidden shape carries a link.", "A hidden shape (`hidden: true`) is not drawn, so its `link` can never be clicked in a slide show.", { standard: SCHEMA }),
1655
- rule("shape-anchor-missing", "format", "error", "An overlay shape is attached to a block that is not on the slide.", "An overlay shape placed with `at` sits against a composed block of its slide, named by the block's `id`. With no block of that id on the slide there is nowhere to put it, so it is not drawn.", { standard: SCHEMA }),
1736
+ 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 }),
1737
+ 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 }),
1656
1738
  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 }),
1657
1739
  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 }),
1658
1740
  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 }),
@@ -1660,6 +1742,8 @@ var formatRules = [
1660
1742
  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 }),
1661
1743
  rule("data-column-duplicate", "format", "error", "A dataset or table has two columns with the same name.", "Series, mappings and fields address columns by name, so a repeated name makes them ambiguous.", { standard: SCHEMA }),
1662
1744
  rule("chart-mapping-unknown-column", "format", "error", "A chart mapping names a column the data does not have.", "The series cannot be built from a column that is not there.", { standard: SCHEMA }),
1745
+ rule("chart-reference-axis-unavailable", "format", "error", "A reference names a value axis the chart does not have.", "Secondary references require an actual secondary line series on a combo chart.", { standard: SCHEMA }),
1746
+ rule("chart-reference-unsupported-type", "format", "error", "A chart has reference lines but its type has no single value axis to draw them on.", "An explicit reference line is never dropped silently, so a chart type that cannot draw it is an error. Column, bar, line, line-with-markers, area and combo charts draw references; the stacked, 100% stacked and every other type do not.", { standard: SCHEMA }),
1663
1747
  rule("number-format-invalid", "format", "error", "A number format cannot be read.", "A format code that no engine can parse is drawn as the plain number or fails to export.", { standard: "Excel number format codes, as far as OPF supports them" }),
1664
1748
  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 }),
1665
1749
  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 }),
@@ -1721,7 +1805,7 @@ var referenceRules = [
1721
1805
  "references",
1722
1806
  "error",
1723
1807
  "A layout template's regions are not valid.",
1724
- "Region names are unique across the whole record and may not be tag, auto or a promoted-region word (left, center, right, 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.",
1808
+ "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.",
1725
1809
  { standard: "spec/schemas/layout.schema.json and the region rules (docs/layout-templates.md)" }
1726
1810
  ),
1727
1811
  rule(
@@ -1778,6 +1862,7 @@ var dataRules = [
1778
1862
  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 }),
1779
1863
  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 }),
1780
1864
  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 }),
1865
+ 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." }),
1781
1866
  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 }),
1782
1867
  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" })
1783
1868
  ];
@@ -1798,13 +1883,13 @@ var onImageRule = rule(
1798
1883
  "text-on-image",
1799
1884
  "accessibility",
1800
1885
  "info",
1801
- "Text sits on a background picture: a note when core draws its automatic scrim behind it, otherwise its contrast cannot be guaranteed.",
1802
- "Contrast over a photograph depends on the photograph. Core draws an automatic scrim behind text on a picture background that has no overlay, at the lowest opacity that keeps it at 4.5:1 over any picture, and this note names it. With an edge-band overlay, or the scrim turned off (overlay: false), only a full-frame overlay that guarantees readability for every possible image certifies the result from the document.",
1886
+ "Text sits on a background picture: a note when core draws its automatic scrim behind it, a warning when the text is too faint over every color the picture can show, otherwise its contrast cannot be guaranteed.",
1887
+ "Contrast over a photograph depends on the photograph. Core draws an automatic scrim behind text on a picture background that has no overlay, at the lowest opacity that keeps it at 4.5:1 over any picture, and this note names it. With an edge-band overlay, or the scrim turned off (overlay: false), only a full-frame overlay that guarantees readability for every possible image certifies the result from the document. Text that stays below the threshold over every color the picture can show (a duotone in dark colors under dark text, for one) is a warning: it is low contrast whatever the picture.",
1803
1888
  {
1804
1889
  standard: "WCAG 2.2 SC 1.4.3 Contrast (Minimum), level AA",
1805
1890
  thresholds: ["contrastNormal", "contrastLarge"],
1806
1891
  cost: "composition",
1807
- approximations: "Core reads picture pixels only through a host that measures them (ComposeSlideOptions.pictureLuminance). Otherwise the picture is bounded by a gray ramp from black to white, composited through the image opacity and a full-frame design.background overlay or the automatic scrim over the text it covers; the text passes only when every step of that ramp passes. An edge-banded overlay is not counted."
1892
+ approximations: "Core reads picture pixels only through a host that measures them (ComposeSlideOptions.pictureLuminance). Otherwise the picture is bounded by a gray ramp from black to white, composited through the image opacity and a full-frame design.background overlay or the automatic scrim over the text it covers; the text passes only when every step of that ramp passes. A duotone recolor bounds the ramp to its own two colors, and an edge-banded overlay counts over the text it reaches, beside the uncovered picture where the text reaches past it."
1808
1893
  }
1809
1894
  );
1810
1895
  var altRule = rule(
@@ -1815,7 +1900,7 @@ var altRule = rule(
1815
1900
  'People using a screen reader get nothing for a picture without alternative text. A picture that is purely decorative should say so with an empty alt (alt: ""), which is an explicit, reviewed choice instead of an omission.',
1816
1901
  {
1817
1902
  standard: "WCAG 2.2 SC 1.1.1 Non-text Content, level A",
1818
- approximations: "Checks the alt field of images (image blocks, Slide.image and region images, placed or not), video, organization logos (each shape and background), header/footer images (a logo reference such as var:organization.logo.icon is checked on the organization), quote photos and speaker photos, following asset: references to the assets registry. Whether the text describes the picture well is not judged here (see opf/poor-alt-text). Charts carry `chart.alt` and are checked by opf/chart-text-alternative. Picture backgrounds are decorative unless they carry their own alt, and watermarks are decorative, so neither is checked."
1903
+ approximations: "Checks the alt field of images (image blocks, Slide.image and region images, placed or not), video, organization logos (each shape and background), header/footer images (a logo reference such as var:organization.logo.icon is checked on the organization), quote photos and speaker photos, following asset: references to the assets registry and image variables (var:<id>, RR-105) to their value (a template's unfilled variable to its example). Whether the text describes the picture well is not judged here (see opf/poor-alt-text). Charts carry `chart.alt` and are checked by opf/chart-text-alternative. Picture backgrounds are decorative unless they carry their own alt, and watermarks are decorative, so neither is checked."
1819
1904
  }
1820
1905
  );
1821
1906
  var poorAltRule = rule(
@@ -1851,7 +1936,7 @@ var readingOrderRule = rule(
1851
1936
  {
1852
1937
  standard: 'WCAG 2.2 SC 1.3.2 Meaningful Sequence, level A (PowerPoint: "Check reading order")',
1853
1938
  cost: "composition",
1854
- 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. 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."
1939
+ 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."
1855
1940
  }
1856
1941
  );
1857
1942
  var linkRule = rule(
@@ -1899,7 +1984,7 @@ var languageRule = rule(
1899
1984
  "info",
1900
1985
  "The presentation does not declare its language.",
1901
1986
  "Screen readers and text-to-speech choose pronunciation and hyphenation from the declared language; spell checkers and translation tools use it too.",
1902
- { 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.lang`; opf/language-tag checks how those tags are written)." }
1987
+ { 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)." }
1903
1988
  );
1904
1989
  var MAX_FURNITURE_LINES = 2;
1905
1990
  var overflowRule = rule(
@@ -1982,6 +2067,30 @@ var arrangementAdaptedRule = rule(
1982
2067
  "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.",
1983
2068
  { cost: "composition" }
1984
2069
  );
2070
+ var shapeOffSlideRule = rule(
2071
+ "shape-off-slide",
2072
+ "layout",
2073
+ "warning",
2074
+ "A shape or image callout lies wholly outside the slide.",
2075
+ "Overlay shapes and image callouts may straddle or leave the slide on purpose, so a position outside it is valid. One with no part on the slide draws nothing, which is nearly always a percent or a pixel written where a fraction belongs.",
2076
+ { cost: "composition" }
2077
+ );
2078
+ var chartLabelCollisionRule = rule(
2079
+ "chart-label-collision",
2080
+ "layout",
2081
+ "warning",
2082
+ "A reference label meets another label, a data line or a mark at both ends of its line.",
2083
+ "A reference label is tried above and below its line (beside it on a bar chart), at its own end and then at the other end of the line. When all four places meet another reference label, a data line, a bar or an area, it is drawn at the first and reported; its text and value are kept, and on a bar or an area it stands on a plate of the chart background.",
2084
+ { cost: "composition" }
2085
+ );
2086
+ var timelinePeriodShortRule = rule(
2087
+ "timeline-period-short",
2088
+ "layout",
2089
+ "warning",
2090
+ "A timeline period is too short to read.",
2091
+ 'A timeline period keeps the proportion its `duration` gives it, whatever the size. A period shorter than its marker is drawn as it is and reported; it is not text overflow, so a strict composition (`overflow: "error"`) does not refuse the slide.',
2092
+ { cost: "composition" }
2093
+ );
1985
2094
  var unplacedRule = rule(
1986
2095
  "layout-unplaced",
1987
2096
  "layout",
@@ -2057,11 +2166,11 @@ var languageTagRule = rule(
2057
2166
  "language-tag",
2058
2167
  "content",
2059
2168
  "warning",
2060
- "A language tag is malformed, uses an unassigned region or is not in canonical case.",
2061
- "Engines read the deck language and each run's `lang` as BCP 47 tags to choose script fonts, text direction, proofing language and the PowerPoint `lang` attribute. A tag such as `en-a`, or a region that does not exist (`en-UK`; the United Kingdom is `GB`), is guessed at or dropped, and a wrong-case tag (`EN-us`) is not what a locale lookup expects.",
2169
+ "A language tag is malformed, uses an unassigned region, is not in canonical case or names a numbering system OPF does not draw.",
2170
+ "Engines read the deck and slide language and each run's `language` as BCP 47 tags to choose script fonts, text direction, proofing language and the PowerPoint `lang` attribute. A tag such as `en-a`, or a region that does not exist (`en-UK`; the United Kingdom is `GB`), is guessed at or dropped, and a wrong-case tag (`EN-us`) is not what a locale lookup expects.",
2062
2171
  {
2063
2172
  standard: "BCP 47 (RFC 5646, section 2.1) and the platform locale data (Intl.getCanonicalLocales, Intl.DisplayNames)",
2064
- approximations: "Checks the root `language` (a tag string, or the `bcp47` of an inline Language object) and `lang` on the TextRun objects of titles, subtitles, tags, text, lists, tables, quotes, metrics and timelines. A region is assigned when the runtime's CLDR data names it (ISO 3166-1 codes and UN M.49 areas such as 419); private-use regions (`AA`, `QM`-`QZ`, `XA`-`XZ`) and `ZZ` are accepted, as are private-use (`x-...`) tags. Only the spelling of a tag is checked, not whether the language subtag is assigned or whether the language suits the text. The schema rejects tags with characters other than letters, digits and hyphens (`en_US` is a schema error, with no suggestion), and `en-UK` as the deck language is already an error of the schema rule, so those are not reported twice."
2173
+ approximations: "Checks the root and slide `language` (a tag string, or the `bcp47` of an inline Language object) and `language` on the TextRun objects of titles, subtitles, tags, text, lists, tables, quotes, metrics and timelines. A region is assigned when the runtime's CLDR data names it (ISO 3166-1 codes and UN M.49 areas such as 419); private-use regions (`AA`, `QM`-`QZ`, `XA`-`XZ`) and `ZZ` are accepted, as are private-use (`x-...`) tags. Only the spelling of a tag is checked, not whether the language subtag is assigned or whether the language suits the text. The schema rejects tags with characters other than letters, digits and hyphens (`en_US` is a schema error, with no suggestion), and `en-UK` as the deck language is already an error of the schema rule, so those are not reported twice."
2065
2174
  }
2066
2175
  );
2067
2176
  var SHRUNK_RATIO = 0.7;
@@ -2175,6 +2284,9 @@ var implementedRules = [
2175
2284
  unplacedRule,
2176
2285
  iconDroppedRule,
2177
2286
  arrangementAdaptedRule,
2287
+ chartLabelCollisionRule,
2288
+ timelinePeriodShortRule,
2289
+ shapeOffSlideRule,
2178
2290
  furnitureWrapsRule,
2179
2291
  outsideRule,
2180
2292
  resolutionRule,
@@ -2221,13 +2333,17 @@ var isLarge = (sizePx, bold) => {
2221
2333
  return pt >= 18 || bold && pt >= 14;
2222
2334
  };
2223
2335
  var within = (box, area) => box.x >= area.x - 0.5 && box.y >= area.y - 0.5 && box.x + box.width <= area.x + area.width + 0.5 && box.y + box.height <= area.y + area.height + 0.5;
2336
+ var overlaps = (box, area) => box.x < area.x + area.width && area.x < box.x + box.width && box.y < area.y + area.height && area.y < box.y + box.height;
2224
2337
  function slideBackdrop(context, box) {
2225
2338
  const { design, composition } = context;
2226
2339
  const image = composition?.backgroundImage;
2227
2340
  if (image) {
2228
2341
  const scrim = box ? image.scrims?.find((entry2) => within(box, entry2.text)) : void 0;
2229
2342
  const overlay = image.overlay && !image.overlay.edge ? { color: resolveTextColor(image.overlay.color, design, "#000000") ?? "#000000", opacity: image.overlay.opacity } : scrim ? { color: scrim.color, opacity: scrim.opacity } : void 0;
2230
- return backdropColors({ kind: "image", opacity: image.opacity ?? 1, base: "#FFFFFF" }, box, design.dimensions, { overlay, ...scrim?.grays ? { grays: scrim.grays } : {} });
2343
+ const duotone = image.recolor?.type === "duotone" ? [resolveTextColor(image.recolor.dark, design, "#000000") ?? "#000000", resolveTextColor(image.recolor.light, design, "#FFFFFF") ?? "#FFFFFF"] : void 0;
2344
+ const edge = image.overlay?.edge ? image.overlay : void 0, reach = box ?? { x: 0, y: 0, ...design.dimensions };
2345
+ const band = edge && overlaps(reach, edge.box) ? { color: resolveTextColor(edge.color, design, "#000000") ?? "#000000", opacity: edge.opacity, whole: within(reach, edge.box) } : void 0;
2346
+ return backdropColors({ kind: "image", opacity: image.opacity ?? 1, base: "#FFFFFF" }, box, design.dimensions, { overlay, ...scrim?.grays ? { grays: scrim.grays } : {}, ...duotone ? { duotone } : {}, ...band ? { band } : {} });
2231
2347
  }
2232
2348
  return backdropColors(design.backdrop, box, design.dimensions);
2233
2349
  }
@@ -2323,6 +2439,18 @@ var contrastRules = [
2323
2439
  const worst = worstContrast(sample.color, sample.backdrop);
2324
2440
  if (worst.ratio >= needed) continue;
2325
2441
  if (sample.backdrop.unknown) {
2442
+ const best = Math.max(...sample.backdrop.colors.map((color) => contrastRatio(sample.color, color)));
2443
+ if (best < needed) {
2444
+ context.report(onImageRule, {
2445
+ path: sample.path,
2446
+ slide,
2447
+ severity: "warning",
2448
+ 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.`,
2449
+ 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.",
2450
+ measured: { ratio: round(worst.ratio), best: round(best), needed, textColor: sample.color }
2451
+ });
2452
+ continue;
2453
+ }
2326
2454
  if (!imageReported.done) {
2327
2455
  imageReported.done = true;
2328
2456
  context.report(onImageRule, {
@@ -2335,8 +2463,8 @@ var contrastRules = [
2335
2463
  }
2336
2464
  continue;
2337
2465
  }
2338
- const key2 = `${sample.source === "default" ? "default" : sample.path}|${sample.color}|${worst.against}|${large}`;
2339
- const known = aggregated.get(key2);
2466
+ const key3 = `${sample.source === "default" ? "default" : sample.path}|${sample.color}|${worst.against}|${large}`;
2467
+ const known = aggregated.get(key3);
2340
2468
  if (known && sample.source === "default") {
2341
2469
  known.extra++;
2342
2470
  continue;
@@ -2357,7 +2485,7 @@ var contrastRules = [
2357
2485
  measured: { ratio: round(worst.ratio), needed, large, sizePt: round(sample.sizePx * PX_TO_PT), textColor: sample.color, backgroundColor: worst.against },
2358
2486
  fixes
2359
2487
  });
2360
- if (sample.source === "default") aggregated.set(key2, { diagnostic, extra: 0 });
2488
+ if (sample.source === "default") aggregated.set(key3, { diagnostic, extra: 0 });
2361
2489
  }
2362
2490
  const scrim = slide.composition?.backgroundImage?.scrims?.[0];
2363
2491
  if (scrim && !imageReported.done) {
@@ -2397,7 +2525,7 @@ var altRules = [
2397
2525
  for (const ref of assetRefs(context.document, slide.slide, slide.path, index === 0)) {
2398
2526
  if (seen.has(ref.path)) continue;
2399
2527
  seen.add(ref.path);
2400
- let alt = altOf(ref.value, context.document.assets);
2528
+ let alt = altOf(ref.value, context.document.assets, context.document.variables, context.document.template === true);
2401
2529
  if (ref.kind === "video" && !alt) alt = typeof rec(ref.value).title === "string" ? rec(ref.value).title : void 0;
2402
2530
  if (alt !== void 0 && alt.trim() !== "") continue;
2403
2531
  if (alt === "") continue;
@@ -2422,7 +2550,7 @@ var altRules = [
2422
2550
  for (const ref of assetRefs(context.document, slide.slide, slide.path, index === 0)) {
2423
2551
  if (seen.has(ref.path)) continue;
2424
2552
  seen.add(ref.path);
2425
- const alt = altOf(ref.value, context.document.assets)?.trim();
2553
+ const alt = altOf(ref.value, context.document.assets, context.document.variables, context.document.template === true)?.trim();
2426
2554
  if (!alt) continue;
2427
2555
  const source = sourceOfAsset(ref.value);
2428
2556
  const problem = GENERIC_ALT.test(alt) ? "is a generic word" : FILE_ALT.test(alt) ? "looks like a file name" : /^(https?:\/\/|data:|www\.)/i.test(alt) || source && alt === source ? "is a URL" : /^(image|picture|photo|graphic) of\b/i.test(alt) ? 'starts with "image of", which a screen reader already announces' : alt.length > 250 ? `is ${alt.length} characters long; aim for a sentence or two` : void 0;
@@ -2543,7 +2671,27 @@ function bindingOrder(items, regions) {
2543
2671
  };
2544
2672
  return items.map((item, index) => ({ item, index, region: rank.get(item.region ?? "") ?? regions.length, block: blockRank(item) })).sort((a, b) => a.region - b.region || a.block - b.block || a.index - b.index).map((entry2) => entry2.item.path);
2545
2673
  }
2546
- function visualOrder(items, rtl) {
2674
+ function visualOrder(items, rtl, base = items[0]?.path.match(/^slides\.\d+/)?.[0] ?? "") {
2675
+ const units = /* @__PURE__ */ new Map();
2676
+ for (const item of items) {
2677
+ const rest = item.path.startsWith(`${base}.`) ? item.path.slice(base.length + 1) : "";
2678
+ const key3 = /^blocks\.\d+/.exec(rest)?.[0] ?? rest.split(".")[0] ?? "";
2679
+ (units.get(key3) ?? units.set(key3, []).get(key3)).push(item);
2680
+ }
2681
+ if (units.has("")) return flatOrder(items, rtl);
2682
+ if (units.size === 1) return visualOrder(items, rtl, `${base}.${[...units.keys()][0]}`);
2683
+ const placed = [...units].map(([key3, members]) => {
2684
+ const left = Math.min(...members.map((item) => item.box.x)), top = Math.min(...members.map((item) => item.box.y));
2685
+ const right = Math.max(...members.map((item) => item.box.x + item.box.width)), bottom = Math.max(...members.map((item) => item.box.y + item.box.height));
2686
+ return { path: key3, members, box: { x: left, y: top, width: right - left, height: bottom - top } };
2687
+ });
2688
+ const order2 = flatOrder(placed, rtl);
2689
+ return order2.flatMap((key3) => {
2690
+ const unit = placed.find((entry2) => entry2.path === key3);
2691
+ return unit.members.length > 1 ? visualOrder(unit.members, rtl, `${base}.${key3}`) : unit.members.map((item) => item.path);
2692
+ });
2693
+ }
2694
+ function flatOrder(items, rtl) {
2547
2695
  if (rtl) return readingRows(items).flatMap((row) => row.map((item) => item.path));
2548
2696
  return visualReadingOrder(items).map((item) => item.path);
2549
2697
  }
@@ -2783,6 +2931,15 @@ function languageTagProblem(tag) {
2783
2931
  };
2784
2932
  }
2785
2933
  }
2934
+ const system = numberingSystemExtension(tag);
2935
+ if (system !== void 0 && !isSupportedNumberingSystem(system)) {
2936
+ const only = /-u-nu-[a-z0-9]+$/i.test(tag) && tag.toLowerCase().split("-u-").length === 2;
2937
+ return {
2938
+ message: `'${tag}' names the numbering system '${system}', which OPF does not draw; generated numbers use the language's own digits, or Latin ones. OPF draws only the systems PowerPoint also draws in a native chart: ${supportedNumberingSystems().map((name) => `'${name}'`).join(", ")}.`,
2939
+ ...only ? { suggestion: plainLanguageTag(tag) } : {},
2940
+ caseOnly: false
2941
+ };
2942
+ }
2786
2943
  if (parsed === tag) return void 0;
2787
2944
  if (parsed.toLowerCase() === tag.toLowerCase())
2788
2945
  return { message: `'${tag}' is not in canonical case; the canonical form is '${parsed}' (language lower case, script title case, region upper case).`, suggestion: parsed, caseOnly: true };
@@ -2796,30 +2953,35 @@ function languageTagProblem(tag) {
2796
2953
  }
2797
2954
 
2798
2955
  // src/rules-language.ts
2799
- var report = (context, tag, path, slide) => {
2800
- if (typeof tag !== "string") return;
2956
+ var isEnUk = (tag) => typeof tag === "string" && tag.toLowerCase() === "en-uk";
2957
+ var report = (context, tag, path, slide, owned = false) => {
2958
+ if (typeof tag !== "string" || owned && isEnUk(tag)) return;
2801
2959
  const problem = languageTagProblem(tag);
2802
2960
  if (!problem) return;
2803
2961
  context.report(languageTagRule, {
2804
2962
  path,
2805
2963
  slide,
2806
2964
  message: problem.message,
2965
+ ...isEnUk(tag) ? { severity: "error" } : {},
2807
2966
  help: problem.suggestion ? `Write '${problem.suggestion}'.` : 'Write a well-formed BCP 47 tag with an assigned region, such as "en-US", "pt-BR" or "es-419".',
2808
2967
  ...problem.suggestion ? { fixes: [{ id: "use-canonical-tag", title: `Use '${problem.suggestion}'`, kind: "patch", safe: problem.caseOnly, patch: [{ op: "replace", path, value: problem.suggestion }] }] } : {}
2809
2968
  });
2810
2969
  };
2811
- var isEnUk = (tag) => typeof tag === "string" && tag.toLowerCase() === "en-uk";
2812
2970
  var languageTagRules = [
2813
2971
  {
2814
2972
  info: languageTagRule,
2815
2973
  run(context) {
2816
2974
  const language = context.document.language;
2817
- if (typeof language === "string") {
2818
- if (!isEnUk(language)) report(context, language, "/language");
2819
- } else if (language !== void 0 && !isEnUk(rec(language).bcp47)) report(context, rec(language).bcp47, "/language/bcp47");
2975
+ if (typeof language === "string") report(context, language, "/language", void 0, true);
2976
+ else if (language !== void 0) report(context, rec(language).bcp47, "/language/bcp47", void 0, true);
2977
+ for (const slide of context.slides) {
2978
+ const language2 = slide.slide.language;
2979
+ if (typeof language2 === "string") report(context, language2, `${slide.path}/language`, slide, true);
2980
+ else if (language2 !== void 0) report(context, rec(language2).bcp47, `${slide.path}/language/bcp47`, slide, true);
2981
+ }
2820
2982
  for (const slide of context.slides)
2821
2983
  for (const tv of slide.texts)
2822
- if (typeof tv.value !== "string") for (const run of runsOf(tv)) report(context, run.style.lang, `${run.path}/lang`, slide);
2984
+ if (typeof tv.value !== "string") for (const run of runsOf(tv)) report(context, run.style.language, `${run.path}/language`, slide);
2823
2985
  }
2824
2986
  }
2825
2987
  ];
@@ -2827,11 +2989,14 @@ var languageTagRules = [
2827
2989
  // src/rules-layout-content.ts
2828
2990
  var PX_TO_PT2 = 0.75;
2829
2991
  var round2 = (value, places = 1) => Math.round(value * 10 ** places) / 10 ** places;
2992
+ var pointAnchorRule = ruleInfo("opf/shape-anchor-missing");
2830
2993
  var REGION_RULES = { "region-unknown": regionUnknownRule, "region-kind": regionKindRule, "region-full": regionFullRule, "layout-unplaced": unplacedRule };
2831
2994
  var layoutRules = [
2832
2995
  {
2833
2996
  info: overflowRule,
2834
- also: [unresolvedRule, layoutFailedRule, minFontRule, regionUnknownRule, regionKindRule, regionFullRule, unplacedRule, iconDroppedRule, arrangementAdaptedRule],
2997
+ // Format validates anchor identities in schema-check without composition. Geometry may add
2998
+ // the same located finding during an enabled layout audit, but must not trigger one.
2999
+ also: [unresolvedRule, layoutFailedRule, minFontRule, regionUnknownRule, regionKindRule, regionFullRule, unplacedRule, iconDroppedRule, arrangementAdaptedRule, chartLabelCollisionRule, timelinePeriodShortRule, shapeOffSlideRule],
2835
3000
  run(context) {
2836
3001
  const deckLevel = /* @__PURE__ */ new Set();
2837
3002
  for (const slide of context.slides) {
@@ -2840,19 +3005,28 @@ var layoutRules = [
2840
3005
  for (const { diagnostic } of slide.layoutDiagnostics) {
2841
3006
  const path = pointerOfDotted(diagnostic.path);
2842
3007
  if (!path.startsWith("/slides/")) {
2843
- const key2 = `${diagnostic.code}|${path}|${diagnostic.message}`;
2844
- if (deckLevel.has(key2)) continue;
2845
- deckLevel.add(key2);
3008
+ const key3 = `${diagnostic.code}|${path}|${diagnostic.message}`;
3009
+ if (deckLevel.has(key3)) continue;
3010
+ deckLevel.add(key3);
2846
3011
  }
2847
3012
  if (diagnostic.code === "text-overflow")
2848
3013
  context.report(overflowRule, { path, slide, message: diagnostic.message, help: "Shorten the text, give it more space (fewer blocks, a different composition) or split the slide (paginate); raising the readable minimum makes it worse." });
3014
+ else if (diagnostic.code === "shape-anchor-missing") context.report(pointAnchorRule, { path, slide, message: diagnostic.message, help: "Choose a plotted point in a qualified classic chart, or use a whole-block anchor." });
2849
3015
  else if (diagnostic.code === "small-cell") continue;
2850
3016
  else if (diagnostic.code === "icon-dropped")
2851
3017
  context.report(iconDroppedRule, { path, slide, message: diagnostic.message, help: "Shorten the text or give the slide more room so the chips fit at the same text size, or remove the icon. An icon draws on the first-level entries of an unnumbered list, on a metric and on a group." });
2852
3018
  else if (diagnostic.code === "arrangement-adapted")
2853
3019
  context.report(arrangementAdaptedRule, { path, slide, message: diagnostic.message, help: /four entries/.test(diagnostic.message) ? "Write four entries for the quadrants, or choose another layout for this many." : "Shorten the entries, write one level without descriptions, or choose another layout." });
3020
+ else if (diagnostic.code === "shape-off-slide")
3021
+ context.report(shapeOffSlideRule, { path, slide, message: diagnostic.message, help: "Write the position as fractions (0.2 for 20%), move the shape so part of it is on the slide, or remove it. A shape may hang over an edge; only one with nothing on the slide is reported." });
3022
+ else if (diagnostic.code === "chart-label-collision")
3023
+ 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." });
3024
+ else if (diagnostic.code === "timeline-period-short")
3025
+ context.report(timelinePeriodShortRule, { path, slide, message: diagnostic.message, help: "Give the timeline more room, or make its shortest period longer relative to the others." });
2854
3026
  else if (Object.hasOwn(REGION_RULES, diagnostic.code))
2855
3027
  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." });
3028
+ else if (diagnostic.message.startsWith("The diagram cannot be drawn"))
3029
+ 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." });
2856
3030
  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." });
2857
3031
  }
2858
3032
  for (const tv of slide.texts)
@@ -3003,7 +3177,7 @@ var contentRules = [
3003
3177
  run(context) {
3004
3178
  for (const slide of context.slides)
3005
3179
  for (const tv of slide.texts) {
3006
- if (["table", "table-header", "list-description"].includes(tv.role)) continue;
3180
+ if (["table", "table-header", "list-description", "callout"].includes(tv.role)) continue;
3007
3181
  if (plainText(tv.value).trim() !== "") continue;
3008
3182
  context.report(emptyTextRule, {
3009
3183
  path: tv.path,
@@ -3064,7 +3238,7 @@ function setsRunSize(value, depth2 = 0) {
3064
3238
  if (Array.isArray(value)) return value.some((entry2) => setsRunSize(entry2, depth2 + 1));
3065
3239
  const object2 = value;
3066
3240
  if (typeof object2.fontSize === "number") return true;
3067
- return ["text", "description", "rows", "columns", "value"].some((key2) => setsRunSize(object2[key2], depth2 + 1));
3241
+ return ["text", "description", "rows", "columns", "value"].some((key3) => setsRunSize(object2[key3], depth2 + 1));
3068
3242
  }
3069
3243
  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 };
3070
3244
  function fittedSize(item, slide, document) {
@@ -3154,7 +3328,7 @@ var centeredBody = {
3154
3328
  path: pointerOfDotted(item.path),
3155
3329
  slide,
3156
3330
  message: `A centered ${item.field === "text" ? "paragraph" : "list"} of ${lines} line${lines === 1 ? "" : "s"} (${characters} characters); every line starts at a different place, which is harder to read.${others}`,
3157
- help: 'Align body text to the start (contentAlignment "left" on the slide or block design), or shorten it to a statement of one or two lines.',
3331
+ help: 'Align body text to the start (contentAlignment "start" on the slide or block design), or shorten it to a statement of one or two lines.',
3158
3332
  measured: { lines, characters, maximumLines: CENTERED_BODY_LINES, maximumCharacters: CENTERED_BODY_CHARACTERS, blocks: count }
3159
3333
  });
3160
3334
  }
@@ -3372,7 +3546,7 @@ var isRecord2 = (value) => value !== null && typeof value === "object" && !Array
3372
3546
  var isCell = (value) => value === null || ["string", "number", "boolean"].includes(typeof value);
3373
3547
  function foreignChartKeys(chart) {
3374
3548
  if (!isRecord2(chart) || Object.hasOwn(chart, "data")) return [];
3375
- return FOREIGN_CHART_KEYS.filter((key2) => Object.hasOwn(chart, key2));
3549
+ return FOREIGN_CHART_KEYS.filter((key3) => Object.hasOwn(chart, key3));
3376
3550
  }
3377
3551
  function convertChartData(chart) {
3378
3552
  const labels = chart.categories ?? chart.labels;
@@ -3396,7 +3570,7 @@ function chartShapePatch(chart, path) {
3396
3570
  const data = convertChartData(chart);
3397
3571
  const keys = foreignChartKeys(chart);
3398
3572
  if (!data || !keys.length) return void 0;
3399
- return [{ op: "add", path: `${path}/data`, value: data }, ...keys.map((key2) => ({ op: "remove", path: `${path}/${key2}` }))];
3573
+ return [{ op: "add", path: `${path}/data`, value: data }, ...keys.map((key3) => ({ op: "remove", path: `${path}/${key3}` }))];
3400
3574
  }
3401
3575
  var SHOWN_ROWS = 3;
3402
3576
  var json = (value) => JSON.stringify(value);
@@ -3409,7 +3583,7 @@ function dataExample(chart) {
3409
3583
  function chartShapeHelp(chart) {
3410
3584
  const keys = foreignChartKeys(chart);
3411
3585
  if (!keys.length || !isRecord2(chart)) return void 0;
3412
- const names2 = keys.map((key2) => `"${key2}"`).join(" and ");
3586
+ const names2 = keys.map((key3) => `"${key3}"`).join(" and ");
3413
3587
  const example = dataExample(chart);
3414
3588
  const next = `replace ${names2} with ${example}. The first column holds the category labels and each further column is one series.`;
3415
3589
  return {
@@ -3420,7 +3594,7 @@ function chartShapeHelp(chart) {
3420
3594
  }
3421
3595
 
3422
3596
  // src/check-document.ts
3423
- var own = (value, key2) => Object.hasOwn(value, key2);
3597
+ var own = (value, key3) => Object.hasOwn(value, key3);
3424
3598
  var object = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
3425
3599
  var primitive = (value) => value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value);
3426
3600
  var pointer3 = (parts2) => parts2.length ? "/" + parts2.map((part) => String(part).replaceAll("~", "~0").replaceAll("/", "~1")).join("/") : "";
@@ -3432,7 +3606,7 @@ function parts(path) {
3432
3606
  }
3433
3607
  function at(value, path) {
3434
3608
  return parts(path).reduce(
3435
- (current, key2) => object(current) || Array.isArray(current) ? own(current, key2) ? current[key2] : void 0 : void 0,
3609
+ (current, key3) => object(current) || Array.isArray(current) ? own(current, key3) ? current[key3] : void 0 : void 0,
3436
3610
  value
3437
3611
  );
3438
3612
  }
@@ -3442,13 +3616,13 @@ function checkDocumentOptions(options2) {
3442
3616
  throw new TypeError("Validate contracts must be an array.");
3443
3617
  for (const contract2 of options2.contracts ?? []) {
3444
3618
  if (!object(contract2) || Object.keys(contract2).some(
3445
- (key2) => ![
3619
+ (key3) => ![
3446
3620
  "path",
3447
3621
  "allowedValues",
3448
3622
  "severity",
3449
3623
  "message",
3450
3624
  "documentation"
3451
- ].includes(key2)
3625
+ ].includes(key3)
3452
3626
  ) || typeof contract2.path !== "string" || !Array.isArray(contract2.allowedValues) || !contract2.allowedValues.every(primitive) || contract2.severity !== void 0 && (typeof contract2.severity !== "string" || !["error", "warning", "info"].includes(contract2.severity)) || contract2.message !== void 0 && typeof contract2.message !== "string" || contract2.documentation !== void 0 && typeof contract2.documentation !== "string")
3453
3627
  throw new TypeError(
3454
3628
  "Invalid contract: provide a path and primitive allowedValues, with optional severity, message and documentation."
@@ -3478,12 +3652,19 @@ function issueFinding(issue2, ruleId = issueRuleId(issue2), schemaName = "presen
3478
3652
  help = `Add the required ${JSON.stringify(issue2.params.missingProperty)} field in this object, using the intended schema form.`;
3479
3653
  else if (issue2.keyword === "additionalProperties")
3480
3654
  help = `Review ${JSON.stringify(issue2.params.additionalProperty)} against this object's schema. Preserve custom metadata in document.extensions where appropriate; do not delete authored content to clear this error.`;
3481
- else if (issue2.keyword === "enum")
3482
- help = "Choose one of this schema branch\u2019s allowed values; inspect the other alternatives if the field uses another form.";
3483
- else if (issue2.keyword === "opf")
3484
- help = "Resolve the reported structural conflict while preserving every content field. Preview the result after editing.";
3655
+ else if (issue2.keyword === "enum") {
3656
+ const values = Array.isArray(issue2.params.allowedValues) ? issue2.params.allowedValues.filter(primitive) : [];
3657
+ help = values.length > 0 && values.length <= 12 ? `Use one of: ${values.map((value) => JSON.stringify(value)).join(", ")}.` : "Choose one of this schema branch\u2019s allowed values; inspect the other alternatives if the field uses another form.";
3658
+ } else if (issue2.keyword === "dependentRequired")
3659
+ help = `${JSON.stringify(issue2.params.property)} only applies together with ${JSON.stringify(issue2.params.missingProperty)}: add ${JSON.stringify(issue2.params.missingProperty)}, or remove ${JSON.stringify(issue2.params.property)}.`;
3660
+ else if (issue2.keyword === "opf") help = semanticHelp(issue2);
3485
3661
  const allowed = Array.isArray(issue2.params.allowedValues) ? issue2.params.allowedValues.filter(primitive) : [];
3486
3662
  const nearest2 = issue2.keyword === "additionalProperties" ? nearestProperties(issue2, entry2.schema, precise?.pointer, precise?.schemaName) : [];
3663
+ const typedName = issue2.keyword === "additionalProperties" && typeof issue2.params.additionalProperty === "string" ? issue2.params.additionalProperty : void 0;
3664
+ if (typedName !== void 0 && nearest2[0]?.value === logicalName(typedName) && nearest2[0].value !== typedName)
3665
+ help = `Write ${JSON.stringify(nearest2[0].value)}: layout words follow the deck's direction, so the sides are "start" and "end", not "left" and "right".`;
3666
+ else if (typedName !== void 0 && typeof nearest2[0]?.value === "string" && nearest2[0].value.startsWith(typedName))
3667
+ help = `Write ${JSON.stringify(nearest2[0].value)} instead; ${JSON.stringify(typedName)} is not a field of this object.`;
3487
3668
  return finding(ruleId, {
3488
3669
  ...severity ? { severity } : {},
3489
3670
  path,
@@ -3504,6 +3685,7 @@ function issueFinding(issue2, ruleId = issueRuleId(issue2), schemaName = "presen
3504
3685
  });
3505
3686
  }
3506
3687
  var NEAREST_PROPERTIES = 3;
3688
+ var logicalName = (name) => name.split(":").map((part) => part.split("+").map((word) => word === "left" ? "start" : word === "right" ? "end" : word).join("+")).join(":");
3507
3689
  function nearestProperties(issue2, fallbackRoot, pointerToKeyword, schemaName) {
3508
3690
  const typed = issue2.params.additionalProperty;
3509
3691
  if (typeof typed !== "string" || pointerToKeyword === void 0) return [];
@@ -3511,12 +3693,15 @@ function nearestProperties(issue2, fallbackRoot, pointerToKeyword, schemaName) {
3511
3693
  let node = rootEntry?.schema ?? fallbackRoot;
3512
3694
  const base = pointerToKeyword.split("/").slice(0, -1);
3513
3695
  for (const token of base.slice(1)) {
3514
- if (!isRecord(node)) return [];
3515
- node = node[token.replaceAll("~1", "/").replaceAll("~0", "~")];
3696
+ if (Array.isArray(node)) node = /^\d+$/.test(token) ? node[Number(token)] : void 0;
3697
+ else if (isRecord(node)) node = node[token.replaceAll("~1", "/").replaceAll("~0", "~")];
3698
+ else return [];
3516
3699
  }
3517
3700
  if (!isRecord(node) || !isRecord(node.properties)) return [];
3518
3701
  const root = rootEntry?.schema ?? fallbackRoot, limit = typed.length <= 3 ? 1 : 2, lower = typed.toLowerCase();
3519
- return Object.keys(node.properties).map((name) => ({ name, away: distance(lower, name.toLowerCase()) })).filter(({ name, away }) => name !== typed && away <= limit).sort((a, b) => a.away - b.away || (a.name < b.name ? -1 : a.name > b.name ? 1 : 0)).slice(0, NEAREST_PROPERTIES).map(({ name }) => ({
3702
+ const declared = Object.keys(node.properties), logical = logicalName(typed), longer = typed.length >= 3 ? declared.filter((name) => name !== typed && name.toLowerCase().startsWith(lower)) : [], exact = logical !== typed && declared.includes(logical) ? [logical] : longer.length === 1 ? longer : [];
3703
+ const near = declared.map((name) => ({ name, away: distance(lower, name.toLowerCase()) })).filter(({ name, away }) => name !== typed && away <= limit && !exact.includes(name)).sort((a, b) => a.away - b.away || (a.name < b.name ? -1 : a.name > b.name ? 1 : 0)).map(({ name }) => name);
3704
+ return [...exact, ...near].slice(0, NEAREST_PROPERTIES).map((name) => ({
3520
3705
  value: name,
3521
3706
  label: name,
3522
3707
  origin: "schema",
@@ -3547,13 +3732,13 @@ function score(schema, value) {
3547
3732
  if (own(schema, "const")) return schema.const === value ? 100 : -1e4;
3548
3733
  let result = 1;
3549
3734
  if (object(value) && object(schema.properties)) {
3550
- for (const [key2, child] of Object.entries(schema.properties))
3551
- if (own(value, key2) && object(child))
3552
- result += own(child, "const") ? child.const === value[key2] ? 100 : -1e3 : 1;
3735
+ for (const [key3, child] of Object.entries(schema.properties))
3736
+ if (own(value, key3) && object(child))
3737
+ result += own(child, "const") ? child.const === value[key3] ? 100 : -1e3 : 1;
3553
3738
  }
3554
3739
  if (Array.isArray(schema.required)) {
3555
- for (const key2 of schema.required)
3556
- if (typeof key2 === "string" && (!object(value) || !own(value, key2)))
3740
+ for (const key3 of schema.required)
3741
+ if (typeof key3 === "string" && (!object(value) || !own(value, key3)))
3557
3742
  result -= 2;
3558
3743
  }
3559
3744
  return result;
@@ -3575,7 +3760,7 @@ function active(cursor, value) {
3575
3760
  const selected = candidates.sort((a, b) => score(b.schema, value) - score(a.schema, value))[0];
3576
3761
  return selected ? { ...selected, baseSchemas: [...selected.baseSchemas ?? [], resolved] } : resolved;
3577
3762
  }
3578
- function childCursor(cursors, key2) {
3763
+ function childCursor(cursors, key3) {
3579
3764
  for (const keyword of [
3580
3765
  "properties",
3581
3766
  "patternProperties",
@@ -3584,8 +3769,8 @@ function childCursor(cursors, key2) {
3584
3769
  for (const cursor of cursors) {
3585
3770
  const declarations = cursor.schema[keyword];
3586
3771
  if (!object(declarations)) continue;
3587
- const name = keyword === "properties" ? key2 : keyword === "patternProperties" ? Object.keys(declarations).find(
3588
- (pattern) => new RegExp(pattern).test(key2)
3772
+ const name = keyword === "properties" ? key3 : keyword === "patternProperties" ? Object.keys(declarations).find(
3773
+ (pattern) => new RegExp(pattern).test(key3)
3589
3774
  ) : void 0;
3590
3775
  const schema = keyword === "additionalProperties" ? declarations : name === void 0 ? void 0 : declarations[name];
3591
3776
  if (object(schema))
@@ -3644,13 +3829,13 @@ function fields(document) {
3644
3829
  });
3645
3830
  });
3646
3831
  else if (object(entry2.value))
3647
- for (const [key2, value] of Object.entries(entry2.value)) {
3648
- if (entry2.path.length === 0 && key2 === "catalogs") continue;
3649
- const cursor = childCursor(cursors, key2);
3832
+ for (const [key3, value] of Object.entries(entry2.value)) {
3833
+ if (entry2.path.length === 0 && key3 === "catalogs") continue;
3834
+ const cursor = childCursor(cursors, key3);
3650
3835
  if (!cursor) continue;
3651
3836
  stack.push({
3652
3837
  value,
3653
- path: [...entry2.path, key2],
3838
+ path: [...entry2.path, key3],
3654
3839
  cursor,
3655
3840
  ancestors
3656
3841
  });
@@ -3732,7 +3917,7 @@ function chartNumberFixPaths(document) {
3732
3917
  }
3733
3918
  var HELP = {
3734
3919
  "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.',
3735
- "chart-mapping-adapted": "The mapping entry is ignored. Remove it, or name a different column.",
3920
+ "chart-mapping-adapted": "Choose a compatible chart type or mapping for the selected data. The message explains how the mapping or drawing was adapted.",
3736
3921
  "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.",
3737
3922
  "chart-highlight-adapted": "The highlight is adapted by every engine. Name a series or category the chart type can emphasise, or remove the entry.",
3738
3923
  "slide-theme-dimensions": "A PPTX has one slide size. Set design.dimensions on the deck, or give every slide the same theme dimensions.",
@@ -3742,11 +3927,123 @@ var HELP = {
3742
3927
  "variable-unknown": "Declare the variable in the top-level variables map, or write '\\{{' for literal braces.",
3743
3928
  "variable-unknown-value": "Remove the supplied value, or declare the variable it belongs to.",
3744
3929
  "variable-unused": "Reference the variable as {{id}} or var:id where it belongs, or remove its declaration.",
3930
+ "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.",
3745
3931
  "variable-reference-unknown": "Declare the variable in the top-level variables map, or use another colour.",
3746
3932
  "run-color-unrecognized": "Use a #RRGGBB hex colour, a colour-scheme name or a var: reference to a declared colour variable.",
3747
3933
  "numbering-start-ignored": "Add a 'numbering' field to the payload, or remove 'start'.",
3748
3934
  "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."
3749
3935
  };
3936
+ function semanticHelp(issue2) {
3937
+ const params2 = issue2.params ?? {}, field = typeof params2.field === "string" ? params2.field : void 0, quoted2 = JSON.stringify(field);
3938
+ if (params2.code === "image-option-unsupported-payload" && field) return `Remove ${quoted2}, or put it on an image block ({ "image": ... }); it has no meaning on another kind of content.`;
3939
+ if (params2.code === "shape-option-unsupported-payload" && field === "alt" && params2.type === "image") return `A picture's alt text goes inside its image object: { "image": { "src": "...", "alt": "..." } }.`;
3940
+ if (params2.code === "shape-option-unsupported-payload" && field) return `Remove ${quoted2}, or draw this as a shape: a shape block ({ "shape": ... } with no "image") or an overlay shape in the slide's "shapes".`;
3941
+ if (params2.code === "caption-unsupported-payload") return "Put the caption on the image, chart, table, video or diagram it describes, or write it as a text block of its own.";
3942
+ if (Array.isArray(params2.incompatible) && params2.incompatible.includes("bullets") && params2.type === "list") return 'For a list, write the entries under "items". To keep "bullets" (talking points, which belong to a text payload), remove "type" or write "type": "text".';
3943
+ return "Resolve the reported structural conflict while preserving every content field. Preview the result after editing.";
3944
+ }
3945
+ var BACKGROUND_TYPES = ["theme", "solid", "gradient", "image", "pattern"];
3946
+ var BACKGROUND_HELP = `A background is a string (a theme slot such as "light1", a hex color, or an image source such as "asset:hero" or "./photo.jpg") or an object with "type": ${BACKGROUND_TYPES.map((type) => JSON.stringify(type)).join(", ")}, for example { "type": "solid", "color": "accent1" }.`;
3947
+ function collapseAuthoringShapes(document, findings) {
3948
+ const valueAt = (path) => {
3949
+ let node = document;
3950
+ for (const segment of splitPointer(path)) node = Array.isArray(node) ? node[Number(segment)] : isRecord(node) ? node[segment] : void 0;
3951
+ return node;
3952
+ };
3953
+ const schema = (entry2) => entry2?.ruleId === "opf/schema";
3954
+ const fills = /* @__PURE__ */ new Map();
3955
+ for (const entry2 of findings) {
3956
+ if (!schema(entry2)) continue;
3957
+ const at2 = /^(.*\/fill)(?:\/[^/]+)?$/.exec(entry2.path)?.[1];
3958
+ if (!at2 || fills.has(at2) || at2.endsWith("/style/fill")) continue;
3959
+ const fill = valueAt(at2);
3960
+ if (!isRecord(fill) || Object.hasOwn(fill, "lighten") || Object.hasOwn(fill, "darken")) continue;
3961
+ const solid = (fill.type === "solid" || fill.type === void 0) && fill.color !== void 0 && !Object.hasOwn(fill, "gradient") && !Object.hasOwn(fill, "pattern");
3962
+ const typed = fill.type === "gradient" && isRecord(fill.gradient) || fill.type === "pattern" && isRecord(fill.pattern);
3963
+ if (!solid && !typed) continue;
3964
+ const color = typeof fill.color === "string" ? JSON.stringify(fill.color) : '"accent1"';
3965
+ fills.set(at2, {
3966
+ ...entry2,
3967
+ path: at2,
3968
+ message: solid ? `A shape's solid fill is the color itself, not an object: write "fill": ${color}.` : `A shape's fill has no "type": write "fill": { ${JSON.stringify(fill.type)}: { ... } }.`,
3969
+ help: solid ? `Write "fill": ${color}. A fill is "none", a color ("accent1", "#1E40AF", or { "color": "accent1", "lighten": 0.4 }), { "gradient": { ... } } or { "pattern": { ... } }; only a slide background takes { "type": "solid", ... }.` : `Remove "type": a fill is told apart by its key, { "gradient": { ... } } or { "pattern": { ... } }; only a slide background takes "type".`,
3970
+ fixes: [solid && typeof fill.color === "string" ? { id: "fill-color", title: `Write the fill as ${color}`, kind: "patch", safe: false, patch: [{ op: "replace", path: at2, value: fill.color }] } : { id: "fill-remove-type", title: 'Remove "type"', kind: "patch", safe: false, patch: [{ op: "remove", path: `${at2}/type` }] }]
3971
+ });
3972
+ }
3973
+ if (fills.size) {
3974
+ const seen = /* @__PURE__ */ new Set();
3975
+ for (let index = 0; index < findings.length; index++) {
3976
+ const entry2 = findings[index];
3977
+ if (!schema(entry2)) continue;
3978
+ const at2 = [...fills.keys()].find((path) => entry2.path === path || entry2.path.startsWith(`${path}/`));
3979
+ if (!at2) continue;
3980
+ if (seen.has(at2)) {
3981
+ findings.splice(index--, 1);
3982
+ continue;
3983
+ }
3984
+ seen.add(at2);
3985
+ findings[index] = fills.get(at2);
3986
+ }
3987
+ }
3988
+ const backgrounds = /* @__PURE__ */ new Set();
3989
+ for (const entry2 of findings) {
3990
+ if (!schema(entry2)) continue;
3991
+ const at2 = /^((?:.*\/)?design\/background)(?:\/.*)?$/.exec(entry2.path)?.[1];
3992
+ if (!at2 || backgrounds.has(at2)) continue;
3993
+ const background = valueAt(at2), type = isRecord(background) ? background.type : void 0;
3994
+ if (typeof background === "string" || isRecord(background) && typeof type === "string" && BACKGROUND_TYPES.includes(type)) continue;
3995
+ backgrounds.add(at2);
3996
+ }
3997
+ for (const at2 of backgrounds) {
3998
+ const background = valueAt(at2), type = isRecord(background) ? background.type : void 0;
3999
+ const first = findings.findIndex((entry2) => schema(entry2) && (entry2.path === at2 || entry2.path.startsWith(`${at2}/`)));
4000
+ const { fixes: _fixes, suggestions: _suggestions, ...kept } = findings[first];
4001
+ const one = {
4002
+ ...kept,
4003
+ path: at2,
4004
+ message: isRecord(background) ? type === void 0 ? 'A background object needs a "type".' : `${JSON.stringify(type)} is not a background type.` : "This is not a background OPF can read.",
4005
+ help: BACKGROUND_HELP
4006
+ };
4007
+ for (let index = findings.length - 1; index >= 0; index--) {
4008
+ const entry2 = findings[index];
4009
+ if (schema(entry2) && (entry2.path === at2 || entry2.path.startsWith(`${at2}/`))) findings.splice(index, 1);
4010
+ }
4011
+ findings.splice(first, 0, one);
4012
+ }
4013
+ for (let index = findings.length - 1; index >= 0; index--) {
4014
+ const entry2 = findings[index];
4015
+ if (!schema(entry2) || entry2.validation?.keyword !== "if") continue;
4016
+ const stem = entry2.validation.schemaPath.replace(/if$/, "");
4017
+ if (findings.some((other) => other !== entry2 && schema(other) && other.path.startsWith(entry2.path) && typeof other.validation?.schemaPath === "string" && (other.validation.schemaPath.startsWith(`${stem}then`) || other.validation.schemaPath.startsWith(`${stem}else`)))) findings.splice(index, 1);
4018
+ }
4019
+ for (const [index, entry2] of findings.entries()) {
4020
+ if (!schema(entry2) || entry2.validation?.keyword !== "maximum") continue;
4021
+ const match2 = /^(\/slides\/\d+\/shapes\/\d+\/at)\/(width|height)$/.exec(entry2.path);
4022
+ const at2 = match2?.[1] ? valueAt(match2[1]) : void 0, key3 = match2?.[2], size = key3 && isRecord(at2) ? at2[key3] : void 0;
4023
+ if (!key3 || !isRecord(at2) || typeof size !== "number" || !(size > 8 && size <= 1280) || Object.hasOwn(at2, `${key3}Px`)) continue;
4024
+ const px = `${key3}Px`;
4025
+ findings[index] = {
4026
+ ...entry2,
4027
+ message: `at.${key3} is ${size}, but it is a fraction of the block, at most 8: did you mean "${px}"?`,
4028
+ help: `Did you mean "${px}"? "${key3}" is a fraction of the block (1 is its own size, up to 8); a size in pixels is "${px}". A 0.33 deck wrote pixels under "${key3}".`,
4029
+ fixes: [{ id: "rename", title: `Rename ${key3} to ${px}`, kind: "patch", safe: false, patch: [{ op: "move", from: entry2.path, path: `${entry2.path}Px` }] }]
4030
+ };
4031
+ }
4032
+ for (let index = findings.length - 1; index >= 0; index--) {
4033
+ const entry2 = findings[index];
4034
+ if (!schema(entry2) || entry2.validation?.keyword !== "required" || entry2.validation.params.missingProperty !== "items") continue;
4035
+ const payload = valueAt(entry2.path);
4036
+ if (isRecord(payload) && payload.type === "list" && Object.hasOwn(payload, "bullets")) findings.splice(index, 1);
4037
+ }
4038
+ const OPTION_RULES = ["opf/image-option-unsupported-payload", "opf/shape-option-unsupported-payload", "opf/caption-unsupported-payload"];
4039
+ const optionDefinition = (entry2) => entry2.validation?.keyword === "required" && /^must have required property '(?:image|shape|path|chart|table|video|diagram)'/.test(entry2.message) || entry2.validation?.keyword === "not" && entry2.message === "must NOT be valid" || (entry2.validation?.keyword === "anyOf" || entry2.validation?.keyword === "oneOf") && /must match a schema in anyOf|must match exactly one schema/.test(entry2.message);
4040
+ for (let index = findings.length - 1; index >= 0; index--) {
4041
+ const entry2 = findings[index];
4042
+ if (!schema(entry2) || !optionDefinition(entry2)) continue;
4043
+ const prefix = `${entry2.path}/`;
4044
+ if (findings.some((other) => other !== entry2 && other.path.startsWith(prefix) && !other.path.slice(prefix.length).includes("/") && OPTION_RULES.includes(other.ruleId))) findings.splice(index, 1);
4045
+ }
4046
+ }
3750
4047
  function collapseChartShape(document, findings) {
3751
4048
  const chartAt = (path) => {
3752
4049
  let node = document;
@@ -3780,9 +4077,11 @@ function engineFindings(document, engine, enabled) {
3780
4077
  const findings = [];
3781
4078
  for (const issue2 of engine.errors) {
3782
4079
  const ruleId = issueRuleId(issue2);
3783
- if (enabled(ruleId)) findings.push(issueFinding(issue2, ruleId));
4080
+ if (!enabled(ruleId)) continue;
4081
+ findings.push(issueFinding(issue2, ruleId));
3784
4082
  }
3785
4083
  collapseChartShape(document, findings);
4084
+ collapseAuthoringShapes(document, findings);
3786
4085
  let numberFixes;
3787
4086
  for (const issue2 of engine.warnings) {
3788
4087
  const code2 = issue2.params.code;
@@ -3801,9 +4100,14 @@ function engineFindings(document, engine, enabled) {
3801
4100
  continue;
3802
4101
  }
3803
4102
  }
3804
- const found = issueFinding(issue2, ruleId, "presentation", "", "document", "warning");
4103
+ const found = issueFinding(issue2, ruleId, "presentation", "", "document", code2 === "variable-group-omitted" ? "info" : "warning");
3805
4104
  const help = HELP[code2];
3806
4105
  if (help) found.help = help;
4106
+ if (code2 === "shape-anchor-size-unit") {
4107
+ const key3 = String(issue2.params.key), px = `${key3}Px`;
4108
+ found.help = `Did you mean "${px}"? "${key3}" is a fraction of the block.`;
4109
+ found.fixes = [{ id: "rename", title: `Rename ${key3} to ${px}`, kind: "patch", safe: false, patch: [{ op: "move", from: found.path, path: `${found.path}Px` }] }];
4110
+ }
3807
4111
  findings.push(found);
3808
4112
  }
3809
4113
  return findings;
@@ -3855,9 +4159,9 @@ function variableFindings(document, engine, schemaValid) {
3855
4159
  return;
3856
4160
  }
3857
4161
  if (value && typeof value === "object")
3858
- for (const [key2, entry2] of Object.entries(value)) {
3859
- if (path.length === 0 && ["variables", "extensions", "catalogs", "assets"].includes(key2)) continue;
3860
- walk2(entry2, [...path, key2], depth2 + 1);
4162
+ for (const [key3, entry2] of Object.entries(value)) {
4163
+ if (path.length === 0 && ["variables", "extensions", "catalogs", "assets"].includes(key3)) continue;
4164
+ walk2(entry2, [...path, key3], depth2 + 1);
3861
4165
  }
3862
4166
  };
3863
4167
  walk2(document, [], 0);
@@ -4074,7 +4378,7 @@ function contractFindings(document, contracts) {
4074
4378
  };
4075
4379
  const message = (contract2.message ?? "This value is outside the allowed values for {{path}}.").replace(
4076
4380
  /\{\{(path|value|allowed|file)\}\}/g,
4077
- (_, key2) => values[key2] ?? ""
4381
+ (_, key3) => values[key3] ?? ""
4078
4382
  );
4079
4383
  findings.push(
4080
4384
  finding("opf/contract", {
@@ -4092,9 +4396,9 @@ function contractFindings(document, contracts) {
4092
4396
  })
4093
4397
  );
4094
4398
  } else if (object(entry2.value) || Array.isArray(entry2.value)) {
4095
- const key2 = pattern[entry2.depth];
4399
+ const key3 = pattern[entry2.depth];
4096
4400
  for (const [name, value] of Object.entries(entry2.value))
4097
- if (key2 === "*" || key2 === name)
4401
+ if (key3 === "*" || key3 === name)
4098
4402
  stack.push({
4099
4403
  value,
4100
4404
  path: [...entry2.path, name],
@@ -4122,9 +4426,9 @@ function canonicalJson(value) {
4122
4426
  } else {
4123
4427
  const record = item;
4124
4428
  const members = [];
4125
- for (const key2 of Object.keys(record).sort()) {
4126
- const member = write(record[key2]);
4127
- if (member !== void 0) members.push(`${JSON.stringify(key2)}:${member}`);
4429
+ for (const key3 of Object.keys(record).sort()) {
4430
+ const member = write(record[key3]);
4431
+ if (member !== void 0) members.push(`${JSON.stringify(key3)}:${member}`);
4128
4432
  }
4129
4433
  text2 = `{${members.join(",")}}`;
4130
4434
  }
@@ -4295,7 +4599,7 @@ var OPFPatchHashError = class extends OPFPatchError {
4295
4599
  this.actual = actual;
4296
4600
  }
4297
4601
  };
4298
- var own2 = (value, key2) => Object.prototype.hasOwnProperty.call(value, key2);
4602
+ var own2 = (value, key3) => Object.prototype.hasOwnProperty.call(value, key3);
4299
4603
  var isObject = (value) => !!value && typeof value === "object" && !Array.isArray(value);
4300
4604
  var clone = (value) => structuredClone(value);
4301
4605
  function jsonEqual(a, b) {
@@ -4308,7 +4612,7 @@ function jsonEqual(a, b) {
4308
4612
  }
4309
4613
  const left = a, right = b;
4310
4614
  const keys = Object.keys(left);
4311
- return keys.length === Object.keys(right).length && keys.every((key2) => own2(right, key2) && jsonEqual(left[key2], right[key2]));
4615
+ return keys.length === Object.keys(right).length && keys.every((key3) => own2(right, key3) && jsonEqual(left[key3], right[key3]));
4312
4616
  }
4313
4617
  function escapePointerToken(token) {
4314
4618
  return String(token).replaceAll("~", "~0").replaceAll("/", "~1");
@@ -4471,65 +4775,65 @@ function normalizeOperation(operation, index) {
4471
4775
  return { op, path: operation.path, value: clone(operation.value) };
4472
4776
  }
4473
4777
  function parentOf(document, tokens, path) {
4474
- const key2 = tokens[tokens.length - 1];
4778
+ const key3 = tokens[tokens.length - 1];
4475
4779
  const found = readPointer(document, tokens.slice(0, -1));
4476
4780
  if (!found.found || !found.value || typeof found.value !== "object") {
4477
4781
  throw new OPFPatchError("patch-parent-missing", `Patch parent does not exist for ${path}.`, { path });
4478
4782
  }
4479
- return { parent: found.value, key: key2 };
4783
+ return { parent: found.value, key: key3 };
4480
4784
  }
4481
4785
  var NONE = /* @__PURE__ */ Symbol("none");
4482
4786
  function addAt(document, path, value) {
4483
4787
  const tokens = resolveTokens(document, parsePointer(path), path);
4484
4788
  if (!tokens.length) return { document: clone(value), inverse: { op: "replace", path: "", value: clone(document) }, pointer: "" };
4485
- const { parent, key: key2 } = parentOf(document, tokens, path);
4789
+ const { parent, key: key3 } = parentOf(document, tokens, path);
4486
4790
  if (Array.isArray(parent)) {
4487
- const at2 = arrayIndex(key2, parent.length, true, path);
4791
+ const at2 = arrayIndex(key3, parent.length, true, path);
4488
4792
  parent.splice(at2, 0, clone(value));
4489
4793
  const pointer5 = formatPointer([...tokens.slice(0, -1), at2]);
4490
4794
  return { document, inverse: { op: "remove", path: pointer5 }, pointer: pointer5 };
4491
4795
  }
4492
4796
  const record = parent;
4493
- const previous = own2(record, key2) ? record[key2] : NONE;
4494
- Object.defineProperty(record, key2, { value: clone(value), enumerable: true, configurable: true, writable: true });
4797
+ const previous = own2(record, key3) ? record[key3] : NONE;
4798
+ Object.defineProperty(record, key3, { value: clone(value), enumerable: true, configurable: true, writable: true });
4495
4799
  const pointer4 = formatPointer(tokens);
4496
4800
  return { document, inverse: previous === NONE ? { op: "remove", path: pointer4 } : { op: "replace", path: pointer4, value: clone(previous) }, pointer: pointer4 };
4497
4801
  }
4498
4802
  function replaceAt(document, path, value) {
4499
4803
  const tokens = resolveTokens(document, parsePointer(path), path);
4500
4804
  if (!tokens.length) return { document: clone(value), inverse: { op: "replace", path: "", value: clone(document) }, pointer: "" };
4501
- const { parent, key: key2 } = parentOf(document, tokens, path);
4805
+ const { parent, key: key3 } = parentOf(document, tokens, path);
4502
4806
  let previous;
4503
4807
  let pointer4 = formatPointer(tokens);
4504
4808
  if (Array.isArray(parent)) {
4505
- const at2 = arrayIndex(key2, parent.length, false, path);
4809
+ const at2 = arrayIndex(key3, parent.length, false, path);
4506
4810
  previous = parent[at2];
4507
4811
  parent[at2] = clone(value);
4508
4812
  pointer4 = formatPointer([...tokens.slice(0, -1), at2]);
4509
4813
  } else {
4510
4814
  const record = parent;
4511
- if (!own2(record, key2)) throw new OPFPatchError("patch-path-missing", `Patch path does not exist: ${path}.`, { path });
4512
- previous = record[key2];
4513
- Object.defineProperty(record, key2, { value: clone(value), enumerable: true, configurable: true, writable: true });
4815
+ if (!own2(record, key3)) throw new OPFPatchError("patch-path-missing", `Patch path does not exist: ${path}.`, { path });
4816
+ previous = record[key3];
4817
+ Object.defineProperty(record, key3, { value: clone(value), enumerable: true, configurable: true, writable: true });
4514
4818
  }
4515
4819
  return { document, inverse: { op: "replace", path: pointer4, value: clone(previous) }, pointer: pointer4 };
4516
4820
  }
4517
4821
  function removeAt(document, path) {
4518
4822
  const tokens = resolveTokens(document, parsePointer(path), path);
4519
4823
  if (!tokens.length) throw new OPFPatchError("patch-root-remove", "The document root cannot be removed.", { path });
4520
- const { parent, key: key2 } = parentOf(document, tokens, path);
4824
+ const { parent, key: key3 } = parentOf(document, tokens, path);
4521
4825
  let previous;
4522
4826
  if (Array.isArray(parent)) {
4523
- const at2 = arrayIndex(key2, parent.length, false, path);
4827
+ const at2 = arrayIndex(key3, parent.length, false, path);
4524
4828
  previous = parent[at2];
4525
4829
  parent.splice(at2, 1);
4526
4830
  const pointer5 = formatPointer([...tokens.slice(0, -1), at2]);
4527
4831
  return { document, inverse: { op: "add", path: pointer5, value: clone(previous) }, pointer: pointer5 };
4528
4832
  }
4529
4833
  const record = parent;
4530
- if (!own2(record, key2)) throw new OPFPatchError("patch-path-missing", `Patch path does not exist: ${path}.`, { path });
4531
- previous = record[key2];
4532
- delete record[key2];
4834
+ if (!own2(record, key3)) throw new OPFPatchError("patch-path-missing", `Patch path does not exist: ${path}.`, { path });
4835
+ previous = record[key3];
4836
+ delete record[key3];
4533
4837
  const pointer4 = formatPointer(tokens);
4534
4838
  return { document, inverse: { op: "add", path: pointer4, value: clone(previous) }, pointer: pointer4 };
4535
4839
  }
@@ -4690,7 +4994,7 @@ var schemaCatalogKinds = {
4690
4994
  };
4691
4995
 
4692
4996
  // src/schema-navigation.ts
4693
- var own3 = (object2, key2) => object2 !== null && typeof object2 === "object" && Object.hasOwn(object2, key2);
4997
+ var own3 = (object2, key3) => object2 !== null && typeof object2 === "object" && Object.hasOwn(object2, key3);
4694
4998
  var documents = new Map(Object.values(schemas).map((schema) => [schema.$id, schema]));
4695
4999
  var presentationSchema = schemas.presentation;
4696
5000
  var CATALOG_KIND = /* @__PURE__ */ Symbol.for("@openpresentation/opf:catalog-kind");
@@ -4711,10 +5015,10 @@ function readSchemaPointer(target, pointer4) {
4711
5015
  }
4712
5016
  return current;
4713
5017
  }
4714
- for (const [key2, kind] of Object.entries(schemaCatalogKinds)) {
4715
- const [name = "", pointer4 = ""] = key2.split("#");
5018
+ for (const [key3, kind] of Object.entries(schemaCatalogKinds)) {
5019
+ const [name = "", pointer4 = ""] = key3.split("#");
4716
5020
  const node = readSchemaPointer(schemas[name], pointer4);
4717
- if (node === void 0 || node === null || typeof node !== "object") throw new Error(`schemaCatalogKinds: ${key2} is not a schema node.`);
5021
+ if (node === void 0 || node === null || typeof node !== "object") throw new Error(`schemaCatalogKinds: ${key3} is not a schema node.`);
4718
5022
  catalogKindOfNode.set(node, kind);
4719
5023
  }
4720
5024
  function absolutize(schema, id) {
@@ -4723,7 +5027,7 @@ function absolutize(schema, id) {
4723
5027
  const copy = {};
4724
5028
  const kind = kindOfNode(schema);
4725
5029
  if (kind !== void 0) copy[CATALOG_KIND] = kind;
4726
- for (const [key2, value] of Object.entries(schema)) copy[key2] = key2 === "$ref" && typeof value === "string" && value.startsWith("#") ? `${id}${value}` : absolutize(value, id);
5030
+ for (const [key3, value] of Object.entries(schema)) copy[key3] = key3 === "$ref" && typeof value === "string" && value.startsWith("#") ? `${id}${value}` : absolutize(value, id);
4727
5031
  return copy;
4728
5032
  }
4729
5033
  function mergeAllOf(schema, root, seen) {
@@ -4790,36 +5094,36 @@ function score2(schema, value) {
4790
5094
  if (schema.enum && !schema.enum.includes(value)) return -100;
4791
5095
  let result = 1;
4792
5096
  const record = value;
4793
- for (const [key2, child] of Object.entries(schema.properties ?? {})) {
4794
- if (!record || !own3(record, key2)) continue;
4795
- if (own3(child, "const")) result += record[key2] === child.const ? 100 : -1e3;
5097
+ for (const [key3, child] of Object.entries(schema.properties ?? {})) {
5098
+ if (!record || !own3(record, key3)) continue;
5099
+ if (own3(child, "const")) result += record[key3] === child.const ? 100 : -1e3;
4796
5100
  else result += 1;
4797
5101
  }
4798
- for (const key2 of schema.required ?? []) if (!record || !own3(record, key2)) result -= 2;
5102
+ for (const key3 of schema.required ?? []) if (!record || !own3(record, key3)) result -= 2;
4799
5103
  return result;
4800
5104
  }
4801
5105
  function activeSchema(schema, value, root = presentationSchema) {
4802
5106
  return schemaVariants(schema, root).sort((a, b) => score2(b, value) - score2(a, value))[0] ?? {};
4803
5107
  }
4804
5108
  var INDEX = /^(?:0|[1-9][0-9]*|-)$/;
4805
- function patternChild(schema, key2) {
5109
+ function patternChild(schema, key3) {
4806
5110
  for (const [pattern, child] of Object.entries(schema.patternProperties ?? {})) {
4807
5111
  try {
4808
- if (new RegExp(pattern).test(key2)) return child;
5112
+ if (new RegExp(pattern).test(key3)) return child;
4809
5113
  } catch {
4810
5114
  }
4811
5115
  }
4812
5116
  return void 0;
4813
5117
  }
4814
- function childSchema(schema, key2, value) {
5118
+ function childSchema(schema, key3, value) {
4815
5119
  if (Array.isArray(value) || schema.type === "array") return schema.items ?? void 0;
4816
- return schema.properties?.[key2] ?? patternChild(schema, key2) ?? (typeof schema.additionalProperties === "object" ? schema.additionalProperties : void 0);
5120
+ return schema.properties?.[key3] ?? patternChild(schema, key3) ?? (typeof schema.additionalProperties === "object" ? schema.additionalProperties : void 0);
4817
5121
  }
4818
- function stepSchema(schema, value, key2, root) {
5122
+ function stepSchema(schema, value, key3, root) {
4819
5123
  const variants = schemaVariants(schema, root).sort((a, b) => score2(b, value) - score2(a, value));
4820
5124
  const first = variants[0] ?? {};
4821
- if (value !== void 0 || variants.length < 2 || childSchema(first, key2, value) !== void 0) return first;
4822
- return variants.find((variant) => variant.type === "array" ? INDEX.test(key2) && childSchema(variant, key2, value) !== void 0 : childSchema(variant, key2, value) !== void 0) ?? first;
5125
+ if (value !== void 0 || variants.length < 2 || childSchema(first, key3, value) !== void 0) return first;
5126
+ return variants.find((variant) => variant.type === "array" ? INDEX.test(key3) && childSchema(variant, key3, value) !== void 0 : childSchema(variant, key3, value) !== void 0) ?? first;
4823
5127
  }
4824
5128
  function walk(presentation, parts2, rootSchema) {
4825
5129
  let current = rootSchema;
@@ -4828,21 +5132,21 @@ function walk(presentation, parts2, rootSchema) {
4828
5132
  let parent;
4829
5133
  let known = true;
4830
5134
  for (let index = 0; index < parts2.length; index++) {
4831
- const key2 = parts2[index];
4832
- const resolved = stepSchema(current, value, key2, root);
5135
+ const key3 = parts2[index];
5136
+ const resolved = stepSchema(current, value, key3, root);
4833
5137
  parent = resolved;
4834
5138
  let next;
4835
5139
  const recordSchema = parts2[0] === "catalogs" && index === 3 ? catalogSchemaNames[parts2[2]] : void 0;
4836
5140
  if (recordSchema) {
4837
5141
  next = schemas[recordSchema] ?? {};
4838
5142
  root = next;
4839
- } else next = childSchema(resolved, key2, value);
5143
+ } else next = childSchema(resolved, key3, value);
4840
5144
  if (next === void 0) {
4841
5145
  known = false;
4842
5146
  next = {};
4843
5147
  }
4844
5148
  current = next;
4845
- value = value !== null && typeof value === "object" ? value[key2] : void 0;
5149
+ value = value !== null && typeof value === "object" ? value[key3] : void 0;
4846
5150
  }
4847
5151
  return { raw: current, schema: resolveSchema(current, root), root, parent, value, known };
4848
5152
  }
@@ -4864,7 +5168,7 @@ function createSchemaValue(schema, root = presentationSchema, depth2 = 0) {
4864
5168
  if (type === "object") {
4865
5169
  const value = {};
4866
5170
  const properties = s.properties ?? {};
4867
- for (const key2 of /* @__PURE__ */ new Set([...s.required ?? [], ...Object.keys(properties).filter((name) => own3(properties[name], "const"))])) value[key2] = createSchemaValue(properties[key2] ?? {}, root, depth2 + 1);
5171
+ for (const key3 of /* @__PURE__ */ new Set([...s.required ?? [], ...Object.keys(properties).filter((name) => own3(properties[name], "const"))])) value[key3] = createSchemaValue(properties[key3] ?? {}, root, depth2 + 1);
4868
5172
  return value;
4869
5173
  }
4870
5174
  if (type === "array") return Array.from({ length: Math.min(s.minItems ?? 0, 100) }, () => createSchemaValue(s.items ?? {}, root, depth2 + 1));
@@ -4881,26 +5185,26 @@ function listSchemaFields() {
4881
5185
  for (const [name, root] of Object.entries(schemas)) {
4882
5186
  const visit = (schema, path) => {
4883
5187
  if (!schema || typeof schema !== "object") return;
4884
- for (const [key2, child] of Object.entries(schema.properties ?? {})) {
5188
+ for (const [key3, child] of Object.entries(schema.properties ?? {})) {
4885
5189
  result.push({
4886
5190
  schema: name,
4887
- path: formatPointer([...path, "properties", key2]),
4888
- name: key2,
5191
+ path: formatPointer([...path, "properties", key3]),
5192
+ name: key3,
4889
5193
  description: child.description ?? "",
4890
5194
  reference: child.$ref ?? null,
4891
5195
  type: child.type ?? null,
4892
5196
  values: child.enum ?? (own3(child, "const") ? [child.const] : null)
4893
5197
  });
4894
- visit(child, [...path, "properties", key2]);
5198
+ visit(child, [...path, "properties", key3]);
4895
5199
  }
4896
- for (const [key2, child] of Object.entries(schema.$defs ?? {})) visit(child, [...path, "$defs", key2]);
5200
+ for (const [key3, child] of Object.entries(schema.$defs ?? {})) visit(child, [...path, "$defs", key3]);
4897
5201
  for (const keyword of ["oneOf", "anyOf", "allOf"]) {
4898
5202
  const members = schema[keyword] ?? [];
4899
5203
  for (let index = 0; index < members.length; index++) visit(members[index], [...path, keyword, String(index)]);
4900
5204
  }
4901
5205
  if (schema.items) visit(schema.items, [...path, "items"]);
4902
5206
  if (typeof schema.additionalProperties === "object") visit(schema.additionalProperties, [...path, "additionalProperties"]);
4903
- for (const [key2, child] of Object.entries(schema.patternProperties ?? {})) visit(child, [...path, "patternProperties", key2]);
5207
+ for (const [key3, child] of Object.entries(schema.patternProperties ?? {})) visit(child, [...path, "patternProperties", key3]);
4904
5208
  };
4905
5209
  visit(root, []);
4906
5210
  }
@@ -4910,16 +5214,16 @@ var COMMON_KEYS = Object.freeze({
4910
5214
  /** The root of a document. */
4911
5215
  deck: Object.freeze(["name", "slides", "design", "language", "audience", "purpose", "tone", "narrative", "organization", "speaker"]),
4912
5216
  /** A slide (`slides[n]`). */
4913
- slide: Object.freeze(["title", "subtitle", "layout", "items", "text", "notes", "image", "chart", "table", "quote", "code", "metric", "timeline", "diagram", "blocks", "design", "id", "section", "tag", "hidden", "beat"]),
5217
+ slide: Object.freeze(["title", "subtitle", "layout", "items", "text", "notes", "image", "chart", "table", "quote", "code", "metric", "timeline", "diagram", "blocks", "design", "id", "section", "tag", "hidden", "beat", "language"]),
4914
5218
  /** `design`, on the deck and on a slide. */
4915
5219
  design: Object.freeze(["theme", "colorScheme", "fontScheme", "dimensions", "background", "header", "footer"])
4916
5220
  });
4917
5221
  var UNRANKED_PRIORITY = 1e6;
4918
5222
  var DEFINITION_LISTS = { Slide: COMMON_KEYS.slide, Design: COMMON_KEYS.design, SlideDesign: COMMON_KEYS.design };
4919
5223
  var ADVANCED_KEYS = /* @__PURE__ */ new Set(["extensions", "$schema"]);
4920
- var REGION_KEY = /^(?:(?:top|middle|bottom)(?:\+(?:top|middle|bottom))*)?(?::)?(?:(?:left|center|right)(?:\+(?:left|center|right))*)?$/;
4921
- function isPromotedRegionKey(key2) {
4922
- return key2 !== "" && key2 !== ":" && REGION_KEY.test(key2);
5224
+ var REGION_KEY = /^(?:(?:top|middle|bottom)(?:\+(?:top|middle|bottom))*)?(?::)?(?:(?:start|center|end)(?:\+(?:start|center|end))*)?$/;
5225
+ function isPromotedRegionKey(key3) {
5226
+ return key3 !== "" && key3 !== ":" && REGION_KEY.test(key3);
4923
5227
  }
4924
5228
  var uniq = (items) => [...new Set(items)];
4925
5229
  function variantType(variant) {
@@ -4978,8 +5282,8 @@ function typeLabelOf(raw, variants, root) {
4978
5282
  if (type === "object") return definitionOf(raw) ?? "object";
4979
5283
  return type;
4980
5284
  }
4981
- function priorityOf(list, key2) {
4982
- const index = list ? list.indexOf(key2) : -1;
5285
+ function priorityOf(list, key3) {
5286
+ const index = list ? list.indexOf(key3) : -1;
4983
5287
  return index < 0 ? UNRANKED_PRIORITY : index;
4984
5288
  }
4985
5289
  function objectForm(variants, value) {
@@ -4990,24 +5294,24 @@ function objectForm(variants, value) {
4990
5294
  if (best) used = [best];
4991
5295
  }
4992
5296
  const properties = /* @__PURE__ */ new Map();
4993
- for (const variant of used) for (const [key2, child] of Object.entries(variant.properties ?? {})) if (!properties.has(key2)) properties.set(key2, child);
4994
- const required = used.length ? (used[0]?.required ?? []).filter((key2) => used.every((variant) => (variant.required ?? []).includes(key2))) : [];
5297
+ for (const variant of used) for (const [key3, child] of Object.entries(variant.properties ?? {})) if (!properties.has(key3)) properties.set(key3, child);
5298
+ const required = used.length ? (used[0]?.required ?? []).filter((key3) => used.every((variant) => (variant.required ?? []).includes(key3))) : [];
4995
5299
  return { properties, required };
4996
5300
  }
4997
5301
  function childrenOf(form, list, isSlide, root) {
4998
5302
  const children = [];
4999
- for (const [key2, raw] of form.properties) {
5303
+ for (const [key3, raw] of form.properties) {
5000
5304
  const resolved = resolveSchema(raw, root);
5001
5305
  const variants = schemaVariants(raw, root);
5002
5306
  const description = firstParagraph(resolved.description);
5003
5307
  const catalogKind = catalogKindOf(resolved, variants);
5004
5308
  children.push({
5005
- key: key2,
5309
+ key: key3,
5006
5310
  types: uniq(variants.map(variantType)),
5007
5311
  typeLabel: typeLabelOf(raw, variants, root),
5008
- required: form.required.includes(key2),
5009
- advanced: ADVANCED_KEYS.has(key2) || isSlide && isPromotedRegionKey(key2),
5010
- priority: priorityOf(list, key2),
5312
+ required: form.required.includes(key3),
5313
+ advanced: ADVANCED_KEYS.has(key3) || isSlide && isPromotedRegionKey(key3),
5314
+ priority: priorityOf(list, key3),
5011
5315
  ...description ? { description } : {},
5012
5316
  ...catalogKind ? { catalogKind } : {},
5013
5317
  ...resolved.deprecated === true ? { deprecated: true } : {},
@@ -5040,7 +5344,7 @@ function describeAt(presentation, path, depth2) {
5040
5344
  const inherited = schema.description;
5041
5345
  const last = parts2.at(-1);
5042
5346
  const parentIsArray = parent !== void 0 && variantType(parent) === "array";
5043
- const key2 = last !== void 0 && !parentIsArray ? last : void 0;
5347
+ const key3 = last !== void 0 && !parentIsArray ? last : void 0;
5044
5348
  const definition = definitionOf(raw);
5045
5349
  const description = firstParagraph(schema.description);
5046
5350
  const enumList = enumValues(variants, inherited);
@@ -5070,12 +5374,12 @@ function describeAt(presentation, path, depth2) {
5070
5374
  known: true,
5071
5375
  path: shown,
5072
5376
  pointer: pointer4,
5073
- ...key2 !== void 0 ? { key: key2 } : {},
5377
+ ...key3 !== void 0 ? { key: key3 } : {},
5074
5378
  types: uniq(infos2.map((variant) => variant.type)),
5075
5379
  ...description ? { description } : {},
5076
5380
  ...typeof schema.description === "string" && schema.description.trim() ? { fullDescription: schema.description.trim() } : {},
5077
5381
  ...definition ? { definition } : {},
5078
- required: key2 !== void 0 && Array.isArray(parent?.required) && parent.required.includes(key2),
5382
+ required: key3 !== void 0 && Array.isArray(parent?.required) && parent.required.includes(key3),
5079
5383
  ...schema.deprecated === true ? { deprecated: true } : {},
5080
5384
  examples: Array.isArray(schema.examples) ? [...schema.examples] : [],
5081
5385
  ...own3(schema, "default") ? { default: schema.default } : {},
@@ -5654,7 +5958,7 @@ var Analyzer = class {
5654
5958
  });
5655
5959
  }
5656
5960
  // -- values --
5657
- parseValue(path, key2) {
5961
+ parseValue(path, key3) {
5658
5962
  const token = this.peek();
5659
5963
  switch (token.kind) {
5660
5964
  case "lbrace":
@@ -5673,7 +5977,7 @@ var Analyzer = class {
5673
5977
  return { start: token.start, end: token.end, kind: "scalar" };
5674
5978
  case "word":
5675
5979
  this.take();
5676
- this.bareWord(token, path, key2);
5980
+ this.bareWord(token, path, key3);
5677
5981
  return { start: token.start, end: token.end, kind: "scalar" };
5678
5982
  case "unknown":
5679
5983
  this.take();
@@ -5682,7 +5986,7 @@ var Analyzer = class {
5682
5986
  return void 0;
5683
5987
  }
5684
5988
  }
5685
- bareWord(token, path, key2) {
5989
+ bareWord(token, path, key3) {
5686
5990
  const word = token.text;
5687
5991
  const lower = word.toLowerCase();
5688
5992
  const edit = (insert) => [{ offset: token.start, length: token.end - token.start, insert }];
@@ -5698,7 +6002,7 @@ var Analyzer = class {
5698
6002
  next = "write null, or put it in quotes if it is text. JSON has no NaN, Infinity or undefined.";
5699
6003
  fixes.push({ id: "use-null", title: "Use null", safe: lower === "null", edits: edit("null") });
5700
6004
  } else {
5701
- message = key2 !== void 0 ? `\`${key2}\` needs a quoted string: ${JSON.stringify(word)}.` : `\`${clip(word, 24)}\` needs quotes to be text: ${JSON.stringify(word)}.`;
6005
+ message = key3 !== void 0 ? `\`${key3}\` needs a quoted string: ${JSON.stringify(word)}.` : `\`${clip(word, 24)}\` needs quotes to be text: ${JSON.stringify(word)}.`;
5702
6006
  next = `put it in double quotes: ${JSON.stringify(word)}.`;
5703
6007
  }
5704
6008
  fixes.push({ id: "quote-value", title: "Quote the value", safe: false, edits: edit(JSON.stringify(word)) });
@@ -5922,23 +6226,23 @@ var Analyzer = class {
5922
6226
  fixes: [{ id: "remove-token", title: `Remove ${clip(token.text, 12)}`, safe: false, edits: [{ offset: token.start, length: token.end - token.start, insert: "" }] }]
5923
6227
  });
5924
6228
  }
5925
- missingColon(keyToken, key2, path, valueFollows, container) {
6229
+ missingColon(keyToken, key3, path, valueFollows, container) {
5926
6230
  const keyEnd = keyToken.end;
5927
- const shown = clip(key2, 30);
6231
+ const shown = clip(key3, 30);
5928
6232
  const removal = this.removeEntry(keyToken.start, keyEnd);
5929
6233
  this.structural({
5930
6234
  code: "missing-colon",
5931
6235
  range: this.range(keyToken.start, keyToken.end),
5932
6236
  path,
5933
6237
  message: valueFollows ? `\`${shown}\` is missing a colon.` : `\`${shown}\` has no colon and value.`,
5934
- next: valueFollows ? "add `:` after the property name." : `write ${JSON.stringify(key2)}: and a value, or remove the property.`,
6238
+ next: valueFollows ? "add `:` after the property name." : `write ${JSON.stringify(key3)}: and a value, or remove the property.`,
5935
6239
  fixes: [
5936
6240
  { id: "insert-colon", title: "Add colon", safe: valueFollows, edits: [{ offset: keyEnd, length: 0, insert: valueFollows ? ":" : ": " }], caret: keyEnd + (valueFollows ? 1 : 2) },
5937
- ...valueFollows ? [] : [{ id: "remove-key", title: `Remove ${JSON.stringify(key2)}`, safe: false, edits: removal }]
6241
+ ...valueFollows ? [] : [{ id: "remove-key", title: `Remove ${JSON.stringify(key3)}`, safe: false, edits: removal }]
5938
6242
  ]
5939
6243
  });
5940
6244
  }
5941
- missingValue(keyToken, colon, key2, path) {
6245
+ missingValue(keyToken, colon, key3, path) {
5942
6246
  const needsComma = (() => {
5943
6247
  const next = this.peek();
5944
6248
  return (next.kind === "string" || next.kind === "word") && this.peek(1).kind === "colon";
@@ -5949,12 +6253,12 @@ var Analyzer = class {
5949
6253
  const edits = [{ offset: at2, length: 0, insert: `${gap ? " " : ""}${hint.insert}` }];
5950
6254
  if (needsComma) edits.push({ offset: at2, length: 0, insert: "," });
5951
6255
  const fixes = [{ id: "add-value", title: hint.title, safe: false, edits, caret: at2 + (gap ? 1 : 0) + hint.caret }];
5952
- fixes.push({ id: "remove-key", title: `Remove ${JSON.stringify(key2)}`, safe: false, edits: this.removeEntry(keyToken.start, colon.end) });
6256
+ fixes.push({ id: "remove-key", title: `Remove ${JSON.stringify(key3)}`, safe: false, edits: this.removeEntry(keyToken.start, colon.end) });
5953
6257
  this.structural({
5954
6258
  code: "missing-value",
5955
6259
  range: this.range(keyToken.start, colon.end),
5956
6260
  path,
5957
- message: `\`${key2}\` needs a value.`,
6261
+ message: `\`${key3}\` needs a value.`,
5958
6262
  next: `${hint.next} Press Ctrl+Space after the colon for options.`,
5959
6263
  fixes
5960
6264
  });
@@ -6011,8 +6315,8 @@ ${indentOf(text2, open.start)}${closer}`;
6011
6315
  const insert = inner.join("") + own4;
6012
6316
  this.cascade = { last: this.last, inserts: [...inner, own4] };
6013
6317
  const closers = insert.replace(/\s/g, "");
6014
- const key2 = container.path.at(-1);
6015
- const entry2 = typeof key2 === "string" ? `"${key2}": ${open.text}` : open.text;
6318
+ const key3 = container.path.at(-1);
6319
+ const entry2 = typeof key3 === "string" ? `"${key3}": ${open.text}` : open.text;
6016
6320
  const context = container.type === "{" ? firstEntryOf(text2, open) : void 0;
6017
6321
  const what = container.type === "{" ? "property" : "item";
6018
6322
  this.add({
@@ -6223,18 +6527,18 @@ function parseSource(source) {
6223
6527
  if (node.type === "object") {
6224
6528
  const keys = /* @__PURE__ */ new Set();
6225
6529
  for (const property of node.children ?? []) {
6226
- const key2 = property.children?.[0];
6227
- if (!key2) continue;
6228
- if (keys.has(key2.value))
6530
+ const key3 = property.children?.[0];
6531
+ if (!key3) continue;
6532
+ if (keys.has(key3.value))
6229
6533
  duplicates.push(
6230
6534
  finding("opf/duplicate-key", {
6231
- path: pointer3(getNodePath(key2)),
6232
- message: `Duplicate JSON property ${JSON.stringify(key2.value)}.`,
6535
+ path: pointer3(getNodePath(key3)),
6536
+ message: `Duplicate JSON property ${JSON.stringify(key3.value)}.`,
6233
6537
  help: "Resolve the duplicate explicitly, preserving the intended content from both occurrences. JSON.parse would otherwise hide an earlier value.",
6234
- location: location(key2.offset, key2.length)
6538
+ location: location(key3.offset, key3.length)
6235
6539
  })
6236
6540
  );
6237
- keys.add(key2.value);
6541
+ keys.add(key3.value);
6238
6542
  }
6239
6543
  }
6240
6544
  stack.push(...node.children ?? []);
@@ -6269,7 +6573,7 @@ function parseSource(source) {
6269
6573
  var WORDS = { object: "an object", array: "a list", string: "text", number: "a number", integer: "a whole number", boolean: "true or false", null: "null" };
6270
6574
  var KIND_WORDS = { layouts: "layout", themes: "theme", colorSchemes: "color scheme", fontSchemes: "font scheme", narratives: "narrative", audiences: "audience", purposes: "purpose", tones: "tone", languages: "language" };
6271
6575
  var KIND_EXAMPLES = { layouts: "`pillars` or `acme:hero`", themes: "`minimal` or `acme:bold`", colorSchemes: "`boost` or `acme:night`", fontSchemes: "`aptos` or `acme:brand`", narratives: "`classic-story`", audiences: "`board`", purposes: "`inform`", tones: "`formal`" };
6272
- var ALIASES = { middle: "center", centre: "center", centered: "center", centred: "center", justify: "left", col: "column", cols: "column", pic: "image", picture: "image", photo: "image", paragraph: "text", bullets: "list", bullet: "list" };
6576
+ var ALIASES = { middle: "center", centre: "center", centered: "center", centred: "center", justify: "start", left: "start", right: "end", col: "column", cols: "column", pic: "image", picture: "image", photo: "image", paragraph: "text", bullets: "list", bullet: "list" };
6273
6577
  function segmentsOf(path) {
6274
6578
  if (Array.isArray(path)) return path.map(String);
6275
6579
  if (typeof path !== "string" || path === "" || path === "/") return [];
@@ -6473,7 +6777,7 @@ var BLOCK_KINDS = ["chart", "image", "video", "table", "code", "metric", "quote"
6473
6777
  function blockKind(node) {
6474
6778
  if (!isRecord3(node)) return void 0;
6475
6779
  if (typeof node.type === "string" && node.type !== "group") return node.type;
6476
- const found = BLOCK_KINDS.find((key2) => node[key2] !== void 0);
6780
+ const found = BLOCK_KINDS.find((key3) => node[key3] !== void 0);
6477
6781
  if (found === "items" || found === "bullets") return "list";
6478
6782
  return found;
6479
6783
  }
@@ -6488,12 +6792,12 @@ function brief(text2, max = 40) {
6488
6792
  }
6489
6793
 
6490
6794
  // src/finding-text-audit.ts
6491
- var measuredNumber = (finding2, key2) => {
6492
- const value = finding2.measured?.[key2];
6795
+ var measuredNumber = (finding2, key3) => {
6796
+ const value = finding2.measured?.[key3];
6493
6797
  return typeof value === "number" ? value : void 0;
6494
6798
  };
6495
- var measuredText = (finding2, key2) => {
6496
- const value = finding2.measured?.[key2];
6799
+ var measuredText = (finding2, key3) => {
6800
+ const value = finding2.measured?.[key3];
6497
6801
  return typeof value === "string" ? value : void 0;
6498
6802
  };
6499
6803
  var num = (value, digits = 2) => String(Math.round(value * 10 ** digits) / 10 ** digits);
@@ -6520,6 +6824,12 @@ var textOnImage = (finding2) => {
6520
6824
  const ratio = measuredNumber(finding2, "ratio");
6521
6825
  const needed = measuredNumber(finding2, "needed");
6522
6826
  const scrim = measuredNumber(finding2, "scrimOpacity");
6827
+ const best = measuredNumber(finding2, "best");
6828
+ if (best !== void 0)
6829
+ return {
6830
+ message: `This text is too faint on the picture: at most ${num(best, 1)}:1 over any part of it here${needed !== void 0 ? `, and ${num(needed)}:1 is needed` : ""}.`,
6831
+ next: `set the background's ${code("tone")} so the text color follows the picture, or give the text a readable color.`
6832
+ };
6523
6833
  if (scrim !== void 0)
6524
6834
  return {
6525
6835
  message: `Text sits on this picture, so a scrim at ${num(scrim * 100)}% is drawn behind it to keep it readable${needed !== void 0 ? ` at ${num(needed)}:1` : ""}.`,
@@ -6726,6 +7036,18 @@ var iconDropped = (finding2) => {
6726
7036
  next: room ? "shorten the text or give the slide more room, or remove the icon." : "move the icon to an entry, metric or group it can mark, or remove it."
6727
7037
  };
6728
7038
  };
7039
+ var shapeOffSlide = (finding2) => ({
7040
+ message: /callout/.test(finding2.message) ? "An image callout lies wholly outside the slide, so it is not drawn." : "A shape lies wholly outside the slide, so it is not drawn.",
7041
+ next: "write its position as fractions (0.2 for 20%), or move it so part of it is on the slide."
7042
+ });
7043
+ var chartLabelCollision = () => ({
7044
+ message: "A reference label meets another label, a data line or a mark at both ends of its line.",
7045
+ next: "shorten the label, give the chart more room, or set the line where a bar or the area leaves room beside it."
7046
+ });
7047
+ var timelinePeriodShort = () => ({
7048
+ message: "A timeline period is too short to read: its duration gives it less room than its marker.",
7049
+ next: "give the timeline more room, or make its shortest period longer."
7050
+ });
6729
7051
  var arrangementAdapted = (finding2) => {
6730
7052
  const cards = /needs four entries/.test(finding2.message);
6731
7053
  return {
@@ -6803,7 +7125,7 @@ var centeredBody2 = (finding2) => {
6803
7125
  const blocks = measuredNumber(finding2, "blocks") ?? 1;
6804
7126
  return {
6805
7127
  message: `A centered ${what}${onSlide(finding2)} runs ${lines} line${lines === 1 ? "" : "s"} (${characters} characters)${blocks > 1 ? `, with ${blocks - 1} more like it` : ""}; each line starts at a different place, which is harder to read.`,
6806
- next: `set ${code('contentAlignment: "left"')} in the slide's design, or cut it to a line or two.`
7128
+ next: `set ${code('contentAlignment: "start"')} in the slide's design, or cut it to a line or two.`
6807
7129
  };
6808
7130
  };
6809
7131
  var tightSpacing2 = (finding2) => {
@@ -6904,6 +7226,17 @@ var codeHighlightRangeReversed = (finding2) => {
6904
7226
  next: `write [${found[3]}, ${found[4]}].`
6905
7227
  };
6906
7228
  };
7229
+ var variableGroupOmitted = (finding2) => {
7230
+ const ids = [...finding2.message.matchAll(/'([a-z][a-z0-9-]*)'/g)].map((found) => found[1]);
7231
+ const idParam = isRecord3(finding2.validation?.params) ? finding2.validation.params.id : void 0;
7232
+ const names2 = [...new Set(ids.length ? ids : typeof idParam === "string" ? [idParam] : [])];
7233
+ if (!names2.length) return void 0;
7234
+ const list = names2.length === 1 ? code(names2[0]) : `${names2.slice(0, -1).map((id) => code(id)).join(", ")} and ${code(names2.at(-1))}`;
7235
+ return {
7236
+ message: `A group${onSlide(finding2)} is left out when ${list} ${names2.length === 1 ? "has" : "have"} no value, with its pictures, cards and other text.`,
7237
+ next: `give ${names2.length === 1 ? "it" : "one of them"} a value to draw the group, or move what should always show out of the group.`
7238
+ };
7239
+ };
6907
7240
  var variableBuiltinMissing = (finding2, _context, helpers) => {
6908
7241
  const idParam = isRecord3(finding2.validation?.params) ? finding2.validation.params.id : void 0;
6909
7242
  const id = (typeof idParam === "string" ? idParam : void 0) ?? match(finding2.message, /^Built-in '(.+?)' has no value/)?.[1] ?? match(finding2.message, /'\{\{(.+?)\}\}'/)?.[1];
@@ -7002,6 +7335,9 @@ var AUDIT_TEXT = {
7002
7335
  "opf/region-full": regionFull,
7003
7336
  "opf/icon-dropped": iconDropped,
7004
7337
  "opf/arrangement-adapted": arrangementAdapted,
7338
+ "opf/chart-label-collision": chartLabelCollision,
7339
+ "opf/shape-off-slide": shapeOffSlide,
7340
+ "opf/timeline-period-short": timelinePeriodShort,
7005
7341
  "opf/layout-unplaced": layoutUnplaced,
7006
7342
  "opf/furniture-wraps": furnitureWraps,
7007
7343
  "opf/font-outside-scheme": fontOutsideScheme,
@@ -7013,6 +7349,7 @@ var AUDIT_TEXT = {
7013
7349
  "opf/code-highlight-out-of-range": codeHighlightOutOfRange,
7014
7350
  "opf/code-highlight-range-reversed": codeHighlightRangeReversed,
7015
7351
  "opf/variable-builtin-missing": variableBuiltinMissing,
7352
+ "opf/variable-group-omitted": variableGroupOmitted,
7016
7353
  "opf/duration-outside-narrative": durationOutsideNarrative2,
7017
7354
  "opf/narrative-duration-range": narrativeDurationRange,
7018
7355
  "opf/placeholder-text": placeholderText,
@@ -7037,10 +7374,10 @@ var jsonSyntax = (finding2) => ({
7037
7374
  next: helpAsNext(finding2, "fix the syntax error at the marked position.")
7038
7375
  });
7039
7376
  var duplicateKey = (finding2, _context, helpers) => {
7040
- const key2 = helpers.segments.at(-1) ?? unquote(match(finding2.message, /^Duplicate JSON property (".*")\.$/)?.[1]);
7377
+ const key3 = helpers.segments.at(-1) ?? unquote(match(finding2.message, /^Duplicate JSON property (".*")\.$/)?.[1]);
7041
7378
  const owner = placeWords(helpers.segments.slice(0, -1));
7042
7379
  return {
7043
- message: `${code(key2)} appears twice ${owner}. JSON keeps only the last value, so the earlier one is ignored.`,
7380
+ message: `${code(key3)} appears twice ${owner}. JSON keeps only the last value, so the earlier one is ignored.`,
7044
7381
  next: "keep one of them, or merge their values into one."
7045
7382
  };
7046
7383
  };
@@ -7083,8 +7420,8 @@ var captionUnsupportedPayload = (finding2) => {
7083
7420
  const kind = type ?? (/a group cannot carry one/.test(finding2.message) ? "group" : void 0);
7084
7421
  const is = kind ? kindPhrase(kind) : "not one of those";
7085
7422
  return {
7086
- message: `A ${code("caption")} belongs to one image, chart, table or video; this block is ${is}.`,
7087
- next: `put the ${code("caption")} on the image, chart, table or video it describes, or remove it.`
7423
+ message: `A ${code("caption")} belongs to one image, chart, table, video or diagram; this block is ${is}.`,
7424
+ next: `put the ${code("caption")} on the image, chart, table, video or diagram it describes, or remove it.`
7088
7425
  };
7089
7426
  };
7090
7427
  var imageOptionUnsupportedPayload = (finding2) => {
@@ -7130,6 +7467,10 @@ var shapeLinkHidden = () => ({
7130
7467
  message: "This shape is hidden, so its `link` can never be clicked.",
7131
7468
  next: "remove `hidden`, or remove the `link`."
7132
7469
  });
7470
+ var shapeAnchorSizeUnit = (finding2) => {
7471
+ const { key: key3, size } = params(finding2);
7472
+ return typeof key3 === "string" ? { message: `${code(`at.${key3}: ${String(size)}`)} is a fraction, not pixels.`, next: `rename ${code(key3)} to ${code(`${key3}Px`)} if it is pixels.` } : void 0;
7473
+ };
7133
7474
  var shapeAnchorMissing = (finding2) => {
7134
7475
  const { id, known } = params(finding2);
7135
7476
  if (typeof id !== "string") return void 0;
@@ -7219,6 +7560,17 @@ var chartMappingUnknownColumn = (finding2) => {
7219
7560
  next: chooseNext(name, columns)
7220
7561
  };
7221
7562
  };
7563
+ var chartReferenceAxisUnavailable = () => ({
7564
+ message: "This reference uses a secondary value axis that the chart does not have.",
7565
+ next: "use the value axis, or put a line series on a combo chart's secondary axis."
7566
+ });
7567
+ var chartReferenceUnsupportedType = (finding2) => {
7568
+ const type = match(finding2.message, /a '(.+?)' chart has none/)?.[1];
7569
+ return {
7570
+ message: type ? `A ${code(type)} chart cannot draw reference lines: it has no single value axis.` : "This chart type cannot draw reference lines: it has no single value axis.",
7571
+ next: "remove `referenceLines`, or use a column, bar, line, line-with-markers, area or combo chart."
7572
+ };
7573
+ };
7222
7574
  var numberFormatInvalid = (finding2, _context, helpers) => {
7223
7575
  const value = helpers.valueAt(helpers.segments);
7224
7576
  const reason = match(finding2.message, /^Number format '.*?' ((?:needs|scales|has|uses|asks|allows|is)\b.+)$/)?.[1];
@@ -7603,6 +7955,7 @@ var FORMAT_TEXT = {
7603
7955
  "opf/shape-adjust-unknown": shapeAdjustUnknown,
7604
7956
  "opf/shape-adjust-range": shapeAdjustRange,
7605
7957
  "opf/shape-link-hidden": shapeLinkHidden,
7958
+ "opf/shape-anchor-size-unit": shapeAnchorSizeUnit,
7606
7959
  "opf/shape-anchor-missing": shapeAnchorMissing,
7607
7960
  "opf/connector-end-missing": connectorEndMissing,
7608
7961
  "opf/layout-placeholder-group": layoutPlaceholderGroup,
@@ -7610,6 +7963,8 @@ var FORMAT_TEXT = {
7610
7963
  "opf/dataset-field-unknown": datasetFieldUnknown,
7611
7964
  "opf/data-column-duplicate": dataColumnDuplicate,
7612
7965
  "opf/chart-mapping-unknown-column": chartMappingUnknownColumn,
7966
+ "opf/chart-reference-axis-unavailable": chartReferenceAxisUnavailable,
7967
+ "opf/chart-reference-unsupported-type": chartReferenceUnsupportedType,
7613
7968
  "opf/number-format-invalid": numberFormatInvalid,
7614
7969
  "opf/variable-invalid-value": variableInvalidValue,
7615
7970
  "opf/variable-unknown-builtin": variableUnknownBuiltin,
@@ -7658,12 +8013,12 @@ var RULE_TEXT = Object.freeze(
7658
8013
  );
7659
8014
 
7660
8015
  // src/markdown/dialect.ts
7661
- var SLIDE_OPTION_KEYS = ["id", "type", "layout", "section", "tag", "hidden", "beat"];
8016
+ var SLIDE_OPTION_KEYS = ["id", "type", "layout", "section", "tag", "hidden", "beat", "language"];
7662
8017
  var BLOCK_OPTION_KEYS = ["id", "type", "as", "region"];
7663
8018
  var BLOCK_AS_VALUES = ["bullets", "video"];
7664
- var FENCE_KINDS = ["chart", "metric", "timeline", "mermaid", "opf-block", "opf-slide"];
8019
+ var FENCE_KINDS = ["chart", "metric", "timeline", "mermaid", "dot", "plantuml", "opf-block", "opf-slide"];
7665
8020
  var METRIC_KEYS = ["value", "label", "description", "unit", "delta", "trend", "sentiment"];
7666
- var FENCE_ATTRIBUTES = { chart: ["alt"], mermaid: ["alt"], timeline: ["name", "description"], code: ["title"] };
8021
+ var FENCE_ATTRIBUTES = { chart: ["alt"], mermaid: ["alt"], dot: ["alt"], plantuml: ["alt"], timeline: ["name", "description"], code: ["title"] };
7667
8022
  var SPAN_FLAGS = ["bold", "italic", "underline", "strike", "sup", "sub"];
7668
8023
  var SPAN_VALUES = ["color", "size", "font", "lang"];
7669
8024
  var LINE_KEYWORDS = ["Note:", "Notes:"];
@@ -7677,25 +8032,25 @@ var optionKeys = (kind) => kind === "block" ? BLOCK_OPTION_KEYS : SLIDE_OPTION_K
7677
8032
  var options = {
7678
8033
  "markdown/options-unknown-key": (finding2) => {
7679
8034
  const kind = quoted(finding2.message, /^Unknown (slide|block) option/) ?? "slide";
7680
- const key2 = quoted(finding2.message, /option "(.*)"\.$/) ?? "";
8035
+ const key3 = quoted(finding2.message, /option "(.*)"\.$/) ?? "";
7681
8036
  const guess = finding2.suggestions?.[0]?.value;
7682
8037
  const keys = optionKeys(kind).join(", ");
7683
8038
  return {
7684
- message: `${code(key2)} is not a ${kind} option.`,
8039
+ message: `${code(key3)} is not a ${kind} option.`,
7685
8040
  next: guess !== void 0 ? `did you mean ${code(guess)}? The keys are ${keys}. Anything else goes in an \`opf-${kind}\` fence.` : `use one of ${keys}. Anything else goes in an \`opf-${kind}\` fence.`
7686
8041
  };
7687
8042
  },
7688
8043
  "markdown/options-value": (finding2) => {
7689
8044
  if (/^hidden takes/.test(finding2.message)) return keep2(finding2, "write `hidden=true`, `hidden=false` or just `hidden`.");
7690
- const key2 = quoted(finding2.message, /^Option (\w+) needs a value/);
7691
- if (key2) return keep2(finding2, `write ${code(`${key2}=value`)}, for example ${code(key2 === "layout" ? "layout=title" : key2 === "id" ? "id=cover" : `${key2}=name`)}.`);
8045
+ const key3 = quoted(finding2.message, /^Option (\w+) needs a value/);
8046
+ if (key3) return keep2(finding2, `write ${code(`${key3}=value`)}, for example ${code(key3 === "layout" ? "layout=title" : key3 === "id" ? "id=cover" : `${key3}=name`)}.`);
7692
8047
  if (/^as takes/.test(finding2.message)) return keep2(finding2, "write `as=bullets` before a list or `as=video` before an image line.");
7693
8048
  return keep2(finding2, "put `as=bullets` before a list and `as=video` before an image line, or remove `as`.");
7694
8049
  },
7695
8050
  "markdown/options-syntax": (finding2) => keep2(finding2, `write options as ${code("key=value")} pairs, with text in double quotes: ${code('<!-- slide: layout=title section="Part 1" -->')}.`),
7696
8051
  "markdown/options-duplicate": (finding2) => {
7697
- const key2 = quoted(finding2.message, /^Option (\w+) is given twice/);
7698
- if (key2) return keep2(finding2, `keep one ${code(`${key2}=`)} in the comment.`);
8052
+ const key3 = quoted(finding2.message, /^Option (\w+) is given twice/);
8053
+ if (key3) return keep2(finding2, `keep one ${code(`${key3}=`)} in the comment.`);
7699
8054
  return keep2(finding2, "merge them into one.");
7700
8055
  },
7701
8056
  "markdown/options-orphan": (finding2) => keep2(finding2, "put the `<!-- block: \u2026 -->` comment directly before the block it describes, or remove it."),
@@ -7720,7 +8075,7 @@ var markdown = {
7720
8075
  "markdown/chart-attributes": (finding2) => keep2(finding2, 'write ```chart column alt="What the data shows" (`alt` is optional).'),
7721
8076
  "markdown/chart-data": wholeHelp,
7722
8077
  "markdown/chart-ragged": (finding2) => keep2(finding2, "give every row one value per column."),
7723
- "markdown/diagram-attributes": (finding2) => keep2(finding2, 'write ```mermaid alt="What the diagram shows" (`alt` is optional).'),
8078
+ "markdown/diagram-attributes": (finding2) => keep2(finding2, `write \`\`\`${/\b(dot|plantuml) fence/.exec(finding2.help ?? "")?.[1] ?? "mermaid"} alt="What the diagram shows" (\`alt\` is optional).`),
7724
8079
  "markdown/diagram-source": wholeHelp,
7725
8080
  "markdown/metric-block": (finding2) => keep2(finding2, `write ${code("key: value")} lines using ${METRIC_KEYS.join(", ")}; a value is plain text or a JSON string in double quotes.`),
7726
8081
  "markdown/timeline-attributes": (finding2) => keep2(finding2, 'write ```timeline name="Roadmap" description="\u2026" (both are optional).'),
@@ -7795,8 +8150,8 @@ var SOURCE_EXPLAIN = {
7795
8150
  "markdown/chart-attributes": entry("format", "error", "A chart fence has an attribute it cannot take.", "A chart fence takes `alt`, a text alternative in double quotes.", 'Write ```chart column alt="What the data shows".'),
7796
8151
  "markdown/chart-data": entry("format", "error", "A chart fence has no usable data.", "The chart is drawn from CSV with a header row, or a JSON object with `columns` and `rows`.", "Write CSV with a header row and at least one data row."),
7797
8152
  "markdown/chart-ragged": entry("format", "warning", "A chart row has a different number of values than the header.", "Missing cells plot as gaps.", "Give every row one value per column."),
7798
- "markdown/diagram-attributes": entry("format", "error", "A mermaid fence has an attribute it cannot take.", "A mermaid fence takes `alt`, a text alternative in double quotes.", 'Write ```mermaid alt="What the diagram shows".'),
7799
- "markdown/diagram-source": entry("format", "error", "A mermaid fence has no source.", "A diagram is drawn from its Mermaid source.", "Write the diagram between the fences, starting with its type (`flowchart LR`, `sequenceDiagram`, `mindmap`, ...)."),
8153
+ "markdown/diagram-attributes": entry("format", "error", "A diagram fence (mermaid, dot or plantuml) has an attribute it cannot take.", "A diagram fence takes `alt`, a text alternative in double quotes.", 'Write ```mermaid alt="What the diagram shows" (or ```dot alt=...).'),
8154
+ "markdown/diagram-source": entry("format", "error", "A diagram fence (mermaid, dot or plantuml) has no source.", "A diagram is drawn from its Mermaid, DOT or PlantUML source.", "Write the diagram between the fences: Mermaid starting with its type (`flowchart LR`, `sequenceDiagram`, `mindmap`, ...), DOT as one graph (`digraph { a -> b }`), PlantUML from `@startuml` to `@enduml`."),
7800
8155
  "markdown/metric-block": entry("format", "error", "A metric fence is malformed.", "A metric is `key: value` lines using a fixed set of keys.", "Write `value:` and, if you like, `label:`, `unit:`, `delta:`, `trend:` and `sentiment:`.", "```metric\nlabel: Revenue\n```", "```metric\nvalue: 42\nlabel: Revenue\n```"),
7801
8156
  "markdown/timeline-attributes": entry("format", "error", "A timeline fence has an attribute it cannot take.", "A timeline fence takes `name` and `description`.", "Remove the attribute, or use `name=` or `description=`."),
7802
8157
  "markdown/timeline-description": entry("format", "error", "An indented line has no event above it.", "A description belongs to the event before it.", "Put the event first, then its description indented below it."),
@@ -7823,6 +8178,7 @@ var ID = "an id of lowercase letters, digits and hyphens that starts with a lett
7823
8178
  var ID_NEXT = "use lowercase letters, digits and hyphens, and start with a letter.";
7824
8179
  var LANGUAGE = "a language tag like `en-US` or `de`";
7825
8180
  var PATTERN_PHRASES = Object.freeze({
8181
+ "\\S": { what: "a label with at least one non-whitespace character", next: "write a nonblank label, or omit it." },
7826
8182
  "^#(?:[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." },
7827
8183
  "^[a-z][a-z0-9-]*$": { what: ID, next: ID_NEXT },
7828
8184
  "^[a-z0-9][a-z0-9-]*$": { what: "an id of lowercase letters, digits and hyphens, like `my-chart`", next: ID_NEXT },
@@ -7974,6 +8330,9 @@ function describeSchema(finding2, context, helpers) {
7974
8330
  case "exclusiveMinimum":
7975
8331
  case "maximum":
7976
8332
  case "exclusiveMaximum": {
8333
+ const key3 = segments.at(-1);
8334
+ if (keyword === "maximum" && segments.at(-2) === "at" && (key3 === "width" || key3 === "height") && finding2.fixes?.some((fix) => fix.id === "rename"))
8335
+ return { message: `${cap(label)} is a fraction of the block, at most ${params2.limit}, but is ${describeValue(actual)}.`, next: `did you mean ${code(`${key3}Px`)}? Rename the key to keep the size in pixels.` };
7977
8336
  const bound = /minimum/i.test(keyword) ? "at least" : "at most";
7978
8337
  return {
7979
8338
  message: `${cap(label)} must be ${keyword.startsWith("exclusive") ? bound === "at least" ? "greater than" : "less than" : bound} ${params2.limit}, but is ${describeValue(actual)}.`,
@@ -8018,9 +8377,9 @@ function starterValue(document, segments, property) {
8018
8377
  // src/schema-fixes.ts
8019
8378
  var MAX_CHANGES = 5;
8020
8379
  var patch = (id, title, operations, safe2 = false) => ({ id, title, kind: "patch", safe: safe2, patch: operations });
8021
- var allowsKey = (document, segments, key2) => {
8380
+ var allowsKey = (document, segments, key3) => {
8022
8381
  try {
8023
- return schemaVariants(schemaAtPath(document, segments)).some((variant) => Object.hasOwn(variant.properties ?? {}, key2));
8382
+ return schemaVariants(schemaAtPath(document, segments)).some((variant) => Object.hasOwn(variant.properties ?? {}, key3));
8024
8383
  } catch {
8025
8384
  return false;
8026
8385
  }
@@ -8118,7 +8477,7 @@ function scriptProfile(presentation, slideIndex, options2, language) {
8118
8477
  }
8119
8478
  const slots = (role) => {
8120
8479
  const latin = options2.fontFamilies[role];
8121
- const slot = (key2) => !resolved || resolved.sources[key2] === "latin" || resolved.sources[key2] === "schemeFamily" ? latin : resolved[role][key2] ?? latin;
8480
+ const slot = (key3) => !resolved || resolved.sources[key3] === "latin" || resolved.sources[key3] === "schemeFamily" ? latin : resolved[role][key3] ?? latin;
8122
8481
  return { latin, eastAsian: slot("eastAsian"), complexScript: slot("complexScript") };
8123
8482
  };
8124
8483
  return {
@@ -8338,7 +8697,7 @@ function relax(value) {
8338
8697
  walk2(copy);
8339
8698
  return copy;
8340
8699
  }
8341
- function buildSlides(document, options2) {
8700
+ function buildSlides(document, options2, memo) {
8342
8701
  const slides = Array.isArray(document.slides) ? document.slides : [];
8343
8702
  return slides.map((slide, index) => {
8344
8703
  const path = pointer2("slides", index);
@@ -8356,7 +8715,7 @@ function buildSlides(document, options2) {
8356
8715
  });
8357
8716
  const design = lazy(() => resolveDesign(document, index, resolved()));
8358
8717
  const layout = lazy(() => resolved().options.layout);
8359
- const composed = lazy(() => {
8718
+ const compute = () => {
8360
8719
  const result = { layoutDiagnostics: [] };
8361
8720
  let fontFamilies;
8362
8721
  const compose = (input, withLayout) => {
@@ -8379,7 +8738,8 @@ function buildSlides(document, options2) {
8379
8738
  } else result.layoutError = error instanceof Error ? error.message : String(error);
8380
8739
  }
8381
8740
  return result;
8382
- });
8741
+ };
8742
+ const composed = lazy(() => memo ? memo(index, compute) : compute());
8383
8743
  const payloads = lazy(() => slidePayloads(slide, path));
8384
8744
  const texts = lazy(() => textValues(slide, path));
8385
8745
  const rtl = lazy(() => {
@@ -8404,6 +8764,214 @@ function buildSlides(document, options2) {
8404
8764
  });
8405
8765
  }
8406
8766
 
8767
+ // src/validation-cache.ts
8768
+ var MAX_ENTRIES = 64;
8769
+ var MAX_BYTES = 8 * 1024 * 1024;
8770
+ var MAX_KEY_BYTES = 2 * 1024 * 1024;
8771
+ function key2(value, opaque) {
8772
+ let bytes = 0;
8773
+ const seen = /* @__PURE__ */ new Set();
8774
+ const part = (text2) => {
8775
+ bytes += text2.length * 2;
8776
+ if (bytes > MAX_KEY_BYTES) throw new RangeError("Review cache key budget exceeded.");
8777
+ return text2;
8778
+ };
8779
+ const walk2 = (node, depth2) => {
8780
+ if (depth2 > 128) throw new RangeError("Review cache key depth exceeded.");
8781
+ if (node === null) return part("null;");
8782
+ if (node === void 0) return part("undefined;");
8783
+ if (typeof node === "string") return part(`s${JSON.stringify(node)}`);
8784
+ if (typeof node === "boolean") return part(node ? "true;" : "false;");
8785
+ if (typeof node === "number" && Number.isFinite(node)) return part(`n${Object.is(node, -0) ? "-0" : node};`);
8786
+ if (typeof node === "function" && opaque) {
8787
+ opaque.push(node);
8788
+ return part(`f${opaque.length};`);
8789
+ }
8790
+ if (typeof node !== "object" || seen.has(node) || !Array.isArray(node) && ![Object.prototype, null].includes(Object.getPrototypeOf(node))) throw new TypeError("Opaque review cache input.");
8791
+ seen.add(node);
8792
+ const descriptors = Object.getOwnPropertyDescriptors(node);
8793
+ 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.");
8794
+ if (Reflect.ownKeys(node).some((name) => typeof name === "symbol") || Object.values(descriptors).some((descriptor) => !("value" in descriptor))) throw new TypeError("Opaque review cache input.");
8795
+ 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("}");
8796
+ seen.delete(node);
8797
+ return result;
8798
+ };
8799
+ return walk2(value, 0);
8800
+ }
8801
+ var hasCallable = (value) => typeof value === "function" || !!value && typeof value === "object" && Object.values(value).some(hasCallable);
8802
+ function boundedDependencyInput(value) {
8803
+ let bytes = 0;
8804
+ const seen = /* @__PURE__ */ new Set();
8805
+ const charge = (count) => {
8806
+ bytes += count;
8807
+ if (bytes > MAX_KEY_BYTES) throw new RangeError("Dependency input budget exceeded.");
8808
+ };
8809
+ const walk2 = (node, depth2) => {
8810
+ if (depth2 > 128) throw new RangeError("Dependency input depth exceeded.");
8811
+ if (typeof node === "string") {
8812
+ charge(node.length * 2 + 8);
8813
+ return;
8814
+ }
8815
+ if (node === null || node === void 0 || typeof node === "boolean" || typeof node === "number" && Number.isFinite(node)) {
8816
+ charge(16);
8817
+ return;
8818
+ }
8819
+ if (typeof node !== "object" || seen.has(node)) throw new TypeError("Opaque dependency input.");
8820
+ const array = Array.isArray(node);
8821
+ if (array ? Object.getPrototypeOf(node) !== Array.prototype : ![Object.prototype, null].includes(Object.getPrototypeOf(node))) throw new TypeError("Opaque dependency prototype.");
8822
+ seen.add(node);
8823
+ charge(16);
8824
+ const length = array ? Object.getOwnPropertyDescriptor(node, "length")?.value : 0;
8825
+ if (array && (!Number.isSafeInteger(length) || length < 0 || length * 8 > MAX_KEY_BYTES - bytes)) throw new RangeError("Dependency input count exceeded.");
8826
+ const names2 = Reflect.ownKeys(node);
8827
+ if (names2.length * 8 > MAX_KEY_BYTES - bytes || array && names2.length !== length + 1) throw new RangeError("Dependency input count exceeded.");
8828
+ let index = 0;
8829
+ for (const name of names2) {
8830
+ if (typeof name !== "string") throw new TypeError("Opaque dependency key.");
8831
+ const descriptor = Object.getOwnPropertyDescriptor(node, name);
8832
+ if (!descriptor || !("value" in descriptor)) throw new TypeError("Accessor dependency input.");
8833
+ if (array && name === "length") continue;
8834
+ if (!descriptor.enumerable || array && name !== String(index++)) throw new TypeError("Non-JSON dependency input.");
8835
+ charge(name.length * 2 + 8);
8836
+ walk2(descriptor.value, depth2 + 1);
8837
+ }
8838
+ seen.delete(node);
8839
+ };
8840
+ try {
8841
+ walk2(value, 0);
8842
+ return true;
8843
+ } catch {
8844
+ return false;
8845
+ }
8846
+ }
8847
+ function upstreamKey(slide, raw, conservative) {
8848
+ try {
8849
+ if (conservative || lonePayload(slide)?.field === "text") return raw;
8850
+ const notes = [];
8851
+ walkCitationRuns(slide, "", (entry2) => {
8852
+ notes.push([entry2.path, entry2.cite, entry2.footnote]);
8853
+ });
8854
+ return key2(["non-message-upstream", slide.section, slide.design, slide.layout, notes]);
8855
+ } catch {
8856
+ return raw;
8857
+ }
8858
+ }
8859
+ function snapshotValue(value) {
8860
+ try {
8861
+ let candidate = value;
8862
+ const rootDescriptors = Object.getOwnPropertyDescriptors(value);
8863
+ const composition = rootDescriptors.composition;
8864
+ if (composition && "value" in composition && composition.value && Object.hasOwn(composition.value, HALF_STEPPED)) {
8865
+ const marker = Object.getOwnPropertyDescriptor(composition.value, HALF_STEPPED);
8866
+ const paths = marker && "value" in marker ? marker.value : void 0;
8867
+ if (marker?.enumerable && paths && typeof paths === "object" && Object.getPrototypeOf(paths) === Set.prototype && Reflect.ownKeys(paths).length === 0 && Array.from(Set.prototype.values.call(paths)).every((path) => typeof path === "string")) {
8868
+ const descriptors = Object.getOwnPropertyDescriptors(composition.value);
8869
+ Reflect.deleteProperty(descriptors, HALF_STEPPED);
8870
+ rootDescriptors.composition = { ...composition, value: Object.create(Object.getPrototypeOf(composition.value), descriptors) };
8871
+ candidate = Object.create(Object.getPrototypeOf(value), rootDescriptors);
8872
+ }
8873
+ }
8874
+ const encoded = key2(candidate);
8875
+ return { value: structuredClone(candidate), bytes: encoded.length * 4 + 256 };
8876
+ } catch {
8877
+ return void 0;
8878
+ }
8879
+ }
8880
+ var ValidationCompositionCache = class {
8881
+ snapshot;
8882
+ entries = /* @__PURE__ */ new Map();
8883
+ valueBytes = 0;
8884
+ get info() {
8885
+ return { entries: this.entries.size, bytes: (this.snapshot?.bytes ?? 0) + this.valueBytes, maxEntries: MAX_ENTRIES, maxBytes: MAX_BYTES };
8886
+ }
8887
+ clear() {
8888
+ this.snapshot = void 0;
8889
+ this.entries.clear();
8890
+ this.valueBytes = 0;
8891
+ }
8892
+ drop(index) {
8893
+ const entry2 = this.entries.get(index);
8894
+ if (entry2) this.valueBytes -= entry2.bytes;
8895
+ this.entries.delete(index);
8896
+ }
8897
+ trim() {
8898
+ while (this.entries.size > MAX_ENTRIES || this.info.bytes > MAX_BYTES) {
8899
+ const oldest = this.entries.keys().next().value;
8900
+ if (oldest === void 0) break;
8901
+ this.drop(oldest);
8902
+ }
8903
+ }
8904
+ begin(document, options2) {
8905
+ let next;
8906
+ try {
8907
+ if (![Object.prototype, null].includes(Object.getPrototypeOf(document)) || Reflect.ownKeys(document).length !== Object.keys(document).length || Object.values(Object.getOwnPropertyDescriptors(document)).some((descriptor) => !("value" in descriptor))) throw new TypeError("Non-JSON review document.");
8908
+ const { slides, datasets, ...metadata } = document;
8909
+ const opaque = [];
8910
+ const ids = slides.map((slide) => slide.id);
8911
+ const rawContext = key2([metadata, ids, options2], opaque);
8912
+ const raw = slides.map((slide) => key2(slide));
8913
+ const inlined = datasets ? inlineDatasets({ datasets, slides }).slides : slides;
8914
+ const data = datasets ? inlined.map((slide) => key2(slide)) : raw;
8915
+ const otherOptions = Object.fromEntries(Object.entries(options2).filter(([name]) => name !== "fonts"));
8916
+ const conservative = metadata.variables !== void 0 || metadata.template === true || options2.values !== void 0 || options2.template !== void 0 || hasCallable(metadata) || hasCallable(otherOptions);
8917
+ const upstream = slides.map((slide, i) => upstreamKey(slide, raw[i], conservative));
8918
+ const bytes = 256 + rawContext.length * 2 + raw.reduce((sum, text2) => sum + text2.length * 2 + 32, 0) + (data === raw ? 0 : data.reduce((sum, text2) => sum + text2.length * 2 + 16, 0)) + upstream.reduce((sum, text2, i) => sum + (text2 === raw[i] ? 16 : text2.length * 2 + 16), 0) + opaque.length * 16;
8919
+ if (bytes > MAX_KEY_BYTES) throw new RangeError("Review cache shared key budget exceeded.");
8920
+ let context = rawContext;
8921
+ if (!conservative && metadata.template === void 0) {
8922
+ let nameUnused = false;
8923
+ try {
8924
+ if (boundedDependencyInput(document)) {
8925
+ key2(document);
8926
+ nameUnused = !hasBuiltinDependency(document, "deck.name");
8927
+ }
8928
+ } catch {
8929
+ }
8930
+ if (nameUnused) {
8931
+ const { name: _name, ...geometryMetadata } = metadata;
8932
+ context = key2([geometryMetadata, ids, options2], []);
8933
+ }
8934
+ }
8935
+ const previous = this.snapshot;
8936
+ const same = previous?.context === context && previous.opaque.length === opaque.length && opaque.every((value, i) => value === previous.opaque[i]);
8937
+ if (!same) this.clear();
8938
+ let prefixEqual = !!same;
8939
+ const prefix = upstream.map((text2, i) => {
8940
+ prefixEqual = prefixEqual && text2 === previous?.upstream[i];
8941
+ return prefixEqual && previous?.prefix[i] || /* @__PURE__ */ Symbol();
8942
+ });
8943
+ next = { context, opaque, raw, data, upstream, prefix, bytes };
8944
+ } catch {
8945
+ this.clear();
8946
+ return void 0;
8947
+ }
8948
+ this.snapshot = next;
8949
+ for (const [i, entry2] of this.entries) if (entry2.prefix !== next.prefix[i] || entry2.data !== next.data[i]) this.drop(i);
8950
+ this.trim();
8951
+ return (index, compute) => {
8952
+ if (this.snapshot !== next) return compute();
8953
+ const hit = this.entries.get(index);
8954
+ if (hit) {
8955
+ this.entries.delete(index);
8956
+ this.entries.set(index, hit);
8957
+ return structuredClone(hit.value);
8958
+ }
8959
+ const value = compute();
8960
+ const saved = !value.layoutError && !value.layoutDiagnostics.some((entry2) => entry2.strict) && snapshotValue(value);
8961
+ const data = next.data[index], prefix = next.prefix[index];
8962
+ if (saved && data !== void 0 && prefix !== void 0 && this.snapshot === next) {
8963
+ const bytes = saved.bytes + data.length * 2 + 64;
8964
+ if (bytes + next.bytes <= MAX_BYTES) {
8965
+ this.entries.set(index, { prefix, data, value: saved.value, bytes });
8966
+ this.valueBytes += bytes;
8967
+ this.trim();
8968
+ }
8969
+ }
8970
+ return value;
8971
+ };
8972
+ }
8973
+ };
8974
+
8407
8975
  // src/validator.ts
8408
8976
  var SEVERITIES = ["error", "warning", "info"];
8409
8977
  var OPTION_KEYS = ["only", "ignore", "severity", "ignorePaths", "catalogs", "contracts", "thresholds", "fonts", "chartPalette", "template", "values"];
@@ -8441,7 +9009,7 @@ function names(list, what) {
8441
9009
  }
8442
9010
  function resolveOptions(options2) {
8443
9011
  if (!isObject2(options2)) throw new TypeError("Validate options must be an object.");
8444
- for (const key2 of Object.keys(options2)) if (!OPTION_KEYS.includes(key2)) throw new TypeError(`Unknown validate option ${JSON.stringify(key2)}. Options: ${OPTION_KEYS.join(", ")}.`);
9012
+ for (const key3 of Object.keys(options2)) if (!OPTION_KEYS.includes(key3)) throw new TypeError(`Unknown validate option ${JSON.stringify(key3)}. Options: ${OPTION_KEYS.join(", ")}.`);
8445
9013
  checkDocumentOptions(options2);
8446
9014
  const only = names(options2.only, "only");
8447
9015
  const ignore = names(options2.ignore, "ignore");
@@ -8470,10 +9038,10 @@ function resolveOptions(options2) {
8470
9038
  const thresholds = { ...DEFAULT_VALIDATION_THRESHOLDS };
8471
9039
  if (options2.thresholds !== void 0) {
8472
9040
  if (!isObject2(options2.thresholds)) throw new TypeError("Validate thresholds must be an object.");
8473
- for (const [key2, value] of Object.entries(options2.thresholds)) {
8474
- if (!(key2 in DEFAULT_VALIDATION_THRESHOLDS)) throw new TypeError(`Unknown validate threshold ${JSON.stringify(key2)}. Thresholds: ${Object.keys(DEFAULT_VALIDATION_THRESHOLDS).join(", ")}.`);
8475
- if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) throw new TypeError(`Validate threshold ${key2} must be a positive number.`);
8476
- thresholds[key2] = value;
9041
+ for (const [key3, value] of Object.entries(options2.thresholds)) {
9042
+ if (!(key3 in DEFAULT_VALIDATION_THRESHOLDS)) throw new TypeError(`Unknown validate threshold ${JSON.stringify(key3)}. Thresholds: ${Object.keys(DEFAULT_VALIDATION_THRESHOLDS).join(", ")}.`);
9043
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) throw new TypeError(`Validate threshold ${key3} must be a positive number.`);
9044
+ thresholds[key3] = value;
8477
9045
  }
8478
9046
  }
8479
9047
  if (options2.fonts !== void 0) {
@@ -8538,7 +9106,7 @@ function syntaxReport(parsed, run) {
8538
9106
  const tally = counts(findings);
8539
9107
  return { valid: tally.error === 0, schemaValid: null, findings, counts: tally, checks };
8540
9108
  }
8541
- function validateDocument(document, run, parsed) {
9109
+ function validateDocument(document, run, parsed, cache) {
8542
9110
  const engine = validateAgainstSchema(document, "presentation", { template: run.options.template, values: run.options.values, ...run.options.catalogs ? { catalogs: run.options.catalogs } : {} });
8543
9111
  const schemaValid = engine.errors.length === 0;
8544
9112
  const slides = isObject2(document) && Array.isArray(document.slides) ? document.slides : [];
@@ -8567,7 +9135,7 @@ function validateDocument(document, run, parsed) {
8567
9135
  const doc = document;
8568
9136
  const context = {
8569
9137
  document: doc,
8570
- slides: buildSlides(doc, run.options),
9138
+ slides: buildSlides(doc, run.options, cache?.begin(doc, run.options)),
8571
9139
  thresholds: run.thresholds,
8572
9140
  options: run.options,
8573
9141
  chartPalette: run.chartPalette,
@@ -8646,12 +9214,34 @@ function validateDocument(document, run, parsed) {
8646
9214
  };
8647
9215
  }
8648
9216
  function validate(input, options2 = {}) {
9217
+ return validateInput(input, options2);
9218
+ }
9219
+ function validateInput(input, options2, cache) {
8649
9220
  const run = resolveOptions(options2);
8650
9221
  if (typeof input === "string") {
8651
9222
  const parsed = parseSource(input);
8652
- return parsed.syntax.length ? syntaxReport(parsed, run) : validateDocument(parsed.value, run, parsed);
9223
+ return parsed.syntax.length ? syntaxReport(parsed, run) : validateDocument(parsed.value, run, parsed, cache);
8653
9224
  }
8654
- return validateDocument(input, run);
9225
+ return validateDocument(input, run, void 0, cache);
9226
+ }
9227
+ function createValidator() {
9228
+ const cache = new ValidationCompositionCache();
9229
+ return {
9230
+ validate(input, options2 = {}) {
9231
+ try {
9232
+ const report2 = validateInput(input, options2, cache);
9233
+ if (!report2.schemaValid) cache.clear();
9234
+ return report2;
9235
+ } catch (error) {
9236
+ cache.clear();
9237
+ throw error;
9238
+ }
9239
+ },
9240
+ clear: () => cache.clear(),
9241
+ get cache() {
9242
+ return cache.info;
9243
+ }
9244
+ };
8655
9245
  }
8656
9246
  function assertValid(value, options2 = {}) {
8657
9247
  if (typeof value === "string") throw new TypeError("assertValid takes a parsed presentation. Use validate(text) for JSON text.");
@@ -8681,4 +9271,4 @@ function assertValidCatalogRecord(kind, value) {
8681
9271
  if (!report2.valid) throw new OPFValidationError(report2);
8682
9272
  }
8683
9273
 
8684
- 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, describeField, describeFinding, distance2 as 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 };
9274
+ 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, distance2 as 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 };