@superdoc/mcp 1.4.0-next.6 → 1.4.0-next.8

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 +416 -206
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -31330,10 +31330,10 @@ var init_host = __esm(() => {
31330
31330
  });
31331
31331
 
31332
31332
  // ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
31333
- var SDK_VERSION = "2.17.0-next.6";
31333
+ var SDK_VERSION = "2.17.0-next.8";
31334
31334
 
31335
31335
  // ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
31336
- import { chmodSync, existsSync } from "node:fs";
31336
+ import { accessSync, chmodSync, constants, existsSync, statSync } from "node:fs";
31337
31337
  import { createRequire as createRequire2 } from "node:module";
31338
31338
  import path from "node:path";
31339
31339
  import { fileURLToPath } from "node:url";
@@ -31387,7 +31387,15 @@ function ensureEmbeddedExecutable(binaryPath) {
31387
31387
  if (process.platform === "win32")
31388
31388
  return;
31389
31389
  try {
31390
- chmodSync(binaryPath, 493);
31390
+ accessSync(binaryPath, constants.X_OK);
31391
+ return;
31392
+ } catch {}
31393
+ let mode = 493;
31394
+ try {
31395
+ mode = statSync(binaryPath).mode & 4095 | 73;
31396
+ } catch {}
31397
+ try {
31398
+ chmodSync(binaryPath, mode);
31391
31399
  } catch {}
31392
31400
  }
31393
31401
  var require2, TARGET_TO_PACKAGE, TARGET_TO_DIR;
@@ -153497,10 +153505,12 @@ var init_content_types = __esm(() => {
153497
153505
 
153498
153506
  // ../../../v2/editor-core/dist/opc/package-open.js
153499
153507
  function isCompleteOpenedPartBytes(opened, partUri, bytes) {
153500
- if (!bytes || bytes.byteLength === 0)
153508
+ if (!bytes)
153501
153509
  return false;
153502
153510
  const expected = opened.parts.get(normalizePartUri(partUri))?.uncompressedSize;
153503
- return typeof expected !== "number" || expected <= 0 || bytes.byteLength === expected;
153511
+ if (bytes.byteLength === 0)
153512
+ return expected === 0;
153513
+ return typeof expected !== "number" || expected < 0 || bytes.byteLength === expected;
153504
153514
  }
153505
153515
  function readCompleteOpenedPartBytes(opened, partUri) {
153506
153516
  const fromZip = opened.zip.readPayload(partUri);
@@ -203109,6 +203119,101 @@ var init_paragraph_property_history = __esm(() => {
203109
203119
  init_paragraph_property_namespaces();
203110
203120
  });
203111
203121
 
203122
+ // ../../../v2/editor-core/dist/document/transactions/tracked-paragraph-properties.js
203123
+ function readParagraphProperties(xml, namespaceBindings) {
203124
+ const prefix = [...namespaceBindings].find(([key2, uri]) => key2 && uri === NS_W)?.[0] ?? "w";
203125
+ const source = xml || `<${prefix}:pPr/>`;
203126
+ const parsed = collectXmlElementRanges(source, {
203127
+ fragment: true,
203128
+ additionalNamespaces: Object.fromEntries(namespaceBindings)
203129
+ });
203130
+ const ranges = parsed.ranges.sort((a, b) => a.start - b.start || b.end - a.end);
203131
+ const root = ranges[0];
203132
+ if (parsed.errors.length || !root || root.start !== 0 || root.end !== source.length || root.tag.namespaceUri !== NS_W || root.tag.localName !== "pPr")
203133
+ return null;
203134
+ if (ranges.some((range) => range.tag.namespaceUri === NS_W && ["ins", "del", "moveFrom", "moveTo", "pPrChange", "rPrChange", "sectPr"].includes(range.tag.localName)))
203135
+ return null;
203136
+ const children = [];
203137
+ let cursor = root.openEnd;
203138
+ for (const range of ranges.slice(1)) {
203139
+ if (range.start < cursor)
203140
+ continue;
203141
+ if (source.slice(cursor, range.start).trim())
203142
+ return null;
203143
+ children.push(range);
203144
+ cursor = range.end;
203145
+ }
203146
+ const marks = children.filter((child) => child.tag.namespaceUri === NS_W && child.tag.localName === "rPr");
203147
+ if (marks.length > 1)
203148
+ return null;
203149
+ const mark = marks[0];
203150
+ const baseChildren = children.filter((child) => child !== mark).map((child) => source.slice(child.start, child.end)).join("");
203151
+ return {
203152
+ source,
203153
+ root,
203154
+ mark,
203155
+ markXml: mark ? source.slice(mark.start, mark.end) : "",
203156
+ baseChildren
203157
+ };
203158
+ }
203159
+ function isSafeTrackedParagraphProperties(xml, namespaceBindings) {
203160
+ return readParagraphProperties(xml, namespaceBindings) !== null;
203161
+ }
203162
+ function prepareTrackedParagraphProperties(input) {
203163
+ const prefix = [...input.namespaceBindings].find(([key2, uri]) => key2 && uri === NS_W)?.[0] ?? "w";
203164
+ const before = readParagraphProperties(input.beforeXml, input.namespaceBindings);
203165
+ const after = readParagraphProperties(input.afterXml, input.namespaceBindings);
203166
+ if (!before || !after)
203167
+ return null;
203168
+ const wordIds = [];
203169
+ const markBindings = after.mark?.namespaceBindings ?? after.root.namespaceBindings;
203170
+ const wrapperBindings = (kind) => ({
203171
+ ...kind === "rPr" ? markBindings : after.root.namespaceBindings,
203172
+ [prefix]: NS_W
203173
+ });
203174
+ const wrapper = (kind, old) => {
203175
+ const id = input.stamp.revisionIds?.[wordIds.length] ?? input.stamp.revisionId + wordIds.length;
203176
+ if (input.stamp.revisionIds && wordIds.length >= input.stamp.revisionIds.length)
203177
+ return null;
203178
+ wordIds.push(String(id));
203179
+ const namespace = (kind === "rPr" ? markBindings : after.root.namespaceBindings)[prefix] === NS_W ? "" : ` xmlns:${prefix}="${NS_W}"`;
203180
+ return `<${prefix}:${kind}Change${namespace} ${prefix}:id="${id}" ${prefix}:author="${escapeXmlAttribute(input.stamp.author.name)}" ${prefix}:date="${escapeXmlAttribute(input.stamp.date)}">${old}</${prefix}:${kind}Change>`;
203181
+ };
203182
+ let mark = after.markXml;
203183
+ if (before.markXml !== after.markXml) {
203184
+ const oldMark = before.mark ? copyParagraphPropertyChild(before.source, before.mark, wrapperBindings("rPr")) : `<${prefix}:rPr/>`;
203185
+ const change = wrapper("rPr", oldMark);
203186
+ if (!change)
203187
+ return null;
203188
+ if (!after.mark || after.mark.tag.isSelfClosing) {
203189
+ const open = after.mark ? after.markXml.replace(/\/>$/, ">") : `<${prefix}:rPr>`;
203190
+ mark = open + change + `</${after.mark?.tag.name ?? `${prefix}:rPr`}>`;
203191
+ } else {
203192
+ const at = after.mark.closeStart - after.mark.start;
203193
+ mark = after.markXml.slice(0, at) + change + after.markXml.slice(at);
203194
+ }
203195
+ }
203196
+ let paragraphChange = "";
203197
+ if (before.baseChildren !== after.baseChildren) {
203198
+ const oldProperties = paragraphPropertyOpeningWithNamespaces(before.source, before.root, wrapperBindings("pPr")).replace(/\/>$/, ">") + before.baseChildren + `</${before.root.tag.name}>`;
203199
+ const change = wrapper("pPr", oldProperties);
203200
+ if (!change)
203201
+ return null;
203202
+ paragraphChange = change;
203203
+ }
203204
+ if (wordIds.length === 0)
203205
+ return { xml: input.afterXml, wordIds };
203206
+ return {
203207
+ xml: after.source.slice(0, after.root.openEnd).replace(/\/>$/, ">") + after.baseChildren + mark + paragraphChange + `</${after.root.tag.name}>`,
203208
+ wordIds
203209
+ };
203210
+ }
203211
+ var init_tracked_paragraph_properties = __esm(() => {
203212
+ init_xml_sax();
203213
+ init_xml_text();
203214
+ init_paragraph_property_namespaces();
203215
+ });
203216
+
203112
203217
  // ../../../v2/editor-core/dist/document/transactions/tracked-changes/review-decision-semantics.js
203113
203218
  function structuralDecisionBehavior(kind, decision) {
203114
203219
  if (kind === "paragraph-mark-deletion" && decision === "accept" || kind === "paragraph-mark-insertion" && decision === "reject" || kind === "section-break-deletion" && decision === "accept")
@@ -203678,7 +203783,7 @@ function mergeParagraphMarkedBoundary(lookupContext, xml, fragment3, namespaceBi
203678
203783
  return { ok: false, reason: "unsupported-context" };
203679
203784
  }
203680
203785
  const pendingInsertionTerminalDeletion = fragment3.structuralKind === "paragraph-mark-deletion" && isPendingFullParagraphInsertion(currentWithoutMarker, fragment3.tagPrefix);
203681
- const merged = fragment3.structuralKind === "paragraph-mark-insertion" ? mergeParagraphXmlKeepingFirstForDecision(currentWithoutMarker, next.xml) : pendingInsertionTerminalDeletion ? mergeParagraphXmlKeepingPendingInsertion(currentWithoutMarker, next.xml) : next.wrapper ? mergeParagraphXmlForDecisionWithWrappedSuccessor(currentWithoutMarker, next.xml, next.wrapper) : mergeParagraphXmlForDecision(currentWithoutMarker, next.xml);
203786
+ const merged = fragment3.structuralKind === "paragraph-mark-insertion" ? mergeParagraphXmlKeepingFirstForDecision(currentWithoutMarker, next.xml) : pendingInsertionTerminalDeletion ? mergeParagraphXmlKeepingPendingInsertion(currentWithoutMarker, next.xml, effectiveNamespaceBindings) : next.wrapper ? mergeParagraphXmlForDecisionWithWrappedSuccessor(currentWithoutMarker, next.xml, next.wrapper) : mergeParagraphXmlForDecision(currentWithoutMarker, next.xml);
203682
203787
  if (!merged)
203683
203788
  return { ok: false, reason: "invalid-input" };
203684
203789
  return {
@@ -203891,7 +203996,7 @@ function mergeParagraphXmlForDecisionWithWrappedSuccessor(firstXml, secondXml, w
203891
203996
  return null;
203892
203997
  return secondOpenMatch[0] + secondPPr + firstRuns + wrapper.openTag + secondRuns + wrapper.closeTag + secondCloseMatch[0];
203893
203998
  }
203894
- function mergeParagraphXmlKeepingPendingInsertion(firstXml, secondXml) {
203999
+ function mergeParagraphXmlKeepingPendingInsertion(firstXml, secondXml, namespaceBindings) {
203895
204000
  firstXml = expandEmptyParagraphForMerge(firstXml);
203896
204001
  secondXml = expandEmptyParagraphForMerge(secondXml);
203897
204002
  const firstOpenMatch = firstXml.match(/^<[\w.-]+:p\b[^>]*>/);
@@ -203904,9 +204009,14 @@ function mergeParagraphXmlKeepingPendingInsertion(firstXml, secondXml) {
203904
204009
  const secondInner = secondXml.slice(secondOpenMatch[0].length, secondXml.length - secondCloseMatch[0].length);
203905
204010
  const firstPPr = matchLeadingElement(firstInner, "pPr");
203906
204011
  const secondPPr = matchLeadingElement(secondInner, "pPr");
203907
- if (!firstPPr || secondPPr)
204012
+ const parsedSecond = collectXmlElementRanges(secondXml, {
204013
+ fragment: true,
204014
+ additionalNamespaces: xmlFragmentAdditionalNamespaces(secondXml, new Map(Object.entries(namespaceBindings)))
204015
+ });
204016
+ const secondRoot = parsedSecond.ranges.find((range) => range.start === 0 && range.end === secondXml.length);
204017
+ if (!firstPPr || parsedSecond.errors.length || !secondRoot || !isSafeTrackedParagraphProperties(secondPPr, new Map(Object.entries(secondRoot.namespaceBindings))))
203908
204018
  return null;
203909
- return firstOpenMatch[0] + firstPPr + firstInner.slice(firstPPr.length) + secondInner + firstCloseMatch[0];
204019
+ return firstOpenMatch[0] + firstPPr + firstInner.slice(firstPPr.length) + secondInner.slice(secondPPr.length) + firstCloseMatch[0];
203910
204020
  }
203911
204021
  function isPendingFullParagraphInsertion(paragraphXml, prefix) {
203912
204022
  const parsed = collectXmlElementRanges(paragraphXml, {
@@ -205041,6 +205151,7 @@ var init_decide_engine = __esm(() => {
205041
205151
  init_paragraph_mark_format_history();
205042
205152
  init_paragraph_property_history();
205043
205153
  init_paragraph_property_namespaces();
205154
+ init_tracked_paragraph_properties();
205044
205155
  init_structural_groups();
205045
205156
  init_paragraph_property_block();
205046
205157
  init_block_deletion_text();
@@ -213037,97 +213148,6 @@ var init_tracked_block_replacement = __esm(() => {
213037
213148
  init_tracked_table_replacement();
213038
213149
  });
213039
213150
 
213040
- // ../../../v2/editor-core/dist/document/transactions/tracked-paragraph-properties.js
213041
- function prepareTrackedParagraphProperties(input) {
213042
- const prefix = [...input.namespaceBindings].find(([key2, uri]) => key2 && uri === NS_W)?.[0] ?? "w";
213043
- const read = (xml) => {
213044
- const source = xml || `<${prefix}:pPr/>`;
213045
- const parsed = collectXmlElementRanges(source, {
213046
- fragment: true,
213047
- additionalNamespaces: Object.fromEntries(input.namespaceBindings)
213048
- });
213049
- const ranges = parsed.ranges.sort((a, b) => a.start - b.start || b.end - a.end);
213050
- const root = ranges[0];
213051
- if (parsed.errors.length || !root || root.start !== 0 || root.end !== source.length || root.tag.namespaceUri !== NS_W || root.tag.localName !== "pPr")
213052
- return null;
213053
- if (ranges.some((range) => range.tag.namespaceUri === NS_W && ["ins", "del", "moveFrom", "moveTo", "pPrChange", "rPrChange", "sectPr"].includes(range.tag.localName)))
213054
- return null;
213055
- const children = [];
213056
- let cursor = root.openEnd;
213057
- for (const range of ranges.slice(1)) {
213058
- if (range.start < cursor)
213059
- continue;
213060
- if (source.slice(cursor, range.start).trim())
213061
- return null;
213062
- children.push(range);
213063
- cursor = range.end;
213064
- }
213065
- const marks = children.filter((child) => child.tag.namespaceUri === NS_W && child.tag.localName === "rPr");
213066
- if (marks.length > 1)
213067
- return null;
213068
- const mark2 = marks[0];
213069
- const baseChildren = children.filter((child) => child !== mark2).map((child) => source.slice(child.start, child.end)).join("");
213070
- return {
213071
- source,
213072
- root,
213073
- mark: mark2,
213074
- markXml: mark2 ? source.slice(mark2.start, mark2.end) : "",
213075
- baseChildren
213076
- };
213077
- };
213078
- const before = read(input.beforeXml);
213079
- const after = read(input.afterXml);
213080
- if (!before || !after)
213081
- return null;
213082
- const wordIds = [];
213083
- const markBindings = after.mark?.namespaceBindings ?? after.root.namespaceBindings;
213084
- const wrapperBindings = (kind) => ({
213085
- ...kind === "rPr" ? markBindings : after.root.namespaceBindings,
213086
- [prefix]: NS_W
213087
- });
213088
- const wrapper = (kind, old) => {
213089
- const id = input.stamp.revisionIds?.[wordIds.length] ?? input.stamp.revisionId + wordIds.length;
213090
- if (input.stamp.revisionIds && wordIds.length >= input.stamp.revisionIds.length)
213091
- return null;
213092
- wordIds.push(String(id));
213093
- const namespace = (kind === "rPr" ? markBindings : after.root.namespaceBindings)[prefix] === NS_W ? "" : ` xmlns:${prefix}="${NS_W}"`;
213094
- return `<${prefix}:${kind}Change${namespace} ${prefix}:id="${id}" ${prefix}:author="${escapeXmlAttribute(input.stamp.author.name)}" ${prefix}:date="${escapeXmlAttribute(input.stamp.date)}">${old}</${prefix}:${kind}Change>`;
213095
- };
213096
- let mark = after.markXml;
213097
- if (before.markXml !== after.markXml) {
213098
- const oldMark = before.mark ? copyParagraphPropertyChild(before.source, before.mark, wrapperBindings("rPr")) : `<${prefix}:rPr/>`;
213099
- const change = wrapper("rPr", oldMark);
213100
- if (!change)
213101
- return null;
213102
- if (!after.mark || after.mark.tag.isSelfClosing) {
213103
- const open = after.mark ? after.markXml.replace(/\/>$/, ">") : `<${prefix}:rPr>`;
213104
- mark = open + change + `</${after.mark?.tag.name ?? `${prefix}:rPr`}>`;
213105
- } else {
213106
- const at = after.mark.closeStart - after.mark.start;
213107
- mark = after.markXml.slice(0, at) + change + after.markXml.slice(at);
213108
- }
213109
- }
213110
- let paragraphChange = "";
213111
- if (before.baseChildren !== after.baseChildren) {
213112
- const oldProperties = paragraphPropertyOpeningWithNamespaces(before.source, before.root, wrapperBindings("pPr")).replace(/\/>$/, ">") + before.baseChildren + `</${before.root.tag.name}>`;
213113
- const change = wrapper("pPr", oldProperties);
213114
- if (!change)
213115
- return null;
213116
- paragraphChange = change;
213117
- }
213118
- if (wordIds.length === 0)
213119
- return { xml: input.afterXml, wordIds };
213120
- return {
213121
- xml: after.source.slice(0, after.root.openEnd).replace(/\/>$/, ">") + after.baseChildren + mark + paragraphChange + `</${after.root.tag.name}>`,
213122
- wordIds
213123
- };
213124
- }
213125
- var init_tracked_paragraph_properties = __esm(() => {
213126
- init_xml_sax();
213127
- init_xml_text();
213128
- init_paragraph_property_namespaces();
213129
- });
213130
-
213131
213151
  // ../../../v2/editor-core/dist/document/transactions/tracked-terminal-paragraph-delete.js
213132
213152
  function prepareTrackedTerminalParagraphDeletion(input) {
213133
213153
  const read = (xml, namespaces) => {
@@ -213157,7 +213177,7 @@ function prepareTrackedTerminalParagraphDeletion(input) {
213157
213177
  if (!previous || !current)
213158
213178
  return null;
213159
213179
  const pendingInsertion = (() => {
213160
- if (!previous.properties || current.propertiesXml || !previous.runs.trim())
213180
+ if (!previous.properties || !previous.runs.trim())
213161
213181
  return false;
213162
213182
  const properties2 = collectXmlElementRanges(previous.propertiesXml, {
213163
213183
  fragment: true,
@@ -213184,6 +213204,8 @@ function prepareTrackedTerminalParagraphDeletion(input) {
213184
213204
  return parsedContent.errors.length === 0 && contentRanges.length > 0 && contentRoot?.start === 0 && contentRoot.end === content.length && contentRoot.tag.namespaceUri === NS_W && contentRoot.tag.localName === "ins";
213185
213205
  })();
213186
213206
  if (pendingInsertion) {
213207
+ if (!isSafeTrackedParagraphProperties(current.propertiesXml, new Map(Object.entries(current.root.namespaceBindings))))
213208
+ return null;
213187
213209
  const ids2 = input.stamp.revisionIds ?? [input.stamp.revisionId, input.stamp.revisionId + 1];
213188
213210
  if (ids2.length < 2)
213189
213211
  return null;
@@ -213207,7 +213229,7 @@ function prepareTrackedTerminalParagraphDeletion(input) {
213207
213229
  return null;
213208
213230
  return {
213209
213231
  previousXml: previous.opening + previousProperties + previous.runs + previous.closing,
213210
- currentXml: current.opening + deleted2.xml + current.closing,
213232
+ currentXml: current.opening + current.propertiesXml + deleted2.xml + current.closing,
213211
213233
  wordIds: [String(ids2[0]), ...deleted2.wordIds]
213212
213234
  };
213213
213235
  }
@@ -316550,9 +316572,9 @@ var init_codes = __esm(() => {
316550
316572
  });
316551
316573
 
316552
316574
  // ../../../v2/node_modules/.pnpm/micromark-util-symbol@2.0.1/node_modules/micromark-util-symbol/lib/constants.js
316553
- var constants;
316575
+ var constants2;
316554
316576
  var init_constants = __esm(() => {
316555
- constants = {
316577
+ constants2 = {
316556
316578
  attentionSideAfter: 2,
316557
316579
  attentionSideBefore: 1,
316558
316580
  atxHeadingOpeningFenceSizeMax: 6,
@@ -316826,7 +316848,7 @@ function splice(list, start, remove, items) {
316826
316848
  start = start > end ? end : start;
316827
316849
  }
316828
316850
  remove = remove > 0 ? remove : 0;
316829
- if (items.length < constants.v8MaxSafeChunkSize) {
316851
+ if (items.length < constants2.v8MaxSafeChunkSize) {
316830
316852
  parameters = Array.from(items);
316831
316853
  parameters.unshift(start, remove);
316832
316854
  list.splice(...parameters);
@@ -316834,11 +316856,11 @@ function splice(list, start, remove, items) {
316834
316856
  if (remove)
316835
316857
  list.splice(start, remove);
316836
316858
  while (chunkStart < items.length) {
316837
- parameters = items.slice(chunkStart, chunkStart + constants.v8MaxSafeChunkSize);
316859
+ parameters = items.slice(chunkStart, chunkStart + constants2.v8MaxSafeChunkSize);
316838
316860
  parameters.unshift(start, 0);
316839
316861
  list.splice(...parameters);
316840
- chunkStart += constants.v8MaxSafeChunkSize;
316841
- start += constants.v8MaxSafeChunkSize;
316862
+ chunkStart += constants2.v8MaxSafeChunkSize;
316863
+ start += constants2.v8MaxSafeChunkSize;
316842
316864
  }
316843
316865
  }
316844
316866
  }
@@ -316993,7 +317015,7 @@ function initializeContent(effects2) {
316993
317015
  }
316994
317016
  function lineStart(code) {
316995
317017
  const token = effects2.enter(types9.chunkText, {
316996
- contentType: constants.contentTypeText,
317018
+ contentType: constants2.contentTypeText,
316997
317019
  previous
316998
317020
  });
316999
317021
  if (previous) {
@@ -317121,7 +317143,7 @@ function initializeDocument(effects2) {
317121
317143
  childFlow = childFlow || self.parser.flow(self.now());
317122
317144
  effects2.enter(types9.chunkFlow, {
317123
317145
  _tokenizer: childFlow,
317124
- contentType: constants.contentTypeFlow,
317146
+ contentType: constants2.contentTypeFlow,
317125
317147
  previous: childToken
317126
317148
  });
317127
317149
  return flowContinue(code);
@@ -317206,7 +317228,7 @@ function initializeDocument(effects2) {
317206
317228
  }
317207
317229
  function tokenizeContainer(effects2, ok3, nok) {
317208
317230
  ok2(this.parser.constructs.disable.null, "expected `disable.null` to be populated");
317209
- return factorySpace(effects2, effects2.attempt(this.parser.constructs.document, ok3, nok), types9.linePrefix, this.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants.tabSize);
317231
+ return factorySpace(effects2, effects2.attempt(this.parser.constructs.document, ok3, nok), types9.linePrefix, this.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants2.tabSize);
317210
317232
  }
317211
317233
  var document3, containerConstruct;
317212
317234
  var init_document2 = __esm(() => {
@@ -317222,10 +317244,10 @@ var init_document2 = __esm(() => {
317222
317244
  // ../../../v2/node_modules/.pnpm/micromark-util-classify-character@2.0.1/node_modules/micromark-util-classify-character/dev/index.js
317223
317245
  function classifyCharacter(code) {
317224
317246
  if (code === codes.eof || markdownLineEndingOrSpace(code) || unicodeWhitespace(code)) {
317225
- return constants.characterGroupWhitespace;
317247
+ return constants2.characterGroupWhitespace;
317226
317248
  }
317227
317249
  if (unicodePunctuation(code)) {
317228
- return constants.characterGroupPunctuation;
317250
+ return constants2.characterGroupPunctuation;
317229
317251
  }
317230
317252
  }
317231
317253
  var init_dev6 = __esm(() => {
@@ -317358,8 +317380,8 @@ function tokenizeAttention(effects2, ok3) {
317358
317380
  const token = effects2.exit("attentionSequence");
317359
317381
  const after = classifyCharacter(code);
317360
317382
  ok2(attentionMarkers, "expected `attentionMarkers` to be populated");
317361
- const open = !after || after === constants.characterGroupPunctuation && before || attentionMarkers.includes(code);
317362
- const close = !before || before === constants.characterGroupPunctuation && after || attentionMarkers.includes(previous);
317383
+ const open = !after || after === constants2.characterGroupPunctuation && before || attentionMarkers.includes(code);
317384
+ const close = !before || before === constants2.characterGroupPunctuation && after || attentionMarkers.includes(previous);
317363
317385
  token._open = Boolean(marker === codes.asterisk ? open : open && (before || !close));
317364
317386
  token._close = Boolean(marker === codes.asterisk ? close : close && (after || !open));
317365
317387
  return ok3(code);
@@ -317419,7 +317441,7 @@ function tokenizeAutolink(effects2, ok3, nok) {
317419
317441
  size = 0;
317420
317442
  return urlInside;
317421
317443
  }
317422
- if ((code === codes.plusSign || code === codes.dash || code === codes.dot || asciiAlphanumeric(code)) && size++ < constants.autolinkSchemeSizeMax) {
317444
+ if ((code === codes.plusSign || code === codes.dash || code === codes.dot || asciiAlphanumeric(code)) && size++ < constants2.autolinkSchemeSizeMax) {
317423
317445
  effects2.consume(code);
317424
317446
  return schemeInsideOrEmailAtext;
317425
317447
  }
@@ -317472,7 +317494,7 @@ function tokenizeAutolink(effects2, ok3, nok) {
317472
317494
  return emailValue(code);
317473
317495
  }
317474
317496
  function emailValue(code) {
317475
- if ((code === codes.dash || asciiAlphanumeric(code)) && size++ < constants.autolinkDomainSizeMax) {
317497
+ if ((code === codes.dash || asciiAlphanumeric(code)) && size++ < constants2.autolinkDomainSizeMax) {
317476
317498
  const next = code === codes.dash ? emailValue : emailLabel;
317477
317499
  effects2.consume(code);
317478
317500
  return next;
@@ -317544,7 +317566,7 @@ function tokenizeBlockQuoteContinuation(effects2, ok3, nok) {
317544
317566
  function contStart(code) {
317545
317567
  if (markdownSpace(code)) {
317546
317568
  ok2(self.parser.constructs.disable.null, "expected `disable.null` to be populated");
317547
- return factorySpace(effects2, contBefore, types9.linePrefix, self.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants.tabSize)(code);
317569
+ return factorySpace(effects2, contBefore, types9.linePrefix, self.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants2.tabSize)(code);
317548
317570
  }
317549
317571
  return contBefore(code);
317550
317572
  }
@@ -317625,7 +317647,7 @@ function tokenizeCharacterReference(effects2, ok3, nok) {
317625
317647
  return numeric;
317626
317648
  }
317627
317649
  effects2.enter(types9.characterReferenceValue);
317628
- max2 = constants.characterReferenceNamedSizeMax;
317650
+ max2 = constants2.characterReferenceNamedSizeMax;
317629
317651
  test = asciiAlphanumeric;
317630
317652
  return value2(code);
317631
317653
  }
@@ -317635,12 +317657,12 @@ function tokenizeCharacterReference(effects2, ok3, nok) {
317635
317657
  effects2.consume(code);
317636
317658
  effects2.exit(types9.characterReferenceMarkerHexadecimal);
317637
317659
  effects2.enter(types9.characterReferenceValue);
317638
- max2 = constants.characterReferenceHexadecimalSizeMax;
317660
+ max2 = constants2.characterReferenceHexadecimalSizeMax;
317639
317661
  test = asciiHexDigit;
317640
317662
  return value2;
317641
317663
  }
317642
317664
  effects2.enter(types9.characterReferenceValue);
317643
- max2 = constants.characterReferenceDecimalSizeMax;
317665
+ max2 = constants2.characterReferenceDecimalSizeMax;
317644
317666
  test = asciiDigit;
317645
317667
  return value2(code);
317646
317668
  }
@@ -317702,7 +317724,7 @@ function tokenizeCodeFenced(effects2, ok3, nok) {
317702
317724
  effects2.consume(code);
317703
317725
  return sequenceOpen;
317704
317726
  }
317705
- if (sizeOpen < constants.codeFencedSequenceSizeMin) {
317727
+ if (sizeOpen < constants2.codeFencedSequenceSizeMin) {
317706
317728
  return nok(code);
317707
317729
  }
317708
317730
  effects2.exit(types9.codeFencedFenceSequence);
@@ -317714,7 +317736,7 @@ function tokenizeCodeFenced(effects2, ok3, nok) {
317714
317736
  return self.interrupt ? ok3(code) : effects2.check(nonLazyContinuation, atNonLazyBreak, after)(code);
317715
317737
  }
317716
317738
  effects2.enter(types9.codeFencedFenceInfo);
317717
- effects2.enter(types9.chunkString, { contentType: constants.contentTypeString });
317739
+ effects2.enter(types9.chunkString, { contentType: constants2.contentTypeString });
317718
317740
  return info(code);
317719
317741
  }
317720
317742
  function info(code) {
@@ -317739,7 +317761,7 @@ function tokenizeCodeFenced(effects2, ok3, nok) {
317739
317761
  return infoBefore(code);
317740
317762
  }
317741
317763
  effects2.enter(types9.codeFencedFenceMeta);
317742
- effects2.enter(types9.chunkString, { contentType: constants.contentTypeString });
317764
+ effects2.enter(types9.chunkString, { contentType: constants2.contentTypeString });
317743
317765
  return meta3(code);
317744
317766
  }
317745
317767
  function meta3(code) {
@@ -317800,7 +317822,7 @@ function tokenizeCodeFenced(effects2, ok3, nok) {
317800
317822
  function start2(code) {
317801
317823
  ok2(self.parser.constructs.disable.null, "expected `disable.null` to be populated");
317802
317824
  effects3.enter(types9.codeFencedFence);
317803
- return markdownSpace(code) ? factorySpace(effects3, beforeSequenceClose, types9.linePrefix, self.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants.tabSize)(code) : beforeSequenceClose(code);
317825
+ return markdownSpace(code) ? factorySpace(effects3, beforeSequenceClose, types9.linePrefix, self.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants2.tabSize)(code) : beforeSequenceClose(code);
317804
317826
  }
317805
317827
  function beforeSequenceClose(code) {
317806
317828
  if (code === marker) {
@@ -317871,11 +317893,11 @@ function tokenizeCodeIndented(effects2, ok3, nok) {
317871
317893
  function start(code) {
317872
317894
  ok2(markdownSpace(code));
317873
317895
  effects2.enter(types9.codeIndented);
317874
- return factorySpace(effects2, afterPrefix, types9.linePrefix, constants.tabSize + 1)(code);
317896
+ return factorySpace(effects2, afterPrefix, types9.linePrefix, constants2.tabSize + 1)(code);
317875
317897
  }
317876
317898
  function afterPrefix(code) {
317877
317899
  const tail = self.events[self.events.length - 1];
317878
- return tail && tail[1].type === types9.linePrefix && tail[2].sliceSerialize(tail[1], true).length >= constants.tabSize ? atBreak(code) : nok(code);
317900
+ return tail && tail[1].type === types9.linePrefix && tail[2].sliceSerialize(tail[1], true).length >= constants2.tabSize ? atBreak(code) : nok(code);
317879
317901
  }
317880
317902
  function atBreak(code) {
317881
317903
  if (code === codes.eof) {
@@ -317913,11 +317935,11 @@ function tokenizeFurtherStart(effects2, ok3, nok) {
317913
317935
  effects2.exit(types9.lineEnding);
317914
317936
  return furtherStart2;
317915
317937
  }
317916
- return factorySpace(effects2, afterPrefix, types9.linePrefix, constants.tabSize + 1)(code);
317938
+ return factorySpace(effects2, afterPrefix, types9.linePrefix, constants2.tabSize + 1)(code);
317917
317939
  }
317918
317940
  function afterPrefix(code) {
317919
317941
  const tail = self.events[self.events.length - 1];
317920
- return tail && tail[1].type === types9.linePrefix && tail[2].sliceSerialize(tail[1], true).length >= constants.tabSize ? ok3(code) : markdownLineEnding(code) ? furtherStart2(code) : nok(code);
317942
+ return tail && tail[1].type === types9.linePrefix && tail[2].sliceSerialize(tail[1], true).length >= constants2.tabSize ? ok3(code) : markdownLineEnding(code) ? furtherStart2(code) : nok(code);
317921
317943
  }
317922
317944
  }
317923
317945
  var codeIndented, furtherStart;
@@ -318129,12 +318151,12 @@ class SpliceBuffer {
318129
318151
  }
318130
318152
  function chunkedPush(list, right) {
318131
318153
  let chunkStart = 0;
318132
- if (right.length < constants.v8MaxSafeChunkSize) {
318154
+ if (right.length < constants2.v8MaxSafeChunkSize) {
318133
318155
  list.push(...right);
318134
318156
  } else {
318135
318157
  while (chunkStart < right.length) {
318136
- list.push(...right.slice(chunkStart, chunkStart + constants.v8MaxSafeChunkSize));
318137
- chunkStart += constants.v8MaxSafeChunkSize;
318158
+ list.push(...right.slice(chunkStart, chunkStart + constants2.v8MaxSafeChunkSize));
318159
+ chunkStart += constants2.v8MaxSafeChunkSize;
318138
318160
  }
318139
318161
  }
318140
318162
  }
@@ -318313,7 +318335,7 @@ function tokenizeContent(effects2, ok3) {
318313
318335
  ok2(code !== codes.eof && !markdownLineEnding(code), "expected no eof or eol");
318314
318336
  effects2.enter(types9.content);
318315
318337
  previous2 = effects2.enter(types9.chunkContent, {
318316
- contentType: constants.contentTypeContent
318338
+ contentType: constants2.contentTypeContent
318317
318339
  });
318318
318340
  return chunkInside(code);
318319
318341
  }
@@ -318338,7 +318360,7 @@ function tokenizeContent(effects2, ok3) {
318338
318360
  effects2.exit(types9.chunkContent);
318339
318361
  ok2(previous2, "expected previous token");
318340
318362
  previous2.next = effects2.enter(types9.chunkContent, {
318341
- contentType: constants.contentTypeContent,
318363
+ contentType: constants2.contentTypeContent,
318342
318364
  previous: previous2
318343
318365
  });
318344
318366
  previous2 = previous2.next;
@@ -318362,7 +318384,7 @@ function tokenizeContinuation(effects2, ok3, nok) {
318362
318384
  }
318363
318385
  ok2(self.parser.constructs.disable.null, "expected `disable.null` to be populated");
318364
318386
  const tail = self.events[self.events.length - 1];
318365
- if (!self.parser.constructs.disable.null.includes("codeIndented") && tail && tail[1].type === types9.linePrefix && tail[2].sliceSerialize(tail[1], true).length >= constants.tabSize) {
318387
+ if (!self.parser.constructs.disable.null.includes("codeIndented") && tail && tail[1].type === types9.linePrefix && tail[2].sliceSerialize(tail[1], true).length >= constants2.tabSize) {
318366
318388
  return ok3(code);
318367
318389
  }
318368
318390
  return effects2.interrupt(self.parser.constructs.flow, nok, ok3)(code);
@@ -318399,7 +318421,7 @@ function factoryDestination(effects2, ok3, nok, type, literalType2, literalMarke
318399
318421
  effects2.enter(type);
318400
318422
  effects2.enter(rawType);
318401
318423
  effects2.enter(stringType2);
318402
- effects2.enter(types9.chunkString, { contentType: constants.contentTypeString });
318424
+ effects2.enter(types9.chunkString, { contentType: constants2.contentTypeString });
318403
318425
  return raw(code);
318404
318426
  }
318405
318427
  function enclosedBefore(code) {
@@ -318412,7 +318434,7 @@ function factoryDestination(effects2, ok3, nok, type, literalType2, literalMarke
318412
318434
  return ok3;
318413
318435
  }
318414
318436
  effects2.enter(stringType2);
318415
- effects2.enter(types9.chunkString, { contentType: constants.contentTypeString });
318437
+ effects2.enter(types9.chunkString, { contentType: constants2.contentTypeString });
318416
318438
  return enclosed(code);
318417
318439
  }
318418
318440
  function enclosed(code) {
@@ -318487,7 +318509,7 @@ function factoryLabel(effects2, ok3, nok, type, markerType, stringType2) {
318487
318509
  return atBreak;
318488
318510
  }
318489
318511
  function atBreak(code) {
318490
- if (size > constants.linkReferenceSizeMax || code === codes.eof || code === codes.leftSquareBracket || code === codes.rightSquareBracket && !seen || code === codes.caret && !size && "_hiddenFootnoteSupport" in self.parser.constructs) {
318512
+ if (size > constants2.linkReferenceSizeMax || code === codes.eof || code === codes.leftSquareBracket || code === codes.rightSquareBracket && !seen || code === codes.caret && !size && "_hiddenFootnoteSupport" in self.parser.constructs) {
318491
318513
  return nok(code);
318492
318514
  }
318493
318515
  if (code === codes.rightSquareBracket) {
@@ -318504,11 +318526,11 @@ function factoryLabel(effects2, ok3, nok, type, markerType, stringType2) {
318504
318526
  effects2.exit(types9.lineEnding);
318505
318527
  return atBreak;
318506
318528
  }
318507
- effects2.enter(types9.chunkString, { contentType: constants.contentTypeString });
318529
+ effects2.enter(types9.chunkString, { contentType: constants2.contentTypeString });
318508
318530
  return labelInside(code);
318509
318531
  }
318510
318532
  function labelInside(code) {
318511
- if (code === codes.eof || code === codes.leftSquareBracket || code === codes.rightSquareBracket || markdownLineEnding(code) || size++ > constants.linkReferenceSizeMax) {
318533
+ if (code === codes.eof || code === codes.leftSquareBracket || code === codes.rightSquareBracket || markdownLineEnding(code) || size++ > constants2.linkReferenceSizeMax) {
318512
318534
  effects2.exit(types9.chunkString);
318513
318535
  return atBreak(code);
318514
318536
  }
@@ -318572,7 +318594,7 @@ function factoryTitle(effects2, ok3, nok, type, markerType, stringType2) {
318572
318594
  effects2.exit(types9.lineEnding);
318573
318595
  return factorySpace(effects2, atBreak, types9.linePrefix);
318574
318596
  }
318575
- effects2.enter(types9.chunkString, { contentType: constants.contentTypeString });
318597
+ effects2.enter(types9.chunkString, { contentType: constants2.contentTypeString });
318576
318598
  return inside(code);
318577
318599
  }
318578
318600
  function inside(code) {
@@ -318748,7 +318770,7 @@ function resolveHeadingAtx(events, context) {
318748
318770
  type: types9.chunkText,
318749
318771
  start: events[contentStart][1].start,
318750
318772
  end: events[contentEnd][1].end,
318751
- contentType: constants.contentTypeText
318773
+ contentType: constants2.contentTypeText
318752
318774
  };
318753
318775
  splice(events, contentStart, contentEnd - contentStart + 1, [
318754
318776
  ["enter", content3, context],
@@ -318772,7 +318794,7 @@ function tokenizeHeadingAtx(effects2, ok3, nok) {
318772
318794
  return sequenceOpen(code);
318773
318795
  }
318774
318796
  function sequenceOpen(code) {
318775
- if (code === codes.numberSign && size++ < constants.atxHeadingOpeningFenceSizeMax) {
318797
+ if (code === codes.numberSign && size++ < constants2.atxHeadingOpeningFenceSizeMax) {
318776
318798
  effects2.consume(code);
318777
318799
  return sequenceOpen;
318778
318800
  }
@@ -318943,7 +318965,7 @@ function tokenizeHtmlFlow(effects2, ok3, nok) {
318943
318965
  }
318944
318966
  if (code === codes.questionMark) {
318945
318967
  effects2.consume(code);
318946
- marker = constants.htmlInstruction;
318968
+ marker = constants2.htmlInstruction;
318947
318969
  return self.interrupt ? ok3 : continuationDeclarationInside;
318948
318970
  }
318949
318971
  if (asciiAlpha(code)) {
@@ -318957,18 +318979,18 @@ function tokenizeHtmlFlow(effects2, ok3, nok) {
318957
318979
  function declarationOpen(code) {
318958
318980
  if (code === codes.dash) {
318959
318981
  effects2.consume(code);
318960
- marker = constants.htmlComment;
318982
+ marker = constants2.htmlComment;
318961
318983
  return commentOpenInside;
318962
318984
  }
318963
318985
  if (code === codes.leftSquareBracket) {
318964
318986
  effects2.consume(code);
318965
- marker = constants.htmlCdata;
318987
+ marker = constants2.htmlCdata;
318966
318988
  index = 0;
318967
318989
  return cdataOpenInside;
318968
318990
  }
318969
318991
  if (asciiAlpha(code)) {
318970
318992
  effects2.consume(code);
318971
- marker = constants.htmlDeclaration;
318993
+ marker = constants2.htmlDeclaration;
318972
318994
  return self.interrupt ? ok3 : continuationDeclarationInside;
318973
318995
  }
318974
318996
  return nok(code);
@@ -318981,7 +319003,7 @@ function tokenizeHtmlFlow(effects2, ok3, nok) {
318981
319003
  return nok(code);
318982
319004
  }
318983
319005
  function cdataOpenInside(code) {
318984
- const value2 = constants.cdataOpeningString;
319006
+ const value2 = constants2.cdataOpeningString;
318985
319007
  if (code === value2.charCodeAt(index++)) {
318986
319008
  effects2.consume(code);
318987
319009
  if (index === value2.length) {
@@ -319005,18 +319027,18 @@ function tokenizeHtmlFlow(effects2, ok3, nok) {
319005
319027
  const slash = code === codes.slash;
319006
319028
  const name = buffer.toLowerCase();
319007
319029
  if (!slash && !closingTag && htmlRawNames.includes(name)) {
319008
- marker = constants.htmlRaw;
319030
+ marker = constants2.htmlRaw;
319009
319031
  return self.interrupt ? ok3(code) : continuation(code);
319010
319032
  }
319011
319033
  if (htmlBlockNames.includes(buffer.toLowerCase())) {
319012
- marker = constants.htmlBasic;
319034
+ marker = constants2.htmlBasic;
319013
319035
  if (slash) {
319014
319036
  effects2.consume(code);
319015
319037
  return basicSelfClosing;
319016
319038
  }
319017
319039
  return self.interrupt ? ok3(code) : continuation(code);
319018
319040
  }
319019
- marker = constants.htmlComplete;
319041
+ marker = constants2.htmlComplete;
319020
319042
  return self.interrupt && !self.parser.lazy[self.now().line] ? nok(code) : closingTag ? completeClosingTagAfter(code) : completeAttributeNameBefore(code);
319021
319043
  }
319022
319044
  if (code === codes.dash || asciiAlphanumeric(code)) {
@@ -319131,27 +319153,27 @@ function tokenizeHtmlFlow(effects2, ok3, nok) {
319131
319153
  return nok(code);
319132
319154
  }
319133
319155
  function continuation(code) {
319134
- if (code === codes.dash && marker === constants.htmlComment) {
319156
+ if (code === codes.dash && marker === constants2.htmlComment) {
319135
319157
  effects2.consume(code);
319136
319158
  return continuationCommentInside;
319137
319159
  }
319138
- if (code === codes.lessThan && marker === constants.htmlRaw) {
319160
+ if (code === codes.lessThan && marker === constants2.htmlRaw) {
319139
319161
  effects2.consume(code);
319140
319162
  return continuationRawTagOpen;
319141
319163
  }
319142
- if (code === codes.greaterThan && marker === constants.htmlDeclaration) {
319164
+ if (code === codes.greaterThan && marker === constants2.htmlDeclaration) {
319143
319165
  effects2.consume(code);
319144
319166
  return continuationClose;
319145
319167
  }
319146
- if (code === codes.questionMark && marker === constants.htmlInstruction) {
319168
+ if (code === codes.questionMark && marker === constants2.htmlInstruction) {
319147
319169
  effects2.consume(code);
319148
319170
  return continuationDeclarationInside;
319149
319171
  }
319150
- if (code === codes.rightSquareBracket && marker === constants.htmlCdata) {
319172
+ if (code === codes.rightSquareBracket && marker === constants2.htmlCdata) {
319151
319173
  effects2.consume(code);
319152
319174
  return continuationCdataInside;
319153
319175
  }
319154
- if (markdownLineEnding(code) && (marker === constants.htmlBasic || marker === constants.htmlComplete)) {
319176
+ if (markdownLineEnding(code) && (marker === constants2.htmlBasic || marker === constants2.htmlComplete)) {
319155
319177
  effects2.exit(types9.htmlFlowData);
319156
319178
  return effects2.check(blankLineBefore, continuationAfter, continuationStart)(code);
319157
319179
  }
@@ -319203,7 +319225,7 @@ function tokenizeHtmlFlow(effects2, ok3, nok) {
319203
319225
  }
319204
319226
  return continuation(code);
319205
319227
  }
319206
- if (asciiAlpha(code) && buffer.length < constants.htmlRawSizeMax) {
319228
+ if (asciiAlpha(code) && buffer.length < constants2.htmlRawSizeMax) {
319207
319229
  ok2(code !== null);
319208
319230
  effects2.consume(code);
319209
319231
  buffer += String.fromCharCode(code);
@@ -319223,7 +319245,7 @@ function tokenizeHtmlFlow(effects2, ok3, nok) {
319223
319245
  effects2.consume(code);
319224
319246
  return continuationClose;
319225
319247
  }
319226
- if (code === codes.dash && marker === constants.htmlComment) {
319248
+ if (code === codes.dash && marker === constants2.htmlComment) {
319227
319249
  effects2.consume(code);
319228
319250
  return continuationDeclarationInside;
319229
319251
  }
@@ -319370,7 +319392,7 @@ function tokenizeHtmlText(effects2, ok3, nok) {
319370
319392
  return code === codes.greaterThan ? end(code) : code === codes.dash ? commentClose(code) : comment(code);
319371
319393
  }
319372
319394
  function cdataOpenInside(code) {
319373
- const value2 = constants.cdataOpeningString;
319395
+ const value2 = constants2.cdataOpeningString;
319374
319396
  if (code === value2.charCodeAt(index++)) {
319375
319397
  effects2.consume(code);
319376
319398
  return index === value2.length ? cdata : cdataOpenInside;
@@ -319586,7 +319608,7 @@ function tokenizeHtmlText(effects2, ok3, nok) {
319586
319608
  }
319587
319609
  function lineEndingAfter(code) {
319588
319610
  ok2(self.parser.constructs.disable.null, "expected `disable.null` to be populated");
319589
- return markdownSpace(code) ? factorySpace(effects2, lineEndingAfterPrefix, types9.linePrefix, self.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants.tabSize)(code) : lineEndingAfterPrefix(code);
319611
+ return markdownSpace(code) ? factorySpace(effects2, lineEndingAfterPrefix, types9.linePrefix, self.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants2.tabSize)(code) : lineEndingAfterPrefix(code);
319590
319612
  }
319591
319613
  function lineEndingAfterPrefix(code) {
319592
319614
  effects2.enter(types9.htmlTextData);
@@ -319749,7 +319771,7 @@ function tokenizeResource(effects2, ok3, nok) {
319749
319771
  if (code === codes.rightParenthesis) {
319750
319772
  return resourceEnd(code);
319751
319773
  }
319752
- return factoryDestination(effects2, resourceDestinationAfter, resourceDestinationMissing, types9.resourceDestination, types9.resourceDestinationLiteral, types9.resourceDestinationLiteralMarker, types9.resourceDestinationRaw, types9.resourceDestinationString, constants.linkResourceDestinationBalanceMax)(code);
319774
+ return factoryDestination(effects2, resourceDestinationAfter, resourceDestinationMissing, types9.resourceDestination, types9.resourceDestinationLiteral, types9.resourceDestinationLiteralMarker, types9.resourceDestinationRaw, types9.resourceDestinationString, constants2.linkResourceDestinationBalanceMax)(code);
319753
319775
  }
319754
319776
  function resourceDestinationAfter(code) {
319755
319777
  return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects2, resourceBetween)(code) : resourceEnd(code);
@@ -319940,7 +319962,7 @@ function tokenizeThematicBreak(effects2, ok3, nok) {
319940
319962
  effects2.enter(types9.thematicBreakSequence);
319941
319963
  return sequence(code);
319942
319964
  }
319943
- if (size >= constants.thematicBreakMarkerCountMin && (code === codes.eof || markdownLineEnding(code))) {
319965
+ if (size >= constants2.thematicBreakMarkerCountMin && (code === codes.eof || markdownLineEnding(code))) {
319944
319966
  effects2.exit(types9.thematicBreak);
319945
319967
  return ok3(code);
319946
319968
  }
@@ -319997,7 +320019,7 @@ function tokenizeListStart(effects2, ok3, nok) {
319997
320019
  }
319998
320020
  function inside(code) {
319999
320021
  ok2(self.containerState, "expected state");
320000
- if (asciiDigit(code) && ++size < constants.listItemValueSizeMax) {
320022
+ if (asciiDigit(code) && ++size < constants2.listItemValueSizeMax) {
320001
320023
  effects2.consume(code);
320002
320024
  return inside;
320003
320025
  }
@@ -320064,7 +320086,7 @@ function tokenizeListContinuation(effects2, ok3, nok) {
320064
320086
  self.containerState._closeFlow = true;
320065
320087
  self.interrupt = undefined;
320066
320088
  ok2(self.parser.constructs.disable.null, "expected `disable.null` to be populated");
320067
- return factorySpace(effects2, effects2.attempt(list, ok3, nok), types9.linePrefix, self.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants.tabSize)(code);
320089
+ return factorySpace(effects2, effects2.attempt(list, ok3, nok), types9.linePrefix, self.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants2.tabSize)(code);
320068
320090
  }
320069
320091
  }
320070
320092
  function tokenizeIndent(effects2, ok3, nok) {
@@ -320086,7 +320108,7 @@ function tokenizeListEnd(effects2) {
320086
320108
  function tokenizeListItemPrefixWhitespace(effects2, ok3, nok) {
320087
320109
  const self = this;
320088
320110
  ok2(self.parser.constructs.disable.null, "expected `disable.null` to be populated");
320089
- return factorySpace(effects2, afterPrefix, types9.listItemPrefixWhitespace, self.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants.tabSize + 1);
320111
+ return factorySpace(effects2, afterPrefix, types9.listItemPrefixWhitespace, self.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants2.tabSize + 1);
320090
320112
  function afterPrefix(code) {
320091
320113
  const tail = self.events[self.events.length - 1];
320092
320114
  return !markdownSpace(code) && tail && tail[1].type === types9.listItemPrefixWhitespace ? ok3(code) : nok(code);
@@ -320384,7 +320406,7 @@ function resolveAllLineSuffixes(events, context) {
320384
320406
  }
320385
320407
  if (size) {
320386
320408
  const token = {
320387
- type: eventIndex === events.length || tabs2 || size < constants.hardBreakPrefixSizeMin ? types9.lineSuffix : types9.hardBreakTrailing,
320409
+ type: eventIndex === events.length || tabs2 || size < constants2.hardBreakPrefixSizeMin ? types9.lineSuffix : types9.hardBreakTrailing,
320388
320410
  start: {
320389
320411
  _bufferIndex: index ? bufferIndex : data.start._bufferIndex + bufferIndex,
320390
320412
  _index: data.start._index + index,
@@ -321640,7 +321662,7 @@ function preprocess2() {
321640
321662
  break;
321641
321663
  }
321642
321664
  case codes.ht: {
321643
- next = Math.ceil(column / constants.tabSize) * constants.tabSize;
321665
+ next = Math.ceil(column / constants2.tabSize) * constants2.tabSize;
321644
321666
  chunks.push(codes.horizontalTab);
321645
321667
  while (column++ < next)
321646
321668
  chunks.push(codes.virtualSpace);
@@ -321694,7 +321716,7 @@ function decode4($0, $1, $2) {
321694
321716
  if (head === codes.numberSign) {
321695
321717
  const head2 = $2.charCodeAt(1);
321696
321718
  const hex3 = head2 === codes.lowercaseX || head2 === codes.uppercaseX;
321697
- return decodeNumericCharacterReference($2.slice(hex3 ? 2 : 1), hex3 ? constants.numericBaseHexadecimal : constants.numericBaseDecimal);
321719
+ return decodeNumericCharacterReference($2.slice(hex3 ? 2 : 1), hex3 ? constants2.numericBaseHexadecimal : constants2.numericBaseDecimal);
321698
321720
  }
321699
321721
  return decodeNamedCharacterReference($2) || $0;
321700
321722
  }
@@ -322041,7 +322063,7 @@ function compiler(options) {
322041
322063
  const ancestor = this.stack[this.stack.length - 2];
322042
322064
  ok2(ancestor, "expected nodes on stack");
322043
322065
  ok2(ancestor.type === "list", "expected list on stack");
322044
- ancestor.start = Number.parseInt(this.sliceSerialize(token), constants.numericBaseDecimal);
322066
+ ancestor.start = Number.parseInt(this.sliceSerialize(token), constants2.numericBaseDecimal);
322045
322067
  this.data.expectingFirstListItemValue = undefined;
322046
322068
  }
322047
322069
  }
@@ -322282,7 +322304,7 @@ function compiler(options) {
322282
322304
  const type = this.data.characterReferenceType;
322283
322305
  let value2;
322284
322306
  if (type) {
322285
- value2 = decodeNumericCharacterReference(data2, type === types9.characterReferenceMarkerNumeric ? constants.numericBaseDecimal : constants.numericBaseHexadecimal);
322307
+ value2 = decodeNumericCharacterReference(data2, type === types9.characterReferenceMarkerNumeric ? constants2.numericBaseDecimal : constants2.numericBaseHexadecimal);
322286
322308
  this.data.characterReferenceType = undefined;
322287
322309
  } else {
322288
322310
  const result = decodeNamedCharacterReference(data2);
@@ -323582,7 +323604,7 @@ function tokenizeGfmFootnoteCall(effects2, ok4, nok) {
323582
323604
  return callData;
323583
323605
  }
323584
323606
  function callData(code2) {
323585
- if (size > constants.linkReferenceSizeMax || code2 === codes.rightSquareBracket && !data || code2 === codes.eof || code2 === codes.leftSquareBracket || markdownLineEndingOrSpace(code2)) {
323607
+ if (size > constants2.linkReferenceSizeMax || code2 === codes.rightSquareBracket && !data || code2 === codes.eof || code2 === codes.leftSquareBracket || markdownLineEndingOrSpace(code2)) {
323586
323608
  return nok(code2);
323587
323609
  }
323588
323610
  if (code2 === codes.rightSquareBracket) {
@@ -323641,7 +323663,7 @@ function tokenizeDefinitionStart(effects2, ok4, nok) {
323641
323663
  return nok(code2);
323642
323664
  }
323643
323665
  function labelInside(code2) {
323644
- if (size > constants.linkReferenceSizeMax || code2 === codes.rightSquareBracket && !data || code2 === codes.eof || code2 === codes.leftSquareBracket || markdownLineEndingOrSpace(code2)) {
323666
+ if (size > constants2.linkReferenceSizeMax || code2 === codes.rightSquareBracket && !data || code2 === codes.eof || code2 === codes.leftSquareBracket || markdownLineEndingOrSpace(code2)) {
323645
323667
  return nok(code2);
323646
323668
  }
323647
323669
  if (code2 === codes.rightSquareBracket) {
@@ -323693,10 +323715,10 @@ function gfmFootnoteDefinitionEnd(effects2) {
323693
323715
  }
323694
323716
  function tokenizeIndent2(effects2, ok4, nok) {
323695
323717
  const self = this;
323696
- return factorySpace(effects2, afterPrefix, "gfmFootnoteDefinitionIndent", constants.tabSize + 1);
323718
+ return factorySpace(effects2, afterPrefix, "gfmFootnoteDefinitionIndent", constants2.tabSize + 1);
323697
323719
  function afterPrefix(code2) {
323698
323720
  const tail = self.events[self.events.length - 1];
323699
- return tail && tail[1].type === "gfmFootnoteDefinitionIndent" && tail[2].sliceSerialize(tail[1], true).length === constants.tabSize ? ok4(code2) : nok(code2);
323721
+ return tail && tail[1].type === "gfmFootnoteDefinitionIndent" && tail[2].sliceSerialize(tail[1], true).length === constants2.tabSize ? ok4(code2) : nok(code2);
323700
323722
  }
323701
323723
  }
323702
323724
  var indent;
@@ -323808,8 +323830,8 @@ function gfmStrikethrough(options) {
323808
323830
  return nok(code2);
323809
323831
  const token = effects2.exit("strikethroughSequenceTemporary");
323810
323832
  const after = classifyCharacter(code2);
323811
- token._open = !after || after === constants.attentionSideAfter && Boolean(before);
323812
- token._close = !before || before === constants.attentionSideAfter && Boolean(after);
323833
+ token._open = !after || after === constants2.attentionSideAfter && Boolean(before);
323834
+ token._close = !before || before === constants2.attentionSideAfter && Boolean(after);
323813
323835
  return ok4(code2);
323814
323836
  }
323815
323837
  }
@@ -324008,7 +324030,7 @@ function tokenizeTable(effects2, ok4, nok) {
324008
324030
  seen = false;
324009
324031
  if (markdownSpace(code2)) {
324010
324032
  ok2(self.parser.constructs.disable.null, "expected `disabled.null`");
324011
- return factorySpace(effects2, headDelimiterBefore, types9.linePrefix, self.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants.tabSize)(code2);
324033
+ return factorySpace(effects2, headDelimiterBefore, types9.linePrefix, self.parser.constructs.disable.null.includes("codeIndented") ? undefined : constants2.tabSize)(code2);
324012
324034
  }
324013
324035
  return headDelimiterBefore(code2);
324014
324036
  }
@@ -324259,7 +324281,7 @@ function flushCell(map3, context, range, rowKind, rowEnd, previousCell) {
324259
324281
  const end = context.events[range[3]];
324260
324282
  start[1].end = Object.assign({}, end[1].end);
324261
324283
  start[1].type = types9.chunkText;
324262
- start[1].contentType = constants.contentTypeText;
324284
+ start[1].contentType = constants2.contentTypeText;
324263
324285
  if (range[3] > range[2] + 1) {
324264
324286
  const a = range[2] + 1;
324265
324287
  const b = range[3] - range[2] - 1;
@@ -388595,7 +388617,7 @@ function serializeSelectionRange(context, target, includeHtml, options) {
388595
388617
  };
388596
388618
  const tableCellPath = boundaryMap.byBlockId(entry.blockId)?.tableCellPath ?? [];
388597
388619
  const blockSdtPath = boundaryMap.byBlockId(entry.blockId)?.blockSdtPath ?? [];
388598
- const properties = readParagraphProperties(paragraphXml);
388620
+ const properties = readParagraphProperties2(paragraphXml);
388599
388621
  const selectedInlineControl = options?.wholeParagraphs !== true && startEntry.ordinal === endEntry.ordinal && map3.pieces.some((piece) => piece.kind === "container" && piece.containerKind === "sdt" && piece.visibleStart === from && piece.visibleEnd === to);
388600
388622
  const fullyCovered = !selectedInlineControl && from === 0 && to === map3.visibleLength && (options?.wholeParagraphs === true || startEntry.ordinal !== endEntry.ordinal || properties.styleRef !== undefined || properties.numbering !== undefined || hasParagraphProperties(paragraphXml));
388601
388623
  const styleModel = copyStyleModel ?? (copyStyleModel = compileCopyStyleModel(context));
@@ -389628,7 +389650,7 @@ function capturePPrXml(paragraphXml, notes) {
389628
389650
  return null;
389629
389651
  return pPr;
389630
389652
  }
389631
- function readParagraphProperties(paragraphXml) {
389653
+ function readParagraphProperties2(paragraphXml) {
389632
389654
  const pPr = /<w:pPr\b(?:[^>]*\/>|[^>]*>[\s\S]*?<\/w:pPr\s*>)/.exec(paragraphXml)?.[0] ?? "";
389633
389655
  const styleRef = /<w:pStyle\b[^>]*w:val="([^"]+)"/.exec(pPr)?.[1];
389634
389656
  const numPr = /<w:numPr\b[\s\S]*?<\/w:numPr>/.exec(pPr)?.[0];
@@ -429196,6 +429218,7 @@ function emissionContext(owner, xml) {
429196
429218
  return cached2.context;
429197
429219
  }
429198
429220
  function materializeProjection(input) {
429221
+ const readStorySnapshot = input.readStorySnapshot ?? snapshotStoryShard;
429199
429222
  const previousById = new Map;
429200
429223
  const previousByPartUri = new Map;
429201
429224
  if (input.previousRecord) {
@@ -429288,6 +429311,7 @@ function materializeProjection(input) {
429288
429311
  let fullStoryRebuilds = 0;
429289
429312
  const storyHandles = input.shardRegistry.listStories();
429290
429313
  const stories = [];
429314
+ const contentControlTopologies = new Map;
429291
429315
  const sourceBootstrapDigests = new Map;
429292
429316
  for (const handle of storyHandles) {
429293
429317
  const readTarget = shardReadTarget(handle);
@@ -429305,7 +429329,7 @@ function materializeProjection(input) {
429305
429329
  }
429306
429330
  const namespaces = previous3 ? emissionContext(previous3, previous3.xml) : bootstrap?.sourceXml ? emissionContext(bootstrap, bootstrap.sourceXml) : new XmlEmissionContext("");
429307
429331
  const sourceNamespaces = bootstrap?.sourceXml ? emissionContext(bootstrap, bootstrap.sourceXml) : namespaces;
429308
- let useBootstrapSourceXml = !previous3 && (bootstrap?.sourceStoryDigest ? canonicalDigest(snapshotStoryShard(readTarget)) === bootstrap.sourceStoryDigest : !explicitDirtyStoryShardIds.has(handle.shardId)) && typeof bootstrap?.sourceXml === "string" && bootstrap.sourceXml.length > 0;
429332
+ let useBootstrapSourceXml = !previous3 && (bootstrap?.sourceStoryDigest ? canonicalDigest(readStorySnapshot(readTarget)) === bootstrap.sourceStoryDigest : !explicitDirtyStoryShardIds.has(handle.shardId)) && typeof bootstrap?.sourceXml === "string" && bootstrap.sourceXml.length > 0;
429309
429333
  const syntheticAtoms = buildSyntheticCommentAtomsForStory({
429310
429334
  storyDoc: readTarget,
429311
429335
  storyShardId: handle.shardId,
@@ -429313,7 +429337,7 @@ function materializeProjection(input) {
429313
429337
  });
429314
429338
  if (syntheticAtoms.size > 0)
429315
429339
  useBootstrapSourceXml = false;
429316
- if (previous3 && sourceBootstrapDigest && bootstrap?.sourceStoryDigest && previous3.xml === bootstrap.sourceXml && syntheticAtoms.size === 0 && canonicalDigest(snapshotStoryShard(readTarget)) === bootstrap.sourceStoryDigest) {
429340
+ if (previous3 && sourceBootstrapDigest && bootstrap?.sourceStoryDigest && previous3.xml === bootstrap.sourceXml && syntheticAtoms.size === 0 && canonicalDigest(readStorySnapshot(readTarget)) === bootstrap.sourceStoryDigest) {
429317
429341
  stories.push(previous3);
429318
429342
  continue;
429319
429343
  }
@@ -429325,12 +429349,30 @@ function materializeProjection(input) {
429325
429349
  const tableReplacements = readTableStructuralReplacements(readTarget);
429326
429350
  const previousBlockIndex = previous3 ? blockDigestIndex(previous3.blockDigests) : null;
429327
429351
  const insertedBlockHint = previousBlockIndex && [...dirtyStoryBlocks.get(handle.shardId) ?? []].some((blockId) => !previousBlockIndex.has(blockId));
429328
- const structuralSnapshot = previous3 && (wholeStoryDirtyShardIds.has(handle.shardId) || insertedBlockHint) ? snapshotStoryShard(readTarget) : null;
429352
+ const structuralSnapshot = previous3 && (wholeStoryDirtyShardIds.has(handle.shardId) || insertedBlockHint) ? readStorySnapshot(readTarget) : null;
429329
429353
  const overlaidTableIds = structuralSnapshot ? new Set(tableReplacements.map((table) => table.tableNodeId)) : null;
429330
429354
  const restoredTableBoundary = structuralSnapshot && previousBlockIndex ? structuralSnapshot.blocks.some((block) => block.structuralRefs.tableNodeId != null && !previousBlockIndex.has(block.blockId) && !overlaidTableIds.has(block.structuralRefs.tableNodeId)) : false;
429331
429355
  const removedTableBoundary = structuralSnapshot && previous3 ? hasRemovedTableBoundary(previous3, structuralSnapshot.blocks, new Set(tableReplacements.filter((table) => table.deltaKind === "table.rewrite" && table.xml === "").flatMap((table) => table.affectedBlockIds))) : false;
429332
- if (hasContentControlGroups(resolveStoryShardScope(readTarget)) || restoredTableBoundary || removedTableBoundary) {
429333
- const snapshot4 = structuralSnapshot ?? snapshotStoryShard(readTarget);
429356
+ const controlledSnapshot = hasContentControlGroups(resolveStoryShardScope(readTarget)) ? structuralSnapshot ?? readStorySnapshot(readTarget) : null;
429357
+ let controlledTextOnly = false;
429358
+ if (controlledSnapshot) {
429359
+ const envelope = storyEnvelope(controlledSnapshot.meta.storyKind, bootstrap);
429360
+ const prior = previous3 ? CONTENT_CONTROL_TOPOLOGIES.get(previous3) : undefined;
429361
+ const stable = prior && prior.prefix === envelope.prefix && prior.suffix === envelope.suffix && prior.sourceXml === bootstrap?.sourceXml && prior.trailingXml === controlledSnapshot.meta.trailingXml && prior.blocks.length === controlledSnapshot.blocks.length && controlledSnapshot.blocks.every((block, index2) => {
429362
+ const old = prior.blocks[index2];
429363
+ return block.blockId === old.blockId && block.leadingXml === old.leadingXml && block.trailingXml === old.trailingXml && block.splitFromBlockId === old.splitFromBlockId;
429364
+ });
429365
+ controlledTextOnly = !!stable && !fullPackageRebuild && !insertedBlockHint && !wholeStoryDirtyShardIds.has(handle.shardId) && tableReplacements.length === 0 && input.dirty.length > 0 && input.dirty.every((dirty) => dirty.kind === PROJECTION_DIRTY_KIND.storyText && dirty.shardId === handle.shardId && !!dirty.blockId);
429366
+ contentControlTopologies.set(partUriHint, stable ? prior : {
429367
+ prefix: envelope.prefix,
429368
+ suffix: envelope.suffix,
429369
+ sourceXml: bootstrap?.sourceXml,
429370
+ trailingXml: controlledSnapshot.meta.trailingXml,
429371
+ blocks: controlledSnapshot.blocks.map(({ blockId, leadingXml, trailingXml, splitFromBlockId }) => ({ blockId, leadingXml, trailingXml, splitFromBlockId }))
429372
+ });
429373
+ }
429374
+ if (controlledSnapshot && !controlledTextOnly || restoredTableBoundary || removedTableBoundary) {
429375
+ const snapshot4 = controlledSnapshot ?? structuralSnapshot ?? readStorySnapshot(readTarget);
429334
429376
  const placements2 = projectedNamespaceContexts(snapshot4, bootstrap, sourceNamespaces);
429335
429377
  const blocks = snapshot4.blocks.map((block) => ({
429336
429378
  blockId: block.blockId,
@@ -429344,6 +429386,7 @@ function materializeProjection(input) {
429344
429386
  const composed = composeStoryProjection(snapshot4.meta.storyKind, blocks, bootstrap, snapshot4.meta.trailingXml);
429345
429387
  const base3 = { ...composed, partUri: partUriHint, storyId: storyIdHint, storyKind: snapshot4.meta.storyKind };
429346
429388
  const projected = composeTableStructuralProjection({
429389
+ readStorySnapshot,
429347
429390
  handle,
429348
429391
  previous: base3,
429349
429392
  bootstrap,
@@ -429378,7 +429421,7 @@ function materializeProjection(input) {
429378
429421
  blockHints.add(blockId);
429379
429422
  }
429380
429423
  if (blockHints && blockHints.size > 0 && previous3) {
429381
- const currentSnapshot = structuralSnapshot ?? snapshotStoryShard(readTarget);
429424
+ const currentSnapshot = structuralSnapshot ?? readStorySnapshot(readTarget);
429382
429425
  let placements2;
429383
429426
  const currentBlockIds = currentSnapshot.blocks.map((block) => block.blockId);
429384
429427
  if (wholeStoryDirtyShardIds.has(handle.shardId)) {
@@ -429518,6 +429561,7 @@ function materializeProjection(input) {
429518
429561
  };
429519
429562
  })();
429520
429563
  const projectedWithTables = composeTableStructuralProjection({
429564
+ readStorySnapshot,
429521
429565
  handle,
429522
429566
  previous: blockPatchedStory,
429523
429567
  bootstrap,
@@ -429533,6 +429577,7 @@ function materializeProjection(input) {
429533
429577
  storiesRebuilt += 1;
429534
429578
  } else if (tableReplacements.length > 0) {
429535
429579
  const projectedWithTables = composeTableStructuralProjection({
429580
+ readStorySnapshot,
429536
429581
  handle,
429537
429582
  previous: previous3,
429538
429583
  bootstrap,
@@ -429553,6 +429598,7 @@ function materializeProjection(input) {
429553
429598
  }
429554
429599
  }
429555
429600
  const tableStructuralProjection = composeTableStructuralProjection({
429601
+ readStorySnapshot,
429556
429602
  handle,
429557
429603
  previous: previous3,
429558
429604
  bootstrap,
@@ -429568,7 +429614,7 @@ function materializeProjection(input) {
429568
429614
  storiesRebuilt += 1;
429569
429615
  continue;
429570
429616
  }
429571
- const snapshot3 = snapshotStoryShard(readTarget);
429617
+ const snapshot3 = readStorySnapshot(readTarget);
429572
429618
  const placements = projectedNamespaceContexts(snapshot3, bootstrap, sourceNamespaces);
429573
429619
  const partUri = snapshot3.meta.sourcePartUri || `/word/story-${snapshot3.meta.storyId}.xml`;
429574
429620
  const blockDigests = [];
@@ -429626,6 +429672,11 @@ function materializeProjection(input) {
429626
429672
  stories[index2] = { ...story, sourceBootstrapDigest: digest6 };
429627
429673
  }
429628
429674
  stories.sort((a, b) => a.partUri < b.partUri ? -1 : a.partUri > b.partUri ? 1 : 0);
429675
+ for (const story of stories) {
429676
+ const topology = contentControlTopologies.get(story.partUri);
429677
+ if (topology)
429678
+ CONTENT_CONTROL_TOPOLOGIES.set(story, topology);
429679
+ }
429629
429680
  let relationships = input.previousRecord?.relationships ? [...input.previousRecord.relationships] : [];
429630
429681
  let parts = input.previousRecord?.parts ? [...input.previousRecord.parts] : [];
429631
429682
  let contentTypes = input.previousRecord?.contentTypes ?? { defaults: [], overrides: [] };
@@ -429660,17 +429711,21 @@ function materializeProjection(input) {
429660
429711
  safety,
429661
429712
  digest: ""
429662
429713
  };
429714
+ let projectionDigest;
429663
429715
  const withDigest = {
429664
429716
  ...record3,
429665
- digest: canonicalDigest({
429666
- stories: canonicalStoryDigestInputs(record3.stories),
429667
- parts: record3.parts,
429668
- relationships: record3.relationships,
429669
- contentTypes: record3.contentTypes,
429670
- media: record3.media,
429671
- safety: record3.safety,
429672
- snapshotToken: record3.snapshotToken.digest
429673
- })
429717
+ get digest() {
429718
+ projectionDigest ?? (projectionDigest = canonicalDigest({
429719
+ stories: canonicalStoryDigestInputs(record3.stories),
429720
+ parts: record3.parts,
429721
+ relationships: record3.relationships,
429722
+ contentTypes: record3.contentTypes,
429723
+ media: record3.media,
429724
+ safety: record3.safety,
429725
+ snapshotToken: record3.snapshotToken.digest
429726
+ }));
429727
+ return projectionDigest;
429728
+ }
429674
429729
  };
429675
429730
  return { record: withDigest, storiesRebuilt, fullStoryRebuilds, fullPackageRebuild };
429676
429731
  }
@@ -429788,6 +429843,12 @@ function blockProjection(block, extraAtoms = []) {
429788
429843
  }
429789
429844
  function projectedNamespaceContexts(snapshot3, bootstrap, source) {
429790
429845
  const envelope = storyEnvelope(snapshot3.meta.storyKind, bootstrap);
429846
+ const cached2 = PROJECTED_NAMESPACE_CONTEXTS.get(source);
429847
+ if (cached2 && cached2.prefix === envelope.prefix && cached2.suffix === envelope.suffix && cached2.trailingXml === snapshot3.meta.trailingXml && cached2.blocks.length === snapshot3.blocks.length && snapshot3.blocks.every((block, index2) => {
429848
+ const prior = cached2.blocks[index2];
429849
+ return block.blockId === prior.blockId && block.leadingXml === prior.leadingXml && block.trailingXml === prior.trailingXml && block.splitFromBlockId === prior.splitFromBlockId;
429850
+ }))
429851
+ return cached2.contexts;
429791
429852
  let wrappers = envelope.prefix;
429792
429853
  const positions = new Map;
429793
429854
  const blocksById = new Map(snapshot3.blocks.map((block) => [block.blockId, block]));
@@ -429797,9 +429858,6 @@ function projectedNamespaceContexts(snapshot3, bootstrap, source) {
429797
429858
  wrappers += `<projection-slot id="${xmlEscape(block.blockId)}" source="${xmlEscape(block.splitFromBlockId ?? "")}"/>${block.trailingXml ?? ""}`;
429798
429859
  }
429799
429860
  wrappers += snapshot3.meta.trailingXml + envelope.suffix;
429800
- const cached2 = PROJECTED_NAMESPACE_CONTEXTS.get(source);
429801
- if (cached2?.wrappers === wrappers)
429802
- return cached2.contexts;
429803
429861
  const placement3 = new XmlEmissionContext(wrappers);
429804
429862
  const contexts = new Map(snapshot3.blocks.map((block) => {
429805
429863
  const inherited = placement3.at(positions.get(block.blockId));
@@ -429813,7 +429871,13 @@ function projectedNamespaceContexts(snapshot3, bootstrap, source) {
429813
429871
  }
429814
429872
  return [block.blockId, { inherited, source: sourceBindings ?? inherited }];
429815
429873
  }));
429816
- PROJECTED_NAMESPACE_CONTEXTS.set(source, { wrappers, contexts });
429874
+ PROJECTED_NAMESPACE_CONTEXTS.set(source, {
429875
+ prefix: envelope.prefix,
429876
+ suffix: envelope.suffix,
429877
+ trailingXml: snapshot3.meta.trailingXml,
429878
+ blocks: snapshot3.blocks.map(({ blockId, leadingXml, trailingXml, splitFromBlockId }) => ({ blockId, leadingXml, trailingXml, splitFromBlockId })),
429879
+ contexts
429880
+ });
429817
429881
  return contexts;
429818
429882
  }
429819
429883
  function hasRemovedTableBoundary(previous3, blocks, overlayDeletedBlockIds) {
@@ -429873,6 +429937,8 @@ function replaceProjectedTrailingXml(story, trailingXml, bootstrap) {
429873
429937
  if (start === null)
429874
429938
  throw new Error(`Story ${story.storyId} has no resolved trailing XML boundary.`);
429875
429939
  const suffix = trailingXml + envelope.suffix;
429940
+ if (story.xml.slice(start) === suffix)
429941
+ return story;
429876
429942
  const xml = story.xml.slice(0, start) + suffix;
429877
429943
  return { ...story, xml, byteLength: UTF8_ENCODER3.encode(xml).length };
429878
429944
  }
@@ -430448,9 +430514,12 @@ function removeRedundantSplitSeparators(projection, redundantBlockIds) {
430448
430514
  };
430449
430515
  }
430450
430516
  function composeTableStructuralProjection(input) {
430451
- const snapshotBlocks = snapshotStoryShard(shardReadTarget(input.handle)).blocks;
430517
+ const replacements = input.tableReplacements ?? readTableStructuralReplacements(shardReadTarget(input.handle));
430518
+ if (replacements.length === 0)
430519
+ return null;
430520
+ const snapshotBlocks = (input.readStorySnapshot ?? snapshotStoryShard)(shardReadTarget(input.handle)).blocks;
430452
430521
  const liveBlockIds = new Set(snapshotBlocks.map((block) => block.blockId));
430453
- const rawTableReplacements = (input.tableReplacements ?? readTableStructuralReplacements(shardReadTarget(input.handle))).map((replacement) => {
430522
+ const rawTableReplacements = replacements.map((replacement) => {
430454
430523
  if (!replacement.creationPlacement && !replacement.relocation && !replacement.rowReordered && replacement.splitChildren.length === 0)
430455
430524
  return replacement;
430456
430525
  const liveTableBlockIds = snapshotBlocks.filter((block) => block.structuralRefs.tableNodeId === replacement.tableNodeId).map((block) => block.blockId);
@@ -432911,7 +432980,7 @@ function canonicalStoryDigestInputs(stories) {
432911
432980
  tableStructuralOverlays: [...story.tableStructuralOverlays ?? []].sort((left, right) => left.tableNodeId < right.tableNodeId ? -1 : left.tableNodeId > right.tableNodeId ? 1 : 0)
432912
432981
  }));
432913
432982
  }
432914
- var WORD_ML_NS2 = 'xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"', WORD_ML_2010_NS = 'xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"', STORY_ROOT_NS, TEXT_DECODER7, STORY_BLOCK_INDEX_CACHE, SYNTHETIC_PARAGRAPH_BLOCK_ID_PREFIX4 = "__sd:paragraph:", UTF8_ENCODER3, SOURCE_XML_BYTE_ALIGNED_CACHE, XML_EMISSION_CONTEXTS, PROJECTED_NAMESPACE_CONTEXTS, PARAGRAPH_PROPERTY_ORDER, RUN_PROPERTY_CONTENT_LOCAL_NAMES;
432983
+ var WORD_ML_NS2 = 'xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"', WORD_ML_2010_NS = 'xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"', STORY_ROOT_NS, TEXT_DECODER7, STORY_BLOCK_INDEX_CACHE, SYNTHETIC_PARAGRAPH_BLOCK_ID_PREFIX4 = "__sd:paragraph:", UTF8_ENCODER3, SOURCE_XML_BYTE_ALIGNED_CACHE, XML_EMISSION_CONTEXTS, CONTENT_CONTROL_TOPOLOGIES, PROJECTED_NAMESPACE_CONTEXTS, PARAGRAPH_PROPERTY_ORDER, RUN_PROPERTY_CONTENT_LOCAL_NAMES;
432915
432984
  var init_materialize = __esm(() => {
432916
432985
  init_package_part();
432917
432986
  init_anchors();
@@ -432937,6 +433006,7 @@ var init_materialize = __esm(() => {
432937
433006
  UTF8_ENCODER3 = new TextEncoder;
432938
433007
  SOURCE_XML_BYTE_ALIGNED_CACHE = new WeakMap;
432939
433008
  XML_EMISSION_CONTEXTS = new WeakMap;
433009
+ CONTENT_CONTROL_TOPOLOGIES = new WeakMap;
432940
433010
  PROJECTED_NAMESPACE_CONTEXTS = new WeakMap;
432941
433011
  PARAGRAPH_PROPERTY_ORDER = new Map([
432942
433012
  "pStyle",
@@ -433270,8 +433340,143 @@ var init_freshness = __esm(() => {
433270
433340
  }
433271
433341
  });
433272
433342
 
433343
+ // ../../../v2/collaboration-v2/dist/projection/story-snapshot-reader.js
433344
+ function createProjectionStorySnapshotReader() {
433345
+ const stories = new Map;
433346
+ function drop(state) {
433347
+ state.dispose();
433348
+ stories.delete(state.scope.blocks);
433349
+ }
433350
+ function create10(scope) {
433351
+ const invalidate = () => {
433352
+ state.snapshot = null;
433353
+ };
433354
+ const onBlocks = (events) => {
433355
+ for (const event of events) {
433356
+ if (event.target === scope.blocks) {
433357
+ invalidate();
433358
+ continue;
433359
+ }
433360
+ let owner = event.target;
433361
+ while (owner && owner.parent !== scope.blocks) {
433362
+ owner = owner.parent;
433363
+ }
433364
+ if (owner instanceof YMap)
433365
+ state.dirty.add(owner);
433366
+ else
433367
+ invalidate();
433368
+ }
433369
+ };
433370
+ const onMeta = (events) => {
433371
+ if (events.some((event) => [...event.keysChanged ?? []].some((key2) => key2.startsWith("contentControlGroup:"))))
433372
+ invalidate();
433373
+ };
433374
+ const onDestroy = () => drop(state);
433375
+ const state = {
433376
+ scope,
433377
+ snapshot: null,
433378
+ indices: new Map,
433379
+ boundaries: new Map,
433380
+ dirty: new Set,
433381
+ dispose() {
433382
+ scope.blocks.unobserveDeep(onBlocks);
433383
+ scope.order.unobserveDeep(invalidate);
433384
+ scope.meta.unobserveDeep(onMeta);
433385
+ scope.doc.off("destroy", onDestroy);
433386
+ }
433387
+ };
433388
+ scope.blocks.observeDeep(onBlocks);
433389
+ scope.order.observeDeep(invalidate);
433390
+ scope.meta.observeDeep(onMeta);
433391
+ scope.doc.on("destroy", onDestroy);
433392
+ return state;
433393
+ }
433394
+ function read2(target) {
433395
+ const scope = resolveStoryShardScope(target);
433396
+ if (scope.meta.get(STORY_META_KEY.storyKind) !== STORY_KIND.main)
433397
+ return snapshotStoryShard(target);
433398
+ if (scope.doc._transaction || scope.doc._transactionCleanups.length > 0)
433399
+ return snapshotStoryShard(target);
433400
+ let state = stories.get(scope.blocks);
433401
+ if (state && (state.scope.meta !== scope.meta || state.scope.order !== scope.order || state.scope.tables !== scope.tables || state.scope.doc !== scope.doc)) {
433402
+ drop(state);
433403
+ state = undefined;
433404
+ }
433405
+ if (!state) {
433406
+ state = create10(scope);
433407
+ stories.set(scope.blocks, state);
433408
+ }
433409
+ if (state.snapshot && state.dirty.size) {
433410
+ const blocks = [...state.snapshot.blocks];
433411
+ for (const carrier of state.dirty) {
433412
+ const index2 = state.indices.get(carrier);
433413
+ const previous3 = index2 === undefined ? undefined : blocks[index2];
433414
+ if (!previous3 || carrier.get(BLOCK_KEY.blockId) !== previous3.blockId || carrier.get(BLOCK_KEY.mergedIntoBlockId)) {
433415
+ state.snapshot = null;
433416
+ break;
433417
+ }
433418
+ const block = snapshotBlock(carrier);
433419
+ const boundary = state.boundaries.get(carrier);
433420
+ blocks[index2] = boundary.suffix === undefined && !boundary.prefix ? block : {
433421
+ ...block,
433422
+ leadingXml: block.leadingXml + boundary.prefix,
433423
+ trailingXml: boundary.suffix
433424
+ };
433425
+ }
433426
+ if (state.snapshot)
433427
+ state.snapshot = { meta: readMeta(scope), blocks };
433428
+ }
433429
+ state.dirty.clear();
433430
+ if (!state.snapshot) {
433431
+ state.indices.clear();
433432
+ state.boundaries.clear();
433433
+ const snapshot3 = snapshotStoryShard(scope);
433434
+ if (snapshot3.blocks.length !== scope.blocks.length || snapshot3.blocks.some((block) => block.mergedIntoBlockId || block.mergedTailBlockIds.length)) {
433435
+ return snapshot3;
433436
+ }
433437
+ const indices = new Map;
433438
+ for (const [index2, block] of snapshot3.blocks.entries()) {
433439
+ const carrier = findBlockById(scope, block.blockId);
433440
+ if (!carrier || indices.has(carrier))
433441
+ return snapshot3;
433442
+ const leading = String(carrier.get(BLOCK_KEY.leadingXml) ?? "");
433443
+ if (!block.leadingXml.startsWith(leading))
433444
+ return snapshot3;
433445
+ state.boundaries.set(carrier, {
433446
+ prefix: block.leadingXml.slice(leading.length),
433447
+ suffix: block.trailingXml
433448
+ });
433449
+ indices.set(carrier, index2);
433450
+ }
433451
+ state.indices = indices;
433452
+ state.snapshot = snapshot3;
433453
+ }
433454
+ return { meta: readMeta(scope), blocks: state.snapshot.blocks };
433455
+ }
433456
+ return {
433457
+ read: read2,
433458
+ retain(targets) {
433459
+ const live = new Set(targets.map((target) => resolveStoryShardScope(target).blocks));
433460
+ for (const state of stories.values())
433461
+ if (!live.has(state.scope.blocks))
433462
+ drop(state);
433463
+ },
433464
+ dispose() {
433465
+ for (const state of stories.values())
433466
+ drop(state);
433467
+ }
433468
+ };
433469
+ }
433470
+ var init_story_snapshot_reader = __esm(() => {
433471
+ init_yjs();
433472
+ init_constants4();
433473
+ init_read_view();
433474
+ init_scope3();
433475
+ });
433476
+
433273
433477
  // ../../../v2/collaboration-v2/dist/projection/runtime.js
433274
433478
  function createCollabV2ProjectionRuntime(options) {
433479
+ const storySnapshots = createProjectionStorySnapshotReader();
433275
433480
  let freshness = PROJECTION_FRESHNESS.dirty;
433276
433481
  let blockingReason = null;
433277
433482
  let lastCleanSnapshot = null;
@@ -433333,12 +433538,14 @@ function createCollabV2ProjectionRuntime(options) {
433333
433538
  function materialize(snapshotToken) {
433334
433539
  const currentImport = getPackagePartsMap(options.rootDoc);
433335
433540
  const replaced = currentImport !== projectedImport;
433541
+ storySnapshots.retain(options.shardRegistry.listStories().map(shardReadTarget));
433336
433542
  const output = materializeProjection({
433337
433543
  snapshotToken,
433338
433544
  rootDoc: options.rootDoc,
433339
433545
  shardRegistry: options.shardRegistry,
433340
433546
  dirty: pendingDirty,
433341
- previousRecord: replaced ? null : lastCleanRecord
433547
+ previousRecord: replaced ? null : lastCleanRecord,
433548
+ readStorySnapshot: storySnapshots.read
433342
433549
  });
433343
433550
  projectedImport = currentImport;
433344
433551
  if (output.fullPackageRebuild)
@@ -433592,6 +433799,7 @@ function createCollabV2ProjectionRuntime(options) {
433592
433799
  hasCollabMutation = true;
433593
433800
  },
433594
433801
  reset() {
433802
+ storySnapshots.dispose();
433595
433803
  pendingDirty = [];
433596
433804
  diagnostics = [];
433597
433805
  freshness = PROJECTION_FRESHNESS.dirty;
@@ -433619,6 +433827,7 @@ function createCollabV2ProjectionRuntime(options) {
433619
433827
  return freshness === PROJECTION_FRESHNESS.clean && pendingDirty.length === 0;
433620
433828
  },
433621
433829
  dispose() {
433830
+ storySnapshots.dispose();
433622
433831
  disposed = true;
433623
433832
  freshness = PROJECTION_FRESHNESS.invalid;
433624
433833
  blockingReason = PROJECTION_BLOCKING_REASON.disposed;
@@ -433677,6 +433886,7 @@ var init_runtime5 = __esm(() => {
433677
433886
  init_checkpoint();
433678
433887
  init_reducer();
433679
433888
  init_schema3();
433889
+ init_story_snapshot_reader();
433680
433890
  DEFAULT_BYTES_ENCODER = {
433681
433891
  encode: encodeProjectionAsBytes
433682
433892
  };
@@ -439526,7 +439736,7 @@ function createCollabV2SessionProjectionController(options) {
439526
439736
  };
439527
439737
  }
439528
439738
  const forceStoryBytes = input.forceStoryBytes === true || sessionStoryAlignment === "room-realignment-required" && (remoteProjectionPending || deferredSessionAuthoritativeRemotePending);
439529
- if (!packageReplaced && !input.forceApply && !forceStoryBytes && lastAppliedRecord?.digest === record3.digest) {
439739
+ if (!packageReplaced && !input.forceApply && !forceStoryBytes && lastAppliedRecord === record3) {
439530
439740
  return { ok: true };
439531
439741
  }
439532
439742
  const tBuild = projectionTraceNow();