@superdoc-dev/cli 0.2.0-next.141 → 0.2.0-next.143

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 +654 -502
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -660,18 +660,17 @@ function isTextAddress(value) {
660
660
  return false;
661
661
  return range.start <= range.end;
662
662
  }
663
- function isSDAddress(value) {
663
+ function isBlockNodeAddress(value) {
664
664
  if (!isRecord(value))
665
665
  return false;
666
- if (typeof value.kind !== "string" || !SD_ADDRESS_KINDS.has(value.kind))
666
+ if (value.kind !== "block")
667
+ return false;
668
+ if (typeof value.nodeType !== "string" || !BLOCK_NODE_TYPES_SET.has(value.nodeType))
667
669
  return false;
668
- if (typeof value.stability !== "string" || !SD_ADDRESS_STABILITIES.has(value.stability))
670
+ if (typeof value.nodeId !== "string")
669
671
  return false;
670
672
  return true;
671
673
  }
672
- function isValidTarget(value) {
673
- return isTextAddress(value) || isSDAddress(value);
674
- }
675
674
  function assertNoUnknownFields(input, allowlist, operationName) {
676
675
  for (const key of Object.keys(input)) {
677
676
  if (!allowlist.has(key)) {
@@ -697,12 +696,12 @@ function validateNestingPolicyValue(value) {
697
696
  throw new DocumentApiValidationError("INVALID_INPUT", `nestingPolicy.tables must be one of: forbid, allow. Got "${String(value.tables)}".`, { field: "nestingPolicy.tables", value: value.tables });
698
697
  }
699
698
  }
700
- var SD_ADDRESS_KINDS, SD_ADDRESS_STABILITIES, NESTING_POLICY_ALLOWED_KEYS;
699
+ var BLOCK_NODE_TYPES_SET, NESTING_POLICY_ALLOWED_KEYS;
701
700
  var init_validation_primitives = __esm(() => {
701
+ init_base();
702
702
  init_placement();
703
703
  init_errors2();
704
- SD_ADDRESS_KINDS = new Set(["content", "inline", "annotation", "section"]);
705
- SD_ADDRESS_STABILITIES = new Set(["stable", "ephemeral"]);
704
+ BLOCK_NODE_TYPES_SET = new Set(BLOCK_NODE_TYPES);
706
705
  NESTING_POLICY_ALLOWED_KEYS = new Set(["tables"]);
707
706
  });
708
707
 
@@ -1419,8 +1418,8 @@ var init_operation_definitions = __esm(() => {
1419
1418
  },
1420
1419
  insert: {
1421
1420
  memberPath: "insert",
1422
- description: "Insert inline content at a text position within an existing block, or at the end of the document when target is omitted. " + "This is NOT for creating sibling blocks use create.paragraph, create.heading, or lists.insert for that. " + "Accepts two input shapes: legacy string-based (value + type) or structural SDFragment (content). " + "Supports text (default), markdown, and html content types via the `type` field in legacy mode. " + "Structural mode accepts an SDFragment with typed nodes (paragraphs, tables, images, etc.).",
1423
- expectedResult: "Returns a TextMutationReceipt with applied status; receipt reports NO_OP if the insertion point is invalid or content is empty.",
1421
+ description: "Insert content into the document. Two input shapes: " + "legacy string-based (value + type) inserts inline content at a text position within an existing block; " + "structural SDFragment (content) inserts one or more blocks as siblings relative to a BlockNodeAddress target. " + "When target is omitted, content appends at the end of the document. " + "Legacy mode supports text (default), markdown, and html content types via the `type` field. " + "Structural mode uses `placement` (before/after/insideStart/insideEnd) to position relative to the target block.",
1422
+ expectedResult: "Returns an SDMutationReceipt with applied status; resolution reports a TextAddress for legacy text insertion or a BlockNodeAddress for structural insertion. Receipt reports NO_OP if the insertion point is invalid or content is empty.",
1424
1423
  requiresDocumentContext: true,
1425
1424
  metadata: mutationOperation({
1426
1425
  idempotency: "non-idempotent",
@@ -1458,7 +1457,7 @@ var init_operation_definitions = __esm(() => {
1458
1457
  },
1459
1458
  replace: {
1460
1459
  memberPath: "replace",
1461
- description: "Replace content at a contiguous document selection. " + "Text path accepts a SelectionTarget or ref plus replacement text. " + "Structural path accepts an SDAddress, SelectionTarget, or ref plus SDFragment content.",
1460
+ description: "Replace content at a contiguous document selection. " + "Text path accepts a SelectionTarget or ref plus replacement text. " + "Structural path accepts a BlockNodeAddress (replaces whole block), SelectionTarget (expands to full covered block boundaries), or ref plus SDFragment content.",
1462
1461
  expectedResult: "Returns an SDMutationReceipt with applied status; receipt reports NO_OP if the target range already contains identical content.",
1463
1462
  requiresDocumentContext: true,
1464
1463
  metadata: mutationOperation({
@@ -7552,7 +7551,7 @@ function buildInternalContractSchemas() {
7552
7551
  operations
7553
7552
  };
7554
7553
  }
7555
- var nodeTypeValues, blockNodeTypeValues, deletableBlockNodeTypeValues, inlineNodeTypeValues, knownTargetKindValues, SHARED_DEFS, rangeSchema, positionSchema, inlineAnchorSchema, targetKindSchema, textAddressSchema, textTargetSchema, blockNodeAddressSchema, deletableBlockNodeAddressSchema, paragraphAddressSchema, headingAddressSchema, listItemAddressSchema, paragraphTargetSchema, sectionAddressSchema, inlineNodeAddressSchema, nodeAddressSchema, commentAddressSchema, trackedChangeAddressSchema, entityAddressSchema, selectionTargetSchema, targetLocatorSchema, deleteBehaviorSchema, resolvedHandleSchema, pageInfoSchema, receiptSuccessSchema, textMutationRangeSchema, textMutationResolutionSchema, textMutationSuccessSchema, matchRunSchema, matchBlockSchema, trackChangeRefSchema, createParagraphSuccessSchema, createHeadingSuccessSchema, headingLevelSchema, listsInsertSuccessSchema, listsMutateItemSuccessSchema, listsExitSuccessSchema, nodeSummarySchema, nodeInfoSchema, matchContextSchema, unknownNodeDiagnosticSchema, textSelectorSchema, nodeSelectorSchema, selectorShorthandSchema, sdTextSelectorSchema, sdNodeSelectorSchema, sdSelectorSchema, sdAddressSchema, sdReadOptionsSchema, sdFindInputSchema, sdNodeResultSchema, sdFindResultSchema, sdMutationResolutionSchema, sdMutationSuccessSchema, documentInfoCountsSchema, documentInfoOutlineItemSchema, documentInfoCapabilitiesSchema, documentInfoSchema, listKindSchema, listInsertPositionSchema, listItemInfoSchema, listItemDomainItemSchema, listsListResultSchema, sectionBreakTypeSchema, sectionOrientationSchema, sectionVerticalAlignSchema, sectionDirectionSchema, sectionHeaderFooterKindSchema, sectionHeaderFooterVariantSchema, sectionLineNumberRestartSchema, sectionPageNumberFormatSchema, sectionRangeDomainSchema, sectionPageMarginsSchema, sectionHeaderFooterMarginsSchema, sectionPageSetupSchema, sectionColumnsSchema, sectionLineNumberingSchema, sectionPageNumberingSchema, sectionHeaderFooterRefsSchema, sectionBorderSpecSchema, sectionPageBordersSchema, sectionInfoSchema, sectionResolvedHandleSchema, sectionDomainItemSchema, sectionsListResultSchema, sectionMutationSuccessSchema, documentMutationSuccessSchema, paragraphMutationTargetSchema, paragraphMutationSuccessSchema, createSectionBreakSuccessSchema, commentInfoSchema, commentDomainItemSchema, commentsListResultSchema, trackChangeInfoSchema, trackChangeDomainItemSchema, trackChangesListResultSchema, capabilityReasonCodeSchema, capabilityReasonsSchema, capabilityFlagSchema, operationRuntimeCapabilitySchema, operationCapabilitiesSchema, inlinePropertyCapabilitySchema, inlinePropertyCapabilitiesByKeySchema, formatCapabilitiesSchema, planEngineCapabilitiesSchema, capabilitiesOutputSchema, strictEmptyObjectSchema, insertInputSchema, tableLocatorSchema, _tableScopedRowLocatorSchema, _tableScopedColumnLocatorSchema, mergeRangeLocatorSchema, mixedRowLocatorOneOf, tableCreateLocationSchema, tableMutationSuccessSchema, createTableSuccessSchema, tableMutationFailureCodes, tableMutationFailureSchema, tableMutationResultSchema, createTableResultSchema, historyActionSuccessSchema, historyActionFailureSchema, formatInlineAliasOperationSchemas, tocMutationFailureCodes, tocMutationFailureSchema, tocMutationSuccessSchema, tocEntryMutationFailureCodes, tocEntryMutationFailureSchema, tocEntryMutationSuccessSchema, hyperlinkTargetSchema, hyperlinkReadPropertiesSchema, hyperlinkDestinationSchema, hyperlinkSpecSchema, hyperlinkPatchSchema, hyperlinkDomainSchema, hyperlinkMutationSuccessSchema, hyperlinkMutationFailureCodes, hyperlinkMutationFailureSchema, hyperlinkInfoSchema, contentControlTargetSchema, contentControlMutationSuccessSchema, contentControlMutationFailureSchema, ccListResultSchema, ccInfoSchema, refListQuerySchema, discoveryOutputSchema, receiptFailureSchema, refFailureSchema, bookmarkAddressSchema, bookmarkMutation, footnoteAddressSchema, footnoteConfigScopeSchema, footnoteNumberingSchema, footnoteMutation, footnoteConfig, crossRefAddressSchema, crossRefTargetSchema, crossRefDisplaySchema, crossRefMutation, indexAddressSchema, indexEntryAddressSchema, indexConfigSchema, indexEntryDataSchema, indexEntryPatchSchema, indexMutation, indexEntryMutation, captionAddressSchema, captionMutation, captionConfig, fieldAddressSchema, fieldMutation, citationAddressSchema, citationSourceAddressSchema, bibliographyAddressSchema, citationMutation, citationSourceMutation, bibliographyMutation, citationPersonSchema, citationSourceFieldsSchema, tocCreateLocationSchema, authoritiesAddressSchema, authorityEntryAddressSchema, authoritiesConfigSchema, authorityEntryDataSchema, authorityEntryPatchSchema, authoritiesMutation, authorityEntryMutation, operationSchemas;
7554
+ var nodeTypeValues, blockNodeTypeValues, deletableBlockNodeTypeValues, inlineNodeTypeValues, knownTargetKindValues, SHARED_DEFS, rangeSchema, positionSchema, inlineAnchorSchema, targetKindSchema, textAddressSchema, textTargetSchema, blockNodeAddressSchema, deletableBlockNodeAddressSchema, paragraphAddressSchema, headingAddressSchema, listItemAddressSchema, paragraphTargetSchema, sectionAddressSchema, inlineNodeAddressSchema, nodeAddressSchema, commentAddressSchema, trackedChangeAddressSchema, entityAddressSchema, selectionTargetSchema, targetLocatorSchema, deleteBehaviorSchema, resolvedHandleSchema, pageInfoSchema, receiptSuccessSchema, textMutationRangeSchema, textMutationResolutionSchema, textMutationSuccessSchema, matchRunSchema, matchBlockSchema, trackChangeRefSchema, createParagraphSuccessSchema, createHeadingSuccessSchema, headingLevelSchema, listsInsertSuccessSchema, listsMutateItemSuccessSchema, listsExitSuccessSchema, nodeSummarySchema, nodeInfoSchema, matchContextSchema, unknownNodeDiagnosticSchema, textSelectorSchema, nodeSelectorSchema, selectorShorthandSchema, sdTextSelectorSchema, sdNodeSelectorSchema, sdSelectorSchema, sdReadOptionsSchema, sdFindInputSchema, sdNodeResultSchema, sdFindResultSchema, sdMutationResolutionSchema, sdMutationSuccessSchema, documentInfoCountsSchema, documentInfoOutlineItemSchema, documentInfoCapabilitiesSchema, documentInfoSchema, listKindSchema, listInsertPositionSchema, listItemInfoSchema, listItemDomainItemSchema, listsListResultSchema, sectionBreakTypeSchema, sectionOrientationSchema, sectionVerticalAlignSchema, sectionDirectionSchema, sectionHeaderFooterKindSchema, sectionHeaderFooterVariantSchema, sectionLineNumberRestartSchema, sectionPageNumberFormatSchema, sectionRangeDomainSchema, sectionPageMarginsSchema, sectionHeaderFooterMarginsSchema, sectionPageSetupSchema, sectionColumnsSchema, sectionLineNumberingSchema, sectionPageNumberingSchema, sectionHeaderFooterRefsSchema, sectionBorderSpecSchema, sectionPageBordersSchema, sectionInfoSchema, sectionResolvedHandleSchema, sectionDomainItemSchema, sectionsListResultSchema, sectionMutationSuccessSchema, documentMutationSuccessSchema, paragraphMutationTargetSchema, paragraphMutationSuccessSchema, createSectionBreakSuccessSchema, commentInfoSchema, commentDomainItemSchema, commentsListResultSchema, trackChangeInfoSchema, trackChangeDomainItemSchema, trackChangesListResultSchema, capabilityReasonCodeSchema, capabilityReasonsSchema, capabilityFlagSchema, operationRuntimeCapabilitySchema, operationCapabilitiesSchema, inlinePropertyCapabilitySchema, inlinePropertyCapabilitiesByKeySchema, formatCapabilitiesSchema, planEngineCapabilitiesSchema, capabilitiesOutputSchema, strictEmptyObjectSchema, sdFragmentSchema, placementSchema, nestingPolicySchema, insertInputSchema, tableLocatorSchema, _tableScopedRowLocatorSchema, _tableScopedColumnLocatorSchema, mergeRangeLocatorSchema, mixedRowLocatorOneOf, tableCreateLocationSchema, tableMutationSuccessSchema, createTableSuccessSchema, tableMutationFailureCodes, tableMutationFailureSchema, tableMutationResultSchema, createTableResultSchema, historyActionSuccessSchema, historyActionFailureSchema, formatInlineAliasOperationSchemas, tocMutationFailureCodes, tocMutationFailureSchema, tocMutationSuccessSchema, tocEntryMutationFailureCodes, tocEntryMutationFailureSchema, tocEntryMutationSuccessSchema, hyperlinkTargetSchema, hyperlinkReadPropertiesSchema, hyperlinkDestinationSchema, hyperlinkSpecSchema, hyperlinkPatchSchema, hyperlinkDomainSchema, hyperlinkMutationSuccessSchema, hyperlinkMutationFailureCodes, hyperlinkMutationFailureSchema, hyperlinkInfoSchema, contentControlTargetSchema, contentControlMutationSuccessSchema, contentControlMutationFailureSchema, ccListResultSchema, ccInfoSchema, refListQuerySchema, discoveryOutputSchema, receiptFailureSchema, refFailureSchema, bookmarkAddressSchema, bookmarkMutation, footnoteAddressSchema, footnoteConfigScopeSchema, footnoteNumberingSchema, footnoteMutation, footnoteConfig, crossRefAddressSchema, crossRefTargetSchema, crossRefDisplaySchema, crossRefMutation, indexAddressSchema, indexEntryAddressSchema, indexConfigSchema, indexEntryDataSchema, indexEntryPatchSchema, indexMutation, indexEntryMutation, captionAddressSchema, captionMutation, captionConfig, fieldAddressSchema, fieldMutation, citationAddressSchema, citationSourceAddressSchema, bibliographyAddressSchema, citationMutation, citationSourceMutation, bibliographyMutation, citationPersonSchema, citationSourceFieldsSchema, tocCreateLocationSchema, authoritiesAddressSchema, authorityEntryAddressSchema, authoritiesConfigSchema, authorityEntryDataSchema, authorityEntryPatchSchema, authoritiesMutation, authorityEntryMutation, operationSchemas;
7556
7555
  var init_schemas = __esm(() => {
7557
7556
  init_command_catalog();
7558
7557
  init_types2();
@@ -7890,23 +7889,12 @@ var init_schemas = __esm(() => {
7890
7889
  }, ["type", "pattern"]);
7891
7890
  sdNodeSelectorSchema = objectSchema({
7892
7891
  type: { const: "node" },
7893
- kind: { enum: ["content", "inline"] },
7894
- nodeKind: { type: "string" }
7892
+ kind: { enum: ["block", "inline"] },
7893
+ nodeType: { type: "string" }
7895
7894
  }, ["type"]);
7896
7895
  sdSelectorSchema = {
7897
7896
  oneOf: [sdTextSelectorSchema, sdNodeSelectorSchema]
7898
7897
  };
7899
- sdAddressSchema = objectSchema({
7900
- kind: { enum: ["content", "inline", "annotation", "section"] },
7901
- stability: { enum: ["stable", "ephemeral"] },
7902
- nodeId: { type: "string" },
7903
- anchor: objectSchema({
7904
- start: objectSchema({ blockId: { type: "string" }, offset: { type: "integer" } }, ["blockId", "offset"]),
7905
- end: objectSchema({ blockId: { type: "string" }, offset: { type: "integer" } }, ["blockId", "offset"])
7906
- }),
7907
- evaluatedRevision: { type: "string" },
7908
- path: arraySchema({ oneOf: [{ type: "string" }, { type: "integer" }] })
7909
- }, ["kind", "stability"]);
7910
7898
  sdReadOptionsSchema = objectSchema({
7911
7899
  includeResolved: { type: "boolean" },
7912
7900
  includeProvenance: { type: "boolean" },
@@ -7914,14 +7902,14 @@ var init_schemas = __esm(() => {
7914
7902
  });
7915
7903
  sdFindInputSchema = objectSchema({
7916
7904
  select: sdSelectorSchema,
7917
- within: sdAddressSchema,
7905
+ within: blockNodeAddressSchema,
7918
7906
  limit: { type: "integer" },
7919
7907
  offset: { type: "integer" },
7920
7908
  options: sdReadOptionsSchema
7921
7909
  }, ["select"]);
7922
7910
  sdNodeResultSchema = objectSchema({
7923
7911
  node: { type: "object" },
7924
- address: sdAddressSchema,
7912
+ address: nodeAddressSchema,
7925
7913
  context: { type: "object" }
7926
7914
  }, ["node", "address"]);
7927
7915
  sdFindResultSchema = objectSchema({
@@ -7931,10 +7919,10 @@ var init_schemas = __esm(() => {
7931
7919
  items: arraySchema(sdNodeResultSchema)
7932
7920
  }, ["total", "limit", "offset", "items"]);
7933
7921
  sdMutationResolutionSchema = objectSchema({
7934
- requestedTarget: sdAddressSchema,
7935
- target: sdAddressSchema,
7922
+ target: { oneOf: [textAddressSchema, blockNodeAddressSchema] },
7923
+ range: textMutationRangeSchema,
7936
7924
  selectionTarget: selectionTargetSchema
7937
- }, ["target"]);
7925
+ }, ["target", "range"]);
7938
7926
  sdMutationSuccessSchema = objectSchema({
7939
7927
  success: { const: true },
7940
7928
  resolution: sdMutationResolutionSchema,
@@ -8241,11 +8229,28 @@ var init_schemas = __esm(() => {
8241
8229
  planEngine: planEngineCapabilitiesSchema
8242
8230
  }, ["global", "format", "operations", "planEngine"]);
8243
8231
  strictEmptyObjectSchema = objectSchema({});
8244
- insertInputSchema = objectSchema({
8245
- target: textAddressSchema,
8246
- value: { type: "string" },
8247
- type: { type: "string", enum: ["text", "markdown", "html"] }
8248
- }, ["value"]);
8232
+ sdFragmentSchema = {
8233
+ oneOf: [{ type: "object" }, { type: "array", items: { type: "object" } }]
8234
+ };
8235
+ placementSchema = { enum: ["before", "after", "insideStart", "insideEnd"] };
8236
+ nestingPolicySchema = objectSchema({
8237
+ tables: { enum: ["forbid", "allow"] }
8238
+ });
8239
+ insertInputSchema = {
8240
+ oneOf: [
8241
+ objectSchema({
8242
+ target: textAddressSchema,
8243
+ value: { type: "string" },
8244
+ type: { type: "string", enum: ["text", "markdown", "html"] }
8245
+ }, ["value"]),
8246
+ objectSchema({
8247
+ target: blockNodeAddressSchema,
8248
+ content: sdFragmentSchema,
8249
+ placement: placementSchema,
8250
+ nestingPolicy: nestingPolicySchema
8251
+ }, ["content"])
8252
+ ]
8253
+ };
8249
8254
  tableLocatorSchema = {
8250
8255
  ...objectSchema({
8251
8256
  target: blockNodeAddressSchema,
@@ -8710,14 +8715,14 @@ var init_schemas = __esm(() => {
8710
8715
  {
8711
8716
  oneOf: [
8712
8717
  objectSchema({
8713
- target: { oneOf: [sdAddressSchema, textAddressSchema, selectionTargetSchema] },
8714
- content: { type: "object" },
8715
- nestingPolicy: { type: "object" }
8718
+ target: { oneOf: [blockNodeAddressSchema, selectionTargetSchema] },
8719
+ content: sdFragmentSchema,
8720
+ nestingPolicy: nestingPolicySchema
8716
8721
  }, ["target", "content"]),
8717
8722
  objectSchema({
8718
8723
  ref: { type: "string" },
8719
- content: { type: "object" },
8720
- nestingPolicy: { type: "object" }
8724
+ content: sdFragmentSchema,
8725
+ nestingPolicy: nestingPolicySchema
8721
8726
  }, ["ref", "content"])
8722
8727
  ]
8723
8728
  }
@@ -9786,7 +9791,7 @@ var init_schemas = __esm(() => {
9786
9791
  "query.match": {
9787
9792
  input: objectSchema({
9788
9793
  select: { oneOf: [textSelectorSchema, nodeSelectorSchema] },
9789
- within: nodeAddressSchema,
9794
+ within: blockNodeAddressSchema,
9790
9795
  require: { enum: ["any", "first", "exactlyOne", "all"] },
9791
9796
  mode: { enum: ["strict", "candidates"] },
9792
9797
  includeNodes: { type: "boolean" },
@@ -9796,7 +9801,7 @@ var init_schemas = __esm(() => {
9796
9801
  output: (() => {
9797
9802
  const textMatchItemSchema = discoveryItemSchema({
9798
9803
  matchKind: { const: "text" },
9799
- address: nodeAddressSchema,
9804
+ address: blockNodeAddressSchema,
9800
9805
  target: selectionTargetSchema,
9801
9806
  snippet: { type: "string" },
9802
9807
  highlightRange: rangeSchema,
@@ -9815,13 +9820,13 @@ var init_schemas = __esm(() => {
9815
9820
  const selectWhereSchema = objectSchema({
9816
9821
  by: { const: "select", type: "string" },
9817
9822
  select: { oneOf: [textSelectorSchema, nodeSelectorSchema] },
9818
- within: nodeAddressSchema,
9823
+ within: blockNodeAddressSchema,
9819
9824
  require: { enum: ["first", "exactlyOne", "all"] }
9820
9825
  }, ["by", "select", "require"]);
9821
9826
  const refWhereSchema = objectSchema({
9822
9827
  by: { const: "ref", type: "string" },
9823
9828
  ref: { type: "string" },
9824
- within: nodeAddressSchema
9829
+ within: blockNodeAddressSchema
9825
9830
  }, ["by", "ref"]);
9826
9831
  const targetWhereSchema = objectSchema({
9827
9832
  by: { const: "target", type: "string" },
@@ -9831,13 +9836,13 @@ var init_schemas = __esm(() => {
9831
9836
  const insertWhereSchema = objectSchema({
9832
9837
  by: { const: "select", type: "string" },
9833
9838
  select: { oneOf: [textSelectorSchema, nodeSelectorSchema] },
9834
- within: nodeAddressSchema,
9839
+ within: blockNodeAddressSchema,
9835
9840
  require: { enum: ["first", "exactlyOne"] }
9836
9841
  }, ["by", "select", "require"]);
9837
9842
  const assertWhereSchema = objectSchema({
9838
9843
  by: { const: "select", type: "string" },
9839
9844
  select: { oneOf: [textSelectorSchema, nodeSelectorSchema] },
9840
- within: nodeAddressSchema
9845
+ within: blockNodeAddressSchema
9841
9846
  }, ["by", "select"]);
9842
9847
  const replacementBlockSchema = objectSchema({ text: { type: "string" } }, ["text"]);
9843
9848
  const replacementPayloadSchema = {
@@ -10983,7 +10988,7 @@ var init_schemas = __esm(() => {
10983
10988
  "images.removeCaption": imagesMutationSchemaSet(objectSchema({ imageId: { type: "string" } }, ["imageId"])),
10984
10989
  "hyperlinks.list": {
10985
10990
  input: objectSchema({
10986
- within: nodeAddressSchema,
10991
+ within: blockNodeAddressSchema,
10987
10992
  hrefPattern: { type: "string" },
10988
10993
  anchor: { type: "string" },
10989
10994
  textPattern: { type: "string" },
@@ -12161,6 +12166,9 @@ var init_comments = __esm(() => {
12161
12166
  function executeFind(adapter, input) {
12162
12167
  return adapter.find(input);
12163
12168
  }
12169
+ var init_find = __esm(() => {
12170
+ init_errors2();
12171
+ });
12164
12172
 
12165
12173
  // ../../packages/document-api/src/format/format.ts
12166
12174
  function validateTargetLocator(input, operation) {
@@ -12850,29 +12858,18 @@ var init_fragment_validator = __esm(() => {
12850
12858
  });
12851
12859
 
12852
12860
  // ../../packages/document-api/src/receipt-bridge.ts
12853
- function textAddressToSDAddress(textAddr) {
12854
- return {
12855
- kind: "content",
12856
- stability: "stable",
12857
- nodeId: textAddr.blockId,
12858
- anchor: {
12859
- start: { blockId: textAddr.blockId, offset: textAddr.range.start },
12860
- end: { blockId: textAddr.blockId, offset: textAddr.range.end }
12861
- }
12862
- };
12863
- }
12864
- function buildSDResolution(resolution) {
12861
+ function buildResolution(resolution) {
12865
12862
  return {
12866
- ...resolution.requestedTarget ? { requestedTarget: textAddressToSDAddress(resolution.requestedTarget) } : {},
12867
- target: textAddressToSDAddress(resolution.target),
12868
- ...resolution.selectionTarget ? { selectionTarget: resolution.selectionTarget } : undefined
12863
+ target: resolution.target,
12864
+ range: resolution.range,
12865
+ ...resolution.selectionTarget ? { selectionTarget: resolution.selectionTarget } : {}
12869
12866
  };
12870
12867
  }
12871
12868
  function textReceiptToSDReceipt(receipt2) {
12872
12869
  if (receipt2.success) {
12873
12870
  return {
12874
12871
  success: true,
12875
- resolution: receipt2.resolution ? buildSDResolution(receipt2.resolution) : undefined
12872
+ resolution: receipt2.resolution ? buildResolution(receipt2.resolution) : undefined
12876
12873
  };
12877
12874
  }
12878
12875
  const failure = {
@@ -12897,7 +12894,22 @@ function textReceiptToSDReceipt(receipt2) {
12897
12894
  return {
12898
12895
  success: false,
12899
12896
  failure,
12900
- resolution: receipt2.resolution ? buildSDResolution(receipt2.resolution) : undefined
12897
+ resolution: receipt2.resolution ? buildResolution(receipt2.resolution) : undefined
12898
+ };
12899
+ }
12900
+ function buildStructuralReceipt(success, params, failure) {
12901
+ const resolution = {
12902
+ target: params.target,
12903
+ range: params.range,
12904
+ ...params.selectionTarget ? { selectionTarget: params.selectionTarget } : {}
12905
+ };
12906
+ if (success) {
12907
+ return { success: true, resolution };
12908
+ }
12909
+ return {
12910
+ success: false,
12911
+ failure: { code: failure?.code ?? "INTERNAL_ERROR", message: failure?.message ?? "" },
12912
+ resolution
12901
12913
  };
12902
12914
  }
12903
12915
 
@@ -12954,8 +12966,8 @@ function validateStructuralInsertInput(input) {
12954
12966
  }
12955
12967
  assertNoUnknownFields(input, STRUCTURAL_INSERT_ALLOWED_KEYS, "insert");
12956
12968
  const { target, content, placement: placement2, nestingPolicy } = input;
12957
- if (target !== undefined && !isValidTarget(target)) {
12958
- throw new DocumentApiValidationError("INVALID_TARGET", "target must be a valid address (SDAddress or TextAddress).", {
12969
+ if (target !== undefined && !isBlockNodeAddress(target)) {
12970
+ throw new DocumentApiValidationError("INVALID_TARGET", 'target must be a BlockNodeAddress ({ kind: "block", nodeType, nodeId }).', {
12959
12971
  field: "target",
12960
12972
  value: target
12961
12973
  });
@@ -13188,8 +13200,11 @@ function validateStructuralReplaceInput(input) {
13188
13200
  fields: ["target", "ref"]
13189
13201
  });
13190
13202
  }
13191
- if (hasTarget && !isSDAddress(target) && !isTextAddress(target) && !isSelectionTarget(target)) {
13192
- throw new DocumentApiValidationError("INVALID_TARGET", "target must be a valid address (SDAddress, TextAddress, or SelectionTarget).", { field: "target", value: target });
13203
+ if (hasTarget && !isBlockNodeAddress(target) && !isSelectionTarget(target)) {
13204
+ throw new DocumentApiValidationError("INVALID_TARGET", "target must be a BlockNodeAddress or SelectionTarget.", {
13205
+ field: "target",
13206
+ value: target
13207
+ });
13193
13208
  }
13194
13209
  if (hasRef && typeof refValue !== "string") {
13195
13210
  throw new DocumentApiValidationError("INVALID_TARGET", "ref must be a string.", {
@@ -16409,7 +16424,11 @@ function createDocumentApi(adapters) {
16409
16424
  },
16410
16425
  query: {
16411
16426
  match(input) {
16412
- return adapters.query.match(input);
16427
+ if (!input || typeof input !== "object") {
16428
+ throw new DocumentApiValidationError("INVALID_INPUT", "query.match requires a QueryMatchInput or selector object.", { value: input });
16429
+ }
16430
+ const normalized = "select" in input ? input : { select: input };
16431
+ return adapters.query.match(normalized);
16413
16432
  }
16414
16433
  },
16415
16434
  ranges: {
@@ -16452,6 +16471,7 @@ var init_src = __esm(() => {
16452
16471
  init_errors2();
16453
16472
  init_ranges();
16454
16473
  init_comments();
16474
+ init_find();
16455
16475
  init_format();
16456
16476
  init_inline_run_patch();
16457
16477
  init_styles();
@@ -38780,7 +38800,7 @@ var init_remark_gfm_z_sDF4ss_es = __esm(() => {
38780
38800
  emptyOptions2 = {};
38781
38801
  });
38782
38802
 
38783
- // ../../packages/superdoc/dist/chunks/SuperConverter-BParsWaS.es.js
38803
+ // ../../packages/superdoc/dist/chunks/SuperConverter-voJQZ_PC.es.js
38784
38804
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
38785
38805
  const fieldValue = extension$1.config[field];
38786
38806
  if (typeof fieldValue === "function")
@@ -39594,18 +39614,17 @@ function isTextAddress2(value) {
39594
39614
  return false;
39595
39615
  return range.start <= range.end;
39596
39616
  }
39597
- function isSDAddress2(value) {
39617
+ function isBlockNodeAddress2(value) {
39598
39618
  if (!isRecord3(value))
39599
39619
  return false;
39600
- if (typeof value.kind !== "string" || !SD_ADDRESS_KINDS2.has(value.kind))
39620
+ if (value.kind !== "block")
39621
+ return false;
39622
+ if (typeof value.nodeType !== "string" || !BLOCK_NODE_TYPES_SET2.has(value.nodeType))
39601
39623
  return false;
39602
- if (typeof value.stability !== "string" || !SD_ADDRESS_STABILITIES2.has(value.stability))
39624
+ if (typeof value.nodeId !== "string")
39603
39625
  return false;
39604
39626
  return true;
39605
39627
  }
39606
- function isValidTarget2(value) {
39607
- return isTextAddress2(value) || isSDAddress2(value);
39608
- }
39609
39628
  function assertNoUnknownFields3(input, allowlist, operationName) {
39610
39629
  for (const key of Object.keys(input))
39611
39630
  if (!allowlist.has(key))
@@ -42005,35 +42024,18 @@ function validateLegacyInlineContent2(item, parentType) {
42005
42024
  throw new DocumentApiValidationError2("INVALID_PAYLOAD", `Inline image content in ${parentType} requires a non-empty "src" string field.`, { field: "src" });
42006
42025
  }
42007
42026
  }
42008
- function textAddressToSDAddress2(textAddr) {
42009
- return {
42010
- kind: "content",
42011
- stability: "stable",
42012
- nodeId: textAddr.blockId,
42013
- anchor: {
42014
- start: {
42015
- blockId: textAddr.blockId,
42016
- offset: textAddr.range.start
42017
- },
42018
- end: {
42019
- blockId: textAddr.blockId,
42020
- offset: textAddr.range.end
42021
- }
42022
- }
42023
- };
42024
- }
42025
- function buildSDResolution2(resolution) {
42027
+ function buildResolution2(resolution) {
42026
42028
  return {
42027
- ...resolution.requestedTarget ? { requestedTarget: textAddressToSDAddress2(resolution.requestedTarget) } : {},
42028
- target: textAddressToSDAddress2(resolution.target),
42029
- ...resolution.selectionTarget ? { selectionTarget: resolution.selectionTarget } : undefined
42029
+ target: resolution.target,
42030
+ range: resolution.range,
42031
+ ...resolution.selectionTarget ? { selectionTarget: resolution.selectionTarget } : {}
42030
42032
  };
42031
42033
  }
42032
42034
  function textReceiptToSDReceipt2(receipt2) {
42033
42035
  if (receipt2.success)
42034
42036
  return {
42035
42037
  success: true,
42036
- resolution: receipt2.resolution ? buildSDResolution2(receipt2.resolution) : undefined
42038
+ resolution: receipt2.resolution ? buildResolution2(receipt2.resolution) : undefined
42037
42039
  };
42038
42040
  const failure = {
42039
42041
  code: "INTERNAL_ERROR",
@@ -42056,7 +42058,27 @@ function textReceiptToSDReceipt2(receipt2) {
42056
42058
  return {
42057
42059
  success: false,
42058
42060
  failure,
42059
- resolution: receipt2.resolution ? buildSDResolution2(receipt2.resolution) : undefined
42061
+ resolution: receipt2.resolution ? buildResolution2(receipt2.resolution) : undefined
42062
+ };
42063
+ }
42064
+ function buildStructuralReceipt2(success, params, failure) {
42065
+ const resolution = {
42066
+ target: params.target,
42067
+ range: params.range,
42068
+ ...params.selectionTarget ? { selectionTarget: params.selectionTarget } : {}
42069
+ };
42070
+ if (success)
42071
+ return {
42072
+ success: true,
42073
+ resolution
42074
+ };
42075
+ return {
42076
+ success: false,
42077
+ failure: {
42078
+ code: failure?.code ?? "INTERNAL_ERROR",
42079
+ message: failure?.message ?? ""
42080
+ },
42081
+ resolution
42060
42082
  };
42061
42083
  }
42062
42084
  function isStructuralInsertInput2(input) {
@@ -42104,8 +42126,8 @@ function validateStructuralInsertInput2(input) {
42104
42126
  throw new DocumentApiValidationError2("INVALID_INPUT", '"type" field is only valid with legacy string input ("value"), not with structural "content".', { field: "type" });
42105
42127
  assertNoUnknownFields3(input, STRUCTURAL_INSERT_ALLOWED_KEYS2, "insert");
42106
42128
  const { target, content: content$2, placement: placement2, nestingPolicy } = input;
42107
- if (target !== undefined && !isValidTarget2(target))
42108
- throw new DocumentApiValidationError2("INVALID_TARGET", "target must be a valid address (SDAddress or TextAddress).", {
42129
+ if (target !== undefined && !isBlockNodeAddress2(target))
42130
+ throw new DocumentApiValidationError2("INVALID_TARGET", 'target must be a BlockNodeAddress ({ kind: "block", nodeType, nodeId }).', {
42109
42131
  field: "target",
42110
42132
  value: target
42111
42133
  });
@@ -42305,8 +42327,8 @@ function validateStructuralReplaceInput2(input) {
42305
42327
  throw new DocumentApiValidationError2("INVALID_INPUT", 'Structural replace must provide either "target" or "ref", not both.', { fields: ["target", "ref"] });
42306
42328
  if (!hasTarget && !hasRef)
42307
42329
  throw new DocumentApiValidationError2("INVALID_TARGET", "Structural replace requires a target or ref.", { fields: ["target", "ref"] });
42308
- if (hasTarget && !isSDAddress2(target) && !isTextAddress2(target) && !isSelectionTarget2(target))
42309
- throw new DocumentApiValidationError2("INVALID_TARGET", "target must be a valid address (SDAddress, TextAddress, or SelectionTarget).", {
42330
+ if (hasTarget && !isBlockNodeAddress2(target) && !isSelectionTarget2(target))
42331
+ throw new DocumentApiValidationError2("INVALID_TARGET", "target must be a BlockNodeAddress or SelectionTarget.", {
42310
42332
  field: "target",
42311
42333
  value: target
42312
42334
  });
@@ -45167,7 +45189,10 @@ function createDocumentApi2(adapters) {
45167
45189
  }
45168
45190
  },
45169
45191
  query: { match(input) {
45170
- return adapters.query.match(input);
45192
+ if (!input || typeof input !== "object")
45193
+ throw new DocumentApiValidationError2("INVALID_INPUT", "query.match requires a QueryMatchInput or selector object.", { value: input });
45194
+ const normalized = "select" in input ? input : { select: input };
45195
+ return adapters.query.match(normalized);
45171
45196
  } },
45172
45197
  ranges: { resolve(input) {
45173
45198
  return executeResolveRange2(adapters.ranges, input);
@@ -63483,7 +63508,7 @@ var isRegExp = (value) => {
63483
63508
  }, decode$72 = (attrs) => {
63484
63509
  const { pos } = attrs || {};
63485
63510
  return pos?.toString();
63486
- }, attributes_default$6, DocumentApiValidationError2, NODE_TYPES2, BLOCK_NODE_TYPES2, DELETABLE_BLOCK_NODE_TYPES2, INLINE_NODE_TYPES2, SELECTION_EDGE_NODE_TYPES2, MARK_KEYS2, INLINE_DIRECTIVES2, SD_CONTENT_NODE_KINDS2, SD_INLINE_NODE_KINDS2, PLACEMENT_VALUES2, TABLE_NESTING_POLICY_VALUES2, DEFAULT_NESTING_POLICY2, SD_ADDRESS_KINDS2, SD_ADDRESS_STABILITIES2, NESTING_POLICY_ALLOWED_KEYS2, schemaBooleanOrNull2 = () => ({ oneOf: [{ type: "boolean" }, { type: "null" }] }), schemaStringOrNull2 = () => ({ oneOf: [{
63511
+ }, attributes_default$6, DocumentApiValidationError2, NODE_TYPES2, BLOCK_NODE_TYPES2, DELETABLE_BLOCK_NODE_TYPES2, INLINE_NODE_TYPES2, SELECTION_EDGE_NODE_TYPES2, MARK_KEYS2, INLINE_DIRECTIVES2, SD_CONTENT_NODE_KINDS2, SD_INLINE_NODE_KINDS2, PLACEMENT_VALUES2, TABLE_NESTING_POLICY_VALUES2, DEFAULT_NESTING_POLICY2, BLOCK_NODE_TYPES_SET2, NESTING_POLICY_ALLOWED_KEYS2, schemaBooleanOrNull2 = () => ({ oneOf: [{ type: "boolean" }, { type: "null" }] }), schemaStringOrNull2 = () => ({ oneOf: [{
63487
63512
  type: "string",
63488
63513
  minLength: 1
63489
63514
  }, { type: "null" }] }), schemaNumberOrNull2 = () => ({ oneOf: [{ type: "number" }, { type: "null" }] }), schemaObjectOrNull2 = (properties) => ({ oneOf: [{
@@ -63523,7 +63548,7 @@ var isRegExp = (value) => {
63523
63548
  tracked: false,
63524
63549
  carrier: runAttributeCarrier2(runPropertyKey ?? key),
63525
63550
  schema
63526
- }), INLINE_PROPERTY_REGISTRY2, INLINE_PROPERTY_KEY_SET2, INLINE_PROPERTY_BY_KEY2, UNDERLINE_OBJECT_ALLOWED_KEYS2, SHADING_ALLOWED_KEYS2, BORDER_ALLOWED_KEYS2, FIT_TEXT_ALLOWED_KEYS2, LANG_ALLOWED_KEYS2, RFONTS_ALLOWED_KEYS2, EAST_ASIAN_LAYOUT_ALLOWED_KEYS2, STYLISTIC_SET_ALLOWED_KEYS2, VERT_ALIGN_VALUES2, NONE_FAILURES2, NONE_THROWS2, T_NOT_FOUND2, T_NOT_FOUND_CAPABLE2, T_PLAN_ENGINE2, T_NOT_FOUND_COMMAND2, T_NOT_FOUND_COMMAND_TRACKED2, T_IMAGE_COMMAND2, T_CC_READ2, T_CC_MUTATION2, T_CC_TYPED2, T_CC_TYPED_READ2, T_CC_RAW2, T_QUERY_MATCH2, T_SECTION_CREATE2, T_SECTION_READ2, T_PARAGRAPH_MUTATION2, T_SECTION_MUTATION2, T_SECTION_SETTINGS_MUTATION2, T_HEADER_FOOTER_MUTATION2, T_REF_READ_LIST2, T_REF_MUTATION2, T_REF_MUTATION_REMOVE2, T_REF_INSERT2, FORMAT_INLINE_ALIAS_OPERATION_DEFINITIONS2, OPERATION_DEFINITIONS2, OPERATION_IDS2, COMMAND_CATALOG3, PARAGRAPH_ALIGNMENTS2, TAB_STOP_ALIGNMENTS2, TAB_STOP_LEADERS2, BORDER_SIDES2, CLEAR_BORDER_SIDES2, LINE_RULES2, PARAGRAPH_BLOCK_TYPES2, SET_STYLE_KEYS2, CLEAR_STYLE_KEYS2, RESET_DIRECT_FORMATTING_KEYS2, SET_ALIGNMENT_KEYS2, CLEAR_ALIGNMENT_KEYS2, SET_INDENTATION_KEYS2, CLEAR_INDENTATION_KEYS2, SET_SPACING_KEYS2, CLEAR_SPACING_KEYS2, SET_KEEP_OPTIONS_KEYS2, SET_OUTLINE_LEVEL_KEYS2, SET_FLOW_OPTIONS_KEYS2, SET_TAB_STOP_KEYS2, CLEAR_TAB_STOP_KEYS2, CLEAR_ALL_TAB_STOPS_KEYS2, SET_BORDER_KEYS2, CLEAR_BORDER_KEYS2, SET_SHADING_KEYS2, CLEAR_SHADING_KEYS2, ST_ON_OFF_ON_VALUES2, ST_ON_OFF_OFF_VALUES2, ST_UNDERLINE_VALUES2, ST_UNDERLINE_VALUE_SET2, ST_VERTICAL_ALIGN_RUN2, ST_EM2, ST_TEXT_ALIGNMENT2, ST_TEXT_DIRECTION2, ST_TEXTBOX_TIGHT_WRAP2, ST_TEXT_TRANSFORM2, ST_JUSTIFICATION2, FONT_FAMILY_SCHEMA2, COLOR_SCHEMA2, SPACING_SCHEMA2, INDENT_SCHEMA2, UNDERLINE_SCHEMA2, BORDER_PROPERTIES_SCHEMA2, SHADING_SCHEMA2, LANG_SCHEMA2, EAST_ASIAN_LAYOUT_SCHEMA2, FIT_TEXT_SCHEMA2, NUMBERING_PROPERTIES_SCHEMA2, FRAME_PR_SCHEMA2, PARAGRAPH_BORDERS_SCHEMA2, TAB_STOP_SCHEMA2, PROPERTY_REGISTRY3, ALLOWED_KEYS_BY_CHANNEL2, PROPERTY_INDEX2, EXCLUDED_KEYS2, INPUT_ALLOWED_KEYS2, TARGET_ALLOWED_KEYS2, OPTIONS_ALLOWED_KEYS2, VALID_CHANNELS2, Z_ORDER_RELATIVE_HEIGHT_MAX2 = 4294967295, nodeTypeValues2, blockNodeTypeValues2, deletableBlockNodeTypeValues2, inlineNodeTypeValues2, rangeSchema2, textAddressSchema2, textTargetSchema2, blockNodeAddressSchema2, deletableBlockNodeAddressSchema2, paragraphAddressSchema2, headingAddressSchema2, listItemAddressSchema2, paragraphTargetSchema2, sectionAddressSchema2, nodeAddressSchema2, commentAddressSchema2, trackedChangeAddressSchema2, entityAddressSchema2, selectionTargetSchema2, deleteBehaviorSchema2, resolvedHandleSchema2, pageInfoSchema2, receiptSuccessSchema2, textMutationResolutionSchema2, textMutationSuccessSchema2, matchBlockSchema2, trackChangeRefSchema2, createParagraphSuccessSchema2, createHeadingSuccessSchema2, headingLevelSchema2, listsInsertSuccessSchema2, listsMutateItemSuccessSchema2, textSelectorSchema2, nodeSelectorSchema2, sdSelectorSchema2, sdAddressSchema2, sdMutationResolutionSchema2, sdMutationSuccessSchema2, documentInfoCountsSchema2, documentInfoOutlineItemSchema2, documentInfoCapabilitiesSchema2, listKindSchema2, listInsertPositionSchema2, sectionBreakTypeSchema2, sectionOrientationSchema2, sectionVerticalAlignSchema2, sectionDirectionSchema2, sectionHeaderFooterKindSchema2, sectionHeaderFooterVariantSchema2, sectionLineNumberRestartSchema2, sectionPageNumberFormatSchema2, sectionRangeDomainSchema2, sectionPageMarginsSchema2, sectionHeaderFooterMarginsSchema2, sectionPageSetupSchema2, sectionColumnsSchema2, sectionLineNumberingSchema2, sectionPageNumberingSchema2, sectionHeaderFooterRefsSchema2, sectionBorderSpecSchema2, sectionPageBordersSchema2, sectionMutationSuccessSchema2, documentMutationSuccessSchema2, paragraphMutationTargetSchema2, paragraphMutationSuccessSchema2, createSectionBreakSuccessSchema2, capabilityReasonsSchema2, capabilityFlagSchema2, operationRuntimeCapabilitySchema2, operationCapabilitiesSchema2, inlinePropertyCapabilitySchema2, formatCapabilitiesSchema2, planEngineCapabilitiesSchema2, tableCreateLocationSchema2, formatInlineAliasOperationSchemas2, tocMutationFailureSchema2, tocMutationSuccessSchema2, tocEntryMutationFailureSchema2, tocEntryMutationSuccessSchema2, hyperlinkTargetSchema2, hyperlinkReadPropertiesSchema2, hyperlinkSpecSchema2, hyperlinkPatchSchema2, hyperlinkDomainSchema2, hyperlinkMutationSuccessSchema2, hyperlinkMutationFailureSchema2, contentControlTargetSchema2, contentControlMutationSuccessSchema2, contentControlMutationFailureSchema2, ccListResultSchema2, ccInfoSchema2, refFailureSchema2, bookmarkAddressSchema2, bookmarkMutation2, footnoteAddressSchema2, footnoteConfigScopeSchema2, footnoteNumberingSchema2, footnoteMutation2, footnoteConfig2, crossRefAddressSchema2, crossRefTargetSchema2, crossRefDisplaySchema2, crossRefMutation2, indexAddressSchema2, indexEntryAddressSchema2, indexConfigSchema2, indexEntryDataSchema2, indexEntryPatchSchema2, indexMutation2, indexEntryMutation2, captionAddressSchema2, captionMutation2, captionConfig2, fieldAddressSchema2, fieldMutation2, citationAddressSchema2, citationSourceAddressSchema2, bibliographyAddressSchema2, citationMutation2, citationSourceMutation2, bibliographyMutation2, citationPersonSchema2, citationSourceFieldsSchema2, tocCreateLocationSchema2, authoritiesAddressSchema2, authorityEntryAddressSchema2, authoritiesConfigSchema2, authorityEntryDataSchema2, authorityEntryPatchSchema2, authoritiesMutation2, authorityEntryMutation2, GROUP_METADATA2, STEP_OP_CATALOG_UNFROZEN2, PUBLIC_STEP_OP_CATALOG_UNFROZEN2, PUBLIC_MUTATION_STEP_OP_IDS2, PUBLIC_MUTATION_STEP_OP_SET2, CAPABILITY_REASON_CODES2, VALID_EDGE_VALUES2, VALID_EDGE_NODE_TYPES2, VALID_DOCUMENT_EDGES2, VALID_REF_BOUNDARIES2, VALID_ANCHOR_KINDS2, RESOLVE_RANGE_ALLOWED_KEYS2, CREATE_COMMENT_ALLOWED_KEYS2, PATCH_COMMENT_ALLOWED_KEYS2, STYLE_APPLY_INPUT_ALLOWED_KEYS2, INLINE_ALIAS_INPUT_ALLOWED_KEYS2, DELETE_INPUT_ALLOWED_KEYS2, VALID_BEHAVIORS2, CONTENT_KIND_SET2, INLINE_KIND_SET2, LEGACY_TOP_LEVEL_TYPES2, LEGACY_INSERT_ALLOWED_KEYS2, STRUCTURAL_INSERT_ALLOWED_KEYS2, VALID_INSERT_TYPES2, TEXT_REPLACE_ALLOWED_KEYS2, STRUCTURAL_REPLACE_ALLOWED_KEYS2, SECTION_BREAK_TYPES$1, SUPPORTED_DELETE_NODE_TYPES2, REJECTED_DELETE_NODE_TYPES2, VALID_BLOCK_NODE_TYPES2, TABLE_LOCATOR_OPS2, ROW_LOCATOR_OPS2, COLUMN_LOCATOR_OPS2, MERGE_RANGE_LOCATOR_OPS2, HEADER_FOOTER_KINDS$1, HEADER_FOOTER_VARIANTS$1, DEFAULT_SECTIONS_LIST_LIMIT2 = 250, SECTION_BREAK_TYPES3, SECTION_ORIENTATIONS2, SECTION_VERTICAL_ALIGNS2, SECTION_DIRECTIONS2, HEADER_FOOTER_KINDS3, HEADER_FOOTER_VARIANTS3, LINE_NUMBER_RESTARTS2, PAGE_NUMBER_FORMATS2, PAGE_BORDER_DISPLAYS2, PAGE_BORDER_OFFSET_FROM_VALUES2, PAGE_BORDER_Z_ORDER_VALUES2, VALID_WRAP_TYPES2, VALID_WRAP_SIDES2, VALID_IMAGE_SIZE_UNITS2, PATCH_FIELDS2, ADAPTER_GATED_PREFIXES2, _buffers, _defaultCollectionId = null, _nextCollectionId = 1, generateV2HandlerEntity = (handlerName, translator$215) => ({
63551
+ }), INLINE_PROPERTY_REGISTRY2, INLINE_PROPERTY_KEY_SET2, INLINE_PROPERTY_BY_KEY2, UNDERLINE_OBJECT_ALLOWED_KEYS2, SHADING_ALLOWED_KEYS2, BORDER_ALLOWED_KEYS2, FIT_TEXT_ALLOWED_KEYS2, LANG_ALLOWED_KEYS2, RFONTS_ALLOWED_KEYS2, EAST_ASIAN_LAYOUT_ALLOWED_KEYS2, STYLISTIC_SET_ALLOWED_KEYS2, VERT_ALIGN_VALUES2, NONE_FAILURES2, NONE_THROWS2, T_NOT_FOUND2, T_NOT_FOUND_CAPABLE2, T_PLAN_ENGINE2, T_NOT_FOUND_COMMAND2, T_NOT_FOUND_COMMAND_TRACKED2, T_IMAGE_COMMAND2, T_CC_READ2, T_CC_MUTATION2, T_CC_TYPED2, T_CC_TYPED_READ2, T_CC_RAW2, T_QUERY_MATCH2, T_SECTION_CREATE2, T_SECTION_READ2, T_PARAGRAPH_MUTATION2, T_SECTION_MUTATION2, T_SECTION_SETTINGS_MUTATION2, T_HEADER_FOOTER_MUTATION2, T_REF_READ_LIST2, T_REF_MUTATION2, T_REF_MUTATION_REMOVE2, T_REF_INSERT2, FORMAT_INLINE_ALIAS_OPERATION_DEFINITIONS2, OPERATION_DEFINITIONS2, OPERATION_IDS2, COMMAND_CATALOG3, PARAGRAPH_ALIGNMENTS2, TAB_STOP_ALIGNMENTS2, TAB_STOP_LEADERS2, BORDER_SIDES2, CLEAR_BORDER_SIDES2, LINE_RULES2, PARAGRAPH_BLOCK_TYPES2, SET_STYLE_KEYS2, CLEAR_STYLE_KEYS2, RESET_DIRECT_FORMATTING_KEYS2, SET_ALIGNMENT_KEYS2, CLEAR_ALIGNMENT_KEYS2, SET_INDENTATION_KEYS2, CLEAR_INDENTATION_KEYS2, SET_SPACING_KEYS2, CLEAR_SPACING_KEYS2, SET_KEEP_OPTIONS_KEYS2, SET_OUTLINE_LEVEL_KEYS2, SET_FLOW_OPTIONS_KEYS2, SET_TAB_STOP_KEYS2, CLEAR_TAB_STOP_KEYS2, CLEAR_ALL_TAB_STOPS_KEYS2, SET_BORDER_KEYS2, CLEAR_BORDER_KEYS2, SET_SHADING_KEYS2, CLEAR_SHADING_KEYS2, ST_ON_OFF_ON_VALUES2, ST_ON_OFF_OFF_VALUES2, ST_UNDERLINE_VALUES2, ST_UNDERLINE_VALUE_SET2, ST_VERTICAL_ALIGN_RUN2, ST_EM2, ST_TEXT_ALIGNMENT2, ST_TEXT_DIRECTION2, ST_TEXTBOX_TIGHT_WRAP2, ST_TEXT_TRANSFORM2, ST_JUSTIFICATION2, FONT_FAMILY_SCHEMA2, COLOR_SCHEMA2, SPACING_SCHEMA2, INDENT_SCHEMA2, UNDERLINE_SCHEMA2, BORDER_PROPERTIES_SCHEMA2, SHADING_SCHEMA2, LANG_SCHEMA2, EAST_ASIAN_LAYOUT_SCHEMA2, FIT_TEXT_SCHEMA2, NUMBERING_PROPERTIES_SCHEMA2, FRAME_PR_SCHEMA2, PARAGRAPH_BORDERS_SCHEMA2, TAB_STOP_SCHEMA2, PROPERTY_REGISTRY3, ALLOWED_KEYS_BY_CHANNEL2, PROPERTY_INDEX2, EXCLUDED_KEYS2, INPUT_ALLOWED_KEYS2, TARGET_ALLOWED_KEYS2, OPTIONS_ALLOWED_KEYS2, VALID_CHANNELS2, Z_ORDER_RELATIVE_HEIGHT_MAX2 = 4294967295, nodeTypeValues2, blockNodeTypeValues2, deletableBlockNodeTypeValues2, inlineNodeTypeValues2, rangeSchema2, textAddressSchema2, textTargetSchema2, blockNodeAddressSchema2, deletableBlockNodeAddressSchema2, paragraphAddressSchema2, headingAddressSchema2, listItemAddressSchema2, paragraphTargetSchema2, sectionAddressSchema2, nodeAddressSchema2, commentAddressSchema2, trackedChangeAddressSchema2, entityAddressSchema2, selectionTargetSchema2, deleteBehaviorSchema2, resolvedHandleSchema2, pageInfoSchema2, receiptSuccessSchema2, textMutationRangeSchema2, textMutationResolutionSchema2, textMutationSuccessSchema2, matchBlockSchema2, trackChangeRefSchema2, createParagraphSuccessSchema2, createHeadingSuccessSchema2, headingLevelSchema2, listsInsertSuccessSchema2, listsMutateItemSuccessSchema2, textSelectorSchema2, nodeSelectorSchema2, sdMutationResolutionSchema2, sdMutationSuccessSchema2, documentInfoCountsSchema2, documentInfoOutlineItemSchema2, documentInfoCapabilitiesSchema2, listKindSchema2, listInsertPositionSchema2, sectionBreakTypeSchema2, sectionOrientationSchema2, sectionVerticalAlignSchema2, sectionDirectionSchema2, sectionHeaderFooterKindSchema2, sectionHeaderFooterVariantSchema2, sectionLineNumberRestartSchema2, sectionPageNumberFormatSchema2, sectionRangeDomainSchema2, sectionPageMarginsSchema2, sectionHeaderFooterMarginsSchema2, sectionPageSetupSchema2, sectionColumnsSchema2, sectionLineNumberingSchema2, sectionPageNumberingSchema2, sectionHeaderFooterRefsSchema2, sectionBorderSpecSchema2, sectionPageBordersSchema2, sectionMutationSuccessSchema2, documentMutationSuccessSchema2, paragraphMutationTargetSchema2, paragraphMutationSuccessSchema2, createSectionBreakSuccessSchema2, capabilityReasonsSchema2, capabilityFlagSchema2, operationRuntimeCapabilitySchema2, operationCapabilitiesSchema2, inlinePropertyCapabilitySchema2, formatCapabilitiesSchema2, planEngineCapabilitiesSchema2, sdFragmentSchema2, placementSchema2, nestingPolicySchema2, tableCreateLocationSchema2, formatInlineAliasOperationSchemas2, tocMutationFailureSchema2, tocMutationSuccessSchema2, tocEntryMutationFailureSchema2, tocEntryMutationSuccessSchema2, hyperlinkTargetSchema2, hyperlinkReadPropertiesSchema2, hyperlinkSpecSchema2, hyperlinkPatchSchema2, hyperlinkDomainSchema2, hyperlinkMutationSuccessSchema2, hyperlinkMutationFailureSchema2, contentControlTargetSchema2, contentControlMutationSuccessSchema2, contentControlMutationFailureSchema2, ccListResultSchema2, ccInfoSchema2, refFailureSchema2, bookmarkAddressSchema2, bookmarkMutation2, footnoteAddressSchema2, footnoteConfigScopeSchema2, footnoteNumberingSchema2, footnoteMutation2, footnoteConfig2, crossRefAddressSchema2, crossRefTargetSchema2, crossRefDisplaySchema2, crossRefMutation2, indexAddressSchema2, indexEntryAddressSchema2, indexConfigSchema2, indexEntryDataSchema2, indexEntryPatchSchema2, indexMutation2, indexEntryMutation2, captionAddressSchema2, captionMutation2, captionConfig2, fieldAddressSchema2, fieldMutation2, citationAddressSchema2, citationSourceAddressSchema2, bibliographyAddressSchema2, citationMutation2, citationSourceMutation2, bibliographyMutation2, citationPersonSchema2, citationSourceFieldsSchema2, tocCreateLocationSchema2, authoritiesAddressSchema2, authorityEntryAddressSchema2, authoritiesConfigSchema2, authorityEntryDataSchema2, authorityEntryPatchSchema2, authoritiesMutation2, authorityEntryMutation2, GROUP_METADATA2, STEP_OP_CATALOG_UNFROZEN2, PUBLIC_STEP_OP_CATALOG_UNFROZEN2, PUBLIC_MUTATION_STEP_OP_IDS2, PUBLIC_MUTATION_STEP_OP_SET2, CAPABILITY_REASON_CODES2, VALID_EDGE_VALUES2, VALID_EDGE_NODE_TYPES2, VALID_DOCUMENT_EDGES2, VALID_REF_BOUNDARIES2, VALID_ANCHOR_KINDS2, RESOLVE_RANGE_ALLOWED_KEYS2, CREATE_COMMENT_ALLOWED_KEYS2, PATCH_COMMENT_ALLOWED_KEYS2, STYLE_APPLY_INPUT_ALLOWED_KEYS2, INLINE_ALIAS_INPUT_ALLOWED_KEYS2, DELETE_INPUT_ALLOWED_KEYS2, VALID_BEHAVIORS2, CONTENT_KIND_SET2, INLINE_KIND_SET2, LEGACY_TOP_LEVEL_TYPES2, LEGACY_INSERT_ALLOWED_KEYS2, STRUCTURAL_INSERT_ALLOWED_KEYS2, VALID_INSERT_TYPES2, TEXT_REPLACE_ALLOWED_KEYS2, STRUCTURAL_REPLACE_ALLOWED_KEYS2, SECTION_BREAK_TYPES$1, SUPPORTED_DELETE_NODE_TYPES2, REJECTED_DELETE_NODE_TYPES2, VALID_BLOCK_NODE_TYPES2, TABLE_LOCATOR_OPS2, ROW_LOCATOR_OPS2, COLUMN_LOCATOR_OPS2, MERGE_RANGE_LOCATOR_OPS2, HEADER_FOOTER_KINDS$1, HEADER_FOOTER_VARIANTS$1, DEFAULT_SECTIONS_LIST_LIMIT2 = 250, SECTION_BREAK_TYPES3, SECTION_ORIENTATIONS2, SECTION_VERTICAL_ALIGNS2, SECTION_DIRECTIONS2, HEADER_FOOTER_KINDS3, HEADER_FOOTER_VARIANTS3, LINE_NUMBER_RESTARTS2, PAGE_NUMBER_FORMATS2, PAGE_BORDER_DISPLAYS2, PAGE_BORDER_OFFSET_FROM_VALUES2, PAGE_BORDER_Z_ORDER_VALUES2, VALID_WRAP_TYPES2, VALID_WRAP_SIDES2, VALID_IMAGE_SIZE_UNITS2, PATCH_FIELDS2, ADAPTER_GATED_PREFIXES2, _buffers, _defaultCollectionId = null, _nextCollectionId = 1, generateV2HandlerEntity = (handlerName, translator$215) => ({
63527
63552
  handlerName,
63528
63553
  handler: (params) => {
63529
63554
  const { nodes } = params;
@@ -75603,7 +75628,7 @@ var isRegExp = (value) => {
75603
75628
  state.kern = kernNode.attributes["w:val"];
75604
75629
  }
75605
75630
  }, SuperConverter;
75606
- var init_SuperConverter_BParsWaS_es = __esm(() => {
75631
+ var init_SuperConverter_voJQZ_PC_es = __esm(() => {
75607
75632
  init_rolldown_runtime_B2q5OVn9_es();
75608
75633
  init_jszip_ChlR43oI_es();
75609
75634
  init_xml_js_DLE8mr0n_es();
@@ -78149,13 +78174,7 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
78149
78174
  ]);
78150
78175
  TABLE_NESTING_POLICY_VALUES2 = new Set(["forbid", "allow"]);
78151
78176
  DEFAULT_NESTING_POLICY2 = Object.freeze({ tables: "forbid" });
78152
- SD_ADDRESS_KINDS2 = new Set([
78153
- "content",
78154
- "inline",
78155
- "annotation",
78156
- "section"
78157
- ]);
78158
- SD_ADDRESS_STABILITIES2 = new Set(["stable", "ephemeral"]);
78177
+ BLOCK_NODE_TYPES_SET2 = new Set(BLOCK_NODE_TYPES2);
78159
78178
  NESTING_POLICY_ALLOWED_KEYS2 = new Set(["tables"]);
78160
78179
  UNDERLINE_OBJECT_SCHEMA2 = {
78161
78180
  type: "object",
@@ -78647,8 +78666,8 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
78647
78666
  },
78648
78667
  insert: {
78649
78668
  memberPath: "insert",
78650
- description: "Insert inline content at a text position within an existing block, or at the end of the document when target is omitted. This is NOT for creating sibling blocks — use create.paragraph, create.heading, or lists.insert for that. Accepts two input shapes: legacy string-based (value + type) or structural SDFragment (content). Supports text (default), markdown, and html content types via the `type` field in legacy mode. Structural mode accepts an SDFragment with typed nodes (paragraphs, tables, images, etc.).",
78651
- expectedResult: "Returns a TextMutationReceipt with applied status; receipt reports NO_OP if the insertion point is invalid or content is empty.",
78669
+ description: "Insert content into the document. Two input shapes: legacy string-based (value + type) inserts inline content at a text position within an existing block; structural SDFragment (content) inserts one or more blocks as siblings relative to a BlockNodeAddress target. When target is omitted, content appends at the end of the document. Legacy mode supports text (default), markdown, and html content types via the `type` field. Structural mode uses `placement` (before/after/insideStart/insideEnd) to position relative to the target block.",
78670
+ expectedResult: "Returns an SDMutationReceipt with applied status; resolution reports a TextAddress for legacy text insertion or a BlockNodeAddress for structural insertion. Receipt reports NO_OP if the insertion point is invalid or content is empty.",
78652
78671
  requiresDocumentContext: true,
78653
78672
  metadata: mutationOperation2({
78654
78673
  idempotency: "non-idempotent",
@@ -78686,7 +78705,7 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
78686
78705
  },
78687
78706
  replace: {
78688
78707
  memberPath: "replace",
78689
- description: "Replace content at a contiguous document selection. Text path accepts a SelectionTarget or ref plus replacement text. Structural path accepts an SDAddress, SelectionTarget, or ref plus SDFragment content.",
78708
+ description: "Replace content at a contiguous document selection. Text path accepts a SelectionTarget or ref plus replacement text. Structural path accepts a BlockNodeAddress (replaces whole block), SelectionTarget (expands to full covered block boundaries), or ref plus SDFragment content.",
78690
78709
  expectedResult: "Returns an SDMutationReceipt with applied status; receipt reports NO_OP if the target range already contains identical content.",
78691
78710
  requiresDocumentContext: true,
78692
78711
  metadata: mutationOperation2({
@@ -84458,7 +84477,7 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
84458
84477
  resolvedHandleSchema2 = ref2("ResolvedHandle");
84459
84478
  pageInfoSchema2 = ref2("PageInfo");
84460
84479
  receiptSuccessSchema2 = ref2("ReceiptSuccess");
84461
- ref2("TextMutationRange");
84480
+ textMutationRangeSchema2 = ref2("TextMutationRange");
84462
84481
  textMutationResolutionSchema2 = ref2("TextMutationResolution");
84463
84482
  textMutationSuccessSchema2 = ref2("TextMutationSuccess");
84464
84483
  ref2("MatchRun");
@@ -84540,41 +84559,18 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
84540
84559
  kind: { enum: ["block", "inline"] }
84541
84560
  }, ["type"]);
84542
84561
  objectSchema2({ nodeType: { enum: [...nodeTypeValues2] } }, ["nodeType"]);
84543
- sdSelectorSchema2 = { oneOf: [objectSchema2({
84544
- type: { const: "text" },
84545
- pattern: { type: "string" },
84546
- mode: { enum: ["contains", "regex"] },
84547
- caseSensitive: { type: "boolean" }
84548
- }, ["type", "pattern"]), objectSchema2({
84549
- type: { const: "node" },
84550
- kind: { enum: ["content", "inline"] },
84551
- nodeKind: { type: "string" }
84552
- }, ["type"])] };
84553
- sdAddressSchema2 = objectSchema2({
84554
- kind: { enum: [
84555
- "content",
84556
- "inline",
84557
- "annotation",
84558
- "section"
84559
- ] },
84560
- stability: { enum: ["stable", "ephemeral"] },
84561
- nodeId: { type: "string" },
84562
- anchor: objectSchema2({
84563
- start: objectSchema2({
84564
- blockId: { type: "string" },
84565
- offset: { type: "integer" }
84566
- }, ["blockId", "offset"]),
84567
- end: objectSchema2({
84568
- blockId: { type: "string" },
84569
- offset: { type: "integer" }
84570
- }, ["blockId", "offset"])
84571
- }),
84572
- evaluatedRevision: { type: "string" },
84573
- path: arraySchema2({ oneOf: [{ type: "string" }, { type: "integer" }] })
84574
- }, ["kind", "stability"]);
84575
84562
  objectSchema2({
84576
- select: sdSelectorSchema2,
84577
- within: sdAddressSchema2,
84563
+ select: { oneOf: [objectSchema2({
84564
+ type: { const: "text" },
84565
+ pattern: { type: "string" },
84566
+ mode: { enum: ["contains", "regex"] },
84567
+ caseSensitive: { type: "boolean" }
84568
+ }, ["type", "pattern"]), objectSchema2({
84569
+ type: { const: "node" },
84570
+ kind: { enum: ["block", "inline"] },
84571
+ nodeType: { type: "string" }
84572
+ }, ["type"])] },
84573
+ within: blockNodeAddressSchema2,
84578
84574
  limit: { type: "integer" },
84579
84575
  offset: { type: "integer" },
84580
84576
  options: objectSchema2({
@@ -84598,7 +84594,7 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
84598
84594
  },
84599
84595
  items: arraySchema2(objectSchema2({
84600
84596
  node: { type: "object" },
84601
- address: sdAddressSchema2,
84597
+ address: nodeAddressSchema2,
84602
84598
  context: { type: "object" }
84603
84599
  }, ["node", "address"]))
84604
84600
  }, [
@@ -84608,10 +84604,10 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
84608
84604
  "items"
84609
84605
  ]);
84610
84606
  sdMutationResolutionSchema2 = objectSchema2({
84611
- requestedTarget: sdAddressSchema2,
84612
- target: sdAddressSchema2,
84607
+ target: { oneOf: [textAddressSchema2, blockNodeAddressSchema2] },
84608
+ range: textMutationRangeSchema2,
84613
84609
  selectionTarget: selectionTargetSchema2
84614
- }, ["target"]);
84610
+ }, ["target", "range"]);
84615
84611
  sdMutationSuccessSchema2 = objectSchema2({
84616
84612
  success: { const: true },
84617
84613
  resolution: sdMutationResolutionSchema2,
@@ -85082,6 +85078,17 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
85082
85078
  "planEngine"
85083
85079
  ]);
85084
85080
  objectSchema2({});
85081
+ sdFragmentSchema2 = { oneOf: [{ type: "object" }, {
85082
+ type: "array",
85083
+ items: { type: "object" }
85084
+ }] };
85085
+ placementSchema2 = { enum: [
85086
+ "before",
85087
+ "after",
85088
+ "insideStart",
85089
+ "insideEnd"
85090
+ ] };
85091
+ nestingPolicySchema2 = objectSchema2({ tables: { enum: ["forbid", "allow"] } });
85085
85092
  objectSchema2({
85086
85093
  target: textAddressSchema2,
85087
85094
  value: { type: "string" },
@@ -85093,7 +85100,12 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
85093
85100
  "html"
85094
85101
  ]
85095
85102
  }
85096
- }, ["value"]);
85103
+ }, ["value"]), objectSchema2({
85104
+ target: blockNodeAddressSchema2,
85105
+ content: sdFragmentSchema2,
85106
+ placement: placementSchema2,
85107
+ nestingPolicy: nestingPolicySchema2
85108
+ }, ["content"]);
85097
85109
  ({ ...objectSchema2({
85098
85110
  target: blockNodeAddressSchema2,
85099
85111
  nodeId: { type: "string" }
@@ -85668,17 +85680,13 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
85668
85680
  "lossy",
85669
85681
  "diagnostics"
85670
85682
  ]), receiptResultSchemaFor2("clearContent"), receiptFailureResultSchemaFor2("clearContent"), sdMutationResultSchemaFor2("insert"), sdMutationFailureSchemaFor2("insert"), { ...targetLocatorWithPayload2({ text: { type: "string" } }, ["text"]) }, objectSchema2({
85671
- target: { oneOf: [
85672
- sdAddressSchema2,
85673
- textAddressSchema2,
85674
- selectionTargetSchema2
85675
- ] },
85676
- content: { type: "object" },
85677
- nestingPolicy: { type: "object" }
85683
+ target: { oneOf: [blockNodeAddressSchema2, selectionTargetSchema2] },
85684
+ content: sdFragmentSchema2,
85685
+ nestingPolicy: nestingPolicySchema2
85678
85686
  }, ["target", "content"]), objectSchema2({
85679
85687
  ref: { type: "string" },
85680
- content: { type: "object" },
85681
- nestingPolicy: { type: "object" }
85688
+ content: sdFragmentSchema2,
85689
+ nestingPolicy: nestingPolicySchema2
85682
85690
  }, ["ref", "content"]), sdMutationResultSchemaFor2("replace"), sdMutationFailureSchemaFor2("replace"), { ...targetLocatorWithPayload2({ behavior: deleteBehaviorSchema2 }) }, textMutationResultSchemaFor2("delete"), textMutationFailureSchemaFor2("delete"), { ...targetLocatorWithPayload2({ inline: buildInlineRunPatchSchema2() }, ["inline"]) }, textMutationResultSchemaFor2("format.apply"), textMutationFailureSchemaFor2("format.apply"), { ...formatInlineAliasOperationSchemas2 }, objectSchema2({
85683
85691
  offset: {
85684
85692
  type: "number",
@@ -86479,7 +86487,7 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
86479
86487
  ] }
86480
86488
  }), objectSchema2({ id: { type: "string" } }, ["id"]), objectSchema2({ id: { type: "string" } }, ["id"]), objectSchema2({ scope: { enum: ["all"] } }, ["scope"]), receiptResultSchemaFor2("trackChanges.decide"), receiptFailureResultSchemaFor2("trackChanges.decide"), objectSchema2({
86481
86489
  select: { oneOf: [textSelectorSchema2, nodeSelectorSchema2] },
86482
- within: nodeAddressSchema2,
86490
+ within: blockNodeAddressSchema2,
86483
86491
  require: { enum: [
86484
86492
  "any",
86485
86493
  "first",
@@ -86499,7 +86507,7 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
86499
86507
  }, ["select"]), (() => {
86500
86508
  const textMatchItemSchema = discoveryItemSchema2({
86501
86509
  matchKind: { const: "text" },
86502
- address: nodeAddressSchema2,
86510
+ address: blockNodeAddressSchema2,
86503
86511
  target: selectionTargetSchema2,
86504
86512
  snippet: { type: "string" },
86505
86513
  highlightRange: rangeSchema2,
@@ -86539,7 +86547,7 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
86539
86547
  type: "string"
86540
86548
  },
86541
86549
  select: { oneOf: [textSelectorSchema2, nodeSelectorSchema2] },
86542
- within: nodeAddressSchema2,
86550
+ within: blockNodeAddressSchema2,
86543
86551
  require: { enum: [
86544
86552
  "first",
86545
86553
  "exactlyOne",
@@ -86556,7 +86564,7 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
86556
86564
  type: "string"
86557
86565
  },
86558
86566
  ref: { type: "string" },
86559
- within: nodeAddressSchema2
86567
+ within: blockNodeAddressSchema2
86560
86568
  }, ["by", "ref"]),
86561
86569
  objectSchema2({
86562
86570
  by: {
@@ -86572,7 +86580,7 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
86572
86580
  type: "string"
86573
86581
  },
86574
86582
  select: { oneOf: [textSelectorSchema2, nodeSelectorSchema2] },
86575
- within: nodeAddressSchema2,
86583
+ within: blockNodeAddressSchema2,
86576
86584
  require: { enum: ["first", "exactlyOne"] }
86577
86585
  }, [
86578
86586
  "by",
@@ -86585,7 +86593,7 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
86585
86593
  type: "string"
86586
86594
  },
86587
86595
  select: { oneOf: [textSelectorSchema2, nodeSelectorSchema2] },
86588
- within: nodeAddressSchema2
86596
+ within: blockNodeAddressSchema2
86589
86597
  }, ["by", "select"]);
86590
86598
  const replacementBlockSchema = objectSchema2({ text: { type: "string" } }, ["text"]);
86591
86599
  const replacementPayloadSchema = { oneOf: [objectSchema2({ text: { type: "string" } }, ["text"]), objectSchema2({ blocks: arraySchema2(replacementBlockSchema) }, ["blocks"])] };
@@ -87844,7 +87852,7 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
87844
87852
  imageId: { type: "string" },
87845
87853
  text: { type: "string" }
87846
87854
  }, ["imageId", "text"])), imagesMutationSchemaSet2(objectSchema2({ imageId: { type: "string" } }, ["imageId"])), objectSchema2({
87847
- within: nodeAddressSchema2,
87855
+ within: blockNodeAddressSchema2,
87848
87856
  hrefPattern: { type: "string" },
87849
87857
  anchor: { type: "string" },
87850
87858
  textPattern: { type: "string" },
@@ -110306,7 +110314,7 @@ var init_remark_stringify_D8vxv_XI_es = __esm(() => {
110306
110314
  eol = /\r?\n|\r/g;
110307
110315
  });
110308
110316
 
110309
- // ../../packages/superdoc/dist/chunks/DocxZipper-_tW4mTs0.es.js
110317
+ // ../../packages/superdoc/dist/chunks/DocxZipper-BmRnFofk.es.js
110310
110318
  function getLens2(b64) {
110311
110319
  var len$1 = b64.length;
110312
110320
  if (len$1 % 4 > 0)
@@ -110616,7 +110624,7 @@ function syncPackageMetadata({ baseFiles, updatedDocs }) {
110616
110624
  relsXml: serializeXml(relsParsed)
110617
110625
  };
110618
110626
  }
110619
- var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document", buffer2, base64Js2, lookup2, revLookup2, Arr2, code4 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", i2, len2, ieee7542, Buffer3, isXmlLike = (name) => /\.xml$|\.rels$/i.test(name), MANAGED_PACKAGE_PARTS, import_lib$12, RELATIONSHIPS_NS = "http://schemas.openxmlformats.org/package/2006/relationships", import_lib3, import_jszip_min, IMAGE_EXTS, MIME_TYPE_FOR_EXT, CUSTOM_XML_ITEM_PROPS_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.customXmlProperties+xml", DocxZipper = class {
110627
+ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document", buffer2, base64Js2, lookup2, revLookup2, Arr2, code4 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", i2, len2, ieee7542, Buffer3, isXmlLike = (name) => /\.xml$|\.rels$/i.test(name), MANAGED_PACKAGE_PARTS, import_lib$12, RELATIONSHIPS_NS = "http://schemas.openxmlformats.org/package/2006/relationships", import_lib3, import_jszip_min, IMAGE_EXTS, MIME_TYPE_FOR_EXT, CUSTOM_XML_ITEM_PROPS_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.customXmlProperties+xml", FONT_CONTENT_TYPES, DocxZipper = class {
110620
110628
  constructor(params = {}) {
110621
110629
  this.debug = params.debug || false;
110622
110630
  this.zip = new import_jszip_min.default;
@@ -110672,7 +110680,7 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
110672
110680
  return null;
110673
110681
  return fileSplit[fileSplit.length - 1];
110674
110682
  }
110675
- async updateContentTypes(docx, media, fromJson, updatedDocs = {}) {
110683
+ async updateContentTypes(docx, media, fromJson, updatedDocs = {}, fonts = {}) {
110676
110684
  const additionalPartNames = Object.keys(updatedDocs || {});
110677
110685
  const newMediaTypes = Object.keys(media).map((name) => this.getFileExtension(name)).filter((ext) => ext && IMAGE_EXTS.has(ext));
110678
110686
  const extensionlessMediaOverrides = Object.entries(media).filter(([name]) => !this.getFileExtension(name)).map(([name, value]) => ({
@@ -110700,6 +110708,17 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
110700
110708
  typesString += newContentType;
110701
110709
  seenTypes.add(type);
110702
110710
  }
110711
+ if (fonts) {
110712
+ const fontExts = new Set(Object.keys(fonts).map((name) => this.getFileExtension(name)).filter((ext) => ext && FONT_CONTENT_TYPES[ext]));
110713
+ for (const ext of fontExts) {
110714
+ if (defaultMediaTypes.includes(ext))
110715
+ continue;
110716
+ if (seenTypes.has(ext))
110717
+ continue;
110718
+ typesString += `<Default Extension="${ext}" ContentType="${FONT_CONTENT_TYPES[ext]}"/>`;
110719
+ seenTypes.add(ext);
110720
+ }
110721
+ }
110703
110722
  const types3 = JSON.parse(import_lib3.xml2json(contentTypesXml, null, 2)).elements?.find((el) => el.name === "Types") || {};
110704
110723
  const hasPartOverride = (partName) => types3.elements?.some((el) => el.name === "Override" && el.attributes.PartName === partName);
110705
110724
  for (const { name, contentType } of extensionlessMediaOverrides) {
@@ -110854,7 +110873,7 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
110854
110873
  async updateZip({ docx, updatedDocs, originalDocxFile, media, fonts, isHeadless, compression = "DEFLATE" }) {
110855
110874
  let zip;
110856
110875
  if (originalDocxFile)
110857
- zip = await this.exportFromOriginalFile(originalDocxFile, updatedDocs, media);
110876
+ zip = await this.exportFromOriginalFile(originalDocxFile, updatedDocs, media, fonts);
110858
110877
  else
110859
110878
  zip = await this.exportFromCollaborativeDocx(docx, updatedDocs, media, fonts);
110860
110879
  const exportType = isHeadless ? "nodebuffer" : "blob";
@@ -110884,11 +110903,11 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
110884
110903
  });
110885
110904
  for (const [fontName, fontUintArray] of Object.entries(fonts))
110886
110905
  zip.file(fontName, fontUintArray);
110887
- await this.updateContentTypes(zip, media, false, updatedDocs);
110906
+ await this.updateContentTypes(zip, media, false, updatedDocs, fonts);
110888
110907
  await this.#syncPackageMetadataInZip(zip);
110889
110908
  return zip;
110890
110909
  }
110891
- async exportFromOriginalFile(originalDocxFile, updatedDocs, media) {
110910
+ async exportFromOriginalFile(originalDocxFile, updatedDocs, media, fonts) {
110892
110911
  const unzippedOriginalDocx = await this.unzip(originalDocxFile);
110893
110912
  const filePromises = [];
110894
110913
  unzippedOriginalDocx.forEach((relativePath, zipEntry) => {
@@ -110907,7 +110926,10 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
110907
110926
  Object.keys(media).forEach((path2) => {
110908
110927
  unzippedOriginalDocx.file(path2, media[path2]);
110909
110928
  });
110910
- await this.updateContentTypes(unzippedOriginalDocx, media, false, updatedDocs);
110929
+ if (fonts)
110930
+ for (const [fontName, fontUintArray] of Object.entries(fonts))
110931
+ unzippedOriginalDocx.file(fontName, fontUintArray);
110932
+ await this.updateContentTypes(unzippedOriginalDocx, media, false, updatedDocs, fonts);
110911
110933
  await this.#syncPackageMetadataInZip(unzippedOriginalDocx);
110912
110934
  return unzippedOriginalDocx;
110913
110935
  }
@@ -110928,7 +110950,7 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
110928
110950
  return `image/${MIME_TYPE_FOR_EXT[detectedType] || detectedType}`;
110929
110951
  }
110930
110952
  }, DocxZipper_default;
110931
- var init_DocxZipper__tW4mTs0_es = __esm(() => {
110953
+ var init_DocxZipper_BmRnFofk_es = __esm(() => {
110932
110954
  init_rolldown_runtime_B2q5OVn9_es();
110933
110955
  init_jszip_ChlR43oI_es();
110934
110956
  init_xml_js_DLE8mr0n_es();
@@ -112589,6 +112611,11 @@ var init_DocxZipper__tW4mTs0_es = __esm(() => {
112589
112611
  tif: "tiff",
112590
112612
  jpg: "jpeg"
112591
112613
  };
112614
+ FONT_CONTENT_TYPES = {
112615
+ odttf: "application/vnd.openxmlformats-officedocument.obfuscatedFont",
112616
+ ttf: "application/x-font-ttf",
112617
+ otf: "application/vnd.ms-opentype"
112618
+ };
112592
112619
  DocxZipper_default = DocxZipper;
112593
112620
  });
112594
112621
 
@@ -136026,7 +136053,7 @@ var init_remark_gfm_CjV8kaUy_es = __esm(() => {
136026
136053
  init_remark_gfm_z_sDF4ss_es();
136027
136054
  });
136028
136055
 
136029
- // ../../packages/superdoc/dist/chunks/src-DvnhdISL.es.js
136056
+ // ../../packages/superdoc/dist/chunks/src-D_53T9-x.es.js
136030
136057
  function deleteProps(obj, propOrProps) {
136031
136058
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
136032
136059
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -138924,7 +138951,7 @@ function createPositionTrackerPlugin() {
138924
138951
  }
138925
138952
  },
138926
138953
  props: { decorations() {
138927
- return DecorationSet.empty;
138954
+ return null;
138928
138955
  } }
138929
138956
  });
138930
138957
  }
@@ -144628,11 +144655,6 @@ function assertUnambiguous(matches2, blockId) {
144628
144655
  matchCount: matches2.length
144629
144656
  });
144630
144657
  }
144631
- function findInlineWithinTextBlock(index2, blockId) {
144632
- const matches2 = findTextBlockCandidates(index2, blockId);
144633
- assertUnambiguous(matches2, blockId);
144634
- return matches2[0];
144635
- }
144636
144658
  function resolveTextTarget(editor, target) {
144637
144659
  const matches2 = findTextBlockCandidates(getBlockIndex(editor), target.blockId);
144638
144660
  assertUnambiguous(matches2, target.blockId);
@@ -144816,42 +144838,20 @@ function resolveWithinScope(index2, query2, diagnostics) {
144816
144838
  ok: true,
144817
144839
  range: undefined
144818
144840
  };
144819
- if (query2.within.kind === "block") {
144820
- const within$1 = findBlockById(index2, query2.within);
144821
- if (!within$1) {
144822
- addDiagnostic2(diagnostics, `Within block "${query2.within.nodeType}" with id "${query2.within.nodeId}" was not found in the document.`);
144823
- return { ok: false };
144824
- }
144825
- return {
144826
- ok: true,
144827
- range: {
144828
- start: within$1.pos,
144829
- end: within$1.end
144830
- }
144831
- };
144832
- }
144833
- if (query2.within.anchor.start.blockId !== query2.within.anchor.end.blockId) {
144834
- addDiagnostic2(diagnostics, "Inline within anchors that span multiple blocks are not supported.");
144835
- return { ok: false };
144836
- }
144837
- const block = findInlineWithinTextBlock(index2, query2.within.anchor.start.blockId);
144838
- if (!block) {
144839
- addDiagnostic2(diagnostics, `Within inline anchor block "${query2.within.anchor.start.blockId}" was not found in the document.`);
144840
- return { ok: false };
144841
- }
144842
- const resolved = resolveTextRangeInBlock(block.node, block.pos, {
144843
- start: query2.within.anchor.start.offset,
144844
- end: query2.within.anchor.end.offset
144845
- });
144846
- if (!resolved) {
144847
- addDiagnostic2(diagnostics, "Inline within anchor offsets could not be resolved in the target block.");
144841
+ let within$1 = findBlockById(index2, query2.within);
144842
+ if (!within$1 && query2.within.kind === "block")
144843
+ try {
144844
+ within$1 = findBlockByNodeIdOnly(index2, query2.within.nodeId);
144845
+ } catch {}
144846
+ if (!within$1) {
144847
+ addDiagnostic2(diagnostics, `Within block "${query2.within.nodeType}" with id "${query2.within.nodeId}" was not found in the document.`);
144848
144848
  return { ok: false };
144849
144849
  }
144850
144850
  return {
144851
144851
  ok: true,
144852
144852
  range: {
144853
- start: resolved.from,
144854
- end: resolved.to
144853
+ start: within$1.pos,
144854
+ end: within$1.end
144855
144855
  }
144856
144856
  };
144857
144857
  }
@@ -147317,7 +147317,7 @@ function buildTextContext(editor, address2, matchFrom, matchTo, textRanges) {
147317
147317
  textRanges: textRanges?.length ? textRanges : undefined
147318
147318
  };
147319
147319
  }
147320
- function toTextAddress$1(editor, block, range) {
147320
+ function toTextAddress$2(editor, block, range) {
147321
147321
  const blockStart = block.pos + 1;
147322
147322
  const blockEnd = block.end - 1;
147323
147323
  if (range.from < blockStart || range.to > blockEnd)
@@ -147584,7 +147584,7 @@ function executeTextSelector(editor, index2, query2, diagnostics) {
147584
147584
  return;
147585
147585
  if (!source)
147586
147586
  source = block;
147587
- return toTextAddress$1(editor, block, range);
147587
+ return toTextAddress$2(editor, block, range);
147588
147588
  }).filter((range) => Boolean(range));
147589
147589
  if (!source)
147590
147590
  source = findCandidateByPos(textBlocks, match$1.from) ?? findBlockByPos(index2, match$1.from);
@@ -148581,39 +148581,50 @@ function translateToInternalQuery(input2) {
148581
148581
  const { select: select2, within: within$1, limit, offset: offset$1 } = input2;
148582
148582
  if (within$1)
148583
148583
  validateWithinAddress(within$1);
148584
- if (select2.type === "text")
148585
- return {
148586
- select: {
148587
- type: "text",
148588
- pattern: select2.pattern,
148589
- ...select2.mode != null && { mode: select2.mode },
148590
- ...select2.caseSensitive != null && { caseSensitive: select2.caseSensitive }
148591
- },
148592
- limit,
148593
- offset: offset$1,
148594
- includeNodes: true
148595
- };
148584
+ if (select2.type === "node") {
148585
+ const raw = select2;
148586
+ if ("nodeKind" in raw && raw.nodeKind != null)
148587
+ throw new DocumentApiAdapterError("INVALID_INPUT", `"nodeKind" is no longer supported on node selectors. Use "nodeType" instead: { type: 'node', nodeType: '${String(raw.nodeKind)}' }.`, {
148588
+ field: "select.nodeKind",
148589
+ value: raw.nodeKind
148590
+ });
148591
+ if (raw.kind === "content")
148592
+ throw new DocumentApiAdapterError("INVALID_INPUT", `kind: 'content' is no longer supported on node selectors. Use kind: 'block' instead.`, {
148593
+ field: "select.kind",
148594
+ value: raw.kind
148595
+ });
148596
+ }
148596
148597
  return {
148597
- select: {
148598
- type: "node",
148599
- ...select2.nodeKind != null && { nodeType: select2.nodeKind },
148600
- ...select2.kind === "content" && { kind: "block" },
148601
- ...select2.kind === "inline" && { kind: "inline" }
148602
- },
148598
+ select: select2,
148603
148599
  limit,
148604
148600
  offset: offset$1,
148605
148601
  includeNodes: true
148606
148602
  };
148607
148603
  }
148608
- function validateWithinAddress(sdAddress) {
148609
- if (sdAddress.kind === "content" && sdAddress.nodeId)
148610
- return { nodeId: sdAddress.nodeId };
148611
- throw new DocumentApiAdapterError("INVALID_TARGET", `"within" scope requires a content-kind SDAddress with a nodeId. Got kind="${sdAddress.kind}".`, {
148604
+ function validateWithinAddress(address2) {
148605
+ if (address2.kind === "block" && "nodeId" in address2 && typeof address2.nodeId === "string")
148606
+ return {
148607
+ nodeId: address2.nodeId,
148608
+ nodeType: address2.nodeType
148609
+ };
148610
+ throw new DocumentApiAdapterError("INVALID_TARGET", '"within" scope requires a BlockNodeAddress with a nodeId.', {
148612
148611
  field: "within",
148613
- value: sdAddress
148612
+ value: address2
148614
148613
  });
148615
148614
  }
148616
- function resolveWithinNodeType(index2, nodeId) {
148615
+ function resolveWithinAddress(index2, nodeId, expectedNodeType) {
148616
+ if (expectedNodeType) {
148617
+ const match$2 = findBlockByIdStrict(index2, {
148618
+ kind: "block",
148619
+ nodeType: expectedNodeType,
148620
+ nodeId
148621
+ });
148622
+ return {
148623
+ kind: "block",
148624
+ nodeType: match$2.nodeType,
148625
+ nodeId: match$2.nodeId
148626
+ };
148627
+ }
148617
148628
  const match$1 = findBlockByNodeIdOnly(index2, nodeId);
148618
148629
  return {
148619
148630
  kind: "block",
@@ -148621,28 +148632,6 @@ function resolveWithinNodeType(index2, nodeId) {
148621
148632
  nodeId: match$1.nodeId
148622
148633
  };
148623
148634
  }
148624
- function toSDAddress(address2) {
148625
- if (address2.kind === "block")
148626
- return {
148627
- kind: "content",
148628
- stability: "stable",
148629
- nodeId: address2.nodeId
148630
- };
148631
- return {
148632
- kind: "inline",
148633
- stability: "ephemeral",
148634
- anchor: {
148635
- start: {
148636
- blockId: address2.anchor.start.blockId,
148637
- offset: address2.anchor.start.offset
148638
- },
148639
- end: {
148640
- blockId: address2.anchor.end.blockId,
148641
- offset: address2.anchor.end.offset
148642
- }
148643
- }
148644
- };
148645
- }
148646
148635
  function projectMatchToSDNodeResult(editor, address2, blockIndex) {
148647
148636
  if (address2.kind === "block") {
148648
148637
  const candidate = blockIndex.byId.get(`${address2.nodeType}:${address2.nodeId}`);
@@ -148652,12 +148641,12 @@ function projectMatchToSDNodeResult(editor, address2, blockIndex) {
148652
148641
  return null;
148653
148642
  return {
148654
148643
  node: projectContentNode(found2.node),
148655
- address: toSDAddress(address2)
148644
+ address: address2
148656
148645
  };
148657
148646
  }
148658
148647
  return {
148659
148648
  node: projectContentNode(candidate.node),
148660
- address: toSDAddress(address2)
148649
+ address: address2
148661
148650
  };
148662
148651
  }
148663
148652
  const inlineCandidate = findInlineByAnchor(getInlineIndex(editor), address2);
@@ -148665,13 +148654,13 @@ function projectMatchToSDNodeResult(editor, address2, blockIndex) {
148665
148654
  if (inlineCandidate.node)
148666
148655
  return {
148667
148656
  node: projectInlineNode(inlineCandidate.node),
148668
- address: toSDAddress(address2)
148657
+ address: address2
148669
148658
  };
148670
148659
  const markProjected = projectMarkBasedInline(editor, inlineCandidate);
148671
148660
  if (markProjected)
148672
148661
  return {
148673
148662
  node: markProjected,
148674
- address: toSDAddress(address2)
148663
+ address: address2
148675
148664
  };
148676
148665
  }
148677
148666
  return {
@@ -148679,15 +148668,15 @@ function projectMatchToSDNodeResult(editor, address2, blockIndex) {
148679
148668
  kind: "run",
148680
148669
  run: { text: resolveTextByBlockId(editor, address2.anchor) }
148681
148670
  },
148682
- address: toSDAddress(address2)
148671
+ address: address2
148683
148672
  };
148684
148673
  }
148685
148674
  function sdFindAdapter(editor, input2) {
148686
148675
  const query2 = translateToInternalQuery(input2);
148687
148676
  const index2 = getBlockIndex(editor);
148688
148677
  if (input2.within) {
148689
- const { nodeId } = validateWithinAddress(input2.within);
148690
- query2.within = resolveWithinNodeType(index2, nodeId);
148678
+ const { nodeId, nodeType } = validateWithinAddress(input2.within);
148679
+ query2.within = resolveWithinAddress(index2, nodeId, nodeType);
148691
148680
  }
148692
148681
  const diagnostics = [];
148693
148682
  const isInlineSelector = query2.select.type !== "text" && isInlineQuery(query2.select);
@@ -148712,41 +148701,29 @@ function findBlocksByTypeAndId(blockIndex, nodeType, nodeId) {
148712
148701
  return [byIdMatch];
148713
148702
  return blockIndex.candidates.filter((candidate) => candidate.nodeType === nodeType && candidate.nodeId === nodeId);
148714
148703
  }
148715
- function buildBlockAddress(nodeId) {
148716
- return {
148717
- kind: "content",
148718
- stability: "stable",
148719
- nodeId
148720
- };
148721
- }
148722
148704
  function buildInlineAddress(address2) {
148723
- return {
148724
- kind: "inline",
148725
- stability: "ephemeral",
148726
- anchor: {
148727
- start: {
148728
- blockId: address2.anchor.start.blockId,
148729
- offset: address2.anchor.start.offset
148730
- },
148731
- end: {
148732
- blockId: address2.anchor.end.blockId,
148733
- offset: address2.anchor.end.offset
148734
- }
148735
- }
148736
- };
148705
+ return address2;
148737
148706
  }
148738
148707
  function getNodeAdapter(editor, address2) {
148739
148708
  const blockIndex = getBlockIndex(editor);
148740
148709
  if (address2.kind === "block") {
148741
148710
  const matches2 = findBlocksByTypeAndId(blockIndex, address2.nodeType, address2.nodeId);
148742
- if (matches2.length === 0)
148743
- throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Node "${address2.nodeType}" not found for id "${address2.nodeId}".`);
148744
148711
  if (matches2.length > 1)
148745
148712
  throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Multiple nodes share ${address2.nodeType} id "${address2.nodeId}".`);
148746
- const candidate$1 = matches2[0];
148713
+ let candidate$1 = matches2[0];
148714
+ if (!candidate$1)
148715
+ try {
148716
+ candidate$1 = findBlockByNodeIdOnly(blockIndex, address2.nodeId);
148717
+ } catch {}
148718
+ if (!candidate$1)
148719
+ throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Node "${address2.nodeType}" not found for id "${address2.nodeId}".`);
148747
148720
  return {
148748
148721
  node: projectContentNode(candidate$1.node),
148749
- address: buildBlockAddress(address2.nodeId)
148722
+ address: {
148723
+ kind: "block",
148724
+ nodeType: candidate$1.nodeType,
148725
+ nodeId: candidate$1.nodeId
148726
+ }
148750
148727
  };
148751
148728
  }
148752
148729
  const candidate = findInlineByAnchor(getInlineIndex(editor), address2);
@@ -148796,10 +148773,14 @@ function resolveBlockById(editor, nodeId, nodeType) {
148796
148773
  }
148797
148774
  function getNodeByIdAdapter(editor, input2) {
148798
148775
  const { nodeId, nodeType } = input2;
148799
- const { candidate } = resolveBlockById(editor, nodeId, nodeType);
148776
+ const { candidate, resolvedType } = resolveBlockById(editor, nodeId, nodeType);
148800
148777
  return {
148801
148778
  node: projectContentNode(candidate.node),
148802
- address: buildBlockAddress(nodeId)
148779
+ address: {
148780
+ kind: "block",
148781
+ nodeType: resolvedType,
148782
+ nodeId: candidate.nodeId
148783
+ }
148803
148784
  };
148804
148785
  }
148805
148786
  function getTextAdapter(editor, _input) {
@@ -152028,36 +152009,52 @@ function buildMarksFromLegacyRun(schema, run2) {
152028
152009
  marks.push(schema.marks.highlight.create({ color: run2.highlight }));
152029
152010
  return marks;
152030
152011
  }
152031
- function resolveInsertTarget(editor, target) {
152032
- if (!target)
152033
- return resolveDocumentEndTarget(editor);
152034
- const index2 = getBlockIndex(editor);
152035
- let candidate;
152012
+ function findBlockByTarget(index2, target, operationName) {
152013
+ const nodeId = target.kind === "block" ? target.nodeId : target.blockId;
152036
152014
  try {
152037
- candidate = findBlockByNodeIdOnly(index2, target.blockId);
152015
+ if (target.kind === "block") {
152016
+ const typed = findBlockById(index2, target);
152017
+ if (typed)
152018
+ return typed;
152019
+ return findBlockByNodeIdOnly(index2, nodeId);
152020
+ }
152021
+ return findBlockByNodeIdOnly(index2, nodeId);
152038
152022
  } catch {
152039
- throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Cannot resolve insert target for block "${target.blockId}".`);
152023
+ throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Cannot resolve ${operationName} target for block "${nodeId}".`);
152040
152024
  }
152025
+ }
152026
+ function resolveInsertTarget(editor, target) {
152027
+ if (!target)
152028
+ return resolveDocumentEndTarget(editor);
152029
+ const candidate = findBlockByTarget(getBlockIndex(editor), target, "insert");
152041
152030
  return {
152042
152031
  insertPos: candidate.end,
152043
152032
  structuralEnd: false,
152044
- effectiveTarget: target,
152033
+ effectiveTarget: target.kind === "block" ? {
152034
+ kind: "text",
152035
+ blockId: target.nodeId,
152036
+ range: {
152037
+ start: 0,
152038
+ end: 0
152039
+ }
152040
+ } : target,
152045
152041
  targetNode: candidate.node,
152046
152042
  targetNodePos: candidate.pos
152047
152043
  };
152048
152044
  }
152049
152045
  function resolveReplaceTarget(editor, target) {
152050
- const index2 = getBlockIndex(editor);
152051
- let candidate;
152052
- try {
152053
- candidate = findBlockByNodeIdOnly(index2, target.blockId);
152054
- } catch {
152055
- throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Cannot resolve replace target for block "${target.blockId}".`);
152056
- }
152046
+ const candidate = findBlockByTarget(getBlockIndex(editor), target, "replace");
152057
152047
  return {
152058
152048
  from: candidate.pos,
152059
152049
  to: candidate.end,
152060
- effectiveTarget: target
152050
+ effectiveTarget: target.kind === "block" ? {
152051
+ kind: "text",
152052
+ blockId: target.nodeId,
152053
+ range: {
152054
+ start: 0,
152055
+ end: 0
152056
+ }
152057
+ } : target
152061
152058
  };
152062
152059
  }
152063
152060
  function resolveDocumentEndTarget(editor) {
@@ -152298,17 +152295,16 @@ function ensureTableSeparators(jsonNodes) {
152298
152295
  if (jsonNodes[i$1].type === "table" && jsonNodes[i$1 + 1].type === "table")
152299
152296
  jsonNodes.splice(i$1 + 1, 0, { type: "paragraph" });
152300
152297
  }
152301
- function narrowToTextAddress(target) {
152298
+ function targetBlockId$1(target) {
152299
+ return target.kind === "block" ? target.nodeId : target.blockId;
152300
+ }
152301
+ function toTextAddress$1(target) {
152302
152302
  if (target.kind === "text")
152303
152303
  return target;
152304
- const sd = target;
152305
152304
  return {
152306
152305
  kind: "text",
152307
- blockId: sd.nodeId ?? "",
152308
- range: sd.anchor ? {
152309
- start: sd.anchor.start.offset,
152310
- end: sd.anchor.end.offset
152311
- } : {
152306
+ blockId: target.nodeId,
152307
+ range: {
152312
152308
  start: 0,
152313
152309
  end: 0
152314
152310
  }
@@ -152649,6 +152645,8 @@ function buildSelectionResolutionFromOutcome(stepOutcome, compiled, stepId) {
152649
152645
  return buildSelectionResolutionFromCompiled(compiled, stepId);
152650
152646
  }
152651
152647
  function insertStructuredWrapper(editor, input2, options) {
152648
+ if (isStructuralInsertInput2(input2) && input2.target)
152649
+ return executeStructuralInsertDirect(editor, input2, options);
152652
152650
  return textReceiptToSDReceipt2(insertStructuredInner(editor, input2, options));
152653
152651
  }
152654
152652
  function insertStructuredInner(editor, input2, options) {
@@ -152837,14 +152835,13 @@ function insertStructuredInner(editor, input2, options) {
152837
152835
  function executeStructuralInsertWrapper(editor, input2, options) {
152838
152836
  const { content: content3, target, placement: placement2, nestingPolicy } = input2;
152839
152837
  const mode = options?.changeMode ?? "direct";
152840
- const textTarget = target ? narrowToTextAddress(target) : undefined;
152841
152838
  let resolved;
152842
152839
  try {
152843
- resolved = resolveInsertTarget(editor, textTarget);
152840
+ resolved = resolveInsertTarget(editor, target);
152844
152841
  } catch (err) {
152845
152842
  if (err instanceof DocumentApiAdapterError)
152846
152843
  throw err;
152847
- throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Cannot resolve insert target${textTarget ? ` for block "${textTarget.blockId}"` : ""}.`);
152844
+ throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Cannot resolve insert target${target ? ` for block "${target.nodeId}"` : ""}.`);
152848
152845
  }
152849
152846
  const effectiveTarget = resolved.effectiveTarget ?? {
152850
152847
  kind: "text",
@@ -152860,7 +152857,6 @@ function executeStructuralInsertWrapper(editor, input2, options) {
152860
152857
  else
152861
152858
  insertPos = resolved.insertPos;
152862
152859
  const resolution = buildTextMutationResolution({
152863
- requestedTarget: textTarget,
152864
152860
  target: effectiveTarget,
152865
152861
  range: {
152866
152862
  from: insertPos,
@@ -152871,7 +152867,7 @@ function executeStructuralInsertWrapper(editor, input2, options) {
152871
152867
  try {
152872
152868
  if (options?.dryRun) {
152873
152869
  executeStructuralInsert(editor, {
152874
- target: textTarget,
152870
+ target,
152875
152871
  content: content3,
152876
152872
  placement: placement2,
152877
152873
  nestingPolicy,
@@ -152885,7 +152881,7 @@ function executeStructuralInsertWrapper(editor, input2, options) {
152885
152881
  }
152886
152882
  if (!(executeDomainCommand(editor, () => {
152887
152883
  return executeStructuralInsert(editor, {
152888
- target: textTarget,
152884
+ target,
152889
152885
  content: content3,
152890
152886
  placement: placement2,
152891
152887
  nestingPolicy,
@@ -152920,10 +152916,78 @@ function executeStructuralInsertWrapper(editor, input2, options) {
152920
152916
  };
152921
152917
  }
152922
152918
  }
152919
+ function executeStructuralInsertDirect(editor, input2, options) {
152920
+ const { content: content3, target, placement: placement2, nestingPolicy } = input2;
152921
+ const mode = options?.changeMode ?? "direct";
152922
+ let resolved;
152923
+ try {
152924
+ resolved = resolveInsertTarget(editor, target);
152925
+ } catch (err) {
152926
+ if (err instanceof DocumentApiAdapterError)
152927
+ throw err;
152928
+ throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Cannot resolve insert target for block "${target.nodeId}".`);
152929
+ }
152930
+ let insertPos;
152931
+ if (resolved.targetNode && resolved.targetNodePos !== undefined)
152932
+ insertPos = resolvePlacement(editor.state.doc, resolved.targetNodePos, resolved.targetNode, placement2);
152933
+ else
152934
+ insertPos = resolved.insertPos;
152935
+ const receiptParams = {
152936
+ target,
152937
+ range: {
152938
+ from: insertPos,
152939
+ to: insertPos
152940
+ }
152941
+ };
152942
+ try {
152943
+ if (options?.dryRun) {
152944
+ executeStructuralInsert(editor, {
152945
+ target,
152946
+ content: content3,
152947
+ placement: placement2,
152948
+ nestingPolicy,
152949
+ changeMode: mode,
152950
+ dryRun: true
152951
+ });
152952
+ return buildStructuralReceipt2(true, receiptParams);
152953
+ }
152954
+ if (executeDomainCommand(editor, () => {
152955
+ return executeStructuralInsert(editor, {
152956
+ target,
152957
+ content: content3,
152958
+ placement: placement2,
152959
+ nestingPolicy,
152960
+ changeMode: mode
152961
+ }).success;
152962
+ }, {
152963
+ expectedRevision: options?.expectedRevision,
152964
+ changeMode: mode
152965
+ }).steps[0]?.effect !== "changed")
152966
+ return buildStructuralReceipt2(false, receiptParams, {
152967
+ code: "INVALID_TARGET",
152968
+ message: "Structural insert failed."
152969
+ });
152970
+ return buildStructuralReceipt2(true, receiptParams);
152971
+ } catch (err) {
152972
+ if (err instanceof DocumentApiAdapterError)
152973
+ throw err;
152974
+ return buildStructuralReceipt2(false, receiptParams, {
152975
+ code: "INVALID_TARGET",
152976
+ message: `Structural insert failed: ${err instanceof Error ? err.message : String(err)}`
152977
+ });
152978
+ }
152979
+ }
152923
152980
  function replaceStructuredWrapper(editor, input2, options) {
152924
152981
  if (!isStructuralReplaceInput2(input2))
152925
152982
  throw new DocumentApiAdapterError("INVALID_INPUT", 'replaceStructured requires structural content input with a "content" field.');
152926
- return textReceiptToSDReceipt2(executeStructuralReplaceWrapper(editor, input2, options));
152983
+ const blockTarget = input2.target && "kind" in input2.target && input2.target.kind === "block" ? input2.target : undefined;
152984
+ const textReceipt = executeStructuralReplaceWrapper(editor, input2, options);
152985
+ if (!blockTarget)
152986
+ return textReceiptToSDReceipt2(textReceipt);
152987
+ const sdReceipt = textReceiptToSDReceipt2(textReceipt);
152988
+ if (sdReceipt.resolution)
152989
+ sdReceipt.resolution.target = blockTarget;
152990
+ return sdReceipt;
152927
152991
  }
152928
152992
  function resolveStructuralLocator(editor, input2) {
152929
152993
  const { target, ref: ref$1 } = input2;
@@ -152952,7 +153016,7 @@ function resolveStructuralLocator(editor, input2) {
152952
153016
  effectiveSelectionTarget: buildEffectiveSelectionTarget(expanded)
152953
153017
  };
152954
153018
  }
152955
- return { textTarget: narrowToTextAddress(target) };
153019
+ return { textTarget: target };
152956
153020
  }
152957
153021
  if (ref$1 !== undefined) {
152958
153022
  if (ref$1.startsWith("text:"))
@@ -153122,7 +153186,7 @@ function executeStructuralReplaceWrapper(editor, input2, options) {
153122
153186
  } catch (err) {
153123
153187
  if (err instanceof DocumentApiAdapterError)
153124
153188
  throw err;
153125
- throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Cannot resolve replace target for block "${textTarget.blockId}".`);
153189
+ throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Cannot resolve replace target for block "${targetBlockId$1(textTarget)}".`);
153126
153190
  }
153127
153191
  effectiveRange = {
153128
153192
  from: resolvedBlock.from,
@@ -153131,13 +153195,13 @@ function executeStructuralReplaceWrapper(editor, input2, options) {
153131
153195
  }
153132
153196
  const coveredText = editor.state.doc.textBetween(effectiveRange.from, effectiveRange.to, `
153133
153197
  `, "");
153198
+ const textAddr = toTextAddress$1(textTarget);
153134
153199
  let resolution;
153135
153200
  if (effectiveSelectionTarget)
153136
153201
  resolution = selectionTargetToResolution(effectiveSelectionTarget, effectiveRange, coveredText);
153137
153202
  else
153138
153203
  resolution = buildTextMutationResolution({
153139
- requestedTarget: isRefBased ? undefined : textTarget,
153140
- target: textTarget,
153204
+ target: textAddr,
153141
153205
  range: effectiveRange,
153142
153206
  text: coveredText
153143
153207
  });
@@ -215721,6 +215785,7 @@ var Node$13 = class Node$14 {
215721
215785
  #footerRegions = /* @__PURE__ */ new Map;
215722
215786
  #session = { mode: "body" };
215723
215787
  #activeEditor = null;
215788
+ #activeEditorEventCleanup = null;
215724
215789
  #hoverOverlay = null;
215725
215790
  #hoverTooltip = null;
215726
215791
  #modeBanner = null;
@@ -215838,6 +215903,7 @@ var Node$13 = class Node$14 {
215838
215903
  resetSession: () => {
215839
215904
  this.#managerCleanups = [];
215840
215905
  this.#session = { mode: "body" };
215906
+ this.#teardownActiveEditorEventBridge();
215841
215907
  this.#activeEditor = null;
215842
215908
  this.#deps?.notifyInputBridgeTargetChanged();
215843
215909
  },
@@ -215992,6 +216058,7 @@ var Node$13 = class Node$14 {
215992
216058
  this.#activeEditor.setEditable(false);
215993
216059
  this.#activeEditor.setOptions({ documentMode: "viewing" });
215994
216060
  }
216061
+ this.#teardownActiveEditorEventBridge();
215995
216062
  this.#overlayManager?.hideEditingOverlay();
215996
216063
  this.#overlayManager?.showSelectionOverlay();
215997
216064
  this.#activeEditor = null;
@@ -216025,6 +216092,7 @@ var Node$13 = class Node$14 {
216025
216092
  this.#activeEditor.setEditable(false);
216026
216093
  this.#activeEditor.setOptions({ documentMode: "viewing" });
216027
216094
  }
216095
+ this.#teardownActiveEditorEventBridge();
216028
216096
  this.#overlayManager.hideEditingOverlay();
216029
216097
  this.#activeEditor = null;
216030
216098
  this.#session = { mode: "body" };
@@ -216152,6 +216220,7 @@ var Node$13 = class Node$14 {
216152
216220
  }
216153
216221
  this.#overlayManager.hideSelectionOverlay();
216154
216222
  this.#activeEditor = editor;
216223
+ this.#setupActiveEditorEventBridge(editor);
216155
216224
  this.#session = {
216156
216225
  mode: region.kind,
216157
216226
  kind: region.kind,
@@ -216175,6 +216244,7 @@ var Node$13 = class Node$14 {
216175
216244
  this.#overlayManager?.hideEditingOverlay();
216176
216245
  this.#overlayManager?.showSelectionOverlay();
216177
216246
  this.clearHover();
216247
+ this.#teardownActiveEditorEventBridge();
216178
216248
  this.#activeEditor = null;
216179
216249
  this.#session = { mode: "body" };
216180
216250
  } catch (cleanupError) {
@@ -216234,6 +216304,46 @@ var Node$13 = class Node$14 {
216234
216304
  const message = this.#session.mode === "body" ? "Exited header/footer edit mode." : `Editing ${this.#session.kind === "header" ? "Header" : "Footer"} (${this.#session.sectionType ?? "default"})`;
216235
216305
  this.#callbacks.onAnnounce?.(message);
216236
216306
  }
216307
+ #setupActiveEditorEventBridge(editor) {
216308
+ this.#teardownActiveEditorEventBridge();
216309
+ const emitSurfaceUpdate = () => {
216310
+ if (this.#session.mode !== "header" && this.#session.mode !== "footer")
216311
+ return;
216312
+ this.#callbacks.onSurfaceUpdate?.({
216313
+ sourceEditor: editor,
216314
+ surface: this.#session.mode,
216315
+ headerId: this.#session.headerId ?? null,
216316
+ sectionType: this.#session.sectionType ?? null
216317
+ });
216318
+ };
216319
+ const emitSurfaceTransaction = ({ transaction, duration }) => {
216320
+ if (this.#session.mode !== "header" && this.#session.mode !== "footer")
216321
+ return;
216322
+ this.#callbacks.onSurfaceTransaction?.({
216323
+ sourceEditor: editor,
216324
+ surface: this.#session.mode,
216325
+ headerId: this.#session.headerId ?? null,
216326
+ sectionType: this.#session.sectionType ?? null,
216327
+ transaction,
216328
+ duration
216329
+ });
216330
+ };
216331
+ editor.on("update", emitSurfaceUpdate);
216332
+ editor.on("transaction", emitSurfaceTransaction);
216333
+ this.#activeEditorEventCleanup = () => {
216334
+ editor.off?.("update", emitSurfaceUpdate);
216335
+ editor.off?.("transaction", emitSurfaceTransaction);
216336
+ };
216337
+ }
216338
+ #teardownActiveEditorEventBridge() {
216339
+ try {
216340
+ this.#activeEditorEventCleanup?.();
216341
+ } catch (error) {
216342
+ console.warn("[HeaderFooterSessionManager] Failed to clean up active editor bridge:", error);
216343
+ } finally {
216344
+ this.#activeEditorEventCleanup = null;
216345
+ }
216346
+ }
216237
216347
  #updateModeBanner() {
216238
216348
  if (!this.#modeBanner)
216239
216349
  return;
@@ -216650,6 +216760,7 @@ var Node$13 = class Node$14 {
216650
216760
  return pages[0];
216651
216761
  }
216652
216762
  destroy() {
216763
+ this.#teardownActiveEditorEventBridge();
216653
216764
  this.#managerCleanups.forEach((fn) => {
216654
216765
  try {
216655
216766
  fn();
@@ -221809,16 +221920,16 @@ var Node$13 = class Node$14 {
221809
221920
  return false;
221810
221921
  return Boolean(checker(attrs));
221811
221922
  }, SuperToolbar, ICONS, TEXTS, tableActionsOptions;
221812
- var init_src_DvnhdISL_es = __esm(() => {
221923
+ var init_src_D_53T9_x_es = __esm(() => {
221813
221924
  init_rolldown_runtime_B2q5OVn9_es();
221814
- init_SuperConverter_BParsWaS_es();
221925
+ init_SuperConverter_voJQZ_PC_es();
221815
221926
  init_jszip_ChlR43oI_es();
221816
221927
  init_uuid_qzgm05fK_es();
221817
221928
  init_constants_CMPtQbp7_es();
221818
221929
  init_unified_BRHLwnjP_es();
221819
221930
  init_remark_gfm_z_sDF4ss_es();
221820
221931
  init_remark_stringify_D8vxv_XI_es();
221821
- init_DocxZipper__tW4mTs0_es();
221932
+ init_DocxZipper_BmRnFofk_es();
221822
221933
  init_vue_DQHWm9lq_es();
221823
221934
  init__plugin_vue_export_helper_HmhZBO0u_es();
221824
221935
  init_eventemitter3_DGBTyUUP_es();
@@ -231442,7 +231553,7 @@ function print() { __p += __j.call(arguments, '') }
231442
231553
  resolvedOptions.isNewFile = explicitIsNewFile ?? false;
231443
231554
  this.#sourcePath = null;
231444
231555
  }
231445
- } else if (resolvedMode === "docx" && !options?.content && !options?.html && !options?.markdown && !options?.json) {
231556
+ } else if (resolvedMode === "docx" && !options?.content && !options?.html && !options?.markdown) {
231446
231557
  const arrayBuffer = await getArrayBufferFromUrl(BLANK_DOCX_DATA_URI);
231447
231558
  const canUseBuffer = typeof process$1$1 !== "undefined" && !!process$1$1.versions?.node && typeof Buffer3 !== "undefined";
231448
231559
  const uint8Array = new Uint8Array(arrayBuffer);
@@ -231455,8 +231566,14 @@ function print() { __p += __j.call(arguments, '') }
231455
231566
  throw new Error("Blob is not available to create blank DOCX");
231456
231567
  const [docx, _media, mediaFiles, fonts] = await Editor2.loadXmlData(fileSource, canUseBuffer);
231457
231568
  resolvedOptions.content = docx;
231458
- resolvedOptions.mediaFiles = mediaFiles;
231459
- resolvedOptions.fonts = fonts;
231569
+ resolvedOptions.mediaFiles = {
231570
+ ...mediaFiles,
231571
+ ...options?.mediaFiles ?? {}
231572
+ };
231573
+ resolvedOptions.fonts = {
231574
+ ...fonts,
231575
+ ...options?.fonts ?? {}
231576
+ };
231460
231577
  resolvedOptions.fileSource = fileSource;
231461
231578
  resolvedOptions.isNewFile = explicitIsNewFile ?? true;
231462
231579
  this.#sourcePath = null;
@@ -232513,7 +232630,7 @@ function print() { __p += __j.call(arguments, '') }
232513
232630
  }
232514
232631
  const zipper = new DocxZipper_default;
232515
232632
  if (getUpdatedDocs) {
232516
- updatedDocs["[Content_Types].xml"] = await zipper.updateContentTypes({ files: this.options.content }, media2, true, updatedDocs);
232633
+ updatedDocs["[Content_Types].xml"] = await zipper.updateContentTypes({ files: this.options.content }, media2, true, updatedDocs, this.options.fonts);
232517
232634
  const content3 = this.options.content;
232518
232635
  const { contentTypesXml, relsXml } = syncPackageMetadata({
232519
232636
  baseFiles: Array.isArray(content3) || content3 && typeof content3 === "object" ? content3 : null,
@@ -242344,6 +242461,26 @@ function print() { __p += __j.call(arguments, '') }
242344
242461
  },
242345
242462
  onUpdateAwarenessSession: () => {
242346
242463
  this.#updateAwarenessSession();
242464
+ },
242465
+ onSurfaceUpdate: ({ sourceEditor, surface, headerId, sectionType }) => {
242466
+ this.emit("headerFooterUpdate", {
242467
+ editor: this.#editor,
242468
+ sourceEditor,
242469
+ surface,
242470
+ headerId,
242471
+ sectionType
242472
+ });
242473
+ },
242474
+ onSurfaceTransaction: ({ sourceEditor, surface, headerId, sectionType, transaction, duration }) => {
242475
+ this.emit("headerFooterTransaction", {
242476
+ editor: this.#editor,
242477
+ sourceEditor,
242478
+ surface,
242479
+ headerId,
242480
+ sectionType,
242481
+ transaction,
242482
+ duration
242483
+ });
242347
242484
  }
242348
242485
  });
242349
242486
  this.#headerFooterSession.initialize();
@@ -255633,13 +255770,13 @@ var init_zipper_DqXT7uTa_es = __esm(() => {
255633
255770
 
255634
255771
  // ../../packages/superdoc/dist/super-editor.es.js
255635
255772
  var init_super_editor_es = __esm(() => {
255636
- init_src_DvnhdISL_es();
255637
- init_SuperConverter_BParsWaS_es();
255773
+ init_src_D_53T9_x_es();
255774
+ init_SuperConverter_voJQZ_PC_es();
255638
255775
  init_jszip_ChlR43oI_es();
255639
255776
  init_xml_js_DLE8mr0n_es();
255640
255777
  init_constants_CMPtQbp7_es();
255641
255778
  init_unified_BRHLwnjP_es();
255642
- init_DocxZipper__tW4mTs0_es();
255779
+ init_DocxZipper_BmRnFofk_es();
255643
255780
  init_vue_DQHWm9lq_es();
255644
255781
  init_eventemitter3_DGBTyUUP_es();
255645
255782
  init_zipper_DqXT7uTa_es();
@@ -257104,11 +257241,6 @@ function assertUnambiguous2(matches2, blockId) {
257104
257241
  });
257105
257242
  }
257106
257243
  }
257107
- function findInlineWithinTextBlock2(index2, blockId) {
257108
- const matches2 = findTextBlockCandidates2(index2, blockId);
257109
- assertUnambiguous2(matches2, blockId);
257110
- return matches2[0];
257111
- }
257112
257244
  function resolveTextTarget2(editor, target) {
257113
257245
  const index2 = getBlockIndex2(editor);
257114
257246
  const matches2 = findTextBlockCandidates2(index2, target.blockId);
@@ -257275,32 +257407,17 @@ function dedupeDiagnostics2(diagnostics) {
257275
257407
  function resolveWithinScope2(index2, query2, diagnostics) {
257276
257408
  if (!query2.within)
257277
257409
  return { ok: true, range: undefined };
257278
- if (query2.within.kind === "block") {
257279
- const within2 = findBlockById2(index2, query2.within);
257280
- if (!within2) {
257281
- addDiagnostic3(diagnostics, `Within block "${query2.within.nodeType}" with id "${query2.within.nodeId}" was not found in the document.`);
257282
- return { ok: false };
257283
- }
257284
- return { ok: true, range: { start: within2.pos, end: within2.end } };
257285
- }
257286
- if (query2.within.anchor.start.blockId !== query2.within.anchor.end.blockId) {
257287
- addDiagnostic3(diagnostics, "Inline within anchors that span multiple blocks are not supported.");
257288
- return { ok: false };
257410
+ let within2 = findBlockById2(index2, query2.within);
257411
+ if (!within2 && query2.within.kind === "block") {
257412
+ try {
257413
+ within2 = findBlockByNodeIdOnly2(index2, query2.within.nodeId);
257414
+ } catch {}
257289
257415
  }
257290
- const block = findInlineWithinTextBlock2(index2, query2.within.anchor.start.blockId);
257291
- if (!block) {
257292
- addDiagnostic3(diagnostics, `Within inline anchor block "${query2.within.anchor.start.blockId}" was not found in the document.`);
257416
+ if (!within2) {
257417
+ addDiagnostic3(diagnostics, `Within block "${query2.within.nodeType}" with id "${query2.within.nodeId}" was not found in the document.`);
257293
257418
  return { ok: false };
257294
257419
  }
257295
- const resolved = resolveTextRangeInBlock2(block.node, block.pos, {
257296
- start: query2.within.anchor.start.offset,
257297
- end: query2.within.anchor.end.offset
257298
- });
257299
- if (!resolved) {
257300
- addDiagnostic3(diagnostics, "Inline within anchor offsets could not be resolved in the target block.");
257301
- return { ok: false };
257302
- }
257303
- return { ok: true, range: { start: resolved.from, end: resolved.to } };
257420
+ return { ok: true, range: { start: within2.pos, end: within2.end } };
257304
257421
  }
257305
257422
  function scopeByRange2(candidates, range) {
257306
257423
  if (!range)
@@ -266562,62 +266679,38 @@ function translateToInternalQuery2(input2) {
266562
266679
  const { select: select2, within: within2, limit, offset: offset2 } = input2;
266563
266680
  if (within2)
266564
266681
  validateWithinAddress2(within2);
266565
- if (select2.type === "text") {
266566
- return {
266567
- select: {
266568
- type: "text",
266569
- pattern: select2.pattern,
266570
- ...select2.mode != null && { mode: select2.mode },
266571
- ...select2.caseSensitive != null && { caseSensitive: select2.caseSensitive }
266572
- },
266573
- limit,
266574
- offset: offset2,
266575
- includeNodes: true
266576
- };
266682
+ if (select2.type === "node") {
266683
+ const raw = select2;
266684
+ if ("nodeKind" in raw && raw.nodeKind != null) {
266685
+ throw new DocumentApiAdapterError3("INVALID_INPUT", `"nodeKind" is no longer supported on node selectors. Use "nodeType" instead: ` + `{ type: 'node', nodeType: '${String(raw.nodeKind)}' }.`, { field: "select.nodeKind", value: raw.nodeKind });
266686
+ }
266687
+ if (raw.kind === "content") {
266688
+ throw new DocumentApiAdapterError3("INVALID_INPUT", `kind: 'content' is no longer supported on node selectors. Use kind: 'block' instead.`, { field: "select.kind", value: raw.kind });
266689
+ }
266577
266690
  }
266578
- const nodeSelect = {
266579
- type: "node",
266580
- ...select2.nodeKind != null && { nodeType: select2.nodeKind },
266581
- ...select2.kind === "content" && { kind: "block" },
266582
- ...select2.kind === "inline" && { kind: "inline" }
266583
- };
266584
266691
  return {
266585
- select: nodeSelect,
266692
+ select: select2,
266586
266693
  limit,
266587
266694
  offset: offset2,
266588
266695
  includeNodes: true
266589
266696
  };
266590
266697
  }
266591
- function validateWithinAddress2(sdAddress) {
266592
- if (sdAddress.kind === "content" && sdAddress.nodeId) {
266593
- return { nodeId: sdAddress.nodeId };
266698
+ function validateWithinAddress2(address2) {
266699
+ if (address2.kind === "block" && "nodeId" in address2 && typeof address2.nodeId === "string") {
266700
+ return { nodeId: address2.nodeId, nodeType: address2.nodeType };
266594
266701
  }
266595
- throw new DocumentApiAdapterError3("INVALID_TARGET", `"within" scope requires a content-kind SDAddress with a nodeId. Got kind="${sdAddress.kind}".`, { field: "within", value: sdAddress });
266596
- }
266597
- function resolveWithinNodeType2(index2, nodeId) {
266598
- const match2 = findBlockByNodeIdOnly2(index2, nodeId);
266599
- return {
266600
- kind: "block",
266601
- nodeType: match2.nodeType,
266602
- nodeId: match2.nodeId
266603
- };
266702
+ throw new DocumentApiAdapterError3("INVALID_TARGET", '"within" scope requires a BlockNodeAddress with a nodeId.', {
266703
+ field: "within",
266704
+ value: address2
266705
+ });
266604
266706
  }
266605
- function toSDAddress2(address2) {
266606
- if (address2.kind === "block") {
266607
- return {
266608
- kind: "content",
266609
- stability: "stable",
266610
- nodeId: address2.nodeId
266611
- };
266707
+ function resolveWithinAddress2(index2, nodeId, expectedNodeType) {
266708
+ if (expectedNodeType) {
266709
+ const match3 = findBlockByIdStrict2(index2, { kind: "block", nodeType: expectedNodeType, nodeId });
266710
+ return { kind: "block", nodeType: match3.nodeType, nodeId: match3.nodeId };
266612
266711
  }
266613
- return {
266614
- kind: "inline",
266615
- stability: "ephemeral",
266616
- anchor: {
266617
- start: { blockId: address2.anchor.start.blockId, offset: address2.anchor.start.offset },
266618
- end: { blockId: address2.anchor.end.blockId, offset: address2.anchor.end.offset }
266619
- }
266620
- };
266712
+ const match2 = findBlockByNodeIdOnly2(index2, nodeId);
266713
+ return { kind: "block", nodeType: match2.nodeType, nodeId: match2.nodeId };
266621
266714
  }
266622
266715
  function projectMatchToSDNodeResult2(editor, address2, blockIndex) {
266623
266716
  if (address2.kind === "block") {
@@ -266628,12 +266721,12 @@ function projectMatchToSDNodeResult2(editor, address2, blockIndex) {
266628
266721
  return null;
266629
266722
  return {
266630
266723
  node: projectContentNode2(found3.node),
266631
- address: toSDAddress2(address2)
266724
+ address: address2
266632
266725
  };
266633
266726
  }
266634
266727
  return {
266635
266728
  node: projectContentNode2(candidate.node),
266636
- address: toSDAddress2(address2)
266729
+ address: address2
266637
266730
  };
266638
266731
  }
266639
266732
  const inlineIndex = getInlineIndex2(editor);
@@ -266642,26 +266735,26 @@ function projectMatchToSDNodeResult2(editor, address2, blockIndex) {
266642
266735
  if (inlineCandidate.node) {
266643
266736
  return {
266644
266737
  node: projectInlineNode2(inlineCandidate.node),
266645
- address: toSDAddress2(address2)
266738
+ address: address2
266646
266739
  };
266647
266740
  }
266648
266741
  const markProjected = projectMarkBasedInline2(editor, inlineCandidate);
266649
266742
  if (markProjected) {
266650
- return { node: markProjected, address: toSDAddress2(address2) };
266743
+ return { node: markProjected, address: address2 };
266651
266744
  }
266652
266745
  }
266653
266746
  const resolvedText = resolveTextByBlockId2(editor, address2.anchor);
266654
266747
  return {
266655
266748
  node: { kind: "run", run: { text: resolvedText } },
266656
- address: toSDAddress2(address2)
266749
+ address: address2
266657
266750
  };
266658
266751
  }
266659
266752
  function sdFindAdapter2(editor, input2) {
266660
266753
  const query2 = translateToInternalQuery2(input2);
266661
266754
  const index2 = getBlockIndex2(editor);
266662
266755
  if (input2.within) {
266663
- const { nodeId } = validateWithinAddress2(input2.within);
266664
- query2.within = resolveWithinNodeType2(index2, nodeId);
266756
+ const { nodeId, nodeType } = validateWithinAddress2(input2.within);
266757
+ query2.within = resolveWithinAddress2(index2, nodeId, nodeType);
266665
266758
  }
266666
266759
  const diagnostics = [];
266667
266760
  const isInlineSelector = query2.select.type !== "text" && isInlineQuery2(query2.select);
@@ -266705,37 +266798,28 @@ function findBlocksByTypeAndId2(blockIndex, nodeType, nodeId) {
266705
266798
  return [byIdMatch];
266706
266799
  return blockIndex.candidates.filter((candidate) => candidate.nodeType === nodeType && candidate.nodeId === nodeId);
266707
266800
  }
266708
- function buildBlockAddress2(nodeId) {
266709
- return {
266710
- kind: "content",
266711
- stability: "stable",
266712
- nodeId
266713
- };
266714
- }
266715
266801
  function buildInlineAddress2(address2) {
266716
- return {
266717
- kind: "inline",
266718
- stability: "ephemeral",
266719
- anchor: {
266720
- start: { blockId: address2.anchor.start.blockId, offset: address2.anchor.start.offset },
266721
- end: { blockId: address2.anchor.end.blockId, offset: address2.anchor.end.offset }
266722
- }
266723
- };
266802
+ return address2;
266724
266803
  }
266725
266804
  function getNodeAdapter2(editor, address2) {
266726
266805
  const blockIndex = getBlockIndex2(editor);
266727
266806
  if (address2.kind === "block") {
266728
266807
  const matches3 = findBlocksByTypeAndId2(blockIndex, address2.nodeType, address2.nodeId);
266729
- if (matches3.length === 0) {
266730
- throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", `Node "${address2.nodeType}" not found for id "${address2.nodeId}".`);
266731
- }
266732
266808
  if (matches3.length > 1) {
266733
266809
  throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", `Multiple nodes share ${address2.nodeType} id "${address2.nodeId}".`);
266734
266810
  }
266735
- const candidate2 = matches3[0];
266811
+ let candidate2 = matches3[0];
266812
+ if (!candidate2) {
266813
+ try {
266814
+ candidate2 = findBlockByNodeIdOnly2(blockIndex, address2.nodeId);
266815
+ } catch {}
266816
+ }
266817
+ if (!candidate2) {
266818
+ throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", `Node "${address2.nodeType}" not found for id "${address2.nodeId}".`);
266819
+ }
266736
266820
  return {
266737
266821
  node: projectContentNode2(candidate2.node),
266738
- address: buildBlockAddress2(address2.nodeId)
266822
+ address: { kind: "block", nodeType: candidate2.nodeType, nodeId: candidate2.nodeId }
266739
266823
  };
266740
266824
  }
266741
266825
  const inlineIndex = getInlineIndex2(editor);
@@ -266783,13 +266867,14 @@ function resolveBlockById2(editor, nodeId, nodeType) {
266783
266867
  }
266784
266868
  function getNodeByIdAdapter2(editor, input2) {
266785
266869
  const { nodeId, nodeType } = input2;
266786
- const { candidate } = resolveBlockById2(editor, nodeId, nodeType);
266870
+ const { candidate, resolvedType } = resolveBlockById2(editor, nodeId, nodeType);
266787
266871
  return {
266788
266872
  node: projectContentNode2(candidate.node),
266789
- address: buildBlockAddress2(nodeId)
266873
+ address: { kind: "block", nodeType: resolvedType, nodeId: candidate.nodeId }
266790
266874
  };
266791
266875
  }
266792
266876
  var init_get_node_adapter = __esm(() => {
266877
+ init_node_address_resolver();
266793
266878
  init_index_cache();
266794
266879
  init_inline_address_resolver();
266795
266880
  init_sd_projection();
@@ -327841,37 +327926,41 @@ var init_node_materializer = __esm(() => {
327841
327926
  });
327842
327927
 
327843
327928
  // ../../packages/super-editor/src/document-api-adapters/structural-write-engine/target-resolver.ts
327929
+ function findBlockByTarget2(index3, target, operationName) {
327930
+ const nodeId = target.kind === "block" ? target.nodeId : target.blockId;
327931
+ try {
327932
+ if (target.kind === "block") {
327933
+ const typed = findBlockById2(index3, target);
327934
+ if (typed)
327935
+ return typed;
327936
+ return findBlockByNodeIdOnly2(index3, nodeId);
327937
+ }
327938
+ return findBlockByNodeIdOnly2(index3, nodeId);
327939
+ } catch {
327940
+ throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", `Cannot resolve ${operationName} target for block "${nodeId}".`);
327941
+ }
327942
+ }
327844
327943
  function resolveInsertTarget2(editor, target) {
327845
327944
  if (!target) {
327846
327945
  return resolveDocumentEndTarget2(editor);
327847
327946
  }
327848
327947
  const index3 = getBlockIndex2(editor);
327849
- let candidate;
327850
- try {
327851
- candidate = findBlockByNodeIdOnly2(index3, target.blockId);
327852
- } catch {
327853
- throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", `Cannot resolve insert target for block "${target.blockId}".`);
327854
- }
327948
+ const candidate = findBlockByTarget2(index3, target, "insert");
327855
327949
  return {
327856
327950
  insertPos: candidate.end,
327857
327951
  structuralEnd: false,
327858
- effectiveTarget: target,
327952
+ effectiveTarget: target.kind === "block" ? { kind: "text", blockId: target.nodeId, range: { start: 0, end: 0 } } : target,
327859
327953
  targetNode: candidate.node,
327860
327954
  targetNodePos: candidate.pos
327861
327955
  };
327862
327956
  }
327863
327957
  function resolveReplaceTarget2(editor, target) {
327864
327958
  const index3 = getBlockIndex2(editor);
327865
- let candidate;
327866
- try {
327867
- candidate = findBlockByNodeIdOnly2(index3, target.blockId);
327868
- } catch {
327869
- throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", `Cannot resolve replace target for block "${target.blockId}".`);
327870
- }
327959
+ const candidate = findBlockByTarget2(index3, target, "replace");
327871
327960
  return {
327872
327961
  from: candidate.pos,
327873
327962
  to: candidate.end,
327874
- effectiveTarget: target
327963
+ effectiveTarget: target.kind === "block" ? { kind: "text", blockId: target.nodeId, range: { start: 0, end: 0 } } : target
327875
327964
  };
327876
327965
  }
327877
327966
  function resolveDocumentEndTarget2(editor) {
@@ -328169,15 +328258,13 @@ function ensureTableSeparators2(jsonNodes) {
328169
328258
  }
328170
328259
  }
328171
328260
  }
328172
- function narrowToTextAddress2(target) {
328261
+ function targetBlockId2(target) {
328262
+ return target.kind === "block" ? target.nodeId : target.blockId;
328263
+ }
328264
+ function toTextAddress3(target) {
328173
328265
  if (target.kind === "text")
328174
328266
  return target;
328175
- const sd = target;
328176
- return {
328177
- kind: "text",
328178
- blockId: sd.nodeId ?? "",
328179
- range: sd.anchor ? { start: sd.anchor.start.offset, end: sd.anchor.end.offset } : { start: 0, end: 0 }
328180
- };
328267
+ return { kind: "text", blockId: target.nodeId, range: { start: 0, end: 0 } };
328181
328268
  }
328182
328269
  function normalizeWriteLocator2(request) {
328183
328270
  const hasBlockId = request.blockId !== undefined;
@@ -328468,6 +328555,9 @@ function buildSelectionResolutionFromOutcome2(stepOutcome, compiled, stepId) {
328468
328555
  return buildSelectionResolutionFromCompiled2(compiled, stepId);
328469
328556
  }
328470
328557
  function insertStructuredWrapper2(editor, input2, options) {
328558
+ if (isStructuralInsertInput(input2) && input2.target) {
328559
+ return executeStructuralInsertDirect2(editor, input2, options);
328560
+ }
328471
328561
  return textReceiptToSDReceipt(insertStructuredInner2(editor, input2, options));
328472
328562
  }
328473
328563
  function insertStructuredInner2(editor, input2, options) {
@@ -328638,14 +328728,13 @@ function insertStructuredInner2(editor, input2, options) {
328638
328728
  function executeStructuralInsertWrapper2(editor, input2, options) {
328639
328729
  const { content: content5, target, placement: placement2, nestingPolicy } = input2;
328640
328730
  const mode = options?.changeMode ?? "direct";
328641
- const textTarget = target ? narrowToTextAddress2(target) : undefined;
328642
328731
  let resolved;
328643
328732
  try {
328644
- resolved = resolveInsertTarget2(editor, textTarget);
328733
+ resolved = resolveInsertTarget2(editor, target);
328645
328734
  } catch (err) {
328646
328735
  if (err instanceof DocumentApiAdapterError3)
328647
328736
  throw err;
328648
- throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", `Cannot resolve insert target${textTarget ? ` for block "${textTarget.blockId}"` : ""}.`);
328737
+ throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", `Cannot resolve insert target${target ? ` for block "${target.nodeId}"` : ""}.`);
328649
328738
  }
328650
328739
  const effectiveTarget = resolved.effectiveTarget ?? {
328651
328740
  kind: "text",
@@ -328660,7 +328749,6 @@ function executeStructuralInsertWrapper2(editor, input2, options) {
328660
328749
  }
328661
328750
  const resolvedRange = { from: insertPos, to: insertPos };
328662
328751
  const resolution = buildTextMutationResolution2({
328663
- requestedTarget: textTarget,
328664
328752
  target: effectiveTarget,
328665
328753
  range: resolvedRange,
328666
328754
  text: ""
@@ -328668,7 +328756,7 @@ function executeStructuralInsertWrapper2(editor, input2, options) {
328668
328756
  try {
328669
328757
  if (options?.dryRun) {
328670
328758
  executeStructuralInsert2(editor, {
328671
- target: textTarget,
328759
+ target,
328672
328760
  content: content5,
328673
328761
  placement: placement2,
328674
328762
  nestingPolicy,
@@ -328679,7 +328767,7 @@ function executeStructuralInsertWrapper2(editor, input2, options) {
328679
328767
  }
328680
328768
  const receipt2 = executeDomainCommand2(editor, () => {
328681
328769
  const result = executeStructuralInsert2(editor, {
328682
- target: textTarget,
328770
+ target,
328683
328771
  content: content5,
328684
328772
  placement: placement2,
328685
328773
  nestingPolicy,
@@ -328707,11 +328795,77 @@ function executeStructuralInsertWrapper2(editor, input2, options) {
328707
328795
  };
328708
328796
  }
328709
328797
  }
328798
+ function executeStructuralInsertDirect2(editor, input2, options) {
328799
+ const { content: content5, target, placement: placement2, nestingPolicy } = input2;
328800
+ const mode = options?.changeMode ?? "direct";
328801
+ let resolved;
328802
+ try {
328803
+ resolved = resolveInsertTarget2(editor, target);
328804
+ } catch (err) {
328805
+ if (err instanceof DocumentApiAdapterError3)
328806
+ throw err;
328807
+ throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", `Cannot resolve insert target for block "${target.nodeId}".`);
328808
+ }
328809
+ let insertPos;
328810
+ if (resolved.targetNode && resolved.targetNodePos !== undefined) {
328811
+ insertPos = resolvePlacement2(editor.state.doc, resolved.targetNodePos, resolved.targetNode, placement2);
328812
+ } else {
328813
+ insertPos = resolved.insertPos;
328814
+ }
328815
+ const range = { from: insertPos, to: insertPos };
328816
+ const receiptParams = { target, range };
328817
+ try {
328818
+ if (options?.dryRun) {
328819
+ executeStructuralInsert2(editor, {
328820
+ target,
328821
+ content: content5,
328822
+ placement: placement2,
328823
+ nestingPolicy,
328824
+ changeMode: mode,
328825
+ dryRun: true
328826
+ });
328827
+ return buildStructuralReceipt(true, receiptParams);
328828
+ }
328829
+ const receipt2 = executeDomainCommand2(editor, () => {
328830
+ const result = executeStructuralInsert2(editor, {
328831
+ target,
328832
+ content: content5,
328833
+ placement: placement2,
328834
+ nestingPolicy,
328835
+ changeMode: mode
328836
+ });
328837
+ return result.success;
328838
+ }, { expectedRevision: options?.expectedRevision, changeMode: mode });
328839
+ if (receipt2.steps[0]?.effect !== "changed") {
328840
+ return buildStructuralReceipt(false, receiptParams, {
328841
+ code: "INVALID_TARGET",
328842
+ message: "Structural insert failed."
328843
+ });
328844
+ }
328845
+ return buildStructuralReceipt(true, receiptParams);
328846
+ } catch (err) {
328847
+ if (err instanceof DocumentApiAdapterError3)
328848
+ throw err;
328849
+ const message = err instanceof Error ? err.message : String(err);
328850
+ return buildStructuralReceipt(false, receiptParams, {
328851
+ code: "INVALID_TARGET",
328852
+ message: `Structural insert failed: ${message}`
328853
+ });
328854
+ }
328855
+ }
328710
328856
  function replaceStructuredWrapper2(editor, input2, options) {
328711
328857
  if (!isStructuralReplaceInput(input2)) {
328712
328858
  throw new DocumentApiAdapterError3("INVALID_INPUT", 'replaceStructured requires structural content input with a "content" field.');
328713
328859
  }
328714
- return textReceiptToSDReceipt(executeStructuralReplaceWrapper2(editor, input2, options));
328860
+ const blockTarget = input2.target && "kind" in input2.target && input2.target.kind === "block" ? input2.target : undefined;
328861
+ const textReceipt = executeStructuralReplaceWrapper2(editor, input2, options);
328862
+ if (!blockTarget)
328863
+ return textReceiptToSDReceipt(textReceipt);
328864
+ const sdReceipt = textReceiptToSDReceipt(textReceipt);
328865
+ if (sdReceipt.resolution) {
328866
+ sdReceipt.resolution.target = blockTarget;
328867
+ }
328868
+ return sdReceipt;
328715
328869
  }
328716
328870
  function resolveStructuralLocator2(editor, input2) {
328717
328871
  const { target, ref: ref4 } = input2;
@@ -328735,7 +328889,7 @@ function resolveStructuralLocator2(editor, input2) {
328735
328889
  effectiveSelectionTarget: buildEffectiveSelectionTarget2(expanded)
328736
328890
  };
328737
328891
  }
328738
- return { textTarget: narrowToTextAddress2(target) };
328892
+ return { textTarget: target };
328739
328893
  }
328740
328894
  if (ref4 !== undefined) {
328741
328895
  if (ref4.startsWith("text:")) {
@@ -328884,19 +329038,19 @@ function executeStructuralReplaceWrapper2(editor, input2, options) {
328884
329038
  } catch (err) {
328885
329039
  if (err instanceof DocumentApiAdapterError3)
328886
329040
  throw err;
328887
- throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", `Cannot resolve replace target for block "${textTarget.blockId}".`);
329041
+ throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", `Cannot resolve replace target for block "${targetBlockId2(textTarget)}".`);
328888
329042
  }
328889
329043
  effectiveRange = { from: resolvedBlock.from, to: resolvedBlock.to };
328890
329044
  }
328891
329045
  const coveredText = editor.state.doc.textBetween(effectiveRange.from, effectiveRange.to, `
328892
329046
  `, "");
329047
+ const textAddr = toTextAddress3(textTarget);
328893
329048
  let resolution;
328894
329049
  if (effectiveSelectionTarget) {
328895
329050
  resolution = selectionTargetToResolution2(effectiveSelectionTarget, effectiveRange, coveredText);
328896
329051
  } else {
328897
329052
  resolution = buildTextMutationResolution2({
328898
- requestedTarget: isRefBased ? undefined : textTarget,
328899
- target: textTarget,
329053
+ target: textAddr,
328900
329054
  range: effectiveRange,
328901
329055
  text: coveredText
328902
329056
  });
@@ -329138,7 +329292,7 @@ function resolveImportedId2(candidate) {
329138
329292
  const attrs = candidate.attrs ?? {};
329139
329293
  return toNonEmptyString2(attrs.importedId);
329140
329294
  }
329141
- function toTextAddress3(candidate) {
329295
+ function toTextAddress4(candidate) {
329142
329296
  const { start: start2, end } = candidate.anchor;
329143
329297
  if (start2.blockId !== end.blockId)
329144
329298
  return null;
@@ -329160,7 +329314,7 @@ function listCommentAnchors2(editor) {
329160
329314
  const commentId = resolveCommentId2(candidate);
329161
329315
  if (!commentId)
329162
329316
  continue;
329163
- const target = toTextAddress3(candidate);
329317
+ const target = toTextAddress4(candidate);
329164
329318
  if (!target)
329165
329319
  continue;
329166
329320
  const dedupeKey = `${commentId}|${target.blockId}:${target.range.start}:${target.range.end}`;
@@ -337135,7 +337289,7 @@ var init_tables_adapter = __esm(() => {
337135
337289
  });
337136
337290
 
337137
337291
  // ../../packages/super-editor/src/document-api-adapters/plan-engine/register-executors.ts
337138
- function targetBlockId2(t) {
337292
+ function targetBlockId3(t) {
337139
337293
  return t?.kind === "range" ? t.blockId : "";
337140
337294
  }
337141
337295
  function selectionTargetToRange2(t) {
@@ -337316,7 +337470,7 @@ function registerBuiltInExecutors2() {
337316
337470
  op: step3.op,
337317
337471
  effect: "noop",
337318
337472
  matchCount: targets.length,
337319
- data: { domain: "table", tableId: targetBlockId2(targets[0]) }
337473
+ data: { domain: "table", tableId: targetBlockId3(targets[0]) }
337320
337474
  };
337321
337475
  }
337322
337476
  const handler3 = step3._handler;
@@ -337342,7 +337496,7 @@ function registerBuiltInExecutors2() {
337342
337496
  data: { domain: "table", tableId: "" }
337343
337497
  };
337344
337498
  }
337345
- const input2 = buildTableInput2(step3.op, targetBlockId2(targets[0]), step3.args);
337499
+ const input2 = buildTableInput2(step3.op, targetBlockId3(targets[0]), step3.args);
337346
337500
  const result = adapterFn(ctx2.editor, input2, { changeMode: ctx2.changeMode });
337347
337501
  if (result.success)
337348
337502
  ctx2.commandDispatched = true;
@@ -337351,7 +337505,7 @@ function registerBuiltInExecutors2() {
337351
337505
  op: step3.op,
337352
337506
  effect: result.success ? "changed" : "noop",
337353
337507
  matchCount: result.success ? 1 : 0,
337354
- data: { domain: "table", tableId: targetBlockId2(targets[0]) }
337508
+ data: { domain: "table", tableId: targetBlockId3(targets[0]) }
337355
337509
  };
337356
337510
  }
337357
337511
  });
@@ -337460,7 +337614,7 @@ function registerBuiltInExecutors2() {
337460
337614
  op: step3.op,
337461
337615
  effect: "noop",
337462
337616
  matchCount: _targets.length,
337463
- data: { domain: "table", tableId: targetBlockId2(_targets[0]) }
337617
+ data: { domain: "table", tableId: targetBlockId3(_targets[0]) }
337464
337618
  };
337465
337619
  }
337466
337620
  const handler3 = step3._handler;
@@ -401053,15 +401207,14 @@ function validateQuerySelect(value2, path3) {
401053
401207
  };
401054
401208
  }
401055
401209
  if (type2 === "node") {
401056
- expectOnlyKeys(obj, ["type", "nodeKind", "kind", "nodeType"], path3);
401057
- const rawNodeKind = obj.nodeKind ?? obj.nodeType;
401058
- const nodeKind = rawNodeKind != null ? String(rawNodeKind) : undefined;
401059
- if (obj.kind != null && obj.kind !== "content" && obj.kind !== "inline" && !NODE_KINDS2.has(obj.kind)) {
401060
- throw new CliError("VALIDATION_ERROR", `${path3}.kind must be "content", "inline", "block", or "inline".`);
401210
+ expectOnlyKeys(obj, ["type", "nodeType", "kind"], path3);
401211
+ const nodeType2 = obj.nodeType != null ? String(obj.nodeType) : undefined;
401212
+ if (obj.kind != null && !NODE_KINDS2.has(obj.kind)) {
401213
+ throw new CliError("VALIDATION_ERROR", `${path3}.kind must be "block" or "inline".`);
401061
401214
  }
401062
401215
  return {
401063
401216
  type: "node",
401064
- nodeKind,
401217
+ nodeType: nodeType2,
401065
401218
  kind: obj.kind
401066
401219
  };
401067
401220
  }
@@ -401071,7 +401224,7 @@ function validateQuerySelect(value2, path3) {
401071
401224
  expectOnlyKeys(obj, ["type"], path3);
401072
401225
  return {
401073
401226
  type: "node",
401074
- nodeKind: type2
401227
+ nodeType: type2
401075
401228
  };
401076
401229
  }
401077
401230
  function validateQuery(value2, path3 = "query") {
@@ -401081,12 +401234,11 @@ function validateQuery(value2, path3 = "query") {
401081
401234
  select: validateQuerySelect(obj.select, `${path3}.select`)
401082
401235
  };
401083
401236
  if (obj.within != null) {
401084
- const within2 = expectRecord(obj.within, `${path3}.within`);
401085
- if (within2.kind === "content" && typeof within2.nodeId === "string") {
401086
- query3.within = within2;
401087
- } else {
401088
- query3.within = validateNodeAddress(obj.within, `${path3}.within`);
401237
+ const within2 = validateNodeAddress(obj.within, `${path3}.within`);
401238
+ if (within2.kind !== "block") {
401239
+ throw new CliError("VALIDATION_ERROR", `${path3}.within must be a BlockNodeAddress (kind: "block").`);
401089
401240
  }
401241
+ query3.within = within2;
401090
401242
  }
401091
401243
  if (obj.limit != null) {
401092
401244
  query3.limit = expectNonNegativeInteger(obj.limit, `${path3}.limit`);
@@ -401134,7 +401286,7 @@ function buildFlatFindQueryDraft(parsed) {
401134
401286
  return {
401135
401287
  select: {
401136
401288
  type: "node",
401137
- nodeKind: getStringOption(parsed, "node-type"),
401289
+ nodeType: getStringOption(parsed, "node-type"),
401138
401290
  kind: getStringOption(parsed, "kind")
401139
401291
  },
401140
401292
  limit: getNumberOption(parsed, "limit"),
@@ -401144,7 +401296,7 @@ function buildFlatFindQueryDraft(parsed) {
401144
401296
  const kind2 = getStringOption(parsed, "kind");
401145
401297
  const select2 = kind2 ? {
401146
401298
  type: "node",
401147
- nodeKind: selectorType,
401299
+ nodeType: selectorType,
401148
401300
  kind: kind2
401149
401301
  } : {
401150
401302
  type: selectorType