@superdoc/mcp 1.4.0-next.7 → 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 +412 -204
  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.7";
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;
@@ -203111,6 +203119,101 @@ var init_paragraph_property_history = __esm(() => {
203111
203119
  init_paragraph_property_namespaces();
203112
203120
  });
203113
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
+
203114
203217
  // ../../../v2/editor-core/dist/document/transactions/tracked-changes/review-decision-semantics.js
203115
203218
  function structuralDecisionBehavior(kind, decision) {
203116
203219
  if (kind === "paragraph-mark-deletion" && decision === "accept" || kind === "paragraph-mark-insertion" && decision === "reject" || kind === "section-break-deletion" && decision === "accept")
@@ -203680,7 +203783,7 @@ function mergeParagraphMarkedBoundary(lookupContext, xml, fragment3, namespaceBi
203680
203783
  return { ok: false, reason: "unsupported-context" };
203681
203784
  }
203682
203785
  const pendingInsertionTerminalDeletion = fragment3.structuralKind === "paragraph-mark-deletion" && isPendingFullParagraphInsertion(currentWithoutMarker, fragment3.tagPrefix);
203683
- 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);
203684
203787
  if (!merged)
203685
203788
  return { ok: false, reason: "invalid-input" };
203686
203789
  return {
@@ -203893,7 +203996,7 @@ function mergeParagraphXmlForDecisionWithWrappedSuccessor(firstXml, secondXml, w
203893
203996
  return null;
203894
203997
  return secondOpenMatch[0] + secondPPr + firstRuns + wrapper.openTag + secondRuns + wrapper.closeTag + secondCloseMatch[0];
203895
203998
  }
203896
- function mergeParagraphXmlKeepingPendingInsertion(firstXml, secondXml) {
203999
+ function mergeParagraphXmlKeepingPendingInsertion(firstXml, secondXml, namespaceBindings) {
203897
204000
  firstXml = expandEmptyParagraphForMerge(firstXml);
203898
204001
  secondXml = expandEmptyParagraphForMerge(secondXml);
203899
204002
  const firstOpenMatch = firstXml.match(/^<[\w.-]+:p\b[^>]*>/);
@@ -203906,9 +204009,14 @@ function mergeParagraphXmlKeepingPendingInsertion(firstXml, secondXml) {
203906
204009
  const secondInner = secondXml.slice(secondOpenMatch[0].length, secondXml.length - secondCloseMatch[0].length);
203907
204010
  const firstPPr = matchLeadingElement(firstInner, "pPr");
203908
204011
  const secondPPr = matchLeadingElement(secondInner, "pPr");
203909
- 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))))
203910
204018
  return null;
203911
- 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];
203912
204020
  }
203913
204021
  function isPendingFullParagraphInsertion(paragraphXml, prefix) {
203914
204022
  const parsed = collectXmlElementRanges(paragraphXml, {
@@ -205043,6 +205151,7 @@ var init_decide_engine = __esm(() => {
205043
205151
  init_paragraph_mark_format_history();
205044
205152
  init_paragraph_property_history();
205045
205153
  init_paragraph_property_namespaces();
205154
+ init_tracked_paragraph_properties();
205046
205155
  init_structural_groups();
205047
205156
  init_paragraph_property_block();
205048
205157
  init_block_deletion_text();
@@ -213039,97 +213148,6 @@ var init_tracked_block_replacement = __esm(() => {
213039
213148
  init_tracked_table_replacement();
213040
213149
  });
213041
213150
 
213042
- // ../../../v2/editor-core/dist/document/transactions/tracked-paragraph-properties.js
213043
- function prepareTrackedParagraphProperties(input) {
213044
- const prefix = [...input.namespaceBindings].find(([key2, uri]) => key2 && uri === NS_W)?.[0] ?? "w";
213045
- const read = (xml) => {
213046
- const source = xml || `<${prefix}:pPr/>`;
213047
- const parsed = collectXmlElementRanges(source, {
213048
- fragment: true,
213049
- additionalNamespaces: Object.fromEntries(input.namespaceBindings)
213050
- });
213051
- const ranges = parsed.ranges.sort((a, b) => a.start - b.start || b.end - a.end);
213052
- const root = ranges[0];
213053
- if (parsed.errors.length || !root || root.start !== 0 || root.end !== source.length || root.tag.namespaceUri !== NS_W || root.tag.localName !== "pPr")
213054
- return null;
213055
- if (ranges.some((range) => range.tag.namespaceUri === NS_W && ["ins", "del", "moveFrom", "moveTo", "pPrChange", "rPrChange", "sectPr"].includes(range.tag.localName)))
213056
- return null;
213057
- const children = [];
213058
- let cursor = root.openEnd;
213059
- for (const range of ranges.slice(1)) {
213060
- if (range.start < cursor)
213061
- continue;
213062
- if (source.slice(cursor, range.start).trim())
213063
- return null;
213064
- children.push(range);
213065
- cursor = range.end;
213066
- }
213067
- const marks = children.filter((child) => child.tag.namespaceUri === NS_W && child.tag.localName === "rPr");
213068
- if (marks.length > 1)
213069
- return null;
213070
- const mark2 = marks[0];
213071
- const baseChildren = children.filter((child) => child !== mark2).map((child) => source.slice(child.start, child.end)).join("");
213072
- return {
213073
- source,
213074
- root,
213075
- mark: mark2,
213076
- markXml: mark2 ? source.slice(mark2.start, mark2.end) : "",
213077
- baseChildren
213078
- };
213079
- };
213080
- const before = read(input.beforeXml);
213081
- const after = read(input.afterXml);
213082
- if (!before || !after)
213083
- return null;
213084
- const wordIds = [];
213085
- const markBindings = after.mark?.namespaceBindings ?? after.root.namespaceBindings;
213086
- const wrapperBindings = (kind) => ({
213087
- ...kind === "rPr" ? markBindings : after.root.namespaceBindings,
213088
- [prefix]: NS_W
213089
- });
213090
- const wrapper = (kind, old) => {
213091
- const id = input.stamp.revisionIds?.[wordIds.length] ?? input.stamp.revisionId + wordIds.length;
213092
- if (input.stamp.revisionIds && wordIds.length >= input.stamp.revisionIds.length)
213093
- return null;
213094
- wordIds.push(String(id));
213095
- const namespace = (kind === "rPr" ? markBindings : after.root.namespaceBindings)[prefix] === NS_W ? "" : ` xmlns:${prefix}="${NS_W}"`;
213096
- 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>`;
213097
- };
213098
- let mark = after.markXml;
213099
- if (before.markXml !== after.markXml) {
213100
- const oldMark = before.mark ? copyParagraphPropertyChild(before.source, before.mark, wrapperBindings("rPr")) : `<${prefix}:rPr/>`;
213101
- const change = wrapper("rPr", oldMark);
213102
- if (!change)
213103
- return null;
213104
- if (!after.mark || after.mark.tag.isSelfClosing) {
213105
- const open = after.mark ? after.markXml.replace(/\/>$/, ">") : `<${prefix}:rPr>`;
213106
- mark = open + change + `</${after.mark?.tag.name ?? `${prefix}:rPr`}>`;
213107
- } else {
213108
- const at = after.mark.closeStart - after.mark.start;
213109
- mark = after.markXml.slice(0, at) + change + after.markXml.slice(at);
213110
- }
213111
- }
213112
- let paragraphChange = "";
213113
- if (before.baseChildren !== after.baseChildren) {
213114
- const oldProperties = paragraphPropertyOpeningWithNamespaces(before.source, before.root, wrapperBindings("pPr")).replace(/\/>$/, ">") + before.baseChildren + `</${before.root.tag.name}>`;
213115
- const change = wrapper("pPr", oldProperties);
213116
- if (!change)
213117
- return null;
213118
- paragraphChange = change;
213119
- }
213120
- if (wordIds.length === 0)
213121
- return { xml: input.afterXml, wordIds };
213122
- return {
213123
- xml: after.source.slice(0, after.root.openEnd).replace(/\/>$/, ">") + after.baseChildren + mark + paragraphChange + `</${after.root.tag.name}>`,
213124
- wordIds
213125
- };
213126
- }
213127
- var init_tracked_paragraph_properties = __esm(() => {
213128
- init_xml_sax();
213129
- init_xml_text();
213130
- init_paragraph_property_namespaces();
213131
- });
213132
-
213133
213151
  // ../../../v2/editor-core/dist/document/transactions/tracked-terminal-paragraph-delete.js
213134
213152
  function prepareTrackedTerminalParagraphDeletion(input) {
213135
213153
  const read = (xml, namespaces) => {
@@ -213159,7 +213177,7 @@ function prepareTrackedTerminalParagraphDeletion(input) {
213159
213177
  if (!previous || !current)
213160
213178
  return null;
213161
213179
  const pendingInsertion = (() => {
213162
- if (!previous.properties || current.propertiesXml || !previous.runs.trim())
213180
+ if (!previous.properties || !previous.runs.trim())
213163
213181
  return false;
213164
213182
  const properties2 = collectXmlElementRanges(previous.propertiesXml, {
213165
213183
  fragment: true,
@@ -213186,6 +213204,8 @@ function prepareTrackedTerminalParagraphDeletion(input) {
213186
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";
213187
213205
  })();
213188
213206
  if (pendingInsertion) {
213207
+ if (!isSafeTrackedParagraphProperties(current.propertiesXml, new Map(Object.entries(current.root.namespaceBindings))))
213208
+ return null;
213189
213209
  const ids2 = input.stamp.revisionIds ?? [input.stamp.revisionId, input.stamp.revisionId + 1];
213190
213210
  if (ids2.length < 2)
213191
213211
  return null;
@@ -213209,7 +213229,7 @@ function prepareTrackedTerminalParagraphDeletion(input) {
213209
213229
  return null;
213210
213230
  return {
213211
213231
  previousXml: previous.opening + previousProperties + previous.runs + previous.closing,
213212
- currentXml: current.opening + deleted2.xml + current.closing,
213232
+ currentXml: current.opening + current.propertiesXml + deleted2.xml + current.closing,
213213
213233
  wordIds: [String(ids2[0]), ...deleted2.wordIds]
213214
213234
  };
213215
213235
  }
@@ -316552,9 +316572,9 @@ var init_codes = __esm(() => {
316552
316572
  });
316553
316573
 
316554
316574
  // ../../../v2/node_modules/.pnpm/micromark-util-symbol@2.0.1/node_modules/micromark-util-symbol/lib/constants.js
316555
- var constants;
316575
+ var constants2;
316556
316576
  var init_constants = __esm(() => {
316557
- constants = {
316577
+ constants2 = {
316558
316578
  attentionSideAfter: 2,
316559
316579
  attentionSideBefore: 1,
316560
316580
  atxHeadingOpeningFenceSizeMax: 6,
@@ -316828,7 +316848,7 @@ function splice(list, start, remove, items) {
316828
316848
  start = start > end ? end : start;
316829
316849
  }
316830
316850
  remove = remove > 0 ? remove : 0;
316831
- if (items.length < constants.v8MaxSafeChunkSize) {
316851
+ if (items.length < constants2.v8MaxSafeChunkSize) {
316832
316852
  parameters = Array.from(items);
316833
316853
  parameters.unshift(start, remove);
316834
316854
  list.splice(...parameters);
@@ -316836,11 +316856,11 @@ function splice(list, start, remove, items) {
316836
316856
  if (remove)
316837
316857
  list.splice(start, remove);
316838
316858
  while (chunkStart < items.length) {
316839
- parameters = items.slice(chunkStart, chunkStart + constants.v8MaxSafeChunkSize);
316859
+ parameters = items.slice(chunkStart, chunkStart + constants2.v8MaxSafeChunkSize);
316840
316860
  parameters.unshift(start, 0);
316841
316861
  list.splice(...parameters);
316842
- chunkStart += constants.v8MaxSafeChunkSize;
316843
- start += constants.v8MaxSafeChunkSize;
316862
+ chunkStart += constants2.v8MaxSafeChunkSize;
316863
+ start += constants2.v8MaxSafeChunkSize;
316844
316864
  }
316845
316865
  }
316846
316866
  }
@@ -316995,7 +317015,7 @@ function initializeContent(effects2) {
316995
317015
  }
316996
317016
  function lineStart(code) {
316997
317017
  const token = effects2.enter(types9.chunkText, {
316998
- contentType: constants.contentTypeText,
317018
+ contentType: constants2.contentTypeText,
316999
317019
  previous
317000
317020
  });
317001
317021
  if (previous) {
@@ -317123,7 +317143,7 @@ function initializeDocument(effects2) {
317123
317143
  childFlow = childFlow || self.parser.flow(self.now());
317124
317144
  effects2.enter(types9.chunkFlow, {
317125
317145
  _tokenizer: childFlow,
317126
- contentType: constants.contentTypeFlow,
317146
+ contentType: constants2.contentTypeFlow,
317127
317147
  previous: childToken
317128
317148
  });
317129
317149
  return flowContinue(code);
@@ -317208,7 +317228,7 @@ function initializeDocument(effects2) {
317208
317228
  }
317209
317229
  function tokenizeContainer(effects2, ok3, nok) {
317210
317230
  ok2(this.parser.constructs.disable.null, "expected `disable.null` to be populated");
317211
- 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);
317212
317232
  }
317213
317233
  var document3, containerConstruct;
317214
317234
  var init_document2 = __esm(() => {
@@ -317224,10 +317244,10 @@ var init_document2 = __esm(() => {
317224
317244
  // ../../../v2/node_modules/.pnpm/micromark-util-classify-character@2.0.1/node_modules/micromark-util-classify-character/dev/index.js
317225
317245
  function classifyCharacter(code) {
317226
317246
  if (code === codes.eof || markdownLineEndingOrSpace(code) || unicodeWhitespace(code)) {
317227
- return constants.characterGroupWhitespace;
317247
+ return constants2.characterGroupWhitespace;
317228
317248
  }
317229
317249
  if (unicodePunctuation(code)) {
317230
- return constants.characterGroupPunctuation;
317250
+ return constants2.characterGroupPunctuation;
317231
317251
  }
317232
317252
  }
317233
317253
  var init_dev6 = __esm(() => {
@@ -317360,8 +317380,8 @@ function tokenizeAttention(effects2, ok3) {
317360
317380
  const token = effects2.exit("attentionSequence");
317361
317381
  const after = classifyCharacter(code);
317362
317382
  ok2(attentionMarkers, "expected `attentionMarkers` to be populated");
317363
- const open = !after || after === constants.characterGroupPunctuation && before || attentionMarkers.includes(code);
317364
- 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);
317365
317385
  token._open = Boolean(marker === codes.asterisk ? open : open && (before || !close));
317366
317386
  token._close = Boolean(marker === codes.asterisk ? close : close && (after || !open));
317367
317387
  return ok3(code);
@@ -317421,7 +317441,7 @@ function tokenizeAutolink(effects2, ok3, nok) {
317421
317441
  size = 0;
317422
317442
  return urlInside;
317423
317443
  }
317424
- 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) {
317425
317445
  effects2.consume(code);
317426
317446
  return schemeInsideOrEmailAtext;
317427
317447
  }
@@ -317474,7 +317494,7 @@ function tokenizeAutolink(effects2, ok3, nok) {
317474
317494
  return emailValue(code);
317475
317495
  }
317476
317496
  function emailValue(code) {
317477
- if ((code === codes.dash || asciiAlphanumeric(code)) && size++ < constants.autolinkDomainSizeMax) {
317497
+ if ((code === codes.dash || asciiAlphanumeric(code)) && size++ < constants2.autolinkDomainSizeMax) {
317478
317498
  const next = code === codes.dash ? emailValue : emailLabel;
317479
317499
  effects2.consume(code);
317480
317500
  return next;
@@ -317546,7 +317566,7 @@ function tokenizeBlockQuoteContinuation(effects2, ok3, nok) {
317546
317566
  function contStart(code) {
317547
317567
  if (markdownSpace(code)) {
317548
317568
  ok2(self.parser.constructs.disable.null, "expected `disable.null` to be populated");
317549
- 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);
317550
317570
  }
317551
317571
  return contBefore(code);
317552
317572
  }
@@ -317627,7 +317647,7 @@ function tokenizeCharacterReference(effects2, ok3, nok) {
317627
317647
  return numeric;
317628
317648
  }
317629
317649
  effects2.enter(types9.characterReferenceValue);
317630
- max2 = constants.characterReferenceNamedSizeMax;
317650
+ max2 = constants2.characterReferenceNamedSizeMax;
317631
317651
  test = asciiAlphanumeric;
317632
317652
  return value2(code);
317633
317653
  }
@@ -317637,12 +317657,12 @@ function tokenizeCharacterReference(effects2, ok3, nok) {
317637
317657
  effects2.consume(code);
317638
317658
  effects2.exit(types9.characterReferenceMarkerHexadecimal);
317639
317659
  effects2.enter(types9.characterReferenceValue);
317640
- max2 = constants.characterReferenceHexadecimalSizeMax;
317660
+ max2 = constants2.characterReferenceHexadecimalSizeMax;
317641
317661
  test = asciiHexDigit;
317642
317662
  return value2;
317643
317663
  }
317644
317664
  effects2.enter(types9.characterReferenceValue);
317645
- max2 = constants.characterReferenceDecimalSizeMax;
317665
+ max2 = constants2.characterReferenceDecimalSizeMax;
317646
317666
  test = asciiDigit;
317647
317667
  return value2(code);
317648
317668
  }
@@ -317704,7 +317724,7 @@ function tokenizeCodeFenced(effects2, ok3, nok) {
317704
317724
  effects2.consume(code);
317705
317725
  return sequenceOpen;
317706
317726
  }
317707
- if (sizeOpen < constants.codeFencedSequenceSizeMin) {
317727
+ if (sizeOpen < constants2.codeFencedSequenceSizeMin) {
317708
317728
  return nok(code);
317709
317729
  }
317710
317730
  effects2.exit(types9.codeFencedFenceSequence);
@@ -317716,7 +317736,7 @@ function tokenizeCodeFenced(effects2, ok3, nok) {
317716
317736
  return self.interrupt ? ok3(code) : effects2.check(nonLazyContinuation, atNonLazyBreak, after)(code);
317717
317737
  }
317718
317738
  effects2.enter(types9.codeFencedFenceInfo);
317719
- effects2.enter(types9.chunkString, { contentType: constants.contentTypeString });
317739
+ effects2.enter(types9.chunkString, { contentType: constants2.contentTypeString });
317720
317740
  return info(code);
317721
317741
  }
317722
317742
  function info(code) {
@@ -317741,7 +317761,7 @@ function tokenizeCodeFenced(effects2, ok3, nok) {
317741
317761
  return infoBefore(code);
317742
317762
  }
317743
317763
  effects2.enter(types9.codeFencedFenceMeta);
317744
- effects2.enter(types9.chunkString, { contentType: constants.contentTypeString });
317764
+ effects2.enter(types9.chunkString, { contentType: constants2.contentTypeString });
317745
317765
  return meta3(code);
317746
317766
  }
317747
317767
  function meta3(code) {
@@ -317802,7 +317822,7 @@ function tokenizeCodeFenced(effects2, ok3, nok) {
317802
317822
  function start2(code) {
317803
317823
  ok2(self.parser.constructs.disable.null, "expected `disable.null` to be populated");
317804
317824
  effects3.enter(types9.codeFencedFence);
317805
- 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);
317806
317826
  }
317807
317827
  function beforeSequenceClose(code) {
317808
317828
  if (code === marker) {
@@ -317873,11 +317893,11 @@ function tokenizeCodeIndented(effects2, ok3, nok) {
317873
317893
  function start(code) {
317874
317894
  ok2(markdownSpace(code));
317875
317895
  effects2.enter(types9.codeIndented);
317876
- return factorySpace(effects2, afterPrefix, types9.linePrefix, constants.tabSize + 1)(code);
317896
+ return factorySpace(effects2, afterPrefix, types9.linePrefix, constants2.tabSize + 1)(code);
317877
317897
  }
317878
317898
  function afterPrefix(code) {
317879
317899
  const tail = self.events[self.events.length - 1];
317880
- 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);
317881
317901
  }
317882
317902
  function atBreak(code) {
317883
317903
  if (code === codes.eof) {
@@ -317915,11 +317935,11 @@ function tokenizeFurtherStart(effects2, ok3, nok) {
317915
317935
  effects2.exit(types9.lineEnding);
317916
317936
  return furtherStart2;
317917
317937
  }
317918
- return factorySpace(effects2, afterPrefix, types9.linePrefix, constants.tabSize + 1)(code);
317938
+ return factorySpace(effects2, afterPrefix, types9.linePrefix, constants2.tabSize + 1)(code);
317919
317939
  }
317920
317940
  function afterPrefix(code) {
317921
317941
  const tail = self.events[self.events.length - 1];
317922
- 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);
317923
317943
  }
317924
317944
  }
317925
317945
  var codeIndented, furtherStart;
@@ -318131,12 +318151,12 @@ class SpliceBuffer {
318131
318151
  }
318132
318152
  function chunkedPush(list, right) {
318133
318153
  let chunkStart = 0;
318134
- if (right.length < constants.v8MaxSafeChunkSize) {
318154
+ if (right.length < constants2.v8MaxSafeChunkSize) {
318135
318155
  list.push(...right);
318136
318156
  } else {
318137
318157
  while (chunkStart < right.length) {
318138
- list.push(...right.slice(chunkStart, chunkStart + constants.v8MaxSafeChunkSize));
318139
- chunkStart += constants.v8MaxSafeChunkSize;
318158
+ list.push(...right.slice(chunkStart, chunkStart + constants2.v8MaxSafeChunkSize));
318159
+ chunkStart += constants2.v8MaxSafeChunkSize;
318140
318160
  }
318141
318161
  }
318142
318162
  }
@@ -318315,7 +318335,7 @@ function tokenizeContent(effects2, ok3) {
318315
318335
  ok2(code !== codes.eof && !markdownLineEnding(code), "expected no eof or eol");
318316
318336
  effects2.enter(types9.content);
318317
318337
  previous2 = effects2.enter(types9.chunkContent, {
318318
- contentType: constants.contentTypeContent
318338
+ contentType: constants2.contentTypeContent
318319
318339
  });
318320
318340
  return chunkInside(code);
318321
318341
  }
@@ -318340,7 +318360,7 @@ function tokenizeContent(effects2, ok3) {
318340
318360
  effects2.exit(types9.chunkContent);
318341
318361
  ok2(previous2, "expected previous token");
318342
318362
  previous2.next = effects2.enter(types9.chunkContent, {
318343
- contentType: constants.contentTypeContent,
318363
+ contentType: constants2.contentTypeContent,
318344
318364
  previous: previous2
318345
318365
  });
318346
318366
  previous2 = previous2.next;
@@ -318364,7 +318384,7 @@ function tokenizeContinuation(effects2, ok3, nok) {
318364
318384
  }
318365
318385
  ok2(self.parser.constructs.disable.null, "expected `disable.null` to be populated");
318366
318386
  const tail = self.events[self.events.length - 1];
318367
- 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) {
318368
318388
  return ok3(code);
318369
318389
  }
318370
318390
  return effects2.interrupt(self.parser.constructs.flow, nok, ok3)(code);
@@ -318401,7 +318421,7 @@ function factoryDestination(effects2, ok3, nok, type, literalType2, literalMarke
318401
318421
  effects2.enter(type);
318402
318422
  effects2.enter(rawType);
318403
318423
  effects2.enter(stringType2);
318404
- effects2.enter(types9.chunkString, { contentType: constants.contentTypeString });
318424
+ effects2.enter(types9.chunkString, { contentType: constants2.contentTypeString });
318405
318425
  return raw(code);
318406
318426
  }
318407
318427
  function enclosedBefore(code) {
@@ -318414,7 +318434,7 @@ function factoryDestination(effects2, ok3, nok, type, literalType2, literalMarke
318414
318434
  return ok3;
318415
318435
  }
318416
318436
  effects2.enter(stringType2);
318417
- effects2.enter(types9.chunkString, { contentType: constants.contentTypeString });
318437
+ effects2.enter(types9.chunkString, { contentType: constants2.contentTypeString });
318418
318438
  return enclosed(code);
318419
318439
  }
318420
318440
  function enclosed(code) {
@@ -318489,7 +318509,7 @@ function factoryLabel(effects2, ok3, nok, type, markerType, stringType2) {
318489
318509
  return atBreak;
318490
318510
  }
318491
318511
  function atBreak(code) {
318492
- 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) {
318493
318513
  return nok(code);
318494
318514
  }
318495
318515
  if (code === codes.rightSquareBracket) {
@@ -318506,11 +318526,11 @@ function factoryLabel(effects2, ok3, nok, type, markerType, stringType2) {
318506
318526
  effects2.exit(types9.lineEnding);
318507
318527
  return atBreak;
318508
318528
  }
318509
- effects2.enter(types9.chunkString, { contentType: constants.contentTypeString });
318529
+ effects2.enter(types9.chunkString, { contentType: constants2.contentTypeString });
318510
318530
  return labelInside(code);
318511
318531
  }
318512
318532
  function labelInside(code) {
318513
- 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) {
318514
318534
  effects2.exit(types9.chunkString);
318515
318535
  return atBreak(code);
318516
318536
  }
@@ -318574,7 +318594,7 @@ function factoryTitle(effects2, ok3, nok, type, markerType, stringType2) {
318574
318594
  effects2.exit(types9.lineEnding);
318575
318595
  return factorySpace(effects2, atBreak, types9.linePrefix);
318576
318596
  }
318577
- effects2.enter(types9.chunkString, { contentType: constants.contentTypeString });
318597
+ effects2.enter(types9.chunkString, { contentType: constants2.contentTypeString });
318578
318598
  return inside(code);
318579
318599
  }
318580
318600
  function inside(code) {
@@ -318750,7 +318770,7 @@ function resolveHeadingAtx(events, context) {
318750
318770
  type: types9.chunkText,
318751
318771
  start: events[contentStart][1].start,
318752
318772
  end: events[contentEnd][1].end,
318753
- contentType: constants.contentTypeText
318773
+ contentType: constants2.contentTypeText
318754
318774
  };
318755
318775
  splice(events, contentStart, contentEnd - contentStart + 1, [
318756
318776
  ["enter", content3, context],
@@ -318774,7 +318794,7 @@ function tokenizeHeadingAtx(effects2, ok3, nok) {
318774
318794
  return sequenceOpen(code);
318775
318795
  }
318776
318796
  function sequenceOpen(code) {
318777
- if (code === codes.numberSign && size++ < constants.atxHeadingOpeningFenceSizeMax) {
318797
+ if (code === codes.numberSign && size++ < constants2.atxHeadingOpeningFenceSizeMax) {
318778
318798
  effects2.consume(code);
318779
318799
  return sequenceOpen;
318780
318800
  }
@@ -318945,7 +318965,7 @@ function tokenizeHtmlFlow(effects2, ok3, nok) {
318945
318965
  }
318946
318966
  if (code === codes.questionMark) {
318947
318967
  effects2.consume(code);
318948
- marker = constants.htmlInstruction;
318968
+ marker = constants2.htmlInstruction;
318949
318969
  return self.interrupt ? ok3 : continuationDeclarationInside;
318950
318970
  }
318951
318971
  if (asciiAlpha(code)) {
@@ -318959,18 +318979,18 @@ function tokenizeHtmlFlow(effects2, ok3, nok) {
318959
318979
  function declarationOpen(code) {
318960
318980
  if (code === codes.dash) {
318961
318981
  effects2.consume(code);
318962
- marker = constants.htmlComment;
318982
+ marker = constants2.htmlComment;
318963
318983
  return commentOpenInside;
318964
318984
  }
318965
318985
  if (code === codes.leftSquareBracket) {
318966
318986
  effects2.consume(code);
318967
- marker = constants.htmlCdata;
318987
+ marker = constants2.htmlCdata;
318968
318988
  index = 0;
318969
318989
  return cdataOpenInside;
318970
318990
  }
318971
318991
  if (asciiAlpha(code)) {
318972
318992
  effects2.consume(code);
318973
- marker = constants.htmlDeclaration;
318993
+ marker = constants2.htmlDeclaration;
318974
318994
  return self.interrupt ? ok3 : continuationDeclarationInside;
318975
318995
  }
318976
318996
  return nok(code);
@@ -318983,7 +319003,7 @@ function tokenizeHtmlFlow(effects2, ok3, nok) {
318983
319003
  return nok(code);
318984
319004
  }
318985
319005
  function cdataOpenInside(code) {
318986
- const value2 = constants.cdataOpeningString;
319006
+ const value2 = constants2.cdataOpeningString;
318987
319007
  if (code === value2.charCodeAt(index++)) {
318988
319008
  effects2.consume(code);
318989
319009
  if (index === value2.length) {
@@ -319007,18 +319027,18 @@ function tokenizeHtmlFlow(effects2, ok3, nok) {
319007
319027
  const slash = code === codes.slash;
319008
319028
  const name = buffer.toLowerCase();
319009
319029
  if (!slash && !closingTag && htmlRawNames.includes(name)) {
319010
- marker = constants.htmlRaw;
319030
+ marker = constants2.htmlRaw;
319011
319031
  return self.interrupt ? ok3(code) : continuation(code);
319012
319032
  }
319013
319033
  if (htmlBlockNames.includes(buffer.toLowerCase())) {
319014
- marker = constants.htmlBasic;
319034
+ marker = constants2.htmlBasic;
319015
319035
  if (slash) {
319016
319036
  effects2.consume(code);
319017
319037
  return basicSelfClosing;
319018
319038
  }
319019
319039
  return self.interrupt ? ok3(code) : continuation(code);
319020
319040
  }
319021
- marker = constants.htmlComplete;
319041
+ marker = constants2.htmlComplete;
319022
319042
  return self.interrupt && !self.parser.lazy[self.now().line] ? nok(code) : closingTag ? completeClosingTagAfter(code) : completeAttributeNameBefore(code);
319023
319043
  }
319024
319044
  if (code === codes.dash || asciiAlphanumeric(code)) {
@@ -319133,27 +319153,27 @@ function tokenizeHtmlFlow(effects2, ok3, nok) {
319133
319153
  return nok(code);
319134
319154
  }
319135
319155
  function continuation(code) {
319136
- if (code === codes.dash && marker === constants.htmlComment) {
319156
+ if (code === codes.dash && marker === constants2.htmlComment) {
319137
319157
  effects2.consume(code);
319138
319158
  return continuationCommentInside;
319139
319159
  }
319140
- if (code === codes.lessThan && marker === constants.htmlRaw) {
319160
+ if (code === codes.lessThan && marker === constants2.htmlRaw) {
319141
319161
  effects2.consume(code);
319142
319162
  return continuationRawTagOpen;
319143
319163
  }
319144
- if (code === codes.greaterThan && marker === constants.htmlDeclaration) {
319164
+ if (code === codes.greaterThan && marker === constants2.htmlDeclaration) {
319145
319165
  effects2.consume(code);
319146
319166
  return continuationClose;
319147
319167
  }
319148
- if (code === codes.questionMark && marker === constants.htmlInstruction) {
319168
+ if (code === codes.questionMark && marker === constants2.htmlInstruction) {
319149
319169
  effects2.consume(code);
319150
319170
  return continuationDeclarationInside;
319151
319171
  }
319152
- if (code === codes.rightSquareBracket && marker === constants.htmlCdata) {
319172
+ if (code === codes.rightSquareBracket && marker === constants2.htmlCdata) {
319153
319173
  effects2.consume(code);
319154
319174
  return continuationCdataInside;
319155
319175
  }
319156
- if (markdownLineEnding(code) && (marker === constants.htmlBasic || marker === constants.htmlComplete)) {
319176
+ if (markdownLineEnding(code) && (marker === constants2.htmlBasic || marker === constants2.htmlComplete)) {
319157
319177
  effects2.exit(types9.htmlFlowData);
319158
319178
  return effects2.check(blankLineBefore, continuationAfter, continuationStart)(code);
319159
319179
  }
@@ -319205,7 +319225,7 @@ function tokenizeHtmlFlow(effects2, ok3, nok) {
319205
319225
  }
319206
319226
  return continuation(code);
319207
319227
  }
319208
- if (asciiAlpha(code) && buffer.length < constants.htmlRawSizeMax) {
319228
+ if (asciiAlpha(code) && buffer.length < constants2.htmlRawSizeMax) {
319209
319229
  ok2(code !== null);
319210
319230
  effects2.consume(code);
319211
319231
  buffer += String.fromCharCode(code);
@@ -319225,7 +319245,7 @@ function tokenizeHtmlFlow(effects2, ok3, nok) {
319225
319245
  effects2.consume(code);
319226
319246
  return continuationClose;
319227
319247
  }
319228
- if (code === codes.dash && marker === constants.htmlComment) {
319248
+ if (code === codes.dash && marker === constants2.htmlComment) {
319229
319249
  effects2.consume(code);
319230
319250
  return continuationDeclarationInside;
319231
319251
  }
@@ -319372,7 +319392,7 @@ function tokenizeHtmlText(effects2, ok3, nok) {
319372
319392
  return code === codes.greaterThan ? end(code) : code === codes.dash ? commentClose(code) : comment(code);
319373
319393
  }
319374
319394
  function cdataOpenInside(code) {
319375
- const value2 = constants.cdataOpeningString;
319395
+ const value2 = constants2.cdataOpeningString;
319376
319396
  if (code === value2.charCodeAt(index++)) {
319377
319397
  effects2.consume(code);
319378
319398
  return index === value2.length ? cdata : cdataOpenInside;
@@ -319588,7 +319608,7 @@ function tokenizeHtmlText(effects2, ok3, nok) {
319588
319608
  }
319589
319609
  function lineEndingAfter(code) {
319590
319610
  ok2(self.parser.constructs.disable.null, "expected `disable.null` to be populated");
319591
- 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);
319592
319612
  }
319593
319613
  function lineEndingAfterPrefix(code) {
319594
319614
  effects2.enter(types9.htmlTextData);
@@ -319751,7 +319771,7 @@ function tokenizeResource(effects2, ok3, nok) {
319751
319771
  if (code === codes.rightParenthesis) {
319752
319772
  return resourceEnd(code);
319753
319773
  }
319754
- 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);
319755
319775
  }
319756
319776
  function resourceDestinationAfter(code) {
319757
319777
  return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects2, resourceBetween)(code) : resourceEnd(code);
@@ -319942,7 +319962,7 @@ function tokenizeThematicBreak(effects2, ok3, nok) {
319942
319962
  effects2.enter(types9.thematicBreakSequence);
319943
319963
  return sequence(code);
319944
319964
  }
319945
- if (size >= constants.thematicBreakMarkerCountMin && (code === codes.eof || markdownLineEnding(code))) {
319965
+ if (size >= constants2.thematicBreakMarkerCountMin && (code === codes.eof || markdownLineEnding(code))) {
319946
319966
  effects2.exit(types9.thematicBreak);
319947
319967
  return ok3(code);
319948
319968
  }
@@ -319999,7 +320019,7 @@ function tokenizeListStart(effects2, ok3, nok) {
319999
320019
  }
320000
320020
  function inside(code) {
320001
320021
  ok2(self.containerState, "expected state");
320002
- if (asciiDigit(code) && ++size < constants.listItemValueSizeMax) {
320022
+ if (asciiDigit(code) && ++size < constants2.listItemValueSizeMax) {
320003
320023
  effects2.consume(code);
320004
320024
  return inside;
320005
320025
  }
@@ -320066,7 +320086,7 @@ function tokenizeListContinuation(effects2, ok3, nok) {
320066
320086
  self.containerState._closeFlow = true;
320067
320087
  self.interrupt = undefined;
320068
320088
  ok2(self.parser.constructs.disable.null, "expected `disable.null` to be populated");
320069
- 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);
320070
320090
  }
320071
320091
  }
320072
320092
  function tokenizeIndent(effects2, ok3, nok) {
@@ -320088,7 +320108,7 @@ function tokenizeListEnd(effects2) {
320088
320108
  function tokenizeListItemPrefixWhitespace(effects2, ok3, nok) {
320089
320109
  const self = this;
320090
320110
  ok2(self.parser.constructs.disable.null, "expected `disable.null` to be populated");
320091
- 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);
320092
320112
  function afterPrefix(code) {
320093
320113
  const tail = self.events[self.events.length - 1];
320094
320114
  return !markdownSpace(code) && tail && tail[1].type === types9.listItemPrefixWhitespace ? ok3(code) : nok(code);
@@ -320386,7 +320406,7 @@ function resolveAllLineSuffixes(events, context) {
320386
320406
  }
320387
320407
  if (size) {
320388
320408
  const token = {
320389
- 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,
320390
320410
  start: {
320391
320411
  _bufferIndex: index ? bufferIndex : data.start._bufferIndex + bufferIndex,
320392
320412
  _index: data.start._index + index,
@@ -321642,7 +321662,7 @@ function preprocess2() {
321642
321662
  break;
321643
321663
  }
321644
321664
  case codes.ht: {
321645
- next = Math.ceil(column / constants.tabSize) * constants.tabSize;
321665
+ next = Math.ceil(column / constants2.tabSize) * constants2.tabSize;
321646
321666
  chunks.push(codes.horizontalTab);
321647
321667
  while (column++ < next)
321648
321668
  chunks.push(codes.virtualSpace);
@@ -321696,7 +321716,7 @@ function decode4($0, $1, $2) {
321696
321716
  if (head === codes.numberSign) {
321697
321717
  const head2 = $2.charCodeAt(1);
321698
321718
  const hex3 = head2 === codes.lowercaseX || head2 === codes.uppercaseX;
321699
- 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);
321700
321720
  }
321701
321721
  return decodeNamedCharacterReference($2) || $0;
321702
321722
  }
@@ -322043,7 +322063,7 @@ function compiler(options) {
322043
322063
  const ancestor = this.stack[this.stack.length - 2];
322044
322064
  ok2(ancestor, "expected nodes on stack");
322045
322065
  ok2(ancestor.type === "list", "expected list on stack");
322046
- ancestor.start = Number.parseInt(this.sliceSerialize(token), constants.numericBaseDecimal);
322066
+ ancestor.start = Number.parseInt(this.sliceSerialize(token), constants2.numericBaseDecimal);
322047
322067
  this.data.expectingFirstListItemValue = undefined;
322048
322068
  }
322049
322069
  }
@@ -322284,7 +322304,7 @@ function compiler(options) {
322284
322304
  const type = this.data.characterReferenceType;
322285
322305
  let value2;
322286
322306
  if (type) {
322287
- value2 = decodeNumericCharacterReference(data2, type === types9.characterReferenceMarkerNumeric ? constants.numericBaseDecimal : constants.numericBaseHexadecimal);
322307
+ value2 = decodeNumericCharacterReference(data2, type === types9.characterReferenceMarkerNumeric ? constants2.numericBaseDecimal : constants2.numericBaseHexadecimal);
322288
322308
  this.data.characterReferenceType = undefined;
322289
322309
  } else {
322290
322310
  const result = decodeNamedCharacterReference(data2);
@@ -323584,7 +323604,7 @@ function tokenizeGfmFootnoteCall(effects2, ok4, nok) {
323584
323604
  return callData;
323585
323605
  }
323586
323606
  function callData(code2) {
323587
- 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)) {
323588
323608
  return nok(code2);
323589
323609
  }
323590
323610
  if (code2 === codes.rightSquareBracket) {
@@ -323643,7 +323663,7 @@ function tokenizeDefinitionStart(effects2, ok4, nok) {
323643
323663
  return nok(code2);
323644
323664
  }
323645
323665
  function labelInside(code2) {
323646
- 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)) {
323647
323667
  return nok(code2);
323648
323668
  }
323649
323669
  if (code2 === codes.rightSquareBracket) {
@@ -323695,10 +323715,10 @@ function gfmFootnoteDefinitionEnd(effects2) {
323695
323715
  }
323696
323716
  function tokenizeIndent2(effects2, ok4, nok) {
323697
323717
  const self = this;
323698
- return factorySpace(effects2, afterPrefix, "gfmFootnoteDefinitionIndent", constants.tabSize + 1);
323718
+ return factorySpace(effects2, afterPrefix, "gfmFootnoteDefinitionIndent", constants2.tabSize + 1);
323699
323719
  function afterPrefix(code2) {
323700
323720
  const tail = self.events[self.events.length - 1];
323701
- 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);
323702
323722
  }
323703
323723
  }
323704
323724
  var indent;
@@ -323810,8 +323830,8 @@ function gfmStrikethrough(options) {
323810
323830
  return nok(code2);
323811
323831
  const token = effects2.exit("strikethroughSequenceTemporary");
323812
323832
  const after = classifyCharacter(code2);
323813
- token._open = !after || after === constants.attentionSideAfter && Boolean(before);
323814
- 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);
323815
323835
  return ok4(code2);
323816
323836
  }
323817
323837
  }
@@ -324010,7 +324030,7 @@ function tokenizeTable(effects2, ok4, nok) {
324010
324030
  seen = false;
324011
324031
  if (markdownSpace(code2)) {
324012
324032
  ok2(self.parser.constructs.disable.null, "expected `disabled.null`");
324013
- 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);
324014
324034
  }
324015
324035
  return headDelimiterBefore(code2);
324016
324036
  }
@@ -324261,7 +324281,7 @@ function flushCell(map3, context, range, rowKind, rowEnd, previousCell) {
324261
324281
  const end = context.events[range[3]];
324262
324282
  start[1].end = Object.assign({}, end[1].end);
324263
324283
  start[1].type = types9.chunkText;
324264
- start[1].contentType = constants.contentTypeText;
324284
+ start[1].contentType = constants2.contentTypeText;
324265
324285
  if (range[3] > range[2] + 1) {
324266
324286
  const a = range[2] + 1;
324267
324287
  const b = range[3] - range[2] - 1;
@@ -388597,7 +388617,7 @@ function serializeSelectionRange(context, target, includeHtml, options) {
388597
388617
  };
388598
388618
  const tableCellPath = boundaryMap.byBlockId(entry.blockId)?.tableCellPath ?? [];
388599
388619
  const blockSdtPath = boundaryMap.byBlockId(entry.blockId)?.blockSdtPath ?? [];
388600
- const properties = readParagraphProperties(paragraphXml);
388620
+ const properties = readParagraphProperties2(paragraphXml);
388601
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);
388602
388622
  const fullyCovered = !selectedInlineControl && from === 0 && to === map3.visibleLength && (options?.wholeParagraphs === true || startEntry.ordinal !== endEntry.ordinal || properties.styleRef !== undefined || properties.numbering !== undefined || hasParagraphProperties(paragraphXml));
388603
388623
  const styleModel = copyStyleModel ?? (copyStyleModel = compileCopyStyleModel(context));
@@ -389630,7 +389650,7 @@ function capturePPrXml(paragraphXml, notes) {
389630
389650
  return null;
389631
389651
  return pPr;
389632
389652
  }
389633
- function readParagraphProperties(paragraphXml) {
389653
+ function readParagraphProperties2(paragraphXml) {
389634
389654
  const pPr = /<w:pPr\b(?:[^>]*\/>|[^>]*>[\s\S]*?<\/w:pPr\s*>)/.exec(paragraphXml)?.[0] ?? "";
389635
389655
  const styleRef = /<w:pStyle\b[^>]*w:val="([^"]+)"/.exec(pPr)?.[1];
389636
389656
  const numPr = /<w:numPr\b[\s\S]*?<\/w:numPr>/.exec(pPr)?.[0];
@@ -429198,6 +429218,7 @@ function emissionContext(owner, xml) {
429198
429218
  return cached2.context;
429199
429219
  }
429200
429220
  function materializeProjection(input) {
429221
+ const readStorySnapshot = input.readStorySnapshot ?? snapshotStoryShard;
429201
429222
  const previousById = new Map;
429202
429223
  const previousByPartUri = new Map;
429203
429224
  if (input.previousRecord) {
@@ -429290,6 +429311,7 @@ function materializeProjection(input) {
429290
429311
  let fullStoryRebuilds = 0;
429291
429312
  const storyHandles = input.shardRegistry.listStories();
429292
429313
  const stories = [];
429314
+ const contentControlTopologies = new Map;
429293
429315
  const sourceBootstrapDigests = new Map;
429294
429316
  for (const handle of storyHandles) {
429295
429317
  const readTarget = shardReadTarget(handle);
@@ -429307,7 +429329,7 @@ function materializeProjection(input) {
429307
429329
  }
429308
429330
  const namespaces = previous3 ? emissionContext(previous3, previous3.xml) : bootstrap?.sourceXml ? emissionContext(bootstrap, bootstrap.sourceXml) : new XmlEmissionContext("");
429309
429331
  const sourceNamespaces = bootstrap?.sourceXml ? emissionContext(bootstrap, bootstrap.sourceXml) : namespaces;
429310
- 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;
429311
429333
  const syntheticAtoms = buildSyntheticCommentAtomsForStory({
429312
429334
  storyDoc: readTarget,
429313
429335
  storyShardId: handle.shardId,
@@ -429315,7 +429337,7 @@ function materializeProjection(input) {
429315
429337
  });
429316
429338
  if (syntheticAtoms.size > 0)
429317
429339
  useBootstrapSourceXml = false;
429318
- 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) {
429319
429341
  stories.push(previous3);
429320
429342
  continue;
429321
429343
  }
@@ -429327,12 +429349,30 @@ function materializeProjection(input) {
429327
429349
  const tableReplacements = readTableStructuralReplacements(readTarget);
429328
429350
  const previousBlockIndex = previous3 ? blockDigestIndex(previous3.blockDigests) : null;
429329
429351
  const insertedBlockHint = previousBlockIndex && [...dirtyStoryBlocks.get(handle.shardId) ?? []].some((blockId) => !previousBlockIndex.has(blockId));
429330
- const structuralSnapshot = previous3 && (wholeStoryDirtyShardIds.has(handle.shardId) || insertedBlockHint) ? snapshotStoryShard(readTarget) : null;
429352
+ const structuralSnapshot = previous3 && (wholeStoryDirtyShardIds.has(handle.shardId) || insertedBlockHint) ? readStorySnapshot(readTarget) : null;
429331
429353
  const overlaidTableIds = structuralSnapshot ? new Set(tableReplacements.map((table) => table.tableNodeId)) : null;
429332
429354
  const restoredTableBoundary = structuralSnapshot && previousBlockIndex ? structuralSnapshot.blocks.some((block) => block.structuralRefs.tableNodeId != null && !previousBlockIndex.has(block.blockId) && !overlaidTableIds.has(block.structuralRefs.tableNodeId)) : false;
429333
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;
429334
- if (hasContentControlGroups(resolveStoryShardScope(readTarget)) || restoredTableBoundary || removedTableBoundary) {
429335
- 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);
429336
429376
  const placements2 = projectedNamespaceContexts(snapshot4, bootstrap, sourceNamespaces);
429337
429377
  const blocks = snapshot4.blocks.map((block) => ({
429338
429378
  blockId: block.blockId,
@@ -429346,6 +429386,7 @@ function materializeProjection(input) {
429346
429386
  const composed = composeStoryProjection(snapshot4.meta.storyKind, blocks, bootstrap, snapshot4.meta.trailingXml);
429347
429387
  const base3 = { ...composed, partUri: partUriHint, storyId: storyIdHint, storyKind: snapshot4.meta.storyKind };
429348
429388
  const projected = composeTableStructuralProjection({
429389
+ readStorySnapshot,
429349
429390
  handle,
429350
429391
  previous: base3,
429351
429392
  bootstrap,
@@ -429380,7 +429421,7 @@ function materializeProjection(input) {
429380
429421
  blockHints.add(blockId);
429381
429422
  }
429382
429423
  if (blockHints && blockHints.size > 0 && previous3) {
429383
- const currentSnapshot = structuralSnapshot ?? snapshotStoryShard(readTarget);
429424
+ const currentSnapshot = structuralSnapshot ?? readStorySnapshot(readTarget);
429384
429425
  let placements2;
429385
429426
  const currentBlockIds = currentSnapshot.blocks.map((block) => block.blockId);
429386
429427
  if (wholeStoryDirtyShardIds.has(handle.shardId)) {
@@ -429520,6 +429561,7 @@ function materializeProjection(input) {
429520
429561
  };
429521
429562
  })();
429522
429563
  const projectedWithTables = composeTableStructuralProjection({
429564
+ readStorySnapshot,
429523
429565
  handle,
429524
429566
  previous: blockPatchedStory,
429525
429567
  bootstrap,
@@ -429535,6 +429577,7 @@ function materializeProjection(input) {
429535
429577
  storiesRebuilt += 1;
429536
429578
  } else if (tableReplacements.length > 0) {
429537
429579
  const projectedWithTables = composeTableStructuralProjection({
429580
+ readStorySnapshot,
429538
429581
  handle,
429539
429582
  previous: previous3,
429540
429583
  bootstrap,
@@ -429555,6 +429598,7 @@ function materializeProjection(input) {
429555
429598
  }
429556
429599
  }
429557
429600
  const tableStructuralProjection = composeTableStructuralProjection({
429601
+ readStorySnapshot,
429558
429602
  handle,
429559
429603
  previous: previous3,
429560
429604
  bootstrap,
@@ -429570,7 +429614,7 @@ function materializeProjection(input) {
429570
429614
  storiesRebuilt += 1;
429571
429615
  continue;
429572
429616
  }
429573
- const snapshot3 = snapshotStoryShard(readTarget);
429617
+ const snapshot3 = readStorySnapshot(readTarget);
429574
429618
  const placements = projectedNamespaceContexts(snapshot3, bootstrap, sourceNamespaces);
429575
429619
  const partUri = snapshot3.meta.sourcePartUri || `/word/story-${snapshot3.meta.storyId}.xml`;
429576
429620
  const blockDigests = [];
@@ -429628,6 +429672,11 @@ function materializeProjection(input) {
429628
429672
  stories[index2] = { ...story, sourceBootstrapDigest: digest6 };
429629
429673
  }
429630
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
+ }
429631
429680
  let relationships = input.previousRecord?.relationships ? [...input.previousRecord.relationships] : [];
429632
429681
  let parts = input.previousRecord?.parts ? [...input.previousRecord.parts] : [];
429633
429682
  let contentTypes = input.previousRecord?.contentTypes ?? { defaults: [], overrides: [] };
@@ -429662,17 +429711,21 @@ function materializeProjection(input) {
429662
429711
  safety,
429663
429712
  digest: ""
429664
429713
  };
429714
+ let projectionDigest;
429665
429715
  const withDigest = {
429666
429716
  ...record3,
429667
- digest: canonicalDigest({
429668
- stories: canonicalStoryDigestInputs(record3.stories),
429669
- parts: record3.parts,
429670
- relationships: record3.relationships,
429671
- contentTypes: record3.contentTypes,
429672
- media: record3.media,
429673
- safety: record3.safety,
429674
- snapshotToken: record3.snapshotToken.digest
429675
- })
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
+ }
429676
429729
  };
429677
429730
  return { record: withDigest, storiesRebuilt, fullStoryRebuilds, fullPackageRebuild };
429678
429731
  }
@@ -429790,6 +429843,12 @@ function blockProjection(block, extraAtoms = []) {
429790
429843
  }
429791
429844
  function projectedNamespaceContexts(snapshot3, bootstrap, source) {
429792
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;
429793
429852
  let wrappers = envelope.prefix;
429794
429853
  const positions = new Map;
429795
429854
  const blocksById = new Map(snapshot3.blocks.map((block) => [block.blockId, block]));
@@ -429799,9 +429858,6 @@ function projectedNamespaceContexts(snapshot3, bootstrap, source) {
429799
429858
  wrappers += `<projection-slot id="${xmlEscape(block.blockId)}" source="${xmlEscape(block.splitFromBlockId ?? "")}"/>${block.trailingXml ?? ""}`;
429800
429859
  }
429801
429860
  wrappers += snapshot3.meta.trailingXml + envelope.suffix;
429802
- const cached2 = PROJECTED_NAMESPACE_CONTEXTS.get(source);
429803
- if (cached2?.wrappers === wrappers)
429804
- return cached2.contexts;
429805
429861
  const placement3 = new XmlEmissionContext(wrappers);
429806
429862
  const contexts = new Map(snapshot3.blocks.map((block) => {
429807
429863
  const inherited = placement3.at(positions.get(block.blockId));
@@ -429815,7 +429871,13 @@ function projectedNamespaceContexts(snapshot3, bootstrap, source) {
429815
429871
  }
429816
429872
  return [block.blockId, { inherited, source: sourceBindings ?? inherited }];
429817
429873
  }));
429818
- 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
+ });
429819
429881
  return contexts;
429820
429882
  }
429821
429883
  function hasRemovedTableBoundary(previous3, blocks, overlayDeletedBlockIds) {
@@ -429875,6 +429937,8 @@ function replaceProjectedTrailingXml(story, trailingXml, bootstrap) {
429875
429937
  if (start === null)
429876
429938
  throw new Error(`Story ${story.storyId} has no resolved trailing XML boundary.`);
429877
429939
  const suffix = trailingXml + envelope.suffix;
429940
+ if (story.xml.slice(start) === suffix)
429941
+ return story;
429878
429942
  const xml = story.xml.slice(0, start) + suffix;
429879
429943
  return { ...story, xml, byteLength: UTF8_ENCODER3.encode(xml).length };
429880
429944
  }
@@ -430450,9 +430514,12 @@ function removeRedundantSplitSeparators(projection, redundantBlockIds) {
430450
430514
  };
430451
430515
  }
430452
430516
  function composeTableStructuralProjection(input) {
430453
- 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;
430454
430521
  const liveBlockIds = new Set(snapshotBlocks.map((block) => block.blockId));
430455
- const rawTableReplacements = (input.tableReplacements ?? readTableStructuralReplacements(shardReadTarget(input.handle))).map((replacement) => {
430522
+ const rawTableReplacements = replacements.map((replacement) => {
430456
430523
  if (!replacement.creationPlacement && !replacement.relocation && !replacement.rowReordered && replacement.splitChildren.length === 0)
430457
430524
  return replacement;
430458
430525
  const liveTableBlockIds = snapshotBlocks.filter((block) => block.structuralRefs.tableNodeId === replacement.tableNodeId).map((block) => block.blockId);
@@ -432913,7 +432980,7 @@ function canonicalStoryDigestInputs(stories) {
432913
432980
  tableStructuralOverlays: [...story.tableStructuralOverlays ?? []].sort((left, right) => left.tableNodeId < right.tableNodeId ? -1 : left.tableNodeId > right.tableNodeId ? 1 : 0)
432914
432981
  }));
432915
432982
  }
432916
- 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;
432917
432984
  var init_materialize = __esm(() => {
432918
432985
  init_package_part();
432919
432986
  init_anchors();
@@ -432939,6 +433006,7 @@ var init_materialize = __esm(() => {
432939
433006
  UTF8_ENCODER3 = new TextEncoder;
432940
433007
  SOURCE_XML_BYTE_ALIGNED_CACHE = new WeakMap;
432941
433008
  XML_EMISSION_CONTEXTS = new WeakMap;
433009
+ CONTENT_CONTROL_TOPOLOGIES = new WeakMap;
432942
433010
  PROJECTED_NAMESPACE_CONTEXTS = new WeakMap;
432943
433011
  PARAGRAPH_PROPERTY_ORDER = new Map([
432944
433012
  "pStyle",
@@ -433272,8 +433340,143 @@ var init_freshness = __esm(() => {
433272
433340
  }
433273
433341
  });
433274
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
+
433275
433477
  // ../../../v2/collaboration-v2/dist/projection/runtime.js
433276
433478
  function createCollabV2ProjectionRuntime(options) {
433479
+ const storySnapshots = createProjectionStorySnapshotReader();
433277
433480
  let freshness = PROJECTION_FRESHNESS.dirty;
433278
433481
  let blockingReason = null;
433279
433482
  let lastCleanSnapshot = null;
@@ -433335,12 +433538,14 @@ function createCollabV2ProjectionRuntime(options) {
433335
433538
  function materialize(snapshotToken) {
433336
433539
  const currentImport = getPackagePartsMap(options.rootDoc);
433337
433540
  const replaced = currentImport !== projectedImport;
433541
+ storySnapshots.retain(options.shardRegistry.listStories().map(shardReadTarget));
433338
433542
  const output = materializeProjection({
433339
433543
  snapshotToken,
433340
433544
  rootDoc: options.rootDoc,
433341
433545
  shardRegistry: options.shardRegistry,
433342
433546
  dirty: pendingDirty,
433343
- previousRecord: replaced ? null : lastCleanRecord
433547
+ previousRecord: replaced ? null : lastCleanRecord,
433548
+ readStorySnapshot: storySnapshots.read
433344
433549
  });
433345
433550
  projectedImport = currentImport;
433346
433551
  if (output.fullPackageRebuild)
@@ -433594,6 +433799,7 @@ function createCollabV2ProjectionRuntime(options) {
433594
433799
  hasCollabMutation = true;
433595
433800
  },
433596
433801
  reset() {
433802
+ storySnapshots.dispose();
433597
433803
  pendingDirty = [];
433598
433804
  diagnostics = [];
433599
433805
  freshness = PROJECTION_FRESHNESS.dirty;
@@ -433621,6 +433827,7 @@ function createCollabV2ProjectionRuntime(options) {
433621
433827
  return freshness === PROJECTION_FRESHNESS.clean && pendingDirty.length === 0;
433622
433828
  },
433623
433829
  dispose() {
433830
+ storySnapshots.dispose();
433624
433831
  disposed = true;
433625
433832
  freshness = PROJECTION_FRESHNESS.invalid;
433626
433833
  blockingReason = PROJECTION_BLOCKING_REASON.disposed;
@@ -433679,6 +433886,7 @@ var init_runtime5 = __esm(() => {
433679
433886
  init_checkpoint();
433680
433887
  init_reducer();
433681
433888
  init_schema3();
433889
+ init_story_snapshot_reader();
433682
433890
  DEFAULT_BYTES_ENCODER = {
433683
433891
  encode: encodeProjectionAsBytes
433684
433892
  };
@@ -439528,7 +439736,7 @@ function createCollabV2SessionProjectionController(options) {
439528
439736
  };
439529
439737
  }
439530
439738
  const forceStoryBytes = input.forceStoryBytes === true || sessionStoryAlignment === "room-realignment-required" && (remoteProjectionPending || deferredSessionAuthoritativeRemotePending);
439531
- if (!packageReplaced && !input.forceApply && !forceStoryBytes && lastAppliedRecord?.digest === record3.digest) {
439739
+ if (!packageReplaced && !input.forceApply && !forceStoryBytes && lastAppliedRecord === record3) {
439532
439740
  return { ok: true };
439533
439741
  }
439534
439742
  const tBuild = projectionTraceNow();