@beyondwork/docx-react-component 1.0.123 → 1.0.125

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 (101) hide show
  1. package/dist/api/public-types.cjs +147 -35
  2. package/dist/api/public-types.d.cts +2 -2
  3. package/dist/api/public-types.d.ts +2 -2
  4. package/dist/api/public-types.js +3 -3
  5. package/dist/api/v3.cjs +797 -99
  6. package/dist/api/v3.d.cts +3 -3
  7. package/dist/api/v3.d.ts +3 -3
  8. package/dist/api/v3.js +10 -10
  9. package/dist/{canonical-document-CG2TgAzj.d.cts → canonical-document-CXCFCbAz.d.cts} +2 -0
  10. package/dist/{canonical-document-CG2TgAzj.d.ts → canonical-document-CXCFCbAz.d.ts} +2 -0
  11. package/dist/{chunk-PFYUJU3Q.js → chunk-2QL5DAKF.js} +98 -43
  12. package/dist/{chunk-4IPEZYQX.js → chunk-4EENH4FG.js} +1 -1
  13. package/dist/{chunk-BOHHIVQ2.js → chunk-4G3OS2H6.js} +3 -3
  14. package/dist/{chunk-MB7RJBSN.js → chunk-4YJVRIUB.js} +58 -19
  15. package/dist/{chunk-FNWKE74J.js → chunk-5DGKFNQT.js} +5 -1
  16. package/dist/{chunk-RSYN6FTS.js → chunk-6F5QW44A.js} +2 -2
  17. package/dist/{chunk-KOHQFZMM.js → chunk-BYSRJ4FE.js} +1 -1
  18. package/dist/{chunk-H6IL5ABU.js → chunk-CXSYRB37.js} +64 -20
  19. package/dist/{chunk-32ZAOQ54.js → chunk-D5HYZQTG.js} +1 -1
  20. package/dist/{chunk-ML4A4WUN.js → chunk-ESJ2MES5.js} +1 -1
  21. package/dist/{chunk-H2YQKA55.js → chunk-JN444Z5S.js} +505 -44
  22. package/dist/{chunk-IR7QV2BX.js → chunk-KV435YXO.js} +2 -2
  23. package/dist/{chunk-N4VIXI2Z.js → chunk-MWSBGJQO.js} +137 -18
  24. package/dist/{chunk-UHJLCPLU.js → chunk-OHTK7F3F.js} +96 -13
  25. package/dist/{chunk-SGSJ4DQA.js → chunk-QT3LX4FA.js} +321 -51
  26. package/dist/{chunk-NNPVA5VL.js → chunk-TQDQU2E3.js} +2 -2
  27. package/dist/{chunk-E5IBDE5E.js → chunk-V6XVZFFH.js} +2 -2
  28. package/dist/{chunk-RWERZWHR.js → chunk-YD2JE54B.js} +1 -1
  29. package/dist/{chunk-ZRHLLPSJ.js → chunk-YHZHPXDB.js} +85 -18
  30. package/dist/{chunk-HXHQA4BU.js → chunk-YIYM4ZAP.js} +1 -1
  31. package/dist/{chunk-LGWNN3L2.js → chunk-ZDOAUP3V.js} +2 -2
  32. package/dist/compare.d.cts +1 -1
  33. package/dist/compare.d.ts +1 -1
  34. package/dist/core/commands/formatting-commands.d.cts +2 -2
  35. package/dist/core/commands/formatting-commands.d.ts +2 -2
  36. package/dist/core/commands/image-commands.cjs +65 -20
  37. package/dist/core/commands/image-commands.d.cts +2 -2
  38. package/dist/core/commands/image-commands.d.ts +2 -2
  39. package/dist/core/commands/image-commands.js +5 -5
  40. package/dist/core/commands/section-layout-commands.d.cts +2 -2
  41. package/dist/core/commands/section-layout-commands.d.ts +2 -2
  42. package/dist/core/commands/style-commands.d.cts +2 -2
  43. package/dist/core/commands/style-commands.d.ts +2 -2
  44. package/dist/core/commands/table-structure-commands.cjs +65 -20
  45. package/dist/core/commands/table-structure-commands.d.cts +2 -2
  46. package/dist/core/commands/table-structure-commands.d.ts +2 -2
  47. package/dist/core/commands/table-structure-commands.js +4 -4
  48. package/dist/core/commands/text-commands.cjs +66 -21
  49. package/dist/core/commands/text-commands.d.cts +2 -2
  50. package/dist/core/commands/text-commands.d.ts +2 -2
  51. package/dist/core/commands/text-commands.js +5 -5
  52. package/dist/core/selection/mapping.d.cts +2 -2
  53. package/dist/core/selection/mapping.d.ts +2 -2
  54. package/dist/core/state/editor-state.d.cts +2 -2
  55. package/dist/core/state/editor-state.d.ts +2 -2
  56. package/dist/index.cjs +1347 -191
  57. package/dist/index.d.cts +5 -5
  58. package/dist/index.d.ts +5 -5
  59. package/dist/index.js +39 -21
  60. package/dist/io/docx-session.cjs +57 -18
  61. package/dist/io/docx-session.d.cts +4 -4
  62. package/dist/io/docx-session.d.ts +4 -4
  63. package/dist/io/docx-session.js +4 -4
  64. package/dist/legal.cjs +42 -10
  65. package/dist/legal.d.cts +1 -1
  66. package/dist/legal.d.ts +1 -1
  67. package/dist/legal.js +3 -3
  68. package/dist/{loader-D9y4ZRjj.d.ts → loader-B1MxvbeV.d.ts} +3 -3
  69. package/dist/{loader-D9KCtj4m.d.cts → loader-CJXsswcd.d.cts} +3 -3
  70. package/dist/{public-types-DajNGKV4.d.cts → public-types-BEGhv2YR.d.ts} +108 -6
  71. package/dist/{public-types-CNnMHZM9.d.ts → public-types-DrhlQ5Zy.d.cts} +108 -6
  72. package/dist/public-types.cjs +147 -35
  73. package/dist/public-types.d.cts +2 -2
  74. package/dist/public-types.d.ts +2 -2
  75. package/dist/public-types.js +3 -3
  76. package/dist/runtime/collab.d.cts +3 -3
  77. package/dist/runtime/collab.d.ts +3 -3
  78. package/dist/runtime/document-runtime.cjs +685 -98
  79. package/dist/runtime/document-runtime.d.cts +2 -2
  80. package/dist/runtime/document-runtime.d.ts +2 -2
  81. package/dist/runtime/document-runtime.js +14 -14
  82. package/dist/{session-DyQGlryH.d.cts → session-Bp3zqnkS.d.cts} +3 -3
  83. package/dist/{session-DEmaOEjA.d.ts → session-xMOU_NtL.d.ts} +3 -3
  84. package/dist/session.cjs +57 -18
  85. package/dist/session.d.cts +5 -5
  86. package/dist/session.d.ts +5 -5
  87. package/dist/session.js +5 -5
  88. package/dist/tailwind.cjs +238 -73
  89. package/dist/tailwind.d.cts +2 -2
  90. package/dist/tailwind.d.ts +2 -2
  91. package/dist/tailwind.js +7 -7
  92. package/dist/{types-DjJNaE9c.d.ts → types-BFT8536T.d.ts} +2 -2
  93. package/dist/{types-CxE1aZiv.d.cts → types-DDPxEygX.d.cts} +2 -2
  94. package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +3 -3
  95. package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +3 -3
  96. package/dist/ui-tailwind/editor-surface/search-plugin.js +4 -4
  97. package/dist/ui-tailwind.cjs +238 -73
  98. package/dist/ui-tailwind.d.cts +3 -3
  99. package/dist/ui-tailwind.d.ts +3 -3
  100. package/dist/ui-tailwind.js +7 -7
  101. package/package.json +2 -2
package/dist/api/v3.cjs CHANGED
@@ -13436,7 +13436,7 @@ function createParagraphEditableTarget(paragraph, kind, storyKey, blockPath, tar
13436
13436
  context: { storyKey, insideSdt: contentControl !== void 0 },
13437
13437
  ...tableTarget
13438
13438
  }) : void 0;
13439
- const listAddress = tableIdentity === void 0 && paragraph.numbering !== void 0 ? createCanonicalAddress({
13439
+ const listAddress = paragraph.numbering !== void 0 ? createCanonicalAddress({
13440
13440
  addressKind: "list-item-text",
13441
13441
  storyKey,
13442
13442
  staleCheckKind: "paragraph",
@@ -13470,6 +13470,7 @@ function createParagraphEditableTarget(paragraph, kind, storyKey, blockPath, tar
13470
13470
  ...contentControl !== void 0 ? { contentControl } : {},
13471
13471
  ...tableIdentity !== void 0 ? { table: tableIdentity } : {},
13472
13472
  ...editableOwner !== void 0 ? { editableOwner } : {},
13473
+ ...listAddress !== void 0 ? { listAddress } : {},
13473
13474
  ...tableIdentity !== void 0 ? {
13474
13475
  canonicalAddress: createTableTargetCanonicalAddress(
13475
13476
  tableIdentity,
@@ -14333,6 +14334,9 @@ function validateEditableTargetRef(value, path = "$") {
14333
14334
  if (record.canonicalAddress !== void 0) {
14334
14335
  validateTargetCanonicalAddress(record.canonicalAddress, `${path}.canonicalAddress`, issues);
14335
14336
  }
14337
+ if (record.listAddress !== void 0) {
14338
+ validateTargetCanonicalAddress(record.listAddress, `${path}.listAddress`, issues);
14339
+ }
14336
14340
  const staleCheck = asPlainObject(record.staleCheck, `${path}.staleCheck`, issues);
14337
14341
  if (staleCheck) {
14338
14342
  if (staleCheck.paragraphTextHash !== void 0) {
@@ -18405,6 +18409,8 @@ function resolveContentType(path, contentTypes) {
18405
18409
  // src/io/ooxml/parse-bookmark-references.ts
18406
18410
  var HYPERLINK_ANCHOR_RE = /<(?:\w+:)?hyperlink\b[^>]*\bw:anchor\s*=\s*"([^"]*)"/gi;
18407
18411
  var INSTR_TEXT_RE = /<(?:\w+:)?instrText\b[^>]*>([\s\S]*?)<\/(?:\w+:)?instrText>/gi;
18412
+ var FLD_SIMPLE_INSTR_DOUBLE_RE = /<(?:\w+:)?fldSimple\b[^>]*?\b(?:w:)?instr\s*=\s*"([^"]*)"/gi;
18413
+ var FLD_SIMPLE_INSTR_SINGLE_RE = /<(?:\w+:)?fldSimple\b[^>]*?\b(?:w:)?instr\s*=\s*'([^']*)'/gi;
18408
18414
  var TOC_FIELD_RE = /\bTOC\b/;
18409
18415
  var REFLIKE_FIELD_RE = /\b(?:HYPERLINK|REF|PAGEREF|NOTEREF)\s+([A-Za-z0-9_:.\-]+)/g;
18410
18416
  var DATA_BINDING_RE = /<(?:\w+:)?dataBinding\b/i;
@@ -18424,12 +18430,21 @@ function scanBookmarkReferences(documentXml, callerAllowlist = []) {
18424
18430
  INSTR_TEXT_RE.lastIndex = 0;
18425
18431
  while ((m = INSTR_TEXT_RE.exec(documentXml)) !== null) {
18426
18432
  const instrText = m[1] ?? "";
18427
- if (TOC_FIELD_RE.test(instrText)) retainAllToc = true;
18428
- REFLIKE_FIELD_RE.lastIndex = 0;
18429
- let r;
18430
- while ((r = REFLIKE_FIELD_RE.exec(instrText)) !== null) {
18431
- if (r[1]) retained.add(r[1]);
18432
- }
18433
+ scanFieldInstruction(instrText, retained, () => {
18434
+ retainAllToc = true;
18435
+ });
18436
+ }
18437
+ FLD_SIMPLE_INSTR_DOUBLE_RE.lastIndex = 0;
18438
+ while ((m = FLD_SIMPLE_INSTR_DOUBLE_RE.exec(documentXml)) !== null) {
18439
+ scanFieldInstruction(decodeXmlAttribute(m[1] ?? ""), retained, () => {
18440
+ retainAllToc = true;
18441
+ });
18442
+ }
18443
+ FLD_SIMPLE_INSTR_SINGLE_RE.lastIndex = 0;
18444
+ while ((m = FLD_SIMPLE_INSTR_SINGLE_RE.exec(documentXml)) !== null) {
18445
+ scanFieldInstruction(decodeXmlAttribute(m[1] ?? ""), retained, () => {
18446
+ retainAllToc = true;
18447
+ });
18433
18448
  }
18434
18449
  retainRevisionBoundedBookmarks(documentXml, retained);
18435
18450
  return {
@@ -18438,6 +18453,17 @@ function scanBookmarkReferences(documentXml, callerAllowlist = []) {
18438
18453
  retainAll
18439
18454
  };
18440
18455
  }
18456
+ function scanFieldInstruction(instrText, retained, retainToc) {
18457
+ if (TOC_FIELD_RE.test(instrText)) retainToc();
18458
+ REFLIKE_FIELD_RE.lastIndex = 0;
18459
+ let r;
18460
+ while ((r = REFLIKE_FIELD_RE.exec(instrText)) !== null) {
18461
+ if (r[1]) retained.add(r[1]);
18462
+ }
18463
+ }
18464
+ function decodeXmlAttribute(value) {
18465
+ return value.replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
18466
+ }
18441
18467
  function retainRevisionBoundedBookmarks(documentXml, retained) {
18442
18468
  const starts = /* @__PURE__ */ new Map();
18443
18469
  BOOKMARK_START_RE.lastIndex = 0;
@@ -18789,18 +18815,23 @@ function parseNumberingXml(xml, context) {
18789
18815
  const abstractDefinitions = {};
18790
18816
  const instances = {};
18791
18817
  const numPicBullets = {};
18818
+ const topLevelOrdinals = /* @__PURE__ */ new Map();
18792
18819
  for (const child of numberingElement.children) {
18793
18820
  if (child.type !== "element") {
18794
18821
  continue;
18795
18822
  }
18796
- if (localName(child.name) === "numPicBullet") {
18823
+ const childName = localName(child.name);
18824
+ const childOrdinal = (topLevelOrdinals.get(childName) ?? 0) + 1;
18825
+ topLevelOrdinals.set(childName, childOrdinal);
18826
+ const childXmlPath = `/numbering[1]/${childName}[${childOrdinal}]`;
18827
+ if (childName === "numPicBullet") {
18797
18828
  const rawId = readStringAttr(child, "w:numPicBulletId");
18798
18829
  if (rawId) {
18799
- numPicBullets[rawId] = readNumPicBullet(child, rawId, context);
18830
+ numPicBullets[rawId] = readNumPicBullet(child, rawId, context, childXmlPath);
18800
18831
  }
18801
18832
  continue;
18802
18833
  }
18803
- switch (localName(child.name)) {
18834
+ switch (childName) {
18804
18835
  case "abstractNum": {
18805
18836
  const rawId = readStringAttr(child, "w:abstractNumId");
18806
18837
  if (!rawId) {
@@ -18820,7 +18851,7 @@ function parseNumberingXml(xml, context) {
18820
18851
  const numStyleLink = numStyleLinkEl ? readStringAttr(numStyleLinkEl, "w:val") : void 0;
18821
18852
  abstractDefinitions[abstractNumberingId] = {
18822
18853
  abstractNumberingId,
18823
- ...context?.partPath !== void 0 ? { sourceRef: createNumberingSourceRef(context.partPath, "abstractNum", rawId) } : {},
18854
+ ...context?.partPath !== void 0 ? { sourceRef: createNumberingSourceRef(context.partPath, "abstractNum", rawId, childXmlPath) } : {},
18824
18855
  levels: readLevels(child),
18825
18856
  ...nsid ? { nsid } : {},
18826
18857
  ...multiLevelType ? { multiLevelType } : {},
@@ -18840,7 +18871,7 @@ function parseNumberingXml(xml, context) {
18840
18871
  const numberingInstanceId = toCanonicalNumberingInstanceId(rawId);
18841
18872
  instances[numberingInstanceId] = {
18842
18873
  numberingInstanceId,
18843
- ...context?.partPath !== void 0 ? { sourceRef: createNumberingSourceRef(context.partPath, "num", rawId) } : {},
18874
+ ...context?.partPath !== void 0 ? { sourceRef: createNumberingSourceRef(context.partPath, "num", rawId, childXmlPath) } : {},
18844
18875
  abstractNumberingId: toCanonicalAbstractNumberingId(rawAbstractId),
18845
18876
  overrides: readOverrides(child)
18846
18877
  };
@@ -18854,15 +18885,16 @@ function parseNumberingXml(xml, context) {
18854
18885
  ...Object.keys(numPicBullets).length > 0 ? { numPicBullets } : {}
18855
18886
  };
18856
18887
  }
18857
- function createNumberingSourceRef(partPath, element, rawId) {
18888
+ function createNumberingSourceRef(partPath, element, rawId, xmlPath) {
18858
18889
  return {
18859
18890
  sourceId: `part:${partPath}#${element}:${rawId}`,
18860
18891
  partPath,
18861
18892
  storyKind: "numbering",
18862
- element
18893
+ element,
18894
+ ...xmlPath !== void 0 ? { xmlPath } : {}
18863
18895
  };
18864
18896
  }
18865
- function readNumPicBullet(node, numPicBulletId, context) {
18897
+ function readNumPicBullet(node, numPicBulletId, context, xmlPath) {
18866
18898
  let widthEmu;
18867
18899
  let heightEmu;
18868
18900
  let mediaId;
@@ -18925,6 +18957,7 @@ function readNumPicBullet(node, numPicBulletId, context) {
18925
18957
  }
18926
18958
  return {
18927
18959
  numPicBulletId,
18960
+ ...context?.partPath !== void 0 ? { sourceRef: createNumberingSourceRef(context.partPath, "numPicBullet", numPicBulletId, xmlPath) } : {},
18928
18961
  rawXml: serializeXmlElementToString(node),
18929
18962
  ...widthEmu !== void 0 ? { widthEmu } : {},
18930
18963
  ...heightEmu !== void 0 ? { heightEmu } : {},
@@ -22898,7 +22931,11 @@ function parseBodyChild(node, sourceXml, relationshipMap, relationships, mediaPa
22898
22931
  switch (localName(child.name)) {
22899
22932
  case "pPr":
22900
22933
  styleId = readParagraphStyleId(child);
22901
- numbering = readParagraphNumbering(child, sourcePartPath);
22934
+ numbering = readParagraphNumbering(
22935
+ child,
22936
+ sourcePartPath,
22937
+ `${sourceXmlPath}/pPr[${countPriorElementSiblingsByName(node, child) + 1}]`
22938
+ );
22902
22939
  alignment = readParagraphAlignment(child);
22903
22940
  spacing = readParagraphSpacing2(child);
22904
22941
  contextualSpacing = readOptionalOnOffParagraphProperty(child, "contextualSpacing");
@@ -23981,7 +24018,7 @@ function readParagraphStyleId(node) {
23981
24018
  }
23982
24019
  return void 0;
23983
24020
  }
23984
- function readParagraphNumbering(node, sourcePartPath) {
24021
+ function readParagraphNumbering(node, sourcePartPath, sourceXmlPath) {
23985
24022
  const numberingProperties = node.children.find(
23986
24023
  (child) => child.type === "element" && localName(child.name) === "numPr"
23987
24024
  );
@@ -24001,16 +24038,22 @@ function readParagraphNumbering(node, sourcePartPath) {
24001
24038
  }
24002
24039
  return {
24003
24040
  numberingInstanceId: toCanonicalNumberingInstanceId(rawInstanceId),
24004
- sourceRef: createElementSourceRef(sourcePartPath, "numPr", numberingProperties),
24041
+ sourceRef: createElementSourceRef(
24042
+ sourcePartPath,
24043
+ "numPr",
24044
+ numberingProperties,
24045
+ sourceXmlPath !== void 0 ? `${sourceXmlPath}/numPr[${countPriorElementSiblingsByName(node, numberingProperties) + 1}]` : void 0
24046
+ ),
24005
24047
  level: Number.parseInt(rawLevel, 10)
24006
24048
  };
24007
24049
  }
24008
- function createElementSourceRef(partPath, element, node) {
24050
+ function createElementSourceRef(partPath, element, node, xmlPath) {
24009
24051
  return {
24010
24052
  sourceId: `part:${partPath}#${element}:${node.start}`,
24011
24053
  partPath,
24012
24054
  storyKind: storyKindFromPartPath(partPath),
24013
24055
  element,
24056
+ ...xmlPath !== void 0 ? { xmlPath } : {},
24014
24057
  startOffset: node.start,
24015
24058
  endOffset: node.end
24016
24059
  };
@@ -32535,8 +32578,8 @@ async function computeStructuralHash(blocks) {
32535
32578
  }
32536
32579
 
32537
32580
  // src/runtime/layout/layout-engine-version.ts
32538
- var LAYOUT_ENGINE_VERSION = 87;
32539
- var LAYCACHE_SCHEMA_VERSION = 11;
32581
+ var LAYOUT_ENGINE_VERSION = 88;
32582
+ var LAYCACHE_SCHEMA_VERSION = 12;
32540
32583
 
32541
32584
  // src/runtime/prerender/customxml-cache.ts
32542
32585
  var LAYCACHE_NAMESPACE_NAME = "laycache";
@@ -34207,14 +34250,17 @@ function paragraphHasBookmarkId(paragraph, bookmarkId) {
34207
34250
  function commandActionHandleForAddress(commandFamily, address) {
34208
34251
  return address ? `scope-command:${commandFamily}:${address.addressKey}` : void 0;
34209
34252
  }
34210
- function withCommandAction(evidence, target) {
34211
- if (evidence.status !== "supported" || !target.canonicalAddress) return evidence;
34253
+ function withCommandAction(evidence, target, canonicalAddress = target.canonicalAddress) {
34254
+ if (evidence.status !== "supported" || !canonicalAddress) return evidence;
34212
34255
  return {
34213
34256
  ...evidence,
34214
- actionHandle: commandActionHandleForAddress(target.commandFamily, target.canonicalAddress),
34215
- canonicalAddress: target.canonicalAddress
34257
+ actionHandle: commandActionHandleForAddress(target.commandFamily, canonicalAddress),
34258
+ canonicalAddress
34216
34259
  };
34217
34260
  }
34261
+ function commandAddressForTarget(target, scopeKind) {
34262
+ return scopeKind === "list-item" && target.listAddress !== void 0 ? target.listAddress : target.canonicalAddress;
34263
+ }
34218
34264
  function runtimeTextCommandEvidence(target, workflowBlockers) {
34219
34265
  const shapeIssues = validateEditableTargetRef(target);
34220
34266
  if (shapeIssues.length > 0) {
@@ -34267,6 +34313,9 @@ var TABLE_TEXT_TARGET_KINDS2 = /* @__PURE__ */ new Set([
34267
34313
  var LIST_TEXT_TARGET_KINDS2 = /* @__PURE__ */ new Set([
34268
34314
  "paragraph-text",
34269
34315
  "sdt-paragraph-text",
34316
+ "table-cell-paragraph-text",
34317
+ "nested-table-cell-paragraph-text",
34318
+ "sdt-table-cell-paragraph-text",
34270
34319
  "secondary-story-paragraph-text"
34271
34320
  ]);
34272
34321
  function tableTextScopeReplacementPosture(target) {
@@ -34317,7 +34366,7 @@ function runtimeCommandEvidence(target, workflowBlockers, textCommand, scopeKind
34317
34366
  intents: commandIntentsForTarget(target, scopeKind),
34318
34367
  reason: textCommand.reason,
34319
34368
  ...textCommand.blockers ? { blockers: textCommand.blockers } : {}
34320
- }, target);
34369
+ }, target, commandAddressForTarget(target, scopeKind));
34321
34370
  }
34322
34371
  if (target.commandFamily === "comment-revision") {
34323
34372
  const isOpen = target.review?.status === "open";
@@ -36778,6 +36827,7 @@ function mergeLevelDefinition(base, override, startOverride, fallbackLevel) {
36778
36827
  );
36779
36828
  const runProperties = override?.runProperties ?? base?.runProperties;
36780
36829
  const restartAfterLevel = override?.restartAfterLevel ?? base?.restartAfterLevel;
36830
+ const picBulletId = override?.picBulletId ?? base?.picBulletId;
36781
36831
  return {
36782
36832
  level,
36783
36833
  format,
@@ -36788,7 +36838,8 @@ function mergeLevelDefinition(base, override, startOverride, fallbackLevel) {
36788
36838
  ...override?.suffix ?? base?.suffix ? { suffix: override?.suffix ?? base?.suffix } : {},
36789
36839
  ...paragraphGeometry ? { paragraphGeometry } : {},
36790
36840
  ...runProperties ? { runProperties } : {},
36791
- ...restartAfterLevel !== void 0 ? { restartAfterLevel } : {}
36841
+ ...restartAfterLevel !== void 0 ? { restartAfterLevel } : {},
36842
+ ...picBulletId !== void 0 ? { picBulletId } : {}
36792
36843
  };
36793
36844
  }
36794
36845
  function withDefaultStartAt(level) {
@@ -36916,7 +36967,7 @@ function resolveHangingWidth(indentation) {
36916
36967
  // src/runtime/formatting/numbering/prefix.ts
36917
36968
  function createNumberingPrefixResolver(catalog) {
36918
36969
  const sequenceStates = /* @__PURE__ */ new Map();
36919
- function resolveInternal(numbering, paragraph) {
36970
+ function resolveInternal(numbering, paragraph, options = {}) {
36920
36971
  const resolved = resolveNumberingDefinitionSet(
36921
36972
  catalog,
36922
36973
  paragraph?.numbering ?? numbering,
@@ -36929,29 +36980,44 @@ function createNumberingPrefixResolver(catalog) {
36929
36980
  if (!resolvedNumbering) {
36930
36981
  return null;
36931
36982
  }
36932
- const sequenceState = getSequenceState(sequenceStates, resolvedNumbering.numberingInstanceId);
36933
- advanceSequence(sequenceState, resolved.effectiveLevel.level, resolved.effectiveLevels);
36983
+ const advance = options.advance !== false;
36984
+ const sequenceState = getSequenceState(
36985
+ sequenceStates,
36986
+ resolvedNumbering.numberingInstanceId,
36987
+ { create: advance }
36988
+ );
36989
+ if (!sequenceState) {
36990
+ return null;
36991
+ }
36992
+ const workingState = advance ? sequenceState : cloneSequenceState(sequenceState);
36993
+ advanceSequence(workingState, resolved.effectiveLevel.level, resolved.effectiveLevels);
36994
+ const currentCounter = workingState.counters[resolved.effectiveLevel.level];
36934
36995
  const effectiveLevelDefs = resolved.effectiveLevel.isLegalNumbering ? new Map(
36935
36996
  Array.from(resolved.effectiveLevels.entries()).map(([level, definition]) => [
36936
36997
  level,
36937
36998
  { ...definition, format: "decimal" }
36938
36999
  ])
36939
37000
  ) : resolved.effectiveLevels;
37001
+ const picBulletId = resolved.effectiveLevel.picBulletId;
36940
37002
  const text = renderLevelText(
36941
37003
  resolved.effectiveLevel.text,
36942
- sequenceState.counters,
37004
+ workingState.counters,
36943
37005
  effectiveLevelDefs
36944
37006
  );
36945
- if (resolved.effectiveLevel.format !== "none" && text === null) {
37007
+ if (picBulletId == null && resolved.effectiveLevel.format !== "none" && text === null) {
36946
37008
  return null;
36947
37009
  }
36948
37010
  const visibleText = resolved.effectiveLevel.format === "none" ? null : text;
36949
- const picBulletId = resolved.effectiveLevel.picBulletId;
37011
+ const formatPosture = getNumberingFormatPosture(
37012
+ resolved.effectiveLevel.format,
37013
+ currentCounter
37014
+ );
36950
37015
  const picBulletMediaId = picBulletId != null ? catalog.numPicBullets?.[picBulletId]?.mediaId : void 0;
36951
37016
  return {
36952
37017
  text: visibleText,
36953
37018
  level: resolved.effectiveLevel.level,
36954
37019
  format: resolved.effectiveLevel.format,
37020
+ ...formatPosture !== void 0 ? { formatPosture } : {},
36955
37021
  startAt: resolved.effectiveLevel.startAt ?? DEFAULT_NUMBERING_START_AT,
36956
37022
  ...resolved.effectiveLevel.suffix ? { suffix: resolved.effectiveLevel.suffix } : {},
36957
37023
  ...resolved.effectiveLevel.paragraphStyleId ? { paragraphStyleId: resolved.effectiveLevel.paragraphStyleId } : {},
@@ -36962,23 +37028,26 @@ function createNumberingPrefixResolver(catalog) {
36962
37028
  };
36963
37029
  }
36964
37030
  return {
36965
- resolve(numbering) {
36966
- const result = resolveInternal(numbering);
37031
+ resolve(numbering, options) {
37032
+ const result = resolveInternal(numbering, void 0, options);
36967
37033
  return result?.text ?? null;
36968
37034
  },
36969
- resolveDetailed(numbering, paragraph) {
36970
- return resolveInternal(numbering, paragraph);
37035
+ resolveDetailed(numbering, paragraph, options) {
37036
+ return resolveInternal(numbering, paragraph, options);
36971
37037
  },
36972
- resolveParagraph(paragraph) {
36973
- return resolveInternal(paragraph.numbering, paragraph);
37038
+ resolveParagraph(paragraph, options) {
37039
+ return resolveInternal(paragraph.numbering, paragraph, options);
36974
37040
  }
36975
37041
  };
36976
37042
  }
36977
- function getSequenceState(states, numberingInstanceId) {
37043
+ function getSequenceState(states, numberingInstanceId, options = { create: true }) {
36978
37044
  const existing = states.get(numberingInstanceId);
36979
37045
  if (existing) {
36980
37046
  return existing;
36981
37047
  }
37048
+ if (options.create === false) {
37049
+ return { counters: [], lastLevel: null };
37050
+ }
36982
37051
  const created = {
36983
37052
  counters: [],
36984
37053
  lastLevel: null
@@ -36986,6 +37055,12 @@ function getSequenceState(states, numberingInstanceId) {
36986
37055
  states.set(numberingInstanceId, created);
36987
37056
  return created;
36988
37057
  }
37058
+ function cloneSequenceState(state) {
37059
+ return {
37060
+ counters: [...state.counters],
37061
+ lastLevel: state.lastLevel
37062
+ };
37063
+ }
36989
37064
  function advanceSequence(state, currentLevel, levelDefinitions) {
36990
37065
  for (let level = currentLevel + 1; level < state.counters.length; level += 1) {
36991
37066
  if (shouldResetDeeperLevel(level, currentLevel, levelDefinitions)) {
@@ -37017,6 +37092,25 @@ function shouldResetDeeperLevel(level, triggeringLevel, levelDefinitions) {
37017
37092
  function getLevelStartAt(level, levelDefinitions) {
37018
37093
  return levelDefinitions.get(level)?.startAt ?? DEFAULT_NUMBERING_START_AT;
37019
37094
  }
37095
+ function getNumberingFormatPosture(format, value) {
37096
+ if (!isSupportedNumberingFormat(format)) {
37097
+ return {
37098
+ status: "approximated",
37099
+ requestedFormat: format,
37100
+ renderedFormat: "decimal",
37101
+ reason: "unsupported-numbering-format-decimal-fallback"
37102
+ };
37103
+ }
37104
+ if (value !== void 0 && ((format === "upperRoman" || format === "lowerRoman") && (value <= 0 || value >= 4e3) || (format === "cardinalText" || format === "ordinalText") && (!Number.isInteger(value) || value < 1 || value > 999) || (format === "upperLetter" || format === "lowerLetter" || format === "chicago") && value < 1)) {
37105
+ return {
37106
+ status: "approximated",
37107
+ requestedFormat: format,
37108
+ renderedFormat: "decimal",
37109
+ reason: "numbering-format-range-decimal-fallback"
37110
+ };
37111
+ }
37112
+ return void 0;
37113
+ }
37020
37114
  function renderLevelText(text, counters, levelDefinitions) {
37021
37115
  if (!text) {
37022
37116
  return null;
@@ -37859,6 +37953,7 @@ function toNumberingLayoutInput(numbering) {
37859
37953
  associatedTabStops: toLayoutTabStops(numbering.geometry.tabStops, "numbering"),
37860
37954
  level: numbering.level,
37861
37955
  format: numbering.format,
37956
+ ...numbering.formatPosture !== void 0 ? { formatPosture: { ...numbering.formatPosture } } : {},
37862
37957
  startAt: numbering.startAt,
37863
37958
  ...numbering.isLegalNumbering ? { isLegalNumbering: true } : {},
37864
37959
  ...numbering.picBulletMediaId ? { pictureBulletMediaId: numbering.picBulletMediaId } : {}
@@ -38088,13 +38183,10 @@ var FormattingContextImpl = class {
38088
38183
  const effectiveNumbering = this.resolveEffectiveParagraphNumbering(para);
38089
38184
  if (!effectiveNumbering) return null;
38090
38185
  if (!emitGeometry) {
38091
- if (advance) this.numbering.resolve(effectiveNumbering);
38186
+ this.numbering.resolve(effectiveNumbering, { advance });
38092
38187
  return null;
38093
38188
  }
38094
- if (!advance) {
38095
- console.warn("[formatting-context] resolveParagraphNumbering({advance:false}) is not supported; counter always advances");
38096
- }
38097
- return this.numbering.resolveDetailed(effectiveNumbering, para);
38189
+ return this.numbering.resolveDetailed(effectiveNumbering, para, { advance });
38098
38190
  }
38099
38191
  resolveNumberingLayoutInput(para, options = {}) {
38100
38192
  return toNumberingLayoutInput(this.resolveParagraphNumbering(para, options));
@@ -39184,6 +39276,21 @@ function compileParagraphScope(entry, options = {}) {
39184
39276
  partial: true
39185
39277
  };
39186
39278
  }
39279
+ function storyKeyFromHandle(handle) {
39280
+ const target = handle.storyTarget;
39281
+ if (target.kind === "main") return "main";
39282
+ return null;
39283
+ }
39284
+ function textLeafEditableTargetHint(entry, semanticBlockRange) {
39285
+ const storyKey = storyKeyFromHandle(entry.handle);
39286
+ if (!storyKey) return void 0;
39287
+ return {
39288
+ kind: "text-leaf",
39289
+ storyKey,
39290
+ blockPath: `${storyKey}/block[${entry.blockIndex}]`,
39291
+ semanticBlockRange
39292
+ };
39293
+ }
39187
39294
  function compileParagraphReplacement(entry, proposed, options) {
39188
39295
  if (proposed.operation !== "replace" && proposed.operation !== "insert-before" && proposed.operation !== "insert-after") {
39189
39296
  return null;
@@ -39239,6 +39346,7 @@ function compileParagraphReplacement(entry, proposed, options) {
39239
39346
  {
39240
39347
  kind: stepKind,
39241
39348
  summary: stepKind === "text-replace" ? actionSummary : `suggest-mode ${actionSummary}`,
39349
+ ...textLeafEditableTargetHint(entry, blockRange) ? { editableTargetHint: textLeafEditableTargetHint(entry, blockRange) } : {},
39242
39350
  range: { from: operationRange.from, to: operationRange.to },
39243
39351
  text,
39244
39352
  ...proposed.formatting ? { formatting: proposed.formatting } : {}
@@ -39266,6 +39374,7 @@ function compileParagraphReplacement(entry, proposed, options) {
39266
39374
  {
39267
39375
  kind: "fragment-replace",
39268
39376
  summary: actionSummary,
39377
+ ...textLeafEditableTargetHint(entry, blockRange) ? { editableTargetHint: textLeafEditableTargetHint(entry, blockRange) } : {},
39269
39378
  range: { from: operationRange.from, to: operationRange.to },
39270
39379
  fragment
39271
39380
  }
@@ -42307,6 +42416,24 @@ function refusalIdForPostureBlocker(target, blocker2) {
42307
42416
  return "editable_target_opaque_content";
42308
42417
  case "synthetic-layout-cell":
42309
42418
  return "editable_target_synthetic_layout_cell";
42419
+ case "list-text-readback-missing":
42420
+ return "list_text_readback_missing";
42421
+ case "list-structure-command-missing":
42422
+ return "list_structure_command_missing";
42423
+ case "list-target-stale":
42424
+ return "list_target_stale";
42425
+ case "list-secondary-story-unsupported":
42426
+ return "list_secondary_story_unsupported";
42427
+ case "list-table-target-missing":
42428
+ return "list_table_target_missing";
42429
+ case "list-export-persistence-missing":
42430
+ return "list_export_persistence_missing";
42431
+ case "numbering-format-unsupported":
42432
+ return "numbering_format_unsupported";
42433
+ case "picture-bullet-preserve-only":
42434
+ return "picture_bullet_preserve_only";
42435
+ case "marker-geometry-unavailable":
42436
+ return "marker_geometry_unavailable";
42310
42437
  case "unmodeled-target":
42311
42438
  return target.commandFamily === "link-bookmark" ? "editable_target_linked_content_unmodeled" : "editable_target_unmodeled";
42312
42439
  }
@@ -42329,12 +42456,42 @@ function auditCategoryForPostureBlocker(target, blocker2) {
42329
42456
  return target.commandFamily === "link-bookmark" ? "linked-content" : "unsupported-command";
42330
42457
  case "synthetic-layout-cell":
42331
42458
  return "synthetic-cell";
42459
+ case "list-target-stale":
42460
+ return "stale-ref";
42461
+ case "picture-bullet-preserve-only":
42462
+ case "list-export-persistence-missing":
42463
+ return "preserve-only";
42464
+ case "list-text-readback-missing":
42465
+ case "list-structure-command-missing":
42466
+ case "list-secondary-story-unsupported":
42467
+ case "list-table-target-missing":
42468
+ case "numbering-format-unsupported":
42469
+ case "marker-geometry-unavailable":
42470
+ return "unsupported-command";
42332
42471
  }
42333
42472
  }
42334
42473
  function messageForPostureBlocker(blocker2) {
42335
42474
  switch (blocker2) {
42336
42475
  case "synthetic-layout-cell":
42337
42476
  return "Hidden vertical-merge continuation or synthetic layout cells are not editable targets.";
42477
+ case "list-text-readback-missing":
42478
+ return "List text edits need an authoritative list-item text target before mutation.";
42479
+ case "list-structure-command-missing":
42480
+ return "List structure changes need a supported list command envelope before mutation.";
42481
+ case "list-target-stale":
42482
+ return "List target identity is stale for the current canonical document.";
42483
+ case "list-secondary-story-unsupported":
42484
+ return "List edits in this secondary story are not yet supported.";
42485
+ case "list-table-target-missing":
42486
+ return "Table-contained list item is missing a command-safe list target.";
42487
+ case "list-export-persistence-missing":
42488
+ return "List mutation is blocked until export/reopen persistence is available.";
42489
+ case "numbering-format-unsupported":
42490
+ return "Numbering format is unsupported for this list command.";
42491
+ case "picture-bullet-preserve-only":
42492
+ return "Picture bullet lists are preserve-only until picture bullet mutation is supported.";
42493
+ case "marker-geometry-unavailable":
42494
+ return "List marker geometry is unavailable for this target.";
42338
42495
  default:
42339
42496
  return void 0;
42340
42497
  }
@@ -48016,6 +48173,7 @@ function toSurfaceResolvedNumbering(numbering) {
48016
48173
  return {
48017
48174
  level: numbering.level,
48018
48175
  format: numbering.format,
48176
+ ...numbering.formatPosture !== void 0 ? { formatPosture: { ...numbering.formatPosture } } : {},
48019
48177
  ...numbering.text !== null ? { text: numbering.text } : {},
48020
48178
  startAt: numbering.startAt,
48021
48179
  ...numbering.paragraphStyleId ? { paragraphStyleId: numbering.paragraphStyleId } : {},
@@ -52339,8 +52497,9 @@ function projectSurfaceBlocksToPageFragments(surface, pages, splits, columnByBlo
52339
52497
  const perPageCounter = /* @__PURE__ */ new Map();
52340
52498
  const fieldRegionsByParagraphIndex = buildFieldRegionsByParagraphIndex(fieldRegions);
52341
52499
  const generatedTargets = buildGeneratedTargets(editableTargets);
52500
+ const numberingTargets = buildNumberingTargets(editableTargets);
52342
52501
  const bookmarkRanges = buildBookmarkRanges(editableTargets);
52343
- const numberingByParagraphIndex = buildNumberingByParagraphIndex(numberingInputs);
52502
+ const numberingIndex = buildNumberingInputIndex(numberingInputs);
52344
52503
  const pushFragment = (pageIndex, fragment) => {
52345
52504
  const existing = byPage.get(pageIndex);
52346
52505
  if (existing) {
@@ -52376,8 +52535,9 @@ function projectSurfaceBlocksToPageFragments(surface, pages, splits, columnByBlo
52376
52535
  },
52377
52536
  fieldRegionsByParagraphIndex,
52378
52537
  generatedTargets,
52538
+ numberingTargets,
52379
52539
  bookmarkRanges,
52380
- numberingByParagraphIndex,
52540
+ numberingIndex,
52381
52541
  blockPath
52382
52542
  );
52383
52543
  continue;
@@ -52398,8 +52558,9 @@ function projectSurfaceBlocksToPageFragments(surface, pages, splits, columnByBlo
52398
52558
  },
52399
52559
  fieldRegionsByParagraphIndex,
52400
52560
  generatedTargets,
52561
+ numberingTargets,
52401
52562
  bookmarkRanges,
52402
- numberingByParagraphIndex,
52563
+ numberingIndex,
52403
52564
  blockPath
52404
52565
  );
52405
52566
  continue;
@@ -52431,8 +52592,9 @@ function projectSurfaceBlocksToPageFragments(surface, pages, splits, columnByBlo
52431
52592
  paginationRole: "whole",
52432
52593
  fieldRegionsByParagraphIndex,
52433
52594
  generatedTargets,
52595
+ numberingTargets,
52434
52596
  bookmarkRanges,
52435
- numberingByParagraphIndex,
52597
+ numberingIndex,
52436
52598
  blockPath
52437
52599
  }),
52438
52600
  ...columnIndex !== void 0 ? { columnIndex } : {}
@@ -52579,7 +52741,7 @@ function buildRunAnchorsForLine(input) {
52579
52741
  }
52580
52742
  return anchors;
52581
52743
  }
52582
- function emitSlicedParagraph(block, slices, emit2, fieldRegionsByParagraphIndex = /* @__PURE__ */ new Map(), generatedTargets = [], bookmarkRanges = [], numberingByParagraphIndex = /* @__PURE__ */ new Map(), blockPath) {
52744
+ function emitSlicedParagraph(block, slices, emit2, fieldRegionsByParagraphIndex = /* @__PURE__ */ new Map(), generatedTargets = [], numberingTargets = [], bookmarkRanges = [], numberingIndex = EMPTY_NUMBERING_INPUT_INDEX, blockPath) {
52583
52745
  for (let i = 0; i < slices.length; i += 1) {
52584
52746
  const slice = slices[i];
52585
52747
  const heightTwips = slice.heightTwips ?? estimateSliceHeightFromLines(slice.lineRange);
@@ -52604,8 +52766,9 @@ function emitSlicedParagraph(block, slices, emit2, fieldRegionsByParagraphIndex
52604
52766
  paginationRole: slice.lineRange.from > 0 ? "continuation" : "slice",
52605
52767
  fieldRegionsByParagraphIndex,
52606
52768
  generatedTargets,
52769
+ numberingTargets,
52607
52770
  bookmarkRanges,
52608
- numberingByParagraphIndex,
52771
+ numberingIndex,
52609
52772
  blockPath
52610
52773
  })
52611
52774
  };
@@ -52626,7 +52789,7 @@ function estimateSliceHeightFromLines(lineRange) {
52626
52789
  const lines = Math.max(0, lineRange.to - lineRange.from);
52627
52790
  return lines * 240;
52628
52791
  }
52629
- function emitSlicedTable(block, slices, emit2, fieldRegionsByParagraphIndex = /* @__PURE__ */ new Map(), generatedTargets = [], bookmarkRanges = [], numberingByParagraphIndex = /* @__PURE__ */ new Map(), blockPath) {
52792
+ function emitSlicedTable(block, slices, emit2, fieldRegionsByParagraphIndex = /* @__PURE__ */ new Map(), generatedTargets = [], numberingTargets = [], bookmarkRanges = [], numberingIndex = EMPTY_NUMBERING_INPUT_INDEX, blockPath) {
52630
52793
  for (let i = 0; i < slices.length; i += 1) {
52631
52794
  const slice = slices[i];
52632
52795
  const heightTwips = slice.heightTwips ?? estimateSliceHeightFromRows(slice.rowRange);
@@ -52650,8 +52813,9 @@ function emitSlicedTable(block, slices, emit2, fieldRegionsByParagraphIndex = /*
52650
52813
  paginationRole: slice.rowRange.from > 0 ? "continuation" : "slice",
52651
52814
  fieldRegionsByParagraphIndex,
52652
52815
  generatedTargets,
52816
+ numberingTargets,
52653
52817
  bookmarkRanges,
52654
- numberingByParagraphIndex,
52818
+ numberingIndex,
52655
52819
  blockPath
52656
52820
  }),
52657
52821
  ...slice.columnIndex !== void 0 ? { columnIndex: slice.columnIndex } : {}
@@ -52725,7 +52889,8 @@ function buildFragmentLayoutObject(input) {
52725
52889
  const numberingRows = collectNumberingLayoutFactsForBlock(
52726
52890
  input.block,
52727
52891
  input.blockPath,
52728
- input.numberingByParagraphIndex
52892
+ input.numberingIndex,
52893
+ input.numberingTargets
52729
52894
  );
52730
52895
  const numbering = input.block.kind === "paragraph" ? numberingRows[0] : void 0;
52731
52896
  const fieldRegions = collectFieldRegionLayoutFacts(
@@ -52896,6 +53061,11 @@ function buildGeneratedTargets(targets) {
52896
53061
  (target) => target.kind === "field-result-text" || target.kind === "hyperlink-text" || target.kind === "hyperlink-destination" || target.kind === "bookmark-anchor" || target.kind === "bookmark-content-range"
52897
53062
  );
52898
53063
  }
53064
+ function buildNumberingTargets(targets) {
53065
+ return targets.filter(
53066
+ (target) => target.listAddress !== void 0 || target.canonicalAddress?.addressKind === "list-item-text"
53067
+ );
53068
+ }
52899
53069
  function buildBookmarkRanges(targets) {
52900
53070
  const anchors = /* @__PURE__ */ new Map();
52901
53071
  const contentRanges = /* @__PURE__ */ new Map();
@@ -52943,14 +53113,27 @@ function buildBookmarkRanges(targets) {
52943
53113
  }
52944
53114
  return ranges;
52945
53115
  }
52946
- function buildNumberingByParagraphIndex(numberingInputs) {
53116
+ var EMPTY_NUMBERING_INPUT_INDEX = {
53117
+ byNumberingKey: /* @__PURE__ */ new Map(),
53118
+ byBlockPath: /* @__PURE__ */ new Map(),
53119
+ byParagraphIndex: /* @__PURE__ */ new Map()
53120
+ };
53121
+ function buildNumberingInputIndex(numberingInputs) {
53122
+ const byNumberingKey = /* @__PURE__ */ new Map();
53123
+ const byBlockPath = /* @__PURE__ */ new Map();
52947
53124
  const byParagraph = /* @__PURE__ */ new Map();
52948
53125
  for (const input of numberingInputs) {
53126
+ if (!byNumberingKey.has(input.numberingKey)) {
53127
+ byNumberingKey.set(input.numberingKey, input);
53128
+ }
53129
+ if (!byBlockPath.has(input.blockPath)) {
53130
+ byBlockPath.set(input.blockPath, input);
53131
+ }
52949
53132
  if (!byParagraph.has(input.paragraphIndex)) {
52950
53133
  byParagraph.set(input.paragraphIndex, input);
52951
53134
  }
52952
53135
  }
52953
- return byParagraph;
53136
+ return { byNumberingKey, byBlockPath, byParagraphIndex: byParagraph };
52954
53137
  }
52955
53138
  function collectBookmarkRangeLayoutFacts(fragmentId, blockPath, bookmarkRanges) {
52956
53139
  if (!blockPath || !bookmarkRanges || bookmarkRanges.length === 0) return [];
@@ -53031,6 +53214,7 @@ function collectNumberingLayoutFacts(block) {
53031
53214
  ...block.numbering?.numberingInstanceId !== void 0 ? { numberingInstanceId: block.numbering.numberingInstanceId } : {},
53032
53215
  ...block.numbering?.level !== void 0 ? { level: block.numbering.level } : {},
53033
53216
  ...block.resolvedNumbering?.format !== void 0 ? { format: block.resolvedNumbering.format } : {},
53217
+ ...block.resolvedNumbering?.formatPosture !== void 0 ? { formatPosture: { ...block.resolvedNumbering.formatPosture } } : {},
53034
53218
  ...block.numberingPrefix !== void 0 ? { markerText: block.numberingPrefix } : {},
53035
53219
  ...block.numberingSuffix !== void 0 ? { markerSuffix: block.numberingSuffix } : {},
53036
53220
  ...block.resolvedNumbering?.geometry.markerJustification !== void 0 ? { markerJustification: block.resolvedNumbering.geometry.markerJustification } : {},
@@ -53058,15 +53242,21 @@ function collectNumberingLayoutFacts(block) {
53058
53242
  } : {}
53059
53243
  };
53060
53244
  }
53061
- function collectNumberingLayoutFactsForBlock(block, blockPath, numberingByParagraphIndex) {
53245
+ function collectNumberingLayoutFactsForBlock(block, blockPath, numberingIndex, numberingTargets = []) {
53062
53246
  const rows = [];
53063
53247
  const seen = /* @__PURE__ */ new Set();
53064
53248
  visitParagraphBlocks(block, (paragraph, context) => {
53065
53249
  const numbering = collectNumberingLayoutFacts(paragraph);
53066
53250
  if (!numbering) return;
53067
53251
  const paragraphIndex = parseParagraphBlockIndex(paragraph.blockId);
53068
- const canonical = paragraphIndex !== void 0 ? numberingByParagraphIndex?.get(paragraphIndex) : void 0;
53069
53252
  const numberingKey = context.path !== void 0 ? `main:${context.path}:numbering` : void 0;
53253
+ const canonical = lookupNumberingInput(
53254
+ numberingIndex,
53255
+ numberingKey,
53256
+ context.path,
53257
+ paragraphIndex
53258
+ );
53259
+ const target = findNumberingTarget(numberingTargets, context.path);
53070
53260
  const numberingLayoutId = numberingKey ?? [
53071
53261
  "numbering",
53072
53262
  paragraph.blockId,
@@ -53075,6 +53265,7 @@ function collectNumberingLayoutFactsForBlock(block, blockPath, numberingByParagr
53075
53265
  ].join(":");
53076
53266
  if (seen.has(numberingLayoutId)) return;
53077
53267
  seen.add(numberingLayoutId);
53268
+ const unavailableReasons = collectNumberingUnavailableReasons(numbering, canonical);
53078
53269
  rows.push({
53079
53270
  numberingLayoutId,
53080
53271
  ...numberingKey !== void 0 ? { numberingKey } : {},
@@ -53082,6 +53273,10 @@ function collectNumberingLayoutFactsForBlock(block, blockPath, numberingByParagr
53082
53273
  ...canonical?.blockPath !== void 0 ? { sourceBlockPath: canonical.blockPath } : context.path !== void 0 ? { sourceBlockPath: context.path } : {},
53083
53274
  sourceBlockId: paragraph.blockId,
53084
53275
  ...paragraphIndex !== void 0 ? { paragraphIndex } : {},
53276
+ ...target?.targetKey !== void 0 ? { targetKey: target.targetKey } : {},
53277
+ ...target?.kind !== void 0 ? { targetKind: target.kind } : {},
53278
+ ...target?.canonicalAddress?.addressKey !== void 0 ? { canonicalAddressKey: target.canonicalAddress.addressKey } : {},
53279
+ ...target?.listAddress?.addressKey !== void 0 ? { listAddressKey: target.listAddress.addressKey } : {},
53085
53280
  ...canonical?.sourceRef !== void 0 ? { sourceRef: { ...canonical.sourceRef } } : {},
53086
53281
  ...canonical?.numberingSourceRef !== void 0 ? { numberingSourceRef: { ...canonical.numberingSourceRef } } : {},
53087
53282
  ...canonical?.numberingOrigin !== void 0 ? { numberingOrigin: canonical.numberingOrigin } : {},
@@ -53089,11 +53284,41 @@ function collectNumberingLayoutFactsForBlock(block, blockPath, numberingByParagr
53089
53284
  ...canonical?.numberingInstanceSourceRef !== void 0 ? { numberingInstanceSourceRef: { ...canonical.numberingInstanceSourceRef } } : {},
53090
53285
  ...canonical?.abstractNumberingId !== void 0 ? { abstractNumberingId: canonical.abstractNumberingId } : {},
53091
53286
  ...canonical?.abstractNumberingSourceRef !== void 0 ? { abstractNumberingSourceRef: { ...canonical.abstractNumberingSourceRef } } : {},
53092
- ...numbering
53287
+ ...numbering,
53288
+ ...unavailableReasons.length > 0 ? { unavailableReasons } : {}
53093
53289
  });
53094
53290
  }, blockPath);
53095
53291
  return rows;
53096
53292
  }
53293
+ function findNumberingTarget(numberingTargets, blockPath) {
53294
+ if (blockPath === void 0) return void 0;
53295
+ return numberingTargets.find((target) => target.blockPath === blockPath);
53296
+ }
53297
+ function lookupNumberingInput(numberingIndex, numberingKey, blockPath, paragraphIndex) {
53298
+ if (!numberingIndex) return void 0;
53299
+ if (numberingKey !== void 0) {
53300
+ const byKey = numberingIndex.byNumberingKey.get(numberingKey);
53301
+ if (byKey !== void 0) return byKey;
53302
+ }
53303
+ if (blockPath !== void 0) {
53304
+ const byPath = numberingIndex.byBlockPath.get(blockPath);
53305
+ if (byPath !== void 0) return byPath;
53306
+ }
53307
+ return paragraphIndex !== void 0 ? numberingIndex.byParagraphIndex.get(paragraphIndex) : void 0;
53308
+ }
53309
+ function collectNumberingUnavailableReasons(numbering, canonical) {
53310
+ const reasons = [];
53311
+ if (canonical === void 0) {
53312
+ reasons.push("canonical-numbering-input-missing");
53313
+ }
53314
+ if (numbering.markerLane === void 0) {
53315
+ reasons.push("numbering-marker-lane-unavailable");
53316
+ }
53317
+ if (numbering.textColumn === void 0) {
53318
+ reasons.push("numbering-text-column-unavailable");
53319
+ }
53320
+ return reasons;
53321
+ }
53097
53322
  function findPageIndexForOffset(pages, offset) {
53098
53323
  for (let i = 0; i < pages.length; i += 1) {
53099
53324
  const page = pages[i];
@@ -56549,19 +56774,19 @@ function locateTargetRange(document2, surface, target) {
56549
56774
  if (!sdt || sdt.kind !== "sdt_block") return null;
56550
56775
  const paragraph = sdt.children[sdtPath.childIndex];
56551
56776
  if (!paragraph || paragraph.kind !== "paragraph") return null;
56552
- return { from: paragraph.from, to: paragraph.to };
56777
+ return textLeafTargetRange(target, paragraph.from, paragraph.to);
56553
56778
  }
56554
56779
  const paragraphPath = parseTopLevelParagraphPath(target.blockPath);
56555
56780
  if (paragraphPath) {
56556
56781
  const paragraph = surface[paragraphPath.blockIndex];
56557
56782
  if (!paragraph || paragraph.kind !== "paragraph") return null;
56558
- return { from: paragraph.from, to: paragraph.to };
56783
+ return textLeafTargetRange(target, paragraph.from, paragraph.to);
56559
56784
  }
56560
56785
  const secondaryParagraphPath = parseSecondaryStoryParagraphPath(target.blockPath);
56561
56786
  if (secondaryParagraphPath) {
56562
56787
  const paragraph = surface[secondaryParagraphPath.blockIndex];
56563
56788
  if (!paragraph || paragraph.kind !== "paragraph") return null;
56564
- return { from: paragraph.from, to: paragraph.to };
56789
+ return textLeafTargetRange(target, paragraph.from, paragraph.to);
56565
56790
  }
56566
56791
  if (target.kind === "textbox-paragraph-text") {
56567
56792
  return {
@@ -56577,6 +56802,18 @@ function locateTargetRange(document2, surface, target) {
56577
56802
  }
56578
56803
  return null;
56579
56804
  }
56805
+ function textLeafTargetRange(target, from, to) {
56806
+ return {
56807
+ from,
56808
+ to,
56809
+ textTarget: {
56810
+ kind: "text-leaf",
56811
+ blockPath: target.blockPath,
56812
+ paragraphStart: from,
56813
+ paragraphEnd: to
56814
+ }
56815
+ };
56816
+ }
56580
56817
  function locateHyperlinkDisplayRange(document2, surface, target) {
56581
56818
  const canonical = resolveHyperlinkDisplayPath(document2, target.blockPath);
56582
56819
  if (!canonical) return null;
@@ -57696,6 +57933,17 @@ var hyperlinkDestinationEditMetadata = actionMethodMetadata(
57696
57933
  expectedDelta: "hyperlink destination changes"
57697
57934
  }
57698
57935
  );
57936
+ var hyperlinkTextEditMetadata = actionMethodMetadata(
57937
+ "hyperlinkTextEdit",
57938
+ "mutate",
57939
+ "actions-link-bookmark",
57940
+ "Edit supported hyperlink display text through the L07 text-leaf command target; broad carrier scope rewrite remains refused.",
57941
+ {
57942
+ uiVisible: true,
57943
+ expectsUxResponse: "inline-change",
57944
+ expectedDelta: "hyperlink display text changes"
57945
+ }
57946
+ );
57699
57947
  var listOperationMetadata = actionMethodMetadata(
57700
57948
  "listOperation",
57701
57949
  "mutate",
@@ -57755,6 +58003,7 @@ var ACTION_METHODS = Object.freeze([
57755
58003
  "tocRefresh",
57756
58004
  "bookmarkEdit",
57757
58005
  "hyperlinkDestinationEdit",
58006
+ "hyperlinkTextEdit",
57758
58007
  "listOperation",
57759
58008
  "tableFragment",
57760
58009
  "tableSelection",
@@ -57764,6 +58013,9 @@ var DEFAULT_LOCATE_LIMIT = 20;
57764
58013
  var DEFAULT_REWRITE_ALL_LIMIT = 10;
57765
58014
  var DEFAULT_TABLE_TEXT_SCOPE_LIMIT = 3;
57766
58015
  var DEFAULT_PLAN_STEP_LIMIT = 20;
58016
+ function documentContentHash(runtime) {
58017
+ return JSON.stringify(runtime.getCanonicalDocument().content);
58018
+ }
57767
58019
  function createActionsFamily(runtime) {
57768
58020
  const category = {
57769
58021
  discover(input) {
@@ -58010,6 +58262,14 @@ function createActionsFamily(runtime) {
58010
58262
  ...readback ? { text: readback.text, excerpt: excerpt(readback.text) } : {}
58011
58263
  };
58012
58264
  }
58265
+ if (resolved.target.kind === "editable-text") {
58266
+ return {
58267
+ status: "read",
58268
+ target: summarizeTarget(resolved.target),
58269
+ text: resolved.target.readback.text,
58270
+ excerpt: excerpt(resolved.target.readback.text)
58271
+ };
58272
+ }
58013
58273
  const text = resolved.target.scope.content.text;
58014
58274
  return {
58015
58275
  status: "read",
@@ -58090,6 +58350,31 @@ function createActionsFamily(runtime) {
58090
58350
  input
58091
58351
  );
58092
58352
  },
58353
+ hyperlinkTextEdit(input) {
58354
+ if (input.text === void 0) {
58355
+ return blockedApply(
58356
+ "actions:hyperlink-text-edit:text-required",
58357
+ "input",
58358
+ "Hyperlink display text edit actions require a text value.",
58359
+ "Retry with a text string."
58360
+ );
58361
+ }
58362
+ const resolved = resolveTarget(runtime, input.target);
58363
+ if (!resolved.ok) return blockedApplyFromResolution(resolved);
58364
+ if (resolved.target.kind !== "editable-text" || resolved.target.targetKind !== "hyperlink-text") {
58365
+ return blockedApply(
58366
+ "actions:hyperlink-text-edit:hyperlink-text-handle-required",
58367
+ "unsupported",
58368
+ "Hyperlink display text edits require an exact hyperlink-text actionHandle.",
58369
+ "Call ai.actions.locateAll and retry with a returned scope-command:text-leaf actionHandle."
58370
+ );
58371
+ }
58372
+ return applyEditableTextRewrite(runtime, resolved.target, {
58373
+ text: input.text,
58374
+ actorId: input.actorId,
58375
+ origin: input.origin
58376
+ });
58377
+ },
58093
58378
  listOperation(input) {
58094
58379
  return applyListOperation(runtime, input);
58095
58380
  },
@@ -58138,6 +58423,7 @@ function runPlan(runtime, input) {
58138
58423
  for (const step of input.steps) {
58139
58424
  const result = runPlanStep(runtime, mode, step, input);
58140
58425
  results.push(result);
58426
+ if (isSuspectMutationStep(result)) break;
58141
58427
  if (stopOnBlocker && (result.status === "blocked" || result.status === "unsupported")) {
58142
58428
  break;
58143
58429
  }
@@ -58202,24 +58488,27 @@ function runPlanStep(runtime, mode, step, plan) {
58202
58488
  ...before.readback ? { beforeReadback: before.readback } : {}
58203
58489
  };
58204
58490
  }
58491
+ const documentHashBeforeApply = documentContentHash(runtime);
58205
58492
  const applied = applyPlanStep(runtime, step, plan);
58493
+ const documentHashAfterApply = documentContentHash(runtime);
58494
+ const projectedApply = !applied.applied && documentHashAfterApply !== documentHashBeforeApply ? withSuspectMutationApplyResult(applied, step.id, applied.target ?? before.target) : applied;
58206
58495
  const after = step.kind === "flag" ? before : step.target ? readPlanTarget(runtime, step.target) : before;
58207
58496
  return {
58208
58497
  id: step.id,
58209
58498
  kind: step.kind,
58210
- status: applied.status === "unsupported" ? "unsupported" : applied.applied ? "applied" : "blocked",
58211
- applied: applied.applied,
58212
- changed: applied.changed,
58213
- ...applied.target ?? before.target ? { target: applied.target ?? before.target } : {},
58499
+ status: projectedApply.status === "unsupported" ? "unsupported" : projectedApply.applied ? "applied" : "blocked",
58500
+ applied: projectedApply.applied,
58501
+ changed: projectedApply.changed,
58502
+ ...projectedApply.target ?? before.target ? { target: projectedApply.target ?? before.target } : {},
58214
58503
  ...before.tableAction ? { tableAction: before.tableAction } : {},
58215
58504
  ...before.readback ? { beforeReadback: before.readback } : {},
58216
58505
  ...after.ok && after.readback ? { afterReadback: after.readback } : {},
58217
- ...applied.proposalId ? { proposalId: applied.proposalId } : {},
58218
- ...applied.posture ? { posture: applied.posture } : {},
58219
- ...applied.blockers ? { blockers: applied.blockers } : {},
58220
- ...applied.blockerDetails ? { blockerDetails: applied.blockerDetails } : {},
58221
- ...applied.auditReference ? { auditReference: applied.auditReference } : {},
58222
- ...applied.commandReference ? { commandReference: applied.commandReference } : {}
58506
+ ...projectedApply.proposalId ? { proposalId: projectedApply.proposalId } : {},
58507
+ ...projectedApply.posture ? { posture: projectedApply.posture } : {},
58508
+ ...projectedApply.blockers ? { blockers: projectedApply.blockers } : {},
58509
+ ...projectedApply.blockerDetails ? { blockerDetails: projectedApply.blockerDetails } : {},
58510
+ ...projectedApply.auditReference ? { auditReference: projectedApply.auditReference } : {},
58511
+ ...projectedApply.commandReference ? { commandReference: projectedApply.commandReference } : {}
58223
58512
  };
58224
58513
  }
58225
58514
  function runPlanTableActionStep(runtime, mode, step, plan) {
@@ -58347,6 +58636,23 @@ function locateAll(runtime, input) {
58347
58636
  isEmpty: text.trim().length === 0
58348
58637
  });
58349
58638
  }
58639
+ if (matches.length < limit && !input.kind) {
58640
+ for (const scope of scopes) {
58641
+ if (matches.length >= limit) break;
58642
+ for (const action of editableTextActionsForScope(runtime, scope.handle)) {
58643
+ if (matches.length >= limit) break;
58644
+ if (!textMatches(action.readback.text, input.query, input.matchCase)) continue;
58645
+ matches.push({
58646
+ kind: action.targetKind,
58647
+ text: action.readback.text,
58648
+ excerpt: excerpt(action.readback.text),
58649
+ actionHandle: action.actionHandle,
58650
+ readback: action.readback,
58651
+ isEmpty: action.readback.isEmpty
58652
+ });
58653
+ }
58654
+ }
58655
+ }
58350
58656
  if (matches.length < limit && shouldScanTableText) {
58351
58657
  const tableTextScopeLimit = Math.max(
58352
58658
  0,
@@ -58381,23 +58687,27 @@ function locateAll(runtime, input) {
58381
58687
  function resolveTarget(runtime, target) {
58382
58688
  if ("actionHandle" in target) {
58383
58689
  const action = findTableAction(runtime, target.actionHandle);
58384
- if (!action) {
58385
- return blockedResolution(
58386
- `actions:target:action-handle-not-found:${target.actionHandle}`,
58387
- "unresolved-target",
58388
- "No current table text action matches the supplied actionHandle.",
58389
- "Call ai.actions.locateAll or ai.listTableActions again and retry with a fresh actionHandle."
58390
- );
58690
+ if (action) {
58691
+ if (action.family !== "table-text") {
58692
+ return blockedResolution(
58693
+ `actions:target:action-handle-not-text:${target.actionHandle}`,
58694
+ "unsupported",
58695
+ "This actionHandle is not a table text action.",
58696
+ "Use table structure handles with ai.applyTableAction, or use a table text actionHandle for rewrite."
58697
+ );
58698
+ }
58699
+ return { ok: true, target: { kind: "table-text", action } };
58391
58700
  }
58392
- if (action.family !== "table-text") {
58393
- return blockedResolution(
58394
- `actions:target:action-handle-not-text:${target.actionHandle}`,
58395
- "unsupported",
58396
- "This actionHandle is not a table text action.",
58397
- "Use table structure handles with ai.applyTableAction, or use a table text actionHandle for rewrite."
58398
- );
58701
+ const editableTextAction = findEditableTextAction(runtime, target.actionHandle);
58702
+ if (editableTextAction) {
58703
+ return { ok: true, target: editableTextAction };
58399
58704
  }
58400
- return { ok: true, target: { kind: "table-text", action } };
58705
+ return blockedResolution(
58706
+ `actions:target:action-handle-not-found:${target.actionHandle}`,
58707
+ "unresolved-target",
58708
+ "No current table text or editable text action matches the supplied actionHandle.",
58709
+ "Call ai.actions.locateAll again and retry with a fresh actionHandle."
58710
+ );
58401
58711
  }
58402
58712
  if ("handle" in target) {
58403
58713
  const compiled = createScopeCompilerService(runtime).compileScopeById(target.handle.scopeId);
@@ -58482,7 +58792,21 @@ function applyRewrite(runtime, target, input) {
58482
58792
  ...result2.afterReadback ? { afterReadback: result2.afterReadback } : {}
58483
58793
  };
58484
58794
  }
58795
+ if (target.kind === "editable-text") {
58796
+ return applyEditableTextRewrite(runtime, target, input);
58797
+ }
58798
+ const rewriteBlocker = scopeRewriteCapabilityBlocker(target.scope);
58799
+ if (rewriteBlocker) {
58800
+ return blockedApply(
58801
+ rewriteBlocker.code,
58802
+ rewriteBlocker.category,
58803
+ rewriteBlocker.message,
58804
+ rewriteBlocker.nextStep,
58805
+ [rewriteBlocker]
58806
+ );
58807
+ }
58485
58808
  const beforeText = target.scope.content.text;
58809
+ const documentHashBeforeApply = documentContentHash(runtime);
58486
58810
  const result = createReplacementFamily(runtime).applyReplacementScope({
58487
58811
  targetScopeId: target.handle.scopeId,
58488
58812
  operation: "replace",
@@ -58494,7 +58818,22 @@ function applyRewrite(runtime, target, input) {
58494
58818
  ...input.origin ? { origin: input.origin } : {},
58495
58819
  ...input.proposalId ? { proposalId: input.proposalId } : {}
58496
58820
  });
58497
- return projectRewriteScopeResult(runtime, result, target, beforeText, input.text);
58821
+ const documentMutated = documentContentHash(runtime) !== documentHashBeforeApply;
58822
+ if (!result.applied) {
58823
+ return documentMutated ? withSuspectMutationApplyResult(
58824
+ projectApplyResult(result, target),
58825
+ target.handle.scopeId,
58826
+ summarizeTarget(target)
58827
+ ) : projectApplyResult(result, target);
58828
+ }
58829
+ return projectRewriteScopeResult(
58830
+ runtime,
58831
+ result,
58832
+ target,
58833
+ beforeText,
58834
+ input.text,
58835
+ documentMutated
58836
+ );
58498
58837
  }
58499
58838
  function projectApplyResult(result, target) {
58500
58839
  return {
@@ -58515,7 +58854,79 @@ function projectApplyResult(result, target) {
58515
58854
  ...result.auditReference ? { auditReference: result.auditReference } : {}
58516
58855
  };
58517
58856
  }
58518
- function projectRewriteScopeResult(runtime, result, target, beforeText, proposedText) {
58857
+ function applyEditableTextRewrite(runtime, target, input) {
58858
+ const before = runtime.getCanonicalDocument();
58859
+ runtime.dispatch({
58860
+ type: "selection.set",
58861
+ selection: target.selection,
58862
+ origin: actionOrigin(runtime, input)
58863
+ });
58864
+ runtime.applyActiveStoryTextCommand({
58865
+ type: "text.insert",
58866
+ text: input.text,
58867
+ editableTarget: target.editableTarget,
58868
+ origin: actionOrigin(runtime, input)
58869
+ });
58870
+ const changed = runtime.getCanonicalDocument() !== before;
58871
+ if (!changed) {
58872
+ return blockedApply(
58873
+ `actions:editable-text:runtime-noop:${target.actionHandle}`,
58874
+ "blocked",
58875
+ "The editable text command was accepted but produced no document change.",
58876
+ "Refresh the action handle with ai.actions.locateAll and retry; route persistent failures to L07 text command support.",
58877
+ [
58878
+ blockerWithOwner(
58879
+ `actions:editable-text:runtime-noop:${target.actionHandle}`,
58880
+ "blocked",
58881
+ "The editable text command was accepted but produced no document change.",
58882
+ "Refresh the action handle with ai.actions.locateAll and retry; route persistent failures to L07 text command support.",
58883
+ "L07 runtime text command support"
58884
+ )
58885
+ ]
58886
+ );
58887
+ }
58888
+ const afterTarget = findEditableTextActionByTargetKey(
58889
+ runtime,
58890
+ target.editableTarget.targetKey
58891
+ );
58892
+ const afterReadback = afterTarget?.readback ?? editableTextTargetState(
58893
+ runtime.getCanonicalDocument(),
58894
+ target.editableTarget
58895
+ )?.readback;
58896
+ if (!afterReadback || afterReadback.text !== input.text) {
58897
+ return {
58898
+ status: "blocked",
58899
+ applied: false,
58900
+ changed: true,
58901
+ target: summarizeTarget(afterTarget ?? target),
58902
+ posture: "suspect-readback",
58903
+ blockers: Object.freeze([`actions:editable-text:readback-mismatch:${target.actionHandle}`]),
58904
+ blockerDetails: Object.freeze([
58905
+ blocker(
58906
+ `actions:editable-text:readback-mismatch:${target.actionHandle}`,
58907
+ "blocked",
58908
+ "The editable text command changed the document, but exact target readback did not match the proposed text.",
58909
+ "Treat the mutation as suspect. Re-read the target and export before claiming success."
58910
+ )
58911
+ ]),
58912
+ ...afterReadback ? { afterReadback } : {}
58913
+ };
58914
+ }
58915
+ return {
58916
+ status: "applied",
58917
+ applied: true,
58918
+ changed: true,
58919
+ target: summarizeTarget(afterTarget ?? { ...target, readback: afterReadback }),
58920
+ commandReference: {
58921
+ command: "text.insert",
58922
+ actorId: input.actorId ?? "v3-ai-api",
58923
+ origin: input.origin ?? "agent",
58924
+ emittedAtUtc: currentAuditTimestamp(runtime)
58925
+ },
58926
+ afterReadback
58927
+ };
58928
+ }
58929
+ function projectRewriteScopeResult(runtime, result, target, beforeText, proposedText, documentMutated) {
58519
58930
  if (!result.applied) return projectApplyResult(result, target);
58520
58931
  const compiledAfter = createScopeCompilerService(runtime).compileScopeById(
58521
58932
  target.handle.scopeId
@@ -58526,7 +58937,8 @@ function projectRewriteScopeResult(runtime, result, target, beforeText, proposed
58526
58937
  target,
58527
58938
  `actions:rewrite:authoritative-readback-unresolvable:${target.handle.scopeId}`,
58528
58939
  "The replacement primitive reported success, but the target scope could not be re-read afterwards.",
58529
- "Treat the mutation as untrusted. Re-locate the target and retry only after the scope resolves, or create an issue flag instead."
58940
+ "Treat the mutation as untrusted. Re-locate the target and retry only after the scope resolves, or create an issue flag instead.",
58941
+ documentMutated
58530
58942
  );
58531
58943
  }
58532
58944
  const afterText = compiledAfter.scope.content.text;
@@ -58538,7 +58950,8 @@ function projectRewriteScopeResult(runtime, result, target, beforeText, proposed
58538
58950
  { ...target, scope: compiledAfter.scope, handle: compiledAfter.scope.handle },
58539
58951
  `actions:rewrite:authoritative-readback-unchanged:${target.handle.scopeId}`,
58540
58952
  "The replacement primitive reported success, but authoritative scope readback showed unchanged text.",
58541
- "Treat the mutation as not applied. Retry with a narrower scope or create an issue flag; do not claim the replacement succeeded."
58953
+ "Treat the mutation as not applied. Retry with a narrower scope or create an issue flag; do not claim the replacement succeeded.",
58954
+ documentMutated
58542
58955
  );
58543
58956
  }
58544
58957
  if (!expectedPresent) {
@@ -58547,7 +58960,8 @@ function projectRewriteScopeResult(runtime, result, target, beforeText, proposed
58547
58960
  { ...target, scope: compiledAfter.scope, handle: compiledAfter.scope.handle },
58548
58961
  `actions:rewrite:authoritative-readback-mismatch:${target.handle.scopeId}`,
58549
58962
  "The replacement primitive reported success, but authoritative scope readback did not contain the proposed text.",
58550
- "Treat the mutation as suspect. Re-read the target, inspect the exported package when available, and retry only with a verified target."
58963
+ "Treat the mutation as suspect. Re-read the target, inspect the exported package when available, and retry only with a verified target.",
58964
+ documentMutated
58551
58965
  );
58552
58966
  }
58553
58967
  return {
@@ -58564,17 +58978,27 @@ function projectRewriteScopeResult(runtime, result, target, beforeText, proposed
58564
58978
  ...result.auditReference ? { auditReference: result.auditReference } : {}
58565
58979
  };
58566
58980
  }
58567
- function blockedRewriteReadback(result, target, code, message, nextStep) {
58981
+ function blockedRewriteReadback(result, target, code, message, nextStep, documentMutated = false) {
58568
58982
  const detail = blocker(code, "blocked", message, nextStep);
58983
+ const details = documentMutated ? [
58984
+ detail,
58985
+ blockerWithOwner(
58986
+ `actions:rewrite:suspect-mutation:${target.handle.scopeId}`,
58987
+ "blocked",
58988
+ "The document changed even though authoritative target readback failed.",
58989
+ "Abort the plan, inspect the export/readback evidence, and route the target to L08/L07 scope edit-target mapping before retrying.",
58990
+ "L08 semantic scopes and L07 runtime text commands"
58991
+ )
58992
+ ] : [detail];
58569
58993
  return {
58570
58994
  status: "blocked",
58571
58995
  applied: false,
58572
- changed: false,
58996
+ changed: documentMutated,
58573
58997
  target: summarizeTarget(target),
58574
58998
  proposalId: result.proposalId,
58575
- posture: "suspect-readback",
58576
- blockers: Object.freeze([detail.code]),
58577
- blockerDetails: Object.freeze([detail]),
58999
+ posture: documentMutated ? "suspect-mutation" : "suspect-readback",
59000
+ blockers: Object.freeze(details.map((entry) => entry.code)),
59001
+ blockerDetails: Object.freeze(details),
58578
59002
  ...result.auditReference ? { auditReference: result.auditReference } : {}
58579
59003
  };
58580
59004
  }
@@ -58590,11 +59014,23 @@ function summarizeTarget(target) {
58590
59014
  canMark: false
58591
59015
  };
58592
59016
  }
59017
+ if (target.kind === "editable-text") {
59018
+ return {
59019
+ kind: target.targetKind,
59020
+ handle: target.ownerHandle,
59021
+ actionHandle: target.actionHandle,
59022
+ readback: target.readback,
59023
+ canRewriteText: true,
59024
+ canInsertAdjacentText: false,
59025
+ canFlag: false,
59026
+ canMark: false
59027
+ };
59028
+ }
58593
59029
  return {
58594
59030
  kind: target.scope.kind,
58595
59031
  handle: target.handle,
58596
59032
  canRewriteText: canRewriteScopeText(target.scope),
58597
- canInsertAdjacentText: canRewriteScopeText(target.scope),
59033
+ canInsertAdjacentText: canInsertAdjacentScopeText(target.scope),
58598
59034
  canFlag: true,
58599
59035
  canMark: canMarkScope(target.scope)
58600
59036
  };
@@ -58606,6 +59042,34 @@ function tableTextActionsForScope(runtime, handle) {
58606
59042
  });
58607
59043
  return result.actions.filter((action) => action.family === "table-text");
58608
59044
  }
59045
+ function editableTextActionsForScope(runtime, handle) {
59046
+ const bundle = createScopeCompilerService(runtime).compileBundleById(
59047
+ handle.scopeId,
59048
+ currentAuditTimestamp(runtime)
59049
+ );
59050
+ const entries = bundle?.evidence.editableTargets?.entries ?? [];
59051
+ const currentTargets = collectEditableTargetRefs(runtime.getCanonicalDocument());
59052
+ const actions2 = [];
59053
+ for (const entry of entries) {
59054
+ if (entry.kind !== "hyperlink-text" || entry.commandFamily !== "text-leaf" || entry.runtimeCommand.status !== "supported" || !entry.runtimeCommand.actionHandle) {
59055
+ continue;
59056
+ }
59057
+ const currentTarget = currentTargets.find((target) => target.targetKey === entry.targetKey);
59058
+ if (!currentTarget || currentTarget.kind !== "hyperlink-text") continue;
59059
+ const targetState = editableTextTargetState(runtime.getCanonicalDocument(), currentTarget);
59060
+ if (!targetState) continue;
59061
+ actions2.push({
59062
+ kind: "editable-text",
59063
+ targetKind: "hyperlink-text",
59064
+ actionHandle: entry.runtimeCommand.actionHandle,
59065
+ editableTarget: currentTarget,
59066
+ ownerHandle: handle,
59067
+ readback: targetState.readback,
59068
+ selection: targetState.selection
59069
+ });
59070
+ }
59071
+ return Object.freeze(actions2);
59072
+ }
58609
59073
  function findTableAction(runtime, actionHandle) {
58610
59074
  const action = findAnyTableAction(runtime, actionHandle);
58611
59075
  return action?.family === "table-text" ? action : null;
@@ -58625,6 +59089,27 @@ function findAnyTableAction(runtime, actionHandle) {
58625
59089
  }
58626
59090
  return null;
58627
59091
  }
59092
+ function findEditableTextAction(runtime, actionHandle) {
59093
+ if (!actionHandle.startsWith("scope-command:text-leaf:")) return null;
59094
+ const compiler = createScopeCompilerService(runtime);
59095
+ for (const scope of compiler.compileAllScopes()) {
59096
+ const action = editableTextActionsForScope(runtime, scope.handle).find(
59097
+ (candidate) => candidate.actionHandle === actionHandle
59098
+ );
59099
+ if (action) return action;
59100
+ }
59101
+ return null;
59102
+ }
59103
+ function findEditableTextActionByTargetKey(runtime, targetKey) {
59104
+ const compiler = createScopeCompilerService(runtime);
59105
+ for (const scope of compiler.compileAllScopes()) {
59106
+ const action = editableTextActionsForScope(runtime, scope.handle).find(
59107
+ (candidate) => candidate.editableTarget.targetKey === targetKey
59108
+ );
59109
+ if (action) return action;
59110
+ }
59111
+ return null;
59112
+ }
58628
59113
  function readDocumentPlanTarget(runtime) {
58629
59114
  const document2 = createInspectFamily(runtime).inspectDocument();
58630
59115
  return {
@@ -58681,6 +59166,18 @@ function readPlanTarget(runtime, target) {
58681
59166
  ])
58682
59167
  };
58683
59168
  }
59169
+ const editableText = findEditableTextAction(runtime, target.actionHandle);
59170
+ if (editableText) {
59171
+ return {
59172
+ ok: true,
59173
+ target: summarizeTarget(editableText),
59174
+ readback: {
59175
+ text: editableText.readback.text,
59176
+ excerpt: excerpt(editableText.readback.text),
59177
+ isEmpty: editableText.readback.isEmpty
59178
+ }
59179
+ };
59180
+ }
58684
59181
  return readPlanTableAction(runtime, target.actionHandle);
58685
59182
  }
58686
59183
  function readPlanTableAction(runtime, actionHandle) {
@@ -58743,6 +59240,15 @@ function checkPlanStepCapability(runtime, step, before) {
58743
59240
  "Regenerate the plan with a ScopeHandle or opaque actionHandle returned by L09."
58744
59241
  );
58745
59242
  }
59243
+ if (step.kind === "rewrite" && target.kind === "list-item") {
59244
+ return blockerWithOwner(
59245
+ "capability:list-item:authoritative-readback-required",
59246
+ "blocked",
59247
+ "List-item text replacement is not yet backed by an authoritative mutation/readback route.",
59248
+ "Use listOperation for numbering changes, or create an issue/explanation until L08/L07 list-item text replacement is proven.",
59249
+ "L08 semantic scopes and L07 runtime text commands"
59250
+ );
59251
+ }
58746
59252
  if (step.kind === "rewrite" && !target.canRewriteText) {
58747
59253
  return blocker(
58748
59254
  `actions:plan:target-not-rewriteable:${step.id}`,
@@ -58775,7 +59281,20 @@ function checkPlanStepCapability(runtime, step, before) {
58775
59281
  "Use a supported semantic scope or create an issue flag instead."
58776
59282
  );
58777
59283
  }
58778
- if (step.kind === "fieldRefresh" || step.kind === "tocRefresh" || step.kind === "bookmarkEdit" || step.kind === "hyperlinkDestinationEdit") {
59284
+ if (step.kind === "fieldRefresh" || step.kind === "tocRefresh" || step.kind === "bookmarkEdit" || step.kind === "hyperlinkDestinationEdit" || step.kind === "hyperlinkTextEdit") {
59285
+ if (step.kind === "hyperlinkTextEdit") {
59286
+ const resolved2 = resolveTarget(runtime, step.target);
59287
+ if (!resolved2.ok) return resolved2.blockerDetails[0] ?? null;
59288
+ if (resolved2.target.kind !== "editable-text" || resolved2.target.targetKind !== "hyperlink-text") {
59289
+ return blocker(
59290
+ `actions:hyperlink-text-edit:hyperlink-text-handle-required:${step.id}`,
59291
+ "unsupported",
59292
+ "Hyperlink display text plan steps require an exact hyperlink-text actionHandle.",
59293
+ "Regenerate the plan with a scope-command:text-leaf actionHandle returned by ai.actions.locateAll."
59294
+ );
59295
+ }
59296
+ return null;
59297
+ }
58779
59298
  const resolved = resolveScopeExactTarget(runtime, step.target, step.kind);
58780
59299
  if (!resolved.ok) return resolved.blockerDetails[0] ?? null;
58781
59300
  const targetRef = resolveModeledEditableTarget(runtime, resolved.target, step.kind);
@@ -58880,6 +59399,13 @@ function applyPlanStep(runtime, step, plan) {
58880
59399
  actorId: step.actorId ?? plan.actorId,
58881
59400
  origin: step.origin ?? plan.origin
58882
59401
  });
59402
+ case "hyperlinkTextEdit":
59403
+ return createActionsFamily(runtime).actions.hyperlinkTextEdit({
59404
+ target: step.target,
59405
+ text: step.text,
59406
+ actorId: step.actorId ?? plan.actorId,
59407
+ origin: step.origin ?? plan.origin
59408
+ });
58883
59409
  case "listOperation":
58884
59410
  return createActionsFamily(runtime).actions.listOperation({
58885
59411
  target: step.target,
@@ -59196,11 +59722,159 @@ function isTableFamilyScope(kind) {
59196
59722
  return kind === "table" || kind === "table-row" || kind === "table-cell";
59197
59723
  }
59198
59724
  function canRewriteScopeText(scope) {
59725
+ return !isTableFamilyScope(scope.kind) && scope.kind !== "list-item" && (scope.replaceability.level === "full" || scope.replaceability.level === "text-only");
59726
+ }
59727
+ function canInsertAdjacentScopeText(scope) {
59199
59728
  return !isTableFamilyScope(scope.kind) && (scope.replaceability.level === "full" || scope.replaceability.level === "text-only");
59200
59729
  }
59730
+ function scopeRewriteCapabilityBlocker(scope) {
59731
+ if (scope.kind === "list-item") {
59732
+ return blockerWithOwner(
59733
+ "capability:list-item:authoritative-readback-required",
59734
+ "blocked",
59735
+ "List-item text replacement is not yet backed by an authoritative mutation/readback route.",
59736
+ "Use listOperation for numbering changes, or create an issue/explanation until L08/L07 list-item text replacement is proven.",
59737
+ "L08 semantic scopes and L07 runtime text commands"
59738
+ );
59739
+ }
59740
+ if (!canRewriteScopeText(scope)) {
59741
+ return blocker(
59742
+ `actions:rewrite:target-not-rewriteable:${scope.handle.scopeId}`,
59743
+ "unsupported",
59744
+ "The target capability posture does not allow text rewrite.",
59745
+ "Use a supported text target, table text actionHandle, or create an issue flag instead."
59746
+ );
59747
+ }
59748
+ return null;
59749
+ }
59201
59750
  function canMarkScope(scope) {
59202
59751
  return !isTableFamilyScope(scope.kind) && scope.replaceability.level !== "blocked" && scope.replaceability.level !== "preserve-only";
59203
59752
  }
59753
+ function editableTextTargetState(document2, target) {
59754
+ if (target.kind !== "hyperlink-text") return void 0;
59755
+ const resolved = resolveHyperlinkTarget(document2, target);
59756
+ if (!resolved) return void 0;
59757
+ const text = collectInlineText2(resolved.hyperlink.children);
59758
+ return {
59759
+ readback: { text, isEmpty: text.length === 0 },
59760
+ selection: {
59761
+ anchor: resolved.from,
59762
+ head: resolved.to,
59763
+ isCollapsed: resolved.from === resolved.to,
59764
+ activeRange: {
59765
+ kind: "range",
59766
+ from: resolved.from,
59767
+ to: resolved.to,
59768
+ assoc: { start: -1, end: 1 }
59769
+ }
59770
+ }
59771
+ };
59772
+ }
59773
+ function resolveHyperlinkTarget(document2, target) {
59774
+ const parsed = parseBlockInlinePath(target.blockPath);
59775
+ if (!parsed) return null;
59776
+ let blocks = document2.content.children;
59777
+ let block;
59778
+ let row;
59779
+ let offset = 0;
59780
+ for (const token of parsed) {
59781
+ switch (token.kind) {
59782
+ case "block":
59783
+ for (let index = 0; index < token.index; index += 1) {
59784
+ offset += blockTextLength(blocks[index]);
59785
+ }
59786
+ block = blocks[token.index];
59787
+ row = void 0;
59788
+ if (!block) return null;
59789
+ break;
59790
+ case "row":
59791
+ if (block?.type !== "table") return null;
59792
+ row = block.rows[token.index];
59793
+ block = void 0;
59794
+ if (!row) return null;
59795
+ break;
59796
+ case "cell": {
59797
+ const cell = row?.cells[token.index];
59798
+ if (!cell) return null;
59799
+ blocks = cell.children;
59800
+ block = void 0;
59801
+ row = void 0;
59802
+ break;
59803
+ }
59804
+ case "inline": {
59805
+ if (block?.type !== "paragraph") return null;
59806
+ for (let index = 0; index < token.index; index += 1) {
59807
+ offset += inlineTextLength(block.children[index]);
59808
+ }
59809
+ const inline = block.children[token.index];
59810
+ if (inline?.type !== "hyperlink") return null;
59811
+ const length = collectInlineText2(inline.children).length;
59812
+ return { hyperlink: inline, from: offset, to: offset + length };
59813
+ }
59814
+ }
59815
+ }
59816
+ return null;
59817
+ }
59818
+ function parseBlockInlinePath(path) {
59819
+ if (!path.startsWith("main/")) return null;
59820
+ const tokens = [];
59821
+ const re = /(block|row|cell|inline)\[(\d+)\]/gu;
59822
+ let match;
59823
+ while ((match = re.exec(path)) !== null) {
59824
+ const kind = match[1];
59825
+ tokens.push({ kind, index: Number(match[2]) });
59826
+ }
59827
+ return tokens.length > 0 ? Object.freeze(tokens) : null;
59828
+ }
59829
+ function collectInlineText2(inlines) {
59830
+ let text = "";
59831
+ for (const inline of inlines) {
59832
+ switch (inline.type) {
59833
+ case "text":
59834
+ text += inline.text;
59835
+ break;
59836
+ case "hyperlink":
59837
+ case "field":
59838
+ text += collectInlineText2(inline.children);
59839
+ break;
59840
+ default:
59841
+ break;
59842
+ }
59843
+ }
59844
+ return text;
59845
+ }
59846
+ function blockTextLength(block) {
59847
+ if (!block) return 0;
59848
+ switch (block.type) {
59849
+ case "paragraph":
59850
+ return collectInlineText2(block.children).length;
59851
+ case "table":
59852
+ return block.rows.reduce(
59853
+ (rowSum, row) => rowSum + row.cells.reduce(
59854
+ (cellSum, cell) => cellSum + cell.children.reduce((blockSum, child) => blockSum + blockTextLength(child), 0),
59855
+ 0
59856
+ ),
59857
+ 0
59858
+ );
59859
+ case "sdt":
59860
+ case "custom_xml":
59861
+ return block.children.reduce((sum, child) => sum + blockTextLength(child), 0);
59862
+ default:
59863
+ return 0;
59864
+ }
59865
+ }
59866
+ function inlineTextLength(inline) {
59867
+ if (!inline) return 0;
59868
+ switch (inline.type) {
59869
+ case "text":
59870
+ return inline.text.length;
59871
+ case "hyperlink":
59872
+ case "field":
59873
+ return collectInlineText2(inline.children).length;
59874
+ default:
59875
+ return 0;
59876
+ }
59877
+ }
59204
59878
  function textMatches(text, query, matchCase) {
59205
59879
  if (matchCase) return text.includes(query);
59206
59880
  return text.toLocaleLowerCase().includes(query.toLocaleLowerCase());
@@ -59259,6 +59933,30 @@ function blockedApplyFromResolution(resolution) {
59259
59933
  blockerDetails: resolution.blockerDetails
59260
59934
  };
59261
59935
  }
59936
+ function withSuspectMutationApplyResult(result, stepOrScopeId, target) {
59937
+ const detail = blockerWithOwner(
59938
+ `actions:plan:suspect-mutation:${stepOrScopeId}`,
59939
+ "blocked",
59940
+ "The document changed even though the action did not return an applied result.",
59941
+ "Abort the remaining plan, inspect authoritative readback/export evidence, and route the target to the owning edit-target/readback layer before retrying.",
59942
+ "L08 semantic scopes and L07 runtime text commands"
59943
+ );
59944
+ return {
59945
+ ...result,
59946
+ status: "blocked",
59947
+ applied: false,
59948
+ changed: true,
59949
+ ...target ? { target } : {},
59950
+ posture: "suspect-mutation",
59951
+ blockers: Object.freeze([...result.blockers ?? [], detail.code]),
59952
+ blockerDetails: Object.freeze([...result.blockerDetails ?? [], detail])
59953
+ };
59954
+ }
59955
+ function isSuspectMutationStep(step) {
59956
+ return step.posture === "suspect-mutation" || (step.blockers ?? []).some(
59957
+ (code) => code.startsWith("actions:plan:suspect-mutation:") || code.startsWith("actions:rewrite:suspect-mutation:")
59958
+ );
59959
+ }
59262
59960
  function blockedPlan(mode, code, category, message, nextStep) {
59263
59961
  const detail = blocker(code, category, message, nextStep);
59264
59962
  return {