@beyondwork/docx-react-component 1.0.124 → 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 +791 -101
  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-A74Y5NE4.js → chunk-4YJVRIUB.js} +52 -21
  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-TY4DIJO3.js → chunk-ESJ2MES5.js} +1 -1
  21. package/dist/{chunk-ZMRO6P3A.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-Q76XPPTA.js → chunk-OHTK7F3F.js} +96 -13
  25. package/dist/{chunk-MPH4ZQS4.js → chunk-QT3LX4FA.js} +321 -51
  26. package/dist/{chunk-7PC6XUNO.js → chunk-TQDQU2E3.js} +2 -2
  27. package/dist/{chunk-4B74ETJI.js → chunk-V6XVZFFH.js} +2 -2
  28. package/dist/{chunk-NAMAWCXN.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 +1341 -193
  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 +51 -20
  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 +36 -12
  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-CNnMHZM9.d.ts → public-types-BEGhv2YR.d.ts} +108 -6
  71. package/dist/{public-types-DajNGKV4.d.cts → 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 +51 -20
  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 +1 -1
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,7 +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;
18408
- var FLD_SIMPLE_INSTR_RE = /<(?:\w+:)?fldSimple\b[^>]*(?:\bw:instr|\binstr)\s*=\s*(["'])([\s\S]*?)\1/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;
18409
18414
  var TOC_FIELD_RE = /\bTOC\b/;
18410
18415
  var REFLIKE_FIELD_RE = /\b(?:HYPERLINK|REF|PAGEREF|NOTEREF)\s+([A-Za-z0-9_:.\-]+)/g;
18411
18416
  var DATA_BINDING_RE = /<(?:\w+:)?dataBinding\b/i;
@@ -18424,11 +18429,22 @@ function scanBookmarkReferences(documentXml, callerAllowlist = []) {
18424
18429
  }
18425
18430
  INSTR_TEXT_RE.lastIndex = 0;
18426
18431
  while ((m = INSTR_TEXT_RE.exec(documentXml)) !== null) {
18427
- if (scanInstructionText(m[1] ?? "", retained)) retainAllToc = true;
18432
+ const instrText = m[1] ?? "";
18433
+ scanFieldInstruction(instrText, retained, () => {
18434
+ retainAllToc = true;
18435
+ });
18428
18436
  }
18429
- FLD_SIMPLE_INSTR_RE.lastIndex = 0;
18430
- while ((m = FLD_SIMPLE_INSTR_RE.exec(documentXml)) !== null) {
18431
- if (scanInstructionText(m[2] ?? "", retained)) retainAllToc = true;
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
+ });
18432
18448
  }
18433
18449
  retainRevisionBoundedBookmarks(documentXml, retained);
18434
18450
  return {
@@ -18437,14 +18453,16 @@ function scanBookmarkReferences(documentXml, callerAllowlist = []) {
18437
18453
  retainAll
18438
18454
  };
18439
18455
  }
18440
- function scanInstructionText(instrText, retained) {
18441
- const hasTocField = TOC_FIELD_RE.test(instrText);
18456
+ function scanFieldInstruction(instrText, retained, retainToc) {
18457
+ if (TOC_FIELD_RE.test(instrText)) retainToc();
18442
18458
  REFLIKE_FIELD_RE.lastIndex = 0;
18443
18459
  let r;
18444
18460
  while ((r = REFLIKE_FIELD_RE.exec(instrText)) !== null) {
18445
18461
  if (r[1]) retained.add(r[1]);
18446
18462
  }
18447
- return hasTocField;
18463
+ }
18464
+ function decodeXmlAttribute(value) {
18465
+ return value.replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
18448
18466
  }
18449
18467
  function retainRevisionBoundedBookmarks(documentXml, retained) {
18450
18468
  const starts = /* @__PURE__ */ new Map();
@@ -18797,18 +18815,23 @@ function parseNumberingXml(xml, context) {
18797
18815
  const abstractDefinitions = {};
18798
18816
  const instances = {};
18799
18817
  const numPicBullets = {};
18818
+ const topLevelOrdinals = /* @__PURE__ */ new Map();
18800
18819
  for (const child of numberingElement.children) {
18801
18820
  if (child.type !== "element") {
18802
18821
  continue;
18803
18822
  }
18804
- 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") {
18805
18828
  const rawId = readStringAttr(child, "w:numPicBulletId");
18806
18829
  if (rawId) {
18807
- numPicBullets[rawId] = readNumPicBullet(child, rawId, context);
18830
+ numPicBullets[rawId] = readNumPicBullet(child, rawId, context, childXmlPath);
18808
18831
  }
18809
18832
  continue;
18810
18833
  }
18811
- switch (localName(child.name)) {
18834
+ switch (childName) {
18812
18835
  case "abstractNum": {
18813
18836
  const rawId = readStringAttr(child, "w:abstractNumId");
18814
18837
  if (!rawId) {
@@ -18828,7 +18851,7 @@ function parseNumberingXml(xml, context) {
18828
18851
  const numStyleLink = numStyleLinkEl ? readStringAttr(numStyleLinkEl, "w:val") : void 0;
18829
18852
  abstractDefinitions[abstractNumberingId] = {
18830
18853
  abstractNumberingId,
18831
- ...context?.partPath !== void 0 ? { sourceRef: createNumberingSourceRef(context.partPath, "abstractNum", rawId) } : {},
18854
+ ...context?.partPath !== void 0 ? { sourceRef: createNumberingSourceRef(context.partPath, "abstractNum", rawId, childXmlPath) } : {},
18832
18855
  levels: readLevels(child),
18833
18856
  ...nsid ? { nsid } : {},
18834
18857
  ...multiLevelType ? { multiLevelType } : {},
@@ -18848,7 +18871,7 @@ function parseNumberingXml(xml, context) {
18848
18871
  const numberingInstanceId = toCanonicalNumberingInstanceId(rawId);
18849
18872
  instances[numberingInstanceId] = {
18850
18873
  numberingInstanceId,
18851
- ...context?.partPath !== void 0 ? { sourceRef: createNumberingSourceRef(context.partPath, "num", rawId) } : {},
18874
+ ...context?.partPath !== void 0 ? { sourceRef: createNumberingSourceRef(context.partPath, "num", rawId, childXmlPath) } : {},
18852
18875
  abstractNumberingId: toCanonicalAbstractNumberingId(rawAbstractId),
18853
18876
  overrides: readOverrides(child)
18854
18877
  };
@@ -18862,15 +18885,16 @@ function parseNumberingXml(xml, context) {
18862
18885
  ...Object.keys(numPicBullets).length > 0 ? { numPicBullets } : {}
18863
18886
  };
18864
18887
  }
18865
- function createNumberingSourceRef(partPath, element, rawId) {
18888
+ function createNumberingSourceRef(partPath, element, rawId, xmlPath) {
18866
18889
  return {
18867
18890
  sourceId: `part:${partPath}#${element}:${rawId}`,
18868
18891
  partPath,
18869
18892
  storyKind: "numbering",
18870
- element
18893
+ element,
18894
+ ...xmlPath !== void 0 ? { xmlPath } : {}
18871
18895
  };
18872
18896
  }
18873
- function readNumPicBullet(node, numPicBulletId, context) {
18897
+ function readNumPicBullet(node, numPicBulletId, context, xmlPath) {
18874
18898
  let widthEmu;
18875
18899
  let heightEmu;
18876
18900
  let mediaId;
@@ -18933,6 +18957,7 @@ function readNumPicBullet(node, numPicBulletId, context) {
18933
18957
  }
18934
18958
  return {
18935
18959
  numPicBulletId,
18960
+ ...context?.partPath !== void 0 ? { sourceRef: createNumberingSourceRef(context.partPath, "numPicBullet", numPicBulletId, xmlPath) } : {},
18936
18961
  rawXml: serializeXmlElementToString(node),
18937
18962
  ...widthEmu !== void 0 ? { widthEmu } : {},
18938
18963
  ...heightEmu !== void 0 ? { heightEmu } : {},
@@ -22906,7 +22931,11 @@ function parseBodyChild(node, sourceXml, relationshipMap, relationships, mediaPa
22906
22931
  switch (localName(child.name)) {
22907
22932
  case "pPr":
22908
22933
  styleId = readParagraphStyleId(child);
22909
- numbering = readParagraphNumbering(child, sourcePartPath);
22934
+ numbering = readParagraphNumbering(
22935
+ child,
22936
+ sourcePartPath,
22937
+ `${sourceXmlPath}/pPr[${countPriorElementSiblingsByName(node, child) + 1}]`
22938
+ );
22910
22939
  alignment = readParagraphAlignment(child);
22911
22940
  spacing = readParagraphSpacing2(child);
22912
22941
  contextualSpacing = readOptionalOnOffParagraphProperty(child, "contextualSpacing");
@@ -23989,7 +24018,7 @@ function readParagraphStyleId(node) {
23989
24018
  }
23990
24019
  return void 0;
23991
24020
  }
23992
- function readParagraphNumbering(node, sourcePartPath) {
24021
+ function readParagraphNumbering(node, sourcePartPath, sourceXmlPath) {
23993
24022
  const numberingProperties = node.children.find(
23994
24023
  (child) => child.type === "element" && localName(child.name) === "numPr"
23995
24024
  );
@@ -24009,16 +24038,22 @@ function readParagraphNumbering(node, sourcePartPath) {
24009
24038
  }
24010
24039
  return {
24011
24040
  numberingInstanceId: toCanonicalNumberingInstanceId(rawInstanceId),
24012
- 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
+ ),
24013
24047
  level: Number.parseInt(rawLevel, 10)
24014
24048
  };
24015
24049
  }
24016
- function createElementSourceRef(partPath, element, node) {
24050
+ function createElementSourceRef(partPath, element, node, xmlPath) {
24017
24051
  return {
24018
24052
  sourceId: `part:${partPath}#${element}:${node.start}`,
24019
24053
  partPath,
24020
24054
  storyKind: storyKindFromPartPath(partPath),
24021
24055
  element,
24056
+ ...xmlPath !== void 0 ? { xmlPath } : {},
24022
24057
  startOffset: node.start,
24023
24058
  endOffset: node.end
24024
24059
  };
@@ -32543,8 +32578,8 @@ async function computeStructuralHash(blocks) {
32543
32578
  }
32544
32579
 
32545
32580
  // src/runtime/layout/layout-engine-version.ts
32546
- var LAYOUT_ENGINE_VERSION = 87;
32547
- var LAYCACHE_SCHEMA_VERSION = 11;
32581
+ var LAYOUT_ENGINE_VERSION = 88;
32582
+ var LAYCACHE_SCHEMA_VERSION = 12;
32548
32583
 
32549
32584
  // src/runtime/prerender/customxml-cache.ts
32550
32585
  var LAYCACHE_NAMESPACE_NAME = "laycache";
@@ -34215,14 +34250,17 @@ function paragraphHasBookmarkId(paragraph, bookmarkId) {
34215
34250
  function commandActionHandleForAddress(commandFamily, address) {
34216
34251
  return address ? `scope-command:${commandFamily}:${address.addressKey}` : void 0;
34217
34252
  }
34218
- function withCommandAction(evidence, target) {
34219
- if (evidence.status !== "supported" || !target.canonicalAddress) return evidence;
34253
+ function withCommandAction(evidence, target, canonicalAddress = target.canonicalAddress) {
34254
+ if (evidence.status !== "supported" || !canonicalAddress) return evidence;
34220
34255
  return {
34221
34256
  ...evidence,
34222
- actionHandle: commandActionHandleForAddress(target.commandFamily, target.canonicalAddress),
34223
- canonicalAddress: target.canonicalAddress
34257
+ actionHandle: commandActionHandleForAddress(target.commandFamily, canonicalAddress),
34258
+ canonicalAddress
34224
34259
  };
34225
34260
  }
34261
+ function commandAddressForTarget(target, scopeKind) {
34262
+ return scopeKind === "list-item" && target.listAddress !== void 0 ? target.listAddress : target.canonicalAddress;
34263
+ }
34226
34264
  function runtimeTextCommandEvidence(target, workflowBlockers) {
34227
34265
  const shapeIssues = validateEditableTargetRef(target);
34228
34266
  if (shapeIssues.length > 0) {
@@ -34275,6 +34313,9 @@ var TABLE_TEXT_TARGET_KINDS2 = /* @__PURE__ */ new Set([
34275
34313
  var LIST_TEXT_TARGET_KINDS2 = /* @__PURE__ */ new Set([
34276
34314
  "paragraph-text",
34277
34315
  "sdt-paragraph-text",
34316
+ "table-cell-paragraph-text",
34317
+ "nested-table-cell-paragraph-text",
34318
+ "sdt-table-cell-paragraph-text",
34278
34319
  "secondary-story-paragraph-text"
34279
34320
  ]);
34280
34321
  function tableTextScopeReplacementPosture(target) {
@@ -34325,7 +34366,7 @@ function runtimeCommandEvidence(target, workflowBlockers, textCommand, scopeKind
34325
34366
  intents: commandIntentsForTarget(target, scopeKind),
34326
34367
  reason: textCommand.reason,
34327
34368
  ...textCommand.blockers ? { blockers: textCommand.blockers } : {}
34328
- }, target);
34369
+ }, target, commandAddressForTarget(target, scopeKind));
34329
34370
  }
34330
34371
  if (target.commandFamily === "comment-revision") {
34331
34372
  const isOpen = target.review?.status === "open";
@@ -36786,6 +36827,7 @@ function mergeLevelDefinition(base, override, startOverride, fallbackLevel) {
36786
36827
  );
36787
36828
  const runProperties = override?.runProperties ?? base?.runProperties;
36788
36829
  const restartAfterLevel = override?.restartAfterLevel ?? base?.restartAfterLevel;
36830
+ const picBulletId = override?.picBulletId ?? base?.picBulletId;
36789
36831
  return {
36790
36832
  level,
36791
36833
  format,
@@ -36796,7 +36838,8 @@ function mergeLevelDefinition(base, override, startOverride, fallbackLevel) {
36796
36838
  ...override?.suffix ?? base?.suffix ? { suffix: override?.suffix ?? base?.suffix } : {},
36797
36839
  ...paragraphGeometry ? { paragraphGeometry } : {},
36798
36840
  ...runProperties ? { runProperties } : {},
36799
- ...restartAfterLevel !== void 0 ? { restartAfterLevel } : {}
36841
+ ...restartAfterLevel !== void 0 ? { restartAfterLevel } : {},
36842
+ ...picBulletId !== void 0 ? { picBulletId } : {}
36800
36843
  };
36801
36844
  }
36802
36845
  function withDefaultStartAt(level) {
@@ -36924,7 +36967,7 @@ function resolveHangingWidth(indentation) {
36924
36967
  // src/runtime/formatting/numbering/prefix.ts
36925
36968
  function createNumberingPrefixResolver(catalog) {
36926
36969
  const sequenceStates = /* @__PURE__ */ new Map();
36927
- function resolveInternal(numbering, paragraph) {
36970
+ function resolveInternal(numbering, paragraph, options = {}) {
36928
36971
  const resolved = resolveNumberingDefinitionSet(
36929
36972
  catalog,
36930
36973
  paragraph?.numbering ?? numbering,
@@ -36937,29 +36980,44 @@ function createNumberingPrefixResolver(catalog) {
36937
36980
  if (!resolvedNumbering) {
36938
36981
  return null;
36939
36982
  }
36940
- const sequenceState = getSequenceState(sequenceStates, resolvedNumbering.numberingInstanceId);
36941
- 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];
36942
36995
  const effectiveLevelDefs = resolved.effectiveLevel.isLegalNumbering ? new Map(
36943
36996
  Array.from(resolved.effectiveLevels.entries()).map(([level, definition]) => [
36944
36997
  level,
36945
36998
  { ...definition, format: "decimal" }
36946
36999
  ])
36947
37000
  ) : resolved.effectiveLevels;
37001
+ const picBulletId = resolved.effectiveLevel.picBulletId;
36948
37002
  const text = renderLevelText(
36949
37003
  resolved.effectiveLevel.text,
36950
- sequenceState.counters,
37004
+ workingState.counters,
36951
37005
  effectiveLevelDefs
36952
37006
  );
36953
- if (resolved.effectiveLevel.format !== "none" && text === null) {
37007
+ if (picBulletId == null && resolved.effectiveLevel.format !== "none" && text === null) {
36954
37008
  return null;
36955
37009
  }
36956
37010
  const visibleText = resolved.effectiveLevel.format === "none" ? null : text;
36957
- const picBulletId = resolved.effectiveLevel.picBulletId;
37011
+ const formatPosture = getNumberingFormatPosture(
37012
+ resolved.effectiveLevel.format,
37013
+ currentCounter
37014
+ );
36958
37015
  const picBulletMediaId = picBulletId != null ? catalog.numPicBullets?.[picBulletId]?.mediaId : void 0;
36959
37016
  return {
36960
37017
  text: visibleText,
36961
37018
  level: resolved.effectiveLevel.level,
36962
37019
  format: resolved.effectiveLevel.format,
37020
+ ...formatPosture !== void 0 ? { formatPosture } : {},
36963
37021
  startAt: resolved.effectiveLevel.startAt ?? DEFAULT_NUMBERING_START_AT,
36964
37022
  ...resolved.effectiveLevel.suffix ? { suffix: resolved.effectiveLevel.suffix } : {},
36965
37023
  ...resolved.effectiveLevel.paragraphStyleId ? { paragraphStyleId: resolved.effectiveLevel.paragraphStyleId } : {},
@@ -36970,23 +37028,26 @@ function createNumberingPrefixResolver(catalog) {
36970
37028
  };
36971
37029
  }
36972
37030
  return {
36973
- resolve(numbering) {
36974
- const result = resolveInternal(numbering);
37031
+ resolve(numbering, options) {
37032
+ const result = resolveInternal(numbering, void 0, options);
36975
37033
  return result?.text ?? null;
36976
37034
  },
36977
- resolveDetailed(numbering, paragraph) {
36978
- return resolveInternal(numbering, paragraph);
37035
+ resolveDetailed(numbering, paragraph, options) {
37036
+ return resolveInternal(numbering, paragraph, options);
36979
37037
  },
36980
- resolveParagraph(paragraph) {
36981
- return resolveInternal(paragraph.numbering, paragraph);
37038
+ resolveParagraph(paragraph, options) {
37039
+ return resolveInternal(paragraph.numbering, paragraph, options);
36982
37040
  }
36983
37041
  };
36984
37042
  }
36985
- function getSequenceState(states, numberingInstanceId) {
37043
+ function getSequenceState(states, numberingInstanceId, options = { create: true }) {
36986
37044
  const existing = states.get(numberingInstanceId);
36987
37045
  if (existing) {
36988
37046
  return existing;
36989
37047
  }
37048
+ if (options.create === false) {
37049
+ return { counters: [], lastLevel: null };
37050
+ }
36990
37051
  const created = {
36991
37052
  counters: [],
36992
37053
  lastLevel: null
@@ -36994,6 +37055,12 @@ function getSequenceState(states, numberingInstanceId) {
36994
37055
  states.set(numberingInstanceId, created);
36995
37056
  return created;
36996
37057
  }
37058
+ function cloneSequenceState(state) {
37059
+ return {
37060
+ counters: [...state.counters],
37061
+ lastLevel: state.lastLevel
37062
+ };
37063
+ }
36997
37064
  function advanceSequence(state, currentLevel, levelDefinitions) {
36998
37065
  for (let level = currentLevel + 1; level < state.counters.length; level += 1) {
36999
37066
  if (shouldResetDeeperLevel(level, currentLevel, levelDefinitions)) {
@@ -37025,6 +37092,25 @@ function shouldResetDeeperLevel(level, triggeringLevel, levelDefinitions) {
37025
37092
  function getLevelStartAt(level, levelDefinitions) {
37026
37093
  return levelDefinitions.get(level)?.startAt ?? DEFAULT_NUMBERING_START_AT;
37027
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
+ }
37028
37114
  function renderLevelText(text, counters, levelDefinitions) {
37029
37115
  if (!text) {
37030
37116
  return null;
@@ -37867,6 +37953,7 @@ function toNumberingLayoutInput(numbering) {
37867
37953
  associatedTabStops: toLayoutTabStops(numbering.geometry.tabStops, "numbering"),
37868
37954
  level: numbering.level,
37869
37955
  format: numbering.format,
37956
+ ...numbering.formatPosture !== void 0 ? { formatPosture: { ...numbering.formatPosture } } : {},
37870
37957
  startAt: numbering.startAt,
37871
37958
  ...numbering.isLegalNumbering ? { isLegalNumbering: true } : {},
37872
37959
  ...numbering.picBulletMediaId ? { pictureBulletMediaId: numbering.picBulletMediaId } : {}
@@ -38096,13 +38183,10 @@ var FormattingContextImpl = class {
38096
38183
  const effectiveNumbering = this.resolveEffectiveParagraphNumbering(para);
38097
38184
  if (!effectiveNumbering) return null;
38098
38185
  if (!emitGeometry) {
38099
- if (advance) this.numbering.resolve(effectiveNumbering);
38186
+ this.numbering.resolve(effectiveNumbering, { advance });
38100
38187
  return null;
38101
38188
  }
38102
- if (!advance) {
38103
- console.warn("[formatting-context] resolveParagraphNumbering({advance:false}) is not supported; counter always advances");
38104
- }
38105
- return this.numbering.resolveDetailed(effectiveNumbering, para);
38189
+ return this.numbering.resolveDetailed(effectiveNumbering, para, { advance });
38106
38190
  }
38107
38191
  resolveNumberingLayoutInput(para, options = {}) {
38108
38192
  return toNumberingLayoutInput(this.resolveParagraphNumbering(para, options));
@@ -39192,6 +39276,21 @@ function compileParagraphScope(entry, options = {}) {
39192
39276
  partial: true
39193
39277
  };
39194
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
+ }
39195
39294
  function compileParagraphReplacement(entry, proposed, options) {
39196
39295
  if (proposed.operation !== "replace" && proposed.operation !== "insert-before" && proposed.operation !== "insert-after") {
39197
39296
  return null;
@@ -39247,6 +39346,7 @@ function compileParagraphReplacement(entry, proposed, options) {
39247
39346
  {
39248
39347
  kind: stepKind,
39249
39348
  summary: stepKind === "text-replace" ? actionSummary : `suggest-mode ${actionSummary}`,
39349
+ ...textLeafEditableTargetHint(entry, blockRange) ? { editableTargetHint: textLeafEditableTargetHint(entry, blockRange) } : {},
39250
39350
  range: { from: operationRange.from, to: operationRange.to },
39251
39351
  text,
39252
39352
  ...proposed.formatting ? { formatting: proposed.formatting } : {}
@@ -39274,6 +39374,7 @@ function compileParagraphReplacement(entry, proposed, options) {
39274
39374
  {
39275
39375
  kind: "fragment-replace",
39276
39376
  summary: actionSummary,
39377
+ ...textLeafEditableTargetHint(entry, blockRange) ? { editableTargetHint: textLeafEditableTargetHint(entry, blockRange) } : {},
39277
39378
  range: { from: operationRange.from, to: operationRange.to },
39278
39379
  fragment
39279
39380
  }
@@ -42315,6 +42416,24 @@ function refusalIdForPostureBlocker(target, blocker2) {
42315
42416
  return "editable_target_opaque_content";
42316
42417
  case "synthetic-layout-cell":
42317
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";
42318
42437
  case "unmodeled-target":
42319
42438
  return target.commandFamily === "link-bookmark" ? "editable_target_linked_content_unmodeled" : "editable_target_unmodeled";
42320
42439
  }
@@ -42337,12 +42456,42 @@ function auditCategoryForPostureBlocker(target, blocker2) {
42337
42456
  return target.commandFamily === "link-bookmark" ? "linked-content" : "unsupported-command";
42338
42457
  case "synthetic-layout-cell":
42339
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";
42340
42471
  }
42341
42472
  }
42342
42473
  function messageForPostureBlocker(blocker2) {
42343
42474
  switch (blocker2) {
42344
42475
  case "synthetic-layout-cell":
42345
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.";
42346
42495
  default:
42347
42496
  return void 0;
42348
42497
  }
@@ -48024,6 +48173,7 @@ function toSurfaceResolvedNumbering(numbering) {
48024
48173
  return {
48025
48174
  level: numbering.level,
48026
48175
  format: numbering.format,
48176
+ ...numbering.formatPosture !== void 0 ? { formatPosture: { ...numbering.formatPosture } } : {},
48027
48177
  ...numbering.text !== null ? { text: numbering.text } : {},
48028
48178
  startAt: numbering.startAt,
48029
48179
  ...numbering.paragraphStyleId ? { paragraphStyleId: numbering.paragraphStyleId } : {},
@@ -52347,8 +52497,9 @@ function projectSurfaceBlocksToPageFragments(surface, pages, splits, columnByBlo
52347
52497
  const perPageCounter = /* @__PURE__ */ new Map();
52348
52498
  const fieldRegionsByParagraphIndex = buildFieldRegionsByParagraphIndex(fieldRegions);
52349
52499
  const generatedTargets = buildGeneratedTargets(editableTargets);
52500
+ const numberingTargets = buildNumberingTargets(editableTargets);
52350
52501
  const bookmarkRanges = buildBookmarkRanges(editableTargets);
52351
- const numberingByParagraphIndex = buildNumberingByParagraphIndex(numberingInputs);
52502
+ const numberingIndex = buildNumberingInputIndex(numberingInputs);
52352
52503
  const pushFragment = (pageIndex, fragment) => {
52353
52504
  const existing = byPage.get(pageIndex);
52354
52505
  if (existing) {
@@ -52384,8 +52535,9 @@ function projectSurfaceBlocksToPageFragments(surface, pages, splits, columnByBlo
52384
52535
  },
52385
52536
  fieldRegionsByParagraphIndex,
52386
52537
  generatedTargets,
52538
+ numberingTargets,
52387
52539
  bookmarkRanges,
52388
- numberingByParagraphIndex,
52540
+ numberingIndex,
52389
52541
  blockPath
52390
52542
  );
52391
52543
  continue;
@@ -52406,8 +52558,9 @@ function projectSurfaceBlocksToPageFragments(surface, pages, splits, columnByBlo
52406
52558
  },
52407
52559
  fieldRegionsByParagraphIndex,
52408
52560
  generatedTargets,
52561
+ numberingTargets,
52409
52562
  bookmarkRanges,
52410
- numberingByParagraphIndex,
52563
+ numberingIndex,
52411
52564
  blockPath
52412
52565
  );
52413
52566
  continue;
@@ -52439,8 +52592,9 @@ function projectSurfaceBlocksToPageFragments(surface, pages, splits, columnByBlo
52439
52592
  paginationRole: "whole",
52440
52593
  fieldRegionsByParagraphIndex,
52441
52594
  generatedTargets,
52595
+ numberingTargets,
52442
52596
  bookmarkRanges,
52443
- numberingByParagraphIndex,
52597
+ numberingIndex,
52444
52598
  blockPath
52445
52599
  }),
52446
52600
  ...columnIndex !== void 0 ? { columnIndex } : {}
@@ -52587,7 +52741,7 @@ function buildRunAnchorsForLine(input) {
52587
52741
  }
52588
52742
  return anchors;
52589
52743
  }
52590
- 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) {
52591
52745
  for (let i = 0; i < slices.length; i += 1) {
52592
52746
  const slice = slices[i];
52593
52747
  const heightTwips = slice.heightTwips ?? estimateSliceHeightFromLines(slice.lineRange);
@@ -52612,8 +52766,9 @@ function emitSlicedParagraph(block, slices, emit2, fieldRegionsByParagraphIndex
52612
52766
  paginationRole: slice.lineRange.from > 0 ? "continuation" : "slice",
52613
52767
  fieldRegionsByParagraphIndex,
52614
52768
  generatedTargets,
52769
+ numberingTargets,
52615
52770
  bookmarkRanges,
52616
- numberingByParagraphIndex,
52771
+ numberingIndex,
52617
52772
  blockPath
52618
52773
  })
52619
52774
  };
@@ -52634,7 +52789,7 @@ function estimateSliceHeightFromLines(lineRange) {
52634
52789
  const lines = Math.max(0, lineRange.to - lineRange.from);
52635
52790
  return lines * 240;
52636
52791
  }
52637
- 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) {
52638
52793
  for (let i = 0; i < slices.length; i += 1) {
52639
52794
  const slice = slices[i];
52640
52795
  const heightTwips = slice.heightTwips ?? estimateSliceHeightFromRows(slice.rowRange);
@@ -52658,8 +52813,9 @@ function emitSlicedTable(block, slices, emit2, fieldRegionsByParagraphIndex = /*
52658
52813
  paginationRole: slice.rowRange.from > 0 ? "continuation" : "slice",
52659
52814
  fieldRegionsByParagraphIndex,
52660
52815
  generatedTargets,
52816
+ numberingTargets,
52661
52817
  bookmarkRanges,
52662
- numberingByParagraphIndex,
52818
+ numberingIndex,
52663
52819
  blockPath
52664
52820
  }),
52665
52821
  ...slice.columnIndex !== void 0 ? { columnIndex: slice.columnIndex } : {}
@@ -52733,7 +52889,8 @@ function buildFragmentLayoutObject(input) {
52733
52889
  const numberingRows = collectNumberingLayoutFactsForBlock(
52734
52890
  input.block,
52735
52891
  input.blockPath,
52736
- input.numberingByParagraphIndex
52892
+ input.numberingIndex,
52893
+ input.numberingTargets
52737
52894
  );
52738
52895
  const numbering = input.block.kind === "paragraph" ? numberingRows[0] : void 0;
52739
52896
  const fieldRegions = collectFieldRegionLayoutFacts(
@@ -52904,6 +53061,11 @@ function buildGeneratedTargets(targets) {
52904
53061
  (target) => target.kind === "field-result-text" || target.kind === "hyperlink-text" || target.kind === "hyperlink-destination" || target.kind === "bookmark-anchor" || target.kind === "bookmark-content-range"
52905
53062
  );
52906
53063
  }
53064
+ function buildNumberingTargets(targets) {
53065
+ return targets.filter(
53066
+ (target) => target.listAddress !== void 0 || target.canonicalAddress?.addressKind === "list-item-text"
53067
+ );
53068
+ }
52907
53069
  function buildBookmarkRanges(targets) {
52908
53070
  const anchors = /* @__PURE__ */ new Map();
52909
53071
  const contentRanges = /* @__PURE__ */ new Map();
@@ -52951,14 +53113,27 @@ function buildBookmarkRanges(targets) {
52951
53113
  }
52952
53114
  return ranges;
52953
53115
  }
52954
- 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();
52955
53124
  const byParagraph = /* @__PURE__ */ new Map();
52956
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
+ }
52957
53132
  if (!byParagraph.has(input.paragraphIndex)) {
52958
53133
  byParagraph.set(input.paragraphIndex, input);
52959
53134
  }
52960
53135
  }
52961
- return byParagraph;
53136
+ return { byNumberingKey, byBlockPath, byParagraphIndex: byParagraph };
52962
53137
  }
52963
53138
  function collectBookmarkRangeLayoutFacts(fragmentId, blockPath, bookmarkRanges) {
52964
53139
  if (!blockPath || !bookmarkRanges || bookmarkRanges.length === 0) return [];
@@ -53039,6 +53214,7 @@ function collectNumberingLayoutFacts(block) {
53039
53214
  ...block.numbering?.numberingInstanceId !== void 0 ? { numberingInstanceId: block.numbering.numberingInstanceId } : {},
53040
53215
  ...block.numbering?.level !== void 0 ? { level: block.numbering.level } : {},
53041
53216
  ...block.resolvedNumbering?.format !== void 0 ? { format: block.resolvedNumbering.format } : {},
53217
+ ...block.resolvedNumbering?.formatPosture !== void 0 ? { formatPosture: { ...block.resolvedNumbering.formatPosture } } : {},
53042
53218
  ...block.numberingPrefix !== void 0 ? { markerText: block.numberingPrefix } : {},
53043
53219
  ...block.numberingSuffix !== void 0 ? { markerSuffix: block.numberingSuffix } : {},
53044
53220
  ...block.resolvedNumbering?.geometry.markerJustification !== void 0 ? { markerJustification: block.resolvedNumbering.geometry.markerJustification } : {},
@@ -53066,15 +53242,21 @@ function collectNumberingLayoutFacts(block) {
53066
53242
  } : {}
53067
53243
  };
53068
53244
  }
53069
- function collectNumberingLayoutFactsForBlock(block, blockPath, numberingByParagraphIndex) {
53245
+ function collectNumberingLayoutFactsForBlock(block, blockPath, numberingIndex, numberingTargets = []) {
53070
53246
  const rows = [];
53071
53247
  const seen = /* @__PURE__ */ new Set();
53072
53248
  visitParagraphBlocks(block, (paragraph, context) => {
53073
53249
  const numbering = collectNumberingLayoutFacts(paragraph);
53074
53250
  if (!numbering) return;
53075
53251
  const paragraphIndex = parseParagraphBlockIndex(paragraph.blockId);
53076
- const canonical = paragraphIndex !== void 0 ? numberingByParagraphIndex?.get(paragraphIndex) : void 0;
53077
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);
53078
53260
  const numberingLayoutId = numberingKey ?? [
53079
53261
  "numbering",
53080
53262
  paragraph.blockId,
@@ -53083,6 +53265,7 @@ function collectNumberingLayoutFactsForBlock(block, blockPath, numberingByParagr
53083
53265
  ].join(":");
53084
53266
  if (seen.has(numberingLayoutId)) return;
53085
53267
  seen.add(numberingLayoutId);
53268
+ const unavailableReasons = collectNumberingUnavailableReasons(numbering, canonical);
53086
53269
  rows.push({
53087
53270
  numberingLayoutId,
53088
53271
  ...numberingKey !== void 0 ? { numberingKey } : {},
@@ -53090,6 +53273,10 @@ function collectNumberingLayoutFactsForBlock(block, blockPath, numberingByParagr
53090
53273
  ...canonical?.blockPath !== void 0 ? { sourceBlockPath: canonical.blockPath } : context.path !== void 0 ? { sourceBlockPath: context.path } : {},
53091
53274
  sourceBlockId: paragraph.blockId,
53092
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 } : {},
53093
53280
  ...canonical?.sourceRef !== void 0 ? { sourceRef: { ...canonical.sourceRef } } : {},
53094
53281
  ...canonical?.numberingSourceRef !== void 0 ? { numberingSourceRef: { ...canonical.numberingSourceRef } } : {},
53095
53282
  ...canonical?.numberingOrigin !== void 0 ? { numberingOrigin: canonical.numberingOrigin } : {},
@@ -53097,11 +53284,41 @@ function collectNumberingLayoutFactsForBlock(block, blockPath, numberingByParagr
53097
53284
  ...canonical?.numberingInstanceSourceRef !== void 0 ? { numberingInstanceSourceRef: { ...canonical.numberingInstanceSourceRef } } : {},
53098
53285
  ...canonical?.abstractNumberingId !== void 0 ? { abstractNumberingId: canonical.abstractNumberingId } : {},
53099
53286
  ...canonical?.abstractNumberingSourceRef !== void 0 ? { abstractNumberingSourceRef: { ...canonical.abstractNumberingSourceRef } } : {},
53100
- ...numbering
53287
+ ...numbering,
53288
+ ...unavailableReasons.length > 0 ? { unavailableReasons } : {}
53101
53289
  });
53102
53290
  }, blockPath);
53103
53291
  return rows;
53104
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
+ }
53105
53322
  function findPageIndexForOffset(pages, offset) {
53106
53323
  for (let i = 0; i < pages.length; i += 1) {
53107
53324
  const page = pages[i];
@@ -56557,19 +56774,19 @@ function locateTargetRange(document2, surface, target) {
56557
56774
  if (!sdt || sdt.kind !== "sdt_block") return null;
56558
56775
  const paragraph = sdt.children[sdtPath.childIndex];
56559
56776
  if (!paragraph || paragraph.kind !== "paragraph") return null;
56560
- return { from: paragraph.from, to: paragraph.to };
56777
+ return textLeafTargetRange(target, paragraph.from, paragraph.to);
56561
56778
  }
56562
56779
  const paragraphPath = parseTopLevelParagraphPath(target.blockPath);
56563
56780
  if (paragraphPath) {
56564
56781
  const paragraph = surface[paragraphPath.blockIndex];
56565
56782
  if (!paragraph || paragraph.kind !== "paragraph") return null;
56566
- return { from: paragraph.from, to: paragraph.to };
56783
+ return textLeafTargetRange(target, paragraph.from, paragraph.to);
56567
56784
  }
56568
56785
  const secondaryParagraphPath = parseSecondaryStoryParagraphPath(target.blockPath);
56569
56786
  if (secondaryParagraphPath) {
56570
56787
  const paragraph = surface[secondaryParagraphPath.blockIndex];
56571
56788
  if (!paragraph || paragraph.kind !== "paragraph") return null;
56572
- return { from: paragraph.from, to: paragraph.to };
56789
+ return textLeafTargetRange(target, paragraph.from, paragraph.to);
56573
56790
  }
56574
56791
  if (target.kind === "textbox-paragraph-text") {
56575
56792
  return {
@@ -56585,6 +56802,18 @@ function locateTargetRange(document2, surface, target) {
56585
56802
  }
56586
56803
  return null;
56587
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
+ }
56588
56817
  function locateHyperlinkDisplayRange(document2, surface, target) {
56589
56818
  const canonical = resolveHyperlinkDisplayPath(document2, target.blockPath);
56590
56819
  if (!canonical) return null;
@@ -57704,6 +57933,17 @@ var hyperlinkDestinationEditMetadata = actionMethodMetadata(
57704
57933
  expectedDelta: "hyperlink destination changes"
57705
57934
  }
57706
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
+ );
57707
57947
  var listOperationMetadata = actionMethodMetadata(
57708
57948
  "listOperation",
57709
57949
  "mutate",
@@ -57763,6 +58003,7 @@ var ACTION_METHODS = Object.freeze([
57763
58003
  "tocRefresh",
57764
58004
  "bookmarkEdit",
57765
58005
  "hyperlinkDestinationEdit",
58006
+ "hyperlinkTextEdit",
57766
58007
  "listOperation",
57767
58008
  "tableFragment",
57768
58009
  "tableSelection",
@@ -57772,6 +58013,9 @@ var DEFAULT_LOCATE_LIMIT = 20;
57772
58013
  var DEFAULT_REWRITE_ALL_LIMIT = 10;
57773
58014
  var DEFAULT_TABLE_TEXT_SCOPE_LIMIT = 3;
57774
58015
  var DEFAULT_PLAN_STEP_LIMIT = 20;
58016
+ function documentContentHash(runtime) {
58017
+ return JSON.stringify(runtime.getCanonicalDocument().content);
58018
+ }
57775
58019
  function createActionsFamily(runtime) {
57776
58020
  const category = {
57777
58021
  discover(input) {
@@ -58018,6 +58262,14 @@ function createActionsFamily(runtime) {
58018
58262
  ...readback ? { text: readback.text, excerpt: excerpt(readback.text) } : {}
58019
58263
  };
58020
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
+ }
58021
58273
  const text = resolved.target.scope.content.text;
58022
58274
  return {
58023
58275
  status: "read",
@@ -58098,6 +58350,31 @@ function createActionsFamily(runtime) {
58098
58350
  input
58099
58351
  );
58100
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
+ },
58101
58378
  listOperation(input) {
58102
58379
  return applyListOperation(runtime, input);
58103
58380
  },
@@ -58146,6 +58423,7 @@ function runPlan(runtime, input) {
58146
58423
  for (const step of input.steps) {
58147
58424
  const result = runPlanStep(runtime, mode, step, input);
58148
58425
  results.push(result);
58426
+ if (isSuspectMutationStep(result)) break;
58149
58427
  if (stopOnBlocker && (result.status === "blocked" || result.status === "unsupported")) {
58150
58428
  break;
58151
58429
  }
@@ -58210,24 +58488,27 @@ function runPlanStep(runtime, mode, step, plan) {
58210
58488
  ...before.readback ? { beforeReadback: before.readback } : {}
58211
58489
  };
58212
58490
  }
58491
+ const documentHashBeforeApply = documentContentHash(runtime);
58213
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;
58214
58495
  const after = step.kind === "flag" ? before : step.target ? readPlanTarget(runtime, step.target) : before;
58215
58496
  return {
58216
58497
  id: step.id,
58217
58498
  kind: step.kind,
58218
- status: applied.status === "unsupported" ? "unsupported" : applied.applied ? "applied" : "blocked",
58219
- applied: applied.applied,
58220
- changed: applied.changed,
58221
- ...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 } : {},
58222
58503
  ...before.tableAction ? { tableAction: before.tableAction } : {},
58223
58504
  ...before.readback ? { beforeReadback: before.readback } : {},
58224
58505
  ...after.ok && after.readback ? { afterReadback: after.readback } : {},
58225
- ...applied.proposalId ? { proposalId: applied.proposalId } : {},
58226
- ...applied.posture ? { posture: applied.posture } : {},
58227
- ...applied.blockers ? { blockers: applied.blockers } : {},
58228
- ...applied.blockerDetails ? { blockerDetails: applied.blockerDetails } : {},
58229
- ...applied.auditReference ? { auditReference: applied.auditReference } : {},
58230
- ...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 } : {}
58231
58512
  };
58232
58513
  }
58233
58514
  function runPlanTableActionStep(runtime, mode, step, plan) {
@@ -58355,6 +58636,23 @@ function locateAll(runtime, input) {
58355
58636
  isEmpty: text.trim().length === 0
58356
58637
  });
58357
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
+ }
58358
58656
  if (matches.length < limit && shouldScanTableText) {
58359
58657
  const tableTextScopeLimit = Math.max(
58360
58658
  0,
@@ -58389,23 +58687,27 @@ function locateAll(runtime, input) {
58389
58687
  function resolveTarget(runtime, target) {
58390
58688
  if ("actionHandle" in target) {
58391
58689
  const action = findTableAction(runtime, target.actionHandle);
58392
- if (!action) {
58393
- return blockedResolution(
58394
- `actions:target:action-handle-not-found:${target.actionHandle}`,
58395
- "unresolved-target",
58396
- "No current table text action matches the supplied actionHandle.",
58397
- "Call ai.actions.locateAll or ai.listTableActions again and retry with a fresh actionHandle."
58398
- );
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 } };
58399
58700
  }
58400
- if (action.family !== "table-text") {
58401
- return blockedResolution(
58402
- `actions:target:action-handle-not-text:${target.actionHandle}`,
58403
- "unsupported",
58404
- "This actionHandle is not a table text action.",
58405
- "Use table structure handles with ai.applyTableAction, or use a table text actionHandle for rewrite."
58406
- );
58701
+ const editableTextAction = findEditableTextAction(runtime, target.actionHandle);
58702
+ if (editableTextAction) {
58703
+ return { ok: true, target: editableTextAction };
58407
58704
  }
58408
- 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
+ );
58409
58711
  }
58410
58712
  if ("handle" in target) {
58411
58713
  const compiled = createScopeCompilerService(runtime).compileScopeById(target.handle.scopeId);
@@ -58490,7 +58792,21 @@ function applyRewrite(runtime, target, input) {
58490
58792
  ...result2.afterReadback ? { afterReadback: result2.afterReadback } : {}
58491
58793
  };
58492
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
+ }
58493
58808
  const beforeText = target.scope.content.text;
58809
+ const documentHashBeforeApply = documentContentHash(runtime);
58494
58810
  const result = createReplacementFamily(runtime).applyReplacementScope({
58495
58811
  targetScopeId: target.handle.scopeId,
58496
58812
  operation: "replace",
@@ -58502,7 +58818,22 @@ function applyRewrite(runtime, target, input) {
58502
58818
  ...input.origin ? { origin: input.origin } : {},
58503
58819
  ...input.proposalId ? { proposalId: input.proposalId } : {}
58504
58820
  });
58505
- 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
+ );
58506
58837
  }
58507
58838
  function projectApplyResult(result, target) {
58508
58839
  return {
@@ -58523,7 +58854,79 @@ function projectApplyResult(result, target) {
58523
58854
  ...result.auditReference ? { auditReference: result.auditReference } : {}
58524
58855
  };
58525
58856
  }
58526
- 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) {
58527
58930
  if (!result.applied) return projectApplyResult(result, target);
58528
58931
  const compiledAfter = createScopeCompilerService(runtime).compileScopeById(
58529
58932
  target.handle.scopeId
@@ -58534,7 +58937,8 @@ function projectRewriteScopeResult(runtime, result, target, beforeText, proposed
58534
58937
  target,
58535
58938
  `actions:rewrite:authoritative-readback-unresolvable:${target.handle.scopeId}`,
58536
58939
  "The replacement primitive reported success, but the target scope could not be re-read afterwards.",
58537
- "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
58538
58942
  );
58539
58943
  }
58540
58944
  const afterText = compiledAfter.scope.content.text;
@@ -58546,7 +58950,8 @@ function projectRewriteScopeResult(runtime, result, target, beforeText, proposed
58546
58950
  { ...target, scope: compiledAfter.scope, handle: compiledAfter.scope.handle },
58547
58951
  `actions:rewrite:authoritative-readback-unchanged:${target.handle.scopeId}`,
58548
58952
  "The replacement primitive reported success, but authoritative scope readback showed unchanged text.",
58549
- "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
58550
58955
  );
58551
58956
  }
58552
58957
  if (!expectedPresent) {
@@ -58555,7 +58960,8 @@ function projectRewriteScopeResult(runtime, result, target, beforeText, proposed
58555
58960
  { ...target, scope: compiledAfter.scope, handle: compiledAfter.scope.handle },
58556
58961
  `actions:rewrite:authoritative-readback-mismatch:${target.handle.scopeId}`,
58557
58962
  "The replacement primitive reported success, but authoritative scope readback did not contain the proposed text.",
58558
- "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
58559
58965
  );
58560
58966
  }
58561
58967
  return {
@@ -58572,17 +58978,27 @@ function projectRewriteScopeResult(runtime, result, target, beforeText, proposed
58572
58978
  ...result.auditReference ? { auditReference: result.auditReference } : {}
58573
58979
  };
58574
58980
  }
58575
- function blockedRewriteReadback(result, target, code, message, nextStep) {
58981
+ function blockedRewriteReadback(result, target, code, message, nextStep, documentMutated = false) {
58576
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];
58577
58993
  return {
58578
58994
  status: "blocked",
58579
58995
  applied: false,
58580
- changed: false,
58996
+ changed: documentMutated,
58581
58997
  target: summarizeTarget(target),
58582
58998
  proposalId: result.proposalId,
58583
- posture: "suspect-readback",
58584
- blockers: Object.freeze([detail.code]),
58585
- 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),
58586
59002
  ...result.auditReference ? { auditReference: result.auditReference } : {}
58587
59003
  };
58588
59004
  }
@@ -58598,11 +59014,23 @@ function summarizeTarget(target) {
58598
59014
  canMark: false
58599
59015
  };
58600
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
+ }
58601
59029
  return {
58602
59030
  kind: target.scope.kind,
58603
59031
  handle: target.handle,
58604
59032
  canRewriteText: canRewriteScopeText(target.scope),
58605
- canInsertAdjacentText: canRewriteScopeText(target.scope),
59033
+ canInsertAdjacentText: canInsertAdjacentScopeText(target.scope),
58606
59034
  canFlag: true,
58607
59035
  canMark: canMarkScope(target.scope)
58608
59036
  };
@@ -58614,6 +59042,34 @@ function tableTextActionsForScope(runtime, handle) {
58614
59042
  });
58615
59043
  return result.actions.filter((action) => action.family === "table-text");
58616
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
+ }
58617
59073
  function findTableAction(runtime, actionHandle) {
58618
59074
  const action = findAnyTableAction(runtime, actionHandle);
58619
59075
  return action?.family === "table-text" ? action : null;
@@ -58633,6 +59089,27 @@ function findAnyTableAction(runtime, actionHandle) {
58633
59089
  }
58634
59090
  return null;
58635
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
+ }
58636
59113
  function readDocumentPlanTarget(runtime) {
58637
59114
  const document2 = createInspectFamily(runtime).inspectDocument();
58638
59115
  return {
@@ -58689,6 +59166,18 @@ function readPlanTarget(runtime, target) {
58689
59166
  ])
58690
59167
  };
58691
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
+ }
58692
59181
  return readPlanTableAction(runtime, target.actionHandle);
58693
59182
  }
58694
59183
  function readPlanTableAction(runtime, actionHandle) {
@@ -58751,6 +59240,15 @@ function checkPlanStepCapability(runtime, step, before) {
58751
59240
  "Regenerate the plan with a ScopeHandle or opaque actionHandle returned by L09."
58752
59241
  );
58753
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
+ }
58754
59252
  if (step.kind === "rewrite" && !target.canRewriteText) {
58755
59253
  return blocker(
58756
59254
  `actions:plan:target-not-rewriteable:${step.id}`,
@@ -58783,7 +59281,20 @@ function checkPlanStepCapability(runtime, step, before) {
58783
59281
  "Use a supported semantic scope or create an issue flag instead."
58784
59282
  );
58785
59283
  }
58786
- 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
+ }
58787
59298
  const resolved = resolveScopeExactTarget(runtime, step.target, step.kind);
58788
59299
  if (!resolved.ok) return resolved.blockerDetails[0] ?? null;
58789
59300
  const targetRef = resolveModeledEditableTarget(runtime, resolved.target, step.kind);
@@ -58888,6 +59399,13 @@ function applyPlanStep(runtime, step, plan) {
58888
59399
  actorId: step.actorId ?? plan.actorId,
58889
59400
  origin: step.origin ?? plan.origin
58890
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
+ });
58891
59409
  case "listOperation":
58892
59410
  return createActionsFamily(runtime).actions.listOperation({
58893
59411
  target: step.target,
@@ -59204,11 +59722,159 @@ function isTableFamilyScope(kind) {
59204
59722
  return kind === "table" || kind === "table-row" || kind === "table-cell";
59205
59723
  }
59206
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) {
59207
59728
  return !isTableFamilyScope(scope.kind) && (scope.replaceability.level === "full" || scope.replaceability.level === "text-only");
59208
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
+ }
59209
59750
  function canMarkScope(scope) {
59210
59751
  return !isTableFamilyScope(scope.kind) && scope.replaceability.level !== "blocked" && scope.replaceability.level !== "preserve-only";
59211
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
+ }
59212
59878
  function textMatches(text, query, matchCase) {
59213
59879
  if (matchCase) return text.includes(query);
59214
59880
  return text.toLocaleLowerCase().includes(query.toLocaleLowerCase());
@@ -59267,6 +59933,30 @@ function blockedApplyFromResolution(resolution) {
59267
59933
  blockerDetails: resolution.blockerDetails
59268
59934
  };
59269
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
+ }
59270
59960
  function blockedPlan(mode, code, category, message, nextStep) {
59271
59961
  const detail = blocker(code, category, message, nextStep);
59272
59962
  return {