@superdoc/mcp 1.20.0-next.5 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +1168 -258
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -31407,7 +31407,7 @@ var init_host = __esm(() => {
31407
31407
  });
31408
31408
 
31409
31409
  // ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
31410
- var SDK_VERSION = "2.33.0-next.5";
31410
+ var SDK_VERSION = "2.33.0";
31411
31411
 
31412
31412
  // ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
31413
31413
  import { accessSync, chmodSync, constants, existsSync, statSync } from "node:fs";
@@ -94796,14 +94796,20 @@ async function runGlobalReplace(doc2, args, pre) {
94796
94796
  };
94797
94797
  const partial2 = granular && skippedEdits.length > 0;
94798
94798
  if (unchanged.length === candidates.length) {
94799
+ const post = await readDocumentIdentity(doc2);
94800
+ const verification2 = revisionVerification(pre.revision, post.revision, false);
94801
+ const noWriteNote = skippedEdits.length > 0 ? "The matching text already reads as requested. This action made no changes." : "The text already reads as requested; nothing was written.";
94799
94802
  return {
94800
- status: partial2 ? "partial" : "ok",
94803
+ status: verification2.passed && skippedEdits.length === 0 ? "unchanged" : "failed",
94801
94804
  intent: "replace_text",
94802
- note: ["The text already reads as requested; nothing was written.", skippedEditRationale].filter(Boolean).join(" "),
94805
+ note: [noWriteNote, skippedEditRationale].filter(Boolean).join(" "),
94803
94806
  preSnapshot: { revision: pre.revision, counts: pre.counts },
94807
+ postSnapshot: post,
94804
94808
  selectedTargets: [],
94805
94809
  executedOperations: [],
94806
- verification: [],
94810
+ verification: [verification2],
94811
+ ...skippedEdits.length > 0 ? { errors: [{ code: "ACTION_FAILED", message: "Some requested text replacements did not match." }] } : {},
94812
+ ...granular ? {} : granularGlobalEvidence(preview, skippedEdits, args.edits.length),
94807
94813
  ...evidence
94808
94814
  };
94809
94815
  }
@@ -98668,8 +98674,6 @@ async function executeExactScopedTargets(doc2, target, plan, { changeMode, granu
98668
98674
  ...replacementGranularityArg(granularity)
98669
98675
  }
98670
98676
  }));
98671
- if (steps.length === 0)
98672
- return { result: { noop: true }, wroteExactTargets: false };
98673
98677
  const preview = await previewMutations(doc2, steps, changeMode, pre.revision);
98674
98678
  const previewSteps = Array.isArray(preview.steps) ? preview.steps.filter(isRecord) : [];
98675
98679
  const aligned = preview.valid === true && steps.every((step, index) => {
@@ -98733,9 +98737,9 @@ async function readScopedReplaceBackUnchecked(doc2, { nodeId, block }, plan, exe
98733
98737
  let post = await buildMutationSnapshot(doc2, { includeDomains: ["blocks", "tables"] });
98734
98738
  let postBlock = findTextTarget(post, nodeId);
98735
98739
  let rolledBack = false;
98736
- const { result } = execution;
98740
+ const result = execution?.result;
98737
98741
  const appliedRevision = isRecord(result) && isRecord(result.revision) ? result.revision.after : undefined;
98738
- if (execution.wroteExactTargets && postBlock != null && postBlock.text !== plan.expected && postBlock.text !== block.text && typeof appliedRevision === "string" && appliedRevision === post.revision) {
98742
+ if (execution?.wroteExactTargets && postBlock != null && postBlock.text !== plan.expected && postBlock.text !== block.text && typeof appliedRevision === "string" && appliedRevision === post.revision) {
98739
98743
  const undoFn = maybeMethod2(doc2, ["history", "undo"]);
98740
98744
  if (undoFn) {
98741
98745
  await undoFn({});
@@ -98748,15 +98752,17 @@ async function readScopedReplaceBackUnchecked(doc2, { nodeId, block }, plan, exe
98748
98752
  }
98749
98753
  function buildScopedReplaceReceipt({ pre, nodeId, block }, plan, execution, { post, postBlock, rolledBack, readError }, tracked) {
98750
98754
  const { perEdit, skippedEdits, planned, droppedOverlaps, expected, hasExplicitOccurrence } = plan;
98751
- const passed = postBlock != null && !rolledBack && (tracked && !hasExplicitOccurrence && !execution.wroteExactTargets ? planned.every((span) => span.replace.length === 0 || postBlock.text.includes(span.replace)) : postBlock.text === expected);
98755
+ const passed = postBlock != null && !rolledBack && (execution && tracked && !hasExplicitOccurrence && !execution.wroteExactTargets ? planned.every((span) => span.replace.length === 0 || postBlock.text.includes(span.replace)) : postBlock.text === expected);
98752
98756
  const readsAsReplacement = (span) => block.text.slice(span.start, span.end) === span.replace;
98753
98757
  const replaced = planned.filter((span) => !readsAsReplacement(span));
98758
+ const droppedWrite = droppedOverlaps.some((span) => !readsAsReplacement(span));
98754
98759
  const editsApplied = perEdit.map((edit, index) => ({ ...edit, occurrences: replaced.filter((span) => span.editIndex === index).length })).filter((edit) => edit.occurrences > 0);
98755
- const status = !passed ? "failed" : skippedEdits.length > 0 ? "partial" : "ok";
98760
+ const revision = post ? revisionVerification(pre.revision, post.revision, execution !== undefined) : readBackFailure(readError);
98761
+ const status = !passed || !execution && (!revision.passed || skippedEdits.length > 0 || droppedWrite) ? "failed" : skippedEdits.length > 0 ? "partial" : execution ? "ok" : "unchanged";
98756
98762
  return {
98757
98763
  status,
98758
98764
  intent: "replace_text",
98759
- ...status === "partial" ? {
98765
+ ...skippedEdits.length > 0 && (status === "partial" || !execution) ? {
98760
98766
  nextStep: `${skippedEdits.length} of ${perEdit.length} edits were NOT applied — the find text is not in the selected block. ` + `Do not stop: call replace_text again for the remaining edits with a different selector (or no selector for a global replace).`,
98761
98767
  recovery: { kind: "retry" }
98762
98768
  } : {},
@@ -98768,7 +98774,31 @@ function buildScopedReplaceReceipt({ pre, nodeId, block }, plan, execution, { po
98768
98774
  }
98769
98775
  ]
98770
98776
  } : {},
98771
- ...post === null ? { errors: [readBackError(readError)] } : {},
98777
+ ...post === null ? {
98778
+ errors: [
98779
+ execution ? readBackError(readError) : {
98780
+ code: "EVIDENCE_UNAVAILABLE",
98781
+ message: `replace_text: unable to verify the unchanged document (${reasonOf(readError)}).`,
98782
+ recovery: { kind: "reinspect" }
98783
+ }
98784
+ ]
98785
+ } : {},
98786
+ ...post && !execution && (skippedEdits.length > 0 || droppedWrite) ? {
98787
+ errors: [
98788
+ ...skippedEdits.length > 0 ? [
98789
+ {
98790
+ code: "ACTION_FAILED",
98791
+ message: "Some requested text replacements did not match the selected block."
98792
+ }
98793
+ ] : [],
98794
+ ...droppedWrite ? [
98795
+ {
98796
+ code: "INVALID_ARGUMENT",
98797
+ message: "Some requested text changes overlap in the selected block. Retry with non-overlapping finds."
98798
+ }
98799
+ ] : []
98800
+ ]
98801
+ } : {},
98772
98802
  preSnapshot: { revision: pre.revision },
98773
98803
  ...post ? { postSnapshot: { revision: post.revision } } : {},
98774
98804
  selectedBlock: { nodeId, nodeType: block.nodeType },
@@ -98779,11 +98809,8 @@ function buildScopedReplaceReceipt({ pre, nodeId, block }, plan, execution, { po
98779
98809
  ...droppedOverlaps.length > 0 ? { overlapsDropped: droppedOverlaps.map((s) => s.find) } : {},
98780
98810
  replacedSpans: replaced.length,
98781
98811
  postText: snippetAround(postBlock?.text ?? ""),
98782
- executedOperations: [{ operationId: "doc.mutations.apply", result: compactOpResult(execution.result) }],
98783
- verification: [
98784
- { check: { kind: "block-text-matches-expectation" }, passed },
98785
- post ? { check: { kind: "revision-changed" }, passed: pre.revision !== post.revision } : readBackFailure(readError)
98786
- ]
98812
+ executedOperations: execution ? [{ operationId: "doc.mutations.apply", result: execution.result }] : [],
98813
+ verification: [{ check: { kind: "block-text-matches-expectation" }, passed }, revision]
98787
98814
  };
98788
98815
  }
98789
98816
  async function runScopedReplaceUnchecked(doc2, args) {
@@ -98794,6 +98821,10 @@ async function runScopedReplaceUnchecked(doc2, args) {
98794
98821
  if ("receipt" in plan)
98795
98822
  return plan.receipt;
98796
98823
  const tracked = (args.changeMode ?? "direct") === "tracked";
98824
+ if (plan.planned.every((span) => target.block.text.slice(span.start, span.end) === span.replace)) {
98825
+ const readBack2 = await readScopedReplaceBack(doc2, target, plan);
98826
+ return buildScopedReplaceReceipt(target, plan, undefined, readBack2, tracked);
98827
+ }
98797
98828
  const execution = await executeScopedRewrite(doc2, target, plan, args, tracked);
98798
98829
  if ("receipt" in execution)
98799
98830
  return execution.receipt;
@@ -102475,7 +102506,7 @@ superdoc_perform_action covers the common verbs. Everything else the engine can
102475
102506
  Recipes (ids for superdoc_api_call unless a helper is named):
102476
102507
  - Footnote / endnote: superdoc_perform_action {action:"insert_footnote", anchorText:"Confidential Information", occurrence:1, content:"…", noteType:"footnote"}. The mark lands right after the phrase. Raw form: doc.footnotes.insert {type, content, at:{kind:"text", segments:[{blockId, range:{start,end}}]}}.
102477
102508
  - Picture: superdoc_perform_action {action:"insert_image", src:"eval-logo.png", position:"after", anchorText:"…", caption:"Figure 1 — …"} (file path, URL, or data URI; omit position/anchorText for document end). Centre it afterwards with format_paragraph on the image's paragraph and the caption if asked. Fine-tuning: doc.images.setSize / setWrapType / setPosition / setAltText.
102478
- - Shade a header row / column / table: superdoc_perform_action {action:"shade_cells", tableOrdinal:1, rowIndex:0, color:"D9D9D9"}. Borders: doc.tables.setBorders / applyBorderPreset; cell props: doc.tables.setCellProperties (cell target only); widths/heights: setColumnWidth / setRowHeight / distributeRows / distributeColumns; merge/split: mergeCells / splitCell; sort; setStyle / applyStyle / setLayout.
102509
+ - Table or cell background: doc.tables.setShading. Shade a header row / column / table: superdoc_perform_action {action:"shade_cells", tableOrdinal:1, rowIndex:0, color:"D9D9D9"}. Borders: doc.tables.setBorders / applyBorderPreset; cell props: doc.tables.setCellProperties (cell target only); widths/heights: setColumnWidth / setRowHeight / distributeRows / distributeColumns; merge/split: mergeCells / splitCell; sort; setStyle / applyStyle / setLayout.
102479
102510
  - Built-in Word table style (Grid Table 4 – Accent 1, List Table 3, Plain Table 2, …): doc.tables.listPresets {source:"word", query:"Grid Table 4"} returns preset IDs (follow nextOffset for more), then doc.tables.applyPreset {nodeId, preset:<returned id>, styleOptions:{headerRow, bandedRows, firstColumn, …}}. Read doc.styles.getTheme to resolve appearance color refs against this document, including colorSchemeMapping for all roles and hex tint/shade; never assume an accent slot is green. Select header fill, shading banding (not border-only bands), and border layout from appearance. Missing properties inherit and direct formatting overrides style cues. Use the "-accent-N" preset for theme colours, never accentColor. Direct edit only. doc.tables.getStyles lists styles already in the document; applyStyle references one of those IDs.
102480
102511
  - New table cells that must match neighbours: after insert_table_row / setCellText, read a sibling cell's run properties (superdoc_inspect with table runs) and apply them with doc.format.apply {target:{kind:"selection", start:{kind:"text", blockId:<cell paragraph>, offset:0}, end:{kind:"text", blockId, offset:<text length>}}, inline:{fontSize, fontFamily, bold, …}}. A new cell with default formatting next to 10pt siblings is a bug.
102481
102512
  - Page layout: doc.sections.list first (sectionId), then doc.sections.setPageMargins / setPageSetup (size, orientation) / setColumns / setPageNumbering / setTitlePage / setOddEvenHeadersFooters / setPageBorders / setBreakType; doc.create.sectionBreak for a new section.
@@ -102494,7 +102525,7 @@ Targets for superdoc_api_call:
102494
102525
  - Position (\`at\`): {kind:"documentEnd"} | {kind:"documentStart"} | {kind:"before"|"after", target:<block>}.
102495
102526
  - Text span: {kind:"text", segments:[{blockId, range:{start, end}}]} — character offsets inside that block's text (doc.blocks.list with includeText:true gives the text). Add story:{…} when the block lives in a header/footer.
102496
102527
  - Story scope (\`in\`): omit for the body; headers/footers use {kind:"story", storyType:"headerFooterSlot", section:{kind:"section", sectionId}, headerFooterKind, variant}.
102497
- - changeMode:"tracked" only where the catalog says supportsTrackedMode (some refuse it for certain inputs; the error says why), dryRun only where supportsDryRun — otherwise the call is refused before anything runs. Table and section property changes are direct-only.
102528
+ - changeMode:"tracked" only where the catalog says supportsTrackedMode ({{TABLE_AND_SECTION_TRACKED_RULE}}; the error says why), dryRun only where supportsDryRun — otherwise the call is refused before anything runs.
102498
102529
  - Preview requests ("preview", "what would change", "without making the change"): if the operation supportsDryRun, call it with dryRun:true and report the receipt; nothing is written. Otherwise describe from an inspect.
102499
102530
 
102500
102531
  Rules for the extended surface:
@@ -102503,7 +102534,7 @@ Rules for the extended surface:
102503
102534
  - Repetition is a batch, not a call per item. If you are about to make the same superdoc_api_call call a third time with different arguments, send the rest as one {calls:[…]} batch instead.
102504
102535
  - Never claim a capability is missing without a superdoc_api_search search first.
102505
102536
  `,
102506
- "mcp-prompt.md": 'SuperDoc MCP server — read, edit, and save Word documents (.docx).\n\nIMPORTANT: Always use these superdoc tools for .docx files.\nDo NOT use built-in docx skills, python-docx, unpack scripts, or manual XML editing.\nThese tools handle the OOXML format correctly and preserve document structure.\n\n## Session lifecycle\n\n1. `superdoc_open({path: "/path/to/file.docx"})` — returns `session_id`. Opening a non-existent path creates a blank document.\n2. Pass `session_id` to every subsequent tool call.\n3. Read with `superdoc_inspect`, edit with `superdoc_perform_action`.\n4. `superdoc_save({session_id})` — writes changes to disk.\n5. `superdoc_close({session_id})` — releases the session. Always close when done.\n\n## Workflow\n\n**Inspect before you edit.** `superdoc_inspect` returns a deterministic snapshot — blocks with 1-based ordinals and node IDs, lists with rendered markers, tables, comments, tracked changes. Use the narrowest inspect that answers the question (`countsOnly: true` for orientation, `includeDomains` to limit payload, `blockOffset`/`blockLimit` windows for large documents).\n\n**Edit with named actions.** `superdoc_perform_action` takes an `action` plus flat arguments — the full action list, argument shapes, selector vocabulary, and placement rules are documented in the tool\'s own description. Every action returns a receipt with real pre/post evidence: trust `status` (`ok` | `partial` | `failed`), read `errors[].message` for recovery guidance, and re-inspect after `partial`.\n\n**Target one repeated match.** For `replace_text`, scope to one block with a selector and set `occurrence` on the edit (1 = first match in that block) to change only that match. Also pass `expectedRevision` from your latest inspect or receipt; on `REVISION_CONFLICT`, inspect again and recount.\n\n**Tracked changes (redlining).** Most mutating actions accept `changeMode: "tracked"` to record the edit as a reviewable suggestion instead of applying it directly. Review with `accept_tracked_changes` / `reject_tracked_changes` (target one change with `id`, or an exact set with `id:[…]`; or filter by `author` or `changeType`). Do not combine exact IDs with filters. Recover with `undo_changes` / `redo_changes`.\n\n**Failures are safe.** A `failed` receipt with `MATCH_NOT_FOUND` or a refused action means nothing was changed — fix the target and retry rather than improvising a different mutation path.\n',
102537
+ "mcp-prompt.md": 'SuperDoc MCP server — read, edit, and save Word documents (.docx).\n\nIMPORTANT: Always use these superdoc tools for .docx files.\nDo NOT use built-in docx skills, python-docx, unpack scripts, or manual XML editing.\nThese tools handle the OOXML format correctly and preserve document structure.\n\n## Session lifecycle\n\n1. `superdoc_open({path: "/path/to/file.docx"})` — returns `session_id`. Opening a non-existent path creates a blank document.\n2. Pass `session_id` to every subsequent tool call.\n3. Read with `superdoc_inspect`, edit with `superdoc_perform_action`.\n4. `superdoc_save({session_id})` — writes changes to disk.\n5. `superdoc_close({session_id})` — releases the session. Always close when done.\n\n## Workflow\n\n**Inspect before you edit.** `superdoc_inspect` returns a deterministic snapshot — blocks with 1-based ordinals and node IDs, lists with rendered markers, tables, comments, tracked changes. Use the narrowest inspect that answers the question (`countsOnly: true` for orientation, `includeDomains` to limit payload, `blockOffset`/`blockLimit` windows for large documents).\n\n**Edit with named actions.** `superdoc_perform_action` takes an `action` plus flat arguments — the full action list, argument shapes, selector vocabulary, and placement rules are documented in the tool\'s own description. Every action returns a receipt with real pre/post evidence. Trust `status` (`ok` | `unchanged` | `partial` | `failed`). An `unchanged` receipt means the document already reads as requested and nothing was written. Read `errors[].message` for recovery guidance and re-inspect after `partial`.\n\n**Target one repeated match.** For `replace_text`, scope to one block with a selector and set `occurrence` on the edit (1 = first match in that block) to change only that match. Also pass `expectedRevision` from your latest inspect or receipt; on `REVISION_CONFLICT`, inspect again and recount.\n\n**Tracked changes (redlining).** Most mutating actions accept `changeMode: "tracked"` to record the edit as a reviewable suggestion instead of applying it directly. Review with `accept_tracked_changes` / `reject_tracked_changes` (target one change with `id`, or an exact set with `id:[…]`; or filter by `author` or `changeType`). Do not combine exact IDs with filters. Recover with `undo_changes` / `redo_changes`.\n\n**Failures are safe.** A `failed` receipt with `MATCH_NOT_FOUND` or a refused action means nothing was changed — fix the target and retry rather than improvising a different mutation path.\n',
102507
102538
  "system-prompt.md": `You are an expert document editor working inside a live Word document. You know how documents actually work — headings structure content, numbering schemes carry legal meaning, tables hold data, tracked changes record intent, comments carry review. You edit the way a skilled human editor would: you understand what people MEAN, not just what they SAY, and you leave the document the way a professional would leave it.
102508
102539
 
102509
102540
  ============================================================
@@ -102732,6 +102763,11 @@ function pickScalarFields(value, keys, limit = 6) {
102732
102763
  }
102733
102764
  return compact;
102734
102765
  }
102766
+ function compactTrackedChangeRef(value) {
102767
+ if (isRecord(value) && value.kind === "entity" && value.entityType === "trackedChange" && typeof value.entityId === "string") {
102768
+ return { kind: value.kind, entityType: value.entityType, entityId: value.entityId };
102769
+ }
102770
+ }
102735
102771
  function compactOperationResult(result) {
102736
102772
  if (result == null || typeof result === "string" || typeof result === "number" || typeof result === "boolean") {
102737
102773
  return result;
@@ -102748,9 +102784,43 @@ function compactOperationResult(result) {
102748
102784
  if (Object.keys(revision).length > 0)
102749
102785
  compact.revision = revision;
102750
102786
  }
102787
+ const stepTrackedChangeIds = Array.isArray(result.steps) ? result.steps.map((step) => isRecord(step) && Array.isArray(step.trackedChangeIds) ? step.trackedChangeIds.filter((id) => typeof id === "string") : []) : [];
102788
+ const representedIds = new Set(stepTrackedChangeIds.slice(0, 4).flat());
102751
102789
  if (Array.isArray(result.steps)) {
102752
102790
  compact.stepCount = result.steps.length;
102753
- compact.steps = result.steps.slice(0, 4).map((step) => isRecord(step) ? pickScalarFields(step, ["stepId", "op", "effect", "matchCount"], 4) : {});
102791
+ compact.steps = result.steps.slice(0, 4).map((step, index) => {
102792
+ if (!isRecord(step))
102793
+ return {};
102794
+ const trackedChangeIds2 = stepTrackedChangeIds[index];
102795
+ return {
102796
+ ...pickScalarFields(step, ["stepId", "op", "effect", "matchCount"], 4),
102797
+ ...trackedChangeIds2?.length ? { trackedChangeIds: trackedChangeIds2 } : {}
102798
+ };
102799
+ });
102800
+ }
102801
+ for (const key of ["trackedChanges", "invalidatedRefs"]) {
102802
+ if (!Array.isArray(result[key]))
102803
+ continue;
102804
+ const refs = result[key].map(compactTrackedChangeRef).filter((ref) => ref !== undefined);
102805
+ if (refs.length > 0)
102806
+ compact[key] = refs;
102807
+ if (key === "trackedChanges")
102808
+ for (const ref of refs)
102809
+ representedIds.add(ref.entityId);
102810
+ }
102811
+ const trackedChangeIds = [...new Set(stepTrackedChangeIds.flat())];
102812
+ if (trackedChangeIds.some((id) => !representedIds.has(id)))
102813
+ compact.trackedChangeIds = trackedChangeIds;
102814
+ if (Array.isArray(result.remappedRefs)) {
102815
+ const remappedRefs = result.remappedRefs.flatMap((pair) => {
102816
+ if (!isRecord(pair))
102817
+ return [];
102818
+ const from = compactTrackedChangeRef(pair.from);
102819
+ const to = compactTrackedChangeRef(pair.to);
102820
+ return from && to ? [{ from, to }] : [];
102821
+ });
102822
+ if (remappedRefs.length > 0)
102823
+ compact.remappedRefs = remappedRefs;
102754
102824
  }
102755
102825
  if (Array.isArray(result.items))
102756
102826
  compact.itemCount = result.items.length;
@@ -104386,7 +104456,7 @@ async function fullGetSystemPrompt(includeExec, options) {
104386
104456
  const count = includeExec ? "five" : "four";
104387
104457
  const pruned = opt("leanprompt") ? withoutActionLines(base) : base;
104388
104458
  const { excludedActions } = resolveActionPolicy(coreOptions);
104389
- const addendum = withoutUnofferedHelpers(opt("leanaddendum") ? LEAN_ADDENDUM : _addendumCache, helpers).replace("{{WHOLE_BODY_FONT}}", wholeBodyFontLine(excludedActions));
104459
+ const addendum = withoutUnofferedHelpers(opt("leanaddendum") ? LEAN_ADDENDUM : _addendumCache, helpers).replace("{{WHOLE_BODY_FONT}}", wholeBodyFontLine(excludedActions)).replace("{{TABLE_AND_SECTION_TRACKED_RULE}}", TABLE_AND_SECTION_TRACKED_RULE);
104390
104460
  const rewritten = pruned.replace("TOOLS — two of them", `TOOLS — ${count} of them`).replace(' superdoc_perform_action — named edit verbs we authored, tested, and validate statically. Pass {action:"name", ...flat args}.', toolLines.join(`
104391
104461
  `)).replace("If no action expresses the request, say what is missing rather than faking it.", "If no action expresses the request, escalate: superdoc_api_search → superdoc_api_call (see EXTENDED SURFACE below). Say something is impossible only after the catalog has no operation for it.");
104392
104462
  const extended = (opt("trustcalls") ? addendum.replace(/- After a structural superdoc_api_call[^\n]*\n/, `- A superdoc_api_call receipt with success:true (or a batch with completed === total) IS the verification; do not spend a superdoc_inspect call to confirm what the receipt already proves.
@@ -104643,7 +104713,7 @@ function buildFullPreset(id, includeExec, description) {
104643
104713
  dispatch: (documentHandle, toolName, args, invokeOptions) => fullDispatch(includeExec, documentHandle, toolName, args, invokeOptions)
104644
104714
  };
104645
104715
  }
104646
- var HIDDEN_PARAMS, RESERVED_ARG_KEYS3, RESULT_CHAR_CAP = 8000, SCHEMA_CHAR_CAP = 1800, NOT_CATALOGUED, NOT_CATALOGUED_DOMAINS, OPAQUE_RESULT_OPS, CATALOG_SIZE, DEFAULT_OPTS = "leanschema,leanaddendum,searchschemas,compactsearch,compactinspect,trustcalls,quickref", FULL_OPTS, opt = (name) => FULL_OPTS.has(name), LEAN_ADDENDUM = `============================================================
104716
+ var HIDDEN_PARAMS, RESERVED_ARG_KEYS3, RESULT_CHAR_CAP = 8000, SCHEMA_CHAR_CAP = 1800, NOT_CATALOGUED, NOT_CATALOGUED_DOMAINS, OPAQUE_RESULT_OPS, CATALOG_SIZE, DEFAULT_OPTS = "leanschema,leanaddendum,searchschemas,compactsearch,compactinspect,trustcalls,quickref", FULL_OPTS, opt = (name) => FULL_OPTS.has(name), TABLE_AND_SECTION_TRACKED_RULE = "tables and sections included; some refuse it for certain inputs, e.g. Word presets in doc.tables.applyPreset", LEAN_ADDENDUM = `============================================================
104647
104717
  EXTENDED SURFACE — the whole Document API (full preset)
104648
104718
  ============================================================
104649
104719
 
@@ -104676,7 +104746,7 @@ Targets for superdoc_api_call:
104676
104746
  - Position (\`at\`): {kind:"documentEnd"} | {kind:"documentStart"} | {kind:"before"|"after", target:<block>}.
104677
104747
  - Text span: {kind:"text", segments:[{blockId, range:{start, end}}]} — character offsets inside that block's text. Add story:{…} inside headers/footers.
104678
104748
  - One locator per call: target OR nodeId, never both.
104679
- - changeMode:"tracked" only where supportsTrackedMode ([tracked]; some refuse it for certain inputs, the error says why), dryRun only where supportsDryRun; otherwise the call is refused. Table and section property changes are direct-only.
104749
+ - changeMode:"tracked" only where supportsTrackedMode ([tracked], {{TABLE_AND_SECTION_TRACKED_RULE}}), dryRun only where supportsDryRun; otherwise the call is refused.
104680
104750
 
104681
104751
  Rules for the extended surface:
104682
104752
  - The receipt is the truth. success:true (or a batch with completed === total) IS the verification: do not spend a superdoc_inspect call to confirm it. {success:false, failure} means nothing changed for that call — fix the args (usually a wrong target shape or missing nodeId), retry once. A thrown VALIDATION error also changed nothing. After a TIMEOUT, re-inspect before retrying an insert.
@@ -104980,6 +105050,12 @@ var init_full = __esm(() => {
104980
105050
  ].join(`
104981
105051
  `);
104982
105052
  HELPER_PROMPT_MENTIONS = {
105053
+ shade_cells: [
105054
+ ", shade_cells {tableOrdinal?, rowIndex?, columnIndex?, color}",
105055
+ ", not shade_cells per cell",
105056
+ ", shade_cells",
105057
+ 'Shade a header row / column / table: superdoc_perform_action {action:"shade_cells", tableOrdinal:1, rowIndex:0, color:"D9D9D9"}. '
105058
+ ],
104983
105059
  compare_with_file: [
104984
105060
  ", compare_with_file {path} (differences land here as tracked changes)",
104985
105061
  "; compare_with_file {path} lands the text differences as tracked changes",
@@ -135223,7 +135299,11 @@ function utf8ByteLength(cp) {
135223
135299
  return 3;
135224
135300
  return 4;
135225
135301
  }
135226
- var NS_W = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", NS_WSTRICT = "http://purl.oclc.org/ooxml/wordprocessingml/main", NS_W14 = "http://schemas.microsoft.com/office/word/2010/wordml", NS_W15 = "http://schemas.microsoft.com/office/word/2012/wordml", NS_W16CID = "http://schemas.microsoft.com/office/word/2016/wordml/cid", NS_MC = "http://schemas.openxmlformats.org/markup-compatibility/2006", NS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", NS_RSTRICT = "http://purl.oclc.org/ooxml/officeDocument/relationships", NS_A = "http://schemas.openxmlformats.org/drawingml/2006/main", NS_V = "urn:schemas-microsoft-com:vml", NS_XML = "http://www.w3.org/XML/1998/namespace";
135302
+ var NS_W = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", NS_WSTRICT = "http://purl.oclc.org/ooxml/wordprocessingml/main", NS_W14 = "http://schemas.microsoft.com/office/word/2010/wordml", NS_W15 = "http://schemas.microsoft.com/office/word/2012/wordml", NS_W16CID = "http://schemas.microsoft.com/office/word/2016/wordml/cid", NS_MC = "http://schemas.openxmlformats.org/markup-compatibility/2006", NS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", NS_RSTRICT = "http://purl.oclc.org/ooxml/officeDocument/relationships", NS_A = "http://schemas.openxmlformats.org/drawingml/2006/main", NS_V = "urn:schemas-microsoft-com:vml", NS_XML = "http://www.w3.org/XML/1998/namespace", COMMENT_MARKER_ELEMENT_PREFIX, COMMENT_MARKER_ID_ATTRIBUTE;
135303
+ var init_xml_tokens = __esm(() => {
135304
+ COMMENT_MARKER_ELEMENT_PREFIX = String.raw`(?<markerPrefix>[\w.-]+)`;
135305
+ COMMENT_MARKER_ID_ATTRIBUTE = String.raw`(?:\k<markerPrefix>|w):id`;
135306
+ });
135227
135307
 
135228
135308
  // ../../../v2/editor-core/dist/util/sha256-sync.js
135229
135309
  function rightRotate(value, amount) {
@@ -137858,6 +137938,7 @@ function authoredTableReplacementGroup(fragment2) {
137858
137938
  }
137859
137939
  var REVISION_IDENTITY_NAMESPACE = "urn:superdoc:revision-identity:1", ENCODER;
137860
137940
  var init_revision_id_identity = __esm(() => {
137941
+ init_xml_tokens();
137861
137942
  init_sha256_sync();
137862
137943
  init_xml_sax();
137863
137944
  init_xml_text();
@@ -139384,6 +139465,7 @@ var COMPACT_CELL_NS = "urn:superdoc:compact-cell-deletion:1", COMPACT_CELL_REL =
139384
139465
  var init_compact_cell_deletion = __esm(() => {
139385
139466
  init_revision_id_identity();
139386
139467
  init_relationships();
139468
+ init_xml_tokens();
139387
139469
  init_xml_sax();
139388
139470
  init_xml_range_topology();
139389
139471
  init_docx_package_sanitizer();
@@ -139528,6 +139610,7 @@ function openTagWithTrackedChangeMetadata(openTag, metadata, scope = {}) {
139528
139610
  }
139529
139611
  var TRACKED_CHANGE_NAMESPACE = "urn:superdoc:tracked-change:1";
139530
139612
  var init_tracked_change_email = __esm(() => {
139613
+ init_xml_tokens();
139531
139614
  init_xml_sax();
139532
139615
  init_xml_text();
139533
139616
  });
@@ -139631,6 +139714,7 @@ function revisionOpenTagWithPrivateInitials(openTag, inheritedBindings = {}) {
139631
139714
  }
139632
139715
  var MARKUP_PATTERN, MARKUP;
139633
139716
  var init_revision_open_tag = __esm(() => {
139717
+ init_xml_tokens();
139634
139718
  init_tracked_change_email();
139635
139719
  init_xml_sax();
139636
139720
  init_xml_text();
@@ -139839,6 +139923,7 @@ function anchorTextById(xml, knownIds) {
139839
139923
  var decoder, appearanceNamespace = "http://schemas.microsoft.com/office/word/2012/wordml", SDMetadataProjectionConflictError;
139840
139924
  var init_metadata_projection = __esm(() => {
139841
139925
  init_xml_part_decoder();
139926
+ init_xml_tokens();
139842
139927
  init_xml_sax();
139843
139928
  decoder = createXmlPartDecoder();
139844
139929
  SDMetadataProjectionConflictError = class SDMetadataProjectionConflictError extends Error {
@@ -141060,6 +141145,7 @@ function* resolveCommentParagraphsForExportWork(xml, comments) {
141060
141145
  var SDExportPolicyError, isWord = (range, name) => (range.tag.namespaceUri === NS_W || range.tag.namespaceUri === NS_WSTRICT) && range.tag.localName === name;
141061
141146
  var init_docx_export_policies = __esm(() => {
141062
141147
  init_compact_cell_deletion();
141148
+ init_xml_tokens();
141063
141149
  init_xml_sax();
141064
141150
  init_xml_range_topology();
141065
141151
  init_xml_namespace_scope();
@@ -141086,6 +141172,7 @@ function appendXmlIgnorablePrefix(openTag, namespaceBindings, prefix, mcPrefix)
141086
141172
  return openTag.slice(0, -1) + ` xmlns:${mcPrefix}="${NS_MC}" ${mcPrefix}:Ignorable="${prefix}">`;
141087
141173
  }
141088
141174
  var init_xml_ignorable = __esm(() => {
141175
+ init_xml_tokens();
141089
141176
  init_xml_sax();
141090
141177
  });
141091
141178
 
@@ -141198,6 +141285,7 @@ function normalizeRevisionIdsForWordExport(parts, excludedPartUris) {
141198
141285
  }
141199
141286
  var MIN_WORD_ID, MAX_WORD_ID = 2147483647n, WORD_CARRIERS, EXTENDED_CARRIERS, RevisionIdExportCoverageError;
141200
141287
  var init_revision_id_export = __esm(() => {
141288
+ init_xml_tokens();
141201
141289
  init_xml_sax();
141202
141290
  init_xml_ignorable();
141203
141291
  init_revision_id_identity();
@@ -141286,6 +141374,7 @@ var REVISION_METADATA_NAMESPACES;
141286
141374
  var init_paragraph_property_namespaces = __esm(() => {
141287
141375
  init_xml_text();
141288
141376
  init_tracked_change_email();
141377
+ init_xml_tokens();
141289
141378
  REVISION_METADATA_NAMESPACES = new Set([TRACKED_CHANGE_NAMESPACE, NS_MC]);
141290
141379
  });
141291
141380
 
@@ -141324,6 +141413,7 @@ function isCommentMarkerGap(xml, namespaces) {
141324
141413
  return valid && result.errors.length === 0 && stack.length === 0;
141325
141414
  }
141326
141415
  var init_comment_marker_gap = __esm(() => {
141416
+ init_xml_tokens();
141327
141417
  init_xml_sax();
141328
141418
  });
141329
141419
 
@@ -141703,6 +141793,7 @@ function createParagraphSemanticOwnershipCollector(xml) {
141703
141793
  }
141704
141794
  var origins, properties, revisions;
141705
141795
  var init_paragraph_semantic_ownership = __esm(() => {
141796
+ init_xml_tokens();
141706
141797
  init_xml_sax();
141707
141798
  init_canonical_xml_analysis_frame();
141708
141799
  origins = new WeakMap;
@@ -141715,7 +141806,9 @@ function createOutermostTableIdResolver() {
141715
141806
  let nextOutermostTableId = 0;
141716
141807
  return (tag, parentTableId) => parentTableId ?? (tag.namespaceUri === NS_W && tag.localName === "tbl" ? nextOutermostTableId++ : undefined);
141717
141808
  }
141718
- var init_wml_table_ancestry = () => {};
141809
+ var init_wml_table_ancestry = __esm(() => {
141810
+ init_xml_tokens();
141811
+ });
141719
141812
 
141720
141813
  // ../../../v2/editor-core/dist/scan/wml-paragraph-spans.js
141721
141814
  function scanWmlParagraphSpans(xml, options = {}) {
@@ -141878,6 +141971,7 @@ function lowerBoundParagraphStart(paragraphs, start) {
141878
141971
  }
141879
141972
  var STORY_ROOT_LOCAL_NAMES;
141880
141973
  var init_wml_paragraph_spans = __esm(() => {
141974
+ init_xml_tokens();
141881
141975
  init_wml_table_ancestry();
141882
141976
  init_canonical_xml_analysis_frame();
141883
141977
  init_xml_sax();
@@ -143215,6 +143309,7 @@ function codePointCharWidth(value, charOffset) {
143215
143309
  var editGradeInlineModelBuildCount = 0, denseUtf8CharIndexBuildCount = 0;
143216
143310
  var init_paragraph_inline_model = __esm(() => {
143217
143311
  init_xml_range_topology();
143312
+ init_xml_tokens();
143218
143313
  init_canonical_xml_analysis_frame();
143219
143314
  init_xml_sax();
143220
143315
  init_tracked_change_email();
@@ -143775,6 +143870,7 @@ function decodedXmlTextLength(rawText) {
143775
143870
  }
143776
143871
  var DECODED_ENTITY_PATTERN;
143777
143872
  var init_paragraph_text_projection = __esm(() => {
143873
+ init_xml_tokens();
143778
143874
  init_xml_sax();
143779
143875
  init_paragraph_inline_model();
143780
143876
  init_xml_text();
@@ -145875,6 +145971,7 @@ function readMainBodyNamespaceContext(readRange, byteLength) {
145875
145971
  }
145876
145972
  var init_main_body_namespace_context = __esm(() => {
145877
145973
  init_xml_part_decoder();
145974
+ init_xml_tokens();
145878
145975
  init_canonical_xml_analysis_frame();
145879
145976
  init_xml_sax();
145880
145977
  });
@@ -146674,6 +146771,7 @@ var issued, standalone, topologies, pending, pendingReaders, paragraphCoordinate
146674
146771
  var init_catalog_xml_analysis = __esm(() => {
146675
146772
  init_xml_range_topology();
146676
146773
  init_wml_paragraph_spans();
146774
+ init_xml_tokens();
146677
146775
  init_xml_sax();
146678
146776
  init_paragraph_inline_model();
146679
146777
  issued = new WeakSet;
@@ -147588,6 +147686,7 @@ var init_structural_groups = __esm(() => {
147588
147686
  init_catalog_xml_analysis();
147589
147687
  init_xml_text();
147590
147688
  init_pairing_markers();
147689
+ init_xml_tokens();
147591
147690
  init_xml_sax();
147592
147691
  });
147593
147692
 
@@ -147752,6 +147851,7 @@ function projectEnclosedTableDeletionGroups(input, lookupContext) {
147752
147851
  }
147753
147852
  }
147754
147853
  var init_enclosed_table_groups = __esm(() => {
147854
+ init_xml_tokens();
147755
147855
  init_xml_sax();
147756
147856
  init_logical_catalog();
147757
147857
  init_structural_groups();
@@ -147812,6 +147912,7 @@ function collectCellSplitOwnedParagraphs(input, supplied) {
147812
147912
  return result;
147813
147913
  }
147814
147914
  var init_cell_split_paragraph_ownership = __esm(() => {
147915
+ init_xml_tokens();
147815
147916
  init_xml_sax();
147816
147917
  });
147817
147918
 
@@ -147974,6 +148075,7 @@ function projectNoteStoryCreationGroups(input) {
147974
148075
  }
147975
148076
  var LIFECYCLE_NS = "urn:superdoc:note-lifecycle";
147976
148077
  var init_note_story_creation_group = __esm(() => {
148078
+ init_xml_tokens();
147977
148079
  init_xml_sax();
147978
148080
  });
147979
148081
 
@@ -148072,6 +148174,7 @@ function isReferenceOnlyRunReplacement(before, after, referenceName, namespaces)
148072
148174
  return !!reference && !before.slice(end, run.closeStart).trim() && before.slice(0, reference.start) + before.slice(reference.end) === after;
148073
148175
  }
148074
148176
  var init_note_reference_removal_group = __esm(() => {
148177
+ init_xml_tokens();
148075
148178
  init_xml_sax();
148076
148179
  });
148077
148180
 
@@ -148207,6 +148310,7 @@ function collectBookmarkRenameRevisionGroups(endpointGroups, xml, lookupContext)
148207
148310
  return result;
148208
148311
  }
148209
148312
  var init_bookmark_revision_groups = __esm(() => {
148313
+ init_xml_tokens();
148210
148314
  init_xml_sax();
148211
148315
  });
148212
148316
 
@@ -148321,6 +148425,7 @@ async function collectNativeTableMoveRowsCooperatively(xml, yieldPoint, options)
148321
148425
  }
148322
148426
  var word2 = (tag, name) => tag?.namespaceUri === NS_W && tag.localName === name;
148323
148427
  var init_table_move_rows = __esm(() => {
148428
+ init_xml_tokens();
148324
148429
  init_xml_sax();
148325
148430
  });
148326
148431
 
@@ -148409,6 +148514,7 @@ function projectNativeTableMoveGroups(input) {
148409
148514
  }
148410
148515
  }
148411
148516
  var init_table_move_groups = __esm(() => {
148517
+ init_xml_tokens();
148412
148518
  init_xml_sax();
148413
148519
  init_table_move_rows();
148414
148520
  });
@@ -148654,6 +148760,7 @@ function unique(values) {
148654
148760
  }
148655
148761
  var MATERIAL_LEAVES;
148656
148762
  var init_native_sdt_groups = __esm(() => {
148763
+ init_xml_tokens();
148657
148764
  init_xml_sax();
148658
148765
  MATERIAL_LEAVES = new Set(["t", "delText", "instrText", "delInstrText", "tab", "br", "cr", "drawing", "pict", "object", "fldChar", "footnoteReference", "endnoteReference", "sym"]);
148659
148766
  });
@@ -148812,6 +148919,7 @@ function unhandledPiece(piece) {
148812
148919
  var TD4, XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/", COMMON_NAMESPACE_BINDINGS, BREAK_DEFAULT_ATTRIBUTE_VALUES;
148813
148920
  var init_textbox_paragraph_signature = __esm(() => {
148814
148921
  init_paragraph_inline_model();
148922
+ init_xml_tokens();
148815
148923
  init_xml_sax();
148816
148924
  TD4 = new TextDecoder;
148817
148925
  COMMON_NAMESPACE_BINDINGS = {
@@ -149779,6 +149887,7 @@ function addNamespaceDeclarations(openTag, sourceNamespaces, inheritedNamespaceB
149779
149887
  var PARAGRAPH_MARK_REVISION_CHILDREN, INHERITED_MC_LIST_ATTRIBUTES;
149780
149888
  var init_paragraph_property_block = __esm(() => {
149781
149889
  init_xml_text();
149890
+ init_xml_tokens();
149782
149891
  init_xml_sax();
149783
149892
  PARAGRAPH_MARK_REVISION_CHILDREN = new Set(["ins", "del", "moveFrom", "moveTo", "rPrChange"]);
149784
149893
  INHERITED_MC_LIST_ATTRIBUTES = new Set(["Ignorable", "PreserveAttributes", "PreserveElements", "ProcessContent"]);
@@ -150815,6 +150924,7 @@ var init_numbering_catalog = __esm(() => {
150815
150924
  init_sd_document_state();
150816
150925
  init_style_definitions_part();
150817
150926
  init_xml_text();
150927
+ init_xml_tokens();
150818
150928
  init_xml_sax();
150819
150929
  init_paragraph_property_block();
150820
150930
  init_direct_paragraph_list_properties();
@@ -151030,6 +151140,7 @@ function completeDeletedField(wrapper, childrenOf) {
151030
151140
  return phase === "after" && [...bookmarks.values()].every((state) => state === "closed");
151031
151141
  }
151032
151142
  var init_field_paragraph_deletion_groups = __esm(() => {
151143
+ init_xml_tokens();
151033
151144
  init_xml_sax();
151034
151145
  init_logical_catalog();
151035
151146
  });
@@ -151226,6 +151337,7 @@ function readFieldPhase(runs, childrenOf, initial) {
151226
151337
  }
151227
151338
  var native2 = (range, name) => range.tag.namespaceUri === NS_W && range.tag.localName === name;
151228
151339
  var init_field_paragraph_range_deletion_groups = __esm(() => {
151340
+ init_xml_tokens();
151229
151341
  init_xml_sax();
151230
151342
  init_logical_catalog();
151231
151343
  });
@@ -151459,6 +151571,7 @@ function* projectDeletedInlineObjectParagraphGroupsWork(input, lookupContext) {
151459
151571
  }
151460
151572
  var native3 = (range, name) => range.tag.namespaceUri === NS_W && range.tag.localName === name;
151461
151573
  var init_image_paragraph_deletion_groups = __esm(() => {
151574
+ init_xml_tokens();
151462
151575
  init_xml_sax();
151463
151576
  init_logical_catalog();
151464
151577
  init_field_paragraph_deletion_groups();
@@ -151619,6 +151732,7 @@ function readRowHeightReviewCohorts(xml, options = {}) {
151619
151732
  }
151620
151733
  var word3 = (range, name) => (range.tag.namespaceUri === NS_W || range.tag.namespaceUri === NS_WSTRICT) && (name === undefined || range.tag.localName === name), attr2 = (range, name) => range.tag.attributes.find((attribute) => (attribute.namespaceUri === NS_W || attribute.namespaceUri === NS_WSTRICT) && attribute.localName === name)?.value;
151621
151734
  var init_row_height_review_geometry = __esm(() => {
151735
+ init_xml_tokens();
151622
151736
  init_xml_sax();
151623
151737
  init_tracked_change_email();
151624
151738
  });
@@ -154545,6 +154659,7 @@ function findMarkDeletionOwnerForParagraph(byId, entries, paragraphStart) {
154545
154659
  var ATOM_SEQUENCE_BATCH = 32, LIVE_FORMATTING_GESTURE_WINDOW_MS = 1000;
154546
154660
  var init_review_groups = __esm(() => {
154547
154661
  init_comment_marker_gap();
154662
+ init_xml_tokens();
154548
154663
  init_catalog3();
154549
154664
  init_logical_catalog();
154550
154665
  init_revision_id_identity();
@@ -154736,6 +154851,7 @@ function projectComparisonHunkReviewGroup(entry, logical) {
154736
154851
  }
154737
154852
  var COMPARISON_HUNK_NAMESPACE = "urn:superdoc:tracked-review:1";
154738
154853
  var init_comparison_hunk_groups = __esm(() => {
154854
+ init_xml_tokens();
154739
154855
  init_xml_sax();
154740
154856
  init_xml_ignorable();
154741
154857
  init_logical_catalog();
@@ -155590,6 +155706,7 @@ function captureParagraphLocalCommentMarkersUncached(xml, namespaceBindings) {
155590
155706
  var COMMENT_MARKUP_RE;
155591
155707
  var init_comment_range_invariance = __esm(() => {
155592
155708
  init_canonical_xml_analysis_frame();
155709
+ init_xml_tokens();
155593
155710
  init_paragraph_inline_model();
155594
155711
  init_xml_sax();
155595
155712
  COMMENT_MARKUP_RE = /<(?:[\w.-]+:)?(?:commentRangeStart|commentRangeEnd|commentReference)\b/;
@@ -160625,6 +160742,7 @@ var init_logical_catalog = __esm(() => {
160625
160742
  init_bookmark_revision_groups();
160626
160743
  init_table_move_groups();
160627
160744
  init_native_sdt_groups();
160745
+ init_xml_tokens();
160628
160746
  init_textbox_paragraph_signature();
160629
160747
  init_paragraph_inline_model();
160630
160748
  init_xml_sax();
@@ -160903,6 +161021,7 @@ function resolveVisibleReviewOwner(logical, entry) {
160903
161021
  }
160904
161022
  var REWRITE_NAMESPACE = "urn:superdoc:tracked-rewrite:1";
160905
161023
  var init_rewrite_groups = __esm(() => {
161024
+ init_xml_tokens();
160906
161025
  init_xml_sax();
160907
161026
  init_xml_ignorable();
160908
161027
  init_catalog3();
@@ -161889,10 +162008,10 @@ function collectCommentAnchorEnvelopes(state) {
161889
162008
  const xml = TD9.decode(bytes);
161890
162009
  const starts = [];
161891
162010
  const endsBySourceId = new Map;
161892
- const tokenRe = /<[\w.-]+:(commentRangeStart|commentRangeEnd)\b[^>]*\bw:id="([^"]+)"[^>]*\/?>/g;
162011
+ const tokenRe = new RegExp(String.raw`<${COMMENT_MARKER_ELEMENT_PREFIX}:(commentRangeStart|commentRangeEnd)\b[^>]*\b${COMMENT_MARKER_ID_ATTRIBUTE}="([^"]+)"[^>]*\/?>`, "g");
161893
162012
  for (let match = tokenRe.exec(xml);match; match = tokenRe.exec(xml)) {
161894
- const item = { sourceWId: match[2] ?? "", pos: match.index };
161895
- if (match[1] === "commentRangeStart")
162013
+ const item = { sourceWId: match[3] ?? "", pos: match.index };
162014
+ if (match[2] === "commentRangeStart")
161896
162015
  starts.push(item);
161897
162016
  else {
161898
162017
  const ends = endsBySourceId.get(item.sourceWId);
@@ -162061,6 +162180,7 @@ var init_comments_catalog = __esm(() => {
162061
162180
  init_xml_text();
162062
162181
  init_lazy_indexes();
162063
162182
  init_wml_paragraph_spans();
162183
+ init_xml_tokens();
162064
162184
  init_xml_sax();
162065
162185
  init_comment_metadata_sidecar();
162066
162186
  TD9 = createXmlPartDecoder();
@@ -162269,6 +162389,7 @@ function rangesOverlap(a, b) {
162269
162389
  var BYTE_FACTS_KEY = "__comment-anchor-byte-facts", TD10;
162270
162390
  var init_body_comment_anchors = __esm(() => {
162271
162391
  init_xml_part_decoder();
162392
+ init_xml_tokens();
162272
162393
  init_xml_sax();
162273
162394
  TD10 = createXmlPartDecoder();
162274
162395
  });
@@ -162744,14 +162865,14 @@ function scanStoryForAnchors(xml, story, previous, owner, capturedParagraphFacts
162744
162865
  function* scanStoryForAnchorsSteps(xml, story, previous, owner, capturedParagraphFacts) {
162745
162866
  const markers = [];
162746
162867
  if (story.kind === "body") {
162747
- const markerRe = /<[\w.-]+:(commentRangeStart|commentRangeEnd|commentReference)\s[^>]*?\bw:id="([^"]+)"[^>]*\/>/g;
162868
+ const markerRe = new RegExp(String.raw`<${COMMENT_MARKER_ELEMENT_PREFIX}:(commentRangeStart|commentRangeEnd|commentReference)\s[^>]*?\b${COMMENT_MARKER_ID_ATTRIBUTE}="([^"]+)"[^>]*\/>`, "g");
162748
162869
  for (let m = markerRe.exec(xml);m; m = markerRe.exec(xml)) {
162749
162870
  if (markers.length > 0 && markers.length % 64 === 0)
162750
162871
  yield;
162751
- const tagName = m[1];
162872
+ const tagName = m[2];
162752
162873
  markers.push({
162753
162874
  kind: tagName === "commentRangeStart" ? "start" : tagName === "commentRangeEnd" ? "end" : "ref",
162754
- id: m[2],
162875
+ id: m[3],
162755
162876
  charStart: m.index ?? 0,
162756
162877
  charEnd: (m.index ?? 0) + m[0].length
162757
162878
  });
@@ -162960,12 +163081,14 @@ var TD11, COMMENT_ANCHOR_INDEX_KEY = "__comment-anchor-index", ANCHOR_TAG, BODY_
162960
163081
  var init_comment_anchor_index = __esm(() => {
162961
163082
  init_xml_part_decoder();
162962
163083
  init_xml_sax();
163084
+ init_xml_tokens();
162963
163085
  init_lazy_indexes();
162964
163086
  init_wml_paragraph_spans();
162965
163087
  init_paragraph_inline_model();
162966
163088
  init_xml_sax();
162967
163089
  init_comments_catalog();
162968
163090
  init_body_comment_anchors();
163091
+ init_xml_tokens();
162969
163092
  init_relationship();
162970
163093
  init_xml_text();
162971
163094
  init_catalog_xml_analysis();
@@ -163520,6 +163643,7 @@ var MAX_SPEC_PARA_ID = 2147483647, WELL_FORMED_PARA_ID_RE, STORY_ROOT_TAG_RE, ST
163520
163643
  var init_ensure_para_ids = __esm(() => {
163521
163644
  init_xml_part_decoder();
163522
163645
  init_wml_paragraph_spans();
163646
+ init_xml_tokens();
163523
163647
  init_wml_table_ancestry();
163524
163648
  init_xml_sax();
163525
163649
  init_paragraph_semantic_ownership();
@@ -167000,6 +167124,7 @@ async function streamEmptyOrTriviaBody(args) {
167000
167124
  }
167001
167125
  var NS_W2, NS_MC2, DEFAULT_SOURCE_BOOTSTRAP_POLICY, B, TD12, NEEDLE_COMMENT_END, NEEDLE_CDATA_END, NEEDLE_PI_END, NEEDLE_LT_BANG_CDATA, NEEDLE_LT_BANG_DASH, RANGE_MARKER_LOCAL_NAMES, REVISION_CONTAINER_LOCAL_NAMES, STORY_SPINE_DEFAULTS, VALIDATED_BOOTSTRAP_BOUNDARIES, ISSUED_BOOTSTRAP_BOUNDARIES, ISSUED_BOOTSTRAP_BOUNDARY_COORDINATES, DEFAULT_STREAMING_SCAN_CHUNK_BYTES, DEFAULT_STREAMING_SCAN_WINDOW_CEILING_BYTES, STREAM_NEED_MORE = -2;
167002
167126
  var init_body_boundary_scan = __esm(() => {
167127
+ init_xml_tokens();
167003
167128
  init_xml_sax();
167004
167129
  init_paragraph_scan_count();
167005
167130
  NS_W2 = NS_W;
@@ -169599,10 +169724,11 @@ function residentCrossParagraphHit(id, idOwners, owners, partUri, models) {
169599
169724
  const markers = [];
169600
169725
  for (const owner of idOwners) {
169601
169726
  for (const match of owner.xml.matchAll(STRICT_COMMENT_MARKER_RE)) {
169602
- if (match[2] !== id)
169727
+ if (match.groups?.id !== id)
169603
169728
  continue;
169729
+ const kind = match.groups?.kind;
169604
169730
  markers.push({
169605
- kind: match[1] === "commentRangeStart" ? "start" : match[1] === "commentRangeEnd" ? "end" : "ref",
169731
+ kind: kind === "commentRangeStart" ? "start" : kind === "commentRangeEnd" ? "end" : "ref",
169606
169732
  ordinal: owner.ordinal,
169607
169733
  charStart: match.index,
169608
169734
  charEnd: match.index + match[0].length
@@ -171202,6 +171328,7 @@ var init_resident_review = __esm(() => {
171202
171328
  init_review_source_alias();
171203
171329
  init_suffix_delta_index();
171204
171330
  init_resident_paragraphs();
171331
+ init_xml_tokens();
171205
171332
  init_comment_anchor_index();
171206
171333
  init_paragraph_inline_model();
171207
171334
  init_sd_document_state();
@@ -171226,7 +171353,7 @@ var init_resident_review = __esm(() => {
171226
171353
  capturedParagraphLengths = new WeakMap;
171227
171354
  sourceIdsByLogical = new WeakMap;
171228
171355
  decoder2 = createXmlPartDecoder();
171229
- STRICT_COMMENT_MARKER_RE = /<[\w.-]+:(commentRangeStart|commentRangeEnd|commentReference)\s[^>]*?\bw:id="([^"]+)"[^>]*\/>/g;
171356
+ STRICT_COMMENT_MARKER_RE = new RegExp(String.raw`<${COMMENT_MARKER_ELEMENT_PREFIX}:(?<kind>commentRangeStart|commentRangeEnd|commentReference)\s[^>]*?\b${COMMENT_MARKER_ID_ATTRIBUTE}="(?<id>[^"]+)"[^>]*\/>`, "g");
171230
171357
  projectionComponents = new WeakMap;
171231
171358
  projectionReadCaches = new WeakMap;
171232
171359
  projectionCatalogs = new WeakMap;
@@ -172090,6 +172217,7 @@ function readAttrValueByPrefixes(tag, prefixes, local) {
172090
172217
  }
172091
172218
  var B_LT = 60, B_GT = 62, B_SLASH = 47, B_EXCL = 33, B_QUEST = 63, B_DASH = 45, B_LBRACK = 91, B_RBRACK = 93, B_DQUOTE = 34, B_SQUOTE = 39, B_COLON = 58, B_UNDER = 95, B_DOT = 46, B_DASH2 = 45, B_EQ = 61, B_SPACE = 32, B_TAB = 9, B_LF = 10, B_CR = 13, B_A_UPPER = 65, B_Z_UPPER = 90, B_A_LOWER = 97, B_Z_LOWER = 122, B_0 = 48, B_9 = 57, TD14;
172092
172219
  var init_byte_chunk_scanner = __esm(() => {
172220
+ init_xml_tokens();
172093
172221
  TD14 = new TextDecoder("utf-8", { fatal: false });
172094
172222
  });
172095
172223
 
@@ -172566,6 +172694,7 @@ function readRelationshipAttrValue(tag, local) {
172566
172694
  }
172567
172695
  var TD15;
172568
172696
  var init_chunk_scanner = __esm(() => {
172697
+ init_xml_tokens();
172569
172698
  init_xml_sax();
172570
172699
  TD15 = new TextDecoder("utf-8", { fatal: false });
172571
172700
  });
@@ -173094,6 +173223,7 @@ function isWordprocessingNamespace2(namespaceUri) {
173094
173223
  return namespaceUri === NS_W || namespaceUri === NS_WSTRICT;
173095
173224
  }
173096
173225
  var init_style_definitions_xml = __esm(() => {
173226
+ init_xml_tokens();
173097
173227
  init_xml_sax();
173098
173228
  });
173099
173229
 
@@ -174062,6 +174192,7 @@ function decodeRange(buf, start, end) {
174062
174192
  }
174063
174193
  var TD17;
174064
174194
  var init_sectpr_parser = __esm(() => {
174195
+ init_xml_tokens();
174065
174196
  init_xml_sax();
174066
174197
  init_diagnostics();
174067
174198
  TD17 = new TextDecoder("utf-8", { fatal: false });
@@ -174320,6 +174451,7 @@ function toggleFromAttrs(attrs) {
174320
174451
  var TD18;
174321
174452
  var init_settings_signals = __esm(() => {
174322
174453
  init_xml_part_decoder();
174454
+ init_xml_tokens();
174323
174455
  init_xml_sax();
174324
174456
  init_diagnostics();
174325
174457
  TD18 = createXmlPartDecoder({ fatal: false });
@@ -174733,6 +174865,7 @@ function byteAnchor(input, byteStart, byteEnd) {
174733
174865
  var NS_A2 = "http://schemas.openxmlformats.org/drawingml/2006/main", NS_V2 = "urn:schemas-microsoft-com:vml", TD19;
174734
174866
  var init_secondary_story_scan = __esm(() => {
174735
174867
  init_xml_part_decoder();
174868
+ init_xml_tokens();
174736
174869
  init_xml_sax();
174737
174870
  init_diagnostics();
174738
174871
  init_heading_signals();
@@ -177195,6 +177328,7 @@ function scopeHintNeedsAncestorNamespaces(openTag) {
177195
177328
  var TD21, XML_ATTRIBUTE_RE, XML_OPEN_TAG_RE, PARAGRAPH_OPEN_TAG_RE, ROOT_NAMESPACE_SCAN_BYTES = 16384, ancestorNamespacePrefixScanCount = 0, W14_NAMESPACE = "http://schemas.microsoft.com/office/word/2010/wordml";
177196
177329
  var init_paragraph_para_id_attrs = __esm(() => {
177197
177330
  init_xml_part_decoder();
177331
+ init_xml_tokens();
177198
177332
  init_xml_text();
177199
177333
  TD21 = createXmlPartDecoder();
177200
177334
  XML_ATTRIBUTE_RE = /\s+([^\s"'<>/=]+)\s*=\s*(["'])(.*?)\2/g;
@@ -177259,6 +177393,7 @@ async function collectNativeCellTopologyCooperatively(xml, yieldPoint, options)
177259
177393
  return parsed.errors.length ? null : result.topology;
177260
177394
  }
177261
177395
  var init_table_vertical_merges = __esm(() => {
177396
+ init_xml_tokens();
177262
177397
  init_xml_sax();
177263
177398
  });
177264
177399
 
@@ -193123,6 +193258,7 @@ var init_resident_paragraph_ownership = __esm(() => {
193123
193258
  init_xml_part_decoder();
193124
193259
  init_canonical_xml_analysis_frame();
193125
193260
  init_xml_sax();
193261
+ init_xml_tokens();
193126
193262
  init_paragraph_semantic_ownership();
193127
193263
  init_wml_paragraph_spans();
193128
193264
  init_paragraph_index();
@@ -193211,6 +193347,7 @@ function isNativeEmptyTableCellBody(xml, namespaceBindings = {}, options = {}) {
193211
193347
  }
193212
193348
  var WORD_REVISION_RANGE, WORD_REVISION_WRAPPERS;
193213
193349
  var init_table_cell_content = __esm(() => {
193350
+ init_xml_tokens();
193214
193351
  init_xml_sax();
193215
193352
  init_xml_text();
193216
193353
  WORD_REVISION_RANGE = /^(?:move(?:From|To)|customXml(?:Ins|Del|MoveFrom|MoveTo))Range(?:Start|End)$/;
@@ -193624,6 +193761,7 @@ function preserveUnwrappedNamespaces(xml, removals, namespaces = new Map) {
193624
193761
  }
193625
193762
  var RANGE_NAMES, KIND_BY_NAME;
193626
193763
  var init_native_sdt_ownership = __esm(() => {
193764
+ init_xml_tokens();
193627
193765
  init_xml_sax();
193628
193766
  init_xml_text();
193629
193767
  init_tracked_change_email();
@@ -193780,6 +193918,7 @@ function hasCompleteEmptyParagraphMoveRows(xml, rows, eligible, selectedStarts)
193780
193918
  return true;
193781
193919
  }
193782
193920
  var init_empty_paragraph_move = __esm(() => {
193921
+ init_xml_tokens();
193783
193922
  init_xml_sax();
193784
193923
  init_table_cell_content();
193785
193924
  init_native_sdt_ownership();
@@ -194732,7 +194871,13 @@ function prepareNativeTrackedCatalogPublication(state, group) {
194732
194871
  formattingByKey: map3(raw.formattingByKey, format),
194733
194872
  structuralByPart: map3(raw.structuralByPart, structural),
194734
194873
  structuralByKey: map3(raw.structuralByKey, structural),
194735
- unsupportedByStory: map3(raw.unsupportedByStory, (f) => f.partUri !== uri ? f : { ...f, byteStart: char(f.byteStart), byteEnd: char(f.byteEnd) }),
194874
+ unsupportedByStory: map3(raw.unsupportedByStory, (f) => f.partUri !== uri ? f : {
194875
+ ...f,
194876
+ byteStart: char(f.byteStart),
194877
+ byteEnd: char(f.byteEnd),
194878
+ sourceByteStart: byte(f.sourceByteStart) ?? -1,
194879
+ sourceByteEnd: byte(f.sourceByteEnd) ?? -1
194880
+ }),
194736
194881
  moveRangeMarkersByPart
194737
194882
  };
194738
194883
  return { before: raw, after: next, paragraphCharStart, charStart: start, charEnd: end, edit: native4, publish: () => {
@@ -195854,6 +195999,8 @@ function* scanFragmentsWork(xml, partUri, storyId, sourceByteBase = 0, initialNa
195854
195999
  const kind = tag.localName;
195855
196000
  const wId = readNamespacedAttr(tag.attrs, namespaceBindingsByTagStart.get(tag.start), "id") ?? "";
195856
196001
  unsupported.push({
196002
+ sourceByteStart: -1,
196003
+ sourceByteEnd: -1,
195857
196004
  storyId,
195858
196005
  partUri,
195859
196006
  byteStart: tag.start,
@@ -195883,6 +196030,8 @@ function* scanFragmentsWork(xml, partUri, storyId, sourceByteBase = 0, initialNa
195883
196030
  const namespaceBindings = namespaceBindingsByTagStart.get(tag.start);
195884
196031
  if (tag.selfClose) {
195885
196032
  unsupported.push({
196033
+ sourceByteStart: -1,
196034
+ sourceByteEnd: -1,
195886
196035
  storyId,
195887
196036
  partUri,
195888
196037
  byteStart: tag.start,
@@ -195901,6 +196050,8 @@ function* scanFragmentsWork(xml, partUri, storyId, sourceByteBase = 0, initialNa
195901
196050
  const outer = findImmediateParentElement(elementIndex, tag.start);
195902
196051
  if (!outer || outer.localName !== outerLocalName) {
195903
196052
  unsupported.push({
196053
+ sourceByteStart: -1,
196054
+ sourceByteEnd: -1,
195904
196055
  storyId,
195905
196056
  partUri,
195906
196057
  byteStart: tag.start,
@@ -195987,6 +196138,8 @@ function* scanFragmentsWork(xml, partUri, storyId, sourceByteBase = 0, initialNa
195987
196138
  trackedWrappers.wrappers.sort((a, b) => a.byteStart - b.byteStart);
195988
196139
  const precollectedTextWrapperRanges = new Set(trackedWrappers.wrappers.map((wrapper) => `${wrapper.byteStart}:${wrapper.byteEnd}`));
195989
196140
  unsupported.push(...trackedWrappers.malformed.map((wrapper) => ({
196141
+ sourceByteStart: -1,
196142
+ sourceByteEnd: -1,
195990
196143
  storyId,
195991
196144
  partUri,
195992
196145
  byteStart: wrapper.byteStart,
@@ -196009,6 +196162,8 @@ function* scanFragmentsWork(xml, partUri, storyId, sourceByteBase = 0, initialNa
196009
196162
  if (parent?.localName === "rPr" && grandparent?.localName === "pPr" && !emptyParagraphMoves.has(byteStart)) {
196010
196163
  if (!isEmptyMoveMarkerContent(inner)) {
196011
196164
  unsupported.push({
196165
+ sourceByteStart: -1,
196166
+ sourceByteEnd: -1,
196012
196167
  storyId,
196013
196168
  partUri,
196014
196169
  byteStart,
@@ -196079,6 +196234,8 @@ function* scanFragmentsWork(xml, partUri, storyId, sourceByteBase = 0, initialNa
196079
196234
  continue;
196080
196235
  }
196081
196236
  unsupported.push({
196237
+ sourceByteStart: -1,
196238
+ sourceByteEnd: -1,
196082
196239
  storyId,
196083
196240
  partUri,
196084
196241
  byteStart,
@@ -196292,6 +196449,8 @@ function* scanFragmentsWork(xml, partUri, storyId, sourceByteBase = 0, initialNa
196292
196449
  partUri,
196293
196450
  byteStart: issue2.start,
196294
196451
  byteEnd: issue2.end,
196452
+ sourceByteStart: -1,
196453
+ sourceByteEnd: -1,
196295
196454
  kind: "unknown",
196296
196455
  reason: "malformed-wrapper",
196297
196456
  wId: ""
@@ -196303,7 +196462,7 @@ function* scanFragmentsWork(xml, partUri, storyId, sourceByteBase = 0, initialNa
196303
196462
  yield* markFullParagraphInsertionsWork(xml, fragments, structural, elementIndex, namespaceBindingsByTagStart, structuralScan.bookmarkBoundaries);
196304
196463
  endFullParagraphs();
196305
196464
  const endCoordinates = beginSDCooperativeReadPhase("catalog.raw.coordinates");
196306
- const trackedLength = yield* populateFragmentSourceCoordinatesWork(xml, fragments, formatting, structural, sourceByteBase, shared, paragraphLengths ? { token: paragraphLengths, partUri, storyId } : undefined, initialNamespaceBindings);
196465
+ const trackedLength = yield* populateFragmentSourceCoordinatesWork(xml, fragments, formatting, structural, unsupported, sourceByteBase, shared, paragraphLengths ? { token: paragraphLengths, partUri, storyId } : undefined, initialNamespaceBindings);
196307
196466
  endCoordinates();
196308
196467
  formatting.sort((left, right) => left.byteStart - right.byteStart || left.byteEnd - right.byteEnd);
196309
196468
  structural.sort((left, right) => left.byteStart - right.byteStart || left.byteEnd - right.byteEnd);
@@ -196514,7 +196673,7 @@ function isCoveredByInsertionRanges(xml, start, end, ranges, commentNamespaces)
196514
196673
  }
196515
196674
  return coveredGap(xml.slice(cursor, end));
196516
196675
  }
196517
- function* populateFragmentSourceCoordinatesWork(xml, fragments, formatting, structural, sourceByteBase, shared, paragraphLengths, initialNamespaceBindings) {
196676
+ function* populateFragmentSourceCoordinatesWork(xml, fragments, formatting, structural, unsupported, sourceByteBase, shared, paragraphLengths, initialNamespaceBindings) {
196518
196677
  const scanned = fragments.length > 0 ? shared ?? scanTrackedCatalogParagraphs(xml, initialNamespaceBindings) : undefined;
196519
196678
  const paragraphScan = scanned?.paragraphs;
196520
196679
  const paragraphs = paragraphScan && paragraphScan.paragraphs.length > 0 ? paragraphScan.paragraphs : fragments.length > 0 && /^\s*<[\w.-]+:p\b/.test(xml) && /<\/[\w.-]+:p>\s*$/.test(xml) ? [{
@@ -196543,6 +196702,11 @@ function* populateFragmentSourceCoordinatesWork(xml, fragments, formatting, stru
196543
196702
  boundaries.add(fragment3.byteStart);
196544
196703
  boundaries.add(fragment3.byteEnd);
196545
196704
  }
196705
+ for (const fragment3 of unsupported) {
196706
+ yield;
196707
+ boundaries.add(fragment3.byteStart);
196708
+ boundaries.add(fragment3.byteEnd);
196709
+ }
196546
196710
  for (const paragraph of paragraphs) {
196547
196711
  yield;
196548
196712
  boundaries.add(paragraph.openStart);
@@ -196583,6 +196747,11 @@ function* populateFragmentSourceCoordinatesWork(xml, fragments, formatting, stru
196583
196747
  fragment3.sourceByteStart = sourceOffsetByChar.get(fragment3.byteStart) ?? -1;
196584
196748
  fragment3.sourceByteEnd = sourceOffsetByChar.get(fragment3.byteEnd) ?? -1;
196585
196749
  }
196750
+ for (const fragment3 of unsupported) {
196751
+ yield;
196752
+ fragment3.sourceByteStart = sourceOffsetByChar.get(fragment3.byteStart) ?? -1;
196753
+ fragment3.sourceByteEnd = sourceOffsetByChar.get(fragment3.byteEnd) ?? -1;
196754
+ }
196586
196755
  return trackedCoordinates.trackedLength;
196587
196756
  }
196588
196757
  function* buildTrackedWrapperCoordinatesWork(xml, fragments, paragraphs, paragraphByteByChar, shared, paragraphLengths) {
@@ -197407,6 +197576,7 @@ var init_catalog3 = __esm(() => {
197407
197576
  init_empty_paragraph_move();
197408
197577
  init_native_sdt_ownership();
197409
197578
  init_src2();
197579
+ init_xml_tokens();
197410
197580
  init_xml_text();
197411
197581
  init_paragraph_inline_model();
197412
197582
  init_simple_text_run_split();
@@ -197740,6 +197910,7 @@ var RESTORE_NS = "urn:superdoc:tracked-rewrite:1", MC_NS3 = "http://schemas.open
197740
197910
  var init_insertion_restoration = __esm(() => {
197741
197911
  init_xml_part_decoder();
197742
197912
  init_src2();
197913
+ init_xml_tokens();
197743
197914
  init_xml_sax();
197744
197915
  init_xml_namespace_scope();
197745
197916
  init_sha256_sync();
@@ -197794,6 +197965,7 @@ function readNativeTableRowSpans(xml, namespaces) {
197794
197965
  return cells;
197795
197966
  }
197796
197967
  var init_table_row_spans = __esm(() => {
197968
+ init_xml_tokens();
197797
197969
  init_xml_sax();
197798
197970
  });
197799
197971
 
@@ -197952,6 +198124,7 @@ function restoreIndependentParagraphProperties(before, live, prefix2, namespaces
197952
198124
  return before.slice(0, boundary) + copied + before.slice(boundary);
197953
198125
  }
197954
198126
  var init_paragraph_property_history = __esm(() => {
198127
+ init_xml_tokens();
197955
198128
  init_xml_sax();
197956
198129
  init_paragraph_property_namespaces();
197957
198130
  });
@@ -198046,6 +198219,7 @@ function prepareTrackedParagraphProperties(input) {
198046
198219
  };
198047
198220
  }
198048
198221
  var init_tracked_paragraph_properties = __esm(() => {
198222
+ init_xml_tokens();
198049
198223
  init_xml_sax();
198050
198224
  init_tracked_change_email();
198051
198225
  init_xml_text();
@@ -198140,6 +198314,7 @@ function normalizeBlockDeletionText(xml) {
198140
198314
  }
198141
198315
  var TRACKED_WRAPPER_NAMES;
198142
198316
  var init_block_deletion_text = __esm(() => {
198317
+ init_xml_tokens();
198143
198318
  init_xml_sax();
198144
198319
  TRACKED_WRAPPER_NAMES = new Set(["ins", "del", "moveFrom", "moveTo"]);
198145
198320
  });
@@ -200370,6 +200545,7 @@ var NS_W3 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
200370
200545
  var init_decide_engine = __esm(() => {
200371
200546
  init_insertion_restoration();
200372
200547
  init_revision_open_tag();
200548
+ init_xml_tokens();
200373
200549
  init_table_cell_content();
200374
200550
  init_cell_split_paragraph_ownership();
200375
200551
  init_table_row_spans();
@@ -200577,6 +200753,7 @@ var CARRIERS, CELL_REVIEW_MARKERS, PROPERTY_HISTORY_PATTERN, SDTrackedPropertyPr
200577
200753
  var init_property_export_projection = __esm(() => {
200578
200754
  init_xml_sax();
200579
200755
  init_xml_range_topology();
200756
+ init_xml_tokens();
200580
200757
  init_xml_sax();
200581
200758
  init_xml_range_topology();
200582
200759
  init_xml_text();
@@ -200688,6 +200865,7 @@ var init_move_stamps = __esm(() => {
200688
200865
  init_tracked_change_email();
200689
200866
  init_revision_wid_scan();
200690
200867
  init_xml_sax();
200868
+ init_xml_tokens();
200691
200869
  TD27 = new TextDecoder;
200692
200870
  });
200693
200871
 
@@ -201230,6 +201408,7 @@ var init_export_projection = __esm(() => {
201230
201408
  init_xml_part_decoder();
201231
201409
  init_revision_open_tag();
201232
201410
  init_xml_sax();
201411
+ init_xml_tokens();
201233
201412
  init_metadata_projection();
201234
201413
  init_docx_export_policies();
201235
201414
  init_revision_id_export();
@@ -201326,6 +201505,7 @@ var authoredTocStyles, TD28;
201326
201505
  var init_toc_entry_style = __esm(() => {
201327
201506
  init_xml_part_decoder();
201328
201507
  init_style_definitions_part();
201508
+ init_xml_tokens();
201329
201509
  init_xml_sax();
201330
201510
  init_direct_paragraph_list_properties();
201331
201511
  authoredTocStyles = new WeakMap;
@@ -201878,6 +202058,7 @@ var init_resident_paragraphs = __esm(() => {
201878
202058
  init_xml_text();
201879
202059
  init_resident_paragraph_ownership();
201880
202060
  init_wml_paragraph_spans();
202061
+ init_xml_tokens();
201881
202062
  init_xml_sax();
201882
202063
  init_canonical_xml_analysis_frame();
201883
202064
  init_catalog_xml_analysis();
@@ -202210,6 +202391,7 @@ var init_table_catalog_publication = __esm(() => {
202210
202391
  init_part_payload();
202211
202392
  init_main_body_namespace_context();
202212
202393
  init_resident_paragraphs();
202394
+ init_xml_tokens();
202213
202395
  init_xml_sax();
202214
202396
  init_effective_list_reference();
202215
202397
  init_catalog3();
@@ -205729,6 +205911,7 @@ var init_field_paragraph_owner = __esm(() => {
205729
205911
  init_sd_document_state();
205730
205912
  init_paragraph_index();
205731
205913
  init_xml_text();
205914
+ init_xml_tokens();
205732
205915
  init_xml_sax();
205733
205916
  TD32 = createXmlPartDecoder();
205734
205917
  XML_PARSE_CHUNK_CODE_UNITS = 512 * 1024;
@@ -206760,6 +206943,7 @@ var init_field_catalog = __esm(() => {
206760
206943
  init_resident_paragraph_ownership();
206761
206944
  init_xml_text();
206762
206945
  init_xml_sax();
206946
+ init_xml_tokens();
206763
206947
  init_wml_paragraph_spans();
206764
206948
  init_part_wml_scan_cache();
206765
206949
  init_field_paragraph_owner();
@@ -207293,6 +207477,7 @@ var init_hyperlink_catalog = __esm(() => {
207293
207477
  init_xml_part_decoder();
207294
207478
  init_sd_document_state();
207295
207479
  init_wml_paragraph_spans();
207480
+ init_xml_tokens();
207296
207481
  init_relationships();
207297
207482
  init_xml_sax();
207298
207483
  init_part_wml_scan_cache();
@@ -208277,6 +208462,7 @@ var TD35, TOPOLOGY_BY_SOURCE_BYTES, LAST_TOPOLOGY_BY_STATE, YIELD_BYTE_INTERVAL,
208277
208462
  var init_top_level_table_topology = __esm(() => {
208278
208463
  init_xml_part_decoder();
208279
208464
  init_sd_document_state();
208465
+ init_xml_tokens();
208280
208466
  init_xml_sax();
208281
208467
  init_body_comment_anchors();
208282
208468
  init_paragraph_inline_model();
@@ -211659,6 +211845,7 @@ var TD36, TE9, MAX_SNAPSHOTS = 64, MAX_RETAINED_BYTES, MAX_BODY_WRAPPER_BYTES, O
211659
211845
  var init_paragraph_snapshots = __esm(() => {
211660
211846
  init_xml_part_decoder();
211661
211847
  init_relationship();
211848
+ init_xml_tokens();
211662
211849
  init_xml_sax();
211663
211850
  init_sha256_sync();
211664
211851
  init_inline_text_extraction();
@@ -212208,6 +212395,7 @@ var encoder6, decoder6, paragraphId = (range) => range.tag.attributes.find((attr
212208
212395
  var init_history_paragraph_insertion = __esm(() => {
212209
212396
  init_xml_text();
212210
212397
  init_history_replay_resources();
212398
+ init_xml_tokens();
212211
212399
  init_xml_sax();
212212
212400
  init_patch_substrate();
212213
212401
  encoder6 = new TextEncoder;
@@ -214921,17 +215109,213 @@ var init_paste_run_validation = __esm(() => {
214921
215109
  });
214922
215110
 
214923
215111
  // ../../../v2/editor-core/dist/document/transactions/types.js
215112
+ function isPasteCellBorderStyle(value) {
215113
+ return PASTE_CELL_BORDER_STYLES.some((style) => style === value);
215114
+ }
214924
215115
  function isPasteTabAlignment(value) {
214925
215116
  return PASTE_TAB_ALIGNMENTS.some((alignment) => alignment === value);
214926
215117
  }
214927
215118
  function isPasteTabLeader(value) {
214928
215119
  return PASTE_TAB_LEADERS.some((leader) => leader === value);
214929
215120
  }
214930
- var SD_PASTE_FRAGMENT_SUPPORTED_VERSIONS, PASTE_TAB_ALIGNMENTS, PASTE_TAB_LEADERS, SD_STYLE_CHAIN_TOGGLE_KEYS;
215121
+ var SD_PASTE_FRAGMENT_SUPPORTED_VERSIONS, PASTE_TAB_ALIGNMENTS, PASTE_TAB_LEADERS, PASTE_CELL_BORDER_STYLES, SD_STYLE_CHAIN_TOGGLE_KEYS;
214931
215122
  var init_types6 = __esm(() => {
214932
215123
  SD_PASTE_FRAGMENT_SUPPORTED_VERSIONS = new Set(["v2.1", "v2.2"]);
214933
215124
  PASTE_TAB_ALIGNMENTS = ["left", "center", "right", "decimal", "bar", "clear", "num"];
214934
215125
  PASTE_TAB_LEADERS = ["none", "dot", "hyphen", "underscore", "middleDot", "heavy"];
215126
+ PASTE_CELL_BORDER_STYLES = [
215127
+ "single",
215128
+ "thick",
215129
+ "double",
215130
+ "dotted",
215131
+ "dashed",
215132
+ "dotDash",
215133
+ "dotDotDash",
215134
+ "triple",
215135
+ "thinThickSmallGap",
215136
+ "thickThinSmallGap",
215137
+ "thinThickThinSmallGap",
215138
+ "thinThickMediumGap",
215139
+ "thickThinMediumGap",
215140
+ "thinThickThinMediumGap",
215141
+ "thinThickLargeGap",
215142
+ "thickThinLargeGap",
215143
+ "thinThickThinLargeGap",
215144
+ "wave",
215145
+ "doubleWave",
215146
+ "dashSmallGap",
215147
+ "dashDotStroked",
215148
+ "threeDEmboss",
215149
+ "threeDEngrave",
215150
+ "outset",
215151
+ "inset",
215152
+ "apples",
215153
+ "archedScallops",
215154
+ "babyPacifier",
215155
+ "babyRattle",
215156
+ "balloons3Colors",
215157
+ "balloonsHotAir",
215158
+ "basicBlackDashes",
215159
+ "basicBlackDots",
215160
+ "basicBlackSquares",
215161
+ "basicThinLines",
215162
+ "basicWhiteDashes",
215163
+ "basicWhiteDots",
215164
+ "basicWhiteSquares",
215165
+ "basicWideInline",
215166
+ "basicWideMidline",
215167
+ "basicWideOutline",
215168
+ "bats",
215169
+ "birds",
215170
+ "birdsFlight",
215171
+ "cabins",
215172
+ "cakeSlice",
215173
+ "candyCorn",
215174
+ "celticKnotwork",
215175
+ "certificateBanner",
215176
+ "chainLink",
215177
+ "champagneBottle",
215178
+ "checkedBarBlack",
215179
+ "checkedBarColor",
215180
+ "checkered",
215181
+ "christmasTree",
215182
+ "circlesLines",
215183
+ "circlesRectangles",
215184
+ "classicalWave",
215185
+ "clocks",
215186
+ "compass",
215187
+ "confetti",
215188
+ "confettiGrays",
215189
+ "confettiOutline",
215190
+ "confettiStreamers",
215191
+ "confettiWhite",
215192
+ "cornerTriangles",
215193
+ "couponCutoutDashes",
215194
+ "couponCutoutDots",
215195
+ "crazyMaze",
215196
+ "creaturesButterfly",
215197
+ "creaturesFish",
215198
+ "creaturesInsects",
215199
+ "creaturesLadyBug",
215200
+ "crossStitch",
215201
+ "cup",
215202
+ "decoArch",
215203
+ "decoArchColor",
215204
+ "decoBlocks",
215205
+ "diamondsGray",
215206
+ "doubleD",
215207
+ "doubleDiamonds",
215208
+ "earth1",
215209
+ "earth2",
215210
+ "earth3",
215211
+ "eclipsingSquares1",
215212
+ "eclipsingSquares2",
215213
+ "eggsBlack",
215214
+ "fans",
215215
+ "film",
215216
+ "firecrackers",
215217
+ "flowersBlockPrint",
215218
+ "flowersDaisies",
215219
+ "flowersModern1",
215220
+ "flowersModern2",
215221
+ "flowersPansy",
215222
+ "flowersRedRose",
215223
+ "flowersRoses",
215224
+ "flowersTeacup",
215225
+ "flowersTiny",
215226
+ "gems",
215227
+ "gingerbreadMan",
215228
+ "gradient",
215229
+ "handmade1",
215230
+ "handmade2",
215231
+ "heartBalloon",
215232
+ "heartGray",
215233
+ "hearts",
215234
+ "heebieJeebies",
215235
+ "holly",
215236
+ "houseFunky",
215237
+ "hypnotic",
215238
+ "iceCreamCones",
215239
+ "lightBulb",
215240
+ "lightning1",
215241
+ "lightning2",
215242
+ "mapPins",
215243
+ "mapleLeaf",
215244
+ "mapleMuffins",
215245
+ "marquee",
215246
+ "marqueeToothed",
215247
+ "moons",
215248
+ "mosaic",
215249
+ "musicNotes",
215250
+ "northwest",
215251
+ "ovals",
215252
+ "packages",
215253
+ "palmsBlack",
215254
+ "palmsColor",
215255
+ "paperClips",
215256
+ "papyrus",
215257
+ "partyFavor",
215258
+ "partyGlass",
215259
+ "pencils",
215260
+ "people",
215261
+ "peopleWaving",
215262
+ "peopleHats",
215263
+ "poinsettias",
215264
+ "postageStamp",
215265
+ "pumpkin1",
215266
+ "pushPinNote2",
215267
+ "pushPinNote1",
215268
+ "pyramids",
215269
+ "pyramidsAbove",
215270
+ "quadrants",
215271
+ "rings",
215272
+ "safari",
215273
+ "sawtooth",
215274
+ "sawtoothGray",
215275
+ "scaredCat",
215276
+ "seattle",
215277
+ "shadowedSquares",
215278
+ "sharksTeeth",
215279
+ "shorebirdTracks",
215280
+ "skyrocket",
215281
+ "snowflakeFancy",
215282
+ "snowflakes",
215283
+ "sombrero",
215284
+ "southwest",
215285
+ "stars",
215286
+ "starsTop",
215287
+ "stars3d",
215288
+ "starsBlack",
215289
+ "starsShadowed",
215290
+ "sun",
215291
+ "swirligig",
215292
+ "tornPaper",
215293
+ "tornPaperBlack",
215294
+ "trees",
215295
+ "triangleParty",
215296
+ "triangles",
215297
+ "triangle1",
215298
+ "triangle2",
215299
+ "triangleCircle1",
215300
+ "triangleCircle2",
215301
+ "shapes1",
215302
+ "shapes2",
215303
+ "twistedLines1",
215304
+ "twistedLines2",
215305
+ "vine",
215306
+ "waveline",
215307
+ "weavingAngles",
215308
+ "weavingBraid",
215309
+ "weavingRibbon",
215310
+ "weavingStrips",
215311
+ "whiteFlowers",
215312
+ "woodwork",
215313
+ "xIllusions",
215314
+ "zanyTriangles",
215315
+ "zigZag",
215316
+ "zigZagStitch",
215317
+ "custom"
215318
+ ];
214935
215319
  SD_STYLE_CHAIN_TOGGLE_KEYS = [
214936
215320
  "bold",
214937
215321
  "italic",
@@ -215357,11 +215741,16 @@ function renderPasteTableCellBody(cellSpec) {
215357
215741
  }
215358
215742
  function renderPasteTableCell(cell, renderParagraph = renderPasteParagraphBlock, renderTable = renderPasteTableBlock) {
215359
215743
  const gridSpan = Math.max(1, cell.gridSpan ?? 1);
215360
- const shading = cell.shadingColor ? `<w:shd w:val="clear" w:color="auto" w:fill="${escapeXmlAttribute(cell.shadingColor.toUpperCase())}"/>` : "";
215744
+ const themeByte = (name, value) => value === undefined ? "" : ` w:${name}="${value.toString(16).toUpperCase().padStart(2, "0")}"`;
215745
+ const themeFill = cell.shadingTheme ? ` w:themeFill="${escapeXmlAttribute(cell.shadingTheme.theme)}"${themeByte("themeFillTint", cell.shadingTheme.tint)}${themeByte("themeFillShade", cell.shadingTheme.shade)}` : "";
215746
+ const shading = cell.shadingColor || cell.shadingTheme ? `<w:shd w:val="clear" w:color="auto" w:fill="${escapeXmlAttribute(cell.shadingColor?.toUpperCase() ?? "auto")}"${themeFill}/>` : "";
215747
+ const noWrap = cell.noWrap === undefined ? "" : cell.noWrap ? "<w:noWrap/>" : '<w:noWrap w:val="0"/>';
215361
215748
  const marginSides = [
215362
215749
  ["top", cell.padding?.topPt],
215750
+ ["start", cell.padding?.startPt],
215363
215751
  ["left", cell.padding?.leftPt],
215364
215752
  ["bottom", cell.padding?.bottomPt],
215753
+ ["end", cell.padding?.endPt],
215365
215754
  ["right", cell.padding?.rightPt]
215366
215755
  ];
215367
215756
  const margins = marginSides.flatMap(([side, points]) => points === undefined ? [] : [`<w:${side} w:w="${Math.round(points * 20)}" w:type="dxa"/>`]).join("");
@@ -215369,12 +215758,12 @@ function renderPasteTableCell(cell, renderParagraph = renderPasteParagraphBlock,
215369
215758
  const borderSides = ["top", "left", "bottom", "right"];
215370
215759
  const borders = borderSides.flatMap((side) => {
215371
215760
  const border = cell.borders?.[side];
215372
- return border ? [border.lineStyle === "nil" ? `<w:${side} w:val="nil"/>` : `<w:${side} w:val="${escapeXmlAttribute(border.lineStyle)}" w:sz="${Math.max(1, Math.round(border.lineWeightPt * 8))}" w:color="${escapeXmlAttribute(border.color.toUpperCase())}"/>`] : [];
215761
+ return border ? [border.lineStyle === "nil" ? `<w:${side} w:val="nil"/>` : `<w:${side} w:val="${escapeXmlAttribute(border.lineStyle)}" w:sz="${Math.max(1, Math.round(border.lineWeightPt * 8))}" w:color="${escapeXmlAttribute(border.color === "auto" ? "auto" : border.color.toUpperCase())}"/>`] : [];
215373
215762
  }).join("");
215374
215763
  const tcBorders = borders ? `<w:tcBorders>${borders}</w:tcBorders>` : "";
215375
215764
  const vMerge = cell.vMerge === "restart" ? '<w:vMerge w:val="restart"/>' : cell.vMerge === "continue" ? "<w:vMerge/>" : "";
215376
215765
  const verticalAlign = cell.verticalAlign ? `<w:vAlign w:val="${cell.verticalAlign}"/>` : "";
215377
- const tcPr = `<w:tcPr><w:tcW w:w="0" w:type="auto"/>` + (gridSpan > 1 ? `<w:gridSpan w:val="${gridSpan}"/>` : "") + vMerge + tcBorders + shading + tcMar + verticalAlign + "</w:tcPr>";
215766
+ const tcPr = `<w:tcPr><w:tcW w:w="0" w:type="auto"/>` + (gridSpan > 1 ? `<w:gridSpan w:val="${gridSpan}"/>` : "") + vMerge + tcBorders + shading + noWrap + tcMar + verticalAlign + "</w:tcPr>";
215378
215767
  return `<w:tc>${tcPr}${cell.paragraphs.map((block) => ("rows" in block) ? renderTable(block) : renderParagraph(block)).join("")}</w:tc>`;
215379
215768
  }
215380
215769
  function renderPasteRunProperties(run, options) {
@@ -215652,6 +216041,7 @@ var WORDPROCESSINGML_NAMESPACE3 = "http://schemas.openxmlformats.org/wordprocess
215652
216041
  var init_paragraph_contribution = __esm(() => {
215653
216042
  init_tracked_change_email();
215654
216043
  init_xml_sax();
216044
+ init_xml_tokens();
215655
216045
  init_xml_text();
215656
216046
  init_paragraph_para_id_attrs();
215657
216047
  init_highlight_ooxml();
@@ -215958,6 +216348,7 @@ function serializeAttributes(attributes) {
215958
216348
  }
215959
216349
  var NS_XMLNS = "http://www.w3.org/2000/xmlns/";
215960
216350
  var init_simple_field_complex_runs = __esm(() => {
216351
+ init_xml_tokens();
215961
216352
  init_xml_sax();
215962
216353
  init_xml_text();
215963
216354
  });
@@ -216082,6 +216473,7 @@ function inlineRevisionSegments(xml, namespaceBindings, containers) {
216082
216473
  }
216083
216474
  var RUN_REVISION_CHILDREN, REVISION_CONTAINERS;
216084
216475
  var init_tracked_inline_replacement = __esm(() => {
216476
+ init_xml_tokens();
216085
216477
  init_xml_sax();
216086
216478
  init_paragraph_contribution();
216087
216479
  init_block_deletion_text();
@@ -216189,6 +216581,7 @@ function prepareTrackedParagraphContentReplacement(input) {
216189
216581
  return after === null ? null : { xml: before + after, wordIds };
216190
216582
  }
216191
216583
  var init_tracked_paragraph_content = __esm(() => {
216584
+ init_xml_tokens();
216192
216585
  init_xml_sax();
216193
216586
  init_tracked_inline_replacement();
216194
216587
  });
@@ -216307,6 +216700,7 @@ function prepareTrackedTableStructureXml(input, rootKind) {
216307
216700
  });
216308
216701
  }
216309
216702
  var init_tracked_table_replacement = __esm(() => {
216703
+ init_xml_tokens();
216310
216704
  init_xml_sax();
216311
216705
  init_paragraph_contribution();
216312
216706
  });
@@ -216406,6 +216800,7 @@ function prepareTrackedBlockXmlReplacement(input) {
216406
216800
  return inserted === null ? null : { xml: deleted + inserted, wordIds };
216407
216801
  }
216408
216802
  var init_tracked_block_replacement = __esm(() => {
216803
+ init_xml_tokens();
216409
216804
  init_xml_sax();
216410
216805
  init_paragraph_contribution();
216411
216806
  init_tracked_paragraph_content();
@@ -216505,6 +216900,7 @@ function planTableCellReplacementParaId(parts) {
216505
216900
  }
216506
216901
  var init_table_cell_text_replacement = __esm(() => {
216507
216902
  init_ensure_para_ids();
216903
+ init_xml_tokens();
216508
216904
  init_xml_sax();
216509
216905
  init_tracked_block_replacement();
216510
216906
  init_tracked_inline_replacement();
@@ -218748,6 +219144,7 @@ function nativeSdtValidationView(xml, namespaces, kind) {
218748
219144
  }
218749
219145
  var word4 = (range2) => range2.tag.namespaceUri === NS_W || range2.tag.namespaceUri === NS_WSTRICT, XMLNS = "http://www.w3.org/2000/xmlns/";
218750
219146
  var init_native_sdt_validation = __esm(() => {
219147
+ init_xml_tokens();
218751
219148
  init_xml_sax();
218752
219149
  init_xml_namespace_scope();
218753
219150
  init_paragraph_snapshots();
@@ -219851,6 +220248,7 @@ var TE11, TD37, W144 = "http://schemas.microsoft.com/office/word/2010/wordml", O
219851
220248
  var init_native_ooxml_import = __esm(() => {
219852
220249
  init_xml_part_decoder();
219853
220250
  init_native_sdt_validation();
220251
+ init_xml_tokens();
219854
220252
  init_xml_sax();
219855
220253
  init_sha256_sync();
219856
220254
  init_xml_text();
@@ -220003,6 +220401,7 @@ function normalizePasteMath(input, namespaces = {}) {
220003
220401
  }
220004
220402
  var M = "http://schemas.openxmlformats.org/officeDocument/2006/math", MATH_NAMES, CONSTRUCTOR_ARGUMENTS, REPEATING_ARGUMENTS, PROPERTY_CHILDREN, ARGUMENT_NAMES, OBJECT_NAMES, STRUCTURAL_NAMES;
220005
220403
  var init_paste_math = __esm(() => {
220404
+ init_xml_tokens();
220006
220405
  init_xml_sax();
220007
220406
  init_inline_text_extraction();
220008
220407
  init_native_ooxml_import();
@@ -220098,6 +220497,7 @@ function proveAnnotationSourceEffect(input) {
220098
220497
  }
220099
220498
  var TE12, TD38;
220100
220499
  var init_render_commit_annotation_effect = __esm(() => {
220500
+ init_xml_tokens();
220101
220501
  init_body_comment_anchors();
220102
220502
  TE12 = new TextEncoder;
220103
220503
  TD38 = new TextDecoder;
@@ -220477,6 +220877,7 @@ function normalizeDecimalNumberingId(value) {
220477
220877
  return Number.isSafeInteger(normalized) ? String(normalized) : null;
220478
220878
  }
220479
220879
  var init_numbering = __esm(() => {
220880
+ init_xml_tokens();
220480
220881
  init_xml_sax();
220481
220882
  });
220482
220883
 
@@ -220937,6 +221338,7 @@ var init_compile_comment_helpers = __esm(() => {
220937
221338
  init_package_graph();
220938
221339
  init_xml_text();
220939
221340
  init_xml_sax();
221341
+ init_xml_tokens();
220940
221342
  init_xml_namespace_scope();
220941
221343
  TE16 = new TextEncoder;
220942
221344
  TD41 = createXmlPartDecoder();
@@ -222017,6 +222419,7 @@ function planRightToLeftReplacementSpans({ paragraphXml, startOffset, endOffset,
222017
222419
  var STRONG_RTL, LETTER2, RUN_PROPERTY_ORDER2;
222018
222420
  var init_complex_script_run_properties = __esm(() => {
222019
222421
  init_paragraph_inline_model();
222422
+ init_xml_tokens();
222020
222423
  init_xml_sax();
222021
222424
  STRONG_RTL = new RegExp("(?=\\p{L})[\\p{Script=Hebrew}\\p{Script=Arabic}\\p{Script=Syriac}\\p{Script=Thaana}\\p{Script=Nko}" + "\\p{Script=Samaritan}\\p{Script=Mandaic}\\p{Script=Adlam}\\p{Script=Hanifi_Rohingya}]", "u");
222022
222425
  LETTER2 = /\p{L}/u;
@@ -223832,6 +224235,7 @@ var TD44, TE18, TOC_ENTRY_STYLE_RE, TOC_ENTRY_DESCENDABLE, EMPTY, DEFAULT_FRESH_
223832
224235
  var init_compile_edit_text_inline_plan = __esm(() => {
223833
224236
  init_word_text_payload();
223834
224237
  init_complex_script_run_properties();
224238
+ init_xml_tokens();
223835
224239
  init_xml_sax();
223836
224240
  init_paragraph_inline_model();
223837
224241
  init_paragraph_property_block();
@@ -224492,6 +224896,7 @@ var init_render_commit_inline_effect = __esm(() => {
224492
224896
  init_paragraph_inline_model();
224493
224897
  init_resident_paragraphs();
224494
224898
  init_xml_text();
224899
+ init_xml_tokens();
224495
224900
  init_xml_sax();
224496
224901
  init_compile_edit_text_inline_plan();
224497
224902
  residentEffectModels = new WeakMap;
@@ -224906,6 +225311,7 @@ function paragraphPropertiesSignature(xml, property, ranges) {
224906
225311
  var init_remote_tracked_paragraph_effect = __esm(() => {
224907
225312
  init_paragraph_inline_model();
224908
225313
  init_xml_sax();
225314
+ init_xml_tokens();
224909
225315
  });
224910
225316
 
224911
225317
  // ../../../v2/editor-core/dist/document/transactions/preserved-structural-sdt.js
@@ -224957,6 +225363,7 @@ function stripPreservedStructuralSdtTags(origin, current) {
224957
225363
  }
224958
225364
  var INLINE_SDT_DEPENDENCY_RE;
224959
225365
  var init_preserved_structural_sdt = __esm(() => {
225366
+ init_xml_tokens();
224960
225367
  init_xml_sax();
224961
225368
  INLINE_SDT_DEPENDENCY_RE = /<(?:[\w.-]+:)?sdt\b/;
224962
225369
  });
@@ -225047,6 +225454,7 @@ function childElements(xml, from, to) {
225047
225454
  }
225048
225455
  var MARK_KINDS;
225049
225456
  var init_paragraph_mark_markers = __esm(() => {
225457
+ init_xml_tokens();
225050
225458
  init_xml_sax();
225051
225459
  MARK_KINDS = new Set(["ins", "del", "moveFrom", "moveTo"]);
225052
225460
  });
@@ -225323,6 +225731,7 @@ var init_structural_tracked_carrier_partition = __esm(() => {
225323
225731
  init_paragraph_inline_model();
225324
225732
  init_resident_paragraph_ownership();
225325
225733
  init_resident_review();
225734
+ init_xml_tokens();
225326
225735
  init_tracked_change_email();
225327
225736
  init_catalog3();
225328
225737
  init_comment_range_invariance();
@@ -231435,6 +231844,7 @@ var init_render_commit_envelope = __esm(() => {
231435
231844
  init_tracked_annotation_history();
231436
231845
  init_tracked_annotation_reconstruction();
231437
231846
  init_paragraph_mark_markers();
231847
+ init_xml_tokens();
231438
231848
  init_body_boundary_scan();
231439
231849
  init_comment_range_invariance();
231440
231850
  init_source_coverage_chunks();
@@ -232710,9 +233120,10 @@ function collidesWithExistingParaId2(state, candidate2) {
232710
233120
  }
232711
233121
  function collectCommentIdsInRange(xml) {
232712
233122
  const out = new Set;
232713
- for (const m of xml.matchAll(/<[\w.-]+:(?:commentRangeStart|commentRangeEnd|commentReference)\b[^>]*\bw:id="([^"]+)"/g)) {
232714
- if (m[1])
232715
- out.add(m[1]);
233123
+ const markerRe = new RegExp(String.raw`<${COMMENT_MARKER_ELEMENT_PREFIX}:(?:commentRangeStart|commentRangeEnd|commentReference)\b[^>]*\b${COMMENT_MARKER_ID_ATTRIBUTE}="([^"]+)"`, "g");
233124
+ for (const m of xml.matchAll(markerRe)) {
233125
+ if (m[2])
233126
+ out.add(m[2]);
232716
233127
  }
232717
233128
  return out;
232718
233129
  }
@@ -234170,6 +234581,7 @@ var TD46, TE20, TABLE_MINT_COUNTER = 0;
234170
234581
  var init_compile_table_ops = __esm(() => {
234171
234582
  init_xml_part_decoder();
234172
234583
  init_xml_sax();
234584
+ init_xml_tokens();
234173
234585
  init_paragraph_contribution();
234174
234586
  init_hyperlink_catalog();
234175
234587
  init_retired_story_relationships();
@@ -235091,6 +235503,7 @@ function unboundPrefixedAttributeValue(openTag, prefix2, localName2) {
235091
235503
  }
235092
235504
  var BASE_RUN_PROPERTIES_IN_SCHEMA_ORDER, INSERTED_BLOCK_BASE_RUN_PROPERTIES, MAX_CHARACTER_STYLE_CHAIN_LENGTH = 64, PROPERTIES_WITH_INDEPENDENT_SCRIPT_SLOTS, FONT_SLOT_ATTRIBUTE_PAIRS;
235093
235505
  var init_inserted_block_run_properties = __esm(() => {
235506
+ init_xml_tokens();
235094
235507
  init_xml_text();
235095
235508
  init_style_definitions_xml();
235096
235509
  init_xml_sax();
@@ -235782,6 +236195,7 @@ var init_insertion_formatting_context = __esm(() => {
235782
236195
  init_style_definitions_xml();
235783
236196
  init_paragraph_inline_model();
235784
236197
  init_xml_text();
236198
+ init_xml_tokens();
235785
236199
  init_xml_sax();
235786
236200
  init_paragraph_contribution();
235787
236201
  init_direct_paragraph_list_properties();
@@ -238882,6 +239296,8 @@ function pasteTableSpec(block, mintNextParaId, bindW14NamespaceInline, runs = (b
238882
239296
  ...cell.gridSpan !== undefined ? { gridSpan: cell.gridSpan } : {},
238883
239297
  ...cell.vMerge !== undefined ? { vMerge: cell.vMerge } : {},
238884
239298
  ...cell.shadingColor !== undefined ? { shadingColor: cell.shadingColor } : {},
239299
+ ...cell.shadingTheme !== undefined ? { shadingTheme: cell.shadingTheme } : {},
239300
+ ...cell.noWrap !== undefined ? { noWrap: cell.noWrap } : {},
238885
239301
  ...cell.padding !== undefined ? { padding: cell.padding } : {},
238886
239302
  ...cell.verticalAlign !== undefined ? { verticalAlign: cell.verticalAlign } : {},
238887
239303
  ...cell.borders !== undefined ? { borders: cell.borders } : {},
@@ -239424,6 +239840,7 @@ function outsideControlBoundary(xml, nodeId, placement2) {
239424
239840
  return paragraphId2 ? { xmlOffset: placement2 === "before" ? control2.start : control2.end, paragraphId: paragraphId2, boundaryXml, beforeControlMarkup: placement2 === "before" ? xml.slice(neighbour.end, control2.start) : "" } : null;
239425
239841
  }
239426
239842
  var init_outside_control_boundary = __esm(() => {
239843
+ init_xml_tokens();
239427
239844
  init_xml_sax();
239428
239845
  });
239429
239846
 
@@ -239510,6 +239927,7 @@ function stampTrackedRangeParagraph(xml, rsid, partBytes, paragraphStartByte) {
239510
239927
  var TE22, TD49;
239511
239928
  var init_tracked_enclosed_tables = __esm(() => {
239512
239929
  init_xml_part_decoder();
239930
+ init_xml_tokens();
239513
239931
  init_xml_sax();
239514
239932
  init_paragraph_contribution();
239515
239933
  init_paragraph_para_id_attrs();
@@ -247315,6 +247733,7 @@ var init_compile_edit_text = __esm(() => {
247315
247733
  init_source_coverage_chunks();
247316
247734
  init_revision_wid_scan();
247317
247735
  init_wml_paragraph_spans();
247736
+ init_xml_tokens();
247318
247737
  init_xml_sax();
247319
247738
  init_paragraph_inline_model();
247320
247739
  init_textbox_paragraph_signature();
@@ -248703,6 +249122,7 @@ var init_semantic_style_dependencies = __esm(() => {
248703
249122
  init_semantic_style_definitions();
248704
249123
  init_sd_document_state();
248705
249124
  init_xml_sax();
249125
+ init_xml_tokens();
248706
249126
  init_relationships();
248707
249127
  init_style_definitions_part();
248708
249128
  init_patch_substrate();
@@ -250001,6 +250421,7 @@ var TD56, STATE_CACHE3, PART_CACHE;
250001
250421
  var init_image_catalog = __esm(() => {
250002
250422
  init_xml_part_decoder();
250003
250423
  init_sd_document_state();
250424
+ init_xml_tokens();
250004
250425
  init_xml_sax();
250005
250426
  init_wml_paragraph_spans();
250006
250427
  init_part_wml_scan_cache();
@@ -251304,6 +251725,7 @@ var init_compile_image_ops = __esm(() => {
251304
251725
  init_xml_text();
251305
251726
  init_tracked_change_email();
251306
251727
  init_paragraph_inline_model();
251728
+ init_xml_tokens();
251307
251729
  init_xml_sax();
251308
251730
  init_sd_document_state();
251309
251731
  init_commit_prepared_mutation();
@@ -251602,6 +252024,7 @@ function incompleteFieldAt(catalog, byteOffset) {
251602
252024
  var TD58, PAIRED_RANGE_MARKER_FAMILIES, PAIRED_RANGE_MARKER_TAG;
251603
252025
  var init_range_integrity = __esm(() => {
251604
252026
  init_paragraph_inline_model();
252027
+ init_xml_tokens();
251605
252028
  init_paragraph_para_id_attrs();
251606
252029
  init_xml_sax();
251607
252030
  init_field_catalog();
@@ -251734,6 +252157,7 @@ function serializeTrackedListRemovalMetadata(xml, wordPrefix, namespaces, option
251734
252157
  }
251735
252158
  var property = "removedListIndent", indentTag;
251736
252159
  var init_tracked_list_removal_indent = __esm(() => {
252160
+ init_xml_tokens();
251737
252161
  init_xml_sax();
251738
252162
  init_tracked_change_email();
251739
252163
  init_xml_text();
@@ -251914,6 +252338,7 @@ function isReversibleTrackedListBoundary(input) {
251914
252338
  }
251915
252339
  var propertyOrder;
251916
252340
  var init_tracked_list_boundary_restore = __esm(() => {
252341
+ init_xml_tokens();
251917
252342
  init_xml_sax();
251918
252343
  init_paragraph_inline_model();
251919
252344
  init_tracked_change_email();
@@ -252060,6 +252485,7 @@ function withoutProperties(value) {
252060
252485
  }
252061
252486
  var init_paragraph_section_collapse = __esm(() => {
252062
252487
  init_xml_namespace_scope();
252488
+ init_xml_tokens();
252063
252489
  init_xml_sax();
252064
252490
  init_paragraph_para_id_attrs();
252065
252491
  init_split_paragraph_inline();
@@ -252072,7 +252498,7 @@ function requiredCellParagraphReplacement(partXml, paragraphStart) {
252072
252498
  return null;
252073
252499
  const { paragraph, ranges: ranges2 } = boundary;
252074
252500
  const firstChild = directChildren2(ranges2, paragraph)[0];
252075
- const properties3 = firstChild?.tag.namespaceUri === NS_W && firstChild.tag.localName === "pPr" ? firstChild : undefined;
252501
+ const properties3 = firstChild && isWordprocessingNamespace(firstChild.tag.namespaceUri) && firstChild.tag.localName === "pPr" ? firstChild : undefined;
252076
252502
  const open2 = partXml.slice(paragraph.start, paragraph.openEnd);
252077
252503
  if (paragraph.tag.isSelfClosing)
252078
252504
  return open2;
@@ -252084,13 +252510,13 @@ function inspectCellParagraphRange(partXml, paragraphStart, rangeEnd) {
252084
252510
  return null;
252085
252511
  const ranges2 = parsed.ranges.sort((a, b) => a.start - b.start);
252086
252512
  const paragraph = ranges2.find((range2) => range2.start === paragraphStart);
252087
- if (!paragraph || paragraph.tag.namespaceUri !== NS_W || paragraph.tag.localName !== "p")
252513
+ if (!paragraph || !isWordprocessingNamespace(paragraph.tag.namespaceUri) || paragraph.tag.localName !== "p")
252088
252514
  return null;
252089
252515
  const parent = ranges2.filter((range2) => range2.start < paragraph.start && range2.end > paragraph.end).at(-1);
252090
- if (!parent || parent.tag.namespaceUri !== NS_W || parent.tag.localName !== "tc")
252516
+ if (!parent || !isWordprocessingNamespace(parent.tag.namespaceUri) || parent.tag.localName !== "tc")
252091
252517
  return null;
252092
252518
  const end = rangeEnd ?? paragraph.end;
252093
- const blocks = directChildren2(ranges2, parent).filter(({ tag }) => tag.namespaceUri === NS_W && CELL_BLOCKS.has(tag.localName));
252519
+ const blocks = directChildren2(ranges2, parent).filter(({ tag }) => isWordprocessingNamespace(tag.namespaceUri) && CELL_BLOCKS.has(tag.localName));
252094
252520
  const selected = blocks.filter((block) => block.start >= paragraph.start && block.end <= end);
252095
252521
  if (!selected.length || selected.at(-1).end !== end || selected.some((block) => block.tag.localName !== "p"))
252096
252522
  return null;
@@ -252115,6 +252541,7 @@ function directChildren2(ranges2, parent) {
252115
252541
  var CELL_BLOCKS;
252116
252542
  var init_paragraph_delete_cell_boundary = __esm(() => {
252117
252543
  init_xml_sax();
252544
+ init_xml_tokens();
252118
252545
  CELL_BLOCKS = new Set(["p", "tbl", "sdt", "customXml", "altChunk"]);
252119
252546
  });
252120
252547
 
@@ -252286,6 +252713,7 @@ function prepareTrackedParagraphMergeProperties(input) {
252286
252713
  return { xml: secondXml.slice(0, start) + propertiesXml + secondXml.slice(end), wordIds: prepared.wordIds };
252287
252714
  }
252288
252715
  var init_tracked_paragraph_merge = __esm(() => {
252716
+ init_xml_tokens();
252289
252717
  init_xml_sax();
252290
252718
  init_split_paragraph_inline();
252291
252719
  init_paragraph_property_namespaces();
@@ -252413,6 +252841,7 @@ function prepareTrackedTerminalParagraphDeletion(input) {
252413
252841
  }
252414
252842
  var init_tracked_terminal_paragraph_delete = __esm(() => {
252415
252843
  init_tracked_change_email();
252844
+ init_xml_tokens();
252416
252845
  init_xml_sax();
252417
252846
  init_paragraph_property_namespaces();
252418
252847
  init_paragraph_contribution();
@@ -252515,6 +252944,7 @@ function prepareDrawingParagraphContentDeletion(input) {
252515
252944
  }
252516
252945
  var DRAWING = "http://schemas.openxmlformats.org/drawingml/2006/main", RELATIONSHIP = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
252517
252946
  var init_paragraph_drawing_delete = __esm(() => {
252947
+ init_xml_tokens();
252518
252948
  init_xml_sax();
252519
252949
  init_package_graph();
252520
252950
  init_tracked_paragraph_content();
@@ -252700,6 +253130,7 @@ function prepareParagraphPropertyChange(input) {
252700
253130
  }
252701
253131
  var OFFICE_MATH_NAMESPACE3 = "http://schemas.openxmlformats.org/officeDocument/2006/math", ANNOTATION_ONLY_RUN_CHILDREN;
252702
253132
  var init_paragraph_property_change = __esm(() => {
253133
+ init_xml_tokens();
252703
253134
  init_xml_sax();
252704
253135
  init_xml_namespace_scope();
252705
253136
  init_tracked_change_email();
@@ -254461,6 +254892,7 @@ var init_compile_list_ops = __esm(() => {
254461
254892
  init_tracked_list_removal_indent();
254462
254893
  init_paragraph_para_id_attrs();
254463
254894
  init_xml_sax();
254895
+ init_xml_tokens();
254464
254896
  init_paragraph_property_change();
254465
254897
  init_paragraph_property_namespaces();
254466
254898
  init_semantic_style_roles();
@@ -254595,6 +255027,7 @@ function prepareMovedPictureIdentities(input) {
254595
255027
  }
254596
255028
  var PIC = "http://schemas.openxmlformats.org/drawingml/2006/picture", DRAWING2 = "http://schemas.openxmlformats.org/drawingml/2006/main", WP14 = "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing";
254597
255029
  var init_moved_picture_identities = __esm(() => {
255030
+ init_xml_tokens();
254598
255031
  init_xml_sax();
254599
255032
  init_drawing_id_allocator();
254600
255033
  });
@@ -254804,6 +255237,7 @@ function prepareTrackedBlockMove(input) {
254804
255237
  return destinationXml == null ? null : { sourceXml, destinationXml, wordIds };
254805
255238
  }
254806
255239
  var init_tracked_block_move = __esm(() => {
255240
+ init_xml_tokens();
254807
255241
  init_table_cell_content();
254808
255242
  init_xml_sax();
254809
255243
  init_xml_text();
@@ -258308,6 +258742,7 @@ var init_compile_paragraph_ops = __esm(() => {
258308
258742
  init_structural_boundary_map();
258309
258743
  init_paragraph_section_collapse();
258310
258744
  init_paragraph_delete_cell_boundary();
258745
+ init_xml_tokens();
258311
258746
  init_xml_sax();
258312
258747
  init_tracked_paragraph_merge();
258313
258748
  init_tracked_terminal_paragraph_delete();
@@ -261447,12 +261882,18 @@ function validateBlocks(blocks) {
261447
261882
  if (cell.shadingColor !== undefined && (typeof cell.shadingColor !== "string" || !/^[0-9A-F]{6}$/i.test(cell.shadingColor))) {
261448
261883
  return { ok: false, reason: "paste-structure-unsupported" };
261449
261884
  }
261885
+ if (cell.shadingTheme !== undefined && !isPasteCellThemeShading(cell.shadingTheme)) {
261886
+ return { ok: false, reason: "paste-structure-unsupported" };
261887
+ }
261888
+ if (cell.noWrap !== undefined && typeof cell.noWrap !== "boolean") {
261889
+ return { ok: false, reason: "paste-structure-unsupported" };
261890
+ }
261450
261891
  if (cell.padding !== undefined) {
261451
261892
  if (typeof cell.padding !== "object" || cell.padding === null || Array.isArray(cell.padding)) {
261452
261893
  return { ok: false, reason: "paste-structure-unsupported" };
261453
261894
  }
261454
261895
  let hasPaddingSide = false;
261455
- for (const side of ["topPt", "rightPt", "bottomPt", "leftPt"]) {
261896
+ for (const side of ["topPt", "rightPt", "bottomPt", "leftPt", "startPt", "endPt"]) {
261456
261897
  const value = cell.padding[side];
261457
261898
  if (value === undefined)
261458
261899
  continue;
@@ -261474,7 +261915,7 @@ function validateBlocks(blocks) {
261474
261915
  const border = cell.borders[side];
261475
261916
  if (border === undefined)
261476
261917
  continue;
261477
- if (typeof border !== "object" || border === null || Array.isArray(border) || typeof border.lineStyle !== "string" || (border.lineStyle === "nil" ? border.lineWeightPt !== 0 || border.color !== "auto" : !["single", "dashed", "dotted", "double"].includes(border.lineStyle) || typeof border.lineWeightPt !== "number" || !Number.isFinite(border.lineWeightPt) || border.lineWeightPt <= 0 || !Number.isSafeInteger(Math.round(border.lineWeightPt * 8)) || typeof border.color !== "string" || !/^[0-9A-F]{6}$/i.test(border.color)))
261918
+ if (typeof border !== "object" || border === null || Array.isArray(border) || typeof border.lineStyle !== "string" || (border.lineStyle === "nil" ? border.lineWeightPt !== 0 || border.color !== "auto" : !isPasteCellBorderStyle(border.lineStyle) || typeof border.lineWeightPt !== "number" || !Number.isFinite(border.lineWeightPt) || border.lineWeightPt <= 0 || !Number.isSafeInteger(Math.round(border.lineWeightPt * 8)) || typeof border.color !== "string" || border.color !== "auto" && !/^[0-9A-F]{6}$/i.test(border.color)))
261478
261919
  return { ok: false, reason: "paste-structure-unsupported" };
261479
261920
  }
261480
261921
  }
@@ -261720,6 +262161,12 @@ function visibleCharLength(block) {
261720
262161
  function isMaterializablePasteBlocks(blocks) {
261721
262162
  return blocks.every((block) => block.kind === "paragraph" || block.kind === "horizontalRule" || block.kind === "table");
261722
262163
  }
262164
+ function isThemeByte(value) {
262165
+ return value === undefined || typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 255;
262166
+ }
262167
+ function isPasteCellThemeShading(value) {
262168
+ return typeof value === "object" && value !== null && typeof value.theme === "string" && /^[A-Za-z0-9]+$/.test(value.theme) && isThemeByte(value.tint) && isThemeByte(value.shade);
262169
+ }
261723
262170
  function isSafePaddingPoints(value) {
261724
262171
  return typeof value === "number" && Number.isFinite(value) && value >= 0 && Number.isSafeInteger(value * 20);
261725
262172
  }
@@ -262257,6 +262704,7 @@ var init_compile_paste_fragment = __esm(() => {
262257
262704
  init_image_content_types();
262258
262705
  init_sd_document_state();
262259
262706
  init_text_offset_mapping();
262707
+ init_xml_tokens();
262260
262708
  init_body_boundary_scan();
262261
262709
  init_body_section_scan();
262262
262710
  init_xml_sax();
@@ -268521,6 +268969,7 @@ function colorFromBackgroundAttrs(attrs) {
268521
268969
  }
268522
268970
  var TD65, SIX_HEX;
268523
268971
  var init_document_background = __esm(() => {
268972
+ init_xml_tokens();
268524
268973
  init_xml_sax();
268525
268974
  TD65 = new TextDecoder("utf-8", { fatal: false });
268526
268975
  SIX_HEX = /^[0-9a-fA-F]{6}$/;
@@ -269130,6 +269579,7 @@ function createBlockLevelMathWalk(xml) {
269130
269579
  }
269131
269580
  var BLOCK_LEVEL_MATH_STORY_KINDS, UTF8_MATH_MARKER, XML_DECLARATION_ENCODING, MATH_NAMESPACES, MATH_BLOCK_ELEMENTS, PARAGRAPH_CONTAINERS, BLOCK_PASS_THROUGH_CONTAINERS, BLOCK_REVISION_CONTAINERS;
269132
269581
  var init_block_level_math = __esm(() => {
269582
+ init_xml_tokens();
269133
269583
  init_xml_part_decoder();
269134
269584
  init_xml_sax();
269135
269585
  init_ensure_package_para_ids();
@@ -272077,6 +272527,7 @@ function assertAuthoredRevisionEmailAfterCommit(input) {
272077
272527
  var DECODER2, AUTHOR_BEARING;
272078
272528
  var init_revision_author_invariant = __esm(() => {
272079
272529
  init_xml_part_decoder();
272530
+ init_xml_tokens();
272080
272531
  init_xml_sax();
272081
272532
  init_tracked_change_email();
272082
272533
  init_xml_text();
@@ -272107,6 +272558,44 @@ var init_revision_author_invariant = __esm(() => {
272107
272558
  ]);
272108
272559
  });
272109
272560
 
272561
+ // ../../../v2/editor-core/dist/document/transactions/word-element-scope.js
272562
+ function prefixBoundIn(bindings2, preferred, accepts) {
272563
+ if (preferred && accepts(bindings2[preferred]))
272564
+ return preferred;
272565
+ return Object.keys(bindings2).find((prefix2) => prefix2 !== "" && accepts(bindings2[prefix2])) ?? null;
272566
+ }
272567
+ function wordElementScopeAt(bytes, insertByte, source) {
272568
+ return wordElementScopeFromBindings(namespaceBindingsAtPosition(bytes, insertByte), source.prefix, () => namespaceBindingsAtPosition(bytes, source.byteOffset, source.openTag));
272569
+ }
272570
+ function wordElementScopeFromBindings(insertionBindings, sourcePrefix, sourceBindings) {
272571
+ return elementScopeFromBindings(insertionBindings, sourcePrefix, sourceBindings, isWordprocessingNamespace);
272572
+ }
272573
+ function elementScopeForNamespace(bindings2, preferred, namespaceUri, reserved) {
272574
+ const inScope = prefixBoundIn(bindings2, preferred, (candidate2) => candidate2 === namespaceUri);
272575
+ if (inScope)
272576
+ return { prefix: inScope, declaration: "" };
272577
+ let prefix2 = preferred && !reserved.has(preferred) ? preferred : "w";
272578
+ for (let suffix = 1;reserved.has(prefix2); suffix += 1)
272579
+ prefix2 = `ns${suffix}`;
272580
+ return { prefix: prefix2, declaration: ` xmlns:${prefix2}="${escapeXmlAttribute(namespaceUri)}"` };
272581
+ }
272582
+ function elementScopeFromBindings(insertionBindings, sourcePrefix, sourceBindings, accepts) {
272583
+ const inScope = prefixBoundIn(insertionBindings, sourcePrefix, accepts);
272584
+ if (inScope)
272585
+ return { prefix: inScope, declaration: "" };
272586
+ const bindings2 = sourceBindings();
272587
+ const declared = prefixBoundIn(bindings2, sourcePrefix, accepts);
272588
+ const namespaceUri = declared ? bindings2[declared] : undefined;
272589
+ if (!declared || namespaceUri === undefined)
272590
+ return null;
272591
+ return { prefix: declared, declaration: ` xmlns:${declared}="${escapeXmlAttribute(namespaceUri)}"` };
272592
+ }
272593
+ var init_word_element_scope = __esm(() => {
272594
+ init_xml_tokens();
272595
+ init_xml_text();
272596
+ init_paragraph_para_id_attrs();
272597
+ });
272598
+
272110
272599
  // ../../../v2/editor-core/dist/document/transactions/compile-tracked-whole-story-delete.js
272111
272600
  function runTrackedWholeStoryDeleteCommit(input) {
272112
272601
  const { state, op, txId } = input;
@@ -274047,6 +274536,7 @@ var init_compile_format_run_range = __esm(() => {
274047
274536
  init_xml_sax();
274048
274537
  init_resident_paragraphs();
274049
274538
  init_resident_paragraph_ownership();
274539
+ init_xml_tokens();
274050
274540
  init_simple_text_run_split();
274051
274541
  init_paragraph_mark_format_history();
274052
274542
  init_highlight_ooxml();
@@ -274450,6 +274940,7 @@ function isStoryPartUri2(partUri) {
274450
274940
  var TD68, TE35, FOOTNOTES_PART_URI2 = "/word/footnotes.xml", ENDNOTES_PART_URI2 = "/word/endnotes.xml", SETTINGS_PART_URI2 = "/word/settings.xml", DOCUMENT_RELS_PART_URI8 = "/word/_rels/document.xml.rels", CONTENT_TYPES_PART_URI10 = "/[Content_Types].xml", FOOTNOTES_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes", ENDNOTES_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes", NOTE_CONFIG_CHILD_RE;
274451
274941
  var init_note_export_hygiene = __esm(() => {
274452
274942
  init_xml_part_decoder();
274943
+ init_xml_tokens();
274453
274944
  init_xml_sax();
274454
274945
  TD68 = createXmlPartDecoder();
274455
274946
  TE35 = new TextEncoder;
@@ -274781,6 +275272,7 @@ function hasSessionSyncAdjacentRevisionDecision(xml, fragments, decision, namesp
274781
275272
  }
274782
275273
  var OFFICE_MATH_NAMESPACE4 = "http://schemas.openxmlformats.org/officeDocument/2006/math", TEXTBOX_CONTENT_LOCAL_NAMES, SDT_LOCAL_NAMES, OPAQUE_CARRIER_LOCAL_NAMES;
274783
275274
  var init_structural_inline_decision = __esm(() => {
275275
+ init_xml_tokens();
274784
275276
  init_xml_sax();
274785
275277
  TEXTBOX_CONTENT_LOCAL_NAMES = new Set(["txbxContent"]);
274786
275278
  SDT_LOCAL_NAMES = new Set(["sdt"]);
@@ -275492,6 +275984,7 @@ var init_compile_tracked_change_decide_local = __esm(() => {
275492
275984
  init_resident_paragraph_ownership();
275493
275985
  init_paragraph_inline_model();
275494
275986
  init_xml_sax();
275987
+ init_xml_tokens();
275495
275988
  init_lazy_indexes();
275496
275989
  init_commit_prepared_mutation();
275497
275990
  init_prepared_mutation();
@@ -275665,6 +276158,7 @@ function proveFinalTrackedDecisionSource(input) {
275665
276158
  var TE37, TD72, MAX_SOURCE_BYTES, MAX_PARAGRAPHS = 32, ALLOWED_ELEMENTS;
275666
276159
  var init_tracked_decision_final_source = __esm(() => {
275667
276160
  init_xml_part_decoder();
276161
+ init_xml_tokens();
275668
276162
  init_xml_sax();
275669
276163
  init_paragraph_index();
275670
276164
  init_resident_paragraph_ownership();
@@ -276274,6 +276768,7 @@ function unchangedTableMoveSupportingParagraph(xml, pair) {
276274
276768
  return { start: paragraph.start, end: paragraph.end, nodeId: id };
276275
276769
  }
276276
276770
  var init_tracked_table_move = __esm(() => {
276771
+ init_xml_tokens();
276277
276772
  init_xml_sax();
276278
276773
  init_tracked_block_move();
276279
276774
  init_table_trailing_paragraph();
@@ -276668,6 +277163,7 @@ var init_bibliography_review_resources = __esm(() => {
276668
277163
  init_xml_part_decoder();
276669
277164
  init_xml_text();
276670
277165
  init_xml_sax();
277166
+ init_xml_tokens();
276671
277167
  init_patch_substrate();
276672
277168
  init_bibliography_style();
276673
277169
  TD74 = createXmlPartDecoder();
@@ -277238,6 +277734,7 @@ function createAcceptedInsertionReplacementResolver(input) {
277238
277734
  };
277239
277735
  }
277240
277736
  var init_accepted_insertion_replacement = __esm(() => {
277737
+ init_xml_tokens();
277241
277738
  init_xml_sax();
277242
277739
  init_xml_namespace_scope();
277243
277740
  init_revision_open_tag();
@@ -277316,6 +277813,7 @@ function collectSelectedCompoundMoveWrapperIds(xml, paragraph, selected, paragra
277316
277813
  return covered(root, true) && visited.size === selected.length && ids.size === selected.length ? ids : null;
277317
277814
  }
277318
277815
  var init_compound_move_paragraph = __esm(() => {
277816
+ init_xml_tokens();
277319
277817
  init_xml_sax();
277320
277818
  });
277321
277819
 
@@ -282743,6 +283241,7 @@ var init_compile_tracked_change_decide = __esm(() => {
282743
283241
  init_xml_namespace_scope();
282744
283242
  init_lazy_indexes();
282745
283243
  init_resident_review();
283244
+ init_xml_tokens();
282746
283245
  init_content_types();
282747
283246
  init_xml_sax();
282748
283247
  init_revision_wid_allocator();
@@ -285550,6 +286049,7 @@ function prepareTrackedTablePropertyReplacement(input) {
285550
286049
  }
285551
286050
  var PROPERTY_BLOCKS, TOPOLOGY;
285552
286051
  var init_tracked_table_properties = __esm(() => {
286052
+ init_xml_tokens();
285553
286053
  init_xml_sax();
285554
286054
  init_xml_text();
285555
286055
  init_tracked_change_email();
@@ -285766,6 +286266,7 @@ function prepareTrackedSdtXmlReplacement(input) {
285766
286266
  return xml === null ? null : { xml, wordIds };
285767
286267
  }
285768
286268
  var init_tracked_sdt_replacement = __esm(() => {
286269
+ init_xml_tokens();
285769
286270
  init_xml_sax();
285770
286271
  init_tracked_block_replacement();
285771
286272
  init_tracked_inline_replacement();
@@ -286279,6 +286780,7 @@ function remapReplacementTableParagraphIds(xml, namespaceBindings, nextId) {
286279
286780
  }
286280
286781
  var W147 = "http://schemas.microsoft.com/office/word/2010/wordml", TE46, TD80, UNSAFE;
286281
286782
  var init_compare_table_block_replay = __esm(() => {
286783
+ init_xml_tokens();
286282
286784
  init_xml_sax();
286283
286785
  init_table_catalog();
286284
286786
  TE46 = new TextEncoder;
@@ -293832,6 +294334,7 @@ var init_compile_compare_apply = __esm(() => {
293832
294334
  init_tracked_terminal_paragraph_delete();
293833
294335
  init_patch_substrate();
293834
294336
  init_xml_sax();
294337
+ init_xml_tokens();
293835
294338
  init_tracked_change_email();
293836
294339
  init_content_types();
293837
294340
  init_revision_wid_allocator();
@@ -293986,6 +294489,7 @@ function hasSimpleHyperlinkResultRuns(xml, namespaceBindings) {
293986
294489
  }
293987
294490
  var init_tracked_hyperlink_target = __esm(() => {
293988
294491
  init_tracked_change_email();
294492
+ init_xml_tokens();
293989
294493
  init_xml_sax();
293990
294494
  init_xml_text();
293991
294495
  init_tracked_inline_replacement();
@@ -295445,6 +295949,7 @@ var init_compile_hyperlink_ops = __esm(() => {
295445
295949
  init_tracked_hyperlink_removal();
295446
295950
  init_body_comment_anchors();
295447
295951
  init_xml_namespace_scope();
295952
+ init_xml_tokens();
295448
295953
  init_paragraph_para_id_attrs();
295449
295954
  init_revision_wid_allocator();
295450
295955
  init_session_owned_insertion();
@@ -297379,11 +297884,14 @@ class TxContext {
297379
297884
  const parentReference = parentAnchors.references[0];
297380
297885
  const referenceInsertByte = parentReference ? insertionByteAfterCommentReferenceRun(parentStoryBytes, parentReference) : null;
297381
297886
  if (parentReference && referenceInsertByte != null) {
297887
+ const replyRunScope = wordScopeForInsertedReplyRun(parentStoryBytes, parentReference, referenceInsertByte);
297888
+ if (!replyRunScope)
297889
+ return rejected21(this.txId, "unsupported-context");
297382
297890
  const replyReferencePatch = {
297383
297891
  kind: "insertBytes",
297384
297892
  order: 0,
297385
297893
  atByte: referenceInsertByte,
297386
- bytes: TE49.encode(commentReplyReferenceRun(commentId))
297894
+ bytes: TE49.encode(commentReplyReferenceRun(commentId, replyRunScope))
297387
297895
  };
297388
297896
  perPart[parentStoryInfo.partUri] = {
297389
297897
  kind: "modify",
@@ -297546,10 +298054,10 @@ class TxContext {
297546
298054
  const newEnd = translateAfterRemovals(newRange.byteEnd, mergedRemovals);
297547
298055
  if (newStart == null || newEnd == null)
297548
298056
  return rejected21(this.txId, "comment-move-overlap");
297549
- const rewrite = rewriteDocumentXml(TD_KEEP_BOM.decode(stripped), { ...op.on, startByte: newStart, endByte: newEnd }, markerWId, undefined, {
297550
- start: relocatedAnchors.map((anchor) => commentRangeStart(anchor.markerWId)).join(""),
297551
- end: relocatedAnchors.map((anchor) => commentRangeEnd(anchor.markerWId) + commentReferenceRun(anchor.markerWId, anchor.referenceRunXml)).join("")
297552
- });
298057
+ const rewrite = rewriteDocumentXml(TD_KEEP_BOM.decode(stripped), { ...op.on, startByte: newStart, endByte: newEnd }, markerWId, undefined, (wordPrefix) => ({
298058
+ start: relocatedAnchors.map((anchor) => commentRangeStart(anchor.markerWId, wordPrefix)).join(""),
298059
+ end: relocatedAnchors.map((anchor) => commentRangeEnd(anchor.markerWId, wordPrefix) + commentReferenceRun(anchor.markerWId, wordPrefix, anchor.referenceRunXml)).join("")
298060
+ }));
297553
298061
  if (!rewrite.ok)
297554
298062
  return rejected21(this.txId, rewrite.reason);
297555
298063
  const documentReplacePatch = {
@@ -298574,9 +299082,9 @@ function rewriteDocumentXml(documentXml, range2, commentId, commentReferenceXml,
298574
299082
  }
298575
299083
  function hoistCommentAnchorsOutOfTrackedWrappers(paragraphXml, commentId) {
298576
299084
  const id = commentId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
298577
- const start = `(?:\\s*<(?:[\\w.-]+:)?commentRangeStart\\b[^>]*\\bw:id="${id}"[^>]*/>)`;
298578
- const end = `(?:\\s*<(?:[\\w.-]+:)?commentRangeEnd\\b[^>]*\\bw:id="${id}"[^>]*/>)`;
298579
- const reference = `(?:\\s*<(?:[\\w.-]+:)?r\\b[^>]*>(?:<(?:[\\w.-]+:)?rPr>[\\s\\S]*?</(?:[\\w.-]+:)?rPr>)?<(?:[\\w.-]+:)?commentReference\\b[^>]*\\bw:id="${id}"[^>]*/></(?:[\\w.-]+:)?r>)`;
299085
+ const start = `(?:\\s*<(?:[\\w.-]+:)?commentRangeStart\\b[^>]*\\b[\\w.-]+:id="${id}"[^>]*/>)`;
299086
+ const end = `(?:\\s*<(?:[\\w.-]+:)?commentRangeEnd\\b[^>]*\\b[\\w.-]+:id="${id}"[^>]*/>)`;
299087
+ const reference = `(?:\\s*<(?:[\\w.-]+:)?r\\b[^>]*>(?:<(?:[\\w.-]+:)?rPr>[\\s\\S]*?</(?:[\\w.-]+:)?rPr>)?<(?:[\\w.-]+:)?commentReference\\b[^>]*\\b[\\w.-]+:id="${id}"[^>]*/></(?:[\\w.-]+:)?r>)`;
298580
299088
  const leading = new RegExp(`^(${start}+)`);
298581
299089
  const trailing = new RegExp(`(${end}(?:${reference})?)\\s*$`);
298582
299090
  const wrapper = /<((?:[\w.-]+:)?(?:ins|del))\b([^>]*)>([\s\S]*?)<\/\1>/g;
@@ -298766,15 +299274,23 @@ function collectParagraphs(documentXml) {
298766
299274
  return out;
298767
299275
  }
298768
299276
  function rewriteParagraphXml(paragraphXml, options) {
299277
+ const wordPrefix = leadingElementPrefix(paragraphXml);
299278
+ const boundNamespace = wordPrefix ? options.namespaceBindings?.[wordPrefix] : undefined;
299279
+ if (!wordPrefix || boundNamespace !== undefined && !isWordprocessingNamespace(boundNamespace)) {
299280
+ return { ok: false, reason: "unsupported-context" };
299281
+ }
299282
+ const anchorXml = options.commentAnchorXml?.(wordPrefix) ?? {
299283
+ start: commentRangeStart(options.commentId, wordPrefix),
299284
+ end: commentRangeEnd(options.commentId, wordPrefix) + commentReferenceRun(options.commentId, wordPrefix, options.commentReferenceXml)
299285
+ };
298769
299286
  if (options.startOffset != null && options.startOffset === options.endOffset) {
298770
299287
  const point = findCommentDeletionPoint(parseParagraphInlineMap(paragraphXml, options.namespaceBindings), options.coordinateSpace, options.startOffset);
298771
299288
  if (point) {
298772
299289
  const offset = point.boundary === "before" ? point.piece.charStart : point.piece.charEnd;
298773
- const markers = (options.commentAnchorXml?.start ?? commentRangeStart(options.commentId)) + (options.commentAnchorXml?.end ?? commentRangeEnd(options.commentId) + commentReferenceRun(options.commentId, options.commentReferenceXml));
298774
- return { ok: true, xml: paragraphXml.slice(0, offset) + markers + paragraphXml.slice(offset) };
299290
+ return { ok: true, xml: paragraphXml.slice(0, offset) + anchorXml.start + anchorXml.end + paragraphXml.slice(offset) };
298775
299291
  }
298776
299292
  }
298777
- const wholeParagraph = rewriteWholeParagraphCommentAnchor(paragraphXml, options);
299293
+ const wholeParagraph = rewriteWholeParagraphCommentAnchor(paragraphXml, options, anchorXml);
298778
299294
  if (wholeParagraph)
298779
299295
  return { ok: true, xml: wholeParagraph };
298780
299296
  const { runs, paragraph, ranges: ranges2 } = paragraphRuns(paragraphXml, options.namespaceBindings);
@@ -298808,11 +299324,11 @@ function rewriteParagraphXml(paragraphXml, options) {
298808
299324
  const emitMarkers = (position) => {
298809
299325
  const allowStart = position !== "run-end" || options.coordinateSpace !== "tracked";
298810
299326
  if (allowStart && !insertedStart && options.startOffset === cursor) {
298811
- out += options.commentAnchorXml?.start ?? commentRangeStart(options.commentId);
299327
+ out += anchorXml.start;
298812
299328
  insertedStart = true;
298813
299329
  }
298814
299330
  if (!insertedEnd && options.endOffset === cursor && (options.startOffset !== options.endOffset || insertedStart)) {
298815
- out += options.commentAnchorXml?.end ?? commentRangeEnd(options.commentId) + commentReferenceRun(options.commentId, options.commentReferenceXml);
299331
+ out += anchorXml.end;
298816
299332
  insertedEnd = true;
298817
299333
  }
298818
299334
  };
@@ -298912,7 +299428,7 @@ function rewriteParagraphXml(paragraphXml, options) {
298912
299428
  cursor = textStart + local;
298913
299429
  emitMarkers("in-run");
298914
299430
  const next = nextMarkerOffsetWithinText(segment.text.length, local, textStart, options);
298915
- out += textRun(segment.text.slice(local, next), rPr, runOpen, runClose, segment.textLocalName);
299431
+ out += textRun(segment.text.slice(local, next), rPr, runOpen, runClose, segment.leaf);
298916
299432
  local = next;
298917
299433
  }
298918
299434
  cursor = textStart + segment.text.length;
@@ -298928,7 +299444,7 @@ function rewriteParagraphXml(paragraphXml, options) {
298928
299444
  return { ok: false, reason: "invalid-range" };
298929
299445
  return { ok: true, xml: out + paragraphXml.slice(xmlCursor) };
298930
299446
  }
298931
- function rewriteWholeParagraphCommentAnchor(paragraphXml, options) {
299447
+ function rewriteWholeParagraphCommentAnchor(paragraphXml, options, anchorXml) {
298932
299448
  if (options.startOffset !== 0 || options.endOffset == null)
298933
299449
  return null;
298934
299450
  const map3 = parseParagraphInlineMap(paragraphXml);
@@ -298940,14 +299456,14 @@ function rewriteWholeParagraphCommentAnchor(paragraphXml, options) {
298940
299456
  return null;
298941
299457
  }
298942
299458
  if (paragraph.selfClosing) {
298943
- return paragraphXml.slice(0, paragraph.openEnd).replace(/\/>$/, ">") + (options.commentAnchorXml?.start ?? commentRangeStart(options.commentId)) + (options.commentAnchorXml?.end ?? commentRangeEnd(options.commentId) + commentReferenceRun(options.commentId, options.commentReferenceXml)) + `</${paragraph.qname}>`;
299459
+ return paragraphXml.slice(0, paragraph.openEnd).replace(/\/>$/, ">") + anchorXml.start + anchorXml.end + `</${paragraph.qname}>`;
298944
299460
  }
298945
299461
  const leadingContent = paragraphXml.slice(paragraph.openEnd, paragraph.closeStart);
298946
299462
  const leadingWhitespaceLength = leadingContent.length - leadingContent.trimStart().length;
298947
299463
  const leadingProperties = matchLeadingElement(leadingContent.slice(leadingWhitespaceLength), "pPr");
298948
299464
  const contentStart = paragraph.openEnd + leadingWhitespaceLength + leadingProperties.length;
298949
299465
  const contentEnd = paragraph.closeStart;
298950
- return paragraphXml.slice(0, contentStart) + (options.commentAnchorXml?.start ?? commentRangeStart(options.commentId)) + paragraphXml.slice(contentStart, contentEnd) + (options.commentAnchorXml?.end ?? commentRangeEnd(options.commentId) + commentReferenceRun(options.commentId, options.commentReferenceXml)) + paragraphXml.slice(contentEnd);
299466
+ return paragraphXml.slice(0, contentStart) + anchorXml.start + paragraphXml.slice(contentStart, contentEnd) + anchorXml.end + paragraphXml.slice(contentEnd);
298951
299467
  }
298952
299468
  function nextMarkerOffsetWithinText(textLength, localOffset, absoluteCursor, options) {
298953
299469
  let next = textLength;
@@ -299059,6 +299575,14 @@ function decodeTextContent(content) {
299059
299575
  }
299060
299576
  return text;
299061
299577
  }
299578
+ function runTextLeaf(child) {
299579
+ const namespaceDeclarations3 = Object.entries(child.tag.namespaceBindings).map(([prefix2, uri]) => ` ${prefix2 ? `xmlns:${prefix2}` : "xmlns"}="${escapeXmlAttribute(uri)}"`).join("");
299580
+ return {
299581
+ prefix: child.tag.prefix,
299582
+ localName: child.tag.localName === "delText" ? "delText" : "t",
299583
+ namespaceDeclarations: namespaceDeclarations3
299584
+ };
299585
+ }
299062
299586
  function runSegments(paragraphXml, run, paragraph, coordinateSpace) {
299063
299587
  const segments = [];
299064
299588
  let cursor = run.range.openEnd;
@@ -299072,7 +299596,7 @@ function runSegments(paragraphXml, run, paragraph, coordinateSpace) {
299072
299596
  const text = child.tag.isSelfClosing ? "" : decodeTextContent(paragraphXml.slice(child.openEnd, child.closeStart));
299073
299597
  if (text === null)
299074
299598
  return null;
299075
- segments.push({ kind: "text", text, textLocalName: child.tag.localName === "delText" ? "delText" : "t" });
299599
+ segments.push({ kind: "text", text, leaf: runTextLeaf(child) });
299076
299600
  continue;
299077
299601
  }
299078
299602
  if (!RUN_CONTROL_LEAVES.some((name) => isWordElement5(child, name)))
@@ -299278,24 +299802,37 @@ function randomDurableId() {
299278
299802
  }
299279
299803
  return out;
299280
299804
  }
299281
- function textRun(text, rPr, runOpen = "<w:r>", runClose = "</w:r>", textLocalName = "t") {
299805
+ function textRun(text, rPr, runOpen, runClose, textLeaf) {
299282
299806
  const preserve = needsXmlSpacePreserve(text) ? ' xml:space="preserve"' : "";
299283
- return `${runOpen}${rPr}<w:${textLocalName}${preserve}>${escapeXmlText(text)}</w:${textLocalName}>${runClose}`;
299807
+ const qname = textLeaf.prefix ? `${textLeaf.prefix}:${textLeaf.localName}` : textLeaf.localName;
299808
+ return `${runOpen}${rPr}<${qname}${textLeaf.namespaceDeclarations}${preserve}>${escapeXmlText(text)}</${qname}>${runClose}`;
299809
+ }
299810
+ function leadingElementPrefix(xml) {
299811
+ return /^<([\w.-]+):/.exec(xml)?.[1] ?? null;
299284
299812
  }
299285
- function commentRangeStart(id) {
299286
- return `<w:commentRangeStart w:id="${id}"/>`;
299813
+ function commentRangeStart(id, wordPrefix) {
299814
+ return `<${wordPrefix}:commentRangeStart ${wordPrefix}:id="${id}"/>`;
299287
299815
  }
299288
- function commentRangeEnd(id) {
299289
- return `<w:commentRangeEnd w:id="${id}"/>`;
299816
+ function commentRangeEnd(id, wordPrefix) {
299817
+ return `<${wordPrefix}:commentRangeEnd ${wordPrefix}:id="${id}"/>`;
299290
299818
  }
299291
- function commentReferenceRun(id, existingXml) {
299819
+ function commentReferenceRun(id, wordPrefix, existingXml) {
299292
299820
  if (existingXml && /^<[\w.-]+:r(?:\s|>)/.test(existingXml) && /<\/[\w.-]+:r>\s*$/.test(existingXml)) {
299293
299821
  return existingXml;
299294
299822
  }
299295
- return `<w:r><w:commentReference w:id="${id}"/></w:r>`;
299823
+ return `<${wordPrefix}:r><${wordPrefix}:commentReference ${wordPrefix}:id="${id}"/></${wordPrefix}:r>`;
299296
299824
  }
299297
- function commentReplyReferenceRun(id) {
299298
- return `<w:r><w:rPr><w:rStyle w:val="CommentReference"/></w:rPr><w:commentReference w:id="${id}"/></w:r>`;
299825
+ function commentReplyReferenceRun(id, scope) {
299826
+ const w = scope.prefix;
299827
+ return `<${w}:r${scope.declaration}><${w}:rPr><${w}:rStyle ${w}:val="CommentReference"/></${w}:rPr><${w}:commentReference ${w}:id="${id}"/></${w}:r>`;
299828
+ }
299829
+ function wordScopeForInsertedReplyRun(storyBytes, reference, insertByte) {
299830
+ const referenceXml = TD83.decode(storyBytes.subarray(reference.byteStart, reference.byteEnd));
299831
+ return wordElementScopeAt(storyBytes, insertByte, {
299832
+ prefix: leadingElementPrefix(referenceXml),
299833
+ byteOffset: reference.byteStart,
299834
+ openTag: /^<[^>]*>/.exec(referenceXml)?.[0] ?? ""
299835
+ });
299299
299836
  }
299300
299837
  function insertionByteAfterCommentReferenceRun(storyBytes, reference) {
299301
299838
  const referenceXml = TD83.decode(storyBytes.subarray(reference.byteStart, reference.byteEnd));
@@ -299576,6 +300113,8 @@ var init_tx_context = __esm(() => {
299576
300113
  init_sd_document_state();
299577
300114
  init_text_offset_mapping();
299578
300115
  init_paragraph_index();
300116
+ init_xml_tokens();
300117
+ init_word_element_scope();
299579
300118
  init_wml_paragraph_spans();
299580
300119
  init_body_boundary_scan();
299581
300120
  init_xml_sax();
@@ -299971,6 +300510,14 @@ var init_list_numbering = __esm(() => {
299971
300510
  });
299972
300511
 
299973
300512
  // ../../../v2/editor-core/dist/document/list-summary.js
300513
+ function matchTypedAutoListPrefix(prefix2, insertedText) {
300514
+ const candidate2 = `${prefix2}${insertedText}`;
300515
+ if (AUTO_LIST_ORDERED_PREFIX_RE.test(candidate2))
300516
+ return "ordered";
300517
+ if (AUTO_LIST_BULLET_PREFIX_RE.test(candidate2))
300518
+ return "bullet";
300519
+ return null;
300520
+ }
299974
300521
  function readListSummary(state, options) {
299975
300522
  const storyId = options?.storyId ?? state.mainStoryId;
299976
300523
  if (!storyId) {
@@ -300261,7 +300808,7 @@ function extractParagraphText(paraXml) {
300261
300808
  }
300262
300809
  return out;
300263
300810
  }
300264
- var TD84, LIST_SUMMARY_CACHE, PAGE_LIST_FORMATS, LARGEST_PAGE_ROMAN = 3999;
300811
+ var TD84, AUTO_LIST_BULLET_PREFIX_RE, AUTO_LIST_ORDERED_PREFIX_RE, LIST_SUMMARY_CACHE, PAGE_LIST_FORMATS, LARGEST_PAGE_ROMAN = 3999;
300265
300812
  var init_list_summary = __esm(() => {
300266
300813
  init_list_numbering();
300267
300814
  init_xml_part_decoder();
@@ -300273,6 +300820,8 @@ var init_list_summary = __esm(() => {
300273
300820
  init_effective_list_reference();
300274
300821
  init_part_payload();
300275
300822
  TD84 = createXmlPartDecoder();
300823
+ AUTO_LIST_BULLET_PREFIX_RE = /^\s*([-+*])\s$/;
300824
+ AUTO_LIST_ORDERED_PREFIX_RE = /^\d+\.\s$/;
300276
300825
  LIST_SUMMARY_CACHE = Symbol.for("sd.v2.listSummaryCache");
300277
300826
  PAGE_LIST_FORMATS = new Set(["decimal", "decimalZero", "upperRoman", "lowerRoman", "bullet"]);
300278
300827
  });
@@ -300303,6 +300852,8 @@ function* buildReviewProjectionOverlaySteps(input) {
300303
300852
  partUri: fact.partUri,
300304
300853
  sourceStart: fact.byteStart,
300305
300854
  sourceEnd: fact.byteEnd,
300855
+ sourceByteStart: fact.sourceByteStart,
300856
+ sourceByteEnd: fact.sourceByteEnd,
300306
300857
  reason: fact.reason
300307
300858
  });
300308
300859
  yield;
@@ -301127,6 +301678,7 @@ var init_bookmark_catalog = __esm(() => {
301127
301678
  init_part_wml_scan_cache();
301128
301679
  init_part_wml_bookmark_start_cache();
301129
301680
  init_wml_paragraph_spans();
301681
+ init_xml_tokens();
301130
301682
  init_xml_sax();
301131
301683
  init_patch_substrate();
301132
301684
  init_paragraph_inline_model();
@@ -303349,6 +303901,7 @@ var TD86, TOLERANT_NAMESPACES, CHANGE_CONTAINERS;
303349
303901
  var init_style_usage_signals = __esm(() => {
303350
303902
  init_xml_part_decoder();
303351
303903
  init_xml_sax();
303904
+ init_xml_tokens();
303352
303905
  init_diagnostics();
303353
303906
  TD86 = createXmlPartDecoder({ fatal: false });
303354
303907
  TOLERANT_NAMESPACES = {
@@ -303915,40 +304468,68 @@ function ensureLiveCommentStoryReferences(state, catalog, existingOverrides) {
303915
304468
  const unresolved = [];
303916
304469
  if (xmlByPart.size === 0)
303917
304470
  return { xmlByPart, unresolved };
303918
- const anchorIds = collectStoryAnchorIds(xmlByPart);
304471
+ const views = new StoryCommentViews;
304472
+ const anchorIds = collectStoryAnchorIds(xmlByPart, views);
303919
304473
  for (const root of allThreadRoots(catalog)) {
303920
304474
  const threadEntries = threadEntriesForRoot(catalog, root);
303921
- const missing = threadEntries.filter((entry) => !storyHasCommentReference(xmlByPart, entry.commentId));
304475
+ const missing = threadEntries.filter((entry) => !storyHasCommentReference(xmlByPart, views, entry.commentId));
303922
304476
  if (missing.length === 0)
303923
304477
  continue;
303924
304478
  const threadAnchored = threadEntries.some((entry) => anchorIds.has(entry.commentId) || entry.sourceWId !== "" && anchorIds.has(entry.sourceWId));
303925
304479
  if (!threadAnchored)
303926
304480
  continue;
303927
- const anchorRef = findStoryReferenceForEntry(xmlByPart, root) ?? firstThreadStoryReference(xmlByPart, threadEntries);
304481
+ const anchorRef = findStoryReferenceForEntry(xmlByPart, views, root) ?? firstThreadStoryReference(xmlByPart, views, threadEntries);
303928
304482
  if (!anchorRef) {
303929
304483
  for (const entry of missing) {
303930
304484
  unresolved.push({ commentId: entry.commentId, sourceWId: entry.sourceWId, anchored: true });
303931
304485
  }
303932
304486
  continue;
303933
304487
  }
303934
- const insertXml = missing.map((entry) => renderCommentReferenceRun(entry.commentId, anchorRef.prefix)).join("");
304488
+ const insertXml = missing.map((entry) => renderCommentReferenceRun(entry.commentId, anchorRef)).join("");
303935
304489
  xmlByPart.set(anchorRef.partUri, anchorRef.xml.slice(0, anchorRef.insertAt) + insertXml + anchorRef.xml.slice(anchorRef.insertAt));
303936
304490
  }
303937
304491
  return { xmlByPart, unresolved };
303938
304492
  }
303939
- function collectStoryAnchorIds(xmlByPart) {
304493
+
304494
+ class StoryCommentViews {
304495
+ constructor() {
304496
+ this.currentByPart = new Map;
304497
+ }
304498
+ of(partUri, xml) {
304499
+ const current = this.currentByPart.get(partUri);
304500
+ if (current?.xml === xml)
304501
+ return current.view;
304502
+ const view = buildStoryCommentView(xml);
304503
+ this.currentByPart.set(partUri, { xml, view });
304504
+ return view;
304505
+ }
304506
+ }
304507
+ function wordIdOf(range2) {
304508
+ return range2.tag.attributes.find((attribute3) => attribute3.localName === "id" && isWordprocessingNamespace(attribute3.namespaceUri))?.value;
304509
+ }
304510
+ function isElement(range2, localName2, accepts) {
304511
+ return range2.tag.localName === localName2 && accepts(range2.tag.namespaceUri);
304512
+ }
304513
+ function buildStoryCommentView(xml) {
304514
+ const { ranges: ranges2, errors: errors4 } = collectXmlElementRanges(xml);
304515
+ if (errors4.length > 0) {
304516
+ const idsOf2 = (localName2) => new Set([...xml.matchAll(new RegExp(String.raw`<${COMMENT_MARKER_ELEMENT_PREFIX}:${localName2}\b[^>]*\b${COMMENT_MARKER_ID_ATTRIBUTE}="([^"]+)"`, "g"))].map((match) => match[2] ?? ""));
304517
+ return { ranges: null, rangeStartIds: idsOf2("commentRangeStart"), referenceIds: idsOf2("commentReference") };
304518
+ }
304519
+ const idsOf = (localName2) => new Set(ranges2.filter((range2) => isElement(range2, localName2, isWordprocessingNamespace)).flatMap((range2) => wordIdOf(range2) ?? []));
304520
+ return { ranges: ranges2, rangeStartIds: idsOf("commentRangeStart"), referenceIds: idsOf("commentReference") };
304521
+ }
304522
+ function collectStoryAnchorIds(xmlByPart, views) {
303940
304523
  const out = new Set;
303941
- for (const xml of xmlByPart.values()) {
303942
- const re = /<[\w.-]+:commentRangeStart\b[^>]*\bw:id="([^"]+)"/g;
303943
- for (let match = re.exec(xml);match; match = re.exec(xml)) {
303944
- out.add(match[1] ?? "");
303945
- }
304524
+ for (const [partUri, xml] of xmlByPart) {
304525
+ for (const id of views.of(partUri, xml).rangeStartIds)
304526
+ out.add(id);
303946
304527
  }
303947
304528
  return out;
303948
304529
  }
303949
- function firstThreadStoryReference(xmlByPart, entries2) {
304530
+ function firstThreadStoryReference(xmlByPart, views, entries2) {
303950
304531
  for (const entry of entries2) {
303951
- const ref3 = findStoryReferenceForEntry(xmlByPart, entry);
304532
+ const ref3 = findStoryReferenceForEntry(xmlByPart, views, entry);
303952
304533
  if (ref3)
303953
304534
  return ref3;
303954
304535
  }
@@ -304025,44 +304606,45 @@ function threadRootEntry(catalog, entry) {
304025
304606
  }
304026
304607
  return entry;
304027
304608
  }
304028
- function storyHasCommentReference(xmlByPart, commentId) {
304029
- const re = new RegExp(`<[\\w.-]+:commentReference\\b[^>]*\\bw:id="${escapeRegex10(commentId)}"`);
304030
- for (const xml of xmlByPart.values()) {
304031
- if (re.test(xml))
304609
+ function storyHasCommentReference(xmlByPart, views, commentId) {
304610
+ for (const [partUri, xml] of xmlByPart) {
304611
+ if (views.of(partUri, xml).referenceIds.has(commentId))
304032
304612
  return true;
304033
304613
  }
304034
304614
  return false;
304035
304615
  }
304036
- function findStoryReferenceForEntry(xmlByPart, entry) {
304616
+ function findStoryReferenceForEntry(xmlByPart, views, entry) {
304037
304617
  const candidateIds = [entry.commentId, entry.sourceWId].filter(Boolean);
304038
304618
  for (const id of candidateIds) {
304039
- const re = new RegExp(`<([\\w.-]+):commentReference\\b[^>]*\\bw:id="${escapeRegex10(id)}"[^>]*/>`);
304040
304619
  for (const [partUri, xml] of xmlByPart) {
304041
- const match = re.exec(xml);
304042
- if (match) {
304043
- const prefix2 = match[1] ?? "w";
304044
- return {
304045
- partUri,
304046
- xml,
304047
- insertAt: insertionPointAfterEnclosingRun(xml, match.index, match[0].length, prefix2),
304048
- prefix: prefix2
304049
- };
304050
- }
304620
+ const view = views.of(partUri, xml);
304621
+ if (!view.ranges || !view.referenceIds.has(id))
304622
+ continue;
304623
+ const site = referenceInsertionSite(view.ranges, id);
304624
+ if (site)
304625
+ return { partUri, xml, ...site };
304051
304626
  }
304052
304627
  }
304053
304628
  return null;
304054
304629
  }
304055
- function insertionPointAfterEnclosingRun(xml, referenceStart, referenceLength, prefix2) {
304056
- const closeTag = `</${prefix2}:r>`;
304057
- const openBefore = xml.lastIndexOf(`<${prefix2}:r`, referenceStart);
304058
- const closeBefore = xml.lastIndexOf(closeTag, referenceStart);
304059
- const closeAfter2 = xml.indexOf(closeTag, referenceStart + referenceLength);
304060
- if (openBefore > closeBefore && closeAfter2 >= 0)
304061
- return closeAfter2 + closeTag.length;
304062
- return referenceStart + referenceLength;
304063
- }
304064
- function renderCommentReferenceRun(commentId, prefix2) {
304065
- return `<${prefix2}:r><${prefix2}:rPr><${prefix2}:rStyle ${prefix2}:val="CommentReference"/></${prefix2}:rPr>` + `<${prefix2}:commentReference ${prefix2}:id="${escapeXmlAttribute(commentId)}"/></${prefix2}:r>`;
304630
+ function referenceInsertionSite(ranges2, commentId) {
304631
+ const reference = ranges2.find((range2) => isElement(range2, "commentReference", isWordprocessingNamespace) && wordIdOf(range2) === commentId);
304632
+ if (!reference)
304633
+ return null;
304634
+ const innermostContainer = (inner, accept) => ranges2.reduce((best, range2) => range2 !== inner && range2.start < inner.start && inner.end <= range2.end && accept(range2) && (!best || range2.start > best.start) ? range2 : best, null);
304635
+ const isMathNamespace = (namespaceUri) => namespaceUri === NS_MATH;
304636
+ const anchor = innermostContainer(reference, (range2) => isElement(range2, "r", isWordprocessingNamespace) || isElement(range2, "r", isMathNamespace)) ?? reference;
304637
+ const parentBindings = innermostContainer(anchor, () => true)?.namespaceBindings ?? {};
304638
+ const runScope = elementScopeForNamespace(parentBindings, anchor.tag.prefix || null, anchor.tag.namespaceUri, new Set);
304639
+ const childBindings = runScope.declaration ? { ...parentBindings, [runScope.prefix]: anchor.tag.namespaceUri } : parentBindings;
304640
+ const wordScope = elementScopeForNamespace(childBindings, reference.tag.prefix || null, reference.tag.namespaceUri, new Set([runScope.prefix]));
304641
+ return { insertAt: anchor.end, runScope, wordScope };
304642
+ }
304643
+ function renderCommentReferenceRun(commentId, site) {
304644
+ const r = site.runScope.prefix;
304645
+ const w = site.wordScope.prefix;
304646
+ const declarations = [...new Set([site.runScope.declaration, site.wordScope.declaration])].join("");
304647
+ return `<${r}:r${declarations}><${w}:rPr><${w}:rStyle ${w}:val="CommentReference"/></${w}:rPr>` + `<${w}:commentReference ${w}:id="${escapeXmlAttribute(commentId)}"/></${r}:r>`;
304066
304648
  }
304067
304649
  function ensureCommentsExtendedRelationship(xml) {
304068
304650
  if (xml.includes("http://schemas.microsoft.com/office/2011/relationships/commentsExtended"))
@@ -304177,7 +304759,7 @@ function replaceNthStoryMarkerAcrossParts(xmlByPart, marker, target) {
304177
304759
  }
304178
304760
  }
304179
304761
  function replaceNthStoryMarkerInPart(storyXml, marker, target, startingOccurrenceIndex) {
304180
- const re = target.sourceWId === "" ? new RegExp(`<([\\w.-]+):${marker}\\b([^>]*?\\bw:id=")("[^>]*)/>`, "g") : new RegExp(`<([\\w.-]+):${marker}\\b([^>]*?\\bw:id=")${escapeRegex10(target.sourceWId)}("[^>]*)/>`, "g");
304762
+ const re = target.sourceWId === "" ? new RegExp(String.raw`<${COMMENT_MARKER_ELEMENT_PREFIX}:${marker}\b([^>]*?\b${COMMENT_MARKER_ID_ATTRIBUTE}=")("[^>]*)/>`, "g") : new RegExp(String.raw`<${COMMENT_MARKER_ELEMENT_PREFIX}:${marker}\b([^>]*?\b${COMMENT_MARKER_ID_ATTRIBUTE}=")${escapeRegex10(target.sourceWId)}("[^>]*)/>`, "g");
304181
304763
  let remaining = startingOccurrenceIndex;
304182
304764
  let replaced = false;
304183
304765
  const xml = storyXml.replace(re, (match, prefix2, head, tail) => {
@@ -304221,7 +304803,7 @@ function compareStoryPartUris(a, b) {
304221
304803
  function escapeRegex10(value) {
304222
304804
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
304223
304805
  }
304224
- var TD87, TE51, CommentExportStoryReferenceError;
304806
+ var TD87, TE51, CommentExportStoryReferenceError, NS_MATH = "http://schemas.openxmlformats.org/officeDocument/2006/math";
304225
304807
  var init_comment_export_normalization = __esm(() => {
304226
304808
  init_xml_part_decoder();
304227
304809
  init_comments_catalog();
@@ -304230,6 +304812,8 @@ var init_comment_export_normalization = __esm(() => {
304230
304812
  init_compile_comment_helpers();
304231
304813
  init_docx_export_policies();
304232
304814
  init_xml_text();
304815
+ init_word_element_scope();
304816
+ init_xml_tokens();
304233
304817
  init_xml_sax();
304234
304818
  init_comment_metadata_sidecar();
304235
304819
  TD87 = createXmlPartDecoder();
@@ -311284,6 +311868,7 @@ var init_sd_document_session = __esm(() => {
311284
311868
  init_revision_wid_scan();
311285
311869
  init_document_background();
311286
311870
  init_xml_sax();
311871
+ init_xml_tokens();
311287
311872
  init_revision_wid_allocator();
311288
311873
  init_text_offset_mapping();
311289
311874
  init_transactions();
@@ -311882,6 +312467,7 @@ function prepareTrackedBookmarkRename(input) {
311882
312467
  return { xml, bookmarkId: String(nextId2), wordIds };
311883
312468
  }
311884
312469
  var init_tracked_bookmark_rename = __esm(() => {
312470
+ init_xml_tokens();
311885
312471
  init_xml_sax();
311886
312472
  init_xml_text();
311887
312473
  init_tracked_inline_replacement();
@@ -311991,6 +312577,7 @@ function prepareTrackedTocInsertion(input) {
311991
312577
  return { xml: result + input.xml.slice(cursor), wordIds };
311992
312578
  }
311993
312579
  var init_tracked_toc_insertion = __esm(() => {
312580
+ init_xml_tokens();
311994
312581
  init_xml_sax();
311995
312582
  init_paragraph_contribution();
311996
312583
  init_tracked_inline_replacement();
@@ -312047,6 +312634,7 @@ function prepareTrackedFieldMarkerRun(input) {
312047
312634
  };
312048
312635
  }
312049
312636
  var init_tracked_field_marker = __esm(() => {
312637
+ init_xml_tokens();
312050
312638
  init_xml_sax();
312051
312639
  init_paragraph_property_namespaces();
312052
312640
  init_tracked_paragraph_properties();
@@ -312376,6 +312964,7 @@ function hasCompleteField(xml, namespaceBindings) {
312376
312964
  return depth === 0;
312377
312965
  }
312378
312966
  var init_tracked_toc_replacement = __esm(() => {
312967
+ init_xml_tokens();
312379
312968
  init_xml_sax();
312380
312969
  init_tracked_inline_replacement();
312381
312970
  init_tracked_paragraph_properties();
@@ -312477,6 +313066,7 @@ function prepareTrackedInsertedParagraphContent(input) {
312477
313066
  return { xml, wordIds: [...ids.values()] };
312478
313067
  }
312479
313068
  var init_tracked_inserted_paragraph_content = __esm(() => {
313069
+ init_xml_tokens();
312480
313070
  init_xml_sax();
312481
313071
  init_paragraph_inline_model();
312482
313072
  init_overlap_edit_compiler();
@@ -312586,6 +313176,7 @@ var init_sd_document_session_internal = __esm(() => {
312586
313176
  init_relationships();
312587
313177
  init_clone_relationships();
312588
313178
  init_xml_sax();
313179
+ init_xml_tokens();
312589
313180
  init_xml_namespace_scope();
312590
313181
  init_sd_document_session();
312591
313182
  init_compile_list_ops();
@@ -352210,15 +352801,15 @@ function parseAbstract(node3, inheritedBindings) {
352210
352801
  }
352211
352802
  function normalizeOverrideNamespace(node3, inheritedBindings) {
352212
352803
  const bindings2 = extendNamespaceBindings3(inheritedBindings, node3);
352213
- const normalizeName2 = (name, isElement = false) => {
352804
+ const normalizeName2 = (name, isElement2 = false) => {
352214
352805
  const separator = name.indexOf(":");
352215
352806
  if (separator < 1)
352216
- return isElement && WORD_NAMESPACES2.includes(bindings2.get("") ?? "") ? `w:${name}` : name;
352807
+ return isElement2 && WORD_NAMESPACES2.includes(bindings2.get("") ?? "") ? `w:${name}` : name;
352217
352808
  const prefix2 = name.slice(0, separator);
352218
352809
  const localName2 = name.slice(separator + 1);
352219
352810
  if (WORD_NAMESPACES2.includes(bindings2.get(prefix2) ?? ""))
352220
352811
  return `w:${localName2}`;
352221
- if (isElement && bindings2.get(prefix2) === MCE_NAMESPACE2 && (localName2 === "AlternateContent" || localName2 === "Choice" || localName2 === "Fallback"))
352812
+ if (isElement2 && bindings2.get(prefix2) === MCE_NAMESPACE2 && (localName2 === "AlternateContent" || localName2 === "Choice" || localName2 === "Fallback"))
352222
352813
  return name;
352223
352814
  return prefix2 === "w" ? `nonWord_${localName2}` : name;
352224
352815
  };
@@ -367918,9 +368509,9 @@ function insertParagraphIndentation(paragraphXml, context, attributes) {
367918
368509
  while (insertionBindings[prefix2])
367919
368510
  prefix2 += "w";
367920
368511
  }
367921
- const declaration = ` xmlns:${prefix2}="${WORD_NAMESPACE12}"`;
368512
+ const declaration = insertionBindings[prefix2] === WORD_NAMESPACE12 ? "" : ` xmlns:${prefix2}="${WORD_NAMESPACE12}"`;
367922
368513
  const attrs = attributes.map(([attr6, value2]) => `${prefix2}:${attr6}="${value2}"`).join(" ");
367923
- const xml = `<${prefix2}:ind${declaration} ${attrs}/>`;
368514
+ const xml = `<${prefix2}:ind ${attrs}/>`;
367924
368515
  if (!properties3) {
367925
368516
  const pPr = `<${prefix2}:pPr${declaration}>${xml}</${prefix2}:pPr>`;
367926
368517
  return replaceRangeContainerInner(paragraphXml, paragraph2, pPr + paragraphXml.slice(paragraph2.openEnd, paragraph2.closeStart));
@@ -367940,7 +368531,7 @@ function insertParagraphIndentation(paragraphXml, context, attributes) {
367940
368531
  children3.push({ name: "", localName: "", prefix: "", xml: paragraphXml.slice(cursor, properties3.closeStart) });
367941
368532
  const qualifiedProperties = properties3.tag.prefix ? undefined : {
367942
368533
  name: `${prefix2}:pPr`,
367943
- declaration: insertionBindings[prefix2] === WORD_NAMESPACE12 ? "" : declaration
368534
+ declaration
367944
368535
  };
367945
368536
  return replaceRangeContainerInner(paragraphXml, properties3, serializeTopLevelChildren(setParagraphPropertyChild(children3, "ind", xml)), qualifiedProperties);
367946
368537
  }
@@ -379860,7 +380451,7 @@ function sourceRangeForParseError(error48) {
379860
380451
  }
379861
380452
 
379862
380453
  // ../../../v2/document-api-v2-adapter/dist/conversion/html/tree.js
379863
- function isElement(node3) {
380454
+ function isElement2(node3) {
379864
380455
  return "tagName" in node3;
379865
380456
  }
379866
380457
  function isText(node3) {
@@ -379878,7 +380469,7 @@ function textContent(parent) {
379878
380469
  for (const child of parent.childNodes) {
379879
380470
  if (isText(child))
379880
380471
  output += child.value;
379881
- else if (isElement(child))
380472
+ else if (isElement2(child))
379882
380473
  output += textContent(child);
379883
380474
  }
379884
380475
  return output;
@@ -379906,7 +380497,7 @@ function collectHtmlClassStyleSheet(root, maxRules = Number.MAX_SAFE_INTEGER) {
379906
380497
  };
379907
380498
  const visit = (parent) => {
379908
380499
  for (const child of parent.childNodes) {
379909
- if (!isElement(child))
380500
+ if (!isElement2(child))
379910
380501
  continue;
379911
380502
  if (child.tagName === "style") {
379912
380503
  const range2 = sourceRangeForNode(child);
@@ -379950,7 +380541,7 @@ function exceedsHtmlStyleRuleApplicationLimit(root, sheet, maxApplications) {
379950
380541
  let applications = 0;
379951
380542
  const visit = (parent) => {
379952
380543
  for (const child of parent.childNodes) {
379953
- if (!isElement(child))
380544
+ if (!isElement2(child))
379954
380545
  continue;
379955
380546
  for (const rule of matchingRules(child, sheet)) {
379956
380547
  applications += rule.declarations.length;
@@ -380836,7 +381427,7 @@ function collectWordListStyles(root) {
380836
381427
  const styles = new Map;
380837
381428
  const visit = (parent) => {
380838
381429
  for (const child of parent.childNodes) {
380839
- if (!isElement(child))
381430
+ if (!isElement2(child))
380840
381431
  continue;
380841
381432
  if (child.tagName !== "style") {
380842
381433
  visit(child);
@@ -380883,14 +381474,14 @@ function describeWordListParagraph(element, listStyles = new Map) {
380883
381474
  };
380884
381475
  }
380885
381476
  function isWordListMarkerNode(node3) {
380886
- if (!isElement(node3))
381477
+ if (!isElement2(node3))
380887
381478
  return false;
380888
381479
  return /(?:^|;)\s*mso-list\s*:\s*ignore(?:;|$)/i.test(attributeValue3(node3, "style") ?? "");
380889
381480
  }
380890
381481
  function isWordListMarkerContainer(node3) {
380891
381482
  if (isWordListMarkerNode(node3))
380892
381483
  return true;
380893
- if (!isElement(node3) || node3.tagName !== "span")
381484
+ if (!isElement2(node3) || node3.tagName !== "span")
380894
381485
  return false;
380895
381486
  let containsMarker = false;
380896
381487
  for (const child of node3.childNodes) {
@@ -380899,7 +381490,7 @@ function isWordListMarkerContainer(node3) {
380899
381490
  return false;
380900
381491
  continue;
380901
381492
  }
380902
- if (isElement(child) && isWordListMarkerContainer(child)) {
381493
+ if (isElement2(child) && isWordListMarkerContainer(child)) {
380903
381494
  containsMarker = true;
380904
381495
  continue;
380905
381496
  }
@@ -380918,7 +381509,7 @@ function wordMarkerText(element) {
380918
381509
  function findWordListMarkerNode(node3) {
380919
381510
  if (isWordListMarkerNode(node3))
380920
381511
  return node3;
380921
- if (!isElement(node3))
381512
+ if (!isElement2(node3))
380922
381513
  return null;
380923
381514
  for (const child of node3.childNodes) {
380924
381515
  const marker = findWordListMarkerNode(child);
@@ -381169,7 +381760,7 @@ function isEmptyListWrapper(element) {
381169
381760
  if (isText(child) && (!isFormattingWhitespace(child) || current.tagName === "pre" && child.value !== "")) {
381170
381761
  return false;
381171
381762
  }
381172
- if (isElement(child))
381763
+ if (isElement2(child))
381173
381764
  pending2.push(child);
381174
381765
  }
381175
381766
  }
@@ -381183,14 +381774,14 @@ function attachSiblingListsToPreviousItems(parent) {
381183
381774
  let previousItem = null;
381184
381775
  const retained = [];
381185
381776
  for (const child of current.childNodes) {
381186
- if (isElement(child) && child.tagName === "li") {
381777
+ if (isElement2(child) && child.tagName === "li") {
381187
381778
  previousItem = child;
381188
381779
  retained.push(child);
381189
- } else if (previousItem && isElement(child) && (child.tagName === "ul" || child.tagName === "ol")) {
381780
+ } else if (previousItem && isElement2(child) && (child.tagName === "ul" || child.tagName === "ol")) {
381190
381781
  previousItem.childNodes.push(child);
381191
381782
  child.parentNode = previousItem;
381192
381783
  } else {
381193
- if (isText(child) && !isFormattingWhitespace(child) || isElement(child) && !SCAFFOLDING_ELEMENTS.has(child.tagName) && !ACTIVE_ELEMENTS.has(child.tagName) && !isEmptyListWrapper(child))
381784
+ if (isText(child) && !isFormattingWhitespace(child) || isElement2(child) && !SCAFFOLDING_ELEMENTS.has(child.tagName) && !ACTIVE_ELEMENTS.has(child.tagName) && !isEmptyListWrapper(child))
381194
381785
  previousItem = null;
381195
381786
  retained.push(child);
381196
381787
  }
@@ -381198,7 +381789,7 @@ function attachSiblingListsToPreviousItems(parent) {
381198
381789
  current.childNodes = retained;
381199
381790
  }
381200
381791
  for (const child of current.childNodes) {
381201
- if (isElement(child))
381792
+ if (isElement2(child))
381202
381793
  pending2.push(child);
381203
381794
  }
381204
381795
  }
@@ -381265,7 +381856,7 @@ function hasRecoveredDuplicateElement(root) {
381265
381856
  const starts = new Set;
381266
381857
  const visit = (parent) => {
381267
381858
  for (const child of parent.childNodes) {
381268
- if (!isElement(child))
381859
+ if (!isElement2(child))
381269
381860
  continue;
381270
381861
  const start = child.sourceCodeLocation?.startTag?.startOffset;
381271
381862
  if (start !== undefined) {
@@ -381291,7 +381882,7 @@ function inspectTreeLimits(root, limits) {
381291
381882
  return { kind: "nodes", path: nodePath, node: node3 };
381292
381883
  if (depth + 1 > limits.maxNestingDepth)
381293
381884
  return { kind: "depth", path: nodePath, node: node3 };
381294
- if (isElement(node3)) {
381885
+ if (isElement2(node3)) {
381295
381886
  const violation = visit(node3, depth + 1, nodePath);
381296
381887
  if (violation)
381297
381888
  return violation;
@@ -381317,7 +381908,7 @@ function convertFlowChildren(children3, context, inlineContext, path7, indexOffs
381317
381908
  pending2.appendText(node3.value, inlineContext.runProps, inlineContext.preserveWhitespace);
381318
381909
  continue;
381319
381910
  }
381320
- if (!isElement(node3))
381911
+ if (!isElement2(node3))
381321
381912
  continue;
381322
381913
  const word6 = describeWordListParagraph(node3, context.wordListStyles);
381323
381914
  if (word6) {
@@ -381330,7 +381921,7 @@ function convertFlowChildren(children3, context, inlineContext, path7, indexOffs
381330
381921
  lookahead += 1;
381331
381922
  continue;
381332
381923
  }
381333
- if (!isElement(next))
381924
+ if (!isElement2(next))
381334
381925
  break;
381335
381926
  const nextWord = describeWordListParagraph(next, context.wordListStyles);
381336
381927
  if (!nextWord || nextWord.listKey !== word6.listKey)
@@ -381452,7 +382043,7 @@ function convertBlock(element, context, inherited, path7) {
381452
382043
  const child = element.childNodes[index];
381453
382044
  if (isText(child))
381454
382045
  builder2.appendPreformattedText(child.value, childContext2.runProps);
381455
- else if (isElement(child))
382046
+ else if (isElement2(child))
381456
382047
  appendInlineNode(child, builder2, context, childContext2, [...path7, index]);
381457
382048
  }
381458
382049
  const inlines2 = builder2.finish(false);
@@ -381477,7 +382068,7 @@ function convertBlock(element, context, inherited, path7) {
381477
382068
  const child = element.childNodes[index];
381478
382069
  if (isText(child))
381479
382070
  builder.appendText(child.value, childContext.runProps, false);
381480
- else if (isElement(child))
382071
+ else if (isElement2(child))
381481
382072
  appendInlineNode(child, builder, context, childContext, [...path7, index]);
381482
382073
  }
381483
382074
  const inlines = builder.finish(true);
@@ -381544,12 +382135,12 @@ function convertSemanticList(root, context, inherited, path7) {
381544
382135
  }
381545
382136
  for (let itemIndex = 0;itemIndex < list.childNodes.length; itemIndex += 1) {
381546
382137
  const item2 = list.childNodes[itemIndex];
381547
- if (!isElement(item2) || item2.tagName !== "li") {
381548
- if (isElement(item2) && (SCAFFOLDING_ELEMENTS.has(item2.tagName) || ACTIVE_ELEMENTS.has(item2.tagName))) {
382138
+ if (!isElement2(item2) || item2.tagName !== "li") {
382139
+ if (isElement2(item2) && (SCAFFOLDING_ELEMENTS.has(item2.tagName) || ACTIVE_ELEMENTS.has(item2.tagName))) {
381549
382140
  convertBlock(item2, context, inherited, [...listPath, itemIndex]);
381550
382141
  continue;
381551
382142
  }
381552
- if (isElement(item2) && !isEmptyListWrapper(item2) || isText(item2) && !isFormattingWhitespace(item2)) {
382143
+ if (isElement2(item2) && !isEmptyListWrapper(item2) || isText(item2) && !isFormattingWhitespace(item2)) {
381553
382144
  addDiagnostic(context, {
381554
382145
  code: "conversion-malformed-input",
381555
382146
  severity: "error",
@@ -381568,11 +382159,11 @@ function convertSemanticList(root, context, inherited, path7) {
381568
382159
  let sawNestedList = false;
381569
382160
  for (let childIndex = 0;childIndex < item2.childNodes.length; childIndex += 1) {
381570
382161
  const child = item2.childNodes[childIndex];
381571
- if (isElement(child) && (child.tagName === "ul" || child.tagName === "ol")) {
382162
+ if (isElement2(child) && (child.tagName === "ul" || child.tagName === "ol")) {
381572
382163
  nestedListCount += 1;
381573
382164
  sawNestedList = true;
381574
382165
  inspectDefinitions(child, level + 1, [...listPath, itemIndex, childIndex]);
381575
- } else if (sawNestedList && (isElement(child) || isText(child) && !isFormattingWhitespace(child))) {
382166
+ } else if (sawNestedList && (isElement2(child) || isText(child) && !isFormattingWhitespace(child))) {
381576
382167
  requiresNestedRepresentation = true;
381577
382168
  }
381578
382169
  }
@@ -381606,7 +382197,7 @@ function convertSemanticList(root, context, inherited, path7) {
381606
382197
  let itemOrdinal = 0;
381607
382198
  for (let index = 0;index < list.childNodes.length; index += 1) {
381608
382199
  const child = list.childNodes[index];
381609
- if (!isElement(child) || child.tagName !== "li")
382200
+ if (!isElement2(child) || child.tagName !== "li")
381610
382201
  continue;
381611
382202
  const itemPath = [...listPath, index];
381612
382203
  const canonicalPath = [...parentItemPath, itemOrdinal];
@@ -381615,7 +382206,7 @@ function convertSemanticList(root, context, inherited, path7) {
381615
382206
  const itemValue = orderedListItemValue(child, definition, context, itemPath);
381616
382207
  if (itemValue === null)
381617
382208
  rejected22 = true;
381618
- const contentChildren = child.childNodes.filter((itemChild) => !(isElement(itemChild) && (itemChild.tagName === "ul" || itemChild.tagName === "ol")));
382209
+ const contentChildren = child.childNodes.filter((itemChild) => !(isElement2(itemChild) && (itemChild.tagName === "ul" || itemChild.tagName === "ol")));
381619
382210
  const itemContext = inlineContextForElement(child, context, inherited, itemPath);
381620
382211
  const droppedContentStart = context.droppedContentCount;
381621
382212
  const content = convertFlowChildren(contentChildren, context, itemContext, itemPath);
@@ -381629,7 +382220,7 @@ function convertSemanticList(root, context, inherited, path7) {
381629
382220
  });
381630
382221
  for (let nestedIndex = 0;nestedIndex < child.childNodes.length; nestedIndex += 1) {
381631
382222
  const nested = child.childNodes[nestedIndex];
381632
- if (isElement(nested) && (nested.tagName === "ul" || nested.tagName === "ol")) {
382223
+ if (isElement2(nested) && (nested.tagName === "ul" || nested.tagName === "ol")) {
381633
382224
  appendList(nested, level + 1, [...itemPath, nestedIndex], canonicalPath);
381634
382225
  }
381635
382226
  }
@@ -381659,7 +382250,7 @@ function convertSemanticList(root, context, inherited, path7) {
381659
382250
  let itemOrdinal = 0;
381660
382251
  for (let index = 0;index < list.childNodes.length; index += 1) {
381661
382252
  const child = list.childNodes[index];
381662
- if (!isElement(child) || child.tagName !== "li")
382253
+ if (!isElement2(child) || child.tagName !== "li")
381663
382254
  continue;
381664
382255
  const itemPath = [...listPath, index];
381665
382256
  const canonicalPath = [...parentItemPath, itemOrdinal];
@@ -381674,7 +382265,7 @@ function convertSemanticList(root, context, inherited, path7) {
381674
382265
  let segmentStart = 0;
381675
382266
  for (let nestedIndex = 0;nestedIndex < child.childNodes.length; nestedIndex += 1) {
381676
382267
  const nested = child.childNodes[nestedIndex];
381677
- if (isElement(nested) && (nested.tagName === "ul" || nested.tagName === "ol")) {
382268
+ if (isElement2(nested) && (nested.tagName === "ul" || nested.tagName === "ol")) {
381678
382269
  nestedContent.push(...convertFlowChildren(child.childNodes.slice(segmentStart, nestedIndex), context, itemContext, itemPath, segmentStart));
381679
382270
  if (nestedContent.length === 0) {
381680
382271
  nestedContent.push(paragraph2(context, [], undefined, itemPath, false));
@@ -381871,7 +382462,7 @@ function convertTable(table, context, inherited, path7) {
381871
382462
  for (const [rowIndex, { row, path: rowPath }] of rows.entries()) {
381872
382463
  for (let cellIndex = 0;cellIndex < row.childNodes.length; cellIndex += 1) {
381873
382464
  const cell = row.childNodes[cellIndex];
381874
- if (!isElement(cell) || cell.tagName !== "td" && cell.tagName !== "th")
382465
+ if (!isElement2(cell) || cell.tagName !== "td" && cell.tagName !== "th")
381875
382466
  continue;
381876
382467
  const span = spanGrid.get(cell);
381877
382468
  firstRetainedRow = Math.min(firstRetainedRow, rowIndex);
@@ -381911,7 +382502,7 @@ function convertTable(table, context, inherited, path7) {
381911
382502
  let maxNewCover = 0;
381912
382503
  for (let cellIndex = 0;cellIndex < row.childNodes.length; cellIndex += 1) {
381913
382504
  const cell = row.childNodes[cellIndex];
381914
- if (!isElement(cell) || cell.tagName !== "td" && cell.tagName !== "th")
382505
+ if (!isElement2(cell) || cell.tagName !== "td" && cell.tagName !== "th")
381915
382506
  continue;
381916
382507
  const cellPath = [...rowPath, cellIndex];
381917
382508
  inspectElementAttributes(cell, context, cellPath);
@@ -382076,7 +382667,7 @@ function appendInlineNode(element, builder, context, inherited, path7) {
382076
382667
  const child = element.childNodes[index];
382077
382668
  if (isText(child))
382078
382669
  builder.appendText(child.value, nextContext.runProps, nextContext.preserveWhitespace);
382079
- else if (isElement(child))
382670
+ else if (isElement2(child))
382080
382671
  appendInlineNode(child, builder, context, nextContext, [...path7, index]);
382081
382672
  }
382082
382673
  }
@@ -382087,7 +382678,7 @@ function appendHyperlink(element, builder, context, inherited, path7) {
382087
382678
  const child = element.childNodes[index];
382088
382679
  if (isText(child))
382089
382680
  childBuilder.appendText(child.value, childContext.runProps, childContext.preserveWhitespace);
382090
- else if (isElement(child))
382681
+ else if (isElement2(child))
382091
382682
  appendInlineNode(child, childBuilder, context, childContext, [...path7, index]);
382092
382683
  }
382093
382684
  const children3 = childBuilder.finish(false);
@@ -382347,7 +382938,7 @@ function isSuspiciousRecoveredElement(element) {
382347
382938
  }
382348
382939
  function hasBlockDescendant(element) {
382349
382940
  for (const child of element.childNodes) {
382350
- if (!isElement(child))
382941
+ if (!isElement2(child))
382351
382942
  continue;
382352
382943
  if (isBlockElement(child) || FLOW_WRAPPERS.has(child.tagName))
382353
382944
  return true;
@@ -382479,7 +383070,7 @@ function parseTableSpanGrid(rows, context) {
382479
383070
  let column = 0;
382480
383071
  for (let cellIndex = 0;cellIndex < row.childNodes.length; cellIndex += 1) {
382481
383072
  const cell = row.childNodes[cellIndex];
382482
- if (!isElement(cell) || cell.tagName !== "td" && cell.tagName !== "th")
383073
+ if (!isElement2(cell) || cell.tagName !== "td" && cell.tagName !== "th")
382483
383074
  continue;
382484
383075
  const cellPath = [...path7, cellIndex];
382485
383076
  const authoredRowSpan = readSpan(cell, cellPath, "rowspan");
@@ -382530,7 +383121,7 @@ function tableColumnSharesFromHtml(table, htmlRows, convertedRows, context, path
382530
383121
  const candidates = [];
382531
383122
  for (let rowIndex = 0;rowIndex < convertedRows.length; rowIndex += 1) {
382532
383123
  const row = convertedRows[rowIndex];
382533
- const htmlCells = htmlRows[rowIndex].childNodes.filter((cell) => isElement(cell) && (cell.tagName === "td" || cell.tagName === "th"));
383124
+ const htmlCells = htmlRows[rowIndex].childNodes.filter((cell) => isElement2(cell) && (cell.tagName === "td" || cell.tagName === "th"));
382534
383125
  const shares = [];
382535
383126
  let cellCount = 0;
382536
383127
  let col = 0;
@@ -382631,7 +383222,7 @@ function collectTableRows(table, tablePath) {
382631
383222
  let directRows = [];
382632
383223
  for (let index = 0;index < table.childNodes.length; index += 1) {
382633
383224
  const child = table.childNodes[index];
382634
- if (!isElement(child))
383225
+ if (!isElement2(child))
382635
383226
  continue;
382636
383227
  const childPath = [...tablePath, index];
382637
383228
  if (child.tagName === "tr") {
@@ -382642,7 +383233,7 @@ function collectTableRows(table, tablePath) {
382642
383233
  const group = [];
382643
383234
  for (let rowIndex = 0;rowIndex < child.childNodes.length; rowIndex += 1) {
382644
383235
  const row = child.childNodes[rowIndex];
382645
- if (isElement(row) && row.tagName === "tr")
383236
+ if (isElement2(row) && row.tagName === "tr")
382646
383237
  group.push({ row, path: [...childPath, rowIndex] });
382647
383238
  }
382648
383239
  appendGroup(group);
@@ -382654,7 +383245,7 @@ function collectTableRows(table, tablePath) {
382654
383245
  function findDescendantElement(element, tagName) {
382655
383246
  const visit = (parent) => {
382656
383247
  for (const child of parent.childNodes) {
382657
- if (!isElement(child))
383248
+ if (!isElement2(child))
382658
383249
  continue;
382659
383250
  if (child.tagName === tagName)
382660
383251
  return child;
@@ -382682,7 +383273,7 @@ function emptyParagraphMarkRunProps(element, context, inherited, path7) {
382682
383273
  const visit = (parent, parentContext, parentPath) => {
382683
383274
  for (let index = 0;index < parent.childNodes.length; index += 1) {
382684
383275
  const child = parent.childNodes[index];
382685
- if (!isElement(child))
383276
+ if (!isElement2(child))
382686
383277
  continue;
382687
383278
  const childContext = inlineContextForElement(child, context, parentContext, [...parentPath, index]);
382688
383279
  markRunProps = childContext.runProps;
@@ -395031,50 +395622,56 @@ function emphasizeHeaderCellBlock(block) {
395031
395622
  function lowerCellProperties(props, path8) {
395032
395623
  if (!props)
395033
395624
  return {};
395034
- const supported = new Set(["shading", "padding", "verticalAlign", "borders"]);
395625
+ const supported = new Set(["shading", "padding", "verticalAlign", "borders", "noWrap"]);
395035
395626
  const unsupportedKeys = Object.keys(props).filter((key3) => !supported.has(key3));
395036
395627
  if (unsupportedKeys.length > 0) {
395037
395628
  unsupported3(path8, `Table-cell properties are not materializable: ${unsupportedKeys.sort().join(", ")}.`);
395038
395629
  }
395039
- let shadingColor;
395040
- if (props.shading) {
395041
- if (props.shading.model !== "rgb" || !/^[0-9A-Fa-f]{6}$/.test(props.shading.value)) {
395042
- unsupported3([...path8, "shading"], "Only six-digit RGB cell shading is materializable.");
395043
- }
395044
- shadingColor = props.shading.value.toUpperCase();
395045
- }
395630
+ const shading = props.shading ? lowerCellShading(props.shading, [...path8, "shading"]) : {};
395046
395631
  const verticalAlign = props.verticalAlign;
395047
395632
  if (verticalAlign !== undefined && verticalAlign !== "top" && verticalAlign !== "center" && verticalAlign !== "bottom") {
395048
395633
  unsupported3([...path8, "verticalAlign"], "Table-cell verticalAlign must be top, center, or bottom.");
395049
395634
  }
395050
- const padding = props.padding ? {
395051
- ...props.padding.top !== undefined ? { topPt: safeScaledNonnegative(props.padding.top, 20, [...path8, "padding", "top"]) } : {},
395052
- ...props.padding.right !== undefined ? { rightPt: safeScaledNonnegative(props.padding.right, 20, [...path8, "padding", "right"]) } : {},
395053
- ...props.padding.bottom !== undefined ? { bottomPt: safeScaledNonnegative(props.padding.bottom, 20, [...path8, "padding", "bottom"]) } : {},
395054
- ...props.padding.left !== undefined ? { leftPt: safeScaledNonnegative(props.padding.left, 20, [...path8, "padding", "left"]) } : {}
395055
- } : undefined;
395635
+ if (props.noWrap !== undefined && typeof props.noWrap !== "boolean") {
395636
+ invalid5([...path8, "noWrap"], "Table-cell noWrap must be a boolean.");
395637
+ }
395638
+ const padding = props.padding ? Object.fromEntries(["top", "right", "bottom", "left", "start", "end"].flatMap((side) => {
395639
+ const points = props.padding?.[side];
395640
+ return points === undefined ? [] : [[`${side}Pt`, safeScaledNonnegative(points, 20, [...path8, "padding", side])]];
395641
+ })) : undefined;
395056
395642
  const borders = props.borders ? Object.fromEntries(["top", "right", "bottom", "left"].flatMap((side) => {
395057
395643
  const border = props.borders?.[side];
395058
395644
  return border ? [[side, lowerCellBorder(border, [...path8, "borders", side])]] : [];
395059
395645
  })) : undefined;
395060
395646
  return {
395061
- ...shadingColor ? { shadingColor } : {},
395647
+ ...shading,
395648
+ ...props.noWrap !== undefined ? { noWrap: props.noWrap } : {},
395062
395649
  ...verticalAlign ? { verticalAlign } : {},
395063
395650
  ...padding && Object.keys(padding).length > 0 ? { padding } : {},
395064
395651
  ...borders && Object.keys(borders).length > 0 ? { borders } : {}
395065
395652
  };
395066
395653
  }
395654
+ function lowerCellShading(shading, path8) {
395655
+ if (shading.model === "rgb" && /^[0-9A-Fa-f]{6}$/.test(shading.value))
395656
+ return { shadingColor: shading.value.toUpperCase() };
395657
+ const isByte = (value2) => value2 === undefined || Number.isInteger(value2) && value2 >= 0 && value2 <= 255;
395658
+ if (shading.model === "theme" && /^[A-Za-z0-9]+$/.test(shading.theme) && isByte(shading.tint) && isByte(shading.shade)) {
395659
+ return { shadingTheme: { theme: shading.theme, ...shading.tint !== undefined ? { tint: shading.tint } : {}, ...shading.shade !== undefined ? { shade: shading.shade } : {} } };
395660
+ }
395661
+ unsupported3(path8, "Only six-digit RGB or theme cell shading is materializable.");
395662
+ }
395067
395663
  function lowerCellBorder(value2, path8) {
395068
395664
  if (value2 === "none")
395069
395665
  return { lineStyle: "nil", lineWeightPt: 0, color: "auto" };
395070
- const match = /^(single|dashed|dotted|double) (\d+(?:\.\d+)?)pt #([0-9A-F]{6})$/.exec(value2);
395071
- if (!match)
395072
- unsupported3(path8, "Only normalized solid, dashed, dotted, or double RGB cell borders are materializable.");
395073
- const lineWeightPt = Number.parseFloat(match[2]);
395666
+ const [, lineStyle, weight, color2] = /^(\S+) (\d+(?:\.\d+)?)pt (?:#([0-9A-Fa-f]{6})|auto)$/.exec(value2) ?? [];
395667
+ if (!lineStyle || !weight || !isPasteCellBorderStyle(lineStyle)) {
395668
+ unsupported3(path8, 'Cell borders must read "<ST_Border style> <weight>pt <#RRGGBB or auto>" or "none".');
395669
+ }
395670
+ const lineWeightPt = Number.parseFloat(weight);
395074
395671
  if (!Number.isFinite(lineWeightPt) || lineWeightPt <= 0 || !Number.isSafeInteger(Math.round(lineWeightPt * 8))) {
395075
395672
  unsupported3(path8, "Cell border weight must produce a positive safe OOXML eighth-point measure.");
395076
395673
  }
395077
- return { lineStyle: match[1], lineWeightPt, color: match[3] };
395674
+ return { lineStyle, lineWeightPt, color: color2 ? color2.toUpperCase() : "auto" };
395078
395675
  }
395079
395676
  function positiveInteger(value2, path8) {
395080
395677
  if (!Number.isSafeInteger(value2) || value2 < 1 || value2 > MAX_SIGNED_32_BIT_INTEGER4) {
@@ -417407,7 +418004,7 @@ function blockNumberingProjector(context, storyId, reviewMode, overlayRead) {
417407
418004
  const facts = new Map;
417408
418005
  let usable = overlayRead.status !== "stale";
417409
418006
  return {
417410
- advance(blockId, paragraph3, tableInfo, sourceStoryId = storyId) {
418007
+ advance(blockId, paragraph3, tableInfo, sourceStoryId = storyId, attachment) {
417411
418008
  if (!usable)
417412
418009
  return;
417413
418010
  if (boundedEmptyOverlay && projectionXmlHasReviewMarkup(paragraph3.rawXml)) {
@@ -417459,6 +418056,7 @@ function blockNumberingProjector(context, storyId, reviewMode, overlayRead) {
417459
418056
  }
417460
418057
  const marker = numbering.advance({
417461
418058
  ...properties3,
418059
+ ...attachment,
417462
418060
  paragraphOrdinal: paragraph3.ordinal,
417463
418061
  membership: membership.membership,
417464
418062
  sectionBreakMembership: membership.sectionBreakMembership,
@@ -417868,8 +418466,12 @@ function captureParagraphIndexMaterialization(index2) {
417868
418466
  sourceRecordCount: paragraphIndexMaterializedSourceRecordCount(index2)
417869
418467
  };
417870
418468
  }
417871
- function buildReviewAwareBlockNumbering(context, storyId, index2, storyByteRange, reviewMode) {
417872
- const cache = storyByteRange ? null : blockNumberingCache(context, storyId, index2);
418469
+ function previewListAttachmentMarker(context, storyId, index2, previousBlockId, attachment) {
418470
+ const numbering = buildReviewAwareBlockNumbering(context, storyId, index2, undefined, "final", attachment);
418471
+ return numbering.has(previousBlockId) ? numbering.get(attachment.blockId)?.marker : undefined;
418472
+ }
418473
+ function buildReviewAwareBlockNumbering(context, storyId, index2, storyByteRange, reviewMode, attachment) {
418474
+ const cache = storyByteRange || attachment ? null : blockNumberingCache(context, storyId, index2);
417873
418475
  const cached2 = cache?.modes.get(reviewMode);
417874
418476
  if (cached2)
417875
418477
  return cached2;
@@ -417891,6 +418493,7 @@ function buildReviewAwareBlockNumbering(context, storyId, index2, storyByteRange
417891
418493
  continue;
417892
418494
  }
417893
418495
  const tableContext = tableContexts.get(source.storyId);
418496
+ const proposed = source.storyId === storyId && entry.blockId === attachment?.blockId ? attachment : undefined;
417894
418497
  let rawXml;
417895
418498
  projector.advance(source.storyId === storyId ? entry.blockId : null, {
417896
418499
  ordinal: ordinal++,
@@ -417900,7 +418503,9 @@ function buildReviewAwareBlockNumbering(context, storyId, index2, storyByteRange
417900
418503
  get rawXml() {
417901
418504
  return rawXml ?? (rawXml = readParagraphXml(context, partUriBytes, entry));
417902
418505
  }
417903
- }, tableContext.resolver?.resolve(entry), source.storyId);
418506
+ }, tableContext.resolver?.resolve(entry), source.storyId, proposed);
418507
+ if (proposed)
418508
+ break;
417904
418509
  }
417905
418510
  const result = projector.result();
417906
418511
  cache?.modes.set(reviewMode, result);
@@ -432277,18 +432882,18 @@ function* indexCommentSourcePartSteps(xml) {
432277
432882
  }
432278
432883
  }
432279
432884
  const markers = new Map;
432280
- const marker = /<[\w.-]+:commentRange(Start|End)\b[^>]*\bw:id="([^"]*)"[^>]*\/>/g;
432885
+ const marker = new RegExp(String.raw`<${COMMENT_MARKER_ELEMENT_PREFIX}:commentRange(Start|End)\b[^>]*\b${COMMENT_MARKER_ID_ATTRIBUTE}="([^"]*)"[^>]*\/>`, "g");
432281
432886
  let markerCount = 0;
432282
432887
  for (let match;match = marker.exec(xml); ) {
432283
432888
  if (++markerCount % 64 === 0)
432284
432889
  yield;
432285
- const id = match[2];
432890
+ const id = match[3];
432286
432891
  let offsets = markers.get(id);
432287
432892
  if (!offsets) {
432288
432893
  offsets = { starts: [], ends: [] };
432289
432894
  markers.set(id, offsets);
432290
432895
  }
432291
- if (match[1] === "Start")
432896
+ if (match[2] === "Start")
432292
432897
  offsets.starts.push(match.index);
432293
432898
  else
432294
432899
  offsets.ends.push(match.index + match[0].length);
@@ -432312,7 +432917,9 @@ function* indexCommentSourcePartSteps(xml) {
432312
432917
  }
432313
432918
  };
432314
432919
  }
432315
- var init_source_part_index = () => {};
432920
+ var init_source_part_index = __esm(() => {
432921
+ init_sd_document_session_internal();
432922
+ });
432316
432923
 
432317
432924
  // ../../../v2/document-api-v2-adapter/dist/comments/cooperative-read-cache.js
432318
432925
  function releaseCooperativeCommentReadCache(session) {
@@ -441819,6 +442426,9 @@ class V2ListsAdapter {
441819
442426
  if (state.isListItem) {
441820
442427
  return successItem(target.paraId, { changed: false });
441821
442428
  }
442429
+ const ordered = input.kind === "ordered" ? resolveOrderedAutoList(this.context, target) : undefined;
442430
+ if (ordered === null)
442431
+ return successItem(target.paraId, { changed: false });
441822
442432
  const preflight = beginListMutation(this.context, options);
441823
442433
  if ("failure" in preflight)
441824
442434
  return failure9(preflight.failure.code, preflight.failure.message);
@@ -441837,7 +442447,8 @@ class V2ListsAdapter {
441837
442447
  kind: "replace",
441838
442448
  target: input.target,
441839
442449
  text: "",
441840
- in: target.story
442450
+ in: target.story,
442451
+ ...ordered ? { expectedText: ordered.prefix } : {}
441841
442452
  }, stepOptions);
441842
442453
  if (!deleteReceipt.success) {
441843
442454
  failureResult = failure9(deleteReceipt.failure.code, deleteReceipt.failure.message);
@@ -441854,7 +442465,8 @@ class V2ListsAdapter {
441854
442465
  changeMode: stepOptions?.changeMode ?? "direct",
441855
442466
  target: { storyId: target.storyId, paraId: target.paraId },
441856
442467
  seed: input.kind,
441857
- ilvl: 0
442468
+ ilvl: 0,
442469
+ ...ordered?.reuseNumId ? { reuseNumId: ordered.reuseNumId } : {}
441858
442470
  });
441859
442471
  const receipt3 = tx.commit();
441860
442472
  if (receipt3.status === "rejected") {
@@ -443658,6 +444270,42 @@ function resolveStoryIdForListRange(context, story) {
443658
444270
  return null;
443659
444271
  return resolved.storyId;
443660
444272
  }
444273
+ function resolveOrderedAutoList(context, target) {
444274
+ const index2 = paragraphIndexForStory4(context, target.storyId);
444275
+ const entry = index2?.byParaId(target.paraId);
444276
+ if (!index2 || !entry || target.startOffset !== 0)
444277
+ return null;
444278
+ const prefix2 = readResolvedSelectionText(index2, context.session, {
444279
+ startBlockId: target.paraId,
444280
+ startOffset: target.startOffset,
444281
+ endOffset: target.endOffset
444282
+ });
444283
+ if (prefix2.length !== target.endOffset || matchTypedAutoListPrefix(prefix2, " ") !== "ordered")
444284
+ return null;
444285
+ if (prefix2 === "1.")
444286
+ return { prefix: prefix2 };
444287
+ const previous3 = index2.entries[entry.ordinal - 1];
444288
+ const adjacent = previous3 && (entry.directBodyChildOrdinal !== undefined ? previous3.directBodyChildOrdinal === entry.directBodyChildOrdinal - 1 : previous3.partUri === entry.partUri && isSameListParagraphContainer(context, previous3, entry));
444289
+ if (!adjacent)
444290
+ return null;
444291
+ const state = readListStateForSession(context.session, target.storyId, previous3.blockId);
444292
+ if (!state?.numId || state.ilvl !== 0 || state.numFmt !== "decimal" || state.lvlText !== "%1.")
444293
+ return null;
444294
+ const marker = previewListAttachmentMarker(context, target.storyId, index2, previous3.blockId, {
444295
+ blockId: entry.blockId,
444296
+ numId: state.numId,
444297
+ ilvl: 0
444298
+ });
444299
+ return marker === prefix2 ? { prefix: prefix2, reuseNumId: state.numId } : null;
444300
+ }
444301
+ function isSameListParagraphContainer(context, previous3, entry) {
444302
+ if (previous3.byteEnd === entry.byteStart)
444303
+ return true;
444304
+ if (previous3.byteEnd > entry.byteStart)
444305
+ return false;
444306
+ const between = getSDDocumentSessionInternalPartRange(context.session, entry.partUri, previous3.byteEnd, entry.byteStart);
444307
+ return between !== null && LISTS_XML_DECODER.decode(between).trim() === "";
444308
+ }
443661
444309
  function resolveAutoListPrefixTarget(context, target) {
443662
444310
  if (target.kind !== "selection") {
443663
444311
  return {
@@ -444427,7 +445075,9 @@ function listParagraphProtectionFailure(context, storyId, paraIds) {
444427
445075
  }
444428
445076
  var LISTS_XML_DECODER, BULLET_GLYPH_BY_LEVEL;
444429
445077
  var init_adapter16 = __esm(() => {
445078
+ init_adapter9();
444430
445079
  init_xml_part_decoder();
445080
+ init_list_summary();
444431
445081
  init_src3();
444432
445082
  init_sd_document_session_internal();
444433
445083
  init_src6();
@@ -448971,8 +449621,8 @@ function* adjacentCells(rows, item2, side) {
448971
449621
  if (neighbor && neighbor !== item2)
448972
449622
  neighbors.push({
448973
449623
  owner: neighbor,
448974
- attributes: row?.attributes.has(neighbor) ? row.attributes.get(neighbor) : neighbor.attributes,
448975
- ownAttributes: row?.attributes.has(item2) ? row.attributes.get(item2) : item2.attributes
449624
+ attributes: row?.sourceCells.has(neighbor) ? row.sourceCells.get(neighbor)?.attributes : neighbor.attributes,
449625
+ ownAttributes: row?.sourceCells.has(item2) ? row.sourceCells.get(item2)?.attributes : item2.attributes
448976
449626
  });
448977
449627
  yield;
448978
449628
  }
@@ -448996,8 +449646,8 @@ function* adjacentCells(rows, item2, side) {
448996
449646
  if (neighbor !== item2)
448997
449647
  neighbors.push({
448998
449648
  owner: neighbor,
448999
- attributes: row?.attributes.has(neighbor) ? row.attributes.get(neighbor) : neighbor.attributes,
449000
- ownAttributes: ownRow?.attributes.has(item2) ? ownRow.attributes.get(item2) : item2.attributes
449649
+ attributes: row?.sourceCells.has(neighbor) ? row.sourceCells.get(neighbor)?.attributes : neighbor.attributes,
449650
+ ownAttributes: ownRow?.sourceCells.has(item2) ? ownRow.sourceCells.get(item2)?.attributes : item2.attributes
449001
449651
  });
449002
449652
  yield;
449003
449653
  }
@@ -449007,6 +449657,23 @@ function* adjacentCells(rows, item2, side) {
449007
449657
  function borderKey(border) {
449008
449658
  return projectionBorderCss({ left: border }).join(";");
449009
449659
  }
449660
+ function visibleBorderKey(border) {
449661
+ return border?.none || border?.style === "none" ? "" : borderKey(border);
449662
+ }
449663
+ function verticalDividerIsUnrepresented(row, left, right, defaultVerticalKey) {
449664
+ if (left.lastRow === left.firstRow && right.lastRow === right.firstRow)
449665
+ return false;
449666
+ const sourceRight = row.sourceCells.get(left)?.attributes?.borders?.right;
449667
+ const sourceLeft = row.sourceCells.get(right)?.attributes?.borders?.left;
449668
+ const expectedRight = sourceRight === undefined && sourceLeft === undefined ? defaultVerticalKey : visibleBorderKey(sourceRight);
449669
+ const expectedLeft = visibleBorderKey(sourceLeft);
449670
+ const emittedRight = visibleBorderKey(emittedCellBorder(left, "right"));
449671
+ const emittedLeft = visibleBorderKey(emittedCellBorder(right, "left"));
449672
+ return differsFromBoth(expectedRight, emittedRight, emittedLeft) || differsFromBoth(expectedLeft, emittedRight, emittedLeft) || differsFromBoth(emittedRight, expectedRight, expectedLeft) || differsFromBoth(emittedLeft, expectedRight, expectedLeft);
449673
+ }
449674
+ function differsFromBoth(key3, first, second) {
449675
+ return key3 !== "" && key3 !== first && key3 !== second;
449676
+ }
449010
449677
  function continuedEdgeBorder(neighbors, side, opposite) {
449011
449678
  if (side !== "left" && side !== "right")
449012
449679
  return;
@@ -449053,7 +449720,7 @@ function* presentationSteps(input, index2) {
449053
449720
  byteStart: row.rowByteStart,
449054
449721
  css: rowPresentation.css,
449055
449722
  cells: [],
449056
- attributes: new Map,
449723
+ sourceCells: new Map,
449057
449724
  byColumn: new Map,
449058
449725
  byEndColumn: new Map
449059
449726
  };
@@ -449107,7 +449774,7 @@ function* presentationSteps(input, index2) {
449107
449774
  } else
449108
449775
  verticalStarts.delete(cell.gridColumnStart);
449109
449776
  state.cells.push(item2);
449110
- state.attributes.set(item2, attributes);
449777
+ state.sourceCells.set(item2, { attributes, byteStart: cell.cellByteStart });
449111
449778
  yield;
449112
449779
  }
449113
449780
  rowStates.push(state);
@@ -449332,12 +449999,27 @@ function* presentationSteps(input, index2) {
449332
449999
  yield;
449333
450000
  }
449334
450001
  const rows = new Map;
450002
+ const unrepresentedBorderCells = new Set;
450003
+ const defaultVerticalKey = visibleBorderKey(presentation.borders?.insideV);
449335
450004
  for (const [rowIndex, row] of rowStates.entries()) {
449336
450005
  const cells = new Map;
449337
450006
  for (const item2 of row.cells) {
449338
- if (item2.firstRow !== rowIndex)
450007
+ if (unrepresentedBorderSegments) {
450008
+ const right = row.byColumn.get(item2.column + item2.descriptor.gridSpan);
450009
+ if (right && verticalDividerIsUnrepresented(row, item2, right, defaultVerticalKey)) {
450010
+ for (const owner of [item2, right]) {
450011
+ unrepresentedBorderCells.add(owner.descriptor.cellByteStart);
450012
+ const source = row.sourceCells.get(owner);
450013
+ if (source)
450014
+ unrepresentedBorderCells.add(source.byteStart);
450015
+ }
450016
+ }
450017
+ }
450018
+ if (item2.firstRow !== rowIndex) {
450019
+ yield;
449339
450020
  continue;
449340
- cells.set(item2.descriptor.cellByteStart, projectionCellCss(item2.attributes, item2.fallback, item2.suppressed, rowStates[item2.lastRow]?.attributes.get(item2)?.borders?.bottom));
450021
+ }
450022
+ cells.set(item2.descriptor.cellByteStart, projectionCellCss(item2.attributes, item2.fallback, item2.suppressed, rowStates[item2.lastRow]?.sourceCells.get(item2)?.attributes?.borders?.bottom));
449341
450023
  yield;
449342
450024
  }
449343
450025
  rows.set(row.byteStart, { css: row.css, cells });
@@ -449347,6 +450029,7 @@ function* presentationSteps(input, index2) {
449347
450029
  css: presentation.css,
449348
450030
  columns: presentation.columns,
449349
450031
  unrepresentedBorderSegments,
450032
+ unrepresentedBorderCells,
449350
450033
  rows
449351
450034
  });
449352
450035
  yield;
@@ -450312,6 +450995,123 @@ var ANCHOR_ID_PREFIX = "sd-bookmark-";
450312
450995
  var init_internal_links = () => {};
450313
450996
 
450314
450997
  // ../../../v2/document-api-v2-adapter/dist/content-projection/scope.js
450998
+ function projectionDiagnosticsInScope(diagnostics, plan, blocks, paragraphOrder, tableDiagnostics) {
450999
+ const work = projectionDiagnosticsInScopeWork(diagnostics, plan, blocks, paragraphOrder, tableDiagnostics);
451000
+ let step3 = work.next();
451001
+ while (!step3.done)
451002
+ step3 = work.next();
451003
+ return step3.value;
451004
+ }
451005
+ async function projectionDiagnosticsInScopeCooperatively(diagnostics, plan, blocks, paragraphOrder, sliceGate, tableDiagnostics) {
451006
+ const work = projectionDiagnosticsInScopeWork(diagnostics, plan, blocks, paragraphOrder, tableDiagnostics);
451007
+ let step3 = work.next();
451008
+ while (!step3.done) {
451009
+ await sliceGate();
451010
+ step3 = work.next();
451011
+ }
451012
+ return step3.value;
451013
+ }
451014
+ function* projectionDiagnosticsInScopeWork(diagnostics, plan, blocks, paragraphOrder, tableDiagnostics) {
451015
+ if (plan.resolved.kind === "story") {
451016
+ const result2 = [];
451017
+ for (const diagnostic2 of diagnostics) {
451018
+ result2.push(diagnostic2);
451019
+ yield;
451020
+ }
451021
+ return result2;
451022
+ }
451023
+ const owners3 = new Set;
451024
+ const ranges2 = new Map;
451025
+ if (plan.blockId)
451026
+ owners3.add(plan.blockId);
451027
+ const range2 = plan.range;
451028
+ if (range2 && range2.start.kind === "text" && range2.end.kind === "text") {
451029
+ const startId = range2.start.blockId;
451030
+ const endId = range2.end.blockId;
451031
+ let selected = false;
451032
+ for (const id of paragraphOrder) {
451033
+ if (id === startId)
451034
+ selected = true;
451035
+ if (selected) {
451036
+ owners3.add(id);
451037
+ ranges2.set(id, {
451038
+ start: id === startId ? range2.start.offset : 0,
451039
+ end: id === endId ? range2.end.offset : Number.MAX_SAFE_INTEGER
451040
+ });
451041
+ }
451042
+ yield;
451043
+ if (id === endId && selected)
451044
+ break;
451045
+ }
451046
+ }
451047
+ const emittedPlaceholderDiagnostics = new Set;
451048
+ const pending2 = [];
451049
+ for (const block of blocks) {
451050
+ pending2.push(block);
451051
+ yield;
451052
+ }
451053
+ while (pending2.length > 0) {
451054
+ const block = pending2.pop();
451055
+ if (!block)
451056
+ continue;
451057
+ const id = publicId(block);
451058
+ if (id && (!range2 || block.kind === "table"))
451059
+ owners3.add(id);
451060
+ if (block.kind === "table") {
451061
+ for (const row of block.rows) {
451062
+ const rowId = publicId(row);
451063
+ if (rowId)
451064
+ owners3.add(rowId);
451065
+ for (const cell of row.cells) {
451066
+ const cellId = publicId(cell);
451067
+ if (cellId)
451068
+ owners3.add(cellId);
451069
+ for (const child of cell.blocks) {
451070
+ pending2.push(child);
451071
+ yield;
451072
+ }
451073
+ yield;
451074
+ }
451075
+ yield;
451076
+ }
451077
+ } else {
451078
+ if (block.kind === "placeholder" && block.role === "unsupportedTable") {
451079
+ for (const diagnostic2 of block.diagnostics) {
451080
+ emittedPlaceholderDiagnostics.add(diagnostic2);
451081
+ yield;
451082
+ }
451083
+ }
451084
+ if (!range2) {
451085
+ for (const sourceId of sourceParagraphIds(block)) {
451086
+ owners3.add(sourceId);
451087
+ yield;
451088
+ }
451089
+ }
451090
+ }
451091
+ yield;
451092
+ }
451093
+ const result = [];
451094
+ for (const diagnostic2 of diagnostics) {
451095
+ const { blockId, range: sourceRange } = diagnostic2.source;
451096
+ const selectedRange = blockId ? ranges2.get(blockId) : undefined;
451097
+ const tableSources = tableDiagnostics?.sourceIdsByDiagnostic.get(diagnostic2);
451098
+ if (diagnostic2.severity === "error" || emittedPlaceholderDiagnostics.has(diagnostic2) || tableSources && blockId !== undefined && plan.blockId === blockId) {
451099
+ result.push(diagnostic2);
451100
+ } else if (tableDiagnostics && tableSources) {
451101
+ for (const sourceId of tableSources) {
451102
+ if (tableDiagnostics.selectedSourceBlocks.has(sourceId)) {
451103
+ result.push(diagnostic2);
451104
+ break;
451105
+ }
451106
+ yield;
451107
+ }
451108
+ } else if (!blockId || owners3.has(blockId) && (!selectedRange || !sourceRange || (sourceRange.start === sourceRange.end ? selectedRange.start <= sourceRange.start && sourceRange.start <= selectedRange.end : selectedRange.start < selectedRange.end && sourceRange.start < selectedRange.end && sourceRange.end > selectedRange.start))) {
451109
+ result.push(diagnostic2);
451110
+ }
451111
+ yield;
451112
+ }
451113
+ return result;
451114
+ }
450315
451115
  function normalizeProjectionScope(input) {
450316
451116
  const scope = input.scope;
450317
451117
  if (!scope)
@@ -450795,6 +451595,8 @@ function createParagraphInlineMapTokenSource() {
450795
451595
  const tokens = [];
450796
451596
  const bookmarks = [];
450797
451597
  collectTokens(model.pieces, input, [], [], tokens, bookmarks);
451598
+ const emptyInlineDeletions = [];
451599
+ collectEmptyInlineDeletions(model.pieces, input.paragraphByteStart, emptyInlineDeletions);
450798
451600
  const upstream = new Map;
450799
451601
  const downstream = new Map;
450800
451602
  for (const offset of input.visibleOffsets ?? []) {
@@ -450807,6 +451609,7 @@ function createParagraphInlineMapTokenSource() {
450807
451609
  return {
450808
451610
  tokens,
450809
451611
  bookmarks,
451612
+ ...emptyInlineDeletions.length ? { emptyInlineDeletions } : {},
450810
451613
  trackedLength: model.trackedLength,
450811
451614
  visibleOffsetsInTrackedSpace: { upstream, downstream }
450812
451615
  };
@@ -450816,6 +451619,22 @@ function createParagraphInlineMapTokenSource() {
450816
451619
  }
450817
451620
  };
450818
451621
  }
451622
+ function collectEmptyInlineDeletions(pieces, paragraphByteStart, out) {
451623
+ for (const piece of pieces) {
451624
+ if (piece.kind === "tracked") {
451625
+ if (piece.trackedKind === "del" && piece.children.length === 0 && piece.trackedStart === piece.trackedEnd) {
451626
+ out.push({
451627
+ byteStart: paragraphByteStart + piece.byteStart,
451628
+ byteEnd: paragraphByteStart + piece.byteEnd,
451629
+ trackedOffset: piece.trackedStart
451630
+ });
451631
+ }
451632
+ collectEmptyInlineDeletions(piece.children, paragraphByteStart, out);
451633
+ } else if (piece.kind === "container") {
451634
+ collectEmptyInlineDeletions(piece.children, paragraphByteStart, out);
451635
+ }
451636
+ }
451637
+ }
450819
451638
  function visibleOffsetToTrackedBoundaries(pieces, offset, visibleLength, trackedLength) {
450820
451639
  if (!Number.isInteger(offset) || offset < 0 || offset > visibleLength)
450821
451640
  return null;
@@ -451108,6 +451927,7 @@ function prepareProjectionBuild(context, input, supplied) {
451108
451927
  diagnostics,
451109
451928
  hasDiagnostic: createProjectionDiagnosticLookup(diagnostics),
451110
451929
  visibleToTracked,
451930
+ emptyDeletionPoints: new Map,
451111
451931
  paragraphTrackedRanges: new Map,
451112
451932
  progress: { storyTrackedCursor: 0 },
451113
451933
  paragraphBlocks: paragraphBlocks2,
@@ -451129,6 +451949,13 @@ function visitProjectionParagraph(state, paragraph4) {
451129
451949
  blockId: paragraph4.blockId,
451130
451950
  visibleOffsets: requestedVisibleOffsets
451131
451951
  });
451952
+ for (const point3 of tokenRead.emptyInlineDeletions ?? []) {
451953
+ state.emptyDeletionPoints.set(point3.byteStart, {
451954
+ blockId: paragraph4.blockId,
451955
+ byteEnd: point3.byteEnd,
451956
+ trackedOffset: point3.trackedOffset
451957
+ });
451958
+ }
451132
451959
  visibleToTracked.set(paragraph4.blockId, tokenRead.visibleOffsetsInTrackedSpace);
451133
451960
  paragraphTrackedRanges.set(paragraph4.blockId, {
451134
451961
  storyStart: progress.storyTrackedCursor,
@@ -451233,6 +452060,7 @@ function finishProjectionBuild(state) {
451233
452060
  async function finishProjectionBuildCooperatively(state, sliceGate) {
451234
452061
  const { context, input, packageRevision, evaluatedRevision, reviewMode, storyLocator, resolved, overlay, paragraphs: paragraphs3, tables: tables2, nestedTables, comments, tokenSource, diagnostics, visibleToTracked, paragraphTrackedRanges, paragraphBlocks: paragraphBlocks2, paragraphOrder, paragraphBoundaryMerges } = state;
451235
452062
  const projectedParagraphBlocks = await applyParagraphBoundaryMergesCooperatively(paragraphBlocks2, paragraphBoundaryMerges, diagnostics, storyLocator, sliceGate);
452063
+ const tableDiagnosticSourceIds = new Map;
451236
452064
  const wholeStoryBlocks = await assembleStoryBlocksCooperatively({
451237
452065
  paragraphs: paragraphs3,
451238
452066
  paragraphBlocks: projectedParagraphBlocks,
@@ -451242,19 +452070,12 @@ async function finishProjectionBuildCooperatively(state, sliceGate) {
451242
452070
  overlay,
451243
452071
  reviewMode,
451244
452072
  story: storyLocator,
451245
- diagnostics
452073
+ diagnostics,
452074
+ tableDiagnosticSourceIds
451246
452075
  }, sliceGate);
451247
452076
  for (const unsupported4 of overlay.unsupported) {
451248
452077
  if (unsupported4.storyId === resolved.storyId) {
451249
- diagnostics.push(projectionDiagnostic({
451250
- code: "projection-unsupported-construct",
451251
- severity: "warning",
451252
- message: "A malformed tracked-change carrier could not be projected semantically.",
451253
- construct: "trackedChange",
451254
- disposition: "placeholder",
451255
- lossy: true,
451256
- story: storyLocator
451257
- }));
452078
+ diagnostics.push(unsupportedProjectionDiagnostic(unsupported4, state));
451258
452079
  }
451259
452080
  await sliceGate();
451260
452081
  }
@@ -451314,7 +452135,8 @@ async function finishProjectionBuildCooperatively(state, sliceGate) {
451314
452135
  sourceLocalRanges,
451315
452136
  sourceStoryTrackedRanges
451316
452137
  }, sliceGate);
451317
- const sortedDiagnostics = await sortProjectionDiagnosticsCooperatively(diagnostics, sliceGate);
452138
+ const scopedDiagnostics = await projectionDiagnosticsInScopeCooperatively(diagnostics, scopePlan, blocks, paragraphOrder, sliceGate, { sourceIdsByDiagnostic: tableDiagnosticSourceIds, selectedSourceBlocks: sourceBlockRanges });
452139
+ const sortedDiagnostics = await sortProjectionDiagnosticsCooperatively(scopedDiagnostics, sliceGate);
451318
452140
  return {
451319
452141
  status: "success",
451320
452142
  model: {
@@ -451344,6 +452166,7 @@ function* finishProjectionBuildSteps(state) {
451344
452166
  const { context, input, packageRevision, evaluatedRevision, reviewMode, storyLocator, resolved, overlay, paragraphs: paragraphs3, tables: tables2, nestedTables, comments, tokenSource, diagnostics, visibleToTracked, paragraphTrackedRanges, paragraphBlocks: paragraphBlocks2, paragraphOrder, paragraphBoundaryMerges } = state;
451345
452167
  const projectedParagraphBlocks = applyParagraphBoundaryMerges(paragraphBlocks2, paragraphBoundaryMerges, diagnostics, storyLocator);
451346
452168
  yield;
452169
+ const tableDiagnosticSourceIds = new Map;
451347
452170
  const wholeStoryBlocks = assembleStoryBlocks({
451348
452171
  tablePresentations: state.tablePresentations,
451349
452172
  paragraphs: paragraphs3,
@@ -451353,21 +452176,14 @@ function* finishProjectionBuildSteps(state) {
451353
452176
  overlay,
451354
452177
  reviewMode,
451355
452178
  story: storyLocator,
451356
- diagnostics
452179
+ diagnostics,
452180
+ tableDiagnosticSourceIds
451357
452181
  });
451358
452182
  yield;
451359
452183
  for (const unsupported4 of overlay.unsupported) {
451360
452184
  if (unsupported4.storyId !== resolved.storyId)
451361
452185
  continue;
451362
- diagnostics.push(projectionDiagnostic({
451363
- code: "projection-unsupported-construct",
451364
- severity: "warning",
451365
- message: "A malformed tracked-change carrier could not be projected semantically.",
451366
- construct: "trackedChange",
451367
- disposition: "placeholder",
451368
- lossy: true,
451369
- story: storyLocator
451370
- }));
452186
+ diagnostics.push(unsupportedProjectionDiagnostic(unsupported4, state));
451371
452187
  }
451372
452188
  yield;
451373
452189
  const scopePlan = normalizeProjectionScope({
@@ -451417,6 +452233,7 @@ function* finishProjectionBuildSteps(state) {
451417
452233
  sourceStoryTrackedRanges
451418
452234
  });
451419
452235
  yield;
452236
+ const scopedDiagnostics = projectionDiagnosticsInScope(diagnostics, scopePlan, blocks, paragraphOrder, { sourceIdsByDiagnostic: tableDiagnosticSourceIds, selectedSourceBlocks: sourceBlockRanges });
451420
452237
  const model = {
451421
452238
  version: "sd-content-projection-ir/1",
451422
452239
  evaluatedRevision,
@@ -451431,7 +452248,7 @@ function* finishProjectionBuildSteps(state) {
451431
452248
  scope: scopePlan.resolved,
451432
452249
  blocks,
451433
452250
  annotations,
451434
- diagnostics: sortProjectionDiagnostics(diagnostics),
452251
+ diagnostics: sortProjectionDiagnostics(scopedDiagnostics),
451435
452252
  counters: {
451436
452253
  paragraphsVisited: paragraphs3.length,
451437
452254
  inlineMapsBuilt: tokenSource.telemetry.inlineMapsBuilt,
@@ -451440,6 +452257,50 @@ function* finishProjectionBuildSteps(state) {
451440
452257
  };
451441
452258
  return { status: "success", model };
451442
452259
  }
452260
+ function unsupportedProjectionMessage(reason) {
452261
+ switch (reason) {
452262
+ case "empty-or-self-closing-wrapper":
452263
+ return "An empty tracked-change marker could not be projected semantically.";
452264
+ case "nested-same-kind-wrapper":
452265
+ case "structural-content-wrapper":
452266
+ return "A tracked-change carrier with an unsupported structure could not be projected semantically.";
452267
+ case "malformed-wrapper":
452268
+ case "malformed-formatting-wrapper":
452269
+ return "A malformed tracked-change carrier could not be projected semantically.";
452270
+ }
452271
+ }
452272
+ function unsupportedProjectionDiagnostic(fact, state) {
452273
+ const blockId = unsupportedProjectionBlockId(fact, state.paragraphs);
452274
+ const point3 = fact.reason === "empty-or-self-closing-wrapper" ? state.emptyDeletionPoints.get(fact.sourceByteStart) : undefined;
452275
+ const range2 = point3 && point3.blockId === blockId && point3.byteEnd === fact.sourceByteEnd ? { start: point3.trackedOffset, end: point3.trackedOffset } : undefined;
452276
+ return projectionDiagnostic({
452277
+ code: "projection-unsupported-construct",
452278
+ severity: "warning",
452279
+ message: unsupportedProjectionMessage(fact.reason),
452280
+ construct: "trackedChange",
452281
+ disposition: "placeholder",
452282
+ lossy: true,
452283
+ story: state.storyLocator,
452284
+ blockId,
452285
+ range: range2
452286
+ });
452287
+ }
452288
+ function unsupportedProjectionBlockId(fact, paragraphs3) {
452289
+ if (fact.sourceByteStart < 0 || fact.sourceByteEnd < fact.sourceByteStart)
452290
+ return;
452291
+ let low = 0;
452292
+ let high = paragraphs3.length;
452293
+ while (low < high) {
452294
+ const middle = Math.floor((low + high) / 2);
452295
+ const paragraph5 = paragraphs3[middle];
452296
+ if (paragraph5 && paragraph5.byteStart <= fact.sourceByteStart)
452297
+ low = middle + 1;
452298
+ else
452299
+ high = middle;
452300
+ }
452301
+ const paragraph4 = paragraphs3[low - 1];
452302
+ return paragraph4 && paragraph4.partUri === fact.partUri && paragraph4.byteEnd >= fact.sourceByteEnd ? paragraph4.blockId : undefined;
452303
+ }
451443
452304
  function sourceParagraphsForScope(paragraphs3, tables2, scopePlan, paragraphOrder) {
451444
452305
  if (scopePlan.resolved.kind === "story")
451445
452306
  return [...paragraphs3];
@@ -453296,13 +454157,15 @@ function projectTable(input, table, container) {
453296
454157
  const paragraphs3 = sourceParagraphs.map((paragraph4) => input.paragraphBlocks.get(paragraph4.blockId)).filter((block) => block != null);
453297
454158
  const changeIds = uniqueSorted2(reviewFacts.map((fact) => fact.reviewOwnerId));
453298
454159
  const diagnostic2 = nestedTableReviewDiagnostic(input, container, changeIds);
454160
+ const sourceBlockIds = sourceParagraphs.map((paragraph4) => paragraph4.blockId);
453299
454161
  input.diagnostics.push(diagnostic2);
454162
+ input.tableDiagnosticSourceIds.set(diagnostic2, sourceBlockIds);
453300
454163
  return {
453301
454164
  kind: "placeholder",
453302
454165
  role: "unsupportedTable",
453303
454166
  text: paragraphs3.map(projectionBlockPlainText).filter(Boolean).join(`
453304
454167
  `),
453305
- sourceBlockIds: sourceParagraphs.map((paragraph4) => paragraph4.blockId),
454168
+ sourceBlockIds,
453306
454169
  nodeType: "table",
453307
454170
  identity: nestedTableIdentity(),
453308
454171
  ...containerParentBlockId(container),
@@ -453314,7 +454177,8 @@ function projectTable(input, table, container) {
453314
454177
  }
453315
454178
  const topologyFacts = container ? [] : tableTopologyFacts(input.overlay, table);
453316
454179
  if (input.reviewMode === "original" && topologyFacts.length > 0) {
453317
- const paragraphs3 = paragraphsWithinRange2(input.paragraphs, table.tableByteStart, table.tableByteEnd).map((paragraph4) => input.paragraphBlocks.get(paragraph4.blockId)).filter((block) => block != null);
454180
+ const sourceParagraphs = paragraphsWithinRange2(input.paragraphs, table.tableByteStart, table.tableByteEnd);
454181
+ const paragraphs3 = sourceParagraphs.map((paragraph4) => input.paragraphBlocks.get(paragraph4.blockId)).filter((block) => block != null);
453318
454182
  const diagnostic2 = projectionDiagnostic({
453319
454183
  code: "projection-unsupported-construct",
453320
454184
  severity: "warning",
@@ -453327,6 +454191,7 @@ function projectTable(input, table, container) {
453327
454191
  changeIds: topologyFacts.map((fact) => fact.reviewOwnerId)
453328
454192
  });
453329
454193
  input.diagnostics.push(diagnostic2);
454194
+ input.tableDiagnosticSourceIds.set(diagnostic2, sourceParagraphs.map((paragraph4) => paragraph4.blockId));
453330
454195
  return {
453331
454196
  kind: "placeholder",
453332
454197
  role: "unsupportedTable",
@@ -453345,6 +454210,7 @@ function projectTable(input, table, container) {
453345
454210
  return null;
453346
454211
  const presentation = input.tablePresentations.get(table.tableByteStart);
453347
454212
  const rows = [];
454213
+ const borderSourceIds = [];
453348
454214
  for (const row of table.rows) {
453349
454215
  const rowIdentity = container ? nestedTableIdentity() : identity(row);
453350
454216
  const rowReview = structuralNodeReview(input.overlay, "row", row.rowNodeId, table.storyId, row.rowByteStart, row.rowByteEnd, input.nestedTables, input.reviewMode, !container);
@@ -453353,6 +454219,10 @@ function projectTable(input, table, container) {
453353
454219
  const rowPresentation = presentation?.rows.get(row.rowByteStart);
453354
454220
  const cells = [];
453355
454221
  for (const cell of row.cells) {
454222
+ if (presentation?.unrepresentedBorderCells.has(cell.cellByteStart)) {
454223
+ for (const paragraph4 of paragraphsWithinRange2(input.paragraphs, cell.bodyByteStart, cell.bodyByteEnd))
454224
+ borderSourceIds.push(paragraph4.blockId);
454225
+ }
453356
454226
  const cellReview = structuralNodeReview(input.overlay, "cell", cell.cellNodeId, table.storyId, cell.cellByteStart, cell.cellByteEnd, input.nestedTables, input.reviewMode, !container);
453357
454227
  if (cell.vMerge === "continue" || cellReview.omit)
453358
454228
  continue;
@@ -453401,17 +454271,11 @@ function projectTable(input, table, container) {
453401
454271
  changeIds: topologyFacts.map((fact) => fact.reviewOwnerId)
453402
454272
  })
453403
454273
  ] : [];
453404
- if (presentation?.unrepresentedBorderSegments)
453405
- topologyDiagnostics.push(projectionDiagnostic({
453406
- code: "projection-unsupported-construct",
453407
- severity: "warning",
453408
- message: "Some merged-cell border segments cannot be represented without overlapping authored borders.",
453409
- construct: "table",
453410
- disposition: "downgraded",
453411
- lossy: true,
453412
- story: input.story,
453413
- blockId: tableIdentity.identity === "public" ? tableIdentity.blockId : undefined
453414
- }));
454274
+ if (presentation?.unrepresentedBorderSegments) {
454275
+ const diagnostic2 = tableBorderDiagnostic(tableIdentity, input.story);
454276
+ topologyDiagnostics.push(diagnostic2);
454277
+ input.tableDiagnosticSourceIds.set(diagnostic2, borderSourceIds);
454278
+ }
453415
454279
  input.diagnostics.push(...topologyDiagnostics);
453416
454280
  return {
453417
454281
  kind: "table",
@@ -453432,6 +454296,18 @@ function projectTable(input, table, container) {
453432
454296
  diagnostics: topologyDiagnostics
453433
454297
  };
453434
454298
  }
454299
+ function tableBorderDiagnostic(tableIdentity, story) {
454300
+ return projectionDiagnostic({
454301
+ code: "projection-unsupported-construct",
454302
+ severity: "warning",
454303
+ message: "Some merged-cell border segments cannot be represented without overlapping authored borders.",
454304
+ construct: "table",
454305
+ disposition: "downgraded",
454306
+ lossy: true,
454307
+ story,
454308
+ blockId: tableIdentity.identity === "public" ? tableIdentity.blockId : undefined
454309
+ });
454310
+ }
453435
454311
  async function projectTableCooperatively(input, table, sliceGate, container) {
453436
454312
  if (container) {
453437
454313
  const reviewFacts = [];
@@ -453453,6 +454329,7 @@ async function projectTableCooperatively(input, table, sliceGate, container) {
453453
454329
  const changeIds = await uniqueSortedProjectionValuesCooperatively([reviewFacts.map((fact) => fact.reviewOwnerId)], sliceGate);
453454
454330
  const diagnostic2 = nestedTableReviewDiagnostic(input, container, changeIds);
453455
454331
  input.diagnostics.push(diagnostic2);
454332
+ input.tableDiagnosticSourceIds.set(diagnostic2, sourceBlockIds);
453456
454333
  const text4 = [];
453457
454334
  const commentIds = [];
453458
454335
  for (const paragraph4 of paragraphs3) {
@@ -453485,7 +454362,9 @@ async function projectTableCooperatively(input, table, sliceGate, container) {
453485
454362
  }
453486
454363
  if (input.reviewMode === "original" && topologyFacts.length > 0) {
453487
454364
  const paragraphs3 = [];
454365
+ const sourceBlockIds = [];
453488
454366
  for (const paragraph4 of await paragraphsWithinRangeCooperatively(input.paragraphs, table.tableByteStart, table.tableByteEnd, sliceGate)) {
454367
+ sourceBlockIds.push(paragraph4.blockId);
453489
454368
  const block = input.paragraphBlocks.get(paragraph4.blockId);
453490
454369
  if (block)
453491
454370
  paragraphs3.push(block);
@@ -453503,6 +454382,7 @@ async function projectTableCooperatively(input, table, sliceGate, container) {
453503
454382
  changeIds: topologyChangeIds
453504
454383
  });
453505
454384
  input.diagnostics.push(diagnostic2);
454385
+ input.tableDiagnosticSourceIds.set(diagnostic2, sourceBlockIds);
453506
454386
  const text4 = [];
453507
454387
  const commentIds = [];
453508
454388
  for (const paragraph4 of paragraphs3) {
@@ -453530,6 +454410,7 @@ async function projectTableCooperatively(input, table, sliceGate, container) {
453530
454410
  return null;
453531
454411
  const presentation = input.tablePresentations.get(table.tableByteStart);
453532
454412
  const rows = [];
454413
+ const borderSourceIds = [];
453533
454414
  for (const row of table.rows) {
453534
454415
  const rowIdentity = container ? nestedTableIdentity() : identity(row);
453535
454416
  const rowReview = await structuralNodeReviewCooperatively(input.overlay, "row", row.rowNodeId, table.storyId, row.rowByteStart, row.rowByteEnd, input.nestedTables, input.reviewMode, !container, sliceGate);
@@ -453540,6 +454421,12 @@ async function projectTableCooperatively(input, table, sliceGate, container) {
453540
454421
  const rowPresentation = presentation?.rows.get(row.rowByteStart);
453541
454422
  const cells = [];
453542
454423
  for (const cell of row.cells) {
454424
+ if (presentation?.unrepresentedBorderCells.has(cell.cellByteStart)) {
454425
+ for (const paragraph4 of await paragraphsWithinRangeCooperatively(input.paragraphs, cell.bodyByteStart, cell.bodyByteEnd, sliceGate)) {
454426
+ borderSourceIds.push(paragraph4.blockId);
454427
+ await sliceGate();
454428
+ }
454429
+ }
453543
454430
  const cellReview = await structuralNodeReviewCooperatively(input.overlay, "cell", cell.cellNodeId, table.storyId, cell.cellByteStart, cell.cellByteEnd, input.nestedTables, input.reviewMode, !container, sliceGate);
453544
454431
  if (cell.vMerge === "continue" || cellReview.omit) {
453545
454432
  await sliceGate();
@@ -453602,17 +454489,11 @@ async function projectTableCooperatively(input, table, sliceGate, container) {
453602
454489
  changeIds: topologyChangeIds
453603
454490
  })
453604
454491
  ] : [];
453605
- if (presentation?.unrepresentedBorderSegments)
453606
- topologyDiagnostics.push(projectionDiagnostic({
453607
- code: "projection-unsupported-construct",
453608
- severity: "warning",
453609
- message: "Some merged-cell border segments cannot be represented without overlapping authored borders.",
453610
- construct: "table",
453611
- disposition: "downgraded",
453612
- lossy: true,
453613
- story: input.story,
453614
- blockId: tableIdentity.identity === "public" ? tableIdentity.blockId : undefined
453615
- }));
454492
+ if (presentation?.unrepresentedBorderSegments) {
454493
+ const diagnostic2 = tableBorderDiagnostic(tableIdentity, input.story);
454494
+ topologyDiagnostics.push(diagnostic2);
454495
+ input.tableDiagnosticSourceIds.set(diagnostic2, borderSourceIds);
454496
+ }
453616
454497
  input.diagnostics.push(...topologyDiagnostics);
453617
454498
  const rowCommentIds = [];
453618
454499
  for (const row of rows) {
@@ -515605,6 +516486,7 @@ var init_parse_paragraph = __esm(() => {
515605
516486
  init_constants4();
515606
516487
  init_xml_namespace_scope();
515607
516488
  init_xml_sax();
516489
+ init_xml_tokens();
515608
516490
  init_symbol_character();
515609
516491
  init_direct_paragraph_list_properties();
515610
516492
  init_catalog3();
@@ -525060,6 +525942,7 @@ function readCommentTagAccount(commentXml, inheritedNamespaces = {}) {
525060
525942
  var XML_SAFE_TEXT, NAMED_ENTITIES;
525061
525943
  var init_comment_account = __esm(() => {
525062
525944
  init_xml_sax();
525945
+ init_xml_tokens();
525063
525946
  XML_SAFE_TEXT = /^[\u0009\u000A\u000D -퟿-�\u{10000}-\u{10FFFF}]*$/u;
525064
525947
  NAMED_ENTITIES = { quot: '"', apos: "'", lt: "<", gt: ">", amp: "&" };
525065
525948
  });
@@ -534743,6 +535626,7 @@ var init_package_xml = __esm(() => {
534743
535626
  init_diagnostics2();
534744
535627
  init_settings_field_order();
534745
535628
  init_xml_sax();
535629
+ init_xml_tokens();
534746
535630
  init_ooxml_namespaces();
534747
535631
  init_settings();
534748
535632
  init_canonical();
@@ -540334,11 +541218,30 @@ function normalizeLiveTrackedWrapperOverlap(atoms, namespaces) {
540334
541218
  const atomIndexes = new Map(atoms.map((atom, index2) => [atom, index2]));
540335
541219
  for (const [parentKey, children4] of foreignChildrenByParent) {
540336
541220
  const parent = spansByKey.get(parentKey);
540337
- if (parent && wrapsInlineContainerOutsideChildren(parent, children4, atoms, atomIndexes))
541221
+ if (!parent)
541222
+ continue;
541223
+ if (hasAtomOutsideChildren(parent, children4, atoms, atomIndexes, isInlineContainerWrapper))
540338
541224
  foreignChildrenByParent.delete(parentKey);
540339
541225
  }
540340
541226
  if (foreignChildrenByParent.size === 0)
540341
541227
  return [...atoms];
541228
+ const deletionsByOpen = new Map(spans.filter((span) => span.kind === "del").map((span) => [span.openAtom, span]));
541229
+ const hasRetainedMarkup = (parent, ownsOpaqueControl, from4, to) => {
541230
+ const start = atomIndexes.get(from4), end = atomIndexes.get(to);
541231
+ if (start === undefined || end === undefined)
541232
+ return false;
541233
+ return atoms.slice(start + 1, end).some((atom) => {
541234
+ if (isOpaqueControl(atom))
541235
+ return true;
541236
+ if (!ownsOpaqueControl)
541237
+ return false;
541238
+ const deletion = deletionsByOpen.get(atom);
541239
+ if (!deletion || deletion.parentKey !== parent.key)
541240
+ return false;
541241
+ const close = atomIndexes.get(deletion.closeAtom);
541242
+ return close !== undefined && close < end;
541243
+ });
541244
+ };
540342
541245
  const syntheticAtoms = [];
540343
541246
  const coveredParentEdges = new Set;
540344
541247
  const coveredEndChildren = new Map;
@@ -540346,6 +541249,7 @@ function normalizeLiveTrackedWrapperOverlap(atoms, namespaces) {
540346
541249
  const parent = spansByKey.get(parentKey);
540347
541250
  if (!parent)
540348
541251
  continue;
541252
+ const ownsOpaqueControl = hasAtomOutsideChildren(parent, children4, atoms, atomIndexes, isOpaqueControl);
540349
541253
  const orderedChildren = [...children4].sort((left, right) => {
540350
541254
  if (left.startOffset !== right.startOffset)
540351
541255
  return left.startOffset - right.startOffset;
@@ -540354,7 +541258,7 @@ function normalizeLiveTrackedWrapperOverlap(atoms, namespaces) {
540354
541258
  return left.key - right.key;
540355
541259
  });
540356
541260
  const firstChild = orderedChildren[0];
540357
- if (firstChild.startOffset > parent.startOffset || firstChild.startDrawingCount > parent.startDrawingCount) {
541261
+ if (firstChild.startOffset > parent.startOffset || firstChild.startDrawingCount > parent.startDrawingCount || hasRetainedMarkup(parent, ownsOpaqueControl, parent.openAtom, firstChild.openAtom)) {
540358
541262
  syntheticAtoms.push(makeSyntheticTrackedWrapperAtom(parent.closeAtom, firstChild.startOffset, firstChild.openAtom.sortOrder, firstChild.openAtom.sequence - 0.5));
540359
541263
  } else {
540360
541264
  coveredParentEdges.add(parent.openAtom);
@@ -540362,13 +541266,13 @@ function normalizeLiveTrackedWrapperOverlap(atoms, namespaces) {
540362
541266
  for (let index2 = 0;index2 < orderedChildren.length - 1; index2 += 1) {
540363
541267
  const current = orderedChildren[index2];
540364
541268
  const next = orderedChildren[index2 + 1];
540365
- if (current.endOffset > next.startOffset || current.endOffset === next.startOffset && current.endDrawingCount >= next.startDrawingCount)
541269
+ if (current.endOffset > next.startOffset || current.endOffset === next.startOffset && current.endDrawingCount >= next.startDrawingCount && !hasRetainedMarkup(parent, ownsOpaqueControl, current.closeAtom, next.openAtom))
540366
541270
  continue;
540367
541271
  syntheticAtoms.push(makeSyntheticTrackedWrapperAtom(parent.openAtom, current.endOffset, current.closeAtom.sortOrder, current.closeAtom.sequence + 0.5));
540368
541272
  syntheticAtoms.push(makeSyntheticTrackedWrapperAtom(parent.closeAtom, next.startOffset, next.openAtom.sortOrder, next.openAtom.sequence - 0.5));
540369
541273
  }
540370
541274
  const lastChild = orderedChildren[orderedChildren.length - 1];
540371
- if (lastChild.endOffset < parent.endOffset || lastChild.endDrawingCount < parent.endDrawingCount) {
541275
+ if (lastChild.endOffset < parent.endOffset || lastChild.endDrawingCount < parent.endDrawingCount || hasRetainedMarkup(parent, ownsOpaqueControl, lastChild.closeAtom, parent.closeAtom)) {
540372
541276
  syntheticAtoms.push(makeSyntheticTrackedWrapperAtom(parent.openAtom, lastChild.endOffset, lastChild.closeAtom.sortOrder, lastChild.closeAtom.sequence + 0.5));
540373
541277
  } else {
540374
541278
  coveredParentEdges.add(parent.closeAtom);
@@ -540408,13 +541312,19 @@ function normalizeLiveTrackedWrapperOverlap(atoms, namespaces) {
540408
541312
  ...syntheticAtoms
540409
541313
  ]);
540410
541314
  }
540411
- function wrapsInlineContainerOutsideChildren(parent, children4, atoms, atomIndexes) {
541315
+ function isInlineContainerWrapper(atom) {
541316
+ return atom.kind === INLINE_ATOM_KIND.preserved && INLINE_CONTAINER_WRAPPERS.has(atom.meta.wrapper);
541317
+ }
541318
+ function isOpaqueControl(atom) {
541319
+ return atom.kind === INLINE_ATOM_KIND.preserved && atom.meta.tag === "sdt";
541320
+ }
541321
+ function hasAtomOutsideChildren(parent, children4, atoms, atomIndexes, matches2) {
540412
541322
  const indexOf = (atom) => atomIndexes.get(atom) ?? -1;
540413
541323
  const childRanges = children4.map((child) => [indexOf(child.openAtom), indexOf(child.closeAtom)]);
540414
541324
  const parentClose = indexOf(parent.closeAtom);
540415
541325
  for (let index2 = indexOf(parent.openAtom) + 1;index2 < parentClose; index2 += 1) {
540416
541326
  const atom = atoms[index2];
540417
- if (atom?.kind !== INLINE_ATOM_KIND.preserved || !INLINE_CONTAINER_WRAPPERS.has(atom.meta.wrapper))
541327
+ if (!atom || !matches2(atom))
540418
541328
  continue;
540419
541329
  if (!childRanges.some(([open2, close]) => index2 > open2 && index2 < close))
540420
541330
  return true;