@superdoc/mcp 1.2.1-next.4 → 1.2.1-next.5

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 +1040 -588
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -31314,7 +31314,7 @@ var init_host = __esm(() => {
31314
31314
  });
31315
31315
 
31316
31316
  // ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
31317
- var SDK_VERSION = "2.15.1-next.4";
31317
+ var SDK_VERSION = "2.15.1-next.5";
31318
31318
 
31319
31319
  // ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
31320
31320
  import { chmodSync, existsSync } from "node:fs";
@@ -121309,7 +121309,39 @@ function prepareTextboxAtomReplacement(state, source, perPart) {
121309
121309
  storyId: record3.ownerStoryId,
121310
121310
  blockId: record3.ownerBlockId,
121311
121311
  beforeXml: decoder.decode(bytes.subarray(start, end)),
121312
- afterXml: decoder.decode(after)
121312
+ afterXml: decoder.decode(after),
121313
+ ...textboxOwnerRenderFacts(state, record3, patch)
121314
+ };
121315
+ }
121316
+ function textboxOwnerRenderFacts(state, record3, patch) {
121317
+ const ownerRange = record3.ownerParagraphRange;
121318
+ const ownerStoryId = record3.ownerStoryId;
121319
+ if (!ownerRange || !ownerStoryId || !record3.ownerBlockId || patch.kind !== "replaceBytes")
121320
+ return {};
121321
+ if (patch.startByte < ownerRange[0] || patch.endByte > ownerRange[1])
121322
+ return {};
121323
+ const entry = state.paragraphIndexes.get(ownerStoryId)?.byParaId(record3.ownerBlockId);
121324
+ const story = state.stories.get(ownerStoryId);
121325
+ const part = state.parts.get(record3.ownerPartUri);
121326
+ if (!entry || !story || !part || entry.byteStart !== ownerRange[0] || entry.byteEnd !== ownerRange[1] || entry.partUri !== record3.ownerPartUri)
121327
+ return {};
121328
+ return {
121329
+ ownerRenderRange: {
121330
+ storyId: ownerStoryId,
121331
+ storyRevision: story.descriptor.revision,
121332
+ partUri: record3.ownerPartUri,
121333
+ partRevision: part.descriptor.revision,
121334
+ startByte: entry.byteStart,
121335
+ endByte: entry.byteEnd,
121336
+ paragraphByteStart: entry.byteStart,
121337
+ paragraphByteEnd: entry.byteEnd,
121338
+ startBlockId: entry.blockId,
121339
+ endBlockId: entry.blockId,
121340
+ startOffset: 0,
121341
+ endOffset: entry.textLength,
121342
+ sourceAddress: { blockId: entry.blockId, range: { start: 0, end: entry.textLength } }
121343
+ },
121344
+ previousContentRange: [record3.contentRange[0], record3.contentRange[1]]
121313
121345
  };
121314
121346
  }
121315
121347
  var decoder;
@@ -131996,6 +132028,8 @@ function createSDTxPerfProbe() {
131996
132028
  catalogMaintenanceMs: null,
131997
132029
  catalogTextSplicesApplied: null,
131998
132030
  catalogTableSlicesReparsed: null,
132031
+ catalogFactsBuilds: null,
132032
+ catalogFactsBytesParsed: null,
131999
132033
  trackedTextNamespaceTableParagraphHits: null,
132000
132034
  trackedTextNamespacePartFallbacks: null,
132001
132035
  addressResolveMs: null,
@@ -143969,7 +144003,7 @@ function buildExactPartMutationProof(input) {
143969
144003
  return validateExactPartMutationProof(proof) ? proof : null;
143970
144004
  }
143971
144005
  function validateExactPartMutationProof(proof) {
143972
- if (!proof || proof.schemaVersion !== 1 || proof.provenance !== "tracked-text-decide" || typeof proof.partUri !== "string" || proof.partUri.length === 0 || !Number.isSafeInteger(proof.beforeByteLength) || !Number.isSafeInteger(proof.afterByteLength) || proof.beforeByteLength < 0 || proof.afterByteLength < 0 || !Array.isArray(proof.splices) || proof.splices.length === 0)
144006
+ if (!proof || proof.schemaVersion !== 1 || proof.provenance !== "tracked-text-decide" && proof.provenance !== "nested-story-text-edit" || typeof proof.partUri !== "string" || proof.partUri.length === 0 || !Number.isSafeInteger(proof.beforeByteLength) || !Number.isSafeInteger(proof.afterByteLength) || proof.beforeByteLength < 0 || proof.afterByteLength < 0 || !Array.isArray(proof.splices) || proof.splices.length === 0)
143973
144007
  return null;
143974
144008
  let previousBeforeEnd = 0;
143975
144009
  let previousAfterEnd = 0;
@@ -143990,10 +144024,36 @@ function validateExactPartMutationProof(proof) {
143990
144024
  partUri: proof.partUri,
143991
144025
  beforeByteLength: proof.beforeByteLength,
143992
144026
  afterByteLength: proof.afterByteLength,
143993
- provenance: "tracked-text-decide",
144027
+ provenance: proof.provenance,
143994
144028
  splices: Object.freeze(splices)
143995
144029
  });
143996
144030
  }
144031
+ function buildExactPartMutationProofFromWindows(input) {
144032
+ if (input.windows.length === 0)
144033
+ return null;
144034
+ const windows = [...input.windows].sort((left, right) => left.startByte - right.startByte || left.endByte - right.endByte);
144035
+ const splices = [];
144036
+ let cumulativeDelta = 0;
144037
+ for (const window2 of windows) {
144038
+ const afterStart = window2.startByte + cumulativeDelta;
144039
+ splices.push({
144040
+ beforeStart: window2.startByte,
144041
+ beforeEnd: window2.endByte,
144042
+ afterStart,
144043
+ afterEnd: afterStart + window2.afterLength
144044
+ });
144045
+ cumulativeDelta += window2.afterLength - (window2.endByte - window2.startByte);
144046
+ }
144047
+ const proof = {
144048
+ schemaVersion: 1,
144049
+ partUri: input.partUri,
144050
+ beforeByteLength: input.beforeByteLength,
144051
+ afterByteLength: input.beforeByteLength + cumulativeDelta,
144052
+ provenance: input.provenance,
144053
+ splices: coalesceAdjacentSplices(splices)
144054
+ };
144055
+ return validateExactPartMutationProof(proof) ? proof : null;
144056
+ }
143997
144057
  function exactUnchangedRanges(delta) {
143998
144058
  const ranges = [];
143999
144059
  let beforeCursor = 0;
@@ -176287,7 +176347,14 @@ function buildSDRenderCommitEnvelope(state, prepared, result, context = {}, opti
176287
176347
  }
176288
176348
  if (op.on.storyId !== state.mainStoryId)
176289
176349
  return broad("non-main-story");
176290
- const storyEffects = exactStoryEffectsForPrimary(op.on.storyId, prepared.resolvedTargets.stories, result.storiesChanged ?? [], result.auxiliaryStoryEffects ?? []);
176350
+ const ownerContentEffects = source.sourceKind === "textboxAtomReplacement" ? textboxOwnerContentEffects(state, prepared, result.storiesChanged ?? []) : [];
176351
+ if (!ownerContentEffects)
176352
+ return broad("multi-story");
176353
+ const ownerContentStoryIds = new Set(ownerContentEffects.map((effect) => effect.storyId));
176354
+ const storyEffects = exactStoryEffectsForPrimary(op.on.storyId, prepared.resolvedTargets.stories, result.storiesChanged ?? [], [
176355
+ ...(result.auxiliaryStoryEffects ?? []).filter((effect) => !ownerContentStoryIds.has(effect.storyId)),
176356
+ ...ownerContentEffects
176357
+ ]);
176291
176358
  if (!storyEffects)
176292
176359
  return broad("multi-story");
176293
176360
  if (result.partsChanged?.length !== 1 || prepared.resolvedTargets.partUris.length !== 1) {
@@ -176412,7 +176479,7 @@ function buildSDRenderCommitEnvelope(state, prepared, result, context = {}, opti
176412
176479
  changeMode: prepared.source.changeMode,
176413
176480
  coordinateSpace: prepared.source.on.coordinateSpace ?? "visible"
176414
176481
  } : null;
176415
- const sliceDependencyReason = trackedDecisionRefDelta ? classifyTrackedDecisionSliceDependency(postParagraphXml, context.originParagraphXml, trackedDecisionRefDelta.kind) : classifyUnprovedSliceDependency(postParagraphXml, trackedAnnotations, context.originParagraphXml, {
176482
+ const sliceDependencyReason = source.sourceKind === "textboxAtomReplacement" ? classifyTextboxAtomSliceDependency(prepared, postParagraphXml, context.originParagraphXml, trackedAnnotations) : trackedDecisionRefDelta ? classifyTrackedDecisionSliceDependency(postParagraphXml, context.originParagraphXml, trackedDecisionRefDelta.kind) : classifyUnprovedSliceDependency(postParagraphXml, trackedAnnotations, context.originParagraphXml, {
176416
176483
  allowTrackedWrapperDelta: source.sourceKind === "trackedChangeDecide",
176417
176484
  trackedCarrierRefinementProved,
176418
176485
  trackedTextResolutionProved
@@ -176504,6 +176571,7 @@ function buildSDRenderCommitEnvelope(state, prepared, result, context = {}, opti
176504
176571
  postCommitXml,
176505
176572
  ...!retainWholeOwner ? { postCommitPayloadKind: "paragraph" } : {},
176506
176573
  postCommitParagraphXml: postParagraphXml,
176574
+ ...textboxStoriesWithin(state, op.on.storyId, currentOwnerByteStart, currentOwnerByteEnd),
176507
176575
  dependencies: {
176508
176576
  parts: dependencyParts,
176509
176577
  section: section.dependency
@@ -176519,6 +176587,18 @@ function buildSDRenderCommitEnvelope(state, prepared, result, context = {}, opti
176519
176587
  }
176520
176588
  };
176521
176589
  }
176590
+ function textboxStoriesWithin(state, ownerStoryId, bodyChildByteStart, bodyChildByteEnd) {
176591
+ const stories = [];
176592
+ for (const record3 of state.textboxRegistry.records) {
176593
+ const ownerRange = record3.ownerParagraphRange;
176594
+ if (!record3.supported || record3.ownerStoryId !== ownerStoryId || !ownerRange || ownerRange[0] < bodyChildByteStart || ownerRange[1] > bodyChildByteEnd)
176595
+ continue;
176596
+ const descriptor = getStoryDescriptorFromState(state, record3.storyId);
176597
+ if (descriptor?.textbox)
176598
+ stories.push(descriptor);
176599
+ }
176600
+ return stories.length > 0 ? { textboxStories: stories } : {};
176601
+ }
176522
176602
  function captureTrackedDecisionAllResolvedProof(state, prepared, base2) {
176523
176603
  if (prepared.source.kind !== "trackedChangeDecide")
176524
176604
  return null;
@@ -176692,7 +176772,7 @@ function exactStoryEffectsForPrimary(primaryStoryId, preparedStoryIds, storyDelt
176692
176772
  if (effect.storyId === primaryStoryId || auxiliaryById.has(effect.storyId))
176693
176773
  return null;
176694
176774
  const delta = storyDeltas.find((candidate2) => candidate2.storyId === effect.storyId);
176695
- if (!delta || delta.previousRevision !== effect.previousRevision || delta.nextRevision !== effect.nextRevision || !validContentRange(effect.previousContentRange) || !validContentRange(effect.currentContentRange) || effect.kind === "revision-only" !== rangesEqual2(effect.previousContentRange, effect.currentContentRange))
176775
+ if (!delta || delta.previousRevision !== effect.previousRevision || delta.nextRevision !== effect.nextRevision || !validContentRange(effect.previousContentRange) || !validContentRange(effect.currentContentRange) || effect.kind !== "owner-content" && effect.kind === "revision-only" !== rangesEqual2(effect.previousContentRange, effect.currentContentRange))
176696
176776
  return null;
176697
176777
  auxiliaryById.set(effect.storyId, effect);
176698
176778
  }
@@ -178113,7 +178193,44 @@ function emptyFacts(stories) {
178113
178193
  structuralDirty: false
178114
178194
  };
178115
178195
  }
178196
+ function resolveTextboxAtomRenderSource(state, prepared) {
178197
+ const source = prepared.source;
178198
+ if (source.kind !== "editText" && source.kind !== "insertInlineControl")
178199
+ return null;
178200
+ const changeMode = source.kind === "editText" ? source.changeMode : source.changeMode ?? "direct";
178201
+ if (changeMode !== "direct")
178202
+ return null;
178203
+ const atom = prepared.backendExtensions.storySurface?.inlineAtomReplacement;
178204
+ const on = atom?.ownerRenderRange;
178205
+ if (!atom || !on || !atom.previousContentRange)
178206
+ return null;
178207
+ const record3 = state.textboxRegistry.byStoryId.get(source.on.storyId);
178208
+ if (!record3?.supported || !state.mainStoryId || atom.storyId !== state.mainStoryId || on.storyId !== state.mainStoryId || record3.ownerStoryId !== state.mainStoryId || record3.ownerBlockId !== atom.blockId || on.startBlockId !== atom.blockId || on.endBlockId !== atom.blockId || on.partUri !== source.on.partUri)
178209
+ return null;
178210
+ return { sourceKind: "textboxAtomReplacement", changeMode: "direct", on };
178211
+ }
178212
+ function textboxOwnerContentEffects(state, prepared, storyDeltas) {
178213
+ const source = prepared.source;
178214
+ if (source.kind !== "editText" && source.kind !== "insertInlineControl")
178215
+ return null;
178216
+ const previousContentRange = prepared.backendExtensions.storySurface?.inlineAtomReplacement?.previousContentRange;
178217
+ const record3 = state.textboxRegistry.byStoryId.get(source.on.storyId);
178218
+ const delta = storyDeltas.find((candidate2) => candidate2.storyId === source.on.storyId);
178219
+ if (!previousContentRange || !record3?.supported || !delta)
178220
+ return null;
178221
+ return [{
178222
+ storyId: source.on.storyId,
178223
+ kind: "owner-content",
178224
+ previousContentRange: [previousContentRange[0], previousContentRange[1]],
178225
+ currentContentRange: [record3.contentRange[0], record3.contentRange[1]],
178226
+ previousRevision: delta.previousRevision,
178227
+ nextRevision: delta.nextRevision
178228
+ }];
178229
+ }
178116
178230
  function resolveNarrowTextRenderSource(state, prepared, options) {
178231
+ const textboxOwner = resolveTextboxAtomRenderSource(state, prepared);
178232
+ if (textboxOwner)
178233
+ return textboxOwner;
178117
178234
  if (prepared.source.kind === "editText") {
178118
178235
  return {
178119
178236
  sourceKind: "editText",
@@ -178202,7 +178319,22 @@ function resolveTrackedDecisionParagraphScopeFromGroup(prepared, patchGroup) {
178202
178319
  }
178203
178320
  function resolveLocalizedParagraphPatch(patchGroup, prepared, source, revisions) {
178204
178321
  const partEntry = patchGroup.perPart[source.on.partUri];
178205
- if (!partEntry || partEntry.kind !== "modify" || partEntry.patches.length !== 1)
178322
+ if (!partEntry || partEntry.kind !== "modify")
178323
+ return null;
178324
+ if (source.sourceKind === "textboxAtomReplacement") {
178325
+ const window2 = { startByte: source.on.paragraphByteStart, endByte: source.on.paragraphByteEnd };
178326
+ let delta2 = 0;
178327
+ for (const candidate2 of partEntry.patches) {
178328
+ const candidateDelta = patchByteDelta(candidate2);
178329
+ if (candidateDelta == null || !patchContainedByWindow(candidate2, window2))
178330
+ return null;
178331
+ delta2 += candidateDelta;
178332
+ }
178333
+ if (partEntry.patches.length === 0)
178334
+ return null;
178335
+ return { postStart: window2.startByte, postEnd: window2.endByte + delta2, ...revisions };
178336
+ }
178337
+ if (partEntry.patches.length !== 1)
178206
178338
  return null;
178207
178339
  const patch = partEntry.patches[0];
178208
178340
  if (source.sourceKind === "editText" || source.sourceKind === "formatRunRange" || source.sourceKind === "storyFormatMutation" || source.sourceKind === "insertInlineControl") {
@@ -178714,6 +178846,31 @@ function classifyUnprovedSliceDependency(xml, trackedAnnotations, originXml, opt
178714
178846
  }
178715
178847
  return null;
178716
178848
  }
178849
+ function classifyTextboxAtomSliceDependency(prepared, postOwnerXml, originOwnerXml, trackedAnnotations) {
178850
+ const atom = prepared.backendExtensions.storySurface?.inlineAtomReplacement;
178851
+ if (!atom || originOwnerXml == null)
178852
+ return "origin-slice-unavailable";
178853
+ const originAt = originOwnerXml.indexOf(atom.beforeXml);
178854
+ const postAt = postOwnerXml.indexOf(atom.afterXml);
178855
+ if (originAt < 0 || postAt !== originAt || originOwnerXml.indexOf(atom.beforeXml, originAt + 1) >= 0 || originOwnerXml.slice(0, originAt) !== postOwnerXml.slice(0, postAt) || originOwnerXml.slice(originAt + atom.beforeXml.length) !== postOwnerXml.slice(postAt + atom.afterXml.length)) {
178856
+ return "global-dependency-change";
178857
+ }
178858
+ const beforeBodies = [...atom.beforeXml.matchAll(TEXTBOX_CONTENT_RE)];
178859
+ const afterBodies = [...atom.afterXml.matchAll(TEXTBOX_CONTENT_RE)];
178860
+ const hostShell = (xml) => xml.replace(TEXTBOX_CONTENT_RE, "$1$3");
178861
+ if (beforeBodies.length === 0 || beforeBodies.length !== afterBodies.length || hostShell(atom.beforeXml) !== hostShell(atom.afterXml) || TEXT_DEPENDENT_SHAPE_SIZE_RE.test(atom.beforeXml)) {
178862
+ return "global-dependency-change";
178863
+ }
178864
+ const ownerOutsideHost = classifyUnprovedSliceDependency(postOwnerXml.slice(0, postAt) + postOwnerXml.slice(postAt + atom.afterXml.length), trackedAnnotations, originOwnerXml.slice(0, originAt) + originOwnerXml.slice(originAt + atom.beforeXml.length));
178865
+ if (ownerOutsideHost)
178866
+ return ownerOutsideHost;
178867
+ for (let index = 0;index < beforeBodies.length; index += 1) {
178868
+ const reason = classifyUnprovedSliceDependency(afterBodies[index][2], trackedAnnotations, beforeBodies[index][2]);
178869
+ if (reason)
178870
+ return reason;
178871
+ }
178872
+ return null;
178873
+ }
178717
178874
  function classifyTrackedDecisionSliceDependency(xml, originXml, direction) {
178718
178875
  if (originXml == null)
178719
178876
  return "origin-slice-unavailable";
@@ -179383,7 +179540,7 @@ function collapseStoryDeltas(deltas) {
179383
179540
  function unique2(values) {
179384
179541
  return [...new Set(values)];
179385
179542
  }
179386
- var TD24, TE6, RECEIPT_RENDER_COMMITS, RENDER_COMMIT_CARRIER_ENVELOPES, RECEIPT_RENDER_COMMIT_CARRIER, MAX_NARROW_SLICE_BYTES, TRACKED_WRAPPER_RE, TRACKED_WRAPPER_TAG_RE, TRACKED_WRAPPER_TOKEN_RE, FAIL_CLOSED_REF_OR_ANCHOR_RE, FAIL_CLOSED_NON_COMMENT_REF_OR_ANCHOR_RE, COMMENT_ANCHOR_RE, STRUCTURAL_NOTE_REF_RE, STRUCTURAL_REVIEW_ANCHOR_TAG_RE, STRUCTURAL_REVIEW_RANGE_TAG_RE, BOOKMARK_ANCHOR_RE, BOOKMARK_ANCHOR_TAG_RE, VISIBLE_TEXT_RUN_RE, GLOBAL_SLICE_DEPENDENCY_RE, SECTION_PROPERTIES_DEPENDENCY_RE, PAGE_OR_COLUMN_BREAK_RE, INLINE_SDT_DEPENDENCY_RE, PAGE_BREAK_BEFORE_DEPENDENCY_RE, NUMBERING_PROPERTY_RE2, PARAGRAPH_OPEN_TAG_RE, NATIVE_PARA_ID_ATTR_RE, FIELD_TOKEN_RE, FIELD_SIGNATURE_TOKEN_RE, NON_FIELD_GLOBAL_SLICE_DEPENDENCY_RE, DISABLED_PAGE_BREAK_BEFORE_TAG_RE, PAGE_REF_INSTR_RE, DRAWING_OPEN_RE, DRAWING_CLOSE_RE, REF_ANCHOR_TAG_RE, COLUMN_WIDTH_EQUALITY_TOLERANCE_TWIPS = 7.5, DEPENDENCY_LOCATION_KEYS;
179543
+ var TD24, TE6, RECEIPT_RENDER_COMMITS, RENDER_COMMIT_CARRIER_ENVELOPES, RECEIPT_RENDER_COMMIT_CARRIER, MAX_NARROW_SLICE_BYTES, TRACKED_WRAPPER_RE, TRACKED_WRAPPER_TAG_RE, TRACKED_WRAPPER_TOKEN_RE, FAIL_CLOSED_REF_OR_ANCHOR_RE, FAIL_CLOSED_NON_COMMENT_REF_OR_ANCHOR_RE, COMMENT_ANCHOR_RE, STRUCTURAL_NOTE_REF_RE, STRUCTURAL_REVIEW_ANCHOR_TAG_RE, STRUCTURAL_REVIEW_RANGE_TAG_RE, BOOKMARK_ANCHOR_RE, BOOKMARK_ANCHOR_TAG_RE, VISIBLE_TEXT_RUN_RE, GLOBAL_SLICE_DEPENDENCY_RE, SECTION_PROPERTIES_DEPENDENCY_RE, PAGE_OR_COLUMN_BREAK_RE, INLINE_SDT_DEPENDENCY_RE, PAGE_BREAK_BEFORE_DEPENDENCY_RE, NUMBERING_PROPERTY_RE2, PARAGRAPH_OPEN_TAG_RE, NATIVE_PARA_ID_ATTR_RE, FIELD_TOKEN_RE, FIELD_SIGNATURE_TOKEN_RE, NON_FIELD_GLOBAL_SLICE_DEPENDENCY_RE, DISABLED_PAGE_BREAK_BEFORE_TAG_RE, PAGE_REF_INSTR_RE, DRAWING_OPEN_RE, DRAWING_CLOSE_RE, REF_ANCHOR_TAG_RE, TEXTBOX_CONTENT_RE, TEXT_DEPENDENT_SHAPE_SIZE_RE, COLUMN_WIDTH_EQUALITY_TOLERANCE_TWIPS = 7.5, DEPENDENCY_LOCATION_KEYS;
179387
179544
  var init_render_commit_envelope = __esm(() => {
179388
179545
  init_sd_document_state();
179389
179546
  init_patch_substrate();
@@ -179431,6 +179588,8 @@ var init_render_commit_envelope = __esm(() => {
179431
179588
  DRAWING_OPEN_RE = /<(?:[\w.-]+:)?drawing[\s>]/g;
179432
179589
  DRAWING_CLOSE_RE = /<\/(?:[\w.-]+:)?drawing>/g;
179433
179590
  REF_ANCHOR_TAG_RE = /<(?:[\w.-]+:)?(?:footnoteReference|endnoteReference|commentRangeStart|commentRangeEnd|commentReference|permStart|permEnd)\b[^>]*>/g;
179591
+ TEXTBOX_CONTENT_RE = /(<(?:[\w.-]+:)?txbxContent\b[^>]*>)([\s\S]*?)(<\/(?:[\w.-]+:)?txbxContent>)/g;
179592
+ TEXT_DEPENDENT_SHAPE_SIZE_RE = /<(?:[\w.-]+:)?spAutoFit\b|\bmso-fit-shape-to-text\s*:\s*t/;
179434
179593
  DEPENDENCY_LOCATION_KEYS = new Set([
179435
179594
  "sourceAnchor",
179436
179595
  "storyRevision",
@@ -183273,6 +183432,174 @@ var init_source_inventory = __esm(() => {
183273
183432
  TRACKED_OPEN_TAG_RE = /<[\w.-]+:(?:ins|del|moveFrom|moveTo|moveFromRangeStart|moveFromRangeEnd|moveToRangeStart|moveToRangeEnd|customXml(?:Ins|Del|MoveFrom|MoveTo)Range(?:Start|End)|cellIns|cellDel|cellMerge|rPrChange|pPrChange|tblPrChange|tblPrExChange|tblGridChange|trPrChange|tcPrChange|sectPrChange|sdtPrChange)\b/u;
183274
183433
  });
183275
183434
 
183435
+ // ../../../v2/editor-core/dist/document/transactions/paragraph-para-id-attrs.js
183436
+ function namespaceBindingsAtPosition(bytes, byteOffset, localOpenTag = "") {
183437
+ const bindings = {
183438
+ ...readNamespacesBeforeByte(bytes, byteOffset),
183439
+ ...readNamespaceDeclarations2(localOpenTag)
183440
+ };
183441
+ return Object.fromEntries(Object.entries(bindings).filter((entry) => entry[1] != null));
183442
+ }
183443
+ function matchParagraphOpenTag(paragraphXml) {
183444
+ return paragraphXml.match(PARAGRAPH_OPEN_TAG_RE2)?.[0] ?? null;
183445
+ }
183446
+ function stripW14ParaIdAttrsFromParagraphOpenTag(openTag, partBytes, paragraphStartByte) {
183447
+ const rootNamespaces = readPartRootNamespaces(partBytes);
183448
+ const localNamespaces = readNamespaceDeclarations2(openTag);
183449
+ const rootOrLocalNamespaces = { ...rootNamespaces, ...localNamespaces };
183450
+ const namespaces = shouldReadAncestorNamespaces(openTag, rootOrLocalNamespaces, localNamespaces) ? { ...readNamespacesBeforeByte(partBytes, paragraphStartByte), ...localNamespaces } : rootOrLocalNamespaces;
183451
+ XML_ATTRIBUTE_RE.lastIndex = 0;
183452
+ return openTag.replace(XML_ATTRIBUTE_RE, (source, rawName) => {
183453
+ const { prefix, localName: localName2 } = splitQName(rawName);
183454
+ if (localName2 !== "paraId")
183455
+ return source;
183456
+ if (!prefix)
183457
+ return source;
183458
+ if (prefix === "w14" && namespaces[prefix] === undefined)
183459
+ return "";
183460
+ return namespaces[prefix] === W14_NAMESPACE ? "" : source;
183461
+ });
183462
+ }
183463
+ function readPartRootNamespaces(bytes) {
183464
+ const head = stripXmlCommentsAndCdata(TD29.decode(bytes.subarray(0, Math.min(bytes.length, ROOT_NAMESPACE_SCAN_BYTES))));
183465
+ const rootOpenTag = head.match(XML_OPEN_TAG_RE)?.[0] ?? "";
183466
+ return readNamespaceDeclarations2(rootOpenTag);
183467
+ }
183468
+ function readNamespacesBeforeByte(bytes, byteOffset) {
183469
+ ancestorNamespacePrefixScanCount += 1;
183470
+ const prefix = stripXmlCommentsAndCdata(TD29.decode(bytes.subarray(0, Math.max(0, byteOffset))));
183471
+ const stack = [];
183472
+ const tagRe = /<([!?/])?([\w.-]+(?::[\w.-]+)?)\b((?:"[^"]*"|'[^']*'|[^>"'])*)>/g;
183473
+ let match;
183474
+ while ((match = tagRe.exec(prefix)) !== null) {
183475
+ const marker = match[1];
183476
+ const name = match[2];
183477
+ if (!name || marker === "!" || marker === "?")
183478
+ continue;
183479
+ if (marker === "/") {
183480
+ for (let index = stack.length - 1;index >= 0; index--) {
183481
+ if (stack[index].name !== name)
183482
+ continue;
183483
+ stack.length = index;
183484
+ break;
183485
+ }
183486
+ continue;
183487
+ }
183488
+ const namespaces = readNamespaceDeclarations2(match[0]);
183489
+ if (/\/\s*>$/.test(match[0]))
183490
+ continue;
183491
+ stack.push({ name, namespaces });
183492
+ }
183493
+ return stack.reduce((acc, frame) => ({ ...acc, ...frame.namespaces }), {});
183494
+ }
183495
+ function stripXmlCommentsAndCdata(xml) {
183496
+ let result = "";
183497
+ let cursor = 0;
183498
+ while (cursor < xml.length) {
183499
+ const commentStart = xml.indexOf("<!--", cursor);
183500
+ const cdataStart = xml.indexOf("<![CDATA[", cursor);
183501
+ const candidates = [commentStart, cdataStart].filter((offset) => offset >= 0);
183502
+ if (candidates.length === 0)
183503
+ return result + xml.slice(cursor);
183504
+ const sectionStart = Math.min(...candidates);
183505
+ result += xml.slice(cursor, sectionStart);
183506
+ const isComment = sectionStart === commentStart;
183507
+ const close = isComment ? "-->" : "]]>";
183508
+ const sectionEnd = xml.indexOf(close, sectionStart + (isComment ? 4 : 9));
183509
+ if (sectionEnd < 0)
183510
+ return result;
183511
+ cursor = sectionEnd + close.length;
183512
+ }
183513
+ return result;
183514
+ }
183515
+ function shouldReadAncestorNamespaces(openTag, rootOrLocalNamespaces, localNamespaces) {
183516
+ const paraIdPrefixes = parseXmlAttributeNames(openTag).map((attr) => splitQName(attr)).filter(({ prefix, localName: localName2 }) => prefix && localName2 === "paraId").map(({ prefix }) => prefix);
183517
+ const hasAlternateParaIdPrefix = paraIdPrefixes.some((prefix) => prefix !== "w14");
183518
+ for (const prefix of paraIdPrefixes) {
183519
+ const locallyBound = Object.prototype.hasOwnProperty.call(localNamespaces, prefix);
183520
+ if (locallyBound)
183521
+ continue;
183522
+ if (prefix !== "w14")
183523
+ return true;
183524
+ if (hasAlternateParaIdPrefix)
183525
+ return true;
183526
+ if (rootOrLocalNamespaces[prefix] === undefined)
183527
+ return true;
183528
+ if (rootOrLocalNamespaces[prefix] !== W14_NAMESPACE)
183529
+ return true;
183530
+ }
183531
+ return false;
183532
+ }
183533
+ function parseXmlAttributeNames(openTag) {
183534
+ const names = [];
183535
+ XML_ATTRIBUTE_RE.lastIndex = 0;
183536
+ let match;
183537
+ while ((match = XML_ATTRIBUTE_RE.exec(openTag)) !== null) {
183538
+ names.push(match[1]);
183539
+ }
183540
+ return names;
183541
+ }
183542
+ function readNamespaceDeclarations2(openTag) {
183543
+ const namespaces = {};
183544
+ XML_ATTRIBUTE_RE.lastIndex = 0;
183545
+ let match;
183546
+ while ((match = XML_ATTRIBUTE_RE.exec(openTag)) !== null) {
183547
+ const name = match[1];
183548
+ if (name !== "xmlns" && !name.startsWith("xmlns:"))
183549
+ continue;
183550
+ const prefix = name === "xmlns" ? "" : name.slice("xmlns:".length);
183551
+ namespaces[prefix] = decodeXmlText(match[3] ?? "");
183552
+ }
183553
+ return namespaces;
183554
+ }
183555
+ function positionBindsW14Namespace(bytes, byteOffset, context = {}) {
183556
+ const localNamespaces = readNamespaceDeclarations2(context.localOpenTag ?? "");
183557
+ if (Object.prototype.hasOwnProperty.call(localNamespaces, "w14")) {
183558
+ return localNamespaces.w14 === W14_NAMESPACE;
183559
+ }
183560
+ const rootNamespaces = readPartRootNamespaces(bytes);
183561
+ if (rootNamespaces.w14 === W14_NAMESPACE && !scopeHintNeedsAncestorNamespaces(context.scopeHintOpenTag ?? "")) {
183562
+ return true;
183563
+ }
183564
+ const namespaces = { ...readNamespacesBeforeByte(bytes, byteOffset), ...localNamespaces };
183565
+ return namespaces.w14 === W14_NAMESPACE;
183566
+ }
183567
+ function wordprocessingNamespaceAtPosition(bytes, byteOffset, context = {}) {
183568
+ const namespaces = namespaceBindingsAtPosition(bytes, byteOffset, context.localOpenTag);
183569
+ const existingPrefix = Object.entries(namespaces).find(([prefix2, namespaceUri]) => prefix2 !== "" && namespaceUri === NS_W)?.[0];
183570
+ if (existingPrefix)
183571
+ return { prefix: existingPrefix, bindInline: false };
183572
+ let prefix = "w";
183573
+ let suffix = 0;
183574
+ while (Object.prototype.hasOwnProperty.call(namespaces, prefix)) {
183575
+ prefix = `wml${suffix || ""}`;
183576
+ suffix += 1;
183577
+ }
183578
+ return { prefix, bindInline: true };
183579
+ }
183580
+ function scopeHintNeedsAncestorNamespaces(openTag) {
183581
+ if (!openTag)
183582
+ return false;
183583
+ const localNamespaces = readNamespaceDeclarations2(openTag);
183584
+ if (Object.prototype.hasOwnProperty.call(localNamespaces, "w14"))
183585
+ return true;
183586
+ if (Object.entries(localNamespaces).some(([prefix, uri]) => prefix !== "w14" && uri === W14_NAMESPACE)) {
183587
+ return true;
183588
+ }
183589
+ return parseXmlAttributeNames(openTag).some((attr) => {
183590
+ const { prefix, localName: localName2 } = splitQName(attr);
183591
+ return localName2 === "paraId" && Boolean(prefix) && prefix !== "w14";
183592
+ });
183593
+ }
183594
+ var TD29, XML_ATTRIBUTE_RE, XML_OPEN_TAG_RE, PARAGRAPH_OPEN_TAG_RE2, ROOT_NAMESPACE_SCAN_BYTES = 16384, ancestorNamespacePrefixScanCount = 0, W14_NAMESPACE = "http://schemas.microsoft.com/office/word/2010/wordml";
183595
+ var init_paragraph_para_id_attrs = __esm(() => {
183596
+ init_xml_text();
183597
+ TD29 = new TextDecoder;
183598
+ XML_ATTRIBUTE_RE = /\s+([^\s"'<>/=]+)\s*=\s*(["'])(.*?)\2/g;
183599
+ XML_OPEN_TAG_RE = /<[\w.-]+:[\w.-]+\b(?:"[^"]*"|'[^']*'|[^>"'])*>/;
183600
+ PARAGRAPH_OPEN_TAG_RE2 = /^<[\w.-]+:p\b(?:"[^"]*"|'[^']*'|[^>"'])*>/;
183601
+ });
183602
+
183276
183603
  // ../../../v2/editor-core/dist/document/transactions/table-vertical-merges.js
183277
183604
  function collector2(options) {
183278
183605
  const values = new Map;
@@ -183333,7 +183660,7 @@ async function buildTableCatalogCooperatively(input) {
183333
183660
  return projectTableCatalogForStory(built.tables, input.storyId);
183334
183661
  }
183335
183662
  function buildPartTableFactsTables(bytes, baseOffset, rootNamespaceBindings) {
183336
- const xml = TD29.decode(bytes);
183663
+ const xml = TD30.decode(bytes);
183337
183664
  const utf8Offsets = buildUtf8OffsetMap(xml);
183338
183665
  const movedRows = new Set(collectNativeTableMoveRows(xml, rootNamespaceBindings ? { fragment: true, additionalNamespaces: { ...rootNamespaceBindings } } : undefined).filter((row) => row.kind === "moveFrom").map((row) => row.start));
183339
183666
  const cellTopology = collectNativeCellTopology(xml, rootNamespaceBindings ? { fragment: true, additionalNamespaces: { ...rootNamespaceBindings } } : undefined);
@@ -184098,8 +184425,8 @@ async function buildUtf8OffsetMapCooperatively(xml, yieldPoint) {
184098
184425
  function ensureTableCatalogCaches(state) {
184099
184426
  const anyState = state;
184100
184427
  let existing = anyState[TABLE_CATALOG_KEY];
184101
- if (!existing || !existing.partFacts) {
184102
- existing = { partFacts: new Map, storyCatalogs: new Map };
184428
+ if (!existing || !existing.partFacts || !existing.nestedStoryCatalogs) {
184429
+ existing = { partFacts: new Map, storyCatalogs: new Map, nestedStoryCatalogs: new Map };
184103
184430
  anyState[TABLE_CATALOG_KEY] = existing;
184104
184431
  }
184105
184432
  return existing;
@@ -184108,10 +184435,21 @@ function getOrBuildTableCatalogForStory(state, storyId) {
184108
184435
  const resolved = resolveTableCatalogInputs(state, storyId);
184109
184436
  if (!resolved)
184110
184437
  return null;
184111
- const { caches: caches2, partUri, bytes } = resolved;
184438
+ const { caches: caches2, partUri, bytes, nestedRange } = resolved;
184439
+ if (nestedRange) {
184440
+ const cached2 = currentNestedStoryCatalog(caches2, storyId, bytes, nestedRange);
184441
+ if (cached2)
184442
+ return cached2;
184443
+ const input = nestedStoryTableFactsInput(state, storyId, bytes, nestedRange);
184444
+ let built = input.rangeHasTable ? buildTableFactsCounted(input.rangeBytes, input.start, input.rootNamespaceBindings) : EMPTY_FACTS;
184445
+ if (input.rangeHasTable && built.tables.length === 0) {
184446
+ built = buildTableFactsCounted(input.rangeBytes, input.start, input.ancestorNamespaceBindings());
184447
+ }
184448
+ return storeNestedStoryCatalog(caches2, storyId, input, built);
184449
+ }
184112
184450
  let facts = currentPartFacts(caches2, partUri, bytes);
184113
184451
  if (!facts) {
184114
- const built = buildPartTableFactsTables(bytes, 0);
184452
+ const built = buildTableFactsCounted(bytes, 0);
184115
184453
  facts = storePartFacts(caches2, partUri, bytes, built);
184116
184454
  }
184117
184455
  return projectAndCacheStoryCatalog(caches2, storyId, facts);
@@ -184120,10 +184458,23 @@ async function getOrBuildTableCatalogForStoryCooperatively(state, storyId, yield
184120
184458
  const resolved = resolveTableCatalogInputs(state, storyId);
184121
184459
  if (!resolved)
184122
184460
  return null;
184123
- const { caches: caches2, partUri, bytes } = resolved;
184461
+ const { caches: caches2, partUri, bytes, nestedRange } = resolved;
184462
+ if (nestedRange) {
184463
+ const cached2 = currentNestedStoryCatalog(caches2, storyId, bytes, nestedRange);
184464
+ if (cached2)
184465
+ return cached2;
184466
+ const input = nestedStoryTableFactsInput(state, storyId, bytes, nestedRange);
184467
+ let built = input.rangeHasTable ? await buildTableFactsCountedCooperatively(input.rangeBytes, input.start, yieldPoint, input.rootNamespaceBindings) : EMPTY_FACTS;
184468
+ if (input.rangeHasTable && built.tables.length === 0) {
184469
+ built = await buildTableFactsCountedCooperatively(input.rangeBytes, input.start, yieldPoint, input.ancestorNamespaceBindings());
184470
+ }
184471
+ if (state.packageBytes.get(partUri) !== bytes)
184472
+ return null;
184473
+ return storeNestedStoryCatalog(caches2, storyId, input, built);
184474
+ }
184124
184475
  let facts = currentPartFacts(caches2, partUri, bytes);
184125
184476
  if (!facts) {
184126
- const built = await buildPartTableFactsTablesCooperatively(bytes, 0, yieldPoint);
184477
+ const built = await buildTableFactsCountedCooperatively(bytes, 0, yieldPoint);
184127
184478
  if (state.packageBytes.get(partUri) !== bytes)
184128
184479
  return null;
184129
184480
  facts = storePartFacts(caches2, partUri, bytes, built);
@@ -184137,7 +184488,49 @@ function resolveTableCatalogInputs(state, storyId) {
184137
184488
  return null;
184138
184489
  if (!state.stories.get(storyId))
184139
184490
  return null;
184140
- return { caches: ensureTableCatalogCaches(state), partUri, bytes };
184491
+ const range = getStoryByteRangeFromState(state, storyId);
184492
+ const nestedRange = range && range[0] >= 0 && range[0] <= range[1] && range[1] <= bytes.byteLength ? range : null;
184493
+ return { caches: ensureTableCatalogCaches(state), partUri, bytes, nestedRange };
184494
+ }
184495
+ function buildTableFactsCounted(bytes, baseOffset, rootNamespaceBindings) {
184496
+ recordSDTxPerf("catalogFactsBuilds", 1);
184497
+ recordSDTxPerf("catalogFactsBytesParsed", bytes.byteLength);
184498
+ return buildPartTableFactsTables(bytes, baseOffset, rootNamespaceBindings);
184499
+ }
184500
+ function buildTableFactsCountedCooperatively(bytes, baseOffset, yieldPoint, rootNamespaceBindings) {
184501
+ recordSDTxPerf("catalogFactsBuilds", 1);
184502
+ recordSDTxPerf("catalogFactsBytesParsed", bytes.byteLength);
184503
+ return buildPartTableFactsTablesCooperatively(bytes, baseOffset, yieldPoint, rootNamespaceBindings);
184504
+ }
184505
+ function nestedStoryTableFactsInput(state, storyId, bytes, range) {
184506
+ const [start, end] = range;
184507
+ const rangeBytes = bytes.slice(start, end);
184508
+ const hostRange = state.textboxRegistry.byStoryId.get(storyId)?.hostRange ?? null;
184509
+ const hostLocalBindings = hostRange && hostRange[0] <= start && start <= hostRange[1] ? namespaceBindingsAtPosition(bytes.subarray(hostRange[0], start), start - hostRange[0]) : {};
184510
+ return {
184511
+ start,
184512
+ end,
184513
+ rangeBytes,
184514
+ rangeHasTable: TABLE_MARKER_RE.test(TD30.decode(rangeBytes)),
184515
+ rootNamespaceBindings: { ...textboxNamespaceBindingsFromPartBytes(bytes), ...hostLocalBindings },
184516
+ ancestorNamespaceBindings: () => namespaceBindingsAtPosition(bytes, start)
184517
+ };
184518
+ }
184519
+ function currentNestedStoryCatalog(caches2, storyId, bytes, range) {
184520
+ const entry = caches2.nestedStoryCatalogs.get(storyId);
184521
+ if (!entry || entry.start !== range[0] || entry.end !== range[1])
184522
+ return null;
184523
+ return bytesEqual3(entry.rangeBytes, bytes.subarray(range[0], range[1])) ? entry.catalog : null;
184524
+ }
184525
+ function storeNestedStoryCatalog(caches2, storyId, input, built) {
184526
+ const catalog = projectTableCatalogForStory(built.tables, storyId);
184527
+ caches2.nestedStoryCatalogs.set(storyId, {
184528
+ start: input.start,
184529
+ end: input.end,
184530
+ rangeBytes: input.rangeBytes,
184531
+ catalog
184532
+ });
184533
+ return catalog;
184141
184534
  }
184142
184535
  function currentPartFacts(caches2, partUri, bytes) {
184143
184536
  const facts = caches2.partFacts.get(partUri);
@@ -184207,7 +184600,7 @@ function maintainTableCatalogFactsAcrossSplice(state, input) {
184207
184600
  const overlapping = facts.tables.filter((table) => input.windowEnd > table.tableByteStart && input.windowStart < table.tableByteEnd);
184208
184601
  let nextTables = null;
184209
184602
  if (overlapping.length === 0) {
184210
- const windowsCarryTableTags = TABLE_MARKER_RE.test(TD29.decode(input.beforeWindowBytes)) || TABLE_MARKER_RE.test(TD29.decode(input.afterWindowBytes));
184603
+ const windowsCarryTableTags = TABLE_MARKER_RE.test(TD30.decode(input.beforeWindowBytes)) || TABLE_MARKER_RE.test(TD30.decode(input.afterWindowBytes));
184211
184604
  nextTables = windowsCarryTableTags ? null : shiftTablesAcrossWindow(facts.tables, input.windowEnd, input.delta);
184212
184605
  } else if (overlapping.length === 1 && input.windowStart >= overlapping[0].tableByteStart && input.windowEnd <= overlapping[0].tableByteEnd && facts.rootNamespaceBindings != null) {
184213
184606
  const target = overlapping[0];
@@ -184251,8 +184644,8 @@ function maintainTableCatalogFactsAcrossSplice(state, input) {
184251
184644
  });
184252
184645
  }
184253
184646
  function paragraphTextSplicePreservesCatalogFacts(input) {
184254
- const beforeXml = TD29.decode(input.beforeWindowBytes);
184255
- const afterXml = TD29.decode(input.afterWindowBytes);
184647
+ const beforeXml = TD30.decode(input.beforeWindowBytes);
184648
+ const afterXml = TD30.decode(input.afterWindowBytes);
184256
184649
  if (TABLE_CATALOG_PARAGRAPH_UNSAFE_MARKER_RE.test(beforeXml) || TABLE_CATALOG_PARAGRAPH_UNSAFE_MARKER_RE.test(afterXml))
184257
184650
  return false;
184258
184651
  const scan = (xml) => scanWmlParagraphSpans(xml, {
@@ -184484,7 +184877,7 @@ function shiftTableDescriptor(table, delta) {
184484
184877
  };
184485
184878
  }
184486
184879
  function parseSingleTableSlice(sliceBytes, absoluteByteBase, rootNamespaceBindings) {
184487
- const xml = TD29.decode(sliceBytes);
184880
+ const xml = TD30.decode(sliceBytes);
184488
184881
  const tableSpans = findChildSpansByLocalName(xml, "tbl");
184489
184882
  if (tableSpans.length !== 1)
184490
184883
  return null;
@@ -184524,15 +184917,18 @@ function bytesEqual3(left, right) {
184524
184917
  }
184525
184918
  return true;
184526
184919
  }
184527
- var TD29, PART_FACTS_STORY_ID = "", TABLE_CATALOG_KEY, TABLE_MARKER_RE, TABLE_CATALOG_PARAGRAPH_UNSAFE_MARKER_RE, MAX_SHIFTED_TABLE_CELLS = 50000;
184920
+ var TD30, PART_FACTS_STORY_ID = "", TABLE_CATALOG_KEY, EMPTY_FACTS, TABLE_MARKER_RE, TABLE_CATALOG_PARAGRAPH_UNSAFE_MARKER_RE, MAX_SHIFTED_TABLE_CELLS = 50000;
184528
184921
  var init_table_catalog = __esm(() => {
184529
184922
  init_sd_document_state();
184923
+ init_textbox_paragraph_signature();
184924
+ init_paragraph_para_id_attrs();
184530
184925
  init_wml_paragraph_spans();
184531
184926
  init_patch_substrate();
184532
184927
  init_table_move_rows();
184533
184928
  init_table_vertical_merges();
184534
- TD29 = new TextDecoder;
184929
+ TD30 = new TextDecoder;
184535
184930
  TABLE_CATALOG_KEY = Symbol.for("sd.v2.tableCatalogCache");
184931
+ EMPTY_FACTS = { tables: [], rootNamespaceBindings: null };
184536
184932
  TABLE_MARKER_RE = /<\/?(?:[\w.-]+:)?tbl[\s/>]/;
184537
184933
  TABLE_CATALOG_PARAGRAPH_UNSAFE_MARKER_RE = /<\/?(?:[\w.-]+:)?(?:tbl|tr|tc|tblGrid|gridCol|gridSpan|vMerge|sdt|drawing|object|hyperlink|oMath|oMathPara)\b/;
184538
184934
  });
@@ -186324,16 +186720,19 @@ function payloadRangeEqualsBytes(input) {
186324
186720
  }
186325
186721
  function buildExactSparsePatches(input) {
186326
186722
  const only = input.entry.patches.length === 1 ? input.entry.patches[0] : null;
186327
- if (only?.kind === "replaceBytes" && only.startByte === 0 && only.endByte === input.delta.beforeByteLength && only.bytes.byteLength === input.delta.afterByteLength) {
186328
- let beforeCursor = 0;
186329
- let afterCursor = 0;
186723
+ const firstSplice = input.delta.splices[0];
186724
+ const lastSplice = input.delta.splices[input.delta.splices.length - 1];
186725
+ if (only?.kind === "replaceBytes" && firstSplice && lastSplice && only.startByte <= firstSplice.beforeStart && only.endByte >= lastSplice.beforeEnd && only.endByte <= input.delta.beforeByteLength && only.bytes.byteLength === only.endByte - only.startByte + (input.delta.afterByteLength - input.delta.beforeByteLength) && (input.delta.splices.length !== 1 || only.startByte !== firstSplice.beforeStart || only.endByte !== firstSplice.beforeEnd)) {
186726
+ const base2 = only.startByte;
186727
+ let beforeCursor = base2;
186728
+ let afterCursor = base2;
186330
186729
  for (const splice of input.delta.splices) {
186331
186730
  if (!payloadRangeEqualsBytes({
186332
186731
  payload: input.beforePayload,
186333
186732
  payloadStart: beforeCursor,
186334
186733
  payloadEnd: splice.beforeStart,
186335
186734
  bytes: only.bytes,
186336
- bytesStart: afterCursor
186735
+ bytesStart: afterCursor - base2
186337
186736
  }))
186338
186737
  return false;
186339
186738
  beforeCursor = splice.beforeEnd;
@@ -186342,13 +186741,13 @@ function buildExactSparsePatches(input) {
186342
186741
  if (!payloadRangeEqualsBytes({
186343
186742
  payload: input.beforePayload,
186344
186743
  payloadStart: beforeCursor,
186345
- payloadEnd: input.delta.beforeByteLength,
186744
+ payloadEnd: only.endByte,
186346
186745
  bytes: only.bytes,
186347
- bytesStart: afterCursor
186746
+ bytesStart: afterCursor - base2
186348
186747
  }))
186349
186748
  return false;
186350
186749
  return input.delta.splices.map((splice, order) => {
186351
- const replacement = only.bytes.slice(splice.afterStart, splice.afterEnd);
186750
+ const replacement = only.bytes.slice(splice.afterStart - base2, splice.afterEnd - base2);
186352
186751
  if (splice.beforeStart === splice.beforeEnd) {
186353
186752
  return { kind: "insertBytes", order, atByte: splice.beforeStart, bytes: replacement };
186354
186753
  }
@@ -187216,7 +187615,7 @@ function readCommentMetadataSidecar(parts) {
187216
187615
  const bytes = parts.get(partUri);
187217
187616
  if (!bytes)
187218
187617
  continue;
187219
- const parsed = parseSidecarXml(TD30.decode(bytes));
187618
+ const parsed = parseSidecarXml(TD31.decode(bytes));
187220
187619
  if (parsed === null)
187221
187620
  continue;
187222
187621
  for (const entry of parsed) {
@@ -187265,7 +187664,7 @@ function findCommentMetadataSidecarLocations(parts) {
187265
187664
  return findSidecarPartUris(parts).map((partUri) => {
187266
187665
  const relsPartUri = relsPartUriForStoragePart(partUri);
187267
187666
  const relsXml = parts.get(relsPartUri);
187268
- const propsPartUri = relsXml ? discoverPropsPartUri(partUri, TD30.decode(relsXml), parts, new Map) : null;
187667
+ const propsPartUri = relsXml ? discoverPropsPartUri(partUri, TD31.decode(relsXml), parts, new Map) : null;
187269
187668
  return {
187270
187669
  partUri,
187271
187670
  propsPartUri: propsPartUri ?? propsPartUriForStoragePart(partUri),
@@ -187321,7 +187720,7 @@ function candidateStoragePartUris(parts) {
187321
187720
  function findSidecarPartUris(parts) {
187322
187721
  return candidateStoragePartUris(parts).filter((partUri) => {
187323
187722
  const bytes = parts.get(partUri);
187324
- return bytes ? parseSidecarXml(TD30.decode(bytes)) !== null : false;
187723
+ return bytes ? parseSidecarXml(TD31.decode(bytes)) !== null : false;
187325
187724
  });
187326
187725
  }
187327
187726
  function allocateStoragePartUri(parts, baseOverrides) {
@@ -187384,7 +187783,7 @@ function ensureContentTypeOverride(xml, partUri, contentType) {
187384
187783
  }
187385
187784
  function readXml(parts, baseOverrides, partUri) {
187386
187785
  const bytes = baseOverrides.get(partUri) ?? parts.get(partUri);
187387
- return bytes ? TD30.decode(bytes) : null;
187786
+ return bytes ? TD31.decode(bytes) : null;
187388
187787
  }
187389
187788
  function readAttribute(attrs, name) {
187390
187789
  const escaped = escapeRegex3(name);
@@ -187419,11 +187818,11 @@ function resolveRelationshipTarget(ownerPartUri, target) {
187419
187818
  function escapeRegex3(value) {
187420
187819
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
187421
187820
  }
187422
- var TD30, TE12, COMMENT_METADATA_SIDECAR_NAMESPACE = "http://superdoc.dev/2024/comment-metadata", CONTENT_TYPES_PART_URI2 = "/[Content_Types].xml", DOCUMENT_RELS_PART_URI = "/word/_rels/document.xml.rels", CUSTOM_XML_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml", CUSTOM_XML_PROPS_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps", CUSTOM_XML_CONTENT_TYPE = "application/xml", CUSTOM_XML_PROPS_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.customXmlProperties+xml", DATASTORE_ITEM_ID = "{A8857A01-5AF9-4CF1-82BE-22CFD98B19D9}", EMPTY_RELATIONSHIPS_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>', EMPTY_CONTENT_TYPES_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"></Types>';
187821
+ var TD31, TE12, COMMENT_METADATA_SIDECAR_NAMESPACE = "http://superdoc.dev/2024/comment-metadata", CONTENT_TYPES_PART_URI2 = "/[Content_Types].xml", DOCUMENT_RELS_PART_URI = "/word/_rels/document.xml.rels", CUSTOM_XML_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml", CUSTOM_XML_PROPS_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps", CUSTOM_XML_CONTENT_TYPE = "application/xml", CUSTOM_XML_PROPS_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.customXmlProperties+xml", DATASTORE_ITEM_ID = "{A8857A01-5AF9-4CF1-82BE-22CFD98B19D9}", EMPTY_RELATIONSHIPS_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>', EMPTY_CONTENT_TYPES_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"></Types>';
187423
187822
  var init_comment_metadata_sidecar = __esm(() => {
187424
187823
  init_xml_text();
187425
187824
  init_xml_sax();
187426
- TD30 = new TextDecoder;
187825
+ TD31 = new TextDecoder;
187427
187826
  TE12 = new TextEncoder;
187428
187827
  });
187429
187828
 
@@ -187472,16 +187871,16 @@ function buildCommentsCatalog(state) {
187472
187871
  const commentsBytes = state.packageBytes.get(COMMENTS_PART_URI);
187473
187872
  if (!commentsBytes)
187474
187873
  return null;
187475
- const commentsXml = TD31.decode(commentsBytes);
187874
+ const commentsXml = TD32.decode(commentsBytes);
187476
187875
  const entries = parseCommentsXml(commentsXml);
187477
187876
  applyCommentMetadataSidecar(entries, readCommentMetadataSidecar(state.packageBytes));
187478
187877
  const extendedBytes = state.packageBytes.get(COMMENTS_EXTENDED_PART_URI);
187479
- let extendedByParaId = extendedBytes ? parseCommentsExtendedXml(TD31.decode(extendedBytes)) : new Map;
187878
+ let extendedByParaId = extendedBytes ? parseCommentsExtendedXml(TD32.decode(extendedBytes)) : new Map;
187480
187879
  if (entries.length > 1) {
187481
187880
  extendedByParaId = mergeInferredThreading(extendedByParaId, inferThreadingFromStoryAnchors(state, entries));
187482
187881
  }
187483
187882
  const idsBytes = state.packageBytes.get(COMMENTS_IDS_PART_URI);
187484
- const durableByParaId = idsBytes ? parseCommentsIdsXml(TD31.decode(idsBytes)) : new Map;
187883
+ const durableByParaId = idsBytes ? parseCommentsIdsXml(TD32.decode(idsBytes)) : new Map;
187485
187884
  const reservedWIds = state.idReservations.comments.wIds;
187486
187885
  const repairedSourceWIds = state.idReservations.comments.repairedSourceWIds;
187487
187886
  const usedCommentIds = new Set;
@@ -187924,7 +188323,7 @@ function collectCommentAnchorEnvelopes(state) {
187924
188323
  for (const [partUri, bytes] of state.packageBytes) {
187925
188324
  if (!isStoryPartUri(partUri))
187926
188325
  continue;
187927
- const xml = TD31.decode(bytes);
188326
+ const xml = TD32.decode(bytes);
187928
188327
  const starts = [];
187929
188328
  const ends = [];
187930
188329
  const tokenRe = /<[\w.-]+:(commentRangeStart|commentRangeEnd)\b[^>]*\bw:id="([^"]+)"[^>]*\/?>/g;
@@ -188035,13 +188434,13 @@ function collectThreadDescendants(catalog, rootParaId) {
188035
188434
  }
188036
188435
  return out;
188037
188436
  }
188038
- var TD31, COMMENTS_PART_URI = "/word/comments.xml", COMMENTS_EXTENDED_PART_URI = "/word/commentsExtended.xml", COMMENTS_IDS_PART_URI = "/word/commentsIds.xml", CATALOG_TAG, TE13, SDCOM_COMMENT_CREATION_ATTR_RE;
188437
+ var TD32, COMMENTS_PART_URI = "/word/comments.xml", COMMENTS_EXTENDED_PART_URI = "/word/commentsExtended.xml", COMMENTS_IDS_PART_URI = "/word/commentsIds.xml", CATALOG_TAG, TE13, SDCOM_COMMENT_CREATION_ATTR_RE;
188039
188438
  var init_comments_catalog = __esm(() => {
188040
188439
  init_lazy_indexes();
188041
188440
  init_wml_paragraph_spans();
188042
188441
  init_xml_sax();
188043
188442
  init_comment_metadata_sidecar();
188044
- TD31 = new TextDecoder;
188443
+ TD32 = new TextDecoder;
188045
188444
  CATALOG_TAG = Symbol.for("@superdoc/v2/comments-catalog");
188046
188445
  TE13 = new TextEncoder;
188047
188446
  SDCOM_COMMENT_CREATION_ATTR_RE = /\bsdcom:(?:externalId|authorId|authorEmail|authorImage|metadata)\s*=/;
@@ -188163,7 +188562,7 @@ function buildCommentAnchorIndex(state, previousStoryScans, catalogOverride) {
188163
188562
  if (!bytes)
188164
188563
  continue;
188165
188564
  const previous = previousStoryScans.find((candidate2) => candidate2.bytes === bytes && sameStoryEnumeration(candidate2.story, story));
188166
- const storyHits = previous?.hits ?? scanStoryForAnchors(TD32.decode(bytes), story);
188565
+ const storyHits = previous?.hits ?? scanStoryForAnchors(TD33.decode(bytes), story);
188167
188566
  storyScans.push({ story: { ...story }, bytes, hits: storyHits });
188168
188567
  for (const hit of storyHits) {
188169
188568
  const list = hitsBySource.get(hit.sourceWId) ?? [];
@@ -188200,7 +188599,7 @@ function enumerateStoryParts(state) {
188200
188599
  }
188201
188600
  const relsBytes = state.packageBytes.get("/word/_rels/document.xml.rels");
188202
188601
  if (relsBytes) {
188203
- const xml = TD32.decode(relsBytes);
188602
+ const xml = TD33.decode(relsBytes);
188204
188603
  const re = /<Relationship\b[^>]*\/>/g;
188205
188604
  for (let m = re.exec(xml);m; m = re.exec(xml)) {
188206
188605
  const fragment2 = m[0];
@@ -188338,182 +188737,14 @@ function findParagraphIndexAt(paragraphs, charIndex) {
188338
188737
  function decodeXmlText5(value) {
188339
188738
  return value.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
188340
188739
  }
188341
- var TD32, COMMENT_ANCHOR_INDEX_KEY = "__comment-anchor-index", ANCHOR_TAG;
188740
+ var TD33, COMMENT_ANCHOR_INDEX_KEY = "__comment-anchor-index", ANCHOR_TAG;
188342
188741
  var init_comment_anchor_index = __esm(() => {
188343
188742
  init_lazy_indexes();
188344
188743
  init_wml_paragraph_spans();
188345
188744
  init_comments_catalog();
188346
188745
  init_tracked_wrapper_coverage();
188347
- TD32 = new TextDecoder;
188348
- ANCHOR_TAG = Symbol.for("@superdoc/v2/comment-anchor-index");
188349
- });
188350
-
188351
- // ../../../v2/editor-core/dist/document/transactions/paragraph-para-id-attrs.js
188352
- function namespaceBindingsAtPosition(bytes, byteOffset, localOpenTag = "") {
188353
- const bindings = {
188354
- ...readNamespacesBeforeByte(bytes, byteOffset),
188355
- ...readNamespaceDeclarations2(localOpenTag)
188356
- };
188357
- return Object.fromEntries(Object.entries(bindings).filter((entry) => entry[1] != null));
188358
- }
188359
- function matchParagraphOpenTag(paragraphXml) {
188360
- return paragraphXml.match(PARAGRAPH_OPEN_TAG_RE2)?.[0] ?? null;
188361
- }
188362
- function stripW14ParaIdAttrsFromParagraphOpenTag(openTag, partBytes, paragraphStartByte) {
188363
- const rootNamespaces = readPartRootNamespaces(partBytes);
188364
- const localNamespaces = readNamespaceDeclarations2(openTag);
188365
- const rootOrLocalNamespaces = { ...rootNamespaces, ...localNamespaces };
188366
- const namespaces = shouldReadAncestorNamespaces(openTag, rootOrLocalNamespaces, localNamespaces) ? { ...readNamespacesBeforeByte(partBytes, paragraphStartByte), ...localNamespaces } : rootOrLocalNamespaces;
188367
- XML_ATTRIBUTE_RE.lastIndex = 0;
188368
- return openTag.replace(XML_ATTRIBUTE_RE, (source, rawName) => {
188369
- const { prefix, localName: localName2 } = splitQName(rawName);
188370
- if (localName2 !== "paraId")
188371
- return source;
188372
- if (!prefix)
188373
- return source;
188374
- if (prefix === "w14" && namespaces[prefix] === undefined)
188375
- return "";
188376
- return namespaces[prefix] === W14_NAMESPACE ? "" : source;
188377
- });
188378
- }
188379
- function readPartRootNamespaces(bytes) {
188380
- const head = stripXmlCommentsAndCdata(TD33.decode(bytes.subarray(0, Math.min(bytes.length, ROOT_NAMESPACE_SCAN_BYTES))));
188381
- const rootOpenTag = head.match(XML_OPEN_TAG_RE)?.[0] ?? "";
188382
- return readNamespaceDeclarations2(rootOpenTag);
188383
- }
188384
- function readNamespacesBeforeByte(bytes, byteOffset) {
188385
- ancestorNamespacePrefixScanCount += 1;
188386
- const prefix = stripXmlCommentsAndCdata(TD33.decode(bytes.subarray(0, Math.max(0, byteOffset))));
188387
- const stack = [];
188388
- const tagRe = /<([!?/])?([\w.-]+(?::[\w.-]+)?)\b((?:"[^"]*"|'[^']*'|[^>"'])*)>/g;
188389
- let match;
188390
- while ((match = tagRe.exec(prefix)) !== null) {
188391
- const marker = match[1];
188392
- const name = match[2];
188393
- if (!name || marker === "!" || marker === "?")
188394
- continue;
188395
- if (marker === "/") {
188396
- for (let index = stack.length - 1;index >= 0; index--) {
188397
- if (stack[index].name !== name)
188398
- continue;
188399
- stack.length = index;
188400
- break;
188401
- }
188402
- continue;
188403
- }
188404
- const namespaces = readNamespaceDeclarations2(match[0]);
188405
- if (/\/\s*>$/.test(match[0]))
188406
- continue;
188407
- stack.push({ name, namespaces });
188408
- }
188409
- return stack.reduce((acc, frame) => ({ ...acc, ...frame.namespaces }), {});
188410
- }
188411
- function stripXmlCommentsAndCdata(xml) {
188412
- let result = "";
188413
- let cursor = 0;
188414
- while (cursor < xml.length) {
188415
- const commentStart = xml.indexOf("<!--", cursor);
188416
- const cdataStart = xml.indexOf("<![CDATA[", cursor);
188417
- const candidates = [commentStart, cdataStart].filter((offset) => offset >= 0);
188418
- if (candidates.length === 0)
188419
- return result + xml.slice(cursor);
188420
- const sectionStart = Math.min(...candidates);
188421
- result += xml.slice(cursor, sectionStart);
188422
- const isComment = sectionStart === commentStart;
188423
- const close = isComment ? "-->" : "]]>";
188424
- const sectionEnd = xml.indexOf(close, sectionStart + (isComment ? 4 : 9));
188425
- if (sectionEnd < 0)
188426
- return result;
188427
- cursor = sectionEnd + close.length;
188428
- }
188429
- return result;
188430
- }
188431
- function shouldReadAncestorNamespaces(openTag, rootOrLocalNamespaces, localNamespaces) {
188432
- const paraIdPrefixes = parseXmlAttributeNames(openTag).map((attr) => splitQName(attr)).filter(({ prefix, localName: localName2 }) => prefix && localName2 === "paraId").map(({ prefix }) => prefix);
188433
- const hasAlternateParaIdPrefix = paraIdPrefixes.some((prefix) => prefix !== "w14");
188434
- for (const prefix of paraIdPrefixes) {
188435
- const locallyBound = Object.prototype.hasOwnProperty.call(localNamespaces, prefix);
188436
- if (locallyBound)
188437
- continue;
188438
- if (prefix !== "w14")
188439
- return true;
188440
- if (hasAlternateParaIdPrefix)
188441
- return true;
188442
- if (rootOrLocalNamespaces[prefix] === undefined)
188443
- return true;
188444
- if (rootOrLocalNamespaces[prefix] !== W14_NAMESPACE)
188445
- return true;
188446
- }
188447
- return false;
188448
- }
188449
- function parseXmlAttributeNames(openTag) {
188450
- const names = [];
188451
- XML_ATTRIBUTE_RE.lastIndex = 0;
188452
- let match;
188453
- while ((match = XML_ATTRIBUTE_RE.exec(openTag)) !== null) {
188454
- names.push(match[1]);
188455
- }
188456
- return names;
188457
- }
188458
- function readNamespaceDeclarations2(openTag) {
188459
- const namespaces = {};
188460
- XML_ATTRIBUTE_RE.lastIndex = 0;
188461
- let match;
188462
- while ((match = XML_ATTRIBUTE_RE.exec(openTag)) !== null) {
188463
- const name = match[1];
188464
- if (name !== "xmlns" && !name.startsWith("xmlns:"))
188465
- continue;
188466
- const prefix = name === "xmlns" ? "" : name.slice("xmlns:".length);
188467
- namespaces[prefix] = decodeXmlText(match[3] ?? "");
188468
- }
188469
- return namespaces;
188470
- }
188471
- function positionBindsW14Namespace(bytes, byteOffset, context = {}) {
188472
- const localNamespaces = readNamespaceDeclarations2(context.localOpenTag ?? "");
188473
- if (Object.prototype.hasOwnProperty.call(localNamespaces, "w14")) {
188474
- return localNamespaces.w14 === W14_NAMESPACE;
188475
- }
188476
- const rootNamespaces = readPartRootNamespaces(bytes);
188477
- if (rootNamespaces.w14 === W14_NAMESPACE && !scopeHintNeedsAncestorNamespaces(context.scopeHintOpenTag ?? "")) {
188478
- return true;
188479
- }
188480
- const namespaces = { ...readNamespacesBeforeByte(bytes, byteOffset), ...localNamespaces };
188481
- return namespaces.w14 === W14_NAMESPACE;
188482
- }
188483
- function wordprocessingNamespaceAtPosition(bytes, byteOffset, context = {}) {
188484
- const namespaces = namespaceBindingsAtPosition(bytes, byteOffset, context.localOpenTag);
188485
- const existingPrefix = Object.entries(namespaces).find(([prefix2, namespaceUri]) => prefix2 !== "" && namespaceUri === NS_W)?.[0];
188486
- if (existingPrefix)
188487
- return { prefix: existingPrefix, bindInline: false };
188488
- let prefix = "w";
188489
- let suffix = 0;
188490
- while (Object.prototype.hasOwnProperty.call(namespaces, prefix)) {
188491
- prefix = `wml${suffix || ""}`;
188492
- suffix += 1;
188493
- }
188494
- return { prefix, bindInline: true };
188495
- }
188496
- function scopeHintNeedsAncestorNamespaces(openTag) {
188497
- if (!openTag)
188498
- return false;
188499
- const localNamespaces = readNamespaceDeclarations2(openTag);
188500
- if (Object.prototype.hasOwnProperty.call(localNamespaces, "w14"))
188501
- return true;
188502
- if (Object.entries(localNamespaces).some(([prefix, uri]) => prefix !== "w14" && uri === W14_NAMESPACE)) {
188503
- return true;
188504
- }
188505
- return parseXmlAttributeNames(openTag).some((attr) => {
188506
- const { prefix, localName: localName2 } = splitQName(attr);
188507
- return localName2 === "paraId" && Boolean(prefix) && prefix !== "w14";
188508
- });
188509
- }
188510
- var TD33, XML_ATTRIBUTE_RE, XML_OPEN_TAG_RE, PARAGRAPH_OPEN_TAG_RE2, ROOT_NAMESPACE_SCAN_BYTES = 16384, ancestorNamespacePrefixScanCount = 0, W14_NAMESPACE = "http://schemas.microsoft.com/office/word/2010/wordml";
188511
- var init_paragraph_para_id_attrs = __esm(() => {
188512
- init_xml_text();
188513
188746
  TD33 = new TextDecoder;
188514
- XML_ATTRIBUTE_RE = /\s+([^\s"'<>/=]+)\s*=\s*(["'])(.*?)\2/g;
188515
- XML_OPEN_TAG_RE = /<[\w.-]+:[\w.-]+\b(?:"[^"]*"|'[^']*'|[^>"'])*>/;
188516
- PARAGRAPH_OPEN_TAG_RE2 = /^<[\w.-]+:p\b(?:"[^"]*"|'[^']*'|[^>"'])*>/;
188747
+ ANCHOR_TAG = Symbol.for("@superdoc/v2/comment-anchor-index");
188517
188748
  });
188518
188749
 
188519
188750
  // ../../../v2/editor-core/dist/document/transactions/highlight-ooxml.js
@@ -192692,6 +192923,126 @@ var init_overlap_edit_compiler = __esm(() => {
192692
192923
  init_paragraph_property_block();
192693
192924
  });
192694
192925
 
192926
+ // ../../../v2/editor-core/dist/document/transactions/tracked-changes/metadata-projection.js
192927
+ function assertMetadataProjectionPreserved(state, sourceXml, projectedXml, mode) {
192928
+ const ids = metadataIds(state);
192929
+ if (ids.size === 0)
192930
+ return;
192931
+ const sourceAnchors = anchorTextById(sourceXml, ids);
192932
+ const projectedAnchors = anchorTextById(projectedXml, ids);
192933
+ if (!sourceAnchors || !projectedAnchors) {
192934
+ throw new SDMetadataProjectionConflictError(ids.values().next().value, mode);
192935
+ }
192936
+ for (const id of ids) {
192937
+ const sourceSegments = sourceAnchors.get(id) ?? [];
192938
+ const projectedSegments = projectedAnchors.get(id) ?? [];
192939
+ if (sourceSegments.length !== projectedSegments.length || sourceSegments.some((text, index) => text !== projectedSegments[index])) {
192940
+ throw new SDMetadataProjectionConflictError(id, mode);
192941
+ }
192942
+ }
192943
+ }
192944
+ function metadataIds(state) {
192945
+ const ids = new Set;
192946
+ for (const [partUri, bytes] of state.packageBytes) {
192947
+ if (!/^\/customXml\/item\d+\.xml$/i.test(partUri))
192948
+ continue;
192949
+ const xml = decoder3.decode(bytes);
192950
+ if (!xml.includes("<refs"))
192951
+ continue;
192952
+ let depth = 0;
192953
+ let rootNamespace = null;
192954
+ walkXmlElements(xml, {
192955
+ onOpenTag({ tag }) {
192956
+ depth += 1;
192957
+ if (depth === 1 && tag.localName === "refs")
192958
+ rootNamespace = tag.namespaceUri;
192959
+ if (depth !== 2 || !rootNamespace || tag.namespaceUri !== rootNamespace || tag.localName !== "ref")
192960
+ return;
192961
+ const id = readXmlAttribute(tag, "", "id")?.value;
192962
+ if (id)
192963
+ ids.add(id);
192964
+ },
192965
+ onCloseTag() {
192966
+ depth -= 1;
192967
+ }
192968
+ });
192969
+ }
192970
+ return ids;
192971
+ }
192972
+ function anchorTextById(xml, knownIds) {
192973
+ const anchors = [];
192974
+ const elements = [];
192975
+ const byId = new Map;
192976
+ const result = walkXmlElements(xml, {
192977
+ onOpenTag({ tag }) {
192978
+ const wordName = tag.namespaceUri === NS_W || tag.namespaceUri === NS_WSTRICT ? tag.localName : "";
192979
+ const parent = elements[elements.length - 1];
192980
+ elements.push(wordName);
192981
+ if (wordName === "sdt")
192982
+ anchors.push({ id: null, alias: null, hidden: false, plainText: false, incompatible: false, contentDepth: 0, text: "" });
192983
+ const anchor = anchors[anchors.length - 1];
192984
+ if (!anchor)
192985
+ return;
192986
+ if (parent === "sdtPr") {
192987
+ if (wordName === "tag")
192988
+ anchor.id = readXmlAttribute(tag, tag.namespaceUri, "val")?.value ?? null;
192989
+ if (wordName === "alias")
192990
+ anchor.alias = readXmlAttribute(tag, tag.namespaceUri, "val")?.value ?? null;
192991
+ if (wordName === "text")
192992
+ anchor.plainText = true;
192993
+ if (/^(checkbox|dropDownList|comboBox|date|picture|repeatingSection|repeatingSectionItem|bibliography|citation|docPartObj|docPartList|group|entityPicker|equation)$/i.test(tag.localName))
192994
+ anchor.incompatible = true;
192995
+ if (tag.namespaceUri === appearanceNamespace && tag.localName === "appearance") {
192996
+ anchor.hidden = readXmlAttribute(tag, appearanceNamespace, "val")?.value === "hidden";
192997
+ }
192998
+ }
192999
+ if (wordName === "sdtContent")
193000
+ anchor.contentDepth = elements.length;
193001
+ if (wordName === "tab" || wordName === "br" || wordName === "cr" || wordName === "noBreakHyphen") {
193002
+ for (const candidate2 of anchors)
193003
+ if (candidate2.contentDepth)
193004
+ candidate2.text += `\x00${wordName}\x00`;
193005
+ }
193006
+ },
193007
+ onText(value) {
193008
+ const current = elements[elements.length - 1];
193009
+ if (current !== "t" && current !== "delText")
193010
+ return;
193011
+ for (const anchor of anchors)
193012
+ if (anchor.contentDepth)
193013
+ anchor.text += value;
193014
+ },
193015
+ onCloseTag({ tag }) {
193016
+ if ((tag.namespaceUri === NS_W || tag.namespaceUri === NS_WSTRICT) && tag.localName === "sdt") {
193017
+ const anchor = anchors.pop();
193018
+ if (anchor?.id && knownIds.has(anchor.id) && anchor.hidden && !anchor.incompatible && (anchor.alias === "Anchored metadata" || anchor.alias === null && anchor.plainText)) {
193019
+ const segments = byId.get(anchor.id) ?? [];
193020
+ segments.push(anchor.text);
193021
+ byId.set(anchor.id, segments);
193022
+ }
193023
+ }
193024
+ for (const anchor of anchors)
193025
+ if (anchor.contentDepth === elements.length)
193026
+ anchor.contentDepth = 0;
193027
+ elements.pop();
193028
+ }
193029
+ });
193030
+ return result.errors.length ? null : byId;
193031
+ }
193032
+ var decoder3, appearanceNamespace = "http://schemas.microsoft.com/office/word/2012/wordml", SDMetadataProjectionConflictError;
193033
+ var init_metadata_projection = __esm(() => {
193034
+ init_xml_sax();
193035
+ decoder3 = new TextDecoder;
193036
+ SDMetadataProjectionConflictError = class SDMetadataProjectionConflictError extends Error {
193037
+ constructor(metadataId, mode) {
193038
+ super(`Export would change anchored metadata ${metadataId}; use review-preserving export or resolve the tracked change first.`);
193039
+ this.code = "PRECONDITION_FAILED";
193040
+ this.name = "SDMetadataProjectionConflictError";
193041
+ this.details = { reason: "metadata-projection-conflict", metadataId, mode };
193042
+ }
193043
+ };
193044
+ });
193045
+
192695
193046
  // ../../../v2/editor-core/dist/document/transactions/tracked-changes/move-stamps.js
192696
193047
  function renderMoveFromOpen(stamp) {
192697
193048
  const initials = stamp.author.initials ? ` ${PREFIX}:initials="${escapeXmlAttribute(stamp.author.initials)}"` : "";
@@ -192804,6 +193155,9 @@ function projectTrackedChangesForExport(state, options) {
192804
193155
  for (const [partUri, xml] of partXmlByUri) {
192805
193156
  const projected = projectTrackedChangesXml(xml, options.mode);
192806
193157
  if (projected !== xml) {
193158
+ if (partUri === "/word/document.xml") {
193159
+ assertMetadataProjectionPreserved(state, xml, projected, options.mode);
193160
+ }
192807
193161
  overrides.set(partUri, ENCODER.encode(projected));
192808
193162
  }
192809
193163
  }
@@ -193234,6 +193588,7 @@ function escapeRegExp6(value) {
193234
193588
  var DECODER, ENCODER;
193235
193589
  var init_export_projection = __esm(() => {
193236
193590
  init_xml_sax();
193591
+ init_metadata_projection();
193237
193592
  init_catalog3();
193238
193593
  init_logical_catalog();
193239
193594
  init_move_stamps();
@@ -193660,7 +194015,8 @@ function runDirectEditTextBatchCommit(input, edits) {
193660
194015
  ...state.storyByteRangeByStoryId.has(storyId) ? { reason: "nested-story-edit" } : {}
193661
194016
  }
193662
194017
  }
193663
- }
194018
+ },
194019
+ ...nestedStoryDerivedIndexProofs(state, storyId, perPart)
193664
194020
  };
193665
194021
  const prepared = {
193666
194022
  txId,
@@ -194075,7 +194431,8 @@ function runTrackedEditTextBatchCommit(input, edits) {
194075
194431
  ...state.storyByteRangeByStoryId.has(storyId) ? { reason: "nested-story-edit" } : {}
194076
194432
  }
194077
194433
  }
194078
- }
194434
+ },
194435
+ ...nestedStoryDerivedIndexProofs(state, storyId, perPart)
194079
194436
  };
194080
194437
  const prepared = {
194081
194438
  txId,
@@ -194322,6 +194679,7 @@ function runInsertInlineControlCommit(input) {
194322
194679
  paragraphWindow: counterpartPlan?.ownerParagraphWindow ?? window2,
194323
194680
  trackedTextInsert: trackedTextEdit ? null : trackedTextInsert,
194324
194681
  trackedTextEdit,
194682
+ ...counterpartPlan ? { nestedExactWindows: counterpartPlan.exactWindows } : {},
194325
194683
  ...counterpartPlan ? { indexRefresh: { blockId: counterpartPlan.ownerBlockId, isNestedStoryEdit: true } } : {}
194326
194684
  });
194327
194685
  }
@@ -194610,7 +194968,8 @@ function finalizeInlineControlCommit(args) {
194610
194968
  patchMaps: args.patchMaps,
194611
194969
  storiesTouched,
194612
194970
  signalLanesToRebuild: ["noteAnchorRefs", "paragraphIndex"],
194613
- indexRefreshScope
194971
+ indexRefreshScope,
194972
+ ...nestedStoryDerivedIndexProofs(state, op.on.storyId, args.perPart, args.nestedExactWindows)
194614
194973
  };
194615
194974
  const storySurface = {
194616
194975
  family: "storyText",
@@ -194888,6 +195247,7 @@ function commitDirect(input, view) {
194888
195247
  byteStart: byteBase + window2.byteStart,
194889
195248
  byteEnd: byteBase + window2.byteEnd
194890
195249
  },
195250
+ ...counterpartPlan ? { nestedExactWindows: counterpartPlan.exactWindows } : {},
194891
195251
  ...counterpartPlan ? { indexRefresh: { blockId: counterpartPlan.ownerBlockId, isNestedStoryEdit: true } } : {}
194892
195252
  });
194893
195253
  }
@@ -195408,6 +195768,7 @@ function commitTracked(input, view) {
195408
195768
  byteStart: byteBase + window2.byteStart,
195409
195769
  byteEnd: byteBase + window2.byteEnd
195410
195770
  },
195771
+ ...counterpartPlan ? { nestedExactWindows: counterpartPlan.exactWindows } : {},
195411
195772
  ...counterpartPlan ? { indexRefresh: { blockId: counterpartPlan.ownerBlockId, isNestedStoryEdit: true } } : {}
195412
195773
  });
195413
195774
  }
@@ -195468,6 +195829,32 @@ function textEditTouchedStories(state, storyId, partUri) {
195468
195829
  }
195469
195830
  return [...out];
195470
195831
  }
195832
+ function nestedStoryDerivedIndexProofs(state, storyId, perPart, exactWindows) {
195833
+ if (!state.storyByteRangeByStoryId.has(storyId))
195834
+ return {};
195835
+ const partUris = Object.keys(perPart);
195836
+ const exactPartMutations = Object.entries(perPart).flatMap(([partUri, entry]) => {
195837
+ if (entry.kind !== "modify")
195838
+ return [];
195839
+ const payload = state.packageBytes.getPayload(partUri);
195840
+ if (!payload)
195841
+ return [];
195842
+ const windows = exactWindows && partUris.length === 1 ? exactWindows : entry.patches.map((patch) => patch.kind === "insertBytes" ? { startByte: patch.atByte, endByte: patch.atByte, afterLength: patch.bytes.byteLength } : {
195843
+ startByte: patch.startByte,
195844
+ endByte: patch.endByte,
195845
+ afterLength: patch.kind === "deleteBytes" ? 0 : patch.bytes.byteLength
195846
+ });
195847
+ const proof = buildExactPartMutationProofFromWindows({
195848
+ partUri,
195849
+ beforeByteLength: payloadLength(payload),
195850
+ windows,
195851
+ provenance: "nested-story-text-edit"
195852
+ });
195853
+ return proof ? [proof] : [];
195854
+ });
195855
+ recordSDTxPerf("exactPartMutationAttachedParts", exactPartMutations.length);
195856
+ return exactPartMutations.length > 0 ? { derivedIndexProofs: { exactPartMutations } } : {};
195857
+ }
195471
195858
  function storyPartOwnershipForTouchedStories(state, storyIds, fallbackPartUri) {
195472
195859
  return storyIds.map((storyId) => ({
195473
195860
  storyId,
@@ -195518,7 +195905,8 @@ function finalizeCommit(args) {
195518
195905
  patchMaps: args.patchMaps,
195519
195906
  storiesTouched,
195520
195907
  signalLanesToRebuild: ["noteAnchorRefs", "paragraphIndex"],
195521
- indexRefreshScope
195908
+ indexRefreshScope,
195909
+ ...nestedStoryDerivedIndexProofs(state, op.on.storyId, args.perPart, args.nestedExactWindows)
195522
195910
  };
195523
195911
  const storySurface = {
195524
195912
  inlineAtomReplacement: prepareTextboxAtomReplacement(state, op, args.perPart),
@@ -197313,7 +197701,12 @@ function planTextboxCounterpartParagraphRangeRewrite(input) {
197313
197701
  hash: sha256Hex(ownerBytes)
197314
197702
  },
197315
197703
  ownerParagraphWindow: { byteStart: ownerStart, byteEnd: ownerEnd },
197316
- ownerBlockId: record3.ownerBlockId
197704
+ ownerBlockId: record3.ownerBlockId,
197705
+ exactWindows: replacements.map((replacement) => ({
197706
+ startByte: ownerStart + replacement.start,
197707
+ endByte: ownerStart + replacement.end,
197708
+ afterLength: replacement.bytes.byteLength
197709
+ })).sort((left, right) => left.startByte - right.startByte)
197317
197710
  }
197318
197711
  };
197319
197712
  }
@@ -198725,6 +199118,8 @@ var init_compile_edit_text = __esm(() => {
198725
199118
  init_rewrite_groups();
198726
199119
  init_word_text_payload();
198727
199120
  init_textbox_atom_replacement();
199121
+ init_part_payload();
199122
+ init_exact_part_mutation_proof();
198728
199123
  init_sd_document_state();
198729
199124
  init_paragraph_index();
198730
199125
  init_part_wml_scan_cache();
@@ -208009,12 +208404,12 @@ function removeAcceptedEmptyNoteParagraphs(currentXml3, originalXml, referenceLo
208009
208404
  }).sort((left, right) => right.start - left.start);
208010
208405
  return removable.reduce((result, range) => result.slice(0, range.start) + result.slice(range.end), currentXml3);
208011
208406
  }
208012
- function currentPartXml(state, perPart, partUri, decoder3 = TD46) {
208407
+ function currentPartXml(state, perPart, partUri, decoder4 = TD46) {
208013
208408
  const existingPatch = firstReplacePatch(perPart[partUri]);
208014
208409
  if (existingPatch)
208015
- return decoder3.decode(existingPatch.bytes);
208410
+ return decoder4.decode(existingPatch.bytes);
208016
208411
  const bytes = state.packageBytes.get(partUri);
208017
- return bytes ? decoder3.decode(bytes) : null;
208412
+ return bytes ? decoder4.decode(bytes) : null;
208018
208413
  }
208019
208414
  function setWholePartReplacement(args, partUri, baseBytes, nextXml) {
208020
208415
  const alreadyModified = args.perPart[partUri]?.kind === "modify";
@@ -209976,10 +210371,10 @@ var init_split_paragraph_inline = __esm(() => {
209976
210371
  function prepareParagraphSectionCollapse(bytes, start, end) {
209977
210372
  if (start.directBodyChildOrdinal == null || end.directBodyChildOrdinal == null)
209978
210373
  return null;
209979
- const decoder3 = new TextDecoder;
210374
+ const decoder4 = new TextDecoder;
209980
210375
  const inherited = namespaceBindingsAtPosition(bytes, start.byteStart);
209981
- const first = readProperties(decoder3.decode(bytes.subarray(start.byteStart, start.byteEnd)), inherited);
209982
- const last = readProperties(decoder3.decode(bytes.subarray(end.byteStart, end.byteEnd)), inherited);
210376
+ const first = readProperties(decoder4.decode(bytes.subarray(start.byteStart, start.byteEnd)), inherited);
210377
+ const last = readProperties(decoder4.decode(bytes.subarray(end.byteStart, end.byteEnd)), inherited);
209983
210378
  if (!first || !last)
209984
210379
  return null;
209985
210380
  const destination = first.properties?.namespaceBindings ?? first.root.namespaceBindings;
@@ -230332,8 +230727,6 @@ function normalizeMatchDestinationBlocks(blocks) {
230332
230727
  // ../../../v2/editor-core/dist/document/transactions/image-catalog.js
230333
230728
  function buildImageCatalog(input) {
230334
230729
  const xml = TD62.decode(input.bytes);
230335
- let utf8Offsets = null;
230336
- let paragraphScan = null;
230337
230730
  const relsXml = input.relsBytes ? TD62.decode(input.relsBytes) : "";
230338
230731
  const imageTargets = parseImageRelTargets(relsXml);
230339
230732
  const catalog = {
@@ -230342,46 +230735,46 @@ function buildImageCatalog(input) {
230342
230735
  images: [],
230343
230736
  byImageId: new Map
230344
230737
  };
230345
- const re = /<([\w.-]+):drawing\b/g;
230346
- let match;
230347
- let ordinal = 0;
230348
- while ((match = re.exec(xml)) != null) {
230349
- const prefix = match[1];
230350
- const openStart = match.index;
230351
- const openEnd = xml.indexOf(">", openStart);
230352
- if (openEnd < 0)
230353
- break;
230354
- if (xml[openEnd - 1] === "/")
230355
- continue;
230356
- const closeTag = `</${prefix}:drawing>`;
230357
- const closeStart = xml.indexOf(closeTag, openEnd + 1);
230358
- if (closeStart < 0)
230359
- continue;
230360
- const closeEnd = closeStart + closeTag.length;
230361
- paragraphScan ?? (paragraphScan = scanWmlParagraphSpans(xml));
230362
- utf8Offsets ?? (utf8Offsets = createMonotonicUtf8OffsetCursor(xml));
230738
+ if (!/<(?:[\w.-]+:)?drawing\b/.test(xml))
230739
+ return catalog;
230740
+ const spans = scanDrawingSpans(xml);
230741
+ if (spans.length === 0)
230742
+ return catalog;
230743
+ const paragraphScan = scanWmlParagraphSpans(xml);
230744
+ const positions = new Set;
230745
+ for (const span of spans) {
230746
+ positions.add(span.openStart);
230747
+ positions.add(span.closeEnd);
230748
+ if (paragraphScan.ok) {
230749
+ const paragraph = findContainingWmlParagraph(paragraphScan.paragraphs, span.openStart);
230750
+ if (paragraph)
230751
+ positions.add(paragraph.openStart);
230752
+ }
230753
+ }
230754
+ const utf8Cursor = createMonotonicUtf8OffsetCursor(xml);
230755
+ const byteOffsets = new Map;
230756
+ for (const position of [...positions].sort((left, right) => left - right)) {
230757
+ byteOffsets.set(position, utf8Cursor.byteOffsetAt(position));
230758
+ }
230759
+ for (const [ordinal, span] of spans.entries()) {
230363
230760
  const descriptor = projectImageDescriptor({
230364
230761
  xml,
230365
- openStart,
230366
- openEnd,
230367
- closeStart,
230368
- closeEnd,
230762
+ ...span,
230369
230763
  ordinal,
230370
230764
  storyId: input.storyId,
230371
230765
  partUri: input.partUri,
230372
230766
  paragraphScan,
230373
230767
  imageTargets,
230374
230768
  existingPartUris: input.existingPartUris,
230375
- byteOffsetAt: (codeUnit) => utf8Offsets.byteOffsetAt(codeUnit)
230769
+ byteOffsetAt: (codeUnit) => byteOffsets.get(codeUnit)
230376
230770
  });
230377
230771
  catalog.images.push(descriptor);
230378
230772
  catalog.byImageId.set(descriptor.imageNodeId, descriptor);
230379
- ordinal += 1;
230380
230773
  }
230381
230774
  return catalog;
230382
230775
  }
230383
230776
  function projectImageDescriptor(input) {
230384
- const inner = input.xml.slice(input.openEnd + 1, input.closeStart);
230777
+ const inner = ownDrawingContent(input);
230385
230778
  let container = "unknown";
230386
230779
  if (/<[\w.-]+:inline\b/.test(inner))
230387
230780
  container = "inline";
@@ -230397,9 +230790,12 @@ function projectImageDescriptor(input) {
230397
230790
  const heightEmu = extentMatch ? Number(extentMatch[2]) : null;
230398
230791
  const docPrMatch = /<[\w.-]+:docPr\b[^>]*\bname="([^"]*)"/.exec(inner);
230399
230792
  const name = docPrMatch ? decodeXmlAttr(docPrMatch[1]) : null;
230400
- const paraId = input.paragraphScan.ok ? findContainingWmlParagraph(input.paragraphScan.paragraphs, input.openStart)?.paraId ?? null : null;
230793
+ const paragraph = input.paragraphScan.ok ? findContainingWmlParagraph(input.paragraphScan.paragraphs, input.openStart) : null;
230794
+ const paraId = paragraph?.paraId ?? null;
230795
+ const paragraphByteStart = paragraph ? input.byteOffsetAt(paragraph.openStart) : null;
230401
230796
  const byteStart = input.byteOffsetAt(input.openStart);
230402
230797
  const byteEnd = input.byteOffsetAt(input.closeEnd);
230798
+ const isPicture = /<[\w.-]+:graphicData\b[^>]*\buri="http:\/\/schemas\.openxmlformats\.org\/drawingml\/2006\/picture"/.test(inner) || /<[\w.-]+:pic\b/.test(inner);
230403
230799
  let unsupportedReason = null;
230404
230800
  if (container === "anchor")
230405
230801
  unsupportedReason = "container-anchor";
@@ -230415,6 +230811,7 @@ function projectImageDescriptor(input) {
230415
230811
  imageNodeId: paraId ? `img:${paraId}:${input.ordinal}` : `img:${byteStart}:${input.ordinal}`,
230416
230812
  storyId: input.storyId,
230417
230813
  paraId,
230814
+ paragraphByteStart,
230418
230815
  byteStart,
230419
230816
  byteEnd,
230420
230817
  container,
@@ -230424,72 +230821,66 @@ function projectImageDescriptor(input) {
230424
230821
  widthEmu,
230425
230822
  heightEmu,
230426
230823
  name,
230824
+ isPicture,
230427
230825
  supported: unsupportedReason === null,
230428
230826
  unsupportedReason
230429
230827
  };
230430
230828
  }
230431
- async function scanDrawingSpansCooperatively(xml, yieldPoint) {
230829
+ function ownDrawingContent(span) {
230830
+ if (span.childRanges.length === 0)
230831
+ return span.xml.slice(span.openEnd, span.closeStart);
230832
+ let content = "";
230833
+ let cursor = span.openEnd;
230834
+ for (const child of span.childRanges) {
230835
+ content += span.xml.slice(cursor, child.openStart);
230836
+ cursor = child.closeEnd;
230837
+ }
230838
+ return content + span.xml.slice(cursor, span.closeStart);
230839
+ }
230840
+ function createDrawingSpanCollector() {
230432
230841
  const spans = [];
230433
- let active = null;
230434
- let cursor = 0;
230435
- let tagsSinceCheck = 0;
230436
- let sliceStart = performance.now();
230437
- while (cursor < xml.length) {
230438
- const openStart = xml.indexOf("<", cursor);
230439
- if (openStart < 0)
230440
- break;
230441
- if (xml.startsWith("<!--", openStart)) {
230442
- const end = xml.indexOf("-->", openStart + 4);
230443
- if (end < 0)
230444
- break;
230445
- cursor = end + 3;
230446
- } else if (xml.startsWith("<![CDATA[", openStart)) {
230447
- const end = xml.indexOf("]]>", openStart + 9);
230448
- if (end < 0)
230449
- break;
230450
- cursor = end + 3;
230451
- } else if (xml.startsWith("<?", openStart)) {
230452
- const end = xml.indexOf("?>", openStart + 2);
230453
- if (end < 0)
230454
- break;
230455
- cursor = end + 2;
230456
- } else {
230457
- const close = xml.indexOf(">", openStart + 1);
230458
- if (close < 0)
230459
- break;
230460
- const body = xml.slice(openStart + 1, close).trim();
230461
- const closing = body.startsWith("/");
230462
- const selfClosing = body.endsWith("/");
230463
- const nameStart = closing ? 1 : 0;
230464
- const nameSource = body.slice(nameStart);
230465
- const nameEndCandidate = nameSource.search(/[\s/]/);
230466
- const qualifiedName2 = nameEndCandidate < 0 ? nameSource : nameSource.slice(0, nameEndCandidate);
230467
- const colon = qualifiedName2.indexOf(":");
230468
- const prefix = colon < 0 ? "" : qualifiedName2.slice(0, colon);
230469
- const localName2 = colon < 0 ? qualifiedName2 : qualifiedName2.slice(colon + 1);
230470
- if (!closing && !selfClosing && localName2 === "drawing" && active == null) {
230471
- active = { prefix, openStart, openEnd: close };
230472
- } else if (closing && localName2 === "drawing" && active && active.prefix === prefix) {
230473
- spans.push({
230474
- openStart: active.openStart,
230475
- openEnd: active.openEnd,
230476
- closeStart: openStart,
230477
- closeEnd: close + 1
230478
- });
230479
- active = null;
230480
- }
230481
- cursor = close + 1;
230482
- }
230483
- tagsSinceCheck += 1;
230484
- if (tagsSinceCheck >= 1024) {
230485
- tagsSinceCheck = 0;
230486
- if (performance.now() - sliceStart >= 8) {
230487
- await yieldPoint();
230488
- sliceStart = performance.now();
230842
+ const stack = [];
230843
+ return {
230844
+ spans,
230845
+ options: {
230846
+ additionalNamespaces: { w: NS_W },
230847
+ onOpenTag(event) {
230848
+ if (event.tag.namespaceUri !== NS_W && event.tag.namespaceUri !== NS_WSTRICT || event.tag.localName !== "drawing" || event.tag.isSelfClosing)
230849
+ return;
230850
+ const span = {
230851
+ openStart: event.start,
230852
+ openEnd: event.end,
230853
+ closeStart: 0,
230854
+ closeEnd: 0,
230855
+ childRanges: []
230856
+ };
230857
+ spans.push(span);
230858
+ stack.push(span);
230859
+ },
230860
+ onCloseTag(event) {
230861
+ if (event.tag.namespaceUri !== NS_W && event.tag.namespaceUri !== NS_WSTRICT || event.tag.localName !== "drawing" || event.tag.isSelfClosing)
230862
+ return;
230863
+ const span = stack.pop();
230864
+ if (!span)
230865
+ return;
230866
+ span.closeStart = event.start;
230867
+ span.closeEnd = event.end;
230868
+ const parent = stack[stack.length - 1];
230869
+ if (parent)
230870
+ parent.childRanges.push({ openStart: span.openStart, closeEnd: span.closeEnd });
230489
230871
  }
230490
230872
  }
230491
- }
230492
- return spans;
230873
+ };
230874
+ }
230875
+ function scanDrawingSpans(xml) {
230876
+ const collector3 = createDrawingSpanCollector();
230877
+ walkXmlElements(xml, collector3.options);
230878
+ return collector3.spans.filter((span) => span.closeEnd > span.openEnd);
230879
+ }
230880
+ async function scanDrawingSpansCooperatively(xml, yieldPoint) {
230881
+ const collector3 = createDrawingSpanCollector();
230882
+ await walkXmlElementsCooperatively(xml, { ...collector3.options, yieldPoint });
230883
+ return collector3.spans.filter((span) => span.closeEnd > span.openEnd);
230493
230884
  }
230494
230885
  async function buildImageCatalogCooperatively(input) {
230495
230886
  const xml = input.sharedXml ?? TD62.decode(input.bytes);
@@ -230778,6 +231169,7 @@ function imageExtension(format) {
230778
231169
  var TD62, STATE_CACHE3;
230779
231170
  var init_image_catalog = __esm(() => {
230780
231171
  init_sd_document_state();
231172
+ init_xml_sax();
230781
231173
  init_wml_paragraph_spans();
230782
231174
  init_part_wml_scan_cache();
230783
231175
  init_table_catalog();
@@ -240891,26 +241283,61 @@ function getOrBuildTopLevelTableTopologyForStory(state, storyId) {
240891
241283
  if (!resolved)
240892
241284
  return null;
240893
241285
  const { bytes } = resolved;
241286
+ const nested = nestedStoryTopologyShape(state, storyId, bytes);
241287
+ if (nested === "table-free")
241288
+ return emptyStoryTopology();
240894
241289
  const current = TOPOLOGY_BY_SOURCE_BYTES.get(bytes);
240895
241290
  if (current)
240896
- return current;
241291
+ return nested === "has-tables" ? withoutReadFacts(current) : current;
240897
241292
  const topology = buildTopLevelTableTopology(bytes);
240898
241293
  TOPOLOGY_BY_SOURCE_BYTES.set(bytes, topology);
240899
- return topology;
241294
+ return nested === "has-tables" ? withoutReadFacts(topology) : topology;
240900
241295
  }
240901
241296
  async function getOrBuildTopLevelTableTopologyForStoryCooperatively(state, storyId, yieldPoint) {
240902
241297
  const resolved = resolveInputs(state, storyId);
240903
241298
  if (!resolved)
240904
241299
  return null;
240905
241300
  const { partUri, bytes } = resolved;
241301
+ const nested = nestedStoryTopologyShape(state, storyId, bytes);
241302
+ if (nested === "table-free")
241303
+ return emptyStoryTopology();
240906
241304
  const current = TOPOLOGY_BY_SOURCE_BYTES.get(bytes);
240907
241305
  if (current)
240908
- return current;
241306
+ return nested === "has-tables" ? withoutReadFacts(current) : current;
240909
241307
  const topology = await buildTopLevelTableTopologyCooperatively(bytes, yieldPoint);
240910
241308
  if (state.packageBytes.get(partUri) !== bytes)
240911
241309
  return null;
240912
241310
  TOPOLOGY_BY_SOURCE_BYTES.set(bytes, topology);
240913
- return topology;
241311
+ return nested === "has-tables" ? withoutReadFacts(topology) : topology;
241312
+ }
241313
+ function emptyStoryTopology() {
241314
+ emptyTopology ?? (emptyTopology = buildTopLevelTableTopology(new TextEncoder().encode('<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:body/></w:document>')));
241315
+ return emptyTopology;
241316
+ }
241317
+ function nestedStoryTopologyShape(state, storyId, bytes) {
241318
+ const range = getStoryByteRangeFromState(state, storyId);
241319
+ if (!range || range[0] < 0 || range[1] < range[0] || range[1] > bytes.byteLength)
241320
+ return "not-nested";
241321
+ let shapes = NESTED_SHAPE_BY_SOURCE_BYTES.get(bytes);
241322
+ if (!shapes) {
241323
+ shapes = new Map;
241324
+ NESTED_SHAPE_BY_SOURCE_BYTES.set(bytes, shapes);
241325
+ }
241326
+ const key2 = `${storyId}@${range[0]}:${range[1]}`;
241327
+ let shape = shapes.get(key2);
241328
+ if (!shape) {
241329
+ shape = TABLE_MARKUP_RE.test(TD68.decode(bytes.subarray(range[0], range[1]))) ? "has-tables" : "table-free";
241330
+ shapes.set(key2, shape);
241331
+ }
241332
+ return shape;
241333
+ }
241334
+ function withoutReadFacts(topology) {
241335
+ let stripped = WITHOUT_READ_FACTS.get(topology);
241336
+ if (!stripped) {
241337
+ stripped = Object.freeze({ ...topology, tableReadFacts: null });
241338
+ WITHOUT_READ_FACTS.set(topology, stripped);
241339
+ }
241340
+ return stripped;
240914
241341
  }
240915
241342
  function resolveInputs(state, storyId) {
240916
241343
  if (!state.stories.has(storyId))
@@ -241594,12 +242021,15 @@ function sameName(bytes, start, end, otherStart, otherEnd) {
241594
242021
  }
241595
242022
  return true;
241596
242023
  }
241597
- var TD68, TOPOLOGY_BY_SOURCE_BYTES, YIELD_BYTE_INTERVAL, LocalName, UNPROVED_TABLE_ELEMENT_NAMES;
242024
+ var TD68, TOPOLOGY_BY_SOURCE_BYTES, YIELD_BYTE_INTERVAL, TABLE_MARKUP_RE, NESTED_SHAPE_BY_SOURCE_BYTES, WITHOUT_READ_FACTS, emptyTopology = null, LocalName, UNPROVED_TABLE_ELEMENT_NAMES;
241598
242025
  var init_top_level_table_topology = __esm(() => {
241599
242026
  init_sd_document_state();
241600
242027
  TD68 = new TextDecoder;
241601
242028
  TOPOLOGY_BY_SOURCE_BYTES = new WeakMap;
241602
242029
  YIELD_BYTE_INTERVAL = 1 << 20;
242030
+ TABLE_MARKUP_RE = /<\/?(?:[\w.-]+:)?tbl[\s/>]/;
242031
+ NESTED_SHAPE_BY_SOURCE_BYTES = new WeakMap;
242032
+ WITHOUT_READ_FACTS = new WeakMap;
241603
242033
  (function(LocalName2) {
241604
242034
  LocalName2[LocalName2["Other"] = 0] = "Other";
241605
242035
  LocalName2[LocalName2["Tbl"] = 1] = "Tbl";
@@ -246422,11 +246852,11 @@ async function* normalizeWordXmlStreamForSave(partUri, chunks) {
246422
246852
  yield* chunks;
246423
246853
  return;
246424
246854
  }
246425
- const decoder3 = new TextDecoder;
246855
+ const decoder4 = new TextDecoder;
246426
246856
  let carry = "";
246427
246857
  const carryLimit = 8192;
246428
246858
  for await (const chunk of chunks) {
246429
- const combined = carry + decoder3.decode(chunk, { stream: true });
246859
+ const combined = carry + decoder4.decode(chunk, { stream: true });
246430
246860
  const cut = chooseWordXmlRepairCut(combined, carryLimit);
246431
246861
  if (cut <= 0) {
246432
246862
  carry = combined;
@@ -246435,7 +246865,7 @@ async function* normalizeWordXmlStreamForSave(partUri, chunks) {
246435
246865
  yield SAVE_XML_ENCODER.encode(repairHexValuedHighlightXml(combined.slice(0, cut)));
246436
246866
  carry = combined.slice(cut);
246437
246867
  }
246438
- const finalText = carry + decoder3.decode();
246868
+ const finalText = carry + decoder4.decode();
246439
246869
  if (finalText)
246440
246870
  yield SAVE_XML_ENCODER.encode(repairHexValuedHighlightXml(finalText));
246441
246871
  }
@@ -279159,11 +279589,6 @@ var init_part = __esm(() => {
279159
279589
  init_sd_document_session_internal();
279160
279590
  });
279161
279591
 
279162
- // ../../../v2/document-api-v2-adapter/dist/core/public-picture-drawing.js
279163
- function isPublicPictureDrawing(drawingXml) {
279164
- return /<[\w.-]+:graphicData\b[^>]*\buri="http:\/\/schemas\.openxmlformats\.org\/drawingml\/2006\/picture"/.test(drawingXml) || /<[\w.-]+:pic\b/.test(drawingXml);
279165
- }
279166
-
279167
279592
  // ../../../v2/document-api-v2-adapter/dist/core/visible-text.js
279168
279593
  function decodeXmlText9(escaped) {
279169
279594
  return escaped.replace(/&(lt|gt|amp|quot|apos|#\d+|#x[0-9a-fA-F]+);/g, (_, entity) => {
@@ -279277,6 +279702,26 @@ function readStoryParagraphByBlockId(context, storyId, blockId, options = {}) {
279277
279702
  return null;
279278
279703
  return projectParagraphByBlockId(context, index, blockId, readParagraphStyleOutlineLevels(context), options.includeNamespaceBindings !== false);
279279
279704
  }
279705
+ function readStoryParagraphByByteStart(context, storyId, byteStart) {
279706
+ const index = getSDDocumentSessionInternalStoryParagraphIndex(context.session, storyId);
279707
+ if (!index)
279708
+ return null;
279709
+ const entry = paragraphEntryAtByteStart(index, byteStart);
279710
+ return entry ? projectEntry(context, entry, readParagraphStyleOutlineLevels(context)) : null;
279711
+ }
279712
+ function paragraphEntryAtByteStart(index, byteStart) {
279713
+ let low = 0;
279714
+ let high = index.entries.length;
279715
+ while (low < high) {
279716
+ const middle = low + high >>> 1;
279717
+ if (index.entries[middle].byteStart < byteStart)
279718
+ low = middle + 1;
279719
+ else
279720
+ high = middle;
279721
+ }
279722
+ const entry = index.entries[low];
279723
+ return entry?.byteStart === byteStart ? entry : null;
279724
+ }
279280
279725
  function readStoryParagraphTextLengthByBlockId(context, storyId, blockId) {
279281
279726
  const index = getSDDocumentSessionInternalStoryParagraphIndex(context.session, storyId);
279282
279727
  if (!index)
@@ -279304,14 +279749,20 @@ function readStoryParagraphImageMap(context, storyId) {
279304
279749
  const bytes = getSDDocumentSessionInternalPartBytes(context.session, catalog.partUri);
279305
279750
  if (!bytes)
279306
279751
  return out;
279752
+ const index = getSDDocumentSessionInternalStoryParagraphIndex(context.session, storyId);
279753
+ if (!index)
279754
+ return out;
279307
279755
  for (const image of catalog.images) {
279308
- if (!image.paraId || !isPublicCatalogPicture(bytes, image))
279756
+ if (!image.isPicture || image.paragraphByteStart == null)
279757
+ continue;
279758
+ const paragraph2 = paragraphEntryAtByteStart(index, image.paragraphByteStart);
279759
+ if (!paragraph2)
279309
279760
  continue;
279310
- const existing = out.get(image.paraId);
279761
+ const existing = out.get(paragraph2.blockId);
279311
279762
  if (existing)
279312
279763
  existing.push(image);
279313
279764
  else
279314
- out.set(image.paraId, [image]);
279765
+ out.set(paragraph2.blockId, [image]);
279315
279766
  }
279316
279767
  return out;
279317
279768
  }
@@ -279319,23 +279770,17 @@ function countPublicPictureDrawings(context) {
279319
279770
  const seen = new Set;
279320
279771
  let count = 0;
279321
279772
  for (const { partUri, catalog } of listImageCatalogsForSession(context.session)) {
279322
- const bytes = getSDDocumentSessionInternalPartBytes(context.session, partUri);
279323
- if (!bytes)
279324
- continue;
279325
279773
  for (const image of catalog.images) {
279326
279774
  const key2 = `${partUri}:${image.byteStart}:${image.byteEnd}`;
279327
279775
  if (seen.has(key2))
279328
279776
  continue;
279329
279777
  seen.add(key2);
279330
- if (isPublicCatalogPicture(bytes, image))
279778
+ if (image.isPicture)
279331
279779
  count += 1;
279332
279780
  }
279333
279781
  }
279334
279782
  return count;
279335
279783
  }
279336
- function isPublicCatalogPicture(bytes, image) {
279337
- return isPublicPictureDrawing(TD79.decode(bytes.subarray(image.byteStart, image.byteEnd)));
279338
- }
279339
279784
  function readTopLevelBodyItems(context) {
279340
279785
  const body = context.resolveFullStoryLocator({ kind: "story", storyType: "body" });
279341
279786
  if ("error" in body)
@@ -289192,13 +289637,13 @@ function preflightSelectionRangeCollapse(deps, plan) {
289192
289637
  return failure3(mapRejectionReason(structuralFailure), structuralFailure);
289193
289638
  }
289194
289639
  if (deps.changeMode === "tracked") {
289195
- const decoder3 = new TextDecoder;
289640
+ const decoder4 = new TextDecoder;
289196
289641
  for (const entry of deps.index.entries) {
289197
289642
  if (entry.ordinal <= startEntry.ordinal || entry.ordinal >= endEntry.ordinal)
289198
289643
  continue;
289199
289644
  if (entry.storyId !== startEntry.storyId || entry.partUri !== startEntry.partUri)
289200
289645
  continue;
289201
- const paragraphXml = decoder3.decode(bytes.subarray(entry.byteStart, entry.byteEnd));
289646
+ const paragraphXml = decoder4.decode(bytes.subarray(entry.byteStart, entry.byteEnd));
289202
289647
  if (/<[\w.-]+:hyperlink\b[^>]*\b[\w.-]+:id\s*=\s*["']/.test(paragraphXml)) {
289203
289648
  return failure3("INVALID_CONTEXT", "paragraph-relationship-bearing-unsupported");
289204
289649
  }
@@ -291086,8 +291531,8 @@ function rewriteWholeBodySelectionText(bytes, index, text) {
291086
291531
  if (!first || !last || !directBodyRangeIsStructurallyPlain(bytes, index.entries, first, last, "tracked")) {
291087
291532
  return { ok: false, reason: "unsupported-context" };
291088
291533
  }
291089
- const firstXml = decoder3.decode(bytes.subarray(first.byteStart, first.byteEnd));
291090
- const lastXml = decoder3.decode(bytes.subarray(last.byteStart, last.byteEnd));
291534
+ const firstXml = decoder4.decode(bytes.subarray(first.byteStart, first.byteEnd));
291535
+ const lastXml = decoder4.decode(bytes.subarray(last.byteStart, last.byteEnd));
291091
291536
  let splitExistingRevision = false;
291092
291537
  const allocateWId = () => {
291093
291538
  splitExistingRevision = true;
@@ -291127,13 +291572,13 @@ function rewriteWholeBodySelectionText(bytes, index, text) {
291127
291572
  return rewritten;
291128
291573
  return {
291129
291574
  ok: true,
291130
- xml: decoder3.decode(bytes.subarray(0, first.byteStart)) + rewritten.xml + decoder3.decode(bytes.subarray(last.byteEnd))
291575
+ xml: decoder4.decode(bytes.subarray(0, first.byteStart)) + rewritten.xml + decoder4.decode(bytes.subarray(last.byteEnd))
291131
291576
  };
291132
291577
  }
291133
- var decoder3;
291578
+ var decoder4;
291134
291579
  var init_whole_body_selection_text = __esm(() => {
291135
291580
  init_sd_document_session_internal();
291136
- decoder3 = new TextDecoder;
291581
+ decoder4 = new TextDecoder;
291137
291582
  });
291138
291583
 
291139
291584
  // ../../../v2/document-api-v2-adapter/dist/selection-mutation/cross-cell-delete.js
@@ -294445,11 +294890,11 @@ class V2FieldsAdapter {
294445
294890
  const sourceBytes = getSDDocumentSessionInternalPartBytes(this.context.session, entry.partUri);
294446
294891
  if (!sourceBytes)
294447
294892
  return mutationFailure2("PRECONDITION_FAILED", "fields.remove could not read its source part.");
294448
- const decoder4 = new TextDecoder;
294893
+ const decoder5 = new TextDecoder;
294449
294894
  const locked = guardContentControlDeletion({
294450
- xml: decoder4.decode(sourceBytes),
294451
- start: decoder4.decode(sourceBytes.subarray(0, entry.descriptor.byteStart)).length,
294452
- end: decoder4.decode(sourceBytes.subarray(0, entry.descriptor.byteEnd)).length,
294895
+ xml: decoder5.decode(sourceBytes),
294896
+ start: decoder5.decode(sourceBytes.subarray(0, entry.descriptor.byteStart)).length,
294897
+ end: decoder5.decode(sourceBytes.subarray(0, entry.descriptor.byteEnd)).length,
294453
294898
  operation: "fields.remove"
294454
294899
  });
294455
294900
  if (locked)
@@ -294719,8 +295164,8 @@ function buildTrackedFieldResultEditXml(context, entry, nextResultXml, stamp, dr
294719
295164
  if (!bytes || !paragraph2 || entry.descriptor.byteEnd > paragraph2.byteEnd)
294720
295165
  return null;
294721
295166
  const descriptor = entry.descriptor;
294722
- const decoder4 = new TextDecoder;
294723
- const fieldXml = decoder4.decode(bytes.subarray(descriptor.byteStart, descriptor.byteEnd));
295167
+ const decoder5 = new TextDecoder;
295168
+ const fieldXml = decoder5.decode(bytes.subarray(descriptor.byteStart, descriptor.byteEnd));
294724
295169
  const parsed = collectXmlElementRanges(fieldXml, {
294725
295170
  fragment: true,
294726
295171
  additionalNamespaces: { ...paragraph2.namespaceBindings }
@@ -294729,7 +295174,7 @@ function buildTrackedFieldResultEditXml(context, entry, nextResultXml, stamp, dr
294729
295174
  return null;
294730
295175
  const fieldRoot = parsed.ranges.find((range) => range.start === 0);
294731
295176
  const replacementInput = {
294732
- beforeXml: decoder4.decode(bytes.subarray(descriptor.resultByteStart, descriptor.resultByteEnd)),
295177
+ beforeXml: decoder5.decode(bytes.subarray(descriptor.resultByteStart, descriptor.resultByteEnd)),
294733
295178
  afterXml: nextResultXml,
294734
295179
  namespaceBindings: new Map(Object.entries(fieldRoot?.namespaceBindings ?? paragraph2.namespaceBindings ?? {})),
294735
295180
  stamp: { ...stamp, revisionId: 0, author: { name: stamp.author.name, initials: stamp.author.initials ?? undefined } }
@@ -294746,7 +295191,7 @@ function buildTrackedFieldResultEditXml(context, entry, nextResultXml, stamp, dr
294746
295191
  });
294747
295192
  if (!replacement)
294748
295193
  return null;
294749
- return decoder4.decode(bytes.subarray(descriptor.byteStart, descriptor.resultByteStart)) + replacement.xml + decoder4.decode(bytes.subarray(descriptor.resultByteEnd, descriptor.byteEnd));
295194
+ return decoder5.decode(bytes.subarray(descriptor.byteStart, descriptor.resultByteStart)) + replacement.xml + decoder5.decode(bytes.subarray(descriptor.resultByteEnd, descriptor.byteEnd));
294750
295195
  }
294751
295196
  function operationError3(code, message) {
294752
295197
  const error48 = new Error(message);
@@ -294864,18 +295309,18 @@ function attachSessionHyperlinks(session, stories) {
294864
295309
  sessionHyperlinks.push({
294865
295310
  storyId: story.storyId,
294866
295311
  paragraphId: paragraph2.blockId,
294867
- startOffset: decoder4.decode(bytes.subarray(0, link.startByte - paragraph2.byteStart)).length,
294868
- endOffset: decoder4.decode(bytes).length,
295312
+ startOffset: decoder5.decode(bytes.subarray(0, link.startByte - paragraph2.byteStart)).length,
295313
+ endOffset: decoder5.decode(bytes).length,
294869
295314
  rel: link.rel
294870
295315
  });
294871
295316
  }
294872
295317
  return sessionHyperlinks.length ? { ...story, sessionHyperlinks } : story;
294873
295318
  });
294874
295319
  }
294875
- var decoder4;
295320
+ var decoder5;
294876
295321
  var init_session_hyperlinks = __esm(() => {
294877
295322
  init_sd_document_session_internal();
294878
- decoder4 = new TextDecoder;
295323
+ decoder5 = new TextDecoder;
294879
295324
  });
294880
295325
 
294881
295326
  // ../../../v2/document-api-v2-adapter/dist/actor-attribution.js
@@ -295642,7 +296087,8 @@ function isMetadataAnchorPr(pr, tag, knownIds) {
295642
296087
  return false;
295643
296088
  const hasHiddenAppearance = attrValue(/<w15:appearance\b[^>]*\/>/.exec(pr)?.[0] ?? "", "val") === "hidden";
295644
296089
  const hasPlainTextPr = /<w:text\b/.test(pr);
295645
- return knownIds.has(tag) && hasHiddenAppearance && hasPlainTextPr;
296090
+ const hasIncompatibleType = /<(?:[\w.-]+:)?(?:checkbox|dropDownList|comboBox|date|picture|repeatingSection|repeatingSectionItem|bibliography|citation|docPartObj|docPartList|group|entityPicker|equation)\b/iu.test(pr);
296091
+ return knownIds.has(tag) && hasHiddenAppearance && !hasIncompatibleType && (alias === METADATA_ANCHOR_ALIAS || hasPlainTextPr);
295646
296092
  }
295647
296093
  function materializeMetadataAnchor(documentXml, sdt, id) {
295648
296094
  const para = findParagraphContaining2(documentXml, sdt.start);
@@ -296177,12 +296623,12 @@ var init_native_table_properties = __esm(() => {
296177
296623
 
296178
296624
  // ../../../v2/document-api-v2-adapter/dist/tables/native-table-split.js
296179
296625
  function prepareNativeTableSplit(input) {
296180
- const xml = decoder5.decode(input.bytes);
296626
+ const xml = decoder6.decode(input.bytes);
296181
296627
  const parsed = collectXmlElementRanges(xml);
296182
296628
  if (parsed.errors.length)
296183
296629
  return null;
296184
- const start = decoder5.decode(input.bytes.subarray(0, input.startByte)).length;
296185
- const end = decoder5.decode(input.bytes.subarray(0, input.endByte)).length;
296630
+ const start = decoder6.decode(input.bytes.subarray(0, input.startByte)).length;
296631
+ const end = decoder6.decode(input.bytes.subarray(0, input.endByte)).length;
296186
296632
  const table = parsed.ranges.find((range) => range.start === start && range.end === end && range.tag.namespaceUri === word2 && range.tag.localName === "tbl");
296187
296633
  if (!table)
296188
296634
  return null;
@@ -296208,10 +296654,10 @@ function prepareNativeTableSplit(input) {
296208
296654
  secondXml: header + xml.slice(rows[input.rowIndex].start, rows.at(-1).end) + footer
296209
296655
  };
296210
296656
  }
296211
- var word2 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", decoder5;
296657
+ var word2 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", decoder6;
296212
296658
  var init_native_table_split = __esm(() => {
296213
296659
  init_sd_document_session_internal();
296214
- decoder5 = new TextDecoder;
296660
+ decoder6 = new TextDecoder;
296215
296661
  });
296216
296662
 
296217
296663
  // ../../../v2/document-api-v2-adapter/dist/tables/tracked-policy.js
@@ -296326,8 +296772,8 @@ function prepareVerticalUnmerge(resolved) {
296326
296772
  }
296327
296773
  if (!cells.some((cell) => cell.cellByteStart === resolved.cell.cellByteStart) || cells.some((cell) => cell.gridSpan !== 1))
296328
296774
  return null;
296329
- const source = decoder6.decode(resolved.bytes);
296330
- const tableStart = decoder6.decode(resolved.bytes.subarray(0, resolved.table.tableByteStart)).length;
296775
+ const source = decoder7.decode(resolved.bytes);
296776
+ const tableStart = decoder7.decode(resolved.bytes.subarray(0, resolved.table.tableByteStart)).length;
296331
296777
  const parsed = collectXmlElementRanges(source);
296332
296778
  if (parsed.errors.length)
296333
296779
  return null;
@@ -296342,8 +296788,8 @@ function prepareVerticalUnmerge(resolved) {
296342
296788
  };
296343
296789
  const changes = [];
296344
296790
  for (const cell of cells) {
296345
- const cellStart = decoder6.decode(resolved.bytes.subarray(0, cell.cellByteStart)).length;
296346
- const cellEnd = decoder6.decode(resolved.bytes.subarray(0, cell.cellByteEnd)).length;
296791
+ const cellStart = decoder7.decode(resolved.bytes.subarray(0, cell.cellByteStart)).length;
296792
+ const cellEnd = decoder7.decode(resolved.bytes.subarray(0, cell.cellByteEnd)).length;
296347
296793
  const owner = parsed.ranges.find((range) => range.start === cellStart && range.end === cellEnd && range.tag.namespaceUri === W5 && range.tag.localName === "tc");
296348
296794
  if (!owner)
296349
296795
  return null;
@@ -296395,18 +296841,18 @@ function renderVerticalUnmerge(plan, stamp) {
296395
296841
  }
296396
296842
  return xml;
296397
296843
  }
296398
- var W5 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", decoder6;
296844
+ var W5 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", decoder7;
296399
296845
  var init_vertical_cell_properties = __esm(() => {
296400
296846
  init_sd_document_session_internal();
296401
296847
  init_tracked_pr_change();
296402
- decoder6 = new TextDecoder;
296848
+ decoder7 = new TextDecoder;
296403
296849
  });
296404
296850
 
296405
296851
  // ../../../v2/document-api-v2-adapter/dist/tables/native-cell-split.js
296406
296852
  function prepareNativeCellSplit(resolved, original, columnInsertIndex) {
296407
- const decoder7 = new TextDecoder;
296408
- const source = decoder7.decode(resolved.bytes);
296409
- const tableStart = decoder7.decode(resolved.bytes.subarray(0, resolved.table.tableByteStart)).length;
296853
+ const decoder8 = new TextDecoder;
296854
+ const source = decoder8.decode(resolved.bytes);
296855
+ const tableStart = decoder8.decode(resolved.bytes.subarray(0, resolved.table.tableByteStart)).length;
296410
296856
  const native4 = collectXmlElementRanges(source);
296411
296857
  if (native4.errors.length)
296412
296858
  return null;
@@ -334490,7 +334936,7 @@ function findTocBlock(context, nodeId) {
334490
334936
  }
334491
334937
  function guardTocContentMutation(context, field, instruction, operation) {
334492
334938
  const unavailable4 = () => ({ code: "CAPABILITY_UNAVAILABLE", message: `${operation}: the TOC source is unavailable.` });
334493
- const decoder7 = new TextDecoder;
334939
+ const decoder8 = new TextDecoder;
334494
334940
  const parts = new Map;
334495
334941
  const add = (partUri, start, end) => {
334496
334942
  let part = parts.get(partUri);
@@ -334498,12 +334944,12 @@ function guardTocContentMutation(context, field, instruction, operation) {
334498
334944
  const bytes = readPartBytes2(context, partUri);
334499
334945
  if (!bytes)
334500
334946
  return false;
334501
- part = { bytes, xml: decoder7.decode(bytes), selections: [] };
334947
+ part = { bytes, xml: decoder8.decode(bytes), selections: [] };
334502
334948
  parts.set(partUri, part);
334503
334949
  }
334504
334950
  part.selections.push({
334505
- start: decoder7.decode(part.bytes.subarray(0, start)).length,
334506
- end: decoder7.decode(part.bytes.subarray(0, end)).length
334951
+ start: decoder8.decode(part.bytes.subarray(0, start)).length,
334952
+ end: decoder8.decode(part.bytes.subarray(0, end)).length
334507
334953
  });
334508
334954
  return true;
334509
334955
  };
@@ -341239,15 +341685,15 @@ async function readSourceBackedProjectionSources(context, resolved, input, expec
341239
341685
  };
341240
341686
  }
341241
341687
  async function decodeProjectionXmlCooperatively(bytes, sliceGate) {
341242
- const decoder7 = new TextDecoder;
341688
+ const decoder8 = new TextDecoder;
341243
341689
  const chunks = [];
341244
341690
  for (let offset = 0;offset < bytes.byteLength; offset += PROJECTION_SCAN_CHUNK_BYTES) {
341245
- chunks.push(decoder7.decode(bytes.subarray(offset, offset + PROJECTION_SCAN_CHUNK_BYTES), {
341691
+ chunks.push(decoder8.decode(bytes.subarray(offset, offset + PROJECTION_SCAN_CHUNK_BYTES), {
341246
341692
  stream: true
341247
341693
  }));
341248
341694
  await sliceGate();
341249
341695
  }
341250
- chunks.push(decoder7.decode());
341696
+ chunks.push(decoder8.decode());
341251
341697
  return chunks.join("");
341252
341698
  }
341253
341699
  async function createProjectionUtf8OffsetIndexCooperatively(xml, sliceGate) {
@@ -346311,13 +346757,13 @@ function readImageCatalogEntries(context, readContext, source) {
346311
346757
  });
346312
346758
  if (candidates.length === 0)
346313
346759
  return [];
346314
- const paragraphsById = new Map;
346315
- for (const paraId of new Set(candidates.map(({ descriptor }) => descriptor.paraId).filter((value2) => typeof value2 === "string" && value2.length > 0))) {
346316
- const paragraph4 = readImageParagraph(context, readContext, storyId, paraId);
346760
+ const paragraphsByStart = new Map;
346761
+ for (const byteStart of new Set(candidates.map(({ descriptor }) => descriptor.paragraphByteStart).filter((value2) => value2 != null))) {
346762
+ const paragraph4 = readStoryParagraphByByteStart(context, storyId, byteStart);
346317
346763
  if (paragraph4)
346318
- paragraphsById.set(paraId, paragraph4);
346764
+ paragraphsByStart.set(byteStart, paragraph4);
346319
346765
  }
346320
- return candidates.map((candidate2) => projectRawImageEntry(readContext, source, relsUri, partXml, hyperlinkTargets, paragraphsById, candidate2));
346766
+ return candidates.map((candidate2) => projectRawImageEntry(readContext, source, relsUri, partXml, hyperlinkTargets, paragraphsByStart, candidate2));
346321
346767
  }
346322
346768
  async function readImageCatalogEntriesCooperatively(context, readContext, source, checkpoint) {
346323
346769
  const { storyId, partUri, catalog, partBytes } = source;
@@ -346342,18 +346788,18 @@ async function readImageCatalogEntriesCooperatively(context, readContext, source
346342
346788
  }
346343
346789
  if (candidates.length === 0)
346344
346790
  return [];
346345
- const paragraphsById = new Map;
346346
- const paragraphIds = new Set(candidates.map(({ descriptor }) => descriptor.paraId).filter((value2) => typeof value2 === "string" && value2.length > 0));
346347
- for (const paraId of paragraphIds) {
346348
- const paragraph4 = readImageParagraph(context, readContext, storyId, paraId);
346791
+ const paragraphsByStart = new Map;
346792
+ const paragraphStarts = new Set(candidates.map(({ descriptor }) => descriptor.paragraphByteStart).filter((value2) => value2 != null));
346793
+ for (const byteStart of paragraphStarts) {
346794
+ const paragraph4 = readStoryParagraphByByteStart(context, storyId, byteStart);
346349
346795
  if (paragraph4)
346350
- paragraphsById.set(paraId, paragraph4);
346796
+ paragraphsByStart.set(byteStart, paragraph4);
346351
346797
  if (!await checkpoint())
346352
346798
  return null;
346353
346799
  }
346354
346800
  const entries = [];
346355
346801
  for (const candidate2 of candidates) {
346356
- entries.push(projectRawImageEntry(readContext, source, relsUri, partXml, hyperlinkTargets, paragraphsById, candidate2));
346802
+ entries.push(projectRawImageEntry(readContext, source, relsUri, partXml, hyperlinkTargets, paragraphsByStart, candidate2));
346357
346803
  if (!await checkpoint())
346358
346804
  return null;
346359
346805
  }
@@ -346363,13 +346809,13 @@ function readImageCatalogCandidate(partBytes, descriptor, wrapper) {
346363
346809
  if (wrapper?.kind === "del" || wrapper?.kind === "moveFrom")
346364
346810
  return null;
346365
346811
  const drawingXml = TD94.decode(partBytes.subarray(descriptor.byteStart, descriptor.byteEnd));
346366
- return isPublicPictureDrawing(drawingXml) ? { descriptor, wrapper, drawingXml } : null;
346812
+ return descriptor.isPicture ? { descriptor, wrapper, drawingXml } : null;
346367
346813
  }
346368
346814
  function readImageParagraph(context, readContext, storyId, paraId) {
346369
346815
  return storyId === readContext.bodyStoryId ? readBodyParagraphByBlockId(context, paraId) : readStoryParagraphByBlockId(context, storyId, paraId);
346370
346816
  }
346371
- function projectRawImageEntry(readContext, { storyId, partUri }, relsUri, partXml, hyperlinkTargets, paragraphsById, { descriptor, wrapper, drawingXml }) {
346372
- const paragraph4 = descriptor.paraId ? paragraphsById.get(descriptor.paraId) ?? null : null;
346817
+ function projectRawImageEntry(readContext, { storyId, partUri }, relsUri, partXml, hyperlinkTargets, paragraphsByStart, { descriptor, wrapper, drawingXml }) {
346818
+ const paragraph4 = descriptor.paragraphByteStart == null ? null : paragraphsByStart.get(descriptor.paragraphByteStart) ?? null;
346373
346819
  const docPrId = extractDocPrId(drawingXml);
346374
346820
  const trackedReplacementOriginalRId = wrapper?.kind === "ins" && docPrId ? readPreviousTrackedDeletionImageRId(partXml, wrapper.range.start, docPrId) : null;
346375
346821
  const publicBaseId = buildPublicImageBaseId(partUri, {
@@ -346394,14 +346840,14 @@ function projectRawImageEntry(readContext, { storyId, partUri }, relsUri, partXm
346394
346840
  }
346395
346841
  function finalizeImageEntries(context, rawEntries) {
346396
346842
  const uniqueEntries2 = [];
346397
- const seenRanges = new Set;
346843
+ const uniqueByRange = new Map;
346398
346844
  for (const entry of rawEntries) {
346399
346845
  const key2 = `${entry.partUri}:${entry.descriptor.byteStart}:${entry.descriptor.byteEnd}`;
346400
- if (seenRanges.has(key2))
346401
- continue;
346402
- seenRanges.add(key2);
346403
- uniqueEntries2.push(entry);
346846
+ const existing = uniqueByRange.get(key2);
346847
+ if (!existing || !existing.paragraph && entry.paragraph)
346848
+ uniqueByRange.set(key2, entry);
346404
346849
  }
346850
+ uniqueEntries2.push(...uniqueByRange.values());
346405
346851
  const counts = new Map;
346406
346852
  for (const entry of uniqueEntries2) {
346407
346853
  counts.set(entry.publicBaseId, (counts.get(entry.publicBaseId) ?? 0) + 1);
@@ -346416,16 +346862,16 @@ function finalizeImageEntries(context, rawEntries) {
346416
346862
  }
346417
346863
  async function finalizeImageEntriesCooperatively(context, rawEntries, checkpoint) {
346418
346864
  const uniqueEntries2 = [];
346419
- const seenRanges = new Set;
346865
+ const uniqueByRange = new Map;
346420
346866
  for (const entry of rawEntries) {
346421
346867
  const key2 = `${entry.partUri}:${entry.descriptor.byteStart}:${entry.descriptor.byteEnd}`;
346422
- if (!seenRanges.has(key2)) {
346423
- seenRanges.add(key2);
346424
- uniqueEntries2.push(entry);
346425
- }
346868
+ const existing = uniqueByRange.get(key2);
346869
+ if (!existing || !existing.paragraph && entry.paragraph)
346870
+ uniqueByRange.set(key2, entry);
346426
346871
  if (!await checkpoint())
346427
346872
  return null;
346428
346873
  }
346874
+ uniqueEntries2.push(...uniqueByRange.values());
346429
346875
  const counts = new Map;
346430
346876
  for (const entry of uniqueEntries2) {
346431
346877
  counts.set(entry.publicBaseId, (counts.get(entry.publicBaseId) ?? 0) + 1);
@@ -346512,6 +346958,7 @@ function readStructuredImageMutationEntry(context, imageId) {
346512
346958
  imageNodeId: `img:${drawing.byteStart}:${rawEntries.length}`,
346513
346959
  storyId: located.storyId,
346514
346960
  paraId,
346961
+ paragraphByteStart: located.paragraph?.byteStart ?? null,
346515
346962
  byteStart: drawing.byteStart,
346516
346963
  byteEnd: drawing.byteEnd,
346517
346964
  container: /<[\w.-]+:anchor\b/.test(drawing.xml) ? "anchor" : "inline",
@@ -346521,10 +346968,11 @@ function readStructuredImageMutationEntry(context, imageId) {
346521
346968
  widthEmu: null,
346522
346969
  heightEmu: null,
346523
346970
  name: null,
346971
+ isPicture: true,
346524
346972
  supported: true,
346525
346973
  unsupportedReason: null
346526
346974
  };
346527
- rawEntries.push(projectRawImageEntry({ bodyStoryId: located.bodyStoryId, captionParagraphIds: new Set }, { storyId: located.storyId, partUri }, relsUri, partXml, hyperlinkTargets, located.paragraph ? new Map([[located.paragraph.blockId, located.paragraph]]) : new Map, { descriptor, wrapper: null, drawingXml: drawing.xml }));
346975
+ rawEntries.push(projectRawImageEntry({ bodyStoryId: located.bodyStoryId, captionParagraphIds: new Set }, { storyId: located.storyId, partUri }, relsUri, partXml, hyperlinkTargets, located.paragraph ? new Map([[located.paragraph.byteStart, located.paragraph]]) : new Map, { descriptor, wrapper: null, drawingXml: drawing.xml }));
346528
346976
  }
346529
346977
  return finalizeImageEntries(context, rawEntries).find((entry) => entry.publicId === imageId) ?? null;
346530
346978
  }
@@ -365723,6 +366171,10 @@ function isSourceBackedSaveUnsupportedError(error48) {
365723
366171
  return record3.name === "SDSourceBackedSaveUnsupportedError" || record3.code === "sd-source-backed-sync-save-unsupported" || record3.code === "save-overlay-unsupported";
365724
366172
  }
365725
366173
  function mapExportError(error48) {
366174
+ if (error48 instanceof Error && error48.name === "SDMetadataProjectionConflictError") {
366175
+ const details = error48.details;
366176
+ throw new DocumentApiValidationError2("PRECONDITION_FAILED", error48.message, details && typeof details === "object" ? details : undefined);
366177
+ }
365726
366178
  if (isCommentExportStoryReferenceError(error48)) {
365727
366179
  throw new DocumentApiValidationError2("PRECONDITION_FAILED", error48.message, {
365728
366180
  reason: "comment-export-missing-story-reference",
@@ -387891,16 +388343,16 @@ class StringDecoder {
387891
388343
  return res;
387892
388344
  }
387893
388345
  }
387894
- var errorUnexpectedEndOfArray, errorIntegerOutOfRange, createDecoder = (uint8Array) => new Decoder(uint8Array), hasContent = (decoder7) => decoder7.pos !== decoder7.arr.length, readUint8Array = (decoder7, len) => {
387895
- const view = new Uint8Array(decoder7.arr.buffer, decoder7.pos + decoder7.arr.byteOffset, len);
387896
- decoder7.pos += len;
388346
+ var errorUnexpectedEndOfArray, errorIntegerOutOfRange, createDecoder = (uint8Array) => new Decoder(uint8Array), hasContent = (decoder8) => decoder8.pos !== decoder8.arr.length, readUint8Array = (decoder8, len) => {
388347
+ const view = new Uint8Array(decoder8.arr.buffer, decoder8.pos + decoder8.arr.byteOffset, len);
388348
+ decoder8.pos += len;
387897
388349
  return view;
387898
- }, readVarUint8Array = (decoder7) => readUint8Array(decoder7, readVarUint(decoder7)), readUint8 = (decoder7) => decoder7.arr[decoder7.pos++], readVarUint = (decoder7) => {
388350
+ }, readVarUint8Array = (decoder8) => readUint8Array(decoder8, readVarUint(decoder8)), readUint8 = (decoder8) => decoder8.arr[decoder8.pos++], readVarUint = (decoder8) => {
387899
388351
  let num = 0;
387900
388352
  let mult = 1;
387901
- const len = decoder7.arr.length;
387902
- while (decoder7.pos < len) {
387903
- const r = decoder7.arr[decoder7.pos++];
388353
+ const len = decoder8.arr.length;
388354
+ while (decoder8.pos < len) {
388355
+ const r = decoder8.arr[decoder8.pos++];
387904
388356
  num = num + (r & BITS7) * mult;
387905
388357
  mult *= 128;
387906
388358
  if (r < BIT8) {
@@ -387911,17 +388363,17 @@ var errorUnexpectedEndOfArray, errorIntegerOutOfRange, createDecoder = (uint8Arr
387911
388363
  }
387912
388364
  }
387913
388365
  throw errorUnexpectedEndOfArray;
387914
- }, readVarInt = (decoder7) => {
387915
- let r = decoder7.arr[decoder7.pos++];
388366
+ }, readVarInt = (decoder8) => {
388367
+ let r = decoder8.arr[decoder8.pos++];
387916
388368
  let num = r & BITS6;
387917
388369
  let mult = 64;
387918
388370
  const sign = (r & BIT7) > 0 ? -1 : 1;
387919
388371
  if ((r & BIT8) === 0) {
387920
388372
  return sign * num;
387921
388373
  }
387922
- const len = decoder7.arr.length;
387923
- while (decoder7.pos < len) {
387924
- r = decoder7.arr[decoder7.pos++];
388374
+ const len = decoder8.arr.length;
388375
+ while (decoder8.pos < len) {
388376
+ r = decoder8.arr[decoder8.pos++];
387925
388377
  num = num + (r & BITS7) * mult;
387926
388378
  mult *= 128;
387927
388379
  if (r < BIT8) {
@@ -387932,32 +388384,32 @@ var errorUnexpectedEndOfArray, errorIntegerOutOfRange, createDecoder = (uint8Arr
387932
388384
  }
387933
388385
  }
387934
388386
  throw errorUnexpectedEndOfArray;
387935
- }, _readVarStringPolyfill = (decoder7) => {
387936
- let remainingLen = readVarUint(decoder7);
388387
+ }, _readVarStringPolyfill = (decoder8) => {
388388
+ let remainingLen = readVarUint(decoder8);
387937
388389
  if (remainingLen === 0) {
387938
388390
  return "";
387939
388391
  } else {
387940
- let encodedString = String.fromCodePoint(readUint8(decoder7));
388392
+ let encodedString = String.fromCodePoint(readUint8(decoder8));
387941
388393
  if (--remainingLen < 100) {
387942
388394
  while (remainingLen--) {
387943
- encodedString += String.fromCodePoint(readUint8(decoder7));
388395
+ encodedString += String.fromCodePoint(readUint8(decoder8));
387944
388396
  }
387945
388397
  } else {
387946
388398
  while (remainingLen > 0) {
387947
388399
  const nextLen = remainingLen < 1e4 ? remainingLen : 1e4;
387948
- const bytes = decoder7.arr.subarray(decoder7.pos, decoder7.pos + nextLen);
387949
- decoder7.pos += nextLen;
388400
+ const bytes = decoder8.arr.subarray(decoder8.pos, decoder8.pos + nextLen);
388401
+ decoder8.pos += nextLen;
387950
388402
  encodedString += String.fromCodePoint.apply(null, bytes);
387951
388403
  remainingLen -= nextLen;
387952
388404
  }
387953
388405
  }
387954
388406
  return decodeURIComponent(escape(encodedString));
387955
388407
  }
387956
- }, _readVarStringNative = (decoder7) => utf8TextDecoder.decode(readVarUint8Array(decoder7)), readVarString, readFromDataView = (decoder7, len) => {
387957
- const dv = new DataView(decoder7.arr.buffer, decoder7.arr.byteOffset + decoder7.pos, len);
387958
- decoder7.pos += len;
388408
+ }, _readVarStringNative = (decoder8) => utf8TextDecoder.decode(readVarUint8Array(decoder8)), readVarString, readFromDataView = (decoder8, len) => {
388409
+ const dv = new DataView(decoder8.arr.buffer, decoder8.arr.byteOffset + decoder8.pos, len);
388410
+ decoder8.pos += len;
387959
388411
  return dv;
387960
- }, readFloat32 = (decoder7) => readFromDataView(decoder7, 4).getFloat32(0, false), readFloat64 = (decoder7) => readFromDataView(decoder7, 8).getFloat64(0, false), readBigInt64 = (decoder7) => readFromDataView(decoder7, 8).getBigInt64(0, false), readAnyLookupTable, readAny = (decoder7) => readAnyLookupTable[127 - readUint8(decoder7)](decoder7), RleDecoder, UintOptRleDecoder, IntDiffOptRleDecoder;
388412
+ }, readFloat32 = (decoder8) => readFromDataView(decoder8, 4).getFloat32(0, false), readFloat64 = (decoder8) => readFromDataView(decoder8, 8).getFloat64(0, false), readBigInt64 = (decoder8) => readFromDataView(decoder8, 8).getBigInt64(0, false), readAnyLookupTable, readAny = (decoder8) => readAnyLookupTable[127 - readUint8(decoder8)](decoder8), RleDecoder, UintOptRleDecoder, IntDiffOptRleDecoder;
387961
388413
  var init_decoding = __esm(() => {
387962
388414
  init_binary();
387963
388415
  init_math();
@@ -387967,31 +388419,31 @@ var init_decoding = __esm(() => {
387967
388419
  errorIntegerOutOfRange = create3("Integer out of Range");
387968
388420
  readVarString = utf8TextDecoder ? _readVarStringNative : _readVarStringPolyfill;
387969
388421
  readAnyLookupTable = [
387970
- (decoder7) => {
388422
+ (decoder8) => {
387971
388423
  return;
387972
388424
  },
387973
- (decoder7) => null,
388425
+ (decoder8) => null,
387974
388426
  readVarInt,
387975
388427
  readFloat32,
387976
388428
  readFloat64,
387977
388429
  readBigInt64,
387978
- (decoder7) => false,
387979
- (decoder7) => true,
388430
+ (decoder8) => false,
388431
+ (decoder8) => true,
387980
388432
  readVarString,
387981
- (decoder7) => {
387982
- const len = readVarUint(decoder7);
388433
+ (decoder8) => {
388434
+ const len = readVarUint(decoder8);
387983
388435
  const obj = {};
387984
388436
  for (let i2 = 0;i2 < len; i2++) {
387985
- const key2 = readVarString(decoder7);
387986
- obj[key2] = readAny(decoder7);
388437
+ const key2 = readVarString(decoder8);
388438
+ obj[key2] = readAny(decoder8);
387987
388439
  }
387988
388440
  return obj;
387989
388441
  },
387990
- (decoder7) => {
387991
- const len = readVarUint(decoder7);
388442
+ (decoder8) => {
388443
+ const len = readVarUint(decoder8);
387992
388444
  const arr = [];
387993
388445
  for (let i2 = 0;i2 < len; i2++) {
387994
- arr.push(readAny(decoder7));
388446
+ arr.push(readAny(decoder8));
387995
388447
  }
387996
388448
  return arr;
387997
388449
  },
@@ -388471,8 +388923,8 @@ class DeleteSet {
388471
388923
  }
388472
388924
 
388473
388925
  class DSDecoderV1 {
388474
- constructor(decoder7) {
388475
- this.restDecoder = decoder7;
388926
+ constructor(decoder8) {
388927
+ this.restDecoder = decoder8;
388476
388928
  }
388477
388929
  resetDsCurVal() {}
388478
388930
  readDsClock() {
@@ -388484,9 +388936,9 @@ class DSDecoderV1 {
388484
388936
  }
388485
388937
 
388486
388938
  class DSDecoderV2 {
388487
- constructor(decoder7) {
388939
+ constructor(decoder8) {
388488
388940
  this.dsCurrVal = 0;
388489
- this.restDecoder = decoder7;
388941
+ this.restDecoder = decoder8;
388490
388942
  }
388491
388943
  resetDsCurVal() {
388492
388944
  this.dsCurrVal = 0;
@@ -388697,25 +389149,25 @@ class StackItem {
388697
389149
  this.meta = new Map;
388698
389150
  }
388699
389151
  }
388700
- function* lazyStructReaderGenerator(decoder7) {
388701
- const numOfStateUpdates = readVarUint(decoder7.restDecoder);
389152
+ function* lazyStructReaderGenerator(decoder8) {
389153
+ const numOfStateUpdates = readVarUint(decoder8.restDecoder);
388702
389154
  for (let i2 = 0;i2 < numOfStateUpdates; i2++) {
388703
- const numberOfStructs = readVarUint(decoder7.restDecoder);
388704
- const client = decoder7.readClient();
388705
- let clock = readVarUint(decoder7.restDecoder);
389155
+ const numberOfStructs = readVarUint(decoder8.restDecoder);
389156
+ const client = decoder8.readClient();
389157
+ let clock = readVarUint(decoder8.restDecoder);
388706
389158
  for (let i3 = 0;i3 < numberOfStructs; i3++) {
388707
- const info = decoder7.readInfo();
389159
+ const info = decoder8.readInfo();
388708
389160
  if (info === 10) {
388709
- const len = readVarUint(decoder7.restDecoder);
389161
+ const len = readVarUint(decoder8.restDecoder);
388710
389162
  yield new Skip(createID(client, clock), len);
388711
389163
  clock += len;
388712
389164
  } else if ((BITS5 & info) !== 0) {
388713
389165
  const cantCopyParentInfo = (info & (BIT7 | BIT8)) === 0;
388714
- const struct = new Item(createID(client, clock), null, (info & BIT8) === BIT8 ? decoder7.readLeftID() : null, null, (info & BIT7) === BIT7 ? decoder7.readRightID() : null, cantCopyParentInfo ? decoder7.readParentInfo() ? decoder7.readString() : decoder7.readLeftID() : null, cantCopyParentInfo && (info & BIT6) === BIT6 ? decoder7.readString() : null, readItemContent(decoder7, info));
389166
+ const struct = new Item(createID(client, clock), null, (info & BIT8) === BIT8 ? decoder8.readLeftID() : null, null, (info & BIT7) === BIT7 ? decoder8.readRightID() : null, cantCopyParentInfo ? decoder8.readParentInfo() ? decoder8.readString() : decoder8.readLeftID() : null, cantCopyParentInfo && (info & BIT6) === BIT6 ? decoder8.readString() : null, readItemContent(decoder8, info));
388715
389167
  yield struct;
388716
389168
  clock += struct.length;
388717
389169
  } else {
388718
- const len = decoder7.readLen();
389170
+ const len = decoder8.readLen();
388719
389171
  yield new GC(createID(client, clock), len);
388720
389172
  clock += len;
388721
389173
  }
@@ -388724,8 +389176,8 @@ function* lazyStructReaderGenerator(decoder7) {
388724
389176
  }
388725
389177
 
388726
389178
  class LazyStructReader {
388727
- constructor(decoder7, filterSkips) {
388728
- this.gen = lazyStructReaderGenerator(decoder7);
389179
+ constructor(decoder8, filterSkips) {
389180
+ this.gen = lazyStructReaderGenerator(decoder8);
388729
389181
  this.curr = null;
388730
389182
  this.done = false;
388731
389183
  this.filterSkips = filterSkips;
@@ -389482,33 +389934,33 @@ var iterateDeletedStructs = (transaction, ds, f) => ds.clients.forEach((deletes,
389482
389934
  encoder2.writeDsLen(item.len);
389483
389935
  }
389484
389936
  });
389485
- }, readDeleteSet = (decoder7) => {
389937
+ }, readDeleteSet = (decoder8) => {
389486
389938
  const ds = new DeleteSet;
389487
- const numClients = readVarUint(decoder7.restDecoder);
389939
+ const numClients = readVarUint(decoder8.restDecoder);
389488
389940
  for (let i2 = 0;i2 < numClients; i2++) {
389489
- decoder7.resetDsCurVal();
389490
- const client = readVarUint(decoder7.restDecoder);
389491
- const numberOfDeletes = readVarUint(decoder7.restDecoder);
389941
+ decoder8.resetDsCurVal();
389942
+ const client = readVarUint(decoder8.restDecoder);
389943
+ const numberOfDeletes = readVarUint(decoder8.restDecoder);
389492
389944
  if (numberOfDeletes > 0) {
389493
389945
  const dsField = setIfUndefined(ds.clients, client, () => []);
389494
389946
  for (let i3 = 0;i3 < numberOfDeletes; i3++) {
389495
- dsField.push(new DeleteItem(decoder7.readDsClock(), decoder7.readDsLen()));
389947
+ dsField.push(new DeleteItem(decoder8.readDsClock(), decoder8.readDsLen()));
389496
389948
  }
389497
389949
  }
389498
389950
  }
389499
389951
  return ds;
389500
- }, readAndApplyDeleteSet = (decoder7, transaction, store) => {
389952
+ }, readAndApplyDeleteSet = (decoder8, transaction, store) => {
389501
389953
  const unappliedDS = new DeleteSet;
389502
- const numClients = readVarUint(decoder7.restDecoder);
389954
+ const numClients = readVarUint(decoder8.restDecoder);
389503
389955
  for (let i2 = 0;i2 < numClients; i2++) {
389504
- decoder7.resetDsCurVal();
389505
- const client = readVarUint(decoder7.restDecoder);
389506
- const numberOfDeletes = readVarUint(decoder7.restDecoder);
389956
+ decoder8.resetDsCurVal();
389957
+ const client = readVarUint(decoder8.restDecoder);
389958
+ const numberOfDeletes = readVarUint(decoder8.restDecoder);
389507
389959
  const structs = store.clients.get(client) || [];
389508
389960
  const state = getState(store, client);
389509
389961
  for (let i3 = 0;i3 < numberOfDeletes; i3++) {
389510
- const clock = decoder7.readDsClock();
389511
- const clockEnd = clock + decoder7.readDsLen();
389962
+ const clock = decoder8.readDsClock();
389963
+ const clockEnd = clock + decoder8.readDsLen();
389512
389964
  if (clock < state) {
389513
389965
  if (state < clockEnd) {
389514
389966
  addToDeleteSet(unappliedDS, client, state, clockEnd - state);
@@ -389571,33 +390023,33 @@ var iterateDeletedStructs = (transaction, ds, f) => ds.clients.forEach((deletes,
389571
390023
  from(sm.entries()).sort((a, b) => b[0] - a[0]).forEach(([client, clock]) => {
389572
390024
  writeStructs(encoder2, store.clients.get(client), client, clock);
389573
390025
  });
389574
- }, readClientsStructRefs = (decoder7, doc2) => {
390026
+ }, readClientsStructRefs = (decoder8, doc2) => {
389575
390027
  const clientRefs = create();
389576
- const numOfStateUpdates = readVarUint(decoder7.restDecoder);
390028
+ const numOfStateUpdates = readVarUint(decoder8.restDecoder);
389577
390029
  for (let i2 = 0;i2 < numOfStateUpdates; i2++) {
389578
- const numberOfStructs = readVarUint(decoder7.restDecoder);
390030
+ const numberOfStructs = readVarUint(decoder8.restDecoder);
389579
390031
  const refs = new Array(numberOfStructs);
389580
- const client = decoder7.readClient();
389581
- let clock = readVarUint(decoder7.restDecoder);
390032
+ const client = decoder8.readClient();
390033
+ let clock = readVarUint(decoder8.restDecoder);
389582
390034
  clientRefs.set(client, { i: 0, refs });
389583
390035
  for (let i3 = 0;i3 < numberOfStructs; i3++) {
389584
- const info = decoder7.readInfo();
390036
+ const info = decoder8.readInfo();
389585
390037
  switch (BITS5 & info) {
389586
390038
  case 0: {
389587
- const len = decoder7.readLen();
390039
+ const len = decoder8.readLen();
389588
390040
  refs[i3] = new GC(createID(client, clock), len);
389589
390041
  clock += len;
389590
390042
  break;
389591
390043
  }
389592
390044
  case 10: {
389593
- const len = readVarUint(decoder7.restDecoder);
390045
+ const len = readVarUint(decoder8.restDecoder);
389594
390046
  refs[i3] = new Skip(createID(client, clock), len);
389595
390047
  clock += len;
389596
390048
  break;
389597
390049
  }
389598
390050
  default: {
389599
390051
  const cantCopyParentInfo = (info & (BIT7 | BIT8)) === 0;
389600
- const struct = new Item(createID(client, clock), null, (info & BIT8) === BIT8 ? decoder7.readLeftID() : null, null, (info & BIT7) === BIT7 ? decoder7.readRightID() : null, cantCopyParentInfo ? decoder7.readParentInfo() ? doc2.get(decoder7.readString()) : decoder7.readLeftID() : null, cantCopyParentInfo && (info & BIT6) === BIT6 ? decoder7.readString() : null, readItemContent(decoder7, info));
390052
+ const struct = new Item(createID(client, clock), null, (info & BIT8) === BIT8 ? decoder8.readLeftID() : null, null, (info & BIT7) === BIT7 ? decoder8.readRightID() : null, cantCopyParentInfo ? decoder8.readParentInfo() ? doc2.get(decoder8.readString()) : decoder8.readLeftID() : null, cantCopyParentInfo && (info & BIT6) === BIT6 ? decoder8.readString() : null, readItemContent(decoder8, info));
389601
390053
  refs[i3] = struct;
389602
390054
  clock += struct.length;
389603
390055
  }
@@ -389703,7 +390155,7 @@ var iterateDeletedStructs = (transaction, ds, f) => ds.clients.forEach((deletes,
389703
390155
  return { missing: missingSV, update: encoder2.toUint8Array() };
389704
390156
  }
389705
390157
  return null;
389706
- }, writeStructsFromTransaction = (encoder2, transaction) => writeClientsStructs(encoder2, transaction.doc.store, transaction.beforeState), readUpdateV2 = (decoder7, ydoc, transactionOrigin, structDecoder = new UpdateDecoderV2(decoder7)) => transact(ydoc, (transaction) => {
390158
+ }, writeStructsFromTransaction = (encoder2, transaction) => writeClientsStructs(encoder2, transaction.doc.store, transaction.beforeState), readUpdateV2 = (decoder8, ydoc, transactionOrigin, structDecoder = new UpdateDecoderV2(decoder8)) => transact(ydoc, (transaction) => {
389707
390159
  transaction.local = false;
389708
390160
  let retry = false;
389709
390161
  const doc2 = transaction.doc;
@@ -389749,8 +390201,8 @@ var iterateDeletedStructs = (transaction, ds, f) => ds.clients.forEach((deletes,
389749
390201
  applyUpdateV2(transaction.doc, update);
389750
390202
  }
389751
390203
  }, transactionOrigin, false), applyUpdateV2 = (ydoc, update, transactionOrigin, YDecoder = UpdateDecoderV2) => {
389752
- const decoder7 = createDecoder(update);
389753
- readUpdateV2(decoder7, ydoc, transactionOrigin, new YDecoder(decoder7));
390204
+ const decoder8 = createDecoder(update);
390205
+ readUpdateV2(decoder8, ydoc, transactionOrigin, new YDecoder(decoder8));
389754
390206
  }, applyUpdate = (ydoc, update, transactionOrigin) => applyUpdateV2(ydoc, update, transactionOrigin, UpdateDecoderV1), writeStateAsUpdate = (encoder2, doc2, targetStateVector = new Map) => {
389755
390207
  writeClientsStructs(encoder2, doc2.store, targetStateVector);
389756
390208
  writeDeleteSet(encoder2, createDeleteSetFromStructStore(doc2.store));
@@ -389772,12 +390224,12 @@ var iterateDeletedStructs = (transaction, ds, f) => ds.clients.forEach((deletes,
389772
390224
  }
389773
390225
  }
389774
390226
  return updates[0];
389775
- }, encodeStateAsUpdate = (doc2, encodedTargetStateVector) => encodeStateAsUpdateV2(doc2, encodedTargetStateVector, new UpdateEncoderV1), readStateVector = (decoder7) => {
390227
+ }, encodeStateAsUpdate = (doc2, encodedTargetStateVector) => encodeStateAsUpdateV2(doc2, encodedTargetStateVector, new UpdateEncoderV1), readStateVector = (decoder8) => {
389776
390228
  const ss = new Map;
389777
- const ssLength = readVarUint(decoder7.restDecoder);
390229
+ const ssLength = readVarUint(decoder8.restDecoder);
389778
390230
  for (let i2 = 0;i2 < ssLength; i2++) {
389779
- const client = readVarUint(decoder7.restDecoder);
389780
- const clock = readVarUint(decoder7.restDecoder);
390231
+ const client = readVarUint(decoder8.restDecoder);
390232
+ const clock = readVarUint(decoder8.restDecoder);
389781
390233
  ss.set(client, clock);
389782
390234
  }
389783
390235
  return ss;
@@ -389805,7 +390257,7 @@ var iterateDeletedStructs = (transaction, ds, f) => ds.clients.forEach((deletes,
389805
390257
  }, callEventHandlerListeners = (eventHandler, arg0, arg1) => callAll(eventHandler.l, [arg0, arg1]), compareIDs = (a, b) => a === b || a !== null && b !== null && a.client === b.client && a.clock === b.clock, createID = (client, clock) => new ID(client, clock), writeID = (encoder2, id2) => {
389806
390258
  writeVarUint(encoder2, id2.client);
389807
390259
  writeVarUint(encoder2, id2.clock);
389808
- }, readID = (decoder7) => createID(readVarUint(decoder7), readVarUint(decoder7)), findRootTypeKey = (type) => {
390260
+ }, readID = (decoder8) => createID(readVarUint(decoder8), readVarUint(decoder8)), findRootTypeKey = (type) => {
389809
390261
  for (const [key2, value2] of type.doc.share.entries()) {
389810
390262
  if (value2 === type) {
389811
390263
  return key2;
@@ -389870,22 +390322,22 @@ var iterateDeletedStructs = (transaction, ds, f) => ds.clients.forEach((deletes,
389870
390322
  const encoder2 = createEncoder();
389871
390323
  writeRelativePosition(encoder2, rpos);
389872
390324
  return toUint8Array(encoder2);
389873
- }, readRelativePosition = (decoder7) => {
390325
+ }, readRelativePosition = (decoder8) => {
389874
390326
  let type = null;
389875
390327
  let tname = null;
389876
390328
  let itemID = null;
389877
- switch (readVarUint(decoder7)) {
390329
+ switch (readVarUint(decoder8)) {
389878
390330
  case 0:
389879
- itemID = readID(decoder7);
390331
+ itemID = readID(decoder8);
389880
390332
  break;
389881
390333
  case 1:
389882
- tname = readVarString(decoder7);
390334
+ tname = readVarString(decoder8);
389883
390335
  break;
389884
390336
  case 2: {
389885
- type = readID(decoder7);
390337
+ type = readID(decoder8);
389886
390338
  }
389887
390339
  }
389888
- const assoc = hasContent(decoder7) ? readVarInt(decoder7) : 0;
390340
+ const assoc = hasContent(decoder8) ? readVarInt(decoder8) : 0;
389889
390341
  return new RelativePosition(type, tname, itemID, assoc);
389890
390342
  }, decodeRelativePosition = (uint8Array) => readRelativePosition(createDecoder(uint8Array)), getItemWithOffset = (store, id2) => {
389891
390343
  const item = getItem(store, id2);
@@ -390321,7 +390773,7 @@ var iterateDeletedStructs = (transaction, ds, f) => ds.clients.forEach((deletes,
390321
390773
  return updates[0];
390322
390774
  }
390323
390775
  const updateDecoders = updates.map((update) => new YDecoder(createDecoder(update)));
390324
- let lazyStructDecoders = updateDecoders.map((decoder7) => new LazyStructReader(decoder7, true));
390776
+ let lazyStructDecoders = updateDecoders.map((decoder8) => new LazyStructReader(decoder8, true));
390325
390777
  let currWrite = null;
390326
390778
  const updateEncoder = new YEncoder;
390327
390779
  const lazyStructEncoder = new LazyStructWriter(updateEncoder);
@@ -390398,7 +390850,7 @@ var iterateDeletedStructs = (transaction, ds, f) => ds.clients.forEach((deletes,
390398
390850
  currWrite = null;
390399
390851
  }
390400
390852
  finishLazyStructWriting(lazyStructEncoder);
390401
- const dss = updateDecoders.map((decoder7) => readDeleteSet(decoder7));
390853
+ const dss = updateDecoders.map((decoder8) => readDeleteSet(decoder8));
390402
390854
  const ds = mergeDeleteSets(dss);
390403
390855
  writeDeleteSet(updateEncoder, ds);
390404
390856
  return updateEncoder.toUint8Array();
@@ -390406,8 +390858,8 @@ var iterateDeletedStructs = (transaction, ds, f) => ds.clients.forEach((deletes,
390406
390858
  const state = decodeStateVector(sv);
390407
390859
  const encoder2 = new YEncoder;
390408
390860
  const lazyStructWriter = new LazyStructWriter(encoder2);
390409
- const decoder7 = new YDecoder(createDecoder(update));
390410
- const reader = new LazyStructReader(decoder7, false);
390861
+ const decoder8 = new YDecoder(createDecoder(update));
390862
+ const reader = new LazyStructReader(decoder8, false);
390411
390863
  while (reader.curr) {
390412
390864
  const curr = reader.curr;
390413
390865
  const currClient = curr.id.client;
@@ -390430,7 +390882,7 @@ var iterateDeletedStructs = (transaction, ds, f) => ds.clients.forEach((deletes,
390430
390882
  }
390431
390883
  }
390432
390884
  finishLazyStructWriting(lazyStructWriter);
390433
- const ds = readDeleteSet(decoder7);
390885
+ const ds = readDeleteSet(decoder8);
390434
390886
  writeDeleteSet(encoder2, ds);
390435
390887
  return encoder2.toUint8Array();
390436
390888
  }, flushLazyStructWriter = (lazyWriter) => {
@@ -391186,11 +391638,11 @@ var iterateDeletedStructs = (transaction, ds, f) => ds.clients.forEach((deletes,
391186
391638
  updateMarkerChanges(parent._searchMarker, currPos.index, -startLength + length2);
391187
391639
  }
391188
391640
  return currPos;
391189
- }, YTextEvent, YText, readYText = (_decoder) => new YText, YXmlTreeWalker, YXmlFragment, readYXmlFragment = (_decoder) => new YXmlFragment, YXmlElement, readYXmlElement = (decoder7) => new YXmlElement(decoder7.readKey()), YXmlEvent, YXmlHook, readYXmlHook = (decoder7) => new YXmlHook(decoder7.readKey()), YXmlText, readYXmlText = (decoder7) => new YXmlText, structGCRefNumber = 0, GC, readContentBinary = (decoder7) => new ContentBinary(decoder7.readBuf()), readContentDeleted = (decoder7) => new ContentDeleted(decoder7.readLen()), createDocFromOpts = (guid3, opts) => new Doc2({ guid: guid3, ...opts, shouldLoad: opts.shouldLoad || opts.autoLoad || false }), readContentDoc = (decoder7) => new ContentDoc(createDocFromOpts(decoder7.readString(), decoder7.readAny())), readContentEmbed = (decoder7) => new ContentEmbed(decoder7.readJSON()), readContentFormat = (decoder7) => new ContentFormat(decoder7.readKey(), decoder7.readJSON()), readContentJSON = (decoder7) => {
391190
- const len = decoder7.readLen();
391641
+ }, YTextEvent, YText, readYText = (_decoder) => new YText, YXmlTreeWalker, YXmlFragment, readYXmlFragment = (_decoder) => new YXmlFragment, YXmlElement, readYXmlElement = (decoder8) => new YXmlElement(decoder8.readKey()), YXmlEvent, YXmlHook, readYXmlHook = (decoder8) => new YXmlHook(decoder8.readKey()), YXmlText, readYXmlText = (decoder8) => new YXmlText, structGCRefNumber = 0, GC, readContentBinary = (decoder8) => new ContentBinary(decoder8.readBuf()), readContentDeleted = (decoder8) => new ContentDeleted(decoder8.readLen()), createDocFromOpts = (guid3, opts) => new Doc2({ guid: guid3, ...opts, shouldLoad: opts.shouldLoad || opts.autoLoad || false }), readContentDoc = (decoder8) => new ContentDoc(createDocFromOpts(decoder8.readString(), decoder8.readAny())), readContentEmbed = (decoder8) => new ContentEmbed(decoder8.readJSON()), readContentFormat = (decoder8) => new ContentFormat(decoder8.readKey(), decoder8.readJSON()), readContentJSON = (decoder8) => {
391642
+ const len = decoder8.readLen();
391191
391643
  const cs = [];
391192
391644
  for (let i2 = 0;i2 < len; i2++) {
391193
- const c = decoder7.readString();
391645
+ const c = decoder8.readString();
391194
391646
  if (c === "undefined") {
391195
391647
  cs.push(undefined);
391196
391648
  } else {
@@ -391198,14 +391650,14 @@ var iterateDeletedStructs = (transaction, ds, f) => ds.clients.forEach((deletes,
391198
391650
  }
391199
391651
  }
391200
391652
  return new ContentJSON(cs);
391201
- }, isDevMode, readContentAny = (decoder7) => {
391202
- const len = decoder7.readLen();
391653
+ }, isDevMode, readContentAny = (decoder8) => {
391654
+ const len = decoder8.readLen();
391203
391655
  const cs = [];
391204
391656
  for (let i2 = 0;i2 < len; i2++) {
391205
- cs.push(decoder7.readAny());
391657
+ cs.push(decoder8.readAny());
391206
391658
  }
391207
391659
  return new ContentAny(cs);
391208
- }, readContentString = (decoder7) => new ContentString(decoder7.readString()), typeRefs, YArrayRefID = 0, YMapRefID = 1, YTextRefID = 2, YXmlElementRefID = 3, YXmlFragmentRefID = 4, YXmlHookRefID = 5, YXmlTextRefID = 6, readContentType = (decoder7) => new ContentType(typeRefs[decoder7.readTypeRef()](decoder7)), followRedone = (store, id2) => {
391660
+ }, readContentString = (decoder8) => new ContentString(decoder8.readString()), typeRefs, YArrayRefID = 0, YMapRefID = 1, YTextRefID = 2, YXmlElementRefID = 3, YXmlFragmentRefID = 4, YXmlHookRefID = 5, YXmlTextRefID = 6, readContentType = (decoder8) => new ContentType(typeRefs[decoder8.readTypeRef()](decoder8)), followRedone = (store, id2) => {
391209
391661
  let nextID = id2;
391210
391662
  let diff = 0;
391211
391663
  let item;
@@ -391319,7 +391771,7 @@ var iterateDeletedStructs = (transaction, ds, f) => ds.clients.forEach((deletes,
391319
391771
  keepItem(redoneItem, true);
391320
391772
  redoneItem.integrate(transaction, 0);
391321
391773
  return redoneItem;
391322
- }, Item, readItemContent = (decoder7, info) => contentRefs[info & BITS5](decoder7), contentRefs, structSkipRefNumber = 10, Skip, glo, importIdentifier = "__ $YJS$ __";
391774
+ }, Item, readItemContent = (decoder8, info) => contentRefs[info & BITS5](decoder8), contentRefs, structSkipRefNumber = 10, Skip, glo, importIdentifier = "__ $YJS$ __";
391323
391775
  var init_yjs = __esm(() => {
391324
391776
  init_observable();
391325
391777
  init_array2();
@@ -391514,19 +391966,19 @@ var init_yjs = __esm(() => {
391514
391966
  }
391515
391967
  };
391516
391968
  UpdateDecoderV2 = class UpdateDecoderV2 extends DSDecoderV2 {
391517
- constructor(decoder7) {
391518
- super(decoder7);
391969
+ constructor(decoder8) {
391970
+ super(decoder8);
391519
391971
  this.keys = [];
391520
- readVarUint(decoder7);
391521
- this.keyClockDecoder = new IntDiffOptRleDecoder(readVarUint8Array(decoder7));
391522
- this.clientDecoder = new UintOptRleDecoder(readVarUint8Array(decoder7));
391523
- this.leftClockDecoder = new IntDiffOptRleDecoder(readVarUint8Array(decoder7));
391524
- this.rightClockDecoder = new IntDiffOptRleDecoder(readVarUint8Array(decoder7));
391525
- this.infoDecoder = new RleDecoder(readVarUint8Array(decoder7), readUint8);
391526
- this.stringDecoder = new StringDecoder(readVarUint8Array(decoder7));
391527
- this.parentInfoDecoder = new RleDecoder(readVarUint8Array(decoder7), readUint8);
391528
- this.typeRefDecoder = new UintOptRleDecoder(readVarUint8Array(decoder7));
391529
- this.lenDecoder = new UintOptRleDecoder(readVarUint8Array(decoder7));
391972
+ readVarUint(decoder8);
391973
+ this.keyClockDecoder = new IntDiffOptRleDecoder(readVarUint8Array(decoder8));
391974
+ this.clientDecoder = new UintOptRleDecoder(readVarUint8Array(decoder8));
391975
+ this.leftClockDecoder = new IntDiffOptRleDecoder(readVarUint8Array(decoder8));
391976
+ this.rightClockDecoder = new IntDiffOptRleDecoder(readVarUint8Array(decoder8));
391977
+ this.infoDecoder = new RleDecoder(readVarUint8Array(decoder8), readUint8);
391978
+ this.stringDecoder = new StringDecoder(readVarUint8Array(decoder8));
391979
+ this.parentInfoDecoder = new RleDecoder(readVarUint8Array(decoder8), readUint8);
391980
+ this.typeRefDecoder = new UintOptRleDecoder(readVarUint8Array(decoder8));
391981
+ this.lenDecoder = new UintOptRleDecoder(readVarUint8Array(decoder8));
391530
391982
  }
391531
391983
  readLeftID() {
391532
391984
  return new ID(this.clientDecoder.read(), this.leftClockDecoder.read());
@@ -393253,9 +393705,9 @@ var messageYjsSyncStep1 = 0, messageYjsSyncStep2 = 1, messageYjsUpdate = 2, writ
393253
393705
  }, writeSyncStep2 = (encoder2, doc2, encodedStateVector) => {
393254
393706
  writeVarUint(encoder2, messageYjsSyncStep2);
393255
393707
  writeVarUint8Array(encoder2, encodeStateAsUpdate(doc2, encodedStateVector));
393256
- }, readSyncStep1 = (decoder7, encoder2, doc2) => writeSyncStep2(encoder2, doc2, readVarUint8Array(decoder7)), readSyncStep2 = (decoder7, doc2, transactionOrigin, errorHandler) => {
393708
+ }, readSyncStep1 = (decoder8, encoder2, doc2) => writeSyncStep2(encoder2, doc2, readVarUint8Array(decoder8)), readSyncStep2 = (decoder8, doc2, transactionOrigin, errorHandler) => {
393257
393709
  try {
393258
- applyUpdate(doc2, readVarUint8Array(decoder7), transactionOrigin);
393710
+ applyUpdate(doc2, readVarUint8Array(decoder8), transactionOrigin);
393259
393711
  } catch (error48) {
393260
393712
  if (errorHandler != null)
393261
393713
  errorHandler(error48);
@@ -393264,17 +393716,17 @@ var messageYjsSyncStep1 = 0, messageYjsSyncStep2 = 1, messageYjsUpdate = 2, writ
393264
393716
  }, writeUpdate = (encoder2, update) => {
393265
393717
  writeVarUint(encoder2, messageYjsUpdate);
393266
393718
  writeVarUint8Array(encoder2, update);
393267
- }, readUpdate, readSyncMessage = (decoder7, encoder2, doc2, transactionOrigin, errorHandler) => {
393268
- const messageType = readVarUint(decoder7);
393719
+ }, readUpdate, readSyncMessage = (decoder8, encoder2, doc2, transactionOrigin, errorHandler) => {
393720
+ const messageType = readVarUint(decoder8);
393269
393721
  switch (messageType) {
393270
393722
  case messageYjsSyncStep1:
393271
- readSyncStep1(decoder7, encoder2, doc2);
393723
+ readSyncStep1(decoder8, encoder2, doc2);
393272
393724
  break;
393273
393725
  case messageYjsSyncStep2:
393274
- readSyncStep2(decoder7, doc2, transactionOrigin, errorHandler);
393726
+ readSyncStep2(decoder8, doc2, transactionOrigin, errorHandler);
393275
393727
  break;
393276
393728
  case messageYjsUpdate:
393277
- readUpdate(decoder7, doc2, transactionOrigin, errorHandler);
393729
+ readUpdate(decoder8, doc2, transactionOrigin, errorHandler);
393278
393730
  break;
393279
393731
  default:
393280
393732
  throw new Error("Unknown message type");
@@ -393289,10 +393741,10 @@ var init_sync = __esm(() => {
393289
393741
  });
393290
393742
 
393291
393743
  // ../../../v2/node_modules/.pnpm/y-protocols@1.0.7_yjs@13.6.31/node_modules/y-protocols/auth.js
393292
- var messagePermissionDenied = 0, readAuthMessage = (decoder7, y, permissionDeniedHandler) => {
393293
- switch (readVarUint(decoder7)) {
393744
+ var messagePermissionDenied = 0, readAuthMessage = (decoder8, y, permissionDeniedHandler) => {
393745
+ switch (readVarUint(decoder8)) {
393294
393746
  case messagePermissionDenied:
393295
- permissionDeniedHandler(y, readVarString(decoder7));
393747
+ permissionDeniedHandler(y, readVarString(decoder8));
393296
393748
  }
393297
393749
  };
393298
393750
  var init_auth = __esm(() => {
@@ -393334,17 +393786,17 @@ var outdatedTimeout = 30000, Awareness, removeAwarenessStates = (awareness, clie
393334
393786
  }
393335
393787
  return toUint8Array(encoder2);
393336
393788
  }, applyAwarenessUpdate = (awareness, update, origin) => {
393337
- const decoder7 = createDecoder(update);
393789
+ const decoder8 = createDecoder(update);
393338
393790
  const timestamp = getUnixTime();
393339
393791
  const added = [];
393340
393792
  const updated = [];
393341
393793
  const filteredUpdated = [];
393342
393794
  const removed = [];
393343
- const len = readVarUint(decoder7);
393795
+ const len = readVarUint(decoder8);
393344
393796
  for (let i2 = 0;i2 < len; i2++) {
393345
- const clientID = readVarUint(decoder7);
393346
- let clock = readVarUint(decoder7);
393347
- const state = JSON.parse(readVarString(decoder7));
393797
+ const clientID = readVarUint(decoder8);
393798
+ let clock = readVarUint(decoder8);
393799
+ const state = JSON.parse(readVarString(decoder8));
393348
393800
  const clientMeta = awareness.meta.get(clientID);
393349
393801
  const prevState = awareness.states.get(clientID);
393350
393802
  const currClock = clientMeta === undefined ? 0 : clientMeta.clock;
@@ -393491,12 +393943,12 @@ var init_url = __esm(() => {
393491
393943
  // ../../../v2/node_modules/.pnpm/y-websocket@3.0.0_yjs@13.6.31/node_modules/y-websocket/src/y-websocket.js
393492
393944
  var messageSync = 0, messageQueryAwareness = 3, messageAwareness = 1, messageAuth = 2, messageHandlers, messageReconnectTimeout = 30000, permissionDeniedHandler = (provider, reason) => console.warn(`Permission denied to access ${provider.url}.
393493
393945
  ${reason}`), readMessage = (provider, buf, emitSynced) => {
393494
- const decoder7 = createDecoder(buf);
393946
+ const decoder8 = createDecoder(buf);
393495
393947
  const encoder2 = createEncoder();
393496
- const messageType = readVarUint(decoder7);
393948
+ const messageType = readVarUint(decoder8);
393497
393949
  const messageHandler = provider.messageHandlers[messageType];
393498
393950
  if (messageHandler) {
393499
- messageHandler(encoder2, decoder7, provider, emitSynced, messageType);
393951
+ messageHandler(encoder2, decoder8, provider, emitSynced, messageType);
393500
393952
  } else {
393501
393953
  console.error("Unable to compute message");
393502
393954
  }
@@ -393587,9 +394039,9 @@ var init_y_websocket = __esm(() => {
393587
394039
  init_url();
393588
394040
  init_environment();
393589
394041
  messageHandlers = [];
393590
- messageHandlers[messageSync] = (encoder2, decoder7, provider, emitSynced, _messageType) => {
394042
+ messageHandlers[messageSync] = (encoder2, decoder8, provider, emitSynced, _messageType) => {
393591
394043
  writeVarUint(encoder2, messageSync);
393592
- const syncMessageType = readSyncMessage(decoder7, encoder2, provider.doc, provider);
394044
+ const syncMessageType = readSyncMessage(decoder8, encoder2, provider.doc, provider);
393593
394045
  if (emitSynced && syncMessageType === messageYjsSyncStep2 && !provider.synced) {
393594
394046
  provider.synced = true;
393595
394047
  }
@@ -393598,11 +394050,11 @@ var init_y_websocket = __esm(() => {
393598
394050
  writeVarUint(encoder2, messageAwareness);
393599
394051
  writeVarUint8Array(encoder2, encodeAwarenessUpdate(provider.awareness, Array.from(provider.awareness.getStates().keys())));
393600
394052
  };
393601
- messageHandlers[messageAwareness] = (_encoder, decoder7, provider, _emitSynced, _messageType) => {
393602
- applyAwarenessUpdate(provider.awareness, readVarUint8Array(decoder7), provider);
394053
+ messageHandlers[messageAwareness] = (_encoder, decoder8, provider, _emitSynced, _messageType) => {
394054
+ applyAwarenessUpdate(provider.awareness, readVarUint8Array(decoder8), provider);
393603
394055
  };
393604
- messageHandlers[messageAuth] = (_encoder, decoder7, provider, _emitSynced, _messageType) => {
393605
- readAuthMessage(decoder7, provider.doc, (_ydoc, reason) => permissionDeniedHandler(provider, reason));
394056
+ messageHandlers[messageAuth] = (_encoder, decoder8, provider, _emitSynced, _messageType) => {
394057
+ readAuthMessage(decoder8, provider.doc, (_ydoc, reason) => permissionDeniedHandler(provider, reason));
393606
394058
  };
393607
394059
  WebsocketProvider = class WebsocketProvider extends ObservableV2 {
393608
394060
  constructor(serverUrl, roomname, doc2, {
@@ -394185,8 +394637,8 @@ function createYWebsocketSingleDocAdapter(config2) {
394185
394637
  }
394186
394638
  const provider = new WebsocketProvider(config2.serverUrl, providerRoomName, ydoc, options);
394187
394639
  activeProvider = provider;
394188
- provider.messageHandlers[messageAuth] = (_encoder, decoder7, currentProvider) => {
394189
- readAuthMessage(decoder7, currentProvider.doc, () => {
394640
+ provider.messageHandlers[messageAuth] = (_encoder, decoder8, currentProvider) => {
394641
+ readAuthMessage(decoder8, currentProvider.doc, () => {
394190
394642
  onFailed({ providerFamily: "y-websocket", reason: "authentication_failed" });
394191
394643
  currentProvider.disconnect();
394192
394644
  });
@@ -394337,16 +394789,16 @@ var floor2, min2 = (a, b) => a < b ? a : b, max3 = (a, b) => a > b ? a : b, BIT8
394337
394789
  }, writeVarUint8Array2 = (encoder2, uint8Array) => {
394338
394790
  writeVarUint2(encoder2, uint8Array.byteLength);
394339
394791
  writeUint8Array2(encoder2, uint8Array);
394340
- }, create6 = (s) => new Error(s), errorUnexpectedEndOfArray2, errorIntegerOutOfRange2, readUint8Array2 = (decoder7, len) => {
394341
- const view = new Uint8Array(decoder7.arr.buffer, decoder7.pos + decoder7.arr.byteOffset, len);
394342
- decoder7.pos += len;
394792
+ }, create6 = (s) => new Error(s), errorUnexpectedEndOfArray2, errorIntegerOutOfRange2, readUint8Array2 = (decoder8, len) => {
394793
+ const view = new Uint8Array(decoder8.arr.buffer, decoder8.pos + decoder8.arr.byteOffset, len);
394794
+ decoder8.pos += len;
394343
394795
  return view;
394344
- }, readVarUint8Array2 = (decoder7) => readUint8Array2(decoder7, readVarUint2(decoder7)), readUint82 = (decoder7) => decoder7.arr[decoder7.pos++], readVarUint2 = (decoder7) => {
394796
+ }, readVarUint8Array2 = (decoder8) => readUint8Array2(decoder8, readVarUint2(decoder8)), readUint82 = (decoder8) => decoder8.arr[decoder8.pos++], readVarUint2 = (decoder8) => {
394345
394797
  let num = 0;
394346
394798
  let mult = 1;
394347
- const len = decoder7.arr.length;
394348
- while (decoder7.pos < len) {
394349
- const r = decoder7.arr[decoder7.pos++];
394799
+ const len = decoder8.arr.length;
394800
+ while (decoder8.pos < len) {
394801
+ const r = decoder8.arr[decoder8.pos++];
394350
394802
  num = num + (r & BITS72) * mult;
394351
394803
  mult *= 128;
394352
394804
  if (r < BIT82) {
@@ -394357,38 +394809,38 @@ var floor2, min2 = (a, b) => a < b ? a : b, max3 = (a, b) => a > b ? a : b, BIT8
394357
394809
  }
394358
394810
  }
394359
394811
  throw errorUnexpectedEndOfArray2;
394360
- }, _readVarStringPolyfill2 = (decoder7) => {
394361
- let remainingLen = readVarUint2(decoder7);
394812
+ }, _readVarStringPolyfill2 = (decoder8) => {
394813
+ let remainingLen = readVarUint2(decoder8);
394362
394814
  if (remainingLen === 0) {
394363
394815
  return "";
394364
394816
  } else {
394365
- let encodedString = String.fromCodePoint(readUint82(decoder7));
394817
+ let encodedString = String.fromCodePoint(readUint82(decoder8));
394366
394818
  if (--remainingLen < 100) {
394367
394819
  while (remainingLen--) {
394368
- encodedString += String.fromCodePoint(readUint82(decoder7));
394820
+ encodedString += String.fromCodePoint(readUint82(decoder8));
394369
394821
  }
394370
394822
  } else {
394371
394823
  while (remainingLen > 0) {
394372
394824
  const nextLen = remainingLen < 1e4 ? remainingLen : 1e4;
394373
- const bytes = decoder7.arr.subarray(decoder7.pos, decoder7.pos + nextLen);
394374
- decoder7.pos += nextLen;
394825
+ const bytes = decoder8.arr.subarray(decoder8.pos, decoder8.pos + nextLen);
394826
+ decoder8.pos += nextLen;
394375
394827
  encodedString += String.fromCodePoint.apply(null, bytes);
394376
394828
  remainingLen -= nextLen;
394377
394829
  }
394378
394830
  }
394379
394831
  return decodeURIComponent(escape(encodedString));
394380
394832
  }
394381
- }, _readVarStringNative2 = (decoder7) => utf8TextDecoder2.decode(readVarUint8Array2(decoder7)), readVarString2, AuthMessageType, writeAuthentication = (encoder2, auth) => {
394833
+ }, _readVarStringNative2 = (decoder8) => utf8TextDecoder2.decode(readVarUint8Array2(decoder8)), readVarString2, AuthMessageType, writeAuthentication = (encoder2, auth) => {
394382
394834
  writeVarUint2(encoder2, AuthMessageType.Token);
394383
394835
  writeVarString2(encoder2, auth);
394384
- }, readAuthMessage2 = (decoder7, permissionDeniedHandler2, authenticatedHandler) => {
394385
- switch (readVarUint2(decoder7)) {
394836
+ }, readAuthMessage2 = (decoder8, permissionDeniedHandler2, authenticatedHandler) => {
394837
+ switch (readVarUint2(decoder8)) {
394386
394838
  case AuthMessageType.PermissionDenied: {
394387
- permissionDeniedHandler2(readVarString2(decoder7));
394839
+ permissionDeniedHandler2(readVarString2(decoder8));
394388
394840
  break;
394389
394841
  }
394390
394842
  case AuthMessageType.Authenticated: {
394391
- authenticatedHandler(readVarString2(decoder7));
394843
+ authenticatedHandler(readVarString2(decoder8));
394392
394844
  break;
394393
394845
  }
394394
394846
  }
@@ -395018,16 +395470,16 @@ var import_attempt, create$2 = () => new Map, setIfUndefined2 = (map4, key2, cre
395018
395470
  }, writeVarUint8Array3 = (encoder2, uint8Array) => {
395019
395471
  writeVarUint3(encoder2, uint8Array.byteLength);
395020
395472
  writeUint8Array3(encoder2, uint8Array);
395021
- }, create7 = (s) => new Error(s), errorUnexpectedEndOfArray3, errorIntegerOutOfRange3, createDecoder2 = (uint8Array) => new Decoder2(uint8Array), readUint8Array3 = (decoder7, len) => {
395022
- const view = new Uint8Array(decoder7.arr.buffer, decoder7.pos + decoder7.arr.byteOffset, len);
395023
- decoder7.pos += len;
395473
+ }, create7 = (s) => new Error(s), errorUnexpectedEndOfArray3, errorIntegerOutOfRange3, createDecoder2 = (uint8Array) => new Decoder2(uint8Array), readUint8Array3 = (decoder8, len) => {
395474
+ const view = new Uint8Array(decoder8.arr.buffer, decoder8.pos + decoder8.arr.byteOffset, len);
395475
+ decoder8.pos += len;
395024
395476
  return view;
395025
- }, readVarUint8Array3 = (decoder7) => readUint8Array3(decoder7, readVarUint3(decoder7)), readUint83 = (decoder7) => decoder7.arr[decoder7.pos++], readVarUint3 = (decoder7) => {
395477
+ }, readVarUint8Array3 = (decoder8) => readUint8Array3(decoder8, readVarUint3(decoder8)), readUint83 = (decoder8) => decoder8.arr[decoder8.pos++], readVarUint3 = (decoder8) => {
395026
395478
  let num = 0;
395027
395479
  let mult = 1;
395028
- const len = decoder7.arr.length;
395029
- while (decoder7.pos < len) {
395030
- const r = decoder7.arr[decoder7.pos++];
395480
+ const len = decoder8.arr.length;
395481
+ while (decoder8.pos < len) {
395482
+ const r = decoder8.arr[decoder8.pos++];
395031
395483
  num = num + (r & BITS73) * mult;
395032
395484
  mult *= 128;
395033
395485
  if (r < BIT83) {
@@ -395038,17 +395490,17 @@ var import_attempt, create$2 = () => new Map, setIfUndefined2 = (map4, key2, cre
395038
395490
  }
395039
395491
  }
395040
395492
  throw errorUnexpectedEndOfArray3;
395041
- }, readVarInt2 = (decoder7) => {
395042
- let r = decoder7.arr[decoder7.pos++];
395493
+ }, readVarInt2 = (decoder8) => {
395494
+ let r = decoder8.arr[decoder8.pos++];
395043
395495
  let num = r & BITS62;
395044
395496
  let mult = 64;
395045
395497
  const sign = (r & BIT72) > 0 ? -1 : 1;
395046
395498
  if ((r & BIT83) === 0) {
395047
395499
  return sign * num;
395048
395500
  }
395049
- const len = decoder7.arr.length;
395050
- while (decoder7.pos < len) {
395051
- r = decoder7.arr[decoder7.pos++];
395501
+ const len = decoder8.arr.length;
395502
+ while (decoder8.pos < len) {
395503
+ r = decoder8.arr[decoder8.pos++];
395052
395504
  num = num + (r & BITS73) * mult;
395053
395505
  mult *= 128;
395054
395506
  if (r < BIT83) {
@@ -395059,31 +395511,31 @@ var import_attempt, create$2 = () => new Map, setIfUndefined2 = (map4, key2, cre
395059
395511
  }
395060
395512
  }
395061
395513
  throw errorUnexpectedEndOfArray3;
395062
- }, _readVarStringPolyfill3 = (decoder7) => {
395063
- let remainingLen = readVarUint3(decoder7);
395514
+ }, _readVarStringPolyfill3 = (decoder8) => {
395515
+ let remainingLen = readVarUint3(decoder8);
395064
395516
  if (remainingLen === 0) {
395065
395517
  return "";
395066
395518
  } else {
395067
- let encodedString = String.fromCodePoint(readUint83(decoder7));
395519
+ let encodedString = String.fromCodePoint(readUint83(decoder8));
395068
395520
  if (--remainingLen < 100) {
395069
395521
  while (remainingLen--) {
395070
- encodedString += String.fromCodePoint(readUint83(decoder7));
395522
+ encodedString += String.fromCodePoint(readUint83(decoder8));
395071
395523
  }
395072
395524
  } else {
395073
395525
  while (remainingLen > 0) {
395074
395526
  const nextLen = remainingLen < 1e4 ? remainingLen : 1e4;
395075
- const bytes = decoder7.arr.subarray(decoder7.pos, decoder7.pos + nextLen);
395076
- decoder7.pos += nextLen;
395527
+ const bytes = decoder8.arr.subarray(decoder8.pos, decoder8.pos + nextLen);
395528
+ decoder8.pos += nextLen;
395077
395529
  encodedString += String.fromCodePoint.apply(null, bytes);
395078
395530
  remainingLen -= nextLen;
395079
395531
  }
395080
395532
  }
395081
395533
  return decodeURIComponent(escape(encodedString));
395082
395534
  }
395083
- }, _readVarStringNative3 = (decoder7) => utf8TextDecoder3.decode(readVarUint8Array3(decoder7)), readVarString3, peekVarString = (decoder7) => {
395084
- const pos = decoder7.pos;
395085
- const s = readVarString3(decoder7);
395086
- decoder7.pos = pos;
395535
+ }, _readVarStringNative3 = (decoder8) => utf8TextDecoder3.decode(readVarUint8Array3(decoder8)), readVarString3, peekVarString = (decoder8) => {
395536
+ const pos = decoder8.pos;
395537
+ const s = readVarString3(decoder8);
395538
+ decoder8.pos = pos;
395087
395539
  return s;
395088
395540
  }, createUint8ArrayFromLen2 = (len) => new Uint8Array(len), createUint8ArrayViewFromArrayBuffer2 = (buffer, byteOffset, length3) => new Uint8Array(buffer, byteOffset, length3), createUint8ArrayFromArrayBuffer2 = (buffer) => new Uint8Array(buffer), toBase64Browser2 = (bytes) => {
395089
395541
  let s = "";
@@ -395172,17 +395624,17 @@ var import_attempt, create$2 = () => new Map, setIfUndefined2 = (map4, key2, cre
395172
395624
  }
395173
395625
  return toUint8Array2(encoder2);
395174
395626
  }, applyAwarenessUpdate2 = (awareness, update, origin) => {
395175
- const decoder7 = createDecoder2(update);
395627
+ const decoder8 = createDecoder2(update);
395176
395628
  const timestamp = getUnixTime2();
395177
395629
  const added = [];
395178
395630
  const updated = [];
395179
395631
  const filteredUpdated = [];
395180
395632
  const removed = [];
395181
- const len = readVarUint3(decoder7);
395633
+ const len = readVarUint3(decoder8);
395182
395634
  for (let i2 = 0;i2 < len; i2++) {
395183
- const clientID = readVarUint3(decoder7);
395184
- let clock = readVarUint3(decoder7);
395185
- const state = JSON.parse(readVarString3(decoder7));
395635
+ const clientID = readVarUint3(decoder8);
395636
+ let clock = readVarUint3(decoder8);
395637
+ const state = JSON.parse(readVarString3(decoder8));
395186
395638
  const clientMeta = awareness.meta.get(clientID);
395187
395639
  const prevState = awareness.states.get(clientID);
395188
395640
  const currClock = clientMeta === undefined ? 0 : clientMeta.clock;
@@ -395233,26 +395685,26 @@ var import_attempt, create$2 = () => new Map, setIfUndefined2 = (map4, key2, cre
395233
395685
  }, writeSyncStep22 = (encoder2, doc2, encodedStateVector) => {
395234
395686
  writeVarUint3(encoder2, messageYjsSyncStep22);
395235
395687
  writeVarUint8Array3(encoder2, encodeStateAsUpdate(doc2, encodedStateVector));
395236
- }, readSyncStep12 = (decoder7, encoder2, doc2) => writeSyncStep22(encoder2, doc2, readVarUint8Array3(decoder7)), readSyncStep22 = (decoder7, doc2, transactionOrigin) => {
395688
+ }, readSyncStep12 = (decoder8, encoder2, doc2) => writeSyncStep22(encoder2, doc2, readVarUint8Array3(decoder8)), readSyncStep22 = (decoder8, doc2, transactionOrigin) => {
395237
395689
  try {
395238
- applyUpdate(doc2, readVarUint8Array3(decoder7), transactionOrigin);
395690
+ applyUpdate(doc2, readVarUint8Array3(decoder8), transactionOrigin);
395239
395691
  } catch (error48) {
395240
395692
  console.error("Caught error while handling a Yjs update", error48);
395241
395693
  }
395242
395694
  }, writeUpdate2 = (encoder2, update) => {
395243
395695
  writeVarUint3(encoder2, messageYjsUpdate2);
395244
395696
  writeVarUint8Array3(encoder2, update);
395245
- }, readUpdate2, readSyncMessage2 = (decoder7, encoder2, doc2, transactionOrigin) => {
395246
- const messageType = readVarUint3(decoder7);
395697
+ }, readUpdate2, readSyncMessage2 = (decoder8, encoder2, doc2, transactionOrigin) => {
395698
+ const messageType = readVarUint3(decoder8);
395247
395699
  switch (messageType) {
395248
395700
  case messageYjsSyncStep12:
395249
- readSyncStep12(decoder7, encoder2, doc2);
395701
+ readSyncStep12(decoder8, encoder2, doc2);
395250
395702
  break;
395251
395703
  case messageYjsSyncStep22:
395252
- readSyncStep22(decoder7, doc2, transactionOrigin);
395704
+ readSyncStep22(decoder8, doc2, transactionOrigin);
395253
395705
  break;
395254
395706
  case messageYjsUpdate2:
395255
- readUpdate2(decoder7, doc2, transactionOrigin);
395707
+ readUpdate2(decoder8, doc2, transactionOrigin);
395256
395708
  break;
395257
395709
  default:
395258
395710
  throw new Error("Unknown message type");